Support for ink! metadata v3 (#4432)
* Support for ink! metadata v3 * Flatten check for V1-V3 * DRY-er is/as conversions * Test for v2 conversion * Remove stray console.log * Generic converter * Cleanups
This commit is contained in:
@@ -69,6 +69,13 @@ const spec = {
|
||||
args: 'Vec<ContractMessageParamSpecV2>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
ContractConstructorSpecV3: {
|
||||
label: 'Text',
|
||||
selector: 'ContractSelector',
|
||||
payable: 'bool',
|
||||
args: 'Vec<ContractMessageParamSpecV2>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
ContractContractSpecV0: {
|
||||
constructors: 'Vec<ContractConstructorSpecV0>',
|
||||
messages: 'Vec<ContractMessageSpecV0>',
|
||||
@@ -81,6 +88,12 @@ const spec = {
|
||||
events: 'Vec<ContractEventSpecV2>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
ContractContractSpecV3: {
|
||||
constructors: 'Vec<ContractConstructorSpecV3>',
|
||||
messages: 'Vec<ContractMessageSpecV2>',
|
||||
events: 'Vec<ContractEventSpecV2>',
|
||||
docs: 'Vec<Text>'
|
||||
},
|
||||
ContractDisplayName: 'SiPath',
|
||||
ContractEventParamSpecV0: {
|
||||
name: 'Text',
|
||||
@@ -152,18 +165,23 @@ const ContractMetadataV2 = {
|
||||
spec: 'ContractContractSpecV2'
|
||||
};
|
||||
|
||||
const ContractMetadataV3 = {
|
||||
types: 'Vec<PortableType>',
|
||||
spec: 'ContractContractSpecV3'
|
||||
};
|
||||
|
||||
const ContractProjectInfo = {
|
||||
source: 'ContractProjectSource',
|
||||
contract: 'ContractProjectContract'
|
||||
};
|
||||
|
||||
const latest = {
|
||||
ContractConstructorSpecLatest: 'ContractConstructorSpecV2',
|
||||
ContractConstructorSpecLatest: 'ContractConstructorSpecV3',
|
||||
ContractEventSpecLatest: 'ContractEventSpecV2',
|
||||
ContractEventParamSpecLatest: 'ContractEventParamSpecV2',
|
||||
ContractMessageParamSpecLatest: 'ContractMessageParamSpecV2',
|
||||
ContractMessageSpecLatest: 'ContractMessageSpecV2',
|
||||
ContractMetadataLatest: 'ContractMetadataV2'
|
||||
ContractMetadataLatest: 'ContractMetadataV3'
|
||||
};
|
||||
|
||||
export default {
|
||||
@@ -173,11 +191,13 @@ export default {
|
||||
ContractMetadataV0,
|
||||
ContractMetadataV1,
|
||||
ContractMetadataV2,
|
||||
ContractMetadataV3,
|
||||
ContractMetadata: {
|
||||
_enum: {
|
||||
V0: 'ContractMetadataV0',
|
||||
V1: 'ContractMetadataV1',
|
||||
V2: 'ContractMetadataV2'
|
||||
V2: 'ContractMetadataV2',
|
||||
V3: 'ContractMetadataV3'
|
||||
}
|
||||
},
|
||||
ContractProjectV0: objectSpread({ metadataVersion: 'Text' }, ContractProjectInfo, ContractMetadataV0),
|
||||
|
||||
@@ -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 ContractConstructorSpecV2 {}
|
||||
export interface ContractConstructorSpecLatest extends ContractConstructorSpecV3 {}
|
||||
|
||||
/** @name ContractConstructorSpecV0 */
|
||||
export interface ContractConstructorSpecV0 extends Struct {
|
||||
@@ -25,6 +25,15 @@ export interface ContractConstructorSpecV2 extends Struct {
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name ContractConstructorSpecV3 */
|
||||
export interface ContractConstructorSpecV3 extends Struct {
|
||||
readonly label: Text;
|
||||
readonly selector: ContractSelector;
|
||||
readonly payable: bool;
|
||||
readonly args: Vec<ContractMessageParamSpecV2>;
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name ContractContractSpecV0 */
|
||||
export interface ContractContractSpecV0 extends Struct {
|
||||
readonly constructors: Vec<ContractConstructorSpecV0>;
|
||||
@@ -41,6 +50,14 @@ export interface ContractContractSpecV2 extends Struct {
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name ContractContractSpecV3 */
|
||||
export interface ContractContractSpecV3 extends Struct {
|
||||
readonly constructors: Vec<ContractConstructorSpecV3>;
|
||||
readonly messages: Vec<ContractMessageSpecV2>;
|
||||
readonly events: Vec<ContractEventSpecV2>;
|
||||
readonly docs: Vec<Text>;
|
||||
}
|
||||
|
||||
/** @name ContractCryptoHasher */
|
||||
export interface ContractCryptoHasher extends Enum {
|
||||
readonly isBlake2x256: boolean;
|
||||
@@ -187,11 +204,13 @@ export interface ContractMetadata extends Enum {
|
||||
readonly asV1: ContractMetadataV1;
|
||||
readonly isV2: boolean;
|
||||
readonly asV2: ContractMetadataV2;
|
||||
readonly type: 'V0' | 'V1' | 'V2';
|
||||
readonly isV3: boolean;
|
||||
readonly asV3: ContractMetadataV3;
|
||||
readonly type: 'V0' | 'V1' | 'V2' | 'V3';
|
||||
}
|
||||
|
||||
/** @name ContractMetadataLatest */
|
||||
export interface ContractMetadataLatest extends ContractMetadataV2 {}
|
||||
export interface ContractMetadataLatest extends ContractMetadataV3 {}
|
||||
|
||||
/** @name ContractMetadataV0 */
|
||||
export interface ContractMetadataV0 extends Struct {
|
||||
@@ -211,6 +230,12 @@ export interface ContractMetadataV2 extends Struct {
|
||||
readonly spec: ContractContractSpecV2;
|
||||
}
|
||||
|
||||
/** @name ContractMetadataV3 */
|
||||
export interface ContractMetadataV3 extends Struct {
|
||||
readonly types: Vec<PortableType>;
|
||||
readonly spec: ContractContractSpecV3;
|
||||
}
|
||||
|
||||
/** @name ContractProject */
|
||||
export interface ContractProject extends ITuple<[ContractProjectInfo, ContractMetadata]> {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user