diff --git a/wallets/rn_cli_wallet/ios/.xcode.env b/wallets/rn_cli_wallet/ios/.xcode.env index 055d6548..5813172d 100644 --- a/wallets/rn_cli_wallet/ios/.xcode.env +++ b/wallets/rn_cli_wallet/ios/.xcode.env @@ -2,7 +2,7 @@ # used when running script phases inside Xcode. # To customize your local environment, you can create an `.xcode.env.local` # file that is not versioned. -## echo export NODE_BINARY=$(command -v node) > .xcode.env.local +## echo export NODE_BINARY=$(command -v node) \\nexport SENTRY_ALLOW_FAILURE=true > .xcode.env.local # NODE_BINARY variable contains the PATH to the node executable. # diff --git a/wallets/rn_cli_wallet/ios/Podfile.lock b/wallets/rn_cli_wallet/ios/Podfile.lock index f6271e09..a8684df8 100644 --- a/wallets/rn_cli_wallet/ios/Podfile.lock +++ b/wallets/rn_cli_wallet/ios/Podfile.lock @@ -1817,6 +1817,34 @@ PODS: - React-Core - react-native-get-random-values (1.11.0): - React-Core + - react-native-mmkv (3.3.3): + - boost + - DoubleConversion + - fast_float + - fmt + - glog + - hermes-engine + - RCT-Folly + - RCT-Folly/Fabric + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - React-jsi + - React-NativeModulesApple + - React-RCTFabric + - React-renderercss + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - SocketRocket + - Yoga - react-native-netinfo (11.4.1): - React-Core - react-native-quick-base64 (2.2.2): @@ -2820,6 +2848,7 @@ DEPENDENCIES: - "react-native-compat (from `../node_modules/@walletconnect/react-native-compat`)" - react-native-config (from `../node_modules/react-native-config`) - react-native-get-random-values (from `../node_modules/react-native-get-random-values`) + - react-native-mmkv (from `../node_modules/react-native-mmkv`) - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" - react-native-quick-base64 (from `../node_modules/react-native-quick-base64`) - react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`) @@ -2963,6 +2992,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-config" react-native-get-random-values: :path: "../node_modules/react-native-get-random-values" + react-native-mmkv: + :path: "../node_modules/react-native-mmkv" react-native-netinfo: :path: "../node_modules/@react-native-community/netinfo" react-native-quick-base64: @@ -3103,6 +3134,7 @@ SPEC CHECKSUMS: react-native-compat: 3573295702a92c9b13cc0ee3dd47499c5aee0c32 react-native-config: 644074ab88db883fcfaa584f03520ec29589d7df react-native-get-random-values: d16467cf726c618e9c7a8c3c39c31faa2244bbba + react-native-mmkv: ac7507625cd74bac0eb5333604a7cd7b08fe9e3e react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187 react-native-quick-base64: 6568199bb2ac8e72ecdfdc73a230fbc5c1d3aac4 react-native-quick-crypto: dac9db2adb0a61b4881909b6db7c51eaaada66a8 diff --git a/wallets/rn_cli_wallet/ios/RNWeb3Wallet.xcodeproj/project.pbxproj b/wallets/rn_cli_wallet/ios/RNWeb3Wallet.xcodeproj/project.pbxproj index bc3b79fc..4dd8154a 100644 --- a/wallets/rn_cli_wallet/ios/RNWeb3Wallet.xcodeproj/project.pbxproj +++ b/wallets/rn_cli_wallet/ios/RNWeb3Wallet.xcodeproj/project.pbxproj @@ -178,8 +178,7 @@ 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, - 1F4795A12E9D5C1200B52C86 /* -Upload Debug Symbols to Sentry */, + 1F4795A12E9D5C1200B52C86 /* Upload Debug Symbols to Sentry */, 330B5F4BDC32F3AF53024071 /* [CP] Embed Pods Frameworks */, 42B98FB2BE62A040A5D168B5 /* [CP] Copy Pods Resources */, ); @@ -202,8 +201,7 @@ Upload Debug Symbols to Sentry */, 1FCDA2922B9B8E6200E0BF0C /* Frameworks */, 1FCDA2942B9B8E6200E0BF0C /* Resources */, 1FCDA29A2B9B8E6200E0BF0C /* Bundle React Native code and images */, - 1F4795A02E9D5BFE00B52C86 /* -Upload Debug Symbols to Sentry */, + 1F4795A02E9D5BFE00B52C86 /* Upload Debug Symbols to Sentry */, 210BFE96CABEC2224D5DEA2E /* [CP] Embed Pods Frameworks */, 1F19C9ADE7D476C9B83CC003 /* [CP] Copy Pods Resources */, ); @@ -340,14 +338,10 @@ Upload Debug Symbols to Sentry */, inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Debug/Pods-App-RNWallet Debug-resources-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Debug/Pods-App-RNWallet Debug-resources-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Debug/Pods-App-RNWallet Debug-resources.sh\"\n"; @@ -367,8 +361,7 @@ Upload Debug Symbols to Sentry */, shellPath = /bin/sh; shellScript = "/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh\n"; }; - 1F4795A02E9D5BFE00B52C86 /* -Upload Debug Symbols to Sentry */ = { + 1F4795A02E9D5BFE00B52C86 /* Upload Debug Symbols to Sentry */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -377,7 +370,7 @@ Upload Debug Symbols to Sentry */ = { ); inputPaths = ( ); - name = "\nUpload Debug Symbols to Sentry"; + name = "Upload Debug Symbols to Sentry"; outputFileListPaths = ( ); outputPaths = ( @@ -386,8 +379,7 @@ Upload Debug Symbols to Sentry */ = { shellPath = /bin/sh; shellScript = "/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh\n"; }; - 1F4795A12E9D5C1200B52C86 /* -Upload Debug Symbols to Sentry */ = { + 1F4795A12E9D5C1200B52C86 /* Upload Debug Symbols to Sentry */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -396,7 +388,7 @@ Upload Debug Symbols to Sentry */ = { ); inputPaths = ( ); - name = "\nUpload Debug Symbols to Sentry"; + name = "Upload Debug Symbols to Sentry"; outputFileListPaths = ( ); outputPaths = ( @@ -505,14 +497,10 @@ Upload Debug Symbols to Sentry */ = { inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Debug/Pods-App-RNWallet Debug-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Debug/Pods-App-RNWallet Debug-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Debug/Pods-App-RNWallet Debug-frameworks.sh\"\n"; @@ -526,14 +514,10 @@ Upload Debug Symbols to Sentry */ = { inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet/Pods-App-RNWallet-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet/Pods-App-RNWallet-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App-RNWallet/Pods-App-RNWallet-frameworks.sh\"\n"; @@ -547,14 +531,10 @@ Upload Debug Symbols to Sentry */ = { inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet/Pods-App-RNWallet-resources-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet/Pods-App-RNWallet-resources-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App-RNWallet/Pods-App-RNWallet-resources.sh\"\n"; @@ -612,14 +592,10 @@ Upload Debug Symbols to Sentry */ = { inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Internal/Pods-App-RNWallet Internal-resources-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Internal/Pods-App-RNWallet Internal-resources-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Internal/Pods-App-RNWallet Internal-resources.sh\"\n"; @@ -633,14 +609,10 @@ Upload Debug Symbols to Sentry */ = { inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Internal/Pods-App-RNWallet Internal-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Internal/Pods-App-RNWallet Internal-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); - outputPaths = ( - ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App-RNWallet Internal/Pods-App-RNWallet Internal-frameworks.sh\"\n"; diff --git a/wallets/rn_cli_wallet/package.json b/wallets/rn_cli_wallet/package.json index 748cdaa9..b8fc0545 100644 --- a/wallets/rn_cli_wallet/package.json +++ b/wallets/rn_cli_wallet/package.json @@ -48,6 +48,7 @@ "react-native-dialog": "9.3.0", "react-native-gesture-handler": "2.28.0", "react-native-get-random-values": "1.11.0", + "react-native-mmkv": "3.3.3", "react-native-modal": "14.0.0-rc.1", "react-native-permissions": "5.4.2", "react-native-quick-base64": "2.2.2", diff --git a/wallets/rn_cli_wallet/src/screens/Settings/index.tsx b/wallets/rn_cli_wallet/src/screens/Settings/index.tsx index 4fe15795..9060d3ab 100644 --- a/wallets/rn_cli_wallet/src/screens/Settings/index.tsx +++ b/wallets/rn_cli_wallet/src/screens/Settings/index.tsx @@ -1,7 +1,6 @@ import {useSnapshot} from 'valtio'; import {useEffect, useState} from 'react'; import {Text, View, Alert, ScrollView} from 'react-native'; -import AsyncStorage from '@react-native-async-storage/async-storage'; import Clipboard from '@react-native-clipboard/clipboard'; import {getVersion, getBuildNumber} from 'react-native-device-info'; @@ -11,6 +10,7 @@ import {Card} from '@/components/Card'; import {useTheme} from '@/hooks/useTheme'; import styles from './styles'; import {SettingsStackScreenProps} from '@/utils/TypesUtil'; +import { storage } from '@/utils/storage'; type Props = SettingsStackScreenProps<'Settings'>; @@ -21,7 +21,7 @@ export default function Settings({navigation}: Props) { useEffect(() => { async function getAsyncData() { - const _clientId = await AsyncStorage.getItem('WALLETCONNECT_CLIENT_ID'); + const _clientId = await storage.getItem('WALLETCONNECT_CLIENT_ID'); if (_clientId) { setClientId(_clientId); } diff --git a/wallets/rn_cli_wallet/src/store/SettingsStore.ts b/wallets/rn_cli_wallet/src/store/SettingsStore.ts index e1bbdc14..2677f7d0 100644 --- a/wallets/rn_cli_wallet/src/store/SettingsStore.ts +++ b/wallets/rn_cli_wallet/src/store/SettingsStore.ts @@ -1,7 +1,7 @@ import {proxy} from 'valtio'; -import AsyncStorage from '@react-native-async-storage/async-storage'; import {Verify, SessionTypes} from '@walletconnect/types'; +import { storage } from '@/utils/storage'; import EIP155Lib from '../lib/EIP155Lib'; import SuiLib from '../lib/SuiLib'; @@ -98,9 +98,9 @@ const SettingsStore = { toggleTestNets() { state.testNets = !state.testNets; if (state.testNets) { - AsyncStorage.setItem('TEST_NETS', 'YES'); + storage.setItem('TEST_NETS', 'YES'); } else { - AsyncStorage.removeItem('TEST_NETS'); + storage.removeItem('TEST_NETS'); } }, diff --git a/wallets/rn_cli_wallet/src/utils/EIP155WalletUtil.ts b/wallets/rn_cli_wallet/src/utils/EIP155WalletUtil.ts index 25b8b91c..35b8ea16 100644 --- a/wallets/rn_cli_wallet/src/utils/EIP155WalletUtil.ts +++ b/wallets/rn_cli_wallet/src/utils/EIP155WalletUtil.ts @@ -1,5 +1,5 @@ -import AsyncStorage from '@react-native-async-storage/async-storage'; import EIP155Lib from '../lib/EIP155Lib'; +import { storage } from './storage'; export let wallet1: EIP155Lib; export let wallet2: EIP155Lib; @@ -13,8 +13,8 @@ let address2: string; * Utilities */ export async function createOrRestoreEIP155Wallet() { - const mnemonic1 = await AsyncStorage.getItem('EIP155_MNEMONIC_1'); - const mnemonic2 = await AsyncStorage.getItem('EIP155_MNEMONIC_2'); + const mnemonic1 = await storage.getItem('EIP155_MNEMONIC_1'); + const mnemonic2 = await storage.getItem('EIP155_MNEMONIC_2'); if (mnemonic1 && mnemonic2) { wallet1 = EIP155Lib.init({mnemonic: mnemonic1}); @@ -24,8 +24,8 @@ export async function createOrRestoreEIP155Wallet() { wallet2 = EIP155Lib.init({}); // Don't store mnemonic in local storage in a production project! - AsyncStorage.setItem('EIP155_MNEMONIC_1', wallet1.getMnemonic()); - AsyncStorage.setItem('EIP155_MNEMONIC_2', wallet2.getMnemonic()); + storage.setItem('EIP155_MNEMONIC_1', wallet1.getMnemonic()); + storage.setItem('EIP155_MNEMONIC_2', wallet2.getMnemonic()); } address1 = wallet1.getAddress(); diff --git a/wallets/rn_cli_wallet/src/utils/SuiWalletUtil.ts b/wallets/rn_cli_wallet/src/utils/SuiWalletUtil.ts index ded48526..7710f276 100644 --- a/wallets/rn_cli_wallet/src/utils/SuiWalletUtil.ts +++ b/wallets/rn_cli_wallet/src/utils/SuiWalletUtil.ts @@ -1,5 +1,5 @@ import SuiLib from '../lib/SuiLib'; -import AsyncStorage from '@react-native-async-storage/async-storage'; +import { storage } from './storage'; export let wallet1: SuiLib; export let suiAddresses: string[]; @@ -8,14 +8,14 @@ export let suiAddresses: string[]; * Utilities */ export async function createOrRestoreSuiWallet() { - const mnemonic1 = await AsyncStorage.getItem('SUI_MNEMONIC_1'); + const mnemonic1 = await storage.getItem('SUI_MNEMONIC_1'); if (mnemonic1) { wallet1 = await SuiLib.init({mnemonic: mnemonic1}); } else { wallet1 = await SuiLib.init({}); // Don't store private keys in local storage in a production project! - await AsyncStorage.setItem('SUI_MNEMONIC_1', wallet1.getMnemonic()); + await storage.setItem('SUI_MNEMONIC_1', wallet1.getMnemonic()); console.log('SUI_MNEMONIC_1', wallet1.getMnemonic()); } diff --git a/wallets/rn_cli_wallet/src/utils/WalletKitUtil.ts b/wallets/rn_cli_wallet/src/utils/WalletKitUtil.ts index b5634201..d45f9ac1 100644 --- a/wallets/rn_cli_wallet/src/utils/WalletKitUtil.ts +++ b/wallets/rn_cli_wallet/src/utils/WalletKitUtil.ts @@ -1,14 +1,15 @@ import {WalletKit, IWalletKit} from '@reown/walletkit'; import {Core} from '@walletconnect/core'; -import AsyncStorage from '@react-native-async-storage/async-storage'; import Config from 'react-native-config'; import {getMetadata} from './misc'; +import { storage } from './storage'; export let walletKit: IWalletKit; export async function createWalletKit(relayerRegionURL: string) { const core = new Core({ projectId: Config.ENV_PROJECT_ID, + storage, relayUrl: relayerRegionURL ?? Config.ENV_RELAY_URL, }); walletKit = await WalletKit.init({ @@ -20,7 +21,7 @@ export async function createWalletKit(relayerRegionURL: string) { const clientId = await walletKit.engine.signClient.core.crypto.getClientId(); console.log('WalletConnect ClientID: ', clientId); - AsyncStorage.setItem('WALLETCONNECT_CLIENT_ID', clientId); + storage.setItem('WALLETCONNECT_CLIENT_ID', clientId); } catch (error) { console.error( 'Failed to set WalletConnect clientId in localStorage: ', diff --git a/wallets/rn_cli_wallet/src/utils/storage.ts b/wallets/rn_cli_wallet/src/utils/storage.ts new file mode 100644 index 00000000..46ee705e --- /dev/null +++ b/wallets/rn_cli_wallet/src/utils/storage.ts @@ -0,0 +1,33 @@ +import { MMKV } from 'react-native-mmkv'; +import { safeJsonParse, safeJsonStringify } from '@walletconnect/safe-json'; + +const mmkv = new MMKV(); + +export const storage = { + getKeys: async () => { + return mmkv.getAllKeys(); + }, + getEntries: async (): Promise<[string, T][]> => { + function parseEntry(key: string): [string, any] { + const value = mmkv.getString(key); + return [key, safeJsonParse(value ?? '')]; + } + + const keys = mmkv.getAllKeys(); + return keys.map(parseEntry); + }, + setItem: async (key: string, value: T) => { + return mmkv.set(key, safeJsonStringify(value)); + }, + getItem: async (key: string): Promise => { + const item = mmkv.getString(key); + if (typeof item === 'undefined' || item === null) { + return undefined; + } + + return safeJsonParse(item) as T; + }, + removeItem: async (key: string) => { + return mmkv.delete(key); + }, +}; \ No newline at end of file diff --git a/wallets/rn_cli_wallet/yarn.lock b/wallets/rn_cli_wallet/yarn.lock index e6dde566..9df1ab60 100644 --- a/wallets/rn_cli_wallet/yarn.lock +++ b/wallets/rn_cli_wallet/yarn.lock @@ -4500,6 +4500,7 @@ __metadata: react-native-dialog: 9.3.0 react-native-gesture-handler: 2.28.0 react-native-get-random-values: 1.11.0 + react-native-mmkv: 3.3.3 react-native-modal: 14.0.0-rc.1 react-native-permissions: 5.4.2 react-native-quick-base64: 2.2.2 @@ -10565,6 +10566,16 @@ __metadata: languageName: node linkType: hard +"react-native-mmkv@npm:3.3.3": + version: 3.3.3 + resolution: "react-native-mmkv@npm:3.3.3" + peerDependencies: + react: "*" + react-native: "*" + checksum: 2f4f6ba36f2c00a1374cd3c0303207e7c0a0b7b2504c4f1986a423a3d8295eb817299fc1ca11e37c425df60648c5a0d02be882f1890924167724775433dd2598 + languageName: node + linkType: hard + "react-native-modal@npm:14.0.0-rc.1": version: 14.0.0-rc.1 resolution: "react-native-modal@npm:14.0.0-rc.1"