web: working transfers
This commit is contained in:
parent
1d960405d1
commit
8d4927cb4a
File diff suppressed because one or more lines are too long
|
@ -14865,4 +14865,4 @@
|
||||||
"methods": {},
|
"methods": {},
|
||||||
"version": 1
|
"version": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,31 +2,32 @@ import React, {useContext} from "react"
|
||||||
import {BalanceInfo, SolanaTokenContext} from "../providers/SolanaTokenContext";
|
import {BalanceInfo, SolanaTokenContext} from "../providers/SolanaTokenContext";
|
||||||
import {Table} from "antd";
|
import {Table} from "antd";
|
||||||
import {CHAIN_ID_SOLANA} from "../utils/bridge";
|
import {CHAIN_ID_SOLANA} from "../utils/bridge";
|
||||||
|
import {BigNumber} from "ethers/utils";
|
||||||
|
|
||||||
function SplBalances() {
|
function SplBalances() {
|
||||||
let t = useContext(SolanaTokenContext);
|
let t = useContext(SolanaTokenContext);
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
|
||||||
title: 'Mint',
|
|
||||||
dataIndex: 'mint',
|
|
||||||
key: 'mint',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'Account',
|
title: 'Account',
|
||||||
key: 'account',
|
key: 'account',
|
||||||
render: (n: any, v: BalanceInfo) => v.account.toString()
|
render: (n: any, v: BalanceInfo) => v.account.toString()
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Mint',
|
||||||
|
dataIndex: 'mint',
|
||||||
|
key: 'mint',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Balance',
|
title: 'Balance',
|
||||||
key: 'balance',
|
key: 'balance',
|
||||||
render: (n: any, v: BalanceInfo) => v.balance.div(Math.pow(10, v.decimals)).toString()
|
render: (n: any, v: BalanceInfo) => v.balance.div(new BigNumber(10).pow(v.decimals)).toString()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Wrapped',
|
title: 'Wrapped',
|
||||||
key: 'wrapped',
|
key: 'wrapped',
|
||||||
render: (n: any, v: BalanceInfo) => {
|
render: (n: any, v: BalanceInfo) => {
|
||||||
return v.assetMeta.chain != CHAIN_ID_SOLANA ? `Wrapped (${v.assetMeta.chain})` : "Native"
|
return v.assetMeta.chain != CHAIN_ID_SOLANA ? `Wrapped (${v.assetMeta.chain} - 0x${v.assetMeta.address.slice(12).toString("hex")})` : "Native"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {PublicKey} from "@solana/web3.js";
|
import {PublicKey} from "@solana/web3.js";
|
||||||
|
|
||||||
const BRIDGE_ADDRESS = "0xac3eB48829fFC3C37437ce4459cE63F1F4d4E0b4";
|
const BRIDGE_ADDRESS = "0x5b1869D9A4C187F2EAa108f3062412ecf0526b24";
|
||||||
|
|
||||||
const SOLANA_BRIDGE_PROGRAM = new PublicKey("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o");
|
const SOLANA_BRIDGE_PROGRAM = new PublicKey("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o");
|
||||||
const TOKEN_PROGRAM = new PublicKey("TokenSVp5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o");
|
const TOKEN_PROGRAM = new PublicKey("TokenSVp5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o");
|
||||||
|
|
|
@ -26,35 +26,36 @@ interface WormholeInterface extends Interface {
|
||||||
|
|
||||||
wrappedAssets: TypedFunctionDescription<{ encode([]: [Arrayish]): string }>;
|
wrappedAssets: TypedFunctionDescription<{ encode([]: [Arrayish]): string }>;
|
||||||
|
|
||||||
|
getGuardianSet: TypedFunctionDescription<{
|
||||||
|
encode([idx]: [BigNumberish]): string;
|
||||||
|
}>;
|
||||||
|
|
||||||
submitVAA: TypedFunctionDescription<{ encode([vaa]: [Arrayish]): string }>;
|
submitVAA: TypedFunctionDescription<{ encode([vaa]: [Arrayish]): string }>;
|
||||||
|
|
||||||
lockAssets: TypedFunctionDescription<{
|
lockAssets: TypedFunctionDescription<{
|
||||||
encode([asset, amount, recipient, target_chain]: [
|
encode([asset, amount, recipient, target_chain, nonce]: [
|
||||||
string,
|
string,
|
||||||
BigNumberish,
|
BigNumberish,
|
||||||
Arrayish,
|
Arrayish,
|
||||||
|
BigNumberish,
|
||||||
BigNumberish
|
BigNumberish
|
||||||
]): string;
|
]): string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
lockETH: TypedFunctionDescription<{
|
lockETH: TypedFunctionDescription<{
|
||||||
encode([recipient, target_chain]: [Arrayish, BigNumberish]): string;
|
encode([recipient, target_chain, nonce]: [
|
||||||
|
Arrayish,
|
||||||
|
BigNumberish,
|
||||||
|
BigNumberish
|
||||||
|
]): string;
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
LogGuardianSetChanged: TypedEventDescription<{
|
LogGuardianSetChanged: TypedEventDescription<{
|
||||||
encodeTopics([oldGuardian, newGuardian]: [
|
encodeTopics([oldGuardianIndex, newGuardianIndex]: [
|
||||||
{
|
null,
|
||||||
x: BigNumberish;
|
null
|
||||||
parity: BigNumberish;
|
|
||||||
expiration_time: BigNumberish;
|
|
||||||
} | null,
|
|
||||||
{
|
|
||||||
x: BigNumberish;
|
|
||||||
parity: BigNumberish;
|
|
||||||
expiration_time: BigNumberish;
|
|
||||||
} | null
|
|
||||||
]): string[];
|
]): string[];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
@ -65,8 +66,17 @@ interface WormholeInterface extends Interface {
|
||||||
token,
|
token,
|
||||||
sender,
|
sender,
|
||||||
recipient,
|
recipient,
|
||||||
amount
|
amount,
|
||||||
]: [null, null, Arrayish | null, Arrayish | null, null, null]): string[];
|
nonce
|
||||||
|
]: [
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
Arrayish | null,
|
||||||
|
Arrayish | null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
]): string[];
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -92,26 +102,12 @@ export class Wormhole extends Contract {
|
||||||
guardian_sets(
|
guardian_sets(
|
||||||
arg0: BigNumberish,
|
arg0: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<{
|
): Promise<number>;
|
||||||
x: BigNumber;
|
|
||||||
parity: number;
|
|
||||||
expiration_time: number;
|
|
||||||
0: BigNumber;
|
|
||||||
1: number;
|
|
||||||
2: number;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
"guardian_sets(uint32)"(
|
"guardian_sets(uint32)"(
|
||||||
arg0: BigNumberish,
|
arg0: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<{
|
): Promise<number>;
|
||||||
x: BigNumber;
|
|
||||||
parity: number;
|
|
||||||
expiration_time: number;
|
|
||||||
0: BigNumber;
|
|
||||||
1: number;
|
|
||||||
2: number;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
isWrappedAsset(
|
isWrappedAsset(
|
||||||
arg0: string,
|
arg0: string,
|
||||||
|
@ -141,6 +137,26 @@ export class Wormhole extends Contract {
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<string>;
|
): Promise<string>;
|
||||||
|
|
||||||
|
getGuardianSet(
|
||||||
|
idx: BigNumberish,
|
||||||
|
overrides?: TransactionOverrides
|
||||||
|
): Promise<{
|
||||||
|
keys: string[];
|
||||||
|
expiration_time: number;
|
||||||
|
0: string[];
|
||||||
|
1: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
"getGuardianSet(uint32)"(
|
||||||
|
idx: BigNumberish,
|
||||||
|
overrides?: TransactionOverrides
|
||||||
|
): Promise<{
|
||||||
|
keys: string[];
|
||||||
|
expiration_time: number;
|
||||||
|
0: string[];
|
||||||
|
1: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
submitVAA(
|
submitVAA(
|
||||||
vaa: Arrayish,
|
vaa: Arrayish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
|
@ -156,26 +172,30 @@ export class Wormhole extends Contract {
|
||||||
amount: BigNumberish,
|
amount: BigNumberish,
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
"lockAssets(address,uint256,bytes32,uint8)"(
|
"lockAssets(address,uint256,bytes32,uint8,uint32)"(
|
||||||
asset: string,
|
asset: string,
|
||||||
amount: BigNumberish,
|
amount: BigNumberish,
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
lockETH(
|
lockETH(
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
"lockETH(bytes32,uint8)"(
|
"lockETH(bytes32,uint8,uint32)"(
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
};
|
};
|
||||||
|
@ -187,26 +207,12 @@ export class Wormhole extends Contract {
|
||||||
guardian_sets(
|
guardian_sets(
|
||||||
arg0: BigNumberish,
|
arg0: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<{
|
): Promise<number>;
|
||||||
x: BigNumber;
|
|
||||||
parity: number;
|
|
||||||
expiration_time: number;
|
|
||||||
0: BigNumber;
|
|
||||||
1: number;
|
|
||||||
2: number;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
"guardian_sets(uint32)"(
|
"guardian_sets(uint32)"(
|
||||||
arg0: BigNumberish,
|
arg0: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<{
|
): Promise<number>;
|
||||||
x: BigNumber;
|
|
||||||
parity: number;
|
|
||||||
expiration_time: number;
|
|
||||||
0: BigNumber;
|
|
||||||
1: number;
|
|
||||||
2: number;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
isWrappedAsset(
|
isWrappedAsset(
|
||||||
arg0: string,
|
arg0: string,
|
||||||
|
@ -236,6 +242,26 @@ export class Wormhole extends Contract {
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<string>;
|
): Promise<string>;
|
||||||
|
|
||||||
|
getGuardianSet(
|
||||||
|
idx: BigNumberish,
|
||||||
|
overrides?: TransactionOverrides
|
||||||
|
): Promise<{
|
||||||
|
keys: string[];
|
||||||
|
expiration_time: number;
|
||||||
|
0: string[];
|
||||||
|
1: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
"getGuardianSet(uint32)"(
|
||||||
|
idx: BigNumberish,
|
||||||
|
overrides?: TransactionOverrides
|
||||||
|
): Promise<{
|
||||||
|
keys: string[];
|
||||||
|
expiration_time: number;
|
||||||
|
0: string[];
|
||||||
|
1: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
submitVAA(
|
submitVAA(
|
||||||
vaa: Arrayish,
|
vaa: Arrayish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
|
@ -251,41 +277,37 @@ export class Wormhole extends Contract {
|
||||||
amount: BigNumberish,
|
amount: BigNumberish,
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
"lockAssets(address,uint256,bytes32,uint8)"(
|
"lockAssets(address,uint256,bytes32,uint8,uint32)"(
|
||||||
asset: string,
|
asset: string,
|
||||||
amount: BigNumberish,
|
amount: BigNumberish,
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
lockETH(
|
lockETH(
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
"lockETH(bytes32,uint8)"(
|
"lockETH(bytes32,uint8,uint32)"(
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
filters: {
|
filters: {
|
||||||
LogGuardianSetChanged(
|
LogGuardianSetChanged(
|
||||||
oldGuardian: {
|
oldGuardianIndex: null,
|
||||||
x: BigNumberish;
|
newGuardianIndex: null
|
||||||
parity: BigNumberish;
|
|
||||||
expiration_time: BigNumberish;
|
|
||||||
} | null,
|
|
||||||
newGuardian: {
|
|
||||||
x: BigNumberish;
|
|
||||||
parity: BigNumberish;
|
|
||||||
expiration_time: BigNumberish;
|
|
||||||
} | null
|
|
||||||
): EventFilter;
|
): EventFilter;
|
||||||
|
|
||||||
LogTokensLocked(
|
LogTokensLocked(
|
||||||
|
@ -294,7 +316,8 @@ export class Wormhole extends Contract {
|
||||||
token: Arrayish | null,
|
token: Arrayish | null,
|
||||||
sender: Arrayish | null,
|
sender: Arrayish | null,
|
||||||
recipient: null,
|
recipient: null,
|
||||||
amount: null
|
amount: null,
|
||||||
|
nonce: null
|
||||||
): EventFilter;
|
): EventFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -345,6 +368,16 @@ export class Wormhole extends Contract {
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
|
getGuardianSet(
|
||||||
|
idx: BigNumberish,
|
||||||
|
overrides?: TransactionOverrides
|
||||||
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
|
"getGuardianSet(uint32)"(
|
||||||
|
idx: BigNumberish,
|
||||||
|
overrides?: TransactionOverrides
|
||||||
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
submitVAA(
|
submitVAA(
|
||||||
vaa: Arrayish,
|
vaa: Arrayish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
|
@ -360,26 +393,30 @@ export class Wormhole extends Contract {
|
||||||
amount: BigNumberish,
|
amount: BigNumberish,
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
"lockAssets(address,uint256,bytes32,uint8)"(
|
"lockAssets(address,uint256,bytes32,uint8,uint32)"(
|
||||||
asset: string,
|
asset: string,
|
||||||
amount: BigNumberish,
|
amount: BigNumberish,
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
lockETH(
|
lockETH(
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
"lockETH(bytes32,uint8)"(
|
"lockETH(bytes32,uint8,uint32)"(
|
||||||
recipient: Arrayish,
|
recipient: Arrayish,
|
||||||
target_chain: BigNumberish,
|
target_chain: BigNumberish,
|
||||||
|
nonce: BigNumberish,
|
||||||
overrides?: TransactionOverrides
|
overrides?: TransactionOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14,6 +14,7 @@ import {BridgeContext} from "../providers/BridgeContext";
|
||||||
import {AssetMeta, SolanaBridge} from "../utils/bridge";
|
import {AssetMeta, SolanaBridge} from "../utils/bridge";
|
||||||
import KeyContext from "../providers/KeyContext";
|
import KeyContext from "../providers/KeyContext";
|
||||||
import {FormInstance} from "antd/lib/form";
|
import {FormInstance} from "antd/lib/form";
|
||||||
|
import SplBalances from "../components/SplBalances";
|
||||||
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -29,11 +30,12 @@ async function lockAssets(asset: string,
|
||||||
let wh = WormholeFactory.connect(BRIDGE_ADDRESS, signer);
|
let wh = WormholeFactory.connect(BRIDGE_ADDRESS, signer);
|
||||||
try {
|
try {
|
||||||
message.loading({content: "Signing transaction...", key: "eth_tx", duration: 1000},)
|
message.loading({content: "Signing transaction...", key: "eth_tx", duration: 1000},)
|
||||||
let res = await wh.lockAssets(asset, amount, recipient, target_chain)
|
let res = await wh.lockAssets(asset, amount, recipient, target_chain, 10)
|
||||||
message.loading({content: "Waiting for transaction to be mined...", key: "eth_tx", duration: 1000})
|
message.loading({content: "Waiting for transaction to be mined...", key: "eth_tx", duration: 1000})
|
||||||
await res.wait(1);
|
await res.wait(1);
|
||||||
message.success({content: "Transfer on ETH succeeded!", key: "eth_tx"})
|
message.success({content: "Transfer on ETH succeeded!", key: "eth_tx"})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
message.error({content: "Transfer failed", key: "eth_tx"})
|
message.error({content: "Transfer failed", key: "eth_tx"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +104,8 @@ function Transfer() {
|
||||||
let [wrappedMint, setWrappedMint] = useState("")
|
let [wrappedMint, setWrappedMint] = useState("")
|
||||||
let [recipient, setRecipient] = useState("")
|
let [recipient, setRecipient] = useState("")
|
||||||
|
|
||||||
|
let [transacting, setTransacting] = useState(false);
|
||||||
|
|
||||||
let formRef = React.createRef<FormInstance>();
|
let formRef = React.createRef<FormInstance>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -137,7 +141,7 @@ function Transfer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchBalance(address)
|
fetchBalance(address)
|
||||||
}, [address])
|
}, [address, transacting])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!addressValid) {
|
if (!addressValid) {
|
||||||
|
@ -184,10 +188,15 @@ function Transfer() {
|
||||||
<Form onFinish={(values) => {
|
<Form onFinish={(values) => {
|
||||||
let recipient = new solanaWeb3.PublicKey(values["recipient"]).toBuffer()
|
let recipient = new solanaWeb3.PublicKey(values["recipient"]).toBuffer()
|
||||||
let transferAmount = new BigNumber(values["amount"]).mul(new BigNumber(10).pow(coinInfo.decimals));
|
let transferAmount = new BigNumber(values["amount"]).mul(new BigNumber(10).pow(coinInfo.decimals));
|
||||||
|
setTransacting(true)
|
||||||
if (coinInfo.allowance.gte(amount) || coinInfo.isWrapped) {
|
if (coinInfo.allowance.gte(amount) || coinInfo.isWrapped) {
|
||||||
lockAssets(values["address"], transferAmount, recipient, values["target_chain"])
|
lockAssets(values["address"], transferAmount, recipient, values["target_chain"]).finally(() => {
|
||||||
|
setTransacting(false)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
approveAssets(values["address"], transferAmount)
|
approveAssets(values["address"], transferAmount).finally(() => {
|
||||||
|
setTransacting(false)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}} style={{width: "100%"}} ref={formRef} layout={"vertical"}>
|
}} style={{width: "100%"}} ref={formRef} layout={"vertical"}>
|
||||||
<Form.Item name="address" validateStatus={addressValid ? "success" : "error"} label={"Token:"}>
|
<Form.Item name="address" validateStatus={addressValid ? "success" : "error"} label={"Token:"}>
|
||||||
|
@ -206,7 +215,7 @@ function Transfer() {
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="target_chain"
|
<Form.Item name="target_chain"
|
||||||
label={"Target Chain:"}>
|
label={"Target Chain:"}>
|
||||||
<Select placeholder="Target Chain" defaultValue={1}>
|
<Select placeholder="Target Chain">
|
||||||
<Select.Option value={1}>
|
<Select.Option value={1}>
|
||||||
Solana
|
Solana
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
|
@ -220,7 +229,8 @@ function Transfer() {
|
||||||
}}/>
|
}}/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button type="primary" htmlType="submit" style={{marginLeft:"auto"}}>
|
<Button type="primary" htmlType="submit" style={{marginLeft: "auto"}}
|
||||||
|
disabled={transacting}>
|
||||||
{coinInfo.allowance.gte(amount) || coinInfo.isWrapped ? "Transfer" : "Approve"}
|
{coinInfo.allowance.gte(amount) || coinInfo.isWrapped ? "Transfer" : "Approve"}
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
@ -264,6 +274,11 @@ function Transfer() {
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
<SplBalances/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ function TransferSolana() {
|
||||||
<Form.Item name="target_chain"
|
<Form.Item name="target_chain"
|
||||||
rules={[{required: true, message: "Please choose a target chain"}]}
|
rules={[{required: true, message: "Please choose a target chain"}]}
|
||||||
label={"Target Chain:"}>
|
label={"Target Chain:"}>
|
||||||
<Select placeholder="Target Chain" defaultValue={2}>
|
<Select placeholder="Target Chain">
|
||||||
<Select.Option value={2}>
|
<Select.Option value={2}>
|
||||||
Ethereum
|
Ethereum
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
|
|
Loading…
Reference in New Issue