bridge_ui: fill in getOriginalAsset

Change-Id: I9e94b9253f0c4da6d4580283e6902461c96f55a3
This commit is contained in:
Reisen 2021-08-30 21:37:55 +00:00 committed by Evan Gray
parent 666a4d12d5
commit 4d7f11fc6c
3 changed files with 21 additions and 10 deletions

View File

@ -48,7 +48,6 @@ function useGetBalanceEffect(sourceOrTarget: "source" | "target") {
const solanaWallet = useSolanaWallet();
const solPK = solanaWallet?.publicKey;
const terraWallet = useConnectedWallet();
const lcd = new LCDClient(TERRA_HOST);
const { provider, signerAddress } = useEthereumProvider();
useEffect(() => {
// source is now handled by getsourceparsedtokenaccounts
@ -61,6 +60,7 @@ function useGetBalanceEffect(sourceOrTarget: "source" | "target") {
let cancelled = false;
if (lookupChain === CHAIN_ID_TERRA && terraWallet) {
const lcd = new LCDClient(TERRA_HOST);
lcd.wasm
.contractQuery(lookupAsset, {
token_info: {},
@ -161,7 +161,6 @@ function useGetBalanceEffect(sourceOrTarget: "source" | "target") {
};
}, [
dispatch,
lcd,
lookupAsset,
lookupChain,
provider,

View File

@ -14,7 +14,6 @@ import {
useConnectedWallet,
} from "@terra-money/wallet-provider";
import { Signer } from "ethers";
import { fromUint8Array } from "js-base64";
import { useSnackbar } from "notistack";
import { useCallback, useMemo } from "react";
import { useDispatch, useSelector } from "react-redux";

View File

@ -4,7 +4,7 @@ import { arrayify } from "ethers/lib/utils";
import { TokenImplementation__factory } from "../ethers-contracts";
import { ChainId, CHAIN_ID_ETH, CHAIN_ID_SOLANA, CHAIN_ID_TERRA } from "../utils";
import { getIsWrappedAssetEth } from "./getIsWrappedAsset";
import { ConnectedWallet as TerraConnectedWallet } from "@terra-money/wallet-provider";
import { LCDClient } from "@terra-money/terra.js";
export interface WormholeWrappedInfo {
isWrapped: boolean;
@ -50,15 +50,28 @@ export async function getOriginalAssetEth(
}
export async function getOriginalAssetTerra(
tokenBridgeAddress: string,
wallet: TerraConnectedWallet,
client: LCDClient,
wrappedAddress: string
): Promise<WormholeWrappedInfo> {
const result: {
asset_address: string,
asset_chain: ChainId,
bridge: string,
} = await client.wasm.contractQuery(wrappedAddress, {
wrapped_asset_info: {},
});
if (result) {
return {
isWrapped: true,
chainId: result.asset_chain,
assetAddress: arrayify(result.asset_address),
};
}
return {
isWrapped: false,
chainId: CHAIN_ID_TERRA,
assetAddress: arrayify(""),
};
isWrapped: false,
chainId: CHAIN_ID_TERRA,
assetAddress: arrayify(wrappedAddress),
}
}
/**