Skip to content

Commit

Permalink
add a way to statically insert mock addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
uint committed Mar 11, 2024
1 parent df67017 commit ae2e069
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions packages/easy-addr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "easy-addr"
version.workspace = true
edition = "2021"
publish = false

[lib]
proc-macro = true

[dependencies]
cosmwasm-std = { workspace = true }
proc-macro2 = "1"
quote = "1"
syn = { version = "1.0.6", features = ["full", "printing", "extra-traits"] }
15 changes: 15 additions & 0 deletions packages/easy-addr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use cosmwasm_std::testing::mock_dependencies;

use proc_macro::TokenStream;
use quote::quote;
use syn::parse_macro_input;

#[proc_macro]
pub fn addr(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as syn::LitStr).value();
let addr = mock_dependencies()
.api
.addr_make(input.as_str())
.to_string();
TokenStream::from(quote! {#addr})
}

0 comments on commit ae2e069

Please sign in to comment.