-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from scio-labs/feat/52-typechain-integration
Feat/52 typechain integration
- Loading branch information
Showing
30 changed files
with
1,285 additions
and
867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@inkathon/contracts": minor | ||
"@inkathon/frontend": minor | ||
--- | ||
|
||
Add type-safe contract integrations via `useRegisteredTypedContract` and `typechain-polkadot`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ deployments | |
target | ||
src | ||
dist | ||
.node-data | ||
.node-data | ||
typed-contracts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ deployments | |
target | ||
src | ||
dist | ||
.node-data | ||
.node-data | ||
typed-contracts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* This file is auto-generated */ | ||
|
||
import type { ContractPromise } from '@polkadot/api-contract'; | ||
import type { GasLimit, GasLimitAndRequiredValue } from '@727-ventures/typechain-types'; | ||
import { buildSubmittableExtrinsic } from '@727-ventures/typechain-types'; | ||
import type * as ArgumentTypes from '../types-arguments/greeter'; | ||
import type BN from 'bn.js'; | ||
import type { ApiPromise } from '@polkadot/api'; | ||
|
||
|
||
|
||
export default class Methods { | ||
readonly __nativeContract : ContractPromise; | ||
readonly __apiPromise: ApiPromise; | ||
|
||
constructor( | ||
nativeContract : ContractPromise, | ||
apiPromise: ApiPromise, | ||
) { | ||
this.__nativeContract = nativeContract; | ||
this.__apiPromise = apiPromise; | ||
} | ||
/** | ||
* greet | ||
* | ||
*/ | ||
"greet" ( | ||
__options: GasLimit, | ||
){ | ||
return buildSubmittableExtrinsic( this.__apiPromise, this.__nativeContract, "greet", [], __options); | ||
} | ||
|
||
/** | ||
* setMessage | ||
* | ||
* @param { string } newValue, | ||
*/ | ||
"setMessage" ( | ||
newValue: string, | ||
__options: GasLimit, | ||
){ | ||
return buildSubmittableExtrinsic( this.__apiPromise, this.__nativeContract, "setMessage", [newValue], __options); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import type { ConstructorOptions } from '@727-ventures/typechain-types' | ||
import { | ||
_genValidGasLimitAndValue, | ||
_signAndSend, | ||
SignAndSendSuccessResponse, | ||
} from '@727-ventures/typechain-types' | ||
import type { ApiPromise } from '@polkadot/api' | ||
import { CodePromise } from '@polkadot/api-contract' | ||
import type { KeyringPair } from '@polkadot/keyring/types' | ||
import type { WeightV2 } from '@polkadot/types/interfaces' | ||
import { ContractFile } from '../contract-info/greeter' | ||
|
||
export default class Constructors { | ||
readonly nativeAPI: ApiPromise | ||
readonly signer: KeyringPair | ||
|
||
constructor(nativeAPI: ApiPromise, signer: KeyringPair) { | ||
this.nativeAPI = nativeAPI | ||
this.signer = signer | ||
} | ||
|
||
/** | ||
* new | ||
* | ||
* @param { string } initValue, | ||
*/ | ||
async new(initValue: string, __options?: ConstructorOptions) { | ||
const __contract = JSON.parse(ContractFile) | ||
const code = new CodePromise(this.nativeAPI, __contract, __contract.source.wasm) | ||
const gasLimit = (await _genValidGasLimitAndValue(this.nativeAPI, __options)) | ||
.gasLimit as WeightV2 | ||
|
||
const storageDepositLimit = __options?.storageDepositLimit | ||
const tx = code.tx['new']!( | ||
{ gasLimit, storageDepositLimit, value: __options?.value }, | ||
initValue, | ||
) | ||
let response | ||
|
||
try { | ||
console.log('sd') | ||
response = await _signAndSend(this.nativeAPI.registry, tx, this.signer, (event: any) => event) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
|
||
return { | ||
result: response as SignAndSendSuccessResponse, | ||
// @ts-ignore | ||
address: (response as SignAndSendSuccessResponse)!.result!.contract.address.toString(), | ||
} | ||
} | ||
/** | ||
* default | ||
* | ||
*/ | ||
async default(__options?: ConstructorOptions) { | ||
const __contract = JSON.parse(ContractFile) | ||
const code = new CodePromise(this.nativeAPI, __contract, __contract.source.wasm) | ||
const gasLimit = (await _genValidGasLimitAndValue(this.nativeAPI, __options)) | ||
.gasLimit as WeightV2 | ||
|
||
const storageDepositLimit = __options?.storageDepositLimit | ||
const tx = code.tx['default']!({ gasLimit, storageDepositLimit, value: __options?.value }) | ||
let response | ||
|
||
try { | ||
console.log('this.signer', this.signer) | ||
response = await _signAndSend(this.nativeAPI.registry, tx, this.signer, (event: any) => event) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
|
||
return { | ||
result: response as SignAndSendSuccessResponse, | ||
// @ts-ignore | ||
address: (response as SignAndSendSuccessResponse)!.result!.contract.address.toString(), | ||
} | ||
} | ||
} |
Oops, something went wrong.
756d685
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
inkathon-xyz – ./
inkathon.xyz
inkathon-xyz-scio-labs.vercel.app
inkathon.vercel.app
inkathon-xyz-git-main-scio-labs.vercel.app
www.inkathon.xyz