@layerzerolabs/protocol-stellar-v2 0.2.8 → 0.2.9
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,21 +1,18 @@
|
|
|
1
1
|
use crate::{errors::SimpleMessageLibError, storage::SmlStorage};
|
|
2
|
-
use common_macros::ttl_configurable;
|
|
2
|
+
use common_macros::{contract_impl, only_owner, ttl_configurable};
|
|
3
3
|
use endpoint_v2::{
|
|
4
4
|
FeeRecipient, FeesAndPacket, IMessageLib, ISendLib, LayerZeroEndpointV2Client, MessageLibType, MessageLibVersion,
|
|
5
5
|
MessagingFee, Origin, OutboundPacket, SetConfigParam,
|
|
6
6
|
};
|
|
7
7
|
use message_lib_common::packet_codec_v1;
|
|
8
|
-
use soroban_sdk::{
|
|
9
|
-
address_payload::AddressPayload, assert_with_error, contract, contractimpl, panic_with_error, vec, Address, Bytes,
|
|
10
|
-
BytesN, Env, Vec,
|
|
11
|
-
};
|
|
8
|
+
use soroban_sdk::{address_payload::AddressPayload, contract, panic_with_error, vec, Address, Bytes, BytesN, Env, Vec};
|
|
12
9
|
use utils::ownable::Ownable;
|
|
13
10
|
|
|
14
11
|
#[contract]
|
|
15
12
|
#[ttl_configurable]
|
|
16
13
|
pub struct SimpleMessageLib;
|
|
17
14
|
|
|
18
|
-
#[
|
|
15
|
+
#[contract_impl]
|
|
19
16
|
impl SimpleMessageLib {
|
|
20
17
|
pub fn __constructor(env: &Env, owner: &Address, endpoint: &Address, fee_recipient: &Address) {
|
|
21
18
|
let endpoint_client = LayerZeroEndpointV2Client::new(env, endpoint);
|
|
@@ -27,52 +24,71 @@ impl SimpleMessageLib {
|
|
|
27
24
|
SmlStorage::set_native_fee(env, &100_i128);
|
|
28
25
|
SmlStorage::set_fee_recipient(env, fee_recipient);
|
|
29
26
|
SmlStorage::set_whitelisted_caller(env, owner);
|
|
30
|
-
|
|
27
|
+
|
|
28
|
+
Self::init_owner(env, owner);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
pub fn validate_packet(env: Env,
|
|
34
|
-
|
|
35
|
-
assert_with_error!(
|
|
36
|
-
env,
|
|
37
|
-
Some(caller) == SmlStorage::whitelisted_caller(&env),
|
|
38
|
-
SimpleMessageLibError::OnlyWhitelistedCaller
|
|
39
|
-
);
|
|
31
|
+
pub fn validate_packet(env: &Env, header_bytes: Bytes, payload_hash: BytesN<32>) {
|
|
32
|
+
Self::whitelisted_caller(env).require_auth();
|
|
40
33
|
|
|
41
|
-
let header = packet_codec_v1::decode_packet_header(
|
|
34
|
+
let header = packet_codec_v1::decode_packet_header(env, &header_bytes);
|
|
42
35
|
let origin = Origin { src_eid: header.src_eid, sender: header.sender, nonce: header.nonce };
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
// Enforce receiver is a contract address
|
|
38
|
+
let receiver = Address::from_payload(env, AddressPayload::ContractIdHash(header.receiver));
|
|
39
|
+
Self::endpoint_client(env).verify(&env.current_contract_address(), &origin, &receiver, &payload_hash);
|
|
46
40
|
}
|
|
47
41
|
|
|
48
|
-
//
|
|
42
|
+
// ============================================================================================
|
|
43
|
+
// Admin Manager
|
|
44
|
+
// ============================================================================================
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
#[only_owner]
|
|
47
|
+
pub fn set_fee_recipient(env: &Env, fee_recipient: &Address) {
|
|
48
|
+
SmlStorage::set_fee_recipient(env, fee_recipient);
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
#[only_owner]
|
|
52
|
+
pub fn set_native_fee(env: &Env, native_fee: &i128) {
|
|
53
|
+
SmlStorage::set_native_fee(env, native_fee);
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
#[only_owner]
|
|
57
|
+
pub fn set_zro_fee(env: &Env, zro_fee: &i128) {
|
|
58
|
+
SmlStorage::set_zro_fee(env, zro_fee);
|
|
60
59
|
}
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
#[only_owner]
|
|
62
|
+
pub fn set_whitelisted_caller(env: &Env, whitelisted_caller: &Address) {
|
|
63
|
+
SmlStorage::set_whitelisted_caller(env, whitelisted_caller);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// ============================================================================================
|
|
67
|
+
// View Functions
|
|
68
|
+
// ============================================================================================
|
|
69
|
+
|
|
66
70
|
pub fn endpoint(env: &Env) -> Address {
|
|
67
71
|
SmlStorage::endpoint(env).unwrap()
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
pub fn
|
|
74
|
+
pub fn local_eid(env: &Env) -> u32 {
|
|
71
75
|
SmlStorage::local_eid(env).unwrap()
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
pub fn
|
|
75
|
-
SmlStorage::
|
|
78
|
+
pub fn native_fee(env: &Env) -> i128 {
|
|
79
|
+
SmlStorage::native_fee(env).unwrap()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
pub fn zro_fee(env: &Env) -> i128 {
|
|
83
|
+
SmlStorage::zro_fee(env).unwrap()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
pub fn fee_recipient(env: &Env) -> Address {
|
|
87
|
+
SmlStorage::fee_recipient(env).unwrap()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pub fn whitelisted_caller(env: &Env) -> Address {
|
|
91
|
+
SmlStorage::whitelisted_caller(env).unwrap()
|
|
76
92
|
}
|
|
77
93
|
|
|
78
94
|
// ==== Internal helpers ====
|
|
@@ -86,7 +102,7 @@ impl SimpleMessageLib {
|
|
|
86
102
|
}
|
|
87
103
|
}
|
|
88
104
|
|
|
89
|
-
#[
|
|
105
|
+
#[contract_impl]
|
|
90
106
|
impl IMessageLib for SimpleMessageLib {
|
|
91
107
|
fn get_config(env: &Env, _eid: u32, _oapp: &Address, _config_type: u32) -> Bytes {
|
|
92
108
|
panic_with_error!(env, SimpleMessageLibError::NotImplemented);
|
|
@@ -109,7 +125,7 @@ impl IMessageLib for SimpleMessageLib {
|
|
|
109
125
|
}
|
|
110
126
|
}
|
|
111
127
|
|
|
112
|
-
#[
|
|
128
|
+
#[contract_impl]
|
|
113
129
|
impl ISendLib for SimpleMessageLib {
|
|
114
130
|
fn quote(env: &Env, _packet: &OutboundPacket, _options: &Bytes, pay_in_zro: bool) -> MessagingFee {
|
|
115
131
|
MessagingFee { native_fee: Self::native_fee(env), zro_fee: if pay_in_zro { Self::zro_fee(env) } else { 0 } }
|
|
@@ -119,12 +135,11 @@ impl ISendLib for SimpleMessageLib {
|
|
|
119
135
|
Self::require_endpoint_auth(env);
|
|
120
136
|
|
|
121
137
|
let native_fee_recipients =
|
|
122
|
-
vec![env, FeeRecipient {
|
|
138
|
+
vec![env, FeeRecipient { to: Self::fee_recipient(env), amount: Self::native_fee(env) }];
|
|
123
139
|
|
|
124
140
|
let mut zro_fee_recipients = vec![env];
|
|
125
141
|
if pay_in_zro {
|
|
126
|
-
zro_fee_recipients
|
|
127
|
-
.push_back(FeeRecipient { address: Self::fee_recipient(env), amount: Self::zro_fee(env) });
|
|
142
|
+
zro_fee_recipients.push_back(FeeRecipient { to: Self::fee_recipient(env), amount: Self::zro_fee(env) });
|
|
128
143
|
}
|
|
129
144
|
|
|
130
145
|
FeesAndPacket {
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
use common_macros::storage;
|
|
2
2
|
use soroban_sdk::Address;
|
|
3
|
-
use utils::ttl::DefaultTtlConfigProvider;
|
|
4
3
|
|
|
5
|
-
#[storage
|
|
4
|
+
#[storage]
|
|
6
5
|
pub enum SmlStorage {
|
|
7
6
|
#[instance(Address)]
|
|
8
7
|
Endpoint,
|
|
9
8
|
|
|
10
|
-
#[instance(Address)]
|
|
11
|
-
Treasury,
|
|
12
|
-
|
|
13
9
|
#[instance(u32)]
|
|
14
|
-
|
|
10
|
+
LocalEid,
|
|
15
11
|
|
|
16
12
|
#[instance(i128)]
|
|
17
13
|
NativeFee,
|
|
18
14
|
|
|
19
15
|
#[instance(i128)]
|
|
20
|
-
|
|
16
|
+
ZroFee,
|
|
21
17
|
|
|
22
18
|
#[instance(Address)]
|
|
23
19
|
FeeRecipient,
|
|
@@ -166,7 +166,7 @@ fn test_send_returns_native_fee_recipient() {
|
|
|
166
166
|
assert_eq!(send_result.zro_fee_recipients.len(), 0);
|
|
167
167
|
|
|
168
168
|
let native_recipient = send_result.native_fee_recipients.get(0).unwrap();
|
|
169
|
-
assert_eq!(native_recipient.
|
|
169
|
+
assert_eq!(native_recipient.to, fee_recipient);
|
|
170
170
|
assert_eq!(native_recipient.amount, 100); // native_fee from setup
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -209,11 +209,11 @@ fn test_send_returns_both_fee_recipients_with_zro() {
|
|
|
209
209
|
assert_eq!(send_result.zro_fee_recipients.len(), 1);
|
|
210
210
|
|
|
211
211
|
let native_recipient = send_result.native_fee_recipients.get(0).unwrap();
|
|
212
|
-
assert_eq!(native_recipient.
|
|
212
|
+
assert_eq!(native_recipient.to, fee_recipient);
|
|
213
213
|
assert_eq!(native_recipient.amount, 100); // native_fee
|
|
214
214
|
|
|
215
215
|
let zro_recipient = send_result.zro_fee_recipients.get(0).unwrap();
|
|
216
|
-
assert_eq!(zro_recipient.
|
|
216
|
+
assert_eq!(zro_recipient.to, fee_recipient);
|
|
217
217
|
assert_eq!(zro_recipient.amount, 99); // zro_fee from setup
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
use common_macros::storage;
|
|
2
2
|
use soroban_sdk::Address;
|
|
3
|
-
use utils::ttl::DefaultTtlConfigProvider;
|
|
4
3
|
|
|
5
|
-
#[storage
|
|
4
|
+
#[storage]
|
|
6
5
|
pub enum TreasuryStorage {
|
|
7
6
|
/// Native fee in basis points (0-10000, where 10000 = 100%)
|
|
8
7
|
#[instance(u32)]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
use common_macros::contract_impl;
|
|
1
2
|
use soroban_sdk::{
|
|
2
|
-
contract,
|
|
3
|
+
contract,
|
|
3
4
|
testutils::{Address as _, MockAuth, MockAuthInvoke},
|
|
4
5
|
token, Address, Env, IntoVal, Val, Vec,
|
|
5
6
|
};
|
|
@@ -18,7 +19,7 @@ pub const BPS_DENOMINATOR: u32 = 10000;
|
|
|
18
19
|
#[contract]
|
|
19
20
|
pub struct DummyContract;
|
|
20
21
|
|
|
21
|
-
#[
|
|
22
|
+
#[contract_impl]
|
|
22
23
|
impl DummyContract {
|
|
23
24
|
pub fn __constructor(_env: &Env) {}
|
|
24
25
|
}
|
|
@@ -145,19 +145,6 @@ fn test_set_zro_fee_lib() {
|
|
|
145
145
|
assert!(setup.treasury.zro_fee_lib().is_none());
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
#[test]
|
|
149
|
-
fn test_set_zro_fee_lib_invalid_address() {
|
|
150
|
-
let setup = setup();
|
|
151
|
-
|
|
152
|
-
// Generate an address that doesn't exist (won't pass .exists() check)
|
|
153
|
-
let non_existent_lib = soroban_sdk::Address::generate(&setup.env);
|
|
154
|
-
|
|
155
|
-
// Try to set non-existent fee lib
|
|
156
|
-
setup.mock_owner_auth("set_zro_fee_lib", (&Some(non_existent_lib.clone()),));
|
|
157
|
-
let result = setup.treasury.try_set_zro_fee_lib(&Some(non_existent_lib));
|
|
158
|
-
assert_eq!(result.err().unwrap().ok().unwrap(), TreasuryError::InvalidZROFeeLib.into());
|
|
159
|
-
}
|
|
160
|
-
|
|
161
148
|
// ============================================================================
|
|
162
149
|
// Edge Cases & Boundary Tests
|
|
163
150
|
// ============================================================================
|
|
@@ -4,9 +4,9 @@ use crate::{
|
|
|
4
4
|
interfaces::ZROFeeLibClient,
|
|
5
5
|
storage::TreasuryStorage,
|
|
6
6
|
};
|
|
7
|
-
use common_macros::{only_owner, ttl_configurable};
|
|
8
|
-
use message_lib_common::ILayerZeroTreasury;
|
|
9
|
-
use soroban_sdk::{assert_with_error, contract,
|
|
7
|
+
use common_macros::{contract_impl, only_owner, ttl_configurable};
|
|
8
|
+
use message_lib_common::interfaces::ILayerZeroTreasury;
|
|
9
|
+
use soroban_sdk::{assert_with_error, contract, token::Client, Address, Env};
|
|
10
10
|
use utils::option_ext::OptionExt;
|
|
11
11
|
|
|
12
12
|
/// Denominator for basis point calculations (10000 = 100%).
|
|
@@ -16,13 +16,15 @@ const BPS_DENOMINATOR: u32 = 10000;
|
|
|
16
16
|
#[ttl_configurable]
|
|
17
17
|
pub struct Treasury;
|
|
18
18
|
|
|
19
|
-
#[
|
|
19
|
+
#[contract_impl]
|
|
20
20
|
impl Treasury {
|
|
21
21
|
pub fn __constructor(env: &Env, owner: &Address) {
|
|
22
|
-
Self::
|
|
22
|
+
Self::init_owner(env, owner);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
//
|
|
25
|
+
// ============================================================================================
|
|
26
|
+
// Owner Management Functions
|
|
27
|
+
// ============================================================================================
|
|
26
28
|
|
|
27
29
|
/// Sets the native fee percentage in basis points.
|
|
28
30
|
///
|
|
@@ -51,16 +53,7 @@ impl Treasury {
|
|
|
51
53
|
/// * `zro_fee_lib` - The ZRO fee library contract address, or `None` to remove
|
|
52
54
|
#[only_owner]
|
|
53
55
|
pub fn set_zro_fee_lib(env: &Env, zro_fee_lib: &Option<Address>) {
|
|
54
|
-
|
|
55
|
-
assert_with_error!(
|
|
56
|
-
env,
|
|
57
|
-
matches!(lib.executable(), Some(Executable::Wasm(_))),
|
|
58
|
-
TreasuryError::InvalidZROFeeLib
|
|
59
|
-
);
|
|
60
|
-
TreasuryStorage::set_zro_fee_lib(env, lib);
|
|
61
|
-
} else {
|
|
62
|
-
TreasuryStorage::remove_zro_fee_lib(env);
|
|
63
|
-
}
|
|
56
|
+
TreasuryStorage::set_or_remove_zro_fee_lib(env, zro_fee_lib);
|
|
64
57
|
ZROFeeLibSet { zro_fee_lib: zro_fee_lib.clone() }.publish(env);
|
|
65
58
|
}
|
|
66
59
|
|
|
@@ -80,7 +73,9 @@ impl Treasury {
|
|
|
80
73
|
TokenWithdrawn { token: token.clone(), to: to.clone(), amount }.publish(env);
|
|
81
74
|
}
|
|
82
75
|
|
|
83
|
-
//
|
|
76
|
+
// ============================================================================================
|
|
77
|
+
// View Functions
|
|
78
|
+
// ============================================================================================
|
|
84
79
|
|
|
85
80
|
/// Returns the native fee percentage in basis points.
|
|
86
81
|
pub fn native_fee_bp(env: &Env) -> u32 {
|
|
@@ -97,7 +92,9 @@ impl Treasury {
|
|
|
97
92
|
TreasuryStorage::zro_fee_lib(env)
|
|
98
93
|
}
|
|
99
94
|
|
|
100
|
-
//
|
|
95
|
+
// ============================================================================================
|
|
96
|
+
// Internal Functions
|
|
97
|
+
// ============================================================================================
|
|
101
98
|
|
|
102
99
|
/// Calculates the treasury fee based on the total native fee and configured basis points.
|
|
103
100
|
fn calculate_native_fee(env: &Env, total_native_fee: i128) -> i128 {
|
|
@@ -105,7 +102,7 @@ impl Treasury {
|
|
|
105
102
|
}
|
|
106
103
|
|
|
107
104
|
/// Returns the ZRO fee library client, panics if not set.
|
|
108
|
-
fn
|
|
105
|
+
fn expect_zro_fee_lib_client(env: &Env) -> ZROFeeLibClient<'static> {
|
|
109
106
|
let fee_lib = Self::zro_fee_lib(env).unwrap_or_panic(env, TreasuryError::ZROFeeLibNotSet);
|
|
110
107
|
ZROFeeLibClient::new(env, &fee_lib)
|
|
111
108
|
}
|
|
@@ -115,7 +112,7 @@ impl Treasury {
|
|
|
115
112
|
// ILayerZeroTreasury Implementation
|
|
116
113
|
// ============================================================================
|
|
117
114
|
|
|
118
|
-
#[
|
|
115
|
+
#[contract_impl]
|
|
119
116
|
impl ILayerZeroTreasury for Treasury {
|
|
120
117
|
/// Get the treasury fee for a cross-chain message.
|
|
121
118
|
///
|
|
@@ -130,7 +127,7 @@ impl ILayerZeroTreasury for Treasury {
|
|
|
130
127
|
let native_treasury_fee = Self::calculate_native_fee(env, total_native_fee);
|
|
131
128
|
if pay_in_zro {
|
|
132
129
|
let zro_fee =
|
|
133
|
-
Self::
|
|
130
|
+
Self::expect_zro_fee_lib_client(env).get_fee(sender, &dst_eid, &total_native_fee, &native_treasury_fee);
|
|
134
131
|
assert_with_error!(env, zro_fee >= 0, TreasuryError::InvalidZROFee);
|
|
135
132
|
zro_fee
|
|
136
133
|
} else {
|
|
@@ -24,5 +24,6 @@ message-lib-common = { workspace = true }
|
|
|
24
24
|
|
|
25
25
|
[dev-dependencies]
|
|
26
26
|
soroban-sdk = { workspace = true, features = ["testutils"] }
|
|
27
|
+
endpoint-v2 = { workspace = true, features = ["testutils"] }
|
|
27
28
|
message-lib-common = { workspace = true, features = ["testutils"] }
|
|
28
29
|
utils = { workspace = true, features = ["testutils"] }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
mod receive_uln;
|
|
2
|
+
mod send_uln;
|
|
3
3
|
|
|
4
|
-
pub use
|
|
5
|
-
pub use
|
|
4
|
+
pub use receive_uln::*;
|
|
5
|
+
pub use send_uln::*;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
use crate::
|
|
2
|
-
use soroban_sdk::{
|
|
1
|
+
use crate::types::{OAppUlnConfig, SetDefaultUlnConfigParam, UlnConfig};
|
|
2
|
+
use soroban_sdk::{contracttrait, Address, Bytes, BytesN, Env, Vec};
|
|
3
3
|
|
|
4
4
|
/// Interface for ULN302 receive library functions.
|
|
5
5
|
///
|
|
6
6
|
/// Handles DVN verification and message commitment on the receiving chain.
|
|
7
|
-
#[
|
|
7
|
+
#[contracttrait(client_name = "ReceiveUln302Client")]
|
|
8
8
|
pub trait IReceiveUln302 {
|
|
9
9
|
/// Called by a DVN to verify a message with a specific number of confirmations.
|
|
10
10
|
///
|
|
@@ -1,90 +1,18 @@
|
|
|
1
|
+
pub use crate::types::{
|
|
2
|
+
ExecutorConfig, OAppExecutorConfig, OAppUlnConfig, SetDefaultExecutorConfigParam, SetDefaultUlnConfigParam,
|
|
3
|
+
UlnConfig,
|
|
4
|
+
};
|
|
1
5
|
use endpoint_v2::ISendLib;
|
|
2
|
-
use soroban_sdk::{
|
|
6
|
+
use soroban_sdk::{contracttrait, Address, Env, Vec};
|
|
3
7
|
|
|
4
|
-
//
|
|
5
|
-
// Config Types
|
|
6
|
-
// ================================================
|
|
7
|
-
|
|
8
|
-
/// Ultra Light Node configuration for message verification.
|
|
9
|
-
#[contracttype]
|
|
10
|
-
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
11
|
-
pub struct UlnConfig {
|
|
12
|
-
/// Number of block confirmations required before message verification begins.
|
|
13
|
-
pub confirmations: u64,
|
|
14
|
-
/// List of DVN addresses that must ALL verify the message (no threshold).
|
|
15
|
-
pub required_dvns: Vec<Address>,
|
|
16
|
-
/// List of DVN addresses from which a threshold number must verify.
|
|
17
|
-
pub optional_dvns: Vec<Address>,
|
|
18
|
-
/// Minimum number of optional DVNs required to verify.
|
|
19
|
-
pub optional_dvn_threshold: u32,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/// OApp-specific ULN configuration with default override flags.
|
|
23
|
-
#[contracttype]
|
|
24
|
-
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
25
|
-
pub struct OAppUlnConfig {
|
|
26
|
-
/// Whether to use default confirmations.
|
|
27
|
-
pub use_default_confirmations: bool,
|
|
28
|
-
/// Whether to use default required DVNs.
|
|
29
|
-
pub use_default_required_dvns: bool,
|
|
30
|
-
/// Whether to use default optional DVNs.
|
|
31
|
-
pub use_default_optional_dvns: bool,
|
|
32
|
-
/// OApp-specific ULN configuration (used when defaults are not applied).
|
|
33
|
-
pub uln_config: UlnConfig,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/// Parameter for setting default ULN configuration for a destination/source endpoint.
|
|
37
|
-
#[contracttype]
|
|
38
|
-
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
39
|
-
pub struct SetDefaultUlnConfigParam {
|
|
40
|
-
/// The destination endpoint ID (for send) or source endpoint ID (for receive).
|
|
41
|
-
pub dst_eid: u32,
|
|
42
|
-
/// The ULN configuration to set as default.
|
|
43
|
-
pub config: UlnConfig,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// === Executor Config Types ===
|
|
47
|
-
|
|
48
|
-
/// Executor configuration for message delivery.
|
|
49
|
-
#[contracttype]
|
|
50
|
-
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
51
|
-
pub struct ExecutorConfig {
|
|
52
|
-
/// Maximum size of messages that can be executed (in bytes).
|
|
53
|
-
pub max_message_size: u32,
|
|
54
|
-
/// Address of the executor contract responsible for message execution.
|
|
55
|
-
pub executor: Address,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/// OApp-specific executor configuration.
|
|
59
|
-
///
|
|
60
|
-
/// If executor is `None`, the default executor is used.
|
|
61
|
-
#[contracttype]
|
|
62
|
-
#[derive(Clone, Default, Eq, PartialEq, Debug)]
|
|
63
|
-
pub struct OAppExecutorConfig {
|
|
64
|
-
/// Maximum size of messages that can be executed (in bytes). 0 means use default configuration.
|
|
65
|
-
pub max_message_size: u32,
|
|
66
|
-
/// Address of the executor contract to be used for message execution. None means use default configuration.
|
|
67
|
-
pub executor: Option<Address>,
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/// Parameter for setting default executor configuration for a destination endpoint.
|
|
71
|
-
#[contracttype]
|
|
72
|
-
#[derive(Clone, Eq, PartialEq, Debug)]
|
|
73
|
-
pub struct SetDefaultExecutorConfigParam {
|
|
74
|
-
/// The destination endpoint ID.
|
|
75
|
-
pub dst_eid: u32,
|
|
76
|
-
/// The executor configuration to set as default.
|
|
77
|
-
pub config: ExecutorConfig,
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// ================================================
|
|
8
|
+
// ============================================================================================
|
|
81
9
|
// ISendUln302 Trait
|
|
82
|
-
//
|
|
10
|
+
// ============================================================================================
|
|
83
11
|
|
|
84
12
|
/// Interface for ULN302 send library functions.
|
|
85
13
|
///
|
|
86
14
|
/// Extends `ISendLib` with ULN-specific configuration management for executors and DVNs.
|
|
87
|
-
#[
|
|
15
|
+
#[contracttrait(client_name = "SendUln302Client")]
|
|
88
16
|
pub trait ISendUln302: ISendLib {
|
|
89
17
|
/// Returns the treasury address for fee collection.
|
|
90
18
|
fn treasury(env: &Env) -> Address;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#![no_std]
|
|
2
2
|
|
|
3
|
+
mod errors;
|
|
4
|
+
pub mod events;
|
|
3
5
|
mod interfaces;
|
|
6
|
+
mod types;
|
|
4
7
|
|
|
8
|
+
pub use errors::*;
|
|
5
9
|
pub use interfaces::*;
|
|
10
|
+
pub use types::*;
|
|
6
11
|
|
|
7
12
|
cfg_if::cfg_if! {
|
|
8
13
|
if #[cfg(any(not(feature = "library"), feature = "testutils"))] {
|
|
9
|
-
mod config_validation;
|
|
10
|
-
mod errors;
|
|
11
|
-
mod events;
|
|
12
14
|
mod storage;
|
|
13
15
|
mod uln302;
|
|
14
|
-
|
|
15
16
|
pub use uln302::{Uln302, Uln302Client};
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
use super::*;
|
|
2
|
+
|
|
3
|
+
// ============================================================================================
|
|
2
4
|
// IReceiveUln302 Contract Implementation
|
|
3
|
-
//
|
|
5
|
+
// ============================================================================================
|
|
4
6
|
|
|
5
|
-
#[contractimpl]
|
|
7
|
+
#[contractimpl(contracttrait)]
|
|
6
8
|
impl IReceiveUln302 for Uln302 {
|
|
7
9
|
/// Called by a DVN to verify a message with a specific number of block confirmations.
|
|
8
10
|
///
|
|
@@ -49,7 +51,9 @@ impl IReceiveUln302 for Uln302 {
|
|
|
49
51
|
LayerZeroEndpointV2Client::new(env, &Self::endpoint(env)).verify(&send_lib, &origin, &receiver, payload_hash);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
//
|
|
54
|
+
// ============================================================================================
|
|
55
|
+
// Owner Set Config Functions
|
|
56
|
+
// ============================================================================================
|
|
53
57
|
|
|
54
58
|
/// Sets default receive ULN configurations for multiple source endpoints.
|
|
55
59
|
///
|
|
@@ -64,7 +68,9 @@ impl IReceiveUln302 for Uln302 {
|
|
|
64
68
|
DefaultUlnReceiveConfigSet { params: params.clone() }.publish(env);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
//
|
|
71
|
+
// ============================================================================================
|
|
72
|
+
// View Functions
|
|
73
|
+
// ============================================================================================
|
|
68
74
|
|
|
69
75
|
/// Returns the number of block confirmations a DVN has submitted for a specific message.
|
|
70
76
|
fn confirmations(env: &Env, dvn: &Address, header_hash: &BytesN<32>, payload_hash: &BytesN<32>) -> Option<u64> {
|
|
@@ -99,13 +105,11 @@ impl IReceiveUln302 for Uln302 {
|
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
//
|
|
108
|
+
// ============================================================================================
|
|
103
109
|
// Internal Functions
|
|
104
|
-
//
|
|
110
|
+
// ============================================================================================
|
|
105
111
|
|
|
106
112
|
impl Uln302 {
|
|
107
|
-
// === OApp Set Config Functions ===
|
|
108
|
-
|
|
109
113
|
/// Sets OApp-specific receive ULN config.
|
|
110
114
|
///
|
|
111
115
|
/// # Arguments
|
|
@@ -115,7 +119,7 @@ impl Uln302 {
|
|
|
115
119
|
///
|
|
116
120
|
/// # Panics
|
|
117
121
|
/// Panics if the final effective config is invalid.
|
|
118
|
-
fn set_receive_uln_config(env: &Env, receiver: &Address, src_eid: u32, config: &OAppUlnConfig) {
|
|
122
|
+
pub(super) fn set_receive_uln_config(env: &Env, receiver: &Address, src_eid: u32, config: &OAppUlnConfig) {
|
|
119
123
|
config.validate_oapp_config(env);
|
|
120
124
|
|
|
121
125
|
UlnStorage::set_oapp_receive_uln_configs(env, receiver, src_eid, config);
|
|
@@ -125,7 +129,9 @@ impl Uln302 {
|
|
|
125
129
|
UlnReceiveConfigSet { receiver: receiver.clone(), src_eid, config: config.clone() }.publish(env);
|
|
126
130
|
}
|
|
127
131
|
|
|
128
|
-
//
|
|
132
|
+
// ============================================================================================
|
|
133
|
+
// Verification Helpers Functions
|
|
134
|
+
// ============================================================================================
|
|
129
135
|
|
|
130
136
|
/// Validates packet header and extracts header, header hash, and effective ULN config.
|
|
131
137
|
fn validate_and_extract_param(env: &Env, packet_header: &Bytes) -> (PacketHeader, BytesN<32>, UlnConfig) {
|
|
@@ -189,7 +195,9 @@ impl Uln302 {
|
|
|
189
195
|
Self::confirmations(env, dvn, header_hash, payload_hash).map(|c| c >= confirmations).unwrap_or(false)
|
|
190
196
|
}
|
|
191
197
|
|
|
192
|
-
//
|
|
198
|
+
// ============================================================================================
|
|
199
|
+
// Helper Functions
|
|
200
|
+
// ============================================================================================
|
|
193
201
|
|
|
194
202
|
/// Returns default receive ULN config or panics if not found.
|
|
195
203
|
fn expect_default_receive_uln_config(env: &Env, src_eid: u32) -> UlnConfig {
|