@layerzerolabs/protocol-stellar-v2 0.2.58 → 0.2.60
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 +119 -53
- package/.turbo/turbo-lint.log +144 -277
- package/.turbo/turbo-test.log +1898 -1869
- package/contracts/common-macros/src/auth.rs +1 -1
- package/contracts/common-macros/src/lib.rs +3 -3
- package/contracts/oapps/oapp/src/oapp_receiver.rs +2 -1
- package/contracts/oapps/oapp/src/oapp_sender.rs +2 -2
- package/contracts/oapps/oapp-macros/src/lib.rs +12 -2
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +2 -1
- package/contracts/oapps/oft-core/src/codec/oft_compose_msg_codec.rs +1 -1
- package/contracts/oapps/oft-core/src/oft_core.rs +12 -14
- package/package.json +4 -4
- package/sdk/.turbo/turbo-test.log +278 -278
- package/sdk/dist/generated/counter.d.ts +4 -4
- package/sdk/dist/generated/counter.js +4 -4
- package/sdk/dist/generated/oft.d.ts +7 -8
- package/sdk/dist/generated/oft.js +5 -5
- package/sdk/package.json +1 -1
|
@@ -19,7 +19,7 @@ use syn::{parse_quote, ItemFn, ItemStruct};
|
|
|
19
19
|
/// This macro implements `OwnableInitializer`, `Auth`, and `Ownable` traits for the contract:
|
|
20
20
|
/// - `OwnableInitializer` provides `init_owner()` for constructor use
|
|
21
21
|
/// - `Auth::authorizer()` returns the stored owner address
|
|
22
|
-
/// - `Ownable` provides ownership management (transfer,
|
|
22
|
+
/// - `Ownable` provides ownership management (transfer, accept, renounce)
|
|
23
23
|
pub fn generate_ownable_impl(input: TokenStream) -> TokenStream {
|
|
24
24
|
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
25
25
|
let name = &item_struct.ident;
|
|
@@ -257,7 +257,7 @@ pub fn only_auth(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
257
257
|
/// # Requirements
|
|
258
258
|
/// - The function must have an `Env` parameter
|
|
259
259
|
/// - The function must have a parameter matching the first macro arg (of type `Address` or `&Address`)
|
|
260
|
-
/// - The contract must
|
|
260
|
+
/// - The contract must implement `RoleBasedAccessControl` (which extends `Auth`)
|
|
261
261
|
///
|
|
262
262
|
/// # Example
|
|
263
263
|
/// ```ignore
|
|
@@ -273,7 +273,7 @@ pub fn only_auth(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
273
273
|
/// # Generated code
|
|
274
274
|
/// ```ignore
|
|
275
275
|
/// pub fn mint(env: Env, caller: Address, amount: i128) {
|
|
276
|
-
/// utils::rbac::ensure_role(&env, &soroban_sdk::Symbol::new(&env, "minter"), &caller);
|
|
276
|
+
/// utils::rbac::ensure_role::<Self>(&env, &soroban_sdk::Symbol::new(&env, "minter"), &caller);
|
|
277
277
|
/// // Original function body (no require_auth)
|
|
278
278
|
/// }
|
|
279
279
|
/// ```
|
|
@@ -307,7 +307,7 @@ pub fn has_role(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
307
307
|
/// # Generated code
|
|
308
308
|
/// ```ignore
|
|
309
309
|
/// pub fn mint(env: Env, caller: Address, amount: i128) {
|
|
310
|
-
/// utils::rbac::ensure_role(&env, &soroban_sdk::Symbol::new(&env, "minter"), &caller);
|
|
310
|
+
/// utils::rbac::ensure_role::<Self>(&env, &soroban_sdk::Symbol::new(&env, "minter"), &caller);
|
|
311
311
|
/// caller.require_auth();
|
|
312
312
|
/// // Original function body
|
|
313
313
|
/// }
|
|
@@ -59,6 +59,7 @@ pub trait LzReceiveInternal {
|
|
|
59
59
|
/// ```ignore
|
|
60
60
|
/// use oapp::oapp_receiver::LzReceiveInternal;
|
|
61
61
|
///
|
|
62
|
+
/// #[common_macros::lz_contract]
|
|
62
63
|
/// #[oapp_macros::oapp]
|
|
63
64
|
/// pub struct MyOApp;
|
|
64
65
|
///
|
|
@@ -112,7 +113,7 @@ pub trait OAppReceiver: OAppCore + LzReceiveInternal {
|
|
|
112
113
|
/// # Arguments
|
|
113
114
|
/// * `executor` - The address of the executor for the received message
|
|
114
115
|
/// * `origin` - The origin information containing the source endpoint and sender address:
|
|
115
|
-
/// - `src_eid`: The source
|
|
116
|
+
/// - `src_eid`: The source endpoint ID
|
|
116
117
|
/// - `sender`: The sender address on the source chain
|
|
117
118
|
/// - `nonce`: The nonce of the message
|
|
118
119
|
/// * `guid` - The unique identifier for the received LayerZero message
|
|
@@ -51,13 +51,13 @@ impl FeePayer {
|
|
|
51
51
|
|
|
52
52
|
/// A helper trait for sending cross-chain messages via LayerZero.
|
|
53
53
|
///
|
|
54
|
-
/// Contracts should implement this trait to gain access to the `
|
|
54
|
+
/// Contracts should implement this trait to gain access to the `__quote` and `__lz_send` helper
|
|
55
55
|
/// methods for cross-chain messaging. This trait provides default implementations that handle
|
|
56
56
|
/// fee payment and message dispatch through the LayerZero endpoint.
|
|
57
57
|
///
|
|
58
58
|
/// # Important
|
|
59
59
|
/// This trait is intended to be used as an **internal helper** only. Do **NOT** expose these
|
|
60
|
-
/// methods as part of your contract's public interface (i.e., do not use `#[
|
|
60
|
+
/// methods as part of your contract's public interface (i.e., do not use `#[contract_impl]` on
|
|
61
61
|
/// the implementation of this trait). Instead, call these methods internally from your
|
|
62
62
|
/// contract's own public functions.
|
|
63
63
|
pub trait OAppSenderInternal: OAppCore {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
//! use oapp_macros::oapp;
|
|
40
40
|
//!
|
|
41
41
|
//! #[oapp]
|
|
42
|
+
//! #[common_macros::lz_contract]
|
|
42
43
|
//! struct MyOApp;
|
|
43
44
|
//!
|
|
44
45
|
//! // Implement LzReceiveInternal to handle incoming messages
|
|
@@ -61,12 +62,16 @@
|
|
|
61
62
|
//!
|
|
62
63
|
//! ```ignore
|
|
63
64
|
//! use oapp::oapp_receiver::LzReceiveInternal;
|
|
65
|
+
//! use utils::rbac::RoleBasedAccessControl;
|
|
64
66
|
//!
|
|
65
67
|
//! #[oapp(custom = [core])]
|
|
68
|
+
//! #[common_macros::lz_contract]
|
|
66
69
|
//! struct MyOApp;
|
|
67
70
|
//!
|
|
71
|
+
//! // Required: `custom = [core]` skips generating both OAppCore and RoleBasedAccessControl impls
|
|
72
|
+
//! impl RoleBasedAccessControl for MyOApp {}
|
|
73
|
+
//!
|
|
68
74
|
//! #[contractimpl(contracttrait)]
|
|
69
|
-
//! #[common_macros::ownable]
|
|
70
75
|
//! impl OAppCore for MyOApp {
|
|
71
76
|
//! fn oapp_version(_env: &Env) -> (u64, u64) {
|
|
72
77
|
//! (1, 1) // Custom version
|
|
@@ -84,6 +89,7 @@
|
|
|
84
89
|
//! use oapp::oapp_receiver::{LzReceiveInternal, OAppReceiver};
|
|
85
90
|
//!
|
|
86
91
|
//! #[oapp(custom = [receiver])]
|
|
92
|
+
//! #[common_macros::lz_contract]
|
|
87
93
|
//! struct MyOrderedOApp;
|
|
88
94
|
//!
|
|
89
95
|
//! impl LzReceiveInternal for MyOrderedOApp {
|
|
@@ -106,12 +112,16 @@
|
|
|
106
112
|
//!
|
|
107
113
|
//! ```ignore
|
|
108
114
|
//! use oapp::oapp_receiver::LzReceiveInternal;
|
|
115
|
+
//! use utils::rbac::RoleBasedAccessControl;
|
|
109
116
|
//!
|
|
110
117
|
//! #[oapp(custom = [core, sender, options_type3])]
|
|
118
|
+
//! #[common_macros::lz_contract]
|
|
111
119
|
//! struct MyCustomOApp;
|
|
112
120
|
//!
|
|
121
|
+
//! // Required: `custom = [core]` skips generating both OAppCore and RoleBasedAccessControl impls
|
|
122
|
+
//! impl RoleBasedAccessControl for MyCustomOApp {}
|
|
123
|
+
//!
|
|
113
124
|
//! #[contractimpl(contracttrait)]
|
|
114
|
-
//! #[common_macros::ownable]
|
|
115
125
|
//! impl OAppCore for MyCustomOApp { /* ... */ }
|
|
116
126
|
//! impl OAppSenderInternal for MyCustomOApp { /* ... */ }
|
|
117
127
|
//! #[contractimpl(contracttrait)]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//! MintBurn type implementation for OFT.
|
|
2
2
|
//!
|
|
3
3
|
//! This OFT type burns tokens on debit (send) and mints tokens on credit (receive).
|
|
4
|
-
//!
|
|
4
|
+
//! On debit, tokens are burned from the sender via the token's SEP-41 `burn`.
|
|
5
|
+
//! On credit, tokens are minted to the recipient via a separate Mintable contract.
|
|
5
6
|
|
|
6
7
|
use crate::interfaces::MintableClient;
|
|
7
8
|
use oft_core::OFTCore;
|
|
@@ -6,7 +6,7 @@ use utils::{buffer_reader::BufferReader, buffer_writer::BufferWriter};
|
|
|
6
6
|
pub struct OFTComposeMsg {
|
|
7
7
|
/// Unique sequence number for the cross-chain message packet
|
|
8
8
|
pub nonce: u64,
|
|
9
|
-
/// Source
|
|
9
|
+
/// Source endpoint ID where the transfer originated
|
|
10
10
|
pub src_eid: u32,
|
|
11
11
|
/// Amount received in local decimals
|
|
12
12
|
pub amount_ld: i128,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//!
|
|
3
3
|
//! This module provides:
|
|
4
4
|
//! - `OFTInternal`: Internal methods NOT exposed as contract entrypoints (`__debit`, `__credit`, `__initialize_oft`, `__receive`, etc.)
|
|
5
|
-
//! - `OFTCore`: Public methods exposed as contract entrypoints (using `#[
|
|
5
|
+
//! - `OFTCore`: Public methods exposed as contract entrypoints (using `#[contract_trait]`)
|
|
6
6
|
//! - `impl_oft_lz_receive!`: Macro to implement `LzReceiveInternal` with default OFT receive logic
|
|
7
7
|
//!
|
|
8
8
|
//! ## Usage
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
//! use oapp_macros::oapp;
|
|
12
12
|
//! use oft_core::{OFTInternal, OFTCore, impl_oft_lz_receive};
|
|
13
13
|
//!
|
|
14
|
+
//! #[common_macros::lz_contract]
|
|
14
15
|
//! #[oapp]
|
|
15
16
|
//! pub struct MyOFT;
|
|
16
17
|
//!
|
|
17
|
-
//! #[
|
|
18
|
+
//! #[contract_impl]
|
|
18
19
|
//! impl MyOFT {
|
|
19
20
|
//! pub fn __constructor(env: &Env, token: &Address, owner: &Address, endpoint: &Address, delegate: &Address) {
|
|
20
21
|
//! Self::__initialize_oft(env, token, 6, owner, endpoint, delegate)
|
|
@@ -22,20 +23,18 @@
|
|
|
22
23
|
//! }
|
|
23
24
|
//!
|
|
24
25
|
//! // Public methods - exposed as contract entrypoints
|
|
25
|
-
//! #[
|
|
26
|
+
//! #[contract_impl(contracttrait)]
|
|
26
27
|
//! impl OFTCore for MyOFT {}
|
|
27
28
|
//!
|
|
28
29
|
//! // Internal methods - NOT exposed as contract entrypoints
|
|
29
|
-
//! // IMPORTANT: Do NOT use #[
|
|
30
|
+
//! // IMPORTANT: Do NOT use #[contract_impl] here to keep methods internal
|
|
30
31
|
//! impl OFTInternal for MyOFT {
|
|
31
|
-
//! fn __debit(env: &Env,
|
|
32
|
-
//! // Your debit logic (
|
|
33
|
-
//! oft_core::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
|
|
32
|
+
//! fn __debit(env: &Env, from: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> (i128, i128) {
|
|
33
|
+
//! // Your debit logic: lock tokens (LockUnlock) or burn tokens (MintBurn)
|
|
34
34
|
//! }
|
|
35
35
|
//!
|
|
36
36
|
//! fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
|
|
37
|
-
//! // Your credit logic (
|
|
38
|
-
//! oft_core::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
|
|
37
|
+
//! // Your credit logic: unlock tokens (LockUnlock) or mint tokens (MintBurn)
|
|
39
38
|
//! }
|
|
40
39
|
//! }
|
|
41
40
|
//!
|
|
@@ -136,7 +135,7 @@ pub trait OFTInternal: OAppReceiver + OAppSenderInternal + OAppOptionsType3 + Ow
|
|
|
136
135
|
/// * `from` - The address to debit the tokens from
|
|
137
136
|
/// * `amount_ld` - The amount of tokens to send in local decimals
|
|
138
137
|
/// * `min_amount_ld` - The minimum amount to send in local decimals
|
|
139
|
-
/// * `dst_eid` - The destination
|
|
138
|
+
/// * `dst_eid` - The destination endpoint ID
|
|
140
139
|
///
|
|
141
140
|
/// # Returns
|
|
142
141
|
/// * `amount_sent_ld` - The amount sent in local decimals
|
|
@@ -418,10 +417,9 @@ pub trait OFTCore: OFTInternal {
|
|
|
418
417
|
|
|
419
418
|
/// Indicates whether the caller must approve a token allowance before calling [`send`](OFTCore::send).
|
|
420
419
|
///
|
|
421
|
-
/// - **`false`** (default) —
|
|
422
|
-
///
|
|
423
|
-
///
|
|
424
|
-
/// sender to call `token.approve(oft_address, amount)` beforehand.
|
|
420
|
+
/// - **`false`** (default) — no separate approval step is needed.
|
|
421
|
+
/// - **`true`** — the caller must grant a token allowance to this contract before
|
|
422
|
+
/// sending (e.g., via `token.approve(oft_address, amount, ...)`).
|
|
425
423
|
///
|
|
426
424
|
/// Wallet and frontend integrators should check this to determine whether an approval
|
|
427
425
|
/// transaction must precede the send.
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/protocol-stellar-v2",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.60",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "LZBL-1.2",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@types/node": "^22.18.6",
|
|
8
8
|
"tsx": "^4.19.3",
|
|
9
9
|
"typescript": "^5.8.2",
|
|
10
|
-
"@layerzerolabs/
|
|
11
|
-
"@layerzerolabs/
|
|
12
|
-
"@layerzerolabs/
|
|
10
|
+
"@layerzerolabs/common-node-utils": "0.2.60",
|
|
11
|
+
"@layerzerolabs/stellar-ts-bindings-gen": "0.2.60",
|
|
12
|
+
"@layerzerolabs/vm-tooling-stellar": "0.2.60"
|
|
13
13
|
},
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "restricted",
|