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

Audit #4

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ optimize:
test:
cargo unit-test

<<<<<<< HEAD
FROM=nibi10rdtquh3jl44hg00x0plzeawuclqqet0he4692
AIRDROP_CONTRACT=nibi10jwwkmmn0rzxvfec5swhgvtkh4l94fshz0r8ndj9ldym87lkgdjs4z4cyp
=======
WALLET=nibi1d3lmwkgjgdyfpsn4xgh299jnpk4r89kd5xs420
AIRDROP_CONTRACT=nibi1lz6h4tav6q8jrpxxs6kv63hztlmpu27jj50jcnrt9p7wd2nrmz9s9600vz
CODE_ID=421
WALLET_NAME=jarvis
>>>>>>> f8a4af504d3b45ae487ba064c7d39c846c54be0e

make-wallet:
@nibid keys add wallet ${WALLET_NAME}
Expand Down
4 changes: 4 additions & 0 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<<<<<<< HEAD
6cad51fd1cd844c98c7e367b1b0910c4389e8f0c4a69edab1821e7aeb99094f9 jarvis_airdrop.wasm
=======
d63576084b69def9913aae0899dcba97a22482511bd860bac1345e455332fbfc jarvis_airdrop.wasm
>>>>>>> f8a4af504d3b45ae487ba064c7d39c846c54be0e
4 changes: 4 additions & 0 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<<<<<<< HEAD
deddb63d42e3a8126c7edda8a28755f4ec6f28ee7f40becb1755b5e3c1be49f7 /target/wasm32-unknown-unknown/release/jarvis_airdrop.wasm
=======
5f9d4a5aeeef32dfe13b0866f83378a51934ead6a95938042e1cc2966ab31032 /target/wasm32-unknown-unknown/release/jarvis_airdrop.wasm
>>>>>>> f8a4af504d3b45ae487ba064c7d39c846c54be0e
Binary file modified artifacts/jarvis_airdrop.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions commands/send_nfts.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"send_nfts": {
"allocations": [
{ "recipient": "nibi1h6rwvqcmu6nj0evgg39u6aq0detsu6a7eax7yf", "amount": 3 },
{ "recipient": "nibi1h6rwvqcmu6nj0evgg39u6aq0detsu6a7eax7yf", "amount": 5 }
{ "recipient": "nibi1h6rwvqcmu6nj0evgg39u6aq0detsu6a7eax7yf", "amount": 2 },
{ "recipient": "nibi1d3lmwkgjgdyfpsn4xgh299jnpk4r89kd5xs420", "amount": 2 }
]
}
}
2 changes: 1 addition & 1 deletion commands/set_nft_contract_addr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"set_nft_contract_addr": {
"addr": "nibi178kzznh9cepjckjefqc3mgt9gf9rfkyw6kk0pymeypx9rplggvyq9yjjuv"
"addr": "nibi1k3z45lxqeulsyffry77djz2f303echnaa5djgda2fk8n8zphyqtq2ffqq4"
}
}
14 changes: 7 additions & 7 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use cw2::set_contract_version;
use cw721::Cw721ExecuteMsg;

use crate::error::ContractError;
use crate::msg::{AllNftsResponse, ExecuteMsg, InstantiateMsg, NftContractAddrResponse, QueryMsg};
use crate::state::{State, NFTS, NFT_CONTRACT_ADDR, STATE};
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, AllNftsResponse, NftContractAddrResponse, SendNftParam};
use crate::state::{State, STATE, NFTS, NFT_CONTRACT_ADDR};

// version info for migration info
const CONTRACT_NAME: &str = "crates.io:jarvis-airdrop";
Expand Down Expand Up @@ -94,7 +94,7 @@ pub mod execute {
deps: DepsMut,
_env: Env,
info: MessageInfo,
allocations: Vec<(Addr, u32)>,
allocations: Vec<SendNftParam>,
) -> Result<Response, ContractError> {
let state = STATE.load(deps.storage)?;

Expand All @@ -109,13 +109,13 @@ pub mod execute {

let mut nfts = NFTS.load(deps.storage)?;
let mut response = Response::new().add_attribute("action", "send_nfts");

for (recipient, amount) in allocations {
for _ in 0..amount {
for ele in allocations {
for _ in 0..ele.amount {
if let Some(token_id) = nfts.pop() {
// Create a transfer message for the cw721 NFT
let transfer_msg = Cw721ExecuteMsg::TransferNft {
recipient: recipient.to_string(),
recipient: ele.recipient.to_string(),
token_id: token_id,
};

Expand Down
12 changes: 8 additions & 4 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ pub enum ExecuteMsg {
msg: Binary,
},
SendNfts {
allocations: Vec<(Addr, u32)>, // Each tuple contains an address and the number of NFTs to send
},
SetNftContractAddr {
addr: String,
allocations: Vec<SendNftParam>, // Each tuple contains an address and the number of NFTs to send
},
SetNftContractAddr { addr: String },
}

#[cw_serde]
Expand All @@ -38,3 +36,9 @@ pub struct AllNftsResponse {
pub struct NftContractAddrResponse {
pub nft_contract_addr: Addr,
}

#[cw_serde]
pub struct SendNftParam {
pub recipient: Addr,
pub amount: u32
}
Loading