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

[feature request] Contract custom type definition generation support #81

Open
1 task
hychen opened this issue Apr 9, 2021 · 0 comments
Open
1 task

Comments

@hychen
Copy link

hychen commented Apr 9, 2021

Given a storage which has a custom type definition as below.

#[derive(....)]
struct CustomType {
    name: String
}

#[ink(storage)]
struct Store {
    members: ink_storage::collections::HashMap<AccountId, CustomType>
}

When a contract developer executes npx redspot compile. it generates three files as below

  • artificats/store.contract :: the contract itself.
  • artificats/store.json :: the contract metadata.
  • artificats/store.ts.d :: the Typescript definiton of the custom types of the contract.(new)

So that a contract developer could import TS types to make ts-lint happy.

import { CustomType } from artificates.contract;
const contractFactory = await getContractFactory('contract', creator);
const contract = await contractFactory.deploy('new');
const member: CustomType = await contract.members(account_id).output;

Dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant