#Typescript bindings

1 messages · Page 1 of 1 (latest)

humble oasis
#

Hello 🙂

I have a custom type in my contract:

pub type Id = Address;

but when generating typescript bindings, it doesnt export it, so i need to add the type manually, otherwise my ts code wont compile

wicked widget
#

Type aliases, as above, are not supported by the contract specification embedded into contracts. If you just use “Address” as the type it’ll work.

humble oasis
humble oasis
#

hey @wicked widget , is this going to be solved?
I just had another issue, this time when deploying the contract:
I have this type:

pub type MyNamespace = Address;

which i use for storage:

#[contracttype]
pub enum NamespacedStorage {
    Main(MyNamespace, StorageKeys),
}

But when deploying the contract, it doesn't recognize MyNamespace, i get the error:
❌ error: Missing Entry MyNamespace

i noticed that it's due to some functions in the contract expecting the type as parameter:

pub fn set_namespaced(env: Env, namespace: MyNamespace, value: u32) {
    env.storage().instance().set(
        &NamespacedStorage::Main(namespace, StorageKeys::SimpleKey),
        &value,
    );
}