diff --git a/.yarn/patches/@rabby-wallet-eth-hd-keyring-npm-4.3.1-a1d8bbe289.patch b/.yarn/patches/@rabby-wallet-eth-hd-keyring-npm-4.3.1-a1d8bbe289.patch new file mode 100644 index 000000000..6312dfd52 --- /dev/null +++ b/.yarn/patches/@rabby-wallet-eth-hd-keyring-npm-4.3.1-a1d8bbe289.patch @@ -0,0 +1,41 @@ +diff --git a/dist/index.js b/dist/index.js +index fd317674caba8bba044ea5fd24c8a67fad859ad8..799ca9a154f06d558383e9f2537216d33d418f17 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -2371,8 +2371,7 @@ __export(eth_hd_keyring_exports, { + module.exports = __toCommonJS(eth_hd_keyring_exports); + var import_hdkey = require("ethereum-cryptography/hdkey"); + var import_eth_simple_keyring = __toESM(require("@rabby-wallet/eth-simple-keyring")); +-var bip39 = __toESM(require("@scure/bip39")); +-var import_english = require("@scure/bip39/wordlists/english"); ++var bip39 = __toESM(require("react-native-quick-bip39")); + var sigUtil = __toESM(require("eth-sig-util")); + var import_util = require("@ethereumjs/util"); + var import_slip39 = __toESM(require_slip392()); +@@ -2469,7 +2468,7 @@ var _HdKeyring = class _HdKeyring extends import_eth_simple_keyring.default { + } + addAccounts(numberOfAccounts = 1) { + if (!this.hdWallet) { +- this.initFromMnemonic(bip39.generateMnemonic(import_english.wordlist)); ++ this.initFromMnemonic(bip39.generateMnemonic()); + } + let count = numberOfAccounts; + let currentIdx = 0; +@@ -2612,7 +2611,7 @@ var _HdKeyring = class _HdKeyring extends import_eth_simple_keyring.default { + return (0, import_util.bytesToHex)((0, import_util.publicToAddress)(publicKey, true)).toLowerCase(); + } + generateMnemonic() { +- return bip39.generateMnemonic(import_english.wordlist); ++ return bip39.generateMnemonic(); + } + setHdPath(hdPath = HD_PATH_BASE["BIP44" /* BIP44 */]) { + this.hdPath = hdPath; +@@ -2690,7 +2689,7 @@ var _HdKeyring = class _HdKeyring extends import_eth_simple_keyring.default { + if (this.checkMnemonicIsSlip39(mnemonic)) { + return true; + } +- return bip39.validateMnemonic(mnemonic, import_english.wordlist); ++ return bip39.validateMnemonic(mnemonic, bip39.wordlists.english); + } + }; + _HdKeyring.type = type; diff --git a/apps/mobile/android/link-assets-manifest.json b/apps/mobile/android/link-assets-manifest.json index df30dd03b..469c51bf9 100644 --- a/apps/mobile/android/link-assets-manifest.json +++ b/apps/mobile/android/link-assets-manifest.json @@ -19,7 +19,7 @@ }, { "path": "assets/custom/InpageBridgeWeb3.js", - "sha1": "7488a411403159ead535e585a76bf5da4dac79c1" + "sha1": "d3bd4ca5ffb5ac158be3e14858e683c17c9ce3bd" }, { "path": "assets/custom/vconsole.min.js", diff --git a/apps/mobile/ios/Podfile.lock b/apps/mobile/ios/Podfile.lock index 8dfeb07de..250ee02b2 100644 --- a/apps/mobile/ios/Podfile.lock +++ b/apps/mobile/ios/Podfile.lock @@ -132,6 +132,7 @@ PODS: - nanopb/encode (= 2.30909.1) - nanopb/decode (2.30909.1) - nanopb/encode (2.30909.1) + - OpenSSL-Universal (3.3.2000) - PromisesObjC (2.3.1) - RCT-Folly (2021.07.22.00): - boost @@ -464,6 +465,11 @@ PODS: - react-native-pager-view (6.2.3): - RCT-Folly (= 2021.07.22.00) - React-Core + - react-native-quick-crypto (0.7.10): + - OpenSSL-Universal + - RCT-Folly (= 2021.07.22.00) + - React + - React-Core - react-native-randombytes (3.6.1): - React-Core - react-native-safe-area-context (4.8.2): @@ -703,6 +709,7 @@ DEPENDENCIES: - react-native-mmkv (from `../node_modules/react-native-mmkv`) - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" - react-native-pager-view (from `../node_modules/react-native-pager-view`) + - react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`) - react-native-randombytes (from `../node_modules/react-native-randombytes`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) - react-native-splash-screen (from `../node_modules/react-native-splash-screen`) @@ -771,6 +778,7 @@ SPEC REPOS: - MMKVCore - MultiplatformBleAdapter - nanopb + - OpenSSL-Universal - PromisesObjC - SDWebImage - SDWebImageWebPCoder @@ -849,6 +857,8 @@ EXTERNAL SOURCES: :path: "../node_modules/@react-native-community/netinfo" react-native-pager-view: :path: "../node_modules/react-native-pager-view" + react-native-quick-crypto: + :path: "../node_modules/react-native-quick-crypto" react-native-randombytes: :path: "../node_modules/react-native-randombytes" react-native-safe-area-context: @@ -970,6 +980,7 @@ SPEC CHECKSUMS: MMKVCore: 9e2e5fd529b64a9fe15f1a7afb3d73b2e27b4db9 MultiplatformBleAdapter: b1fddd0d499b96b607e00f0faa8e60648343dc1d nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5 + OpenSSL-Universal: b60a3702c9fea8b3145549d421fdb018e53ab7b4 PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: 83bca1c184feb4d2e51c72c8369b83d641443f95 @@ -998,6 +1009,7 @@ SPEC CHECKSUMS: react-native-mmkv: 436ee510dcc43b58a49d7be0451f285e06a9fd1d react-native-netinfo: 8a7fd3f7130ef4ad2fb4276d5c9f8d3f28d2df3d react-native-pager-view: cf96a223846458cc7e932017636b5c6d8cc2c549 + react-native-quick-crypto: 64b9662703b8613b41d909fdc85ff79552d21fde react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846 react-native-safe-area-context: 0ee144a6170530ccc37a0fd9388e28d06f516a89 react-native-splash-screen: 4312f786b13a81b5169ef346d76d33bc0c6dc457 diff --git a/apps/mobile/ios/RabbyMobile.xcodeproj/project.pbxproj b/apps/mobile/ios/RabbyMobile.xcodeproj/project.pbxproj index 74cf90018..d3291040f 100644 --- a/apps/mobile/ios/RabbyMobile.xcodeproj/project.pbxproj +++ b/apps/mobile/ios/RabbyMobile.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 00E356F31AD99517003FC87E /* RabbyMobileTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* RabbyMobileTests.m */; }; - 013F94F32CF58D7B00CD67A4 /* InpageBridgeWeb3.js in Resources */ = {isa = PBXBuildFile; fileRef = 013F94F22CF58D7B00CD67A4 /* InpageBridgeWeb3.js */; }; 014102622BF348FE00629679 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 014102612BF348FE00629679 /* PrivacyInfo.xcprivacy */; }; 01BBE0162C3879380033D12B /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = 01BBE0122C3879380033D12B /* UIImage+ImageEffects.m */; }; 01BBE0172C3879380033D12B /* RNScreenshotPrevent.m in Sources */ = {isa = PBXBuildFile; fileRef = 01BBE0132C3879380033D12B /* RNScreenshotPrevent.m */; }; @@ -23,6 +22,7 @@ 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 3FB3928D597B4F3786F9EF3F /* vconsole.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 821CAA7F3D014D818B010EC1 /* vconsole.min.js */; }; + 422E2D11FE504BBDAB378000 /* InpageBridgeWeb3.js in Resources */ = {isa = PBXBuildFile; fileRef = CA1EB923E7E64222ADF0E902 /* InpageBridgeWeb3.js */; }; 5497879220EF4D48850C0543 /* SF-Pro-Rounded-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 48A3C610244545BBA590D079 /* SF-Pro-Rounded-Regular.otf */; }; 61119C058F0C8F2FBCC8530A /* Pods_RabbyMobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA3D14902716EB42CC78905B /* Pods_RabbyMobile.framework */; }; 62F658AD5D35470FBE7DF799 /* SF-Pro-Rounded-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 5B9880A4659D4B78872720D4 /* SF-Pro-Rounded-Bold.otf */; }; @@ -46,7 +46,6 @@ 00E356EE1AD99517003FC87E /* RabbyMobileTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RabbyMobileTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 00E356F21AD99517003FC87E /* RabbyMobileTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RabbyMobileTests.m; sourceTree = ""; }; - 013F94F22CF58D7B00CD67A4 /* InpageBridgeWeb3.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = InpageBridgeWeb3.js; path = ../assets/custom/InpageBridgeWeb3.js; sourceTree = ""; }; 014102612BF348FE00629679 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 01BBE0122C3879380033D12B /* UIImage+ImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+ImageEffects.m"; path = "RabbyMobile/UIImage+ImageEffects.m"; sourceTree = ""; }; 01BBE0132C3879380033D12B /* RNScreenshotPrevent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNScreenshotPrevent.m; path = RabbyMobile/RNScreenshotPrevent.m; sourceTree = ""; }; @@ -77,6 +76,7 @@ A4836FAFC22B499AAA2E435D /* SF-Pro-Rounded-Medium.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "SF-Pro-Rounded-Medium.otf"; path = "../assets/fonts/SF-Pro-Rounded-Medium.otf"; sourceTree = ""; }; A8D4D12C2C7EFDA1002B827D /* RabbyMobile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = RabbyMobile.entitlements; path = RabbyMobile/RabbyMobile.entitlements; sourceTree = ""; }; ACB2DE2C2B72015F00A5516C /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + CA1EB923E7E64222ADF0E902 /* InpageBridgeWeb3.js */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = InpageBridgeWeb3.js; path = ../assets/custom/InpageBridgeWeb3.js; sourceTree = ""; }; CA3D14902716EB42CC78905B /* Pods_RabbyMobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RabbyMobile.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EAEC992AC950B3ACACBDE0F2 /* Pods_RabbyMobile_RabbyMobileTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RabbyMobile_RabbyMobileTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; @@ -204,12 +204,12 @@ D0CA49A24C31446D8C53F168 /* Resources */ = { isa = PBXGroup; children = ( - 013F94F22CF58D7B00CD67A4 /* InpageBridgeWeb3.js */, 821CAA7F3D014D818B010EC1 /* vconsole.min.js */, 5B9880A4659D4B78872720D4 /* SF-Pro-Rounded-Bold.otf */, F13B8F76DB574CA1A0D00501 /* SF-Pro-Rounded-Heavy.otf */, A4836FAFC22B499AAA2E435D /* SF-Pro-Rounded-Medium.otf */, 48A3C610244545BBA590D079 /* SF-Pro-Rounded-Regular.otf */, + CA1EB923E7E64222ADF0E902 /* InpageBridgeWeb3.js */, ); name = Resources; sourceTree = ""; @@ -311,7 +311,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 013F94F32CF58D7B00CD67A4 /* InpageBridgeWeb3.js in Resources */, 01E584B62C370990007F3280 /* LaunchScreen.xib in Resources */, 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 014102622BF348FE00629679 /* PrivacyInfo.xcprivacy in Resources */, @@ -323,6 +322,7 @@ E576F98C62E44D04A874C8B7 /* SF-Pro-Rounded-Heavy.otf in Resources */, 0FDFDF1FBA404AB3A3E6ECCA /* SF-Pro-Rounded-Medium.otf in Resources */, 5497879220EF4D48850C0543 /* SF-Pro-Rounded-Regular.otf in Resources */, + 422E2D11FE504BBDAB378000 /* InpageBridgeWeb3.js in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/apps/mobile/ios/RabbyMobile/Info.plist b/apps/mobile/ios/RabbyMobile/Info.plist index abff1895e..46c6db749 100644 --- a/apps/mobile/ios/RabbyMobile/Info.plist +++ b/apps/mobile/ios/RabbyMobile/Info.plist @@ -36,7 +36,7 @@ CFBundleVersion $(CURRENT_PROJECT_VERSION) ITSAppUsesNonExemptEncryption - + LSApplicationQueriesSchemes imtokenv2 @@ -53,7 +53,7 @@ debank LSRequiresIPhoneOS - + NSAppTransportSecurity NSExceptionDomains @@ -61,7 +61,7 @@ localhost NSExceptionAllowsInsecureHTTPLoads - + @@ -74,7 +74,7 @@ NSFaceIDUsageDescription $(PRODUCT_NAME) needs to authenticate NSLocationWhenInUseUsageDescription - + NSMicrophoneUsageDescription Rabby needs microphone access to record audio UIAppFonts @@ -103,7 +103,7 @@ UIUserInterfaceStyle Automatic UIViewControllerBasedStatusBarAppearance - + rabbit_code $(RABBY_MOBILE_CODE) diff --git a/apps/mobile/ios/link-assets-manifest.json b/apps/mobile/ios/link-assets-manifest.json index df30dd03b..469c51bf9 100644 --- a/apps/mobile/ios/link-assets-manifest.json +++ b/apps/mobile/ios/link-assets-manifest.json @@ -19,7 +19,7 @@ }, { "path": "assets/custom/InpageBridgeWeb3.js", - "sha1": "7488a411403159ead535e585a76bf5da4dac79c1" + "sha1": "d3bd4ca5ffb5ac158be3e14858e683c17c9ce3bd" }, { "path": "assets/custom/vconsole.min.js", diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 96a8b9488..08783dcdb 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -87,7 +87,6 @@ "@rematch/core": "^2.2.0", "@rneui/base": "^4.0.0-rc.8", "@rneui/themed": "^4.0.0-rc.8", - "@scure/bip39": "^1.3.0", "@sentry/react-native": "5.31.0", "@types/highlight-words-core": "1.2.3", "@types/lodash.debounce": "^4.0.9", @@ -152,6 +151,8 @@ "react-native-pager-view": "^6.2.3", "react-native-permissions": "^4.1.2", "react-native-qrcode-svg": "^6.2.0", + "react-native-quick-bip39": "0.0.9", + "react-native-quick-crypto": "0.7.10", "react-native-randombytes": "^3.6.1", "react-native-reanimated": "^3.6.1", "react-native-root-toast": "^3.5.1", diff --git a/apps/mobile/src/core/utils/mnemonic.ts b/apps/mobile/src/core/utils/mnemonic.ts index 346eed204..e860b6b94 100644 --- a/apps/mobile/src/core/utils/mnemonic.ts +++ b/apps/mobile/src/core/utils/mnemonic.ts @@ -1,4 +1,4 @@ -import * as bip39 from '@scure/bip39'; +import * as bip39 from 'react-native-quick-bip39'; import { HDKey } from 'ethereum-cryptography/hdkey'; import * as sigUtil from 'eth-sig-util'; import { bytesToHex, publicToAddress, privateToPublic } from '@ethereumjs/util'; diff --git a/apps/mobile/src/screens/Address/ImportSeedPhraseScreen.tsx b/apps/mobile/src/screens/Address/ImportSeedPhraseScreen.tsx index b076bcf49..3d0dff091 100644 --- a/apps/mobile/src/screens/Address/ImportSeedPhraseScreen.tsx +++ b/apps/mobile/src/screens/Address/ImportSeedPhraseScreen.tsx @@ -15,8 +15,7 @@ import { useScanner } from '../Scanner/ScannerScreen'; import { requestKeyring } from '@/core/apis/keyring'; import { toast } from '@/components/Toast'; import { useFocusEffect } from '@react-navigation/native'; -import { wordlist } from '@scure/bip39/wordlists/english'; -import * as bip39 from '@scure/bip39'; +import * as bip39 from 'react-native-quick-bip39'; const getStyles = (colors: AppColorsVariants) => StyleSheet.create({ @@ -112,13 +111,13 @@ export const ImportSeedPhraseScreen = () => { }); } else { try { - bip39.mnemonicToEntropy(mnemonics?.trim(), wordlist); + bip39.mnemonicToEntropy(mnemonics?.trim(), bip39.wordlists.english); } catch (e) { if ((e as any).message.includes('Unknown letter:')) { let errorWords: string[] = []; mnemonics.split(/\s+/).forEach(word => { let v = word?.trim(); - if (v && !wordlist.includes(v)) { + if (v && !bip39.wordlists.english.includes(v)) { errorWords.push(v); } }); diff --git a/apps/mobile/src/screens/Address/ImportSeedPhraseScreen2024.tsx b/apps/mobile/src/screens/Address/ImportSeedPhraseScreen2024.tsx index 4d1aa76a6..7bf86758c 100644 --- a/apps/mobile/src/screens/Address/ImportSeedPhraseScreen2024.tsx +++ b/apps/mobile/src/screens/Address/ImportSeedPhraseScreen2024.tsx @@ -11,8 +11,7 @@ import { useScanner } from '../Scanner/ScannerScreen'; import { requestKeyring } from '@/core/apis/keyring'; import { toast } from '@/components2024/Toast'; import { useFocusEffect } from '@react-navigation/native'; -import { wordlist } from '@scure/bip39/wordlists/english'; -import * as bip39 from '@scure/bip39'; +import * as bip39 from 'react-native-quick-bip39'; import PasteButton from '@/components2024/PasteButton'; import { NextInput } from '@/components2024/Form/Input'; import { createGetStyles2024, makeDebugBorder } from '@/utils/styles'; @@ -192,13 +191,13 @@ export const ImportSeedPhraseScreen2024 = () => { }); } else { try { - bip39.mnemonicToEntropy(mnemonics?.trim(), wordlist); + bip39.mnemonicToEntropy(mnemonics?.trim(), bip39.wordlists.english); } catch (e) { if ((e as any).message.includes('Unknown letter:')) { let errorWords: string[] = []; mnemonics.split(/\s+/).forEach(word => { let v = word?.trim(); - if (v && !wordlist.includes(v)) { + if (v && !bip39.wordlists.english.includes(v)) { errorWords.push(v); } }); diff --git a/package.json b/package.json index a9a4abcf6..17fa2975f 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,31 @@ "yarn workspace dev-console-cra lint:commit:fix" ] }, + "resolutions": { + "@debank/common@0.3.58": "patch:@debank/common@npm%3A0.3.58#./.yarn/patches/@debank-common-npm-0.3.58-0aa25cb07b.patch", + "@debank/common@^0.3.54": "patch:@debank/common@npm%3A0.3.58#./.yarn/patches/@debank-common-npm-0.3.58-0aa25cb07b.patch", + "@keystonehq/bc-ur-registry@^0.5.0-alpha.4": "patch:@keystonehq/bc-ur-registry@npm%3A0.6.4#./.yarn/patches/@keystonehq-bc-ur-registry-npm-0.6.4-7922ce4e4c.patch", + "@keystonehq/bc-ur-registry@^0.6.0": "patch:@keystonehq/bc-ur-registry@npm%3A0.6.4#./.yarn/patches/@keystonehq-bc-ur-registry-npm-0.6.4-7922ce4e4c.patch", + "@ledgerhq/hw-app-eth@^6.40.0": "patch:@ledgerhq/hw-app-eth@npm%3A6.40.2#./.yarn/patches/@ledgerhq-hw-app-eth-npm-6.40.2-ffdc4add8c.patch", + "@ledgerhq/hw-transport@^6.31.4": "patch:@ledgerhq/hw-transport@npm%3A6.31.4#./.yarn/patches/@ledgerhq-hw-transport-npm-6.31.4-b439e9a1f8.patch", + "@metamask/eth-sig-util@5.1.0": "patch:@metamask/eth-sig-util@npm%3A5.1.0#./.yarn/patches/@metamask-eth-sig-util-npm-5.1.0-fb33750b27.patch", + "@metamask/eth-sig-util@^4.0.0": "patch:@metamask/eth-sig-util@npm%3A5.1.0#./.yarn/patches/@metamask-eth-sig-util-npm-5.1.0-fb33750b27.patch", + "@metamask/eth-sig-util@^5.0.0": "patch:@metamask/eth-sig-util@npm%3A5.1.0#./.yarn/patches/@metamask-eth-sig-util-npm-5.1.0-fb33750b27.patch", + "@onekeyfe/hd-transport-react-native@^1.0.10": "patch:@onekeyfe/hd-transport-react-native@npm%3A1.0.10#./.yarn/patches/@onekeyfe-hd-transport-react-native-npm-1.0.10-09c8057879.patch", + "@rabby-wallet/rabby-api@0.7.25": "patch:@rabby-wallet/rabby-api@npm%3A0.8.5#./.yarn/patches/@rabby-wallet-rabby-api-npm-0.8.5-b09d6e3f2f.patch", + "@rabby-wallet/rabby-api@0.8.5": "patch:@rabby-wallet/rabby-api@npm%3A0.8.5#./.yarn/patches/@rabby-wallet-rabby-api-npm-0.8.5-b09d6e3f2f.patch", + "@react-native-menu/menu@1.1.3": "patch:@react-native-menu/menu@npm%3A1.1.3#./.yarn/patches/@react-native-menu-menu-npm-1.1.3-6b0ecb2e6c.patch", + "eth-rpc-errors@^4.0.2": "patch:eth-rpc-errors@npm%3A4.0.3#./.yarn/patches/eth-rpc-errors-npm-4.0.3-d154190eb6.patch", + "eth-rpc-errors@^4.0.3": "patch:eth-rpc-errors@npm%3A4.0.3#./.yarn/patches/eth-rpc-errors-npm-4.0.3-d154190eb6.patch", + "nativewind@^2.0.11": "patch:nativewind@npm%3A2.0.11#./.yarn/patches/nativewind-npm-2.0.11-dc2ccf9fb5.patch", + "react-native-fs@^2.20.0": "patch:react-native-fs@npm%3A2.20.0#./.yarn/patches/react-native-fs-npm-2.20.0-a38fe24051.patch", + "react-native-keychain@8.0.0": "patch:react-native-keychain@npm%3A8.0.0#./.yarn/patches/react-native-keychain-npm-8.0.0-22c1f5c020.patch", + "react-native-mmkv@^2.12.2": "patch:react-native-mmkv@npm%3A2.12.2#./.yarn/patches/react-native-mmkv-npm-2.12.2-9efa7abf70.patch", + "react-native-webview@13.10.5": "patch:react-native-webview@npm%3A13.10.5#./.yarn/patches/react-native-webview-npm-13.10.5-714eb41569.patch", + "react-use@17.4.2": "patch:react-use@npm%3A17.4.2#./.yarn/patches/react-use-npm-17.4.2-d0e8220eaa.patch", + "zeego@1.10.0": "patch:zeego@npm%3A1.10.0#./.yarn/patches/zeego-npm-1.10.0-1958a3ea63.patch", + "@rabby-wallet/eth-hd-keyring@4.3.1": "patch:@rabby-wallet/eth-hd-keyring@npm%3A4.3.1#./.yarn/patches/@rabby-wallet-eth-hd-keyring-npm-4.3.1-a1d8bbe289.patch" + }, "dependencies": { "@babel/runtime": "^7.20.0", "@debank/common": "^0.3.54", @@ -110,29 +135,5 @@ "ethereumjs-util>ethereum-cryptography>secp256k1": true, "simple-git-hooks": false } - }, - "resolutions": { - "@debank/common@^0.3.54": "patch:@debank/common@npm%3A0.3.58#./.yarn/patches/@debank-common-npm-0.3.58-0aa25cb07b.patch", - "@debank/common@0.3.58": "patch:@debank/common@npm%3A0.3.58#./.yarn/patches/@debank-common-npm-0.3.58-0aa25cb07b.patch", - "@metamask/eth-sig-util@5.1.0": "patch:@metamask/eth-sig-util@npm%3A5.1.0#./.yarn/patches/@metamask-eth-sig-util-npm-5.1.0-fb33750b27.patch", - "@metamask/eth-sig-util@^4.0.0": "patch:@metamask/eth-sig-util@npm%3A5.1.0#./.yarn/patches/@metamask-eth-sig-util-npm-5.1.0-fb33750b27.patch", - "@metamask/eth-sig-util@^5.0.0": "patch:@metamask/eth-sig-util@npm%3A5.1.0#./.yarn/patches/@metamask-eth-sig-util-npm-5.1.0-fb33750b27.patch", - "@onekeyfe/hd-transport-react-native@^1.0.10": "patch:@onekeyfe/hd-transport-react-native@npm%3A1.0.10#./.yarn/patches/@onekeyfe-hd-transport-react-native-npm-1.0.10-09c8057879.patch", - "@rabby-wallet/rabby-api@0.7.25": "patch:@rabby-wallet/rabby-api@npm%3A0.8.5#./.yarn/patches/@rabby-wallet-rabby-api-npm-0.8.5-b09d6e3f2f.patch", - "@rabby-wallet/rabby-api@0.8.5": "patch:@rabby-wallet/rabby-api@npm%3A0.8.5#./.yarn/patches/@rabby-wallet-rabby-api-npm-0.8.5-b09d6e3f2f.patch", - "@react-native-menu/menu@1.1.3": "patch:@react-native-menu/menu@npm%3A1.1.3#./.yarn/patches/@react-native-menu-menu-npm-1.1.3-6b0ecb2e6c.patch", - "eth-rpc-errors@^4.0.3": "patch:eth-rpc-errors@npm%3A4.0.3#./.yarn/patches/eth-rpc-errors-npm-4.0.3-d154190eb6.patch", - "eth-rpc-errors@^4.0.2": "patch:eth-rpc-errors@npm%3A4.0.3#./.yarn/patches/eth-rpc-errors-npm-4.0.3-d154190eb6.patch", - "nativewind@^2.0.11": "patch:nativewind@npm%3A2.0.11#./.yarn/patches/nativewind-npm-2.0.11-dc2ccf9fb5.patch", - "react-native-fs@^2.20.0": "patch:react-native-fs@npm%3A2.20.0#./.yarn/patches/react-native-fs-npm-2.20.0-a38fe24051.patch", - "react-native-keychain@8.0.0": "patch:react-native-keychain@npm%3A8.0.0#./.yarn/patches/react-native-keychain-npm-8.0.0-22c1f5c020.patch", - "react-native-mmkv@^2.12.2": "patch:react-native-mmkv@npm%3A2.12.2#./.yarn/patches/react-native-mmkv-npm-2.12.2-9efa7abf70.patch", - "react-native-webview@13.10.5": "patch:react-native-webview@npm%3A13.10.5#./.yarn/patches/react-native-webview-npm-13.10.5-714eb41569.patch", - "react-use@17.4.2": "patch:react-use@npm%3A17.4.2#./.yarn/patches/react-use-npm-17.4.2-d0e8220eaa.patch", - "zeego@1.10.0": "patch:zeego@npm%3A1.10.0#./.yarn/patches/zeego-npm-1.10.0-1958a3ea63.patch", - "@keystonehq/bc-ur-registry@^0.6.0": "patch:@keystonehq/bc-ur-registry@npm%3A0.6.4#./.yarn/patches/@keystonehq-bc-ur-registry-npm-0.6.4-7922ce4e4c.patch", - "@keystonehq/bc-ur-registry@^0.5.0-alpha.4": "patch:@keystonehq/bc-ur-registry@npm%3A0.6.4#./.yarn/patches/@keystonehq-bc-ur-registry-npm-0.6.4-7922ce4e4c.patch", - "@ledgerhq/hw-app-eth@^6.40.0": "patch:@ledgerhq/hw-app-eth@npm%3A6.40.2#./.yarn/patches/@ledgerhq-hw-app-eth-npm-6.40.2-ffdc4add8c.patch", - "@ledgerhq/hw-transport@^6.31.4": "patch:@ledgerhq/hw-transport@npm%3A6.31.4#./.yarn/patches/@ledgerhq-hw-transport-npm-6.31.4-b439e9a1f8.patch" } } diff --git a/packages/service-keyring/package.json b/packages/service-keyring/package.json index 350729929..69cee7629 100644 --- a/packages/service-keyring/package.json +++ b/packages/service-keyring/package.json @@ -25,11 +25,11 @@ "changelog:validate": "../../scripts/validate-changelog.sh @rabby-wallet/service-keyring", "cov:report": "open ./coverage/index.html", "publish:preview": "yarn npm publish --tag preview", - "tool:decrypt": "yarn ../../ build:deps && node ./scripts/decyrptKeyringState.js", "test": "jest --reporters=jest-silent-reporter", "test:clean": "jest --clearCache", "test:verbose": "jest --verbose", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "tool:decrypt": "yarn ../../ build:deps && node ./scripts/decyrptKeyringState.js" }, "dependencies": { "@metamask/obs-store": "^9.0.0", @@ -37,10 +37,10 @@ "@rabby-wallet/eth-keyring-watch": "^0.1.0", "@rabby-wallet/keyring-utils": "workspace:^", "@rabby-wallet/service-address": "workspace:^", - "@scure/bip39": "^1.3.0", "@types/readable-stream": "^4.0.10", "ethereumjs-util": "^7.1.5", - "loglevel": "^1.8.1" + "loglevel": "^1.8.1", + "react-native-quick-bip39": "0.0.9" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.3", diff --git a/packages/service-keyring/src/global.d.ts b/packages/service-keyring/src/global.d.ts new file mode 100644 index 000000000..65f0aacb0 --- /dev/null +++ b/packages/service-keyring/src/global.d.ts @@ -0,0 +1 @@ +declare module 'react-native-quick-bip39'; diff --git a/packages/service-keyring/src/keyringService.ts b/packages/service-keyring/src/keyringService.ts index 16184d466..e5c8a2ecf 100644 --- a/packages/service-keyring/src/keyringService.ts +++ b/packages/service-keyring/src/keyringService.ts @@ -17,10 +17,9 @@ import type { KeyringTypeName, } from '@rabby-wallet/keyring-utils'; import type { ContactBookService } from '@rabby-wallet/service-address'; -import * as bip39 from '@scure/bip39'; -import { wordlist } from '@scure/bip39/wordlists/english'; import * as ethUtil from 'ethereumjs-util'; import log from 'loglevel'; +import * as bip39 from 'react-native-quick-bip39'; import type { KeyringClassType, KeyringInstance } from './types'; import { keyringSdks } from './types'; @@ -1020,7 +1019,7 @@ export class KeyringService extends RNEventEmitter { * Mnemonic Phrase */ generateMnemonic(): string { - return bip39.generateMnemonic(wordlist); + return bip39.generateMnemonic(); } async generatePreMnemonic(options?: { @@ -1067,7 +1066,7 @@ export class KeyringService extends RNEventEmitter { * @returns {Promise} A Promise that resolves to the state. */ createKeyringWithMnemonics(seed: string): Promise { - if (!bip39.validateMnemonic(seed, wordlist)) { + if (!bip39.validateMnemonic(seed, bip39.wordlists.english)) { return Promise.reject(new Error('background.error.invalidMnemonic')); } diff --git a/yarn.lock b/yarn.lock index 136373cf8..2d65a3bb1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2024,6 +2024,16 @@ __metadata: languageName: node linkType: hard +"@craftzdog/react-native-buffer@npm:^6.0.5": + version: 6.0.5 + resolution: "@craftzdog/react-native-buffer@npm:6.0.5" + dependencies: + ieee754: ^1.2.1 + react-native-quick-base64: ^2.0.5 + checksum: 921b8bc7f84778e355e81e475792399276d611a346a7e51b6266a45cf4aa82194beb3a8106af796ed143d958c8476070c59e3720c0eec0a3c31e368fbb08b350 + languageName: node + linkType: hard + "@cspotcode/source-map-support@npm:^0.8.0": version: 0.8.1 resolution: "@cspotcode/source-map-support@npm:0.8.1::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2F%40cspotcode%2Fsource-map-support%2F-%2Fsource-map-support-0.8.1.tgz" @@ -5722,7 +5732,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.3": +"@noble/hashes@npm:1.3.3, @noble/hashes@npm:~1.3.0": version: 1.3.3 resolution: "@noble/hashes@npm:1.3.3" checksum: 8a6496d1c0c64797339bc694ad06cdfaa0f9e56cd0c3f68ae3666cfb153a791a55deb0af9c653c7ed2db64d537aa3e3054629740d2f2338bb1dcb7ab60cd205b @@ -5736,13 +5746,20 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:^1.3.1, @noble/hashes@npm:~1.3.0, @noble/hashes@npm:~1.3.1, @noble/hashes@npm:~1.3.2": +"@noble/hashes@npm:^1.3.1, @noble/hashes@npm:~1.3.1, @noble/hashes@npm:~1.3.2": version: 1.3.3 resolution: "@noble/hashes@npm:1.3.3::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2F%40noble%2Fhashes%2F-%2Fhashes-1.3.3.tgz" checksum: 8a6496d1c0c64797339bc694ad06cdfaa0f9e56cd0c3f68ae3666cfb153a791a55deb0af9c653c7ed2db64d537aa3e3054629740d2f2338bb1dcb7ab60cd205b languageName: node linkType: hard +"@noble/hashes@npm:~1.6.0": + version: 1.6.1 + resolution: "@noble/hashes@npm:1.6.1" + checksum: 57c62f65ee217c0293b4321b547792aa6d79812bfe70a7d62dc83e0f936cc677b14ed981b4e88cf8fdad37cd6d3a0cbd3bd0908b0728adc9daf066e678be8901 + languageName: node + linkType: hard + "@nodelib/fs.scandir@npm:2.1.5": version: 2.1.5 resolution: "@nodelib/fs.scandir@npm:2.1.5::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2F%40nodelib%2Ffs.scandir%2F-%2Ffs.scandir-2.1.5.tgz" @@ -6153,6 +6170,21 @@ __metadata: languageName: node linkType: hard +"@rabby-wallet/eth-hd-keyring@patch:@rabby-wallet/eth-hd-keyring@npm%3A4.3.1#./.yarn/patches/@rabby-wallet-eth-hd-keyring-npm-4.3.1-a1d8bbe289.patch::locator=%40rabby-wallet%2Fmobile-monorepo%40workspace%3A.": + version: 4.3.1 + resolution: "@rabby-wallet/eth-hd-keyring@patch:@rabby-wallet/eth-hd-keyring@npm%3A4.3.1#./.yarn/patches/@rabby-wallet-eth-hd-keyring-npm-4.3.1-a1d8bbe289.patch::version=4.3.1&hash=691efc&locator=%40rabby-wallet%2Fmobile-monorepo%40workspace%3A." + dependencies: + "@ethereumjs/util": ^9.0.0 + "@metamask/eth-sig-util": ^4.0.0 + "@rabby-wallet/eth-simple-keyring": ^5.0.1 + "@scure/bip39": ^1.2.1 + eth-sig-util: ^3.0.1 + ethereum-cryptography: ^2.1.2 + slip39: ^0.1.9 + checksum: b12015b3e5e7925dc56811ae3521d4e4b88438208b1dfe3ee6ecd568576ed9261b11516fea064ec229a4bae949621851b3033346f1c92645f518fb92e5999a84 + languageName: node + linkType: hard + "@rabby-wallet/eth-keyring-gnosis@workspace:^, @rabby-wallet/eth-keyring-gnosis@workspace:packages/eth-keyring-gnosis": version: 0.0.0-use.local resolution: "@rabby-wallet/eth-keyring-gnosis@workspace:packages/eth-keyring-gnosis" @@ -6620,7 +6652,6 @@ __metadata: "@rabby-wallet/eth-keyring-watch": ^0.1.0 "@rabby-wallet/keyring-utils": "workspace:^" "@rabby-wallet/service-address": "workspace:^" - "@scure/bip39": ^1.3.0 "@types/jest": ^27.4.1 "@types/readable-stream": ^4.0.10 "@types/sinon": ^9.0.10 @@ -6629,6 +6660,7 @@ __metadata: ethereumjs-wallet: ^1.0.2 jest: ^27.5.1 loglevel: ^1.8.1 + react-native-quick-bip39: 0.0.9 sinon: ^9.2.4 ts-jest: ^27.1.4 typedoc: ^0.24.8 @@ -7947,6 +7979,13 @@ __metadata: languageName: node linkType: hard +"@scure/base@npm:~1.2.1": + version: 1.2.1 + resolution: "@scure/base@npm:1.2.1" + checksum: 061e04e4f6ed7bada6cdad4c799e6a82f30dda3f4008895bdb2e556f333f9b41f44dc067d25c064357ed6c012ea9c8be1e7927caf8a083af865b8de27b52370c + languageName: node + linkType: hard + "@scure/bip32@npm:1.3.1": version: 1.3.1 resolution: "@scure/bip32@npm:1.3.1::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2F%40scure%2Fbip32%2F-%2Fbip32-1.3.1.tgz" @@ -7993,7 +8032,7 @@ __metadata: "@scure/bip39@npm:1.2.1": version: 1.2.1 - resolution: "@scure/bip39@npm:1.2.1::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2F%40scure%2Fbip39%2F-%2Fbip39-1.2.1.tgz" + resolution: "@scure/bip39@npm:1.2.1" dependencies: "@noble/hashes": ~1.3.0 "@scure/base": ~1.1.0 @@ -8011,7 +8050,7 @@ __metadata: languageName: node linkType: hard -"@scure/bip39@npm:1.3.0, @scure/bip39@npm:^1.2.1, @scure/bip39@npm:^1.3.0": +"@scure/bip39@npm:1.3.0": version: 1.3.0 resolution: "@scure/bip39@npm:1.3.0" dependencies: @@ -8021,6 +8060,16 @@ __metadata: languageName: node linkType: hard +"@scure/bip39@npm:^1.2.1": + version: 1.5.0 + resolution: "@scure/bip39@npm:1.5.0" + dependencies: + "@noble/hashes": ~1.6.0 + "@scure/base": ~1.2.1 + checksum: 03d1888f5d0d514eebc5c3adc1e071d225963d434fcf789abea5ef2c8b4b99f3ad9ebee8a597c0c13d5415e6b2b380f55f61560c1643cd871961ab91cbcf5122 + languageName: node + linkType: hard + "@sentry-internal/feedback@npm:7.119.0": version: 7.119.0 resolution: "@sentry-internal/feedback@npm:7.119.0" @@ -27515,7 +27564,6 @@ __metadata: "@rematch/core": ^2.2.0 "@rneui/base": ^4.0.0-rc.8 "@rneui/themed": ^4.0.0-rc.8 - "@scure/bip39": ^1.3.0 "@sentry/react-native": 5.31.0 "@tsconfig/react-native": ^3.0.0 "@types/highlight-words-core": 1.2.3 @@ -27602,6 +27650,8 @@ __metadata: react-native-pager-view: ^6.2.3 react-native-permissions: ^4.1.2 react-native-qrcode-svg: ^6.2.0 + react-native-quick-bip39: 0.0.9 + react-native-quick-crypto: 0.7.10 react-native-randombytes: ^3.6.1 react-native-reanimated: ^3.6.1 react-native-root-toast: ^3.5.1 @@ -28368,6 +28418,44 @@ __metadata: languageName: node linkType: hard +"react-native-quick-base64@npm:^2.0.5": + version: 2.1.2 + resolution: "react-native-quick-base64@npm:2.1.2" + dependencies: + base64-js: ^1.5.1 + peerDependencies: + react: "*" + react-native: "*" + checksum: 46f3b26f48b26978686b0c043336220d681e6a02af5abcf3eb4ab7b9216251d1eb2fac5c559e984d963e93f54bd9f323651daac09762196815558abbd551729b + languageName: node + linkType: hard + +"react-native-quick-bip39@npm:0.0.9": + version: 0.0.9 + resolution: "react-native-quick-bip39@npm:0.0.9" + dependencies: + "@craftzdog/react-native-buffer": ^6.0.5 + react-native-quick-crypto: ^0.7.7 + checksum: 1beb61bcf124fda8d803baaee18b9ca3f8aa6cf14dc18ed168c4c5e7f75095dc0edd619fd72049b40e7456d07cd90ee611b4e2071dcbeb1bcc64a2260c47727f + languageName: node + linkType: hard + +"react-native-quick-crypto@npm:0.7.10, react-native-quick-crypto@npm:^0.7.7": + version: 0.7.10 + resolution: "react-native-quick-crypto@npm:0.7.10" + dependencies: + "@craftzdog/react-native-buffer": ^6.0.5 + events: ^3.3.0 + readable-stream: ^4.5.2 + string_decoder: ^1.3.0 + util: ^0.12.5 + peerDependencies: + react: "*" + react-native: "*" + checksum: 45d936f25434ef2ef2e78172e56bb405dac6310aabfd3a25e7ca6b4ae5cf2621b0385db67a09ad6f1cc946f12fcc3026c159d7dd9e640f051420324064312034 + languageName: node + linkType: hard + "react-native-randombytes@npm:^3.5.1, react-native-randombytes@npm:^3.6.1": version: 3.6.1 resolution: "react-native-randombytes@npm:3.6.1::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Freact-native-randombytes%2F-%2Freact-native-randombytes-3.6.1.tgz" @@ -29088,6 +29176,19 @@ __metadata: languageName: node linkType: hard +"readable-stream@npm:^4.5.2": + version: 4.5.2 + resolution: "readable-stream@npm:4.5.2" + dependencies: + abort-controller: ^3.0.0 + buffer: ^6.0.3 + events: ^3.3.0 + process: ^0.11.10 + string_decoder: ^1.3.0 + checksum: c4030ccff010b83e4f33289c535f7830190773e274b3fcb6e2541475070bdfd69c98001c3b0cb78763fc00c8b62f514d96c2b10a8bd35d5ce45203a25fa1d33a + languageName: node + linkType: hard + "readdirp@npm:^3.6.0, readdirp@npm:~3.6.0": version: 3.6.0 resolution: "readdirp@npm:3.6.0::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Freaddirp%2F-%2Freaddirp-3.6.0.tgz"