Skip to content

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

Open
@hychen

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions