@layerzerolabs/lz-sui-sdk-v2 3.0.134-sui.3 → 3.0.134

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 (162) hide show
  1. package/deployments/sui-sandbox-local/blocked_message_lib.json +18 -18
  2. package/deployments/sui-sandbox-local/blocked_msglib_ptb_builder.json +25 -25
  3. package/deployments/sui-sandbox-local/counter.json +47 -82
  4. package/deployments/sui-sandbox-local/dvn.json +14 -15
  5. package/deployments/sui-sandbox-local/dvn_call_type.json +21 -21
  6. package/deployments/sui-sandbox-local/dvn_fee_lib.json +27 -27
  7. package/deployments/sui-sandbox-local/dvn_layerzero.json +24 -24
  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 +25 -25
  11. package/deployments/sui-sandbox-local/executor.json +14 -15
  12. package/deployments/sui-sandbox-local/executor_call_type.json +28 -28
  13. package/deployments/sui-sandbox-local/executor_fee_lib.json +28 -28
  14. package/deployments/sui-sandbox-local/executor_layerzero.json +17 -17
  15. package/deployments/sui-sandbox-local/executor_ptb_builder.json +21 -21
  16. package/deployments/sui-sandbox-local/layerzero_views.json +13 -13
  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 -23
  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/package_whitelist_validator.json +51 -51
  49. package/deployments/sui-sandbox-local/price_feed.json +39 -39
  50. package/deployments/sui-sandbox-local/price_feed_call_types.json +19 -19
  51. package/deployments/sui-sandbox-local/ptb_move_call.json +20 -20
  52. package/deployments/sui-sandbox-local/simple_message_lib.json +33 -33
  53. package/deployments/sui-sandbox-local/simple_msglib_ptb_builder.json +18 -18
  54. package/deployments/sui-sandbox-local/treasury.json +41 -41
  55. package/deployments/sui-sandbox-local/uln_302.json +47 -43
  56. package/deployments/sui-sandbox-local/uln_302_ptb_builder.json +18 -18
  57. package/deployments/sui-sandbox-local/worker_common.json +14 -15
  58. package/deployments/sui-testnet/blocked_message_lib.json +22 -22
  59. package/deployments/sui-testnet/blocked_msglib_ptb_builder.json +29 -29
  60. package/deployments/sui-testnet/call.json +21 -21
  61. package/deployments/sui-testnet/counter.json +40 -40
  62. package/deployments/sui-testnet/dvn.json +21 -22
  63. package/deployments/sui-testnet/dvn_call_type.json +19 -19
  64. package/deployments/sui-testnet/dvn_fee_lib.json +26 -26
  65. package/deployments/sui-testnet/dvn_layerzero.json +24 -24
  66. package/deployments/sui-testnet/dvn_ptb_builder.json +20 -20
  67. package/deployments/sui-testnet/endpoint_ptb_builder.json +30 -30
  68. package/deployments/sui-testnet/endpoint_v2.json +26 -26
  69. package/deployments/sui-testnet/executor.json +21 -22
  70. package/deployments/sui-testnet/executor_call_type.json +19 -19
  71. package/deployments/sui-testnet/executor_fee_lib.json +18 -18
  72. package/deployments/sui-testnet/executor_layerzero.json +25 -25
  73. package/deployments/sui-testnet/executor_ptb_builder.json +20 -20
  74. package/deployments/sui-testnet/layerzero_views.json +13 -13
  75. package/deployments/sui-testnet/message_lib_common.json +21 -21
  76. package/deployments/sui-testnet/msglib_ptb_builder_call_types.json +13 -13
  77. package/deployments/sui-testnet/oapp.json +13 -15
  78. package/deployments/sui-testnet/object-BlockedMessageLib.json +5 -5
  79. package/deployments/sui-testnet/object-BlockedMsglibPtbBuilder.json +5 -5
  80. package/deployments/sui-testnet/object-Counter.json +5 -5
  81. package/deployments/sui-testnet/object-CounterAdminCap.json +5 -5
  82. package/deployments/sui-testnet/object-CounterOApp.json +5 -5
  83. package/deployments/sui-testnet/object-DVN.json +2 -2
  84. package/deployments/sui-testnet/object-DVNCap.json +5 -5
  85. package/deployments/sui-testnet/object-DVNFeeLib.json +5 -5
  86. package/deployments/sui-testnet/object-EndpointPtbBuilder.json +5 -5
  87. package/deployments/sui-testnet/object-EndpointPtbBuilderAdminCap.json +5 -5
  88. package/deployments/sui-testnet/object-EndpointV2.json +5 -5
  89. package/deployments/sui-testnet/object-EndpointV2AdminCap.json +5 -5
  90. package/deployments/sui-testnet/object-Executor.json +2 -2
  91. package/deployments/sui-testnet/object-ExecutorCap.json +5 -5
  92. package/deployments/sui-testnet/object-ExecutorFeeLib.json +5 -5
  93. package/deployments/sui-testnet/object-ExecutorOwnerCap.json +2 -2
  94. package/deployments/sui-testnet/object-PackageWhitelistValidator.json +5 -5
  95. package/deployments/sui-testnet/object-PriceFeed.json +5 -5
  96. package/deployments/sui-testnet/object-PriceFeedOwnerCap.json +5 -5
  97. package/deployments/sui-testnet/object-SimpleMessageLib.json +5 -5
  98. package/deployments/sui-testnet/object-SimpleMessageLibAdminCap.json +5 -5
  99. package/deployments/sui-testnet/object-SmlPtbBuilder.json +5 -5
  100. package/deployments/sui-testnet/object-Treasury.json +5 -5
  101. package/deployments/sui-testnet/object-TreasuryAdminCap.json +5 -5
  102. package/deployments/sui-testnet/object-ULN302.json +5 -5
  103. package/deployments/sui-testnet/object-ULN302AdminCap.json +5 -5
  104. package/deployments/sui-testnet/object-Uln302PtbBuilder.json +5 -5
  105. package/deployments/sui-testnet/object-Uln302Verification.json +5 -5
  106. package/deployments/sui-testnet/object-ZroCoinMetadata.json +5 -5
  107. package/deployments/sui-testnet/object-ZroTreasuryCap.json +5 -5
  108. package/deployments/sui-testnet/package_whitelist_validator.json +44 -44
  109. package/deployments/sui-testnet/price_feed.json +25 -25
  110. package/deployments/sui-testnet/price_feed_call_types.json +12 -12
  111. package/deployments/sui-testnet/ptb_move_call.json +21 -21
  112. package/deployments/sui-testnet/simple_message_lib.json +29 -29
  113. package/deployments/sui-testnet/simple_msglib_ptb_builder.json +26 -26
  114. package/deployments/sui-testnet/treasury.json +58 -30
  115. package/deployments/sui-testnet/uln_302.json +32 -28
  116. package/deployments/sui-testnet/uln_302_ptb_builder.json +25 -25
  117. package/deployments/sui-testnet/utils.json +12 -12
  118. package/deployments/sui-testnet/worker_common.json +20 -21
  119. package/deployments/sui-testnet/zro.json +28 -28
  120. package/dist/index.cjs +418 -1193
  121. package/dist/index.cjs.map +1 -1
  122. package/dist/index.d.mts +343 -693
  123. package/dist/index.d.ts +343 -693
  124. package/dist/index.mjs +418 -1182
  125. package/dist/index.mjs.map +1 -1
  126. package/package.json +7 -7
  127. package/src/bcs/index.ts +1 -2
  128. package/src/generated/addresses.ts +105 -123
  129. package/src/module-manager.ts +3 -15
  130. package/src/modules/call.ts +6 -16
  131. package/src/modules/endpoint.ts +4 -12
  132. package/src/modules/message-libs/simple-message-lib.ts +2 -3
  133. package/src/modules/message-libs/uln302.ts +26 -28
  134. package/src/modules/oapps/counter.ts +50 -34
  135. package/src/modules/oapps/oapp.ts +74 -489
  136. package/src/modules/ptb-builders/endpoint-ptb-builder.ts +3 -9
  137. package/src/modules/ptb-builders/ptb-builder.ts +4 -19
  138. package/src/modules/ptb-builders/uln302-ptb-builder.ts +0 -5
  139. package/src/modules/workers/dvn-layerzero.ts +0 -9
  140. package/src/modules/workers/dvn.ts +6 -214
  141. package/src/modules/workers/executor-fee-lib.ts +3 -11
  142. package/src/modules/workers/executor-layerzero.ts +0 -9
  143. package/src/modules/workers/executor.ts +0 -115
  144. package/src/modules/workers/index.ts +0 -1
  145. package/src/modules/workers/treasury.ts +4 -4
  146. package/src/resource.ts +0 -3
  147. package/src/sdk.ts +2 -7
  148. package/src/types/endpoint.ts +1 -2
  149. package/src/types/modules.ts +0 -1
  150. package/src/types/options.ts +0 -15
  151. package/src/utils/transaction.ts +3 -3
  152. package/deployments/sui-sandbox-local/object-WorkerRegistry.json +0 -9
  153. package/deployments/sui-sandbox-local/sequential_multi_call.json +0 -45
  154. package/deployments/sui-sandbox-local/uln_common.json +0 -49
  155. package/deployments/sui-sandbox-local/worker_registry.json +0 -58
  156. package/deployments/sui-testnet/object-WorkerRegistry.json +0 -9
  157. package/deployments/sui-testnet/sequential_multi_call.json +0 -45
  158. package/deployments/sui-testnet/uln_common.json +0 -49
  159. package/deployments/sui-testnet/worker_registry.json +0 -58
  160. package/src/bcs/oapp.ts +0 -14
  161. package/src/modules/workers/worker-registry.ts +0 -110
  162. package/src/types/oapp.ts +0 -6
