react-moralis
react-moralis copied to clipboard
Export chainType
New Feature Request
Checklist
- [ x] I am not disclosing a vulnerability.
- [ x ] I have searched through existing issues and the Moralis Forum.
Current Limitation
When calling a function that takes a chain as a parameter in typescript, I need to create a new type to do so:
type chainType =
| "eth"
| "0x1"
| "ropsten"
| "0x3"
| "rinkeby"
| "0x4"
| "goerli"
| "0x5"
| "kovan"
| "0x2a"
| "polygon"
| "0x89"
| "mumbai"
| "0x13881"
| "bsc"
| "0x38"
| "bsc testnet"
| "0x61"
| "avalanche"
| "0xa86a"
| "avalanche testnet"
| "0xa869"
| "fantom"
| "0xfa"
| undefined
type tokenIdMetadataParams = {
chain: chainType
address: string
token_id: string
}
const options: tokenIdMetadataParams = {
chain: chainId!.toString() as chainType,
address: nftAddress,
token_id: tokenId.toString(),
}
const fetchTokenIdMetadata = async () => {
const tokenIdMetadata = await Web3Api.token.getTokenIdMetadata(options)
console.log(tokenIdMetadata)
}
It would be great if we could just import this chainType
You can use the Moralis.Chain. but it seems that there are some small differences between these types and the type that gets accepted in the API. Will look into it