feat(api-contract): add support for ink! v6 and pallet-revive compatibility (#6158)

* wip: support revive for ink! v6

* revive components

* fix: support v6 metadata

* fix: remove debug messages

* test: extend tests for v6ToLatestCompatible

* refactor: remove Revive specific components

* test: construct revive compatible contract

* feat: use ContractReviveProjectInfo new type

* fix: parse version to decide what kind of contract

* refactor: remove hardcoded address

* fix: format

---------

Co-authored-by: Peter White <petras9789@gmail.com>
This commit is contained in:
Alex Bean
2025-06-09 14:46:57 -03:00
committed by GitHub
co-authored by Peter White
parent 252de3b812
commit 3ffc196cc3
20 changed files with 2157 additions and 34 deletions
@@ -127,6 +127,13 @@ const spec = {
docs: 'Vec<Text>',
environment: 'ContractEnvironmentV4'
},
ContractContractSpecV6: {
constructors: 'Vec<ContractConstructorSpecV4>',
messages: 'Vec<ContractMessageSpecV3>',
events: 'Vec<ContractEventSpecV3>',
docs: 'Vec<Text>',
environment: 'ContractEnvironmentV4'
},
ContractDisplayName: 'SiPath',
ContractEventParamSpecV0: {
@@ -221,7 +228,7 @@ const latest = {
ContractEventParamSpecLatest: 'ContractEventParamSpecV2',
ContractMessageParamSpecLatest: 'ContractMessageParamSpecV2',
ContractMessageSpecLatest: 'ContractMessageSpecV3',
ContractMetadataLatest: 'ContractMetadataV5'
ContractMetadataLatest: 'ContractMetadataV6'
};
export default {
@@ -234,6 +241,10 @@ export default {
source: 'ContractProjectSource',
contract: 'ContractProjectContract'
},
ContractReviveProjectInfo: {
source: 'ContractReviveProjectSource',
contract: 'ContractProjectContract'
},
ContractMetadataV0: {
metadataVersion: 'Text',
types: 'Vec<Si0Type>',
@@ -261,6 +272,11 @@ export default {
spec: 'ContractContractSpecV5',
version: 'u64'
},
ContractMetadataV6: {
types: 'Vec<PortableType>',
spec: 'ContractContractSpecV6',
version: 'u64'
},
ContractMetadata: {
_enum: {
V0: 'ContractMetadataV0',
@@ -268,7 +284,8 @@ export default {
V2: 'ContractMetadataV2',
V3: 'ContractMetadataV3',
V4: 'ContractMetadataV4',
V5: 'ContractMetadataV5'
V5: 'ContractMetadataV5',
V6: 'ContractMetadataV6'
}
},
ContractProjectV0: {
@@ -301,6 +318,16 @@ export default {
compiler: 'Text',
wasm: 'Raw'
},
ContractReviveProjectSource: {
_alias: {
wasmHash: 'hash',
wasm: 'contract_binary'
},
wasmHash: '[u8; 32]',
language: 'Text',
compiler: 'Text',
wasm: 'Raw'
},
ContractEnvironmentV4: {
_alias: {
hashType: 'hash'
@@ -103,6 +103,15 @@ export interface ContractContractSpecV5 extends Struct {
readonly environment: ContractEnvironmentV4;
}
/** @name ContractContractSpecV6 */
export interface ContractContractSpecV6 extends Struct {
readonly constructors: Vec<ContractConstructorSpecV4>;
readonly messages: Vec<ContractMessageSpecV3>;
readonly events: Vec<ContractEventSpecV3>;
readonly docs: Vec<Text>;
readonly environment: ContractEnvironmentV4;
}
/** @name ContractCryptoHasher */
export interface ContractCryptoHasher extends Enum {
readonly isBlake2x256: boolean;
@@ -304,11 +313,13 @@ export interface ContractMetadata extends Enum {
readonly asV4: ContractMetadataV4;
readonly isV5: boolean;
readonly asV5: ContractMetadataV5;
readonly type: 'V0' | 'V1' | 'V2' | 'V3' | 'V4' | 'V5';
readonly isV6: boolean;
readonly asV6: ContractMetadataV6;
readonly type: 'V0' | 'V1' | 'V2' | 'V3' | 'V4' | 'V5' | 'V6';
}
/** @name ContractMetadataLatest */
export interface ContractMetadataLatest extends ContractMetadataV5 {}
export interface ContractMetadataLatest extends ContractMetadataV6 {}
/** @name ContractMetadataV0 */
export interface ContractMetadataV0 extends Struct {
@@ -349,6 +360,13 @@ export interface ContractMetadataV5 extends Struct {
readonly version: u64;
}
/** @name ContractMetadataV6 */
export interface ContractMetadataV6 extends Struct {
readonly types: Vec<PortableType>;
readonly spec: ContractContractSpecV6;
readonly version: u64;
}
/** @name ContractProject */
export interface ContractProject extends ITuple<[ContractProjectInfo, ContractMetadata]> {}
@@ -387,6 +405,20 @@ export interface ContractProjectV0 extends Struct {
readonly spec: ContractContractSpecV0;
}
/** @name ContractReviveProjectInfo */
export interface ContractReviveProjectInfo extends Struct {
readonly source: ContractReviveProjectSource;
readonly contract: ContractProjectContract;
}
/** @name ContractReviveProjectSource */
export interface ContractReviveProjectSource extends Struct {
readonly wasmHash: U8aFixed;
readonly language: Text;
readonly compiler: Text;
readonly wasm: Raw;
}
/** @name ContractSelector */
export interface ContractSelector extends U8aFixed {}