@layerzerolabs/oft-sui-sdk 0.0.0-stage → 1.2.99

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/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2026 - LayerZero Labs Ltd.
2
+
3
+ Permission is hereby granted, free of charge, to any
4
+ person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the
6
+ Software without restriction, including without
7
+ limitation the rights to use, copy, modify, merge,
8
+ publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software
10
+ is furnished to do so, subject to the following
11
+ conditions:
12
+ The above copyright notice and this permission notice
13
+ shall be included in all copies or substantial portions
14
+ of the Software.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+ DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,180 @@
1
- # Temporary Holding Version
1
+ # @layerzerolabs/oft-sui-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ LayerZero V2 SUI OFT (Omnichain Fungible Token) SDK
4
+
5
+ ## Overview
6
+
7
+ This SDK provides TypeScript bindings for interacting with LayerZero V2 OFT contracts on the SUI blockchain. It enables developers to create, manage, and transfer omnichain fungible tokens across different blockchains using the LayerZero protocol.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @layerzerolabs/oft-sui-sdk
13
+ # or
14
+ yarn add @layerzerolabs/oft-sui-sdk
15
+ # or
16
+ pnpm add @layerzerolabs/oft-sui-sdk
17
+ ```
18
+
19
+ The package is ESM only. It replaces `@layerzerolabs/lz-sui-oft-sdk-v2`, which also shipped a CommonJS build. CommonJS code can `require` it only on Node versions with `require(esm)` (20.19+ or 22.12+). Otherwise, use `import` or a dynamic `import()`.
20
+
21
+ ## Features
22
+
23
+ - **Cross-chain Transfers**: Send tokens across different blockchains
24
+ - **OFT & OFT Adapter**: Interact with deployed OFT & OFT Adapter
25
+ - **OFT Composer Manager**: Advanced composition functionality for complex cross-chain operations
26
+
27
+ ## Usage
28
+
29
+ ### Initialize OFT
30
+
31
+ Create a new OFT that mints/burns tokens for cross-chain transfers:
32
+
33
+ ```typescript
34
+ import { OFT } from '@layerzerolabs/oft-sui-sdk';
35
+ import { SDK, validateTransaction } from '@layerzerolabs/lz-sui-sdk-v2';
36
+ import { Transaction } from '@mysten/sui/transactions';
37
+
38
+ // Initialize LayerZero protocol SDK
39
+ const protocolSDK = new SDK({
40
+ client: suiClient,
41
+ stage: Stage.MAINNET,
42
+ });
43
+
44
+ // Create OFT instance with package ID
45
+ const oft = new OFT(protocolSDK, oftPackageId);
46
+
47
+ // Initialize OFT with treasury capability (for minting/burning)
48
+ const initTx = new Transaction();
49
+ const [adminCap, migrationCap] = oft.initOftMoveCall(
50
+ initTx,
51
+ coinType, // e.g., "0x123::my_coin::MY_COIN"
52
+ oftInitTicketId, // OFT creation ticket
53
+ oappObjectId, // Associated OApp object
54
+ treasuryCapId, // Treasury cap for minting/burning
55
+ metadataId, // Coin metadata
56
+ 6, // Shared decimals for cross-chain compatibility
57
+ );
58
+
59
+ // Transfer capabilities to your address
60
+ initTx.transferObjects([adminCap, migrationCap], initTx.pure.address(yourAddress));
61
+
62
+ // Execute the transaction
63
+ const result = await validateTransaction(suiClient, signer, initTx);
64
+ ```
65
+
66
+ ### Initialize OFT Adapter
67
+
68
+ Create an OFT Adapter that wraps existing tokens:
69
+
70
+ ```typescript
71
+ // Initialize OFT Adapter (wraps existing tokens without minting/burning)
72
+ const adapterTx = new Transaction();
73
+ const [adminCap, migrationCap] = oft.initOftAdapterMoveCall(
74
+ adapterTx,
75
+ coinType, // e.g., "0x123::my_coin::MY_COIN"
76
+ oftInitTicketId, // OFT creation ticket
77
+ oappObjectId, // Associated OApp object
78
+ metadataId, // Coin metadata
79
+ 6, // Shared decimals for cross-chain compatibility
80
+ );
81
+
82
+ // Transfer capabilities to your address
83
+ adapterTx.transferObjects([adminCap, migrationCap], adapterTx.pure.address(yourAddress));
84
+
85
+ // Execute the transaction
86
+ const result = await validateTransaction(suiClient, signer, adapterTx);
87
+ ```
88
+
89
+ ### Register OFT with LayerZero Endpoint
90
+
91
+ ```typescript
92
+ import { validateTransaction } from '@layerzerolabs/lz-sui-sdk-v2';
93
+
94
+ // Register the OFT as an OApp with the LayerZero endpoint
95
+ const registerTx = new Transaction();
96
+
97
+ await oft.registerOAppMoveCall(
98
+ registerTx,
99
+ coinType, // Coin type
100
+ oftObjectId, // Created OFT object ID
101
+ oappObjectId, // Associated OApp object ID
102
+ composerManagerId, // OFT Composer Manager for handling compose messages
103
+ );
104
+
105
+ // Execute the transaction
106
+ const result = await validateTransaction(suiClient, signer, registerTx);
107
+ ```
108
+
109
+ ### Set Peer for Cross-Chain Communication
110
+
111
+ ```typescript
112
+ import { validateTransaction } from '@layerzerolabs/lz-sui-sdk-v2';
113
+
114
+ // Get OApp instance from OFT
115
+ const oapp = protocolSDK.getOApp(oft.oftCallCapId);
116
+
117
+ // Set peer OFT on destination chain
118
+ const setPeerTx = new Transaction();
119
+ await oapp.setPeerMoveCall(
120
+ setPeerTx,
121
+ remoteEid, // Remote chain endpoint ID (e.g., 30102 for Ethereum)
122
+ remotePeerBytes, // Remote OFT address as 32-byte array
123
+ );
124
+
125
+ // Execute the transaction
126
+ const result = await validateTransaction(suiClient, signer, setPeerTx);
127
+ ```
128
+
129
+ ### Quote and Send Tokens
130
+
131
+ ```typescript
132
+ // Create OFT instance (with optional parameters for convenience)
133
+ const oft = new OFT(protocolSDK, oftPackageId);
134
+
135
+ // Prepare send parameters
136
+ const sendParam = {
137
+ dstEid: 30102, // Destination endpoint ID
138
+ to: recipientAddressBytes, // Recipient address as Uint8Array (32 bytes)
139
+ amountLd: 1000000n, // Amount in local decimals
140
+ minAmountLd: 990000n, // Minimum amount (slippage protection)
141
+ extraOptions: new Uint8Array(0), // LayerZero execution options
142
+ composeMsg: new Uint8Array(0), // Optional compose message
143
+ oftCmd: new Uint8Array(0), // Optional OFT command (unused in default OFT)
144
+ };
145
+
146
+ // Quote the transfer fees
147
+ const messagingFee = await oft.quoteSend(
148
+ senderAddress,
149
+ sendParam,
150
+ false, // payInZro: false = pay in native token
151
+ );
152
+
153
+ // Execute the transfer
154
+ const tx = new Transaction();
155
+
156
+ // Split coins from sender's wallet
157
+ const coin = await oft.splitCoinMoveCall(tx, senderAddress, sendParam.amountLd);
158
+
159
+ // Send the tokens
160
+ await oft.sendMoveCall(
161
+ tx,
162
+ senderAddress,
163
+ sendParam,
164
+ coin,
165
+ messagingFee.nativeFee,
166
+ messagingFee.zroFee,
167
+ senderAddress, // refund address
168
+ );
169
+
170
+ // Transfer any remaining coins back to sender
171
+ tx.transferObjects([coin], senderAddress);
172
+ ```
173
+
174
+ ## Documentation
175
+
176
+ For detailed documentation and examples, please visit the [LayerZero documentation](https://docs.layerzero.network/).
177
+
178
+ ## License
179
+
180
+ MIT
@@ -0,0 +1,106 @@
1
+ import { __name } from './VUOMXK5T.js';
2
+ import { bcs } from '@mysten/sui/bcs';
3
+ import { asObject, asAddress, asBytes32, executeSimulate } from '@layerzerolabs/lz-sui-sdk-v2';
4
+
5
+ var OFTComposerManagerErrorCode = {
6
+ // OFT Composer Manager related errors
7
+ EComposeTransferNotFound: 1,
8
+ EDepositAddressNotFound: 2
9
+ };
10
+ var OFTComposerManager = class {
11
+ static {
12
+ __name(this, "OFTComposerManager");
13
+ }
14
+ packageId;
15
+ client;
16
+ registryObjectId;
17
+ protocolSDK;
18
+ constructor(protocolSDK, packageId, registryObjectId) {
19
+ this.client = protocolSDK.client;
20
+ this.protocolSDK = protocolSDK;
21
+ this.packageId = packageId;
22
+ this.registryObjectId = registryObjectId;
23
+ }
24
+ // === Set Functions ===
25
+ /**
26
+ * Set deposit address for OFT composer
27
+ * @param tx - The transaction to add the move call to
28
+ * @param composerCallCap - The composer call capability transaction result
29
+ * @param depositAddress - The new deposit address
30
+ * @returns Transaction result containing the set operation
31
+ */
32
+ setDepositAddressMoveCall(tx, composerCallCap, depositAddress) {
33
+ return tx.moveCall({
34
+ target: this.#target("set_deposit_address"),
35
+ arguments: [
36
+ tx.object(this.registryObjectId),
37
+ asObject(tx, composerCallCap),
38
+ asAddress(tx, depositAddress)
39
+ ]
40
+ });
41
+ }
42
+ // === View Functions ===
43
+ /**
44
+ * Get deposit address for a composer
45
+ * @param tx - The transaction to add the move call to
46
+ * @param composer - The composer address
47
+ * @returns Transaction result containing the deposit address
48
+ */
49
+ getDepositAddressMoveCall(tx, composer) {
50
+ return tx.moveCall({
51
+ target: this.#target("get_deposit_address"),
52
+ arguments: [
53
+ tx.object(this.registryObjectId),
54
+ asAddress(tx, composer)
55
+ ]
56
+ });
57
+ }
58
+ /**
59
+ * Get compose transfer object for composition operations
60
+ * @param tx - The transaction to add the move call to
61
+ * @param from - The sender address
62
+ * @param guid - The GUID transaction result
63
+ * @param composer - The composer address
64
+ * @returns Transaction result containing the compose transfer object
65
+ */
66
+ getComposeTransferMoveCall(tx, from, guid, composer) {
67
+ return tx.moveCall({
68
+ target: this.#target("get_compose_transfer"),
69
+ arguments: [
70
+ tx.object(this.registryObjectId),
71
+ asAddress(tx, from),
72
+ asBytes32(tx, guid, this.protocolSDK.getUtils()),
73
+ asAddress(tx, composer)
74
+ ]
75
+ });
76
+ }
77
+ /**
78
+ * Get compose transfer object address
79
+ * @param from - The sender address
80
+ * @param guid - The GUID as number array
81
+ * @param composer - The composer address
82
+ * @returns Promise<string> - The compose transfer object address
83
+ */
84
+ async getComposeTransfer(from, guid, composer) {
85
+ return executeSimulate(this.client, (tx) => {
86
+ return this.getComposeTransferMoveCall(tx, from, asBytes32(tx, guid, this.protocolSDK.getUtils()), composer);
87
+ }, (result) => {
88
+ const parsed = bcs.Address.parse(result[0].value);
89
+ return parsed;
90
+ });
91
+ }
92
+ // === Private Functions ===
93
+ /**
94
+ * Generate the full target path for move calls
95
+ * @param func - The function name to call
96
+ * @returns The full module path for the move call
97
+ * @private
98
+ */
99
+ #target(func) {
100
+ return `${this.packageId}::oft_composer_manager::${func}`;
101
+ }
102
+ };
103
+
104
+ export { OFTComposerManager, OFTComposerManagerErrorCode };
105
+ //# sourceMappingURL=2EH6TEKC.js.map
106
+ //# sourceMappingURL=2EH6TEKC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/modules/oft-composer-manager.ts"],"names":["OFTComposerManagerErrorCode","EComposeTransferNotFound","EDepositAddressNotFound","OFTComposerManager","packageId","client","registryObjectId","protocolSDK","setDepositAddressMoveCall","tx","composerCallCap","depositAddress","moveCall","target","arguments","object","asObject","asAddress","getDepositAddressMoveCall","composer","getComposeTransferMoveCall","from","guid","asBytes32","getUtils","getComposeTransfer","executeSimulate","result","parsed","bcs","Address","parse","value","func"],"mappings":";;;;AAOO,IAAMA,2BAAAA,GAA8B;;EAEvCC,wBAAAA,EAA0B,CAAA;EAC1BC,uBAAAA,EAAyB;AAC7B;AAQO,IAAMC,qBAAN,MAAMA;EAnBb;;;AAoBWC,EAAAA,SAAAA;AACSC,EAAAA,MAAAA;AACAC,EAAAA,gBAAAA;AACCC,EAAAA,WAAAA;EAEjB,WAAA,CAAYA,WAAAA,EAAkBH,WAAmBE,gBAAAA,EAA0B;AACvE,IAAA,IAAA,CAAKD,SAASE,WAAAA,CAAYF,MAAAA;AAC1B,IAAA,IAAA,CAAKE,WAAAA,GAAcA,WAAAA;AACnB,I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ASA,MAAMM,kBAAAA,CAAmBJ,IAAAA,EAAcC,IAAAA,EAAkBH,QAAAA,EAAmC;AACxF,IAAA,OAAOO,eAAAA,CACH,IAAA,CAAKrB,MAAAA,EACL,CAACI,EAAAA,KAAAA;AACG,MAAA,OAAO,IAAA,CAAKW,0BAAAA,CACRX,EAAAA,EACAY,IAAAA,EACAE,SAAAA,CAAUd,EAAAA,EAAIa,IAAAA,EAAM,IAAA,CAAKf,WAAAA,CAAYiB,QAAAA,EAAQ,CAAA,EAC7CL,QAAAA,CAAAA;AAER,IAAA,CAAA,EACA,CAACQ,MAAAA,KAAAA;AACG,MAAA,MAAMC,SAASC,GAAAA,CAAIC,OAAAA,CAAQC,MAAMJ,MAAAA,CAAO,CAAA,EAAGK,KAAK,CAAA;AAChD,MAAA,OAAOJ,MAAAA;IACX,CAAA,CAAA;AAER,EAAA;;;;;;;;AAUA,EAAA,OAAA,CAAQK,IAAAA,EAAY;AAChB,IAAA,OAAO,CAAA,EAAG,IAAA,CAAK7B,SAAS,CAAA,wBAAA,EAA2B6B,IAAAA,CAAAA,CAAAA;AACvD,EAAA;AACJ","file":"2EH6TEKC.js","sourcesContent":["import { bcs } from '@mysten/sui/bcs';\nimport type { SuiClient } from '@mysten/sui/client';\nimport type { Transaction, TransactionArgument, TransactionResult } from '@mysten/sui/transactions';\n\nimport type { SDK } from '@layerzerolabs/lz-sui-sdk-v2';\nimport { asAddress, asBytes32, asObject, executeSimulate } from '@layerzerolabs/lz-sui-sdk-v2';\n\nexport const OFTComposerManagerErrorCode = {\n // OFT Composer Manager related errors\n EComposeTransferNotFound: 1,\n EDepositAddressNotFound: 2,\n} as const;\n\n/**\n * OFT Composer Manager\n *\n * This class manages the registry for OFT Composer operations, including\n * deposit addresses and compose transfer routing for cross-chain composition.\n */\nexport class OFTComposerManager {\n public packageId: string;\n public readonly client: SuiClient;\n public readonly registryObjectId: string;\n private readonly protocolSDK: SDK;\n\n constructor(protocolSDK: SDK, packageId: string, registryObjectId: string) {\n this.client = protocolSDK.client;\n this.protocolSDK = protocolSDK;\n this.packageId = packageId;\n this.registryObjectId = registryObjectId;\n }\n\n // === Set Functions ===\n\n /**\n * Set deposit address for OFT composer\n * @param tx - The transaction to add the move call to\n * @param composerCallCap - The composer call capability transaction result\n * @param depositAddress - The new deposit address\n * @returns Transaction result containing the set operation\n */\n setDepositAddressMoveCall(\n tx: Transaction,\n composerCallCap: string | TransactionArgument,\n depositAddress: string | TransactionArgument,\n ): TransactionResult {\n return tx.moveCall({\n target: this.#target('set_deposit_address'),\n arguments: [\n tx.object(this.registryObjectId),\n asObject(tx, composerCallCap),\n asAddress(tx, depositAddress),\n ],\n });\n }\n\n // === View Functions ===\n\n /**\n * Get deposit address for a composer\n * @param tx - The transaction to add the move call to\n * @param composer - The composer address\n * @returns Transaction result containing the deposit address\n */\n getDepositAddressMoveCall(\n tx: Transaction,\n composer: string | TransactionArgument,\n ): TransactionResult {\n return tx.moveCall({\n target: this.#target('get_deposit_address'),\n arguments: [tx.object(this.registryObjectId), asAddress(tx, composer)],\n });\n }\n\n /**\n * Get compose transfer object for composition operations\n * @param tx - The transaction to add the move call to\n * @param from - The sender address\n * @param guid - The GUID transaction result\n * @param composer - The composer address\n * @returns Transaction result containing the compose transfer object\n */\n getComposeTransferMoveCall(\n tx: Transaction,\n from: string | TransactionArgument,\n guid: Uint8Array | TransactionArgument,\n composer: string | TransactionArgument,\n ): TransactionResult {\n return tx.moveCall({\n target: this.#target('get_compose_transfer'),\n arguments: [\n tx.object(this.registryObjectId),\n asAddress(tx, from),\n asBytes32(tx, guid, this.protocolSDK.getUtils()),\n asAddress(tx, composer),\n ],\n });\n }\n\n /**\n * Get compose transfer object address\n * @param from - The sender address\n * @param guid - The GUID as number array\n * @param composer - The composer address\n * @returns Promise<string> - The compose transfer object address\n */\n async getComposeTransfer(from: string, guid: Uint8Array, composer: string): Promise<string> {\n return executeSimulate(\n this.client,\n (tx) => {\n return this.getComposeTransferMoveCall(\n tx,\n from,\n asBytes32(tx, guid, this.protocolSDK.getUtils()),\n composer,\n );\n },\n (result) => {\n const parsed = bcs.Address.parse(result[0].value);\n return parsed;\n },\n );\n }\n\n // === Private Functions ===\n\n /**\n * Generate the full target path for move calls\n * @param func - The function name to call\n * @returns The full module path for the move call\n * @private\n */\n #target(func: string): string {\n return `${this.packageId}::oft_composer_manager::${func}`;\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ // src/types.ts
2
+ var OFTMsgType = {
3
+ SEND: 1,
4
+ SEND_AND_CALL: 2
5
+ };
6
+
7
+ export { OFTMsgType };
8
+ //# sourceMappingURL=I5Z2GNDD.js.map
9
+ //# sourceMappingURL=I5Z2GNDD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"names":["OFTMsgType","SEND","SEND_AND_CALL"],"mappings":";AACO,IAAMA,UAAAA,GAAa;EACtBC,IAAAA,EAAM,CAAA;EACNC,aAAAA,EAAe;AACnB","file":"I5Z2GNDD.js","sourcesContent":["// Constants\nexport const OFTMsgType = {\n SEND: 1,\n SEND_AND_CALL: 2,\n} as const;\n\n// Type Definitions\nexport interface SendParam {\n dstEid: number;\n to: Uint8Array;\n amountLd: bigint;\n minAmountLd: bigint;\n extraOptions: Uint8Array;\n composeMsg: Uint8Array;\n oftCmd: Uint8Array;\n}\n\nexport interface OFTLimit {\n minAmountLd: bigint;\n maxAmountLd: bigint;\n}\n\nexport interface OFTFeeDetail {\n feeAmountLd: bigint;\n description: string;\n isReward: boolean;\n}\n\nexport interface OFTReceipt {\n amountSentLd: bigint;\n amountReceivedLd: bigint;\n}\n\nexport interface OFTInfoV1 {\n oftPackage: string;\n oftObject: string;\n}\n"]}
@@ -0,0 +1,58 @@
1
+ import { __name } from './VUOMXK5T.js';
2
+ import { bcs } from '@mysten/sui/bcs';
3
+
4
+ var OFTLimitBcs = bcs.struct("OFTLimit", {
5
+ min_amount_ld: bcs.U64,
6
+ max_amount_ld: bcs.U64
7
+ });
8
+ var OFTFeeDetailBcs = bcs.struct("OFTFeeDetail", {
9
+ fee_amount_ld: bcs.U64,
10
+ is_reward: bcs.Bool,
11
+ description: bcs.String
12
+ });
13
+ var OFTReceiptBcs = bcs.struct("OFTReceipt", {
14
+ amount_sent_ld: bcs.U64,
15
+ amount_received_ld: bcs.U64
16
+ });
17
+ var OFTInfoV1Bcs = bcs.struct("OFTInfoV1", {
18
+ oft_package: bcs.Address,
19
+ oft_object: bcs.Address
20
+ });
21
+ function parseOFTLimit(data) {
22
+ const parsed = OFTLimitBcs.parse(data);
23
+ return {
24
+ minAmountLd: BigInt(parsed.min_amount_ld),
25
+ maxAmountLd: BigInt(parsed.max_amount_ld)
26
+ };
27
+ }
28
+ __name(parseOFTLimit, "parseOFTLimit");
29
+ function parseOFTFeeDetails(data) {
30
+ const vectorBcs = bcs.vector(OFTFeeDetailBcs);
31
+ const parsed = vectorBcs.parse(data);
32
+ return parsed.map((detail) => ({
33
+ feeAmountLd: BigInt(detail.fee_amount_ld),
34
+ isReward: detail.is_reward,
35
+ description: detail.description
36
+ }));
37
+ }
38
+ __name(parseOFTFeeDetails, "parseOFTFeeDetails");
39
+ function parseOFTReceipt(data) {
40
+ const parsed = OFTReceiptBcs.parse(data);
41
+ return {
42
+ amountSentLd: BigInt(parsed.amount_sent_ld),
43
+ amountReceivedLd: BigInt(parsed.amount_received_ld)
44
+ };
45
+ }
46
+ __name(parseOFTReceipt, "parseOFTReceipt");
47
+ function parseOFTInfoV1(data) {
48
+ const parsed = OFTInfoV1Bcs.parse(data);
49
+ return {
50
+ oftPackage: parsed.oft_package,
51
+ oftObject: parsed.oft_object
52
+ };
53
+ }
54
+ __name(parseOFTInfoV1, "parseOFTInfoV1");
55
+
56
+ export { OFTFeeDetailBcs, OFTInfoV1Bcs, OFTLimitBcs, OFTReceiptBcs, parseOFTFeeDetails, parseOFTInfoV1, parseOFTLimit, parseOFTReceipt };
57
+ //# sourceMappingURL=MAHTHNMM.js.map
58
+ //# sourceMappingURL=MAHTHNMM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bcs/oft.ts"],"names":["OFTLimitBcs","bcs","struct","min_amount_ld","U64","max_amount_ld","OFTFeeDetailBcs","fee_amount_ld","is_reward","Bool","description","String","OFTReceiptBcs","amount_sent_ld","amount_received_ld","OFTInfoV1Bcs","oft_package","Address","oft_object","parseOFTLimit","data","parsed","parse","minAmountLd","BigInt","maxAmountLd","parseOFTFeeDetails","vectorBcs","vector","map","detail","feeAmountLd","isReward","parseOFTReceipt","amountSentLd","amountReceivedLd","parseOFTInfoV1","oftPackage","oftObject"],"mappings":";;;AAKO,IAAMA,WAAAA,GAAcC,GAAAA,CAAIC,MAAAA,CAAO,UAAA,EAAY;AAC9CC,EAAAA,aAAAA,EAAeF,GAAAA,CAAIG,GAAAA;AACnBC,EAAAA,aAAAA,EAAeJ,GAAAA,CAAIG;AACvB,CAAA;AAGO,IAAME,eAAAA,GAAkBL,GAAAA,CAAIC,MAAAA,CAAO,cAAA,EAAgB;AACtDK,EAAAA,aAAAA,EAAeN,GAAAA,CAAIG,GAAAA;AACnBI,EAAAA,SAAAA,EAAWP,GAAAA,CAAIQ,IAAAA;AACfC,EAAAA,WAAAA,EAAaT,GAAAA,CAAIU;AACrB,CAAA;AAGO,IAAMC,aAAAA,GAAgBX,GAAAA,CAAIC,MAAAA,CAAO,YAAA,EAAc;AAClDW,EAAAA,cAAAA,EAAgBZ,GAAAA,CAAIG,GAAAA;AACpBU,EAAAA,kBAAAA,EAAoBb,GAAAA,CAAIG;AAC5B,CAAA;AAGO,IAAMW,YAAAA,GAAed,GAAAA,CAAIC,MAAAA,CAAO,WAAA,EAAa;AAChDc,EAAAA,WAAAA,EAAaf,GAAAA,CAAIgB,OAAAA;AACjBC,EAAAA,UAAAA,EAAYjB,GAAAA,CAAIgB;AACpB,CAAA;AAGO,SAASE,cAAcC,IAAAA,EAAgB;AAC1C,EAAA,MAAMC,MAAAA,GAASrB,WAAAA,CAAYsB,KAAAA,CAAMF,IAAAA,CA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;AACtB,GAAA;AACJ;AANgBkB,MAAAA,CAAAA,cAAAA,EAAAA,gBAAAA,CAAAA","file":"MAHTHNMM.js","sourcesContent":["import { bcs } from '@mysten/sui/bcs';\n\nimport type { OFTFeeDetail, OFTInfoV1, OFTLimit, OFTReceipt } from '../types';\n\n// OFTLimit struct BCS definition\nexport const OFTLimitBcs = bcs.struct('OFTLimit', {\n min_amount_ld: bcs.U64,\n max_amount_ld: bcs.U64,\n});\n\n// OFTFeeDetail struct BCS definition\nexport const OFTFeeDetailBcs = bcs.struct('OFTFeeDetail', {\n fee_amount_ld: bcs.U64,\n is_reward: bcs.Bool,\n description: bcs.String,\n});\n\n// OFTReceipt struct BCS definition\nexport const OFTReceiptBcs = bcs.struct('OFTReceipt', {\n amount_sent_ld: bcs.U64,\n amount_received_ld: bcs.U64,\n});\n\n// OFTInfoV1 struct BCS definition\nexport const OFTInfoV1Bcs = bcs.struct('OFTInfoV1', {\n oft_package: bcs.Address,\n oft_object: bcs.Address,\n});\n\n// Helper function to parse OFTLimit\nexport function parseOFTLimit(data: Uint8Array): OFTLimit {\n const parsed = OFTLimitBcs.parse(data);\n return {\n minAmountLd: BigInt(parsed.min_amount_ld),\n maxAmountLd: BigInt(parsed.max_amount_ld),\n };\n}\n\n// Helper function to parse OFTFeeDetail array\nexport function parseOFTFeeDetails(data: Uint8Array): OFTFeeDetail[] {\n // Parse as vector of OFTFeeDetail\n const vectorBcs = bcs.vector(OFTFeeDetailBcs);\n const parsed = vectorBcs.parse(data);\n\n return parsed.map(\n (detail: {\n fee_amount_ld: string | number | bigint;\n is_reward: boolean;\n description: string;\n }) => ({\n feeAmountLd: BigInt(detail.fee_amount_ld),\n isReward: detail.is_reward,\n description: detail.description,\n }),\n );\n}\n\n// Helper function to parse OFTReceipt\nexport function parseOFTReceipt(data: Uint8Array): OFTReceipt {\n const parsed = OFTReceiptBcs.parse(data);\n return {\n amountSentLd: BigInt(parsed.amount_sent_ld),\n amountReceivedLd: BigInt(parsed.amount_received_ld),\n };\n}\n\n// Helper function to parse OFTInfoV1\nexport function parseOFTInfoV1(data: Uint8Array): OFTInfoV1 {\n const parsed = OFTInfoV1Bcs.parse(data);\n return {\n oftPackage: parsed.oft_package,\n oftObject: parsed.oft_object,\n };\n}\n"]}