Skip to content

Commit

Permalink
feat: update sui sdk to newest version (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: npty <[email protected]>
Co-authored-by: Milap Sheth <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2024
1 parent 5c829ce commit 5e28d52
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 94 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-kings-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axelar-network/axelar-cgp-sui': minor
---

Update to the new Sui SDK
143 changes: 70 additions & 73 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
},
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.32.2",
"@mysten/sui.js": "^0.54.1",
"@mysten/sui": "^1.3.0",
"@types/tmp": "^0.2.6",
"child_process": "^1.0.2",
"ethers": "^5.0.0",
"fs": "^0.0.1-security",
"secp256k1": "^5.0.0",
"tmp": "^0.2.1",
"@types/tmp": "^0.2.6"
"tmp": "^0.2.1"
},
"devDependencies": {
"@changesets/cli": "^2.27.6",
Expand Down
2 changes: 1 addition & 1 deletion src/bcs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bcs } from '@mysten/sui.js/bcs';
import { bcs } from '@mysten/sui/bcs';

function getAxelarStructs() {
const Bytes32 = bcs.Address;
Expand Down
22 changes: 11 additions & 11 deletions src/tx-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
SuiObjectChange,
SuiTransactionBlockResponse,
SuiTransactionBlockResponseOptions,
} from '@mysten/sui.js/client';
import { Keypair } from '@mysten/sui.js/dist/cjs/cryptography';
import { TransactionBlock, TransactionObjectInput, TransactionResult } from '@mysten/sui.js/transactions';
} from '@mysten/sui/client';
import { Keypair } from '@mysten/sui/dist/cjs/cryptography';
import { Transaction, TransactionObjectInput, TransactionResult } from '@mysten/sui/transactions';
import { Bytes, utils as ethersUtils } from 'ethers';
import tmp from 'tmp';
import { updateMoveToml } from './utils';
Expand All @@ -32,7 +32,7 @@ function updateCache(objectChanges: SuiObjectChange[]) {
}
}

function getObject(tx: TransactionBlock, object: TransactionObjectInput): TransactionObjectInput {
function getObject(tx: Transaction, object: TransactionObjectInput): TransactionObjectInput {
if (Array.isArray(object)) {
object = hexlify(object);
}
Expand Down Expand Up @@ -78,7 +78,7 @@ function getTypeName(type: SuiMoveNormalizedType): string {
return (type as string).toLowerCase();
}

function getNestedStruct(tx: TransactionBlock, type: SuiMoveNormalizedType, arg: TransactionObjectInput): null | TransactionObjectInput {
function getNestedStruct(tx: Transaction, type: SuiMoveNormalizedType, arg: TransactionObjectInput): null | TransactionObjectInput {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let inside = type as any;

Expand All @@ -105,12 +105,12 @@ function getNestedStruct(tx: TransactionBlock, type: SuiMoveNormalizedType, arg:
const typeName = getTypeName((type as { Vector: SuiMoveNormalizedType }).Vector);
return tx.makeMoveVec({
type: typeName,
objects: nested,
elements: nested,
});
}

function serialize(
tx: TransactionBlock,
tx: Transaction,
type: SuiMoveNormalizedType,
arg: TransactionObjectInput,
):
Expand Down Expand Up @@ -199,10 +199,10 @@ function isString(parameter: SuiMoveNormalizedType): boolean {

export class TxBuilder {
client: SuiClient;
tx: TransactionBlock;
tx: Transaction;
constructor(client: SuiClient) {
this.client = client;
this.tx = new TransactionBlock();
this.tx = new Transaction();
}

async moveCall(moveCallInfo: {
Expand Down Expand Up @@ -283,8 +283,8 @@ export class TxBuilder {
}

async signAndExecute(keypair: Keypair, options: SuiTransactionBlockResponseOptions): Promise<SuiTransactionBlockResponse> {
let result = await this.client.signAndExecuteTransactionBlock({
transactionBlock: this.tx,
let result = await this.client.signAndExecuteTransaction({
transaction: this.tx,
signer: keypair,
options: {
showEffects: true,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { bcs } = require('@mysten/sui.js/bcs');
const { bcs } = require('@mysten/sui/bcs');
const { fromHEX, toHEX } = require('@mysten/bcs');

export const UID = bcs.fixedArray(32, bcs.u8()).transform({
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import { getFullnodeUrl } from '@mysten/sui.js/client';
import { getFullnodeUrl } from '@mysten/sui/client';

export function getModuleNameFromSymbol(symbol: string) {
function isNumber(char: string) {
Expand Down
8 changes: 4 additions & 4 deletions test/axelar-gateway.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { SuiClient, getFullnodeUrl } = require('@mysten/sui.js/client');
const { Ed25519Keypair } = require('@mysten/sui.js/keypairs/ed25519');
const { Secp256k1Keypair } = require('@mysten/sui.js/keypairs/secp256k1');
const { requestSuiFromFaucetV0, getFaucetHost } = require('@mysten/sui.js/faucet');
const { SuiClient, getFullnodeUrl } = require('@mysten/sui/client');
const { Ed25519Keypair } = require('@mysten/sui/keypairs/ed25519');
const { Secp256k1Keypair } = require('@mysten/sui/keypairs/secp256k1');
const { requestSuiFromFaucetV0, getFaucetHost } = require('@mysten/sui/faucet');
const { publishPackage, getRandomBytes32, expectRevert, expectEvent } = require('./utils');
const { TxBuilder } = require('../dist/tx-builder');
const {
Expand Down

0 comments on commit 5e28d52

Please sign in to comment.