Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(svm): format docstrings #853

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions programs/svm-spoke/src/instructions/token_bridge.rs
Original file line number Diff line number Diff line change
@@ -40,28 +40,28 @@ pub struct BridgeTokensToHubPool<'info> {
pub token_messenger_minter_sender_authority: UncheckedAccount<'info>,

/// CHECK: MessageTransmitter is checked in CCTP. Seeds must be \["message_transmitter"\] (CCTP Message Transmitter
/// program).
// program).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turning these into double slashes doesn't remove them from docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should remove them from the docs, aren't they?

Copy link
Contributor

@md0x md0x Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, yes, before your change, Anchor was adding program). to the documentation.
Now, it doesn’t add documentation for this account (expected behavior).

Before your fix:

        {
          "name": "message_transmitter",
          "docs": [
            "program)."
          ],
          "writable": true
        },

After fix:

        {
          "name": "message_transmitter",
          "writable": true
        },

All good!

#[account(mut)]
pub message_transmitter: UncheckedAccount<'info>,

/// CHECK: TokenMessenger is checked in CCTP. Seeds must be \["token_messenger"\] (CCTP Token Messenger Minter
/// program).
// program).
pub token_messenger: UncheckedAccount<'info>,

/// CHECK: RemoteTokenMessenger is checked in CCTP. Seeds must be \["remote_token_messenger"\,
/// remote_domain.to_string()] (CCTP Token Messenger Minter program).
// remote_domain.to_string()] (CCTP Token Messenger Minter program).
pub remote_token_messenger: UncheckedAccount<'info>,

/// CHECK: TokenMinter is checked in CCTP. Seeds must be \["token_minter"\] (CCTP Token Messenger Minter program).
pub token_minter: UncheckedAccount<'info>,

/// CHECK: LocalToken is checked in CCTP. Seeds must be \["local_token", mint\] (CCTP Token Messenger Minter
/// program).
// program).
#[account(mut)]
pub local_token: UncheckedAccount<'info>,

/// CHECK: EventAuthority is checked in CCTP. Seeds must be \["__event_authority"\] (CCTP Token Messenger Minter
/// program).
// program).
pub cctp_event_authority: UncheckedAccount<'info>,

