@layerzerolabs/lz-sui-sdk-v2 3.0.132 → 3.0.134-sui.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/deployments/sui-sandbox-local/blocked_message_lib.json +26 -26
- package/deployments/sui-sandbox-local/blocked_msglib_ptb_builder.json +26 -26
- package/deployments/sui-sandbox-local/call.json +20 -20
- package/deployments/sui-sandbox-local/counter.json +81 -46
- package/deployments/sui-sandbox-local/dvn.json +23 -22
- package/deployments/sui-sandbox-local/dvn_call_type.json +21 -21
- package/deployments/sui-sandbox-local/dvn_fee_lib.json +31 -31
- package/deployments/sui-sandbox-local/dvn_layerzero.json +25 -25
- package/deployments/sui-sandbox-local/dvn_ptb_builder.json +14 -14
- package/deployments/sui-sandbox-local/endpoint_ptb_builder.json +31 -31
- package/deployments/sui-sandbox-local/endpoint_v2.json +26 -26
- package/deployments/sui-sandbox-local/executor.json +21 -20
- package/deployments/sui-sandbox-local/executor_call_type.json +14 -14
- package/deployments/sui-sandbox-local/executor_fee_lib.json +27 -27
- package/deployments/sui-sandbox-local/executor_layerzero.json +22 -22
- package/deployments/sui-sandbox-local/executor_ptb_builder.json +14 -14
- package/deployments/sui-sandbox-local/layerzero_views.json +14 -14
- package/deployments/sui-sandbox-local/message_lib_common.json +22 -22
- package/deployments/sui-sandbox-local/msglib_ptb_builder_call_types.json +14 -14
- package/deployments/sui-sandbox-local/oapp.json +16 -14
- package/deployments/sui-sandbox-local/object-BlockedMessageLib.json +5 -5
- package/deployments/sui-sandbox-local/object-BlockedMsglibPtbBuilder.json +5 -5
- package/deployments/sui-sandbox-local/object-Counter.json +5 -5
- package/deployments/sui-sandbox-local/object-CounterAdminCap.json +5 -5
- package/deployments/sui-sandbox-local/object-CounterOApp.json +5 -5
- package/deployments/sui-sandbox-local/object-DVN.json +2 -2
- package/deployments/sui-sandbox-local/object-DVNCap.json +5 -5
- package/deployments/sui-sandbox-local/object-DVNFeeLib.json +5 -5
- package/deployments/sui-sandbox-local/object-EndpointPtbBuilder.json +5 -5
- package/deployments/sui-sandbox-local/object-EndpointPtbBuilderAdminCap.json +5 -5
- package/deployments/sui-sandbox-local/object-EndpointV2.json +4 -4
- package/deployments/sui-sandbox-local/object-EndpointV2AdminCap.json +4 -4
- package/deployments/sui-sandbox-local/object-Executor.json +2 -2
- package/deployments/sui-sandbox-local/object-ExecutorCap.json +4 -4
- package/deployments/sui-sandbox-local/object-ExecutorFeeLib.json +5 -5
- package/deployments/sui-sandbox-local/object-ExecutorOwnerCap.json +2 -2
- package/deployments/sui-sandbox-local/object-PackageWhitelistValidator.json +5 -5
- package/deployments/sui-sandbox-local/object-PriceFeed.json +5 -5
- package/deployments/sui-sandbox-local/object-PriceFeedOwnerCap.json +5 -5
- package/deployments/sui-sandbox-local/object-SimpleMessageLib.json +5 -5
- package/deployments/sui-sandbox-local/object-SimpleMessageLibAdminCap.json +5 -5
- package/deployments/sui-sandbox-local/object-SmlPtbBuilder.json +5 -5
- package/deployments/sui-sandbox-local/object-Treasury.json +5 -5
- package/deployments/sui-sandbox-local/object-TreasuryAdminCap.json +5 -5
- package/deployments/sui-sandbox-local/object-ULN302.json +5 -5
- package/deployments/sui-sandbox-local/object-ULN302AdminCap.json +5 -5
- package/deployments/sui-sandbox-local/object-Uln302PtbBuilder.json +5 -5
- package/deployments/sui-sandbox-local/object-Uln302Verification.json +5 -5
- package/deployments/sui-sandbox-local/object-WorkerRegistry.json +9 -0
- package/deployments/sui-sandbox-local/object-ZroCoinMetadata.json +4 -4
- package/deployments/sui-sandbox-local/object-ZroTreasuryCap.json +4 -4
- package/deployments/sui-sandbox-local/package_whitelist_validator.json +51 -51
- package/deployments/sui-sandbox-local/price_feed.json +42 -42
- package/deployments/sui-sandbox-local/price_feed_call_types.json +13 -13
- package/deployments/sui-sandbox-local/ptb_move_call.json +14 -14
- package/deployments/sui-sandbox-local/simple_message_lib.json +34 -34
- package/deployments/sui-sandbox-local/simple_msglib_ptb_builder.json +27 -27
- package/deployments/sui-sandbox-local/treasury.json +38 -38
- package/deployments/sui-sandbox-local/uln_302.json +29 -29
- package/deployments/sui-sandbox-local/uln_302_ptb_builder.json +26 -26
- package/deployments/sui-sandbox-local/utils.json +14 -14
- package/deployments/sui-sandbox-local/worker_common.json +16 -15
- package/deployments/sui-sandbox-local/worker_registry.json +58 -0
- package/deployments/sui-sandbox-local/zro.json +23 -23
- package/dist/index.cjs +840 -300
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +541 -316
- package/dist/index.d.ts +541 -316
- package/dist/index.mjs +834 -301
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/bcs/index.ts +2 -1
- package/src/bcs/oapp.ts +14 -0
- package/src/generated/addresses.ts +72 -54
- package/src/module-manager.ts +15 -3
- package/src/modules/endpoint.ts +2 -3
- package/src/modules/oapps/counter.ts +30 -47
- package/src/modules/oapps/oapp.ts +468 -62
- package/src/modules/ptb-builders/ptb-builder.ts +10 -4
- package/src/modules/workers/dvn-layerzero.ts +1 -0
- package/src/modules/workers/dvn.ts +59 -0
- package/src/modules/workers/executor-layerzero.ts +1 -0
- package/src/modules/workers/executor.ts +59 -0
- package/src/modules/workers/index.ts +1 -0
- package/src/modules/workers/worker-registry.ts +109 -0
- package/src/resource.ts +3 -0
- package/src/sdk.ts +7 -2
- package/src/types/endpoint.ts +2 -1
- package/src/types/modules.ts +1 -0
- package/src/types/oapp.ts +6 -0
- package/src/types/options.ts +15 -0
- package/src/utils/transaction.ts +3 -3
|
@@ -2,14 +2,14 @@ import { bcs } from '@mysten/sui/bcs'
|
|
|
2
2
|
import { SuiClient } from '@mysten/sui/client'
|
|
3
3
|
import { Transaction, TransactionResult } from '@mysten/sui/transactions'
|
|
4
4
|
|
|
5
|
-
import { VectorMoveCallBCS } from '../../bcs'
|
|
5
|
+
import { OAppInfoV1Bcs, VectorMoveCallBCS } from '../../bcs'
|
|
6
6
|
import {
|
|
7
7
|
Argument,
|
|
8
8
|
BuilderPlaceholderInfo,
|
|
9
9
|
DEFAULT_SIMULATION_TIMES,
|
|
10
10
|
LzComposeVersion,
|
|
11
|
-
LzReceiveVersion,
|
|
12
11
|
MoveCall,
|
|
12
|
+
OAppInfoVersion,
|
|
13
13
|
SimulateResult,
|
|
14
14
|
} from '../../types'
|
|
15
15
|
import { simulateTransaction } from '../../utils/transaction'
|
|
@@ -48,9 +48,10 @@ export class PtbBuilder {
|
|
|
48
48
|
async simulateLzReceivePtb(tx: Transaction, sender?: string): Promise<MoveCall[]> {
|
|
49
49
|
const ptbCallsResult = await simulateTransaction(this.client, tx, sender)
|
|
50
50
|
const buffer = Buffer.from(bcs.vector(bcs.u8()).parse(ptbCallsResult[0].value))
|
|
51
|
+
|
|
51
52
|
const version = buffer.readInt16BE()
|
|
52
|
-
if (version ===
|
|
53
|
-
return this.#
|
|
53
|
+
if (version === OAppInfoVersion.VERSION_1) {
|
|
54
|
+
return this.#decodeMoveCallsFromOAppInfoV1(new Uint8Array(buffer.subarray(2)))
|
|
54
55
|
}
|
|
55
56
|
throw new Error(`Unknown version: ${version}`)
|
|
56
57
|
}
|
|
@@ -285,6 +286,11 @@ export class PtbBuilder {
|
|
|
285
286
|
return this.#decodeMoveCallsBytes(value)
|
|
286
287
|
}
|
|
287
288
|
|
|
289
|
+
#decodeMoveCallsFromOAppInfoV1(bytes: Uint8Array): MoveCall[] {
|
|
290
|
+
const oappInfo = OAppInfoV1Bcs.parse(bytes)
|
|
291
|
+
return this.#decodeMoveCallsBytes(new Uint8Array(oappInfo.lz_receive_info).subarray(2)) // remove the version prefix
|
|
292
|
+
}
|
|
293
|
+
|
|
288
294
|
/**
|
|
289
295
|
* Decode move calls from raw bytes
|
|
290
296
|
* @param bytes - The raw bytes containing encoded move calls
|
|
@@ -1135,6 +1135,65 @@ export class DVN {
|
|
|
1135
1135
|
)
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
|
+
/**
|
|
1139
|
+
* Get DVN object address from worker registry using this DVN's worker capability (as a move call)
|
|
1140
|
+
* This function chains Move calls to decode worker info and extract the DVN object address
|
|
1141
|
+
* @param tx - The transaction to add the move call to
|
|
1142
|
+
* @returns Transaction result containing the DVN object address
|
|
1143
|
+
*/
|
|
1144
|
+
getDvnObjectAddressMoveCall(tx: Transaction): TransactionResult {
|
|
1145
|
+
// Step 1: Get this DVN's worker capability address
|
|
1146
|
+
const workerCapAddress = this.workerCapAddressMoveCall(tx)
|
|
1147
|
+
|
|
1148
|
+
// Step 2: Get worker info bytes from registry
|
|
1149
|
+
const workerInfoBytes = this.moduleManager
|
|
1150
|
+
.getWorkerRegistry(this.client)
|
|
1151
|
+
.getWorkerInfoMoveCall(tx, workerCapAddress)
|
|
1152
|
+
|
|
1153
|
+
// Step 3: Decode worker info using worker_common::worker_info_v1::decode
|
|
1154
|
+
const workerInfo = tx.moveCall({
|
|
1155
|
+
target: `${this.moduleManager.packages.workerCommon}::worker_info_v1::decode`,
|
|
1156
|
+
arguments: [workerInfoBytes],
|
|
1157
|
+
})
|
|
1158
|
+
|
|
1159
|
+
// Step 4: Extract worker_info field from decoded WorkerInfoV1
|
|
1160
|
+
const dvnInfoBytes = tx.moveCall({
|
|
1161
|
+
target: `${this.moduleManager.packages.workerCommon}::worker_info_v1::worker_info`,
|
|
1162
|
+
arguments: [workerInfo],
|
|
1163
|
+
})
|
|
1164
|
+
|
|
1165
|
+
// Step 5: Decode DVN info using dvn::dvn_info_v1::decode
|
|
1166
|
+
const dvnInfo = tx.moveCall({
|
|
1167
|
+
target: `${this.packageId}::dvn_info_v1::decode`,
|
|
1168
|
+
arguments: [dvnInfoBytes],
|
|
1169
|
+
})
|
|
1170
|
+
|
|
1171
|
+
// Step 6: Extract dvn_object address from decoded DVNInfoV1
|
|
1172
|
+
return tx.moveCall({
|
|
1173
|
+
target: `${this.packageId}::dvn_info_v1::dvn_object`,
|
|
1174
|
+
arguments: [dvnInfo],
|
|
1175
|
+
})
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Get DVN object address from worker registry using this DVN's worker capability
|
|
1180
|
+
* This function uses Move calls to decode worker info and extract the DVN object address
|
|
1181
|
+
* @returns Promise<string> - The DVN object address
|
|
1182
|
+
* @throws Will throw an error if worker info is not found or if decoding fails
|
|
1183
|
+
*/
|
|
1184
|
+
async getDvnObjectAddress(): Promise<string> {
|
|
1185
|
+
return executeSimulate(
|
|
1186
|
+
this.client,
|
|
1187
|
+
(tx) => {
|
|
1188
|
+
this.getDvnObjectAddressMoveCall(tx)
|
|
1189
|
+
},
|
|
1190
|
+
(result) => {
|
|
1191
|
+
// The result is the DVN object address directly from the Move call chain
|
|
1192
|
+
return bcs.Address.parse(result[0].value)
|
|
1193
|
+
}
|
|
1194
|
+
)
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1138
1197
|
// === Witness Functions ===
|
|
1139
1198
|
|
|
1140
1199
|
/**
|
|
@@ -1029,6 +1029,65 @@ export class Executor {
|
|
|
1029
1029
|
)
|
|
1030
1030
|
}
|
|
1031
1031
|
|
|
1032
|
+
/**
|
|
1033
|
+
* Get Executor object address from worker registry using this Executor's worker capability (as a move call)
|
|
1034
|
+
* This function chains Move calls to decode worker info and extract the Executor object address
|
|
1035
|
+
* @param tx - The transaction to add the move call to
|
|
1036
|
+
* @returns Transaction result containing the Executor object address
|
|
1037
|
+
*/
|
|
1038
|
+
getExecutorObjectAddressMoveCall(tx: Transaction): TransactionResult {
|
|
1039
|
+
// Step 1: Get this Executor's worker capability address
|
|
1040
|
+
const workerCapAddress = this.workerCapAddressMoveCall(tx)
|
|
1041
|
+
|
|
1042
|
+
// Step 2: Get worker info bytes from registry
|
|
1043
|
+
const workerInfoBytes = this.moduleManager
|
|
1044
|
+
.getWorkerRegistry(this.client)
|
|
1045
|
+
.getWorkerInfoMoveCall(tx, workerCapAddress)
|
|
1046
|
+
|
|
1047
|
+
// Step 3: Decode worker info using worker_common::worker_info_v1::decode
|
|
1048
|
+
const workerInfo = tx.moveCall({
|
|
1049
|
+
target: `${this.moduleManager.packages.workerCommon}::worker_info_v1::decode`,
|
|
1050
|
+
arguments: [workerInfoBytes],
|
|
1051
|
+
})
|
|
1052
|
+
|
|
1053
|
+
// Step 4: Extract worker_info field from decoded WorkerInfoV1
|
|
1054
|
+
const executorInfoBytes = tx.moveCall({
|
|
1055
|
+
target: `${this.moduleManager.packages.workerCommon}::worker_info_v1::worker_info`,
|
|
1056
|
+
arguments: [workerInfo],
|
|
1057
|
+
})
|
|
1058
|
+
|
|
1059
|
+
// Step 5: Decode Executor info using executor::executor_info_v1::decode
|
|
1060
|
+
const executorInfo = tx.moveCall({
|
|
1061
|
+
target: `${this.packageId}::executor_info_v1::decode`,
|
|
1062
|
+
arguments: [executorInfoBytes],
|
|
1063
|
+
})
|
|
1064
|
+
|
|
1065
|
+
// Step 6: Extract executor_object address from decoded ExecutorInfoV1
|
|
1066
|
+
return tx.moveCall({
|
|
1067
|
+
target: `${this.packageId}::executor_info_v1::executor_object`,
|
|
1068
|
+
arguments: [executorInfo],
|
|
1069
|
+
})
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Get Executor object address from worker registry using this Executor's worker capability
|
|
1074
|
+
* This function uses Move calls to decode worker info and extract the Executor object address
|
|
1075
|
+
* @returns Promise<string> - The Executor object address
|
|
1076
|
+
* @throws Will throw an error if worker info is not found or if decoding fails
|
|
1077
|
+
*/
|
|
1078
|
+
async getExecutorObjectAddress(): Promise<string> {
|
|
1079
|
+
return executeSimulate(
|
|
1080
|
+
this.client,
|
|
1081
|
+
(tx) => {
|
|
1082
|
+
this.getExecutorObjectAddressMoveCall(tx)
|
|
1083
|
+
},
|
|
1084
|
+
(result) => {
|
|
1085
|
+
// The result is the Executor object address directly from the Move call chain
|
|
1086
|
+
return bcs.Address.parse(result[0].value)
|
|
1087
|
+
}
|
|
1088
|
+
)
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1032
1091
|
// === Private Helper Functions ===
|
|
1033
1092
|
|
|
1034
1093
|
private parseDstConfig(data: Uint8Array): DstConfig {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { SuiClient } from '@mysten/sui/client'
|
|
2
|
+
import { Transaction, TransactionArgument, TransactionResult } from '@mysten/sui/transactions'
|
|
3
|
+
|
|
4
|
+
import { ModuleManager } from '../../module-manager'
|
|
5
|
+
import { ObjectOptions } from '../../types'
|
|
6
|
+
import { asAddress, executeSimulate } from '../../utils'
|
|
7
|
+
|
|
8
|
+
const MODULE_NAME = 'worker_registry'
|
|
9
|
+
|
|
10
|
+
export const WorkerRegistryErrorCode = {
|
|
11
|
+
EWorkerInfoInvalid: 1,
|
|
12
|
+
EWorkerInfoNotFound: 2,
|
|
13
|
+
} as const
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* WorkerRegistry provides access to the worker registry contract functionality
|
|
17
|
+
* This module maintains mappings between worker addresses and their associated information.
|
|
18
|
+
*/
|
|
19
|
+
export class WorkerRegistry {
|
|
20
|
+
public packageId: string
|
|
21
|
+
public readonly client: SuiClient
|
|
22
|
+
private readonly objects: ObjectOptions
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a new WorkerRegistry instance
|
|
26
|
+
* @param packageId - The package ID of the worker registry contract
|
|
27
|
+
* @param client - The Sui client instance
|
|
28
|
+
* @param objects - Object options containing contract object IDs
|
|
29
|
+
* @param moduleManager - Module manager for handling dependencies
|
|
30
|
+
*/
|
|
31
|
+
constructor(
|
|
32
|
+
packageId: string,
|
|
33
|
+
client: SuiClient,
|
|
34
|
+
objects: ObjectOptions,
|
|
35
|
+
private readonly moduleManager: ModuleManager
|
|
36
|
+
) {
|
|
37
|
+
this.packageId = packageId
|
|
38
|
+
this.client = client
|
|
39
|
+
this.objects = objects
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// === View Functions ===
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get worker info for a specific worker address (as a move call)
|
|
46
|
+
* This creates a move call that can be used in a PTB (Programmable Transaction Block)
|
|
47
|
+
* @param tx - The transaction to add the move call to
|
|
48
|
+
* @param worker - The worker address or transaction argument
|
|
49
|
+
* @returns TransactionResult - The move call result containing worker info bytes
|
|
50
|
+
* @throws Will throw an error if worker info is not found (EWorkerInfoNotFound)
|
|
51
|
+
*/
|
|
52
|
+
getWorkerInfoMoveCall(tx: Transaction, worker: string | TransactionArgument): TransactionResult {
|
|
53
|
+
return tx.moveCall({
|
|
54
|
+
target: this.#target('get_worker_info'),
|
|
55
|
+
arguments: [tx.object(this.objects.workerRegistry), asAddress(tx, worker)],
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get worker info for a specific worker address
|
|
61
|
+
* Executes the get_worker_info function and returns the worker information bytes
|
|
62
|
+
* @param worker - The worker address to get info for
|
|
63
|
+
* @returns Promise<Uint8Array> - The worker information bytes containing encoded worker data
|
|
64
|
+
* @throws Will throw an error if worker info is not found (EWorkerInfoNotFound)
|
|
65
|
+
*/
|
|
66
|
+
async getWorkerInfo(worker: string): Promise<Uint8Array> {
|
|
67
|
+
return executeSimulate(
|
|
68
|
+
this.client,
|
|
69
|
+
(tx) => {
|
|
70
|
+
this.getWorkerInfoMoveCall(tx, worker)
|
|
71
|
+
},
|
|
72
|
+
(result) => {
|
|
73
|
+
return result[0].value
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Check if worker info exists for a specific worker address
|
|
80
|
+
* This is a convenience method that catches EWorkerInfoNotFound errors
|
|
81
|
+
* @param worker - The worker address to check
|
|
82
|
+
* @returns Promise<boolean> - True if worker info exists, false if not found
|
|
83
|
+
* @throws Will re-throw any errors other than EWorkerInfoNotFound
|
|
84
|
+
*/
|
|
85
|
+
async hasWorkerInfo(worker: string): Promise<boolean> {
|
|
86
|
+
try {
|
|
87
|
+
await this.getWorkerInfo(worker)
|
|
88
|
+
return true
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// If the error is EWorkerInfoNotFound, return false
|
|
91
|
+
if (error instanceof Error && error.message.includes('EWorkerInfoNotFound')) {
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
// Re-throw other errors
|
|
95
|
+
throw error
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// === Private Functions ===
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Generate the target string for move calls
|
|
103
|
+
* @param functionName - The function name to call
|
|
104
|
+
* @returns The fully qualified target string for the move call
|
|
105
|
+
*/
|
|
106
|
+
#target(functionName: string): string {
|
|
107
|
+
return `${this.packageId}::${MODULE_NAME}::${functionName}`
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/resource.ts
CHANGED
|
@@ -33,6 +33,8 @@ const PACKAGE_ADDRESS_MAP: { [K in keyof PackageOptions]: Partial<{ [S in Stage]
|
|
|
33
33
|
oapp: AddressConstants.PACKAGE_OAPP_ADDRESS,
|
|
34
34
|
layerzeroViews: AddressConstants.PACKAGE_LAYERZERO_VIEWS_ADDRESS,
|
|
35
35
|
packageWhitelistValidator: AddressConstants.PACKAGE_PACKAGE_WHITELIST_VALIDATOR_ADDRESS,
|
|
36
|
+
workerRegistry: AddressConstants.PACKAGE_WORKER_REGISTRY_ADDRESS,
|
|
37
|
+
workerCommon: AddressConstants.PACKAGE_WORKER_COMMON_ADDRESS,
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -67,6 +69,7 @@ const OBJECT_ADDRESS_MAP: { [K in keyof ObjectOptions]: Partial<{ [S in Stage]:
|
|
|
67
69
|
priceFeed: AddressConstants.OBJECT_PRICE_FEED_ADDRESS,
|
|
68
70
|
priceFeedOwnerCap: AddressConstants.OBJECT_PRICE_FEED_OWNER_CAP_ADDRESS,
|
|
69
71
|
packageWhitelistValidator: AddressConstants.OBJECT_PACKAGE_WHITELIST_VALIDATOR_ADDRESS,
|
|
72
|
+
workerRegistry: AddressConstants.OBJECT_WORKER_REGISTRY_ADDRESS,
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
/**
|
package/src/sdk.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
Uln302,
|
|
30
30
|
Uln302PtbBuilder,
|
|
31
31
|
Utils,
|
|
32
|
+
WorkerRegistry,
|
|
32
33
|
Zro,
|
|
33
34
|
} from './modules'
|
|
34
35
|
import { ResourceManager } from './resource'
|
|
@@ -106,8 +107,8 @@ export class SDK {
|
|
|
106
107
|
return this.moduleManager.getLayerZeroViews()
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
getOApp(): OApp {
|
|
110
|
-
return this.moduleManager.getOApp()
|
|
110
|
+
getOApp(callCapId: string, options?: ModuleOptions): OApp {
|
|
111
|
+
return this.moduleManager.getOApp(this.client, callCapId, options)
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
// === Non-Core Module Getters (created on-demand with caching) ===
|
|
@@ -172,6 +173,10 @@ export class SDK {
|
|
|
172
173
|
return this.moduleManager.getBlockedMessageLibPtbBuilder(this.client, options)
|
|
173
174
|
}
|
|
174
175
|
|
|
176
|
+
getWorkerRegistry(options?: ModuleOptions): WorkerRegistry {
|
|
177
|
+
return this.moduleManager.getWorkerRegistry(this.client, options)
|
|
178
|
+
}
|
|
179
|
+
|
|
175
180
|
getOrCreateModule<T>(moduleName: string, options: ModuleOptions | undefined, factory: () => T): T {
|
|
176
181
|
return this.moduleManager.getOrCreateModule(moduleName, options, factory)
|
|
177
182
|
}
|
package/src/types/endpoint.ts
CHANGED
|
@@ -11,5 +11,6 @@ export interface Timeout {
|
|
|
11
11
|
* LayerZero protocol version constants
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const OAppInfoVersion = { VERSION_1: 1, VERSION_2: 2 } as const
|
|
15
|
+
export const LzReceiveVersion = { VERSION_1: 1 } as const
|
|
15
16
|
export const LzComposeVersion = { VERSION_1: 1 } as const
|
package/src/types/modules.ts
CHANGED
package/src/types/options.ts
CHANGED
|
@@ -136,6 +136,16 @@ export interface PackageOptions {
|
|
|
136
136
|
*/
|
|
137
137
|
blockedMessageLibPtbBuilder: string
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* The worker registry address.
|
|
141
|
+
*/
|
|
142
|
+
workerRegistry: string
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The worker common address.
|
|
146
|
+
*/
|
|
147
|
+
workerCommon: string
|
|
148
|
+
|
|
139
149
|
/**
|
|
140
150
|
* Allow additional properties beyond the explicitly defined ones
|
|
141
151
|
*/
|
|
@@ -285,6 +295,11 @@ export interface ObjectOptions {
|
|
|
285
295
|
*/
|
|
286
296
|
packageWhitelistValidator: string
|
|
287
297
|
|
|
298
|
+
/**
|
|
299
|
+
* The worker registry object address.
|
|
300
|
+
*/
|
|
301
|
+
workerRegistry: string
|
|
302
|
+
|
|
288
303
|
/**
|
|
289
304
|
* Allow additional properties beyond the explicitly defined ones
|
|
290
305
|
*/
|
package/src/utils/transaction.ts
CHANGED
|
@@ -101,17 +101,17 @@ export async function validateTransaction(
|
|
|
101
101
|
/**
|
|
102
102
|
* Execute simulate using a moveCall function
|
|
103
103
|
* @param client - The Sui client
|
|
104
|
-
* @param moveCallFn - Function that adds moveCall to the transaction
|
|
104
|
+
* @param moveCallFn - Function that adds moveCall to the transaction (supports both sync and async, any return type)
|
|
105
105
|
* @param parser - Function to parse the result
|
|
106
106
|
* @returns The parsed result
|
|
107
107
|
*/
|
|
108
108
|
export async function executeSimulate<T>(
|
|
109
109
|
client: SuiClient,
|
|
110
|
-
moveCallFn: (tx: Transaction) =>
|
|
110
|
+
moveCallFn: (tx: Transaction) => unknown,
|
|
111
111
|
parser: (result: { value: Uint8Array }[]) => T
|
|
112
112
|
): Promise<T> {
|
|
113
113
|
const tx = new Transaction()
|
|
114
|
-
moveCallFn(tx)
|
|
114
|
+
await moveCallFn(tx)
|
|
115
115
|
const result = await simulateTransaction(client, tx)
|
|
116
116
|
return parser(result)
|
|
117
117
|
}
|