-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
390 additions
and
348 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
pub mod config; | ||
pub mod consts; | ||
pub mod contract; | ||
mod crypto; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use super::*; | ||
use crate::contract::CONTRACT_VERSION; | ||
|
||
#[cw_serde] | ||
pub struct Execute; | ||
|
||
impl Execute { | ||
/// Accept transfer contract ownership (previously triggered by owner) | ||
pub fn execute(self, deps: DepsMut, _env: Env, info: MessageInfo) -> Result<Response, ContractError> { | ||
let pending_owner = PENDING_OWNER.load(deps.storage)?; | ||
if pending_owner.is_none() { | ||
return Err(ContractError::NoPendingOwnerFound); | ||
} | ||
if pending_owner.is_some_and(|owner| owner != info.sender) { | ||
return Err(ContractError::NotPendingOwner); | ||
} | ||
OWNER.save(deps.storage, &info.sender)?; | ||
PENDING_OWNER.save(deps.storage, &None)?; | ||
|
||
Ok(Response::new() | ||
.add_attribute("action", "accept-ownership") | ||
.add_events([Event::new("seda-accept-ownership") | ||
.add_attributes([("version", CONTRACT_VERSION), ("new_owner", info.sender.as_ref())])])) | ||
} | ||
} | ||
|
||
impl From<Execute> for crate::msgs::ExecuteMsg { | ||
fn from(value: Execute) -> Self { | ||
super::ExecuteMsg::AcceptOwnership(value).into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use super::*; | ||
use crate::contract::CONTRACT_VERSION; | ||
|
||
#[cw_serde] | ||
pub struct Execute { | ||
/// The public key of the person. | ||
pub(in crate::msgs::owner) public_key: PublicKey, | ||
} | ||
|
||
impl Execute { | ||
/// Add a `Secp256k1PublicKey` to the allow list | ||
pub fn execute(self, deps: DepsMut, info: MessageInfo) -> Result<Response, ContractError> { | ||
// require the sender to be the OWNER | ||
let owner = OWNER.load(deps.storage)?; | ||
if info.sender != owner { | ||
return Err(ContractError::NotOwner); | ||
} | ||
|
||
// add the address to the allowlist | ||
ALLOWLIST.save(deps.storage, &self.public_key, &true)?; | ||
|
||
Ok(Response::new().add_attribute("action", "add-to-allowlist").add_event( | ||
Event::new("add-to-allowlist").add_attributes([ | ||
("version", CONTRACT_VERSION.to_string()), | ||
("pub_key", hex::encode(self.public_key)), | ||
]), | ||
)) | ||
} | ||
} | ||
|
||
impl From<Execute> for crate::msgs::ExecuteMsg { | ||
fn from(value: Execute) -> Self { | ||
super::ExecuteMsg::AddToAllowlist(value).into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use cosmwasm_std::Event; | ||
use state::{ALLOWLIST, OWNER, PENDING_OWNER}; | ||
|
||
use super::*; | ||
use crate::{error::ContractError, types::PublicKey}; | ||
|
||
pub(in crate::msgs::owner) mod accept_ownership; | ||
pub(in crate::msgs::owner) mod add_to_allowlist; | ||
pub(in crate::msgs::owner) mod remove_from_allowlist; | ||
pub(in crate::msgs::owner) mod transfer_ownership; | ||
|
||
#[cw_serde] | ||
#[serde(untagged)] | ||
pub enum ExecuteMsg { | ||
TransferOwnership(transfer_ownership::Execute), | ||
AcceptOwnership(accept_ownership::Execute), | ||
/// Add a user to the allowlist. | ||
AddToAllowlist(add_to_allowlist::Execute), | ||
/// Remove a user from the allowlist. | ||
RemoveFromAllowlist(remove_from_allowlist::Execute), | ||
} | ||
|
||
impl ExecuteMsg { | ||
pub fn execute(self, deps: DepsMut, env: Env, info: MessageInfo) -> Result<Response, ContractError> { | ||
match self { | ||
ExecuteMsg::TransferOwnership(msg) => msg.execute(deps, env, info), | ||
ExecuteMsg::AcceptOwnership(msg) => msg.execute(deps, env, info), | ||
ExecuteMsg::AddToAllowlist(msg) => msg.execute(deps, info), | ||
ExecuteMsg::RemoveFromAllowlist(msg) => msg.execute(deps, info), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use super::*; | ||
use crate::contract::CONTRACT_VERSION; | ||
|
||
#[cw_serde] | ||
pub struct Execute { | ||
/// The public key of the person. | ||
pub(in crate::msgs::owner) public_key: PublicKey, | ||
} | ||
|
||
impl Execute { | ||
/// Remove a `Secp256k1PublicKey` to the allow list | ||
pub fn execute(self, deps: DepsMut, info: MessageInfo) -> Result<Response, ContractError> { | ||
// require the sender to be the OWNER | ||
let owner = OWNER.load(deps.storage)?; | ||
if info.sender != owner { | ||
return Err(ContractError::NotOwner); | ||
} | ||
|
||
// remove the address from the allowlist | ||
ALLOWLIST.remove(deps.storage, &self.public_key); | ||
|
||
Ok(Response::new() | ||
.add_attribute("action", "remove-from-allowlist") | ||
.add_event(Event::new("remove-from-allowlist").add_attributes([ | ||
("version", CONTRACT_VERSION.to_string()), | ||
("pub_key", hex::encode(self.public_key)), | ||
]))) | ||
} | ||
} | ||
|
||
impl From<Execute> for crate::msgs::ExecuteMsg { | ||
fn from(value: Execute) -> Self { | ||
super::ExecuteMsg::RemoveFromAllowlist(value).into() | ||
} | ||
} |
Oops, something went wrong.