aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Bug] Can't find variable: BigInt

Open a943999733 opened this issue 2 years ago • 4 comments

🐛 Bug

Error: Requiring module "src/libs/aptos/index.js", which threw an exception: ReferenceError: Can't find variable: BigInt

To reproduce

"react-native": "0.63.3"
"aptos": "^1.3.16",
Poform: Android 

import {AptosAccount} from 'aptos/src/aptos_account';

Code snippet to reproduce

# import {AptosAccount} from 'aptos/src/aptos_account';
  if (mnemonic) {
    try {
      wallet = AptosAccount.fromDerivePath("m/44'/637'/2'/0'/0'", mnemonic);
    } catch (e) {
      console.log(e);
    }
  } else {
    const privateKeyObject = {privateKeyHex: privateKey};
    wallet = AptosAccount.fromAptosAccountObject(privateKeyObject);
  }

Stack trace/error message

ReferenceError: Can't find variable: BigInt
http://1:8081/index.bundle?platform=android&dev=true&minify=false:905780:26
loadModuleImplementation@http://:8081/index.bundle?platform=android&dev=true&minify=false:271:14
http://:8081/index.bundle?platform=android&dev=true&minify=false:905415:30
loadModuleImpleme

Expected Behavior

a943999733 avatar Oct 26 '22 10:10 a943999733

Is there a version that does not use bigInt, or is there a solution? At present, our RN version does not support it

??

a943999733 avatar Oct 26 '22 10:10 a943999733

If the browser version is low, this problem will also occur, you can refer to my previous solution to add polyfill. Add https://github.com/peterolson/BigInteger.js/blob/master/BigInteger.min.js to your html script. Then add

window.BigInt = window.BigInt && window.BigInt(1) ? window.BigInt : bigInt

Maybe it can help you

s749312025 avatar Oct 27 '22 02:10 s749312025

Instead of using the browser, we use the react-active

a943999733 avatar Oct 27 '22 02:10 a943999733

What version of RN are you using? Have you tried 0.70?

jjleng avatar Nov 07 '22 22:11 jjleng

were you able to create new AptosAccount()? using the SDK? or is it happening only importing existing wallet keys?

thegitparticle avatar Dec 14 '22 21:12 thegitparticle

closing out what looks like a stale issue

davidiw avatar Dec 24 '22 06:12 davidiw