1- import { SuiClient , SuiHTTPTransport } from '@mysten/sui.js /client' ;
1+ import { SuiClient , SuiHTTPTransport } from '@mysten/sui/client' ;
22import {
3- TransactionBlock ,
3+ Transaction ,
44 TransactionObjectArgument ,
5- } from '@mysten/sui.js /transactions' ;
5+ } from '@mysten/sui/transactions' ;
66import { 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 */
123123export 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 */
141141export 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 */
182182export 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 */
250253export 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 */
275278export 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 ,
0 commit comments