Skip to content

Commit ef08497

Browse files
committed
refactor: cleanup
Signed-off-by: Pablo Maldonado <[email protected]>
1 parent 6a63040 commit ef08497

File tree

5 files changed

+14
-27
lines changed

5 files changed

+14
-27
lines changed

Diff for: programs/svm-spoke/src/instructions/deposit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Deposit<'info> {
3636
)]
3737
pub state: Account<'info, State>,
3838

39-
/// CHECK: PDA derived with seeds ["delegate", delegate_seed_hash]; used as a CPI signer. No account data is read or written.
39+
/// CHECK: PDA derived with seeds ["delegate", delegate_seed_hash]; used as a CPI signer.
4040
pub delegate: UncheckedAccount<'info>,
4141

4242
#[account(

Diff for: programs/svm-spoke/src/instructions/fill.rs

-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ fn unwrap_fill_relay_params(
182182
repayment_address: Option<Pubkey>,
183183
account: &Option<Account<FillRelayParams>>,
184184
) -> FillRelayParams {
185-
msg!("unwrap_fill_relay_params: repayment_chain_id: {:?}", repayment_chain_id);
186-
msg!("unwrap_fill_relay_params: repayment_address: {:?}", repayment_address);
187185
match (relay_data, repayment_chain_id, repayment_address) {
188186
(Some(relay_data), Some(repayment_chain_id), Some(repayment_address)) => {
189187
FillRelayParams { relay_data, repayment_chain_id, repayment_address }

Diff for: programs/svm-spoke/src/utils/deposit_utils.rs

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub fn derive_deposit_delegate_seed_hash(
4848
exclusivity_parameter,
4949
message,
5050
};
51-
5251
let serialized = data_struct.try_to_vec().unwrap();
5352

5453
keccak::hash(&serialized).to_bytes()

Diff for: programs/svm-spoke/src/utils/fill_utils.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ pub fn derive_fill_delegate_seed_hash(
1414
) -> [u8; 32] {
1515
let data_struct = FillDelegateSeedData { relay_hash, repayment_chain_id, repayment_address };
1616
let serialized = data_struct.try_to_vec().unwrap();
17-
// Log the raw bytes being hashed
18-
msg!("derive_fill_delegate_seed_hash: relay_hash: {:?}", relay_hash);
19-
msg!("derive_fill_delegate_seed_hash: repayment_chain_id: {:?}", repayment_chain_id);
20-
msg!("derive_fill_delegate_seed_hash: repayment_address: {:?}", repayment_address);
2117

22-
// Compute keccak256
23-
let hash_bytes = keccak::hash(&serialized).to_bytes();
24-
// Log the resulting hash
25-
26-
hash_bytes
18+
keccak::hash(&serialized).to_bytes()
2719
}

Diff for: src/svm/web3-v1/helpers.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const isSolanaDevnet = (provider: AnchorProvider): boolean => {
2525
};
2626

2727
/**
28-
* Borsh‐serializable struct matching your Rust DelegateSeedData
28+
* Deposit Delegate Seed Data
2929
*/
3030
class DepositDelegateSeedData {
3131
depositor!: Uint8Array;
@@ -56,7 +56,7 @@ class DepositDelegateSeedData {
5656
}
5757

5858
/**
59-
* Borsh schema for DelegateSeedData
59+
* Borsh schema for DepositDelegateSeedData
6060
*/
6161
const delegateSeedSchema = new Map([
6262
[
@@ -93,17 +93,14 @@ export function getDepositDelegateSeedHash(depositData: DepositData): Uint8Array
9393
// Borsh will automatically prefix this with a 4‑byte LE length
9494
message: Uint8Array.from(depositData.message),
9595
});
96-
97-
// Serialize with borsh
98-
const serialized = serialize(delegateSeedSchema, ds); // Uint8Array
96+
const serialized = serialize(delegateSeedSchema, ds);
9997
const hashHex = ethers.utils.keccak256(serialized);
100-
const seedHash = Buffer.from(hashHex.slice(2), "hex");
101-
return seedHash;
98+
99+
return Buffer.from(hashHex.slice(2), "hex");
102100
}
103101

104102
/**
105-
* Returns the delegate PDA for a deposit, Borsh‐serializing exactly the same fields
106-
* and ordering as your Rust `derive_deposit_delegate_seed_hash`.
103+
* Returns the delegate PDA for a deposit.
107104
*/
108105
export function getDepositDelegatePda(depositData: DepositData, programId: PublicKey): PublicKey {
109106
const seedHash = getDepositDelegateSeedHash(depositData);
@@ -113,8 +110,9 @@ export function getDepositDelegatePda(depositData: DepositData, programId: Publi
113110

114111
return pda;
115112
}
113+
116114
/**
117-
* Fill‐delegate seed data for relays
115+
* Fill Delegate Seed Data
118116
*/
119117
class FillDelegateSeedData {
120118
relayHash: Uint8Array;
@@ -145,8 +143,7 @@ const fillDelegateSeedSchema = new Map<any, any>([
145143
]);
146144

147145
/**
148-
* Computes the delegate seed hash for a fill relay operation.
149-
* Must match the Rust `derive_fill_delegate_seed_hash` logic exactly.
146+
* Returns the fill delegate seed hash.
150147
*/
151148

152149
export function getFillRelayDelegateSeedHash(
@@ -160,12 +157,12 @@ export function getFillRelayDelegateSeedHash(
160157
repaymentAddress: repaymentAddress.toBuffer(),
161158
});
162159
const serialized = serialize(fillDelegateSeedSchema, ds);
160+
163161
return Buffer.from(ethers.utils.keccak256(serialized).slice(2), "hex");
164162
}
165163

166164
/**
167-
* Derives the program address (PDA) for a fill relay delegate.
168-
* Returns only the PDA; bump can be retrieved via `findProgramAddressSync` if needed.
165+
* Returns the fill delegate PDA.
169166
*/
170167
export function getFillRelayDelegatePda(
171168
relayHash: Uint8Array,
@@ -175,5 +172,6 @@ export function getFillRelayDelegatePda(
175172
): { seedHash: Uint8Array; pda: PublicKey } {
176173
const seedHash = getFillRelayDelegateSeedHash(relayHash, repaymentChainId, repaymentAddress);
177174
const [pda] = PublicKey.findProgramAddressSync([Buffer.from("delegate"), seedHash], programId);
175+
178176
return { seedHash, pda };
179177
}

0 commit comments

Comments
 (0)