@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.
- package/CHANGELOG.md +8 -0
- package/deployments/sui-sandbox-local/blocked_message_lib.json +22 -22
- package/deployments/sui-sandbox-local/blocked_msglib_ptb_builder.json +22 -22
- package/deployments/sui-sandbox-local/counter.json +79 -44
- package/deployments/sui-sandbox-local/dvn.json +23 -22
- package/deployments/sui-sandbox-local/dvn_call_type.json +28 -28
- package/deployments/sui-sandbox-local/dvn_fee_lib.json +27 -27
- package/deployments/sui-sandbox-local/dvn_layerzero.json +17 -17
- package/deployments/sui-sandbox-local/dvn_ptb_builder.json +21 -21
- package/deployments/sui-sandbox-local/endpoint_ptb_builder.json +30 -30
- package/deployments/sui-sandbox-local/endpoint_v2.json +25 -25
- package/deployments/sui-sandbox-local/executor.json +15 -14
- package/deployments/sui-sandbox-local/executor_call_type.json +28 -28
- package/deployments/sui-sandbox-local/executor_fee_lib.json +28 -28
- package/deployments/sui-sandbox-local/executor_layerzero.json +17 -17
- package/deployments/sui-sandbox-local/executor_ptb_builder.json +14 -14
- package/deployments/sui-sandbox-local/layerzero_views.json +21 -21
- package/deployments/sui-sandbox-local/message_lib_common.json +21 -21
- package/deployments/sui-sandbox-local/msglib_ptb_builder_call_types.json +13 -13
- package/deployments/sui-sandbox-local/oapp.json +15 -13
- 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 +4 -4
- 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 +5 -5
- package/deployments/sui-sandbox-local/object-EndpointV2AdminCap.json +5 -5
- 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/package_whitelist_validator.json +51 -51
- package/deployments/sui-sandbox-local/price_feed.json +39 -39
- package/deployments/sui-sandbox-local/price_feed_call_types.json +19 -19
- package/deployments/sui-sandbox-local/ptb_move_call.json +20 -20
- package/deployments/sui-sandbox-local/sequential_multi_call.json +45 -0
- package/deployments/sui-sandbox-local/simple_message_lib.json +33 -33
- package/deployments/sui-sandbox-local/simple_msglib_ptb_builder.json +22 -22
- package/deployments/sui-sandbox-local/treasury.json +40 -40
- package/deployments/sui-sandbox-local/uln_302.json +35 -39
- package/deployments/sui-sandbox-local/uln_302_ptb_builder.json +25 -25
- package/deployments/sui-sandbox-local/uln_common.json +49 -0
- package/deployments/sui-sandbox-local/worker_common.json +15 -14
- package/deployments/sui-sandbox-local/worker_registry.json +58 -0
- package/deployments/sui-testnet/blocked_message_lib.json +22 -22
- package/deployments/sui-testnet/blocked_msglib_ptb_builder.json +29 -29
- package/deployments/sui-testnet/call.json +21 -21
- package/deployments/sui-testnet/counter.json +40 -40
- package/deployments/sui-testnet/dvn.json +22 -21
- package/deployments/sui-testnet/dvn_call_type.json +19 -19
- package/deployments/sui-testnet/dvn_fee_lib.json +26 -26
- package/deployments/sui-testnet/dvn_layerzero.json +24 -24
- package/deployments/sui-testnet/dvn_ptb_builder.json +20 -20
- package/deployments/sui-testnet/endpoint_ptb_builder.json +30 -30
- package/deployments/sui-testnet/endpoint_v2.json +26 -26
- package/deployments/sui-testnet/executor.json +22 -21
- package/deployments/sui-testnet/executor_call_type.json +19 -19
- package/deployments/sui-testnet/executor_fee_lib.json +18 -18
- package/deployments/sui-testnet/executor_layerzero.json +25 -25
- package/deployments/sui-testnet/executor_ptb_builder.json +20 -20
- package/deployments/sui-testnet/layerzero_views.json +13 -13
- package/deployments/sui-testnet/message_lib_common.json +21 -21
- package/deployments/sui-testnet/msglib_ptb_builder_call_types.json +13 -13
- package/deployments/sui-testnet/oapp.json +15 -13
- package/deployments/sui-testnet/object-BlockedMessageLib.json +5 -5
- package/deployments/sui-testnet/object-BlockedMsglibPtbBuilder.json +5 -5
- package/deployments/sui-testnet/object-Counter.json +5 -5
- package/deployments/sui-testnet/object-CounterAdminCap.json +5 -5
- package/deployments/sui-testnet/object-CounterOApp.json +5 -5
- package/deployments/sui-testnet/object-DVN.json +2 -2
- package/deployments/sui-testnet/object-DVNCap.json +5 -5
- package/deployments/sui-testnet/object-DVNFeeLib.json +5 -5
- package/deployments/sui-testnet/object-EndpointPtbBuilder.json +5 -5
- package/deployments/sui-testnet/object-EndpointPtbBuilderAdminCap.json +5 -5
- package/deployments/sui-testnet/object-EndpointV2.json +5 -5
- package/deployments/sui-testnet/object-EndpointV2AdminCap.json +5 -5
- package/deployments/sui-testnet/object-Executor.json +2 -2
- package/deployments/sui-testnet/object-ExecutorCap.json +5 -5
- package/deployments/sui-testnet/object-ExecutorFeeLib.json +5 -5
- package/deployments/sui-testnet/object-ExecutorOwnerCap.json +2 -2
- package/deployments/sui-testnet/object-PackageWhitelistValidator.json +5 -5
- package/deployments/sui-testnet/object-PriceFeed.json +5 -5
- package/deployments/sui-testnet/object-PriceFeedOwnerCap.json +5 -5
- package/deployments/sui-testnet/object-SimpleMessageLib.json +5 -5
- package/deployments/sui-testnet/object-SimpleMessageLibAdminCap.json +5 -5
- package/deployments/sui-testnet/object-SmlPtbBuilder.json +5 -5
- package/deployments/sui-testnet/object-Treasury.json +5 -5
- package/deployments/sui-testnet/object-TreasuryAdminCap.json +5 -5
- package/deployments/sui-testnet/object-ULN302.json +5 -5
- package/deployments/sui-testnet/object-ULN302AdminCap.json +5 -5
- package/deployments/sui-testnet/object-Uln302PtbBuilder.json +5 -5
- package/deployments/sui-testnet/object-Uln302Verification.json +5 -5
- package/deployments/sui-testnet/object-WorkerRegistry.json +9 -0
- package/deployments/sui-testnet/object-ZroCoinMetadata.json +5 -5
- package/deployments/sui-testnet/object-ZroTreasuryCap.json +5 -5
- package/deployments/sui-testnet/package_whitelist_validator.json +44 -44
- package/deployments/sui-testnet/price_feed.json +25 -25
- package/deployments/sui-testnet/price_feed_call_types.json +12 -12
- package/deployments/sui-testnet/ptb_move_call.json +21 -21
- package/deployments/sui-testnet/sequential_multi_call.json +45 -0
- package/deployments/sui-testnet/simple_message_lib.json +29 -29
- package/deployments/sui-testnet/simple_msglib_ptb_builder.json +26 -26
- package/deployments/sui-testnet/treasury.json +30 -58
- package/deployments/sui-testnet/uln_302.json +28 -32
- package/deployments/sui-testnet/uln_302_ptb_builder.json +25 -25
- package/deployments/sui-testnet/uln_common.json +49 -0
- package/deployments/sui-testnet/utils.json +12 -12
- package/deployments/sui-testnet/worker_common.json +21 -20
- package/deployments/sui-testnet/worker_registry.json +58 -0
- package/deployments/sui-testnet/zro.json +28 -28
- package/dist/index.cjs +1193 -418
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +702 -352
- package/dist/index.d.ts +702 -352
- package/dist/index.mjs +1182 -418
- 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 +123 -105
- package/src/module-manager.ts +15 -3
- package/src/modules/call.ts +16 -6
- package/src/modules/endpoint.ts +12 -4
- package/src/modules/message-libs/simple-message-lib.ts +3 -2
- package/src/modules/message-libs/uln302.ts +28 -26
- package/src/modules/oapps/counter.ts +34 -50
- package/src/modules/oapps/oapp.ts +489 -74
- package/src/modules/ptb-builders/endpoint-ptb-builder.ts +9 -3
- package/src/modules/ptb-builders/ptb-builder.ts +19 -4
- package/src/modules/ptb-builders/uln302-ptb-builder.ts +5 -0
- package/src/modules/workers/dvn-layerzero.ts +9 -0
- package/src/modules/workers/dvn.ts +214 -6
- package/src/modules/workers/executor-fee-lib.ts +11 -3
- package/src/modules/workers/executor-layerzero.ts +9 -0
- package/src/modules/workers/executor.ts +115 -0
- package/src/modules/workers/index.ts +1 -0
- package/src/modules/workers/treasury.ts +4 -4
- package/src/modules/workers/worker-registry.ts +110 -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
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
// WorkerRegistry related errors (matching worker_registry.move)
|
|
12
|
+
EWorkerInfoInvalid: 1,
|
|
13
|
+
EWorkerInfoNotFound: 2,
|
|
14
|
+
} as const
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WorkerRegistry provides access to the worker registry contract functionality
|
|
18
|
+
* This module maintains mappings between worker addresses and their associated information.
|
|
19
|
+
*/
|
|
20
|
+
export class WorkerRegistry {
|
|
21
|
+
public packageId: string
|
|
22
|
+
public readonly client: SuiClient
|
|
23
|
+
private readonly objects: ObjectOptions
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a new WorkerRegistry instance
|
|
27
|
+
* @param packageId - The package ID of the worker registry contract
|
|
28
|
+
* @param client - The Sui client instance
|
|
29
|
+
* @param objects - Object options containing contract object IDs
|
|
30
|
+
* @param moduleManager - Module manager for handling dependencies
|
|
31
|
+
*/
|
|
32
|
+
constructor(
|
|
33
|
+
packageId: string,
|
|
34
|
+
client: SuiClient,
|
|
35
|
+
objects: ObjectOptions,
|
|
36
|
+
private readonly moduleManager: ModuleManager
|
|
37
|
+
) {
|
|
38
|
+
this.packageId = packageId
|
|
39
|
+
this.client = client
|
|
40
|
+
this.objects = objects
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// === View Functions ===
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get worker info for a specific worker address (as a move call)
|
|
47
|
+
* This creates a move call that can be used in a PTB (Programmable Transaction Block)
|
|
48
|
+
* @param tx - The transaction to add the move call to
|
|
49
|
+
* @param worker - The worker address or transaction argument
|
|
50
|
+
* @returns TransactionResult - The move call result containing worker info bytes
|
|
51
|
+
* @throws Will throw an error if worker info is not found (EWorkerInfoNotFound)
|
|
52
|
+
*/
|
|
53
|
+
getWorkerInfoMoveCall(tx: Transaction, worker: string | TransactionArgument): TransactionResult {
|
|
54
|
+
return tx.moveCall({
|
|
55
|
+
target: this.#target('get_worker_info'),
|
|
56
|
+
arguments: [tx.object(this.objects.workerRegistry), asAddress(tx, worker)],
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get worker info for a specific worker address
|
|
62
|
+
* Executes the get_worker_info function and returns the worker information bytes
|
|
63
|
+
* @param worker - The worker address to get info for
|
|
64
|
+
* @returns Promise<Uint8Array> - The worker information bytes containing encoded worker data
|
|
65
|
+
* @throws Will throw an error if worker info is not found (EWorkerInfoNotFound)
|
|
66
|
+
*/
|
|
67
|
+
async getWorkerInfo(worker: string): Promise<Uint8Array> {
|
|
68
|
+
return executeSimulate(
|
|
69
|
+
this.client,
|
|
70
|
+
(tx) => {
|
|
71
|
+
this.getWorkerInfoMoveCall(tx, worker)
|
|
72
|
+
},
|
|
73
|
+
(result) => {
|
|
74
|
+
return result[0].value
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Check if worker info exists for a specific worker address
|
|
81
|
+
* This is a convenience method that catches EWorkerInfoNotFound errors
|
|
82
|
+
* @param worker - The worker address to check
|
|
83
|
+
* @returns Promise<boolean> - True if worker info exists, false if not found
|
|
84
|
+
* @throws Will re-throw any errors other than EWorkerInfoNotFound
|
|
85
|
+
*/
|
|
86
|
+
async hasWorkerInfo(worker: string): Promise<boolean> {
|
|
87
|
+
try {
|
|
88
|
+
await this.getWorkerInfo(worker)
|
|
89
|
+
return true
|
|
90
|
+
} catch (error) {
|
|
91
|
+
// If the error is EWorkerInfoNotFound, return false
|
|
92
|
+
if (error instanceof Error && error.message.includes('EWorkerInfoNotFound')) {
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
// Re-throw other errors
|
|
96
|
+
throw error
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// === Private Functions ===
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Generate the target string for move calls
|
|
104
|
+
* @param functionName - The function name to call
|
|
105
|
+
* @returns The fully qualified target string for the move call
|
|
106
|
+
*/
|
|
107
|
+
#target(functionName: string): string {
|
|
108
|
+
return `${this.packageId}::${MODULE_NAME}::${functionName}`
|
|
109
|
+
}
|
|
110
|
+
}
|
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
|
}
|