Skip to content

Commit 406bde9

Browse files
authored
fix: update to use accountInfoOf for latest pallet_revive changes (#588)
1 parent 2d4340b commit 406bde9

File tree

11 files changed

+84
-79
lines changed

11 files changed

+84
-79
lines changed

cypress/e2e/contracts/erc20.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('ERC20 Contract ', () => {
2323
});
2424

2525
it('contract file uploads', () => {
26+
// TODO: In the contract, replaced Address with H160. Fix https://github.com/use-ink/contracts-ui/issues/582
2627
assertUpload('erc20.contract');
2728
});
2829

cypress/e2e/updateMetadata.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Update contract metadata', () => {
1212
'revertOrTrap',
1313
'mutHelloWorld',
1414
];
15-
const messages2 = ['new', 'newDefault', 'flip', 'get'];
15+
const messages2 = ['new', 'flip', 'get'];
1616

1717
before(() => {
1818
beforeAllContracts();
@@ -37,7 +37,7 @@ describe('Update contract metadata', () => {
3737
});
3838
it('displays the docs for the new metadata', () => {
3939
cy.get('[data-cy="message-docs"]').each((item, i, list) => {
40-
expect(list).to.have.length(4);
40+
expect(list).to.have.length(3);
4141
expect(Cypress.$(item).text()).to.contain(messages2[i]);
4242
});
4343
});

cypress/fixtures/erc20.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cypress/fixtures/flipper.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cypress/fixtures/mother.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cypress/fixtures/multisig.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cypress/fixtures/storage_types.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"@vitejs/plugin-react-swc": "^3.7.0",
7777
"autoprefixer": "^10.4.20",
7878
"cross-env": "^7.0.3",
79-
"cypress": "13.13.3",
79+
"cypress": "15.2.0",
8080
"cypress-file-upload": "^5.0.8",
8181
"eslint": "^9.9.1",
8282
"eslint-config-prettier": "^9.1.0",

snapshots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
__version: '13.13.3',
2+
__version: '15.2.0',
33
'Storage Types Contract': {
44
'DryRun getUnsignedIntegers': {
55
1: "<code>{\n u128ValueMax: '340,282,366,920,938,463,463,374,607,431,768,211,455',\n u128ValueMin: '0',\n u16ValueMax: '65,535',\n u16ValueMin: '0',\n u32ValueMax: '4,294,967,295',\n u32ValueMin: '0',\n u64ValueMax: '18,446,744,073,709,551,615',\n u64ValueMin: '0',\n u8ValueMax: '255',\n u8ValueMin: '0',\n }</code>",

src/services/chain/contract.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
SubmittableExtrinsic,
1313
} from 'types';
1414
import { InkVersion } from 'ui/contexts';
15+
import { PalletReviveStorageContractInfo } from '@polkadot/types/lookup';
1516

1617
export function createInstantiateTx(
1718
api: ApiPromise,
@@ -56,7 +57,15 @@ export function createInstantiateTx(
5657
export async function getContractInfo(api: ApiPromise, address: string, version: InkVersion) {
5758
if (isValidAddress(address, version)) {
5859
if (version === 'v6') {
59-
return (await api.query.revive.contractInfoOf(address)).unwrapOr(null);
60+
// TODO: Temporary workaround:
61+
// accountInfoOf is a breaking change until it’s released and included in contracts-api.
62+
const accountInfoOption: any = await api.query.revive.accountInfoOf(address);
63+
if (accountInfoOption.isNone) return null;
64+
65+
const { accountType } = accountInfoOption.unwrap();
66+
return accountType.isContract
67+
? (accountType.asContract as PalletReviveStorageContractInfo)
68+
: null;
6069
} else {
6170
return (await api.query.contracts.contractInfoOf(address)).unwrapOr(null);
6271
}

0 commit comments

Comments
 (0)