-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
react-native app crash -> ethers.Wallet.createRandom({locale:'ko'}) #1298
Comments
You need to pass in the actual wordlist, not the string Also make sure you have followed https://docs.ethers.io/v5/cookbook/react-native/ for setting up the rng. |
Actually, I think strings are fine. But only if the wordlist is included. How are you importing the library? Can you try |
i try this its work!
but its not working and the app is terminated.
i think app crashed here
|
Can you please include the output of the if (ethers.wordlists.ko == null) {
console.log("No Korean Wordlist", Object.keys(ethers.wordlists));
} else {
try {
const wallet = ethers.Wallet.createRandom({ locale: ethers.wordlists.ko });
console.log("Mnemonic", wallet, wallet.mnemonic);
} catch (error) {
console.log("Error", error);
}
} Please include all the output. :) |
i include u r codes
result no console.log and just app is terminated. What am I missing? |
Can you add a stack trace to the |
Did you ever solve this issue? |
We haven't solved it yet, and we are just using the English mnemonic code. And the app just quits without being able to check the console.log. |
How can the Korean mnemonic code work properly? Do you have an idea? If an error appeared on the console, it would have been informed immediately, but the error did not appear on the console, and the app just crashed. |
The Korean Mnemonics (in Hangul) work fine in ethers in node: homestead> w = Wallet.createRandom({ locale: "ko" })
Wallet { address: '0x6297b8bF8857EA882f2090D4fd072B20C9C89266', }
homestead> w.mnemonic
{
phrase: '적당히 갈증 근본 필자 관리 보통 편지 강사 위협 적응 자존심 인구',
path: "m/44'/60'/0'/0/0",
locale: 'ko'
}
homestead> m = '적당히 갈증 근본 필자 관리 보통 편지 강사 위협 적응 자존심 인구'
homestead> w2 = Wallet.fromMnemonic(m, null, ethers.wordlists.ko)
Wallet { address: '0x6297b8bF8857EA882f2090D4fd072B20C9C89266', }
homestead> w2.mnemonic
{
phrase: '적당히 갈증 근본 필자 관리 보통 편지 강사 위협 적응 자존심 인구',
path: "m/44'/60'/0'/0/0",
locale: 'ko'
}
homestead> w2.mnemonic.phrase == w.mnemonic.phrase
true The test cases (which include Korean) also execute in ReactNative during the CI, which generate Korean mnemonics and compare them against known test vectors. The tests are in the iOS simulator. What platform is this on? Have you tried other platforms (iOS vs Android)? Could there be something else about your configuration? Does your platform work in general on the Hangul character set? For example, does this work: console.log("한글");
console.log("한글".normalize("NFKD")); |
I also confirmed that Node has been working well, but when I worked on the actual Android device, the app was dying. And in the previous comment, only the console you gave up, and the same symptoms have been shown.
So I have the information I found. I found the issue in StackOverflow above. Can I resolve the issue in ethers.js? |
That’s strange. The shims test the normalize functionality and should automatically inject unorm if they fail. Can you try one more thing: |
Oh! Also, |
i try this
i used unorm and try again
|
Can u change automatically inject unorm code ?? I want to change this issue and i waiting for you |
The ethers shims do automatically inject the unorm code, which is why I'm confused why it isn't for you. What if you inject the unorm code yourself, before importing the ethers shims? The fact it doesn't mention the Does this cause your app to crash: |
There( and i dont know and |
Ok. That gives me an idea on how to fix this. I will try getting a new shims out this week. Thanks for your help and I’ll let you know soon. |
I've made a change in 5.1.1 that should help. Can you try it out and let me know? |
Hey @gruming, did you get a chance to try |
I am also facing same issue the UI get frozen on fromMnemonic function and it takes around 10 seconds. but when debugger is on it takes just a sec to run the function. please help. |
@s-jain-cognam What version are you using? |
Is the app crashing, or just taking a long time to compute? |
"@ethersproject/shims": "^5.3.0", |
Taking long time to load function... so ui get frozen cause function is syncronus i guess. |
There is an issue with React when performing certain cryptographic operations. I’m not certain, but believe in this case it is the sha2-512. It’s strange because it’s not all that intensive of an algorithm. You mean it runs faster when the debugger is active? I have usually seen things are much faster in RN and browsers with the debugger off. Does the debugger run the JavaScriptCore engine in a different context? Similar to Nitro on iOS? I don’t really have any way to reproduce it, but if you can isolate which operation is being slow, I might be able to provide more context. |
Ohh thank you but i think have figured it out since wallet creation uses scrypt algo, which is a memory and CPU intensive algorithm which computes a key (fixed-length pseudo-random series of bytes) for a given password. since my android is low end device so function uses all of ram and frezzes ui completely. but when i connect debugger and see task manager ram of rn-debugger it get from 0 to 20% when this function run. since it have 16gb ram so it get executed very fast. i can see it in task manager . |
Ah yes. That would be your bottleneck. Scrypt is intentionally slow. If you use my implementation of scrypt, (scrypt-js) it may be a bit slower, but is designed to not block the UI, as it operates as a co-routine, providing event loop operations during each salsa/chacha round. :) |
Yes but it is freezing UI somehow. |
This library is freezing your UI? Maybe I need to make the rounds configurable. |
Yes i guess. |
Hello again, this mnemonicToSeed which uses pbkdf2 and takes around 10 second to user access wallet when he have passwords for security perpose obviously. but when i create a wallet and connect it to provider. this function runs 3 time which increases time 10 to 30 seconds. why is that? couldn't it converted to one time run from create wallet to connect to provider. |
The issue with the Korean (Hangul) wordlists is unfortunately not something that can be solved on Android with broken implementations of normalize. There is no safe way to even detect the issue, since I'm closing this now, and hopefully the user base on platforms still using the broken String implementation on Android dwindles. This issue is over a year old, so maybe it already has. :) |
Hi
Thanks for making the library
I am developing a wallet and I want to use the mnemonic code in Korean, but it works well in debug mode, but when I exit the debug mode, the app is terminated.
its work !
const wallet = ethers.Wallet.createRandom({locale:'en'});
but its not working...
const wallet = ethers.Wallet.createRandom({locale:'ko'});
What can I do to prevent the app from crashing?
Any help would be thanks.
English used Google Translate.
Thanks
The text was updated successfully, but these errors were encountered: