sdk/js: sui support posting VAAs over 1024

This commit is contained in:
Evan Gray 2023-05-03 01:36:27 +00:00 committed by Evan Gray
parent 39369d3d2b
commit d050ad1d67
6 changed files with 25 additions and 13 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 0.9.16
### Changed
Sui redeem fix
## 0.9.15
### Added

View File

@ -1,6 +1,6 @@
{
"name": "@certusone/wormhole-sdk",
"version": "0.9.15",
"version": "0.9.16",
"description": "SDK for interacting with Wormhole",
"homepage": "https://wormhole.com",
"main": "./lib/cjs/index.js",

View File

@ -1,4 +1,5 @@
import {
builder,
getObjectType,
isValidSuiAddress as isValidFullSuiAddress,
JsonRpcProvider,
@ -14,8 +15,12 @@ import { SuiRpcValidationError } from "./error";
import { SuiError } from "./types";
import { DynamicFieldPage } from "@mysten/sui.js/dist/types/dynamic_fields";
const MAX_PURE_ARGUMENT_SIZE = 16 * 1024;
const UPGRADE_CAP_TYPE = "0x2::package::UpgradeCap";
export const uint8ArrayToBCS = (arr: Uint8Array) =>
builder.ser("vector<u8>", arr, { maxSize: MAX_PURE_ARGUMENT_SIZE }).toBytes();
export const executeTransactionBlock = async (
signer: RawSigner,
transactionBlock: TransactionBlock

View File

@ -32,6 +32,7 @@ import {
getUpgradeCapObjectId,
getWrappedCoinType,
publishCoin,
uint8ArrayToBCS,
} from "../sui";
import { callFunctionNear } from "../utils";
import { SignedVaa } from "../vaa";
@ -247,7 +248,7 @@ export async function createWrappedOnSui(
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
arguments: [
tx.object(coreBridgeStateObjectId),
tx.pure([...attestVAA]),
tx.pure(uint8ArrayToBCS(attestVAA)),
tx.object(SUI_CLOCK_OBJECT_ID),
],
});

View File

@ -5,13 +5,13 @@ import {
} from "@mysten/sui.js";
import {
ACCOUNT_SIZE,
NATIVE_MINT,
TOKEN_PROGRAM_ID,
createCloseAccountInstruction,
createInitializeAccountInstruction,
createTransferInstruction,
getMinimumBalanceForRentExemptAccount,
getMint,
NATIVE_MINT,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import {
Commitment,
@ -27,7 +27,7 @@ import { MsgExecuteContract as XplaMsgExecuteContract } from "@xpla/xpla.js";
import { Algodv2 } from "algosdk";
import { AptosClient, Types } from "aptos";
import BN from "bn.js";
import { ethers, Overrides } from "ethers";
import { Overrides, ethers } from "ethers";
import { fromUint8Array } from "js-base64";
import { FunctionCallOptions } from "near-api-js/lib/account";
import { Provider } from "near-api-js/lib/providers";
@ -42,17 +42,17 @@ import {
createCompleteTransferNativeInstruction,
createCompleteTransferWrappedInstruction,
} from "../solana/tokenBridge";
import { getPackageId, getTokenCoinType } from "../sui";
import { getPackageId, getTokenCoinType, uint8ArrayToBCS } from "../sui";
import {
callFunctionNear,
ChainId,
CHAIN_ID_NEAR,
CHAIN_ID_SOLANA,
hashLookup,
ChainId,
MAX_VAA_DECIMALS,
callFunctionNear,
hashLookup,
uint8ArrayToHex,
} from "../utils";
import { parseTokenTransferVaa, SignedVaa } from "../vaa";
import { SignedVaa, parseTokenTransferVaa } from "../vaa";
import { getForeignAssetNear } from "./getForeignAsset";
export async function redeemOnEth(
@ -392,7 +392,7 @@ export async function redeemOnSui(
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
arguments: [
tx.object(coreBridgeStateObjectId),
tx.pure([...transferVAA]),
tx.pure(uint8ArrayToBCS(transferVAA)),
tx.object(SUI_CLOCK_OBJECT_ID),
],
});

View File

@ -13,7 +13,7 @@ import {
createWrappedOnXpla,
} from ".";
import { Bridge__factory } from "../ethers-contracts";
import { getPackageId, getWrappedCoinType } from "../sui";
import { getPackageId, getWrappedCoinType, uint8ArrayToBCS } from "../sui";
export async function updateWrappedOnEth(
tokenBridgeAddress: string,
@ -71,7 +71,7 @@ export async function updateWrappedOnSui(
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
arguments: [
tx.object(coreBridgeStateObjectId),
tx.pure([...attestVAA]),
tx.pure(uint8ArrayToBCS(attestVAA)),
tx.object(SUI_CLOCK_OBJECT_ID),
],
});