@layerzerolabs/lz-sui-sdk-v2 3.0.134-sui.1 → 3.0.134-sui.2

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.
Files changed (73) hide show
  1. package/deployments/sui-sandbox-local/blocked_message_lib.json +26 -26
  2. package/deployments/sui-sandbox-local/blocked_msglib_ptb_builder.json +26 -26
  3. package/deployments/sui-sandbox-local/counter.json +58 -58
  4. package/deployments/sui-sandbox-local/dvn.json +14 -14
  5. package/deployments/sui-sandbox-local/dvn_call_type.json +28 -28
  6. package/deployments/sui-sandbox-local/dvn_fee_lib.json +27 -27
  7. package/deployments/sui-sandbox-local/dvn_layerzero.json +17 -17
  8. package/deployments/sui-sandbox-local/dvn_ptb_builder.json +14 -14
  9. package/deployments/sui-sandbox-local/endpoint_ptb_builder.json +26 -26
  10. package/deployments/sui-sandbox-local/endpoint_v2.json +28 -28
  11. package/deployments/sui-sandbox-local/executor.json +22 -22
  12. package/deployments/sui-sandbox-local/executor_call_type.json +21 -21
  13. package/deployments/sui-sandbox-local/executor_fee_lib.json +27 -27
  14. package/deployments/sui-sandbox-local/executor_layerzero.json +19 -19
  15. package/deployments/sui-sandbox-local/executor_ptb_builder.json +21 -21
  16. package/deployments/sui-sandbox-local/layerzero_views.json +21 -21
  17. package/deployments/sui-sandbox-local/message_lib_common.json +21 -21
  18. package/deployments/sui-sandbox-local/msglib_ptb_builder_call_types.json +13 -13
  19. package/deployments/sui-sandbox-local/oapp.json +21 -21
  20. package/deployments/sui-sandbox-local/object-BlockedMessageLib.json +5 -5
  21. package/deployments/sui-sandbox-local/object-BlockedMsglibPtbBuilder.json +5 -5
  22. package/deployments/sui-sandbox-local/object-Counter.json +5 -5
  23. package/deployments/sui-sandbox-local/object-CounterAdminCap.json +5 -5
  24. package/deployments/sui-sandbox-local/object-CounterOApp.json +5 -5
  25. package/deployments/sui-sandbox-local/object-DVN.json +2 -2
  26. package/deployments/sui-sandbox-local/object-DVNCap.json +4 -4
  27. package/deployments/sui-sandbox-local/object-DVNFeeLib.json +5 -5
  28. package/deployments/sui-sandbox-local/object-EndpointPtbBuilder.json +5 -5
  29. package/deployments/sui-sandbox-local/object-EndpointPtbBuilderAdminCap.json +5 -5
  30. package/deployments/sui-sandbox-local/object-EndpointV2.json +5 -5
  31. package/deployments/sui-sandbox-local/object-EndpointV2AdminCap.json +5 -5
  32. package/deployments/sui-sandbox-local/object-Executor.json +2 -2
  33. package/deployments/sui-sandbox-local/object-ExecutorCap.json +4 -4
  34. package/deployments/sui-sandbox-local/object-ExecutorFeeLib.json +5 -5
  35. package/deployments/sui-sandbox-local/object-ExecutorOwnerCap.json +2 -2
  36. package/deployments/sui-sandbox-local/object-PackageWhitelistValidator.json +5 -5
  37. package/deployments/sui-sandbox-local/object-PriceFeed.json +5 -5
  38. package/deployments/sui-sandbox-local/object-PriceFeedOwnerCap.json +5 -5
  39. package/deployments/sui-sandbox-local/object-SimpleMessageLib.json +5 -5
  40. package/deployments/sui-sandbox-local/object-SimpleMessageLibAdminCap.json +5 -5
  41. package/deployments/sui-sandbox-local/object-SmlPtbBuilder.json +5 -5
  42. package/deployments/sui-sandbox-local/object-Treasury.json +5 -5
  43. package/deployments/sui-sandbox-local/object-TreasuryAdminCap.json +5 -5
  44. package/deployments/sui-sandbox-local/object-ULN302.json +5 -5
  45. package/deployments/sui-sandbox-local/object-ULN302AdminCap.json +5 -5
  46. package/deployments/sui-sandbox-local/object-Uln302PtbBuilder.json +5 -5
  47. package/deployments/sui-sandbox-local/object-Uln302Verification.json +5 -5
  48. package/deployments/sui-sandbox-local/object-WorkerRegistry.json +5 -5
  49. package/deployments/sui-sandbox-local/package_whitelist_validator.json +44 -44
  50. package/deployments/sui-sandbox-local/price_feed.json +40 -40
  51. package/deployments/sui-sandbox-local/price_feed_call_types.json +12 -12
  52. package/deployments/sui-sandbox-local/ptb_move_call.json +20 -20
  53. package/deployments/sui-sandbox-local/simple_message_lib.json +22 -22
  54. package/deployments/sui-sandbox-local/simple_msglib_ptb_builder.json +26 -26
  55. package/deployments/sui-sandbox-local/treasury.json +38 -38
  56. package/deployments/sui-sandbox-local/uln_302.json +42 -46
  57. package/deployments/sui-sandbox-local/uln_302_ptb_builder.json +25 -25
  58. package/deployments/sui-sandbox-local/uln_common.json +49 -0
  59. package/deployments/sui-sandbox-local/worker_common.json +21 -21
  60. package/deployments/sui-sandbox-local/worker_registry.json +24 -24
  61. package/dist/index.cjs +220 -76
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.d.mts +69 -12
  64. package/dist/index.d.ts +69 -12
  65. package/dist/index.mjs +220 -76
  66. package/dist/index.mjs.map +1 -1
  67. package/package.json +7 -7
  68. package/src/generated/addresses.ts +54 -54
  69. package/src/modules/message-libs/uln302.ts +5 -21
  70. package/src/modules/workers/dvn-layerzero.ts +3 -0
  71. package/src/modules/workers/dvn.ts +140 -6
  72. package/src/modules/workers/executor-layerzero.ts +3 -0
  73. package/src/modules/workers/executor.ts +52 -0
