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