Skip to content

Commit

Permalink
add more redundant checks
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao committed Apr 19, 2022
1 parent 62b934c commit 945bcb7
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 63 deletions.
7 changes: 5 additions & 2 deletions Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
anchor_version = "0.22.1"
solana_version = "1.9.0"
anchor_version = "0.24.2"
solana_version = "1.9.12"

[features]
seeds = true

[registry]
url = "https://anchor.projectserum.com"
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

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

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@
"devDependencies": {
"@project-serum/anchor": "^0.24.2",
"@rushstack/eslint-patch": "^1.1.3",
"@saberhq/anchor-contrib": "^1.12.61",
"@saberhq/chai-solana": "^1.12.61",
"@saberhq/eslint-config": "^1.12.61",
"@saberhq/solana-contrib": "^1.12.61",
"@saberhq/token-utils": "^1.12.61",
"@saberhq/tsconfig": "^1.12.61",
"@saberhq/anchor-contrib": "^1.12.62",
"@saberhq/chai-solana": "^1.12.62",
"@saberhq/eslint-config": "^1.12.62",
"@saberhq/solana-contrib": "^1.12.62",
"@saberhq/token-utils": "^1.12.62",
"@saberhq/tsconfig": "^1.12.62",
"@solana/web3.js": "^1.39.1",
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.1",
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.24",
"@types/node": "^17.0.25",
"bn.js": "^5.2.0",
"chai": "^4.3.4",
"eslint": "^8.13.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-plugin-import": "^2.26.0",
"husky": "^7.0.4",
"jsbi": "^4.2.1",
"jsbi": "^4.3.0",
"lint-staged": "^12.3.8",
"mocha": "^9.2.2",
"prettier": "^2.6.2",
Expand Down
13 changes: 8 additions & 5 deletions programs/merkle-distributor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ pub mod merkle_distributor {
amount: u64,
proof: Vec<[u8; 32]>,
) -> Result<()> {
assert_keys_neq!(ctx.accounts.from, ctx.accounts.to);

let claim_status = &mut ctx.accounts.claim_status;
invariant!(
// This check is redundant, we should not be able to initialize a claim status account at the same key.
Expand Down Expand Up @@ -103,10 +105,7 @@ pub mod merkle_distributor {
distributor.mint
);
}
invariant!(
ctx.accounts.to.owner == claimant_account.key(),
OwnerMismatch
);
assert_keys_eq!(ctx.accounts.to.owner, claimant_account.key(), OwnerMismatch);
token::transfer(
CpiContext::new(
ctx.accounts.token_program.to_account_info(),
Expand Down Expand Up @@ -177,7 +176,10 @@ pub struct NewDistributor<'info> {
#[instruction(_bump: u8, index: u64)]
pub struct Claim<'info> {
/// The [MerkleDistributor].
#[account(mut)]
#[account(
mut,
address = from.owner
)]
pub distributor: Account<'info, MerkleDistributor>,

/// Status of the claim.
Expand All @@ -203,6 +205,7 @@ pub struct Claim<'info> {
pub to: Account<'info, TokenAccount>,

/// Who is claiming the tokens.
#[account(address = to.owner @ ErrorCode::OwnerMismatch)]
pub claimant: Signer<'info>,

/// Payer of the claim.
Expand Down
90 changes: 45 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ __metadata:
languageName: node
linkType: hard

"@saberhq/anchor-contrib@npm:^1.12.61":
version: 1.12.61
resolution: "@saberhq/anchor-contrib@npm:1.12.61"
"@saberhq/anchor-contrib@npm:^1.12.62":
version: 1.12.62
resolution: "@saberhq/anchor-contrib@npm:1.12.62"
dependencies:
"@saberhq/solana-contrib": ^1.12.61
"@saberhq/solana-contrib": ^1.12.62
eventemitter3: ^4.0.7
lodash.camelcase: ^4.3.0
lodash.mapvalues: ^4.6.0
Expand All @@ -200,17 +200,17 @@ __metadata:
"@project-serum/anchor": ^0.22 || ^0.23 || ^0.24
"@solana/web3.js": ^1.37
bn.js: ^4 || ^5
checksum: 824bd7120381ac6b1d7ac00d65587fe25fc3573b34177ed3c82c52fb09555431f52162a6d27a7d5db55bad173dd49857bcf1bef424cb45a281572095fd2e5caa
checksum: 7ca63edbba16dc74807129f787627236b590762bbfe857c221e5c58153849fbb9df486d993f561f1a4ddd605639d83aaa0acc2389ca4b741b2a92db643a4b915
languageName: node
linkType: hard

"@saberhq/chai-solana@npm:^1.12.61":
version: 1.12.61
resolution: "@saberhq/chai-solana@npm:1.12.61"
"@saberhq/chai-solana@npm:^1.12.62":
version: 1.12.62
resolution: "@saberhq/chai-solana@npm:1.12.62"
dependencies:
"@saberhq/anchor-contrib": ^1.12.61
"@saberhq/solana-contrib": ^1.12.61
"@saberhq/token-utils": ^1.12.61
"@saberhq/anchor-contrib": ^1.12.62
"@saberhq/solana-contrib": ^1.12.62
"@saberhq/token-utils": ^1.12.62
"@types/chai": ^4.3.1
"@types/chai-as-promised": ^7.1.5
"@types/promise-retry": ^1.1.3
Expand All @@ -224,13 +224,13 @@ __metadata:
"@solana/web3.js": ^1.37
bn.js: ^5.2.0
jsbi: "*"
checksum: f7e63eb7e7bf619b0a91cc859e30961b2e10ada3cd7c4a3b524dc948accbf86deac1493a7d21258c20ce25be7db372aab6d19daf1f29eb600ce2a92773d4cb30
checksum: de82a943b530828494c9fad4d6036de7918d215a53d593160d1c2d035cc168a18a536869cb7166867351b3a233bd3bf5d559e808c9ca61d38b5b5daf6a3153fd
languageName: node
linkType: hard

"@saberhq/eslint-config@npm:^1.12.61":
version: 1.12.61
resolution: "@saberhq/eslint-config@npm:1.12.61"
"@saberhq/eslint-config@npm:^1.12.62":
version: 1.12.62
resolution: "@saberhq/eslint-config@npm:1.12.62"
dependencies:
"@typescript-eslint/eslint-plugin": ^5.19.0
"@typescript-eslint/parser": ^5.19.0
Expand All @@ -243,7 +243,7 @@ __metadata:
prettier: ^2.6.2
peerDependencies:
eslint: ">=7"
checksum: 84a10dda5e0a5555e9347b472bcf96d7835f32cb5f2f4e6c81c794438a8d0289a3c0aafe662b41115f470b7eceed83f5f7319eecb2e13f8b2a12f89eac09bbdf
checksum: ed1fab1b4f7d97d2cdbf1426071115447cd05f546b0a4eb949d4166c899d6316e4b3088938830e992661a955f06211637c9df258154e4ea5189b94ddacce0f1e
languageName: node
linkType: hard

Expand All @@ -253,25 +253,25 @@ __metadata:
dependencies:
"@project-serum/anchor": ^0.24.2
"@rushstack/eslint-patch": ^1.1.3
"@saberhq/anchor-contrib": ^1.12.61
"@saberhq/chai-solana": ^1.12.61
"@saberhq/eslint-config": ^1.12.61
"@saberhq/solana-contrib": ^1.12.61
"@saberhq/token-utils": ^1.12.61
"@saberhq/tsconfig": ^1.12.61
"@saberhq/anchor-contrib": ^1.12.62
"@saberhq/chai-solana": ^1.12.62
"@saberhq/eslint-config": ^1.12.62
"@saberhq/solana-contrib": ^1.12.62
"@saberhq/token-utils": ^1.12.62
"@saberhq/tsconfig": ^1.12.62
"@solana/web3.js": ^1.39.1
"@types/bn.js": ^5.1.0
"@types/chai": ^4.3.1
"@types/mocha": ^9.1.0
"@types/node": ^17.0.24
"@types/node": ^17.0.25
bn.js: ^5.2.0
chai: ^4.3.4
eslint: ^8.13.0
eslint-import-resolver-node: ^0.3.6
eslint-plugin-import: ^2.26.0
husky: ^7.0.4
js-sha3: ^0.8.0
jsbi: ^4.2.1
jsbi: ^4.3.0
lint-staged: ^12.3.8
mocha: ^9.2.2
prettier: ^2.6.2
Expand All @@ -291,9 +291,9 @@ __metadata:
languageName: unknown
linkType: soft

"@saberhq/solana-contrib@npm:^1.12.61":
version: 1.12.61
resolution: "@saberhq/solana-contrib@npm:1.12.61"
"@saberhq/solana-contrib@npm:^1.12.62":
version: 1.12.62
resolution: "@saberhq/solana-contrib@npm:1.12.62"
dependencies:
"@solana/buffer-layout": ^4.0.0
"@types/promise-retry": ^1.1.3
Expand All @@ -305,15 +305,15 @@ __metadata:
peerDependencies:
"@solana/web3.js": ^1.37
bn.js: ^4 || ^5
checksum: 29800595d97a28d3d0a2189afd06b07ff41b882b5426e06b4414ed1b8341b13eb7f9105db6c5574b4c991b23fc53473ec6c4438b35aacdcf67e7c8b3c7a3f482
checksum: 671daf403c53cff347c16f9c51c0ba67dcc37225bd53717a97cc30c62d1aa25019515afb0fac923009a1aa7f67f59fe8aadf1f6b9d645518f24d7094c5a92380
languageName: node
linkType: hard

"@saberhq/token-utils@npm:^1.12.61":
version: 1.12.61
resolution: "@saberhq/token-utils@npm:1.12.61"
"@saberhq/token-utils@npm:^1.12.62":
version: 1.12.62
resolution: "@saberhq/token-utils@npm:1.12.62"
dependencies:
"@saberhq/solana-contrib": ^1.12.61
"@saberhq/solana-contrib": ^1.12.62
"@solana/buffer-layout": ^4.0.0
"@solana/spl-token": ^0.1.8
"@ubeswap/token-math": ^4.4.6
Expand All @@ -323,14 +323,14 @@ __metadata:
"@solana/web3.js": ^1.29.2
bn.js: ^4 || ^5
jsbi: ^3 || ^4
checksum: 4944481657aa2e0a5c4924d63f41a1dc6ff934b9cd99f5ee252a8b4ab66cd8d05fa66ce4ace7e36ee2cde6a62fce3f409ba6ae6c6d5eaee48495b1e4e52ceeea
checksum: 52c251f41b19a120d57237548b2c577a5ac5a18387f749c5ff85bd79f7499169feecb30f02cd8c966f6a335e5cac3d99a3fd15e5d759a10a6fc0e9c4b2c05b0a
languageName: node
linkType: hard

"@saberhq/tsconfig@npm:^1.12.61":
version: 1.12.61
resolution: "@saberhq/tsconfig@npm:1.12.61"
checksum: 73e13da1ed19a05161e3cee985660155dd0c6c6a765ea8b3d2e6c52647007b46a8f102419636817a84a74ee56bb3448e7e49b171ab66f50cfa617ce2e26f4da2
"@saberhq/tsconfig@npm:^1.12.62":
version: 1.12.62
resolution: "@saberhq/tsconfig@npm:1.12.62"
checksum: 16a3d781799b923e40066108c29b05728a7ff163db7968f3fb64577586f9c9fcaa8d02a57327f5eb7ec3daecb9988bde3656ff6fb962acee410ee6da764f565b
languageName: node
linkType: hard

Expand Down Expand Up @@ -548,10 +548,10 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^17.0.24":
version: 17.0.24
resolution: "@types/node@npm:17.0.24"
checksum: 9e7c4f863601b2430b4c2429a89935f22eba692956f5013c90a4c7fb0e1401ed8add8c4307453c5d6b8b985384500f8c3f644427ab88632640cc396159af479a
"@types/node@npm:^17.0.25":
version: 17.0.25
resolution: "@types/node@npm:17.0.25"
checksum: 6a820bd624e69ea772f52a6cdb326484eff5829443dc981939373929ade109f58c21698b9f0a831bd6ceea799e722a75dc49c5fa7a6bc32a81e1cbdfc6507b64
languageName: node
linkType: hard

Expand Down Expand Up @@ -2790,10 +2790,10 @@ fsevents@~2.3.2:
languageName: node
linkType: hard

"jsbi@npm:^4.2.1":
version: 4.2.1
resolution: "jsbi@npm:4.2.1"
checksum: e92d19e845c30406e998b875113782702ed15230f735a3c397c95f900f8ddbed6c460fd0e608317830040f5b13605fe6ddfda57ff5c6fa18987f20d11f92704e
"jsbi@npm:^4.3.0":
version: 4.3.0
resolution: "jsbi@npm:4.3.0"
checksum: 27c4f178eb7fd9d1756144066fdebc62f4a0176e877f55e646e8ce84075c13551bd575a316b9959ccdcca9d5dc05a81c9907cfa09f0cfeb43c9777797e36b0e9
languageName: node
linkType: hard

Expand Down

0 comments on commit 945bcb7

Please sign in to comment.