diff --git a/Cargo.toml b/Cargo.toml index 50fdc0c..c1c91d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,11 +8,11 @@ target = "wasm32-unknown-unknown" [workspace.dependencies] cosmos-sdk-proto = { version = "0.19", default-features = false } -cosmwasm-schema = "1.2" -cosmwasm-std = { version = "1.2", features = ["stargate"] } -cw2 = "1.0" -cw-storage-plus = "1" -cw-utils = "1" +cosmwasm-schema = "=1.4.1" +cosmwasm-std = { version = "=1.4.1", features = ["stargate"] } +cw2 = "1.1.1" +cw-storage-plus = "1.1.0" +cw-utils = "1.0.2" hex = "0.4" prost = "0.11" sha2 = { version = "0.10.8", features = ["oid"]} diff --git a/account/Cargo.toml b/account/Cargo.toml index 66f49bf..ef3f5d3 100644 --- a/account/Cargo.toml +++ b/account/Cargo.toml @@ -25,4 +25,4 @@ bech32 = { workspace = true } base64 = { workspace = true } phf = { workspace = true } rsa = { workspace = true } -getrandom = { workspace = true} \ No newline at end of file +getrandom = { workspace = true } \ No newline at end of file diff --git a/account/src/execute.rs b/account/src/execute.rs index 6939cb6..bb6e198 100644 --- a/account/src/execute.rs +++ b/account/src/execute.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Addr, Binary, Deps, DepsMut, Env, MessageInfo, Order, Response}; +use cosmwasm_std::{Addr, Binary, Deps, DepsMut, Env, Event, MessageInfo, Order, Response}; use crate::auth::{AddAuthenticator, Authenticator}; use crate::{ @@ -25,9 +25,16 @@ pub fn init( AUTHENTICATORS.save(deps.storage, id, &authenticator)?; } - Ok(Response::new() - .add_attribute("method", "init") - .add_attribute("authenticator_id", id.to_string())) + Ok( + Response::new().add_event(Event::new("create_abstract_account").add_attributes(vec![ + ("contract_address", env.contract.address.to_string()), + ( + "authenticator", + serde_json::to_string(&authenticator).unwrap(), + ), + ("authenticator_id", id.to_string()), + ])), + ) } pub fn before_tx( @@ -93,13 +100,15 @@ pub fn add_auth_method( add_authenticator: AddAuthenticator, ) -> ContractResult { assert_self(&info.sender, &env.contract.address)?; - match add_authenticator { + match add_authenticator.clone() { AddAuthenticator::Secp256K1 { id, pubkey, signature, } => { - let auth = Authenticator::Secp256K1 { pubkey }; + let auth = Authenticator::Secp256K1 { + pubkey: pubkey.clone(), + }; if !auth.verify( deps.api, @@ -110,9 +119,7 @@ pub fn add_auth_method( Err(ContractError::InvalidSignature) } else { AUTHENTICATORS.save(deps.storage, id, &auth)?; - Ok(Response::new() - .add_attribute("method", "execute") - .add_attribute("authenticator_id", id.to_string())) + Ok(()) } } AddAuthenticator::Ed25519 { @@ -131,9 +138,7 @@ pub fn add_auth_method( Err(ContractError::InvalidSignature) } else { AUTHENTICATORS.save(deps.storage, id, &auth)?; - Ok(Response::new() - .add_attribute("method", "execute") - .add_attribute("authenticator_id", id.to_string())) + Ok(()) } } AddAuthenticator::EthWallet { @@ -152,9 +157,7 @@ pub fn add_auth_method( Err(ContractError::InvalidSignature) } else { AUTHENTICATORS.save(deps.storage, id, &auth)?; - Ok(Response::new() - .add_attribute("method", "execute") - .add_attribute("authenticator_id", id.to_string())) + Ok(()) } } AddAuthenticator::Jwt { @@ -174,12 +177,19 @@ pub fn add_auth_method( Err(ContractError::InvalidSignature) } else { AUTHENTICATORS.save(deps.storage, id, &auth)?; - Ok(Response::new() - .add_attribute("method", "execute") - .add_attribute("authenticator_id", id.to_string())) + Ok(()) } } - } + }?; + Ok( + Response::new().add_event(Event::new("add_auth_method").add_attributes(vec![ + ("contract_address", env.contract.address.to_string()), + ( + "authenticator", + serde_json::to_string(&add_authenticator).unwrap(), + ), + ])), + ) } pub fn remove_auth_method( @@ -199,9 +209,12 @@ pub fn remove_auth_method( } AUTHENTICATORS.remove(deps.storage, id); - Ok(Response::new() - .add_attribute("method", "execute") - .add_attribute("authenticator_id", id.to_string())) + Ok( + Response::new().add_event(Event::new("remove_auth_method").add_attributes(vec![ + ("contract_address", env.contract.address.to_string()), + ("authenticator_id", id.to_string()), + ])), + ) } pub fn assert_self(sender: &Addr, contract: &Addr) -> ContractResult<()> {