helius-labs / helius-sdk

123 stars 39 forks source link

Changed capitalization for TokenType #113

Closed sohsag closed 1 month ago

sohsag commented 1 month ago

Changed capitalization otherwise it does not work

0xIchigo commented 1 month ago

gm @SohailSaghar, thanks for the PR! Can you provide an example of the current capitalization of the DAS types not working? I'm more than happy to merge this PR — just want to quickly test before we merge

sohsag commented 1 month ago

gm @0xIchigo, hope this example showcases it. The below code uses searchAssets method and I have passed in the parameter tokenType:'fungible'.

import {Helius} from "helius-sdk";

const helius = new Helius(apiKey)
helius.rpc.searchAssets({page: 1, ownerAddress: "49WzUgrr6SMZzycrDzhZ4cwDTHhtjks2iYfuKBb29DdN", tokenType: 'fungible'}).
then(assets => {
    for (const asset of assets.items) {
        console.log(asset.token_info)
    }
})

The return of this is

{
  symbol: 'USDC',
  balance: 2033376,
  supply: 2476922073699006,
  decimals: 6,
  token_program: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
  associated_token_address: '9GYDraXKmAEpAo3wT5dChDFxy3mcG2LhBQJLusVLYpQY',
  price_info: { price_per_token: 1, total_price: 2.033376, currency: 'USDC' },
  mint_authority: '2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9',
  freeze_authority: '3sNBr7kMccME5D55xNgsmYpZnzPgP2g12CixAajXypn6'
}

However, if I were to type tokenType:'Fungible' as the code is now, the variable assets is now undefined