diff --git a/contracts/voting-verifier/src/events.rs b/contracts/voting-verifier/src/events.rs index adf7b4eff..07f96a134 100644 --- a/contracts/voting-verifier/src/events.rs +++ b/contracts/voting-verifier/src/events.rs @@ -208,7 +208,7 @@ mod test { use axelar_wasm_std::voting::Vote; use axelar_wasm_std::{nonempty, Threshold, VerificationStatus}; use cosmwasm_std::testing::MockApi; - use cosmwasm_std::{Attribute, Uint128}; + use cosmwasm_std::Uint128; use multisig::key::KeyType; use multisig::test::common::{build_verifier_set, ecdsa_test_data}; use multisig::verifier_set::VerifierSet; @@ -216,8 +216,7 @@ mod test { use serde_json::json; use super::{TxEventConfirmation, VerifierSetConfirmation}; - use crate::events::{PollEnded, PollMetadata, PollStarted, QuorumReached, Voted}; - use crate::state::Config; + use crate::events::{EmptyEvent, Event}; fn random_32_bytes() -> [u8; 32] { let mut bytes = [0; 32]; @@ -401,7 +400,7 @@ mod test { fn events_should_not_change() { let api = MockApi::default(); - let config = Config { + let event_instantiated: cosmwasm_std::Event = EmptyEvent::Instantiated { service_name: "serviceName".try_into().unwrap(), service_registry_contract: api.addr_make("serviceRegistry_contract"), source_gateway_address: "sourceGatewayAddress".try_into().unwrap(), @@ -412,11 +411,10 @@ mod test { rewards_contract: api.addr_make("rewardsContract"), msg_id_format: MessageIdFormat::HexTxHashAndEventIndex, address_format: AddressFormat::Eip55, - }; - let event_instantiated = - cosmwasm_std::Event::new("instantiated").add_attributes(>::from(config)); + } + .into(); - let event_messages_poll_started: cosmwasm_std::Event = PollStarted::Messages { + let event_messages_poll_started: cosmwasm_std::Event = EmptyEvent::MessagesPollStarted { messages: vec![ TxEventConfirmation { tx_id: "txId1".try_into().unwrap(), @@ -437,29 +435,27 @@ mod test { payload_hash: [1; 32], }, ], - metadata: PollMetadata { - poll_id: 1.into(), - source_chain: "sourceChain".try_into().unwrap(), - source_gateway_address: "sourceGatewayAddress".try_into().unwrap(), - confirmation_height: 1, - expires_at: 1, - participants: vec![ - api.addr_make("participant1"), - api.addr_make("participant2"), - api.addr_make("participant3"), - ], - }, + poll_id: 1.into(), + source_chain: "sourceChain".try_into().unwrap(), + source_gateway_address: "sourceGatewayAddress".try_into().unwrap(), + confirmation_height: 1, + expires_at: 1, + participants: vec![ + api.addr_make("participant1"), + api.addr_make("participant2"), + api.addr_make("participant3"), + ], } .into(); - let event_verifier_set_poll_started: cosmwasm_std::Event = PollStarted::VerifierSet { - verifier_set: VerifierSetConfirmation { - tx_id: "txId".try_into().unwrap(), - event_index: 1, - message_id: "messageId".try_into().unwrap(), - verifier_set: build_verifier_set(KeyType::Ecdsa, &ecdsa_test_data::signers()), - }, - metadata: PollMetadata { + let event_verifier_set_poll_started: cosmwasm_std::Event = + EmptyEvent::VerifierSetPollStarted { + verifier_set: VerifierSetConfirmation { + tx_id: "txId".try_into().unwrap(), + event_index: 1, + message_id: "messageId".try_into().unwrap(), + verifier_set: build_verifier_set(KeyType::Ecdsa, &ecdsa_test_data::signers()), + }, poll_id: 2.into(), source_chain: "sourceChain".try_into().unwrap(), source_gateway_address: "sourceGatewayAddress".try_into().unwrap(), @@ -470,25 +466,24 @@ mod test { api.addr_make("participant5"), api.addr_make("participant6"), ], - }, - } - .into(); + } + .into(); - let event_quorum_reached: cosmwasm_std::Event = QuorumReached { + let event_quorum_reached: cosmwasm_std::Event = Event::QuorumReached { content: "content".to_string(), status: VerificationStatus::NotFoundOnSourceChain, poll_id: 1.into(), } .into(); - let event_voted: cosmwasm_std::Event = Voted { + let event_voted: cosmwasm_std::Event = EmptyEvent::Voted { poll_id: 1.into(), voter: api.addr_make("voter"), votes: vec![Vote::SucceededOnChain, Vote::FailedOnChain, Vote::NotFound], } .into(); - let event_poll_ended: cosmwasm_std::Event = PollEnded { + let event_poll_ended: cosmwasm_std::Event = EmptyEvent::PollEnded { poll_id: 1.into(), source_chain: "sourceChain".try_into().unwrap(), results: vec![ diff --git a/contracts/voting-verifier/src/testdata/events_should_not_change.golden b/contracts/voting-verifier/src/testdata/events_should_not_change.golden index 2ecaacc3c..8eb97de63 100644 --- a/contracts/voting-verifier/src/testdata/events_should_not_change.golden +++ b/contracts/voting-verifier/src/testdata/events_should_not_change.golden @@ -2,16 +2,16 @@ "event_instantiated": { "attributes": [ { - "key": "service_name", - "value": "serviceName" + "key": "service_registry_contract", + "value": "\"cosmwasm19d2spdjdycg0tfu27n2zrkwvr25yxwykaxvxwkpnf7hqkka93j4sfp809w\"" }, { - "key": "service_registry_contract", - "value": "cosmwasm19d2spdjdycg0tfu27n2zrkwvr25yxwykaxvxwkpnf7hqkka93j4sfp809w" + "key": "service_name", + "value": "\"serviceName\"" }, { "key": "source_gateway_address", - "value": "sourceGatewayAddress" + "value": "\"sourceGatewayAddress\"" }, { "key": "voting_threshold", @@ -19,7 +19,7 @@ }, { "key": "block_expiry", - "value": "10" + "value": "\"10\"" }, { "key": "confirmation_height", @@ -27,11 +27,11 @@ }, { "key": "source_chain", - "value": "sourcechain" + "value": "\"sourcechain\"" }, { "key": "rewards_contract", - "value": "cosmwasm1wyhnds94w36ar6jlz4aaaz75cmypwmr0rqnc92nm5m79ejy04hnsx25urh" + "value": "\"cosmwasm1wyhnds94w36ar6jlz4aaaz75cmypwmr0rqnc92nm5m79ejy04hnsx25urh\"" }, { "key": "msg_id_format", @@ -56,11 +56,11 @@ }, { "key": "source_chain", - "value": "sourcechain" + "value": "\"sourcechain\"" }, { "key": "source_gateway_address", - "value": "sourceGatewayAddress" + "value": "\"sourceGatewayAddress\"" }, { "key": "confirmation_height", @@ -123,11 +123,11 @@ }, { "key": "source_chain", - "value": "sourcechain" + "value": "\"sourcechain\"" }, { "key": "source_gateway_address", - "value": "sourceGatewayAddress" + "value": "\"sourceGatewayAddress\"" }, { "key": "confirmation_height", @@ -152,7 +152,7 @@ }, { "key": "voter", - "value": "cosmwasm12ehr5qctpa78s2r2luz4lqyuzm955nxvj5msmptpatlf3qzj0xds4lvke5" + "value": "\"cosmwasm12ehr5qctpa78s2r2luz4lqyuzm955nxvj5msmptpatlf3qzj0xds4lvke5\"" }, { "key": "votes", diff --git a/packages/axelar-wasm-std-derive/src/lib.rs b/packages/axelar-wasm-std-derive/src/lib.rs index 7dfc7876b..addfc7a13 100644 --- a/packages/axelar-wasm-std-derive/src/lib.rs +++ b/packages/axelar-wasm-std-derive/src/lib.rs @@ -64,15 +64,15 @@ pub fn into_contract_error_derive(input: TokenStream) -> TokenStream { /// } /// } /// -/// let actual = Event::from(SomeEvents::SomeEmptyEvent::); +/// let actual: Event = SomeEvents::SomeEmptyEvent::.into(); /// let expected = Event::new("some_empty_event"); /// assert_eq!(actual, expected); /// -/// let actual = Event::from(SomeEvents::SomeOtherEmptyEvent:: {}); +/// let actual: Event = SomeEvents::SomeOtherEmptyEvent:: {}.into(); /// let expected = Event::new("some_other_empty_event"); /// assert_eq!(actual, expected); /// -/// let actual = Event::from(SomeEvents::SomeEvent:: { +/// let actual: Event = SomeEvents::SomeEvent:: { /// some_uint: 42, /// some_string: "some string".to_string(), /// some_bool: true, @@ -82,7 +82,7 @@ pub fn into_contract_error_derive(input: TokenStream) -> TokenStream { /// some_vec: vec!["a".to_string(), "b".to_string()], /// some_map: [("a".to_string(), "b".to_string()), ("c".to_string(), "d".to_string()), ("e".to_string(), "f".to_string())].into_iter().collect(), /// }, -/// }); +/// }.into(); /// let expected = Event::new("some_event") /// .add_attribute("some_uint", "42") /// .add_attribute("some_string", "\"some string\"") @@ -90,10 +90,10 @@ pub fn into_contract_error_derive(input: TokenStream) -> TokenStream { /// .add_attribute("some_object", "{\"some_option\":\"some option\",\"some_other_option\":null,\"some_vec\":[\"a\",\"b\"],\"some_map\":{\"a\":\"b\",\"c\":\"d\",\"e\":\"f\"}}"); /// assert_eq!(actual, expected); /// -/// let actual = Event::from(SomeEvents::SomeGenericsEvent:: { +/// let actual: Event = SomeEvents::SomeGenericsEvent:: { /// some_generics: "some generics".to_string(), /// some_other_generics: 42, -/// }); +/// }.into(); /// let expected = Event::new("some_generics_event") /// .add_attribute("some_generics", "\"some generics\"") /// .add_attribute("some_other_generics", "42");