Skip to content

Commit ea2780e

Browse files
authored
fix: further comment nits (#773)
1 parent 180c6a4 commit ea2780e

File tree

20 files changed

+142
-204
lines changed

20 files changed

+142
-204
lines changed

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828
- name: Install Cargo toolchain
2929
uses: actions-rs/toolchain@v1
3030
with:
31-
toolchain: stable
31+
toolchain: nightly
3232
profile: minimal
3333
components: rustc
3434
- name: Install packages
35-
run: yarn install --frozen-lockfile
35+
run: yarn install --frozen-lockfile && rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt
3636
- name: Lint js
3737
shell: bash
3838
run: yarn lint-js

.rustfmt.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
edition = "2021"
22
max_width = 120
3+
fn_call_width = 120
4+
struct_lit_width = 120
5+
normalize_comments = false

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"lint": "yarn lint-solidity && yarn lint-js && yarn lint-rust",
2323
"lint-solidity": "yarn solhint ./contracts/**/*.sol",
2424
"lint-js": "yarn prettier --list-different **/*.js **/*.ts",
25-
"lint-rust": "cargo fmt --all -- --check && cargo clippy",
26-
"lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo fmt --all",
25+
"lint-rust": "cargo +nightly fmt --all -- --check && cargo clippy",
26+
"lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo +nightly fmt --all && cargo clippy",
2727
"clean-fast": "for dir in node_modules cache cache-zk artifacts artifacts-zk dist typechain; do mv \"${dir}\" \"_${dir}\"; rm -rf \"_${dir}\" &; done",
2828
"clean": "rm -rf node_modules cache cache-zk artifacts artifacts-zk dist typechain",
2929
"build-evm": "hardhat compile",

programs/multicall-handler/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ pub mod multicall_handler {
4646
account_infos.push(account_info.to_owned());
4747
}
4848

49-
let cpi_instruction = Instruction {
50-
program_id: target_program.key(),
51-
accounts,
52-
data: compiled_ix.data,
53-
};
49+
let cpi_instruction = Instruction { program_id: target_program.key(), accounts, data: compiled_ix.data };
5450

5551
match use_handler_signer {
5652
true => invoke_signed(&cpi_instruction, &account_infos, &[&[b"handler_signer", &[bump]]])?,

programs/svm-spoke/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub enum SvmError {
7878
InvalidATACreationAccounts,
7979
}
8080

81-
// Errors to handle the CCTP interactions.
81+
// CCTP specific errors.
8282
#[error_code]
8383
pub enum CallDataError {
8484
#[msg("Invalid solidity selector")]
@@ -99,7 +99,7 @@ pub enum CallDataError {
9999
UnsupportedSelector,
100100
}
101101

102-
// Errors to handle Across+ message calls.
102+
// Across+ specific errors.
103103
#[error_code]
104104
pub enum AcrossPlusError {
105105
#[msg("Message did not deserialize")]

programs/svm-spoke/src/event.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ pub struct RelayedRootBundle {
3030
pub slow_relay_root: [u8; 32],
3131
}
3232

33+
#[event]
34+
pub struct EmergencyDeletedRootBundle {
35+
pub root_bundle_id: u32,
36+
}
37+
3338
// Deposit events
3439
#[event]
3540
pub struct V3FundsDeposited {
@@ -101,7 +106,7 @@ pub struct RequestedV3SlowFill {
101106
pub message_hash: [u8; 32],
102107
}
103108

104-
// Relayer refund events
109+
// Bundle refund events
105110
#[event]
106111
pub struct ExecutedRelayerRefundRoot {
107112
pub amount_to_return: u64,
@@ -122,11 +127,6 @@ pub struct ClaimedRelayerRefund {
122127
pub refund_address: Pubkey,
123128
}
124129

125-
#[event]
126-
pub struct EmergencyDeletedRootBundle {
127-
pub root_bundle_id: u32,
128-
}
129-
130130
#[event]
131131
pub struct BridgedToHubPool {
132132
pub amount: u64,

programs/svm-spoke/src/instructions/admin.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ pub struct TransferOwnership<'info> {
110110
pub fn transfer_ownership(ctx: Context<TransferOwnership>, new_owner: Pubkey) -> Result<()> {
111111
let state = &mut ctx.accounts.state;
112112
state.owner = new_owner;
113+
113114
Ok(())
114115
}
115116

@@ -127,9 +128,7 @@ pub fn set_cross_domain_admin(ctx: Context<SetCrossDomainAdmin>, cross_domain_ad
127128
let state = &mut ctx.accounts.state;
128129
state.cross_domain_admin = cross_domain_admin;
129130

130-
emit_cpi!(SetXDomainAdmin {
131-
new_admin: cross_domain_admin,
132-
});
131+
emit_cpi!(SetXDomainAdmin { new_admin: cross_domain_admin });
133132

134133
Ok(())
135134
}
@@ -190,11 +189,7 @@ pub fn set_enable_route(
190189
) -> Result<()> {
191190
ctx.accounts.route.enabled = enabled;
192191

193-
emit_cpi!(EnabledDepositRoute {
194-
origin_token,
195-
destination_chain_id,
196-
enabled,
197-
});
192+
emit_cpi!(EnabledDepositRoute { origin_token, destination_chain_id, enabled });
198193

199194
Ok(())
200195
}
@@ -233,13 +228,10 @@ pub fn relay_root_bundle(
233228
root_bundle.relayer_refund_root = relayer_refund_root;
234229
root_bundle.slow_relay_root = slow_relay_root;
235230

236-
emit_cpi!(RelayedRootBundle {
237-
root_bundle_id: state.root_bundle_id,
238-
relayer_refund_root,
239-
slow_relay_root,
240-
});
231+
emit_cpi!(RelayedRootBundle { root_bundle_id: state.root_bundle_id, relayer_refund_root, slow_relay_root });
241232

242233
state.root_bundle_id += 1;
234+
243235
Ok(())
244236
}
245237

programs/svm-spoke/src/instructions/bundle.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ impl RelayerRefundLeaf {
9595

9696
pub fn to_keccak_hash(&self) -> Result<[u8; 32]> {
9797
let input = self.to_bytes()?;
98+
9899
Ok(keccak::hash(&input).to_bytes())
99100
}
100101
}
@@ -126,10 +127,7 @@ where
126127
return err!(CommonError::ClaimedMerkleLeaf);
127128
}
128129

129-
set_claimed(
130-
&mut ctx.accounts.root_bundle.claimed_bitmap,
131-
relayer_refund_leaf.leaf_id,
132-
);
130+
set_claimed(&mut ctx.accounts.root_bundle.claimed_bitmap, relayer_refund_leaf.leaf_id);
133131

134132
if relayer_refund_leaf.refund_addresses.len() != relayer_refund_leaf.refund_amounts.len() {
135133
return err!(CommonError::InvalidMerkleLeaf);
@@ -202,11 +200,8 @@ fn distribute_relayer_refunds<'info>(
202200
to: refund_token_account.to_account_info(),
203201
authority: ctx.accounts.state.to_account_info(),
204202
};
205-
let cpi_context = CpiContext::new_with_signer(
206-
ctx.accounts.token_program.to_account_info(),
207-
transfer_accounts,
208-
signer_seeds,
209-
);
203+
let cpi_context =
204+
CpiContext::new_with_signer(ctx.accounts.token_program.to_account_info(), transfer_accounts, signer_seeds);
210205
transfer_checked(cpi_context, amount.to_owned(), ctx.accounts.mint.decimals)?;
211206
}
212207

programs/svm-spoke/src/instructions/fill.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,8 @@ pub fn fill_v3_relay<'info>(
116116
fill_status_account.status = FillStatus::Filled;
117117
fill_status_account.relayer = *ctx.accounts.signer.key;
118118

119-
if relay_data.message.len() > 0 {
120-
invoke_handler(
121-
ctx.accounts.signer.as_ref(),
122-
ctx.remaining_accounts,
123-
&relay_data.message,
124-
)?;
119+
if !relay_data.message.is_empty() {
120+
invoke_handler(ctx.accounts.signer.as_ref(), ctx.remaining_accounts, &relay_data.message)?;
125121
}
126122

127123
// Empty message is not hashed and emits zeroed bytes32 for easier human observability.

programs/svm-spoke/src/instructions/handle_receive_message.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ fn invoke_self<'info>(ctx: &Context<'_, '_, '_, 'info, HandleReceiveMessage<'inf
111111
}
112112
}
113113

114-
let instruction = Instruction {
115-
program_id: crate::ID,
116-
accounts,
117-
data: data.to_owned(),
118-
};
114+
let instruction = Instruction { program_id: crate::ID, accounts, data: data.to_owned() };
119115

120116
program::invoke_signed(
121117
&instruction,

0 commit comments

Comments
 (0)