Skip to content

Commit

Permalink
added jsonschema
Browse files Browse the repository at this point in the history
  • Loading branch information
FloppyDisck committed Jan 4, 2022
1 parent 659c125 commit 696d91f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cosmwasm-schema = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
cosmwasm-std = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
cosmwasm-storage = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
secret-toolkit = { git = "https://github.com/enigmampc/secret-toolkit", branch = "debug-print"}
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
snafu = { version = "0.6.3" }
schemars = "0.7"
remain = "0.2.2"
ripemd160 = "0.9.1"
secp256k1 = "0.20.3"
Expand Down
3 changes: 2 additions & 1 deletion src/permit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::transaction::{PermitSignature, PubKeyValue, SignedTx, TxMsg};
use bech32::FromBase32;
use cosmwasm_std::{to_binary, Binary, CanonicalAddr, StdError, StdResult};
use schemars::JsonSchema;
use secp256k1::Secp256k1;
use secret_toolkit::crypto::sha_256;
use serde::{Deserialize, Serialize};
Expand All @@ -10,7 +11,7 @@ use serde::{Deserialize, Serialize};
// Signature idea taken from https://github.com/scrtlabs/secret-toolkit/blob/token-permits/packages/permit/src/funcs.rs

/// Where the information will be stored
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Permit<T: Clone + Serialize> {
pub params: T,
Expand Down
13 changes: 7 additions & 6 deletions src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use crate::permit::Permit;
use cosmwasm_std::{Api, Binary, CanonicalAddr, HumanAddr, StdResult, Uint128};
use ripemd160::{Digest, Ripemd160};
use schemars::JsonSchema;
use secret_toolkit::crypto::sha_256;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct PermitSignature {
pub pub_key: PubKey,
pub signature: Binary,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct PubKey {
/// ignored, but must be "tendermint/PubKeySecp256k1" otherwise the verification will fail
Expand Down Expand Up @@ -44,7 +45,7 @@ impl PubKeyValue {
}

#[remain::sorted]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct TxMsg<T> {
pub r#type: String,
Expand All @@ -61,7 +62,7 @@ impl<T: Clone + Serialize> TxMsg<T> {
}

#[remain::sorted]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct SignedTx<T> {
/// ignored
Expand Down Expand Up @@ -92,7 +93,7 @@ impl<T: Clone + Serialize> SignedTx<T> {
}

#[remain::sorted]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Fee {
pub amount: Vec<Coin>,
Expand All @@ -109,7 +110,7 @@ impl Default for Fee {
}

#[remain::sorted]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Coin {
pub amount: Uint128,
Expand Down

0 comments on commit 696d91f

Please sign in to comment.