axelarnetwork / support

Your source for support with the Axelar Network
3 stars 1 forks source link

aUSDC Deducted, Funds Missing in MetaMask #147

Open rabi-siddique opened 3 days ago

rabi-siddique commented 3 days ago

I have a Node.js script designed to transfer aUSDC from the Osmosis testnet to the Avalanche testnet. However, while executing the script, I encountered the following error:

/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/base64-js/index.js:26
    throw new Error('Invalid string. Length must be a multiple of 4')
          ^

Error: Invalid string. Length must be a multiple of 4
    at getLens (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/base64-js/index.js:26:11)
    at Object.toByteArray (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/base64-js/index.js:55:14)
    at fromBase64 (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@cosmjs/encoding/build/base64.js:36:21)
    at decodeAttribute (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:43:40)
    at Array.map (<anonymous>)
    at decodeAttributes (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:48:53)
    at decodeEvent (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:53:40)
    at Array.map (<anonymous>)
    at decodeEvents (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:58:49)
    at decodeTxData (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:66:31)

Node.js v18.20.4

I didn’t receive funds in my MetaMask wallet, but the aUSDC tokens were deducted from my wallet. Why did this happen? Will the tokens be returned to me, or are they permanently lost?

Here is my script:

import {
  AxelarAssetTransfer,
  CHAINS,
  Environment,
} from '@axelar-network/axelarjs-sdk';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { config } from 'dotenv';

config();

const OSMOSIS_RPC = 'https://rpc.testnet.osmosis.zone';
const METAMASK_ADDRESS = '0x20E68F6c276AC6E297aC46c84Ab260928276691D';

const getSigner = async () => {
  const MNEMONIC = process.env.MNEMONIC;
  const mnemonic = MNEMONIC;
  return DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: 'osmo' });
};

const main = async () => {
  const wallet = await getSigner();
  const api = new AxelarAssetTransfer({ environment: Environment.TESTNET });

  const requestOptions = {
    fromChain: CHAINS.TESTNET.OSMOSIS,
    toChain: CHAINS.TESTNET.AVALANCHE,
    destinationAddress: METAMASK_ADDRESS,
    asset: {
      // aUSDC
      denom:
        'ibc/1587E7B54FC9EFDA2350DC690EC2F9B9ECEB6FC31CF11884F9C0C5207ABE3921',
    },
    amountInAtomicUnits: '800000',
    options: {
      cosmosOptions: {
        cosmosDirectSigner: wallet,
        rpcUrl: OSMOSIS_RPC,
        fee: {
          gas: '250000',
          amount: [{ denom: 'uosmo', amount: '30000' }],
        },
      },
    },
  };

  const response = await api.sendToken(requestOptions);
  console.log('RESPONSE', response);
};

main();
rabi-siddique commented 3 days ago

I followed the stack trace and made updates in node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js.

Mainly replaced:

function decodeAttribute(attribute) {
    return {
        key: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(attribute.key)),
        value: (0, encoding_1.fromBase64)((0, encodings_1.assertString)(attribute.value ?? "")),
    };
}

With:

  function decodeAttribute(attribute) {
    let key = attribute.key;
    let value = attribute.value;
    return {
      key,
      value,
    };
  }

After making this change, the error message changed to:

/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/rpcclients/httpclient.js:24
            throw new Error(JSON.stringify(response.error));
                  ^

Error: {"code":-32603,"message":"Internal error","data":"transaction indexing is disabled"}
    at HttpClient.execute (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/rpcclients/httpclient.js:24:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Tendermint34Client.doCall (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/tendermint34client.js:310:24)
    at async Tendermint34Client.txSearchAll (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/tendermint34client.js:258:26)
    at async SigningStargateClient.txsQuery (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/stargate/build/stargateclient.js:283:25)
    at async SigningStargateClient.getTx (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/stargate/build/stargateclient.js:213:25)
    at async pollForTx (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/stargate/build/stargateclient.js:254:28)

Node.js v18.20.4

Weird that I see an increment in the aUSDC balance on the Metamask wallet. Even though we encountered an error.

benjamin852 commented 3 days ago

Hey, to confirm you said in your first questions tokens are being decremented and now you're seeing the aUSDC balance incremented on your metamask wallet on avalanche? Is there a tx hash you can share for these txs?

rabi-siddique commented 3 days ago

Hey, to confirm you said in your first questions tokens are being decremented and now you're seeing the aUSDC balance incremented on your metamask wallet on avalanche?

Initially, aUSDC tokens were deducted from my Keplr wallet, but no aUSDC appeared in my Metamask account. But, after implementing the change I mentioned in my earlier comment, I observed an increase in the aUSDC balance on Metamask.

Is there a tx hash you can share for these txs?

Let me check and share.

rabi-siddique commented 3 days ago

@benjamin852 I don’t recall the exact transaction details, as this was done some time ago. However, here’s a link to my transactions on the block explorer:
Transaction history.

I believe the issue occurred during transfers from Osmosis to Avalanche, and these transactions might be relevant:

I observed a similar issue in transactions from Osmosis to Sepolia. In the final transaction, I noticed that aUSDC appeared in my MetaMask wallet. Here are the relevant transactions for your inspection:

Olanetsoft commented 1 day ago

Hello @rabi-siddique, Thank you for sharing all the transaction details. We really appreciate your patience in debugging this.

Regarding the error you encountered, it looks like this is mainly a client-side issue rather than an on-chain one. That’s likely why the transaction went through even though you ran into the error. Since the implementation in JavaScript/TypeScript is asynchronous, it doesn't block the actual on-chain activity, and the indexing error appears to be happening afterward when the transaction details are being fetched.

Specifically, the error "transaction indexing is disabled" suggests that the Osmosis RPC endpoint you used doesn’t have transaction indexing enabled. This means that while the transaction itself was successfully processed, the node couldn't search for or return the transaction details because they weren't indexed yet.

I retried this process on my end using a node with transaction indexing enabled, and it worked smoothly. To move forward, I recommend either:

Trying a Different RPC Endpoint: Look for an Osmosis testnet RPC that has transaction indexing enabled. This should help avoid the indexing error you're seeing.

Adjusting the Client Behavior: You could also adjust the client to handle scenarios where the transaction indexing might take longer, perhaps by adding retry logic or handling the error more gracefully when fetching transaction information. Let me know if this helps or if you need further assistance!

rabi-siddique commented 5 hours ago

@Olanetsoft Thanks for the detailed response. Very helpful.

About the error I encountered first:

/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/base64-js/index.js:26
    throw new Error('Invalid string. Length must be a multiple of 4')
          ^

Error: Invalid string. Length must be a multiple of 4
    at getLens (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/base64-js/index.js:26:11)
    at Object.toByteArray (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/base64-js/index.js:55:14)
    at fromBase64 (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@cosmjs/encoding/build/base64.js:36:21)
    at decodeAttribute (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:43:40)
    at Array.map (<anonymous>)
    at decodeAttributes (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:48:53)
    at decodeEvent (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:53:40)
    at Array.map (<anonymous>)
    at decodeEvents (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:58:49)
    at decodeTxData (/Users/rabisiddique/Desktop/Work/cosmos-to-evm/node_modules/@axelar-network/axelarjs-sdk/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js:66:31)

Node.js v18.20.4

This is resolved via the explanation in this comment. How to overcome this error without slightly changing implementation of @cosmjs/tendermint-rpc