bridge_ui: reset keeps chains, switchEthChain req
Change-Id: I3a4ff01bb3324969cbd2c02d91dbb8dfa8df066d
This commit is contained in:
parent
14e891ac6e
commit
3eae629a1b
|
@ -24,6 +24,7 @@ import {
|
|||
makeStyles,
|
||||
MenuItem,
|
||||
TextField,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@material-ui/core";
|
||||
import { Restore } from "@material-ui/icons";
|
||||
|
@ -121,7 +122,6 @@ async function terra(tx: string) {
|
|||
const emitterAddress = await getEmitterAddressTerra(
|
||||
TERRA_TOKEN_BRIDGE_ADDRESS
|
||||
);
|
||||
console.log(emitterAddress);
|
||||
const { vaaBytes } = await getSignedVAA(
|
||||
WORMHOLE_RPC_HOST,
|
||||
CHAIN_ID_TERRA,
|
||||
|
@ -441,9 +441,11 @@ export default function Recovery({
|
|||
}, [setOpen]);
|
||||
return (
|
||||
<>
|
||||
<Tooltip title="Open Recovery Dialog">
|
||||
<Fab className={classes.fab} onClick={handleOpenClick}>
|
||||
<Restore />
|
||||
</Fab>
|
||||
</Tooltip>
|
||||
<Dialog open={open} onClose={handleCloseClick} maxWidth="md" fullWidth>
|
||||
<DialogTitle>Recovery</DialogTitle>
|
||||
<RecoveryDialogContent onClose={handleCloseClick} disabled={disabled} />
|
||||
|
|
|
@ -175,7 +175,6 @@ const getSolanaParsedTokenAccounts = (
|
|||
})
|
||||
.then(
|
||||
(result) => {
|
||||
console.log(result);
|
||||
const mappedItems = result.value.map((item) =>
|
||||
createParsedTokenAccountFromInfo(item.pubkey, item.account)
|
||||
);
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
CHAIN_ID_SOLANA,
|
||||
CHAIN_ID_TERRA,
|
||||
} from "@certusone/wormhole-sdk";
|
||||
import { hexlify, hexStripZeros } from "@ethersproject/bytes";
|
||||
import { useConnectedWallet } from "@terra-money/wallet-provider";
|
||||
import { useMemo } from "react";
|
||||
import { useEthereumProvider } from "../contexts/EthereumProviderContext";
|
||||
|
@ -43,6 +44,13 @@ function useIsWalletReady(chainId: ChainId): {
|
|||
if (hasCorrectEthNetwork) {
|
||||
return createWalletStatus(true);
|
||||
} else {
|
||||
if (provider) {
|
||||
try {
|
||||
provider.send("wallet_switchEthereumChain", [
|
||||
{ chainId: hexStripZeros(hexlify(ETH_NETWORK_CHAIN_ID)) },
|
||||
]);
|
||||
} catch (e) {}
|
||||
}
|
||||
return createWalletStatus(
|
||||
false,
|
||||
`Wallet is not connected to ${CLUSTER}. Expected Chain ID: ${ETH_NETWORK_CHAIN_ID}`
|
||||
|
@ -51,7 +59,14 @@ function useIsWalletReady(chainId: ChainId): {
|
|||
}
|
||||
//TODO bsc
|
||||
return createWalletStatus(false, "Wallet not connected");
|
||||
}, [chainId, hasTerraWallet, solPK, hasEthInfo, hasCorrectEthNetwork]);
|
||||
}, [
|
||||
chainId,
|
||||
hasTerraWallet,
|
||||
solPK,
|
||||
hasEthInfo,
|
||||
hasCorrectEthNetwork,
|
||||
provider,
|
||||
]);
|
||||
}
|
||||
|
||||
export default useIsWalletReady;
|
||||
|
|
|
@ -2,14 +2,8 @@ import {
|
|||
ChainId,
|
||||
CHAIN_ID_ETH,
|
||||
CHAIN_ID_SOLANA,
|
||||
CHAIN_ID_TERRA,
|
||||
} from "@certusone/wormhole-sdk";
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import {
|
||||
ETH_TEST_TOKEN_ADDRESS,
|
||||
SOL_TEST_TOKEN_ADDRESS,
|
||||
TERRA_TEST_TOKEN_ADDRESS,
|
||||
} from "../utils/consts";
|
||||
|
||||
const LAST_STEP = 3;
|
||||
|
||||
|
@ -28,7 +22,7 @@ export interface AttestState {
|
|||
const initialState: AttestState = {
|
||||
activeStep: 0,
|
||||
sourceChain: CHAIN_ID_SOLANA,
|
||||
sourceAsset: SOL_TEST_TOKEN_ADDRESS,
|
||||
sourceAsset: "",
|
||||
targetChain: CHAIN_ID_ETH,
|
||||
signedVAAHex: undefined,
|
||||
isSending: false,
|
||||
|
@ -51,16 +45,7 @@ export const attestSlice = createSlice({
|
|||
setSourceChain: (state, action: PayloadAction<ChainId>) => {
|
||||
const prevSourceChain = state.sourceChain;
|
||||
state.sourceChain = action.payload;
|
||||
// TODO: remove or check env - for testing purposes
|
||||
if (action.payload === CHAIN_ID_ETH) {
|
||||
state.sourceAsset = ETH_TEST_TOKEN_ADDRESS;
|
||||
}
|
||||
if (action.payload === CHAIN_ID_SOLANA) {
|
||||
state.sourceAsset = SOL_TEST_TOKEN_ADDRESS;
|
||||
}
|
||||
if (action.payload === CHAIN_ID_TERRA) {
|
||||
state.sourceAsset = TERRA_TEST_TOKEN_ADDRESS;
|
||||
}
|
||||
state.sourceAsset = "";
|
||||
if (state.targetChain === action.payload) {
|
||||
state.targetChain = prevSourceChain;
|
||||
}
|
||||
|
@ -74,16 +59,7 @@ export const attestSlice = createSlice({
|
|||
if (state.sourceChain === action.payload) {
|
||||
state.sourceChain = prevTargetChain;
|
||||
state.activeStep = 0;
|
||||
// TODO: remove or check env - for testing purposes
|
||||
if (state.targetChain === CHAIN_ID_ETH) {
|
||||
state.sourceAsset = ETH_TEST_TOKEN_ADDRESS;
|
||||
}
|
||||
if (state.targetChain === CHAIN_ID_SOLANA) {
|
||||
state.sourceAsset = SOL_TEST_TOKEN_ADDRESS;
|
||||
}
|
||||
if (state.targetChain === CHAIN_ID_TERRA) {
|
||||
state.sourceAsset = TERRA_TEST_TOKEN_ADDRESS;
|
||||
}
|
||||
state.sourceAsset = "";
|
||||
}
|
||||
},
|
||||
setSignedVAAHex: (state, action: PayloadAction<string>) => {
|
||||
|
@ -97,7 +73,11 @@ export const attestSlice = createSlice({
|
|||
setIsCreating: (state, action: PayloadAction<boolean>) => {
|
||||
state.isCreating = action.payload;
|
||||
},
|
||||
reset: () => initialState,
|
||||
reset: (state) => ({
|
||||
...initialState,
|
||||
sourceChain: state.sourceChain,
|
||||
targetChain: state.targetChain,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -181,7 +181,11 @@ export const transferSlice = createSlice({
|
|||
setRedeemTx: (state, action: PayloadAction<Transaction>) => {
|
||||
state.redeemTx = action.payload;
|
||||
},
|
||||
reset: () => initialState,
|
||||
reset: (state) => ({
|
||||
...initialState,
|
||||
sourceChain: state.sourceChain,
|
||||
targetChain: state.targetChain,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue