Skip to content

Commit 2ff4988

Browse files
authored
Solana: clarify V2 receive/compose docs (#169)
* update documentation for `LzReceiveTypesV2Accounts` * Enhance documentation for `LzComposeTypesV2Accounts`
1 parent c09287a commit 2ff4988

File tree

4 files changed

+66
-52
lines changed

4 files changed

+66
-52
lines changed

packages/layerzero-v2/solana/anchor-latest/libs/oapp/src/lz_compose_types_v2.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@ use endpoint_interface::COMPOSED_MESSAGE_HASH_SEED;
44

55
pub const LZ_COMPOSE_TYPES_VERSION: u8 = 2;
66

7-
/// The payload returned from `lz_compose_types_info` when version == 2.
8-
/// Provides information needed to construct the call to `lz_compose_types_v2`.
7+
/// Return payload of `lz_compose_types_info` (version == 2).
8+
/// Used by the Executor to construct the call to `lz_compose_types_v2`.
99
///
10-
/// This structure is stored at a deterministic PDA and serves as the bridge between
11-
/// the version discovery phase and the actual execution planning phase of V2.
10+
/// `lz_compose_types_info` accounts:
11+
/// 1. `composer_account`: the Composer identity/account.
12+
/// 2. `lz_compose_types_accounts`: PDA derived with `seeds = [LZ_COMPOSE_TYPES_SEED,
13+
/// &composer_account.key().to_bytes()]`.
14+
/// The program reads this PDA to compute and return `LzComposeTypesV2Accounts`.
1215
///
16+
/// Execution flow:
17+
/// 1. Version discovery: call `lz_compose_types_info`; when version is 2, decode into
18+
/// `LzComposeTypesV2Accounts`.
19+
/// 2. Execution planning: build the account metas for `lz_compose_types_v2` from the decoded value;
20+
/// calling `lz_compose_types_v2` returns the complete execution plan.
21+
///
22+
/// Fields:
23+
/// - `accounts`: `Pubkey`s returned by `lz_compose_types_info`.
1324
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
1425
pub struct LzComposeTypesV2Accounts {
1526
pub accounts: Vec<Pubkey>,
1627
}
1728

1829
/// Output of the lz_compose_types_v2 instruction.
1930
///
20-
/// This structure enables the multi-instruction execution model where OApps can
31+
/// This structure enables the multi-instruction execution model where Composer can
2132
/// define multiple instructions to be executed atomically by the Executor.
2233
/// The Executor constructs a single transaction containing all returned instructions.
2334
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
@@ -38,8 +49,8 @@ pub struct LzComposeTypesV2Result {
3849
/// The list of instructions that can be executed in the LzCompose transaction.
3950
///
4051
/// V2's multi-instruction model enables complex patterns such as:
41-
/// - Preprocessing steps before lz_receive (e.g., account initialization)
42-
/// - Postprocessing steps after lz_receive (e.g., verification, cleanup)
52+
/// - Preprocessing steps before lz_compose (e.g., account initialization)
53+
/// - Postprocessing steps after lz_compose (e.g., verification, cleanup)
4354
/// - ABA messaging patterns with additional LayerZero sends
4455
/// - Conditional execution flows based on message content
4556
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
@@ -52,7 +63,7 @@ pub enum Instruction {
5263
accounts: Vec<AccountMetaRef>,
5364
},
5465
/// Arbitrary custom instruction for preprocessing/postprocessing
55-
/// Enables OApps to implement complex execution flows
66+
/// Enables Composer to implement complex execution flows
5667
Standard {
5768
/// Target program ID for the custom instruction
5869
program_id: Pubkey,

packages/layerzero-v2/solana/anchor-latest/libs/oapp/src/lz_receive_types_v2.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,23 @@ use endpoint_interface::{
1010

1111
pub const LZ_RECEIVE_TYPES_VERSION: u8 = 2;
1212

13-
/// The payload returned from `lz_receive_types_info` when version == 2.
14-
/// Provides information needed to construct the call to `lz_receive_types_v2`.
13+
/// Return payload of `lz_receive_types_info` (version == 2).
14+
/// Used by the Executor to construct the call to `lz_receive_types_v2`.
1515
///
16-
/// This structure is stored at a deterministic PDA and serves as the bridge between
17-
/// the version discovery phase and the actual execution planning phase of V2.
16+
/// `lz_receive_types_info` accounts:
17+
/// 1. `oapp_account`: the OApp identity/account.
18+
/// 2. `lz_receive_types_accounts`: PDA derived with `seeds = [LZ_RECEIVE_TYPES_SEED,
19+
/// &oapp_account.key().to_bytes()]`.
20+
/// The program reads this PDA to compute and return `LzReceiveTypesV2Accounts`.
1821
///
19-
/// # Execution Flow
20-
/// 1. **Version Discovery**: The Executor calls `lz_receive_types_info` using the PDA. If the
21-
/// version is 2, it decodes the returned payload into LzReceiveTypesV2Accounts.
22-
/// 2. **Execution Planning**: The Executor constructs the accounts from LzReceiveTypesV2Accounts to
23-
/// call `lz_receive_types_v2`, which returns the complete execution plan.
22+
/// Execution flow:
23+
/// 1. Version discovery: call `lz_receive_types_info`; when version is 2, decode into
24+
/// `LzReceiveTypesV2Accounts`.
25+
/// 2. Execution planning: build the account metas for `lz_receive_types_v2` from the decoded value;
26+
/// calling `lz_receive_types_v2` returns the complete execution plan.
2427
///
25-
/// # Storage Location
26-
/// This data is stored at a PDA derived using:
27-
/// ```
28-
/// seeds = [LZ_RECEIVE_TYPES_SEED, &oapp_address.to_bytes()]
29-
/// ```
30-
///
31-
/// # Fields
32-
/// - `accounts`: A vector of `Pubkey` containing the static accounts needed to construct the
33-
/// `lz_receive_types_v2` instruction.
28+
/// Fields:
29+
/// - `accounts`: `Pubkey`s returned by `lz_receive_types_info`.
3430
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
3531
pub struct LzReceiveTypesV2Accounts {
3632
pub accounts: Vec<Pubkey>,

packages/layerzero-v2/solana/programs/libs/oapp/src/lz_compose_types_v2.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@ use endpoint::COMPOSED_MESSAGE_HASH_SEED;
44

55
pub const LZ_COMPOSE_TYPES_VERSION: u8 = 2;
66

7-
/// The payload returned from `lz_compose_types_info` when version == 2.
8-
/// Provides information needed to construct the call to `lz_compose_types_v2`.
7+
/// Return payload of `lz_compose_types_info` (version == 2).
8+
/// Used by the Executor to construct the call to `lz_compose_types_v2`.
99
///
10-
/// This structure is stored at a deterministic PDA and serves as the bridge between
11-
/// the version discovery phase and the actual execution planning phase of V2.
10+
/// `lz_compose_types_info` accounts:
11+
/// 1. `composer_account`: the Composer identity/account.
12+
/// 2. `lz_compose_types_accounts`: PDA derived with `seeds = [LZ_COMPOSE_TYPES_SEED,
13+
/// &composer_account.key().to_bytes()]`.
14+
/// The program reads this PDA to compute and return `LzComposeTypesV2Accounts`.
1215
///
16+
/// Execution flow:
17+
/// 1. Version discovery: call `lz_compose_types_info`; when version is 2, decode into
18+
/// `LzComposeTypesV2Accounts`.
19+
/// 2. Execution planning: build the account metas for `lz_compose_types_v2` from the decoded value;
20+
/// calling `lz_compose_types_v2` returns the complete execution plan.
21+
///
22+
/// Fields:
23+
/// - `accounts`: `Pubkey`s returned by `lz_compose_types_info`.
1324
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
1425
pub struct LzComposeTypesV2Accounts {
1526
pub accounts: Vec<Pubkey>,
1627
}
1728

1829
/// Output of the lz_compose_types_v2 instruction.
1930
///
20-
/// This structure enables the multi-instruction execution model where OApps can
31+
/// This structure enables the multi-instruction execution model where Composer can
2132
/// define multiple instructions to be executed atomically by the Executor.
2233
/// The Executor constructs a single transaction containing all returned instructions.
2334
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
@@ -38,8 +49,8 @@ pub struct LzComposeTypesV2Result {
3849
/// The list of instructions that can be executed in the LzCompose transaction.
3950
///
4051
/// V2's multi-instruction model enables complex patterns such as:
41-
/// - Preprocessing steps before lz_receive (e.g., account initialization)
42-
/// - Postprocessing steps after lz_receive (e.g., verification, cleanup)
52+
/// - Preprocessing steps before lz_compose (e.g., account initialization)
53+
/// - Postprocessing steps after lz_compose (e.g., verification, cleanup)
4354
/// - ABA messaging patterns with additional LayerZero sends
4455
/// - Conditional execution flows based on message content
4556
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
@@ -52,7 +63,7 @@ pub enum Instruction {
5263
accounts: Vec<AccountMetaRef>,
5364
},
5465
/// Arbitrary custom instruction for preprocessing/postprocessing
55-
/// Enables OApps to implement complex execution flows
66+
/// Enables Composer to implement complex execution flows
5667
Standard {
5768
/// Target program ID for the custom instruction
5869
program_id: Pubkey,

packages/layerzero-v2/solana/programs/libs/oapp/src/lz_receive_types_v2.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,23 @@ use endpoint::{
1010

1111
pub const LZ_RECEIVE_TYPES_VERSION: u8 = 2;
1212

13-
/// The payload returned from `lz_receive_types_info` when version == 2.
14-
/// Provides information needed to construct the call to `lz_receive_types_v2`.
13+
/// Return payload of `lz_receive_types_info` (version == 2).
14+
/// Used by the Executor to construct the call to `lz_receive_types_v2`.
1515
///
16-
/// This structure is stored at a deterministic PDA and serves as the bridge between
17-
/// the version discovery phase and the actual execution planning phase of V2.
16+
/// `lz_receive_types_info` accounts:
17+
/// 1. `oapp_account`: the OApp identity/account.
18+
/// 2. `lz_receive_types_accounts`: PDA derived with `seeds = [LZ_RECEIVE_TYPES_SEED,
19+
/// &oapp_account.key().to_bytes()]`.
20+
/// The program reads this PDA to compute and return `LzReceiveTypesV2Accounts`.
1821
///
19-
/// # Execution Flow
20-
/// 1. **Version Discovery**: The Executor calls `lz_receive_types_info` using the PDA. If the
21-
/// version is 2, it decodes the returned payload into LzReceiveTypesV2Accounts.
22-
/// 2. **Execution Planning**: The Executor constructs the accounts from LzReceiveTypesV2Accounts to
23-
/// call `lz_receive_types_v2`, which returns the complete execution plan.
22+
/// Execution flow:
23+
/// 1. Version discovery: call `lz_receive_types_info`; when version is 2, decode into
24+
/// `LzReceiveTypesV2Accounts`.
25+
/// 2. Execution planning: build the account metas for `lz_receive_types_v2` from the decoded value;
26+
/// calling `lz_receive_types_v2` returns the complete execution plan.
2427
///
25-
/// # Storage Location
26-
/// This data is stored at a PDA derived using:
27-
/// ```
28-
/// seeds = [LZ_RECEIVE_TYPES_SEED, &oapp_address.to_bytes()]
29-
/// ```
30-
///
31-
/// # Fields
32-
/// - `accounts`: A vector of `Pubkey` containing the static accounts needed to construct the
33-
/// `lz_receive_types_v2` instruction.
28+
/// Fields:
29+
/// - `accounts`: `Pubkey`s returned by `lz_receive_types_info`.
3430
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
3531
pub struct LzReceiveTypesV2Accounts {
3632
pub accounts: Vec<Pubkey>,

0 commit comments

Comments
 (0)