@layerzerolabs/lz-sui-sdk-v2 3.0.134 → 3.0.135

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 (163) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/deployments/sui-sandbox-local/blocked_message_lib.json +22 -22
  3. package/deployments/sui-sandbox-local/blocked_msglib_ptb_builder.json +22 -22
  4. package/deployments/sui-sandbox-local/counter.json +79 -44
  5. package/deployments/sui-sandbox-local/dvn.json +23 -22
  6. package/deployments/sui-sandbox-local/dvn_call_type.json +28 -28
  7. package/deployments/sui-sandbox-local/dvn_fee_lib.json +27 -27
  8. package/deployments/sui-sandbox-local/dvn_layerzero.json +17 -17
  9. package/deployments/sui-sandbox-local/dvn_ptb_builder.json +21 -21
  10. package/deployments/sui-sandbox-local/endpoint_ptb_builder.json +30 -30
  11. package/deployments/sui-sandbox-local/endpoint_v2.json +25 -25
  12. package/deployments/sui-sandbox-local/executor.json +15 -14
  13. package/deployments/sui-sandbox-local/executor_call_type.json +28 -28
  14. package/deployments/sui-sandbox-local/executor_fee_lib.json +28 -28
  15. package/deployments/sui-sandbox-local/executor_layerzero.json +17 -17
  16. package/deployments/sui-sandbox-local/executor_ptb_builder.json +14 -14
  17. package/deployments/sui-sandbox-local/layerzero_views.json +21 -21
  18. package/deployments/sui-sandbox-local/message_lib_common.json +21 -21
  19. package/deployments/sui-sandbox-local/msglib_ptb_builder_call_types.json +13 -13
  20. package/deployments/sui-sandbox-local/oapp.json +15 -13
  21. package/deployments/sui-sandbox-local/object-BlockedMessageLib.json +5 -5
  22. package/deployments/sui-sandbox-local/object-BlockedMsglibPtbBuilder.json +5 -5
  23. package/deployments/sui-sandbox-local/object-Counter.json +5 -5
  24. package/deployments/sui-sandbox-local/object-CounterAdminCap.json +5 -5
  25. package/deployments/sui-sandbox-local/object-CounterOApp.json +5 -5
  26. package/deployments/sui-sandbox-local/object-DVN.json +2 -2
  27. package/deployments/sui-sandbox-local/object-DVNCap.json +4 -4
  28. package/deployments/sui-sandbox-local/object-DVNFeeLib.json +5 -5
  29. package/deployments/sui-sandbox-local/object-EndpointPtbBuilder.json +5 -5
  30. package/deployments/sui-sandbox-local/object-EndpointPtbBuilderAdminCap.json +5 -5
  31. package/deployments/sui-sandbox-local/object-EndpointV2.json +5 -5
  32. package/deployments/sui-sandbox-local/object-EndpointV2AdminCap.json +5 -5
  33. package/deployments/sui-sandbox-local/object-Executor.json +2 -2
  34. package/deployments/sui-sandbox-local/object-ExecutorCap.json +4 -4
  35. package/deployments/sui-sandbox-local/object-ExecutorFeeLib.json +5 -5
  36. package/deployments/sui-sandbox-local/object-ExecutorOwnerCap.json +2 -2
  37. package/deployments/sui-sandbox-local/object-PackageWhitelistValidator.json +5 -5
  38. package/deployments/sui-sandbox-local/object-PriceFeed.json +5 -5
  39. package/deployments/sui-sandbox-local/object-PriceFeedOwnerCap.json +5 -5
  40. package/deployments/sui-sandbox-local/object-SimpleMessageLib.json +5 -5
  41. package/deployments/sui-sandbox-local/object-SimpleMessageLibAdminCap.json +5 -5
  42. package/deployments/sui-sandbox-local/object-SmlPtbBuilder.json +5 -5
  43. package/deployments/sui-sandbox-local/object-Treasury.json +5 -5
  44. package/deployments/sui-sandbox-local/object-TreasuryAdminCap.json +5 -5
  45. package/deployments/sui-sandbox-local/object-ULN302.json +5 -5
  46. package/deployments/sui-sandbox-local/object-ULN302AdminCap.json +5 -5
  47. package/deployments/sui-sandbox-local/object-Uln302PtbBuilder.json +5 -5
  48. package/deployments/sui-sandbox-local/object-Uln302Verification.json +5 -5
  49. package/deployments/sui-sandbox-local/object-WorkerRegistry.json +9 -0
  50. package/deployments/sui-sandbox-local/package_whitelist_validator.json +51 -51
  51. package/deployments/sui-sandbox-local/price_feed.json +39 -39
  52. package/deployments/sui-sandbox-local/price_feed_call_types.json +19 -19
  53. package/deployments/sui-sandbox-local/ptb_move_call.json +20 -20
  54. package/deployments/sui-sandbox-local/sequential_multi_call.json +45 -0
  55. package/deployments/sui-sandbox-local/simple_message_lib.json +33 -33
  56. package/deployments/sui-sandbox-local/simple_msglib_ptb_builder.json +22 -22
  57. package/deployments/sui-sandbox-local/treasury.json +40 -40
  58. package/deployments/sui-sandbox-local/uln_302.json +35 -39
  59. package/deployments/sui-sandbox-local/uln_302_ptb_builder.json +25 -25
  60. package/deployments/sui-sandbox-local/uln_common.json +49 -0
  61. package/deployments/sui-sandbox-local/worker_common.json +15 -14
  62. package/deployments/sui-sandbox-local/worker_registry.json +58 -0
  63. package/deployments/sui-testnet/blocked_message_lib.json +22 -22
  64. package/deployments/sui-testnet/blocked_msglib_ptb_builder.json +29 -29
  65. package/deployments/sui-testnet/call.json +21 -21
  66. package/deployments/sui-testnet/counter.json +40 -40
  67. package/deployments/sui-testnet/dvn.json +22 -21
  68. package/deployments/sui-testnet/dvn_call_type.json +19 -19
  69. package/deployments/sui-testnet/dvn_fee_lib.json +26 -26
  70. package/deployments/sui-testnet/dvn_layerzero.json +24 -24
  71. package/deployments/sui-testnet/dvn_ptb_builder.json +20 -20
  72. package/deployments/sui-testnet/endpoint_ptb_builder.json +30 -30
  73. package/deployments/sui-testnet/endpoint_v2.json +26 -26
  74. package/deployments/sui-testnet/executor.json +22 -21
  75. package/deployments/sui-testnet/executor_call_type.json +19 -19
  76. package/deployments/sui-testnet/executor_fee_lib.json +18 -18
  77. package/deployments/sui-testnet/executor_layerzero.json +25 -25
  78. package/deployments/sui-testnet/executor_ptb_builder.json +20 -20
  79. package/deployments/sui-testnet/layerzero_views.json +13 -13
  80. package/deployments/sui-testnet/message_lib_common.json +21 -21
  81. package/deployments/sui-testnet/msglib_ptb_builder_call_types.json +13 -13
  82. package/deployments/sui-testnet/oapp.json +15 -13
  83. package/deployments/sui-testnet/object-BlockedMessageLib.json +5 -5
  84. package/deployments/sui-testnet/object-BlockedMsglibPtbBuilder.json +5 -5
  85. package/deployments/sui-testnet/object-Counter.json +5 -5
  86. package/deployments/sui-testnet/object-CounterAdminCap.json +5 -5
  87. package/deployments/sui-testnet/object-CounterOApp.json +5 -5
  88. package/deployments/sui-testnet/object-DVN.json +2 -2
  89. package/deployments/sui-testnet/object-DVNCap.json +5 -5
  90. package/deployments/sui-testnet/object-DVNFeeLib.json +5 -5
  91. package/deployments/sui-testnet/object-EndpointPtbBuilder.json +5 -5
  92. package/deployments/sui-testnet/object-EndpointPtbBuilderAdminCap.json +5 -5
  93. package/deployments/sui-testnet/object-EndpointV2.json +5 -5
  94. package/deployments/sui-testnet/object-EndpointV2AdminCap.json +5 -5
  95. package/deployments/sui-testnet/object-Executor.json +2 -2
  96. package/deployments/sui-testnet/object-ExecutorCap.json +5 -5
  97. package/deployments/sui-testnet/object-ExecutorFeeLib.json +5 -5
  98. package/deployments/sui-testnet/object-ExecutorOwnerCap.json +2 -2
  99. package/deployments/sui-testnet/object-PackageWhitelistValidator.json +5 -5
  100. package/deployments/sui-testnet/object-PriceFeed.json +5 -5
  101. package/deployments/sui-testnet/object-PriceFeedOwnerCap.json +5 -5
  102. package/deployments/sui-testnet/object-SimpleMessageLib.json +5 -5
  103. package/deployments/sui-testnet/object-SimpleMessageLibAdminCap.json +5 -5
  104. package/deployments/sui-testnet/object-SmlPtbBuilder.json +5 -5
  105. package/deployments/sui-testnet/object-Treasury.json +5 -5
  106. package/deployments/sui-testnet/object-TreasuryAdminCap.json +5 -5
  107. package/deployments/sui-testnet/object-ULN302.json +5 -5
  108. package/deployments/sui-testnet/object-ULN302AdminCap.json +5 -5
  109. package/deployments/sui-testnet/object-Uln302PtbBuilder.json +5 -5
  110. package/deployments/sui-testnet/object-Uln302Verification.json +5 -5
  111. package/deployments/sui-testnet/object-WorkerRegistry.json +9 -0
  112. package/deployments/sui-testnet/object-ZroCoinMetadata.json +5 -5
  113. package/deployments/sui-testnet/object-ZroTreasuryCap.json +5 -5
  114. package/deployments/sui-testnet/package_whitelist_validator.json +44 -44
  115. package/deployments/sui-testnet/price_feed.json +25 -25
  116. package/deployments/sui-testnet/price_feed_call_types.json +12 -12
  117. package/deployments/sui-testnet/ptb_move_call.json +21 -21
  118. package/deployments/sui-testnet/sequential_multi_call.json +45 -0
  119. package/deployments/sui-testnet/simple_message_lib.json +29 -29
  120. package/deployments/sui-testnet/simple_msglib_ptb_builder.json +26 -26
  121. package/deployments/sui-testnet/treasury.json +30 -58
  122. package/deployments/sui-testnet/uln_302.json +28 -32
  123. package/deployments/sui-testnet/uln_302_ptb_builder.json +25 -25
  124. package/deployments/sui-testnet/uln_common.json +49 -0
  125. package/deployments/sui-testnet/utils.json +12 -12
  126. package/deployments/sui-testnet/worker_common.json +21 -20
  127. package/deployments/sui-testnet/worker_registry.json +58 -0
  128. package/deployments/sui-testnet/zro.json +28 -28
  129. package/dist/index.cjs +1193 -418
  130. package/dist/index.cjs.map +1 -1
  131. package/dist/index.d.mts +702 -352
  132. package/dist/index.d.ts +702 -352
  133. package/dist/index.mjs +1182 -418
  134. package/dist/index.mjs.map +1 -1
  135. package/package.json +7 -7
  136. package/src/bcs/index.ts +2 -1
  137. package/src/bcs/oapp.ts +14 -0
  138. package/src/generated/addresses.ts +123 -105
  139. package/src/module-manager.ts +15 -3
  140. package/src/modules/call.ts +16 -6
  141. package/src/modules/endpoint.ts +12 -4
  142. package/src/modules/message-libs/simple-message-lib.ts +3 -2
  143. package/src/modules/message-libs/uln302.ts +28 -26
  144. package/src/modules/oapps/counter.ts +34 -50
  145. package/src/modules/oapps/oapp.ts +489 -74
  146. package/src/modules/ptb-builders/endpoint-ptb-builder.ts +9 -3
  147. package/src/modules/ptb-builders/ptb-builder.ts +19 -4
  148. package/src/modules/ptb-builders/uln302-ptb-builder.ts +5 -0
  149. package/src/modules/workers/dvn-layerzero.ts +9 -0
  150. package/src/modules/workers/dvn.ts +214 -6
  151. package/src/modules/workers/executor-fee-lib.ts +11 -3
  152. package/src/modules/workers/executor-layerzero.ts +9 -0
  153. package/src/modules/workers/executor.ts +115 -0
  154. package/src/modules/workers/index.ts +1 -0
  155. package/src/modules/workers/treasury.ts +4 -4
  156. package/src/modules/workers/worker-registry.ts +110 -0
  157. package/src/resource.ts +3 -0
  158. package/src/sdk.ts +7 -2
  159. package/src/types/endpoint.ts +2 -1
  160. package/src/types/modules.ts +1 -0
  161. package/src/types/oapp.ts +6 -0
  162. package/src/types/options.ts +15 -0
  163. package/src/utils/transaction.ts +3 -3
