aepp-sdk-js icon indicating copy to clipboard operation
aepp-sdk-js copied to clipboard

Make AEX-2 implementation somehow warn if used different networks

Open intnick opened this issue 5 years ago • 2 comments

Describe the bug Calling a getBalance method from my react app (via AEX2) gets a wrong balance. I have around 240Ae, and the method returns that I have 5Ae. Using Superhero wallet, latest version, on the latest Chrome on windows 10.

To Reproduce Steps to reproduce the behavior:

  1. Create an app similar to the AEX2 example in Vue
  2. Call the getBalance method on the client
  3. Verify that the given balance is not correct

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem. image

Please tell us about your environment:

  • superhero wallet v0.3.2
  • Compiler version: latest
  • SDK Version: v7.6.0

Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. forum, telegram, etc)

intnick avatar Aug 21 '20 11:08 intnick

It looks like you are connected to different networks in the wallet and in your app:

$ curl https://testnet.aeternity.io/v2/accounts/ak_2TKYxRRUdwCH2jFX9go6Se4GVbKUFvyGn4r6mVS1CbrQJ6DWds
{
  "balance":5000000000000000000,
  "id":"ak_2TKYxRRUdwCH2jFX9go6Se4GVbKUFvyGn4r6mVS1CbrQJ6DWds",
  "kind":"basic",
  "nonce":0,
  "payable":true
}
$ curl https://mainnet.aeternity.io/v2/accounts/ak_2TKYxRRUdwCH2jFX9go6Se4GVbKUFvyGn4r6mVS1CbrQJ6DWds
{
  "balance":244267945084000000000,
  "id":"ak_2TKYxRRUdwCH2jFX9go6Se4GVbKUFvyGn4r6mVS1CbrQJ6DWds",
  "kind":"basic",
  "nonce":12,
  "payable":true
}
> new BigNumber('5000000000000000000').shiftedBy(-18).toString()
"5"
> new BigNumber('244267945084000000000').shiftedBy(-18).toString()
"244.267945084"

So, I think the problem is on the side of your aepp. Though AEX-2 should prevent a such case, to investigate that would be nice to see how exactly you are using sdk.

davidyuk avatar Aug 24 '20 06:08 davidyuk

Yes, I removed the testnet from the configuration and now it works ok. Thanks for tracing the issue. I used the code from the example, where it is also specifying both testnet and mainnet so I didn't expect this type of a bug, especially since superhero wallet doesn't have the testnet network connected.

intnick avatar Aug 27 '20 14:08 intnick