-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
additional rewarding-related unit tests
- Loading branch information
Showing
15 changed files
with
565 additions
and
207 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
common/cosmwasm-smart-contracts/contracts-common/src/helpers.rs
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,27 @@ | ||
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use cosmwasm_std::{BankMsg, Coin, CosmosMsg, Response}; | ||
|
||
pub trait ResponseExt<T> { | ||
fn add_optional_message(self, msg: Option<impl Into<CosmosMsg<T>>>) -> Self; | ||
|
||
fn send_tokens(self, to: impl AsRef<str>, amount: Coin) -> Self; | ||
} | ||
|
||
impl<T> ResponseExt<T> for Response<T> { | ||
fn add_optional_message(self, msg: Option<impl Into<CosmosMsg<T>>>) -> Self { | ||
if let Some(msg) = msg { | ||
self.add_message(msg) | ||
} else { | ||
self | ||
} | ||
} | ||
|
||
fn send_tokens(self, to: impl AsRef<str>, amount: Coin) -> Self { | ||
self.add_message(BankMsg::Send { | ||
to_address: to.as_ref().to_string(), | ||
amount: vec![amount], | ||
}) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -10,4 +10,6 @@ pub mod events; | |
pub mod signing; | ||
pub mod types; | ||
|
||
pub mod helpers; | ||
|
||
pub use types::*; |
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
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
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
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
Oops, something went wrong.