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

set incentive admin in instantiate #600

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion smart-contracts/contracts/merkle-incentives/.cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
wasm = "build --release --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin schema"
test-tube = "test --package merkle-incentives --lib -- --include-ignored test_tube:: --nocapture --test-threads=1"
test-tube = "test --package merkle-incentives --test merkle -- --include-ignored --nocapture --test-threads=1"
LaurensKubat marked this conversation as resolved.
Show resolved Hide resolved
test-tube-build = "build --release --lib --target wasm32-unknown-unknown --target-dir ./test-tube-build"
3 changes: 3 additions & 0 deletions smart-contracts/contracts/merkle-incentives/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ The merkle proof/root generator will strip commas and spaces from the csv before

during the claim, the contract will automatically sort the tokens and strip commas/whitespace, so no additional work is required on the client side in order to claim, as long as they have the proper proof generated.

## Updating merkle root
The merkle root of the contract is updated by the incentives admin. This admin is an address set at instantiation and can be updated by the contract admin.

## Test

The test data directory contains a csv called testdata.csv. This is the source document that a merkle tree can be generated on. As you can see we can easily add more rows to add users and more columns to add more incentive tokens.
Expand Down
8 changes: 4 additions & 4 deletions smart-contracts/contracts/merkle-incentives/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn instantiate(
deps: DepsMut,
_env: Env,
info: MessageInfo,
_msg: InstantiateMsg,
_info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

INCENTIVES_ADMIN.save(deps.storage, &info.sender)?;
INCENTIVES_ADMIN.save(deps.storage, &deps.api.addr_validate(&msg.incentives_admin)?)?;

Ok(Response::default().add_attribute("incentive_admin", info.sender))
Ok(Response::default().add_attribute("incentive_admin", msg.incentives_admin))
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
3 changes: 0 additions & 3 deletions smart-contracts/contracts/merkle-incentives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ pub mod incentives;
pub mod msg;
pub mod state;

#[cfg(test)]
mod test_tube;

pub use crate::error::ContractError;
4 changes: 3 additions & 1 deletion smart-contracts/contracts/merkle-incentives/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use crate::{
};

#[cw_serde]
pub struct InstantiateMsg {}
pub struct InstantiateMsg {
pub incentives_admin: String,
}

#[cw_serde]
pub enum ExecuteMsg {
Expand Down

This file was deleted.

Loading
Loading