@layerzerolabs/protocol-stellar-v2 0.2.12 → 0.2.15
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 +384 -278
- package/.turbo/turbo-lint.log +110 -78
- package/.turbo/turbo-test.log +1248 -1014
- package/Cargo.lock +130 -3
- package/Cargo.toml +2 -1
- package/contracts/common-macros/src/contract_impl.rs +6 -1
- package/contracts/common-macros/src/lib.rs +47 -8
- package/contracts/common-macros/src/ownable.rs +7 -25
- package/contracts/common-macros/src/storage.rs +1 -1
- package/contracts/common-macros/src/tests/contract_impl.rs +5 -0
- package/contracts/common-macros/src/tests/mod.rs +1 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap +23 -7
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +5 -25
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +48 -48
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +5 -25
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +21 -0
- package/contracts/common-macros/src/tests/upgradeable.rs +31 -0
- package/contracts/common-macros/src/ttl_configurable.rs +14 -44
- package/contracts/common-macros/src/upgradeable.rs +76 -0
- package/contracts/endpoint-v2/src/endpoint_v2.rs +25 -1
- package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +175 -8
- package/contracts/endpoint-v2/src/tests/endpoint_v2/build_outbound_packet.rs +76 -0
- package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +342 -159
- package/contracts/endpoint-v2/src/tests/endpoint_v2/delegate.rs +3 -15
- package/contracts/endpoint-v2/src/tests/endpoint_v2/initializable.rs +20 -31
- package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +126 -164
- package/contracts/endpoint-v2/src/tests/endpoint_v2/mod.rs +1 -0
- package/contracts/endpoint-v2/src/tests/endpoint_v2/native_token.rs +0 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/owner.rs +0 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +311 -304
- package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +423 -96
- package/contracts/endpoint-v2/src/tests/endpoint_v2/recover_token.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +47 -20
- package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +373 -403
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +96 -22
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +61 -9
- package/contracts/endpoint-v2/src/tests/endpoint_v2/transfer_ownership.rs +4 -4
- package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +8 -11
- package/contracts/endpoint-v2/src/tests/endpoint_v2/verifiable.rs +81 -30
- package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +209 -76
- package/contracts/endpoint-v2/src/tests/endpoint_v2/zro.rs +0 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library.rs +24 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library_timeout.rs +40 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_send_library.rs +24 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_config.rs +108 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_library_index.rs +52 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_receive_library.rs +92 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_registered_libraries.rs +74 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_send_library.rs +83 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_registered_library.rs +32 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_supported_eid.rs +28 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_valid_receive_library.rs +261 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/mod.rs +16 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/receive_library_timeout.rs +62 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +65 -43
- package/contracts/endpoint-v2/src/tests/message_lib_manager/registered_libraries_count.rs +42 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +61 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +3 -5
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +59 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +15 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_config.rs +155 -51
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +114 -92
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +235 -132
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +93 -87
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +346 -245
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +406 -60
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +252 -78
- package/contracts/endpoint-v2/src/tests/message_lib_manager/timeout.rs +102 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +212 -273
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +203 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +94 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_nonce.rs +78 -248
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_payload_hash.rs +7 -282
- package/contracts/endpoint-v2/src/tests/messaging_channel/lazy_inbound_nonce.rs +6 -274
- package/contracts/endpoint-v2/src/tests/messaging_channel/mod.rs +3 -2
- package/contracts/endpoint-v2/src/tests/messaging_channel/next_guid.rs +86 -178
- package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +328 -212
- package/contracts/endpoint-v2/src/tests/messaging_channel/outbound.rs +68 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/outbound_nonce.rs +6 -209
- package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +207 -159
- package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +142 -153
- package/contracts/endpoint-v2/src/tests/messaging_composer/compose_queue.rs +6 -179
- package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +163 -221
- package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +90 -121
- package/contracts/endpoint-v2/src/tests/mock.rs +18 -4
- package/contracts/endpoint-v2/src/tests/util/build_payload.rs +4 -70
- package/contracts/endpoint-v2/src/tests/util/compute_guid.rs +2 -1
- package/contracts/endpoint-v2/src/tests/util/keccak256.rs +17 -106
- package/contracts/layerzero-views/Cargo.toml +35 -0
- package/contracts/layerzero-views/src/errors.rs +10 -0
- package/contracts/layerzero-views/src/layerzero_view.rs +229 -0
- package/contracts/layerzero-views/src/lib.rs +38 -0
- package/contracts/layerzero-views/src/storage.rs +18 -0
- package/contracts/layerzero-views/src/tests/layerzero_view_tests.rs +423 -0
- package/contracts/layerzero-views/src/tests/mod.rs +4 -0
- package/contracts/layerzero-views/src/tests/setup.rs +377 -0
- package/contracts/layerzero-views/src/types.rs +50 -0
- package/contracts/macro-integration-tests/Cargo.toml +30 -0
- package/contracts/macro-integration-tests/src/lib.rs +1 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +62 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +22 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/only_owner_guard.rs +97 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +101 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +225 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/mod.rs +4 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/name_override_runtime.rs +52 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +261 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +137 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +113 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +50 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +139 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +3 -0
- package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.rs +21 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +16 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_owner_missing_env.rs +22 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_owner_missing_env.stderr +16 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +26 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +22 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_owner_env_param_variants.rs +46 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +16 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +19 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +44 -0
- package/contracts/macro-integration-tests/tests/ui_error.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ownable.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_storage.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ttl_configurable.rs +12 -0
- package/contracts/message-libs/blocked-message-lib/src/lib.rs +17 -17
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +64 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet.rs +58 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet_header.rs +138 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/mod.rs +6 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload.rs +30 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload_hash.rs +15 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/test_helper.rs +39 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_dvn_option.rs +57 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +50 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +74 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +280 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +126 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +48 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/mod.rs +7 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +139 -0
- package/contracts/message-libs/message-lib-common/src/worker_options.rs +31 -1
- package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +2 -2
- package/contracts/message-libs/treasury/src/errors.rs +0 -1
- package/contracts/message-libs/treasury/src/lib.rs +3 -3
- package/contracts/message-libs/treasury/src/storage.rs +2 -0
- package/contracts/message-libs/treasury/src/treasury.rs +12 -13
- package/contracts/message-libs/uln-302/Cargo.toml +1 -1
- package/contracts/message-libs/uln-302/src/errors.rs +0 -5
- package/contracts/message-libs/uln-302/src/events.rs +5 -6
- package/contracts/message-libs/uln-302/src/receive_uln.rs +24 -54
- package/contracts/message-libs/uln-302/src/send_uln.rs +89 -135
- package/contracts/message-libs/uln-302/src/storage.rs +5 -5
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +5 -7
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +3 -3
- package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +6 -9
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +3 -3
- package/contracts/message-libs/uln-302/src/tests/setup.rs +9 -0
- package/contracts/message-libs/uln-302/src/tests/testing_utils.rs +5 -0
- package/contracts/message-libs/uln-302/src/tests/uln302/get_app_receive_uln_config.rs +1 -2
- package/contracts/message-libs/uln-302/src/tests/uln302/get_app_send_uln_config.rs +1 -2
- package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +37 -55
- package/contracts/message-libs/uln-302/src/uln302.rs +8 -5
- package/contracts/oapps/counter/src/counter.rs +0 -1
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +306 -224
- package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +0 -1
- package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +0 -1
- package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +0 -1
- package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +0 -1
- package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_core.rs +1 -0
- package/contracts/oapps/oft/integration-tests/setup.rs +10 -3
- package/contracts/oapps/oft/integration-tests/utils.rs +1 -1
- package/contracts/oapps/oft/src/default_oft_impl.rs +9 -3
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +5 -5
- package/contracts/oapps/oft/src/extensions/pausable.rs +1 -1
- package/contracts/oapps/oft/src/extensions/rate_limiter.rs +18 -18
- package/contracts/oapps/oft/src/oft.rs +9 -9
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -1
- package/contracts/oapps/oft/src/tests/extensions/setup.rs +26 -11
- package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +1 -1
- package/contracts/oapps/oft/src/tests/test_send.rs +4 -4
- package/contracts/oapps/oft/src/tests/test_utils.rs +93 -74
- package/contracts/oapps/oft-std/Cargo.toml +6 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/mod.rs +3 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_oft_fee.rs +157 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_pausable.rs +162 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_rate_limiter.rs +186 -0
- package/contracts/oapps/oft-std/integration-tests/mod.rs +3 -0
- package/contracts/oapps/oft-std/integration-tests/setup.rs +245 -0
- package/contracts/oapps/oft-std/integration-tests/utils.rs +427 -0
- package/contracts/oapps/oft-std/src/lib.rs +12 -1
- package/contracts/oapps/oft-std/src/oft.rs +122 -25
- package/contracts/upgrader/Cargo.toml +19 -0
- package/contracts/upgrader/src/lib.rs +96 -0
- package/contracts/upgrader/src/tests/mod.rs +1 -0
- package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract1.wasm +0 -0
- package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract2.wasm +0 -0
- package/contracts/upgrader/src/tests/test_upgrader.rs +120 -0
- package/contracts/utils/src/errors.rs +6 -1
- package/contracts/utils/src/lib.rs +2 -1
- package/contracts/utils/src/ownable.rs +49 -61
- package/contracts/utils/src/tests/mod.rs +3 -1
- package/contracts/utils/src/tests/option_ext.rs +21 -0
- package/contracts/utils/src/tests/ownable.rs +10 -69
- package/contracts/utils/src/tests/ttl_configurable.rs +596 -0
- package/contracts/utils/src/tests/upgradeable.rs +288 -0
- package/contracts/utils/src/{ttl.rs → ttl_configurable.rs} +67 -52
- package/contracts/utils/src/upgradeable.rs +54 -0
- package/contracts/workers/dvn/Cargo.toml +1 -1
- package/contracts/workers/dvn/src/auth.rs +21 -32
- package/contracts/workers/dvn/src/dvn.rs +40 -3
- package/contracts/workers/dvn/src/errors.rs +1 -0
- package/contracts/workers/dvn/src/multisig.rs +10 -6
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +2 -2
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +4 -4
- package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -2
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +46 -14
- package/contracts/workers/dvn-fee-lib/src/errors.rs +3 -2
- package/contracts/workers/dvn-fee-lib/src/lib.rs +5 -11
- package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +30 -16
- package/contracts/workers/executor/src/executor.rs +16 -2
- package/contracts/workers/executor-fee-lib/src/errors.rs +9 -7
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +154 -119
- package/contracts/workers/executor-helper/Cargo.toml +0 -5
- package/contracts/workers/executor-helper/src/lib.rs +1 -7
- package/contracts/workers/price-feed/Cargo.toml +0 -1
- package/contracts/workers/price-feed/src/errors.rs +3 -2
- package/contracts/workers/price-feed/src/lib.rs +5 -6
- package/contracts/workers/price-feed/src/price_feed.rs +39 -17
- package/contracts/workers/worker/Cargo.toml +4 -0
- package/contracts/workers/worker/src/interfaces/price_feed.rs +3 -3
- package/contracts/workers/worker/src/lib.rs +2 -2
- package/contracts/workers/worker/src/tests/mod.rs +4 -0
- package/contracts/workers/worker/src/tests/setup.rs +147 -0
- package/contracts/workers/worker/src/tests/worker.rs +501 -0
- package/contracts/workers/worker/src/worker.rs +10 -16
- package/package.json +3 -3
- package/sdk/dist/generated/bml.d.ts +40 -30
- package/sdk/dist/generated/bml.js +16 -11
- package/sdk/dist/generated/counter.d.ts +168 -134
- package/sdk/dist/generated/counter.js +26 -21
- package/sdk/dist/generated/dvn.d.ts +1932 -0
- package/sdk/dist/generated/dvn.js +288 -0
- package/sdk/dist/generated/dvn_fee_lib.d.ts +615 -0
- package/sdk/dist/generated/dvn_fee_lib.js +123 -0
- package/sdk/dist/generated/endpoint.d.ts +75 -41
- package/sdk/dist/generated/endpoint.js +22 -17
- package/sdk/dist/generated/executor.d.ts +1809 -0
- package/sdk/dist/generated/executor.js +269 -0
- package/sdk/dist/generated/executor_fee_lib.d.ts +999 -0
- package/sdk/dist/generated/executor_fee_lib.js +208 -0
- package/sdk/dist/generated/executor_helper.d.ts +869 -0
- package/sdk/dist/generated/executor_helper.js +187 -0
- package/sdk/dist/generated/oft_std.d.ts +1544 -0
- package/sdk/dist/generated/oft_std.js +271 -0
- package/sdk/dist/generated/price_feed.d.ts +1002 -0
- package/sdk/dist/generated/price_feed.js +170 -0
- package/sdk/dist/generated/sml.d.ts +75 -41
- package/sdk/dist/generated/sml.js +22 -17
- package/sdk/dist/generated/uln302.d.ts +79 -60
- package/sdk/dist/generated/uln302.js +37 -37
- package/sdk/dist/generated/upgrader.d.ts +70 -0
- package/sdk/dist/generated/upgrader.js +19 -0
- package/sdk/dist/index.d.ts +8 -0
- package/sdk/dist/index.js +11 -0
- package/sdk/package.json +4 -3
- package/sdk/src/index.ts +13 -0
- package/sdk/test/index.test.ts +0 -1
- package/sdk/test/oft.test.ts +12 -23
- package/sdk/test/suites/testUpgradeable.ts +169 -0
- package/sdk/test/upgrader.test.ts +309 -0
- package/tools/ts-bindings-gen/src/main.rs +11 -1
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear.rs +0 -316
- package/contracts/endpoint-v2/src/tests/messaging_channel/internal.rs +0 -388
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +0 -162
- package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +0 -319
- package/contracts/utils/src/tests/ttl.rs +0 -421
- /package/contracts/{oapp-macros → oapps/oapp-macros}/Cargo.toml +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/lib.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_full.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_options_type3.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_receiver.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_sender.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/util.rs +0 -0
|
@@ -8,7 +8,7 @@ extern crate std;
|
|
|
8
8
|
use crate::integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address};
|
|
9
9
|
use common_macros::contract_impl;
|
|
10
10
|
use endpoint_v2::{EndpointV2, EndpointV2Client, ILayerZeroComposer};
|
|
11
|
-
use oft::oft::{oft_initialize, OFTClient,
|
|
11
|
+
use oft::oft::{oft_initialize, OFTClient, OFTInternal, OFT};
|
|
12
12
|
use oft::storage::OFTStorage;
|
|
13
13
|
use oft::types::OFTReceipt;
|
|
14
14
|
use simple_message_lib::{SimpleMessageLib, SimpleMessageLibClient};
|
|
@@ -29,7 +29,14 @@ pub struct TestOFT;
|
|
|
29
29
|
|
|
30
30
|
#[contract_impl]
|
|
31
31
|
impl TestOFT {
|
|
32
|
-
pub fn __constructor(
|
|
32
|
+
pub fn __constructor(
|
|
33
|
+
env: &Env,
|
|
34
|
+
token: &Address,
|
|
35
|
+
owner: &Address,
|
|
36
|
+
endpoint: &Address,
|
|
37
|
+
delegate: &Option<Address>,
|
|
38
|
+
shared_decimals: u32,
|
|
39
|
+
) {
|
|
33
40
|
oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
|
|
34
41
|
}
|
|
35
42
|
}
|
|
@@ -37,7 +44,7 @@ impl TestOFT {
|
|
|
37
44
|
#[contractimpl(contracttrait)]
|
|
38
45
|
impl OFT for TestOFT {}
|
|
39
46
|
|
|
40
|
-
impl
|
|
47
|
+
impl OFTInternal for TestOFT {
|
|
41
48
|
fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
42
49
|
// Get the receipt (handles decimal conversion, fees, etc.)
|
|
43
50
|
let receipt = Self::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
|
|
@@ -62,7 +62,7 @@ pub fn default_lz_receive<T>(
|
|
|
62
62
|
_extra_data: &Bytes,
|
|
63
63
|
_value: i128,
|
|
64
64
|
) where
|
|
65
|
-
T: crate::oft::
|
|
65
|
+
T: crate::oft::OFTInternal,
|
|
66
66
|
{
|
|
67
67
|
let oft_msg = OFTMessage::decode(message);
|
|
68
68
|
let send_to = resolve_address(env, &oft_msg.send_to);
|
|
@@ -91,11 +91,17 @@ pub fn default_lz_receive<T>(
|
|
|
91
91
|
/// Returns (OFTLimit, fee details, receipt with estimated amounts).
|
|
92
92
|
pub fn default_quote_oft<T>(env: &Env, send_param: &SendParam) -> (OFTLimit, Vec<OFTFeeDetail>, OFTReceipt)
|
|
93
93
|
where
|
|
94
|
-
T: crate::oft::
|
|
94
|
+
T: crate::oft::OFTInternal,
|
|
95
95
|
{
|
|
96
96
|
let oft_receipt = T::__debit_view(env, send_param.amount_ld, send_param.min_amount_ld, send_param.dst_eid);
|
|
97
97
|
let oft_fee_details = if oft_receipt.amount_sent_ld > oft_receipt.amount_received_ld {
|
|
98
|
-
vec![
|
|
98
|
+
vec![
|
|
99
|
+
env,
|
|
100
|
+
OFTFeeDetail {
|
|
101
|
+
fee_amount_ld: oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld,
|
|
102
|
+
description: Bytes::from_array(env, b"OFT Fee"),
|
|
103
|
+
},
|
|
104
|
+
]
|
|
99
105
|
} else {
|
|
100
106
|
vec![env]
|
|
101
107
|
};
|
|
@@ -118,7 +118,7 @@ pub trait OFTFee: OFTFeeInternal + Ownable + Sized {
|
|
|
118
118
|
/// Internal trait for OFT fee operations used by OFT hooks.
|
|
119
119
|
/// Contains only truly internal methods that are called from OFTInner implementations.
|
|
120
120
|
pub trait OFTFeeInternal {
|
|
121
|
-
///
|
|
121
|
+
/// Calculates the amount after fee deduction (read-only, mirrors `__debit_view`).
|
|
122
122
|
/// Used internally by `__debit_view` to calculate amount after fee.
|
|
123
123
|
///
|
|
124
124
|
/// # Arguments
|
|
@@ -127,7 +127,7 @@ pub trait OFTFeeInternal {
|
|
|
127
127
|
///
|
|
128
128
|
/// # Returns
|
|
129
129
|
/// The amount after fee deduction (original amount - calculated fee)
|
|
130
|
-
fn
|
|
130
|
+
fn __fee_view(env: &Env, dst_eid: u32, amount_ld: i128) -> i128 {
|
|
131
131
|
// Calculate effective fee (destination-specific or default)
|
|
132
132
|
let fee_bps = if OFTFeeStorage::has_fee_bps(env, dst_eid) {
|
|
133
133
|
OFTFeeStorage::fee_bps(env, dst_eid).unwrap()
|
|
@@ -147,14 +147,14 @@ pub trait OFTFeeInternal {
|
|
|
147
147
|
amount_ld - preliminary_fee
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
///
|
|
151
|
-
/// Used internally by `__debit` to collect the fee
|
|
150
|
+
/// Charges the fee by transferring the fee amount from sender to the fee deposit address.
|
|
151
|
+
/// Used internally by `__debit` to collect the fee (mirrors `__debit`).
|
|
152
152
|
///
|
|
153
153
|
/// # Arguments
|
|
154
154
|
/// * `token` - The token address to transfer
|
|
155
155
|
/// * `sender` - The sender address to transfer fee from
|
|
156
156
|
/// * `fee_amount` - The fee amount to transfer
|
|
157
|
-
fn
|
|
157
|
+
fn __charge_fee(env: &Env, token: &Address, sender: &Address, fee_amount: i128) {
|
|
158
158
|
if fee_amount > 0 {
|
|
159
159
|
assert_with_error!(
|
|
160
160
|
env,
|
|
@@ -37,7 +37,7 @@ pub trait OFTPausable: OFTPausableInternal + Ownable + Sized {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/// Internal trait for pausable operations used by OFT hooks.
|
|
40
|
-
/// Contains only truly internal methods that are called from
|
|
40
|
+
/// Contains only truly internal methods that are called from OFTInternal implementations.
|
|
41
41
|
pub trait OFTPausableInternal {
|
|
42
42
|
/// Asserts that the OFT is not paused, panics otherwise.
|
|
43
43
|
/// Used internally by `send`, `quote_send`, and `__lz_receive` to enforce pause state.
|
|
@@ -77,6 +77,16 @@ fn calculate_in_flight(env: &Env, direction: &Direction, eid: u32) -> i128 {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/// Checkpoints the current in-flight amount by applying decay and updating timestamp.
|
|
81
|
+
/// Used internally before modifying rate limit state.
|
|
82
|
+
fn checkpoint_rate_limit_in_flight(env: &Env, direction: &Direction, eid: u32) {
|
|
83
|
+
let in_flight = calculate_in_flight(env, direction, eid);
|
|
84
|
+
let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
|
|
85
|
+
rate_limit.in_flight_on_last_update = in_flight;
|
|
86
|
+
rate_limit.last_update = env.ledger().timestamp();
|
|
87
|
+
RateLimitStorage::set_rate_limit(env, direction, eid, &rate_limit);
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
#[contracttrait]
|
|
81
91
|
pub trait RateLimiter: RateLimiterInternal + Ownable + Sized {
|
|
82
92
|
#[only_owner]
|
|
@@ -90,7 +100,7 @@ pub trait RateLimiter: RateLimiterInternal + Ownable + Sized {
|
|
|
90
100
|
limit != rate_limit_data.limit || window_seconds != rate_limit_data.window_seconds,
|
|
91
101
|
RateLimitError::SameValue
|
|
92
102
|
);
|
|
93
|
-
|
|
103
|
+
checkpoint_rate_limit_in_flight(env, direction, eid);
|
|
94
104
|
let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
|
|
95
105
|
rate_limit.limit = limit;
|
|
96
106
|
rate_limit.window_seconds = window_seconds;
|
|
@@ -146,18 +156,18 @@ pub trait RateLimiter: RateLimiterInternal + Ownable + Sized {
|
|
|
146
156
|
}
|
|
147
157
|
|
|
148
158
|
/// Internal trait for rate limiter operations used by OFT hooks.
|
|
149
|
-
/// Contains only truly internal methods that are called from
|
|
159
|
+
/// Contains only truly internal methods that are called from OFTInternal implementations.
|
|
150
160
|
pub trait RateLimiterInternal {
|
|
151
|
-
///
|
|
152
|
-
/// Used internally by `
|
|
161
|
+
/// Consumes the specified amount from the rate limit capacity.
|
|
162
|
+
/// Used internally by `__debit` and `__credit` to enforce rate limits.
|
|
153
163
|
///
|
|
154
164
|
/// # Errors
|
|
155
165
|
/// * `ExceededRateLimit` - If the amount exceeds the available capacity.
|
|
156
|
-
fn
|
|
166
|
+
fn __consume_rate_limit_capacity(env: &Env, direction: &Direction, eid: u32, amount: i128) {
|
|
157
167
|
if !RateLimitStorage::has_rate_limit(env, direction, eid) {
|
|
158
168
|
return;
|
|
159
169
|
}
|
|
160
|
-
|
|
170
|
+
checkpoint_rate_limit_in_flight(env, direction, eid);
|
|
161
171
|
let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
|
|
162
172
|
// Check against remaining capacity (limit - current in_flight), not total limit
|
|
163
173
|
let capacity = if rate_limit.limit > rate_limit.in_flight_on_last_update {
|
|
@@ -173,12 +183,12 @@ pub trait RateLimiterInternal {
|
|
|
173
183
|
}
|
|
174
184
|
|
|
175
185
|
/// Releases the specified amount back to the rate limit capacity.
|
|
176
|
-
/// Used internally by `
|
|
186
|
+
/// Used internally by `__credit` to release outbound capacity on inbound messages.
|
|
177
187
|
fn __release_rate_limit_capacity(env: &Env, direction: &Direction, eid: u32, amount: i128) {
|
|
178
188
|
if !RateLimitStorage::has_rate_limit(env, direction, eid) {
|
|
179
189
|
return;
|
|
180
190
|
}
|
|
181
|
-
|
|
191
|
+
checkpoint_rate_limit_in_flight(env, direction, eid);
|
|
182
192
|
let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
|
|
183
193
|
if amount >= rate_limit.in_flight_on_last_update {
|
|
184
194
|
rate_limit.in_flight_on_last_update = 0;
|
|
@@ -187,14 +197,4 @@ pub trait RateLimiterInternal {
|
|
|
187
197
|
}
|
|
188
198
|
RateLimitStorage::set_rate_limit(env, direction, eid, &rate_limit);
|
|
189
199
|
}
|
|
190
|
-
|
|
191
|
-
/// Checkpoints the current in-flight amount by applying decay and updating timestamp.
|
|
192
|
-
/// Used internally before modifying rate limit state.
|
|
193
|
-
fn __checkpoint_rate_limit_in_flight(env: &Env, direction: &Direction, eid: u32) {
|
|
194
|
-
let in_flight = calculate_in_flight(env, direction, eid);
|
|
195
|
-
let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
|
|
196
|
-
rate_limit.in_flight_on_last_update = in_flight;
|
|
197
|
-
rate_limit.last_update = env.ledger().timestamp();
|
|
198
|
-
RateLimitStorage::set_rate_limit(env, direction, eid, &rate_limit);
|
|
199
|
-
}
|
|
200
200
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//! OFT traits - the main interface for OFT contracts.
|
|
2
2
|
//!
|
|
3
3
|
//! This module provides two traits:
|
|
4
|
-
//! - `
|
|
4
|
+
//! - `OFTInternal`: Internal methods NOT exposed as contract endpoints (`__debit`, `__credit`, etc.)
|
|
5
5
|
//! - `OFT`: Public methods exposed as contract endpoints (using `#[contracttrait]`)
|
|
6
6
|
//!
|
|
7
7
|
//! ## Usage
|
|
8
8
|
//!
|
|
9
9
|
//! ```ignore
|
|
10
10
|
//! use oapp_macros::{oapp, oapp_options_type3};
|
|
11
|
-
//! use oft::oft::{oft_initialize,
|
|
11
|
+
//! use oft::oft::{oft_initialize, OFTInternal, OFT};
|
|
12
12
|
//!
|
|
13
13
|
//! #[oapp]
|
|
14
14
|
//! pub struct MyOFT;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
//!
|
|
27
27
|
//! // Internal methods - NOT exposed as contract endpoints
|
|
28
28
|
//! // IMPORTANT: Do NOT use #[contractimpl] here to keep methods internal
|
|
29
|
-
//! impl
|
|
29
|
+
//! impl OFTInternal for MyOFT {
|
|
30
30
|
//! fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
31
31
|
//! // Your debit logic (e.g., burn or lock tokens)
|
|
32
32
|
//! oft::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
|
|
@@ -80,7 +80,7 @@ pub fn oft_initialize<T: OFT + OwnableInitializer>(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// =====================================================
|
|
83
|
-
//
|
|
83
|
+
// OFTInternal Trait (NOT exposed as contract endpoints)
|
|
84
84
|
// =====================================================
|
|
85
85
|
|
|
86
86
|
/// Internal OFT trait containing methods that should NOT be exposed as contract endpoints.
|
|
@@ -90,18 +90,18 @@ pub fn oft_initialize<T: OFT + OwnableInitializer>(
|
|
|
90
90
|
///
|
|
91
91
|
/// ```ignore
|
|
92
92
|
/// // Correct - methods stay internal
|
|
93
|
-
/// impl
|
|
93
|
+
/// impl OFTInternal for MyOFT { ... }
|
|
94
94
|
///
|
|
95
95
|
/// // WRONG - would expose methods as endpoints
|
|
96
96
|
/// #[contractimpl]
|
|
97
|
-
/// impl
|
|
97
|
+
/// impl OFTInternal for MyOFT { ... }
|
|
98
98
|
/// ```
|
|
99
99
|
///
|
|
100
100
|
/// Internal OFT trait for token debit/credit operations.
|
|
101
101
|
///
|
|
102
102
|
/// This trait contains only the internal token operations. The OApp supertraits
|
|
103
103
|
/// are on `OFT` instead, keeping this trait focused on token logic.
|
|
104
|
-
pub trait
|
|
104
|
+
pub trait OFTInternal: OAppCore {
|
|
105
105
|
// =========================================================================
|
|
106
106
|
// Required Methods (no defaults - user MUST implement)
|
|
107
107
|
// =========================================================================
|
|
@@ -175,9 +175,9 @@ pub trait OFTInner: OAppCore {
|
|
|
175
175
|
/// contract endpoints. Users implement this with `#[contractimpl(contracttrait)]`.
|
|
176
176
|
///
|
|
177
177
|
/// Internal methods like `__debit`, `__credit`, `__debit_view`, and `__build_msg_and_options`
|
|
178
|
-
/// are in the `
|
|
178
|
+
/// are in the `OFTInternal` trait and are NOT exposed as contract endpoints.
|
|
179
179
|
#[contracttrait(client_name = "OFTClient")]
|
|
180
|
-
pub trait OFT:
|
|
180
|
+
pub trait OFT: OFTInternal + OAppReceiver + OAppSender + OAppOptionsType3 {
|
|
181
181
|
/// Retrieves the token address associated with this OFT.
|
|
182
182
|
fn token(env: &Env) -> Address {
|
|
183
183
|
OFTStorage::token(env).unwrap()
|
|
@@ -22,7 +22,7 @@ use crate::types::OFTReceipt;
|
|
|
22
22
|
/// `OFTReceipt` containing the amount sent and amount received
|
|
23
23
|
pub fn debit<T: OFT>(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
24
24
|
let receipt: OFTReceipt = T::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
|
|
25
|
-
TokenClient::new(env, &T::token(env)).transfer(sender, env.current_contract_address(), &receipt.
|
|
25
|
+
TokenClient::new(env, &T::token(env)).transfer(sender, env.current_contract_address(), &receipt.amount_received_ld);
|
|
26
26
|
receipt
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -10,7 +10,7 @@ use crate::errors::OFTError;
|
|
|
10
10
|
use crate::extensions::oft_fee::{OFTFee, OFTFeeInternal};
|
|
11
11
|
use crate::extensions::pausable::{OFTPausable, OFTPausableInternal};
|
|
12
12
|
use crate::extensions::rate_limiter::{Direction, RateLimiter, RateLimiterInternal};
|
|
13
|
-
use crate::oft::{oft_initialize,
|
|
13
|
+
use crate::oft::{oft_initialize, OFTInternal, OFT};
|
|
14
14
|
use crate::storage::OFTStorage;
|
|
15
15
|
use crate::tests::test_utils::{
|
|
16
16
|
create_recipient_address, DummyToken, MockEndpointWithCompose, MockEndpointWithComposeClient, DEFAULT_NATIVE_FEE,
|
|
@@ -73,31 +73,46 @@ impl OFT for ExtensiveOFT {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// Internal OFT implementation - NOT exposed as contract endpoints
|
|
76
|
-
impl
|
|
76
|
+
impl OFTInternal for ExtensiveOFT {
|
|
77
77
|
fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
78
|
+
// 1. Pausable check
|
|
78
79
|
Self::__assert_not_paused(env);
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
// 2. Core debit logic
|
|
81
82
|
let oft_receipt = crate::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid);
|
|
82
|
-
|
|
83
|
+
|
|
84
|
+
// 3. Rate limit checks
|
|
85
|
+
Self::__consume_rate_limit_capacity(env, &Direction::Outbound, dst_eid, oft_receipt.amount_received_ld);
|
|
86
|
+
Self::__release_rate_limit_capacity(env, &Direction::Inbound, dst_eid, oft_receipt.amount_received_ld);
|
|
87
|
+
|
|
88
|
+
// 4. Charge fee
|
|
89
|
+
Self::__charge_fee(
|
|
83
90
|
env,
|
|
84
91
|
&Self::token(env),
|
|
85
92
|
sender,
|
|
86
93
|
oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld,
|
|
87
94
|
);
|
|
95
|
+
|
|
88
96
|
oft_receipt
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
|
|
100
|
+
// 1. Pausable check
|
|
92
101
|
Self::__assert_not_paused(env);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
|
|
102
|
+
|
|
103
|
+
// 2. Core credit logic
|
|
104
|
+
let amount_credited = crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid);
|
|
105
|
+
|
|
106
|
+
// 3. Rate limit checks
|
|
107
|
+
Self::__consume_rate_limit_capacity(env, &Direction::Inbound, src_eid, amount_credited);
|
|
108
|
+
Self::__release_rate_limit_capacity(env, &Direction::Outbound, src_eid, amount_credited);
|
|
109
|
+
|
|
110
|
+
amount_credited
|
|
96
111
|
}
|
|
97
112
|
|
|
98
113
|
fn __debit_view(env: &Env, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
99
114
|
let conversion_rate = OFTStorage::decimal_conversion_rate(env).unwrap();
|
|
100
|
-
let amount_after_fee = Self::
|
|
115
|
+
let amount_after_fee = Self::__fee_view(env, dst_eid, amount_ld);
|
|
101
116
|
let amount_received_ld = remove_dust(amount_after_fee, conversion_rate);
|
|
102
117
|
// Note: when no fee is applied, amount_send_ld is equal to amount_received_ld
|
|
103
118
|
// this is to align the behavior with the fee extensions on other VMs
|
|
@@ -699,7 +714,7 @@ impl<'a> ExtensiveOFTTestSetup<'a> {
|
|
|
699
714
|
let fee_amount = oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld;
|
|
700
715
|
|
|
701
716
|
// Mock auth order must match contract execution order:
|
|
702
|
-
// 1. Transfer fee (
|
|
717
|
+
// 1. Transfer fee (__charge_fee) - happens before burn
|
|
703
718
|
// 2. Burn tokens (amount_received_ld, not amount_sent_ld)
|
|
704
719
|
// 3. Transfer native/zro fees (__lz_send)
|
|
705
720
|
self.env.mock_auths(&[MockAuth {
|
|
@@ -709,7 +724,7 @@ impl<'a> ExtensiveOFTTestSetup<'a> {
|
|
|
709
724
|
fn_name: "send",
|
|
710
725
|
args: (sender, send_param, fee, refund_address).into_val(self.env),
|
|
711
726
|
sub_invokes: &[
|
|
712
|
-
// 1. Transfer fee to fee deposit address - happens in
|
|
727
|
+
// 1. Transfer fee to fee deposit address - happens in __charge_fee (BEFORE burn)
|
|
713
728
|
MockAuthInvoke {
|
|
714
729
|
contract: &self.token,
|
|
715
730
|
fn_name: "transfer",
|
|
@@ -376,7 +376,7 @@ fn test_consume_rate_limit_when_capacity_exactly_zero() {
|
|
|
376
376
|
assert_eq!(setup.rate_limit_capacity(&Direction::Outbound, dst_eid), 0);
|
|
377
377
|
|
|
378
378
|
// Try to send a small amount - should fail because capacity is exactly 0
|
|
379
|
-
// This tests the branch where capacity = 0 (limit <= in_flight) in
|
|
379
|
+
// This tests the branch where capacity = 0 (limit <= in_flight) in __consume_rate_limit_capacity
|
|
380
380
|
// Use amount that survives dust removal (conversion_rate = 10)
|
|
381
381
|
let small_amount = 100i128;
|
|
382
382
|
setup.fund_tokens(&sender, small_amount);
|
|
@@ -749,7 +749,7 @@ fn test_giving_partial_authorization_with_burn_wrong_arguments() {
|
|
|
749
749
|
sub_invokes: &[MockAuthInvoke {
|
|
750
750
|
contract: &setup.token,
|
|
751
751
|
fn_name: "burn",
|
|
752
|
-
args: (&sender, &oft_receipt.
|
|
752
|
+
args: (&sender, &oft_receipt.amount_received_ld + 1).into_val(&env),
|
|
753
753
|
sub_invokes: &[],
|
|
754
754
|
}],
|
|
755
755
|
},
|
|
@@ -794,7 +794,7 @@ fn test_giving_partial_authorization_without_native_fee_authorizations() {
|
|
|
794
794
|
sub_invokes: &[MockAuthInvoke {
|
|
795
795
|
contract: &setup.token,
|
|
796
796
|
fn_name: "burn",
|
|
797
|
-
args: (&sender, &oft_receipt.
|
|
797
|
+
args: (&sender, &oft_receipt.amount_received_ld).into_val(&env),
|
|
798
798
|
sub_invokes: &[],
|
|
799
799
|
}],
|
|
800
800
|
},
|
|
@@ -840,7 +840,7 @@ fn test_giving_partial_authorization_without_zro_fee_authorizations() {
|
|
|
840
840
|
MockAuthInvoke {
|
|
841
841
|
contract: &setup.token,
|
|
842
842
|
fn_name: "burn",
|
|
843
|
-
args: (&sender, &oft_receipt.
|
|
843
|
+
args: (&sender, &oft_receipt.amount_received_ld).into_val(&env),
|
|
844
844
|
sub_invokes: &[],
|
|
845
845
|
},
|
|
846
846
|
MockAuthInvoke {
|
|
@@ -893,7 +893,7 @@ fn test_giving_full_authorization() {
|
|
|
893
893
|
MockAuthInvoke {
|
|
894
894
|
contract: &setup.token,
|
|
895
895
|
fn_name: "burn",
|
|
896
|
-
args: (&sender, &oft_receipt.
|
|
896
|
+
args: (&sender, &oft_receipt.amount_received_ld).into_val(&env),
|
|
897
897
|
sub_invokes: &[],
|
|
898
898
|
},
|
|
899
899
|
MockAuthInvoke {
|
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
//!
|
|
3
3
|
//! This module provides common test contracts and helpers used across multiple test files.
|
|
4
4
|
|
|
5
|
-
extern crate self as oft;
|
|
6
|
-
|
|
7
5
|
use crate::codec::oft_msg_codec::OFTMessage;
|
|
8
|
-
use crate::oft::
|
|
6
|
+
use crate::oft::OFTClient;
|
|
9
7
|
use crate::types::{OFTReceipt, SendParam};
|
|
10
8
|
use endpoint_v2::{LayerZeroReceiverClient, MessagingFee, MessagingParams, MessagingReceipt, Origin};
|
|
11
9
|
use oapp::oapp_core::OAppCoreClient;
|
|
12
|
-
use oapp::oapp_receiver::OAppReceiver;
|
|
13
|
-
use oapp_macros::oapp_manual_impl;
|
|
14
10
|
use soroban_sdk::{address_payload::AddressPayload, log, String};
|
|
15
11
|
use soroban_sdk::{
|
|
16
12
|
bytes, contract, contractimpl, symbol_short,
|
|
@@ -103,84 +99,105 @@ pub fn create_origin(src_eid: u32, sender: &BytesN<32>, nonce: u64) -> Origin {
|
|
|
103
99
|
Origin { src_eid, sender: sender.clone(), nonce }
|
|
104
100
|
}
|
|
105
101
|
|
|
106
|
-
// ==================== Test OFT
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
102
|
+
// ==================== Test OFT Contracts ====================
|
|
103
|
+
|
|
104
|
+
mod test_mint_burn_oft {
|
|
105
|
+
extern crate self as oft;
|
|
106
|
+
|
|
107
|
+
use crate::oft::{oft_initialize, OFTInternal, OFT};
|
|
108
|
+
use crate::types::OFTReceipt;
|
|
109
|
+
use soroban_sdk::{contractimpl, Address, Env};
|
|
110
|
+
|
|
111
|
+
#[oapp_macros::oapp]
|
|
112
|
+
pub struct TestMintBurnOFT;
|
|
113
|
+
|
|
114
|
+
#[contractimpl]
|
|
115
|
+
impl TestMintBurnOFT {
|
|
116
|
+
pub fn __constructor(
|
|
117
|
+
env: &Env,
|
|
118
|
+
token: &Address,
|
|
119
|
+
owner: &Address,
|
|
120
|
+
endpoint: &Address,
|
|
121
|
+
delegate: &Option<Address>,
|
|
122
|
+
shared_decimals: u32,
|
|
123
|
+
) {
|
|
124
|
+
oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
|
|
125
|
+
}
|
|
122
126
|
}
|
|
123
|
-
}
|
|
124
127
|
|
|
125
|
-
#[contractimpl(contracttrait)]
|
|
126
|
-
impl OFT for TestMintBurnOFT {}
|
|
128
|
+
#[contractimpl(contracttrait)]
|
|
129
|
+
impl OFT for TestMintBurnOFT {}
|
|
127
130
|
|
|
128
|
-
impl
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
impl OFTInternal for TestMintBurnOFT {
|
|
132
|
+
fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
133
|
+
crate::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
|
|
134
|
+
}
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
|
|
137
|
+
crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
|
|
138
|
+
}
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
141
|
+
pub use test_mint_burn_oft::TestMintBurnOFT;
|
|
142
|
+
|
|
143
|
+
mod test_lock_unlock_oft {
|
|
144
|
+
extern crate self as oft;
|
|
145
|
+
|
|
146
|
+
use crate::oft::{oft_initialize, OFTInternal, OFT};
|
|
147
|
+
use crate::types::OFTReceipt;
|
|
148
|
+
use endpoint_v2::Origin;
|
|
149
|
+
use oapp::oapp_receiver::OAppReceiver;
|
|
150
|
+
use oapp_macros::oapp_manual_impl;
|
|
151
|
+
use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
|
|
152
|
+
|
|
153
|
+
#[oapp_macros::oapp]
|
|
154
|
+
#[oapp_manual_impl(receiver)]
|
|
155
|
+
pub struct TestLockUnlockOFT;
|
|
156
|
+
|
|
157
|
+
#[contractimpl]
|
|
158
|
+
impl TestLockUnlockOFT {
|
|
159
|
+
pub fn __constructor(
|
|
160
|
+
env: &Env,
|
|
161
|
+
token: &Address,
|
|
162
|
+
owner: &Address,
|
|
163
|
+
endpoint: &Address,
|
|
164
|
+
delegate: &Option<Address>,
|
|
165
|
+
shared_decimals: u32,
|
|
166
|
+
) {
|
|
167
|
+
oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
|
|
168
|
+
}
|
|
153
169
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
#[contractimpl(contracttrait)]
|
|
157
|
-
impl OFT for TestLockUnlockOFT {}
|
|
158
170
|
|
|
159
|
-
#[contractimpl(contracttrait)]
|
|
160
|
-
impl
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
#[contractimpl(contracttrait)]
|
|
172
|
+
impl OFT for TestLockUnlockOFT {}
|
|
173
|
+
|
|
174
|
+
#[contractimpl(contracttrait)]
|
|
175
|
+
impl OAppReceiver for TestLockUnlockOFT {
|
|
176
|
+
fn lz_receive(
|
|
177
|
+
env: &Env,
|
|
178
|
+
executor: &Address,
|
|
179
|
+
origin: &Origin,
|
|
180
|
+
guid: &BytesN<32>,
|
|
181
|
+
message: &Bytes,
|
|
182
|
+
extra_data: &Bytes,
|
|
183
|
+
value: i128,
|
|
184
|
+
) {
|
|
185
|
+
oapp::oapp_receiver::verify_and_clear_payload::<Self>(env, executor, origin, guid, message, value);
|
|
186
|
+
Self::__lz_receive(env, executor, origin, guid, message, extra_data, value);
|
|
187
|
+
}
|
|
172
188
|
}
|
|
173
|
-
}
|
|
174
189
|
|
|
175
|
-
impl
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
190
|
+
impl OFTInternal for TestLockUnlockOFT {
|
|
191
|
+
fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
192
|
+
crate::oft_types::lock_unlock::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
|
|
193
|
+
}
|
|
179
194
|
|
|
180
|
-
|
|
181
|
-
|
|
195
|
+
fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
|
|
196
|
+
crate::oft_types::lock_unlock::credit::<Self>(env, to, amount_ld, src_eid)
|
|
197
|
+
}
|
|
182
198
|
}
|
|
183
199
|
}
|
|
200
|
+
pub use test_lock_unlock_oft::TestLockUnlockOFT;
|
|
184
201
|
|
|
185
202
|
// ==================== Dummy Contracts ====================
|
|
186
203
|
|
|
@@ -664,17 +681,18 @@ impl<'a> OFTTestSetup<'a> {
|
|
|
664
681
|
oft_receipt: &OFTReceipt,
|
|
665
682
|
) -> (MessagingReceipt, OFTReceipt) {
|
|
666
683
|
// Token operation sub-invoke differs based on OFT type
|
|
684
|
+
// Both MintBurn and LockUnlock use amount_received_ld (after fee/dust removal)
|
|
667
685
|
let token_sub_invoke = match self.oft_type {
|
|
668
686
|
OFTType::MintBurn => MockAuthInvoke {
|
|
669
687
|
contract: &self.token,
|
|
670
688
|
fn_name: "burn",
|
|
671
|
-
args: (sender, &oft_receipt.
|
|
689
|
+
args: (sender, &oft_receipt.amount_received_ld).into_val(self.env),
|
|
672
690
|
sub_invokes: &[],
|
|
673
691
|
},
|
|
674
692
|
OFTType::LockUnlock => MockAuthInvoke {
|
|
675
693
|
contract: &self.token,
|
|
676
694
|
fn_name: "transfer",
|
|
677
|
-
args: (sender, &self.oft.address, &oft_receipt.
|
|
695
|
+
args: (sender, &self.oft.address, &oft_receipt.amount_received_ld).into_val(self.env),
|
|
678
696
|
sub_invokes: &[],
|
|
679
697
|
},
|
|
680
698
|
};
|
|
@@ -718,17 +736,18 @@ impl<'a> OFTTestSetup<'a> {
|
|
|
718
736
|
Result<soroban_sdk::Error, soroban_sdk::InvokeError>,
|
|
719
737
|
> {
|
|
720
738
|
// Token operation sub-invoke differs based on OFT type
|
|
739
|
+
// Both MintBurn and LockUnlock use amount_received_ld (after fee/dust removal)
|
|
721
740
|
let token_sub_invoke = match self.oft_type {
|
|
722
741
|
OFTType::MintBurn => MockAuthInvoke {
|
|
723
742
|
contract: &self.token,
|
|
724
743
|
fn_name: "burn",
|
|
725
|
-
args: (sender, &oft_receipt.
|
|
744
|
+
args: (sender, &oft_receipt.amount_received_ld).into_val(self.env),
|
|
726
745
|
sub_invokes: &[],
|
|
727
746
|
},
|
|
728
747
|
OFTType::LockUnlock => MockAuthInvoke {
|
|
729
748
|
contract: &self.token,
|
|
730
749
|
fn_name: "transfer",
|
|
731
|
-
args: (sender, &self.oft.address, &oft_receipt.
|
|
750
|
+
args: (sender, &self.oft.address, &oft_receipt.amount_received_ld).into_val(self.env),
|
|
732
751
|
sub_invokes: &[],
|
|
733
752
|
},
|
|
734
753
|
};
|
|
@@ -17,3 +17,9 @@ common-macros = { workspace = true }
|
|
|
17
17
|
oapp-macros = { workspace = true }
|
|
18
18
|
oft = { workspace = true }
|
|
19
19
|
|
|
20
|
+
[dev-dependencies]
|
|
21
|
+
soroban-sdk = { workspace = true, features = ["testutils"] }
|
|
22
|
+
simple-message-lib = { workspace = true }
|
|
23
|
+
message-lib-common = { workspace = true, features = ["testutils"] }
|
|
24
|
+
endpoint-v2 = { workspace = true, features = ["testutils"] }
|
|
25
|
+
utils = { workspace = true, features = ["testutils"] }
|