AstarNetwork / astar.js

Astar network Typescript SDK
Apache License 2.0
30 stars 9 forks source link

Api Call Error on shibuya-testnet but Success on astar-mainnet node(endpoint). #70

Closed johnnyji-dev closed 6 months ago

johnnyji-dev commented 6 months ago

Describe the bug I got a error-response(maybe undefined) at "estimatePendingRewards" method on astar-mainnet node.


Debugging [shibuya-testnet node endpoint : 'https://shibuya-rpc.dwellir.com' or 'https://shibuya.public.blastapi.io'] I was using "@astar-network/astar-api": "^0.2.1", "@astar-network/astar-sdk-core": "^0.2.1", version of dependencies. After checking out pull-request-info, I upgraded version 0.2.1 -> 0.2.8. On astar-mainnet node, I worked well. But on shibuya-testnet node, I returned a error[TypeError: Cannot read properties of undefined(reading 'generalEraInfo')].

And I also found that "api.query.dappsStaking.currentEra();" doesn't work on 0.2.8. So I updated source-code ( using "api.query.dappsStaking.generalEraInfo.entries()" and "formatEraTvls" ). I can got the value(current Era info) on astar-mainnet node. BTW, on shibuya-testnet, I can't work and got "Cannot read properties of undefined (reading 'era')". I attach "getCurrentEra" source-code below.

async getCurrentEra(): Promise<any> { const eraInfo = await this.client.query.dappsStaking.generalEraInfo.entries() const eraTvls = formatEraTvls(eraInfo) const currentEra = eraTvls[eraTvls.length -1].era; return currentEra; }


Questions Q1) Why the result is different on mainnet and testnet endpoint? Testnet node is not upgraded? Q2) How can I solve the error on testnet? Can I get some another testnet endpoint?

johnnyji-dev commented 6 months ago

Is it for Switching to V3 on shibuya? image

bobo-k2 commented 6 months ago

dApp staking calls from the libraries above doesn't work on Shibuya anymore, because we deployed dApp staking v3 to Shibuya. The same will happen to Shiden and Astar in following months. If you need test env with old dApp staking pallet you can compile a node from source and run it locally or use Chopsticks to run Shibuya locally from any block before 5335615. Please, have in mind that new dApp staking is coming soon and any development you are working on for the old version will become obsolete very soon.

Please describe what do you want to achieve and I might be able to help or give a better advice.