Skip to content

Commit 313c182

Browse files
authored
Merge pull request #60 from scrtlabs/decoy
Get decoys for every balance update
2 parents ac47423 + ec410c8 commit 313c182

File tree

8 files changed

+1806
-399
lines changed

8 files changed

+1806
-399
lines changed

Cargo.lock

Lines changed: 169 additions & 167 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ backtraces = ["cosmwasm-std/backtraces"]
3232

3333
# debug-print = ["cosmwasm-std/debug-print"]
3434
[dependencies]
35-
cosmwasm-std = { package = "secret-cosmwasm-std", version = "1.0.0", default-features = false }
36-
cosmwasm-storage = { package = "secret-cosmwasm-storage", version = "1.0.0" }
37-
38-
secret-toolkit = { version = "0.7.0", features = [
35+
cosmwasm-std = { git = "https://github.com/scrtlabs/cosmwasm/", default-features = false, tag = "v1.1.9-secret" }
36+
cosmwasm-storage = { git = "https://github.com/scrtlabs/cosmwasm/", tag = "v1.1.9-secret" }
37+
rand = { version = "0.8.5", default-features = false }
38+
secret-toolkit = { git = "https://github.com/scrtlabs/secret-toolkit", features = [
3939
"permit",
4040
"viewing-key",
4141
] }
42-
secret-toolkit-crypto = { version = "0.7.0", features = ["rand", "hash"]}
43-
44-
#secret-toolkit-crypto = { package = "secret-toolkit-crypto", version = "0.7.0", features = ["rand", "hash"] }
42+
secret-toolkit-crypto = { git = "https://github.com/scrtlabs/secret-toolkit", features = [
43+
"rand",
44+
"hash",
45+
] }
4546

4647
schemars = "0.8.12"
4748
serde = { version = "1.0.158", default-features = false, features = ["derive"] }

src/batch.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
use schemars::JsonSchema;
44
use serde::{Deserialize, Serialize};
55

6-
use cosmwasm_std::{Binary, Uint128};
6+
use cosmwasm_std::{Addr, Binary, Uint128};
7+
8+
pub trait HasDecoy {
9+
fn decoys(&self) -> &Option<Vec<Addr>>;
10+
}
711

812
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
913
#[serde(rename_all = "snake_case")]
1014
pub struct TransferAction {
1115
pub recipient: String,
1216
pub amount: Uint128,
1317
pub memo: Option<String>,
18+
pub decoys: Option<Vec<Addr>>,
1419
}
1520

1621
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
@@ -21,6 +26,7 @@ pub struct SendAction {
2126
pub amount: Uint128,
2227
pub msg: Option<Binary>,
2328
pub memo: Option<String>,
29+
pub decoys: Option<Vec<Addr>>,
2430
}
2531

2632
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
@@ -30,6 +36,7 @@ pub struct TransferFromAction {
3036
pub recipient: String,
3137
pub amount: Uint128,
3238
pub memo: Option<String>,
39+
pub decoys: Option<Vec<Addr>>,
3340
}
3441

3542
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
@@ -41,6 +48,7 @@ pub struct SendFromAction {
4148
pub amount: Uint128,
4249
pub msg: Option<Binary>,
4350
pub memo: Option<String>,
51+
pub decoys: Option<Vec<Addr>>,
4452
}
4553

4654
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
@@ -49,6 +57,7 @@ pub struct MintAction {
4957
pub recipient: String,
5058
pub amount: Uint128,
5159
pub memo: Option<String>,
60+
pub decoys: Option<Vec<Addr>>,
5261
}
5362

5463
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
@@ -57,4 +66,22 @@ pub struct BurnFromAction {
5766
pub owner: String,
5867
pub amount: Uint128,
5968
pub memo: Option<String>,
69+
pub decoys: Option<Vec<Addr>>,
6070
}
71+
72+
macro_rules! impl_decoyable {
73+
($struct:ty) => {
74+
impl HasDecoy for $struct {
75+
fn decoys(&self) -> &Option<Vec<Addr>> {
76+
&self.decoys
77+
}
78+
}
79+
};
80+
}
81+
82+
impl_decoyable!(BurnFromAction);
83+
impl_decoyable!(MintAction);
84+
impl_decoyable!(SendFromAction);
85+
impl_decoyable!(TransferFromAction);
86+
impl_decoyable!(TransferAction);
87+
impl_decoyable!(SendAction);

0 commit comments

Comments
 (0)