@layerzerolabs/lz-sui-oft-sdk-v2 3.0.133 → 3.0.134-sui.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -52,18 +52,22 @@ function parseOFTReceipt(data) {
52
52
  // src/modules/oft.ts
53
53
  var MODULE_NAME = "oft";
54
54
  var OFT_SENDER_MODULE_NAME = "oft_sender";
55
+ var OFT_IMPL_MODULE_NAME = "oft_impl";
56
+ var OFT_PTB_BUILDER_MODULE_NAME = "oft_ptb_builder";
55
57
  var OFTErrorCode = {
56
58
  // OFT related errors
57
- OFT_EComposeMsgNotAllowed: 1,
58
- OFT_EComposeMsgRequired: 2,
59
- OFT_EInvalidComposeQueue: 3,
60
- OFT_EInvalidLocalDecimals: 4,
61
- OFT_EPaused: 5,
62
- OFT_EPauseUnchanged: 6,
63
- OFT_ESlippageExceeded: 7,
64
- OFT_EInsufficientBalance: 8
59
+ EComposeMsgNotAllowed: 1,
60
+ EComposeMsgRequired: 2,
61
+ EInsufficientBalance: 3,
62
+ EInvalidAdminCap: 4,
63
+ EInvalidComposeQueue: 5,
64
+ EInvalidLocalDecimals: 6,
65
+ EInvalidMigrationCap: 7,
66
+ EInvalidSendContext: 8,
67
+ ESlippageExceeded: 9,
68
+ EWrongPackageVersion: 10
65
69
  };
66
- var _OFT_instances, buildSendParam_fn, target_fn, adminCapId_fn;
70
+ var _OFT_instances, buildSendParam_fn, target_fn, oappObjectId_fn, adminCapId_fn;
67
71
  var OFT = class {
68
72
  /**
69
73
  * Creates a new OFT instance for interacting with an Omnichain Fungible Token
@@ -74,94 +78,110 @@ var OFT = class {
74
78
  * @param coinType - The Sui coin type string (e.g., "0x123::mycoin::MYCOIN")
75
79
  * @param adminCapId - Optional admin capability object ID for privileged operations (required for admin functions)
76
80
  */
77
- constructor(protocolSDK, oftPackageId, oftObjectId, coinType, adminCapId) {
81
+ constructor(protocolSDK, oftPackageId, oftObjectId, coinType, oappObjectId, adminCapId) {
78
82
  __privateAdd(this, _OFT_instances);
79
83
  this.protocolSDK = protocolSDK;
80
84
  this.oftPackageId = oftPackageId;
81
85
  this.client = protocolSDK.client;
82
86
  this.objects = protocolSDK.objects;
83
87
  this.oftObjectId = oftObjectId;
88
+ this.oappObjectId = oappObjectId;
84
89
  this.adminCapId = adminCapId;
85
90
  this.coinType = coinType;
86
91
  }
92
+ /**
93
+ * Updates the associated OApp object ID
94
+ * @param oappObjectId - The new OApp object ID
95
+ */
96
+ setOappObjectId(oappObjectId) {
97
+ this.oappObjectId = oappObjectId;
98
+ }
87
99
  // ==========================================
88
- // ADMIN FUNCTIONS
100
+ // INITIALIZATION FUNCTIONS
89
101
  // ==========================================
90
- // These functions require admin privileges and are used for OFT configuration
91
- // and management. They require the adminCapId to be provided during construction.
102
+ // These functions are used to initialize OFT instances from OFTCreationTicket
92
103
  /**
93
- * Register OFT as an OApp with LayerZero endpoint
104
+ * Initialize an OFT instance with a treasury capability
105
+ * Creates a new OFT that mints its own tokens
94
106
  * @param tx - The transaction to add the move call to
95
- * @param lzReceiveInfo - PTB Builder lzReceiveInfoMoveCall result, used for protocol SDK to dynamically build the PTB
96
- * for OFT's lzReceive operation
107
+ * @param ticket - The OFTCreationTicket object ID or TransactionArgument
108
+ * @param treasury - The TreasuryCap object ID or TransactionArgument for the coin type
109
+ * @param metadata - The CoinMetadata object ID or TransactionArgument for the coin type
110
+ * @param sharedDecimals - Number of decimals to use for cross-chain operations
111
+ * @returns TransactionResult array containing [AdminCap, MigrationCap] - MigrationCap must be transferred or stored
97
112
  */
98
- registerOAppMoveCall(tx, lzReceiveInfo) {
99
- tx.moveCall({
100
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "register_oapp"),
113
+ initOftMoveCall(tx, ticket, oapp, treasury, metadata, sharedDecimals) {
114
+ return tx.moveCall({
115
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "init_oft", OFT_IMPL_MODULE_NAME),
101
116
  typeArguments: [this.coinType],
102
117
  arguments: [
103
- tx.object(this.oftObjectId),
104
- tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
105
- tx.object(this.objects.endpointV2),
106
- lzSuiSdkV2.asBytes(tx, lzReceiveInfo)
118
+ lzSuiSdkV2.asObject(tx, ticket),
119
+ lzSuiSdkV2.asObject(tx, oapp),
120
+ lzSuiSdkV2.asObject(tx, treasury),
121
+ lzSuiSdkV2.asObject(tx, metadata),
122
+ lzSuiSdkV2.asU8(tx, sharedDecimals)
107
123
  ]
108
124
  });
109
125
  }
110
126
  /**
111
- * Set enforced options for OFT messaging to a destination
127
+ * Initialize an OFT adapter instance
128
+ * Creates an OFT adapter that wraps an existing coin type
112
129
  * @param tx - The transaction to add the move call to
113
- * @param eid - Endpoint ID
114
- * @param msgType - Message type (SEND or SEND_AND_CALL)
115
- * @param options - Enforced options as bytes
130
+ * @param ticket - The OFTCreationTicket object ID or TransactionArgument
131
+ * @param metadata - The CoinMetadata object ID or TransactionArgument for the coin type
132
+ * @param sharedDecimals - Number of decimals to use for cross-chain operations
133
+ * @returns TransactionResult array containing [AdminCap, MigrationCap] - MigrationCap must be transferred or stored
116
134
  */
117
- setEnforcedOptionsMoveCall(tx, eid, msgType, options) {
118
- tx.moveCall({
119
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "set_enforced_options"),
135
+ initOftAdapterMoveCall(tx, ticket, oapp, metadata, sharedDecimals) {
136
+ return tx.moveCall({
137
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "init_oft_adapter", OFT_IMPL_MODULE_NAME),
120
138
  typeArguments: [this.coinType],
121
- arguments: [
122
- tx.object(this.oftObjectId),
123
- tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
124
- lzSuiSdkV2.asU32(tx, eid),
125
- lzSuiSdkV2.asU16(tx, msgType),
126
- lzSuiSdkV2.asBytes(tx, options)
127
- ]
139
+ arguments: [lzSuiSdkV2.asObject(tx, ticket), lzSuiSdkV2.asObject(tx, oapp), lzSuiSdkV2.asObject(tx, metadata), lzSuiSdkV2.asU8(tx, sharedDecimals)]
128
140
  });
129
141
  }
142
+ // ==========================================
143
+ // ADMIN FUNCTIONS
144
+ // ==========================================
145
+ // These functions require admin privileges and are used for OFT configuration
146
+ // and management. They require the adminCapId to be provided during construction.
130
147
  /**
131
- * Set peer OFT on another chain
148
+ * Get LayerZero receive information for OFT registration
149
+ *
150
+ * This function prepares the necessary metadata for registering an OFT
151
+ * with the LayerZero endpoint, enabling it to receive cross-chain messages.
152
+ *
132
153
  * @param tx - The transaction to add the move call to
133
- * @param messagingChannel - The messaging channel object ID
134
- * @param eid - Peer endpoint ID
135
- * @param peer - Peer OFT address as bytes
154
+ * @param composerManager - The composer manager object ID for routing compose transfers
155
+ * @returns TransactionResult containing serialized execution metadata for endpoint registration
136
156
  */
137
- setPeerMoveCall(tx, messagingChannel, eid, peer) {
138
- tx.moveCall({
139
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "set_peer"),
157
+ lzReceiveInfoMoveCall(tx, composerManager) {
158
+ return tx.moveCall({
159
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "lz_receive_info", OFT_PTB_BUILDER_MODULE_NAME),
140
160
  typeArguments: [this.coinType],
141
161
  arguments: [
142
162
  tx.object(this.oftObjectId),
143
- tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
144
163
  tx.object(this.objects.endpointV2),
145
- lzSuiSdkV2.asObject(tx, messagingChannel),
146
- lzSuiSdkV2.asU32(tx, eid),
147
- lzSuiSdkV2.asBytes32(tx, peer, this.protocolSDK.getUtils())
164
+ lzSuiSdkV2.asObject(tx, composerManager),
165
+ tx.object.clock()
148
166
  ]
149
167
  });
150
168
  }
151
169
  /**
152
- * Set delegate for OFT
170
+ * Register OFT as an OApp with LayerZero endpoint
153
171
  * @param tx - The transaction to add the move call to
154
- * @param newDelegate - The new delegate address
172
+ * @param lzReceiveInfo - PTB Builder lzReceiveInfoMoveCall result, used for protocol SDK to dynamically build the PTB
173
+ * for OFT's lzReceive operation
155
174
  */
156
- setDelegateMoveCall(tx, newDelegate) {
175
+ registerOAppMoveCall(tx, lzReceiveInfo) {
157
176
  tx.moveCall({
158
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "set_delegate"),
177
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "register_oapp"),
159
178
  typeArguments: [this.coinType],
160
179
  arguments: [
161
180
  tx.object(this.oftObjectId),
181
+ tx.object(__privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
162
182
  tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
163
183
  tx.object(this.objects.endpointV2),
164
- lzSuiSdkV2.asAddress(tx, newDelegate)
184
+ lzSuiSdkV2.asBytes(tx, lzReceiveInfo)
165
185
  ]
166
186
  });
167
187
  }
@@ -193,16 +213,58 @@ var OFT = class {
193
213
  arguments: [tx.object(this.oftObjectId), tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)), lzSuiSdkV2.asAddress(tx, feeDepositAddress)]
194
214
  });
195
215
  }
216
+ setDefaultFeeBpsMoveCall(tx, feeBps) {
217
+ tx.moveCall({
218
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "set_default_fee_bps"),
219
+ typeArguments: [this.coinType],
220
+ arguments: [tx.object(this.oftObjectId), tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)), lzSuiSdkV2.asU64(tx, feeBps)]
221
+ });
222
+ }
196
223
  /**
197
- * Set fee basis points for OFT transfers
224
+ * Set fee basis points for a specific destination chain
198
225
  * @param tx - The transaction to add the move call to
199
- * @param feeBps - The fee in basis points
226
+ * @param dstEid - Destination endpoint ID
227
+ * @param feeBps - Fee rate in basis points (0-10,000, where 10,000 = 100%)
200
228
  */