@@ -2,43 +2,72 @@ import { bcs } from '@mysten/sui/bcs'
2
2
  import { SuiClient } from '@mysten/sui/client'
3
3
  import { Transaction, TransactionArgument, TransactionResult } from '@mysten/sui/transactions'
4
4
 
5
+ import { OAppInfoV1Bcs } from '../../bcs'
5
6
  import { ModuleManager } from '../../module-manager'
6
7
  import { ObjectOptions } from '../../types'
7
- import { asBytes, asBytes32, asObject, asU16, asU32, executeSimulate } from '../../utils'
8
+ import { OAppInfoV1 } from '../../types/oapp'
9
+ import {
10
+ asAddress,
11
+ asBytes,
12
+ asBytes32,
13
+ asObject,
14
+ asU16,
15
+ asU32,
16
+ asU64,
17
+ executeSimulate,
18
+ isTransactionArgument,
19
+ } from '../../utils'
8
20
 
9
21
  const MODULE_NAME = 'oapp'
10
22
 
11
23
  export const OAppErrorCode = {
12
- // OApp related errors
13
- OApp_EAlreadyInited: 1,
14
- OApp_EChannelNotInited: 2,
15
- OApp_EEndpointNotInited: 3,
16
- OApp_EInvalidAdminCap: 4,
17
- OApp_EInvalidCallCap: 5,
18
- OApp_EOnlyEndpoint: 6,
19
- OApp_EOnlyPeer: 7,
20
- // EndpointConfig related errors
21
- EndpointConfig_EInvalidAdminCap: 1,
22
- EndpointConfig_EInvalidIntentType: 2,
23
- EndpointConfig_EInvalidOAppCallCap: 3,
24
+ // OApp related errors (matching oapp.move)
25
+ OApp_EInvalidAdminCap: 1,
26
+ OApp_EInvalidOAppCap: 2,
27
+ OApp_EInvalidRefundAddress: 3,
28
+ OApp_EInvalidSendingCall: 4,
29
+ OApp_EOnlyEndpoint: 5,
30
+ OApp_EOnlyPeer: 6,
31
+ OApp_ESendingInProgress: 7,
32
+
33
+ // OAppPeer related errors (matching oapp_peer.move)
34
+ OAppPeer_EPeerNotFound: 0,
35
+ OAppPeer_EInvalidPeer: 1,
36
+
37
+ // EnforcedOptions related errors (matching enforced_options.move)
38
+ EnforcedOptions_EEnforcedOptionsNotFound: 1,
39
+ EnforcedOptions_EInvalidOptionsLength: 2,
40
+ EnforcedOptions_EInvalidOptionsType: 3,
41
+
42
+ // OAppInfoV1 related errors (matching oapp_info_v1.move)
43
+ OAppInfoV1_EInvalidData: 1,
44
+ OAppInfoV1_EInvalidVersion: 2,
24
45
  } as const
