feat: ink! v5 (#5791)

* adds definitions and types according to ink v5 changes

* adds toV5 boilerplate code draft

* adds v5 flipper test contract code

* fix license dates

* adds test v5 toLatest test

* implements new scheme to determine event

* apply linter changes

* adds test result outputs

* change `EventRecord['topics'][0]` type to plain `Hash`

* adds testcases for decoding payload data of a ink!v4 and ink!v5 event

* changes `Abi.decodeEvent(data:Bytes)` method interface to `Abi.decodeEvent(record:EventRecord)` which includes the event and the topic for decoding.

* draft implementation with version metadata

* cleaner implementation of versioned Metadata by actually leveraging the `version` field included since v2 contract metadata

* trying to make linter happy

* makes `ContractMetadataSupported` in internal to `Abi` type and not exposing it externally.

* properly types unused parameter for tsc 🤷

* adds `@polkadot/types-support` dev dependency

* Update yarn.lock

* references `types-support` in `api-contract

* resolving change requests

* resolves linter warnings

* changes ContractMetadataV5 field to `u64` from `Text`

* adds contracts and contract metadata compiled with the most recent ink version

* implements decoding of anonymous events if possible

* removes done todo comments
This commit is contained in:
peetzweg/
2024-03-02 09:18:14 -05:00
committed by GitHub
parent f9b2d26381
commit ca4802326c
39 changed files with 6245 additions and 93 deletions
@@ -120,6 +120,13 @@ const spec = {
docs: 'Vec<Text>',
environment: 'ContractEnvironmentV4'
},
ContractContractSpecV5: {
constructors: 'Vec<ContractConstructorSpecV4>',
messages: 'Vec<ContractMessageSpecV3>',
events: 'Vec<ContractEventSpecV3>',
docs: 'Vec<Text>',
environment: 'ContractEnvironmentV4'
},
ContractDisplayName: 'SiPath',
ContractEventParamSpecV0: {
@@ -149,6 +156,13 @@ const spec = {
args: 'Vec<ContractEventParamSpecV2>',
docs: 'Vec<Text>'
},
ContractEventSpecV3: {
label: 'Text',
args: 'Vec<ContractEventParamSpecV2>',
docs: 'Vec<Text>',
module_path: 'Text',
signature_topic: 'Option<[u8; 32]>'
},
ContractMessageParamSpecV0: {
name: 'Text',
type: 'ContractTypeSpec'
@@ -203,11 +217,11 @@ const spec = {
const latest = {
ContractConstructorSpecLatest: 'ContractConstructorSpecV4',
ContractEventSpecLatest: 'ContractEventSpecV2',
ContractEventSpecLatest: 'ContractEventSpecV3',
ContractEventParamSpecLatest: 'ContractEventParamSpecV2',
ContractMessageParamSpecLatest: 'ContractMessageParamSpecV2',
ContractMessageSpecLatest: 'ContractMessageSpecV3',
ContractMetadataLatest: 'ContractMetadataV4'
ContractMetadataLatest: 'ContractMetadataV5'
};
export default {
@@ -239,7 +253,13 @@ export default {
},
ContractMetadataV4: {
types: 'Vec<PortableType>',
spec: 'ContractContractSpecV4'
spec: 'ContractContractSpecV4',
version: 'Text'
},
ContractMetadataV5: {
types: 'Vec<PortableType>',
spec: 'ContractContractSpecV5',
version: 'u64'
},
ContractMetadata: {
_enum: {
@@ -247,7 +267,8 @@ export default {
V1: 'ContractMetadataV1',
V2: 'ContractMetadataV2',
V3: 'ContractMetadataV3',
V4: 'ContractMetadataV4'
V4: 'ContractMetadataV4',
V5: 'ContractMetadataV5'
}
},
ContractProjectV0: {
@@ -94,6 +94,15 @@ export interface ContractContractSpecV4 extends Struct {
readonly environment: ContractEnvironmentV4;
}
/** @name ContractContractSpecV5 */
export interface ContractContractSpecV5 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;
@@ -138,7 +147,7 @@ export interface ContractEventParamSpecV2 extends Struct {
}
/** @name ContractEventSpecLatest */
export interface ContractEventSpecLatest extends ContractEventSpecV2 {}
export interface ContractEventSpecLatest extends ContractEventSpecV3 {}
/** @name ContractEventSpecV0 */
export interface ContractEventSpecV0 extends Struct {
@@ -161,6 +170,15 @@ export interface ContractEventSpecV2 extends Struct {
readonly docs: Vec<Text>;
}
/** @name ContractEventSpecV3 */
export interface ContractEventSpecV3 extends Struct {
readonly label: Text;
readonly args: Vec<ContractEventParamSpecV2>;
readonly docs: Vec<Text>;
readonly module_path: Text;
readonly signature_topic: Option<U8aFixed>;
}
/** @name ContractLayoutArray */
export interface ContractLayoutArray extends Struct {
readonly offset: ContractLayoutKey;
@@ -284,11 +302,13 @@ export interface ContractMetadata extends Enum {
readonly asV3: ContractMetadataV3;
readonly isV4: boolean;
readonly asV4: ContractMetadataV4;
readonly type: 'V0' | 'V1' | 'V2' | 'V3' | 'V4';
readonly isV5: boolean;
readonly asV5: ContractMetadataV5;
readonly type: 'V0' | 'V1' | 'V2' | 'V3' | 'V4' | 'V5';
}
/** @name ContractMetadataLatest */
export interface ContractMetadataLatest extends ContractMetadataV4 {}
export interface ContractMetadataLatest extends ContractMetadataV5 {}
/** @name ContractMetadataV0 */
export interface ContractMetadataV0 extends Struct {
@@ -319,6 +339,14 @@ export interface ContractMetadataV3 extends Struct {
export interface ContractMetadataV4 extends Struct {
readonly types: Vec<PortableType>;
readonly spec: ContractContractSpecV4;
readonly version: '4';
}
/** @name ContractMetadataV5 */
export interface ContractMetadataV5 extends Struct {
readonly types: Vec<PortableType>;
readonly spec: ContractContractSpecV5;
readonly version: 5;
}
/** @name ContractProject */