Skip to content

Commit

Permalink
Add empty ata check (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante authored Nov 23, 2021
1 parent 4ac6e64 commit 60b3f4c
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
global:
- NODE_VERSION="v14.7.0"
- SOLANA_VERSION="v1.7.8"
- ANCHOR_VERSION="v0.13.0"
- ANCHOR_VERSION="v0.17.0"
git:
submodules: true

Expand Down
9 changes: 2 additions & 7 deletions Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
anchor_version = "0.13.0"

[workspace]
members = [
"programs/swap",
]
anchor_version = "0.17.0"

[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"

[programs.mainnet]
serum_swap = { address = "22Y43yTVxuUkoRKdm9thyRhQ3SdgQS7c7kB6UNCiaczD", path = "./target/deploy/serum_swap.so", idl = "./target/idl/serum_swap.json" }
serum_swap = "22Y43yTVxuUkoRKdm9thyRhQ3SdgQS7c7kB6UNCiaczD"
serum_dex = { address = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin", path = "./deps/serum-dex/dex/target/deploy/serum_dex.so" }

[[test.genesis]]
Expand Down
91 changes: 55 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions programs/swap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.13.0"
anchor-spl = "0.13.0"
solana-program = "=1.7.8"
anchor-lang = "0.17.0"
anchor-spl = "0.17.0"
solana-program = "=1.7.11"

[profile.release]
lto = "fat"
codegen-units = 1

[profile.release.build-override]
opt-level = 3
incremental = false
codegen-units = 1
14 changes: 10 additions & 4 deletions programs/swap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ use std::num::NonZeroU64;

declare_id!("22Y43yTVxuUkoRKdm9thyRhQ3SdgQS7c7kB6UNCiaczD");

// Associated token account for Pubkey::default.
mod empty {
use super::*;
declare_id!("HJt8Tjdsc9ms9i4WCZEzhzr4oyf3ANcdzXrNdLPFqm3M");
}

#[program]
pub mod serum_swap {
use super::*;
Expand Down Expand Up @@ -370,7 +376,7 @@ pub struct Swap<'info> {
pub market: MarketAccounts<'info>,
#[account(signer)]
pub authority: AccountInfo<'info>,
#[account(mut)]
#[account(mut, constraint = pc_wallet.key != &empty::ID)]
pub pc_wallet: AccountInfo<'info>,
// Programs.
pub dex_program: AccountInfo<'info>,
Expand Down Expand Up @@ -403,7 +409,7 @@ pub struct SwapTransitive<'info> {
// Must be the authority over all open orders accounts used.
#[account(signer)]
pub authority: AccountInfo<'info>,
#[account(mut)]
#[account(mut, constraint = pc_wallet.key != &empty::ID)]
pub pc_wallet: AccountInfo<'info>,
// Programs.
pub dex_program: AccountInfo<'info>,
Expand Down Expand Up @@ -599,7 +605,7 @@ pub struct MarketAccounts<'info> {
// from the user into the market's vault.
//
// For bids, this is the base currency. For asks, the quote.
#[account(mut)]
#[account(mut, constraint = order_payer_token_account.key != &empty::ID)]
pub order_payer_token_account: AccountInfo<'info>,
// Also known as the "base" currency. For a given A/B market,
// this is the vault for the A mint.
Expand All @@ -612,7 +618,7 @@ pub struct MarketAccounts<'info> {
// PDA owner of the DEX's token accounts for base + quote currencies.
pub vault_signer: AccountInfo<'info>,
// User wallets.
#[account(mut)]
#[account(mut, constraint = coin_wallet.key != &empty::ID)]
pub coin_wallet: AccountInfo<'info>,
}

Expand Down

0 comments on commit 60b3f4c

Please sign in to comment.