bridge_ui: terra2 testnet

This commit is contained in:
Evan Gray 2022-06-17 19:04:47 +00:00 committed by Evan Gray
parent 2144d68a09
commit 0a9e2b12ff
14 changed files with 34 additions and 28 deletions

View File

@ -8,7 +8,7 @@
"name": "test_ui",
"version": "0.1.0",
"dependencies": {
"@certusone/wormhole-sdk": "^0.4.2",
"@certusone/wormhole-sdk": "^0.4.3",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
@ -2132,9 +2132,9 @@
}
},
"node_modules/@certusone/wormhole-sdk": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.2.tgz",
"integrity": "sha512-2OQOq6Rb9VZ4bKT3LIQfayO5p3Z/EMrvUl58dpMv6DIJH/QbgWeCM24Of9f6nJ7Tky/UTCEJzKI2oAAbDyLN0A==",
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.3.tgz",
"integrity": "sha512-2rjH30gzbSWsMBcUOHT1ql9/1x5R2/WQwXFATU/9Vg3qcTKJn8z/kbvU/doHAHuX4OYeoFj3QXQ3qDuwkJl3ig==",
"dependencies": {
"@improbable-eng/grpc-web": "^0.14.0",
"@solana/spl-token": "^0.1.8",
@ -46765,9 +46765,9 @@
}
},
"@certusone/wormhole-sdk": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.2.tgz",
"integrity": "sha512-2OQOq6Rb9VZ4bKT3LIQfayO5p3Z/EMrvUl58dpMv6DIJH/QbgWeCM24Of9f6nJ7Tky/UTCEJzKI2oAAbDyLN0A==",
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.3.tgz",
"integrity": "sha512-2rjH30gzbSWsMBcUOHT1ql9/1x5R2/WQwXFATU/9Vg3qcTKJn8z/kbvU/doHAHuX4OYeoFj3QXQ3qDuwkJl3ig==",
"requires": {
"@improbable-eng/grpc-web": "^0.14.0",
"@solana/spl-token": "^0.1.8",

View File

@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@certusone/wormhole-sdk": "^0.4.2",
"@certusone/wormhole-sdk": "^0.4.3",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",

View File

@ -34,7 +34,6 @@ function Source() {
const handleSourceChange = useCallback(
(event) => {
dispatch(setSourceChain(event.target.value));
console.log(event.target.value);
},
[dispatch]
);

View File

@ -1,6 +1,7 @@
import {
CHAIN_ID_ACALA,
CHAIN_ID_KARURA,
CHAIN_ID_TERRA,
hexToNativeAssetString,
isEVMChain,
isTerraChain,
@ -306,7 +307,7 @@ function FeeMethodSelector() {
</Typography>
</div>
</div>
{(isEVMChain(targetChain) || isTerraChain(targetChain)) && (
{(isEVMChain(targetChain) || targetChain === CHAIN_ID_TERRA) && (
<GasEstimateSummary
methodType="transfer"
chainId={targetChain}

View File

@ -12,9 +12,14 @@ import {
selectAttestSignedVAAHex,
selectTransferOriginAsset,
selectTransferOriginChain,
selectTransferSourceAsset,
selectTransferTargetChain,
} from "../../store/selectors";
import { ChainId, hexToNativeAssetString } from "@certusone/wormhole-sdk";
import {
ChainId,
CHAIN_ID_TERRA2,
hexToNativeAssetString,
} from "@certusone/wormhole-sdk";
export function RegisterNowButtonCore({
originChain,
@ -29,19 +34,30 @@ export function RegisterNowButtonCore({
const history = useHistory();
// user might be in the middle of a different attest
const signedVAAHex = useSelector(selectAttestSignedVAAHex);
const sourceAsset = useSelector(selectTransferSourceAsset);
const canSwitch = originChain && originAsset && !signedVAAHex;
const handleClick = useCallback(() => {
const nativeAsset =
originChain && hexToNativeAssetString(originAsset, originChain);
const nativeAsset = originChain
? originChain === CHAIN_ID_TERRA2
? sourceAsset // use the preimage address for terra2
: hexToNativeAssetString(originAsset, originChain)
: undefined;
if (originChain && originAsset && nativeAsset && canSwitch) {
dispatch(setSourceChain(originChain));
console.log(originChain);
dispatch(setSourceAsset(nativeAsset));
dispatch(setTargetChain(targetChain));
dispatch(setStep(2));
history.push("/register");
}
}, [dispatch, canSwitch, originChain, originAsset, targetChain, history]);
}, [
dispatch,
canSwitch,
originChain,
originAsset,
targetChain,
history,
sourceAsset,
]);
if (!canSwitch) return null;
return (
<Button

View File

@ -125,7 +125,6 @@ function Source() {
const handleSourceChange = useCallback(
(event) => {
dispatch(setSourceChain(event.target.value));
console.log(event.target.value);
},
[dispatch]
);

View File

@ -65,7 +65,6 @@ function Transfer() {
return;
}
if (sourceChain) {
console.log(sourceChain);
dispatch(setSourceChain(sourceChain));
}
if (targetChain) {

View File

@ -134,7 +134,6 @@ function useCheckIfWormholeWrapped(nft?: boolean) {
const wrappedInfo = makeStateSafe(
await getOriginalAssetCosmWasm(lcd, sourceAsset, sourceChain)
);
console.log(wrappedInfo);
if (!cancelled) {
dispatch(setSourceWormholeWrappedInfo(wrappedInfo));
}

View File

@ -67,7 +67,6 @@ function useFetchTargetAsset(nft?: boolean) {
const originAsset = useSelector(
nft ? selectNFTOriginAsset : selectTransferOriginAsset
);
console.log(originAsset);
const originTokenId = useSelector(selectNFTOriginTokenId);
const tokenId = originTokenId || ""; // this should exist by this step for NFT transfers
const targetChain = useSelector(
@ -258,7 +257,6 @@ function useFetchTargetAsset(nft?: boolean) {
originChain,
originAsset
);
console.log("foreign asset algo:", asset);
if (!cancelled) {
dispatch(
setTargetAsset(

View File

@ -235,7 +235,7 @@ async function terra(
) {
dispatch(setIsSending(true));
try {
const tokenBridgeAddress = getTokenBridgeAddressForChain(chainId)
const tokenBridgeAddress = getTokenBridgeAddressForChain(chainId);
const msg = await attestFromTerra(
tokenBridgeAddress,
wallet.terraAddress,
@ -257,9 +257,7 @@ async function terra(
if (!sequence) {
throw new Error("Sequence not found");
}
const emitterAddress = await getEmitterAddressTerra(
tokenBridgeAddress,
);
const emitterAddress = await getEmitterAddressTerra(tokenBridgeAddress);
enqueueSnackbar(null, {
content: <Alert severity="info">Fetching VAA</Alert>,
});

View File

@ -228,7 +228,6 @@ function useOriginalAsset(
if (!cancelled) {
setIsLoading(false);
setArgs();
console.log("setting", result.assetAddress);
setOriginAddress(
hexToNativeAssetString(
uint8ArrayToHex(result.assetAddress),

View File

@ -28,7 +28,6 @@ export default function useTerraNativeBalances(
setIsLoading(true);
setBalances(undefined);
const lcd = new LCDClient(getTerraConfig(chainId));
console.log(lcd);
lcd.bank
.balance(walletAddress)
.then(([coins]) => {

View File

@ -416,7 +416,7 @@ export function GasEstimateSummary({
priceQuote={priceQuote}
/>
);
} else if (chainId === CHAIN_ID_TERRA) { // TODO: terra2 support
} else if (chainId === CHAIN_ID_TERRA) {
return <TerraGasEstimateSummary methodType={methodType} />;
} else {
return null;

View File

@ -30,7 +30,6 @@ export const formatNativeDenom = (
denom: string,
chainId: TerraChainId
): string => {
console.log(denom, chainId);
const unit = denom.slice(1).toUpperCase();
const isValidTerra = isNativeTerra(denom);
return denom === "uluna"