question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

findSeatPrice not accessible

See original GitHub issue

I am unable to getSeatPrice from the API. I have tried many options and tried to recompile the code with different import/export permutations.

There is an existing reference to validators in the compiled js that references a function. I believe they get removed. See https://devblogs.microsoft.com/typescript/announcing-typescript-3-8-beta/#type-only-imports-exports

ERROR:
Uncaught (in promise) TypeError: Cannot read property 'findSeatPrice' of undefined

BASIC SETUP Index.js

const { validators } = require('near-api-js');

async function validatorsInfo(near, epochId) {

    const genesisConfig = await near.connection.provider.sendJsonRpc('EXPERIMENTAL_genesis_config', {});
    const result = await near.connection.provider.sendJsonRpc('validators', [epochId]);
    result.genesisConfig = genesisConfig;
    result.numSeats = genesisConfig.num_block_producer_seats + genesisConfig.avg_hidden_validator_seats_per_shard.reduce((a, b) => a + b);
    return result;
}

async function initContract() {
    const result = await validatorsInfo(near, null);
    const seatPrice = validators.findSeatPrice(result.current_validators, result.numSeats);
   ...
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vgrichinacommented, Jun 19, 2020

this is fixed here AFAIK https://github.com/near/near-api-js/releases/tag/v0.26.0

@chadoh sorry didn’t see your comment here and just decided to fix as needed to cut release with other stuff (like new RPCs)

1reaction
chadohcommented, Jun 19, 2020

We have a separate browser-index.js file that is used as the entry point for browsers, while index.js is used as the entry point for nodejs. It looks like the two have become out-of-sync; browser-index.js does not import & re-export validators the way that index.js does. My guess is that the other classes/types you noticed probably stem from the same issue.

I will extract the common exports to a common-index.js to make sure this doesn’t happen going forward, and so that you can stop using the near-api-js/lib/... workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Releases · near/near-api-js - GitHub
findAccessKey() now throws a typed error if no key exists in keystore for the current ... We are working towards modularization of the...
Read more >
Mapping Seats for Concert Reservations in WordPress ...
Now your website has a working and interactive hall layout integrated. It responds to hover events and seat selection but it is not...
Read more >
Google Flight Tickets To India From Usa Departing Tue Jan
Cheap Flights India. New Delhi From $594 Non-stop. Ahmedabad From $600 1+ stops. Mumbai From $600 1+ stops. Chennai From $605 1+ stops....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found