@layerzerolabs/lz-iotal1-oft-sdk-v2 3.0.143

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.mjs ADDED
@@ -0,0 +1,1312 @@
1
+ import { bcs } from '@iota/iota-sdk/bcs';
2
+ import { Transaction } from '@iota/iota-sdk/transactions';
3
+ import { asObject, asU8, executeSimulate, asBytes, asBool, asAddress, asU64, asU32, isTransactionArgument, asArgWithTx, asArgWithTxAsync, asBytes32 } from '@layerzerolabs/lz-iotal1-sdk-v2';
4
+
5
+ var __typeError = (msg) => {
6
+ throw TypeError(msg);
7
+ };
8
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
11
+ var OFTLimitBcs = bcs.struct("OFTLimit", {
12
+ min_amount_ld: bcs.U64,
13
+ max_amount_ld: bcs.U64
14
+ });
15
+ var OFTFeeDetailBcs = bcs.struct("OFTFeeDetail", {
16
+ fee_amount_ld: bcs.U64,
17
+ is_reward: bcs.Bool,
18
+ description: bcs.String
19
+ });
20
+ var OFTReceiptBcs = bcs.struct("OFTReceipt", {
21
+ amount_sent_ld: bcs.U64,
22
+ amount_received_ld: bcs.U64
23
+ });
24
+ var OFTInfoV1Bcs = bcs.struct("OFTInfoV1", {
25
+ oft_package: bcs.Address,
26
+ oft_object: bcs.Address
27
+ });
28
+ function parseOFTLimit(data) {
29
+ const parsed = OFTLimitBcs.parse(data);
30
+ return {
31
+ minAmountLd: BigInt(parsed.min_amount_ld),
32
+ maxAmountLd: BigInt(parsed.max_amount_ld)
33
+ };
34
+ }
35
+ function parseOFTFeeDetails(data) {
36
+ const vectorBcs = bcs.vector(OFTFeeDetailBcs);
37
+ const parsed = vectorBcs.parse(data);
38
+ return parsed.map(
39
+ (detail) => ({
40
+ feeAmountLd: BigInt(detail.fee_amount_ld),
41
+ isReward: detail.is_reward,
42
+ description: detail.description
43
+ })
44
+ );
45
+ }
46
+ function parseOFTReceipt(data) {
47
+ const parsed = OFTReceiptBcs.parse(data);
48
+ return {
49
+ amountSentLd: BigInt(parsed.amount_sent_ld),
50
+ amountReceivedLd: BigInt(parsed.amount_received_ld)
51
+ };
52
+ }
53
+ function parseOFTInfoV1(data) {
54
+ const parsed = OFTInfoV1Bcs.parse(data);
55
+ return {
56
+ oftPackage: parsed.oft_package,
57
+ oftObject: parsed.oft_object
58
+ };
59
+ }
60
+
61
+ // src/modules/oft.ts
62
+ var MODULE_NAME = "oft";
63
+ var OFT_SENDER_MODULE_NAME = "oft_sender";
64
+ var OFT_IMPL_MODULE_NAME = "oft_impl";
65
+ var OFT_PTB_BUILDER_MODULE_NAME = "oft_ptb_builder";
66
+ var OFTErrorCode = {
67
+ // OFT related errors
68
+ EComposeMsgNotAllowed: 1,
69
+ EComposeMsgRequired: 2,
70
+ EInsufficientBalance: 3,
71
+ EInvalidAdminCap: 4,
72
+ EInvalidComposeQueue: 5,
73
+ EInvalidLocalDecimals: 6,
74
+ EInvalidMigrationCap: 7,
75
+ EInvalidSendContext: 8,
76
+ ESlippageExceeded: 9,
77
+ EWrongPackageVersion: 10
78
+ };
79
+ var _OFT_instances, buildSendParam_fn, target_fn, oappObjectId_fn, oftObjectId_fn, adminCapId_fn, coinType_fn, OftInfo_fn, oftPackageId_fn;
80
+ var OFT = class {
81
+ /**
82
+ * Creates a new OFT instance for interacting with an Omnichain Fungible Token
83
+ *
84
+ * @param protocolSDK - The LayerZero protocol SDK instance providing core cross-chain functionality
85
+ * @param oftCallCapId - The OFT call capability ID used for OFT operations and accessing OFT information
86
+ * @param oftObjectId - Optional OFT object ID on Iota blockchain for direct OFT instance access
87
+ * @param coinType - Optional Iota coin type string (e.g., "0x123::mycoin::MYCOIN") that this OFT represents
88
+ * @param oappObjectId - Optional associated OApp object ID for cross-chain messaging operations
89
+ * @param adminCapId - Optional admin capability object ID for privileged operations
90
+ */
91
+ constructor(protocolSDK, oftCallCapId, oftObjectId, coinType, oappObjectId, adminCapId) {
92
+ __privateAdd(this, _OFT_instances);
93
+ this.protocolSDK = protocolSDK;
94
+ this.oftCallCapId = oftCallCapId;
95
+ this.client = protocolSDK.client;
96
+ this.objects = protocolSDK.objects;
97
+ this.oftObjectId = oftObjectId;
98
+ this.oappObjectId = oappObjectId;
99
+ this.adminCapId = adminCapId;
100
+ this.coinType = coinType;
101
+ }
102
+ /**
103
+ * Updates the associated OApp object ID
104
+ * @param oappObjectId - The new OApp object ID
105
+ */
106
+ setOappObjectId(oappObjectId) {
107
+ this.oappObjectId = oappObjectId;
108
+ }
109
+ // ==========================================
110
+ // INITIALIZATION FUNCTIONS
111
+ // ==========================================
112
+ // These functions are used to initialize OFT instances from OFTCreationTicket
113
+ /**
114
+ * Initialize an OFT instance with a treasury capability
115
+ * Creates a new OFT that mints its own tokens
116
+ * @param tx - The transaction to add the move call to
117
+ * @param coinType - The Iota coin type string (e.g., "0x123::mycoin::MYCOIN")
118
+ * @param ticket - The OFTCreationTicket object ID or TransactionArgument
119
+ * @param oapp - The OApp object ID or TransactionArgument
120
+ * @param treasury - The TreasuryCap object ID or TransactionArgument for the coin type
121
+ * @param metadata - The CoinMetadata object ID or TransactionArgument for the coin type
122
+ * @param sharedDecimals - Number of decimals to use for cross-chain operations
123
+ * @returns TransactionResult array containing [AdminCap, MigrationCap] - MigrationCap must be transferred or stored
124
+ */
125
+ initOftMoveCall(tx, coinType, ticket, oapp, treasury, metadata, sharedDecimals) {
126
+ return tx.moveCall({
127
+ target: `${this.oftCallCapId}::${OFT_IMPL_MODULE_NAME}::init_oft`,
128
+ typeArguments: [coinType],
129
+ arguments: [
130
+ asObject(tx, ticket),
131
+ asObject(tx, oapp),
132
+ asObject(tx, treasury),
133
+ asObject(tx, metadata),
134
+ asU8(tx, sharedDecimals)
135
+ ]
136
+ });
137
+ }
138
+ /**
139
+ * Initialize an OFT adapter instance
140
+ * Creates an OFT adapter that wraps an existing coin type
141
+ * @param tx - The transaction to add the move call to
142
+ * @param coinType - The Iota coin type string (e.g., "0x123::mycoin::MYCOIN")
143
+ * @param ticket - The OFTCreationTicket object ID or TransactionArgument
144
+ * @param oapp - The OApp object ID or TransactionArgument
145
+ * @param metadata - The CoinMetadata object ID or TransactionArgument for the coin type
146
+ * @param sharedDecimals - Number of decimals to use for cross-chain operations
147
+ * @returns TransactionResult array containing [AdminCap, MigrationCap] - MigrationCap must be transferred or stored
148
+ */
149
+ initOftAdapterMoveCall(tx, coinType, ticket, oapp, metadata, sharedDecimals) {
150
+ return tx.moveCall({
151
+ target: `${this.oftCallCapId}::${OFT_IMPL_MODULE_NAME}::init_oft_adapter`,
152
+ typeArguments: [coinType],
153
+ arguments: [asObject(tx, ticket), asObject(tx, oapp), asObject(tx, metadata), asU8(tx, sharedDecimals)]
154
+ });
155
+ }
156
+ // ==========================================
157
+ // ADMIN FUNCTIONS
158
+ // ==========================================
159
+ // These functions require admin privileges and are used for OFT configuration
160
+ // and management. The admin capability is automatically retrieved from the OFT instance.
161
+ /**
162
+ * Get LayerZero receive information for OFT registration
163
+ *
164
+ * This function prepares the necessary metadata for registering an OFT
165
+ * with the LayerZero endpoint, enabling it to receive cross-chain messages.
166
+ *
167
+ * @param tx - The transaction to add the move call to
168
+ * @param composerManager - The composer manager object ID for routing compose transfers
169
+ * @returns TransactionResult containing serialized execution metadata for endpoint registration
170
+ */
171
+ async lzReceiveInfoMoveCall(tx, composerManager) {
172
+ return tx.moveCall({
173
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "lz_receive_info", OFT_PTB_BUILDER_MODULE_NAME),
174
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
175
+ arguments: [
176
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
177
+ tx.object(this.objects.endpointV2),
178
+ asObject(tx, composerManager),
179
+ tx.object.clock()
180
+ ]
181
+ });
182
+ }
183
+ /**
184
+ * Register OFT as an OApp with LayerZero endpoint
185
+ * @param tx - The transaction to add the move call to
186
+ * @param coinType - The Iota coin type string (e.g., "0x123::mycoin::MYCOIN")
187
+ * @param oftObjectId - The OFT object ID
188
+ * @param oappObjectId - The OApp object ID
189
+ * @param composerManager - The composer manager object ID or TransactionArgument
190
+ * @param lzReceiveInfo - Optional LayerZero receive info as Uint8Array or TransactionArgument
191
+ */
192
+ async registerOAppMoveCall(tx, coinType, oftObjectId, oappObjectId, composerManager, lzReceiveInfo) {
193
+ const adminCapId = await executeSimulate(
194
+ this.client,
195
+ (tx2) => {
196
+ tx2.moveCall({
197
+ target: `${this.oftCallCapId}::${MODULE_NAME}::admin_cap`,
198
+ typeArguments: [coinType],
199
+ arguments: [tx2.object(oftObjectId)]
200
+ });
201
+ },
202
+ (result) => bcs.Address.parse(result[0].value)
203
+ );
204
+ if (lzReceiveInfo === void 0) {
205
+ lzReceiveInfo = tx.moveCall({
206
+ target: `${this.oftCallCapId}::${OFT_PTB_BUILDER_MODULE_NAME}::lz_receive_info`,
207
+ typeArguments: [coinType],
208
+ arguments: [
209
+ tx.object(oftObjectId),
210
+ tx.object(this.objects.endpointV2),
211
+ asObject(tx, composerManager),
212
+ tx.object.clock()
213
+ ]
214
+ });
215
+ }
216
+ tx.moveCall({
217
+ target: `${this.oftCallCapId}::${MODULE_NAME}::register_oapp`,
218
+ typeArguments: [coinType],
219
+ arguments: [
220
+ tx.object(oftObjectId),
221
+ tx.object(oappObjectId),
222
+ tx.object(adminCapId),
223
+ tx.object(this.objects.endpointV2),
224
+ asBytes(tx, lzReceiveInfo)
225
+ ]
226
+ });
227
+ }
228
+ /**
229
+ * Set pause state for OFT operations
230
+ * @param tx - The transaction to add the move call to
231
+ * @param pause - Whether to pause or unpause operations
232
+ */
233
+ async setPauseMoveCall(tx, pause) {
234
+ tx.moveCall({
235
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "set_pause"),
236
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
237
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), tx.object(await __privateMethod(this, _OFT_instances, adminCapId_fn).call(this)), asBool(tx, pause)]
238
+ });
239
+ }
240
+ // ==========================================
241
+ // FEE MANAGEMENT ADMIN FUNCTIONS
242
+ // ==========================================
243
+ // Configure fee collection and distribution for OFT transfers
244
+ /**
245
+ * Set fee deposit address for OFT fees
246
+ * @param tx - The transaction to add the move call to
247
+ * @param feeDepositAddress - The new fee deposit address
248
+ */
249
+ async setFeeDepositAddressMoveCall(tx, feeDepositAddress) {
250
+ tx.moveCall({
251
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "set_fee_deposit_address"),
252
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
253
+ arguments: [
254
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
255
+ tx.object(await __privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
256
+ asAddress(tx, feeDepositAddress)
257
+ ]
258
+ });
259
+ }
260
+ /**
261
+ * Set default fee basis points for OFT transfers
262
+ * @param tx - The transaction to add the move call to
263
+ * @param feeBps - Default fee rate in basis points (0-10,000, where 10,000 = 100%)
264
+ */
265
+ async setDefaultFeeBpsMoveCall(tx, feeBps) {
266
+ tx.moveCall({
267
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "set_default_fee_bps"),
268
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
269
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), tx.object(await __privateMethod(this, _OFT_instances, adminCapId_fn).call(this)), asU64(tx, feeBps)]
270
+ });
271
+ }
272
+ /**
273
+ * Set fee basis points for a specific destination chain
274
+ * @param tx - The transaction to add the move call to
275
+ * @param dstEid - Destination endpoint ID
276
+ * @param feeBps - Fee rate in basis points (0-10,000, where 10,000 = 100%)
277
+ */
278
+ async setFeeBpsMoveCall(tx, dstEid, feeBps) {
279
+ tx.moveCall({
280
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "set_fee_bps"),
281
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
282
+ arguments: [
283
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
284
+ tx.object(await __privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
285
+ asU32(tx, dstEid),
286
+ asU64(tx, feeBps)
287
+ ]
288
+ });
289
+ }
290
+ /**
291
+ * Removes the fee rate for a specific destination chain
292
+ * @param tx - The transaction to add the move call to
293
+ * @param dstEid - Destination endpoint ID
294
+ */
295
+ async unsetFeeBpsMoveCall(tx, dstEid) {
296
+ tx.moveCall({
297
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "unset_fee_bps"),
298
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
299
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), tx.object(await __privateMethod(this, _OFT_instances, adminCapId_fn).call(this)), asU32(tx, dstEid)]
300
+ });
301
+ }
302
+ // ==========================================
303
+ // MIGRATION ADMIN FUNCTIONS
304
+ // ==========================================
305
+ // Handle OFT migration to new contracts
306
+ /**
307
+ * Migrate OFT instance to a new contract
308
+ * @param tx - The transaction to add the move call to
309
+ * @param migrationCap - Migration capability object ID or transaction argument
310
+ * @returns TransactionResult containing the migration ticket
311
+ */
312
+ async migrateMoveCall(tx, migrationCap) {
313
+ return tx.moveCall({
314
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "migrate"),
315
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
316
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), asObject(tx, migrationCap)]
317
+ });
318
+ }
319
+ // ==========================================
320
+ // RATE LIMITER ADMIN FUNCTIONS
321
+ // ==========================================
322
+ // Configure transfer rate limits for security and compliance
323
+ /**
324
+ * Set rate limit for OFT transfers
325
+ * @param tx - The transaction to add the move call to
326
+ * @param eid - Endpoint ID
327
+ * @param inbound - Whether this is for inbound or outbound transfers
328
+ * @param rateLimit - Rate limit amount
329
+ * @param windowSeconds - Time window in seconds
330
+ */
331
+ async setRateLimitMoveCall(tx, eid, inbound, rateLimit, windowSeconds) {
332
+ tx.moveCall({
333
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "set_rate_limit"),
334
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
335
+ arguments: [
336
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
337
+ tx.object(await __privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
338
+ asU32(tx, eid),
339
+ asBool(tx, inbound),
340
+ asU64(tx, rateLimit),
341
+ asU64(tx, windowSeconds),
342
+ tx.object.clock()
343
+ ]
344
+ });
345
+ }
346
+ /**
347
+ * Remove rate limit for OFT transfers
348
+ * @param tx - The transaction to add the move call to
349
+ * @param eid - Endpoint ID
350
+ * @param inbound - Whether this is for inbound or outbound transfers
351
+ */
352
+ async unsetRateLimitMoveCall(tx, eid, inbound) {
353
+ tx.moveCall({
354
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "unset_rate_limit"),
355
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
356
+ arguments: [
357
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
358
+ tx.object(await __privateMethod(this, _OFT_instances, adminCapId_fn).call(this)),
359
+ asU32(tx, eid),
360
+ asBool(tx, inbound)
361
+ ]
362
+ });
363
+ }
364
+ // ==========================================
365
+ // CORE FUNCTIONS
366
+ // ==========================================
367
+ // Primary OFT operations for token transfers and coin management
368
+ /**
369
+ * Splits specified amount of coins from user's wallet
370
+ * @param tx - The transaction to add the move call to
371
+ * @param owner - Address of the user whose coins to split
372
+ * @param amount - Amount of coins to split (in smallest units)
373
+ * @param limit - Maximum total number of coins to collect across all pages (default: 200)
374
+ * @param pageSize - Maximum number of coins to fetch per page (default: 50)
375
+ * @returns Promise resolving to split coin as TransactionResult
376
+ * @throws Error if insufficient coins balance or no coins found
377
+ */
378
+ async splitCoinMoveCall(tx, owner, amount, limit = 200, pageSize = 50) {
379
+ return this.protocolSDK.getUtils().splitCoinMoveCall(tx, await __privateMethod(this, _OFT_instances, coinType_fn).call(this), owner, amount, limit, pageSize);
380
+ }
381
+ /**
382
+ * Send OFT tokens to destination chain
383
+ * @param tx - The transaction to add the move call to
384
+ * @param sender - Sender address for ZRO token operations
385
+ * @param sendParam - Send parameters including destination and amounts
386
+ * @param coinProvided - Coin object ID or transaction result to send
387
+ * @param nativeFee - Native token fee amount
388
+ * @param zroFee - ZRO token fee amount
389
+ * @param refundAddress - Address for fee refunds
390
+ * @param validators - Optional PTB validators for transaction validation
391
+ * @param maxSimulationTimes - Optional maximum number of simulation attempts
392
+ * @returns Promise<void> - Completes when the send operation is processed
393
+ */
394
+ async sendMoveCall(tx, sender, sendParam, coinProvided, nativeFee, zroFee, refundAddress, validators, maxSimulationTimes) {
395
+ const sendParamArg = isTransactionArgument(sendParam) ? sendParam : await __privateMethod(this, _OFT_instances, buildSendParam_fn).call(this, tx, sendParam);
396
+ const txSender = await this.txSenderMoveCall(tx);
397
+ const addressArg = isTransactionArgument(refundAddress) ? refundAddress : tx.pure.option("address", refundAddress);
398
+ const transactionResult = tx.moveCall({
399
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "send"),
400
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
401
+ arguments: [
402
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
403
+ tx.object(await __privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
404
+ txSender,
405
+ sendParamArg,
406
+ asObject(tx, coinProvided),
407
+ asArgWithTx(tx, nativeFee, (tx2, val) => tx2.splitCoins(tx2.gas, [asU64(tx2, val)])[0]),
408
+ await asArgWithTxAsync(
409
+ tx,
410
+ zroFee,
411
+ async (tx2, val) => this.protocolSDK.getZro().splitOptionZroTokenMoveCall(tx2, sender, val)
412
+ ),
413
+ addressArg,
414
+ tx.object.clock()
415
+ ]
416
+ });
417
+ const endpointCall = transactionResult[0];
418
+ const oftSendContext = transactionResult[1];
419
+ await this.protocolSDK.getEndpoint().populateSendTransaction(
420
+ tx,
421
+ endpointCall,
422
+ sender,
423
+ validators,
424
+ maxSimulationTimes
425
+ );
426
+ const confirmSendResult = tx.moveCall({
427
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "confirm_send"),
428
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
429
+ arguments: [
430
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
431
+ tx.object(await __privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
432
+ txSender,
433
+ endpointCall,
434
+ oftSendContext
435
+ ]
436
+ });
437
+ const nativeCoin = confirmSendResult[2];
438
+ const zroCoin = confirmSendResult[3];
439
+ tx.moveCall({
440
+ target: "0x1::option::destroy_none",
441
+ arguments: [nativeCoin],
442
+ typeArguments: [`0x2::coin::Coin<0x2::iota::IOTA>`]
443
+ });
444
+ tx.moveCall({
445
+ target: "0x1::option::destroy_none",
446
+ arguments: [zroCoin],
447
+ typeArguments: [`0x2::coin::Coin<${this.protocolSDK.getZro().zroType}>`]
448
+ });
449
+ }
450
+ /**
451
+ * Process inbound cross-chain token transfers
452
+ * @param tx - The transaction to add the move call to
453
+ * @param call - LayerZero receive call containing the verified cross-chain message
454
+ * @returns TransactionResult containing the processed transfer
455
+ */
456
+ async lzReceiveMoveCall(tx, call) {
457
+ return tx.moveCall({
458
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "lz_receive"),
459
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
460
+ arguments: [
461
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
462
+ tx.object(await __privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
463
+ asObject(tx, call),
464
+ tx.object.clock()
465
+ ]
466
+ });
467
+ }
468
+ /**
469
+ * Process inbound cross-chain token transfers with compose functionality
470
+ * @param tx - The transaction to add the move call to
471
+ * @param composeQueue - The composer's message queue for sequencing operations
472
+ * @param composerManager - Manager managing token deposits for composers
473
+ * @param call - LayerZero receive call containing the verified cross-chain message
474
+ * @returns TransactionResult containing the processed transfer
475
+ */
476
+ async lzReceiveWithComposeMoveCall(tx, composeQueue, composerManager, call) {
477
+ return tx.moveCall({
478
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "lz_receive_with_compose"),
479
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
480
+ arguments: [
481
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
482
+ tx.object(await __privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
483
+ asObject(tx, composeQueue),
484
+ asObject(tx, composerManager),
485
+ asObject(tx, call),
486
+ tx.object.clock()
487
+ ]
488
+ });
489
+ }
490
+ /**
491
+ * Confirms and extracts results from a quote operation
492
+ * @param tx - The transaction to add the move call to
493
+ * @param call - Completed Call object from quote_send() execution
494
+ * @returns TransactionResult containing the messaging fee
495
+ */
496
+ async confirmQuoteSendMoveCall(tx, call) {
497
+ return tx.moveCall({
498
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "confirm_quote_send"),
499
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
500
+ arguments: [
501
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
502
+ tx.object(await __privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
503
+ asObject(tx, call)
504
+ ]
505
+ });
506
+ }
507
+ // ==========================================
508
+ // QUOTE FUNCTIONS
509
+ // ==========================================
510
+ // Calculate fees, limits, and receipts before executing operations
511
+ /**
512
+ * Quote OFT sending operation with detailed fee breakdown
513
+ * @param sendParam - Send parameters for the OFT operation
514
+ * @returns Promise with limit, fee details, and receipt information
515
+ */
516
+ async quoteOft(sendParam) {
517
+ return executeSimulate(
518
+ this.client,
519
+ async (tx) => {
520
+ const sendParamArg = isTransactionArgument(sendParam) ? sendParam : await __privateMethod(this, _OFT_instances, buildSendParam_fn).call(this, tx, sendParam);
521
+ tx.moveCall({
522
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "quote_oft"),
523
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
524
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), sendParamArg, tx.object.clock()]
525
+ });
526
+ },
527
+ (result) => {
528
+ return {
529
+ limit: parseOFTLimit(result[0].value),
530
+ feeDetails: parseOFTFeeDetails(result[1].value),
531
+ receipt: parseOFTReceipt(result[2].value)
532
+ };
533
+ }
534
+ );
535
+ }
536
+ /**
537
+ * Quote messaging fees for OFT sending
538
+ * @param sender - Sender address
539
+ * @param sendParam - Send parameters for the OFT operation
540
+ * @param payInZro - Whether to pay in ZRO tokens
541
+ * @param validators - Optional PTB validators for transaction validation
542
+ * @param maxSimulationTimes - Optional maximum number of simulation attempts
543
+ * @returns Promise<MessagingFee> - The calculated messaging fees
544
+ */
545
+ async quoteSend(sender, sendParam, payInZro, validators, maxSimulationTimes) {
546
+ const tx = new Transaction();
547
+ const sendParamArg = isTransactionArgument(sendParam) ? sendParam : await __privateMethod(this, _OFT_instances, buildSendParam_fn).call(this, tx, sendParam);
548
+ const quoteCall = tx.moveCall({
549
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "quote_send"),
550
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
551
+ arguments: [
552
+ tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)),
553
+ tx.object(await __privateMethod(this, _OFT_instances, oappObjectId_fn).call(this)),
554
+ asAddress(tx, sender),
555
+ sendParamArg,
556
+ asBool(tx, payInZro)
557
+ ]
558
+ });
559
+ return this.protocolSDK.getEndpoint().quote(tx, quoteCall, sender, validators, maxSimulationTimes);
560
+ }
561
+ // ==========================================
562
+ // VIEW FUNCTIONS
563
+ // ==========================================
564
+ // Read-only functions to query OFT state and configuration
565
+ /**
566
+ * Get the upgrade version of this OFT instance
567
+ * @param tx - The transaction to add the move call to
568
+ * @returns Transaction result containing the upgrade version
569
+ */
570
+ async upgradeVersionMoveCall(tx) {
571
+ return tx.moveCall({
572
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "upgrade_version"),
573
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
574
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
575
+ });
576
+ }
577
+ /**
578
+ * Get the upgrade version of this OFT instance
579
+ * @returns Promise<bigint> - The upgrade version
580
+ */
581
+ async upgradeVersion() {
582
+ return executeSimulate(
583
+ this.client,
584
+ async (tx) => {
585
+ await this.upgradeVersionMoveCall(tx);
586
+ },
587
+ (result) => BigInt(bcs.U64.parse(result[0].value))
588
+ );
589
+ }
590
+ /**
591
+ * Get the associated OApp object address
592
+ * @param tx - The transaction to add the move call to
593
+ * @returns Transaction result containing the OApp object address
594
+ */
595
+ async oappObjectMoveCall(tx) {
596
+ return tx.moveCall({
597
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "oapp_object"),
598
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
599
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
600
+ });
601
+ }
602
+ /**
603
+ * Get the associated OApp object address
604
+ * @returns Promise<string> - The OApp object address
605
+ */
606
+ async oappObject() {
607
+ return executeSimulate(
608
+ this.client,
609
+ async (tx) => {
610
+ await this.oappObjectMoveCall(tx);
611
+ },
612
+ (result) => bcs.Address.parse(result[0].value)
613
+ );
614
+ }
615
+ /**
616
+ * Get OFT version information
617
+ * @param tx - The transaction to add the move call to
618
+ * @returns Transaction result containing version information
619
+ */
620
+ async oftVersionMoveCall(tx) {
621
+ return tx.moveCall({
622
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "oft_version"),
623
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
624
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
625
+ });
626
+ }
627
+ /**
628
+ * Get OFT version information
629
+ * @returns Promise<{ major: number; minor: number }> - The OFT version
630
+ */
631
+ async oftVersion() {
632
+ return executeSimulate(
633
+ this.client,
634
+ async (tx) => {
635
+ await this.oftVersionMoveCall(tx);
636
+ },
637
+ (result) => {
638
+ const major = Number(bcs.U64.parse(result[0].value));
639
+ const minor = Number(bcs.U64.parse(result[1].value));
640
+ return { major, minor };
641
+ }
642
+ );
643
+ }
644
+ /**
645
+ * Get the OFT capability ID
646
+ * @param tx - The transaction to add the move call to
647
+ * @returns Transaction result containing the OFT capability ID
648
+ */
649
+ async oftCapIdMoveCall(tx) {
650
+ return tx.moveCall({
651
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "oft_cap_id"),
652
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
653
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
654
+ });
655
+ }
656
+ /**
657
+ * Get the OFT capability ID
658
+ * @returns Promise<string> - The OFT capability ID
659
+ */
660
+ async oftCapId() {
661
+ return executeSimulate(
662
+ this.client,
663
+ async (tx) => {
664
+ await this.oftCapIdMoveCall(tx);
665
+ },
666
+ (result) => bcs.Address.parse(result[0].value)
667
+ );
668
+ }
669
+ /**
670
+ * Get the migration capability address for this OFT
671
+ * @param tx - The transaction to add the move call to
672
+ * @returns Transaction result containing the migration capability address
673
+ */
674
+ async migrationCapMoveCall(tx) {
675
+ return tx.moveCall({
676
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "migration_cap"),
677
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
678
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
679
+ });
680
+ }
681
+ /**
682
+ * Get the migration capability address for this OFT
683
+ * @returns Promise<string> - The migration capability address
684
+ */
685
+ async migrationCap() {
686
+ return executeSimulate(
687
+ this.client,
688
+ async (tx) => {
689
+ await this.migrationCapMoveCall(tx);
690
+ },
691
+ (result) => bcs.Address.parse(result[0].value)
692
+ );
693
+ }
694
+ async messagingChannel() {
695
+ return executeSimulate(
696
+ this.client,
697
+ async (tx) => {
698
+ const oftCapId = await this.oftCapIdMoveCall(tx);
699
+ this.protocolSDK.getEndpoint().getMessagingChannelMoveCall(tx, oftCapId);
700
+ },
701
+ (result) => bcs.Address.parse(result[0].value)
702
+ );
703
+ }
704
+ /**
705
+ * Get coin metadata address
706
+ * @param tx - The transaction to add the move call to
707
+ * @returns Transaction result containing coin metadata address
708
+ */
709
+ async coinMetadataMoveCall(tx) {
710
+ return tx.moveCall({
711
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "coin_metadata"),
712
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
713
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
714
+ });
715
+ }
716
+ /**
717
+ * Get coin metadata address
718
+ * @returns Promise<string> - The coin metadata address
719
+ */
720
+ async coinMetadata() {
721
+ return executeSimulate(
722
+ this.client,
723
+ async (tx) => {
724
+ await this.coinMetadataMoveCall(tx);
725
+ },
726
+ (result) => bcs.Address.parse(result[0].value)
727
+ );
728
+ }
729
+ /**
730
+ * Get OFT admin capability address
731
+ * @param tx - The transaction to add the move call to
732
+ * @returns Transaction result containing the admin capability address
733
+ */
734
+ async adminCapMoveCall(tx) {
735
+ return tx.moveCall({
736
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "admin_cap"),
737
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
738
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
739
+ });
740
+ }
741
+ /**
742
+ * Get OFT admin capability address
743
+ * @returns Promise<string> - The admin capability address
744
+ */
745
+ async adminCap() {
746
+ return executeSimulate(
747
+ this.client,
748
+ async (tx) => {
749
+ await this.adminCapMoveCall(tx);
750
+ },
751
+ (result) => bcs.Address.parse(result[0].value)
752
+ );
753
+ }
754
+ /**
755
+ * Get shared decimals for cross-chain compatibility
756
+ * @param tx - The transaction to add the move call to
757
+ * @returns Transaction result containing shared decimals
758
+ */
759
+ async sharedDecimalsMoveCall(tx) {
760
+ return tx.moveCall({
761
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "shared_decimals"),
762
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
763
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
764
+ });
765
+ }
766
+ /**
767
+ * Get shared decimals for cross-chain compatibility
768
+ * @returns Promise<number> - The shared decimal precision
769
+ */
770
+ async sharedDecimals() {
771
+ return executeSimulate(
772
+ this.client,
773
+ async (tx) => {
774
+ await this.sharedDecimalsMoveCall(tx);
775
+ },
776
+ (result) => bcs.U8.parse(result[0].value)
777
+ );
778
+ }
779
+ /**
780
+ * Get the decimal conversion rate for this OFT
781
+ * @param tx - The transaction to add the move call to
782
+ * @returns Transaction result containing the decimal conversion rate
783
+ */
784
+ async decimalConversionRateMoveCall(tx) {
785
+ return tx.moveCall({
786
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "decimal_conversion_rate"),
787
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
788
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
789
+ });
790
+ }
791
+ /**
792
+ * Get the decimal conversion rate for this OFT
793
+ * @returns Promise<bigint> - The decimal conversion rate multiplier
794
+ */
795
+ async decimalConversionRate() {
796
+ return executeSimulate(
797
+ this.client,
798
+ async (tx) => {
799
+ await this.decimalConversionRateMoveCall(tx);
800
+ },
801
+ (result) => BigInt(bcs.U64.parse(result[0].value))
802
+ );
803
+ }
804
+ /**
805
+ * Check if OFT is paused
806
+ * @param tx - The transaction to add the move call to
807
+ * @returns Transaction result containing the paused status
808
+ */
809
+ async isPausedMoveCall(tx) {
810
+ return tx.moveCall({
811
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "is_paused"),
812
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
813
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
814
+ });
815
+ }
816
+ /**
817
+ * Check if OFT is paused
818
+ * @returns Promise<boolean> - True if OFT is paused
819
+ */
820
+ async isPaused() {
821
+ return executeSimulate(
822
+ this.client,
823
+ async (tx) => {
824
+ await this.isPausedMoveCall(tx);
825
+ },
826
+ (result) => bcs.Bool.parse(result[0].value)
827
+ );
828
+ }
829
+ /**
830
+ * Check if this OFT is an adapter (wraps existing token)
831
+ * @param tx - The transaction to add the move call to
832
+ * @returns Transaction result containing the adapter status
833
+ */
834
+ async isAdapterMoveCall(tx) {
835
+ return tx.moveCall({
836
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "is_adapter"),
837
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
838
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
839
+ });
840
+ }
841
+ /**
842
+ * Check if this OFT is an adapter (wraps existing token)
843
+ * @returns Promise<boolean> - True if this is an OFT adapter
844
+ */
845
+ async isAdapter() {
846
+ return executeSimulate(
847
+ this.client,
848
+ async (tx) => {
849
+ await this.isAdapterMoveCall(tx);
850
+ },
851
+ (result) => bcs.Bool.parse(result[0].value)
852
+ );
853
+ }
854
+ /**
855
+ * Decode OFTInfoV1 from encoded bytes
856
+ * @param tx - The transaction to add the move call to
857
+ * @param encodedBytes - The encoded OFTInfoV1 bytes to decode
858
+ * @returns Transaction result containing the decoded OFTInfoV1
859
+ */
860
+ decodeOftInfoV1MoveCall(tx, encodedBytes) {
861
+ return tx.moveCall({
862
+ target: `${this.oftCallCapId}::oft_info_v1::decode`,
863
+ arguments: [asBytes(tx, encodedBytes)]
864
+ });
865
+ }
866
+ /**
867
+ * Decode OFTInfoV1 from encoded bytes
868
+ * @param encodedBytes - The encoded OFTInfoV1 bytes to decode
869
+ * @returns Promise<OFTInfoV1> - The decoded OFTInfoV1 structure
870
+ */
871
+ async decodeOftInfoV1(encodedBytes) {
872
+ return executeSimulate(
873
+ this.client,
874
+ (tx) => {
875
+ this.decodeOftInfoV1MoveCall(tx, encodedBytes);
876
+ },
877
+ (result) => parseOFTInfoV1(result[0].value)
878
+ );
879
+ }
880
+ // ==========================================
881
+ // FEE VIEW FUNCTIONS
882
+ // ==========================================
883
+ // Query current fee configuration and settings
884
+ /**
885
+ * Check if the OFT has a fee rate greater than 0 for the specified destination
886
+ * @param tx - The transaction to add the move call to
887
+ * @param dstEid - Destination endpoint ID
888
+ * @returns Transaction result containing whether fee exists
889
+ */
890
+ async hasOftFeeMoveCall(tx, dstEid) {
891
+ return tx.moveCall({
892
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "has_oft_fee"),
893
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
894
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), asU32(tx, dstEid)]
895
+ });
896
+ }
897
+ /**
898
+ * Check if the OFT has a fee rate greater than 0 for the specified destination
899
+ * @param dstEid - Destination endpoint ID
900
+ * @returns Promise<boolean> - True if fee exists
901
+ */
902
+ async hasOftFee(dstEid) {
903
+ return executeSimulate(
904
+ this.client,
905
+ async (tx) => {
906
+ await this.hasOftFeeMoveCall(tx, dstEid);
907
+ },
908
+ (result) => bcs.Bool.parse(result[0].value)
909
+ );
910
+ }
911
+ /**
912
+ * Get the effective fee rate for a specific destination chain
913
+ * @param tx - The transaction to add the move call to
914
+ * @param dstEid - Destination endpoint ID
915
+ * @returns Transaction result containing the effective fee basis points
916
+ */
917
+ async effectiveFeeBpsMoveCall(tx, dstEid) {
918
+ return tx.moveCall({
919
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "effective_fee_bps"),
920
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
921
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), asU32(tx, dstEid)]
922
+ });
923
+ }
924
+ /**
925
+ * Get the effective fee rate for a specific destination chain
926
+ * @param dstEid - Destination endpoint ID
927
+ * @returns Promise<bigint> - The effective fee in basis points
928
+ */
929
+ async effectiveFeeBps(dstEid) {
930
+ return executeSimulate(
931
+ this.client,
932
+ async (tx) => {
933
+ await this.effectiveFeeBpsMoveCall(tx, dstEid);
934
+ },
935
+ (result) => BigInt(bcs.U64.parse(result[0].value))
936
+ );
937
+ }
938
+ /**
939
+ * Get the default fee rate
940
+ * @param tx - The transaction to add the move call to
941
+ * @returns Transaction result containing the default fee basis points
942
+ */
943
+ async defaultFeeBpsMoveCall(tx) {
944
+ return tx.moveCall({
945
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "default_fee_bps"),
946
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
947
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
948
+ });
949
+ }
950
+ /**
951
+ * Get the default fee rate
952
+ * @returns Promise<bigint> - The default fee in basis points
953
+ */
954
+ async defaultFeeBps() {
955
+ return executeSimulate(
956
+ this.client,
957
+ async (tx) => {
958
+ await this.defaultFeeBpsMoveCall(tx);
959
+ },
960
+ (result) => BigInt(bcs.U64.parse(result[0].value))
961
+ );
962
+ }
963
+ /**
964
+ * Get fee basis points for a specific destination chain
965
+ * @param tx - The transaction to add the move call to
966
+ * @param dstEid - Destination endpoint ID
967
+ * @returns Transaction result containing the fee basis points
968
+ */
969
+ async feeBpsMoveCall(tx, dstEid) {
970
+ return tx.moveCall({
971
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "fee_bps"),
972
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
973
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), asU32(tx, dstEid)]
974
+ });
975
+ }
976
+ /**
977
+ * Get fee basis points for a specific destination chain
978
+ * @param dstEid - Destination endpoint ID
979
+ * @returns Promise<bigint> - The fee in basis points
980
+ */
981
+ async feeBps(dstEid) {
982
+ return executeSimulate(
983
+ this.client,
984
+ async (tx) => {
985
+ await this.feeBpsMoveCall(tx, dstEid);
986
+ },
987
+ (result) => BigInt(bcs.U64.parse(result[0].value))
988
+ );
989
+ }
990
+ /**
991
+ * Get fee deposit address for OFT
992
+ * @param tx - The transaction to add the move call to
993
+ * @returns Transaction result containing the fee deposit address
994
+ */
995
+ async feeDepositAddressMoveCall(tx) {
996
+ return tx.moveCall({
997
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "fee_deposit_address"),
998
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
999
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this))]
1000
+ });
1001
+ }
1002
+ /**
1003
+ * Get fee deposit address for OFT
1004
+ * @returns Promise<string> - The fee deposit address
1005
+ */
1006
+ async feeDepositAddress() {
1007
+ return executeSimulate(
1008
+ this.client,
1009
+ async (tx) => {
1010
+ await this.feeDepositAddressMoveCall(tx);
1011
+ },
1012
+ (result) => bcs.Address.parse(result[0].value)
1013
+ );
1014
+ }
1015
+ // ==========================================
1016
+ // RATE LIMITER VIEW FUNCTIONS
1017
+ // ==========================================
1018
+ // Query current rate limiting configuration and status
1019
+ /**
1020
+ * Get rate limit configuration for an endpoint
1021
+ * @param tx - The transaction to add the move call to
1022
+ * @param eid - Endpoint ID
1023
+ * @param inbound - Whether this is for inbound or outbound transfers
1024
+ * @returns Transaction result containing rate limit configuration
1025
+ */
1026
+ async rateLimitConfigMoveCall(tx, eid, inbound) {
1027
+ return tx.moveCall({
1028
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "rate_limit_config"),
1029
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
1030
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), asU32(tx, eid), asBool(tx, inbound)]
1031
+ });
1032
+ }
1033
+ /**
1034
+ * Get rate limit configuration for an endpoint
1035
+ * @param eid - Endpoint ID
1036
+ * @param inbound - Whether this is for inbound or outbound transfers
1037
+ * @returns Promise<{ limit: bigint; windowSeconds: bigint }> - Rate limit configuration
1038
+ */
1039
+ async rateLimitConfig(eid, inbound) {
1040
+ return executeSimulate(
1041
+ this.client,
1042
+ async (tx) => {
1043
+ await this.rateLimitConfigMoveCall(tx, eid, inbound);
1044
+ },
1045
+ (result) => {
1046
+ const limit = BigInt(bcs.U64.parse(result[0].value));
1047
+ const windowSeconds = BigInt(bcs.U64.parse(result[1].value));
1048
+ return { limit, windowSeconds };
1049
+ }
1050
+ );
1051
+ }
1052
+ /**
1053
+ * Get current in-flight amount for rate limiting
1054
+ * @param tx - The transaction to add the move call to
1055
+ * @param eid - Endpoint ID
1056
+ * @param inbound - Whether this is for inbound or outbound transfers
1057
+ * @returns Transaction result containing in-flight amount
1058
+ */
1059
+ async rateLimitInFlightMoveCall(tx, eid, inbound) {
1060
+ return tx.moveCall({
1061
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "rate_limit_in_flight"),
1062
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
1063
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), asU32(tx, eid), asBool(tx, inbound), tx.object.clock()]
1064
+ });
1065
+ }
1066
+ /**
1067
+ * Get current in-flight amount for rate limiting
1068
+ * @param eid - Endpoint ID
1069
+ * @param inbound - Whether this is for inbound or outbound transfers
1070
+ * @returns Promise<bigint> - Current in-flight amount
1071
+ */
1072
+ async rateLimitInFlight(eid, inbound) {
1073
+ return executeSimulate(
1074
+ this.client,
1075
+ async (tx) => {
1076
+ await this.rateLimitInFlightMoveCall(tx, eid, inbound);
1077
+ },
1078
+ (result) => BigInt(bcs.U64.parse(result[0].value))
1079
+ );
1080
+ }
1081
+ /**
1082
+ * Get rate limit capacity (remaining available amount)
1083
+ * @param tx - The transaction to add the move call to
1084
+ * @param eid - Endpoint ID
1085
+ * @param inbound - Whether this is for inbound or outbound transfers
1086
+ * @returns Transaction result containing rate limit capacity
1087
+ */
1088
+ async rateLimitCapacityMoveCall(tx, eid, inbound) {
1089
+ return tx.moveCall({
1090
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "rate_limit_capacity"),
1091
+ typeArguments: [await __privateMethod(this, _OFT_instances, coinType_fn).call(this)],
1092
+ arguments: [tx.object(await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this)), asU32(tx, eid), asBool(tx, inbound), tx.object.clock()]
1093
+ });
1094
+ }
1095
+ /**
1096
+ * Get rate limit capacity (remaining available amount)
1097
+ * @param eid - Endpoint ID
1098
+ * @param inbound - Whether this is for inbound or outbound transfers
1099
+ * @returns Promise<bigint> - Remaining rate limit capacity
1100
+ */
1101
+ async rateLimitCapacity(eid, inbound) {
1102
+ return executeSimulate(
1103
+ this.client,
1104
+ async (tx) => {
1105
+ await this.rateLimitCapacityMoveCall(tx, eid, inbound);
1106
+ },
1107
+ (result) => BigInt(bcs.U64.parse(result[0].value))
1108
+ );
1109
+ }
1110
+ // ==========================================
1111
+ // OFT SENDER
1112
+ // ==========================================
1113
+ /**
1114
+ * Create a transaction sender object for OFT operations
1115
+ * @param tx - The transaction to add the move call to
1116
+ * @returns Transaction result containing the transaction sender object
1117
+ */
1118
+ async txSenderMoveCall(tx) {
1119
+ return tx.moveCall({
1120
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "tx_sender", OFT_SENDER_MODULE_NAME)
1121
+ });
1122
+ }
1123
+ };
1124
+ _OFT_instances = new WeakSet();
1125
+ buildSendParam_fn = async function(tx, param) {
1126
+ return tx.moveCall({
1127
+ target: await __privateMethod(this, _OFT_instances, target_fn).call(this, "create", "send_param"),
1128
+ arguments: [
1129
+ asU32(tx, param.dstEid),
1130
+ asBytes32(tx, param.to, this.protocolSDK.getUtils()),
1131
+ asU64(tx, param.amountLd),
1132
+ asU64(tx, param.minAmountLd),
1133
+ asBytes(tx, param.extraOptions),
1134
+ asBytes(tx, param.composeMsg),
1135
+ asBytes(tx, param.oftCmd)
1136
+ ]
1137
+ });
1138
+ };
1139
+ target_fn = async function(name, module_name = MODULE_NAME) {
1140
+ return `${await __privateMethod(this, _OFT_instances, oftPackageId_fn).call(this)}::${module_name}::${name}`;
1141
+ };
1142
+ oappObjectId_fn = async function() {
1143
+ if (this.oappObjectId === void 0) {
1144
+ const oappSdk = this.protocolSDK.getOApp(this.oftCallCapId);
1145
+ const oappInfo = await oappSdk.getOAppInfoV1();
1146
+ this.oappObjectId = oappInfo.oapp_object;
1147
+ }
1148
+ return this.oappObjectId;
1149
+ };
1150
+ oftObjectId_fn = async function() {
1151
+ if (this.oftObjectId === void 0) {
1152
+ const oftInfo = await __privateMethod(this, _OFT_instances, OftInfo_fn).call(this);
1153
+ this.oftObjectId = oftInfo.oftObject;
1154
+ }
1155
+ return this.oftObjectId;
1156
+ };
1157
+ adminCapId_fn = async function() {
1158
+ if (this.adminCapId === void 0) {
1159
+ this.adminCapId = await this.adminCap();
1160
+ }
1161
+ return this.adminCapId;
1162
+ };
1163
+ coinType_fn = async function() {
1164
+ if (this.coinType === void 0) {
1165
+ const oftInfo = await this.client.getObject({
1166
+ id: await __privateMethod(this, _OFT_instances, oftObjectId_fn).call(this),
1167
+ options: {
1168
+ showContent: true
1169
+ }
1170
+ });
1171
+ const content = oftInfo.data?.content;
1172
+ if (content?.dataType !== "moveObject" || content.type == null || content.type.length === 0) {
1173
+ throw new Error("Invalid OFT object data or missing type field");
1174
+ }
1175
+ const typeStr = content.type;
1176
+ const angleBracketMatch = typeStr.match(/<([^>]+)>/);
1177
+ const coinType = angleBracketMatch?.[1];
1178
+ if (coinType === void 0 || coinType === "") {
1179
+ throw new Error("Failed to extract coinType from object type");
1180
+ }
1181
+ this.coinType = coinType;
1182
+ }
1183
+ return this.coinType;
1184
+ };
1185
+ OftInfo_fn = async function() {
1186
+ if (!this.oftInfo) {
1187
+ const oappSdk = this.protocolSDK.getOApp(this.oftCallCapId);
1188
+ this.oftInfo = await executeSimulate(
1189
+ this.client,
1190
+ (tx) => {
1191
+ const oappInfo = oappSdk.getOAppInfoV1MoveCall(tx);
1192
+ const extraInfo = oappSdk.getOAppInfoV1ExtraInfoMoveCall(tx, oappInfo);
1193
+ this.decodeOftInfoV1MoveCall(tx, extraInfo);
1194
+ },
1195
+ (result) => parseOFTInfoV1(result[0].value)
1196
+ );
1197
+ }
1198
+ return this.oftInfo;
1199
+ };
1200
+ oftPackageId_fn = async function() {
1201
+ if (this.oftPackageId === void 0) {
1202
+ const oftInfo = await __privateMethod(this, _OFT_instances, OftInfo_fn).call(this);
1203
+ this.oftPackageId = oftInfo.oftPackage;
1204
+ }
1205
+ return this.oftPackageId;
1206
+ };
1207
+ var OFTComposerManagerErrorCode = {
1208
+ // OFT Composer Manager related errors
1209
+ EComposeTransferNotFound: 1,
1210
+ EDepositAddressNotFound: 2
1211
+ };
1212
+ var _OFTComposerManager_instances, target_fn2;
1213
+ var OFTComposerManager = class {
1214
+ constructor(protocolSDK, packageId, registryObjectId) {
1215
+ __privateAdd(this, _OFTComposerManager_instances);
1216
+ this.client = protocolSDK.client;
1217
+ this.protocolSDK = protocolSDK;
1218
+ this.packageId = packageId;
1219
+ this.registryObjectId = registryObjectId;
1220
+ }
1221
+ // === Set Functions ===
1222
+ /**
1223
+ * Set deposit address for OFT composer
1224
+ * @param tx - The transaction to add the move call to
1225
+ * @param composerCallCap - The composer call capability transaction result
1226
+ * @param depositAddress - The new deposit address
1227
+ * @returns Transaction result containing the set operation
1228
+ */
1229
+ setDepositAddressMoveCall(tx, composerCallCap, depositAddress) {
1230
+ return tx.moveCall({
1231
+ target: __privateMethod(this, _OFTComposerManager_instances, target_fn2).call(this, "set_deposit_address"),
1232
+ arguments: [tx.object(this.registryObjectId), asObject(tx, composerCallCap), asAddress(tx, depositAddress)]
1233
+ });
1234
+ }
1235
+ // === View Functions ===
1236
+ /**
1237
+ * Get deposit address for a composer
1238
+ * @param tx - The transaction to add the move call to
1239
+ * @param composer - The composer address
1240
+ * @returns Transaction result containing the deposit address
1241
+ */
1242
+ getDepositAddressMoveCall(tx, composer) {
1243
+ return tx.moveCall({
1244
+ target: __privateMethod(this, _OFTComposerManager_instances, target_fn2).call(this, "get_deposit_address"),
1245
+ arguments: [tx.object(this.registryObjectId), asAddress(tx, composer)]
1246
+ });
1247
+ }
1248
+ /**
1249
+ * Get compose transfer object for composition operations
1250
+ * @param tx - The transaction to add the move call to
1251
+ * @param from - The sender address
1252
+ * @param guid - The GUID transaction result
1253
+ * @param composer - The composer address
1254
+ * @returns Transaction result containing the compose transfer object
1255
+ */
1256
+ getComposeTransferMoveCall(tx, from, guid, composer) {
1257
+ return tx.moveCall({
1258
+ target: __privateMethod(this, _OFTComposerManager_instances, target_fn2).call(this, "get_compose_transfer"),
1259
+ arguments: [
1260
+ tx.object(this.registryObjectId),
1261
+ asAddress(tx, from),
1262
+ asBytes32(tx, guid, this.protocolSDK.getUtils()),
1263
+ asAddress(tx, composer)
1264
+ ]
1265
+ });
1266
+ }
1267
+ /**
1268
+ * Get compose transfer object address
1269
+ * @param from - The sender address
1270
+ * @param guid - The GUID as number array
1271
+ * @param composer - The composer address
1272
+ * @returns Promise<string> - The compose transfer object address
1273
+ */
1274
+ async getComposeTransfer(from, guid, composer) {
1275
+ return executeSimulate(
1276
+ this.client,
1277
+ (tx) => {
1278
+ return this.getComposeTransferMoveCall(
1279
+ tx,
1280
+ from,
1281
+ asBytes32(tx, guid, this.protocolSDK.getUtils()),
1282
+ composer
1283
+ );
1284
+ },
1285
+ (result) => {
1286
+ const parsed = bcs.Address.parse(result[0].value);
1287
+ return parsed;
1288
+ }
1289
+ );
1290
+ }
1291
+ };
1292
+ _OFTComposerManager_instances = new WeakSet();
1293
+ // === Private Functions ===
1294
+ /**
1295
+ * Generate the full target path for move calls
1296
+ * @param func - The function name to call
1297
+ * @returns The full module path for the move call
1298
+ * @private
1299
+ */
1300
+ target_fn2 = function(func) {
1301
+ return `${this.packageId}::oft_composer_manager::${func}`;
1302
+ };
1303
+
1304
+ // src/types.ts
1305
+ var OFTMsgType = {
1306
+ SEND: 1,
1307
+ SEND_AND_CALL: 2
1308
+ };
1309
+
1310
+ export { OFT, OFTComposerManager, OFTComposerManagerErrorCode, OFTErrorCode, OFTFeeDetailBcs, OFTInfoV1Bcs, OFTLimitBcs, OFTMsgType, OFTReceiptBcs, parseOFTFeeDetails, parseOFTInfoV1, parseOFTLimit, parseOFTReceipt };
1311
+ //# sourceMappingURL=index.mjs.map
1312
+ //# sourceMappingURL=index.mjs.map