Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
162efe377c |
@@ -60,6 +60,7 @@ const Accounts = () => {
|
|||||||
networksData,
|
networksData,
|
||||||
selectedNetwork!,
|
selectedNetwork!,
|
||||||
accounts,
|
accounts,
|
||||||
|
currentIndex,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!updatedNamespaces) {
|
if (!updatedNamespaces) {
|
||||||
|
|||||||
@@ -19,7 +19,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('');
|
||||||
@@ -101,6 +101,7 @@ const PairingModal = ({
|
|||||||
networksData,
|
networksData,
|
||||||
selectedNetwork!,
|
selectedNetwork!,
|
||||||
accounts,
|
accounts,
|
||||||
|
currentIndex,
|
||||||
);
|
);
|
||||||
setSupportedNamespaces(nameSpaces);
|
setSupportedNamespaces(nameSpaces);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -126,6 +127,7 @@ const PairingModal = ({
|
|||||||
networksData,
|
networksData,
|
||||||
selectedNetwork,
|
selectedNetwork,
|
||||||
accounts,
|
accounts,
|
||||||
|
currentIndex,
|
||||||
setCurrentProposal,
|
setCurrentProposal,
|
||||||
setModalVisible,
|
setModalVisible,
|
||||||
web3wallet
|
web3wallet
|
||||||
@@ -206,7 +208,7 @@ const PairingModal = ({
|
|||||||
<>
|
<>
|
||||||
{icon.endsWith('.svg') ? (
|
{icon.endsWith('.svg') ? (
|
||||||
<View style={styles.dappLogo}>
|
<View style={styles.dappLogo}>
|
||||||
<Text>SvgURI requestIcon</Text>
|
<Text>SvgURI requstIcon</Text>
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
<Image style={styles.dappLogo} source={{ uri: icon }} />
|
<Image style={styles.dappLogo} source={{ uri: icon }} />
|
||||||
@@ -229,27 +231,25 @@ const PairingModal = ({
|
|||||||
<Modal visible={visible} animationType="slide" transparent>
|
<Modal visible={visible} animationType="slide" transparent>
|
||||||
<View style={styles.modalOuterContainer}>
|
<View style={styles.modalOuterContainer}>
|
||||||
<View style={styles.modalContentContainer}>
|
<View style={styles.modalContentContainer}>
|
||||||
<View style={styles.container}>
|
<ScrollView showsVerticalScrollIndicator={true}>
|
||||||
{icon && (
|
|
||||||
<>
|
|
||||||
{icon.endsWith('.svg') ? (
|
|
||||||
<View style={styles.dappLogo}>
|
|
||||||
<Text>SvgURI requestIcon</Text>
|
|
||||||
</View>
|
|
||||||
) : (
|
|
||||||
<Image style={styles.dappLogo} source={{ uri: icon }} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Text variant="titleMedium">{dappName}</Text>
|
|
||||||
<Text variant="bodyMedium">{url}</Text>
|
|
||||||
<View style={styles.marginVertical8} />
|
|
||||||
<Text variant="titleMedium">Connect to this site?</Text>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<ScrollView showsVerticalScrollIndicator={true} style={styles.scrollViewContainer}>
|
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
{icon && (
|
||||||
|
<>
|
||||||
|
{icon.endsWith('.svg') ? (
|
||||||
|
<View style={styles.dappLogo}>
|
||||||
|
<Text>SvgURI requstIcon</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<Image style={styles.dappLogo} source={{ uri: icon }} />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Text variant="titleMedium">{dappName}</Text>
|
||||||
|
<Text variant="bodyMedium">{url}</Text>
|
||||||
|
<View style={styles.marginVertical8} />
|
||||||
|
<Text variant="titleMedium">Connect to this site?</Text>
|
||||||
|
|
||||||
{walletConnectData.walletConnectMethods.length > 0 && (
|
{walletConnectData.walletConnectMethods.length > 0 && (
|
||||||
<View>
|
<View>
|
||||||
<Text variant="titleMedium">Chains:</Text>
|
<Text variant="titleMedium">Chains:</Text>
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ const styles = StyleSheet.create({
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
paddingHorizontal: 20,
|
paddingHorizontal: 20,
|
||||||
minHeight: 100,
|
|
||||||
},
|
},
|
||||||
modalContentContainer: {
|
modalContentContainer: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -302,11 +301,7 @@ const styles = StyleSheet.create({
|
|||||||
networksButton: {
|
networksButton: {
|
||||||
marginTop: 12,
|
marginTop: 12,
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
},
|
}
|
||||||
scrollViewContainer: {
|
|
||||||
height: 60,
|
|
||||||
marginTop: 20,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { DENOM } from '@cerc-io/registry-sdk'
|
||||||
|
|
||||||
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';
|
||||||
|
|
||||||
@@ -10,7 +12,7 @@ export const DEFAULT_NETWORKS = [
|
|||||||
namespace: COSMOS,
|
namespace: COSMOS,
|
||||||
rpcUrl: process.env.REACT_APP_LACONICD_RPC_URL!,
|
rpcUrl: process.env.REACT_APP_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}`;
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user