forked from cerc-io/laconic-wallet
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
162e32f2de |
@@ -21,7 +21,6 @@
|
|||||||
"@hookform/resolvers": "^3.3.4",
|
"@hookform/resolvers": "^3.3.4",
|
||||||
"@json-rpc-tools/utils": "^1.7.6",
|
"@json-rpc-tools/utils": "^1.7.6",
|
||||||
"@react-native-async-storage/async-storage": "^1.22.3",
|
"@react-native-async-storage/async-storage": "^1.22.3",
|
||||||
"@react-native-clipboard/clipboard": "^1.14.1",
|
|
||||||
"@react-native-community/netinfo": "^11.3.1",
|
"@react-native-community/netinfo": "^11.3.1",
|
||||||
"@react-navigation/elements": "^1.3.30",
|
"@react-navigation/elements": "^1.3.30",
|
||||||
"@react-navigation/native": "^6.1.10",
|
"@react-navigation/native": "^6.1.10",
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Default value for IS_RELEASE
|
|
||||||
IS_RELEASE=${IS_RELEASE:-false}
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
echo "Installing dependencies..."
|
|
||||||
yarn
|
|
||||||
|
|
||||||
# Create the necessary directory for assets
|
|
||||||
mkdir -p android/app/src/main/assets/
|
|
||||||
|
|
||||||
# Bundle the React Native application
|
|
||||||
yarn react-native bundle \
|
|
||||||
--platform android \
|
|
||||||
--dev false \
|
|
||||||
--entry-file index.js \
|
|
||||||
--bundle-output android/app/src/main/assets/index.android.bundle \
|
|
||||||
--assets-dest android/app/src/main/res
|
|
||||||
|
|
||||||
# Navigate to the android directory
|
|
||||||
cd android
|
|
||||||
|
|
||||||
# Run the Gradle build based on the IS_RELEASE flag
|
|
||||||
if [ "$IS_RELEASE" = "true" ]; then
|
|
||||||
echo "Building release version..."
|
|
||||||
./gradlew assembleRelease
|
|
||||||
else
|
|
||||||
echo "Building debug version..."
|
|
||||||
./gradlew assembleDebug
|
|
||||||
fi
|
|
||||||
@@ -60,6 +60,7 @@ const Accounts = () => {
|
|||||||
networksData,
|
networksData,
|
||||||
selectedNetwork!,
|
selectedNetwork!,
|
||||||
accounts,
|
accounts,
|
||||||
|
currentIndex,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!updatedNamespaces) {
|
if (!updatedNamespaces) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
|
||||||
import { View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
|
import React from 'react';
|
||||||
import { Button } from 'react-native-paper';
|
import { Button } from 'react-native-paper';
|
||||||
|
|
||||||
import { CreateWalletProps } from '../types';
|
import { CreateWalletProps } from '../types';
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { View } from 'react-native';
|
||||||
|
import { Button, Dialog, Portal, Text } from 'react-native-paper';
|
||||||
|
|
||||||
|
import styles from '../styles/stylesheet';
|
||||||
|
import GridView from './Grid';
|
||||||
|
import { CustomDialogProps } from '../types';
|
||||||
|
|
||||||
|
const DialogComponent = ({
|
||||||
|
visible,
|
||||||
|
hideDialog,
|
||||||
|
contentText,
|
||||||
|
}: CustomDialogProps) => {
|
||||||
|
const words = contentText.split(' ');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Portal>
|
||||||
|
<Dialog visible={visible} onDismiss={hideDialog}>
|
||||||
|
<Dialog.Content>
|
||||||
|
<Text variant="titleLarge">Mnemonic</Text>
|
||||||
|
<View style={styles.dialogTitle}>
|
||||||
|
<Text variant="titleMedium">
|
||||||
|
Your mnemonic provides full access to your wallet and funds. Make
|
||||||
|
sure to note it down.{' '}
|
||||||
|
</Text>
|
||||||
|
<Text variant="titleMedium" style={styles.dialogWarning}>
|
||||||
|
Do not share your mnemonic with anyone
|
||||||
|
</Text>
|
||||||
|
<GridView words={words} />
|
||||||
|
</View>
|
||||||
|
</Dialog.Content>
|
||||||
|
<Dialog.Actions>
|
||||||
|
<Button onPress={hideDialog}>Done</Button>
|
||||||
|
</Dialog.Actions>
|
||||||
|
</Dialog>
|
||||||
|
</Portal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { DialogComponent };
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { View, TextInput } from 'react-native';
|
|
||||||
import { Dialog, Portal, Paragraph, Button } from 'react-native-paper';
|
|
||||||
|
|
||||||
import styles from '../styles/stylesheet';
|
|
||||||
|
|
||||||
const ImportWalletDialog = ({
|
|
||||||
visible,
|
|
||||||
hideDialog,
|
|
||||||
importWalletHandler,
|
|
||||||
}: {
|
|
||||||
visible: boolean;
|
|
||||||
hideDialog: () => void;
|
|
||||||
importWalletHandler: (recoveryPhrase: string) => Promise<void>;
|
|
||||||
}) => {
|
|
||||||
const [words, setWords] = useState<string[]>(Array(12).fill(''));
|
|
||||||
|
|
||||||
const handleWordChange = (index: number, value: string) => {
|
|
||||||
const newWords = [...words];
|
|
||||||
newWords[index] = value;
|
|
||||||
setWords(newWords);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Portal>
|
|
||||||
<Dialog visible={visible} onDismiss={hideDialog}>
|
|
||||||
<Dialog.Title>Import your wallet from your mnemonic</Dialog.Title>
|
|
||||||
<Dialog.Content>
|
|
||||||
<Paragraph>
|
|
||||||
(You can paste your entire mnemonic into the first textbox)
|
|
||||||
</Paragraph>
|
|
||||||
<View style={styles.container}>
|
|
||||||
{words.map((word, index) => (
|
|
||||||
<View style={styles.inputContainer} key={index}>
|
|
||||||
<TextInput
|
|
||||||
value={word}
|
|
||||||
onChangeText={text => handleWordChange(index, text)}
|
|
||||||
placeholder={`Word ${index + 1}`}
|
|
||||||
style={styles.textInput}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
</Dialog.Content>
|
|
||||||
<Dialog.Actions>
|
|
||||||
<Button
|
|
||||||
mode="contained"
|
|
||||||
onPress={() => importWalletHandler(words.join(' '))}>
|
|
||||||
Import Wallet
|
|
||||||
</Button>
|
|
||||||
<Button mode="text" onPress={hideDialog}>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</Dialog.Actions>
|
|
||||||
</Dialog>
|
|
||||||
</Portal>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ImportWalletDialog;
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { View } from 'react-native';
|
|
||||||
import { Button, Dialog, Portal, Snackbar, Text } from 'react-native-paper';
|
|
||||||
|
|
||||||
import Clipboard from '@react-native-clipboard/clipboard';
|
|
||||||
|
|
||||||
import styles from '../styles/stylesheet';
|
|
||||||
import GridView from './Grid';
|
|
||||||
import { CustomDialogProps } from '../types';
|
|
||||||
|
|
||||||
const MnemonicDialog = ({
|
|
||||||
visible,
|
|
||||||
hideDialog,
|
|
||||||
contentText,
|
|
||||||
}: CustomDialogProps) => {
|
|
||||||
const [toastVisible, setToastVisible] = useState(false);
|
|
||||||
|
|
||||||
const words = contentText.split(' ');
|
|
||||||
|
|
||||||
const handleCopy = () => {
|
|
||||||
Clipboard.setString(contentText);
|
|
||||||
setToastVisible(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Portal>
|
|
||||||
<Dialog visible={visible} onDismiss={hideDialog}>
|
|
||||||
<Dialog.Content>
|
|
||||||
<Text variant="titleLarge">Mnemonic</Text>
|
|
||||||
<View style={styles.dialogTitle}>
|
|
||||||
<Text variant="titleMedium">
|
|
||||||
Your mnemonic provides full access to your wallet and funds.
|
|
||||||
Make sure to note it down.{' '}
|
|
||||||
</Text>
|
|
||||||
<Text variant="titleMedium" style={styles.dialogWarning}>
|
|
||||||
Do not share your mnemonic with anyone
|
|
||||||
</Text>
|
|
||||||
<GridView words={words} />
|
|
||||||
</View>
|
|
||||||
</Dialog.Content>
|
|
||||||
<Dialog.Actions>
|
|
||||||
<Button onPress={handleCopy}>Copy</Button>
|
|
||||||
<Button onPress={hideDialog}>Done</Button>
|
|
||||||
</Dialog.Actions>
|
|
||||||
</Dialog>
|
|
||||||
</Portal>
|
|
||||||
<Snackbar
|
|
||||||
visible={toastVisible}
|
|
||||||
onDismiss={() => setToastVisible(false)}
|
|
||||||
duration={1000}>
|
|
||||||
Mnemonic copied to clipboard
|
|
||||||
</Snackbar>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { MnemonicDialog };
|
|
||||||
@@ -20,7 +20,7 @@ const PairingModal = ({
|
|||||||
setModalVisible,
|
setModalVisible,
|
||||||
setToastVisible,
|
setToastVisible,
|
||||||
}: PairingModalProps) => {
|
}: PairingModalProps) => {
|
||||||
const { accounts } = useAccounts();
|
const { accounts, currentIndex } = useAccounts();
|
||||||
const { selectedNetwork, networksData } = useNetworks();
|
const { selectedNetwork, networksData } = useNetworks();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [chainError, setChainError] = useState('');
|
const [chainError, setChainError] = useState('');
|
||||||
@@ -103,6 +103,7 @@ const PairingModal = ({
|
|||||||
networksData,
|
networksData,
|
||||||
selectedNetwork!,
|
selectedNetwork!,
|
||||||
accounts,
|
accounts,
|
||||||
|
currentIndex,
|
||||||
);
|
);
|
||||||
setSupportedNamespaces(nameSpaces);
|
setSupportedNamespaces(nameSpaces);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -128,6 +129,7 @@ const PairingModal = ({
|
|||||||
networksData,
|
networksData,
|
||||||
selectedNetwork,
|
selectedNetwork,
|
||||||
accounts,
|
accounts,
|
||||||
|
currentIndex,
|
||||||
web3wallet,
|
web3wallet,
|
||||||
setCurrentProposal,
|
setCurrentProposal,
|
||||||
setModalVisible,
|
setModalVisible,
|
||||||
|
|||||||
+11
-37
@@ -7,8 +7,7 @@ import { useNavigation } from '@react-navigation/native';
|
|||||||
import { getSdkError } from '@walletconnect/utils';
|
import { getSdkError } from '@walletconnect/utils';
|
||||||
|
|
||||||
import { createWallet, resetWallet, retrieveAccounts } from '../utils/accounts';
|
import { createWallet, resetWallet, retrieveAccounts } from '../utils/accounts';
|
||||||
import { MnemonicDialog } from '../components/MnemonicDialog';
|
import { DialogComponent } from '../components/Dialog';
|
||||||
import ImportWalletDialog from '../components/ImportWalletDialog';
|
|
||||||
import { NetworkDropdown } from '../components/NetworkDropdown';
|
import { NetworkDropdown } from '../components/NetworkDropdown';
|
||||||
import Accounts from '../components/Accounts';
|
import Accounts from '../components/Accounts';
|
||||||
import CreateWallet from '../components/CreateWallet';
|
import CreateWallet from '../components/CreateWallet';
|
||||||
@@ -56,13 +55,12 @@ const HomeScreen = () => {
|
|||||||
|
|
||||||
const [isWalletCreated, setIsWalletCreated] = useState<boolean>(false);
|
const [isWalletCreated, setIsWalletCreated] = useState<boolean>(false);
|
||||||
const [isWalletCreating, setIsWalletCreating] = useState<boolean>(false);
|
const [isWalletCreating, setIsWalletCreating] = useState<boolean>(false);
|
||||||
const [importWalletDialog, setImportWalletDialog] = useState<boolean>(false);
|
const [walletDialog, setWalletDialog] = useState<boolean>(false);
|
||||||
const [mnemonicDialog, setMnemonicDialog] = useState<boolean>(false);
|
|
||||||
const [resetWalletDialog, setResetWalletDialog] = useState<boolean>(false);
|
const [resetWalletDialog, setResetWalletDialog] = useState<boolean>(false);
|
||||||
const [isAccountsFetched, setIsAccountsFetched] = useState<boolean>(false);
|
const [isAccountsFetched, setIsAccountsFetched] = useState<boolean>(false);
|
||||||
const [phrase, setPhrase] = useState('');
|
const [phrase, setPhrase] = useState('');
|
||||||
|
|
||||||
const hideMnemonicDialog = () => setMnemonicDialog(false);
|
const hideWalletDialog = () => setWalletDialog(false);
|
||||||
const hideResetDialog = () => setResetWalletDialog(false);
|
const hideResetDialog = () => setResetWalletDialog(false);
|
||||||
|
|
||||||
const fetchAccounts = useCallback(async () => {
|
const fetchAccounts = useCallback(async () => {
|
||||||
@@ -85,22 +83,12 @@ const HomeScreen = () => {
|
|||||||
const mnemonic = await createWallet(networksData);
|
const mnemonic = await createWallet(networksData);
|
||||||
if (mnemonic) {
|
if (mnemonic) {
|
||||||
fetchAccounts();
|
fetchAccounts();
|
||||||
setMnemonicDialog(true);
|
setWalletDialog(true);
|
||||||
setPhrase(mnemonic);
|
setPhrase(mnemonic);
|
||||||
setSelectedNetwork(networksData[0]);
|
setSelectedNetwork(networksData[0]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const importWalletHandler = async (recoveryPhrase: string) => {
|
|
||||||
const mnemonic = await createWallet(networksData, recoveryPhrase);
|
|
||||||
if (mnemonic) {
|
|
||||||
fetchAccounts();
|
|
||||||
setPhrase(mnemonic);
|
|
||||||
setSelectedNetwork(networksData[0]);
|
|
||||||
setImportWalletDialog(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const confirmResetWallet = useCallback(async () => {
|
const confirmResetWallet = useCallback(async () => {
|
||||||
setIsWalletCreated(false);
|
setIsWalletCreated(false);
|
||||||
setIsWalletCreating(false);
|
setIsWalletCreating(false);
|
||||||
@@ -164,28 +152,14 @@ const HomeScreen = () => {
|
|||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<CreateWallet
|
||||||
<CreateWallet
|
isWalletCreating={isWalletCreating}
|
||||||
isWalletCreating={isWalletCreating}
|
createWalletHandler={createWalletHandler}
|
||||||
createWalletHandler={createWalletHandler}
|
/>
|
||||||
/>
|
|
||||||
<View style={styles.createWalletContainer}>
|
|
||||||
<Button
|
|
||||||
mode="contained"
|
|
||||||
onPress={() => setImportWalletDialog(true)}>
|
|
||||||
Import Wallet
|
|
||||||
</Button>
|
|
||||||
</View>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
<ImportWalletDialog
|
<DialogComponent
|
||||||
visible={importWalletDialog}
|
visible={walletDialog}
|
||||||
hideDialog={() => setImportWalletDialog(false)}
|
hideDialog={hideWalletDialog}
|
||||||
importWalletHandler={importWalletHandler}
|
|
||||||
/>
|
|
||||||
<MnemonicDialog
|
|
||||||
visible={mnemonicDialog}
|
|
||||||
hideDialog={hideMnemonicDialog}
|
|
||||||
contentText={phrase}
|
contentText={phrase}
|
||||||
/>
|
/>
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
|
|||||||
@@ -88,13 +88,21 @@ const SignRequest = ({ route }: SignRequestProps) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAccount(requestAccount);
|
if (requestAccount !== account) {
|
||||||
setMessage(decodeURIComponent(requestMessage));
|
setAccount(requestAccount);
|
||||||
setNamespace(requestNamespace);
|
}
|
||||||
setChainId(requestChainId);
|
if (requestMessage !== message) {
|
||||||
|
setMessage(decodeURIComponent(requestMessage));
|
||||||
|
}
|
||||||
|
if (requestNamespace !== namespace) {
|
||||||
|
setNamespace(requestNamespace);
|
||||||
|
}
|
||||||
|
if (requestChainId !== chainId) {
|
||||||
|
setChainId(requestChainId);
|
||||||
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
},
|
},
|
||||||
[navigation],
|
[account, message, navigation, namespace, chainId],
|
||||||
);
|
);
|
||||||
|
|
||||||
const sanitizePath = useCallback(
|
const sanitizePath = useCallback(
|
||||||
|
|||||||
@@ -117,12 +117,6 @@ const styles = StyleSheet.create({
|
|||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
},
|
},
|
||||||
textInput: {
|
|
||||||
height: 40,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderRadius: 4,
|
|
||||||
paddingHorizontal: 10,
|
|
||||||
},
|
|
||||||
requestMessage: {
|
requestMessage: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
|
|||||||
+3
-14
@@ -27,25 +27,12 @@ import { COSMOS, EIP155 } from './constants';
|
|||||||
|
|
||||||
const createWallet = async (
|
const createWallet = async (
|
||||||
networksData: NetworksDataState[],
|
networksData: NetworksDataState[],
|
||||||
recoveryPhrase?: string,
|
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
const mnemonic = recoveryPhrase
|
const mnemonic = utils.entropyToMnemonic(utils.randomBytes(16));
|
||||||
? recoveryPhrase
|
|
||||||
: utils.entropyToMnemonic(utils.randomBytes(16));
|
|
||||||
await setInternetCredentials('mnemonicServer', 'mnemonic', mnemonic);
|
await setInternetCredentials('mnemonicServer', 'mnemonic', mnemonic);
|
||||||
|
|
||||||
const hdNode = HDNode.fromMnemonic(mnemonic);
|
const hdNode = HDNode.fromMnemonic(mnemonic);
|
||||||
|
|
||||||
await createWalletFromMnemonic(networksData, hdNode, mnemonic);
|
|
||||||
|
|
||||||
return mnemonic;
|
|
||||||
};
|
|
||||||
|
|
||||||
const createWalletFromMnemonic = async (
|
|
||||||
networksData: NetworksDataState[],
|
|
||||||
hdNode: HDNode,
|
|
||||||
mnemonic: string,
|
|
||||||
): Promise<void> => {
|
|
||||||
for (const network of networksData) {
|
for (const network of networksData) {
|
||||||
const hdPath = `m/44'/${network.coinType}'/0'/0/0`;
|
const hdPath = `m/44'/${network.coinType}'/0'/0/0`;
|
||||||
const node = hdNode.derivePath(hdPath);
|
const node = hdNode.derivePath(hdPath);
|
||||||
@@ -86,6 +73,8 @@ const createWalletFromMnemonic = async (
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mnemonic;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addAccount = async (
|
const addAccount = async (
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { DENOM } from '@cerc-io/registry-sdk';
|
||||||
|
|
||||||
import Config from 'react-native-config';
|
import Config from 'react-native-config';
|
||||||
import { COSMOS_TESTNET_CHAINS } from './wallet-connect/COSMOSData';
|
import { COSMOS_TESTNET_CHAINS } from './wallet-connect/COSMOSData';
|
||||||
import { EIP155_CHAINS } from './wallet-connect/EIP155Data';
|
import { EIP155_CHAINS } from './wallet-connect/EIP155Data';
|
||||||
@@ -11,7 +13,7 @@ export const DEFAULT_NETWORKS = [
|
|||||||
namespace: COSMOS,
|
namespace: COSMOS,
|
||||||
rpcUrl: Config.LACONICD_RPC_URL,
|
rpcUrl: Config.LACONICD_RPC_URL,
|
||||||
blockExplorerUrl: '',
|
blockExplorerUrl: '',
|
||||||
nativeDenom: 'alnt',
|
nativeDenom: DENOM,
|
||||||
addressPrefix: 'laconic',
|
addressPrefix: 'laconic',
|
||||||
coinType: '118',
|
coinType: '118',
|
||||||
gasPrice: '1',
|
gasPrice: '1',
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export const getNamespaces = async (
|
|||||||
networksData: NetworksDataState[],
|
networksData: NetworksDataState[],
|
||||||
selectedNetwork: NetworksDataState,
|
selectedNetwork: NetworksDataState,
|
||||||
accounts: Account[],
|
accounts: Account[],
|
||||||
|
currentIndex: number,
|
||||||
) => {
|
) => {
|
||||||
const namespaceChainId = `${selectedNetwork.namespace}:${selectedNetwork.chainId}`;
|
const namespaceChainId = `${selectedNetwork.namespace}:${selectedNetwork.chainId}`;
|
||||||
|
|
||||||
@@ -100,6 +101,23 @@ export const getNamespaces = async (
|
|||||||
const requiredAddressesArray = await Promise.all(requiredAddressesPromise);
|
const requiredAddressesArray = await Promise.all(requiredAddressesPromise);
|
||||||
const requiredAddresses = requiredAddressesArray.flat();
|
const requiredAddresses = requiredAddressesArray.flat();
|
||||||
|
|
||||||
|
let sortedAccounts = requiredAddresses;
|
||||||
|
|
||||||
|
// If selected network is included in chains requested from dApp,
|
||||||
|
// Put selected account as first account
|
||||||
|
if (walletConnectChains.includes(namespaceChainId)) {
|
||||||
|
const currentAddresses = requiredAddresses.filter(address =>
|
||||||
|
address.includes(namespaceChainId),
|
||||||
|
);
|
||||||
|
sortedAccounts = [
|
||||||
|
currentAddresses[currentIndex],
|
||||||
|
...currentAddresses.filter((address, index) => index !== currentIndex),
|
||||||
|
...requiredAddresses.filter(
|
||||||
|
address => !currentAddresses.includes(address),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// construct namespace object
|
// construct namespace object
|
||||||
const newNamespaces = {
|
const newNamespaces = {
|
||||||
eip155: {
|
eip155: {
|
||||||
@@ -115,7 +133,7 @@ export const getNamespaces = async (
|
|||||||
...(optionalNamespaces.eip155?.events ?? []),
|
...(optionalNamespaces.eip155?.events ?? []),
|
||||||
...(requiredNamespaces.eip155?.events ?? []),
|
...(requiredNamespaces.eip155?.events ?? []),
|
||||||
],
|
],
|
||||||
accounts: requiredAddresses.filter(account => account.includes(EIP155)),
|
accounts: sortedAccounts.filter(account => account.includes(EIP155)),
|
||||||
},
|
},
|
||||||
cosmos: {
|
cosmos: {
|
||||||
chains: walletConnectChains.filter(chain => chain.includes(COSMOS)),
|
chains: walletConnectChains.filter(chain => chain.includes(COSMOS)),
|
||||||
@@ -129,12 +147,18 @@ export const getNamespaces = async (
|
|||||||
...(optionalNamespaces.cosmos?.events ?? []),
|
...(optionalNamespaces.cosmos?.events ?? []),
|
||||||
...(requiredNamespaces.cosmos?.events ?? []),
|
...(requiredNamespaces.cosmos?.events ?? []),
|
||||||
],
|
],
|
||||||
accounts: requiredAddresses.filter(account => account.includes(COSMOS)),
|
accounts: sortedAccounts.filter(account => account.includes(COSMOS)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return newNamespaces;
|
return newNamespaces;
|
||||||
} else {
|
} else {
|
||||||
|
// Set selected account as the first account in supported namespaces
|
||||||
|
const sortedAccounts = [
|
||||||
|
accounts[currentIndex],
|
||||||
|
...accounts.filter((account, index) => index !== currentIndex),
|
||||||
|
];
|
||||||
|
|
||||||
switch (selectedNetwork.namespace) {
|
switch (selectedNetwork.namespace) {
|
||||||
case EIP155:
|
case EIP155:
|
||||||
return {
|
return {
|
||||||
@@ -151,7 +175,7 @@ export const getNamespaces = async (
|
|||||||
...(optionalNamespaces.eip155?.events ?? []),
|
...(optionalNamespaces.eip155?.events ?? []),
|
||||||
...(requiredNamespaces.eip155?.events ?? []),
|
...(requiredNamespaces.eip155?.events ?? []),
|
||||||
],
|
],
|
||||||
accounts: accounts.map(ethAccount => {
|
accounts: sortedAccounts.map(ethAccount => {
|
||||||
return `${namespaceChainId}:${ethAccount.address}`;
|
return `${namespaceChainId}:${ethAccount.address}`;
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@@ -176,7 +200,7 @@ export const getNamespaces = async (
|
|||||||
...(optionalNamespaces.cosmos?.events ?? []),
|
...(optionalNamespaces.cosmos?.events ?? []),
|
||||||
...(requiredNamespaces.cosmos?.events ?? []),
|
...(requiredNamespaces.cosmos?.events ?? []),
|
||||||
],
|
],
|
||||||
accounts: accounts.map(cosmosAccount => {
|
accounts: sortedAccounts.map(cosmosAccount => {
|
||||||
return `${namespaceChainId}:${cosmosAccount.address}`;
|
return `${namespaceChainId}:${cosmosAccount.address}`;
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2071,11 +2071,6 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
merge-options "^3.0.4"
|
merge-options "^3.0.4"
|
||||||
|
|
||||||
"@react-native-clipboard/clipboard@^1.14.1":
|
|
||||||
version "1.14.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/@react-native-clipboard/clipboard/-/clipboard-1.14.1.tgz#835f82fc86881a0808a8405f2576617bb5383554"
|
|
||||||
integrity sha512-SM3el0A28SwoeJljVNhF217o0nI4E7RfalLmuRQcT1/7tGcxUjgFa3jyrEndYUct8/uxxK5EUNGUu1YEDqzxqw==
|
|
||||||
|
|
||||||
"@react-native-community/cli-clean@12.3.2":
|
"@react-native-community/cli-clean@12.3.2":
|
||||||
version "12.3.2"
|
version "12.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.2.tgz#d4f1730c3d22d816b4d513d330d5f3896a3f5921"
|
resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.2.tgz#d4f1730c3d22d816b4d513d330d5f3896a3f5921"
|
||||||
|
|||||||
Reference in New Issue
Block a user