sdk/js: sui support posting VAAs over 1024
This commit is contained in:
parent
39369d3d2b
commit
d050ad1d67
|
@ -1,5 +1,11 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.9.16
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
Sui redeem fix
|
||||||
|
|
||||||
## 0.9.15
|
## 0.9.15
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@certusone/wormhole-sdk",
|
"name": "@certusone/wormhole-sdk",
|
||||||
"version": "0.9.15",
|
"version": "0.9.16",
|
||||||
"description": "SDK for interacting with Wormhole",
|
"description": "SDK for interacting with Wormhole",
|
||||||
"homepage": "https://wormhole.com",
|
"homepage": "https://wormhole.com",
|
||||||
"main": "./lib/cjs/index.js",
|
"main": "./lib/cjs/index.js",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
builder,
|
||||||
getObjectType,
|
getObjectType,
|
||||||
isValidSuiAddress as isValidFullSuiAddress,
|
isValidSuiAddress as isValidFullSuiAddress,
|
||||||
JsonRpcProvider,
|
JsonRpcProvider,
|
||||||
|
@ -14,8 +15,12 @@ import { SuiRpcValidationError } from "./error";
|
||||||
import { SuiError } from "./types";
|
import { SuiError } from "./types";
|
||||||
import { DynamicFieldPage } from "@mysten/sui.js/dist/types/dynamic_fields";
|
import { DynamicFieldPage } from "@mysten/sui.js/dist/types/dynamic_fields";
|
||||||
|
|
||||||
|
const MAX_PURE_ARGUMENT_SIZE = 16 * 1024;
|
||||||
const UPGRADE_CAP_TYPE = "0x2::package::UpgradeCap";
|
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 (
|
export const executeTransactionBlock = async (
|
||||||
signer: RawSigner,
|
signer: RawSigner,
|
||||||
transactionBlock: TransactionBlock
|
transactionBlock: TransactionBlock
|
||||||
|
|
|
@ -32,6 +32,7 @@ import {
|
||||||
getUpgradeCapObjectId,
|
getUpgradeCapObjectId,
|
||||||
getWrappedCoinType,
|
getWrappedCoinType,
|
||||||
publishCoin,
|
publishCoin,
|
||||||
|
uint8ArrayToBCS,
|
||||||
} from "../sui";
|
} from "../sui";
|
||||||
import { callFunctionNear } from "../utils";
|
import { callFunctionNear } from "../utils";
|
||||||
import { SignedVaa } from "../vaa";
|
import { SignedVaa } from "../vaa";
|
||||||
|
@ -247,7 +248,7 @@ export async function createWrappedOnSui(
|
||||||
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
|
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
|
||||||
arguments: [
|
arguments: [
|
||||||
tx.object(coreBridgeStateObjectId),
|
tx.object(coreBridgeStateObjectId),
|
||||||
tx.pure([...attestVAA]),
|
tx.pure(uint8ArrayToBCS(attestVAA)),
|
||||||
tx.object(SUI_CLOCK_OBJECT_ID),
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,13 +5,13 @@ import {
|
||||||
} from "@mysten/sui.js";
|
} from "@mysten/sui.js";
|
||||||
import {
|
import {
|
||||||
ACCOUNT_SIZE,
|
ACCOUNT_SIZE,
|
||||||
|
NATIVE_MINT,
|
||||||
|
TOKEN_PROGRAM_ID,
|
||||||
createCloseAccountInstruction,
|
createCloseAccountInstruction,
|
||||||
createInitializeAccountInstruction,
|
createInitializeAccountInstruction,
|
||||||
createTransferInstruction,
|
createTransferInstruction,
|
||||||
getMinimumBalanceForRentExemptAccount,
|
getMinimumBalanceForRentExemptAccount,
|
||||||
getMint,
|
getMint,
|
||||||
NATIVE_MINT,
|
|
||||||
TOKEN_PROGRAM_ID,
|
|
||||||
} from "@solana/spl-token";
|
} from "@solana/spl-token";
|
||||||
import {
|
import {
|
||||||
Commitment,
|
Commitment,
|
||||||
|
@ -27,7 +27,7 @@ import { MsgExecuteContract as XplaMsgExecuteContract } from "@xpla/xpla.js";
|
||||||
import { Algodv2 } from "algosdk";
|
import { Algodv2 } from "algosdk";
|
||||||
import { AptosClient, Types } from "aptos";
|
import { AptosClient, Types } from "aptos";
|
||||||
import BN from "bn.js";
|
import BN from "bn.js";
|
||||||
import { ethers, Overrides } from "ethers";
|
import { Overrides, ethers } from "ethers";
|
||||||
import { fromUint8Array } from "js-base64";
|
import { fromUint8Array } from "js-base64";
|
||||||
import { FunctionCallOptions } from "near-api-js/lib/account";
|
import { FunctionCallOptions } from "near-api-js/lib/account";
|
||||||
import { Provider } from "near-api-js/lib/providers";
|
import { Provider } from "near-api-js/lib/providers";
|
||||||
|
@ -42,17 +42,17 @@ import {
|
||||||
createCompleteTransferNativeInstruction,
|
createCompleteTransferNativeInstruction,
|
||||||
createCompleteTransferWrappedInstruction,
|
createCompleteTransferWrappedInstruction,
|
||||||
} from "../solana/tokenBridge";
|
} from "../solana/tokenBridge";
|
||||||
import { getPackageId, getTokenCoinType } from "../sui";
|
import { getPackageId, getTokenCoinType, uint8ArrayToBCS } from "../sui";
|
||||||
import {
|
import {
|
||||||
callFunctionNear,
|
|
||||||
ChainId,
|
|
||||||
CHAIN_ID_NEAR,
|
CHAIN_ID_NEAR,
|
||||||
CHAIN_ID_SOLANA,
|
CHAIN_ID_SOLANA,
|
||||||
hashLookup,
|
ChainId,
|
||||||
MAX_VAA_DECIMALS,
|
MAX_VAA_DECIMALS,
|
||||||
|
callFunctionNear,
|
||||||
|
hashLookup,
|
||||||
uint8ArrayToHex,
|
uint8ArrayToHex,
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
import { parseTokenTransferVaa, SignedVaa } from "../vaa";
|
import { SignedVaa, parseTokenTransferVaa } from "../vaa";
|
||||||
import { getForeignAssetNear } from "./getForeignAsset";
|
import { getForeignAssetNear } from "./getForeignAsset";
|
||||||
|
|
||||||
export async function redeemOnEth(
|
export async function redeemOnEth(
|
||||||
|
@ -392,7 +392,7 @@ export async function redeemOnSui(
|
||||||
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
|
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
|
||||||
arguments: [
|
arguments: [
|
||||||
tx.object(coreBridgeStateObjectId),
|
tx.object(coreBridgeStateObjectId),
|
||||||
tx.pure([...transferVAA]),
|
tx.pure(uint8ArrayToBCS(transferVAA)),
|
||||||
tx.object(SUI_CLOCK_OBJECT_ID),
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
createWrappedOnXpla,
|
createWrappedOnXpla,
|
||||||
} from ".";
|
} from ".";
|
||||||
import { Bridge__factory } from "../ethers-contracts";
|
import { Bridge__factory } from "../ethers-contracts";
|
||||||
import { getPackageId, getWrappedCoinType } from "../sui";
|
import { getPackageId, getWrappedCoinType, uint8ArrayToBCS } from "../sui";
|
||||||
|
|
||||||
export async function updateWrappedOnEth(
|
export async function updateWrappedOnEth(
|
||||||
tokenBridgeAddress: string,
|
tokenBridgeAddress: string,
|
||||||
|
@ -71,7 +71,7 @@ export async function updateWrappedOnSui(
|
||||||
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
|
target: `${coreBridgePackageId}::vaa::parse_and_verify`,
|
||||||
arguments: [
|
arguments: [
|
||||||
tx.object(coreBridgeStateObjectId),
|
tx.object(coreBridgeStateObjectId),
|
||||||
tx.pure([...attestVAA]),
|
tx.pure(uint8ArrayToBCS(attestVAA)),
|
||||||
tx.object(SUI_CLOCK_OBJECT_ID),
|
tx.object(SUI_CLOCK_OBJECT_ID),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue