bridge_ui: fill in getOriginalAsset
Change-Id: I9e94b9253f0c4da6d4580283e6902461c96f55a3
This commit is contained in:
parent
666a4d12d5
commit
4d7f11fc6c
|
@ -48,7 +48,6 @@ function useGetBalanceEffect(sourceOrTarget: "source" | "target") {
|
||||||
const solanaWallet = useSolanaWallet();
|
const solanaWallet = useSolanaWallet();
|
||||||
const solPK = solanaWallet?.publicKey;
|
const solPK = solanaWallet?.publicKey;
|
||||||
const terraWallet = useConnectedWallet();
|
const terraWallet = useConnectedWallet();
|
||||||
const lcd = new LCDClient(TERRA_HOST);
|
|
||||||
const { provider, signerAddress } = useEthereumProvider();
|
const { provider, signerAddress } = useEthereumProvider();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// source is now handled by getsourceparsedtokenaccounts
|
// source is now handled by getsourceparsedtokenaccounts
|
||||||
|
@ -61,6 +60,7 @@ function useGetBalanceEffect(sourceOrTarget: "source" | "target") {
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
|
|
||||||
if (lookupChain === CHAIN_ID_TERRA && terraWallet) {
|
if (lookupChain === CHAIN_ID_TERRA && terraWallet) {
|
||||||
|
const lcd = new LCDClient(TERRA_HOST);
|
||||||
lcd.wasm
|
lcd.wasm
|
||||||
.contractQuery(lookupAsset, {
|
.contractQuery(lookupAsset, {
|
||||||
token_info: {},
|
token_info: {},
|
||||||
|
@ -161,7 +161,6 @@ function useGetBalanceEffect(sourceOrTarget: "source" | "target") {
|
||||||
};
|
};
|
||||||
}, [
|
}, [
|
||||||
dispatch,
|
dispatch,
|
||||||
lcd,
|
|
||||||
lookupAsset,
|
lookupAsset,
|
||||||
lookupChain,
|
lookupChain,
|
||||||
provider,
|
provider,
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
useConnectedWallet,
|
useConnectedWallet,
|
||||||
} from "@terra-money/wallet-provider";
|
} from "@terra-money/wallet-provider";
|
||||||
import { Signer } from "ethers";
|
import { Signer } from "ethers";
|
||||||
import { fromUint8Array } from "js-base64";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { arrayify } from "ethers/lib/utils";
|
||||||
import { TokenImplementation__factory } from "../ethers-contracts";
|
import { TokenImplementation__factory } from "../ethers-contracts";
|
||||||
import { ChainId, CHAIN_ID_ETH, CHAIN_ID_SOLANA, CHAIN_ID_TERRA } from "../utils";
|
import { ChainId, CHAIN_ID_ETH, CHAIN_ID_SOLANA, CHAIN_ID_TERRA } from "../utils";
|
||||||
import { getIsWrappedAssetEth } from "./getIsWrappedAsset";
|
import { getIsWrappedAssetEth } from "./getIsWrappedAsset";
|
||||||
import { ConnectedWallet as TerraConnectedWallet } from "@terra-money/wallet-provider";
|
import { LCDClient } from "@terra-money/terra.js";
|
||||||
|
|
||||||
export interface WormholeWrappedInfo {
|
export interface WormholeWrappedInfo {
|
||||||
isWrapped: boolean;
|
isWrapped: boolean;
|
||||||
|
@ -50,15 +50,28 @@ export async function getOriginalAssetEth(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getOriginalAssetTerra(
|
export async function getOriginalAssetTerra(
|
||||||
tokenBridgeAddress: string,
|
client: LCDClient,
|
||||||
wallet: TerraConnectedWallet,
|
|
||||||
wrappedAddress: string
|
wrappedAddress: string
|
||||||
): Promise<WormholeWrappedInfo> {
|
): 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 {
|
return {
|
||||||
isWrapped: false,
|
isWrapped: false,
|
||||||
chainId: CHAIN_ID_TERRA,
|
chainId: CHAIN_ID_TERRA,
|
||||||
assetAddress: arrayify(""),
|
assetAddress: arrayify(wrappedAddress),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue