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

withdraw_spl_token: add mint in params and validate in the instruction processor #5

Closed
Tracked by #2401
brewmaster012 opened this issue Jun 26, 2024 · 2 comments
Assignees

Comments

@brewmaster012
Copy link
Contributor

brewmaster012 commented Jun 26, 2024

Currently, in to withdraw SPL token from the gateway program,
the user must provide correct from and to addresses otherwise the transfer will fail.

let xfer_ctx = CpiContext::new_with_signer(
token.to_account_info(),
anchor_spl::token::Transfer {
from: ctx.accounts.from.to_account_info(),
to: ctx.accounts.to.to_account_info(),
authority: pda.to_account_info(),
},
signer_seeds,
);
transfer(xfer_ctx, amount)?;
msg!("withdraw spl token successfully");

Correct include the following conditions:

  1. the from and to are both token accounts;
  2. the from and to token accounts have the same mint account (they store the same SPL token)

Unlike Ethereum ERC20, SPL token cannot be transferred to arbitrary accounts/addresses.

@lumtis
Copy link
Member

lumtis commented Jul 1, 2024

@brewmaster012 would it be possible to provide some more details and assess if it is in scope for zeta-chain/node#2401?

@brewmaster012
Copy link
Contributor Author

Yeah I'm going to close this one.
After evaluation this issue does not add additional check while introducing significant complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants