From cd5a5da45c07317ee622c3c7c45038b2c90a6cbe Mon Sep 17 00:00:00 2001 From: Keith Ingram Date: Fri, 9 Oct 2020 07:40:24 -0700 Subject: [PATCH] Definition ordering (#2699) * Updated ABI definitions & parsing * Run type generation * Definitions (should be ok-ish) * Cleanup names * Allow aliasses on structs (JSON parsing) * Cleanup json mapping passing * s/types/lookup/ * Parsing as per current output * InkSelector * MtRegistryIndex * String lookup tests * Remove serd ovverride comments (it works as-is) * inkRegistry tests * Extract primitive types * s/ty/id/ * Start of parsing into types (actually to be TypeDef) * Parsing * stringify struct fields * Small cleanups * Add type index to project lookup * Prefix with index * Fix interface generation * Latest contract metadata (#2118) * Add new (provisional) incrementer contract metadata * Update and regenerate type definitions * WIP: generate new format scale-info types * WIP: implementing variants * Implement variants * Fix up type resolution * Fix registry spec tests * Fix lints and some tests * Fix inkTypes tests * Fix some lints * Make imports same line like original * Comment out (temporarily) sanitize import to make CI pass * Sanitize * Remove indices * Remove index * api-contract rewrite * lint * cleanup * latest * latest * fix definition * fiz definitions * rv ink storage * Update packages/api-contract/src/base/Contract.ts Co-authored-by: Jaco Greeff * fixes * rv scripts * restore api-contract * reorder definitions, fix ink storage * fixes * def order * fixes Co-authored-by: Jaco Greeff Co-authored-by: Andrew Jones --- .../interfaces/contractsAbi/definitions.ts | 14 +++++------ .../src/interfaces/contractsAbi/types.ts | 24 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/types/src/interfaces/contractsAbi/definitions.ts b/packages/types/src/interfaces/contractsAbi/definitions.ts index 940368aa54..63b19253ff 100644 --- a/packages/types/src/interfaces/contractsAbi/definitions.ts +++ b/packages/types/src/interfaces/contractsAbi/definitions.ts @@ -103,18 +103,18 @@ const registry = { MtLookupTypeId: 'u32', MtPath: 'Vec', MtType: { - def: 'MtTypeDef', + path: 'MtPath', params: 'Vec', - path: 'MtPath' + def: 'MtTypeDef' }, MtTypeDef: { _enum: { - Array: 'MtTypeDefArray', Composite: 'MtTypeDefComposite', - Primitive: 'MtTypeDefPrimitive', + Variant: 'MtTypeDefVariant', Sequence: 'MtTypeDefSequence', + Array: 'MtTypeDefArray', Tuple: 'MtTypeDefTuple', - Variant: 'MtTypeDefVariant' + Primitive: 'MtTypeDefPrimitive' } }, MtTypeDefArray: { @@ -136,9 +136,9 @@ const registry = { variants: 'Vec' }, MtVariant: { - discriminant: 'Option', + name: 'Text', fields: 'Vec', - name: 'Text' + discriminant: 'Option' } }; diff --git a/packages/types/src/interfaces/contractsAbi/types.ts b/packages/types/src/interfaces/contractsAbi/types.ts index fe49b90631..09f27c0203 100644 --- a/packages/types/src/interfaces/contractsAbi/types.ts +++ b/packages/types/src/interfaces/contractsAbi/types.ts @@ -179,25 +179,25 @@ export interface MtPath extends Vec {} /** @name MtType */ export interface MtType extends Struct { - readonly def: MtTypeDef; - readonly params: Vec; readonly path: MtPath; + readonly params: Vec; + readonly def: MtTypeDef; } /** @name MtTypeDef */ export interface MtTypeDef extends Enum { - readonly isArray: boolean; - readonly asArray: MtTypeDefArray; readonly isComposite: boolean; readonly asComposite: MtTypeDefComposite; - readonly isPrimitive: boolean; - readonly asPrimitive: MtTypeDefPrimitive; - readonly isSequence: boolean; - readonly asSequence: MtTypeDefSequence; - readonly isTuple: boolean; - readonly asTuple: MtTypeDefTuple; readonly isVariant: boolean; readonly asVariant: MtTypeDefVariant; + readonly isSequence: boolean; + readonly asSequence: MtTypeDefSequence; + readonly isArray: boolean; + readonly asArray: MtTypeDefArray; + readonly isTuple: boolean; + readonly asTuple: MtTypeDefTuple; + readonly isPrimitive: boolean; + readonly asPrimitive: MtTypeDefPrimitive; } /** @name MtTypeDefArray */ @@ -243,9 +243,9 @@ export interface MtTypeDefVariant extends Struct { /** @name MtVariant */ export interface MtVariant extends Struct { - readonly discriminant: Option; - readonly fields: Vec; readonly name: Text; + readonly fields: Vec; + readonly discriminant: Option; } export type PHANTOM_CONTRACTSABI = 'contractsAbi';