@layerzerolabs/lz-sui-sdk-v2 3.0.73 → 3.0.75

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.d.ts CHANGED
@@ -1,24 +1,353 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
-
3
- declare function initEid(): Promise<Transaction>;
4
- declare function eid(): Promise<number>;
5
- declare function getSendLibrary(sender: string, dst_eid: number): Promise<string>;
6
- declare function getConfig(): Promise<string>;
7
- declare function populateQuoteTransaction(tx: Transaction): Promise<void>;
8
- declare function populateSendTransaction(tx: Transaction): Promise<void>;
9
- declare function populateGetConfigTransaction(tx: Transaction): Promise<void>;
10
- declare function populateSetConfigTransaction(tx: Transaction): Promise<void>;
11
-
12
- declare const endpoint_eid: typeof eid;
13
- declare const endpoint_getConfig: typeof getConfig;
14
- declare const endpoint_getSendLibrary: typeof getSendLibrary;
15
- declare const endpoint_initEid: typeof initEid;
16
- declare const endpoint_populateGetConfigTransaction: typeof populateGetConfigTransaction;
17
- declare const endpoint_populateQuoteTransaction: typeof populateQuoteTransaction;
18
- declare const endpoint_populateSendTransaction: typeof populateSendTransaction;
19
- declare const endpoint_populateSetConfigTransaction: typeof populateSetConfigTransaction;
20
- declare namespace endpoint {
21
- export { endpoint_eid as eid, endpoint_getConfig as getConfig, endpoint_getSendLibrary as getSendLibrary, endpoint_initEid as initEid, endpoint_populateGetConfigTransaction as populateGetConfigTransaction, endpoint_populateQuoteTransaction as populateQuoteTransaction, endpoint_populateSendTransaction as populateSendTransaction, endpoint_populateSetConfigTransaction as populateSetConfigTransaction };
22
- }
23
-
24
- export { endpoint };
1
+ import { SuiClient, SuiTransactionBlockResponse, SuiExecutionResult } from '@mysten/sui/client';
2
+ import { Transaction, TransactionResult } from '@mysten/sui/transactions';
3
+ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
+ import { EndpointId, Stage, Chain } from '@layerzerolabs/lz-definitions';
5
+ import { Keypair } from '@mysten/sui/cryptography';
6
+ import { Provider } from '@layerzerolabs/lz-core';
7
+ import * as _mysten_sui_dist_cjs_bcs from '@mysten/sui/dist/cjs/bcs';
8
+
9
+ /**
10
+ * Type representing the options for packages.
11
+ */
12
+ type PackageOptions = {
13
+ /**
14
+ * The endpoint V2 address.
15
+ */
16
+ endpoint_v2: string;
17
+ /**
18
+ * The counter V2 address.
19
+ */
20
+ counter_v2: string;
21
+ /**
22
+ * The simple message library address.
23
+ */
24
+ simple_message_lib: string;
25
+ /**
26
+ * The zro address.
27
+ */
28
+ zro: string;
29
+ /**
30
+ * The utils address.
31
+ */
32
+ utils: string;
33
+ } & {
34
+ [key: string]: string;
35
+ };
36
+ /**
37
+ * Type representing the options for objects.
38
+ */
39
+ type ObjectOptions = {
40
+ /**
41
+ * The endpoint V2 object address.
42
+ */
43
+ endpoint_v2: string;
44
+ /**
45
+ * The simple message library object address.
46
+ */
47
+ simple_message_lib: string;
48
+ /**
49
+ * The ULN-302 message library object address.
50
+ */
51
+ uln_302: string;
52
+ /**
53
+ * The blocked message library object address.
54
+ */
55
+ blocked_message_lib: string;
56
+ /**
57
+ * The discovery object address for OApp discovery.
58
+ */
59
+ discovery: string;
60
+ /**
61
+ * The counter OApp object address.
62
+ */
63
+ counter: string;
64
+ /**
65
+ * The OApp core object address.
66
+ */
67
+ oapp_core: string;
68
+ /**
69
+ * The endpoint admin cap object address.
70
+ */
71
+ endpoint_admin_cap: string;
72
+ /**
73
+ * The counter admin cap object address.
74
+ */
75
+ counter_admin_cap: string;
76
+ } & {
77
+ [key: string]: string;
78
+ };
79
+ interface Context {
80
+ endpoint: Endpoint;
81
+ counter: Counter;
82
+ simpleMessageLib: SimpleMessageLib;
83
+ utils: Utils;
84
+ zro: Zro;
85
+ }
86
+
87
+ declare class SimpleMessageLib {
88
+ private readonly context;
89
+ packageId: string;
90
+ readonly client: SuiClient;
91
+ private readonly objects;
92
+ constructor(packageId: string, client: SuiClient, objects: Pick<ObjectOptions, 'simple_message_lib' | 'endpoint_admin_cap' | 'endpoint_v2' | 'discovery'>, context: Context);
93
+ populateInitializeTransaction(): Transaction;
94
+ getNativeFee(): Promise<string>;
95
+ getZroFee(): Promise<string>;
96
+ getFeeRecipient(): Promise<string>;
97
+ isRegistered(): Promise<boolean>;
98
+ populateRegisterLibraryTransaction(): Transaction;
99
+ populateSetMessagingFeeTransaction(zroFee: number, nativeFee: number): Transaction;
100
+ populateSetDefaultConfigTransaction(eid: number, configType: number, config: Uint8Array): Transaction;
101
+ populateSetFeeRecipientTransaction(feeRecipient: string): Transaction;
102
+ populateValidatePacketTransaction(packetHeader: Uint8Array, payloadHash: Uint8Array): Transaction;
103
+ populateRegisterMessageLibDiscoveryTransaction(): Transaction;
104
+ quoteMoveCall(tx: Transaction, quoteCall: TransactionResult): TransactionResult;
105
+ sendMoveCall(tx: Transaction, sendCall: TransactionResult): TransactionResult;
106
+ populateQuoteTransaction(tx: Transaction): void;
107
+ populateSendTransaction(tx: Transaction): void;
108
+ populateSetConfigTransaction(tx: Transaction): void;
109
+ populateGetConfigTransaction(tx: Transaction): void;
110
+ }
111
+
112
+ declare class Endpoint {
113
+ private readonly context;
114
+ packageId: string;
115
+ readonly client: SuiClient;
116
+ private readonly objects;
117
+ constructor(packageId: string, client: SuiClient, objects: Pick<ObjectOptions, 'endpoint_v2' | 'endpoint_admin_cap'>, context: Context);
118
+ eid(): Promise<number>;
119
+ populateInitEidTransaction(eid: number): Transaction;
120
+ getDefaultSendLibrary(srcEid: number): Promise<string>;
121
+ populateSetDefaultSendLibraryTransaction(dstEid: number, newLib: string): Transaction;
122
+ getDefaultReceiveLibrary(srcEid: number): Promise<string>;
123
+ populateSetDefaultReceiveLibraryTransaction(srcEid: number, newLib: string, gracePeriod: number): Transaction;
124
+ confirmQuoteMoveCall(tx: Transaction, executedCall: TransactionResult): TransactionResult;
125
+ confirmSendMoveCall(tx: Transaction, executedCall: TransactionResult): TransactionResult;
126
+ getSendLibrary(sender: string, dstEid: number): Promise<[string, boolean]>;
127
+ getReceiveLibrary(receiver: string, srcEid: number): Promise<[string, boolean]>;
128
+ getInboundNonce(receiver: string, srcEid: number, sender: Uint8Array): Promise<bigint>;
129
+ getLazyInboundNonce(receiver: string, srcEid: number, sender: Uint8Array): Promise<bigint>;
130
+ getOutboundNonce(sender: string, dstEid: number, receiver: Uint8Array): Promise<bigint>;
131
+ getInboundPayloadHash(receiver: string, srcEid: number, sender: Uint8Array, nonce: bigint): Promise<Uint8Array | null>;
132
+ getComposeMessageHash(from: string, to: string, guid: Uint8Array, index: number): Promise<Uint8Array>;
133
+ populateQuoteTransaction(tx: Transaction): void;
134
+ populateSendTransaction(tx: Transaction): void;
135
+ populateGetConfigTransaction(tx: Transaction): void;
136
+ populateSetConfigTransaction(tx: Transaction): void;
137
+ }
138
+
139
+ declare class Counter {
140
+ private readonly context;
141
+ packageId: string;
142
+ utilsPkgId: string;
143
+ readonly client: SuiClient;
144
+ private readonly objects;
145
+ constructor(packageId: string, utilsPkgId: string, client: SuiClient, objects: Pick<ObjectOptions, 'counter' | 'counter_admin_cap' | 'endpoint_v2' | 'simple_message_lib'>, context: Context);
146
+ getPeer(dstEid: number): Promise<string>;
147
+ getCount(): Promise<number>;
148
+ getComposedCount(): Promise<number>;
149
+ populateSetPeerTransaction(dstEid: number, peer: Uint8Array): Transaction;
150
+ /**
151
+ * Builds a transaction for calling the lz_receive function on the counter contract.
152
+ *
153
+ * @param srcEid - The source endpoint ID
154
+ * @param sender - The sender address as Bytes32
155
+ * @param nonce - The nonce
156
+ * @param guid - The GUID as Bytes32
157
+ * @param message - The message as vector<u8>
158
+ * @param value - The value to be sent (Coin<SUI>)
159
+ * @param extraData - Extra data as vector<u8>
160
+ * @returns A Transaction object ready to be executed
161
+ */
162
+ populateLzReceiveTransaction(srcEid: number, sender: Uint8Array, nonce: bigint, guid: Uint8Array, message: Uint8Array, value: bigint, extraData?: Uint8Array): Transaction;
163
+ quote(dstEid: EndpointId, msgType: number, options: Uint8Array, payInZero: boolean): Promise<[bigint, bigint]>;
164
+ send(sender: Ed25519Keypair, dstEid: EndpointId, msgType: number, options: Uint8Array, sendValue: string, nativeFee: string, zroFee: string): Promise<SuiTransactionBlockResponse>;
165
+ }
166
+
167
+ declare class Utils {
168
+ packageId: string;
169
+ readonly client: SuiClient;
170
+ private readonly context;
171
+ constructor(packageId: string, client: SuiClient, context: Context);
172
+ fromBytesMoveCall(tx: Transaction, peer: Uint8Array): TransactionResult;
173
+ fromBytesLeftPaddedMoveCall(tx: Transaction, bytes: Uint8Array): TransactionResult;
174
+ fromBytesRightPaddedMoveCall(tx: Transaction, bytes: Uint8Array): TransactionResult;
175
+ fromAddressMoveCall(tx: Transaction, address: string): TransactionResult;
176
+ fromIdMoveCall(tx: Transaction, id: string): TransactionResult;
177
+ zeroBytes32MoveCall(tx: Transaction): TransactionResult;
178
+ ffBytes32MoveCall(tx: Transaction): TransactionResult;
179
+ isZeroMoveCall(tx: Transaction, bytes32: string): TransactionResult;
180
+ isFfMoveCall(tx: Transaction, bytes32: string): TransactionResult;
181
+ toBytesMoveCall(tx: Transaction, bytes32: string): TransactionResult;
182
+ toAddressMoveCall(tx: Transaction, bytes32: string): TransactionResult;
183
+ toIdMoveCall(tx: Transaction, bytes32: string): TransactionResult;
184
+ newReaderMoveCall(tx: Transaction, buffer: Uint8Array): TransactionResult;
185
+ newWriterMoveCall(tx: Transaction): TransactionResult;
186
+ createWriterMoveCall(tx: Transaction, buffer: Uint8Array): TransactionResult;
187
+ positionMoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
188
+ remainingLengthMoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
189
+ skipMoveCall(tx: Transaction, reader: TransactionResult, len: number): TransactionResult;
190
+ setPositionMoveCall(tx: Transaction, reader: TransactionResult, position: number): TransactionResult;
191
+ rewindMoveCall(tx: Transaction, reader: TransactionResult, len: number): TransactionResult;
192
+ readU8MoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
193
+ readU16MoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
194
+ readU32MoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
195
+ readU64MoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
196
+ readU128MoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
197
+ readU256MoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
198
+ readBytes32MoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
199
+ readAddressMoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
200
+ readFixedLenBytesMoveCall(tx: Transaction, reader: TransactionResult, len: number): TransactionResult;
201
+ readBytesUntilEndMoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
202
+ readerBufferLengthMoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
203
+ readerToBytesMoveCall(tx: Transaction, reader: TransactionResult): TransactionResult;
204
+ writerBufferLengthMoveCall(tx: Transaction, writer: TransactionResult): TransactionResult;
205
+ writerToBytesMoveCall(tx: Transaction, writer: TransactionResult): TransactionResult;
206
+ writeU8MoveCall(tx: Transaction, writer: TransactionResult, value: number): TransactionResult;
207
+ writeU16MoveCall(tx: Transaction, writer: TransactionResult, value: number): TransactionResult;
208
+ writeU32MoveCall(tx: Transaction, writer: TransactionResult, value: number): TransactionResult;
209
+ writeU64MoveCall(tx: Transaction, writer: TransactionResult, value: number): TransactionResult;
210
+ writeU128MoveCall(tx: Transaction, writer: TransactionResult, value: string): TransactionResult;
211
+ writeU256MoveCall(tx: Transaction, writer: TransactionResult, value: string): TransactionResult;
212
+ writeBytesMoveCall(tx: Transaction, writer: TransactionResult, bytes: Uint8Array): TransactionResult;
213
+ writeAddressMoveCall(tx: Transaction, writer: TransactionResult, address: string): TransactionResult;
214
+ writeBytes32MoveCall(tx: Transaction, writer: TransactionResult, bytes32: string): TransactionResult;
215
+ blake2b256MoveCall(tx: Transaction, bytes: Uint8Array): TransactionResult;
216
+ keccak256MoveCall(tx: Transaction, bytes: Uint8Array): TransactionResult;
217
+ }
218
+
219
+ declare class Zro {
220
+ private readonly context;
221
+ packageId: string;
222
+ readonly client: SuiClient;
223
+ constructor(packageId: string, client: SuiClient, context: Context);
224
+ zeroOptionMoveCall(tx: Transaction): TransactionResult;
225
+ noneOptionMoveCall(tx: Transaction): TransactionResult;
226
+ }
227
+
228
+ declare function devInspectTransaction(suiClient: SuiClient, tx: Transaction, sender: string): Promise<SuiExecutionResult[] | null | undefined>;
229
+ declare function moveView(suiClient: SuiClient, tx: Transaction, sender?: string): Promise<SuiExecutionResult | null | undefined>;
230
+ declare function readAddressFromDeployment(network: string, name: string): string | undefined;
231
+ declare function validateTransaction(client: SuiClient, signer: Keypair, tx: Transaction): Promise<SuiTransactionBlockResponse>;
232
+
233
+ /**
234
+ * Creates an instance of the SDK from the given provider.
235
+ *
236
+ * @param {unknown} provider - The provider of the current chain.
237
+ * @param {Stage} [stage] - The stage of the SDK. {@link Stage}
238
+ * @returns {SDK} The initialized SDK instance.
239
+ */
240
+ declare function getSDKFromProvider(provider: Provider, stage?: Stage): SDK;
241
+ /**
242
+ * Options for initializing the SDK.
243
+ */
244
+ interface SdkOptions {
245
+ /**
246
+ * The chain for the SDK (optional).
247
+ * default value is Chain.SUI
248
+ */
249
+ chain?: Chain;
250
+ /**
251
+ * The Sui client for the SDK.
252
+ */
253
+ client: SuiClient;
254
+ /**
255
+ * The stage of the SDK (optional).
256
+ * default value is Stage.SANDBOX
257
+ */
258
+ stage?: Stage;
259
+ /**
260
+ * The package options for the SDK.
261
+ */
262
+ packages?: Partial<PackageOptions>;
263
+ /**
264
+ * The object options for the SDK.
265
+ */
266
+ objects?: Partial<ObjectOptions>;
267
+ }
268
+ /**
269
+ * The SDK class provides methods to interact with LayerZero on Sui.
270
+ * It initializes all modules at once and provides access to them.
271
+ */
272
+ declare class SDK {
273
+ chain: Chain;
274
+ stage: Stage;
275
+ client: SuiClient;
276
+ readonly packages: PackageOptions;
277
+ readonly objects: ObjectOptions;
278
+ endpoint: Endpoint;
279
+ counter: Counter;
280
+ simpleMessageLib: SimpleMessageLib;
281
+ utils: Utils;
282
+ zro: Zro;
283
+ /**
284
+ * Creates an instance of the SDK.
285
+ *
286
+ * @param {SdkOptions} options - The SDK options.
287
+ */
288
+ constructor(options: SdkOptions);
289
+ /**
290
+ * Gets the Sui client.
291
+ *
292
+ * @returns {SuiClient} The Sui client.
293
+ */
294
+ getSuiClient(): SuiClient;
295
+ /**
296
+ * Gets the chain.
297
+ *
298
+ * @returns {Chain} The chain.
299
+ */
300
+ getChain(): Chain;
301
+ /**
302
+ * Gets the stage.
303
+ *
304
+ * @returns {Stage} The stage.
305
+ */
306
+ getStage(): Stage;
307
+ /**
308
+ * Gets the package options.
309
+ *
310
+ * @returns {PackageOptions} The package options.
311
+ */
312
+ getPackages(): PackageOptions;
313
+ /**
314
+ * Gets the object options.
315
+ *
316
+ * @returns {ObjectOptions} The object options.
317
+ */
318
+ getObjects(): ObjectOptions;
319
+ /**
320
+ * Gets the endpoint module.
321
+ *
322
+ * @returns {Endpoint} The endpoint module.
323
+ */
324
+ getEndpoint(): Endpoint;
325
+ /**
326
+ * Gets the counter module.
327
+ *
328
+ * @returns {Counter} The counter module.
329
+ */
330
+ getCounter(): Counter;
331
+ /**
332
+ * Gets the simple message library module.
333
+ *
334
+ * @returns {SimpleMessageLib} The simple message library module.
335
+ */
336
+ getSimpleMessageLib(): SimpleMessageLib;
337
+ /**
338
+ * Gets the utils module.
339
+ *
340
+ * @returns {Utils} The utils module.
341
+ */
342
+ getUtils(): Utils;
343
+ }
344
+
345
+ declare const MessagingFeeBcs: _mysten_sui_dist_cjs_bcs.BcsType<{
346
+ native_fee: string;
347
+ zro_fee: string;
348
+ }, {
349
+ native_fee: string | number | bigint;
350
+ zro_fee: string | number | bigint;
351
+ }>;
352
+
353
+ export { type Context, Counter, Endpoint, MessagingFeeBcs, type ObjectOptions, type PackageOptions, SDK, type SdkOptions, SimpleMessageLib, Utils, Zro, devInspectTransaction, getSDKFromProvider, moveView, readAddressFromDeployment, validateTransaction };