Skip to content

Commit c6a4d4b

Browse files
committed
basic review
1 parent 1369383 commit c6a4d4b

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

programs/instant-send-program/src/instructions/initialize_transfer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ impl<'info> InitializeTransferSPL<'info> {
4444
CpiContext::new(self.token_program.to_account_info(), cpi_accounts)
4545
}
4646

47+
// REVIEW: should be claim_rent_from_sender
4748
pub fn cliam_rent_from_sender(&self) -> Result<()> {
4849
let rent = Rent::get()?;
4950
let recipient_token_account_rent = rent.minimum_balance(TokenAccount::LEN);

programs/instant-send-program/src/instructions/redeem_funds.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub struct RedeemFundsSOL<'info> {
126126
}
127127

128128
impl<'info> RedeemFundsSOL<'info> {
129+
// REVIEW: I assume the secret is randomly generated, otherwise it would be better to use a hash and a salt
129130
pub fn verify_secret(&self, secret: &str) -> Result<()> {
130131
let provided_hash = {
131132
let mut hasher = Sha256::new();
@@ -140,6 +141,7 @@ impl<'info> RedeemFundsSOL<'info> {
140141
}
141142

142143
pub fn transfer_sol_to_recipient(&self, amount: u64) -> Result<()> {
144+
// REVIEW: you have to use the system program to transfer lamports, like you did in the initialize_transfer_spl instruction
143145
**self.recipient.to_account_info().try_borrow_mut_lamports()? += amount;
144146
**self.escrow_account.to_account_info().try_borrow_mut_lamports()? -= amount;
145147
Ok(())
@@ -166,6 +168,7 @@ pub fn redeem_funds_sol(ctx: Context<RedeemFundsSOL>, secret: String) -> Result<
166168

167169
ctx.accounts.escrow_account.is_redeemed = true;
168170
ctx.accounts.transfer_sol_to_recipient(ctx.accounts.escrow_account.amount)?;
171+
// REVIEW: after the transfer, the escrow account should be deleted
169172
// ctx.accounts.refund_remaining_lamports_to_sender()?;
170173

171174
Ok(())

programs/instant-send-program/src/instructions/refund_funds.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct RefundFundsSPL<'info> {
3131
}
3232

3333
impl<'info> RefundFundsSPL<'info> {
34+
// REVIEW: I assume the secret is randomly generated, otherwise it would be better to use a hash and a salt
3435
pub fn verify_secret(&self, secret: &str) -> Result<()> {
3536
let provided_hash = {
3637
let mut hasher = Sha256::new();
@@ -122,6 +123,7 @@ impl<'info> RefundFundsSOL<'info> {
122123
}
123124

124125
pub fn transfer_sol_back_to_sender(&self, amount: u64) -> Result<()> {
126+
// REVIEW: this also does not work because you need to call the system program to transfer lamports
125127
**self.sender.to_account_info().try_borrow_mut_lamports()? += amount;
126128
**self
127129
.escrow_account

0 commit comments

Comments
 (0)