sdk/js: updateWrappedOnSolana

Change-Id: Ib4d25b8c4494d79883ad55873f13ff2688e5e969
This commit is contained in:
Evan Gray 2021-11-19 14:31:29 -05:00
parent 443b18a0f6
commit 55bc96d979
4 changed files with 28 additions and 24 deletions

View File

@ -1,4 +1,3 @@
import { CHAIN_ID_SOLANA } from "@certusone/wormhole-sdk";
import { CircularProgress, makeStyles } from "@material-ui/core";
import { useSelector } from "react-redux";
import useFetchForeignAsset from "../../hooks/useFetchForeignAsset";
@ -35,8 +34,7 @@ function Create() {
originAsset,
targetChain
);
const shouldUpdate =
targetChain !== CHAIN_ID_SOLANA && foreignAssetInfo.data?.doesExist;
const shouldUpdate = foreignAssetInfo.data?.doesExist;
const error = foreignAssetInfo.error || statusMessage;
const { handleClick, disabled, showLoader } = useHandleCreateWrapped(
shouldUpdate || false

View File

@ -7,6 +7,7 @@ import {
createWrappedOnTerra,
updateWrappedOnEth,
updateWrappedOnTerra,
updateWrappedOnSolana,
postVaaSolana,
} from "@certusone/wormhole-sdk";
import { WalletContextState } from "@solana/wallet-adapter-react";
@ -81,7 +82,7 @@ async function solana(
wallet: WalletContextState,
payerAddress: string, // TODO: we may not need this since we have wallet
signedVAA: Uint8Array,
shouldUpdate: boolean //TODO utilize
shouldUpdate: boolean
) {
dispatch(setIsCreating(true));
try {
@ -96,13 +97,21 @@ async function solana(
payerAddress,
Buffer.from(signedVAA)
);
const transaction = await createWrappedOnSolana(
connection,
SOL_BRIDGE_ADDRESS,
SOL_TOKEN_BRIDGE_ADDRESS,
payerAddress,
signedVAA
);
const transaction = shouldUpdate
? await updateWrappedOnSolana(
connection,
SOL_BRIDGE_ADDRESS,
SOL_TOKEN_BRIDGE_ADDRESS,
payerAddress,
signedVAA
)
: await createWrappedOnSolana(
connection,
SOL_BRIDGE_ADDRESS,
SOL_TOKEN_BRIDGE_ADDRESS,
payerAddress,
signedVAA
);
const txid = await signSendAndConfirm(wallet, connection, transaction);
// TODO: didn't want to make an info call we didn't need, can we get the block without it by modifying the above call?
dispatch(setCreateTx({ id: txid, block: 1 }));

View File

@ -1,5 +1,11 @@
# Changelog
## 0.0.11
### Added
updateWrappedOnSolana
## 0.0.10
### Added

View File

@ -1,6 +1,5 @@
import { MsgExecuteContract } from "@terra-money/terra.js";
import { ethers } from "ethers";
import { fromUint8Array } from "js-base64";
import { createWrappedOnSolana, createWrappedOnTerra } from ".";
import { Bridge__factory } from "../ethers-contracts";
export async function updateWrappedOnEth(
@ -14,14 +13,6 @@ export async function updateWrappedOnEth(
return receipt;
}
export async function updateWrappedOnTerra(
tokenBridgeAddress: string,
walletAddress: string,
signedVAA: Uint8Array
) {
return new MsgExecuteContract(walletAddress, tokenBridgeAddress, {
submit_vaa: {
data: fromUint8Array(signedVAA),
},
});
}
export const updateWrappedOnTerra = createWrappedOnTerra;
export const updateWrappedOnSolana = createWrappedOnSolana;