25
46
 
26
47
  export class OApp {
27
48
  public packageId: string
49
+ public oappCallCapId: string
28
50
  public readonly client: SuiClient
51
+ public oappInfo: OAppInfoV1 | null = null
29
52
  private readonly objects: ObjectOptions
30
53
 
31
54
  constructor(
32
55
  packageId: string,
56
+ oappCallCapId: string,
33
57
  client: SuiClient,
34
58
  objects: ObjectOptions,
35
59
  private readonly moduleManager: ModuleManager
36
60
  ) {
37
61
  this.packageId = packageId
62
+ this.oappCallCapId = oappCallCapId
38
63
  this.client = client
39
64
  this.objects = objects
40
65
  }
41
66
 
67
+ // setOAppInfo(oappInfo: OAppInfoV1): void {
68
+ // this.oappInfo = oappInfo
69
+ // }
70
+
42
71
  // === Set Functions ===
43
72
 
44
73
  /**
@@ -50,18 +79,18 @@ export class OApp {
50
79
  * @param msgType - Message type or transaction argument
51
80
  * @param options - Enforced options as bytes or transaction argument
52
81
  */
53
- setEnforcedOptionsMoveCall(
82
+ async setEnforcedOptionsMoveCall(
54
83
  tx: Transaction,
55
- oapp: string | TransactionArgument,
56
- adminCap: string | TransactionArgument,
57
84
  eid: number | TransactionArgument,
58
85
  msgType: number | TransactionArgument,
59
86
  options: Uint8Array | TransactionArgument
60
- ): void {
87
+ ): Promise<void> {
88
+ const oappInfo = await this.#oappInfo()
89
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
61
90
  tx.moveCall({
62
91
  target: this.#target('set_enforced_options'),
63
92
  arguments: [
64
- asObject(tx, oapp),
93
+ asObject(tx, oappInfo.oapp_object),
65
94
  asObject(tx, adminCap),
66
95
  asU32(tx, eid),
67
96
  asU16(tx, msgType),
@@ -78,18 +107,21 @@ export class OApp {
78
107
  * @param eid - Peer endpoint ID or transaction argument
79
108
  * @param peer - Peer OApp address as bytes or transaction argument
80
109
  */
81
- setPeerMoveCall(
110
+ async setPeerMoveCall(
82
111
  tx: Transaction,
83
- oapp: string | TransactionArgument,
84
- adminCap: string | TransactionArgument,
85
112
  eid: number | TransactionArgument,
86
113
  peer: Uint8Array | TransactionArgument
87
- ): void {
114
+ ): Promise<void> {
115
+ const oappInfo = await this.#oappInfo()
116
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
117
+ const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
88
118
  tx.moveCall({
89
119
  target: this.#target('set_peer'),
90
120
  arguments: [
91
- asObject(tx, oapp),
121
+ asObject(tx, oappInfo.oapp_object),
92
122
  asObject(tx, adminCap),
123
+ asObject(tx, this.objects.endpointV2),
124
+ asObject(tx, messagingChannel),
93
125
  asU32(tx, eid),
94
126
  asBytes32(tx, peer, this.moduleManager.getUtils()),
95
127
  ],
@@ -99,56 +131,57 @@ export class OApp {
99
131
  // === View Functions ===
100
132
 
101
133
  /**
102
- * Get admin address for OApp
134
+ * Get admin capability address for OApp
103
135
  * @param tx - The transaction to add the move call to
104
136
  * @param oapp - The OApp object ID or transaction argument
105
- * @returns Transaction result containing the admin address
137
+ * @returns Transaction result containing the admin capability address
106
138
  */
107
- getAdminMoveCall(tx: Transaction, oapp: string | TransactionArgument): TransactionResult {
139
+ getAdminCapMoveCall(tx: Transaction, oapp: string | TransactionArgument): TransactionResult {
108
140
  return tx.moveCall({
109
- target: this.#target('admin'),
141
+ target: this.#target('admin_cap'),
110
142
  arguments: [asObject(tx, oapp)],
111
143
  })
112
144
  }
113
145
 
114
146
  /**
115
- * Get admin address for OApp
147
+ * Get admin capability address for OApp
116
148
  * @param oapp - The OApp object ID
117
- * @returns Promise<string> - The admin address
149
+ * @returns Promise<string> - The admin capability address
118
150
  */
119
- async getAdmin(oapp: string): Promise<string> {
151
+ async getAdminCap(oapp: string): Promise<string> {
120
152
  return executeSimulate(
121
153
  this.client,
122
154
  (tx) => {
123
- this.getAdminMoveCall(tx, oapp)
155
+ this.getAdminCapMoveCall(tx, oapp)
124
156
  },
125
157
  (result) => bcs.Address.parse(result[0].value)
126
158
  )
127
159
  }
128
160
 
129
161
  /**
130
- * Get OApp address (call capability ID)
162
+ * Get OApp CallCap identifier
131
163
  * @param tx - The transaction to add the move call to
132
164
  * @param oapp - The OApp object ID or transaction argument
133
- * @returns Transaction result containing the OApp address
165
+ * @returns Transaction result containing the OApp CallCap identifier
134
166
  */
135
- getOAppAddressMoveCall(tx: Transaction, oapp: string | TransactionArgument): TransactionResult {
167
+ async getOAppCapIdMoveCall(tx: Transaction): Promise<TransactionResult> {
168
+ const oappInfo = await this.#oappInfo()
136
169
  return tx.moveCall({
137
- target: this.#target('oapp_address'),
138
- arguments: [asObject(tx, oapp)],
170
+ target: this.#target('oapp_cap_id'),
171
+ arguments: [asObject(tx, oappInfo.oapp_object)],
139
172
  })
140
173
  }
141
174
 
142
175
  /**
143
- * Get OApp address (call capability ID)
144
- * @param oapp - The OApp object ID
145
- * @returns Promise<string> - The OApp address
176
+ * Get OApp CallCap identifier
177
+ * @param oapp - The OApp object ID (optional, uses configured oapp if not provided)
178
+ * @returns Promise<string> - The OApp CallCap identifier
146
179
  */
147
- async getOAppAddress(oapp: string): Promise<string> {
180
+ async getOAppCapId(): Promise<string> {
148
181
  return executeSimulate(
149
182
  this.client,
150
- (tx) => {
151
- this.getOAppAddressMoveCall(tx, oapp)
183
+ async (tx) => {
184
+ await this.getOAppCapIdMoveCall(tx)
152
185
  },
153
186
  (result) => bcs.Address.parse(result[0].value)
154
187
  )
@@ -163,16 +196,21 @@ export class OApp {
163
196
  * @param extraOptions - Extra options to combine with enforced options or transaction argument
164
197
  * @returns Transaction result containing combined options
165
198
  */
166
- combineOptionsMoveCall(
199
+ async combineOptionsMoveCall(
167
200
  tx: Transaction,
168
- oapp: string | TransactionArgument,
169
201
  eid: number | TransactionArgument,
170
202
  msgType: number | TransactionArgument,
171
203
  extraOptions: Uint8Array | TransactionArgument
172
- ): TransactionResult {
204
+ ): Promise<TransactionResult> {
205
+ const oappInfo = await this.#oappInfo()
173
206
  return tx.moveCall({
174
207
  target: this.#target('combine_options'),
175
- arguments: [asObject(tx, oapp), asU32(tx, eid), asU16(tx, msgType), asBytes(tx, extraOptions)],
208
+ arguments: [
209
+ asObject(tx, oappInfo.oapp_object),
210
+ asU32(tx, eid),
211
+ asU16(tx, msgType),
212
+ asBytes(tx, extraOptions),
213
+ ],
176
214
  })
177
215
  }
178
216
 
@@ -184,11 +222,11 @@ export class OApp {
184
222
  * @param extraOptions - Extra options to combine with enforced options
185
223
  * @returns Promise<Uint8Array> - Combined options as bytes
186
224
  */
187
- async combineOptions(oapp: string, eid: number, msgType: number, extraOptions: Uint8Array): Promise<Uint8Array> {
225
+ async combineOptions(eid: number, msgType: number, extraOptions: Uint8Array): Promise<Uint8Array> {
188
226
  return executeSimulate(
189
227
  this.client,
190
- (tx) => {
191
- this.combineOptionsMoveCall(tx, oapp, eid, msgType, extraOptions)
228
+ async (tx) => {
229
+ await this.combineOptionsMoveCall(tx, eid, msgType, extraOptions)
192
230
  },
193
231
  (result) => new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
194
232
  )
@@ -202,15 +240,15 @@ export class OApp {
202
240
  * @param msgType - Message type or transaction argument
203
241
  * @returns Transaction result containing enforced options
204
242
  */
205
- getEnforcedOptionsMoveCall(
243
+ async getEnforcedOptionsMoveCall(
206
244
  tx: Transaction,
207
- oapp: string | TransactionArgument,
208
245
  eid: number | TransactionArgument,
209
246
  msgType: number | TransactionArgument
210
- ): TransactionResult {
247
+ ): Promise<TransactionResult> {
248
+ const oappInfo = await this.#oappInfo()
211
249
  return tx.moveCall({
212
250
  target: this.#target('get_enforced_options'),
213
- arguments: [asObject(tx, oapp), asU32(tx, eid), asU16(tx, msgType)],
251
+ arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, eid), asU16(tx, msgType)],
214
252
  })
215
253
  }
216
254
 
@@ -221,11 +259,11 @@ export class OApp {
221
259
  * @param msgType - Message type
222
260
  * @returns Promise<Uint8Array> - Enforced options as bytes
223
261
  */
224
- async getEnforcedOptions(oapp: string, eid: number, msgType: number): Promise<Uint8Array> {
262
+ async getEnforcedOptions(eid: number, msgType: number): Promise<Uint8Array> {
225
263
  return executeSimulate(
226
264
  this.client,
227
- (tx) => {
228
- this.getEnforcedOptionsMoveCall(tx, oapp, eid, msgType)
265
+ async (tx) => {
266
+ await this.getEnforcedOptionsMoveCall(tx, eid, msgType)
229
267
  },
230
268
  (result) => new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
231
269
  )
@@ -238,14 +276,11 @@ export class OApp {
238
276
  * @param dstEid - Destination endpoint ID or transaction argument
239
277
  * @returns Transaction result containing boolean result
240
278
  */
241
- hasPeerMoveCall(
242
- tx: Transaction,
243
- oapp: string | TransactionArgument,
244
- dstEid: number | TransactionArgument
245
- ): TransactionResult {
279
+ async hasPeerMoveCall(tx: Transaction, dstEid: number | TransactionArgument): Promise<TransactionResult> {
280
+ const oappInfo = await this.#oappInfo()
246
281
  return tx.moveCall({
247
282
  target: this.#target('has_peer'),
248
- arguments: [asObject(tx, oapp), asU32(tx, dstEid)],
283
+ arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, dstEid)],
249
284
  })
250
285
  }
251
286
 
@@ -255,11 +290,11 @@ export class OApp {
255
290
  * @param dstEid - Destination endpoint ID
256
291
  * @returns Promise<boolean> - True if peer is configured, false otherwise
257
292
  */
258
- async hasPeer(oapp: string, dstEid: number): Promise<boolean> {
293
+ async hasPeer(dstEid: number): Promise<boolean> {
259
294
  return executeSimulate(
260
295
  this.client,
261
- (tx) => {
262
- this.hasPeerMoveCall(tx, oapp, dstEid)
296
+ async (tx) => {
297
+ await this.hasPeerMoveCall(tx, dstEid)
263
298
  },
264
299
  (result) => bcs.Bool.parse(result[0].value)
265
300
  )
@@ -272,14 +307,11 @@ export class OApp {
272
307
  * @param dstEid - Destination endpoint ID or transaction argument
273
308
  * @returns Transaction result containing peer address
274
309
  */
275
- getPeerMoveCall(
276
- tx: Transaction,
277
- oapp: string | TransactionArgument,
278
- dstEid: number | TransactionArgument
279
- ): TransactionResult {
310
+ async getPeerMoveCall(tx: Transaction, dstEid: number | TransactionArgument): Promise<TransactionResult> {
311
+ const oappInfo = await this.#oappInfo()
280
312
  return tx.moveCall({
281
313
  target: this.#target('get_peer'),
282
- arguments: [asObject(tx, oapp), asU32(tx, dstEid)],
314
+ arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, dstEid)],
283
315
  })
284
316
  }
285
317
 
@@ -289,11 +321,11 @@ export class OApp {
289
321
  * @param dstEid - Destination endpoint ID
290
322
  * @returns Promise<Uint8Array> - Peer address as bytes32
291
323
  */
292
- async getPeer(oapp: string, dstEid: number): Promise<Uint8Array> {
324
+ async getPeer(dstEid: number): Promise<Uint8Array> {
293
325
  return executeSimulate(
294
326
  this.client,
295
- (tx) => {
296
- this.getPeerMoveCall(tx, oapp, dstEid)
327
+ async (tx) => {
328
+ await this.getPeerMoveCall(tx, dstEid)
297
329
  },
298
330
  (result) => {
299
331
  return new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
@@ -301,8 +333,391 @@ export class OApp {
301
333
  )
302
334
  }
303
335
 
336
+ getOAppInfoV1MoveCall(tx: Transaction): TransactionResult {
337
+ const endpoint = this.moduleManager.getEndpoint()
338
+ const oappInfoRaw = endpoint.getLzReceiveInfoMoveCall(tx, this.oappCallCapId) // the new OAppInfo used to be named as lz_receive_info
339
+ return tx.moveCall({
340
+ target: `${this.packageId}::oapp_info_v1::decode`,
341
+ arguments: [oappInfoRaw],
342
+ })
343
+ }
344
+
345
+ async getOAppInfoV1(): Promise<OAppInfoV1> {
346
+ return executeSimulate(
347
+ this.client,
348
+ (tx) => {
349
+ this.getOAppInfoV1MoveCall(tx)
350
+ },
351
+ (result) => {
352
+ return OAppInfoV1Bcs.parse(result[0].value)
353
+ }
354
+ )
355
+ }
356
+
357
+ // === Endpoint Call Functions ===
358
+
359
+ /**
360
+ * Register OApp with the endpoint
361
+ * @param tx - The transaction to add the move call to
362
+ * @param oappInfo - OApp information as bytes (optional)
363
+ * @returns Transaction result containing the messaging channel address
364
+ */
365
+ async registerOAppMoveCall(
366
+ tx: Transaction,
367
+ oappInfo?: Uint8Array | TransactionArgument
368
+ ): Promise<TransactionResult> {
369
+ let oappInfoArg: TransactionArgument
370
+ if (isTransactionArgument(oappInfo)) {
371
+ oappInfoArg = oappInfo
372
+ } else if (oappInfo) {
373
+ // For Some(vector<u8>), convert Uint8Array to number[] and wrap in Option
374
+ oappInfoArg = tx.pure.option('vector<u8>', Array.from(oappInfo))
375
+ } else {
376
+ // For None
377
+ oappInfoArg = tx.pure.option('vector<u8>', null)
378
+ }
379
+
380
+ const oappInfoObj = await this.#oappInfo()
381
+ const adminCap = await this.getAdminCap(oappInfoObj.oapp_object)
382
+ return tx.moveCall({
383
+ target: this.#target('register_oapp', 'endpoint_calls'),
384
+ arguments: [
385
+ asObject(tx, oappInfoObj.oapp_object),
386
+ asObject(tx, adminCap),
387
+ asObject(tx, this.objects.endpointV2),
388
+ oappInfoArg,
389
+ ],
390
+ })
391
+ }
392
+
393
+ /**
394
+ * Set delegate for OApp
395
+ * @param tx - The transaction to add the move call to
396
+ * @param newDelegate - New delegate address
397
+ */
398
+ async setDelegateMoveCall(tx: Transaction, newDelegate: string | TransactionArgument): Promise<void> {
399
+ const oappInfo = await this.#oappInfo()
400
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
401
+ tx.moveCall({
402
+ target: this.#target('set_delegate', 'endpoint_calls'),
403
+ arguments: [
404
+ asObject(tx, oappInfo.oapp_object),
405
+ asObject(tx, adminCap),
406
+ asObject(tx, this.objects.endpointV2),
407
+ asAddress(tx, newDelegate),
408
+ ],
409
+ })
410
+ }
411
+
412
+ /**
413
+ * Set OApp information in the endpoint
414
+ * @param tx - The transaction to add the move call to
415
+ * @param oappInfo - OApp information as bytes
416
+ */
417
+ async setOAppInfoMoveCall(tx: Transaction, oappInfo: Uint8Array | TransactionArgument): Promise<void> {
418
+ const oappInfoObj = await this.#oappInfo()
419
+ const adminCap = await this.getAdminCap(oappInfoObj.oapp_object)
420
+ tx.moveCall({
421
+ target: this.#target('set_oapp_info', 'endpoint_calls'),
422
+ arguments: [
423
+ asObject(tx, oappInfoObj.oapp_object),
424
+ asObject(tx, adminCap),
425
+ asObject(tx, this.objects.endpointV2),
426
+ asBytes(tx, oappInfo),
427
+ ],
428
+ })
429
+ }
430
+
431
+ /**
432
+ * Initialize channel with remote OApp
433
+ * @param tx - The transaction to add the move call to
434
+ * @param remoteEid - Remote endpoint ID
435
+ * @param remoteOApp - Remote OApp address as bytes32
436
+ */
437
+ async initChannelMoveCall(
438
+ tx: Transaction,
439
+ remoteEid: number | TransactionArgument,
440
+ remoteOApp: Uint8Array | TransactionArgument
441
+ ): Promise<void> {
442
+ const oappInfo = await this.#oappInfo()
443
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
444
+ const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
445
+ tx.moveCall({
446
+ target: this.#target('init_channel', 'endpoint_calls'),
447
+ arguments: [
448
+ asObject(tx, oappInfo.oapp_object),
449
+ asObject(tx, adminCap),
450
+ asObject(tx, this.objects.endpointV2),
451
+ asObject(tx, messagingChannel),
452
+ asU32(tx, remoteEid),
453
+ asBytes32(tx, remoteOApp, this.moduleManager.getUtils()),
454
+ ],
455
+ })
456
+ }
457
+
458
+ /**
459
+ * Clear a message from the messaging channel
460
+ * @param tx - The transaction to add the move call to
461
+ * @param srcEid - Source endpoint ID
462
+ * @param sender - Sender address as bytes32
463
+ * @param nonce - Message nonce
464
+ * @param guid - Message GUID as bytes32
465
+ * @param message - Message payload
466
+ */
467
+ async clearMoveCall(
468
+ tx: Transaction,
469
+ srcEid: number | TransactionArgument,
470
+ sender: Uint8Array | TransactionArgument,
471
+ nonce: number | bigint | TransactionArgument,
472
+ guid: Uint8Array | TransactionArgument,
473
+ message: Uint8Array | TransactionArgument
474
+ ): Promise<void> {
475
+ const oappInfo = await this.#oappInfo()
476
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
477
+ const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
478
+ tx.moveCall({
479
+ target: this.#target('clear', 'endpoint_calls'),
480
+ arguments: [
481
+ asObject(tx, oappInfo.oapp_object),
482
+ asObject(tx, adminCap),
483
+ asObject(tx, this.objects.endpointV2),
484
+ asObject(tx, messagingChannel),
485
+ asU32(tx, srcEid),
486
+ asBytes32(tx, sender, this.moduleManager.getUtils()),
487
+ asU64(tx, nonce),
488
+ asBytes32(tx, guid, this.moduleManager.getUtils()),
489
+ asBytes(tx, message),
490
+ ],
491
+ })
492
+ }
493
+
494
+ /**
495
+ * Skip a message in the messaging channel
496
+ * @param tx - The transaction to add the move call to
497
+ * @param srcEid - Source endpoint ID
498
+ * @param sender - Sender address as bytes32
499
+ * @param nonce - Message nonce
500
+ */
501
+ async skipMoveCall(
502
+ tx: Transaction,
503
+ srcEid: number | TransactionArgument,
504
+ sender: Uint8Array | TransactionArgument,
505
+ nonce: number | bigint | TransactionArgument
506
+ ): Promise<void> {
507
+ const oappInfo = await this.#oappInfo()
508
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
509
+ const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
510
+ tx.moveCall({
511
+ target: this.#target('skip', 'endpoint_calls'),
512
+ arguments: [
513
+ asObject(tx, oappInfo.oapp_object),
514
+ asObject(tx, adminCap),
515
+ asObject(tx, this.objects.endpointV2),
516
+ asObject(tx, messagingChannel),
517
+ asU32(tx, srcEid),
518
+ asBytes32(tx, sender, this.moduleManager.getUtils()),
519
+ asU64(tx, nonce),
520
+ ],
521
+ })
522
+ }
523
+
524
+ /**
525
+ * Nilify a message in the messaging channel
526
+ * @param tx - The transaction to add the move call to
527
+ * @param srcEid - Source endpoint ID
528
+ * @param sender - Sender address as bytes32
529
+ * @param nonce - Message nonce
530
+ * @param payloadHash - Payload hash as bytes32
531
+ */
532
+ async nilifyMoveCall(
533
+ tx: Transaction,
534
+ srcEid: number | TransactionArgument,
535
+ sender: Uint8Array | TransactionArgument,
536
+ nonce: number | bigint | TransactionArgument,
537
+ payloadHash: Uint8Array | TransactionArgument
538
+ ): Promise<void> {
539
+ const oappInfo = await this.#oappInfo()
540
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
541
+ const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
542
+ tx.moveCall({
543
+ target: this.#target('nilify', 'endpoint_calls'),
544
+ arguments: [
545
+ asObject(tx, oappInfo.oapp_object),
546
+ asObject(tx, adminCap),
547
+ asObject(tx, this.objects.endpointV2),
548
+ asObject(tx, messagingChannel),
549
+ asU32(tx, srcEid),
550
+ asBytes32(tx, sender, this.moduleManager.getUtils()),
551
+ asU64(tx, nonce),
552
+ asBytes32(tx, payloadHash, this.moduleManager.getUtils()),
553
+ ],
554
+ })
555
+ }
556
+
557
+ /**
558
+ * Burn a message in the messaging channel
559
+ * @param tx - The transaction to add the move call to
560
+ * @param srcEid - Source endpoint ID
561
+ * @param sender - Sender address as bytes32
562
+ * @param nonce - Message nonce
563
+ * @param payloadHash - Payload hash as bytes32
564
+ */
565
+ async burnMoveCall(
566
+ tx: Transaction,
567
+ srcEid: number | TransactionArgument,
568
+ sender: Uint8Array | TransactionArgument,
569
+ nonce: number | bigint | TransactionArgument,
570
+ payloadHash: Uint8Array | TransactionArgument
571
+ ): Promise<void> {
572
+ const oappInfo = await this.#oappInfo()
573
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
574
+ const messagingChannel = await this.moduleManager.getEndpoint().getMessagingChannel(this.oappCallCapId)
575
+ tx.moveCall({
576
+ target: this.#target('burn', 'endpoint_calls'),
577
+ arguments: [
578
+ asObject(tx, oappInfo.oapp_object),
579
+ asObject(tx, adminCap),
580
+ asObject(tx, this.objects.endpointV2),
581
+ asObject(tx, messagingChannel),
582
+ asU32(tx, srcEid),
583
+ asBytes32(tx, sender, this.moduleManager.getUtils()),
584
+ asU64(tx, nonce),
585
+ asBytes32(tx, payloadHash, this.moduleManager.getUtils()),
586
+ ],
587
+ })
588
+ }
589
+
590
+ /**
591
+ * Set send library for a destination chain
592
+ * @param tx - The transaction to add the move call to
593
+ * @param dstEid - Destination endpoint ID
594
+ * @param sendLibrary - Send library address
595
+ */
596
+ async setSendLibraryMoveCall(
597
+ tx: Transaction,
598
+ dstEid: number | TransactionArgument,
599
+ sendLibrary: string | TransactionArgument
600
+ ): Promise<void> {
601
+ const oappInfo = await this.#oappInfo()
602
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
603
+ tx.moveCall({
604
+ target: this.#target('set_send_library', 'endpoint_calls'),
605
+ arguments: [
606
+ asObject(tx, oappInfo.oapp_object),
607
+ asObject(tx, adminCap),
608
+ asObject(tx, this.objects.endpointV2),
609
+ asU32(tx, dstEid),
610
+ asAddress(tx, sendLibrary),
611
+ ],
612
+ })
613
+ }
614
+
615
+ /**
616
+ * Set receive library for a source chain
617
+ * @param tx - The transaction to add the move call to
618
+ * @param srcEid - Source endpoint ID
619
+ * @param receiveLibrary - Receive library address
620
+ * @param gracePeriod - Grace period in seconds
621
+ */
622
+ async setReceiveLibraryMoveCall(
623
+ tx: Transaction,
624
+ srcEid: number | TransactionArgument,
625
+ receiveLibrary: string | TransactionArgument,
626
+ gracePeriod: number | bigint | TransactionArgument
627
+ ): Promise<void> {
628
+ const oappInfo = await this.#oappInfo()
629
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
630
+ tx.moveCall({
631
+ target: this.#target('set_receive_library', 'endpoint_calls'),
632
+ arguments: [
633
+ asObject(tx, oappInfo.oapp_object),
634
+ asObject(tx, adminCap),
635
+ asObject(tx, this.objects.endpointV2),
636
+ asU32(tx, srcEid),
637
+ asAddress(tx, receiveLibrary),
638
+ asU64(tx, gracePeriod),
639
+ tx.object.clock(),
640
+ ],
641
+ })
642
+ }
643
+
644
+ /**
645
+ * Set receive library timeout for a source chain
646
+ * @param tx - The transaction to add the move call to
647
+ * @param srcEid - Source endpoint ID
648
+ * @param receiveLibrary - Receive library address
649
+ * @param expiry - Expiry timestamp in seconds
650
+ */
651
+ async setReceiveLibraryTimeoutMoveCall(
652
+ tx: Transaction,
653
+ srcEid: number | TransactionArgument,
654
+ receiveLibrary: string | TransactionArgument,
655
+ expiry: number | bigint | TransactionArgument
656
+ ): Promise<void> {
657
+ const oappInfo = await this.#oappInfo()
658
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
659
+ tx.moveCall({
660
+ target: this.#target('set_receive_library_timeout', 'endpoint_calls'),
661
+ arguments: [
662
+ asObject(tx, oappInfo.oapp_object),
663
+ asObject(tx, adminCap),
664
+ asObject(tx, this.objects.endpointV2),
665
+ asU32(tx, srcEid),
666
+ asAddress(tx, receiveLibrary),
667
+ asU64(tx, expiry),
668
+ tx.object.clock(),
669
+ ],
670
+ })
671
+ }
672
+
673
+ /**
674
+ * Set configuration for a message library
675
+ * @param tx - The transaction to add the move call to
676
+ * @param lib - Library address
677
+ * @param eid - Endpoint ID
678
+ * @param configType - Configuration type
679
+ * @param config - Configuration data as bytes
680
+ * @returns Transaction result containing Call<MessageLibSetConfigParam, Void>
681
+ */
682
+ async setConfigMoveCall(
683
+ tx: Transaction,
684
+ lib: string | TransactionArgument,
685
+ eid: number | TransactionArgument,
686
+ configType: number | TransactionArgument,
687
+ config: Uint8Array | TransactionArgument
688
+ ): Promise<TransactionResult> {
689
+ const oappInfo = await this.#oappInfo()
690
+ const adminCap = await this.getAdminCap(oappInfo.oapp_object)
691
+ return tx.moveCall({
692
+ target: this.#target('set_config', 'endpoint_calls'),
693
+ typeArguments: [],
694
+ arguments: [
695
+ asObject(tx, oappInfo.oapp_object),
696
+ asObject(tx, adminCap),
697
+ asObject(tx, this.objects.endpointV2),
698
+ asAddress(tx, lib),
699
+ asU32(tx, eid),
700
+ asU32(tx, configType),
701
+ asBytes(tx, config),
702
+ ],
703
+ })
704
+ }
705
+
304
706
  // === Private Functions ===
305
707
 
708
+ /**
709
+ * Get OApp info, throwing if not set
710
+ * @returns The OApp info
711
+ * @throws Error if OApp info is not set
712
+ * @private
713
+ */
714
+ async #oappInfo(): Promise<OAppInfoV1> {
715
+ if (!this.oappInfo) {
716
+ this.oappInfo = await this.getOAppInfoV1()
717
+ }
718
+ return this.oappInfo
719
+ }
720
+
306
721
  /**
307
722
  * Generate the full target path for move calls
308
723
  * @param name - The function name to call