201
- setFeeBpsMoveCall(tx, feeBps) {
229
+ setFeeBpsMoveCall(tx, dstEid, feeBps) {
202
230
  tx.moveCall({
203
231
  target: __privateMethod(this, _OFT_instances, target_fn).call(this, "set_fee_bps"),
204
232
  typeArguments: [this.coinType],
205
- arguments: [tx.object(this.oftObjectId), tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)), lzSuiSdkV2.asU64(tx, feeBps)]
233
+ arguments: [
234
+ tx.object(this.oftObjectId),
235
+ tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
236
+ lzSuiSdkV2.asU32(tx, dstEid),
237
+ lzSuiSdkV2.asU64(tx, feeBps)
238
+ ]
239
+ });
240
+ }
241
+ /**
242
+ * Removes the fee rate for a specific destination chain
243
+ * @param tx - The transaction to add the move call to
244
+ * @param dstEid - Destination endpoint ID
245
+ */
246
+ unsetFeeBpsMoveCall(tx, dstEid) {
247
+ tx.moveCall({
248
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "unset_fee_bps"),
249
+ typeArguments: [this.coinType],
250
+ arguments: [tx.object(this.oftObjectId), tx.object(__privateMethod(this, _OFT_instances, adminCapId_fn).call(this)), lzSuiSdkV2.asU32(tx, dstEid)]
251
+ });
252
+ }
253
+ // ==========================================
254
+ // MIGRATION ADMIN FUNCTIONS
255
+ // ==========================================
256
+ // Handle OFT migration to new contracts
257
+ /**
258
+ * Migrate OFT instance to a new contract
259
+ * @param tx - The transaction to add the move call to
260
+ * @param migrationCap - Migration capability object ID or transaction argument
261
+ * @returns TransactionResult containing the migration ticket
262
+ */
263
+ migrateMoveCall(tx, migrationCap) {
264
+ return tx.moveCall({
265
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "migrate"),
266
+ typeArguments: [this.coinType],
267
+ arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asObject(tx, migrationCap)]
206
268
  });
207
269
  }
208
270
  // ==========================================
@@ -287,6 +349,7 @@ var OFT = class {
287
349
  typeArguments: [this.coinType],
288
350
  arguments: [
289
351
  tx.object(this.oftObjectId),
352
+ tx.object(__privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
290
353
  txSender,
291
354
  sendParamArg,
292
355
  lzSuiSdkV2.asObject(tx, coinProvided),
@@ -312,7 +375,13 @@ var OFT = class {
312
375
  const confirmSendResult = tx.moveCall({
313
376
  target: __privateMethod(this, _OFT_instances, target_fn).call(this, "confirm_send"),
314
377
  typeArguments: [this.coinType],
315
- arguments: [tx.object(this.oftObjectId), txSender, endpointCall, oftSendContext]
378
+ arguments: [
379
+ tx.object(this.oftObjectId),
380
+ tx.object(__privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
381
+ txSender,
382
+ endpointCall,
383
+ oftSendContext
384
+ ]
316
385
  });
317
386
  const nativeCoin = confirmSendResult[2];
318
387
  const zroCoin = confirmSendResult[3];
@@ -327,6 +396,59 @@ var OFT = class {
327
396
  typeArguments: [`0x2::coin::Coin<${this.protocolSDK.getZro().zroType}>`]
328
397
  });
329
398
  }
399
+ /**
400
+ * Process inbound cross-chain token transfers
401
+ * @param tx - The transaction to add the move call to
402
+ * @param call - LayerZero receive call containing the verified cross-chain message
403
+ * @returns TransactionResult containing the processed transfer
404
+ */
405
+ lzReceiveMoveCall(tx, call) {
406
+ return tx.moveCall({
407
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "lz_receive"),
408
+ typeArguments: [this.coinType],
409
+ arguments: [
410
+ tx.object(this.oftObjectId),
411
+ tx.object(__privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
412
+ lzSuiSdkV2.asObject(tx, call),
413
+ tx.object.clock()
414
+ ]
415
+ });
416
+ }
417
+ /**
418
+ * Process inbound cross-chain token transfers with compose functionality
419
+ * @param tx - The transaction to add the move call to
420
+ * @param composeQueue - The composer's message queue for sequencing operations
421
+ * @param composerManager - Manager managing token deposits for composers
422
+ * @param call - LayerZero receive call containing the verified cross-chain message
423
+ * @returns TransactionResult containing the processed transfer
424
+ */
425
+ lzReceiveWithComposeMoveCall(tx, composeQueue, composerManager, call) {
426
+ return tx.moveCall({
427
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "lz_receive_with_compose"),
428
+ typeArguments: [this.coinType],
429
+ arguments: [
430
+ tx.object(this.oftObjectId),
431
+ tx.object(__privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
432
+ lzSuiSdkV2.asObject(tx, composeQueue),
433
+ lzSuiSdkV2.asObject(tx, composerManager),
434
+ lzSuiSdkV2.asObject(tx, call),
435
+ tx.object.clock()
436
+ ]
437
+ });
438
+ }
439
+ /**
440
+ * Confirms and extracts results from a quote operation
441
+ * @param tx - The transaction to add the move call to
442
+ * @param call - Completed Call object from quote_send() execution
443
+ * @returns TransactionResult containing the messaging fee
444
+ */
445
+ confirmQuoteSendMoveCall(tx, call) {
446
+ return tx.moveCall({
447
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "confirm_quote_send"),
448
+ typeArguments: [this.coinType],
449
+ arguments: [tx.object(this.oftObjectId), tx.object(__privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)), lzSuiSdkV2.asObject(tx, call)]
450
+ });
451
+ }
330
452
  // ==========================================
331
453
  // QUOTE FUNCTIONS
332
454
  // ==========================================
@@ -369,7 +491,13 @@ var OFT = class {
369
491
  const quoteCall = tx.moveCall({
370
492
  target: __privateMethod(this, _OFT_instances, target_fn).call(this, "quote_send"),
371
493
  typeArguments: [this.coinType],
372
- arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asAddress(tx, sender), sendParamArg, lzSuiSdkV2.asBool(tx, payInZro)]
494
+ arguments: [
495
+ tx.object(this.oftObjectId),
496
+ tx.object(__privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
497
+ lzSuiSdkV2.asAddress(tx, sender),
498
+ sendParamArg,
499
+ lzSuiSdkV2.asBool(tx, payInZro)
500
+ ]
373
501
  });
374
502
  return this.protocolSDK.getEndpoint().quote(tx, quoteCall, sender, validators, maxSimulationTimes);
375
503
  }
@@ -377,6 +505,56 @@ var OFT = class {
377
505
  // VIEW FUNCTIONS
378
506
  // ==========================================
379
507
  // Read-only functions to query OFT state and configuration
508
+ /**
509
+ * Get the upgrade version of this OFT instance
510
+ * @param tx - The transaction to add the move call to
511
+ * @returns Transaction result containing the upgrade version
512
+ */
513
+ upgradeVersionMoveCall(tx) {
514
+ return tx.moveCall({
515
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "upgrade_version"),
516
+ typeArguments: [this.coinType],
517
+ arguments: [tx.object(this.oftObjectId)]
518
+ });
519
+ }
520
+ /**
521
+ * Get the upgrade version of this OFT instance
522
+ * @returns Promise<bigint> - The upgrade version
523
+ */
524
+ async upgradeVersion() {
525
+ return lzSuiSdkV2.executeSimulate(
526
+ this.client,
527
+ (tx) => {
528
+ this.upgradeVersionMoveCall(tx);
529
+ },
530
+ (result) => BigInt(bcs.bcs.U64.parse(result[0].value))
531
+ );
532
+ }
533
+ /**
534
+ * Get the associated OApp object address
535
+ * @param tx - The transaction to add the move call to
536
+ * @returns Transaction result containing the OApp object address
537
+ */
538
+ oappObjectMoveCall(tx) {
539
+ return tx.moveCall({
540
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "oapp_object"),
541
+ typeArguments: [this.coinType],
542
+ arguments: [tx.object(this.oftObjectId)]
543
+ });
544
+ }
545
+ /**
546
+ * Get the associated OApp object address
547
+ * @returns Promise<string> - The OApp object address
548
+ */
549
+ async oappObject() {
550
+ return lzSuiSdkV2.executeSimulate(
551
+ this.client,
552
+ (tx) => {
553
+ this.oappObjectMoveCall(tx);
554
+ },
555
+ (result) => bcs.bcs.Address.parse(result[0].value)
556
+ );
557
+ }
380
558
  /**
381
559
  * Get OFT version information
382
560
  * @param tx - The transaction to add the move call to
@@ -406,17 +584,42 @@ var OFT = class {
406
584
  }
407
585
  );
408
586
  }
409
- oftAddressMoveCall(tx) {
587
+ oftCapIdMoveCall(tx) {
410
588
  return tx.moveCall({
411
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "oft_address"),
589
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "oft_cap_id"),
412
590
  typeArguments: [this.coinType],
413
591
  arguments: [tx.object(this.oftObjectId)]
414
592
  });
415
593
  }
416
- async oftAddress() {
594
+ async oftCapId() {
417
595
  return lzSuiSdkV2.executeSimulate(
418
596
  this.client,
419
- (tx) => this.oftAddressMoveCall(tx),
597
+ (tx) => this.oftCapIdMoveCall(tx),
598
+ (result) => bcs.bcs.Address.parse(result[0].value)
599
+ );
600
+ }
601
+ /**
602
+ * Get the migration capability address for this OFT
603
+ * @param tx - The transaction to add the move call to
604
+ * @returns Transaction result containing the migration capability address
605
+ */
606
+ migrationCapMoveCall(tx) {
607
+ return tx.moveCall({
608
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "migration_cap"),
609
+ typeArguments: [this.coinType],
610
+ arguments: [tx.object(this.oftObjectId)]
611
+ });
612
+ }
613
+ /**
614
+ * Get the migration capability address for this OFT
615
+ * @returns Promise<string> - The migration capability address
616
+ */
617
+ async migrationCap() {
618
+ return lzSuiSdkV2.executeSimulate(
619
+ this.client,
620
+ (tx) => {
621
+ this.migrationCapMoveCall(tx);
622
+ },
420
623
  (result) => bcs.bcs.Address.parse(result[0].value)
421
624
  );
422
625
  }
@@ -424,8 +627,8 @@ var OFT = class {
424
627
  return lzSuiSdkV2.executeSimulate(
425
628
  this.client,
426
629
  (tx) => {
427
- const oftAddress = this.oftAddressMoveCall(tx);
428
- this.protocolSDK.getEndpoint().getMessagingChannelMoveCall(tx, oftAddress);
630
+ const oftCapId = this.oftCapIdMoveCall(tx);
631
+ this.protocolSDK.getEndpoint().getMessagingChannelMoveCall(tx, oftCapId);
429
632
  },
430
633
  (result) => bcs.bcs.Address.parse(result[0].value)
431
634
  );
@@ -456,26 +659,26 @@ var OFT = class {
456
659
  );
457
660
  }
458
661
  /**
459
- * Get OFT admin address
662
+ * Get OFT admin capability address
460
663
  * @param tx - The transaction to add the move call to
461
- * @returns Transaction result containing the admin address
664
+ * @returns Transaction result containing the admin capability address
462
665
  */
463
- adminMoveCall(tx) {
666
+ adminCapMoveCall(tx) {
464
667
  return tx.moveCall({
465
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "admin"),
668
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "admin_cap"),
466
669
  typeArguments: [this.coinType],
467
670
  arguments: [tx.object(this.oftObjectId)]
468
671
  });
469
672
  }
470
673
  /**
471
- * Get OFT admin address
472
- * @returns Promise<string> - The admin address
674
+ * Get OFT admin capability address
675
+ * @returns Promise<string> - The admin capability address
473
676
  */
474
- async admin() {
677
+ async adminCap() {
475
678
  return lzSuiSdkV2.executeSimulate(
476
679
  this.client,
477
680
  (tx) => {
478
- this.adminMoveCall(tx);
681
+ this.adminCapMoveCall(tx);
479
682
  },
480
683
  (result) => bcs.bcs.Address.parse(result[0].value)
481
684
  );
@@ -505,6 +708,31 @@ var OFT = class {
505
708
  (result) => bcs.bcs.U8.parse(result[0].value)
506
709
  );
507
710
  }
711
+ /**
712
+ * Get the decimal conversion rate for this OFT
713
+ * @param tx - The transaction to add the move call to
714
+ * @returns Transaction result containing the decimal conversion rate
715
+ */
716
+ decimalConversionRateMoveCall(tx) {
717
+ return tx.moveCall({
718
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "decimal_conversion_rate"),
719
+ typeArguments: [this.coinType],
720
+ arguments: [tx.object(this.oftObjectId)]
721
+ });
722
+ }
723
+ /**
724
+ * Get the decimal conversion rate for this OFT
725
+ * @returns Promise<bigint> - The decimal conversion rate multiplier
726
+ */
727
+ async decimalConversionRate() {
728
+ return lzSuiSdkV2.executeSimulate(
729
+ this.client,
730
+ (tx) => {
731
+ this.decimalConversionRateMoveCall(tx);
732
+ },
733
+ (result) => BigInt(bcs.bcs.U64.parse(result[0].value))
734
+ );
735
+ }
508
736
  /**
509
737
  * Check if OFT is paused
510
738
  * @param tx - The transaction to add the move call to
@@ -560,26 +788,107 @@ var OFT = class {
560
788
  // ==========================================
561
789
  // Query current fee configuration and settings
562
790
  /**
563
- * Get fee basis points for OFT transfers
791
+ * Check if the OFT has a fee rate greater than 0 for the specified destination
792
+ * @param tx - The transaction to add the move call to
793
+ * @param dstEid - Destination endpoint ID
794
+ * @returns Transaction result containing whether fee exists
795
+ */
796
+ hasOftFeeMoveCall(tx, dstEid) {
797
+ return tx.moveCall({
798
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "has_oft_fee"),
799
+ typeArguments: [this.coinType],
800
+ arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asU32(tx, dstEid)]
801
+ });
802
+ }
803
+ /**
804
+ * Check if the OFT has a fee rate greater than 0 for the specified destination
805
+ * @param dstEid - Destination endpoint ID
806
+ * @returns Promise<boolean> - True if fee exists
807
+ */
808
+ async hasOftFee(dstEid) {
809
+ return lzSuiSdkV2.executeSimulate(
810
+ this.client,
811
+ (tx) => {
812
+ this.hasOftFeeMoveCall(tx, dstEid);
813
+ },
814
+ (result) => bcs.bcs.Bool.parse(result[0].value)
815
+ );
816
+ }
817
+ /**
818
+ * Get the effective fee rate for a specific destination chain
819
+ * @param tx - The transaction to add the move call to
820
+ * @param dstEid - Destination endpoint ID
821
+ * @returns Transaction result containing the effective fee basis points
822
+ */
823
+ effectiveFeeBpsMoveCall(tx, dstEid) {
824
+ return tx.moveCall({
825
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "effective_fee_bps"),
826
+ typeArguments: [this.coinType],
827
+ arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asU32(tx, dstEid)]
828
+ });
829
+ }
830
+ /**
831
+ * Get the effective fee rate for a specific destination chain
832
+ * @param dstEid - Destination endpoint ID
833
+ * @returns Promise<bigint> - The effective fee in basis points
834
+ */
835
+ async effectiveFeeBps(dstEid) {
836
+ return lzSuiSdkV2.executeSimulate(
837
+ this.client,
838
+ (tx) => {
839
+ this.effectiveFeeBpsMoveCall(tx, dstEid);
840
+ },
841
+ (result) => BigInt(bcs.bcs.U64.parse(result[0].value))
842
+ );
843
+ }
844
+ /**
845
+ * Get the default fee rate
564
846
  * @param tx - The transaction to add the move call to
847
+ * @returns Transaction result containing the default fee basis points
848
+ */
849
+ defaultFeeBpsMoveCall(tx) {
850
+ return tx.moveCall({
851
+ target: __privateMethod(this, _OFT_instances, target_fn).call(this, "default_fee_bps"),
852
+ typeArguments: [this.coinType],
853
+ arguments: [tx.object(this.oftObjectId)]
854
+ });
855
+ }
856
+ /**
857
+ * Get the default fee rate
858
+ * @returns Promise<bigint> - The default fee in basis points
859
+ */
860
+ async defaultFeeBps() {
861
+ return lzSuiSdkV2.executeSimulate(
862
+ this.client,
863
+ (tx) => {
864
+ this.defaultFeeBpsMoveCall(tx);
865
+ },
866
+ (result) => BigInt(bcs.bcs.U64.parse(result[0].value))
867
+ );
868
+ }
869
+ /**
870
+ * Get fee basis points for a specific destination chain
871
+ * @param tx - The transaction to add the move call to
872
+ * @param dstEid - Destination endpoint ID
565
873
  * @returns Transaction result containing the fee basis points
566
874
  */
567
- feeBpsMoveCall(tx) {
875
+ feeBpsMoveCall(tx, dstEid) {
568
876
  return tx.moveCall({
569
877
  target: __privateMethod(this, _OFT_instances, target_fn).call(this, "fee_bps"),
570
878
  typeArguments: [this.coinType],
571
- arguments: [tx.object(this.oftObjectId)]
879
+ arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asU32(tx, dstEid)]
572
880
  });
573
881
  }
574
882
  /**
575
- * Get fee basis points for OFT transfers
883
+ * Get fee basis points for a specific destination chain
884
+ * @param dstEid - Destination endpoint ID
576
885
  * @returns Promise<bigint> - The fee in basis points
577
886
  */
578
- async feeBps() {
887
+ async feeBps(dstEid) {
579
888
  return lzSuiSdkV2.executeSimulate(
580
889
  this.client,
581
890
  (tx) => {
582
- this.feeBpsMoveCall(tx);
891
+ this.feeBpsMoveCall(tx, dstEid);
583
892
  },
584
893
  (result) => BigInt(bcs.bcs.U64.parse(result[0].value))
585
894
  );
@@ -704,122 +1013,6 @@ var OFT = class {
704
1013
  (result) => BigInt(bcs.bcs.U64.parse(result[0].value))
705
1014
  );
706
1015
  }
707
- /**
708
- * Combine enforced options with extra options
709
- * @param tx - The transaction to add the move call to
710
- * @param eid - Endpoint ID
711
- * @param msgType - Message type
712
- * @param extraOptions - Extra options to combine with enforced options
713
- * @returns Transaction result containing the combined options
714
- */
715
- combineOptionsMoveCall(tx, eid, msgType, extraOptions) {
716
- return tx.moveCall({
717
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "combine_options"),
718
- typeArguments: [this.coinType],
719
- arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asU32(tx, eid), lzSuiSdkV2.asU16(tx, msgType), lzSuiSdkV2.asBytes(tx, extraOptions)]
720
- });
721
- }
722
- /**
723
- * Combine enforced options with extra options
724
- * @param eid - Endpoint ID
725
- * @param msgType - Message type
726
- * @param extraOptions - Extra options to combine with enforced options
727
- * @returns Promise<Uint8Array> - The combined options as bytes
728
- */
729
- async combineOptions(eid, msgType, extraOptions) {
730
- return lzSuiSdkV2.executeSimulate(
731
- this.client,
732
- (tx) => {
733
- this.combineOptionsMoveCall(tx, eid, msgType, extraOptions);
734
- },
735
- (result) => new Uint8Array(bcs.bcs.vector(bcs.bcs.u8()).parse(result[0].value))
736
- );
737
- }
738
- /**
739
- * Get enforced options for OFT messaging
740
- * @param tx - The transaction to add the move call to
741
- * @param eid - Endpoint ID
742
- * @param msgType - Message type
743
- * @returns Transaction result containing the enforced options
744
- */
745
- getEnforcedOptionsMoveCall(tx, eid, msgType) {
746
- return tx.moveCall({
747
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "get_enforced_options"),
748
- typeArguments: [this.coinType],
749
- arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asU32(tx, eid), lzSuiSdkV2.asU16(tx, msgType)]
750
- });
751
- }
752
- /**
753
- * Get enforced options for OFT messaging
754
- * @param eid - Endpoint ID
755
- * @param msgType - Message type
756
- * @returns Promise<Uint8Array> - The enforced options as bytes
757
- */
758
- async getEnforcedOptions(eid, msgType) {
759
- return lzSuiSdkV2.executeSimulate(
760
- this.client,
761
- (tx) => {
762
- this.getEnforcedOptionsMoveCall(tx, eid, msgType);
763
- },
764
- (result) => new Uint8Array(bcs.bcs.vector(bcs.bcs.u8()).parse(result[0].value))
765
- );
766
- }
767
- /**
768
- * Check if OFT has a peer on specific endpoint
769
- * @param tx - The transaction to add the move call to
770
- * @param eid - Endpoint ID
771
- * @returns Transaction result containing the peer existence status
772
- */
773
- hasPeerMoveCall(tx, eid) {
774
- return tx.moveCall({
775
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "has_peer"),
776
- typeArguments: [this.coinType],
777
- arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asU32(tx, eid)]
778
- });
779
- }
780
- /**
781
- * Check if OFT has a peer on specific endpoint
782
- * @param eid - Endpoint ID
783
- * @returns Promise<boolean> - True if peer exists on the endpoint
784
- */
785
- async hasPeer(eid) {
786
- return lzSuiSdkV2.executeSimulate(
787
- this.client,
788
- (tx) => {
789
- this.hasPeerMoveCall(tx, eid);
790
- },
791
- (result) => bcs.bcs.Bool.parse(result[0].value)
792
- );
793
- }
794
- /**
795
- * Get peer OFT address on specific endpoint
796
- * @param tx - The transaction to add the move call to
797
- * @param eid - Endpoint ID
798
- * @returns Transaction result containing the peer address
799
- */
800
- getPeerMoveCall(tx, eid) {
801
- return tx.moveCall({
802
- target: __privateMethod(this, _OFT_instances, target_fn).call(this, "get_peer"),
803
- typeArguments: [this.coinType],
804
- arguments: [tx.object(this.oftObjectId), lzSuiSdkV2.asU32(tx, eid)]
805
- });
806
- }
807
- /**
808
- * Get peer OFT address on specific endpoint
809
- * @param eid - Endpoint ID
810
- * @returns Promise<Uint8Array> - The peer address as bytes32
811
- */
812
- async getPeer(eid) {
813
- return lzSuiSdkV2.executeSimulate(
814
- this.client,
815
- (tx) => {
816
- this.getPeerMoveCall(tx, eid);
817
- },
818
- (result) => {
819
- return new Uint8Array(bcs.bcs.vector(bcs.bcs.u8()).parse(result[0].value));
820
- }
821
- );
822
- }
823
1016
  // ==========================================