#[account(mut)]
50 changes: 25 additions & 25 deletions programs/svm-spoke/src/lib.rs
Original file line number Diff line number Diff line change
@@ -32,9 +32,9 @@ use utils::*;
pub mod svm_spoke {
use super::*;

/// **************************************
/// ADMIN FUNCTIONS *
/// *************************************
// **************************************
// ADMIN FUNCTIONS *
// *************************************

/// Initializes the state for the SVM Spoke Pool. Only callable once.
///
@@ -194,16 +194,16 @@ pub mod svm_spoke {
instructions::emergency_delete_root_bundle(ctx, root_bundle_id)
}

/// **************************************
/// DEPOSIT FUNCTIONS *
/// *************************************
// **************************************
// DEPOSIT FUNCTIONS *
// *************************************

/// Request to bridge input_token to a target chain and receive output_token.
///
/// The fee paid to relayers and the system is captured in the spread between the input and output amounts,
/// denominated in the input token. A relayer on the destination chain will send `output_amount` of `output_token`
/// to the recipient and receive `input_token` on a repayment chain of their choice. The fee accounts for:
/// Destination transaction costs, relayer's opportunity cost of capital while waiting for a refund during the
/// destination transaction costs, relayer's opportunity cost of capital while waiting for a refund during the
/// optimistic challenge window in the HubPool, and the system fee charged to the relayer.
///
/// On the destination chain, a unique hash of the deposit data is used to identify this deposit. Modifying any
@@ -225,7 +225,7 @@ pub mod svm_spoke {
/// ### Parameters
/// - depositor: The account credited with the deposit. Can be different from the signer.
/// - recipient: The account receiving funds on the destination chain. Depending on the output chain can be an ETH
/// address or a contract address or any other address type encoded as a bytes32 field.
/// address or a contract address or any other address type encoded as a bytes32 field.
/// - input_token: The token pulled from the caller's account and locked into this program's vault on deposit.
/// - output_token: The token that the relayer will send to the recipient on the destination chain.
/// - input_amount: The amount of input tokens to pull from the caller's account and lock into the vault. This
@@ -279,7 +279,7 @@ pub mod svm_spoke {
)
}

// Equivalent to deposit_v3 except quote_timestamp is set to the current time.
/// Equivalent to deposit_v3 except quote_timestamp is set to the current time.
pub fn deposit_v3_now(
ctx: Context<DepositV3>,
depositor: Pubkey,
@@ -311,7 +311,7 @@ pub mod svm_spoke {
}

/// Equivalent to deposit_v3 except the deposit_nonce is not used to derive the deposit_id for the depositor. This
/// Lets the caller influence the deposit ID to make it deterministic for the depositor. The computed depositID is
/// lets the caller influence the deposit ID to make it deterministic for the depositor. The computed depositID is
/// the keccak256 hash of [signer, depositor, deposit_nonce].
pub fn unsafe_deposit_v3(
ctx: Context<DepositV3>,
@@ -363,9 +363,9 @@ pub mod svm_spoke {
Ok(utils::get_unsafe_deposit_id(signer, depositor, deposit_nonce))
}

/// **************************************
/// RELAYER FUNCTIONS *
/// *************************************
// **************************************
// RELAYER FUNCTIONS *
// *************************************

/// Fulfill request to bridge cross chain by sending specified output tokens to recipient.
///
@@ -416,7 +416,7 @@ pub mod svm_spoke {
/// - message: The message to send to the recipient if the recipient is a contract that implements a
/// handle_v3_across_message() public function.
/// - repayment_chain_id: Chain of SpokePool where relayer wants to be refunded after the challenge window has
/// passed. Will receive input_amount of the equivalent token to input_token on the repayment chain.
/// passed. Will receive input_amount of the equivalent token to input_token on the repayment chain.
/// - repayment_address: The address of the recipient on the repayment chain that they want to be refunded to.
/// Note: relay_data, repayment_chain_id, and repayment_address are optional parameters. If None for any of these
/// is passed, the caller must load them via the instruction_params account.
@@ -482,9 +482,9 @@ pub mod svm_spoke {
instructions::create_token_accounts(ctx)
}

/// **************************************
/// BUNDLE FUNCTIONS *
/// *************************************
// **************************************
// BUNDLE FUNCTIONS *
// *************************************

/// Executes relayer refund leaf. Only callable by owner.
///
@@ -520,8 +520,7 @@ pub mod svm_spoke {
/// - token_program: The token program.
/// - system_program: The system program required for account creation.
///
/// execute_relayer_refund_leaf executes in mode (a) where refunds are sent to ATA directly.
/// execute_relayer_refund_leaf_deferred executes in mode (b) where refunds are allocated to the claim_account PDA.
/// execute_relayer_refund_leaf executes in mode where refunds are sent to ATA directly.
pub fn execute_relayer_refund_leaf<'c, 'info>(
ctx: Context<'_, '_, 'c, 'info, ExecuteRelayerRefundLeaf<'info>>,
) -> Result<()>
@@ -531,6 +530,7 @@ pub mod svm_spoke {
instructions::execute_relayer_refund_leaf(ctx, false)
}

/// Similar to execute_relayer_refund_leaf, but executes in mode where refunds are allocated to claim_account PDAs.
pub fn execute_relayer_refund_leaf_deferred<'c, 'info>(
ctx: Context<'_, '_, 'c, 'info, ExecuteRelayerRefundLeaf<'info>>,
) -> Result<()>
@@ -668,9 +668,9 @@ pub mod svm_spoke {
instructions::close_claim_account(ctx)
}

/// **************************************
/// SLOW FILL FUNCTIONS *
/// *************************************
// **************************************
// SLOW FILL FUNCTIONS *
// *************************************

/// Requests Across to send LP funds to this program to fulfill a slow fill.
///
@@ -753,9 +753,9 @@ pub mod svm_spoke {
instructions::execute_v3_slow_relay_leaf(ctx, slow_fill_leaf, proof)
}

/// **************************************
/// CCTP FUNCTIONS FUNCTIONS *
/// *************************************
// **************************************
// CCTP FUNCTIONS FUNCTIONS *
// *************************************

/// Handles cross-chain messages received from L1 Ethereum over CCTP.
///

Unchanged files with check annotations Beta

address public constant L1_DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
// This address on L2 receives extra ETH that is left over after relaying a message via the inbox.
address public immutable L2_REFUND_L2_ADDRESS;

Check warning on line 46 in contracts/chain-adapters/Arbitrum_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 46 in contracts/chain-adapters/Arbitrum_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// Inbox system contract to send messages to Arbitrum. Token bridges use this to send tokens to L2.
// https://github.com/OffchainLabs/nitro-contracts/blob/f7894d3a6d4035ba60f51a7f1334f0f2d4f02dce/src/bridge/Inbox.sol
ArbitrumL1InboxLike public immutable L1_INBOX;

Check warning on line 50 in contracts/chain-adapters/Arbitrum_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 50 in contracts/chain-adapters/Arbitrum_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// Router contract to send tokens to Arbitrum. Routes to correct gateway to bridge tokens. Internally this
// contract calls the Inbox.
// Generic gateway: https://github.com/OffchainLabs/token-bridge-contracts/blob/main/contracts/tokenbridge/ethereum/gateway/L1ArbitrumGateway.sol
ArbitrumL1ERC20GatewayLike public immutable L1_ERC20_GATEWAY_ROUTER;

Check warning on line 55 in contracts/chain-adapters/Arbitrum_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 55 in contracts/chain-adapters/Arbitrum_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
/**
* @notice Constructs new Adapter.
// ArbRetryableTx.getSubmissionPrice). ArbRetryableTicket precompile interface exists at L2 address
// 0x000000000000000000000000000000000000006E.
// The Arbitrum Inbox requires that this uses 18 decimal precision.
uint256 public immutable L2_MAX_SUBMISSION_COST;

Check warning on line 48 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 48 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// L2 Gas price bid for immediate L2 execution attempt (queryable via standard eth*gasPrice RPC)
// The Arbitrum Inbox requires that this is specified in gWei (e.g. 1e9 = 1 gWei)
uint256 public immutable L2_GAS_PRICE;

Check warning on line 52 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 52 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// Native token expected to be sent in L2 message. Should be 0 for most use cases of this constant. This
// constant is unused when sending the native gas token over the inbox since the inbox interprets `l2CallValue`
// The number of decimals of precision for the custom gas token. This is defined in the constructor and not dynamically fetched since decimals are
// not part of the standard ERC20 interface.
uint8 public immutable NATIVE_TOKEN_DECIMALS;

Check warning on line 66 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 66 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// This address on L2 receives extra gas token that is left over after relaying a message via the inbox.
address public immutable L2_REFUND_L2_ADDRESS;

Check warning on line 69 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 69 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// Inbox system contract to send messages to Arbitrum. Token bridges use this to send tokens to L2.
// https://github.com/OffchainLabs/nitro-contracts/blob/f7894d3a6d4035ba60f51a7f1334f0f2d4f02dce/src/bridge/Inbox.sol
ArbitrumL1InboxLike public immutable L1_INBOX;

Check warning on line 73 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 73 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// Router contract to send tokens to Arbitrum. Routes to correct gateway to bridge tokens. Internally this
// contract calls the Inbox.
// Generic gateway: https://github.com/OffchainLabs/token-bridge-contracts/blob/main/contracts/tokenbridge/ethereum/gateway/L1ArbitrumGateway.sol
// Gateway used for communicating with chains that use custom gas tokens:
// https://github.com/OffchainLabs/token-bridge-contracts/blob/main/contracts/tokenbridge/ethereum/gateway/L1ERC20Gateway.sol
ArbitrumL1ERC20GatewayLike public immutable L1_ERC20_GATEWAY_ROUTER;

Check warning on line 80 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 80 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// This token is used to pay for l1 to l2 messages if its configured by an Arbitrum orbit chain.
IERC20 public immutable CUSTOM_GAS_TOKEN;

Check warning on line 83 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase

Check warning on line 83 in contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

GitHub Actions / Lint (20)

Variable name must be in mixedCase
// Contract that funds Inbox cross chain messages with the custom gas token.
FunderInterface public immutable CUSTOM_GAS_TOKEN_FUNDER;