Anchor-Protocol / anchor-earn

The Earn JavaScript SDK for Anchor Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: userCoins.get is not a function

xvvvyz opened this issue · 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] });

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

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

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:
As a workaround, you can use that commit for the time being in your package.json
"@anchor-protocol/anchor-earn": "git://",


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).

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


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

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 )


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

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.

yarn add @anchor-protocol/anchor-earn@2.0.0-alpha1 works like a charm.