From 98c21f1003d743eb77cb248e644489209436f116 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 26 Jun 2024 13:04:38 +0100 Subject: [PATCH 1/2] ignore lazy and mapping types when handling abi types --- packages/typechain-polkadot-parser/index.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/typechain-polkadot-parser/index.ts b/packages/typechain-polkadot-parser/index.ts index 46058aaa..466700f0 100644 --- a/packages/typechain-polkadot-parser/index.ts +++ b/packages/typechain-polkadot-parser/index.ts @@ -63,7 +63,7 @@ export class TypeParser { this.eventTypes = abi.metadata.spec.events; - this.tsTypes = this.abiTypes.map((_, i) => { + this.tsTypes = this.abiTypes.map((t, i) => { // check if type is using anywhere in the ABI let isUsed = false; @@ -122,7 +122,8 @@ export class TypeParser { break; default: break; - }}); + } + }); abi.metadata.spec.events.forEach((event) => { event.args.forEach((arg) => { @@ -132,6 +133,18 @@ export class TypeParser { }); }); + // type can be identified by it's path, e.g. ink_storage::lazy::mapping::Mapping + const typePath = t.type.path.join('::') + // the list of types to ignore + const ignoredTypes = [ + 'ink_storage::lazy::mapping::Mapping', // wrapper for mapping in the contract storage + 'ink_storage::lazy::Lazy' // wrapper type for lazy loaded values in the contract storage + ] + // if the type is an ignored type, mark it as unused + if(ignoredTypes.includes(typePath)) { + isUsed = false + } + if (isUsed) return this.generateType(i); else return TypeInfo.EMPTY_TYPE_INFO; }); From 81ed5120dc88309e589fd6f5b961a739c19e3961 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 26 Jun 2024 16:37:51 +0100 Subject: [PATCH 2/2] lint --- packages/typechain-polkadot-parser/index.ts | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/typechain-polkadot-parser/index.ts b/packages/typechain-polkadot-parser/index.ts index 466700f0..fca6eebe 100644 --- a/packages/typechain-polkadot-parser/index.ts +++ b/packages/typechain-polkadot-parser/index.ts @@ -123,7 +123,7 @@ export class TypeParser { default: break; } - }); + }); abi.metadata.spec.events.forEach((event) => { event.args.forEach((arg) => { @@ -133,17 +133,17 @@ export class TypeParser { }); }); - // type can be identified by it's path, e.g. ink_storage::lazy::mapping::Mapping - const typePath = t.type.path.join('::') - // the list of types to ignore - const ignoredTypes = [ - 'ink_storage::lazy::mapping::Mapping', // wrapper for mapping in the contract storage - 'ink_storage::lazy::Lazy' // wrapper type for lazy loaded values in the contract storage - ] - // if the type is an ignored type, mark it as unused - if(ignoredTypes.includes(typePath)) { - isUsed = false - } + // type can be identified by it's path, e.g. ink_storage::lazy::mapping::Mapping + const typePath = t.type.path.join('::'); + // the list of types to ignore + const ignoredTypes = [ + 'ink_storage::lazy::mapping::Mapping', // wrapper for mapping in the contract storage + 'ink_storage::lazy::Lazy' // wrapper type for lazy loaded values in the contract storage + ]; + // if the type is an ignored type, mark it as unused + if(ignoredTypes.includes(typePath)) { + isUsed = false; + } if (isUsed) return this.generateType(i); else return TypeInfo.EMPTY_TYPE_INFO;