Recently I've been passing through some problems trying to fetch FA metadata, balance of user and etc.
This package could try solve this for common developer.
I had to create an action for my code to work with type safety
import { AccountAddress } from "@aptos-labs/ts-sdk"
export type FungibleAssetMetadata = {
decimals: number
icon_uri: string | null
name: string
project_uri: string | null
symbol: string
}
export async function fetchFungibleAsset(address: `0x${string}`, chainId: string | number) {
const network = getMoveNetworkInfoById(`${chainId}`, true)
const aptos = getAptosClient(network)
const [result] = await aptos.view({
payload: {
function: `${AccountAddress.ONE.toString()}::fungible_asset::metadata`,
typeArguments: [`${AccountAddress.ONE.toString()}::fungible_asset::Metadata`],
functionArguments: [address],
},
})
return result as FungibleAssetMetadata
}
Although, find a FA abi on internet is pretty hard, and the contracts that does have it, doesn't provide the abi or modules that allow to get it. FA still a mystery if it's interface is complete and ready to go or will suffer changes in future.
Even making the abi by hand to try work with type for the code above, still have some issues, the fetch doesn't work (I believe it is because of the typeArguments) and also has the problem of inferring a struct type with the ABI.
Hope we can figure this out soon
Recently I've been passing through some problems trying to fetch FA metadata, balance of user and etc.
This package could try solve this for common developer.
I had to create an action for my code to work with type safety
Although, find a FA abi on internet is pretty hard, and the contracts that does have it, doesn't provide the abi or modules that allow to get it. FA still a mystery if it's interface is complete and ready to go or will suffer changes in future.
Even making the abi by hand to try work with type for the code above, still have some issues, the fetch doesn't work (I believe it is because of the typeArguments) and also has the problem of inferring a struct type with the ABI.
Hope we can figure this out soon