pattern-tech / gateway

Middleware that standardizes DEX API endpoints on different blockchain networks
Apache License 2.0
1 stars 1 forks source link

getAssetBalance method does not work properly #17

Closed mehrdadmms closed 1 month ago

mehrdadmms commented 2 months ago

Case

When calling getAssetBalance, I set the below configurations. For some addresses, I get 0 and for some other addresses, the code does not exit and doesn't return anything: this is my code:

import { Ergo } from './ergo';

const ergo = new Ergo('Testnet');

(async function x() {
  ergo['_assetMap'] = {
    '$Bass Token': {
      tokenId:
        'ba553573f83c61be880d79db0f4068177fa75ab7c250ce3543f7e7aeb471a9d2',
    } as any,
  };
  console.log(
    await ergo['getAssetBalance'](
      {
        address: '9how9k2dp67jXDnCM6TeRPKtQrToCs5MYL2JoSgyGHLXm1eHxWs',
      } as any,
      '$Bass Token',
    ),
  );
})();

and my terminal gets stuck like this:

Image

hirotadashi commented 2 months ago

there are 2 problems with your test:

  1. token name should be upper case: try using this instead:

      import { Ergo } from './ergo';
    
      const ergo = new Ergo('Testnet');
    
      (async function x() {
        ergo['_assetMap'] = {
          '$BASS TOKEN': {
            tokenId:
              'ba553573f83c61be880d79db0f4068177fa75ab7c250ce3543f7e7aeb471a9d2',
          } as any,
        };
        console.log(
          await ergo['getAssetBalance'](
            {
              address: '9how9k2dp67jXDnCM6TeRPKtQrToCs5MYL2JoSgyGHLXm1eHxWs',
            } as any,
            '$Bass Token',
          ),
        );
      })();
    
  2. the address that you used contains lots of utxos so getting all of them take some time. instead use this address: 9gxhg94hCN4KdnCam6ef8i43eZrhZdohG2ahiRsXk9XU5FpUKbC