From 9bd43582e2b70be5f7b8ac39360f8b867734cdd7 Mon Sep 17 00:00:00 2001 From: Ivan Frolov Date: Wed, 15 Jan 2025 03:22:50 -0500 Subject: [PATCH] fix: added schemas for abi --- near/Cargo.lock | 80 ++++++++++++++++------------ near/Cargo.toml | 1 + near/omni-bridge/Cargo.toml | 18 +------ near/omni-bridge/src/storage.rs | 3 +- near/omni-types/Cargo.toml | 3 +- near/omni-types/src/lib.rs | 35 +++++++++--- near/omni-types/src/locker_args.rs | 15 +++--- near/omni-types/src/mpc_types.rs | 7 +-- near/omni-types/src/prover_result.rs | 22 ++++++-- near/omni-types/src/sol_address.rs | 7 ++- 10 files changed, 114 insertions(+), 77 deletions(-) diff --git a/near/Cargo.lock b/near/Cargo.lock index 597f130f..6037313d 100644 --- a/near/Cargo.lock +++ b/near/Cargo.lock @@ -357,9 +357,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "auto_impl" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" +checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" dependencies = [ "proc-macro2", "quote", @@ -452,9 +452,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "bitvec" @@ -523,9 +523,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" +checksum = "9fb65153674e51d3a42c8f27b05b9508cea85edfaade8aa46bc8fc18cecdfef3" dependencies = [ "borsh-derive", "cfg_aliases", @@ -533,9 +533,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" +checksum = "a396e17ad94059c650db3d253bb6e25927f1eb462eede7e7a153bb6e75dce0a7" dependencies = [ "once_cell", "proc-macro-crate 3.2.0", @@ -2166,9 +2166,9 @@ checksum = "72167d68f5fce3b8655487b8038691a3c9984ee769590f93f2a631f4ad64e4f5" [[package]] name = "js-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -2278,7 +2278,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "libc", "redox_syscall", ] @@ -2316,9 +2316,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "lru" @@ -2364,9 +2364,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", ] @@ -2475,6 +2475,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35cbb989542587b47205e608324ddd391f0cee1c22b4b64ae49f458334b95907" dependencies = [ "borsh", + "schemars", "serde", ] @@ -2754,6 +2755,7 @@ dependencies = [ "base64 0.22.1", "borsh", "bs58 0.5.1", + "near-abi", "near-account-id", "near-crypto", "near-gas", @@ -2765,6 +2767,7 @@ dependencies = [ "near-token", "near-vm-runner", "once_cell", + "schemars", "serde", "serde_json", "wee_alloc", @@ -2816,6 +2819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd3e60aa26a74dc514b1b6408fdd06cefe2eb0ff029020956c1c6517594048fd" dependencies = [ "borsh", + "schemars", "serde", ] @@ -3030,6 +3034,7 @@ dependencies = [ "near-plugins", "near-sdk", "omni-types", + "schemars", "serde", ] @@ -3079,6 +3084,7 @@ dependencies = [ "near-contract-standards", "near-sdk", "rlp 0.6.1", + "schemars", "serde", "sha3", "strum_macros 0.26.4", @@ -3096,7 +3102,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "cfg-if 1.0.0", "foreign-types", "libc", @@ -3436,7 +3442,7 @@ checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.7.0", + "bitflags 2.8.0", "lazy_static", "num-traits", "rand", @@ -3536,7 +3542,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", ] [[package]] @@ -3787,7 +3793,7 @@ version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", @@ -3969,7 +3975,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "core-foundation", "core-foundation-sys", "libc", @@ -4434,7 +4440,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "core-foundation", "system-configuration-sys", ] @@ -4953,20 +4959,21 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if 1.0.0", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", @@ -4978,9 +4985,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.49" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -4991,9 +4998,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5001,9 +5008,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -5014,9 +5021,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-opt" @@ -5066,9 +5076,9 @@ checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "web-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/near/Cargo.toml b/near/Cargo.toml index 9853ff94..6a6ad201 100644 --- a/near/Cargo.toml +++ b/near/Cargo.toml @@ -38,6 +38,7 @@ strum_macros = "0.26" near-workspaces = "0.16.0" tokio = "1.40" anyhow = "1" +schemars = "0.8" alloy-sol-types = "0.8" ethereum-types = { version = "0.15.1", default-features = false, features = ["rlp", "serialize"] } rlp = "0.6" diff --git a/near/omni-bridge/Cargo.toml b/near/omni-bridge/Cargo.toml index 10c53dbf..49127e45 100644 --- a/near/omni-bridge/Cargo.toml +++ b/near/omni-bridge/Cargo.toml @@ -8,23 +8,6 @@ publish = false [lib] crate-type = ["cdylib", "rlib"] -# fields to configure build with WASM reproducibility, according to specs -# in https://github.com/near/NEPs/blob/master/neps/nep-0330.md -[package.metadata.near.reproducible_build] -# docker image, descriptor of build environment -image = "sourcescan/cargo-near:0.13.2-rust-1.84.0" -# tag after colon above serves only descriptive purpose; image is identified by digest -image_digest = "sha256:b41cb89907f92b114da9e2be4e109bff30ab792c22ddcbd2a4cff8e340cb9acb" -# list of environment variables names, whose values, if set, will be used as external build parameters -# in a reproducible manner -# supported by `sourcescan/cargo-near:0.10.1-rust-1.82.0` image or later images -passed_env = [] -# build command inside of docker container -# if docker image from default gallery is used https://hub.docker.com/r/sourcescan/cargo-near/tags, -# the command may be any combination of flags of `cargo-near`, -# supported by respective version of binary inside the container besides `--no-locked` flag -container_build_command = ["cargo", "near", "build", "non-reproducible-wasm", "--locked"] - [dependencies] near-sdk.workspace = true near-contract-standards.workspace = true @@ -32,6 +15,7 @@ hex.workspace = true borsh.workspace = true serde.workspace = true near-plugins.workspace = true +schemars.workspace = true omni-types.workspace = true [dev-dependencies] diff --git a/near/omni-bridge/src/storage.rs b/near/omni-bridge/src/storage.rs index 72ca58b8..52c74996 100644 --- a/near/omni-bridge/src/storage.rs +++ b/near/omni-bridge/src/storage.rs @@ -2,6 +2,7 @@ use near_contract_standards::storage_management::{StorageBalance, StorageBalance use near_sdk::{assert_one_yocto, borsh}; use near_sdk::{env, near_bindgen, AccountId, NearToken}; use omni_types::TransferId; +use schemars::JsonSchema; use crate::{ require, BorshDeserialize, BorshSerialize, ChainKind, Contract, ContractExt, Deserialize, Fee, @@ -11,7 +12,7 @@ use crate::{ pub const BRIDGE_TOKEN_INIT_BALANCE: NearToken = NearToken::from_near(3); pub const NEP141_DEPOSIT: NearToken = NearToken::from_yoctonear(1_250_000_000_000_000_000_000); -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive(JsonSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] pub struct TransferMessageStorageValue { pub message: TransferMessage, pub owner: AccountId, diff --git a/near/omni-types/Cargo.toml b/near/omni-types/Cargo.toml index 3ef2022a..edaed8a0 100644 --- a/near/omni-types/Cargo.toml +++ b/near/omni-types/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Near Inc "] edition = "2021" [dependencies] -near-sdk.workspace = true +near-sdk = { workspace = true, features = ["abi"] } near-contract-standards.workspace = true hex.workspace = true borsh.workspace = true @@ -13,6 +13,7 @@ serde.workspace = true strum_macros.workspace = true ethereum-types.workspace = true rlp.workspace = true +schemars.workspace = true alloy-sol-types = "0.8" alloy-sol-macro = "0.8" alloy-primitives = { version = "0.8", features = ["rlp"] } diff --git a/near/omni-types/src/lib.rs b/near/omni-types/src/lib.rs index 6a6ff092..b3f8e153 100644 --- a/near/omni-types/src/lib.rs +++ b/near/omni-types/src/lib.rs @@ -1,3 +1,4 @@ +use borsh::BorshSchema; use core::fmt; use core::str::FromStr; use hex::FromHex; @@ -5,6 +6,7 @@ use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::json_types::U128; use near_sdk::serde::{Deserialize, Serialize}; use near_sdk::AccountId; +use schemars::JsonSchema; use serde::de::Visitor; use sol_address::SolAddress; @@ -20,7 +22,9 @@ pub mod utils; #[cfg(test)] mod tests; -#[derive(BorshDeserialize, BorshSerialize, Debug, Clone, PartialEq, Eq)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Debug, Clone, PartialEq, Eq, +)] pub struct H160(pub [u8; 20]); impl FromStr for H160 { @@ -134,6 +138,8 @@ impl Serialize for H160 { PartialEq, PartialOrd, Ord, + JsonSchema, + BorshSchema, BorshSerialize, BorshDeserialize, Serialize, @@ -175,7 +181,9 @@ pub type EvmAddress = H160; pub const ZERO_ACCOUNT_ID: &str = "0000000000000000000000000000000000000000000000000000000000000000"; -#[derive(BorshDeserialize, BorshSerialize, Debug, Clone, PartialEq, Eq)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Debug, Clone, PartialEq, Eq, +)] pub enum OmniAddress { Eth(EvmAddress), Near(AccountId), @@ -382,7 +390,16 @@ pub struct FeeRecipient { } #[derive( - BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone, PartialEq, Default, + JsonSchema, + BorshSchema, + BorshDeserialize, + BorshSerialize, + Serialize, + Deserialize, + Debug, + Clone, + PartialEq, + Default, )] pub struct Fee { pub fee: U128, @@ -396,6 +413,8 @@ impl Fee { } #[derive( + JsonSchema, + BorshSchema, BorshDeserialize, BorshSerialize, Serialize, @@ -414,7 +433,7 @@ pub struct TransferId { pub origin_nonce: Nonce, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive(JsonSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] pub struct TransferMessage { pub origin_nonce: Nonce, pub token: OmniAddress, @@ -443,14 +462,14 @@ impl TransferMessage { } } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive(BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] pub enum PayloadType { TransferMessage, Metadata, ClaimNativeFee, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive(BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] pub struct TransferMessagePayload { pub prefix: PayloadType, pub destination_nonce: Nonce, @@ -461,7 +480,7 @@ pub struct TransferMessagePayload { pub fee_recipient: Option, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive(BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] pub struct MetadataPayload { pub prefix: PayloadType, pub token: String, @@ -478,7 +497,7 @@ pub struct SignRequest { pub key_version: u32, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive(JsonSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] pub enum UpdateFee { Fee(Fee), Proof(Vec), diff --git a/near/omni-types/src/locker_args.rs b/near/omni-types/src/locker_args.rs index 7ea3d8c4..4a3ce697 100644 --- a/near/omni-types/src/locker_args.rs +++ b/near/omni-types/src/locker_args.rs @@ -1,36 +1,39 @@ -use crate::ChainKind; +use borsh::BorshSchema; use near_sdk::{ borsh::{self, BorshDeserialize, BorshSerialize}, AccountId, }; +use schemars::JsonSchema; + +use crate::ChainKind; -#[derive(BorshDeserialize, BorshSerialize, Clone)] +#[derive(JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Clone)] pub struct StorageDepositAction { pub token_id: AccountId, pub account_id: AccountId, pub storage_deposit_amount: Option, } -#[derive(BorshDeserialize, BorshSerialize, Clone)] +#[derive(JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Clone)] pub struct FinTransferArgs { pub chain_kind: ChainKind, pub storage_deposit_actions: Vec, pub prover_args: Vec, } -#[derive(BorshDeserialize, BorshSerialize, Clone)] +#[derive(JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Clone)] pub struct ClaimFeeArgs { pub chain_kind: ChainKind, pub prover_args: Vec, } -#[derive(BorshDeserialize, BorshSerialize, Clone)] +#[derive(JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Clone)] pub struct BindTokenArgs { pub chain_kind: ChainKind, pub prover_args: Vec, } -#[derive(BorshDeserialize, BorshSerialize, Clone)] +#[derive(JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Clone)] pub struct DeployTokenArgs { pub chain_kind: ChainKind, pub prover_args: Vec, diff --git a/near/omni-types/src/mpc_types.rs b/near/omni-types/src/mpc_types.rs index fb3320d9..cb5de7e3 100644 --- a/near/omni-types/src/mpc_types.rs +++ b/near/omni-types/src/mpc_types.rs @@ -1,16 +1,17 @@ use near_sdk::serde::{Deserialize, Serialize}; +use schemars::JsonSchema; -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(JsonSchema, Serialize, Deserialize, Clone, Debug)] pub struct AffinePoint { pub affine_point: String, } -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(JsonSchema, Serialize, Deserialize, Clone, Debug)] pub struct Scalar { pub scalar: String, } -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(JsonSchema, Serialize, Deserialize, Clone, Debug)] #[serde(crate = "near_sdk::serde")] pub struct SignatureResponse { pub big_r: AffinePoint, diff --git a/near/omni-types/src/prover_result.rs b/near/omni-types/src/prover_result.rs index 9a40b1aa..4ab8c34c 100644 --- a/near/omni-types/src/prover_result.rs +++ b/near/omni-types/src/prover_result.rs @@ -1,11 +1,15 @@ +use borsh::BorshSchema; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::json_types::U128; use near_sdk::serde::{Deserialize, Serialize}; use near_sdk::AccountId; +use schemars::JsonSchema; use crate::{Fee, Nonce, OmniAddress, TransferId}; -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone, +)] pub struct InitTransferMessage { pub origin_nonce: Nonce, pub token: OmniAddress, @@ -17,7 +21,9 @@ pub struct InitTransferMessage { pub emitter_address: OmniAddress, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone, +)] pub struct FinTransferMessage { pub transfer_id: TransferId, pub fee_recipient: AccountId, @@ -25,7 +31,9 @@ pub struct FinTransferMessage { pub emitter_address: OmniAddress, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone, +)] pub struct DeployTokenMessage { pub token: AccountId, pub token_address: OmniAddress, @@ -34,7 +42,9 @@ pub struct DeployTokenMessage { pub emitter_address: OmniAddress, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone, +)] pub struct LogMetadataMessage { pub token_address: OmniAddress, pub name: String, @@ -43,7 +53,9 @@ pub struct LogMetadataMessage { pub emitter_address: OmniAddress, } -#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone, +)] pub enum ProverResult { InitTransfer(InitTransferMessage), FinTransfer(FinTransferMessage), diff --git a/near/omni-types/src/sol_address.rs b/near/omni-types/src/sol_address.rs index 91e7af27..1bd96755 100644 --- a/near/omni-types/src/sol_address.rs +++ b/near/omni-types/src/sol_address.rs @@ -1,11 +1,16 @@ use core::fmt; use core::str::FromStr; + +use borsh::BorshSchema; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::bs58; use near_sdk::serde::{Deserialize, Serialize}; +use schemars::JsonSchema; use serde::de::Visitor; -#[derive(BorshDeserialize, BorshSerialize, Debug, Clone, PartialEq, Eq)] +#[derive( + JsonSchema, BorshSchema, BorshDeserialize, BorshSerialize, Debug, Clone, PartialEq, Eq, +)] pub struct SolAddress(pub [u8; 32]); impl SolAddress {