From 8d62f887ec8582699248a5c9f03ab109d7f6322e Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Mon, 18 Sep 2023 23:10:56 -0400 Subject: [PATCH] refactor: use axelar-wasm-std ContractError (#105) All contracts now return axelar-wasm-std ContractError at the highest level. Going forward, this allows us to stepwise integrate error-stack into each contract in an isolated manner --- Cargo.lock | 27 ++ contracts/aggregate-verifier/Cargo.toml | 4 + contracts/aggregate-verifier/src/contract.rs | 13 +- contracts/aggregate-verifier/src/error.rs | 3 +- contracts/aggregate-verifier/tests/test.rs | 6 +- contracts/batching/Cargo.toml | 4 + contracts/batching/src/contract.rs | 2 +- contracts/connection-router/Cargo.toml | 3 + contracts/connection-router/src/contract.rs | 8 +- contracts/connection-router/src/error.rs | 3 +- contracts/connection-router/tests/test.rs | 300 ++++++++++++++----- contracts/gateway/Cargo.toml | 4 + contracts/gateway/src/contract.rs | 5 +- contracts/gateway/src/error.rs | 3 +- contracts/gateway/tests/tests.rs | 14 +- contracts/multisig-prover/Cargo.toml | 3 + contracts/multisig-prover/src/contract.rs | 33 +- contracts/multisig-prover/src/error.rs | 3 +- contracts/multisig/Cargo.toml | 3 + contracts/multisig/src/contract.rs | 49 +-- contracts/multisig/src/error.rs | 3 +- contracts/service-registry/Cargo.toml | 3 + contracts/service-registry/src/contract.rs | 5 +- contracts/service-registry/src/error.rs | 3 +- contracts/service-registry/tests/tests.rs | 37 ++- contracts/voting-verifier/Cargo.toml | 3 + contracts/voting-verifier/src/contract.rs | 9 +- contracts/voting-verifier/src/error.rs | 8 +- contracts/voting-verifier/tests/tests.rs | 18 +- 29 files changed, 431 insertions(+), 148 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e6867a40..8ded4ecfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,6 +42,8 @@ dependencies = [ name = "aggregate-verifier" version = "0.1.0" dependencies = [ + "axelar-wasm-std", + "axelar-wasm-std-derive", "connection-router", "cosmwasm-schema", "cosmwasm-std", @@ -50,6 +52,8 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw-utils 1.0.1", "cw2 0.15.1", + "error-stack", + "report", "schemars", "serde", "serde_json", @@ -414,9 +418,13 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" name = "batching" version = "0.1.0" dependencies = [ + "axelar-wasm-std", + "axelar-wasm-std-derive", "cosmwasm-schema", "cosmwasm-std", "cw2 0.15.1", + "error-stack", + "report", "thiserror", ] @@ -760,15 +768,18 @@ name = "connection-router" version = "0.1.0" dependencies = [ "axelar-wasm-std", + "axelar-wasm-std-derive", "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", "cw-multi-test", "cw-storage-plus 1.1.0", "cw2 0.15.1", + "error-stack", "flagset", "hex", "rand", + "report", "schemars", "serde", "serde_json", @@ -2261,6 +2272,8 @@ name = "gateway" version = "0.1.0" dependencies = [ "aggregate-verifier", + "axelar-wasm-std", + "axelar-wasm-std-derive", "connection-router", "cosmwasm-schema", "cosmwasm-std", @@ -2269,6 +2282,8 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw-utils 1.0.1", "cw2 0.15.1", + "error-stack", + "report", "schemars", "serde", "serde_json", @@ -3005,6 +3020,7 @@ name = "multisig" version = "0.1.0" dependencies = [ "axelar-wasm-std", + "axelar-wasm-std-derive", "cosmwasm-crypto", "cosmwasm-schema", "cosmwasm-std", @@ -3012,8 +3028,10 @@ dependencies = [ "cw-multi-test", "cw-storage-plus 1.1.0", "cw2 0.15.1", + "error-stack", "getrandom", "rand", + "report", "schemars", "serde", "serde_json", @@ -3026,6 +3044,7 @@ version = "0.1.0" dependencies = [ "anyhow", "axelar-wasm-std", + "axelar-wasm-std-derive", "connection-router", "cosmwasm-schema", "cosmwasm-std", @@ -3035,12 +3054,14 @@ dependencies = [ "cw-utils 1.0.1", "cw2 0.15.1", "either", + "error-stack", "ethabi", "gateway", "hex", "itertools 0.11.0", "k256 0.13.1", "multisig", + "report", "schemars", "serde", "serde_json", @@ -4457,12 +4478,15 @@ name = "service-registry" version = "0.1.0" dependencies = [ "axelar-wasm-std", + "axelar-wasm-std-derive", "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", "cw-multi-test", "cw-storage-plus 0.15.1", "cw2 0.15.1", + "error-stack", + "report", "schemars", "serde", "thiserror", @@ -5510,6 +5534,7 @@ name = "voting-verifier" version = "0.1.0" dependencies = [ "axelar-wasm-std", + "axelar-wasm-std-derive", "connection-router", "cosmwasm-schema", "cosmwasm-std", @@ -5519,6 +5544,8 @@ dependencies = [ "cw0", "cw2 0.15.1", "either", + "error-stack", + "report", "schemars", "serde", "serde_json", diff --git a/contracts/aggregate-verifier/Cargo.toml b/contracts/aggregate-verifier/Cargo.toml index 3bb81dc64..f3a89a20d 100644 --- a/contracts/aggregate-verifier/Cargo.toml +++ b/contracts/aggregate-verifier/Cargo.toml @@ -28,6 +28,8 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] +axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } connection-router = { workspace = true, features = ["library"] } cosmwasm-schema = "1.1.3" cosmwasm-std = "1.1.3" @@ -35,6 +37,8 @@ cosmwasm-storage = "1.1.3" cw-storage-plus = "1.0.1" cw-utils = "1.0.1" cw2 = "0.15.1" +error-stack = { workspace = true } +report = { workspace = true } schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" diff --git a/contracts/aggregate-verifier/src/contract.rs b/contracts/aggregate-verifier/src/contract.rs index 71120d4c7..4b337258f 100644 --- a/contracts/aggregate-verifier/src/contract.rs +++ b/contracts/aggregate-verifier/src/contract.rs @@ -23,7 +23,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, msg: InstantiateMsg, -) -> Result { +) -> Result { let verifier = deps.api.addr_validate(&msg.verifier_address)?; CONFIG.save(deps.storage, &Config { verifier })?; @@ -36,9 +36,10 @@ pub fn execute( _env: Env, _info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { ExecuteMsg::VerifyMessages { messages } => { + // todo: this conversion can go away once the message types are merged let msgs = messages .into_iter() .map(state::Message::try_from) @@ -47,6 +48,7 @@ pub fn execute( verify_messages(deps, msgs) } } + .map_err(axelar_wasm_std::ContractError::from) } pub mod execute { @@ -80,7 +82,11 @@ pub mod execute { const VERIFY_REPLY: u64 = 0; #[cfg_attr(not(feature = "library"), entry_point)] -pub fn reply(_deps: DepsMut, _: Env, reply: Reply) -> Result { +pub fn reply( + _deps: DepsMut, + _: Env, + reply: Reply, +) -> Result { match parse_reply_execute_data(reply) { Ok(MsgExecuteContractResponse { data: Some(data) }) => { // check format of data @@ -97,6 +103,7 @@ pub fn reply(_deps: DepsMut, _: Env, reply: Reply) -> Result().unwrap().to_string(), + ContractError::from(connection_router::error::ContractError::InvalidMessageID).to_string() ) } diff --git a/contracts/batching/Cargo.toml b/contracts/batching/Cargo.toml index 457c4469d..a29d52ee9 100644 --- a/contracts/batching/Cargo.toml +++ b/contracts/batching/Cargo.toml @@ -5,7 +5,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } cosmwasm-schema = "1.1.3" cosmwasm-std = "1.1.3" cw2 = "0.15.1" +error-stack = { workspace = true } +report = { workspace = true } thiserror = { workspace = true } diff --git a/contracts/batching/src/contract.rs b/contracts/batching/src/contract.rs index 385c5ba96..6db89236d 100644 --- a/contracts/batching/src/contract.rs +++ b/contracts/batching/src/contract.rs @@ -1,10 +1,10 @@ +use axelar_wasm_std::ContractError; #[cfg(not(feature = "library"))] use cosmwasm_std::DepsMut; use cosmwasm_std::{ entry_point, Env, Event, MessageInfo, Reply, Response, StdResult, SubMsg, SubMsgResult, }; -use crate::error::ContractError; use crate::msg::{BatchMsg, ExecuteMsg, InstantiateMsg}; #[cfg_attr(not(feature = "library"), entry_point)] diff --git a/contracts/connection-router/Cargo.toml b/contracts/connection-router/Cargo.toml index c8931803f..699601550 100644 --- a/contracts/connection-router/Cargo.toml +++ b/contracts/connection-router/Cargo.toml @@ -29,12 +29,15 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } cosmwasm-schema = "1.1.3" cosmwasm-std = "1.1.3" cosmwasm-storage = "1.1.3" cw-storage-plus = "1.0.1" cw2 = "0.15.1" +error-stack = { workspace = true } flagset = { version = "0.4.3", features = ["serde"] } +report = { workspace = true } schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" diff --git a/contracts/connection-router/src/contract.rs b/contracts/connection-router/src/contract.rs index e00ac593b..9aa7ba800 100644 --- a/contracts/connection-router/src/contract.rs +++ b/contracts/connection-router/src/contract.rs @@ -13,7 +13,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, msg: InstantiateMsg, -) -> Result { +) -> Result { let admin = deps.api.addr_validate(&msg.admin_address)?; let governance = deps.api.addr_validate(&msg.governance_address)?; CONFIG.save( @@ -32,7 +32,7 @@ pub fn execute( _env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { ExecuteMsg::RegisterChain { chain, @@ -63,9 +63,11 @@ pub fn execute( info, msgs.into_iter() .map(Message::try_from) - .collect::, _>>()?, + .collect::, _>>() + .map_err(axelar_wasm_std::ContractError::from)?, ), } + .map_err(axelar_wasm_std::ContractError::from) } pub mod execute { diff --git a/contracts/connection-router/src/error.rs b/contracts/connection-router/src/error.rs index abbe41e2b..d3e9e8139 100644 --- a/contracts/connection-router/src/error.rs +++ b/contracts/connection-router/src/error.rs @@ -1,9 +1,10 @@ +use axelar_wasm_std_derive::IntoContractError; use cosmwasm_std::StdError; use thiserror::Error; use crate::types::ChainName; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, IntoContractError)] pub enum ContractError { #[error(transparent)] Std(#[from] StdError), diff --git a/contracts/connection-router/tests/test.rs b/contracts/connection-router/tests/test.rs index 89cbd59df..1279e003e 100644 --- a/contracts/connection-router/tests/test.rs +++ b/contracts/connection-router/tests/test.rs @@ -1,18 +1,19 @@ -use connection_router::{self, msg}; use std::{collections::HashMap, vec}; -use connection_router::types::{ChainName, GatewayDirection, ID_SEPARATOR}; use cosmwasm_std::Addr; +use cosmwasm_std::HexBinary; use cw_multi_test::{App, ContractWrapper, Executor}; use connection_router::contract::*; use connection_router::error::ContractError; use connection_router::msg::{ExecuteMsg, InstantiateMsg}; -use cosmwasm_std::HexBinary; +use connection_router::types::{ChainName, GatewayDirection, ID_SEPARATOR}; +use connection_router::{self, msg}; + pub mod mock; struct TestConfig { - app: cw_multi_test::App, + app: App, contract_address: Addr, admin_address: Addr, governance_address: Addr, @@ -147,7 +148,12 @@ fn route_non_existing_chain() { &[], ) .unwrap_err(); - assert_eq!(ContractError::ChainNotFound, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainNotFound).to_string() + ); } #[test] @@ -192,7 +198,12 @@ fn message_id() { &[], ) .unwrap_err(); - assert_eq!(ContractError::InvalidMessageID, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidMessageID).to_string() + ); // don't prepend source chain let bad_id = msg.id.split(&msg.source_chain).collect::>()[0]; @@ -208,7 +219,12 @@ fn message_id() { &[], ) .unwrap_err(); - assert_eq!(ContractError::InvalidMessageID, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidMessageID).to_string() + ); let res = config .app @@ -222,7 +238,12 @@ fn message_id() { &[], ) .unwrap_err(); - assert_eq!(ContractError::InvalidMessageID, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidMessageID).to_string() + ); let res = config .app @@ -236,7 +257,12 @@ fn message_id() { &[], ) .unwrap_err(); - assert_eq!(ContractError::InvalidMessageID, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidMessageID).to_string() + ); } #[test] @@ -263,8 +289,11 @@ fn invalid_address() { ) .unwrap_err(); assert_eq!( - ContractError::InvalidAddress("".to_string()), - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidAddress("".to_string())) + .to_string() ); let res = config @@ -280,8 +309,11 @@ fn invalid_address() { ) .unwrap_err(); assert_eq!( - ContractError::InvalidAddress("".to_string()), - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidAddress("".to_string())) + .to_string() ); } @@ -305,7 +337,12 @@ fn wrong_source_chain() { &[], ) .unwrap_err(); - assert_eq!(ContractError::WrongSourceChain, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::WrongSourceChain).to_string() + ); } #[test] @@ -383,7 +420,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config .app @@ -398,7 +440,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config.app.execute_contract( config.governance_address.clone(), @@ -424,7 +471,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config .app @@ -439,7 +491,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config.app.execute_contract( config.admin_address.clone(), @@ -465,7 +522,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config .app @@ -480,7 +542,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config.app.execute_contract( config.admin_address.clone(), @@ -506,7 +573,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config .app @@ -521,7 +593,12 @@ fn authorization() { ) .unwrap_err(); - assert_eq!(ContractError::Unauthorized, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() + ); let res = config.app.execute_contract( config.governance_address.clone(), @@ -610,7 +687,12 @@ fn upgrade_gateway_incoming() { &[], ) .unwrap_err(); - assert_eq!(ContractError::GatewayNotRegistered, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::GatewayNotRegistered).to_string() + ); let res = config.app.execute_contract( new_gateway, @@ -640,7 +722,12 @@ fn register_chain_test() { &[], ) .unwrap_err(); - assert_eq!(ContractError::GatewayNotRegistered, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::GatewayNotRegistered).to_string() + ); register_chain(&mut config, ð); let res = config @@ -652,7 +739,12 @@ fn register_chain_test() { &[], ) .unwrap_err(); - assert_eq!(ContractError::ChainNotFound, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainNotFound).to_string() + ); register_chain(&mut config, &polygon); let res = config.app.execute_contract( @@ -682,7 +774,12 @@ fn chain_already_registered() { &[], ) .unwrap_err(); - assert_eq!(ContractError::ChainAlreadyExists, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainAlreadyExists).to_string() + ); // case insensitive let res = config @@ -697,7 +794,12 @@ fn chain_already_registered() { &[], ) .unwrap_err(); - assert_eq!(ContractError::ChainAlreadyExists, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainAlreadyExists).to_string() + ); } #[test] @@ -715,7 +817,12 @@ fn invalid_chain_name() { &[], ) .unwrap_err(); - assert_eq!(ContractError::InvalidChainName, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidChainName).to_string() + ); let res = config .app @@ -729,7 +836,12 @@ fn invalid_chain_name() { &[], ) .unwrap_err(); - assert_eq!(ContractError::InvalidChainName, res.downcast().unwrap()); + assert_eq!( + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidChainName).to_string() + ); } #[test] @@ -751,8 +863,10 @@ fn gateway_already_registered() { ) .unwrap_err(); assert_eq!( - ContractError::GatewayAlreadyRegistered, - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::GatewayAlreadyRegistered).to_string() ); register_chain(&mut config, &polygon); @@ -769,8 +883,10 @@ fn gateway_already_registered() { ) .unwrap_err(); assert_eq!( - ContractError::GatewayAlreadyRegistered, - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::GatewayAlreadyRegistered).to_string() ); } @@ -807,10 +923,13 @@ fn freeze_incoming() { ) .unwrap_err(); assert_eq!( - ContractError::ChainFrozen { + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { chain: polygon.chain_name.clone() - }, - res.downcast().unwrap() + }) + .to_string() ); let msg = &generate_messages(ð, &polygon, &mut 0, 1)[0]; @@ -879,10 +998,13 @@ fn freeze_outgoing() { ) .unwrap_err(); assert_eq!( - ContractError::ChainFrozen { + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { chain: polygon.chain_name.clone() - }, - res.downcast().unwrap() + }) + .to_string() ); let res = config.app.execute_contract( @@ -952,10 +1074,13 @@ fn freeze_chain() { .unwrap_err(); // can't route to frozen chain assert_eq!( - ContractError::ChainFrozen { + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { chain: polygon.chain_name.clone() - }, - res.downcast().unwrap() + }) + .to_string() ); // can't route from frozen chain @@ -970,10 +1095,13 @@ fn freeze_chain() { ) .unwrap_err(); assert_eq!( - ContractError::ChainFrozen { - chain: polygon.chain_name.clone(), - }, - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { + chain: polygon.chain_name.clone() + }) + .to_string() ); // unfreeze and test that everything works correctly @@ -1077,10 +1205,13 @@ fn unfreeze_incoming() { .unwrap_err(); // can't route to the chain assert_eq!( - ContractError::ChainFrozen { + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { chain: polygon.chain_name.clone() - }, - res.downcast().unwrap() + }) + .to_string() ); } @@ -1131,10 +1262,13 @@ fn unfreeze_outgoing() { ) .unwrap_err(); assert_eq!( - ContractError::ChainFrozen { - chain: polygon.chain_name.clone(), - }, - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { + chain: polygon.chain_name.clone() + }) + .to_string() ); // can route to the chain now @@ -1195,10 +1329,13 @@ fn freeze_incoming_then_outgoing() { .unwrap_err(); // can't route to frozen chain assert_eq!( - ContractError::ChainFrozen { + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { chain: polygon.chain_name.clone() - }, - res.downcast().unwrap() + }) + .to_string() ); // can't route from frozen chain @@ -1213,10 +1350,13 @@ fn freeze_incoming_then_outgoing() { ) .unwrap_err(); assert_eq!( - ContractError::ChainFrozen { - chain: polygon.chain_name.clone(), - }, - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { + chain: polygon.chain_name.clone() + }) + .to_string() ); } @@ -1267,10 +1407,13 @@ fn freeze_outgoing_then_incoming() { .unwrap_err(); // can't route to frozen chain assert_eq!( - ContractError::ChainFrozen { + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { chain: polygon.chain_name.clone() - }, - res.downcast().unwrap() + }) + .to_string() ); // can't route from frozen chain @@ -1285,10 +1428,13 @@ fn freeze_outgoing_then_incoming() { ) .unwrap_err(); assert_eq!( - ContractError::ChainFrozen { - chain: polygon.chain_name.clone(), - }, - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { + chain: polygon.chain_name.clone() + }) + .to_string() ); } @@ -1476,10 +1622,13 @@ fn unfreeze_nothing() { .unwrap_err(); // can't route to frozen chain assert_eq!( - ContractError::ChainFrozen { + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { chain: polygon.chain_name.clone() - }, - res.downcast().unwrap() + }) + .to_string() ); // can't route from frozen chain @@ -1494,10 +1643,13 @@ fn unfreeze_nothing() { ) .unwrap_err(); assert_eq!( - ContractError::ChainFrozen { - chain: polygon.chain_name.clone(), - }, - res.downcast().unwrap() + res.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::ChainFrozen { + chain: polygon.chain_name.clone() + }) + .to_string() ); } diff --git a/contracts/gateway/Cargo.toml b/contracts/gateway/Cargo.toml index 9a6ede8d8..644d1cf78 100644 --- a/contracts/gateway/Cargo.toml +++ b/contracts/gateway/Cargo.toml @@ -29,6 +29,8 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] aggregate-verifier = { workspace = true, features = ["library"] } +axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } connection-router = { workspace = true, features = ["library"] } cosmwasm-schema = "1.1.3" cosmwasm-std = "1.1.3" @@ -36,6 +38,8 @@ cosmwasm-storage = "1.1.3" cw-storage-plus = "1.0.1" cw-utils = "1.0.1" cw2 = "0.15.1" +error-stack = { workspace = true } +report = { workspace = true } schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" diff --git a/contracts/gateway/src/contract.rs b/contracts/gateway/src/contract.rs index 3b3d5d558..0c9a2553a 100644 --- a/contracts/gateway/src/contract.rs +++ b/contracts/gateway/src/contract.rs @@ -18,7 +18,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, msg: InstantiateMsg, -) -> Result { +) -> Result { let router = deps.api.addr_validate(&msg.router_address)?; let verifier = deps.api.addr_validate(&msg.verifier_address)?; @@ -33,7 +33,7 @@ pub fn execute( _env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { ExecuteMsg::VerifyMessages(messages) => { let msgs = messages @@ -57,6 +57,7 @@ pub fn execute( } } } + .map_err(axelar_wasm_std::ContractError::from) } pub mod execute { diff --git a/contracts/gateway/src/error.rs b/contracts/gateway/src/error.rs index 9af76ddc1..5af89069c 100644 --- a/contracts/gateway/src/error.rs +++ b/contracts/gateway/src/error.rs @@ -1,7 +1,8 @@ +use axelar_wasm_std_derive::IntoContractError; use cosmwasm_std::StdError; use thiserror::Error; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, IntoContractError)] pub enum ContractError { #[error(transparent)] Std(#[from] StdError), diff --git a/contracts/gateway/tests/tests.rs b/contracts/gateway/tests/tests.rs index 964ffc7a4..e37be5355 100644 --- a/contracts/gateway/tests/tests.rs +++ b/contracts/gateway/tests/tests.rs @@ -908,7 +908,12 @@ fn duplicate_message_id() { &[], ) .unwrap_err(); - assert_eq!(ContractError::DuplicateMessageID, err.downcast().unwrap()); + assert_eq!( + err.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::DuplicateMessageID).to_string() + ); let err = app .execute_contract( @@ -918,7 +923,12 @@ fn duplicate_message_id() { &[], ) .unwrap_err(); - assert_eq!(ContractError::DuplicateMessageID, err.downcast().unwrap()); + assert_eq!( + err.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::DuplicateMessageID).to_string() + ); //verify one of them mark_messages_as_verified(&mut app, verifier_address.clone(), msgs[0..1].to_vec()); diff --git a/contracts/multisig-prover/Cargo.toml b/contracts/multisig-prover/Cargo.toml index b6b546647..6ab434dd5 100644 --- a/contracts/multisig-prover/Cargo.toml +++ b/contracts/multisig-prover/Cargo.toml @@ -29,6 +29,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } connection-router = { workspace = true, features = ["library"] } cosmwasm-schema = "1.1.3" cosmwasm-std = "1.1.3" @@ -37,12 +38,14 @@ cw-storage-plus = "1.0.1" cw-utils = "1.0.1" cw2 = "0.15.1" either = "1.8.1" +error-stack = { workspace = true } ethabi = { version = "18.0.0", default-features = false, features = [] } gateway = { workspace = true } hex = { version = "0.4.3", default-features = false, features = [] } itertools = "0.11.0" k256 = { version = "0.13.1", features = ["ecdsa"] } multisig = { workspace = true, features = ["library"] } +report = { workspace = true } schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" diff --git a/contracts/multisig-prover/src/contract.rs b/contracts/multisig-prover/src/contract.rs index 55a80d55a..f4d15173a 100644 --- a/contracts/multisig-prover/src/contract.rs +++ b/contracts/multisig-prover/src/contract.rs @@ -25,7 +25,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, msg: InstantiateMsg, -) -> Result { +) -> Result { let admin = deps.api.addr_validate(&msg.admin_address)?; let gateway = deps.api.addr_validate(&msg.gateway_address)?; let multisig = deps.api.addr_validate(&msg.multisig_address)?; @@ -58,20 +58,26 @@ pub fn execute( env: Env, _info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { ExecuteMsg::ConstructProof { message_ids } => execute::construct_proof(deps, message_ids), ExecuteMsg::UpdateWorkerSet {} => execute::update_worker_set(deps, env), ExecuteMsg::ConfirmWorkerSet {} => execute::confirm_worker_set(deps), } + .map_err(axelar_wasm_std::ContractError::from) } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn reply(deps: DepsMut, _env: Env, reply: Reply) -> Result { +pub fn reply( + deps: DepsMut, + _env: Env, + reply: Reply, +) -> Result { match reply.id { START_MULTISIG_REPLY_ID => reply::start_multisig_reply(deps, reply), _ => unreachable!("unknown reply ID"), } + .map_err(axelar_wasm_std::ContractError::from) } #[cfg_attr(not(feature = "library"), entry_point)] @@ -385,8 +391,11 @@ mod tests { assert!(res.is_err()); assert_eq!( - ContractError::WorkerSetUnchanged, - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::WorkerSetUnchanged).to_string() ); } @@ -454,8 +463,11 @@ mod tests { let res = confirm_worker_set(&mut test_case); assert!(res.is_err()); assert_eq!( - ContractError::WorkerSetNotConfirmed, - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::WorkerSetNotConfirmed).to_string() ); } @@ -492,8 +504,11 @@ mod tests { let res = confirm_worker_set(&mut test_case); assert!(res.is_err()); assert_eq!( - ContractError::WorkerSetNotConfirmed, - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::WorkerSetNotConfirmed).to_string() ); } diff --git a/contracts/multisig-prover/src/error.rs b/contracts/multisig-prover/src/error.rs index fd1c07b97..e236b6025 100644 --- a/contracts/multisig-prover/src/error.rs +++ b/contracts/multisig-prover/src/error.rs @@ -1,8 +1,9 @@ use axelar_wasm_std::nonempty; +use axelar_wasm_std_derive::IntoContractError; use cosmwasm_std::StdError; use thiserror::Error; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, IntoContractError)] pub enum ContractError { #[error(transparent)] Std(#[from] StdError), diff --git a/contracts/multisig/Cargo.toml b/contracts/multisig/Cargo.toml index 98d22fe43..2aafdad13 100644 --- a/contracts/multisig/Cargo.toml +++ b/contracts/multisig/Cargo.toml @@ -32,13 +32,16 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } cosmwasm-crypto = "1.2.7" cosmwasm-schema = "1.1.3" cosmwasm-std = "1.1.3" cosmwasm-storage = "1.1.3" cw-storage-plus = "1.0.1" cw2 = "0.15.1" +error-stack = { workspace = true } getrandom = { version = "0.2", default-features = false, features = ["custom"] } +report = { workspace = true } schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" diff --git a/contracts/multisig/src/contract.rs b/contracts/multisig/src/contract.rs index 818f00f37..5531e723b 100644 --- a/contracts/multisig/src/contract.rs +++ b/contracts/multisig/src/contract.rs @@ -22,7 +22,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, _msg: InstantiateMsg, -) -> Result { +) -> Result { SIGNING_SESSION_COUNTER.save(deps.storage, &Uint64::zero())?; Ok(Response::default()) @@ -34,11 +34,15 @@ pub fn execute( _env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { - ExecuteMsg::StartSigningSession { key_id, msg } => { - execute::start_signing_session(deps, info, key_id, msg.try_into()?) - } + ExecuteMsg::StartSigningSession { key_id, msg } => execute::start_signing_session( + deps, + info, + key_id, + msg.try_into() + .map_err(axelar_wasm_std::ContractError::from)?, + ), ExecuteMsg::SubmitSignature { session_id, signature, @@ -52,6 +56,7 @@ pub fn execute( execute::register_pub_key(deps, info, public_key) } } + .map_err(axelar_wasm_std::ContractError::from) } pub mod execute { @@ -303,7 +308,7 @@ mod tests { const INSTANTIATOR: &str = "inst"; const PROVER: &str = "prover"; - fn do_instantiate(deps: DepsMut) -> Result { + fn do_instantiate(deps: DepsMut) -> Result { let info = mock_info(INSTANTIATOR, &[]); let env = mock_env(); @@ -312,7 +317,7 @@ mod tests { instantiate(deps, env, info, msg) } - fn do_key_gen(deps: DepsMut) -> Result<(Response, Key), ContractError> { + fn do_key_gen(deps: DepsMut) -> Result<(Response, Key), axelar_wasm_std::ContractError> { let info = mock_info(PROVER, &[]); let env = mock_env(); @@ -368,7 +373,10 @@ mod tests { ) } - fn do_start_signing_session(deps: DepsMut, sender: &str) -> Result { + fn do_start_signing_session( + deps: DepsMut, + sender: &str, + ) -> Result { let info = mock_info(sender, &[]); let env = mock_env(); @@ -384,7 +392,7 @@ mod tests { deps: DepsMut, session_id: Uint64, signer: &TestSigner, - ) -> Result { + ) -> Result { let msg = ExecuteMsg::SubmitSignature { session_id, signature: signer.signature.clone(), @@ -401,7 +409,7 @@ mod tests { deps: DepsMut, worker: Addr, public_key: PublicKey, - ) -> Result { + ) -> Result { let msg = ExecuteMsg::RegisterPublicKey { public_key }; execute(deps, mock_env(), mock_info(worker.as_str(), &[]), msg) } @@ -475,14 +483,15 @@ mod tests { let res = do_key_gen(deps.as_mut()); assert_eq!( - res.unwrap_err(), - ContractError::DuplicateKeyID { + res.unwrap_err().to_string(), + axelar_wasm_std::ContractError::from(ContractError::DuplicateKeyID { key_id: KeyID { owner: Addr::unchecked(PROVER), subkey: "key".to_string(), } .to_string() - } + }) + .to_string() ); } @@ -538,14 +547,15 @@ mod tests { let res = do_start_signing_session(deps.as_mut(), sender); assert_eq!( - res.unwrap_err(), - ContractError::NoActiveKeyFound { + res.unwrap_err().to_string(), + axelar_wasm_std::ContractError::from(ContractError::NoActiveKeyFound { key_id: KeyID { owner: Addr::unchecked(sender), subkey: "key".to_string(), } .to_string() - } + }) + .to_string() ); } @@ -640,10 +650,11 @@ mod tests { let res = do_sign(deps.as_mut(), invalid_session_id, &signer); assert_eq!( - res.unwrap_err(), - ContractError::SigningSessionNotFound { + res.unwrap_err().to_string(), + axelar_wasm_std::ContractError::from(ContractError::SigningSessionNotFound { session_id: invalid_session_id - } + }) + .to_string() ); } diff --git a/contracts/multisig/src/error.rs b/contracts/multisig/src/error.rs index 915dbb825..2ac1e750c 100644 --- a/contracts/multisig/src/error.rs +++ b/contracts/multisig/src/error.rs @@ -1,7 +1,8 @@ +use axelar_wasm_std_derive::IntoContractError; use cosmwasm_std::{StdError, Uint64}; use thiserror::Error; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, IntoContractError)] pub enum ContractError { #[error(transparent)] Std(#[from] StdError), diff --git a/contracts/service-registry/Cargo.toml b/contracts/service-registry/Cargo.toml index 5564a06d1..9949cf1cd 100644 --- a/contracts/service-registry/Cargo.toml +++ b/contracts/service-registry/Cargo.toml @@ -29,11 +29,14 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } cosmwasm-schema = "1.1.3" cosmwasm-std = "1.2.7" cosmwasm-storage = "1.1.3" cw-storage-plus = "0.15.1" cw2 = "0.15.1" +error-stack = { workspace = true } +report = { workspace = true } schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } thiserror = { workspace = true } diff --git a/contracts/service-registry/src/contract.rs b/contracts/service-registry/src/contract.rs index 8075b9199..5ce2562ea 100644 --- a/contracts/service-registry/src/contract.rs +++ b/contracts/service-registry/src/contract.rs @@ -22,7 +22,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, msg: InstantiateMsg, -) -> Result { +) -> Result { CONFIG.save( deps.storage, &Config { @@ -38,7 +38,7 @@ pub fn execute( env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { ExecuteMsg::RegisterService { service_name, @@ -107,6 +107,7 @@ pub fn execute( execute::claim_stake(deps, env, info, service_name) } } + .map_err(axelar_wasm_std::ContractError::from) } pub mod execute { diff --git a/contracts/service-registry/src/error.rs b/contracts/service-registry/src/error.rs index fcde8f979..2645430ca 100644 --- a/contracts/service-registry/src/error.rs +++ b/contracts/service-registry/src/error.rs @@ -1,10 +1,11 @@ use axelar_wasm_std::nonempty; +use axelar_wasm_std_derive::IntoContractError; use cosmwasm_std::StdError; use thiserror::Error; use crate::state::BondingState; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, IntoContractError)] pub enum ContractError { #[error(transparent)] Std(#[from] StdError), diff --git a/contracts/service-registry/tests/tests.rs b/contracts/service-registry/tests/tests.rs index 1549267b7..904c73306 100644 --- a/contracts/service-registry/tests/tests.rs +++ b/contracts/service-registry/tests/tests.rs @@ -63,8 +63,11 @@ fn register_service() { ); assert!(!res.is_ok()); assert_eq!( - ContractError::Unauthorized, - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() ); } @@ -125,8 +128,11 @@ fn authorize_worker() { &[], ); assert_eq!( - ContractError::Unauthorized, - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::Unauthorized).to_string() ); } @@ -460,8 +466,11 @@ fn bond_wrong_denom() { ); assert!(res.is_err()); assert_eq!( - ContractError::WrongDenom, - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::WrongDenom).to_string() ); } @@ -962,11 +971,17 @@ fn unbonding_period() { ); assert!(!res.is_ok()); assert_eq!( - ContractError::InvalidBondingState(BondingState::Unbonding { - unbonded_at: app.block_info().time, - amount: min_worker_bond, - }), - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::InvalidBondingState( + BondingState::Unbonding { + unbonded_at: app.block_info().time, + amount: min_worker_bond, + } + )) + .to_string() ); assert_eq!( app.wrap() diff --git a/contracts/voting-verifier/Cargo.toml b/contracts/voting-verifier/Cargo.toml index 549521686..95552bbe1 100644 --- a/contracts/voting-verifier/Cargo.toml +++ b/contracts/voting-verifier/Cargo.toml @@ -29,6 +29,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] axelar-wasm-std = { workspace = true } +axelar-wasm-std-derive = { workspace = true } connection-router = { workspace = true, features = ["library"] } cosmwasm-schema = "1.1.3" cosmwasm-std = "1.1.3" @@ -37,6 +38,8 @@ cw-storage-plus = "1.1.0" cw0 = "0.10.3" cw2 = "0.15.1" either = "1.8.1" +error-stack = { workspace = true } +report = { workspace = true } schemars = "0.8.10" serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" diff --git a/contracts/voting-verifier/src/contract.rs b/contracts/voting-verifier/src/contract.rs index 36ec5f32d..88707d8ed 100644 --- a/contracts/voting-verifier/src/contract.rs +++ b/contracts/voting-verifier/src/contract.rs @@ -15,7 +15,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, msg: InstantiateMsg, -) -> Result { +) -> Result { let config = Config { service_name: msg.service_name, service_registry: deps.api.addr_validate(&msg.service_registry_address)?, @@ -36,11 +36,11 @@ pub fn execute( env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> Result { +) -> Result { match msg { ExecuteMsg::VerifyMessages { messages } => { if messages.is_empty() { - return Err(ContractError::EmptyMessages); + Err(ContractError::EmptyMessages)?; } // todo: extract to conversion function @@ -55,7 +55,7 @@ pub fn execute( .iter() .any(|message| !message.source_chain.eq(&source_chain)) { - return Err(ContractError::SourceChainMismatch(source_chain)); + Err(ContractError::SourceChainMismatch(source_chain))?; } execute::verify_messages(deps, env, messages) @@ -67,6 +67,7 @@ pub fn execute( new_operators, } => execute::confirm_worker_set(deps, env, message_id, new_operators), } + .map_err(axelar_wasm_std::ContractError::from) } #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { diff --git a/contracts/voting-verifier/src/error.rs b/contracts/voting-verifier/src/error.rs index 7eac941bd..294724568 100644 --- a/contracts/voting-verifier/src/error.rs +++ b/contracts/voting-verifier/src/error.rs @@ -1,12 +1,12 @@ -use cosmwasm_std::StdError; -use thiserror::Error; - use axelar_wasm_std::{nonempty, voting}; +use axelar_wasm_std_derive::IntoContractError; use connection_router; use connection_router::types::{ChainName, MessageID}; +use cosmwasm_std::StdError; use service_registry; +use thiserror::Error; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, IntoContractError)] pub enum ContractError { #[error(transparent)] Std(#[from] StdError), diff --git a/contracts/voting-verifier/tests/tests.rs b/contracts/voting-verifier/tests/tests.rs index c64f4e3c2..a87d48349 100644 --- a/contracts/voting-verifier/tests/tests.rs +++ b/contracts/voting-verifier/tests/tests.rs @@ -1,7 +1,7 @@ -use axelar_wasm_std::operators::Operators; use cosmwasm_std::{from_binary, Addr, Uint64}; use cw_multi_test::{App, ContractWrapper, Executor}; +use axelar_wasm_std::operators::Operators; use axelar_wasm_std::Threshold; use connection_router::msg::Message; use connection_router::types::{MessageID, ID_SEPARATOR}; @@ -93,8 +93,13 @@ fn should_failed_if_messages_are_not_from_same_source() { .execute_contract(Addr::unchecked(SENDER), contract_address, &msg, &[]) .unwrap_err(); assert_eq!( - ContractError::SourceChainMismatch(SOURCE_CHAIN.parse().unwrap()), - err.downcast().unwrap() + err.downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::SourceChainMismatch( + SOURCE_CHAIN.parse().unwrap() + )) + .to_string() ); } @@ -505,7 +510,10 @@ fn should_not_confirm_twice() { let res = app.execute_contract(Addr::unchecked(SENDER), contract_address.clone(), &msg, &[]); assert!(res.is_err()); assert_eq!( - ContractError::WorkerSetAlreadyConfirmed, - res.unwrap_err().downcast().unwrap() + res.unwrap_err() + .downcast::() + .unwrap() + .to_string(), + axelar_wasm_std::ContractError::from(ContractError::WorkerSetAlreadyConfirmed).to_string() ); }