AstarNetwork / astar.js

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

"api.query.dappsStaking.generalEraInfo.entries()" is undefined, is it deprecated ? How can I get currentEra Info? #72

Closed johnnyji-dev closed 4 months ago

johnnyji-dev commented 4 months ago

After V3 upgrade, my-api server have some issue.

I can get Era info by using "dappsStaking-api etc".

    async getCurrentEra(): Promise<any> {
        try {
            const eraInfo = await this.client.query.dappsStaking.generalEraInfo.entries()
            Logger.debug(`eraInfo : ${eraInfo}`)

            const eraTvls = formatEraTvls(eraInfo)
            Logger.debug(`eraTvls : ${eraTvls}`)

            const currentEra = eraTvls[eraTvls.length -1].era;
            Logger.debug(`currentEra : ${currentEra}`)
            return currentEra;
        } catch (error) {
            Logger.error(`errCode:${error.code} | errMsg:${error.message}`);
            throw new ApplicationException(error.code, error.message);
        }
    }

On that code, return error( Cannot read properties of undefined (reading 'generalEraInfo') )...

On github code, "generalEraInfo" is existed yet!

How can I get current era by calling api?

What version of AstarNode is needed? Over 5.32.0? (https://github.com/AstarNetwork/Astar/releases/tag/v5.32.0)

bobo-k2 commented 4 months ago

Try with

this.client.query.dappStaking.activeProtocolState()

V3 runtime is not compatibile with v2. If you want to get more info on how to use dApp staking from the client perspective check https://github.com/AstarNetwork/astar-apps/tree/main/src/staking-v3

johnnyji-dev commented 4 months ago

Try with

this.client.query.dappStaking.activeProtocolState()

V3 runtime is not compatibile with v2. If you want to get more info on how to use dApp staking from the client perspective check https://github.com/AstarNetwork/astar-apps/tree/main/src/staking-v3

@bobo-k2 It's very helpful for ur feedback~~ so so thx!!

I have additional questions more about controlling(transfer or staking etc) my balance. After upgrade V3, I wonder how to check out a account-balance (Transferable, Staking, Unstaking, etc).

For example, I can retrieve my balance(a7ZEP29Zk9vrfNWiENXdhLQWxp3yVSvaTBtTcJAkDKHijwX) account by subscan.io. image

The account was staking about 1000 ASTR(maybe, not matter that number) on V2. And I didn't unstake ahead on V2. I took a look ur description about V3. It said that staking amount will be unstaked and locked.

Q1) Does it mean that my staked amount before V3(on V2) is locked and it need to wait 10-era to do "withdraw_unbonded"-tx for transit transferable amount? That is right? But on subscan(above picture) it looks like already on tranferable state.

Above all, by using polkadot.js and astar.js api, I tried to get some balance and staking and lockedInfo like belows. Q2) How can I got that meaning of balance?

Q2-1) "subscan" said that my transferable amount is 1129 ASTR but "balance-API" said that miscFrozen(I understand that miscFrozen is locking amount) is 1000.xx ASTR. Which one is correct?

Q2-2) How can I unlock the locked amount? Just wait for 10-era and tried to broadcast "withdraw_unbonded"-tx?

Q2-3) I tried to stake(tx-subscan) 1000 ASTR by portal(portal.astar.network). By the way, on subscan the amount is not display on staking section, still on transferable. It's so weird... I don't know how to interpret this situation. Monosnap astarsubstrate service ts — crypto-grid  개발 컨테이너: crypto-grid  2024-02-14 15-36-00

Q3) I wanna know how to fix to get stakingInfo. Below picture is my ASIS api-method for retrieving [stakingInfo]. (address : a7ZEP29Zk9vrfNWiENXdhLQWxp3yVSvaTBtTcJAkDKHijwX)(https://astar.subscan.io/extrinsic/0xb1192ab5d1311f59e022d106a0c2edf3a506ca7d767cc7b7ac363385aba6af99) after V3 upgrade. image

Q4) I wanna know how to fix to get lockedUnbondingInfo. Below picture is my ASIS api-method for retrieving [lockedUnbondingInfo]. (address : WDQ2Cv41nsn82t4K4Mv4DiAGiTbwhbs4YkS3fWZSGBG8mqZ) image

Q5) I wanna know how to fix to get dAppInfo. Below picture is my ASIS api-method for retrieving [dAppInfo]. image

For Q3~5, I tried to check out V3-runtime(https://github.com/AstarNetwork/astar-apps/tree/main/src/staking-v3) before you let me know, but I can't convince which one is correct?

Thx~!

bobo-k2 commented 4 months ago

Hi, a lot of question are answered in Astar docs and the portal source code. Please refer to documentation and Astar portal source code first and in case you can't find answer there I will try to help

https://docs.astar.network/docs/learn/dapp-staking/ https://docs.astar.network/docs/use/dapp-staking/ https://docs.astar.network/docs/build/dapp-staking/

https://github.com/AstarNetwork/astar-apps/tree/main/src/staking-v3

johnnyji-dev commented 4 months ago

Hi, a lot of question are answered in Astar docs and the portal source code. Please refer to documentation and Astar portal source code first and in case you can't find answer there I will try to help

https://docs.astar.network/docs/learn/dapp-staking/ https://docs.astar.network/docs/use/dapp-staking/ https://docs.astar.network/docs/build/dapp-staking/

https://github.com/AstarNetwork/astar-apps/tree/main/src/staking-v3

thx~! very helpful