anchor-earn icon indicating copy to clipboard operation
anchor-earn copied to clipboard

TypeError: userCoins.get is not a function

Open xvvvyz opened this issue 4 years ago • 10 comments

  • The address I'm using does indeed have funds.
  • After reverting this change it works (cc @ALPAC-4).
import Anchor from '@anchor-protocol/anchor-earn'; // v1.1.0

(async () => {
  const anchorEarn = new Anchor.AnchorEarn({
    address: '...',
    chain: Anchor.CHAINS.TERRA,
    network: Anchor.NETWORKS.COLUMBUS_5,
  });

  const { total_deposit_balance_in_ust: anchorBalance } =
    await anchorEarn.balance({ currencies: [Anchor.DENOMS.UST] });
})()

xvvvyz avatar Oct 25 '21 22:10 xvvvyz

@ALPAC-4 Would you mind having a look at this?

MSNTCS avatar Oct 28 '21 10:10 MSNTCS

Hey guys it looks like I'm facing the same issue. It'd be great if you can take a look into that

crypt0grapher avatar Nov 20 '21 20:11 crypt0grapher

The reason for the issue is that anchor-earn is not aligned with terra.js. I see there's a PR waiting to fix that, it'll help: https://github.com/petes-fan-club/anchor-earn/commit/6ecc5599db9aa6f84b96fa6a46c31b536cf1b816 @cadejscroggins As a workaround, you can use that commit for the time being in your package.json "@anchor-protocol/anchor-earn": "git://github.com/petes-fan-club/anchor-earn.git#6ecc5599db9aa6f84b96fa6a46c31b536cf1b816",

crypt0grapher avatar Nov 21 '21 11:11 crypt0grapher

the only gotcha on that PR is that it assumes that the token appears on the first page of results. the new API provides a paginated response.. so ideally the fix for this issue should check for pagination and fetch more balances. the PR itself is stalled on a node-16 install issue (node-gyp does give so much to everyone).

PFC-developer avatar Nov 21 '21 17:11 PFC-developer

Makes much sense, many thanks for the note @petes-fan-club

crypt0grapher avatar Nov 21 '21 17:11 crypt0grapher

if you know how to make node-gyp resolve itself, I'll fix up the PR.. I'm assuming just adding it to devDependencies will help

PFC-developer avatar Nov 21 '21 17:11 PFC-developer

I'm on the phone can't tell right now, I think node-gyp-build would be necessary as well to build the package. At least installing both inside my docker container before yarn helped me ) I made almost the same fix as you before noticing your PR. The usual )

crypt0grapher avatar Nov 21 '21 17:11 crypt0grapher

PR was merged.. give it a shot.. I'll work on the edge case today

PFC-developer avatar Nov 22 '21 14:11 PFC-developer

Well, it's still a very nice update of yours if downloaded from github url, but it's not installable with npm/yarn since npm package registry holds the 10-day old version. I don't see if there's any github action configured for that, so it looks like this is something yet to be done - to assign a new version number and publish the change to npm.

crypt0grapher avatar Nov 22 '21 16:11 crypt0grapher

yarn add @anchor-protocol/[email protected] works like a charm.

crypt0grapher avatar Nov 23 '21 12:11 crypt0grapher