Skip to content

Commit 0cec4ab

Browse files
committed
update mysten sui to use the latest package
1 parent 4e4f832 commit 0cec4ab

File tree

7 files changed

+81
-76
lines changed

7 files changed

+81
-76
lines changed

apps/client/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const metadata = {
1616
export default function RootLayout({ children }: { children: React.ReactNode }) {
1717
return (
1818
<html lang="en">
19-
<body className={`h-[100%] ${manrope.className} bg-gray-100`}>
19+
<body className={`h-[100%] ${manrope.className} bg-gradient-to-b from-white to-gray-100`}>
2020
<Providers>
2121
<Sidebar>
2222
<div className="m-4">

apps/client/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ export default function Home() {
6666
};
6767

6868
return (
69-
<div className="h-[90dvh] w-[90dvw] flex justify-center relative items-center flex-col bg-gray-100">
69+
<div className="h-[90dvh] w-[90dvw] flex justify-center relative items-center flex-col bg-gradient-to-b from-white to-gray-100">
7070
{/* Chat messages */}
71-
<div className="flex-grow overflow-y-auto p-4 w-[82dvw] rounded mt-3 bg-gray-100 relative">
71+
<div className="flex-grow overflow-y-auto p-4 w-[82dvw] rounded mt-3 bg-transparent relative">
7272
{/* Fixed background container */}
7373
<div className="fixed inset-0 flex justify-center items-center pointer-events-none">
7474
<img src="/atomaLogo.svg" alt="Logo" className="w-[300px] h-[200px] opacity-10" />

packages/sui-agent/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
"license": "ISC",
1717
"description": "",
1818
"dependencies": {
19-
"@mysten/sui.js": "^0.54.1",
19+
"@mysten/sui": "1.1.0",
2020
"aftermath-ts-sdk": "^1.2.49",
2121
"atoma-sdk": "github:atoma-network/atoma-sdk-typescript",
2222
"axios": "^1.7.9",
23-
"typescript": "^5.7.3",
24-
"dotenv": "^16.4.7"
23+
"dotenv": "^16.4.7",
24+
"typescript": "^5.7.3"
2525
},
2626
"devDependencies": {
2727
"@types/dotenv": "^8.2.0",

packages/sui-agent/src/tools/aftermath/PoolTransactionTool.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Aftermath } from 'aftermath-ts-sdk';
2-
import { TransactionBlock } from '@mysten/sui.js/transactions';
3-
import { SuiClient } from '@mysten/sui.js/client';
2+
import { Transaction } from '@mysten/sui/transactions';
3+
import { SuiClient } from '@mysten/sui/client';
44
import { handleError } from '../../utils';
55
import { initSuiClient } from '../../transactions/TransactionTool';
66
import { getRankedPools } from './PoolTool';
@@ -70,8 +70,8 @@ export async function buildMultiPoolDepositTx(
7070
walletAddress: string,
7171
poolDeposits: Array<{ poolId: string; amount: bigint }>,
7272
slippage = 0.01,
73-
): Promise<TransactionBlock> {
74-
const tx = new TransactionBlock();
73+
): Promise<Transaction> {
74+
const tx = new Transaction();
7575
tx.setGasBudget(2000000 * poolDeposits.length); // Scale gas budget with number of deposits
7676

7777
for (const deposit of poolDeposits) {
@@ -105,7 +105,7 @@ export async function buildMultiPoolDepositTx(
105105
arguments: depositTx.arguments.map((arg) =>
106106
typeof arg === 'string' && arg.startsWith('0x')
107107
? tx.object(arg)
108-
: tx.pure(arg),
108+
: tx.pure.address(arg as string),
109109
),
110110
typeArguments: depositTx.typeArguments,
111111
});
@@ -195,8 +195,8 @@ export async function buildMultiPoolWithdrawTx(
195195
walletAddress: string,
196196
poolWithdraws: Array<{ poolId: string; lpAmount: bigint }>,
197197
slippage = 0.01,
198-
): Promise<TransactionBlock> {
199-
const tx = new TransactionBlock();
198+
): Promise<Transaction> {
199+
const tx = new Transaction();
200200
tx.setGasBudget(2000000 * poolWithdraws.length);
201201

202202
for (const withdraw of poolWithdraws) {
@@ -221,7 +221,7 @@ export async function buildMultiPoolWithdrawTx(
221221
arguments: withdrawTx.arguments.map((arg) =>
222222
typeof arg === 'string' && arg.startsWith('0x')
223223
? tx.object(arg)
224-
: tx.pure(arg),
224+
: tx.pure.address(arg as string),
225225
),
226226
typeArguments: withdrawTx.typeArguments,
227227
});

packages/sui-agent/src/transactions/TransactionTool.ts

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { SuiClient, SuiHTTPTransport } from '@mysten/sui.js/client';
1+
import { SuiClient, SuiHTTPTransport } from '@mysten/sui/client';
22
import {
3-
TransactionBlock,
3+
Transaction,
44
TransactionObjectArgument,
5-
} from '@mysten/sui.js/transactions';
5+
} from '@mysten/sui/transactions';
66
import { TokenBalance, NETWORK_CONFIG } from '../@types/interface';
7-
import { Signer } from '@mysten/sui.js/cryptography';
7+
import { Signer } from '@mysten/sui/cryptography';
88

99
/** --------------------------------------------------------------------------
1010
* Core Transaction Infrastructure
@@ -31,8 +31,8 @@ export function initSuiClient(
3131
* @param gasBudget - Maximum gas to spend (in MIST)
3232
* @returns Initialized TransactionBlock
3333
*/
34-
export function createPTB(gasBudget = 2000000): TransactionBlock {
35-
const tx = new TransactionBlock();
34+
export function createPTB(gasBudget = 2000000): Transaction {
35+
const tx = new Transaction();
3636
tx.setGasBudget(gasBudget);
3737
return tx;
3838
}
@@ -58,8 +58,8 @@ export async function buildTransferTx(
5858
toAddress: string,
5959
tokenType: string,
6060
amount: bigint,
61-
): Promise<TransactionBlock> {
62-
const tx = new TransactionBlock();
61+
): Promise<Transaction> {
62+
const tx = new Transaction();
6363

6464
// Set gas budget
6565
tx.setGasBudget(2000000);
@@ -76,8 +76,8 @@ export async function buildTransferTx(
7676

7777
// Select coin and perform transfer
7878
const coin = tx.object(coins.data[0].coinObjectId);
79-
const [splitCoin] = tx.splitCoins(coin, [tx.pure(amount)]);
80-
tx.transferObjects([splitCoin], tx.pure(toAddress));
79+
const [splitCoin] = tx.splitCoins(coin, [tx.pure.u64(amount)]);
80+
tx.transferObjects([splitCoin], tx.pure.address(toAddress));
8181

8282
return tx;
8383
}
@@ -96,13 +96,13 @@ export async function buildMultiTransferTx(
9696
from: string,
9797
to: string,
9898
transfers: TokenBalance[],
99-
): Promise<TransactionBlock> {
100-
const tx = new TransactionBlock();
99+
): Promise<Transaction> {
100+
const tx = new Transaction();
101101

102102
// Process each transfer
103103
for (const transfer of transfers) {
104-
const [coin] = tx.splitCoins(tx.gas, [tx.pure(transfer.amount)]);
105-
tx.transferObjects([coin], tx.pure(to));
104+
const [coin] = tx.splitCoins(tx.gas, [tx.pure.u64(transfer.amount)]);
105+
tx.transferObjects([coin], tx.pure.address(to));
106106
}
107107

108108
return tx;
@@ -122,7 +122,7 @@ export async function buildMultiTransferTx(
122122
*/
123123
export async function estimateGas(
124124
client: SuiClient,
125-
tx: TransactionBlock,
125+
tx: Transaction,
126126
): Promise<bigint> {
127127
const estimate = await client.dryRunTransactionBlock({
128128
transactionBlock: tx.serialize(),
@@ -140,12 +140,12 @@ export async function estimateGas(
140140
*/
141141
export async function executeTransaction(
142142
client: SuiClient,
143-
tx: TransactionBlock,
143+
tx: Transaction,
144144
signer: Signer,
145145
) {
146146
try {
147-
const result = await client.signAndExecuteTransactionBlock({
148-
transactionBlock: tx,
147+
const result = await client.signAndExecuteTransaction({
148+
transaction: tx,
149149
signer,
150150
options: {
151151
showEffects: true,
@@ -180,19 +180,22 @@ type MoveTarget = `${string}::${string}::${string}`;
180180
* addMoveCall(ptb, "0x2::sui::pay", [], [recipient, amount]);
181181
*/
182182
export function addMoveCall(
183-
tx: TransactionBlock,
183+
tx: Transaction,
184184
target: MoveTarget,
185185
typeArguments: string[] = [],
186186
args: (string | number | boolean | bigint)[] = [],
187-
): TransactionBlock {
187+
): Transaction {
188188
tx.moveCall({
189189
target,
190190
typeArguments,
191191
arguments: args.map((arg) => {
192192
if (typeof arg === 'string' && arg.startsWith('0x')) {
193193
return tx.object(arg);
194194
}
195-
return tx.pure(arg);
195+
if (typeof arg === 'bigint') {
196+
return tx.pure.u64(arg);
197+
}
198+
return tx.pure.address(arg as string);
196199
}),
197200
});
198201
return tx;
@@ -218,7 +221,7 @@ export async function createMergeCoinsTx(
218221
coinType: string,
219222
walletAddress: string,
220223
maxCoins = 10,
221-
): Promise<TransactionBlock> {
224+
): Promise<Transaction> {
222225
// Fetch available coins
223226
const coins = await client.getCoins({
224227
owner: walletAddress,
@@ -230,7 +233,7 @@ export async function createMergeCoinsTx(
230233
}
231234

232235
// Create merge transaction
233-
const tx = new TransactionBlock();
236+
const tx = new Transaction();
234237
const coinsToMerge = coins.data.slice(0, maxCoins);
235238
const primaryCoin = coinsToMerge[0].coinObjectId;
236239
const mergeCoins = coinsToMerge.slice(1).map((coin) => coin.coinObjectId);
@@ -248,14 +251,14 @@ export async function createMergeCoinsTx(
248251
* @returns Transaction block ready for sponsor signature
249252
*/
250253
export async function createSponsoredTx(
251-
tx: TransactionBlock,
254+
tx: Transaction,
252255
sender: string,
253256
sponsor: string,
254257
sponsorCoins: { objectId: string; version: string; digest: string }[],
255-
): Promise<TransactionBlock> {
258+
): Promise<Transaction> {
256259
// Extract transaction kind
257260
const kindBytes = await tx.build({ onlyTransactionKind: true });
258-
const sponsoredTx = TransactionBlock.fromKind(kindBytes);
261+
const sponsoredTx = Transaction.fromKind(kindBytes);
259262

260263
// Set up sponsored transaction
261264
sponsoredTx.setSender(sender);
@@ -273,12 +276,12 @@ export async function createSponsoredTx(
273276
* @returns Move vector input for transaction
274277
*/
275278
export function createMoveVec(
276-
tx: TransactionBlock,
279+
tx: Transaction,
277280
elements: (string | TransactionObjectArgument)[],
278281
type?: string,
279282
) {
280283
return tx.makeMoveVec({
281-
objects: elements,
284+
elements,
282285
type,
283286
});
284287
}
@@ -303,10 +306,10 @@ export class TransactionAgent {
303306
* @param recipient - Recipient address
304307
* @returns Prepared transaction block
305308
*/
306-
buildTransferTx(amount: bigint, recipient: string): TransactionBlock {
307-
const tx = new TransactionBlock();
308-
const [coin] = tx.splitCoins(tx.gas, [tx.pure(amount)]);
309-
tx.transferObjects([coin], tx.pure(recipient));
309+
buildTransferTx(amount: bigint, recipient: string): Transaction {
310+
const tx = new Transaction();
311+
const [coin] = tx.splitCoins(tx.gas, [tx.pure.u64(amount)]);
312+
tx.transferObjects([coin], tx.pure.address(recipient));
310313
return tx;
311314
}
312315

@@ -319,8 +322,8 @@ export class TransactionAgent {
319322
buildMergeCoinsTx(
320323
destinationCoin: string,
321324
sourceCoins: string[],
322-
): TransactionBlock {
323-
const tx = new TransactionBlock();
325+
): Transaction {
326+
const tx = new Transaction();
324327
tx.mergeCoins(
325328
tx.object(destinationCoin),
326329
sourceCoins.map((coin) => tx.object(coin)),
@@ -339,16 +342,19 @@ export class TransactionAgent {
339342
target: `${string}::${string}::${string}`,
340343
typeArguments: string[],
341344
args: (string | number | boolean | bigint)[],
342-
): TransactionBlock {
343-
const tx = new TransactionBlock();
345+
): Transaction {
346+
const tx = new Transaction();
344347
tx.moveCall({
345348
target,
346349
typeArguments,
347350
arguments: args.map((arg) => {
348351
if (typeof arg === 'string' && arg.startsWith('0x')) {
349352
return tx.object(arg);
350353
}
351-
return tx.pure(arg);
354+
if (typeof arg === 'bigint') {
355+
return tx.pure.u64(arg);
356+
}
357+
return tx.pure.address(arg as string);
352358
}),
353359
});
354360
return tx;
@@ -363,13 +369,13 @@ export class TransactionAgent {
363369
* @returns Sponsored transaction block
364370
*/
365371
async createSponsoredTx(
366-
tx: TransactionBlock,
372+
tx: Transaction,
367373
sender: string,
368374
sponsor: string,
369375
sponsorCoins: { objectId: string; version: string; digest: string }[],
370-
): Promise<TransactionBlock> {
376+
): Promise<Transaction> {
371377
const kindBytes = await tx.build({ onlyTransactionKind: true });
372-
const sponsoredTx = TransactionBlock.fromKind(kindBytes);
378+
const sponsoredTx = Transaction.fromKind(kindBytes);
373379

374380
sponsoredTx.setSender(sender);
375381
sponsoredTx.setGasOwner(sponsor);
@@ -386,12 +392,12 @@ export class TransactionAgent {
386392
* @returns Move vector
387393
*/
388394
createMoveVec(
389-
tx: TransactionBlock,
395+
tx: Transaction,
390396
elements: (string | TransactionObjectArgument)[],
391397
type?: string,
392398
) {
393399
return tx.makeMoveVec({
394-
objects: elements,
400+
elements,
395401
type,
396402
});
397403
}
@@ -401,7 +407,7 @@ export class TransactionAgent {
401407
* @param tx - Transaction block to estimate
402408
* @returns Estimated gas cost in MIST
403409
*/
404-
async estimateGas(tx: TransactionBlock): Promise<bigint> {
410+
async estimateGas(tx: Transaction): Promise<bigint> {
405411
try {
406412
const dryRunResult = await this.client.dryRunTransactionBlock({
407413
transactionBlock: tx.serialize(),
@@ -420,7 +426,7 @@ export class TransactionAgent {
420426
* @returns Transaction block with effects and events
421427
*/
422428
async waitForTransaction(digest: string) {
423-
return this.client.waitForTransactionBlock({
429+
return this.client.waitForTransaction({
424430
digest,
425431
options: {
426432
showEffects: true,

packages/sui-agent/src/utils/toolWrappers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
createMergeCoinsTx,
1717
estimateGas,
1818
} from '../transactions/TransactionTool';
19-
import { TransactionBlock } from '@mysten/sui.js/transactions';
19+
import { Transaction } from '@mysten/sui/transactions';
2020

2121
// Transaction wrapper functions
2222
export async function transferCoinWrapper(
@@ -102,9 +102,9 @@ export async function mergeCoinsWrapper(
102102
}
103103

104104
export async function estimateGasWrapper(
105-
...args: (string | number | bigint | boolean | TransactionBlock)[]
105+
...args: (string | number | bigint | boolean | Transaction)[]
106106
): Promise<string> {
107-
const [transaction] = args as [TransactionBlock];
107+
const [transaction] = args as [Transaction];
108108
const client = initSuiClient();
109109
const gasEstimate = await estimateGas(client, transaction);
110110
return JSON.stringify([

0 commit comments

Comments
 (0)