Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore lazy and mapping types when handling abi types #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/typechain-polkadot-parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -122,7 +122,8 @@ export class TypeParser {
break;
default:
break;
}});
}
});

abi.metadata.spec.events.forEach((event) => {
event.args.forEach((arg) => {
Expand All @@ -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;
});
Expand Down
Loading