Anchor-Protocol / anchor-earn

The Earn JavaScript SDK for Anchor Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CustomSigner

5bngr opened this issue · comments

commented

Hi,
I'm trying to implement a CustomSigner as per example provided in the docs and get the following error:
error_msg: 'unauthorized: signature verification failed; please verify account number (xxxxx) and chain-id (columbus-5): unauthorized'
Everything else seems to be working, as long as I don't try to use a CustomSigner.

  • I can instantiate an account object
  • I can instantiate an AnchorEarn object using account object above
  • I can check balance on account
  • I can send from account to another wallet (using built in signer)

Any help would be greatly appreciated.
Thanks!

// vars
const terraWalltAddrTest = '...' //address of test wallet I'm using to test anchor earn api
const kucointerraWalletAddr = '...' //terra deposit address on kucoin.
const kucoinmemo = '...' //required memo ID for deposits to kucoin terra address
const sendAmnt = 1 //sending 1 UST to kucoin address.

// CustomSigner Code:
const testWalletSigner = async (tx) => {
const anchoracct = new anchor.MnemonicKey({
mnemonic: '...',
});

const terra = new LCDClient({
URL: 'https://lcd.terra.dev',
chainId: 'columbus-5',
});

const wallet = terra.wallet(anchoracct);

return await wallet.createAndSignTx({
msgs: tx,
// gasAdjustment: 2,
// gasPrices: { uusd: 0.15 },
memo: kucoinmemo,
});
};

// Instantiate Anchor Object:
const anchorEarn = new anchor.AnchorEarn({
chain: anchor.CHAINS.TERRA,
network: anchor.NETWORKS.COLUMBUS_5,
address: terraWalltAddrTest,
});

// Anchor Send Code:
const sendUst = await anchorEarn.send({
currency: anchor.DENOMS.UST,
recipient: kucointerraWalletAddr,
amount: sendAmnt,
log: (data) => {
console.log(data);
},
customSigner: testWalletSigner,
});