824
1017
  // OFT SENDER
825
1018
  // ==========================================
@@ -865,6 +1058,18 @@ buildSendParam_fn = function(tx, param) {
865
1058
  target_fn = function(name, module_name = MODULE_NAME) {
866
1059
  return `${this.oftPackageId}::${module_name}::${name}`;
867
1060
  };
1061
+ /**
1062
+ * Get the OApp object ID, throwing an error if not available
1063
+ * @returns The OApp object ID
1064
+ * @throws Error if OApp object ID was not set
1065
+ * @private
1066
+ */
1067
+ oappObjectId_fn = function() {
1068
+ if (this.oappObjectId === "") {
1069
+ throw new Error("OApp object ID not found");
1070
+ }
1071
+ return this.oappObjectId;
1072
+ };
868
1073
  /**
869
1074
  * Get the admin capability ID, throwing an error if not available
870
1075
  * @returns The admin capability ID
@@ -877,15 +1082,15 @@ adminCapId_fn = function() {
877
1082
  }
878
1083
  return this.adminCapId;
879
1084
  };
880
- var OFTComposerRegistryErrorCode = {
881
- // OFT Composer Registry related errors
1085
+ var OFTComposerManagerErrorCode = {
1086
+ // OFT Composer Manager related errors
882
1087
  EComposeTransferNotFound: 1,
883
1088
  EDepositAddressNotFound: 2
884
1089
  };
885
- var _OFTComposerRegistry_instances, target_fn2;
886
- var OFTComposerRegistry = class {
1090
+ var _OFTComposerManager_instances, target_fn2;
1091
+ var OFTComposerManager = class {
887
1092
  constructor(protocolSDK, packageId, registryObjectId) {
888
- __privateAdd(this, _OFTComposerRegistry_instances);
1093
+ __privateAdd(this, _OFTComposerManager_instances);
889
1094
  this.client = protocolSDK.client;
890
1095
  this.protocolSDK = protocolSDK;
891
1096
  this.packageId = packageId;
@@ -901,7 +1106,7 @@ var OFTComposerRegistry = class {
901
1106
  */
902
1107
  setDepositAddressMoveCall(tx, composerCallCap, depositAddress) {
903
1108
  return tx.moveCall({
904
- target: __privateMethod(this, _OFTComposerRegistry_instances, target_fn2).call(this, "set_deposit_address"),
1109
+ target: __privateMethod(this, _OFTComposerManager_instances, target_fn2).call(this, "set_deposit_address"),
905
1110
  arguments: [tx.object(this.registryObjectId), lzSuiSdkV2.asObject(tx, composerCallCap), lzSuiSdkV2.asAddress(tx, depositAddress)]
906
1111
  });
907
1112
  }
@@ -914,7 +1119,7 @@ var OFTComposerRegistry = class {
914
1119
  */
915
1120
  getDepositAddressMoveCall(tx, composer) {
916
1121
  return tx.moveCall({
917
- target: __privateMethod(this, _OFTComposerRegistry_instances, target_fn2).call(this, "get_deposit_address"),
1122
+ target: __privateMethod(this, _OFTComposerManager_instances, target_fn2).call(this, "get_deposit_address"),
918
1123
  arguments: [tx.object(this.registryObjectId), lzSuiSdkV2.asAddress(tx, composer)]
919
1124
  });
920
1125
  }
@@ -928,7 +1133,7 @@ var OFTComposerRegistry = class {
928
1133
  */
929
1134
  getComposeTransferMoveCall(tx, from, guid, composer) {
930
1135
  return tx.moveCall({
931
- target: __privateMethod(this, _OFTComposerRegistry_instances, target_fn2).call(this, "get_compose_transfer"),
1136
+ target: __privateMethod(this, _OFTComposerManager_instances, target_fn2).call(this, "get_compose_transfer"),
932
1137
  arguments: [
933
1138
  tx.object(this.registryObjectId),
934
1139
  lzSuiSdkV2.asAddress(tx, from),
@@ -962,7 +1167,7 @@ var OFTComposerRegistry = class {
962
1167
  );
963
1168
  }
964
1169
  };
965
- _OFTComposerRegistry_instances = new WeakSet();
1170
+ _OFTComposerManager_instances = new WeakSet();
966
1171
  // === Private Functions ===
967
1172
  /**
968
1173
  * Generate the full target path for move calls
@@ -971,40 +1176,7 @@ _OFTComposerRegistry_instances = new WeakSet();
971
1176
  * @private
972
1177
  */
973
1178
  target_fn2 = function(func) {
974
- return `${this.packageId}::oft_composer_registry::${func}`;
975
- };
976
- var OFTPtbBuilder = class {
977
- constructor(protocolSDK, packageId, objectId, client, coinType, oftObjectId) {
978
- this.objects = protocolSDK.objects;
979
- this.packageId = packageId;
980
- this.objectId = objectId;
981
- this.client = client;
982
- this.coinType = coinType;
983
- this.oftObjectId = oftObjectId;
984
- }
985
- /**
986
- * Get LayerZero receive information for OFT registration
987
- *
988
- * This function prepares the necessary metadata for registering an OFT
989
- * with the LayerZero endpoint, enabling it to receive cross-chain messages.
990
- *
991
- * @param tx - The transaction to add the move call to
992
- * @param composerRegistry - The composer registry object ID for routing compose transfers
993
- * @returns TransactionResult containing serialized execution metadata for endpoint registration
994
- */
995
- lzReceiveInfoMoveCall(tx, composerRegistry) {
996
- return tx.moveCall({
997
- target: `${this.packageId}::oft_ptb_builder::lz_receive_info`,
998
- typeArguments: [this.coinType],
999
- arguments: [
1000
- tx.object(this.objectId),
1001
- tx.object(this.oftObjectId),
1002
- tx.object(this.objects.endpointV2),
1003
- lzSuiSdkV2.asObject(tx, composerRegistry),
1004
- tx.object.clock()
1005
- ]
1006
- });
1007
- }
1179
+ return `${this.packageId}::oft_composer_manager::${func}`;
1008
1180
  };
1009
1181
 
1010
1182
  // src/types.ts
@@ -1014,13 +1186,12 @@ var OFTMsgType = {
1014
1186
  };
1015
1187
 
1016
1188
  exports.OFT = OFT;
1017
- exports.OFTComposerRegistry = OFTComposerRegistry;
1018
- exports.OFTComposerRegistryErrorCode = OFTComposerRegistryErrorCode;
1189
+ exports.OFTComposerManager = OFTComposerManager;
1190
+ exports.OFTComposerManagerErrorCode = OFTComposerManagerErrorCode;
1019
1191
  exports.OFTErrorCode = OFTErrorCode;
1020
1192
  exports.OFTFeeDetailBcs = OFTFeeDetailBcs;
1021
1193
  exports.OFTLimitBcs = OFTLimitBcs;
1022
1194
  exports.OFTMsgType = OFTMsgType;
1023
- exports.OFTPtbBuilder = OFTPtbBuilder;
1024
1195
  exports.OFTReceiptBcs = OFTReceiptBcs;
1025
1196
  exports.parseOFTFeeDetails = parseOFTFeeDetails;
1026
1197
  exports.parseOFTLimit = parseOFTLimit;