@@ -2,72 +2,43 @@ 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'
6
5
  import { ModuleManager } from '../../module-manager'
7
6
  import { ObjectOptions } from '../../types'
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'
7
+ import { asBytes, asBytes32, asObject, asU16, asU32, executeSimulate } from '../../utils'
20
8
 
21
9
  const MODULE_NAME = 'oapp'
22
10
 
23
11
  export const OAppErrorCode = {
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,
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,
45
24
  } as const
46
25
 
47
26
  export class OApp {
48
27
  public packageId: string
49
- public oappCallCapId: string
50
28
  public readonly client: SuiClient
51
- public oappInfo: OAppInfoV1 | null = null
52
29
  private readonly objects: ObjectOptions
53
30
 
54
31
  constructor(
55
32
  packageId: string,
56
- oappCallCapId: string,
57
33
  client: SuiClient,
58
34
  objects: ObjectOptions,
59
35
  private readonly moduleManager: ModuleManager
60
36
  ) {
61
37
  this.packageId = packageId
62
- this.oappCallCapId = oappCallCapId
63
38
  this.client = client
64
39
  this.objects = objects
65
40
  }
66
41
 
67
- // setOAppInfo(oappInfo: OAppInfoV1): void {
68
- // this.oappInfo = oappInfo
69
- // }
70
-
71
42
  // === Set Functions ===
72
43
 
73
44
  /**
@@ -79,18 +50,18 @@ export class OApp {
79
50
  * @param msgType - Message type or transaction argument
80
51
  * @param options - Enforced options as bytes or transaction argument
81
52
  */
82
- async setEnforcedOptionsMoveCall(
53
+ setEnforcedOptionsMoveCall(
83
54
  tx: Transaction,
55
+ oapp: string | TransactionArgument,
56
+ adminCap: string | TransactionArgument,
84
57
  eid: number | TransactionArgument,
85
58
  msgType: number | TransactionArgument,
86
59
  options: Uint8Array | TransactionArgument
87
- ): Promise<void> {
88
- const oappInfo = await this.#oappInfo()
89
- const adminCap = await this.getAdminCap(oappInfo.oapp_object)
60
+ ): void {
90
61
  tx.moveCall({
91
62
  target: this.#target('set_enforced_options'),
92
63
  arguments: [
93
- asObject(tx, oappInfo.oapp_object),
64
+ asObject(tx, oapp),
94
65
  asObject(tx, adminCap),
95
66
  asU32(tx, eid),
96
67
  asU16(tx, msgType),
@@ -107,21 +78,18 @@ export class OApp {
107
78
  * @param eid - Peer endpoint ID or transaction argument
108
79
  * @param peer - Peer OApp address as bytes or transaction argument
109
80
  */
110
- async setPeerMoveCall(
81
+ setPeerMoveCall(
111
82
  tx: Transaction,
83
+ oapp: string | TransactionArgument,
84
+ adminCap: string | TransactionArgument,
112
85
  eid: number | TransactionArgument,
113
86
  peer: Uint8Array | TransactionArgument
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)
87
+ ): void {
118
88
  tx.moveCall({
119
89
  target: this.#target('set_peer'),
120
90
  arguments: [
121
- asObject(tx, oappInfo.oapp_object),
91
+ asObject(tx, oapp),
122
92
  asObject(tx, adminCap),
123
- asObject(tx, this.objects.endpointV2),
124
- asObject(tx, messagingChannel),
125
93
  asU32(tx, eid),
126
94
  asBytes32(tx, peer, this.moduleManager.getUtils()),
127
95
  ],
@@ -131,57 +99,56 @@ export class OApp {
131
99
  // === View Functions ===
132
100
 
133
101
  /**
134
- * Get admin capability address for OApp
102
+ * Get admin address for OApp
135
103
  * @param tx - The transaction to add the move call to
136
104
  * @param oapp - The OApp object ID or transaction argument
137
- * @returns Transaction result containing the admin capability address
105
+ * @returns Transaction result containing the admin address
138
106
  */
139
- getAdminCapMoveCall(tx: Transaction, oapp: string | TransactionArgument): TransactionResult {
107
+ getAdminMoveCall(tx: Transaction, oapp: string | TransactionArgument): TransactionResult {
140
108
  return tx.moveCall({
141
- target: this.#target('admin_cap'),
109
+ target: this.#target('admin'),
142
110
  arguments: [asObject(tx, oapp)],
143
111
  })
144
112
  }
145
113
 
146
114
  /**
147
- * Get admin capability address for OApp
115
+ * Get admin address for OApp
148
116
  * @param oapp - The OApp object ID
149
- * @returns Promise<string> - The admin capability address
117
+ * @returns Promise<string> - The admin address
150
118
  */
151
- async getAdminCap(oapp: string): Promise<string> {
119
+ async getAdmin(oapp: string): Promise<string> {
152
120
  return executeSimulate(
153
121
  this.client,
154
122
  (tx) => {
155
- this.getAdminCapMoveCall(tx, oapp)
123
+ this.getAdminMoveCall(tx, oapp)
156
124
  },
157
125
  (result) => bcs.Address.parse(result[0].value)
158
126
  )
159
127
  }
160
128
 
161
129
  /**
162
- * Get OApp CallCap identifier
130
+ * Get OApp address (call capability ID)
163
131
  * @param tx - The transaction to add the move call to
164
132
  * @param oapp - The OApp object ID or transaction argument
165
- * @returns Transaction result containing the OApp CallCap identifier
133
+ * @returns Transaction result containing the OApp address
166
134
  */
167
- async getOAppCapIdMoveCall(tx: Transaction): Promise<TransactionResult> {
168
- const oappInfo = await this.#oappInfo()
135
+ getOAppAddressMoveCall(tx: Transaction, oapp: string | TransactionArgument): TransactionResult {
169
136
  return tx.moveCall({
170
- target: this.#target('oapp_cap_id'),
171
- arguments: [asObject(tx, oappInfo.oapp_object)],
137
+ target: this.#target('oapp_address'),
138
+ arguments: [asObject(tx, oapp)],
172
139
  })
173
140
  }
174
141
 
175
142
  /**
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
143
+ * Get OApp address (call capability ID)
144
+ * @param oapp - The OApp object ID
145
+ * @returns Promise<string> - The OApp address
179
146
  */
180
- async getOAppCapId(): Promise<string> {
147
+ async getOAppAddress(oapp: string): Promise<string> {
181
148
  return executeSimulate(
182
149
  this.client,
183
- async (tx) => {
184
- await this.getOAppCapIdMoveCall(tx)
150
+ (tx) => {
151
+ this.getOAppAddressMoveCall(tx, oapp)
185
152
  },
186
153
  (result) => bcs.Address.parse(result[0].value)
187
154
  )
@@ -196,21 +163,16 @@ export class OApp {
196
163
  * @param extraOptions - Extra options to combine with enforced options or transaction argument
197
164
  * @returns Transaction result containing combined options
198
165
  */
199
- async combineOptionsMoveCall(
166
+ combineOptionsMoveCall(
200
167
  tx: Transaction,
168
+ oapp: string | TransactionArgument,
201
169
  eid: number | TransactionArgument,
202
170
  msgType: number | TransactionArgument,
203
171
  extraOptions: Uint8Array | TransactionArgument
204
- ): Promise<TransactionResult> {
205
- const oappInfo = await this.#oappInfo()
172
+ ): TransactionResult {
206
173
  return tx.moveCall({
207
174
  target: this.#target('combine_options'),
208
- arguments: [
209
- asObject(tx, oappInfo.oapp_object),
210
- asU32(tx, eid),
211
- asU16(tx, msgType),
212
- asBytes(tx, extraOptions),
213
- ],
175
+ arguments: [asObject(tx, oapp), asU32(tx, eid), asU16(tx, msgType), asBytes(tx, extraOptions)],
214
176
  })
215
177
  }
216
178
 
@@ -222,11 +184,11 @@ export class OApp {
222
184
  * @param extraOptions - Extra options to combine with enforced options
223
185
  * @returns Promise<Uint8Array> - Combined options as bytes
224
186
  */
225
- async combineOptions(eid: number, msgType: number, extraOptions: Uint8Array): Promise<Uint8Array> {
187
+ async combineOptions(oapp: string, eid: number, msgType: number, extraOptions: Uint8Array): Promise<Uint8Array> {
226
188
  return executeSimulate(
227
189
  this.client,
228
- async (tx) => {
229
- await this.combineOptionsMoveCall(tx, eid, msgType, extraOptions)
190
+ (tx) => {
191
+ this.combineOptionsMoveCall(tx, oapp, eid, msgType, extraOptions)
230
192
  },
231
193
  (result) => new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
232
194
  )
@@ -240,15 +202,15 @@ export class OApp {
240
202
  * @param msgType - Message type or transaction argument
241
203
  * @returns Transaction result containing enforced options
242
204
  */
243
- async getEnforcedOptionsMoveCall(
205
+ getEnforcedOptionsMoveCall(
244
206
  tx: Transaction,
207
+ oapp: string | TransactionArgument,
245
208
  eid: number | TransactionArgument,
246
209
  msgType: number | TransactionArgument
247
- ): Promise<TransactionResult> {
248
- const oappInfo = await this.#oappInfo()
210
+ ): TransactionResult {
249
211
  return tx.moveCall({
250
212
  target: this.#target('get_enforced_options'),
251
- arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, eid), asU16(tx, msgType)],
213
+ arguments: [asObject(tx, oapp), asU32(tx, eid), asU16(tx, msgType)],
252
214
  })
253
215
  }
254
216
 
@@ -259,11 +221,11 @@ export class OApp {
259
221
  * @param msgType - Message type
260
222
  * @returns Promise<Uint8Array> - Enforced options as bytes
261
223
  */
262
- async getEnforcedOptions(eid: number, msgType: number): Promise<Uint8Array> {
224
+ async getEnforcedOptions(oapp: string, eid: number, msgType: number): Promise<Uint8Array> {
263
225
  return executeSimulate(
264
226
  this.client,
265
- async (tx) => {
266
- await this.getEnforcedOptionsMoveCall(tx, eid, msgType)
227
+ (tx) => {
228
+ this.getEnforcedOptionsMoveCall(tx, oapp, eid, msgType)
267
229
  },
268
230
  (result) => new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
269
231
  )
@@ -276,11 +238,14 @@ export class OApp {
276
238
  * @param dstEid - Destination endpoint ID or transaction argument
277
239
  * @returns Transaction result containing boolean result
278
240
  */
279
- async hasPeerMoveCall(tx: Transaction, dstEid: number | TransactionArgument): Promise<TransactionResult> {
280
- const oappInfo = await this.#oappInfo()
241
+ hasPeerMoveCall(
242
+ tx: Transaction,
243
+ oapp: string | TransactionArgument,
244
+ dstEid: number | TransactionArgument
245
+ ): TransactionResult {
281
246
  return tx.moveCall({
282
247
  target: this.#target('has_peer'),
283
- arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, dstEid)],
248
+ arguments: [asObject(tx, oapp), asU32(tx, dstEid)],
284
249
  })
285
250
  }
286
251
 
@@ -290,11 +255,11 @@ export class OApp {
290
255
  * @param dstEid - Destination endpoint ID
291
256
  * @returns Promise<boolean> - True if peer is configured, false otherwise
292
257
  */
293
- async hasPeer(dstEid: number): Promise<boolean> {
258
+ async hasPeer(oapp: string, dstEid: number): Promise<boolean> {
294
259
  return executeSimulate(
295
260
  this.client,
296
- async (tx) => {
297
- await this.hasPeerMoveCall(tx, dstEid)
261
+ (tx) => {
262
+ this.hasPeerMoveCall(tx, oapp, dstEid)
298
263
  },
299
264
  (result) => bcs.Bool.parse(result[0].value)
300
265
  )
@@ -307,11 +272,14 @@ export class OApp {
307
272
  * @param dstEid - Destination endpoint ID or transaction argument
308
273
  * @returns Transaction result containing peer address
309
274
  */
310
- async getPeerMoveCall(tx: Transaction, dstEid: number | TransactionArgument): Promise<TransactionResult> {
311
- const oappInfo = await this.#oappInfo()
275
+ getPeerMoveCall(
276
+ tx: Transaction,
277
+ oapp: string | TransactionArgument,
278
+ dstEid: number | TransactionArgument
279
+ ): TransactionResult {
312
280
  return tx.moveCall({
313
281
  target: this.#target('get_peer'),
314
- arguments: [asObject(tx, oappInfo.oapp_object), asU32(tx, dstEid)],
282
+ arguments: [asObject(tx, oapp), asU32(tx, dstEid)],
315
283
  })
316
284
  }
317
285
 
@@ -321,403 +289,20 @@ export class OApp {
321
289
  * @param dstEid - Destination endpoint ID
322
290
  * @returns Promise<Uint8Array> - Peer address as bytes32
323
291
  */
324
- async getPeer(dstEid: number): Promise<Uint8Array> {
325
- return executeSimulate(
326
- this.client,
327
- async (tx) => {
328
- await this.getPeerMoveCall(tx, dstEid)
329
- },
330
- (result) => {
331
- return new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
332
- }
333
- )
334
- }
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> {
292
+ async getPeer(oapp: string, dstEid: number): Promise<Uint8Array> {
346
293
  return executeSimulate(
347
294
  this.client,
348
295
  (tx) => {
349
- this.getOAppInfoV1MoveCall(tx)
296
+ this.getPeerMoveCall(tx, oapp, dstEid)
350
297
  },
351
298
  (result) => {
352
- return OAppInfoV1Bcs.parse(result[0].value)
299
+ return new Uint8Array(bcs.vector(bcs.u8()).parse(result[0].value))
353
300
  }
354
301
  )
355
302
  }
356
303
 
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
-
706
304
  // === Private Functions ===
707
305
 
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
-
721
306
  /**
722
307
  * Generate the full target path for move calls
723
308
  * @param name - The function name to call