Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet and SecretNetworkClient from "secretjs" are undefined #82

Open
noahNewton opened this issue Apr 2, 2022 · 19 comments
Open

Wallet and SecretNetworkClient from "secretjs" are undefined #82

noahNewton opened this issue Apr 2, 2022 · 19 comments
Labels
bug Something isn't working

Comments

@noahNewton
Copy link

Our react native app is trying to import the Wallet class and SecretNetworkClient class and use them to make a transaction as per this documentation: https://secretjs.scrt.network/#broadcasting-transactions

The error I am getting is "TypeError: Cannot read properties of undefined (reading 'Wallet')" when I try to instantiate the object using our mnemonic or when using your mnemonic in the aforementioned documentation.

It is very strange because when I hover over "Wallet" in VScode it will display the comment and @params that are present in your secretjs/dist/wallet_*.js/ts files as if it is indeed imported and is defined.. so perhaps there is an issue in your inheritance model on your end?

We have version ^1.2.0-beta.58 installed

Let me know if you need any more information, thanks in advance for taking a look into this!

@assafmo
Copy link
Member

assafmo commented Apr 3, 2022

Hi, can you share a repo for me to play with or a code example?

@noahNewton
Copy link
Author

noahNewton commented Apr 3, 2022

Hi, can you share a repo for me to play with or a code example?

Unfortunately I cannot because it's a proprietary repo, but there is a new error, all I am doing is following the simple code example here: https://github.com/scrtlabs/secret.js#sending-queries

This code:
`import { SecretNetworkClient } from "secretjs";

// To create a readonly secret.js client, just pass in a gRPC-web endpoint
const secretjs = await SecretNetworkClient.create({
grpcWebUrl: "https://grpc-web.azure-api.net",
chainId: "secret-4",
});

const {
balance: { amount },
} = await secretjs.query.bank.balance({
address: "secret1ap26qrlp8mcq2pg6r47w43l0y8zkqm8a450s03",
denom: "uscrt",
});

console.log(I have ${amount / 1e6} SCRT!);`

Is throwing this error:
Error: Requiring module "node_modules/secretjs/dist/browser.js", which threw an exception: TypeError: Cannot convert a BigInt value to a number

@assafmo
Copy link
Member

assafmo commented Apr 4, 2022

Can you try converting amount / 1e6 into Number(amount) / 1e6?

@noahNewton
Copy link
Author

I tried that but it doesn't help because the issue is importing, the error thrown is:

Error: Requiring module "node_modules/secretjs/dist/browser.js", which threw an exception: TypeError: Cannot convert a BigInt value to a number

Which I believe is an error in a file on your end where there is an attempt to convert a BitInt to a Number

@assafmo
Copy link
Member

assafmo commented Apr 4, 2022

How are you running/compiling this? Using webpack/esbuild/vite? What version of node.js?

@assafmo
Copy link
Member

assafmo commented Apr 4, 2022

Can I get access to the code if I sign an NDA? This seems like an issue with secret.js and I want to iterate faster to solve it.

@noahNewton
Copy link
Author

How are you running/compiling this? Using webpack/esbuild/vite? What version of node.js?

It's a react-native app, so we're doing rn-nodeify in order to get some other dependencies to work, and it's interesting that secretjs 0.17.5 works, just not the latest version, but we want the latest version.

Can I get access to the code if I sign an NDA? This seems like an issue with secret.js and I want to iterate faster to solve it.

I will ask the team lead, or maybe we can coordinate a screenshare session or something

@assafmo
Copy link
Member

assafmo commented Apr 5, 2022

Can you help me set up an empty project? Just to try and reproduce this on my machine.

@noahNewton
Copy link
Author

Can you help me set up an empty project? Just to try and reproduce this on my machine.

Hi Assaf, thanks for your attentiveness to my issue, I really appreciate it.

I've set up a barebones react-native project, and all I did was install the latest version of secretjs and try to do the example in the docs, the code for this can be found here: https://github.com/noahNewton/rn-secretjs-test

I am still faced with the same error: "TypeError: Conversion from 'BigInt' to 'number' is not allowed."

@assafmo
Copy link
Member

assafmo commented Apr 6, 2022

Mmmm it just works for me... What version of node.js are you using?

image

@noahNewton
Copy link
Author

noahNewton commented Apr 6, 2022

Mmmm it just works for me... What version of node.js are you using?

My machine is running node version v16.13.2 and the project is react-native-cli v2.0.1 and react-native 0.67.3

This is very strange, is it possible the Xcode/iOS simulator could be causing this issue? Because it looks like the above is not using react-native?

@noahNewton
Copy link
Author

noahNewton commented Apr 6, 2022

What is your environment like? Node version? Can you try running it in the xcode ios simulator?

@assafmo
Copy link
Member

assafmo commented Apr 6, 2022

I'll try, I don't have xcode but I think I have a lead

@noahNewton
Copy link
Author

Any update @assafmo? Or need any more info?

@assafmo
Copy link
Member

assafmo commented Apr 11, 2022

Hi, can you try to use secretjs@1.2.0-beta.66?

@noahNewton
Copy link
Author

Hi Assaf, sorry for the late response, I have installed version 1.2.0-beta.66 and it appears SecretJS is still not working for ios, same error as before as you can see in the screenshot:

Screen Shot 2022-04-28 at 7 02 49 AM

@assafmo assafmo added the bug Something isn't working label May 1, 2022
assafmo added a commit that referenced this issue Jun 6, 2022
To try to solve the ** -> Math.pow() conversion error

#87
#82
@assafmo
Copy link
Member

assafmo commented Jun 6, 2022

Hi, can you please try secretjs@1.3.0-beta.4?

@noahNewton
Copy link
Author

Screen Shot 2022-06-06 at 6 29 36 AM

Screen Shot 2022-06-06 at 6 29 56 AM

Hi Assaf, does not appear to have been fixed with the latest version. Please see the screenshots of the errors

@assafmo
Copy link
Member

assafmo commented Dec 18, 2022

v1.5 now supports react-native, please check this out https://github.com/scrtlabs/react-native-secretjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants