Add suport for latest ink! metadata (#5650)
* add v5 * add environment * tov5 * use correct version * decode env types * fix tests * remove unnecesary checks * update fixtures * add maxEventTopics * get type defs for environment * fix conversion to v4
This commit is contained in:
@@ -80,6 +80,15 @@ const spec = {
|
||||
args: 'Vec<ContractMessageParamSpecV2>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
ContractConstructorSpecV4: {
|
||||
label: 'Text',
|
||||
selector: 'ContractSelector',
|
||||
payable: 'bool',
|
||||
args: 'Vec<ContractMessageParamSpecV2>',
|
||||
docs: 'Vec<Text>',
|
||||
default: 'bool',
|
||||
returnType: 'Option<ContractTypeSpec>'
|
||||
},
|
||||
ContractContractSpecV0: {
|
||||
constructors: 'Vec<ContractConstructorSpecV0>',
|
||||
messages: 'Vec<ContractMessageSpecV0>',
|
||||
@@ -104,7 +113,14 @@ const spec = {
|
||||
events: 'Vec<ContractEventSpecV2>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
ContractContractSpecV4: 'ContractContractSpecV3',
|
||||
ContractContractSpecV4: {
|
||||
constructors: 'Vec<ContractConstructorSpecV4>',
|
||||
messages: 'Vec<ContractMessageSpecV3>',
|
||||
events: 'Vec<ContractEventSpecV2>',
|
||||
docs: 'Vec<Text>',
|
||||
environment: 'Option<ContractEnvironment>'
|
||||
},
|
||||
|
||||
ContractDisplayName: 'SiPath',
|
||||
ContractEventParamSpecV0: {
|
||||
name: 'Text',
|
||||
@@ -168,6 +184,16 @@ const spec = {
|
||||
returnType: 'Option<ContractTypeSpec>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
ContractMessageSpecV3: {
|
||||
label: 'Text',
|
||||
selector: 'ContractSelector',
|
||||
mutates: 'bool',
|
||||
payable: 'bool',
|
||||
args: 'Vec<ContractMessageParamSpecV2>',
|
||||
returnType: 'Option<ContractTypeSpec>',
|
||||
docs: 'Vec<Text>',
|
||||
default: 'bool'
|
||||
},
|
||||
ContractSelector: '[u8; 4]',
|
||||
ContractTypeSpec: {
|
||||
type: 'SiLookupTypeId',
|
||||
@@ -176,11 +202,11 @@ const spec = {
|
||||
};
|
||||
|
||||
const latest = {
|
||||
ContractConstructorSpecLatest: 'ContractConstructorSpecV3',
|
||||
ContractConstructorSpecLatest: 'ContractConstructorSpecV4',
|
||||
ContractEventSpecLatest: 'ContractEventSpecV2',
|
||||
ContractEventParamSpecLatest: 'ContractEventParamSpecV2',
|
||||
ContractMessageParamSpecLatest: 'ContractMessageParamSpecV2',
|
||||
ContractMessageSpecLatest: 'ContractMessageSpecV2',
|
||||
ContractMessageSpecLatest: 'ContractMessageSpecV3',
|
||||
ContractMetadataLatest: 'ContractMetadataV4'
|
||||
};
|
||||
|
||||
@@ -211,7 +237,10 @@ export default {
|
||||
types: 'Vec<PortableType>',
|
||||
spec: 'ContractContractSpecV3'
|
||||
},
|
||||
ContractMetadataV4: 'ContractMetadataV3',
|
||||
ContractMetadataV4: {
|
||||
types: 'Vec<PortableType>',
|
||||
spec: 'ContractContractSpecV4'
|
||||
},
|
||||
ContractMetadata: {
|
||||
_enum: {
|
||||
V0: 'ContractMetadataV0',
|
||||
@@ -250,6 +279,17 @@ export default {
|
||||
language: 'Text',
|
||||
compiler: 'Text',
|
||||
wasm: 'Raw'
|
||||
},
|
||||
ContractEnvironment: {
|
||||
_alias: {
|
||||
hashType: 'hash'
|
||||
},
|
||||
accountId: 'ContractTypeSpec',
|
||||
balance: 'ContractTypeSpec',
|
||||
blockNumber: 'ContractTypeSpec',
|
||||
hashType: 'ContractTypeSpec',
|
||||
timestamp: 'ContractTypeSpec',
|
||||
maxEventTopics: 'u32'
|
||||
}
|
||||
}
|
||||
} as Definitions;
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { PortableType } from '@polkadot/types/interfaces/metadata';
|
||||
import type { Si0Type, SiLookupTypeId, SiPath } from '@polkadot/types/interfaces/scaleInfo';
|
||||
|
||||
/** @name ContractConstructorSpecLatest */
|
||||
export interface ContractConstructorSpecLatest extends ContractConstructorSpecV3 {}
|
||||
export interface ContractConstructorSpecLatest extends ContractConstructorSpecV4 {}
|
||||
|
||||
/** @name ContractConstructorSpecV0 */
|
||||
export interface ContractConstructorSpecV0 extends Struct {
|
||||
@@ -42,6 +42,17 @@ export interface ContractConstructorSpecV3 extends Struct {
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name ContractConstructorSpecV4 */
|
||||
export interface ContractConstructorSpecV4 extends Struct {
|
||||
readonly label: Text;
|
||||
readonly selector: ContractSelector;
|
||||
readonly payable: bool;
|
||||
readonly args: Vec<ContractMessageParamSpecV2>;
|
||||
readonly docs: Vec<Text>;
|
||||
readonly default: bool;
|
||||
readonly returnType: Option<ContractTypeSpec>;
|
||||
}
|
||||
|
||||
/** @name ContractContractSpecV0 */
|
||||
export interface ContractContractSpecV0 extends Struct {
|
||||
readonly constructors: Vec<ContractConstructorSpecV0>;
|
||||
@@ -75,7 +86,13 @@ export interface ContractContractSpecV3 extends Struct {
|
||||
}
|
||||
|
||||
/** @name ContractContractSpecV4 */
|
||||
export interface ContractContractSpecV4 extends ContractContractSpecV3 {}
|
||||
export interface ContractContractSpecV4 extends Struct {
|
||||
readonly constructors: Vec<ContractConstructorSpecV4>;
|
||||
readonly messages: Vec<ContractMessageSpecV3>;
|
||||
readonly events: Vec<ContractEventSpecV2>;
|
||||
readonly docs: Vec<Text>;
|
||||
readonly environment: Option<ContractEnvironment>;
|
||||
}
|
||||
|
||||
/** @name ContractCryptoHasher */
|
||||
export interface ContractCryptoHasher extends Enum {
|
||||
@@ -91,6 +108,16 @@ export interface ContractDiscriminant extends u32 {}
|
||||
/** @name ContractDisplayName */
|
||||
export interface ContractDisplayName extends SiPath {}
|
||||
|
||||
/** @name ContractEnvironment */
|
||||
export interface ContractEnvironment extends Struct {
|
||||
readonly accountId: ContractTypeSpec;
|
||||
readonly balance: ContractTypeSpec;
|
||||
readonly blockNumber: ContractTypeSpec;
|
||||
readonly hashType: ContractTypeSpec;
|
||||
readonly timestamp: ContractTypeSpec;
|
||||
readonly maxEventTopics: u32;
|
||||
}
|
||||
|
||||
/** @name ContractEventParamSpecLatest */
|
||||
export interface ContractEventParamSpecLatest extends ContractEventParamSpecV2 {}
|
||||
|
||||
@@ -198,7 +225,7 @@ export interface ContractMessageParamSpecV2 extends Struct {
|
||||
}
|
||||
|
||||
/** @name ContractMessageSpecLatest */
|
||||
export interface ContractMessageSpecLatest extends ContractMessageSpecV2 {}
|
||||
export interface ContractMessageSpecLatest extends ContractMessageSpecV3 {}
|
||||
|
||||
/** @name ContractMessageSpecV0 */
|
||||
export interface ContractMessageSpecV0 extends Struct {
|
||||
@@ -233,6 +260,18 @@ export interface ContractMessageSpecV2 extends Struct {
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name ContractMessageSpecV3 */
|
||||
export interface ContractMessageSpecV3 extends Struct {
|
||||
readonly label: Text;
|
||||
readonly selector: ContractSelector;
|
||||
readonly mutates: bool;
|
||||
readonly payable: bool;
|
||||
readonly args: Vec<ContractMessageParamSpecV2>;
|
||||
readonly returnType: Option<ContractTypeSpec>;
|
||||
readonly docs: Vec<Text>;
|
||||
readonly default: bool;
|
||||
}
|
||||
|
||||
/** @name ContractMetadata */
|
||||
export interface ContractMetadata extends Enum {
|
||||
readonly isV0: boolean;
|
||||
@@ -277,7 +316,10 @@ export interface ContractMetadataV3 extends Struct {
|
||||
}
|
||||
|
||||
/** @name ContractMetadataV4 */
|
||||
export interface ContractMetadataV4 extends ContractMetadataV3 {}
|
||||
export interface ContractMetadataV4 extends Struct {
|
||||
readonly types: Vec<PortableType>;
|
||||
readonly spec: ContractContractSpecV4;
|
||||
}
|
||||
|
||||
/** @name ContractProject */
|
||||
export interface ContractProject extends ITuple<[ContractProjectInfo, ContractMetadata]> {}
|
||||
|
||||
Reference in New Issue
Block a user