@layerzerolabs/protocol-stellar-v2 0.2.15 → 0.2.19
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 +365 -297
- package/.turbo/turbo-lint.log +142 -110
- package/.turbo/turbo-test.log +1273 -1222
- package/Cargo.lock +20 -5
- package/Cargo.toml +4 -1
- package/contracts/ERROR_SPEC.md +44 -0
- package/contracts/common-macros/src/auth.rs +113 -0
- package/contracts/common-macros/src/contract_ttl.rs +84 -0
- package/contracts/common-macros/src/lib.rs +181 -30
- package/contracts/common-macros/src/lz_contract.rs +83 -0
- package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
- package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
- package/contracts/common-macros/src/tests/mod.rs +2 -2
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
- package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap → common_macros__tests__auth__snapshot_only_auth_preserves_function_signature.snap} +4 -4
- package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap → common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap} +3 -3
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -21
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +2 -2
- package/contracts/common-macros/src/ttl_configurable.rs +19 -34
- package/contracts/common-macros/src/ttl_extendable.rs +36 -0
- package/contracts/common-macros/src/upgradeable.rs +5 -5
- package/contracts/common-macros/src/utils.rs +9 -0
- package/contracts/endpoint-v2/src/constants.rs +4 -4
- package/contracts/endpoint-v2/src/endpoint_v2.rs +38 -40
- package/contracts/endpoint-v2/src/errors.rs +4 -3
- package/contracts/endpoint-v2/src/events.rs +1 -1
- package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
- package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
- package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
- package/contracts/endpoint-v2/src/storage.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +3 -3
- package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
- package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +3 -3
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +1 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +1 -1
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +4 -4
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +1 -1
- package/contracts/layerzero-views/src/layerzero_view.rs +3 -6
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +2 -2
- package/contracts/macro-integration-tests/tests/runtime/ownable/{only_owner_guard.rs → only_auth_guard.rs} +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +0 -1
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.rs → only_auth_missing_env.rs} +3 -3
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.stderr → only_auth_missing_env.stderr} +4 -4
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +2 -3
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/{only_owner_env_param_variants.rs → only_auth_env_param_variants.rs} +9 -9
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +6 -6
- package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +3 -3
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +1 -2
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +1 -2
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +9 -9
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +1 -1
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +1 -1
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +2 -2
- package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
- package/contracts/message-libs/treasury/src/errors.rs +2 -2
- package/contracts/message-libs/treasury/src/events.rs +1 -1
- package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
- package/contracts/message-libs/treasury/src/storage.rs +1 -1
- package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
- package/contracts/message-libs/treasury/src/treasury.rs +14 -16
- package/contracts/message-libs/uln-302/src/receive_uln.rs +13 -2
- package/contracts/message-libs/uln-302/src/send_uln.rs +24 -4
- package/contracts/message-libs/uln-302/src/uln302.rs +6 -24
- package/contracts/oapps/counter/Cargo.toml +14 -1
- package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
- package/contracts/oapps/counter/integration_tests/{setup.rs → setup_sml.rs} +48 -80
- package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
- package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
- package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
- package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
- package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
- package/contracts/oapps/counter/src/counter.rs +67 -43
- package/contracts/oapps/counter/src/tests/mod.rs +0 -13
- package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
- package/contracts/oapps/oapp/src/errors.rs +5 -1
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +93 -78
- package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
- package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
- package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
- package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
- package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -8
- package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -17
- package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -7
- package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -15
- package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
- package/contracts/oapps/oapp-macros/src/lib.rs +113 -56
- package/contracts/oapps/oft/Cargo.toml +10 -7
- package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_oft_fee.rs +3 -4
- package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_pausable.rs +2 -3
- package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_rate_limiter.rs +1 -1
- package/contracts/oapps/oft/integration-tests/mod.rs +1 -1
- package/contracts/oapps/oft/integration-tests/setup.rs +29 -110
- package/contracts/oapps/oft/integration-tests/utils.rs +254 -21
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +13 -14
- package/contracts/oapps/oft/src/extensions/pausable.rs +4 -4
- package/contracts/oapps/oft/src/extensions/rate_limiter.rs +5 -5
- package/contracts/oapps/oft/src/lib.rs +11 -13
- package/contracts/oapps/oft/src/oft.rs +147 -225
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +9 -13
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +31 -14
- package/contracts/oapps/oft/src/oft_types/mod.rs +13 -0
- package/contracts/oapps/{oft-std → oft-core}/Cargo.toml +6 -4
- package/contracts/oapps/{oft-std → oft-core}/integration-tests/mod.rs +1 -1
- package/contracts/oapps/{oft-std → oft-core}/integration-tests/setup.rs +129 -30
- package/contracts/oapps/{oft → oft-core}/integration-tests/test_with_sml.rs +3 -3
- package/contracts/oapps/oft-core/integration-tests/utils.rs +201 -0
- package/contracts/oapps/oft-core/src/errors.rs +13 -0
- package/contracts/oapps/oft-core/src/lib.rs +18 -0
- package/contracts/oapps/oft-core/src/oft_core.rs +439 -0
- package/contracts/oapps/{oft → oft-core}/src/storage.rs +2 -0
- package/contracts/oapps/{oft → oft-core}/src/tests/mod.rs +0 -2
- package/contracts/oapps/{oft → oft-core}/src/tests/test_decimals.rs +2 -2
- package/contracts/oapps/{oft → oft-core}/src/tests/test_lz_receive.rs +7 -7
- package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_msg_codec.rs +4 -5
- package/contracts/oapps/{oft → oft-core}/src/tests/test_resolve_address.rs +3 -3
- package/contracts/oapps/{oft → oft-core}/src/tests/test_utils.rs +78 -37
- package/contracts/oapps/oft-core/src/types.rs +58 -0
- package/contracts/oapps/{oft → oft-core}/src/utils.rs +1 -1
- package/contracts/upgrader/src/lib.rs +4 -4
- package/contracts/utils/src/auth.rs +44 -0
- package/contracts/utils/src/errors.rs +31 -5
- package/contracts/utils/src/lib.rs +3 -0
- package/contracts/utils/src/multisig.rs +211 -0
- package/contracts/utils/src/ownable.rs +137 -13
- package/contracts/utils/src/tests/buffer_reader.rs +6 -6
- package/contracts/utils/src/tests/buffer_writer.rs +6 -6
- package/contracts/utils/src/tests/bytes_ext.rs +2 -4
- package/contracts/utils/src/tests/mod.rs +1 -0
- package/contracts/utils/src/tests/multisig.rs +731 -0
- package/contracts/utils/src/tests/option_ext.rs +2 -5
- package/contracts/utils/src/tests/ownable.rs +456 -7
- package/contracts/utils/src/tests/ttl_configurable.rs +27 -16
- package/contracts/utils/src/tests/upgradeable.rs +4 -2
- package/contracts/utils/src/ttl_configurable.rs +23 -8
- package/contracts/utils/src/ttl_extendable.rs +27 -0
- package/contracts/utils/src/upgradeable.rs +2 -0
- package/contracts/workers/dvn/Cargo.toml +1 -1
- package/contracts/workers/dvn/src/auth.rs +7 -7
- package/contracts/workers/dvn/src/dvn.rs +10 -38
- package/contracts/workers/dvn/src/errors.rs +0 -7
- package/contracts/workers/dvn/src/events.rs +1 -14
- package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
- package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
- package/contracts/workers/dvn/src/storage.rs +3 -13
- package/contracts/workers/dvn/src/tests/auth.rs +4 -4
- package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
- package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
- package/contracts/workers/dvn/src/tests/setup.rs +5 -5
- package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +3 -6
- package/contracts/workers/executor/src/auth.rs +80 -16
- package/contracts/workers/executor/src/executor.rs +5 -31
- package/contracts/workers/executor/src/storage.rs +2 -9
- package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +3 -6
- package/contracts/workers/executor-helper/Cargo.toml +1 -1
- package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
- package/contracts/workers/price-feed/Cargo.toml +1 -1
- package/contracts/workers/price-feed/src/price_feed.rs +7 -10
- package/contracts/workers/worker/src/errors.rs +4 -0
- package/contracts/workers/worker/src/tests/worker.rs +7 -6
- package/contracts/workers/worker/src/worker.rs +20 -16
- package/package.json +7 -5
- package/sdk/.turbo/turbo-build.log +1 -0
- package/sdk/.turbo/turbo-test.log +1019 -0
- package/sdk/dist/generated/bml.d.ts +95 -8
- package/sdk/dist/generated/bml.js +95 -36
- package/sdk/dist/generated/counter.d.ts +289 -44
- package/sdk/dist/generated/counter.js +119 -49
- package/sdk/dist/generated/dvn.d.ts +312 -229
- package/sdk/dist/generated/dvn.js +144 -83
- package/sdk/dist/generated/dvn_fee_lib.d.ts +258 -63
- package/sdk/dist/generated/dvn_fee_lib.js +95 -26
- package/sdk/dist/generated/endpoint.d.ts +219 -24
- package/sdk/dist/generated/endpoint.js +108 -41
- package/sdk/dist/generated/executor.d.ts +239 -87
- package/sdk/dist/generated/executor.js +135 -63
- package/sdk/dist/generated/executor_fee_lib.d.ts +278 -74
- package/sdk/dist/generated/executor_fee_lib.js +135 -59
- package/sdk/dist/generated/executor_helper.d.ts +163 -21
- package/sdk/dist/generated/executor_helper.js +124 -52
- package/sdk/dist/generated/oft.d.ts +1842 -0
- package/sdk/dist/generated/oft.js +345 -0
- package/sdk/dist/generated/price_feed.d.ts +258 -63
- package/sdk/dist/generated/price_feed.js +95 -26
- package/sdk/dist/generated/sml.d.ts +235 -34
- package/sdk/dist/generated/sml.js +126 -53
- package/sdk/dist/generated/treasury.d.ts +1016 -0
- package/sdk/dist/generated/treasury.js +248 -0
- package/sdk/dist/generated/uln302.d.ts +235 -34
- package/sdk/dist/generated/uln302.js +126 -53
- package/sdk/dist/generated/upgrader.d.ts +17 -2
- package/sdk/dist/generated/upgrader.js +19 -1
- package/sdk/dist/index.d.ts +2 -1
- package/sdk/dist/index.js +2 -1
- package/sdk/package.json +6 -3
- package/sdk/src/index.ts +2 -1
- package/sdk/test/counter-sml.test.ts +376 -0
- package/sdk/test/counter-uln.test.ts +493 -0
- package/sdk/test/{oft.test.ts → oft-sml.test.ts} +196 -321
- package/sdk/test/suites/constants.ts +22 -2
- package/sdk/test/suites/globalSetup.ts +450 -0
- package/sdk/test/suites/localnet.ts +23 -6
- package/sdk/test/upgrader.test.ts +7 -16
- package/sdk/test/utils.ts +558 -85
- package/sdk/turbo.json +8 -0
- package/sdk/vitest.config.ts +21 -0
- package/tools/ts-bindings-gen/Cargo.toml +2 -0
- package/tools/ts-bindings-gen/src/main.rs +52 -4
- package/contracts/common-macros/src/contract_impl.rs +0 -52
- package/contracts/common-macros/src/ownable.rs +0 -41
- package/contracts/common-macros/src/tests/contract_impl.rs +0 -386
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -12
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +0 -50
- package/contracts/oapps/oapp-macros/src/oapp_core.rs +0 -41
- package/contracts/oapps/oapp-macros/src/oapp_full.rs +0 -21
- package/contracts/oapps/oapp-macros/src/oapp_options_type3.rs +0 -31
- package/contracts/oapps/oapp-macros/src/oapp_receiver.rs +0 -48
- package/contracts/oapps/oapp-macros/src/oapp_sender.rs +0 -21
- package/contracts/oapps/oapp-macros/src/util.rs +0 -107
- package/contracts/oapps/oft/src/constants.rs +0 -5
- package/contracts/oapps/oft/src/default_oft_impl.rs +0 -152
- package/contracts/oapps/oft/src/errors.rs +0 -8
- package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +0 -23
- package/contracts/oapps/oft/src/interfaces/mod.rs +0 -3
- package/contracts/oapps/oft/src/tests/extensions/mod.rs +0 -11
- package/contracts/oapps/oft/src/tests/extensions/setup.rs +0 -903
- package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +0 -749
- package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +0 -432
- package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +0 -1078
- package/contracts/oapps/oft/src/types.rs +0 -38
- package/contracts/oapps/oft-std/integration-tests/utils.rs +0 -427
- package/contracts/oapps/oft-std/src/lib.rs +0 -16
- package/contracts/oapps/oft-std/src/oft.rs +0 -156
- package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
- package/contracts/workers/dvn/src/multisig.rs +0 -157
- package/sdk/dist/generated/oft_std.d.ts +0 -1544
- package/sdk/dist/generated/oft_std.js +0 -271
- package/sdk/test/index.test.ts +0 -375
- /package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/mod.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/codec/mod.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/codec/oft_compose_msg_codec.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/codec/oft_msg_codec.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/events.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_compose_msg_codec.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_version.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_oft.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_send.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_send.rs +0 -0
- /package/contracts/oapps/{oft → oft-core}/src/tests/test_token.rs +0 -0
- /package/sdk/test/suites/{testUpgradeable.ts → dummyContractClient.ts} +0 -0
|
@@ -1,251 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//!
|
|
9
|
-
//! ```ignore
|
|
10
|
-
//! use oapp_macros::{oapp, oapp_options_type3};
|
|
11
|
-
//! use oft::oft::{oft_initialize, OFTInternal, OFT};
|
|
12
|
-
//!
|
|
13
|
-
//! #[oapp]
|
|
14
|
-
//! pub struct MyOFT;
|
|
15
|
-
//!
|
|
16
|
-
//! #[contractimpl]
|
|
17
|
-
//! impl MyOFT {
|
|
18
|
-
//! pub fn __constructor(env: &Env, token: &Address, owner: &Address, endpoint: &Address, delegate: &Option<Address>) {
|
|
19
|
-
//! oft_initialize::<Self>(env, owner, token, endpoint, delegate)
|
|
20
|
-
//! }
|
|
21
|
-
//! }
|
|
22
|
-
//!
|
|
23
|
-
//! // Public methods - exposed as contract endpoints
|
|
24
|
-
//! #[contractimpl(contracttrait)]
|
|
25
|
-
//! impl OFT for MyOFT {}
|
|
26
|
-
//!
|
|
27
|
-
//! // Internal methods - NOT exposed as contract endpoints
|
|
28
|
-
//! // IMPORTANT: Do NOT use #[contractimpl] here to keep methods internal
|
|
29
|
-
//! impl OFTInternal for MyOFT {
|
|
30
|
-
//! fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
31
|
-
//! // Your debit logic (e.g., burn or lock tokens)
|
|
32
|
-
//! oft::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
|
|
33
|
-
//! }
|
|
34
|
-
//!
|
|
35
|
-
//! fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
|
|
36
|
-
//! // Your credit logic (e.g., mint or unlock tokens)
|
|
37
|
-
//! oft::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
|
|
38
|
-
//! }
|
|
39
|
-
//! }
|
|
40
|
-
//! ```
|
|
41
|
-
|
|
42
|
-
// Alias for the current crate, allowing `oft::types::SendParam` paths to work both
|
|
43
|
-
// inside this crate and in external crates implementing the OFT trait.
|
|
44
|
-
extern crate self as oft;
|
|
45
|
-
|
|
46
|
-
use crate::{errors::OFTError, storage::OFTStorage, types::OFTReceipt};
|
|
47
|
-
use endpoint_v2::Origin;
|
|
48
|
-
use oapp::{
|
|
49
|
-
oapp_core::{oapp_initialize, OAppCore},
|
|
50
|
-
oapp_options_type3::OAppOptionsType3,
|
|
51
|
-
oapp_receiver::OAppReceiver,
|
|
52
|
-
oapp_sender::OAppSender,
|
|
1
|
+
use crate::{
|
|
2
|
+
extensions::{
|
|
3
|
+
oft_fee::{OFTFee, OFTFeeInternal},
|
|
4
|
+
pausable::{OFTPausable, OFTPausableInternal},
|
|
5
|
+
rate_limiter::{Direction, RateLimiter, RateLimiterInternal},
|
|
6
|
+
},
|
|
7
|
+
oft_types::{lock_unlock, mint_burn, OftType},
|
|
53
8
|
};
|
|
54
|
-
use
|
|
55
|
-
use
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
shared_decimals: u32,
|
|
70
|
-
) {
|
|
71
|
-
// Initialize OApp (includes owner initialization)
|
|
72
|
-
oapp_initialize::<T>(env, owner, endpoint, delegate);
|
|
73
|
-
|
|
74
|
-
let local_decimals = TokenClient::new(env, token).decimals();
|
|
75
|
-
assert_with_error!(env, local_decimals >= shared_decimals, OFTError::InvalidLocalDecimals);
|
|
76
|
-
|
|
77
|
-
// Initialize OFT storage
|
|
78
|
-
OFTStorage::set_token(env, token);
|
|
79
|
-
OFTStorage::set_decimal_conversion_rate(env, &10_i128.pow(local_decimals - shared_decimals));
|
|
9
|
+
use common_macros::{contract_impl, storage};
|
|
10
|
+
use endpoint_v2::{MessagingFee, Origin};
|
|
11
|
+
use oapp::oapp_receiver::LzReceiveInternal;
|
|
12
|
+
use oapp_macros::oapp;
|
|
13
|
+
use oft_core::{
|
|
14
|
+
errors::OFTError,
|
|
15
|
+
types::{OFTFeeDetail, OFTLimit, OFTReceipt, SendParam},
|
|
16
|
+
utils as oft_utils, OFTCore, OFTInternal,
|
|
17
|
+
};
|
|
18
|
+
use soroban_sdk::{assert_with_error, vec, Address, Bytes, BytesN, Env, Vec};
|
|
19
|
+
|
|
20
|
+
#[storage]
|
|
21
|
+
enum OFTStorage {
|
|
22
|
+
#[instance(OftType)]
|
|
23
|
+
OftType,
|
|
80
24
|
}
|
|
81
25
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// =====================================================
|
|
85
|
-
|
|
86
|
-
/// Internal OFT trait containing methods that should NOT be exposed as contract endpoints.
|
|
87
|
-
///
|
|
88
|
-
/// **IMPORTANT**: Implement this trait WITHOUT the `#[contractimpl]` macro to keep
|
|
89
|
-
/// `__debit`, `__credit`, and other internal methods private to the contract.
|
|
90
|
-
///
|
|
91
|
-
/// ```ignore
|
|
92
|
-
/// // Correct - methods stay internal
|
|
93
|
-
/// impl OFTInternal for MyOFT { ... }
|
|
94
|
-
///
|
|
95
|
-
/// // WRONG - would expose methods as endpoints
|
|
96
|
-
/// #[contractimpl]
|
|
97
|
-
/// impl OFTInternal for MyOFT { ... }
|
|
98
|
-
/// ```
|
|
99
|
-
///
|
|
100
|
-
/// Internal OFT trait for token debit/credit operations.
|
|
101
|
-
///
|
|
102
|
-
/// This trait contains only the internal token operations. The OApp supertraits
|
|
103
|
-
/// are on `OFT` instead, keeping this trait focused on token logic.
|
|
104
|
-
pub trait OFTInternal: OAppCore {
|
|
105
|
-
// =========================================================================
|
|
106
|
-
// Required Methods (no defaults - user MUST implement)
|
|
107
|
-
// =========================================================================
|
|
108
|
-
|
|
109
|
-
/// Debits tokens from sender for cross-chain transfer.
|
|
110
|
-
///
|
|
111
|
-
/// # Arguments
|
|
112
|
-
/// * `sender` - The address sending tokens
|
|
113
|
-
/// * `amount_ld` - Amount in local decimals to debit
|
|
114
|
-
/// * `min_amount_ld` - Minimum amount acceptable (slippage protection)
|
|
115
|
-
/// * `dst_eid` - Destination endpoint ID
|
|
116
|
-
///
|
|
117
|
-
/// # Returns
|
|
118
|
-
/// Receipt with amounts sent and received (after fees/dust removal)
|
|
119
|
-
fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt;
|
|
120
|
-
|
|
121
|
-
/// Credits tokens to recipient after receiving cross-chain transfer.
|
|
122
|
-
///
|
|
123
|
-
/// # Arguments
|
|
124
|
-
/// * `to` - The address to credit tokens to
|
|
125
|
-
/// * `amount_ld` - Amount in local decimals to credit
|
|
126
|
-
/// * `src_eid` - Source endpoint ID
|
|
127
|
-
///
|
|
128
|
-
/// # Returns
|
|
129
|
-
/// The amount actually credited
|
|
130
|
-
fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128;
|
|
131
|
-
|
|
132
|
-
// =========================================================================
|
|
133
|
-
// Optional Methods (have defaults - override as needed)
|
|
134
|
-
// =========================================================================
|
|
135
|
-
|
|
136
|
-
/// Calculates debit amounts without executing (view function).
|
|
137
|
-
fn __debit_view(env: &Env, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
138
|
-
crate::default_oft_impl::default_debit_view(env, amount_ld, min_amount_ld, dst_eid)
|
|
139
|
-
}
|
|
26
|
+
#[oapp]
|
|
27
|
+
pub struct OFT;
|
|
140
28
|
|
|
141
|
-
|
|
142
|
-
|
|
29
|
+
#[contract_impl]
|
|
30
|
+
impl OFT {
|
|
31
|
+
pub fn __constructor(
|
|
143
32
|
env: &Env,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
|
|
33
|
+
token: &Address,
|
|
34
|
+
owner: &Address,
|
|
35
|
+
endpoint: &Address,
|
|
36
|
+
delegate: &Option<Address>,
|
|
37
|
+
shared_decimals: u32,
|
|
38
|
+
oft_type: OftType,
|
|
39
|
+
) {
|
|
40
|
+
oft_core::initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals);
|
|
41
|
+
OFTStorage::set_oft_type(env, &oft_type);
|
|
152
42
|
}
|
|
153
43
|
|
|
154
|
-
///
|
|
155
|
-
fn
|
|
156
|
-
env
|
|
157
|
-
_executor: &Address,
|
|
158
|
-
origin: &Origin,
|
|
159
|
-
guid: &BytesN<32>,
|
|
160
|
-
message: &Bytes,
|
|
161
|
-
_extra_data: &Bytes,
|
|
162
|
-
_value: i128,
|
|
163
|
-
) {
|
|
164
|
-
crate::default_oft_impl::default_lz_receive::<Self>(env, _executor, origin, guid, message, _extra_data, _value)
|
|
44
|
+
/// Returns the type of operation for this OFT (LockUnlock or MintBurn)
|
|
45
|
+
pub fn oft_type(env: &Env) -> OftType {
|
|
46
|
+
OFTStorage::oft_type(env).unwrap()
|
|
165
47
|
}
|
|
166
48
|
}
|
|
167
49
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
50
|
+
/// OFTCore trait implementation for standard OFT with extensions
|
|
51
|
+
#[contract_impl(contracttrait)]
|
|
52
|
+
impl OFTCore for OFT {
|
|
53
|
+
fn quote_oft(env: &Env, send_param: &SendParam) -> (OFTLimit, Vec<OFTFeeDetail>, OFTReceipt) {
|
|
54
|
+
Self::__assert_not_paused(env);
|
|
55
|
+
|
|
56
|
+
let oft_receipt = Self::__debit_view(env, send_param.amount_ld, send_param.min_amount_ld, send_param.dst_eid);
|
|
57
|
+
|
|
58
|
+
// fee details (only include if there's an actual fee)
|
|
59
|
+
let fee_amount_ld = oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld;
|
|
60
|
+
let fee_details = if fee_amount_ld > 0 {
|
|
61
|
+
vec![env, OFTFeeDetail { fee_amount_ld, description: Bytes::from_slice(env, b"OFT Fee") }]
|
|
62
|
+
} else {
|
|
63
|
+
vec![env]
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// rate limit capacity
|
|
67
|
+
let capacity = Self::rate_limit_capacity(env, &Direction::Outbound, send_param.dst_eid);
|
|
68
|
+
let oft_limit = OFTLimit { min_amount_ld: 0, max_amount_ld: capacity };
|
|
69
|
+
|
|
70
|
+
(oft_limit, fee_details, oft_receipt)
|
|
184
71
|
}
|
|
185
72
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
(
|
|
73
|
+
fn quote_send(env: &Env, sender: &Address, send_param: &SendParam, pay_in_zro: bool) -> MessagingFee {
|
|
74
|
+
Self::__assert_not_paused(env);
|
|
75
|
+
oft_core::quote_send::<Self>(env, sender, send_param, pay_in_zro)
|
|
189
76
|
}
|
|
77
|
+
}
|
|
190
78
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
let local_decimals = soroban_sdk::token::TokenClient::new(env, &token).decimals();
|
|
79
|
+
/// OFT behavior for standard OFT with extension hooks
|
|
80
|
+
impl OFTInternal for OFT {
|
|
81
|
+
fn __debit_view(env: &Env, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
195
82
|
let conversion_rate = Self::decimal_conversion_rate(env);
|
|
196
|
-
local_decimals - conversion_rate.ilog10()
|
|
197
|
-
}
|
|
198
83
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
84
|
+
// Apply the fee before dust removal to ensure the fee is calculated on the full amount and dust is not transferred
|
|
85
|
+
let fee = Self::__fee_view(env, dst_eid, amount_ld);
|
|
86
|
+
let amount_after_fee = amount_ld - fee;
|
|
87
|
+
let amount_received_ld = oft_utils::remove_dust(amount_after_fee, conversion_rate);
|
|
88
|
+
|
|
89
|
+
// amount_sent_ld = what recipient receives + fee charged
|
|
90
|
+
// Dust is excluded (stays with sender)
|
|
91
|
+
let amount_sent_ld = amount_received_ld + fee;
|
|
203
92
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
///
|
|
208
|
-
/// # Returns
|
|
209
|
-
/// - `true` if a separate token approval step is required
|
|
210
|
-
/// - `false` if no separate approval is needed
|
|
211
|
-
fn approval_required(_env: &Env) -> bool {
|
|
212
|
-
false
|
|
93
|
+
assert_with_error!(env, amount_received_ld >= min_amount_ld, OFTError::SlippageExceeded);
|
|
94
|
+
|
|
95
|
+
OFTReceipt { amount_sent_ld, amount_received_ld }
|
|
213
96
|
}
|
|
214
97
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
env
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
98
|
+
fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
|
|
99
|
+
// 1. Pausable check
|
|
100
|
+
Self::__assert_not_paused(env);
|
|
101
|
+
|
|
102
|
+
// 2. Core debit logic (based on oft_type)
|
|
103
|
+
let oft_receipt = match Self::oft_type(env) {
|
|
104
|
+
OftType::LockUnlock => lock_unlock::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid),
|
|
105
|
+
OftType::MintBurn => mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// 3. Rate limit checks (using amount_received_ld - the actual cross-chain amount)
|
|
109
|
+
Self::__consume_rate_limit_capacity(env, &Direction::Outbound, dst_eid, oft_receipt.amount_received_ld);
|
|
110
|
+
Self::__release_rate_limit_capacity(env, &Direction::Inbound, dst_eid, oft_receipt.amount_received_ld);
|
|
111
|
+
|
|
112
|
+
// 4. Charge fee
|
|
113
|
+
let fee = oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld;
|
|
114
|
+
Self::__charge_fee(env, &Self::token(env), sender, fee);
|
|
115
|
+
|
|
116
|
+
oft_receipt
|
|
224
117
|
}
|
|
225
118
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
env
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
119
|
+
fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
|
|
120
|
+
// 1. Pausable check
|
|
121
|
+
Self::__assert_not_paused(env);
|
|
122
|
+
|
|
123
|
+
// 2. Core credit logic (based on mode)
|
|
124
|
+
let amount_credited = match Self::oft_type(env) {
|
|
125
|
+
OftType::LockUnlock => lock_unlock::credit::<Self>(env, to, amount_ld, src_eid),
|
|
126
|
+
OftType::MintBurn => mint_burn::credit::<Self>(env, to, amount_ld, src_eid),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// 3. Rate limit checks (using amount_credited - the actual credited amount)
|
|
130
|
+
Self::__consume_rate_limit_capacity(env, &Direction::Inbound, src_eid, amount_credited);
|
|
131
|
+
Self::__release_rate_limit_capacity(env, &Direction::Outbound, src_eid, amount_credited);
|
|
132
|
+
|
|
133
|
+
amount_credited
|
|
234
134
|
}
|
|
135
|
+
}
|
|
235
136
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
///
|
|
240
|
-
/// # Returns
|
|
241
|
-
/// (MessagingReceipt, OFTReceipt)
|
|
242
|
-
fn send(
|
|
137
|
+
/// LzReceiveInternal implementation using default OFT receive logic
|
|
138
|
+
impl LzReceiveInternal for OFT {
|
|
139
|
+
fn __lz_receive(
|
|
243
140
|
env: &Env,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
141
|
+
origin: &Origin,
|
|
142
|
+
guid: &BytesN<32>,
|
|
143
|
+
message: &Bytes,
|
|
144
|
+
extra_data: &Bytes,
|
|
145
|
+
executor: &Address,
|
|
146
|
+
value: i128,
|
|
147
|
+
) {
|
|
148
|
+
oft_core::lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
|
|
250
149
|
}
|
|
251
150
|
}
|
|
151
|
+
|
|
152
|
+
// ==================== Extension Trait Implementations ====================
|
|
153
|
+
|
|
154
|
+
/// Pausable extension - allows pausing/unpausing the OFT
|
|
155
|
+
/// Default state: unpaused (all operations allowed)
|
|
156
|
+
#[contract_impl(contracttrait)]
|
|
157
|
+
impl OFTPausable for OFT {}
|
|
158
|
+
|
|
159
|
+
impl OFTPausableInternal for OFT {}
|
|
160
|
+
|
|
161
|
+
/// OFT Fee extension - allows collecting fees on transfers
|
|
162
|
+
/// Default state: 0 BPS (no fee collected)
|
|
163
|
+
#[contract_impl(contracttrait)]
|
|
164
|
+
impl OFTFee for OFT {}
|
|
165
|
+
|
|
166
|
+
impl OFTFeeInternal for OFT {}
|
|
167
|
+
|
|
168
|
+
/// Rate Limiter extension - allows rate limiting transfers
|
|
169
|
+
/// Default state: not set (rate_limit_capacity returns i128::MAX)
|
|
170
|
+
#[contract_impl(contracttrait)]
|
|
171
|
+
impl RateLimiter for OFT {}
|
|
172
|
+
|
|
173
|
+
impl RateLimiterInternal for OFT {}
|
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
//! tokens from the contract on credit (receive).
|
|
5
5
|
//! Used for OFT adapters that wrap existing tokens.
|
|
6
6
|
|
|
7
|
+
use oft_core::{oft_core::OFTCore, types::OFTReceipt};
|
|
7
8
|
use soroban_sdk::{token::TokenClient, Address, Env};
|
|
8
9
|
|
|
9
|
-
use crate::oft::OFT;
|
|
10
|
-
use crate::types::OFTReceipt;
|
|
11
|
-
|
|
12
10
|
/// Debit tokens using LockUnlock OFT type (locks tokens in contract).
|
|
13
11
|
///
|
|
14
12
|
/// # Parameters
|
|
@@ -20,7 +18,13 @@ use crate::types::OFTReceipt;
|
|
|
20
18
|
///
|
|
21
19
|
/// # Returns
|
|
22
20
|
/// `OFTReceipt` containing the amount sent and amount received
|
|
23
|
-
pub fn debit<T:
|
|
21
|
+
pub fn debit<T: OFTCore>(
|
|
22
|
+
env: &Env,
|
|
23
|
+
sender: &Address,
|
|
24
|
+
amount_ld: i128,
|
|
25
|
+
min_amount_ld: i128,
|
|
26
|
+
dst_eid: u32,
|
|
27
|
+
) -> OFTReceipt {
|
|
24
28
|
let receipt: OFTReceipt = T::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
|
|
25
29
|
TokenClient::new(env, &T::token(env)).transfer(sender, env.current_contract_address(), &receipt.amount_received_ld);
|
|
26
30
|
receipt
|
|
@@ -36,15 +40,7 @@ pub fn debit<T: OFT>(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld
|
|
|
36
40
|
///
|
|
37
41
|
/// # Returns
|
|
38
42
|
/// The amount credited
|
|
39
|
-
pub fn credit<T:
|
|
43
|
+
pub fn credit<T: OFTCore>(env: &Env, to: &Address, amount_ld: i128, _src_eid: u32) -> i128 {
|
|
40
44
|
TokenClient::new(env, &T::token(env)).transfer(&env.current_contract_address(), to, &amount_ld);
|
|
41
45
|
amount_ld
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
/// Returns whether approval is required for LockUnlock OFT type.
|
|
45
|
-
///
|
|
46
|
-
/// # Returns
|
|
47
|
-
/// Always `false` - approval not needed for transfer operations
|
|
48
|
-
pub fn approval_required() -> bool {
|
|
49
|
-
false
|
|
50
|
-
}
|
|
@@ -3,11 +3,30 @@
|
|
|
3
3
|
//! This OFT type burns tokens on debit (send) and mints tokens on credit (receive).
|
|
4
4
|
//! Used when the OFT contract has mint/burn authority over the token.
|
|
5
5
|
|
|
6
|
-
use
|
|
6
|
+
use oft_core::{oft_core::OFTCore, types::OFTReceipt};
|
|
7
|
+
use soroban_sdk::{contractclient, Address, Env};
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/// Contract interface for mint and burn token operations.
|
|
10
|
+
///
|
|
11
|
+
/// This interface abstracts the token mint/burn functionality, allowing different
|
|
12
|
+
/// token implementations (e.g., StellarAssetContract, custom tokens) to be used
|
|
13
|
+
/// with the MintBurn OFT.
|
|
14
|
+
#[contractclient(name = "MintBurnTokenClient")]
|
|
15
|
+
pub trait MintBurnToken {
|
|
16
|
+
/// Mints tokens to the specified address.
|
|
17
|
+
///
|
|
18
|
+
/// # Parameters
|
|
19
|
+
/// * `to` - The address to mint tokens to
|
|
20
|
+
/// * `amount` - The amount of tokens to mint (must be non-negative)
|
|
21
|
+
fn mint(env: Env, to: Address, amount: i128);
|
|
22
|
+
|
|
23
|
+
/// Burns tokens from the specified address.
|
|
24
|
+
///
|
|
25
|
+
/// # Parameters
|
|
26
|
+
/// * `from` - The address to burn tokens from
|
|
27
|
+
/// * `amount` - The amount of tokens to burn (must be non-negative)
|
|
28
|
+
fn burn(env: Env, from: Address, amount: i128);
|
|
29
|
+
}
|
|
11
30
|
|
|
12
31
|
/// Debit tokens using MintBurn OFT type (burns tokens from sender).
|
|
13
32
|
///
|
|
@@ -20,7 +39,13 @@ use crate::types::OFTReceipt;
|
|
|
20
39
|
///
|
|
21
40
|
/// # Returns
|
|
22
41
|
/// `OFTReceipt` containing the amount sent and amount received
|
|
23
|
-
pub fn debit<T:
|
|
42
|
+
pub fn debit<T: OFTCore>(
|
|
43
|
+
env: &Env,
|
|
44
|
+
sender: &Address,
|
|
45
|
+
amount_ld: i128,
|
|
46
|
+
min_amount_ld: i128,
|
|
47
|
+
dst_eid: u32,
|
|
48
|
+
) -> OFTReceipt {
|
|
24
49
|
let receipt = T::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
|
|
25
50
|
MintBurnTokenClient::new(env, &T::token(env)).burn(sender, &receipt.amount_received_ld);
|
|
26
51
|
receipt
|
|
@@ -36,15 +61,7 @@ pub fn debit<T: OFT>(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld
|
|
|
36
61
|
///
|
|
37
62
|
/// # Returns
|
|
38
63
|
/// The amount credited
|
|
39
|
-
pub fn credit<T:
|
|
64
|
+
pub fn credit<T: OFTCore>(env: &Env, to: &Address, amount_ld: i128, _src_eid: u32) -> i128 {
|
|
40
65
|
MintBurnTokenClient::new(env, &T::token(env)).mint(to, &amount_ld);
|
|
41
66
|
amount_ld
|
|
42
67
|
}
|
|
43
|
-
|
|
44
|
-
/// Returns whether approval is required for MintBurn OFT type.
|
|
45
|
-
///
|
|
46
|
-
/// # Returns
|
|
47
|
-
/// Always `false` - approval not needed for mint/burn operations.
|
|
48
|
-
pub fn approval_required() -> bool {
|
|
49
|
-
false
|
|
50
|
-
}
|
|
@@ -6,5 +6,18 @@
|
|
|
6
6
|
//! - **LockUnlock**: Locks tokens on send, unlocks on receive. Approval not required.
|
|
7
7
|
//!
|
|
8
8
|
|
|
9
|
+
use soroban_sdk::contracttype;
|
|
10
|
+
|
|
9
11
|
pub mod lock_unlock;
|
|
10
12
|
pub mod mint_burn;
|
|
13
|
+
|
|
14
|
+
/// The type of OFT operation mode
|
|
15
|
+
#[contracttype]
|
|
16
|
+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
17
|
+
#[repr(u8)]
|
|
18
|
+
pub enum OftType {
|
|
19
|
+
/// Lock tokens on send, unlock on receive
|
|
20
|
+
LockUnlock = 0,
|
|
21
|
+
/// Burn tokens on send, mint on receive
|
|
22
|
+
MintBurn = 1,
|
|
23
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[package]
|
|
2
|
-
name = "oft-
|
|
2
|
+
name = "oft-core"
|
|
3
3
|
version.workspace = true
|
|
4
4
|
edition.workspace = true
|
|
5
5
|
license.workspace = true
|
|
6
6
|
|
|
7
7
|
[lib]
|
|
8
|
-
crate-type = ["
|
|
8
|
+
crate-type = ["rlib"]
|
|
9
9
|
doctest = false
|
|
10
10
|
|
|
11
11
|
[dependencies]
|
|
@@ -14,8 +14,6 @@ endpoint-v2 = { workspace = true, features = ["library"] }
|
|
|
14
14
|
utils = { workspace = true }
|
|
15
15
|
oapp = { workspace = true }
|
|
16
16
|
common-macros = { workspace = true }
|
|
17
|
-
oapp-macros = { workspace = true }
|
|
18
|
-
oft = { workspace = true }
|
|
19
17
|
|
|
20
18
|
[dev-dependencies]
|
|
21
19
|
soroban-sdk = { workspace = true, features = ["testutils"] }
|
|
@@ -23,3 +21,7 @@ simple-message-lib = { workspace = true }
|
|
|
23
21
|
message-lib-common = { workspace = true, features = ["testutils"] }
|
|
24
22
|
endpoint-v2 = { workspace = true, features = ["testutils"] }
|
|
25
23
|
utils = { workspace = true, features = ["testutils"] }
|
|
24
|
+
insta = { workspace = true }
|
|
25
|
+
oapp-macros = { workspace = true }
|
|
26
|
+
stellar-macros = { workspace = true }
|
|
27
|
+
stellar-tokens = { workspace = true }
|