From dacd14dc187c5e5ba79874d50e1aca560eeaeb09 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Fri, 8 Sep 2023 11:56:46 +0400 Subject: [PATCH 01/16] upd tokenfactory --- Cargo.lock | 22 +++++++++++++++++++++- contracts/tokenfactory/Cargo.toml | 2 +- contracts/tokenfactory/src/contract.rs | 3 +++ contracts/tokenfactory/src/msg.rs | 4 ++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 146f43b..e7bc94a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -662,6 +662,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "neutron-sdk" +version = "0.6.1" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#2c9e8e63086600b7d232aa858d13fd34037ae056" +dependencies = [ + "base64 0.21.2", + "bech32", + "cosmos-sdk-proto 0.16.0", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "prost 0.11.9", + "protobuf", + "schemars", + "serde", + "serde-json-wasm", + "serde_json", + "thiserror", +] + [[package]] name = "neutron-sdk" version = "0.6.1" @@ -1395,7 +1415,7 @@ version = "0.1.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "neutron-sdk 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "neutron-sdk 0.6.1 (git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update)", "schemars", "serde", ] diff --git a/contracts/tokenfactory/Cargo.toml b/contracts/tokenfactory/Cargo.toml index 69de041..716716b 100644 --- a/contracts/tokenfactory/Cargo.toml +++ b/contracts/tokenfactory/Cargo.toml @@ -36,7 +36,7 @@ library = [] cosmwasm-std = "1.3.1" serde = { version = "1.0.180", default-features = false, features = ["derive"] } schemars = "0.8.12" -neutron-sdk = { package = "neutron-sdk", version = "0.6.1" } +neutron-sdk = { package = "neutron-sdk", git="https://github.com/neutron-org/neutron-sdk", branch="feat/tokenfactory-update" } [dev-dependencies] cosmwasm-schema = { version = "1.3.1", default-features = false } diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 5f4278c..2a071ca 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -38,6 +38,9 @@ pub fn execute( ExecuteMsg::BurnTokens { denom, amount } => { NeutronMsg::submit_burn_tokens(denom, amount).into() } + ExecuteMsg::SetBeforeSendHook { denom, cosm_wasm_addr } => { + NeutronMsg::submit_set_before_send_hoook(denom, cosm_wasm_addr).into() + } ExecuteMsg::SendTokens { recipient, denom, diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index 83e9519..2f36cb8 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -28,6 +28,10 @@ pub enum ExecuteMsg { denom: String, amount: Uint128, }, + SetBeforeSendHook { + denom: String, + cosm_wasm_addr: String, + } } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] From 44015b39d21c47cfd31383ad7d462ee8c1c13737 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Fri, 8 Sep 2023 12:05:04 +0400 Subject: [PATCH 02/16] fmt --- contracts/tokenfactory/src/contract.rs | 7 ++++--- contracts/tokenfactory/src/msg.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 2a071ca..f7449af 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -38,9 +38,10 @@ pub fn execute( ExecuteMsg::BurnTokens { denom, amount } => { NeutronMsg::submit_burn_tokens(denom, amount).into() } - ExecuteMsg::SetBeforeSendHook { denom, cosm_wasm_addr } => { - NeutronMsg::submit_set_before_send_hoook(denom, cosm_wasm_addr).into() - } + ExecuteMsg::SetBeforeSendHook { + denom, + cosm_wasm_addr, + } => NeutronMsg::submit_set_before_send_hoook(denom, cosm_wasm_addr).into(), ExecuteMsg::SendTokens { recipient, denom, diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index 2f36cb8..9070a88 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -31,7 +31,7 @@ pub enum ExecuteMsg { SetBeforeSendHook { denom: String, cosm_wasm_addr: String, - } + }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] From 16041e89c972d7551929eeaa8cac644335f8854d Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Fri, 8 Sep 2023 12:18:06 +0400 Subject: [PATCH 03/16] upd queries --- Cargo.lock | 375 +++++++++++++++++-------- contracts/tokenfactory/src/contract.rs | 2 + contracts/tokenfactory/src/msg.rs | 3 + 3 files changed, 262 insertions(+), 118 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7bc94a..08708ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,17 +13,11 @@ dependencies = [ "version_check", ] -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "autocfg" @@ -38,16 +32,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" [[package]] -name = "base64" -version = "0.13.1" +name = "base16ct" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -81,9 +75,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "845141a4fade3f790628b7daaaa298a25b204fb28907eb54febe5142db6ce653" +checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" [[package]] name = "byteorder" @@ -93,9 +87,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" dependencies = [ "serde", ] @@ -108,11 +102,10 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" dependencies = [ - "android-tzdata", "num-traits", ] @@ -131,9 +124,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "cosmos-sdk-proto" @@ -159,31 +152,31 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e272708a9745dad8b591ef8a718571512130f2b39b33e3d7a27c558e3069394" +checksum = "1ca101fbf2f76723711a30ea3771ef312ec3ec254ad021b237871ed802f9f175" dependencies = [ "digest 0.10.7", "ed25519-zebra", - "k256", + "k256 0.13.1", "rand_core 0.6.4", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "296db6a3caca5283425ae0cf347f4e46999ba3f6620dbea8939a0e00347831ce" +checksum = "c73d2dd292f60e42849d2b07c03d809cf31e128a4299a805abd6d24553bcaaf5" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63c337e097a089e5b52b5d914a7ff6613332777f38ea6d9d36e1887cd0baa72e" +checksum = "6ce34a08020433989af5cc470104f6bd22134320fe0221bd8aeb919fd5ec92d5" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -194,22 +187,22 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "766cc9e7c1762d8fc9c0265808910fcad755200cd0e624195a491dd885a61169" +checksum = "96694ec781a7dd6dea1f968a2529ade009c21ad999c88b5f53d6cc495b3b96f7" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "cosmwasm-std" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5e05a95fd2a420cca50f4e94eb7e70648dac64db45e90403997ebefeb143bd" +checksum = "2a44d3f9c25b2f864737c6605a98f2e4675d53fd8bbc7cf4d7c02475661a793d" dependencies = [ - "base64 0.13.1", + "base64", "bnum", "cosmwasm-crypto", "cosmwasm-derive", @@ -225,9 +218,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "800aaddd70ba915e19bf3d2d992aa3689d8767857727fdd3b414df4fd52d2aa1" +checksum = "ab544dfcad7c9e971933d522d99ec75cc8ddfa338854bb992b092e11bcd7e818" dependencies = [ "cosmwasm-std", "serde", @@ -254,6 +247,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -300,7 +305,7 @@ dependencies = [ "cw-utils", "derivative", "itertools", - "k256", + "k256 0.11.6", "prost 0.9.0", "schemars", "serde", @@ -357,11 +362,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "deranged" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8810e7e2cf385b1e9b50d68264908ec367ba642c96d02edfe61c39e88e2a3c01" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" [[package]] name = "derivative" @@ -370,7 +385,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -390,15 +405,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] [[package]] name = "dyn-clone" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "ecdsa" @@ -406,10 +422,24 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der 0.7.8", + "digest 0.10.7", + "elliptic-curve 0.13.5", + "rfc6979 0.4.0", + "signature 2.1.0", + "spki 0.7.2", ] [[package]] @@ -450,16 +480,35 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "base16ct", - "crypto-bigint", - "der", + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", + "digest 0.10.7", + "ff 0.12.1", + "generic-array", + "group 0.12.1", + "pkcs8 0.9.0", + "rand_core 0.6.4", + "sec1 0.3.0", + "subtle", + "zeroize", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +dependencies = [ + "base16ct 0.2.0", + "crypto-bigint 0.5.3", "digest 0.10.7", - "ff", + "ff 0.13.0", "generic-array", - "group", - "pkcs8", + "group 0.13.0", + "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -474,6 +523,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "flex-error" version = "0.4.4" @@ -497,6 +556,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -516,7 +576,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand_core 0.6.4", "subtle", ] @@ -588,11 +659,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", - "ecdsa", - "elliptic-curve", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", "sha2 0.10.7", ] +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa 0.16.8", + "elliptic-curve 0.13.5", + "once_cell", + "sha2 0.10.7", + "signature 2.1.0", +] + [[package]] name = "libc" version = "0.2.147" @@ -647,7 +732,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adfc6f92cae61b5af9014c09b7bac25ac95b7442be38441a7103377a8edfd37c" dependencies = [ - "base64 0.21.2", + "base64", "bech32", "cosmos-sdk-proto 0.16.0", "cosmwasm-schema", @@ -665,9 +750,9 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.6.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#2c9e8e63086600b7d232aa858d13fd34037ae056" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#09b603e3a1024231f09398a6fd93af56519f312d" dependencies = [ - "base64 0.21.2", + "base64", "bech32", "cosmos-sdk-proto 0.16.0", "cosmwasm-schema", @@ -687,7 +772,7 @@ name = "neutron-sdk" version = "0.6.1" source = "git+https://github.com/neutron-org/neutron-sdk?rev=bb2188561a30d0a7fb293ff05f73907724eb2020#bb2188561a30d0a7fb293ff05f73907724eb2020" dependencies = [ - "base64 0.21.2", + "base64", "bech32", "cosmos-sdk-proto 0.16.0", "cosmwasm-schema", @@ -706,7 +791,7 @@ dependencies = [ name = "neutron_interchain_queries" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64", "cosmos-sdk-proto 0.16.0", "cosmwasm-schema", "cosmwasm-std", @@ -723,7 +808,7 @@ dependencies = [ name = "neutron_interchain_txs" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64", "bech32", "cosmos-sdk-proto 0.16.0", "cosmwasm-schema", @@ -744,7 +829,7 @@ dependencies = [ name = "neutron_validators_test" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64", "bech32", "cosmos-sdk-proto 0.16.0", "cosmwasm-schema", @@ -777,9 +862,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -788,9 +873,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ "num-traits", ] @@ -802,7 +887,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -875,7 +960,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b00664fdffd7558a47a4c106c446104af3e789b740d7740885660c371eb0d09d" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -893,9 +978,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "osmosis-std" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fa46d2ad5ae738572887974e000934374ce3546b820505c0ee19ca708e49622" +checksum = "75895e4db1a81ca29118e366365744f64314938327e4eedba8e6e462fb15e94f" dependencies = [ "chrono", "cosmwasm-std", @@ -909,14 +994,14 @@ dependencies = [ [[package]] name = "osmosis-std-derive" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c2ba5535743617d6f44ae8d572d064fabab6d06ffcf403512f89c58954dbe9" +checksum = "f47f0b2f22adb341bb59e5a3a1b464dde033181954bd055b9ae86d6511ba465b" dependencies = [ "itertools", "proc-macro2", "prost-types", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -941,8 +1026,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "spki", + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.2", ] [[package]] @@ -983,7 +1078,7 @@ dependencies = [ "anyhow", "itertools", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -996,7 +1091,7 @@ dependencies = [ "anyhow", "itertools", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] @@ -1038,9 +1133,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1078,11 +1173,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ - "crypto-bigint", + "crypto-bigint 0.4.9", "hmac", "zeroize", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -1097,9 +1202,9 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" dependencies = [ "dyn-clone", "schemars_derive", @@ -1109,12 +1214,12 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "serde_derive_internals", "syn 1.0.109", ] @@ -1125,10 +1230,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "base16ct", - "der", + "base16ct 0.1.1", + "der 0.6.1", + "generic-array", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.8", "generic-array", - "pkcs8", + "pkcs8 0.10.2", "subtle", "zeroize", ] @@ -1141,9 +1260,9 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.180" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -1177,13 +1296,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.180" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e744d7782b686ab3b73267ef05697159cc0e5abbed3f47f9933165e5219036" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", - "quote 1.0.32", - "syn 2.0.28", + "quote 1.0.33", + "syn 2.0.31", ] [[package]] @@ -1193,15 +1312,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "syn 1.0.109", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -1242,6 +1361,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + [[package]] name = "spki" version = "0.6.0" @@ -1249,7 +1378,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", - "der", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der 0.7.8", ] [[package]] @@ -1279,15 +1418,15 @@ checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" [[package]] name = "strum_macros" -version = "0.25.1" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6069ca09d878a33f883cc06aaa9718ede171841d3832450354410b718b097232" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" dependencies = [ "heck", "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "rustversion", - "syn 2.0.28", + "syn 2.0.31", ] [[package]] @@ -1312,18 +1451,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.28" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", - "quote 1.0.32", + "quote 1.0.33", "unicode-ident", ] @@ -1365,29 +1504,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", - "quote 1.0.32", - "syn 2.0.28", + "quote 1.0.33", + "syn 2.0.31", ] [[package]] name = "time" -version = "0.3.24" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79eabcd964882a646b3584543ccabeae7869e9ac32a46f6f22b7a5bd405308b" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ "deranged", "time-core", @@ -1402,9 +1541,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index f7449af..9678cf1 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -3,6 +3,7 @@ use cosmwasm_std::{ coins, entry_point, to_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; +use neutron_sdk::query::token_factory::query_before_send_hook; use neutron_sdk::{ bindings::{msg::NeutronMsg, query::NeutronQuery}, query::token_factory::{query_denom_admin, query_full_denom}, @@ -63,6 +64,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResul subdenom, } => to_binary(&query_full_denom(deps, creator_addr, subdenom)?)?, QueryMsg::DenomAdmin { subdenom } => to_binary(&query_denom_admin(deps, subdenom)?)?, + QueryMsg::BeforeSendHook { denom } => to_binary(&query_before_send_hook(deps, denom)?)?, }) } diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index 9070a88..cbb643b 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -44,6 +44,9 @@ pub enum QueryMsg { DenomAdmin { subdenom: String, }, + BeforeSendHook { + denom: String, + }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] From 2961e8959dcb968628091e25c42d1c8a85e0abf3 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Fri, 8 Sep 2023 15:56:00 +0400 Subject: [PATCH 04/16] upd sdk --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 08708ca..b77f14f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -750,7 +750,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.6.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#09b603e3a1024231f09398a6fd93af56519f312d" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#116125798a35f07881efce402d28574574d5ab6b" dependencies = [ "base64", "bech32", From b7d5141c91a4ebfc94b92825d98543b655ace650 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Wed, 13 Sep 2023 14:35:24 +0400 Subject: [PATCH 05/16] upd --- Cargo.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b77f14f..aea6449 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,9 +39,9 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -680,9 +680,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "msg_receiver" @@ -750,7 +750,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.6.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#116125798a35f07881efce402d28574574d5ab6b" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#9609e48f5305e8e61871756eae33bc927bca7bae" dependencies = [ "base64", "bech32", @@ -1302,7 +1302,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote 1.0.33", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -1318,9 +1318,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" dependencies = [ "itoa", "ryu", @@ -1426,7 +1426,7 @@ dependencies = [ "proc-macro2", "quote 1.0.33", "rustversion", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -1457,9 +1457,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.31" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote 1.0.33", @@ -1519,7 +1519,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote 1.0.33", - "syn 2.0.31", + "syn 2.0.32", ] [[package]] @@ -1567,9 +1567,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" From 95b2a71f1deab5e1db93b35c721b9cd5d77197cb Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 14 Sep 2023 16:40:04 +0400 Subject: [PATCH 06/16] add before send hook test contract --- Cargo.lock | 11 +++ contracts/before-send-hook/.cargo/config | 6 ++ contracts/before-send-hook/Cargo.toml | 42 ++++++++++ contracts/before-send-hook/README.md | 3 + contracts/before-send-hook/examples/schema.rs | 29 +++++++ contracts/before-send-hook/src/contract.rs | 80 +++++++++++++++++++ contracts/before-send-hook/src/lib.rs | 19 +++++ contracts/before-send-hook/src/msg.rs | 56 +++++++++++++ contracts/before-send-hook/src/state.rs | 6 ++ 9 files changed, 252 insertions(+) create mode 100644 contracts/before-send-hook/.cargo/config create mode 100644 contracts/before-send-hook/Cargo.toml create mode 100644 contracts/before-send-hook/README.md create mode 100644 contracts/before-send-hook/examples/schema.rs create mode 100644 contracts/before-send-hook/src/contract.rs create mode 100644 contracts/before-send-hook/src/lib.rs create mode 100644 contracts/before-send-hook/src/msg.rs create mode 100644 contracts/before-send-hook/src/state.rs diff --git a/Cargo.lock b/Cargo.lock index aea6449..25f76cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,6 +55,17 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "before-send-hook-test" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "schemars", + "serde", +] + [[package]] name = "block-buffer" version = "0.9.0" diff --git a/contracts/before-send-hook/.cargo/config b/contracts/before-send-hook/.cargo/config new file mode 100644 index 0000000..7c11532 --- /dev/null +++ b/contracts/before-send-hook/.cargo/config @@ -0,0 +1,6 @@ +[alias] +wasm = "build --release --target wasm32-unknown-unknown" +wasm-debug = "build --target wasm32-unknown-unknown" +unit-test = "test --lib --features backtraces" +integration-test = "test --test integration" +schema = "run --example schema" diff --git a/contracts/before-send-hook/Cargo.toml b/contracts/before-send-hook/Cargo.toml new file mode 100644 index 0000000..bb2acb0 --- /dev/null +++ b/contracts/before-send-hook/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "before-send-hook-test" +version = "0.1.0" +edition = "2021" + + +exclude = [ + # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. + "contract.wasm", + "hash.txt", +] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib", "rlib"] + +[profile.release] +opt-level = 3 +debug = false +rpath = false +lto = true +debug-assertions = false +codegen-units = 1 +panic = 'abort' +incremental = false +overflow-checks = true + +[features] +# for quicker tests, cargo test --lib +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] +library = [] + +[dependencies] +cosmwasm-std = "1.3.1" +serde = { version = "1.0.180", default-features = false, features = ["derive"] } +schemars = "0.8.12" +cw-storage-plus = "1.1.0" + +[dev-dependencies] +cosmwasm-schema = { version = "1.3.1", default-features = false } diff --git a/contracts/before-send-hook/README.md b/contracts/before-send-hook/README.md new file mode 100644 index 0000000..1b5375d --- /dev/null +++ b/contracts/before-send-hook/README.md @@ -0,0 +1,3 @@ +# Before Hook Tests + +This contract used for testing bank before hooks (set by tokenfactory) diff --git a/contracts/before-send-hook/examples/schema.rs b/contracts/before-send-hook/examples/schema.rs new file mode 100644 index 0000000..3f3914e --- /dev/null +++ b/contracts/before-send-hook/examples/schema.rs @@ -0,0 +1,29 @@ +// Copyright 2022 Neutron +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; +use std::{env::current_dir, fs::create_dir_all}; +use tokenfactory::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; + +fn main() { + let mut out_dir = current_dir().unwrap(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); + + export_schema(&schema_for!(InstantiateMsg), &out_dir); + export_schema(&schema_for!(ExecuteMsg), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); + export_schema(&schema_for!(MigrateMsg), &out_dir); +} diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs new file mode 100644 index 0000000..84f6735 --- /dev/null +++ b/contracts/before-send-hook/src/contract.rs @@ -0,0 +1,80 @@ +use crate::msg::{BlockBeforeSendMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg, SudoResResponse, TrackBeforeSendMsg}; +use cosmwasm_std::{ + entry_point, Deps, DepsMut, Env, MessageInfo, + Response, StdResult, +}; +use crate::state::{SUDO_RES_BLOCK, SUDO_RES_TRACK}; + +#[entry_point] +pub fn instantiate( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: InstantiateMsg, +) -> StdResult { + + SUDO_RES_TRACK.save(deps.storage, &false)?; + SUDO_RES_BLOCK.save(deps.storage, &false)?; + + Ok(Response::new()) +} + +#[entry_point] +pub fn execute( + _deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: ExecuteMsg, +) -> StdResult { + Ok(Response::new()) +} + +#[entry_point] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::SudoResultBlockBefore { + } => query_sudo_result_block_before(deps), + QueryMsg::SudoResultTrackBefore { + } => query_sudo_result_track_before(deps), + } +} + +#[entry_point] +pub fn sudo( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + msg: SudoMsg, +) -> StdResult { + match msg { + SudoMsg::TrackBeforeSendSudoMsg {track_before_send_msg } => sudo_result_track_before(deps, track_before_send_msg), + SudoMsg::BlockBeforeSendSudoMsg {block_before_send_msg} => sudo_result_block_before(deps, block_before_send_msg), + } +} + +#[entry_point] +pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { + Ok(Response::new()) +} + +fn query_sudo_result_block_before(deps: Deps) -> StdResult { + let res = SUDO_RES_TRACK.load(deps.storage)?; + let resp = SudoResResponse::Block { received: res }; + Ok(resp) +} + +fn query_sudo_result_track_before(deps: Deps) -> StdResult { + let res = SUDO_RES_TRACK.load(deps.storage)?; + let resp = SudoResResponse::Block { received: res }; + Ok(resp) +} + +fn sudo_result_track_before(deps: DepsMut, _: TrackBeforeSendMsg) -> StdResult { + SUDO_RES_TRACK.save(deps.storage, &true)?; + Ok(Response::new()) +} + +fn sudo_result_block_before(deps: DepsMut, _: BlockBeforeSendMsg) -> StdResult { + SUDO_RES_BLOCK.save(deps.storage, &true)?; + Ok(Response::new()) +} diff --git a/contracts/before-send-hook/src/lib.rs b/contracts/before-send-hook/src/lib.rs new file mode 100644 index 0000000..c8ea3ef --- /dev/null +++ b/contracts/before-send-hook/src/lib.rs @@ -0,0 +1,19 @@ +// Copyright 2022 Neutron +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![warn(clippy::unwrap_used, clippy::expect_used)] + +pub mod contract; +pub mod msg; +mod state; diff --git a/contracts/before-send-hook/src/msg.rs b/contracts/before-send-hook/src/msg.rs new file mode 100644 index 0000000..93ffa57 --- /dev/null +++ b/contracts/before-send-hook/src/msg.rs @@ -0,0 +1,56 @@ +use cosmwasm_std:: Coin; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg { +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum QueryMsg { + SudoResultBlockBefore {}, + SudoResultTrackBefore {} +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum SudoMsg { + BlockBeforeSendSudoMsg { + block_before_send_msg: BlockBeforeSendMsg, + }, + TrackBeforeSendSudoMsg { + track_before_send_msg: TrackBeforeSendMsg + } +} + +/// Information about if the contract is currently paused. +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum SudoResResponse { + Block { received: bool }, + Track { received: bool }, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub struct TrackBeforeSendMsg { + from: String, + to: String, + amount: Coin +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub struct BlockBeforeSendMsg { + from: String, + to: String, + amount: Coin +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct MigrateMsg {} diff --git a/contracts/before-send-hook/src/state.rs b/contracts/before-send-hook/src/state.rs new file mode 100644 index 0000000..f919acb --- /dev/null +++ b/contracts/before-send-hook/src/state.rs @@ -0,0 +1,6 @@ +use cw_storage_plus::Item; + +/// contains number of transfers to addresses observed by the contract. +pub const SUDO_RES_BLOCK: Item = Item::new("sudo_res_block"); +pub const SUDO_RES_TRACK: Item = Item::new("sudo_res_track"); + From 57f74400262feb48fc850db0887e29ce245cc0f9 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 14 Sep 2023 16:45:16 +0400 Subject: [PATCH 07/16] fmt --- contracts/before-send-hook/examples/schema.rs | 2 +- contracts/before-send-hook/src/contract.rs | 30 ++++++++----------- contracts/before-send-hook/src/msg.rs | 29 +++++++++--------- contracts/before-send-hook/src/state.rs | 1 - 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/contracts/before-send-hook/examples/schema.rs b/contracts/before-send-hook/examples/schema.rs index 3f3914e..5fdbc2b 100644 --- a/contracts/before-send-hook/examples/schema.rs +++ b/contracts/before-send-hook/examples/schema.rs @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +use before_send_hook_test::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use std::{env::current_dir, fs::create_dir_all}; -use tokenfactory::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs index 84f6735..8f740a5 100644 --- a/contracts/before-send-hook/src/contract.rs +++ b/contracts/before-send-hook/src/contract.rs @@ -1,9 +1,9 @@ -use crate::msg::{BlockBeforeSendMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg, SudoResResponse, TrackBeforeSendMsg}; -use cosmwasm_std::{ - entry_point, Deps, DepsMut, Env, MessageInfo, - Response, StdResult, +use crate::msg::{ + BlockBeforeSendMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg, SudoResResponse, + TrackBeforeSendMsg, }; use crate::state::{SUDO_RES_BLOCK, SUDO_RES_TRACK}; +use cosmwasm_std::{entry_point, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; #[entry_point] pub fn instantiate( @@ -12,7 +12,6 @@ pub fn instantiate( _info: MessageInfo, _msg: InstantiateMsg, ) -> StdResult { - SUDO_RES_TRACK.save(deps.storage, &false)?; SUDO_RES_BLOCK.save(deps.storage, &false)?; @@ -32,23 +31,20 @@ pub fn execute( #[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::SudoResultBlockBefore { - } => query_sudo_result_block_before(deps), - QueryMsg::SudoResultTrackBefore { - } => query_sudo_result_track_before(deps), + QueryMsg::SudoResultBlockBefore {} => query_sudo_result_block_before(deps), + QueryMsg::SudoResultTrackBefore {} => query_sudo_result_track_before(deps), } } #[entry_point] -pub fn sudo( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - msg: SudoMsg, -) -> StdResult { +pub fn sudo(deps: DepsMut, _env: Env, _info: MessageInfo, msg: SudoMsg) -> StdResult { match msg { - SudoMsg::TrackBeforeSendSudoMsg {track_before_send_msg } => sudo_result_track_before(deps, track_before_send_msg), - SudoMsg::BlockBeforeSendSudoMsg {block_before_send_msg} => sudo_result_block_before(deps, block_before_send_msg), + SudoMsg::TrackBeforeSendSudoMsg { + track_before_send_msg, + } => sudo_result_track_before(deps, track_before_send_msg), + SudoMsg::BlockBeforeSendSudoMsg { + block_before_send_msg, + } => sudo_result_block_before(deps, block_before_send_msg), } } diff --git a/contracts/before-send-hook/src/msg.rs b/contracts/before-send-hook/src/msg.rs index 93ffa57..b66e8e6 100644 --- a/contracts/before-send-hook/src/msg.rs +++ b/contracts/before-send-hook/src/msg.rs @@ -1,4 +1,4 @@ -use cosmwasm_std:: Coin; +use cosmwasm_std::Coin; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -7,14 +7,13 @@ pub struct InstantiateMsg {} #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { -} +pub enum ExecuteMsg {} #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { SudoResultBlockBefore {}, - SudoResultTrackBefore {} + SudoResultTrackBefore {}, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] @@ -23,9 +22,9 @@ pub enum SudoMsg { BlockBeforeSendSudoMsg { block_before_send_msg: BlockBeforeSendMsg, }, - TrackBeforeSendSudoMsg { - track_before_send_msg: TrackBeforeSendMsg - } + TrackBeforeSendSudoMsg { + track_before_send_msg: TrackBeforeSendMsg, + }, } /// Information about if the contract is currently paused. @@ -38,18 +37,18 @@ pub enum SudoResResponse { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] -pub struct TrackBeforeSendMsg { - from: String, - to: String, - amount: Coin +pub struct TrackBeforeSendMsg { + from: String, + to: String, + amount: Coin, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] -pub struct BlockBeforeSendMsg { - from: String, - to: String, - amount: Coin +pub struct BlockBeforeSendMsg { + from: String, + to: String, + amount: Coin, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/contracts/before-send-hook/src/state.rs b/contracts/before-send-hook/src/state.rs index f919acb..54d7cd3 100644 --- a/contracts/before-send-hook/src/state.rs +++ b/contracts/before-send-hook/src/state.rs @@ -3,4 +3,3 @@ use cw_storage_plus::Item; /// contains number of transfers to addresses observed by the contract. pub const SUDO_RES_BLOCK: Item = Item::new("sudo_res_block"); pub const SUDO_RES_TRACK: Item = Item::new("sudo_res_track"); - From 22b6a2d4ecfb2258d3570ce86af2a0faa1e61a5a Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 14 Sep 2023 16:55:56 +0400 Subject: [PATCH 08/16] upd --- contracts/before-send-hook/src/contract.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs index 8f740a5..d3701fb 100644 --- a/contracts/before-send-hook/src/contract.rs +++ b/contracts/before-send-hook/src/contract.rs @@ -3,7 +3,9 @@ use crate::msg::{ TrackBeforeSendMsg, }; use crate::state::{SUDO_RES_BLOCK, SUDO_RES_TRACK}; -use cosmwasm_std::{entry_point, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; +use cosmwasm_std::{ + entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, +}; #[entry_point] pub fn instantiate( @@ -29,15 +31,15 @@ pub fn execute( } #[entry_point] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::SudoResultBlockBefore {} => query_sudo_result_block_before(deps), - QueryMsg::SudoResultTrackBefore {} => query_sudo_result_track_before(deps), + QueryMsg::SudoResultBlockBefore {} => to_binary(&query_sudo_result_block_before(deps)?), + QueryMsg::SudoResultTrackBefore {} => to_binary(&query_sudo_result_track_before(deps)?), } } #[entry_point] -pub fn sudo(deps: DepsMut, _env: Env, _info: MessageInfo, msg: SudoMsg) -> StdResult { +pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> StdResult { match msg { SudoMsg::TrackBeforeSendSudoMsg { track_before_send_msg, From 3ef39b973eda0dfe18adefe88af545576fe2d25f Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 14 Sep 2023 17:12:27 +0400 Subject: [PATCH 09/16] rm msg --- contracts/before-send-hook/src/contract.rs | 8 ++++---- contracts/before-send-hook/src/msg.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs index d3701fb..f3bfc5d 100644 --- a/contracts/before-send-hook/src/contract.rs +++ b/contracts/before-send-hook/src/contract.rs @@ -42,11 +42,11 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> StdResult { match msg { SudoMsg::TrackBeforeSendSudoMsg { - track_before_send_msg, - } => sudo_result_track_before(deps, track_before_send_msg), + track_before_send, + } => sudo_result_track_before(deps, track_before_send), SudoMsg::BlockBeforeSendSudoMsg { - block_before_send_msg, - } => sudo_result_block_before(deps, block_before_send_msg), + block_before_send, + } => sudo_result_block_before(deps, block_before_send), } } diff --git a/contracts/before-send-hook/src/msg.rs b/contracts/before-send-hook/src/msg.rs index b66e8e6..8cd4659 100644 --- a/contracts/before-send-hook/src/msg.rs +++ b/contracts/before-send-hook/src/msg.rs @@ -20,10 +20,10 @@ pub enum QueryMsg { #[serde(rename_all = "snake_case")] pub enum SudoMsg { BlockBeforeSendSudoMsg { - block_before_send_msg: BlockBeforeSendMsg, + block_before_send: BlockBeforeSendMsg, }, TrackBeforeSendSudoMsg { - track_before_send_msg: TrackBeforeSendMsg, + track_before_send: TrackBeforeSendMsg, }, } From 57d1df34c431ddeb93e19592cbd6a80ae9ff9812 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 14 Sep 2023 17:17:56 +0400 Subject: [PATCH 10/16] fmt --- contracts/before-send-hook/src/contract.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs index f3bfc5d..f087c0c 100644 --- a/contracts/before-send-hook/src/contract.rs +++ b/contracts/before-send-hook/src/contract.rs @@ -41,12 +41,12 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { #[entry_point] pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> StdResult { match msg { - SudoMsg::TrackBeforeSendSudoMsg { - track_before_send, - } => sudo_result_track_before(deps, track_before_send), - SudoMsg::BlockBeforeSendSudoMsg { - block_before_send, - } => sudo_result_block_before(deps, block_before_send), + SudoMsg::TrackBeforeSendSudoMsg { track_before_send } => { + sudo_result_track_before(deps, track_before_send) + } + SudoMsg::BlockBeforeSendSudoMsg { block_before_send } => { + sudo_result_block_before(deps, block_before_send) + } } } From 40b016d8f383ef5d9dc8acf13ef775d0df504d43 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 14 Sep 2023 18:17:59 +0400 Subject: [PATCH 11/16] fix typo --- contracts/before-send-hook/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs index f087c0c..f6f51a0 100644 --- a/contracts/before-send-hook/src/contract.rs +++ b/contracts/before-send-hook/src/contract.rs @@ -63,7 +63,7 @@ fn query_sudo_result_block_before(deps: Deps) -> StdResult { fn query_sudo_result_track_before(deps: Deps) -> StdResult { let res = SUDO_RES_TRACK.load(deps.storage)?; - let resp = SudoResResponse::Block { received: res }; + let resp = SudoResResponse::Track { received: res }; Ok(resp) } From 8832c7cd821b82d93bf8fa13e97bb2ca9427a4ec Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Fri, 15 Sep 2023 12:39:23 +0400 Subject: [PATCH 12/16] upd sudo msg --- contracts/before-send-hook/src/contract.rs | 17 +++++------------ contracts/before-send-hook/src/msg.rs | 12 ++++++++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs index f6f51a0..514b363 100644 --- a/contracts/before-send-hook/src/contract.rs +++ b/contracts/before-send-hook/src/contract.rs @@ -1,7 +1,4 @@ -use crate::msg::{ - BlockBeforeSendMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg, SudoResResponse, - TrackBeforeSendMsg, -}; +use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg, SudoResResponse}; use crate::state::{SUDO_RES_BLOCK, SUDO_RES_TRACK}; use cosmwasm_std::{ entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, @@ -41,12 +38,8 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { #[entry_point] pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> StdResult { match msg { - SudoMsg::TrackBeforeSendSudoMsg { track_before_send } => { - sudo_result_track_before(deps, track_before_send) - } - SudoMsg::BlockBeforeSendSudoMsg { block_before_send } => { - sudo_result_block_before(deps, block_before_send) - } + SudoMsg::TrackBeforeSend { .. } => sudo_result_track_before(deps), + SudoMsg::BlockBeforeSend { .. } => sudo_result_block_before(deps), } } @@ -67,12 +60,12 @@ fn query_sudo_result_track_before(deps: Deps) -> StdResult { Ok(resp) } -fn sudo_result_track_before(deps: DepsMut, _: TrackBeforeSendMsg) -> StdResult { +fn sudo_result_track_before(deps: DepsMut) -> StdResult { SUDO_RES_TRACK.save(deps.storage, &true)?; Ok(Response::new()) } -fn sudo_result_block_before(deps: DepsMut, _: BlockBeforeSendMsg) -> StdResult { +fn sudo_result_block_before(deps: DepsMut) -> StdResult { SUDO_RES_BLOCK.save(deps.storage, &true)?; Ok(Response::new()) } diff --git a/contracts/before-send-hook/src/msg.rs b/contracts/before-send-hook/src/msg.rs index 8cd4659..f573cd6 100644 --- a/contracts/before-send-hook/src/msg.rs +++ b/contracts/before-send-hook/src/msg.rs @@ -19,11 +19,15 @@ pub enum QueryMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum SudoMsg { - BlockBeforeSendSudoMsg { - block_before_send: BlockBeforeSendMsg, + TrackBeforeSend { + from: String, + to: String, + amount: Coin, }, - TrackBeforeSendSudoMsg { - track_before_send: TrackBeforeSendMsg, + BlockBeforeSend { + from: String, + to: String, + amount: Coin, }, } From b0359cfc145b714efc584341ae94077effb0f0bd Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 19 Sep 2023 15:52:30 +0400 Subject: [PATCH 13/16] cargo update; rename cosmwasm_addr -> contract_addr --- Cargo.lock | 40 +++++++++++++------------- contracts/tokenfactory/src/contract.rs | 4 +-- contracts/tokenfactory/src/msg.rs | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25f76cd..ead2b56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,9 +113,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "num-traits", ] @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" [[package]] name = "ecdsa" @@ -761,7 +761,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.6.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#9609e48f5305e8e61871756eae33bc927bca7bae" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/tokenfactory-update#549595cceb2aecce1b970d76cc32e9de6439a1d1" dependencies = [ "base64", "bech32", @@ -1053,9 +1053,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -1213,9 +1213,9 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "schemars" -version = "0.8.13" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" +checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" dependencies = [ "dyn-clone", "schemars_derive", @@ -1225,9 +1225,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.13" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" +checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" dependencies = [ "proc-macro2", "quote 1.0.33", @@ -1313,7 +1313,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote 1.0.33", - "syn 2.0.32", + "syn 2.0.37", ] [[package]] @@ -1329,9 +1329,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -1437,7 +1437,7 @@ dependencies = [ "proc-macro2", "quote 1.0.33", "rustversion", - "syn 2.0.32", + "syn 2.0.37", ] [[package]] @@ -1468,9 +1468,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.32" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote 1.0.33", @@ -1530,7 +1530,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote 1.0.33", - "syn 2.0.32", + "syn 2.0.37", ] [[package]] @@ -1572,9 +1572,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 9678cf1..a679fb8 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -41,8 +41,8 @@ pub fn execute( } ExecuteMsg::SetBeforeSendHook { denom, - cosm_wasm_addr, - } => NeutronMsg::submit_set_before_send_hoook(denom, cosm_wasm_addr).into(), + contract_addr, + } => NeutronMsg::submit_set_before_send_hoook(denom, contract_addr).into(), ExecuteMsg::SendTokens { recipient, denom, diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index cbb643b..eb3d9c3 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -30,7 +30,7 @@ pub enum ExecuteMsg { }, SetBeforeSendHook { denom: String, - cosm_wasm_addr: String, + contract_addr: String, }, } From 48d63b2f931379a3d358d87ad7f02519d1a9fdef Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 19 Sep 2023 16:17:35 +0400 Subject: [PATCH 14/16] make schema --- .../before-send-hook/schema/execute_msg.json | 6 ++++ .../schema/instantiate_msg.json | 5 ++++ .../before-send-hook/schema/migrate_msg.json | 5 ++++ .../before-send-hook/schema/query_msg.json | 30 +++++++++++++++++++ .../tokenfactory/schema/execute_msg.json | 24 +++++++++++++++ contracts/tokenfactory/schema/query_msg.json | 20 +++++++++++++ contracts/tokenfactory/src/contract.rs | 2 +- 7 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 contracts/before-send-hook/schema/execute_msg.json create mode 100644 contracts/before-send-hook/schema/instantiate_msg.json create mode 100644 contracts/before-send-hook/schema/migrate_msg.json create mode 100644 contracts/before-send-hook/schema/query_msg.json diff --git a/contracts/before-send-hook/schema/execute_msg.json b/contracts/before-send-hook/schema/execute_msg.json new file mode 100644 index 0000000..b3d18b4 --- /dev/null +++ b/contracts/before-send-hook/schema/execute_msg.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "type": "string", + "enum": [] +} diff --git a/contracts/before-send-hook/schema/instantiate_msg.json b/contracts/before-send-hook/schema/instantiate_msg.json new file mode 100644 index 0000000..44588cf --- /dev/null +++ b/contracts/before-send-hook/schema/instantiate_msg.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object" +} diff --git a/contracts/before-send-hook/schema/migrate_msg.json b/contracts/before-send-hook/schema/migrate_msg.json new file mode 100644 index 0000000..87b18ea --- /dev/null +++ b/contracts/before-send-hook/schema/migrate_msg.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MigrateMsg", + "type": "object" +} diff --git a/contracts/before-send-hook/schema/query_msg.json b/contracts/before-send-hook/schema/query_msg.json new file mode 100644 index 0000000..77f598c --- /dev/null +++ b/contracts/before-send-hook/schema/query_msg.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "sudo_result_block_before" + ], + "properties": { + "sudo_result_block_before": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "sudo_result_track_before" + ], + "properties": { + "sudo_result_track_before": { + "type": "object" + } + }, + "additionalProperties": false + } + ] +} diff --git a/contracts/tokenfactory/schema/execute_msg.json b/contracts/tokenfactory/schema/execute_msg.json index c8cbe47..e659fa7 100644 --- a/contracts/tokenfactory/schema/execute_msg.json +++ b/contracts/tokenfactory/schema/execute_msg.json @@ -121,6 +121,30 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "set_before_send_hook" + ], + "properties": { + "set_before_send_hook": { + "type": "object", + "required": [ + "contract_addr", + "denom" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "denom": { + "type": "string" + } + } + } + }, + "additionalProperties": false } ], "definitions": { diff --git a/contracts/tokenfactory/schema/query_msg.json b/contracts/tokenfactory/schema/query_msg.json index e8ab387..7f89698 100644 --- a/contracts/tokenfactory/schema/query_msg.json +++ b/contracts/tokenfactory/schema/query_msg.json @@ -45,6 +45,26 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "before_send_hook" + ], + "properties": { + "before_send_hook": { + "type": "object", + "required": [ + "denom" + ], + "properties": { + "denom": { + "type": "string" + } + } + } + }, + "additionalProperties": false } ] } diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index a679fb8..920377f 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -42,7 +42,7 @@ pub fn execute( ExecuteMsg::SetBeforeSendHook { denom, contract_addr, - } => NeutronMsg::submit_set_before_send_hoook(denom, contract_addr).into(), + } => NeutronMsg::submit_set_before_send_hook(denom, contract_addr).into(), ExecuteMsg::SendTokens { recipient, denom, From b183066ed7cb7e9dcbafe408431868c02023513d Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 19 Sep 2023 18:54:57 +0400 Subject: [PATCH 15/16] fix review --- contracts/before-send-hook/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/before-send-hook/src/contract.rs b/contracts/before-send-hook/src/contract.rs index 514b363..f78ed56 100644 --- a/contracts/before-send-hook/src/contract.rs +++ b/contracts/before-send-hook/src/contract.rs @@ -49,7 +49,7 @@ pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult StdResult { - let res = SUDO_RES_TRACK.load(deps.storage)?; + let res = SUDO_RES_BLOCK.load(deps.storage)?; let resp = SudoResResponse::Block { received: res }; Ok(resp) } From 4531935b527a603fa27ca8a8b5c52f7867873558 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 20 Sep 2023 15:04:10 +0400 Subject: [PATCH 16/16] after merge cargo.lock changed --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0d94ff4..1f983c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -783,7 +783,7 @@ name = "neutron-sdk" version = "0.6.1" source = "git+https://github.com/neutron-org/neutron-sdk.git?rev=8f8865870b91cb4c072c42934a621572c2634712#8f8865870b91cb4c072c42934a621572c2634712" dependencies = [ - "base64 0.21.2", + "base64", "bech32", "cosmos-sdk-proto 0.16.0", "cosmwasm-schema",