@@ -268,6 +268,37 @@ export class DVN {
268
268
 
269
269
  // === Set Functions with Signatures ===
270
270
 
271
+ /**
272
+ * Set supported message library (admin with signatures)
273
+ * @param tx - The transaction to add the move call to
274
+ * @param adminCap - The admin capability object ID
275
+ * @param messageLib - The message library address
276
+ * @param supported - Whether to support or remove support for the message library
277
+ * @param expiration - Signature expiration timestamp
278
+ * @param signatures - Multisig signatures for authorization
279
+ */
280
+ setSupportedMessageLibMoveCall(
281
+ tx: Transaction,
282
+ adminCap: string | TransactionArgument,
283
+ messageLib: string | TransactionArgument,
284
+ supported: boolean | TransactionArgument,
285
+ expiration: bigint | number | string | TransactionArgument,
286
+ signatures: Uint8Array | TransactionArgument
287
+ ): void {
288
+ tx.moveCall({
289
+ target: this.#target('set_supported_message_lib'),
290
+ arguments: [
291
+ tx.object(this.objects.dvn),
292
+ asObject(tx, adminCap),
293
+ asAddress(tx, messageLib),
294
+ asBool(tx, supported),
295
+ asU64(tx, expiration),
296
+ asBytes(tx, signatures),
297
+ tx.object.clock(),
298
+ ],
299
+ })
300
+ }
301
+
271
302
  /**
272
303
  * Set allowlist status for an OApp sender (admin with signatures)
273
304
  * @param tx - The transaction to add the move call to
@@ -448,32 +479,33 @@ export class DVN {
448
479
  // Verification Functions
449
480
 
450
481
  /**
451
- * Verify a packet with DVN signatures (admin with signatures)
482
+ * Verify a packet with DVN signatures (admin with signatures) - returns Call object for ULN302
452
483
  * @param tx - The transaction to add the move call to
453
484
  * @param adminCap - The admin capability object ID
454
- * @param verification - The verification object address
485
+ * @param targetMessageLib - The target message library address (usually ULN302)
455
486
  * @param packetHeader - The packet header as bytes
456
487
  * @param payloadHash - The payload hash as bytes
457
488
  * @param confirmations - Required confirmations count
458
489
  * @param expiration - Signature expiration timestamp
459
490
  * @param signatures - DVN multisig signatures
491
+ * @returns Transaction result containing the verification Call object
460
492
  */
461
493
  verifyMoveCall(
462
494
  tx: Transaction,
463
495
  adminCap: string | TransactionArgument,
464
- verification: string | TransactionArgument,
496
+ targetMessageLib: string | TransactionArgument,
465
497
  packetHeader: Uint8Array | TransactionArgument,
466
498
  payloadHash: Uint8Array | TransactionArgument,
467
499
  confirmations: bigint | number | string | TransactionArgument,
468
500
  expiration: bigint | number | string | TransactionArgument,
469
501
  signatures: Uint8Array | TransactionArgument
470
- ): void {
471
- tx.moveCall({
502
+ ): TransactionResult {
503
+ return tx.moveCall({
472
504
  target: this.#target('verify'),
473
505
  arguments: [
474
506
  tx.object(this.objects.dvn),
475
507
  asObject(tx, adminCap),
476
- asObject(tx, verification),
508
+ asAddress(tx, targetMessageLib),
477
509
  asBytes(tx, packetHeader),
478
510
  asBytes32(tx, payloadHash, this.moduleManager.getUtils()),
479
511
  asU64(tx, confirmations),
@@ -770,6 +802,34 @@ export class DVN {
770
802
  )
771
803
  }
772
804
 
805
+ /**
806
+ * Check if a message library is supported by this DVN
807
+ * @param tx - The transaction to add the move call to
808
+ * @param messageLib - The message library address to check
809
+ * @returns Transaction result containing the support status
810
+ */
811
+ isSupportedMessageLibMoveCall(tx: Transaction, messageLib: string | TransactionArgument): TransactionResult {
812
+ return tx.moveCall({
813
+ target: this.#target('is_supported_message_lib'),
814
+ arguments: [tx.object(this.objects.dvn), asAddress(tx, messageLib)],
815
+ })
816
+ }
817
+
818
+ /**
819
+ * Check if a message library is supported by this DVN
820
+ * @param messageLib - The message library address to check
821
+ * @returns Promise<boolean> - True if the message library is supported
822
+ */
823
+ async isSupportedMessageLib(messageLib: string): Promise<boolean> {
824
+ return executeSimulate(
825
+ this.client,
826
+ (tx) => {
827
+ this.isSupportedMessageLibMoveCall(tx, messageLib)
828
+ },
829
+ (result) => bcs.Bool.parse(result[0].value)
830
+ )
831
+ }
832
+
773
833
  /**
774
834
  * Check if an address is allowlisted
775
835
  * @param tx - The transaction to add the move call to
@@ -1580,6 +1640,80 @@ export class DVN {
1580
1640
  })
1581
1641
  }
1582
1642
 
1643
+ /**
1644
+ * Populate verify with DVN verification and ULN verify call
1645
+ * @param tx - The transaction to add the move call to
1646
+ * @param adminCap - The admin capability object ID
1647
+ * @param targetMessageLib - The target message library address (usually ULN302)
1648
+ * @param targetVerification - The verification object address for the target message library
1649
+ * @param packetHeader - The packet header as bytes
1650
+ * @param payloadHash - The payload hash as bytes
1651
+ * @param confirmations - Required confirmations count
1652
+ * @param expiration - Signature expiration timestamp
1653
+ * @param signatures - DVN multisig signatures
1654
+ */
1655
+ populateVerify(
1656
+ tx: Transaction,
1657
+ adminCap: string | TransactionArgument,
1658
+ targetMessageLib: string,
1659
+ targetVerification: string,
1660
+ packetHeader: Uint8Array | TransactionArgument,
1661
+ payloadHash: Uint8Array | TransactionArgument,
1662
+ confirmations: bigint | number | string | TransactionArgument,
1663
+ expiration: bigint | number | string | TransactionArgument,
1664
+ signatures: Uint8Array | TransactionArgument
1665
+ ): void {
1666
+ // Step 1: Call DVN's verifyMoveCall to get the verification call
1667
+ const dvnCall = this.verifyMoveCall(
1668
+ tx,
1669
+ adminCap,
1670
+ targetMessageLib,
1671
+ packetHeader,
1672
+ payloadHash,
1673
+ confirmations,
1674
+ expiration,
1675
+ signatures
1676
+ )
1677
+
1678
+ // Step 2: Get the message library object address based on targetMessageLib
1679
+ const messageLibObjectAddress = this.#getUlnObjectAddress(targetMessageLib)
1680
+
1681
+ tx.moveCall({
1682
+ target: this.#getUlnVerifyTarget(targetMessageLib),
1683
+ arguments: [tx.object(messageLibObjectAddress), asObject(tx, targetVerification), dvnCall],
1684
+ })
1685
+ }
1686
+
1687
+ /**
1688
+ * Get message library object address based on targetMessageLib package address
1689
+ * @param targetMessageLib - The target message library package address
1690
+ * @returns Message library object address
1691
+ * @throws Error if targetMessageLib doesn't match any known message library
1692
+ * @private
1693
+ */
1694
+ #getUlnObjectAddress(targetMessageLib: string): string {
1695
+ // Check if targetMessageLib equals ULN302 package address
1696
+ if (targetMessageLib === this.moduleManager.packages.uln302) {
1697
+ return this.objects.uln302
1698
+ }
1699
+
1700
+ throw new Error('Target message library not match objects')
1701
+ }
1702
+
1703
+ /**
1704
+ * Get ULN verify target path based on targetMessageLib package address
1705
+ * @param targetMessageLib - The target message library package address
1706
+ * @returns Message library verify target path
1707
+ * @throws Error if targetMessageLib doesn't match any known message library
1708
+ * @private
1709
+ */
1710
+ #getUlnVerifyTarget(targetMessageLib: string): string {
1711
+ if (targetMessageLib === this.moduleManager.packages.uln302) {
1712
+ return `${targetMessageLib}::uln_302::verify`
1713
+ }
1714
+
1715
+ throw new Error('Target message library not match any target')
1716
+ }
1583
1717
  /**
1584
1718
  * Generate the full target path for move calls
1585
1719
  * @param name - The function name to call
@@ -32,6 +32,7 @@ export class ExecutorLayerZero {
32
32
  * @param tx - The transaction to add the move call to
33
33
  * @param workerCap - Worker capability object ID or transaction argument
34
34
  * @param depositAddress - Address for fee deposits or transaction argument
35
+ * @param supportedMessageLibs - Array of supported message library addresses or transaction argument
35
36
  * @param priceFeed - Price feed object address or transaction argument
36
37
  * @param workerFeeLib - Worker fee library address or transaction argument
37
38
  * @param defaultMultiplierBps - Default multiplier in basis points or transaction argument
@@ -42,6 +43,7 @@ export class ExecutorLayerZero {
42
43
  tx: Transaction,
43
44
  workerCap: string | TransactionArgument,
44
45
  depositAddress: string | TransactionArgument,
46
+ supportedMessageLibs: string[] | TransactionArgument,
45
47
  priceFeed: string | TransactionArgument,
46
48
  workerFeeLib: string | TransactionArgument,
47
49
  defaultMultiplierBps: number | TransactionArgument,
@@ -53,6 +55,7 @@ export class ExecutorLayerZero {
53
55
  arguments: [
54
56
  asObject(tx, workerCap),
55
57
  asAddress(tx, depositAddress),
58
+ asAddressVector(tx, supportedMessageLibs),
56
59
  asAddress(tx, priceFeed),
57
60
  asAddress(tx, workerFeeLib),
58
61
  asU16(tx, defaultMultiplierBps),
@@ -528,6 +528,30 @@ export class Executor {
528
528
  })
529
529
  }
530
530
 
531
+ /**
532
+ * Set supported message library (owner only)
533
+ * @param tx - The transaction to add the move call to
534
+ * @param ownerCap - The owner capability object ID
535
+ * @param messageLib - The message library address
536
+ * @param supported - Whether to support or remove support for the message library
537
+ */
538
+ setSupportedMessageLibMoveCall(
539
+ tx: Transaction,
540
+ ownerCap: string | TransactionArgument,
541
+ messageLib: string | TransactionArgument,
542
+ supported: boolean | TransactionArgument
543
+ ): void {
544
+ tx.moveCall({
545
+ target: this.#target('set_supported_message_lib'),
546
+ arguments: [
547
+ tx.object(this.objects.executor),
548
+ asObject(tx, ownerCap),
549
+ asAddress(tx, messageLib),
550
+ asBool(tx, supported),
551
+ ],
552
+ })
553
+ }
554
+
531
555
  /**
532
556
  * Set allowlist status for an OApp sender (owner only)
533
557
  * @param tx - The transaction to add the move call to
@@ -814,6 +838,34 @@ export class Executor {
814
838
  )
815
839
  }
816
840
 
841
+ /**
842
+ * Check if a message library is supported by this executor
843
+ * @param tx - The transaction to add the move call to
844
+ * @param messageLib - The message library address to check
845
+ * @returns Transaction result containing the support status
846
+ */
847
+ isSupportedMessageLibMoveCall(tx: Transaction, messageLib: string | TransactionArgument): TransactionResult {
848
+ return tx.moveCall({
849
+ target: this.#target('is_supported_message_lib'),
850
+ arguments: [tx.object(this.objects.executor), asAddress(tx, messageLib)],
851
+ })
852
+ }
853
+
854
+ /**
855
+ * Check if a message library is supported by this executor
856
+ * @param messageLib - The message library address to check
857
+ * @returns Promise<boolean> - True if the message library is supported
858
+ */
859
+ async isSupportedMessageLib(messageLib: string): Promise<boolean> {
860
+ return executeSimulate(
861
+ this.client,
862
+ (tx) => {
863
+ this.isSupportedMessageLibMoveCall(tx, messageLib)
864
+ },
865
+ (result) => bcs.Bool.parse(result[0].value)
866
+ )
867
+ }
868
+
817
869
  /**
818
870
  * Check if an address is allowlisted
819
871
  * @param tx - The transaction to add the move call to