Skip to content

Commit 5b8c229

Browse files
authored
fix(contracts): check contracts presence (#603)
There is a breaking change introduced from `pallet-revive` which replaced the storage `ContractInfoOf` by the `AccountInfoOf`. This work is to comply with this new change. Related PR: paritytech/polkadot-sdk#9101 Code Change: https://github.com/paritytech/polkadot-sdk/pull/9101/files#diff-f55a8416f5e8564cb4463b5f11dfd00d7c865aabab747a05887feeedd4e1c81dL498-L502
1 parent 077ba73 commit 5b8c229

7 files changed

Lines changed: 716 additions & 1943 deletions

File tree

.github/workflows/e2e-contracts-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
mv ./substrate-contracts-node-linux/substrate-contracts-node ./substrate-contracts-node
3232
chmod +x substrate-contracts-node
3333
34-
curl -L -O https://github.com/use-ink/ink-node/releases/download/v0.44.0/ink-node-linux.tar.gz
34+
curl -L -O https://github.com/use-ink/ink-node/releases/download/v0.45.1/ink-node-linux.tar.gz
3535
tar -xzf ink-node-linux.tar.gz
3636
mv ./ink-node-linux/ink-node ./ink-node
3737
chmod +x ink-node

e2e/contracts/src/contracts/flipper_v6.json

Lines changed: 274 additions & 685 deletions
Large diffs are not rendered by default.

examples/scripts/inkv6/flipperv6.json

Lines changed: 10 additions & 12 deletions
Large diffs are not rendered by default.

examples/scripts/inkv6/psp22v6.json

Lines changed: 424 additions & 1241 deletions
Large diffs are not rendered by default.

packages/contracts/src/Contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Contract<ContractApi extends GenericContractApi = GenericContractAp
2727
readonly #options?: ExecutionOptions;
2828

2929
constructor(
30-
readonly client: ISubstrateClient<ContractApi['types']['ChainApi']>,
30+
readonly client: ISubstrateClient<any, any>,
3131
metadata: LooseContractMetadata | string,
3232
address: ContractAddress,
3333
options?: ExecutionOptions,

packages/contracts/src/ContractDeployer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ContractDeployer<ContractApi extends GenericContractApi = GenericCo
1818
readonly #options?: ExecutionOptions;
1919

2020
constructor(
21-
readonly client: ISubstrateClient<ContractApi['types']['ChainApi']>,
21+
readonly client: ISubstrateClient<any, any>,
2222
metadata: LooseContractMetadata | string,
2323
codeHashOrCode: Hash | Uint8Array | string,
2424
options?: ExecutionOptions,

packages/contracts/src/utils/ensure.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ export async function ensureContractPresence(
4747
registry: TypinkRegistry,
4848
address: ContractAddress,
4949
) {
50-
const contractInfo = await (() => {
50+
const contractInfo = await (async () => {
5151
if (registry.isRevive()) {
52-
return client.query.revive.contractInfoOf(address as HexString);
52+
const accountInfo = await client.query.revive.accountInfoOf(address as HexString);
53+
if (accountInfo?.accountType && accountInfo?.accountType?.type === 'Contract') {
54+
return accountInfo.accountType.value;
55+
}
5356
} else {
5457
return client.query.contracts.contractInfoOf(address);
5558
}

0 commit comments

Comments
 (0)