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 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.incentive_admin)?)?;

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

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
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 incentive_admin: String,
LaurensKubat marked this conversation as resolved.
Show resolved Hide resolved
}

#[cw_serde]
pub enum ExecuteMsg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pub mod initialize {
let contract = wasm
.instantiate(
code_id,
&InstantiateMsg {},
&InstantiateMsg {
incentive_admin: admin.address(),
},
Some(admin.address().as_str()),
Some("merkle-incentives"),
&[],
Expand Down