Add empty ata check (#19)

This commit is contained in:
Armani Ferrante 2021-11-23 18:58:44 +00:00 committed by GitHub
parent 4ac6e64471
commit 60b3f4cc59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 51 deletions

View File

@ -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

View File

@ -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]]

91
Cargo.lock generated
View File

@ -25,9 +25,9 @@ checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483"
[[package]]
name = "anchor-attribute-access-control"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "317ec4ca2285689c98600f371a206105613ff0a614fb906403a8293b8d265fdf"
checksum = "7b8ab97bfde16e49bc399586a857e9bd56e7c867a66a89ca809134d53d999138"
dependencies = [
"anchor-syn",
"anyhow",
@ -39,22 +39,24 @@ dependencies = [
[[package]]
name = "anchor-attribute-account"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d9c7955ae7f81ac15b1da0fd5121a664161014183d5f33d13c6bed252b48af8"
checksum = "40d3c2f1ebf823c4a8f0e41c57125991713177d4f02957600f8c1da8bd87adfd"
dependencies = [
"anchor-syn",
"anyhow",
"bs58 0.4.0",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "anchor-attribute-error"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a18ead124777eeee2afd09006c1814ded41c6d19422a56b91d2a0bc35a5c08e"
checksum = "f8b5b954878c4cb1ad373143b42765abaf789691e13dbd0a3a8707dbfd0612cd"
dependencies = [
"anchor-syn",
"proc-macro2",
@ -64,9 +66,9 @@ dependencies = [
[[package]]
name = "anchor-attribute-event"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f46254314ed9da3c8913dcbdcd0130dc7a3e8bbedd14f4a7d0d9de825844f5e"
checksum = "418daba265c778d2386c27191b4ec927c24be270ed6a8667be81de9e541c7a3e"
dependencies = [
"anchor-syn",
"anyhow",
@ -77,9 +79,9 @@ dependencies = [
[[package]]
name = "anchor-attribute-interface"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d116d72c20a6fe9fde7731cf83b0cd8af35afba4f4ef905374388e5e57567bdc"
checksum = "fd2159348897db16999d76ff396ba8722fb101e0e0cc6845b3722eb7472bd0d0"
dependencies = [
"anchor-syn",
"anyhow",
@ -91,9 +93,9 @@ dependencies = [
[[package]]
name = "anchor-attribute-program"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "211418fd8bdec824882fad89cc89af09b6d7360f61b283a518b6d4ca967631df"
checksum = "e6695b491d73439ad9839565beb0749107f5acca6d96b4cbaaaef428ba7b6c11"
dependencies = [
"anchor-syn",
"anyhow",
@ -104,9 +106,9 @@ dependencies = [
[[package]]
name = "anchor-attribute-state"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e5f39d6a3f6a3de5612079b56de0624c3c37c3b322b98508b26c0501d34b23"
checksum = "4bcbbeade2b868e597b55d90418dc51334c4e388f988c0eea1af5d511083ed10"
dependencies = [
"anchor-syn",
"anyhow",
@ -117,9 +119,9 @@ dependencies = [
[[package]]
name = "anchor-derive-accounts"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b48d4574fd51e47c23e3621865fd753d8379f8d8217988e38a458b97e298d9c"
checksum = "dc82ef304c38e7529883176c428acfab9a7bb9e851aa694fff53c8789fbc47b3"
dependencies = [
"anchor-syn",
"anyhow",
@ -130,9 +132,9 @@ dependencies = [
[[package]]
name = "anchor-lang"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "011bb8da56486474f058c42c2c505f6cc995da0dd8a261dfd4bc7e4923a0380d"
checksum = "ff6b7025eb65638005fd2af58e2bd136b61c2ecbadda379e908a5af541351a3a"
dependencies = [
"anchor-attribute-access-control",
"anchor-attribute-account",
@ -151,25 +153,26 @@ dependencies = [
[[package]]
name = "anchor-spl"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e16fc45391a7539ac6912232ade523b415b3be2c5d066a6ddcf81fce2145f575"
checksum = "b49dfaf04f0794ecbdafa1f5dda93d47fc042ae70478fc079194c6c7cd265e94"
dependencies = [
"anchor-lang",
"lazy_static",
"serum_dex",
"solana-program",
"spl-associated-token-account",
"spl-token",
]
[[package]]
name = "anchor-syn"
version = "0.13.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed39067f714dc11cfd1096140f4cc2bdff1e5b1b0573bdd12c3ad5eba6ec9705"
checksum = "321cca8ea1c35b199956e11b2869e8b1b1ae2d547326a12fc45375d0806470c8"
dependencies = [
"anyhow",
"bs58",
"bs58 0.3.1",
"heck",
"proc-macro2",
"proc-macro2-diagnostics",
@ -319,6 +322,12 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb"
[[package]]
name = "bs58"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3"
[[package]]
name = "bv"
version = "0.11.1"
@ -1032,11 +1041,11 @@ dependencies = [
[[package]]
name = "solana-frozen-abi"
version = "1.7.8"
version = "1.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45c6760c1dd139c202ef6df28bff467c904aa35b1aa1a59be268c47aec8bc6c0"
checksum = "21ddfc2b65a555c0e0156c043bce092d473bc4f00daa7ca3c223d97d92d2e807"
dependencies = [
"bs58",
"bs58 0.3.1",
"bv",
"generic-array 0.14.4",
"log",
@ -1052,9 +1061,9 @@ dependencies = [
[[package]]
name = "solana-frozen-abi-macro"
version = "1.7.8"
version = "1.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4dbe296c16dec41e8e6f4e6c2694c6224820d34c0ab11a2d3ff9683f44878ef"
checksum = "a876aa31298fdee6560c8ee0695ebed313bbdbb6fbbee439ac3b9df8aebfb87c"
dependencies = [
"proc-macro2",
"quote",
@ -1064,9 +1073,9 @@ dependencies = [
[[package]]
name = "solana-logger"
version = "1.7.8"
version = "1.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80af1959b520c0fc99bc6583ba9d82bfa15b1ac007516795bceeb4a951af77c7"
checksum = "98a07290cc521e529bff0b0afd3aacd1d3904a41f35321ede6d1f3574efa3e94"
dependencies = [
"env_logger",
"lazy_static",
@ -1075,15 +1084,15 @@ dependencies = [
[[package]]
name = "solana-program"
version = "1.7.8"
version = "1.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5e5dd99d642b5e89eeb20457310c3c23f20dbf44e67c64e473a02fbc50d646"
checksum = "49ffc60d33a318300682e42d28ff4f1276327f6374cab9591c8620a54be7aec1"
dependencies = [
"bincode",
"blake3",
"borsh",
"borsh-derive",
"bs58",
"bs58 0.3.1",
"bv",
"curve25519-dalek",
"hex",
@ -1110,17 +1119,27 @@ dependencies = [
[[package]]
name = "solana-sdk-macro"
version = "1.7.8"
version = "1.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fee909dcddb5b4d349b3e5e1ae92f6660cd2f783dea392ae2e73210776aadc9b"
checksum = "b453dca160617b1676c47e3cfd4361f455dc5bb1c93659ec84b0c5d566b5c039"
dependencies = [
"bs58",
"bs58 0.3.1",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "spl-associated-token-account"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "393e2240d521c3dd770806bff25c2c00d761ac962be106e14e22dd912007f428"
dependencies = [
"solana-program",
"spl-token",
]
[[package]]
name = "spl-token"
version = "3.2.0"

View File

@ -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

View File

@ -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::*;
@ -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>,
@ -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>,
@ -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.
@ -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>,
}