@layerzerolabs/protocol-stellar-v2 0.2.8 → 0.2.10
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/.turbo/turbo-build.log +443 -302
- package/.turbo/turbo-lint.log +118 -96
- package/.turbo/turbo-test.log +853 -731
- package/Cargo.lock +120 -37
- package/Cargo.toml +8 -5
- package/contracts/common-macros/src/contract_impl.rs +44 -0
- package/contracts/common-macros/src/lib.rs +86 -40
- package/contracts/common-macros/src/ownable.rs +24 -32
- package/contracts/common-macros/src/storage.rs +95 -120
- package/contracts/common-macros/src/tests/contract_impl.rs +289 -0
- package/contracts/common-macros/src/tests/mod.rs +9 -0
- package/contracts/common-macros/src/tests/ownable.rs +151 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap +85 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +30 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap +9 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +1072 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +45 -0
- package/contracts/common-macros/src/tests/storage.rs +485 -0
- package/contracts/common-macros/src/tests/test_helpers.rs +93 -0
- package/contracts/common-macros/src/tests/ttl_configurable.rs +34 -0
- package/contracts/common-macros/src/ttl_configurable.rs +31 -14
- package/contracts/common-macros/src/utils.rs +27 -0
- package/contracts/endpoint-v2/ARCHITECTURE.md +4 -4
- package/contracts/endpoint-v2/src/endpoint_v2.rs +18 -15
- package/contracts/endpoint-v2/src/interfaces/message_lib.rs +2 -3
- package/contracts/endpoint-v2/src/interfaces/message_lib_manager.rs +5 -3
- package/contracts/endpoint-v2/src/interfaces/messaging_channel.rs +2 -2
- package/contracts/endpoint-v2/src/interfaces/messaging_composer.rs +2 -2
- package/contracts/endpoint-v2/src/interfaces/send_lib.rs +4 -4
- package/contracts/endpoint-v2/src/lib.rs +6 -5
- package/contracts/endpoint-v2/src/message_lib_manager.rs +14 -6
- package/contracts/endpoint-v2/src/messaging_channel.rs +6 -2
- package/contracts/endpoint-v2/src/messaging_composer.rs +6 -2
- package/contracts/endpoint-v2/src/storage.rs +10 -7
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +16 -16
- package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +46 -46
- package/contracts/endpoint-v2/src/tests/mock.rs +2 -2
- package/contracts/endpoint-v2/src/util.rs +8 -2
- package/contracts/message-libs/block-message-lib/Cargo.toml +1 -0
- package/contracts/message-libs/block-message-lib/src/lib.rs +5 -5
- package/contracts/message-libs/message-lib-common/src/errors.rs +8 -8
- package/contracts/message-libs/message-lib-common/src/interfaces/dvn.rs +0 -1
- package/contracts/message-libs/message-lib-common/src/interfaces/mod.rs +3 -3
- package/contracts/message-libs/message-lib-common/src/lib.rs +0 -2
- package/contracts/message-libs/message-lib-common/src/packet_codec_v1.rs +4 -6
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +2 -2
- package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +11 -11
- package/contracts/message-libs/message-lib-common/src/worker_options.rs +10 -16
- package/contracts/message-libs/simple-message-lib/src/errors.rs +0 -4
- package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +49 -34
- package/contracts/message-libs/simple-message-lib/src/storage.rs +3 -7
- package/contracts/message-libs/simple-message-lib/src/test.rs +3 -3
- package/contracts/message-libs/treasury/src/storage.rs +1 -2
- package/contracts/message-libs/treasury/src/tests/setup.rs +3 -2
- package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +0 -13
- package/contracts/message-libs/treasury/src/treasury.rs +18 -21
- package/contracts/message-libs/uln-302/Cargo.toml +1 -0
- package/contracts/message-libs/uln-302/src/interfaces/mod.rs +4 -4
- package/contracts/message-libs/uln-302/src/interfaces/{receive.rs → receive_uln.rs} +3 -3
- package/contracts/message-libs/uln-302/src/interfaces/{send.rs → send_uln.rs} +8 -80
- package/contracts/message-libs/uln-302/src/lib.rs +5 -4
- package/contracts/message-libs/uln-302/src/{receive.rs → receive_uln.rs} +20 -12
- package/contracts/message-libs/uln-302/src/{send.rs → send_uln.rs} +19 -13
- package/contracts/message-libs/uln-302/src/storage.rs +1 -2
- package/contracts/message-libs/uln-302/src/tests/config/uln_config.rs +3 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/send.rs +30 -30
- package/contracts/message-libs/uln-302/src/tests/setup.rs +12 -11
- package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +1 -1
- package/contracts/message-libs/uln-302/src/{config_validation.rs → types.rs} +79 -11
- package/contracts/message-libs/uln-302/src/uln302.rs +15 -10
- package/contracts/oapp-macros/Cargo.toml +2 -8
- package/contracts/oapp-macros/src/lib.rs +57 -311
- package/contracts/oapp-macros/src/oapp_core.rs +23 -32
- package/contracts/oapp-macros/src/oapp_full.rs +8 -2
- package/contracts/oapp-macros/src/oapp_options_type3.rs +21 -36
- package/contracts/oapp-macros/src/oapp_receiver.rs +38 -57
- package/contracts/oapp-macros/src/oapp_sender.rs +12 -14
- package/contracts/oapp-macros/src/util.rs +14 -10
- package/contracts/oapps/counter/Cargo.toml +2 -1
- package/contracts/oapps/counter/integration_tests/utils.rs +4 -4
- package/contracts/oapps/counter/src/codec.rs +8 -9
- package/contracts/oapps/counter/src/counter.rs +156 -147
- package/contracts/oapps/counter/src/storage.rs +1 -2
- package/contracts/oapps/counter/src/tests/test_codec.rs +5 -5
- package/contracts/oapps/counter/src/tests/test_counter.rs +11 -13
- package/contracts/oapps/oapp/Cargo.toml +1 -0
- package/contracts/oapps/oapp/src/errors.rs +1 -1
- package/contracts/oapps/oapp/src/lib.rs +3 -0
- package/contracts/oapps/oapp/src/macro_tests/mod.rs +1 -0
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +312 -0
- package/contracts/oapps/oapp/src/oapp_core.rs +52 -53
- package/contracts/oapps/oapp/src/oapp_options_type3.rs +18 -28
- package/contracts/oapps/oapp/src/oapp_receiver.rs +82 -31
- package/contracts/oapps/oapp/src/oapp_sender.rs +55 -13
- package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +16 -3
- package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +33 -8
- package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +6 -9
- package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +28 -15
- package/contracts/oapps/oft/Cargo.toml +27 -0
- package/contracts/oapps/oft/integration-tests/mod.rs +3 -0
- package/contracts/oapps/oft/integration-tests/setup.rs +320 -0
- package/contracts/oapps/oft/integration-tests/test_with_sml.rs +155 -0
- package/contracts/oapps/oft/integration-tests/utils.rs +201 -0
- package/contracts/oapps/oft/src/codec/mod.rs +2 -0
- package/contracts/oapps/oft/src/codec/oft_compose_msg_codec.rs +55 -0
- package/contracts/oapps/oft/src/codec/oft_msg_codec.rs +62 -0
- package/contracts/oapps/oft/src/constants.rs +5 -0
- package/contracts/oapps/oft/src/errors.rs +8 -0
- package/contracts/oapps/oft/src/events.rs +19 -0
- package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +23 -0
- package/contracts/oapps/oft/src/interfaces/mod.rs +3 -0
- package/contracts/oapps/oft/src/lib.rs +22 -0
- package/contracts/oapps/oft/src/macro_tests/mod.rs +2 -0
- package/contracts/oapps/oft/src/macro_tests/test_all_default.rs +41 -0
- package/contracts/oapps/oft/src/macro_tests/test_override.rs +83 -0
- package/contracts/oapps/oft/src/oft.rs +320 -0
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +50 -0
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +50 -0
- package/contracts/oapps/oft/src/oft_types/mod.rs +10 -0
- package/contracts/oapps/oft/src/storage.rs +11 -0
- package/contracts/oapps/oft/src/tests/mod.rs +13 -0
- package/contracts/oapps/oft/src/tests/test_decimals.rs +89 -0
- package/contracts/oapps/oft/src/tests/test_lz_receive.rs +282 -0
- package/contracts/oapps/oft/src/tests/test_oft_compose_msg_codec.rs +68 -0
- package/contracts/oapps/oft/src/tests/test_oft_msg_codec.rs +136 -0
- package/contracts/oapps/oft/src/tests/test_oft_version.rs +13 -0
- package/contracts/oapps/oft/src/tests/test_quote_oft.rs +159 -0
- package/contracts/oapps/oft/src/tests/test_quote_send.rs +195 -0
- package/contracts/oapps/oft/src/tests/test_resolve_address.rs +37 -0
- package/contracts/oapps/oft/src/tests/test_send.rs +915 -0
- package/contracts/oapps/oft/src/tests/test_token.rs +47 -0
- package/contracts/oapps/oft/src/tests/test_utils.rs +789 -0
- package/contracts/oapps/oft/src/types.rs +38 -0
- package/contracts/oapps/oft/src/utils.rs +67 -0
- package/contracts/oapps/oft-mint-burn/Cargo.toml +26 -0
- package/contracts/oapps/oft-mint-burn/src/lib.rs +3 -0
- package/contracts/oapps/oft-mint-burn/src/oft.rs +28 -0
- package/contracts/oapps/oft-mint-burn/src/tests/mod.rs +1 -0
- package/contracts/utils/src/buffer_reader.rs +8 -9
- package/contracts/utils/src/buffer_writer.rs +11 -5
- package/contracts/utils/src/errors.rs +5 -5
- package/contracts/utils/src/ownable.rs +14 -6
- package/contracts/utils/src/testing_utils.rs +11 -1
- package/contracts/utils/src/tests/buffer_reader.rs +491 -730
- package/contracts/utils/src/tests/buffer_writer.rs +336 -148
- package/contracts/utils/src/tests/bytes_ext.rs +125 -40
- package/contracts/utils/src/tests/mod.rs +3 -0
- package/contracts/utils/src/tests/ownable.rs +379 -27
- package/contracts/utils/src/tests/test_helper.rs +47 -0
- package/contracts/utils/src/tests/testing_utils.rs +555 -0
- package/contracts/utils/src/tests/ttl.rs +421 -0
- package/contracts/utils/src/ttl.rs +29 -89
- package/contracts/workers/dvn/Cargo.toml +31 -0
- package/contracts/workers/dvn/src/auth.rs +66 -0
- package/contracts/workers/dvn/src/dvn.rs +143 -0
- package/contracts/workers/dvn/src/errors.rs +21 -0
- package/contracts/workers/dvn/src/events.rs +19 -0
- package/contracts/workers/dvn/src/interfaces/dvn.rs +12 -0
- package/contracts/workers/dvn/src/interfaces/mod.rs +5 -0
- package/contracts/workers/dvn/src/interfaces/multisig.rs +15 -0
- package/contracts/workers/dvn/src/lib.rs +24 -0
- package/contracts/workers/dvn/src/multisig.rs +127 -0
- package/contracts/workers/dvn/src/storage.rs +35 -0
- package/contracts/workers/dvn/src/tests/auth.rs +237 -0
- package/contracts/workers/dvn/src/tests/dvn.rs +349 -0
- package/contracts/workers/dvn/src/tests/key_pair.rs +66 -0
- package/contracts/workers/dvn/src/tests/mod.rs +5 -0
- package/contracts/workers/dvn/src/tests/multisig/mod.rs +3 -0
- package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +133 -0
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +108 -0
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +109 -0
- package/contracts/workers/dvn/src/tests/setup.rs +109 -0
- package/contracts/workers/dvn/src/types.rs +26 -0
- package/contracts/workers/dvn-fee-lib/Cargo.toml +24 -0
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +113 -0
- package/contracts/workers/dvn-fee-lib/src/errors.rs +8 -0
- package/contracts/workers/dvn-fee-lib/src/lib.rs +17 -0
- package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +282 -0
- package/contracts/workers/dvn-fee-lib/src/tests/mod.rs +1 -0
- package/contracts/workers/executor/Cargo.toml +10 -7
- package/contracts/workers/executor/src/errors.rs +8 -0
- package/contracts/workers/executor/src/events.rs +4 -7
- package/contracts/workers/executor/src/interfaces/executor.rs +72 -22
- package/contracts/workers/executor/src/interfaces/mod.rs +0 -2
- package/contracts/workers/executor/src/lib.rs +16 -7
- package/contracts/workers/executor/src/lz_executor.rs +308 -0
- package/contracts/workers/executor/src/storage.rs +24 -16
- package/contracts/workers/executor-fee-lib/Cargo.toml +22 -0
- package/contracts/workers/executor-fee-lib/src/errors.rs +15 -0
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +215 -0
- package/contracts/workers/executor-fee-lib/src/executor_option.rs +203 -0
- package/contracts/workers/executor-fee-lib/src/lib.rs +7 -0
- package/contracts/workers/executor-helper/Cargo.toml +29 -0
- package/contracts/workers/executor-helper/src/executor_helper.rs +161 -0
- package/contracts/workers/executor-helper/src/lib.rs +11 -0
- package/contracts/workers/{worker-common → worker}/Cargo.toml +1 -4
- package/contracts/workers/worker/src/errors.rs +24 -0
- package/contracts/workers/worker/src/events.rs +62 -0
- package/contracts/workers/worker/src/interfaces/dvn_fee_lib.rs +75 -0
- package/contracts/workers/worker/src/interfaces/executor_fee_lib.rs +84 -0
- package/contracts/workers/{worker-common → worker}/src/interfaces/mod.rs +2 -2
- package/contracts/workers/worker/src/interfaces/price_feed.rs +85 -0
- package/contracts/workers/worker/src/lib.rs +14 -0
- package/contracts/workers/worker/src/storage.rs +63 -0
- package/contracts/workers/worker/src/worker.rs +459 -0
- package/package.json +3 -3
- package/sdk/dist/generated/bml.d.ts +88 -17
- package/sdk/dist/generated/bml.js +62 -16
- package/sdk/dist/generated/counter.d.ts +281 -102
- package/sdk/dist/generated/counter.js +93 -41
- package/sdk/dist/generated/endpoint.d.ts +128 -105
- package/sdk/dist/generated/endpoint.js +47 -45
- package/sdk/dist/generated/sml.d.ts +212 -69
- package/sdk/dist/generated/sml.js +103 -53
- package/sdk/dist/generated/uln302.d.ts +270 -173
- package/sdk/dist/generated/uln302.js +112 -64
- package/sdk/package.json +11 -11
- package/sdk/test/index.test.ts +147 -42
- package/sdk/test/suites/constants.ts +7 -3
- package/sdk/test/suites/deploy.ts +65 -42
- package/sdk/test/suites/localnet.ts +2 -2
- package/sdk/test/suites/scan.ts +28 -25
- package/sdk/test/utils.ts +199 -0
- package/sdk/tsconfig.json +93 -95
- package/tools/ts-bindings-gen/src/main.rs +2 -0
- package/contracts/common-macros/src/snapshots/common_macros__tests__tests__snapshot_generated_storage_code.snap +0 -310
- package/contracts/common-macros/src/tests.rs +0 -287
- package/contracts/oapp-macros/tests/test_macros.rs +0 -522
- package/contracts/workers/executor/src/executor.rs +0 -347
- package/contracts/workers/executor/src/interfaces/types.rs +0 -51
- package/contracts/workers/worker-common/src/constants.rs +0 -17
- package/contracts/workers/worker-common/src/errors.rs +0 -6
- package/contracts/workers/worker-common/src/events.rs +0 -34
- package/contracts/workers/worker-common/src/interfaces/executor_fee_lib.rs +0 -35
- package/contracts/workers/worker-common/src/interfaces/price_feed.rs +0 -40
- package/contracts/workers/worker-common/src/interfaces/worker.rs +0 -60
- package/contracts/workers/worker-common/src/lib.rs +0 -19
- package/contracts/workers/worker-common/src/storage.rs +0 -32
- package/contracts/workers/worker-common/src/worker_common.rs +0 -166
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
use super::*;
|
|
2
|
+
|
|
1
3
|
// ==============================================================================
|
|
2
4
|
// ISendLib Contract Implementation
|
|
3
5
|
// ==============================================================================
|
|
4
6
|
|
|
5
|
-
#[contractimpl]
|
|
7
|
+
#[contractimpl(contracttrait)]
|
|
6
8
|
impl ISendLib for Uln302 {
|
|
7
9
|
/// Quotes the total fee for sending a cross-chain message.
|
|
8
10
|
///
|
|
@@ -59,7 +61,7 @@ impl ISendLib for Uln302 {
|
|
|
59
61
|
let treasury_fee =
|
|
60
62
|
Self::get_treasury_client(env).get_fee(&packet.sender, &packet.dst_eid, &workers_fee, &pay_in_zro);
|
|
61
63
|
if treasury_fee > 0 {
|
|
62
|
-
let treasury_fee_recipient = FeeRecipient {
|
|
64
|
+
let treasury_fee_recipient = FeeRecipient { to: Self::treasury(env), amount: treasury_fee };
|
|
63
65
|
if pay_in_zro {
|
|
64
66
|
zro_fee_recipients.push_back(treasury_fee_recipient);
|
|
65
67
|
} else {
|
|
@@ -79,10 +81,8 @@ impl ISendLib for Uln302 {
|
|
|
79
81
|
// ISendUln302 Contract Implementation
|
|
80
82
|
// ==============================================================================
|
|
81
83
|
|
|
82
|
-
#[contractimpl]
|
|
84
|
+
#[contractimpl(contracttrait)]
|
|
83
85
|
impl ISendUln302 for Uln302 {
|
|
84
|
-
// === Owner Set Config Functions ===
|
|
85
|
-
|
|
86
86
|
/// Sets default executor configurations for multiple destination endpoints.
|
|
87
87
|
#[only_owner]
|
|
88
88
|
fn set_default_executor_configs(env: &Env, params: &Vec<SetDefaultExecutorConfigParam>) {
|
|
@@ -103,7 +103,9 @@ impl ISendUln302 for Uln302 {
|
|
|
103
103
|
DefaultUlnSendConfigSet { params: params.clone() }.publish(env);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
//
|
|
106
|
+
// ============================================================================================
|
|
107
|
+
// View Functions
|
|
108
|
+
// ============================================================================================
|
|
107
109
|
|
|
108
110
|
/// Returns the treasury address for fee collection.
|
|
109
111
|
fn treasury(env: &Env) -> Address {
|
|
@@ -155,15 +157,13 @@ impl ISendUln302 for Uln302 {
|
|
|
155
157
|
// ==============================================================================
|
|
156
158
|
|
|
157
159
|
impl Uln302 {
|
|
158
|
-
// === OApp Set Config Functions ===
|
|
159
|
-
|
|
160
160
|
/// Sets OApp-specific executor configuration for a destination endpoint.
|
|
161
161
|
///
|
|
162
162
|
/// # Arguments
|
|
163
163
|
/// * `sender` - The sender OApp address
|
|
164
164
|
/// * `dst_eid` - The destination endpoint ID
|
|
165
165
|
/// * `config` - The OApp-specific executor configuration
|
|
166
|
-
fn set_executor_config(env: &Env, sender: &Address, dst_eid: u32, config: &OAppExecutorConfig) {
|
|
166
|
+
pub(super) fn set_executor_config(env: &Env, sender: &Address, dst_eid: u32, config: &OAppExecutorConfig) {
|
|
167
167
|
UlnStorage::set_oapp_executor_configs(env, sender, dst_eid, config);
|
|
168
168
|
ExecutorConfigSet { sender: sender.clone(), dst_eid, config: config.clone() }.publish(env);
|
|
169
169
|
}
|
|
@@ -177,7 +177,7 @@ impl Uln302 {
|
|
|
177
177
|
///
|
|
178
178
|
/// # Panics
|
|
179
179
|
/// Panics if the final effective config is invalid.
|
|
180
|
-
fn set_send_uln_config(env: &Env, sender: &Address, dst_eid: u32, config: &OAppUlnConfig) {
|
|
180
|
+
pub(super) fn set_send_uln_config(env: &Env, sender: &Address, dst_eid: u32, config: &OAppUlnConfig) {
|
|
181
181
|
config.validate_oapp_config(env);
|
|
182
182
|
|
|
183
183
|
UlnStorage::set_oapp_send_uln_configs(env, sender, dst_eid, config);
|
|
@@ -187,7 +187,9 @@ impl Uln302 {
|
|
|
187
187
|
UlnSendConfigSet { sender: sender.clone(), dst_eid, config: config.clone() }.publish(env);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
//
|
|
190
|
+
// ============================================================================================
|
|
191
|
+
// Quote Fee Functions
|
|
192
|
+
// ============================================================================================
|
|
191
193
|
|
|
192
194
|
/// Quotes the executor fee for message execution.
|
|
193
195
|
///
|
|
@@ -241,7 +243,9 @@ impl Uln302 {
|
|
|
241
243
|
.fold(0_i128, |total_fee, (idx, dvn_addr)| total_fee + get_dvn_fee(idx, dvn_addr))
|
|
242
244
|
}
|
|
243
245
|
|
|
244
|
-
//
|
|
246
|
+
// ============================================================================================
|
|
247
|
+
// Assign Job Functions
|
|
248
|
+
// ============================================================================================
|
|
245
249
|
|
|
246
250
|
/// Assigns an executor job and returns the fee recipient.
|
|
247
251
|
///
|
|
@@ -310,7 +314,9 @@ impl Uln302 {
|
|
|
310
314
|
fees
|
|
311
315
|
}
|
|
312
316
|
|
|
313
|
-
//
|
|
317
|
+
// ============================================================================================
|
|
318
|
+
// Helper Functions
|
|
319
|
+
// ============================================================================================
|
|
314
320
|
|
|
315
321
|
/// Gets a validated executor client, ensuring message size is within limits.
|
|
316
322
|
///
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
use crate::interfaces::{ExecutorConfig, OAppExecutorConfig, OAppUlnConfig, UlnConfig};
|
|
2
2
|
use common_macros::storage;
|
|
3
3
|
use soroban_sdk::{Address, BytesN};
|
|
4
|
-
use utils::ttl::DefaultTtlConfigProvider;
|
|
5
4
|
|
|
6
5
|
/// Storage for the Uln302 message library.
|
|
7
|
-
#[storage
|
|
6
|
+
#[storage]
|
|
8
7
|
pub enum UlnStorage {
|
|
9
8
|
/// The endpoint address
|
|
10
9
|
#[instance(Address)]
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
use
|
|
1
|
+
use common_macros::contract_impl;
|
|
2
|
+
use soroban_sdk::{contract, Env};
|
|
2
3
|
|
|
3
4
|
use crate::{errors::Uln302Error, interfaces::UlnConfig};
|
|
4
5
|
|
|
5
6
|
#[contract]
|
|
6
7
|
struct DummyConfig;
|
|
7
8
|
|
|
8
|
-
#[
|
|
9
|
+
#[contract_impl]
|
|
9
10
|
impl DummyConfig {
|
|
10
11
|
pub fn validate_default_config(env: &Env, config: UlnConfig) {
|
|
11
12
|
config.validate_default_config(env);
|
|
@@ -88,25 +88,25 @@ fn test_send_events_emittance() {
|
|
|
88
88
|
assert_eq!(zro_fee_recipients.len(), 0);
|
|
89
89
|
assert_eq!(
|
|
90
90
|
native_fee_recipients.get(0).unwrap(),
|
|
91
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
91
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
92
92
|
);
|
|
93
93
|
assert_eq!(
|
|
94
94
|
native_fee_recipients.get(1).unwrap(),
|
|
95
95
|
FeeRecipient {
|
|
96
96
|
amount: DVN_FEE[0],
|
|
97
|
-
|
|
97
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
100
|
assert_eq!(
|
|
101
101
|
native_fee_recipients.get(2).unwrap(),
|
|
102
102
|
FeeRecipient {
|
|
103
103
|
amount: DVN_FEE[1],
|
|
104
|
-
|
|
104
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(1)).recipient()
|
|
105
105
|
}
|
|
106
106
|
);
|
|
107
107
|
assert_eq!(
|
|
108
108
|
native_fee_recipients.get(3).unwrap(),
|
|
109
|
-
FeeRecipient { amount: TREASURY_NATIVE_FEE,
|
|
109
|
+
FeeRecipient { amount: TREASURY_NATIVE_FEE, to: setup.treasury.address }
|
|
110
110
|
);
|
|
111
111
|
assert_eq!(send_result.encoded_packet, packet_codec_v1::encode_packet(&setup.env, &packet));
|
|
112
112
|
}
|
|
@@ -184,25 +184,25 @@ fn test_send_events_emittance_with_zro() {
|
|
|
184
184
|
assert_eq!(native_fee_recipients.len(), 3);
|
|
185
185
|
assert_eq!(
|
|
186
186
|
native_fee_recipients.get(0).unwrap(),
|
|
187
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
187
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
188
188
|
);
|
|
189
189
|
assert_eq!(
|
|
190
190
|
native_fee_recipients.get(1).unwrap(),
|
|
191
191
|
FeeRecipient {
|
|
192
192
|
amount: DVN_FEE[0],
|
|
193
|
-
|
|
193
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
194
194
|
}
|
|
195
195
|
);
|
|
196
196
|
assert_eq!(
|
|
197
197
|
native_fee_recipients.get(2).unwrap(),
|
|
198
198
|
FeeRecipient {
|
|
199
199
|
amount: DVN_FEE[1],
|
|
200
|
-
|
|
200
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(1)).recipient()
|
|
201
201
|
}
|
|
202
202
|
);
|
|
203
203
|
assert_eq!(
|
|
204
204
|
zro_fee_recipients.get(0).unwrap(),
|
|
205
|
-
FeeRecipient { amount: TREASURY_ZRO_FEE,
|
|
205
|
+
FeeRecipient { amount: TREASURY_ZRO_FEE, to: setup.treasury.address }
|
|
206
206
|
);
|
|
207
207
|
assert_eq!(send_result.encoded_packet, packet_codec_v1::encode_packet(&setup.env, &packet));
|
|
208
208
|
}
|
|
@@ -260,18 +260,18 @@ fn test_send_single_dvn() {
|
|
|
260
260
|
assert_eq!(zro_fee_recipients.len(), 0);
|
|
261
261
|
assert_eq!(
|
|
262
262
|
native_fee_recipients.get(0).unwrap(),
|
|
263
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
263
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
264
264
|
);
|
|
265
265
|
assert_eq!(
|
|
266
266
|
native_fee_recipients.get(1).unwrap(),
|
|
267
267
|
FeeRecipient {
|
|
268
268
|
amount: DVN_FEE[0],
|
|
269
|
-
|
|
269
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
270
270
|
}
|
|
271
271
|
);
|
|
272
272
|
assert_eq!(
|
|
273
273
|
native_fee_recipients.get(2).unwrap(),
|
|
274
|
-
FeeRecipient { amount: TREASURY_NATIVE_FEE,
|
|
274
|
+
FeeRecipient { amount: TREASURY_NATIVE_FEE, to: setup.treasury.address }
|
|
275
275
|
);
|
|
276
276
|
assert_eq!(send_result.encoded_packet, packet_codec_v1::encode_packet(&setup.env, &packet));
|
|
277
277
|
}
|
|
@@ -374,25 +374,25 @@ fn test_send_multiple_dvns() {
|
|
|
374
374
|
assert_eq!(zro_fee_recipients.len(), 0);
|
|
375
375
|
assert_eq!(
|
|
376
376
|
native_fee_recipients.get(0).unwrap(),
|
|
377
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
377
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
378
378
|
);
|
|
379
379
|
assert_eq!(
|
|
380
380
|
native_fee_recipients.get(1).unwrap(),
|
|
381
381
|
FeeRecipient {
|
|
382
382
|
amount: DVN_FEE[0],
|
|
383
|
-
|
|
383
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
384
384
|
}
|
|
385
385
|
);
|
|
386
386
|
assert_eq!(
|
|
387
387
|
native_fee_recipients.get(2).unwrap(),
|
|
388
388
|
FeeRecipient {
|
|
389
389
|
amount: DVN_FEE[1],
|
|
390
|
-
|
|
390
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(1)).recipient()
|
|
391
391
|
}
|
|
392
392
|
);
|
|
393
393
|
assert_eq!(
|
|
394
394
|
native_fee_recipients.get(3).unwrap(),
|
|
395
|
-
FeeRecipient { amount: TREASURY_NATIVE_FEE,
|
|
395
|
+
FeeRecipient { amount: TREASURY_NATIVE_FEE, to: setup.treasury.address }
|
|
396
396
|
);
|
|
397
397
|
assert_eq!(send_result.encoded_packet, packet_codec_v1::encode_packet(&setup.env, &packet));
|
|
398
398
|
}
|
|
@@ -450,18 +450,18 @@ fn test_send_with_only_optional_dvns() {
|
|
|
450
450
|
assert_eq!(zro_fee_recipients.len(), 0);
|
|
451
451
|
assert_eq!(
|
|
452
452
|
native_fee_recipients.get(0).unwrap(),
|
|
453
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
453
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
454
454
|
);
|
|
455
455
|
assert_eq!(
|
|
456
456
|
native_fee_recipients.get(1).unwrap(),
|
|
457
457
|
FeeRecipient {
|
|
458
458
|
amount: DVN_FEE[0],
|
|
459
|
-
|
|
459
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
460
460
|
}
|
|
461
461
|
);
|
|
462
462
|
assert_eq!(
|
|
463
463
|
native_fee_recipients.get(2).unwrap(),
|
|
464
|
-
FeeRecipient { amount: TREASURY_NATIVE_FEE,
|
|
464
|
+
FeeRecipient { amount: TREASURY_NATIVE_FEE, to: setup.treasury.address }
|
|
465
465
|
);
|
|
466
466
|
assert_eq!(send_result.encoded_packet, packet_codec_v1::encode_packet(&setup.env, &packet));
|
|
467
467
|
}
|
|
@@ -624,25 +624,25 @@ fn test_send_with_missing_dvn_options() {
|
|
|
624
624
|
assert_eq!(zro_fee_recipients.len(), 0);
|
|
625
625
|
assert_eq!(
|
|
626
626
|
native_fee_recipients.get(0).unwrap(),
|
|
627
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
627
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
628
628
|
);
|
|
629
629
|
assert_eq!(
|
|
630
630
|
native_fee_recipients.get(1).unwrap(),
|
|
631
631
|
FeeRecipient {
|
|
632
632
|
amount: DVN_FEE[0],
|
|
633
|
-
|
|
633
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
634
634
|
}
|
|
635
635
|
);
|
|
636
636
|
assert_eq!(
|
|
637
637
|
native_fee_recipients.get(2).unwrap(),
|
|
638
638
|
FeeRecipient {
|
|
639
639
|
amount: DVN_FEE[1],
|
|
640
|
-
|
|
640
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(1)).recipient()
|
|
641
641
|
}
|
|
642
642
|
);
|
|
643
643
|
assert_eq!(
|
|
644
644
|
native_fee_recipients.get(3).unwrap(),
|
|
645
|
-
FeeRecipient { amount: TREASURY_NATIVE_FEE,
|
|
645
|
+
FeeRecipient { amount: TREASURY_NATIVE_FEE, to: setup.treasury.address }
|
|
646
646
|
);
|
|
647
647
|
assert_eq!(send_result.encoded_packet, packet_codec_v1::encode_packet(&setup.env, &packet));
|
|
648
648
|
}
|
|
@@ -699,18 +699,18 @@ fn test_send_with_missing_executor_options() {
|
|
|
699
699
|
assert_eq!(zro_fee_recipients.len(), 0);
|
|
700
700
|
assert_eq!(
|
|
701
701
|
native_fee_recipients.get(0).unwrap(),
|
|
702
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
702
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
703
703
|
);
|
|
704
704
|
assert_eq!(
|
|
705
705
|
native_fee_recipients.get(1).unwrap(),
|
|
706
706
|
FeeRecipient {
|
|
707
707
|
amount: DVN_FEE[0],
|
|
708
|
-
|
|
708
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
709
709
|
}
|
|
710
710
|
);
|
|
711
711
|
assert_eq!(
|
|
712
712
|
native_fee_recipients.get(2).unwrap(),
|
|
713
|
-
FeeRecipient { amount: TREASURY_NATIVE_FEE,
|
|
713
|
+
FeeRecipient { amount: TREASURY_NATIVE_FEE, to: setup.treasury.address }
|
|
714
714
|
);
|
|
715
715
|
assert_eq!(send_result.encoded_packet, packet_codec_v1::encode_packet(&setup.env, &packet));
|
|
716
716
|
}
|
|
@@ -797,7 +797,7 @@ fn test_send_derives_from_quote() {
|
|
|
797
797
|
// Verify executor fee is first
|
|
798
798
|
assert_eq!(
|
|
799
799
|
native_fee_recipients.get(0).unwrap(),
|
|
800
|
-
FeeRecipient { amount: EXECUTOR_FEE,
|
|
800
|
+
FeeRecipient { amount: EXECUTOR_FEE, to: DummyExecutorClient::new(&setup.env, &executor).recipient() }
|
|
801
801
|
);
|
|
802
802
|
|
|
803
803
|
// Verify DVN ordering is maintained (required first, then optional)
|
|
@@ -806,7 +806,7 @@ fn test_send_derives_from_quote() {
|
|
|
806
806
|
native_fee_recipients.get(1).unwrap(),
|
|
807
807
|
FeeRecipient {
|
|
808
808
|
amount: DVN_FEE[0],
|
|
809
|
-
|
|
809
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(0)).recipient()
|
|
810
810
|
}
|
|
811
811
|
);
|
|
812
812
|
// DVN 1 (second required)
|
|
@@ -814,7 +814,7 @@ fn test_send_derives_from_quote() {
|
|
|
814
814
|
native_fee_recipients.get(2).unwrap(),
|
|
815
815
|
FeeRecipient {
|
|
816
816
|
amount: DVN_FEE[1],
|
|
817
|
-
|
|
817
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(1)).recipient()
|
|
818
818
|
}
|
|
819
819
|
);
|
|
820
820
|
// DVN 2 (optional)
|
|
@@ -822,13 +822,13 @@ fn test_send_derives_from_quote() {
|
|
|
822
822
|
native_fee_recipients.get(3).unwrap(),
|
|
823
823
|
FeeRecipient {
|
|
824
824
|
amount: DVN_FEE[2],
|
|
825
|
-
|
|
825
|
+
to: DummyDVNClient::new(&setup.env, &dvns.get_unchecked(2)).recipient()
|
|
826
826
|
}
|
|
827
827
|
);
|
|
828
828
|
|
|
829
829
|
// Treasury fee is last
|
|
830
830
|
assert_eq!(
|
|
831
831
|
native_fee_recipients.get(4).unwrap(),
|
|
832
|
-
FeeRecipient { amount: TREASURY_NATIVE_FEE,
|
|
832
|
+
FeeRecipient { amount: TREASURY_NATIVE_FEE, to: setup.treasury.address }
|
|
833
833
|
);
|
|
834
834
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
use endpoint_v2::{FeeRecipient, MessageLibClient, MessageLibManagerClient, Origin, SetConfigParam};
|
|
2
|
-
use message_lib_common::{ILayerZeroDVN, ILayerZeroExecutor, ILayerZeroTreasury};
|
|
2
|
+
use message_lib_common::interfaces::{ILayerZeroDVN, ILayerZeroExecutor, ILayerZeroTreasury};
|
|
3
|
+
use common_macros::contract_impl;
|
|
3
4
|
use soroban_sdk::{
|
|
4
|
-
contract,
|
|
5
|
+
contract, log, symbol_short,
|
|
5
6
|
testutils::{Address as _, MockAuth, MockAuthInvoke},
|
|
6
7
|
vec, Address, Bytes, BytesN, Env, IntoVal, Vec,
|
|
7
8
|
};
|
|
@@ -34,7 +35,7 @@ pub struct TestSetup<'a> {
|
|
|
34
35
|
#[contract]
|
|
35
36
|
struct DummyEndpoint;
|
|
36
37
|
|
|
37
|
-
#[
|
|
38
|
+
#[contract_impl]
|
|
38
39
|
impl DummyEndpoint {
|
|
39
40
|
pub fn eid(_env: &Env) -> u32 {
|
|
40
41
|
LOCAL_EID
|
|
@@ -53,7 +54,7 @@ impl DummyEndpoint {
|
|
|
53
54
|
#[contract]
|
|
54
55
|
struct DummyDVN;
|
|
55
56
|
|
|
56
|
-
#[
|
|
57
|
+
#[contract_impl]
|
|
57
58
|
impl DummyDVN {
|
|
58
59
|
pub fn __constructor(env: &Env, fee: i128) {
|
|
59
60
|
env.storage().persistent().set(&symbol_short!("fee"), &fee);
|
|
@@ -69,7 +70,7 @@ impl DummyDVN {
|
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
#[
|
|
73
|
+
#[contract_impl]
|
|
73
74
|
impl ILayerZeroDVN for DummyDVN {
|
|
74
75
|
fn get_fee(
|
|
75
76
|
env: &Env,
|
|
@@ -95,7 +96,7 @@ impl ILayerZeroDVN for DummyDVN {
|
|
|
95
96
|
_options: &Bytes,
|
|
96
97
|
) -> FeeRecipient {
|
|
97
98
|
FeeRecipient {
|
|
98
|
-
|
|
99
|
+
to: env.storage().persistent().get(&symbol_short!("recipient")).unwrap(),
|
|
99
100
|
amount: env.storage().persistent().get(&symbol_short!("fee")).unwrap(),
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -104,7 +105,7 @@ impl ILayerZeroDVN for DummyDVN {
|
|
|
104
105
|
#[contract]
|
|
105
106
|
struct DummyExecutor;
|
|
106
107
|
|
|
107
|
-
#[
|
|
108
|
+
#[contract_impl]
|
|
108
109
|
impl DummyExecutor {
|
|
109
110
|
pub fn __constructor(env: &Env, fee: i128) {
|
|
110
111
|
env.storage().persistent().set(&symbol_short!("fee"), &fee);
|
|
@@ -116,7 +117,7 @@ impl DummyExecutor {
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
#[
|
|
120
|
+
#[contract_impl]
|
|
120
121
|
impl ILayerZeroExecutor for DummyExecutor {
|
|
121
122
|
fn get_fee(
|
|
122
123
|
env: &Env,
|
|
@@ -138,7 +139,7 @@ impl ILayerZeroExecutor for DummyExecutor {
|
|
|
138
139
|
_options: &Bytes,
|
|
139
140
|
) -> FeeRecipient {
|
|
140
141
|
FeeRecipient {
|
|
141
|
-
|
|
142
|
+
to: env.storage().persistent().get(&symbol_short!("recipient")).unwrap(),
|
|
142
143
|
amount: env.storage().persistent().get(&symbol_short!("fee")).unwrap(),
|
|
143
144
|
}
|
|
144
145
|
}
|
|
@@ -147,7 +148,7 @@ impl ILayerZeroExecutor for DummyExecutor {
|
|
|
147
148
|
#[contract]
|
|
148
149
|
struct DummyTreasury;
|
|
149
150
|
|
|
150
|
-
#[
|
|
151
|
+
#[contract_impl]
|
|
151
152
|
impl DummyTreasury {
|
|
152
153
|
pub fn __constructor(env: &Env, native_fee: i128, zro_fee: i128) {
|
|
153
154
|
env.storage().persistent().set(&symbol_short!("nt_fee"), &native_fee);
|
|
@@ -171,7 +172,7 @@ impl DummyTreasury {
|
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
#[
|
|
175
|
+
#[contract_impl]
|
|
175
176
|
impl ILayerZeroTreasury for DummyTreasury {
|
|
176
177
|
fn get_fee(env: &Env, _sender: &Address, _dst_eid: u32, _total_native_fee: i128, pay_in_zro: bool) -> i128 {
|
|
177
178
|
if pay_in_zro {
|
|
@@ -3,10 +3,10 @@ use endpoint_v2::{MessageLibVersion, SetConfigParam};
|
|
|
3
3
|
use soroban_sdk::{testutils::Address as _, vec, xdr::ToXdr, Address};
|
|
4
4
|
|
|
5
5
|
use crate::{
|
|
6
|
-
config_validation::MAX_DVNS,
|
|
7
6
|
errors::Uln302Error,
|
|
8
7
|
interfaces::{ExecutorConfig, OAppUlnConfig, UlnConfig},
|
|
9
8
|
tests::setup::{setup, TestSetup},
|
|
9
|
+
types::MAX_DVNS,
|
|
10
10
|
uln302::{CONFIG_TYPE_RECEIVE_ULN, CONFIG_TYPE_SEND_ULN},
|
|
11
11
|
Uln302Client,
|
|
12
12
|
};
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
use crate::errors::Uln302Error;
|
|
2
|
-
use
|
|
3
|
-
use crate::OAppExecutorConfig;
|
|
4
|
-
use soroban_sdk::{assert_with_error, map, vec, Env, IntoVal, TryFromVal, Val, Vec};
|
|
2
|
+
use soroban_sdk::{assert_with_error, contracttype, map, vec, Address, Env, IntoVal, TryFromVal, Val, Vec};
|
|
5
3
|
|
|
6
4
|
/// Maximum number of DVNs allowed in a configuration.
|
|
7
5
|
pub const MAX_DVNS: u32 = 127;
|
|
8
6
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
7
|
+
// ============================================================================================
|
|
8
|
+
// ULN Config Types
|
|
9
|
+
// ============================================================================================
|
|
10
|
+
|
|
11
|
+
/// Ultra Light Node configuration for message verification.
|
|
12
|
+
#[contracttype]
|
|
13
|
+
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
14
|
+
pub struct UlnConfig {
|
|
15
|
+
/// Number of block confirmations required before message verification begins.
|
|
16
|
+
pub confirmations: u64,
|
|
17
|
+
/// List of DVN addresses that must ALL verify the message (no threshold).
|
|
18
|
+
pub required_dvns: Vec<Address>,
|
|
19
|
+
/// List of DVN addresses from which a threshold number must verify.
|
|
20
|
+
pub optional_dvns: Vec<Address>,
|
|
21
|
+
/// Minimum number of optional DVNs required to verify.
|
|
22
|
+
pub optional_dvn_threshold: u32,
|
|
23
|
+
}
|
|
12
24
|
|
|
13
25
|
impl UlnConfig {
|
|
14
26
|
/// Validates the required DVNs configuration.
|
|
@@ -64,6 +76,20 @@ impl UlnConfig {
|
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
78
|
|
|
79
|
+
/// OApp-specific ULN configuration with default override flags.
|
|
80
|
+
#[contracttype]
|
|
81
|
+
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
82
|
+
pub struct OAppUlnConfig {
|
|
83
|
+
/// Whether to use default confirmations.
|
|
84
|
+
pub use_default_confirmations: bool,
|
|
85
|
+
/// Whether to use default required DVNs.
|
|
86
|
+
pub use_default_required_dvns: bool,
|
|
87
|
+
/// Whether to use default optional DVNs.
|
|
88
|
+
pub use_default_optional_dvns: bool,
|
|
89
|
+
/// OApp-specific ULN configuration (used when defaults are not applied).
|
|
90
|
+
pub uln_config: UlnConfig,
|
|
91
|
+
}
|
|
92
|
+
|
|
67
93
|
impl OAppUlnConfig {
|
|
68
94
|
/// Creates a default OAppUlnConfig that uses all default values.
|
|
69
95
|
pub fn default(env: &Env) -> Self {
|
|
@@ -128,9 +154,29 @@ impl OAppUlnConfig {
|
|
|
128
154
|
}
|
|
129
155
|
}
|
|
130
156
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
157
|
+
/// Parameter for setting default ULN configuration for a destination/source endpoint.
|
|
158
|
+
#[contracttype]
|
|
159
|
+
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
160
|
+
pub struct SetDefaultUlnConfigParam {
|
|
161
|
+
/// The destination endpoint ID (for send) or source endpoint ID (for receive).
|
|
162
|
+
pub dst_eid: u32,
|
|
163
|
+
/// The ULN configuration to set as default.
|
|
164
|
+
pub config: UlnConfig,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ============================================================================================
|
|
168
|
+
// Executor Config Types
|
|
169
|
+
// ============================================================================================
|
|
170
|
+
|
|
171
|
+
/// Executor configuration for message delivery.
|
|
172
|
+
#[contracttype]
|
|
173
|
+
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
174
|
+
pub struct ExecutorConfig {
|
|
175
|
+
/// Maximum size of messages that can be executed (in bytes).
|
|
176
|
+
pub max_message_size: u32,
|
|
177
|
+
/// Address of the executor contract responsible for message execution.
|
|
178
|
+
pub executor: Address,
|
|
179
|
+
}
|
|
134
180
|
|
|
135
181
|
impl ExecutorConfig {
|
|
136
182
|
/// Validates the executor config for use as a default configuration.
|
|
@@ -139,6 +185,18 @@ impl ExecutorConfig {
|
|
|
139
185
|
}
|
|
140
186
|
}
|
|
141
187
|
|
|
188
|
+
/// OApp-specific executor configuration.
|
|
189
|
+
///
|
|
190
|
+
/// If executor is `None`, the default executor is used.
|
|
191
|
+
#[contracttype]
|
|
192
|
+
#[derive(Clone, Default, Eq, PartialEq, Debug)]
|
|
193
|
+
pub struct OAppExecutorConfig {
|
|
194
|
+
/// Maximum size of messages that can be executed (in bytes). 0 means use default configuration.
|
|
195
|
+
pub max_message_size: u32,
|
|
196
|
+
/// Address of the executor contract to be used for message execution. None means use default configuration.
|
|
197
|
+
pub executor: Option<Address>,
|
|
198
|
+
}
|
|
199
|
+
|
|
142
200
|
impl OAppExecutorConfig {
|
|
143
201
|
/// Merges this OAppExecutorConfig with a default ExecutorConfig to produce the effective config.
|
|
144
202
|
pub fn apply_default_config(&self, default_config: &ExecutorConfig) -> ExecutorConfig {
|
|
@@ -153,9 +211,19 @@ impl OAppExecutorConfig {
|
|
|
153
211
|
}
|
|
154
212
|
}
|
|
155
213
|
|
|
156
|
-
|
|
214
|
+
/// Parameter for setting default executor configuration for a destination endpoint.
|
|
215
|
+
#[contracttype]
|
|
216
|
+
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
217
|
+
pub struct SetDefaultExecutorConfigParam {
|
|
218
|
+
/// The destination endpoint ID.
|
|
219
|
+
pub dst_eid: u32,
|
|
220
|
+
/// The executor configuration to set as default.
|
|
221
|
+
pub config: ExecutorConfig,
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ============================================================================================
|
|
157
225
|
// Helper Functions
|
|
158
|
-
//
|
|
226
|
+
// ============================================================================================
|
|
159
227
|
|
|
160
228
|
/// Checks if a vector contains duplicate elements.
|
|
161
229
|
fn has_duplicates<T>(env: &Env, items: &Vec<T>) -> bool
|
|
@@ -10,14 +10,15 @@ use crate::{
|
|
|
10
10
|
},
|
|
11
11
|
storage::UlnStorage,
|
|
12
12
|
};
|
|
13
|
-
use common_macros::{only_owner, ttl_configurable};
|
|
13
|
+
use common_macros::{contract_impl, only_owner, ttl_configurable};
|
|
14
14
|
use endpoint_v2::{
|
|
15
15
|
util, FeeRecipient, FeesAndPacket, IMessageLib, ISendLib, LayerZeroEndpointV2Client, MessageLibType,
|
|
16
16
|
MessageLibVersion, MessagingFee, Origin, OutboundPacket, SetConfigParam,
|
|
17
17
|
};
|
|
18
18
|
use message_lib_common::{
|
|
19
|
+
interfaces::{LayerZeroDVNClient, LayerZeroExecutorClient, LayerZeroTreasuryClient},
|
|
19
20
|
packet_codec_v1::{self, PacketHeader},
|
|
20
|
-
worker_options,
|
|
21
|
+
worker_options,
|
|
21
22
|
};
|
|
22
23
|
use soroban_sdk::{
|
|
23
24
|
address_payload::AddressPayload,
|
|
@@ -35,15 +36,17 @@ pub const CONFIG_TYPE_RECEIVE_ULN: u32 = 3;
|
|
|
35
36
|
#[ttl_configurable]
|
|
36
37
|
pub struct Uln302;
|
|
37
38
|
|
|
38
|
-
#[
|
|
39
|
+
#[contract_impl]
|
|
39
40
|
impl Uln302 {
|
|
40
41
|
pub fn __constructor(env: &Env, owner: &Address, endpoint: &Address, treasury: &Address) {
|
|
41
|
-
Self::
|
|
42
|
+
Self::init_owner(env, owner);
|
|
42
43
|
UlnStorage::set_endpoint(env, endpoint);
|
|
43
44
|
UlnStorage::set_treasury(env, treasury);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
//
|
|
47
|
+
// ============================================================================================
|
|
48
|
+
// View Functions
|
|
49
|
+
// ============================================================================================
|
|
47
50
|
|
|
48
51
|
/// Returns the LayerZero endpoint contract address.
|
|
49
52
|
pub fn endpoint(env: &Env) -> Address {
|
|
@@ -51,7 +54,7 @@ impl Uln302 {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
#[contractimpl]
|
|
57
|
+
#[contractimpl(contracttrait)]
|
|
55
58
|
impl IMessageLib for Uln302 {
|
|
56
59
|
/// Sets OApp-specific configuration parameters for the message library.
|
|
57
60
|
///
|
|
@@ -104,14 +107,16 @@ impl IMessageLib for Uln302 {
|
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
|
|
107
|
-
//
|
|
110
|
+
// ============================================================================================
|
|
108
111
|
// Helper Functions
|
|
109
|
-
//
|
|
112
|
+
// ============================================================================================
|
|
110
113
|
|
|
111
114
|
/// Parse a config from XDR bytes, panicking with InvalidConfig error if parsing fails
|
|
112
115
|
fn parse_config<T: FromXdr>(env: &Env, config_bytes: &Bytes) -> T {
|
|
113
116
|
T::from_xdr(env, config_bytes).ok().unwrap_or_panic(env, Uln302Error::InvalidConfig)
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
#[path = "receive_uln.rs"]
|
|
120
|
+
mod receive_uln;
|
|
121
|
+
#[path = "send_uln.rs"]
|
|
122
|
+
mod send_uln;
|
|
@@ -9,13 +9,7 @@ publish = false
|
|
|
9
9
|
proc-macro = true
|
|
10
10
|
|
|
11
11
|
[dependencies]
|
|
12
|
+
heck = "0.5"
|
|
12
13
|
proc-macro2 = "1.0"
|
|
13
14
|
quote = "1.0"
|
|
14
|
-
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
|
15
|
-
|
|
16
|
-
[dev-dependencies]
|
|
17
|
-
oapp = { workspace = true }
|
|
18
|
-
soroban-sdk = { workspace = true, features = ["testutils"] }
|
|
19
|
-
common-macros = { workspace = true }
|
|
20
|
-
utils = { workspace = true }
|
|
21
|
-
endpoint-v2 = { workspace = true , features = ["library"]}
|
|
15
|
+
syn = { version = "2.0", features = ["full", "extra-traits"] }
|