From 891d72ad59bed59ecb11bea52bc4c61611a97c16 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:04:53 +0400 Subject: [PATCH 01/34] remove dex bindings contract --- contracts/dex/.cargo/config | 6 - contracts/dex/Cargo.toml | 41 -- contracts/dex/README.md | 3 - contracts/dex/examples/schema.rs | 32 - contracts/dex/schema/dex_msg.json | 414 ------------- contracts/dex/schema/dex_query.json | 715 ---------------------- contracts/dex/schema/instantiate_msg.json | 6 - contracts/dex/src/contract.rs | 147 ----- contracts/dex/src/lib.rs | 1 - 9 files changed, 1365 deletions(-) delete mode 100644 contracts/dex/.cargo/config delete mode 100644 contracts/dex/Cargo.toml delete mode 100644 contracts/dex/README.md delete mode 100644 contracts/dex/examples/schema.rs delete mode 100644 contracts/dex/schema/dex_msg.json delete mode 100644 contracts/dex/schema/dex_query.json delete mode 100644 contracts/dex/schema/instantiate_msg.json delete mode 100644 contracts/dex/src/contract.rs delete mode 100644 contracts/dex/src/lib.rs diff --git a/contracts/dex/.cargo/config b/contracts/dex/.cargo/config deleted file mode 100644 index 8d4bc73..0000000 --- a/contracts/dex/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example schema" diff --git a/contracts/dex/Cargo.toml b/contracts/dex/Cargo.toml deleted file mode 100644 index 632a96a..0000000 --- a/contracts/dex/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "dex" -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 -library = [] - -[dependencies] -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -schemars = { workspace = true } -serde = { version = "1.0.180", default-features = false, features = ["derive"] } -neutron-sdk = { workspace = true } - -[dev-dependencies] -cosmwasm-schema = { workspace = true } diff --git a/contracts/dex/README.md b/contracts/dex/README.md deleted file mode 100644 index 5fae2c9..0000000 --- a/contracts/dex/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Dex - -This contract is used for tests in the main neutron repository. diff --git a/contracts/dex/examples/schema.rs b/contracts/dex/examples/schema.rs deleted file mode 100644 index e6413d9..0000000 --- a/contracts/dex/examples/schema.rs +++ /dev/null @@ -1,32 +0,0 @@ -// 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 std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use dex::contract::InstantiateMsg; -use neutron_sdk::bindings::dex::msg::DexMsg; -use neutron_sdk::bindings::dex::query::DexQuery; - -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!(DexMsg), &out_dir); - export_schema(&schema_for!(DexQuery), &out_dir); -} diff --git a/contracts/dex/schema/dex_msg.json b/contracts/dex/schema/dex_msg.json deleted file mode 100644 index 9d0c7b2..0000000 --- a/contracts/dex/schema/dex_msg.json +++ /dev/null @@ -1,414 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DexMsg", - "oneOf": [ - { - "description": "Deposit provides liquidity to a specific trading pair by depositing tokens at a specific price into one or both sides of the pair in “a liquidity pool”", - "type": "object", - "required": [ - "deposit" - ], - "properties": { - "deposit": { - "type": "object", - "required": [ - "amounts_a", - "amounts_b", - "fees", - "options", - "receiver", - "tick_indexes_a_to_b", - "token_a", - "token_b" - ], - "properties": { - "amounts_a": { - "description": "Amounts of tokenA to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "amounts_b": { - "description": "Amounts of tokenB to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "fees": { - "description": "Fees to use for each deposit", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "options": { - "description": "Additional deposit options", - "type": "array", - "items": { - "$ref": "#/definitions/DepositOptions" - } - }, - "receiver": { - "description": "The account to which PoolShares will be issued", - "type": "string" - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes to deposit at defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Withdraw is used to redeem PoolShares for the user’s pro-rata portion of tokens within a liquidity pool. Users can withdraw from a pool at any time", - "type": "object", - "required": [ - "withdrawal" - ], - "properties": { - "withdrawal": { - "type": "object", - "required": [ - "fees", - "receiver", - "shares_to_remove", - "tick_indexes_a_to_b", - "token_a", - "token_b" - ], - "properties": { - "fees": { - "description": "Fee for the target LiquidityPools", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "receiver": { - "description": "The account to which the tokens are credited", - "type": "string" - }, - "shares_to_remove": { - "description": "Amount of shares to remove from each pool", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes of the target LiquidityPools defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "PlaceLimitOrder provides the primary mechanism for trading on the Duality Dex. Limit orders can provide liquidity to the Dex (“Maker Limit Orders”) and/or can be used to trade against preexisting liquidity (“Taker Limit Orders”)", - "type": "object", - "required": [ - "place_limit_order" - ], - "properties": { - "place_limit_order": { - "type": "object", - "required": [ - "amount_in", - "limit_sell_price", - "order_type", - "receiver", - "tick_index_in_to_out", - "token_in", - "token_out" - ], - "properties": { - "amount_in": { - "description": "Amount of TokenIn to be traded", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "expiration_time": { - "description": "Expiration time for order. Only valid for GOOD_TIL_TIME limit orders", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "limit_sell_price": { - "description": "Accepts standard decimals and decimals with scientific notation (ie. 1234.23E-7)", - "type": "string" - }, - "max_amount_out": { - "description": "Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - }, - "order_type": { - "description": "Type of limit order to be used. Must be one of: GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME", - "allOf": [ - { - "$ref": "#/definitions/LimitOrderType" - } - ] - }, - "receiver": { - "description": "Account to which TokenOut is credited or that will be allowed to withdraw or cancel a maker order", - "type": "string" - }, - "tick_index_in_to_out": { - "description": "Limit tick for a limit order, specified in terms of TokenIn to TokenOut", - "type": "integer", - "format": "int64" - }, - "token_in": { - "description": "Token being “sold”", - "type": "string" - }, - "token_out": { - "description": "Token being “bought”", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "WithdrawFilledLimitOrder. Once a limit order has been filled – either partially or in its entirety, it can be withdrawn at any time. Withdrawing from a limit order credits all available proceeds to the user. Withdraw can be called on a limit order multiple times as new proceeds become available", - "type": "object", - "required": [ - "withdraw_filled_limit_order" - ], - "properties": { - "withdraw_filled_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "CancelLimitOrder. Standard Taker limit orders (Good-til-cancelled & Good-til-Time) can be canceled at any time if they have not been completely filled", - "type": "object", - "required": [ - "cancel_limit_order" - ], - "properties": { - "cancel_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "MultiHopSwap provides a swapping mechanism to achieve better prices by routing through a series of pools", - "type": "object", - "required": [ - "multi_hop_swap" - ], - "properties": { - "multi_hop_swap": { - "type": "object", - "required": [ - "amount_in", - "exit_limit_price", - "pick_best_route", - "receiver", - "routes" - ], - "properties": { - "amount_in": { - "description": "Amount of TokenIn to swap", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "exit_limit_price": { - "description": "Minimum price that that must be satisfied for a route to succeed", - "allOf": [ - { - "$ref": "#/definitions/PrecDec" - } - ] - }, - "pick_best_route": { - "description": "If true all routes are run and the route with the best price is used", - "type": "boolean" - }, - "receiver": { - "description": "Account to which TokenOut is credited", - "type": "string" - }, - "routes": { - "description": "Array of possible routes", - "type": "array", - "items": { - "$ref": "#/definitions/MultiHopRoute" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ], - "definitions": { - "DepositOptions": { - "type": "object", - "properties": { - "disable_autoswap": { - "type": [ - "boolean", - "null" - ] - }, - "fail_tx_on_bel": { - "type": [ - "boolean", - "null" - ] - } - }, - "additionalProperties": false - }, - "LimitOrderType": { - "oneOf": [ - { - "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", - "type": "string", - "enum": [ - "GOOD_TIL_CANCELLED" - ] - }, - { - "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` ( ErrGoodTilOrderWithoutExpiration).", - "type": "string", - "enum": [ - "FILL_OR_KILL" - ] - }, - { - "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", - "type": "string", - "enum": [ - "IMMEDIATE_OR_CANCEL" - ] - }, - { - "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", - "type": "string", - "enum": [ - "JUST_IN_TIME" - ] - }, - { - "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", - "type": "string", - "enum": [ - "GOOD_TIL_TIME" - ] - } - ] - }, - "MultiHopRoute": { - "type": "object", - "required": [ - "hops" - ], - "properties": { - "hops": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - }, - "additionalProperties": false - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/dex/schema/dex_query.json b/contracts/dex/schema/dex_query.json deleted file mode 100644 index bc0a5c0..0000000 --- a/contracts/dex/schema/dex_query.json +++ /dev/null @@ -1,715 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DexQuery", - "oneOf": [ - { - "description": "Parameters queries the parameters of the module.", - "type": "object", - "required": [ - "params" - ], - "properties": { - "params": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a LimitOrderTrancheUser by index.", - "type": "object", - "required": [ - "limit_order_tranche_user" - ], - "properties": { - "limit_order_tranche_user": { - "type": "object", - "required": [ - "address", - "tranche_key" - ], - "properties": { - "address": { - "type": "string" - }, - "tranche_key": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of LimitOrderTrancheMap items.", - "type": "object", - "required": [ - "limit_order_tranche_user_all" - ], - "properties": { - "limit_order_tranche_user_all": { - "type": "object", - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of LimitOrderTrancheUser items for a given address.", - "type": "object", - "required": [ - "limit_order_tranche_user_all_by_address" - ], - "properties": { - "limit_order_tranche_user_all_by_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - }, - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a LimitOrderTranche by index.", - "type": "object", - "required": [ - "limit_order_tranche" - ], - "properties": { - "limit_order_tranche": { - "type": "object", - "required": [ - "pair_id", - "tick_index", - "token_in", - "tranche_key" - ], - "properties": { - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - }, - "tranche_key": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of LimitOrderTranche items for a given pairID / TokenIn combination.", - "type": "object", - "required": [ - "limit_order_tranche_all" - ], - "properties": { - "limit_order_tranche_all": { - "type": "object", - "required": [ - "pair_id", - "token_in" - ], - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - }, - "pair_id": { - "type": "string" - }, - "token_in": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of UserDeposits items.", - "type": "object", - "required": [ - "user_deposit_all" - ], - "properties": { - "user_deposit_all": { - "type": "object", - "required": [ - "address", - "include_pool_data" - ], - "properties": { - "address": { - "type": "string" - }, - "include_pool_data": { - "type": "boolean" - }, - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of TickLiquidity items.", - "type": "object", - "required": [ - "tick_liquidity_all" - ], - "properties": { - "tick_liquidity_all": { - "type": "object", - "required": [ - "pair_id", - "token_in" - ], - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - }, - "pair_id": { - "type": "string" - }, - "token_in": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a InactiveLimitOrderTranche by index.", - "type": "object", - "required": [ - "inactive_limit_order_tranche" - ], - "properties": { - "inactive_limit_order_tranche": { - "type": "object", - "required": [ - "pair_id", - "tick_index", - "token_in", - "tranche_key" - ], - "properties": { - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - }, - "tranche_key": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of InactiveLimitOrderTranche items.", - "type": "object", - "required": [ - "inactive_limit_order_tranche_all" - ], - "properties": { - "inactive_limit_order_tranche_all": { - "type": "object", - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of PoolReserves items.", - "type": "object", - "required": [ - "pool_reserves_all" - ], - "properties": { - "pool_reserves_all": { - "type": "object", - "required": [ - "pair_id", - "token_in" - ], - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - }, - "pair_id": { - "type": "string" - }, - "token_in": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a PoolReserve by index", - "type": "object", - "required": [ - "pool_reserves" - ], - "properties": { - "pool_reserves": { - "type": "object", - "required": [ - "fee", - "pair_id", - "tick_index", - "token_in" - ], - "properties": { - "fee": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries the simulated result of a multihop swap", - "type": "object", - "required": [ - "estimate_multi_hop_swap" - ], - "properties": { - "estimate_multi_hop_swap": { - "type": "object", - "required": [ - "amount_in", - "creator", - "exit_limit_price", - "pick_best_route", - "receiver", - "routes" - ], - "properties": { - "amount_in": { - "$ref": "#/definitions/Int128" - }, - "creator": { - "type": "string" - }, - "exit_limit_price": { - "$ref": "#/definitions/PrecDec" - }, - "pick_best_route": { - "type": "boolean" - }, - "receiver": { - "type": "string" - }, - "routes": { - "type": "array", - "items": { - "$ref": "#/definitions/MultiHopRoute" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries the simulated result of a PlaceLimit order", - "type": "object", - "required": [ - "estimate_place_limit_order" - ], - "properties": { - "estimate_place_limit_order": { - "type": "object", - "required": [ - "amount_in", - "creator", - "order_type", - "receiver", - "tick_index_in_to_out", - "token_in", - "token_out" - ], - "properties": { - "amount_in": { - "$ref": "#/definitions/Int128" - }, - "creator": { - "type": "string" - }, - "expiration_time": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "max_amount_out": { - "anyOf": [ - { - "$ref": "#/definitions/Int128" - }, - { - "type": "null" - } - ] - }, - "order_type": { - "$ref": "#/definitions/LimitOrderType" - }, - "receiver": { - "type": "string" - }, - "tick_index_in_to_out": { - "type": "integer", - "format": "int64" - }, - "token_in": { - "type": "string" - }, - "token_out": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a pool by pair, tick and fee", - "type": "object", - "required": [ - "pool" - ], - "properties": { - "pool": { - "type": "object", - "required": [ - "fee", - "pair_id", - "tick_index" - ], - "properties": { - "fee": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "pair_id": { - "type": "string" - }, - "tick_index": { - "type": "integer", - "format": "int64" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a pool by ID", - "type": "object", - "required": [ - "pool_by_id" - ], - "properties": { - "pool_by_id": { - "type": "object", - "required": [ - "pool_id" - ], - "properties": { - "pool_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a PoolMetadata by ID", - "type": "object", - "required": [ - "pool_metadata" - ], - "properties": { - "pool_metadata": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Queries a list of PoolMetadata items.", - "type": "object", - "required": [ - "pool_metadata_all" - ], - "properties": { - "pool_metadata_all": { - "type": "object", - "properties": { - "pagination": { - "anyOf": [ - { - "$ref": "#/definitions/PageRequest" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", - "type": "string" - }, - "Int128": { - "description": "An implementation of i128 that is using strings for JSON encoding/decoding, such that the full i128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `i128` to get the value out:\n\n``` # use cosmwasm_std::Int128; let a = Int128::from(258i128); assert_eq!(a.i128(), 258); ```", - "type": "string" - }, - "LimitOrderType": { - "oneOf": [ - { - "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", - "type": "string", - "enum": [ - "GOOD_TIL_CANCELLED" - ] - }, - { - "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` ( ErrGoodTilOrderWithoutExpiration).", - "type": "string", - "enum": [ - "FILL_OR_KILL" - ] - }, - { - "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", - "type": "string", - "enum": [ - "IMMEDIATE_OR_CANCEL" - ] - }, - { - "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", - "type": "string", - "enum": [ - "JUST_IN_TIME" - ] - }, - { - "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", - "type": "string", - "enum": [ - "GOOD_TIL_TIME" - ] - } - ] - }, - "MultiHopRoute": { - "type": "object", - "required": [ - "hops" - ], - "properties": { - "hops": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "PageRequest": { - "type": "object", - "required": [ - "count_total", - "key", - "limit", - "offset", - "reverse" - ], - "properties": { - "count_total": { - "description": "**count_total** is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set.", - "type": "boolean" - }, - "key": { - "description": "**key** is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set.", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "limit": { - "description": "**limit** is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "offset": { - "description": "**offset** is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "reverse": { - "description": "reverse is set to true if results are to be returned in the descending order.", - "type": "boolean" - } - }, - "additionalProperties": false - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - }, - "additionalProperties": false - } - } -} diff --git a/contracts/dex/schema/instantiate_msg.json b/contracts/dex/schema/instantiate_msg.json deleted file mode 100644 index 1352613..0000000 --- a/contracts/dex/schema/instantiate_msg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "additionalProperties": false -} diff --git a/contracts/dex/src/contract.rs b/contracts/dex/src/contract.rs deleted file mode 100644 index 5d0f732..0000000 --- a/contracts/dex/src/contract.rs +++ /dev/null @@ -1,147 +0,0 @@ -use cosmwasm_std::{ - entry_point, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, - StdResult, -}; -use cw2::set_contract_version; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -use neutron_sdk::bindings::{ - dex::msg::DexMsg, - dex::query::{ - AllInactiveLimitOrderTrancheResponse, AllLimitOrderTrancheResponse, - AllLimitOrderTrancheUserResponse, AllPoolMetadataResponse, AllPoolReservesResponse, - AllTickLiquidityResponse, AllUserDepositsResponse, AllUserLimitOrdersResponse, DexQuery, - EstimateMultiHopSwapResponse, EstimatePlaceLimitOrderResponse, - InactiveLimitOrderTrancheResponse, LimitOrderTrancheResponse, - LimitOrderTrancheUserResponse, ParamsResponse, PoolMetadataResponse, PoolReservesResponse, - PoolResponse, - }, - msg::NeutronMsg, - query::NeutronQuery, -}; - -const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - _info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - deps.api.debug("WASMDEBUG: instantiate"); - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - Ok(Response::default()) -} - -#[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: DexMsg, -) -> StdResult> { - deps.api - .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); - execute_dex(deps, env, info, msg) -} - -fn execute_dex( - _deps: DepsMut, - _env: Env, - _: MessageInfo, - msg: DexMsg, -) -> StdResult> { - Ok(Response::default().add_message(CosmosMsg::Custom(NeutronMsg::Dex(msg)))) -} - -#[entry_point] -pub fn query(deps: Deps, env: Env, msg: DexQuery) -> StdResult { - query_dex(deps, env, msg) -} - -fn query_dex(deps: Deps, _env: Env, msg: DexQuery) -> StdResult { - match msg { - DexQuery::Params {} => { - let query_response: ParamsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheUser { .. } => { - let query_response: LimitOrderTrancheUserResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheUserAll { .. } => { - let query_response: AllLimitOrderTrancheUserResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheUserAllByAddress { .. } => { - let query_response: AllUserLimitOrdersResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTranche { .. } => { - let query_response: LimitOrderTrancheResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::LimitOrderTrancheAll { .. } => { - let query_response: AllLimitOrderTrancheResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::UserDepositAll { .. } => { - let query_response: AllUserDepositsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::TickLiquidityAll { .. } => { - let query_response: AllTickLiquidityResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::InactiveLimitOrderTranche { .. } => { - let query_response: InactiveLimitOrderTrancheResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::InactiveLimitOrderTrancheAll { .. } => { - let query_response: AllInactiveLimitOrderTrancheResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolReservesAll { .. } => { - let query_response: AllPoolReservesResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolReserves { .. } => { - let query_response: PoolReservesResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::EstimateMultiHopSwap { .. } => { - let query_response: EstimateMultiHopSwapResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::EstimatePlaceLimitOrder { .. } => { - let query_response: EstimatePlaceLimitOrderResponse = - deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::Pool { .. } => { - let query_response: PoolResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolByID { .. } => { - let query_response: PoolResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolMetadata { .. } => { - let query_response: PoolMetadataResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - DexQuery::PoolMetadataAll { .. } => { - let query_response: AllPoolMetadataResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) - } - } -} diff --git a/contracts/dex/src/lib.rs b/contracts/dex/src/lib.rs deleted file mode 100644 index 2943dbb..0000000 --- a/contracts/dex/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod contract; From f52f2248069a0cec86edee4b247c6c5368ecb0e6 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:08:52 +0400 Subject: [PATCH 02/34] fix dex_grpc contract --- Cargo.lock | 56 ++++++++++++++++++++++-------- Cargo.toml | 5 ++- contracts/dex_grpc/Cargo.toml | 1 + contracts/dex_grpc/src/contract.rs | 16 ++++----- contracts/dex_grpc/src/msg.rs | 11 +++--- 5 files changed, 58 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2baea4a..458ffa3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -777,18 +777,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "dex" -version = "0.1.0" -dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", - "cw2 2.0.0", - "neutron-sdk", - "schemars", - "serde", -] - [[package]] name = "dex_grpc" version = "0.1.0" @@ -798,6 +786,7 @@ dependencies = [ "cosmwasm-std 2.1.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "schemars", @@ -1143,14 +1132,39 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#38197fb61ca4180ca695a5d215d31309813046d6" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a097d934ce27531be3bb7368f5fac90268a52f22" +dependencies = [ + "bech32 0.9.1", + "chrono", + "cosmos-sdk-proto 0.20.0", + "cosmwasm-schema 2.1.0", + "cosmwasm-std 2.1.0", + "neutron-std", + "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings)", + "prost 0.12.6", + "prost-types 0.12.6", + "protobuf", + "schemars", + "serde", + "serde-cw-value", + "serde-json-wasm 1.0.1", + "serde_json", + "speedate", + "tendermint-proto 0.34.1", + "thiserror", +] + +[[package]] +name = "neutron-std" +version = "4.2.2-rc" +source = "git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028#cc49ece967353bcae7ad29ce04f75d2cc167b028" dependencies = [ "bech32 0.9.1", "chrono", "cosmos-sdk-proto 0.20.0", "cosmwasm-schema 2.1.0", "cosmwasm-std 2.1.0", - "neutron-std-derive", + "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028)", "prost 0.12.6", "prost-types 0.12.6", "protobuf", @@ -1167,7 +1181,19 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#38197fb61ca4180ca695a5d215d31309813046d6" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a097d934ce27531be3bb7368f5fac90268a52f22" +dependencies = [ + "itertools 0.10.5", + "proc-macro2", + "prost-types 0.12.6", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "neutron-std-derive" +version = "0.20.1" +source = "git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028#cc49ece967353bcae7ad29ce04f75d2cc167b028" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index dc9f388..c93c50b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,10 @@ incremental = false overflow-checks = true [workspace.dependencies] -neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" } +neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/clean-bindings" } +neutron-std = { git = "https://github.com/neutron-org/neutron-std", rev = "cc49ece967353bcae7ad29ce04f75d2cc167b028" } + + prost = "0.12.4" prost-types = "0.12.4" cosmos-sdk-proto = { version = "0.20.0", default-features = false } diff --git a/contracts/dex_grpc/Cargo.toml b/contracts/dex_grpc/Cargo.toml index 90fc9d6..c36eb12 100644 --- a/contracts/dex_grpc/Cargo.toml +++ b/contracts/dex_grpc/Cargo.toml @@ -32,6 +32,7 @@ library = [] [dependencies] neutron-sdk = { workspace = true } +neutron-std = { workspace = true } cosmwasm-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index 57998ee..82c8523 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -4,8 +4,8 @@ use cosmwasm_std::{ StdResult, }; use cw2::set_contract_version; -use neutron_sdk::proto_types::neutron::dex; use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::dex::{DexQuerier, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, MsgWithdrawFilledLimitOrder, MsgWithdrawal}; const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -42,7 +42,7 @@ pub fn execute( fees, options, } => Ok( - Response::new().add_message(Into::::into(dex::MsgDeposit { + Response::new().add_message(Into::::into(MsgDeposit { creator: env.contract.address.to_string(), receiver, token_a, @@ -63,7 +63,7 @@ pub fn execute( tick_indexes_a_to_b, fees, } => Ok( - Response::new().add_message(Into::::into(dex::MsgWithdrawal { + Response::new().add_message(Into::::into(MsgWithdrawal { creator: env.contract.address.to_string(), receiver, token_a, @@ -85,7 +85,7 @@ pub fn execute( expiration_time, max_amount_out, } => Ok( - Response::new().add_message(Into::::into(dex::MsgPlaceLimitOrder { + Response::new().add_message(Into::::into(MsgPlaceLimitOrder { creator: env.contract.address.to_string(), receiver, token_in, @@ -99,7 +99,7 @@ pub fn execute( })), ), ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => Ok(Response::new().add_message( - Into::::into(dex::MsgWithdrawFilledLimitOrder { + Into::::into(MsgWithdrawFilledLimitOrder { creator: env.contract.address.to_string(), tranche_key, }), @@ -107,7 +107,7 @@ pub fn execute( ExecuteMsg::CancelLimitOrder { tranche_key } => { Ok( - Response::new().add_message(Into::::into(dex::MsgCancelLimitOrder { + Response::new().add_message(Into::::into(MsgCancelLimitOrder { creator: env.contract.address.to_string(), tranche_key, })), @@ -121,7 +121,7 @@ pub fn execute( exit_limit_price, pick_best_route, } => Ok( - Response::new().add_message(Into::::into(dex::MsgMultiHopSwap { + Response::new().add_message(Into::::into(MsgMultiHopSwap { creator: env.contract.address.to_string(), receiver, routes, @@ -138,7 +138,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: query: received msg: {:?}", msg).as_str()); - let dex_querier = dex::DexQuerier::new(&deps.querier); + let dex_querier = DexQuerier::new(&deps.querier); match msg { QueryMsg::Params {} => Ok(to_json_binary(&dex_querier.params()?)?), diff --git a/contracts/dex_grpc/src/msg.rs b/contracts/dex_grpc/src/msg.rs index d536d4f..5a156a4 100644 --- a/contracts/dex_grpc/src/msg.rs +++ b/contracts/dex_grpc/src/msg.rs @@ -1,9 +1,6 @@ -use neutron_sdk::proto_types::neutron::dex::{ - DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, - MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute, -}; -use neutron_sdk::proto_types::{cosmos::base::query::v1beta1::PageRequest, neutron::dex}; -use neutron_sdk::shim::Timestamp; +use neutron_std::shim::Timestamp; +use neutron_std::types::cosmos::base::query::v1beta1::PageRequest; +use neutron_std::types::neutron::dex::{DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -50,7 +47,7 @@ pub enum ExecuteMsg { }, MultiHopSwap { receiver: String, - routes: Vec, + routes: Vec, amount_in: String, exit_limit_price: String, pick_best_route: bool, From 17a30fa2e3867992f737e649ba358cee5219a536 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:17:50 +0400 Subject: [PATCH 03/34] remove client_updater contract --- contracts/client_updater/.cargo/config | 6 -- contracts/client_updater/Cargo.toml | 31 -------- contracts/client_updater/README.md | 3 - .../examples/client_updater-schema.rs | 29 ------- .../client_updater/schema/execute_msg.json | 39 ---------- .../schema/instantiate_msg.json | 6 -- contracts/client_updater/src/contract.rs | 78 ------------------- contracts/client_updater/src/lib.rs | 1 - contracts/client_updater/updater.sh | 74 ------------------ 9 files changed, 267 deletions(-) delete mode 100644 contracts/client_updater/.cargo/config delete mode 100644 contracts/client_updater/Cargo.toml delete mode 100644 contracts/client_updater/README.md delete mode 100644 contracts/client_updater/examples/client_updater-schema.rs delete mode 100644 contracts/client_updater/schema/execute_msg.json delete mode 100644 contracts/client_updater/schema/instantiate_msg.json delete mode 100644 contracts/client_updater/src/contract.rs delete mode 100644 contracts/client_updater/src/lib.rs delete mode 100644 contracts/client_updater/updater.sh diff --git a/contracts/client_updater/.cargo/config b/contracts/client_updater/.cargo/config deleted file mode 100644 index f5c196b..0000000 --- a/contracts/client_updater/.cargo/config +++ /dev/null @@ -1,6 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration" -schema = "run --example client_updater-schema" diff --git a/contracts/client_updater/Cargo.toml b/contracts/client_updater/Cargo.toml deleted file mode 100644 index 52a634b..0000000 --- a/contracts/client_updater/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "client_updater" -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"] - -[features] -# for quicker tests, cargo test --lib -library = [] - -[dependencies] -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -neutron-sdk = { workspace = true } - -[dev-dependencies] -cosmwasm-schema = { workspace = true } diff --git a/contracts/client_updater/README.md b/contracts/client_updater/README.md deleted file mode 100644 index ddae8cf..0000000 --- a/contracts/client_updater/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Client updater - -Updates a client through a ClientUpdateProposal proposal to adminmodule diff --git a/contracts/client_updater/examples/client_updater-schema.rs b/contracts/client_updater/examples/client_updater-schema.rs deleted file mode 100644 index 112c257..0000000 --- a/contracts/client_updater/examples/client_updater-schema.rs +++ /dev/null @@ -1,29 +0,0 @@ -// 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 std::env::current_dir; -use std::fs::create_dir_all; - -use client_updater::contract::{ExecuteMsg, InstantiateMsg}; -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -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); -} diff --git a/contracts/client_updater/schema/execute_msg.json b/contracts/client_updater/schema/execute_msg.json deleted file mode 100644 index ade18ff..0000000 --- a/contracts/client_updater/schema/execute_msg.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "submit_client_update_proposal" - ], - "properties": { - "submit_client_update_proposal": { - "type": "object", - "required": [ - "description", - "subject_client_id", - "substitute_client_id", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "subject_client_id": { - "type": "string" - }, - "substitute_client_id": { - "type": "string" - }, - "title": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] -} diff --git a/contracts/client_updater/schema/instantiate_msg.json b/contracts/client_updater/schema/instantiate_msg.json deleted file mode 100644 index 1352613..0000000 --- a/contracts/client_updater/schema/instantiate_msg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "additionalProperties": false -} diff --git a/contracts/client_updater/src/contract.rs b/contracts/client_updater/src/contract.rs deleted file mode 100644 index 9193d31..0000000 --- a/contracts/client_updater/src/contract.rs +++ /dev/null @@ -1,78 +0,0 @@ -use cosmwasm_std::{entry_point, Addr, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; -use cw2::set_contract_version; -use cw_storage_plus::Item; -#[allow(deprecated)] -use neutron_sdk::bindings::msg::{ClientUpdateProposal, NeutronMsg}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - -const OWNER: Item = Item::new("owner"); - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - SubmitClientUpdateProposal { - title: String, - description: String, - subject_client_id: String, - substitute_client_id: String, - }, -} - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - info: MessageInfo, - _msg: InstantiateMsg, -) -> StdResult { - let owner = info.sender; - OWNER.save(deps.storage, &owner)?; - deps.api.debug("WASMDEBUG: instantiate"); - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - Ok(Response::default()) -} - -#[entry_point] -pub fn execute( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { - deps.api - .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); - - let owner = OWNER.load(deps.storage)?; - if info.sender != owner { - return Err(StdError::generic_err("Unauthorized")); - } - - let mut resp = Response::default(); - match msg { - ExecuteMsg::SubmitClientUpdateProposal { - title, - description, - subject_client_id, - substitute_client_id, - } => { - #[allow(deprecated)] - let update_proposal_msg = - NeutronMsg::submit_client_update_proposal(ClientUpdateProposal { - title, - description, - subject_client_id, - substitute_client_id, - }); - - resp = resp.add_message(update_proposal_msg); - } - } - Ok(resp) -} diff --git a/contracts/client_updater/src/lib.rs b/contracts/client_updater/src/lib.rs deleted file mode 100644 index 2943dbb..0000000 --- a/contracts/client_updater/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod contract; diff --git a/contracts/client_updater/updater.sh b/contracts/client_updater/updater.sh deleted file mode 100644 index 05204ae..0000000 --- a/contracts/client_updater/updater.sh +++ /dev/null @@ -1,74 +0,0 @@ -# before execution: create baryon_testwallet in keyring-backend test in NEUTRON_DIR/data/baryon-1 directory -# test in pion-1 testnet -CONTRACT=./artifacts/client_updater.wasm -CHAINID=pion-1 -KEYS_HOME=~/.baryon-1 -NEUTROND_BIN=neutrond -NODE=https://rpc-palvus.pion-1.ntrn.tech:443 -TEST_WALLET=baryon_testwallet -TEST_ADDR=$(${NEUTROND_BIN} keys show ${TEST_WALLET} --keyring-backend test -a --home ${KEYS_HOME}) -GAS_PRICES=0.0025untrn - -echo "Store contract" -RES=$(${NEUTROND_BIN} tx wasm store ${CONTRACT} \ - --from ${TEST_ADDR} \ - --gas 50000000 \ - --chain-id ${CHAINID} \ - --broadcast-mode=block \ - --gas-prices ${GAS_PRICES} -y \ - --output json \ - --keyring-backend test \ - --home ${KEYS_HOME} \ - --node ${NODE}) -CONTRACT_CODE_ID=$(echo $RES | jq -r '.logs[0].events[1].attributes[1].value') -echo $RES -echo $CONTRACT_CODE_ID - -INIT_MSG="{}" - -echo "Instantiate" -RES=$(${NEUTROND_BIN} tx wasm instantiate $CONTRACT_CODE_ID \ - "$INIT_MSG" \ - --from ${TEST_ADDR} \ - --admin ${TEST_ADDR} -y \ - --chain-id ${CHAINID} \ - --output json \ - --broadcast-mode=block \ - --label "init" \ - --keyring-backend test \ - --gas-prices ${GAS_PRICES} \ - --home ${KEYS_HOME} \ - --node ${NODE}) -echo $RES -CONTRACT_ADDRESS=$(echo $RES | jq -r '.logs[0].events[0].attributes[0].value') -echo $CONTRACT_ADDRESS - -echo "Client update" -RES=$(${NEUTROND_BIN} tx wasm execute $CONTRACT_ADDRESS \ - '{"submit_client_update_proposal":{"title": "update pion-1 client 07-tendermint-4 to new one", "description": "update client", "subject_client_id": "07-tendermint-4", "substitute_client_id": "07-tendermint-9"}}' \ - --amount "500untrn" \ - --from ${TEST_ADDR} -y \ - --chain-id ${CHAINID} \ - --output json \ - --broadcast-mode=block \ - --gas-prices ${GAS_PRICES} \ - --gas 1000000 \ - --keyring-backend test \ - --home ${KEYS_HOME} \ - --node ${NODE}) -echo $RES | jq - -echo "Client update 2" -RES=$(${NEUTROND_BIN} tx wasm execute $CONTRACT_ADDRESS \ - '{"submit_client_update_proposal":{"title": "update pion-1 client 07-tendermint-5 to new one", "description": "update client 2", "subject_client_id": "07-tendermint-5", "substitute_client_id": "07-tendermint-10"}}' \ - --amount "500untrn" \ - --from ${TEST_ADDR} -y \ - --chain-id ${CHAINID} \ - --output json \ - --broadcast-mode=block \ - --gas-prices ${GAS_PRICES} \ - --gas 1000000 \ - --keyring-backend test \ - --home ${KEYS_HOME} \ - --node ${NODE}) -echo $RES | jq From 4d3236ad364fdf2e4da7dbb2ce63f3874026d925 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:18:09 +0400 Subject: [PATCH 04/34] fix cron contract --- contracts/cron/src/contract.rs | 14 +++++++------- contracts/cron/src/state.rs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/cron/src/contract.rs b/contracts/cron/src/contract.rs index 538eeca..83f7451 100644 --- a/contracts/cron/src/contract.rs +++ b/contracts/cron/src/contract.rs @@ -1,5 +1,5 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{BEGIN_BLOCKER_SHEDULES, END_BLOCKER_SHEDULES}; +use crate::state::{BEGIN_BLOCKER_SCHEDULES, END_BLOCKER_SCHEDULES}; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, @@ -34,24 +34,24 @@ pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> Std match msg { ExecuteMsg::AddBeginBlockerSchedule { name } => { - let counter = BEGIN_BLOCKER_SHEDULES + let counter = BEGIN_BLOCKER_SCHEDULES .may_load(deps.storage, name.clone())? .unwrap_or_default() .checked_add(1) .unwrap_or_default(); - BEGIN_BLOCKER_SHEDULES.save(deps.storage, name, &counter)?; + BEGIN_BLOCKER_SCHEDULES.save(deps.storage, name, &counter)?; Ok(Response::default()) } ExecuteMsg::AddEndBlockerSchedule { name } => { - let counter = END_BLOCKER_SHEDULES + let counter = END_BLOCKER_SCHEDULES .may_load(deps.storage, name.clone())? .unwrap_or_default() .checked_add(1) .unwrap_or_default(); - END_BLOCKER_SHEDULES.save(deps.storage, name, &counter)?; + END_BLOCKER_SCHEDULES.save(deps.storage, name, &counter)?; Ok(Response::default()) } @@ -62,11 +62,11 @@ pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> Std pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::GetBeginBlockerScheduleCounter { name } => { - let res = BEGIN_BLOCKER_SHEDULES.may_load(deps.storage, name)?; + let res = BEGIN_BLOCKER_SCHEDULES.may_load(deps.storage, name)?; to_json_binary(&res) } QueryMsg::GetEndBlockerScheduleCounter { name } => { - let res = END_BLOCKER_SHEDULES.may_load(deps.storage, name)?; + let res = END_BLOCKER_SCHEDULES.may_load(deps.storage, name)?; to_json_binary(&res) } } diff --git a/contracts/cron/src/state.rs b/contracts/cron/src/state.rs index 065ebbc..848be2a 100644 --- a/contracts/cron/src/state.rs +++ b/contracts/cron/src/state.rs @@ -1,4 +1,4 @@ use cw_storage_plus::Map; -pub const BEGIN_BLOCKER_SHEDULES: Map = Map::new("begin_blocker_shedules"); -pub const END_BLOCKER_SHEDULES: Map = Map::new("end_blocker_shedules"); +pub const BEGIN_BLOCKER_SCHEDULES: Map = Map::new("begin_blocker_shedules"); +pub const END_BLOCKER_SCHEDULES: Map = Map::new("end_blocker_shedules"); From b0119f7a22b04ba0e8abca2d5a485973e6c694c6 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:18:30 +0400 Subject: [PATCH 05/34] fix grpc_querier contract --- contracts/grpc_querier/Cargo.toml | 1 + contracts/grpc_querier/src/contract.rs | 37 +++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/contracts/grpc_querier/Cargo.toml b/contracts/grpc_querier/Cargo.toml index a0f76f1..bab6fa9 100644 --- a/contracts/grpc_querier/Cargo.toml +++ b/contracts/grpc_querier/Cargo.toml @@ -21,6 +21,7 @@ library = [] [dependencies] cosmwasm-std = { workspace = true } +neutron-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } serde = { workspace = true } diff --git a/contracts/grpc_querier/src/contract.rs b/contracts/grpc_querier/src/contract.rs index 5b22634..e68c462 100644 --- a/contracts/grpc_querier/src/contract.rs +++ b/contracts/grpc_querier/src/contract.rs @@ -4,18 +4,17 @@ use cosmwasm_std::{ QueryRequest, Response, StdError, StdResult, SystemResult, }; use std::str::from_utf8; - use crate::grpc; use cw2::set_contract_version; -use neutron_sdk::proto_types::{ - cosmos::{auth, bank}, - ibc::{ - applications::transfer, - core::{client, connection}, - }, - neutron::{feeburner, interchainqueries, interchaintxs}, - osmosis::tokenfactory, -}; +use neutron_std::types::cosmos::auth::v1beta1::AuthQuerier; +use neutron_std::types::cosmos::bank::v1beta1::BankQuerier; +use neutron_std::types::ibc::applications::transfer::v1::TransferQuerier; +use neutron_std::types::ibc::core::client::v1::ClientQuerier; +use neutron_std::types::ibc::core::connection::v1::ConnectionQuerier; +use neutron_std::types::neutron::feeburner::FeeburnerQuerier; +use neutron_std::types::neutron::interchainqueries::InterchainqueriesQuerier; +use neutron_std::types::neutron::interchaintxs::v1::InterchaintxsQuerier; +use neutron_std::types::osmosis::tokenfactory::v1beta1::TokenfactoryQuerier; use prost::Message; use serde_json_wasm::to_vec; @@ -44,15 +43,15 @@ pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: query: received msg: {:?}", msg).as_str()); - let bank_querier = bank::v1beta1::BankQuerier::new(&deps.querier); - let auth_querier = auth::v1beta1::AuthQuerier::new(&deps.querier); - let transfer_querier = transfer::v1::TransferQuerier::new(&deps.querier); - let client_querier = client::v1::ClientQuerier::new(&deps.querier); - let connection_querier = connection::v1::ConnectionQuerier::new(&deps.querier); - let tokenfactory_querier = tokenfactory::v1beta1::TokenfactoryQuerier::new(&deps.querier); - let interchaintxs_querier = interchaintxs::v1::InterchaintxsQuerier::new(&deps.querier); - let interchainqueries_querier = interchainqueries::InterchainqueriesQuerier::new(&deps.querier); - let feeburner_querier = feeburner::FeeburnerQuerier::new(&deps.querier); + let bank_querier = BankQuerier::new(&deps.querier); + let auth_querier = AuthQuerier::new(&deps.querier); + let transfer_querier = TransferQuerier::new(&deps.querier); + let client_querier = ClientQuerier::new(&deps.querier); + let connection_querier = ConnectionQuerier::new(&deps.querier); + let tokenfactory_querier = TokenfactoryQuerier::new(&deps.querier); + let interchaintxs_querier = InterchaintxsQuerier::new(&deps.querier); + let interchainqueries_querier = InterchainqueriesQuerier::new(&deps.querier); + let feeburner_querier = FeeburnerQuerier::new(&deps.querier); match msg { QueryMsg::BankBalance { address, denom } => { From 90c7ab6e9d517e1adccbf440c4e22603203354b3 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:18:41 +0400 Subject: [PATCH 06/34] fix ibc_transfer contract --- contracts/ibc_transfer/src/contract.rs | 6 ++---- contracts/ibc_transfer/src/state.rs | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/contracts/ibc_transfer/src/contract.rs b/contracts/ibc_transfer/src/contract.rs index d8ee8e4..cd817d4 100644 --- a/contracts/ibc_transfer/src/contract.rs +++ b/contracts/ibc_transfer/src/contract.rs @@ -4,9 +4,7 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; use neutron_sdk::interchain_txs::helpers::decode_message_response; -use neutron_sdk::proto_types::neutron::transfer::MsgTransferResponse; use neutron_sdk::{ - bindings::msg::{IbcFee, NeutronMsg}, sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, TransferSudoMsg}, }; use schemars::JsonSchema; @@ -79,7 +77,7 @@ pub fn execute( env: Env, _: MessageInfo, msg: ExecuteMsg, -) -> StdResult> { +) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -195,7 +193,7 @@ fn execute_set_fees( ack_fee: Uint128, timeout_fee: Uint128, denom: String, -) -> StdResult> { +) -> StdResult { let fee = IbcFee { recv_fee: get_fee_item(denom.clone(), recv_fee), ack_fee: get_fee_item(denom.clone(), ack_fee), diff --git a/contracts/ibc_transfer/src/state.rs b/contracts/ibc_transfer/src/state.rs index 74b1b60..1d442a9 100644 --- a/contracts/ibc_transfer/src/state.rs +++ b/contracts/ibc_transfer/src/state.rs @@ -1,6 +1,5 @@ use cosmwasm_std::{from_json, to_json_vec, Binary, StdResult, Storage}; use cw_storage_plus::{Item, Map}; -use neutron_sdk::bindings::msg::IbcFee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; From d7904f5ece583842aebffc5e02f3d5cecd17be77 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:39:13 +0400 Subject: [PATCH 07/34] redo ibc_transfer --- contracts/ibc_transfer/Cargo.toml | 1 + contracts/ibc_transfer/src/contract.rs | 45 ++++++++++++------- .../src/integration_tests_mock_handlers.rs | 4 +- contracts/ibc_transfer/src/state.rs | 3 +- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/contracts/ibc_transfer/Cargo.toml b/contracts/ibc_transfer/Cargo.toml index 6379685..2806e45 100644 --- a/contracts/ibc_transfer/Cargo.toml +++ b/contracts/ibc_transfer/Cargo.toml @@ -21,6 +21,7 @@ library = [] [dependencies] cosmwasm-std = { workspace = true } +neutron-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } serde = { workspace = true } diff --git a/contracts/ibc_transfer/src/contract.rs b/contracts/ibc_transfer/src/contract.rs index cd817d4..4fc1cea 100644 --- a/contracts/ibc_transfer/src/contract.rs +++ b/contracts/ibc_transfer/src/contract.rs @@ -7,9 +7,12 @@ use neutron_sdk::interchain_txs::helpers::decode_message_response; use neutron_sdk::{ sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, TransferSudoMsg}, }; +use neutron_std::types::neutron::feerefunder::Fee; +use neutron_std::types::neutron::transfer::{MsgTransfer, MsgTransferResponse}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; - +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; +use neutron_std::types::ibc::core::client::v1::Height; use crate::state::{ read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE, IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM, @@ -179,11 +182,15 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> StdResult { } } -fn get_fee_item(denom: String, amount: Uint128) -> Vec { +fn get_fee_item(denom: String, amount: Uint128) -> Vec { if amount == Uint128::new(0) { vec![] } else { - vec![coin(amount.u128(), denom)] + let coin = StdCoin { + amount: amount.to_string(), + denom + }; + vec![coin] } } @@ -194,7 +201,7 @@ fn execute_set_fees( timeout_fee: Uint128, denom: String, ) -> StdResult { - let fee = IbcFee { + let fee = Fee { recv_fee: get_fee_item(denom.clone(), recv_fee), ack_fee: get_fee_item(denom.clone(), ack_fee), timeout_fee: get_fee_item(denom, timeout_fee), @@ -213,25 +220,31 @@ fn execute_send( denom: String, amount: Uint128, timeout_height: Option, -) -> StdResult> { +) -> StdResult { let fee = IBC_FEE.load(deps.storage)?; - let coin1 = coin(amount.u128(), denom.clone()); - let msg1 = NeutronMsg::IbcTransfer { + let coin1 = StdCoin { + amount: amount.to_string(), + denom: denom.clone() + }; + let msg1 = MsgTransfer { source_port: "transfer".to_string(), source_channel: channel.clone(), sender: env.contract.address.to_string(), receiver: to.clone(), - token: coin1, - timeout_height: RequestPacketTimeoutHeight { - revision_number: Some(2), - revision_height: timeout_height.or(Some(DEFAULT_TIMEOUT_HEIGHT)), - }, + token: Some(coin1), + timeout_height: Some(Height { + revision_number: 2, + revision_height: timeout_height.unwrap_or(DEFAULT_TIMEOUT_HEIGHT), + }), timeout_timestamp: 0, - fee: fee.clone(), + fee: Some(fee.clone()), memo: "".to_string(), }; - let coin2 = coin(2 * amount.u128(), denom); - let msg2 = NeutronMsg::IbcTransfer { + let coin2 = StdCoin { + amount: (2 * amount).to_string(), + denom: denom.clone() + }; + let msg2 = MsgTransfer { source_port: "transfer".to_string(), source_channel: channel, sender: env.contract.address.to_string(), @@ -268,7 +281,7 @@ fn execute_send( Ok(Response::default().add_submessages(vec![submsg1, submsg2])) } -fn execute_resubmit_failure(_: DepsMut, failure_id: u64) -> StdResult> { +fn execute_resubmit_failure(_: DepsMut, failure_id: u64) -> StdResult { let msg = NeutronMsg::submit_resubmit_failure(failure_id); Ok(Response::default().add_message(msg)) } diff --git a/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs b/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs index c86490a..493908c 100644 --- a/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs +++ b/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs @@ -5,12 +5,12 @@ use neutron_sdk::bindings::msg::NeutronMsg; pub fn set_sudo_failure_mock( deps: DepsMut, state: IntegrationTestsSudoFailureMock, -) -> StdResult> { +) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK.save(deps.storage, &state)?; Ok(Response::default()) } -pub fn unset_sudo_failure_mock(deps: DepsMut) -> StdResult> { +pub fn unset_sudo_failure_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK .save(deps.storage, &IntegrationTestsSudoFailureMock::Disabled)?; Ok(Response::default()) diff --git a/contracts/ibc_transfer/src/state.rs b/contracts/ibc_transfer/src/state.rs index 1d442a9..1970e51 100644 --- a/contracts/ibc_transfer/src/state.rs +++ b/contracts/ibc_transfer/src/state.rs @@ -1,5 +1,6 @@ use cosmwasm_std::{from_json, to_json_vec, Binary, StdResult, Storage}; use cw_storage_plus::{Item, Map}; +use neutron_std::types::neutron::feerefunder::Fee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -9,7 +10,7 @@ pub const IBC_SUDO_ID_RANGE_START: u64 = 1_000_000_000; pub const IBC_SUDO_ID_RANGE_SIZE: u64 = 1_000; pub const IBC_SUDO_ID_RANGE_END: u64 = IBC_SUDO_ID_RANGE_START + IBC_SUDO_ID_RANGE_SIZE; -pub const IBC_FEE: Item = Item::new("ibc_fee"); +pub const IBC_FEE: Item = Item::new("ibc_fee"); pub const REPLY_QUEUE_ID: Map> = Map::new("reply_queue_id"); From e0d0c18c19dc9c9628ced6046c967a698d6cb6c7 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:39:18 +0400 Subject: [PATCH 08/34] use newer deps --- Cargo.lock | 15 ++------------- Cargo.toml | 1 - contracts/marketmap/src/contract.rs | 11 ++--------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 458ffa3..587e814 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,19 +312,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "client_updater" -version = "0.1.0" -dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", - "cw-storage-plus 2.0.0", - "cw2 2.0.0", - "neutron-sdk", - "schemars", - "serde", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -980,6 +967,7 @@ dependencies = [ "cosmwasm-std 2.1.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "schemars", "serde", @@ -1044,6 +1032,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", diff --git a/Cargo.toml b/Cargo.toml index c93c50b..85f9928 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ overflow-checks = true neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/clean-bindings" } neutron-std = { git = "https://github.com/neutron-org/neutron-std", rev = "cc49ece967353bcae7ad29ce04f75d2cc167b028" } - prost = "0.12.4" prost-types = "0.12.4" cosmos-sdk-proto = { version = "0.20.0", default-features = false } diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index 8598150..820ac5d 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -12,13 +12,6 @@ pub struct InstantiateMsg {} #[serde(rename_all = "snake_case")] pub enum ExecuteMsg {} -use neutron_sdk::bindings::marketmap::query::MarketResponse; -use neutron_sdk::bindings::{ - marketmap::query::{LastUpdatedResponse, MarketMapQuery, MarketMapResponse, ParamsResponse}, - msg::NeutronMsg, - query::NeutronQuery, -}; - const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -40,12 +33,12 @@ pub fn execute( _env: Env, _info: MessageInfo, _msg: ExecuteMsg, -) -> StdResult> { +) -> StdResult { Ok(Default::default()) } #[entry_point] -pub fn query(deps: Deps, env: Env, msg: MarketMapQuery) -> StdResult { +pub fn query(deps: Deps, env: Env, msg: MarketMapQuery) -> StdResult { query_marketmap(deps, env, msg) } From ed46b91e4e36fbba92d96665479bf0754142fa72 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:47:58 +0400 Subject: [PATCH 09/34] fix some interchain_queries contract errors --- Cargo.lock | 1 + .../neutron_interchain_queries/Cargo.toml | 1 + .../src/contract.rs | 117 ++++++++++-------- .../src/integration_tests_mock_handlers.rs | 4 +- .../neutron_interchain_queries/src/msg.rs | 4 +- 5 files changed, 69 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 587e814..cbd9dca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1202,6 +1202,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "schemars", "serde", diff --git a/contracts/neutron_interchain_queries/Cargo.toml b/contracts/neutron_interchain_queries/Cargo.toml index d3c2e85..53dc8e5 100644 --- a/contracts/neutron_interchain_queries/Cargo.toml +++ b/contracts/neutron_interchain_queries/Cargo.toml @@ -20,6 +20,7 @@ library = [] [dependencies] cosmwasm-std = { workspace = true, features = ["stargate", "staking"] } +neutron-std = { workspace = true } cw2 = { workspace = true } schemars = { workspace = true } serde = { workspace = true } diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index ca7619a..4644400 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -23,14 +23,8 @@ use crate::state::{ }; use cosmos_sdk_proto::cosmos::bank::v1beta1::MsgSend; use cosmos_sdk_proto::cosmos::tx::v1beta1::{TxBody, TxRaw}; -use cosmwasm_std::{ - entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, - StdResult, -}; +use cosmwasm_std::{entry_point, to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::NeutronMsg; -use neutron_sdk::bindings::query::{NeutronQuery, QueryRegisteredQueryResponse}; -use neutron_sdk::bindings::types::{Height, KVKey}; use neutron_sdk::interchain_queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, @@ -55,6 +49,7 @@ use neutron_sdk::interchain_queries::v047::register_queries::{ use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; +use neutron_sdk::bindings::types::Height; use prost::Message as ProstMessage; /// defines the incoming transfers limit to make a case of failed callback possible. @@ -78,32 +73,32 @@ pub fn instantiate( #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( - deps: DepsMut, + deps: DepsMut, env: Env, _: MessageInfo, msg: ExecuteMsg, -) -> NeutronResult> { +) -> NeutronResult { match msg { ExecuteMsg::RegisterBalancesQuery { connection_id, addr, denoms, update_period, - } => register_balances_query(connection_id, addr, denoms, update_period), + } => register_balances_query(env.contract.address, connection_id, addr, denoms, update_period), ExecuteMsg::RegisterBankTotalSupplyQuery { connection_id, denoms, update_period, - } => register_bank_total_supply_query(connection_id, denoms, update_period), + } => register_bank_total_supply_query(env.contract.address, connection_id, denoms, update_period), ExecuteMsg::RegisterDistributionFeePoolQuery { connection_id, update_period, - } => register_distribution_fee_pool_query(connection_id, update_period), + } => register_distribution_fee_pool_query(env.contract.address, connection_id, update_period), ExecuteMsg::RegisterGovernmentProposalsQuery { connection_id, proposals_ids, update_period, - } => register_gov_proposal_query(connection_id, proposals_ids, update_period), + } => register_gov_proposal_query(env.contract.address, connection_id, proposals_ids, update_period), ExecuteMsg::RegisterGovernmentProposalVotesQuery { connection_id, proposals_ids, @@ -111,6 +106,7 @@ pub fn execute( update_period, } => register_gov_proposal_votes_query( deps, + env.contract.address, connection_id, proposals_ids, voters, @@ -120,19 +116,20 @@ pub fn execute( connection_id, validators, update_period, - } => register_staking_validators_query(connection_id, validators, update_period), + } => register_staking_validators_query(env.contract.address, connection_id, validators, update_period), ExecuteMsg::RegisterDelegatorDelegationsQuery { connection_id, delegator, validators, update_period, - } => register_delegations_query(connection_id, delegator, validators, update_period), + } => register_delegations_query(env.contract.address, connection_id, delegator, validators, update_period), ExecuteMsg::RegisterDelegatorUnbondingDelegationsQuery { connection_id, delegator, validators, update_period, } => register_unbonding_delegations_query( + env.contract.address, connection_id, delegator, validators, @@ -142,7 +139,7 @@ pub fn execute( connection_id, validators, update_period, - } => register_validators_signing_infos_query(connection_id, validators, update_period), + } => register_validators_signing_infos_query(env.contract.address, connection_id, validators, update_period), ExecuteMsg::RegisterTransfersQuery { connection_id, recipients, @@ -171,56 +168,62 @@ pub fn execute( } pub fn register_balances_query( + contract: Addr, connection_id: String, addr: String, denoms: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_balances_query_msg(connection_id, addr, denoms, update_period)?; +) -> NeutronResult { + let msg = new_register_balances_query_msg(contract, connection_id, addr, denoms, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_bank_total_supply_query( + contract: Addr, connection_id: String, denoms: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_bank_total_supply_query_msg(connection_id, denoms, update_period)?; +) -> NeutronResult { + let msg = new_register_bank_total_supply_query_msg(contract, connection_id, denoms, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_distribution_fee_pool_query( + contract: Addr, connection_id: String, update_period: u64, -) -> NeutronResult> { - let msg = new_register_distribution_fee_pool_query_msg(connection_id, update_period)?; +) -> NeutronResult { + let msg = new_register_distribution_fee_pool_query_msg(contract, connection_id, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_gov_proposal_query( + contract: Addr, connection_id: String, proposals_ids: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_gov_proposals_query_msg(connection_id, proposals_ids, update_period)?; +) -> NeutronResult { + let msg = new_register_gov_proposals_query_msg(contract, connection_id, proposals_ids, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_gov_proposal_votes_query( - deps: DepsMut, + deps: DepsMut, + contract: Addr, connection_id: String, proposals_ids: Vec, voters: Vec, update_period: u64, -) -> NeutronResult> { +) -> NeutronResult { deps.api .debug("WASMDEBUG: register_gov_proposal_votes_query"); let msg = new_register_gov_proposals_voters_votes_query_msg( + contract, connection_id, proposals_ids, voters, @@ -231,22 +234,25 @@ pub fn register_gov_proposal_votes_query( } pub fn register_staking_validators_query( + contract: Addr, connection_id: String, validators: Vec, update_period: u64, -) -> NeutronResult> { - let msg = new_register_staking_validators_query_msg(connection_id, validators, update_period)?; +) -> NeutronResult { + let msg = new_register_staking_validators_query_msg(contract, connection_id, validators, update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_delegations_query( + contract: Addr, connection_id: String, delegator: String, validators: Vec, update_period: u64, -) -> NeutronResult> { +) -> NeutronResult { let msg = new_register_delegator_delegations_query_msg( + contract, connection_id, delegator, validators, @@ -257,12 +263,14 @@ pub fn register_delegations_query( } pub fn register_unbonding_delegations_query( + contract: Addr, connection_id: String, delegator: String, validators: Vec, update_period: u64, -) -> NeutronResult> { +) -> NeutronResult { let msg = new_register_delegator_unbonding_delegations_query_msg( + contract, connection_id, delegator, validators, @@ -273,12 +281,13 @@ pub fn register_unbonding_delegations_query( } pub fn register_validators_signing_infos_query( + contract: Addr, connection_id: String, validators: Vec, update_period: u64, -) -> NeutronResult> { +) -> NeutronResult { let msg = - new_register_validators_signing_infos_query_msg(connection_id, validators, update_period)?; + new_register_validators_signing_infos_query_msg(contract, connection_id, validators, update_period)?; Ok(Response::new().add_message(msg)) } @@ -288,7 +297,7 @@ pub fn register_transfers_query( recipients: Vec, update_period: u64, min_height: Option, -) -> NeutronResult> { +) -> NeutronResult { let mut query_data: Vec = recipients .into_iter() .map(|r| TransactionFilterItem { @@ -306,7 +315,7 @@ pub fn register_transfers_query( }) } - let msg = NeutronMsg::register_interchain_query( + let msg = register_interchain_query( QueryPayload::TX(query_data), connection_id, update_period, @@ -316,40 +325,40 @@ pub fn register_transfers_query( } pub fn register_query_empty_id( - _: DepsMut, + _: DepsMut, _: Env, connection_id: String, -) -> NeutronResult> { +) -> NeutronResult { let kv_key = KVKey { path: "test".to_string(), key: Binary::new(vec![]), }; let msg = - NeutronMsg::register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; Ok(Response::new().add_message(msg)) } pub fn register_query_empty_path( - _: DepsMut, + _: DepsMut, _: Env, connection_id: String, -) -> NeutronResult> { +) -> NeutronResult { let kv_key = KVKey { path: "".to_string(), key: Binary::new("test".as_bytes().to_vec()), }; let msg = - NeutronMsg::register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; Ok(Response::new().add_message(msg)) } pub fn register_query_empty_keys( - _: DepsMut, + _: DepsMut, _: Env, connection_id: String, -) -> NeutronResult> { - let msg = NeutronMsg::register_interchain_query(QueryPayload::KV(vec![]), connection_id, 10)?; +) -> NeutronResult { + let msg = register_interchain_query(QueryPayload::KV(vec![]), connection_id, 10)?; Ok(Response::new().add_message(msg)) } @@ -358,7 +367,7 @@ pub fn update_interchain_query( new_keys: Option>, new_update_period: Option, new_recipient: Option, -) -> NeutronResult> { +) -> NeutronResult { let new_filter = new_recipient.map(|recipient| { vec![TransactionFilterItem { field: RECIPIENT_FIELD.to_string(), @@ -368,17 +377,17 @@ pub fn update_interchain_query( }); let update_msg = - NeutronMsg::update_interchain_query(query_id, new_keys, new_update_period, new_filter)?; + update_interchain_query(query_id, new_keys, new_update_period, new_filter)?; Ok(Response::new().add_message(update_msg)) } -pub fn remove_interchain_query(query_id: u64) -> NeutronResult> { - let remove_msg = NeutronMsg::remove_interchain_query(query_id); +pub fn remove_interchain_query(query_id: u64) -> NeutronResult { + let remove_msg = remove_interchain_query(query_id); Ok(Response::new().add_message(remove_msg)) } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { match msg { //TODO: check if query.result.height is too old (for all interchain queries) QueryMsg::Balance { query_id } => Ok(to_json_binary(&query_balance(deps, env, query_id)?)?), @@ -415,7 +424,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult } } -fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { +fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { let txs = RECIPIENT_TXS .load(deps.storage, &recipient) .unwrap_or_default(); @@ -423,7 +432,7 @@ fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronRe } /// Returns the number of transfers made on remote chain and queried with ICQ -fn query_transfers_number(deps: Deps) -> NeutronResult { +fn query_transfers_number(deps: Deps) -> NeutronResult { let transfers_number = TRANSFERS.load(deps.storage).unwrap_or_default(); Ok(to_json_binary(&GetTransfersAmountResponse { transfers_number, @@ -431,7 +440,7 @@ fn query_transfers_number(deps: Deps) -> NeutronResult { } /// Returns block height of last KV query callback execution -pub fn query_kv_callback_stats(deps: Deps, query_id: u64) -> NeutronResult { +pub fn query_kv_callback_stats(deps: Deps, query_id: u64) -> NeutronResult { Ok(to_json_binary(&KvCallbackStatsResponse { last_update_height: KV_CALLBACK_STATS .may_load(deps.storage, query_id)? @@ -446,7 +455,7 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult, env: Env, msg: SudoMsg) -> NeutronResult { +pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { match msg { SudoMsg::TxQueryResult { query_id, @@ -461,7 +470,7 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResul /// sudo_check_tx_query_result is an example callback for transaction query results that stores the /// deposits received as a result on the registered query in the contract's state. pub fn sudo_tx_query_result( - deps: DepsMut, + deps: DepsMut, _env: Env, query_id: u64, _height: Height, @@ -587,7 +596,7 @@ fn check_deposits_size(deposits: &Vec) -> StdResult<()> { /// sudo_kv_query_result is the contract's callback for KV query results. Note that only the query /// id is provided, so you need to read the query result from the state. pub fn sudo_kv_query_result( - deps: DepsMut, + deps: DepsMut, env: Env, query_id: u64, ) -> NeutronResult { diff --git a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs index 6f1e690..47b546c 100644 --- a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs +++ b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs @@ -4,12 +4,12 @@ use neutron_sdk::bindings::msg::NeutronMsg; use neutron_sdk::bindings::query::NeutronQuery; use neutron_sdk::NeutronResult; -pub fn set_query_mock(deps: DepsMut) -> NeutronResult> { +pub fn set_query_mock(deps: DepsMut) -> NeutronResult { INTEGRATION_TESTS_QUERY_MOCK.save(deps.storage, &IntegrationTestsQueryMock::Enabled)?; Ok(Response::default()) } -pub fn unset_query_mock(deps: DepsMut) -> NeutronResult> { +pub fn unset_query_mock(deps: DepsMut) -> NeutronResult { INTEGRATION_TESTS_QUERY_MOCK.save(deps.storage, &IntegrationTestsQueryMock::Disabled)?; Ok(Response::default()) } diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index 311a181..ef413cd 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -1,5 +1,5 @@ +use neutron_std::types::neutron::interchainqueries::KvKey; use crate::state::Transfer; -use neutron_sdk::bindings::types::KVKey; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -65,7 +65,7 @@ pub enum ExecuteMsg { }, UpdateInterchainQuery { query_id: u64, - new_keys: Option>, + new_keys: Option>, new_update_period: Option, new_recipient: Option, }, From ab04311001a463d90820b089d343df6544e91d13 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 15:57:43 +0400 Subject: [PATCH 10/34] fix some problems with oracle, neutron_validator, neutron_interchain_txs --- Cargo.lock | 305 +++++++++--------- contracts/marketmap/src/contract.rs | 2 +- .../neutron_interchain_txs/src/contract.rs | 12 +- contracts/neutron_validator_test/Cargo.toml | 1 + .../neutron_validator_test/src/contract.rs | 99 +++--- .../neutron_validator_test/src/storage.rs | 3 +- contracts/oracle/Cargo.toml | 1 + contracts/oracle/src/contract.rs | 28 +- contracts/tokenfactory/src/contract.rs | 2 +- 9 files changed, 227 insertions(+), 226 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbd9dca..b9c9a4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,9 +33,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "ark-bls12-381" @@ -160,13 +160,13 @@ dependencies = [ [[package]] name = "astroport" -version = "5.4.0" -source = "git+https://github.com/astroport-fi/astroport-core#034ec4375ce50e34d9e9aff15d1f86d497b27b81" +version = "5.5.0" +source = "git+https://github.com/astroport-fi/astroport-core#b9566f26ed21c85904a866697fb3cc13e9096478" dependencies = [ "astroport-circular-buffer", "cosmos-sdk-proto 0.19.0", - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-asset", "cw-storage-plus 1.2.0", "cw-utils", @@ -179,27 +179,27 @@ dependencies = [ [[package]] name = "astroport-circular-buffer" version = "0.2.0" -source = "git+https://github.com/astroport-fi/astroport-core#034ec4375ce50e34d9e9aff15d1f86d497b27b81" +source = "git+https://github.com/astroport-fi/astroport-core#b9566f26ed21c85904a866697fb3cc13e9096478" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "thiserror", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "balance-tracker" version = "0.1.0" dependencies = [ "astroport", - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "cw2 1.1.2", "thiserror", @@ -245,8 +245,8 @@ checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" name = "before-send-hook-test" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "schemars", "serde", @@ -290,9 +290,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -342,15 +342,15 @@ dependencies = [ [[package]] name = "cosmwasm-core" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d075f6bb1483a6ce83b5cbc73a3a1207e0316ac1e34ed1f2a4d9fc3a0f07bf6" +checksum = "5f6ceb8624260d0d3a67c4e1a1d43fc7e9406720afbcb124521501dd138f90aa" [[package]] name = "cosmwasm-crypto" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f862b355f7e47711e0acfe6af92cb3fd8fd5936b66a9eaa338b51edabd1e77d" +checksum = "58535cbcd599b3c193e3967c8292fe1dbbb5de7c2a2d87380661091dd4744044" dependencies = [ "digest 0.10.7", "ed25519-zebra 3.1.0", @@ -361,9 +361,9 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ced5a6dd2801a383d3e14e5ae5caa7fdfeff1bd9f22b30e810e0aded8a5869" +checksum = "4125381e5fd7fefe9f614640049648088015eca2b60d861465329a5d87dfa538" dependencies = [ "ark-bls12-381", "ark-ec", @@ -384,31 +384,31 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd85de6467cd1073688c86b39833679ae6db18cf4771471edd9809f15f1679f1" +checksum = "a8e07de16c800ac82fd188d055ecdb923ead0cf33960d3350089260bb982c09f" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-derive" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd1873f84d9b17edf8a90ffe10a89a649b82feacc00e36788b81d2c3cbf03c" +checksum = "1b5658b1dc64e10b56ae7a449f678f96932a96f6cfad1769d608d1d1d656480a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "cosmwasm-schema" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4cd28147a66eba73720b47636a58097a979ad8c8bfdb4ed437ebcbfe362576" +checksum = "93d388adfa9cb449557a92e9318121ac1a481fc4f599213b03a5b62699b403b4" dependencies = [ - "cosmwasm-schema-derive 1.5.7", + "cosmwasm-schema-derive 1.5.8", "schemars", "serde", "serde_json", @@ -417,11 +417,11 @@ dependencies = [ [[package]] name = "cosmwasm-schema" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27984b137eb2ac561f97f6bdb02004a98eb6f2ba263062c140b8e231ee1826b7" +checksum = "f86b4d949b6041519c58993a73f4bbfba8083ba14f7001eae704865a09065845" dependencies = [ - "cosmwasm-schema-derive 2.1.0", + "cosmwasm-schema-derive 2.1.4", "schemars", "serde", "serde_json", @@ -430,9 +430,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9acd45c63d41bc9b16bc6dc7f6bd604a8c2ad29ce96c8f3c96d7fc8ef384392e" +checksum = "2411b389e56e6484f81ba955b758d02522d620c98fc960c4bd2251d48b7aa19f" dependencies = [ "proc-macro2", "quote", @@ -441,26 +441,26 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ef0d201f611bdb6c9124207032423eb956f1fc8ab3e3ee7253a9c08a5f5809" +checksum = "c8ef1b5835a65fcca3ab8b9a02b4f4dacc78e233a5c2f20b270efb9db0666d12" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "cosmwasm-std" -version = "1.5.7" +version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2685c2182624b2e9e17f7596192de49a3f86b7a0c9a5f6b25c1df5e24592e836" +checksum = "c21fde95ccd20044a23c0ac6fd8c941f3e8c158169dc94b5aa6491a2d9551a8d" dependencies = [ "base64 0.21.7", "bech32 0.9.1", "bnum 0.10.0", - "cosmwasm-crypto 1.5.7", - "cosmwasm-derive 1.5.7", + "cosmwasm-crypto 1.5.8", + "cosmwasm-derive 1.5.8", "derivative", "forward_ref", "hex", @@ -474,16 +474,16 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "2.1.0" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2522fb5c9a0409712bb1d036128bccf3564e6b2ac82f942ae4cf3c8df3e26fa8" +checksum = "70eb7ab0c1e99dd6207496963ba2a457c4128ac9ad9c72a83f8d9808542b849b" dependencies = [ "base64 0.22.1", "bech32 0.11.0", "bnum 0.11.0", "cosmwasm-core", - "cosmwasm-crypto 2.1.0", - "cosmwasm-derive 2.1.0", + "cosmwasm-crypto 2.1.4", + "cosmwasm-derive 2.1.4", "derive_more", "hex", "rand_core 0.6.4", @@ -497,9 +497,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -508,8 +508,8 @@ dependencies = [ name = "cron" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -607,7 +607,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -616,7 +616,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" dependencies = [ - "cosmwasm-std 1.5.7", + "cosmwasm-std 1.5.8", ] [[package]] @@ -625,8 +625,8 @@ version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c999a12f8cd8736f6f86e9a4ede5905530cb23cfdef946b9da1c506ad1b70799" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-address-like", "cw-storage-plus 1.2.0", "cw20", @@ -639,7 +639,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ - "cosmwasm-std 1.5.7", + "cosmwasm-std 1.5.8", "schemars", "serde", ] @@ -650,7 +650,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ - "cosmwasm-std 2.1.0", + "cosmwasm-std 2.1.4", "schemars", "serde", ] @@ -661,8 +661,8 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw2 1.1.2", "schemars", "semver", @@ -676,8 +676,8 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-storage-plus 1.2.0", "schemars", "semver", @@ -691,8 +691,8 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "schemars", "semver", @@ -706,8 +706,8 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" dependencies = [ - "cosmwasm-schema 1.5.7", - "cosmwasm-std 1.5.7", + "cosmwasm-schema 1.5.8", + "cosmwasm-std 1.5.8", "cw-utils", "schemars", "serde", @@ -745,22 +745,22 @@ dependencies = [ [[package]] name = "derive_more" -version = "1.0.0-beta.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7abbfc297053be59290e3152f8cbcd52c8642e0728b69ee187d991d4c1af08d" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "1.0.0-beta.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", "unicode-xid", ] @@ -769,8 +769,8 @@ name = "dex_grpc" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", "neutron-std", @@ -825,8 +825,8 @@ dependencies = [ name = "echo" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "schemars", "serde", ] @@ -872,9 +872,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -963,8 +963,8 @@ dependencies = [ name = "grpc_querier" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", "neutron-std", @@ -1027,8 +1027,8 @@ dependencies = [ name = "ibc_transfer" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -1064,9 +1064,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -1078,28 +1078,34 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "marketmap" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", "schemars", "serde", ] +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + [[package]] name = "msg_receiver" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -1111,8 +1117,8 @@ dependencies = [ name = "neutron-price-feed-mock" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "thiserror", @@ -1126,8 +1132,8 @@ dependencies = [ "bech32 0.9.1", "chrono", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "neutron-std", "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings)", "prost 0.12.6", @@ -1151,8 +1157,8 @@ dependencies = [ "bech32 0.9.1", "chrono", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028)", "prost 0.12.6", "prost-types 0.12.6", @@ -1197,8 +1203,8 @@ version = "0.1.0" dependencies = [ "base64 0.21.7", "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -1214,8 +1220,8 @@ name = "neutron_interchain_txs" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", @@ -1231,11 +1237,12 @@ name = "neutron_validators_test" version = "0.1.0" dependencies = [ "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -1288,9 +1295,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -1302,10 +1309,11 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" name = "oracle" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", ] @@ -1346,9 +1354,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "primeorder" @@ -1361,9 +1372,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -1411,7 +1422,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1454,9 +1465,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1520,8 +1531,8 @@ dependencies = [ name = "reflect" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", "schemars", @@ -1540,9 +1551,9 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] @@ -1580,7 +1591,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1605,9 +1616,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -1641,22 +1652,22 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1667,16 +1678,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1760,14 +1772,14 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "subtle-encoding" @@ -1791,9 +1803,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1838,22 +1850,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1889,8 +1901,8 @@ dependencies = [ name = "tokenfactory" version = "0.1.0" dependencies = [ - "cosmwasm-schema 2.1.0", - "cosmwasm-std 2.1.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", "neutron-sdk", "schemars", "serde", @@ -1916,21 +1928,21 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1944,6 +1956,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -1955,7 +1968,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] [[package]] @@ -1975,5 +1988,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.79", ] diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index 820ac5d..eee9e82 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -42,7 +42,7 @@ pub fn query(deps: Deps, env: Env, msg: MarketMapQuery) -> StdResult { query_marketmap(deps, env, msg) } -fn query_marketmap(deps: Deps, _env: Env, msg: MarketMapQuery) -> StdResult { +fn query_marketmap(deps: Deps, _env: Env, msg: MarketMapQuery) -> StdResult { match msg { MarketMapQuery::Params { .. } => { let query_response: ParamsResponse = deps.querier.query(&msg.into())?; diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 5efba78..e28e12b 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -191,7 +191,7 @@ pub fn execute( } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { match msg { QueryMsg::InterchainAccountAddress { interchain_account_id, @@ -210,7 +210,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult } pub fn query_interchain_address( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, connection_id: String, @@ -226,7 +226,7 @@ pub fn query_interchain_address( } pub fn query_interchain_address_contract( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, ) -> NeutronResult { @@ -238,7 +238,7 @@ pub fn query_interchain_address_contract( } pub fn query_acknowledgement_result( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, sequence_id: u64, @@ -248,7 +248,7 @@ pub fn query_acknowledgement_result( Ok(to_json_binary(&res)?) } -pub fn query_acknowledgement_results(deps: Deps) -> NeutronResult { +pub fn query_acknowledgement_results(deps: Deps) -> NeutronResult { let results: Vec = ACKNOWLEDGEMENT_RESULTS .range(deps.storage, None, None, cosmwasm_std::Order::Ascending) .take(100) @@ -264,7 +264,7 @@ pub fn query_acknowledgement_results(deps: Deps) -> NeutronResult< Ok(to_json_binary(&results)?) } -pub fn query_errors_queue(deps: Deps) -> NeutronResult { +pub fn query_errors_queue(deps: Deps) -> NeutronResult { let res = read_errors_from_queue(deps.storage)?; Ok(to_json_binary(&res)?) } diff --git a/contracts/neutron_validator_test/Cargo.toml b/contracts/neutron_validator_test/Cargo.toml index 60b7be8..db6436f 100644 --- a/contracts/neutron_validator_test/Cargo.toml +++ b/contracts/neutron_validator_test/Cargo.toml @@ -27,6 +27,7 @@ serde-json-wasm = { workspace = true } cw-storage-plus = { workspace = true } cosmos-sdk-proto = { workspace = true } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index fc1b9d8..bef6611 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -23,20 +23,12 @@ use cosmos_sdk_proto::{ }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; -use cosmwasm_std::{ - coin, to_json_binary, Binary, Coin as CosmosCoin, CosmosMsg, CustomQuery, Deps, DepsMut, Env, - MessageInfo, Reply, Response, StdError, StdResult, SubMsg, Uint128, -}; +use cosmwasm_std::{coin, to_json_binary, Addr, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult, SubMsg, Uint128}; use cw2::set_contract_version; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use neutron_sdk::bindings::msg::{ChannelOrdering, IbcFee, NeutronMsg}; -use neutron_sdk::bindings::query::{ - NeutronQuery, QueryInterchainAccountAddressResponse, QueryRegisteredQueryResponse, -}; -use neutron_sdk::bindings::types::{Height, ProtobufAny}; use neutron_sdk::interchain_queries::queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, @@ -48,15 +40,18 @@ use neutron_sdk::interchain_queries::v045::{ }; use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id}; use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; -use neutron_sdk::proto_types::neutron::interchaintxs::v1::MsgSubmitTxResponse; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; - +use neutron_sdk::bindings::msg::ChannelOrdering; +use neutron_std::types::ibc::applications::fee::v1::Fee; +use neutron_std::types::neutron::interchainqueries::{InterchainqueriesQuerier, QueryRegisteredQueryResponse, RegisteredQuery}; use crate::storage::{ read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, AcknowledgementResult, GetRecipientTxsResponse, SudoPayload, Transfer, ACKNOWLEDGEMENT_RESULTS, IBC_FEE, INTERCHAIN_ACCOUNTS, LAST_SEQ_ID, RECIPIENT_TXS, SUDO_PAYLOAD_REPLY_ID, }; +use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; +use neutron_std::types::neutron::interchaintxs::v1::MsgSubmitTxResponse; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -81,7 +76,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, _msg: InstantiateMsg, -) -> NeutronResult> { +) -> NeutronResult { deps.api.debug("WASMDEBUG: instantiate"); set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; Ok(Response::default()) @@ -93,7 +88,7 @@ pub fn execute( env: Env, _: MessageInfo, msg: ExecuteMsg, -) -> NeutronResult> { +) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -156,7 +151,7 @@ pub fn execute( } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult { match msg { QueryMsg::InterchainAccountAddress { interchain_account_id, @@ -176,23 +171,18 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult } pub fn query_interchain_address( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, connection_id: String, ) -> NeutronResult { - let query = NeutronQuery::InterchainAccountAddress { - owner_address: env.contract.address.to_string(), - interchain_account_id, - connection_id, - }; - - let res: QueryInterchainAccountAddressResponse = deps.querier.query(&query.into())?; + let querier = InterchainqueriesQuerier::new(deps.querier); + let res = querier.interchain_account_address(owner_address: env.contract.address.to_string(), interchain_account_id, connection_id) // TODO Ok(to_json_binary(&res)?) } pub fn query_interchain_address_contract( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, ) -> NeutronResult { @@ -204,7 +194,7 @@ pub fn query_interchain_address_contract( } pub fn query_acknowledgement_result( - deps: Deps, + deps: Deps, env: Env, interchain_account_id: String, sequence_id: u64, @@ -214,12 +204,12 @@ pub fn query_acknowledgement_result( Ok(to_json_binary(&res)?) } -pub fn query_last_ack_seq_id(deps: Deps) -> NeutronResult { +pub fn query_last_ack_seq_id(deps: Deps) -> NeutronResult { let res = LAST_SEQ_ID.may_load(deps.storage)?; Ok(to_json_binary(&res)?) } -fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { +fn query_recipient_txs(deps: Deps, recipient: String) -> NeutronResult { let txs = RECIPIENT_TXS .load(deps.storage, &recipient) .unwrap_or_default(); @@ -239,7 +229,7 @@ fn get_fee_item(denom: String, amount: Uint128) -> Vec { if amount == Uint128::new(0) { vec![] } else { - vec![coin(amount.u128(), denom)] + vec![CosmosCoin { amount: amount.to_string(), denom }] } } @@ -249,8 +239,8 @@ fn execute_set_fees( ack_fee: Uint128, timeout_fee: Uint128, denom: String, -) -> NeutronResult> { - let fee = IbcFee { +) -> NeutronResult { + let fee = Fee { recv_fee: get_fee_item(denom.clone(), recv_fee), ack_fee: get_fee_item(denom.clone(), ack_fee), timeout_fee: get_fee_item(denom, timeout_fee), @@ -266,8 +256,8 @@ fn execute_register_ica( env: Env, connection_id: String, interchain_account_id: String, -) -> NeutronResult> { - let register = NeutronMsg::register_interchain_account( +) -> NeutronResult { + let register = register_interchain_account( connection_id, interchain_account_id.clone(), None, @@ -286,7 +276,7 @@ fn execute_delegate( amount: Uint128, denom: String, timeout: Option, -) -> NeutronResult> { +) -> NeutronResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &interchain_account_id)?; let delegate_msg = MsgDelegate { @@ -306,12 +296,12 @@ fn execute_delegate( )))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgDelegate".to_string(), value: Binary::from(buf), }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( connection_id, interchain_account_id.clone(), vec![any_msg], @@ -343,7 +333,7 @@ fn execute_undelegate( amount: Uint128, denom: String, timeout: Option, -) -> NeutronResult> { +) -> NeutronResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &interchain_account_id)?; let delegate_msg = MsgUndelegate { @@ -364,12 +354,12 @@ fn execute_undelegate( )))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgUndelegate".to_string(), value: Binary::from(buf), }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( connection_id, interchain_account_id.clone(), vec![any_msg], @@ -391,7 +381,7 @@ fn execute_undelegate( Ok(Response::default().add_submessages(vec![submsg])) } -fn execute_clean_ack_results(deps: DepsMut) -> NeutronResult> { +fn execute_clean_ack_results(deps: DepsMut) -> NeutronResult { let keys: Vec> = ACKNOWLEDGEMENT_RESULTS .keys(deps.storage, None, None, cosmwasm_std::Order::Descending) .collect(); @@ -402,7 +392,7 @@ fn execute_clean_ack_results(deps: DepsMut) -> NeutronResult NeutronResult> { +fn execute_clean_recipient_txs(deps: DepsMut) -> NeutronResult { let keys: Vec> = RECIPIENT_TXS .keys(deps.storage, None, None, cosmwasm_std::Order::Descending) .collect(); @@ -413,35 +403,37 @@ fn execute_clean_recipient_txs(deps: DepsMut) -> NeutronResult NeutronResult> { - let msg = new_register_balances_query_msg(connection_id, addr, vec![denom], update_period)?; +) -> NeutronResult { + let msg = new_register_balances_query_msg(contract, connection_id, addr, vec![denom], update_period)?; Ok(Response::new().add_message(msg)) } pub fn register_transfers_query( + contract: Addr, connection_id: String, recipient: String, update_period: u64, min_height: Option, ) -> NeutronResult> { let msg = - new_register_transfers_query_msg(connection_id, recipient, update_period, min_height)?; + new_register_transfers_query_msg(contract, connection_id, recipient, update_period, min_height)?; Ok(Response::new().add_message(msg)) } -pub fn remove_interchain_query(query_id: u64) -> NeutronResult> { - let remove_msg = NeutronMsg::remove_interchain_query(query_id); +pub fn remove_interchain_query(contract: Addr, query_id: u64) -> NeutronResult { + let remove_msg = remove_interchain_query(contract, query_id)?; Ok(Response::new().add_message(remove_msg)) } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { +pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: sudo: received sudo msg: {:?}", msg).as_str()); match msg { @@ -471,7 +463,7 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResul } fn sudo_open_ack( - deps: DepsMut, + deps: DepsMut, _env: Env, port_id: String, _channel_id: String, @@ -497,7 +489,7 @@ fn sudo_open_ack( } pub fn sudo_tx_query_result( - deps: DepsMut, + deps: DepsMut, _env: Env, query_id: u64, _height: Height, @@ -508,9 +500,8 @@ pub fn sudo_tx_query_result( let body: TxBody = TxBody::decode(tx.body_bytes.as_slice())?; // Get the registered query by ID and retrieve the raw query string - let registered_query: QueryRegisteredQueryResponse = - get_registered_query(deps.as_ref(), query_id)?; - let transactions_filter = registered_query.registered_query.transactions_filter; + let registered_query: RegisteredQuery = get_registered_query(deps.as_ref(), query_id)?; + let transactions_filter = registered_query.transactions_filter; #[allow(clippy::match_single_binding)] // Depending of the query type, check the transaction data to see whether is satisfies @@ -518,7 +509,7 @@ pub fn sudo_tx_query_result( // all submitted results will be treated as valid. // // TODO: come up with solution to determine transactions filter type - match registered_query.registered_query.query_type { + match registered_query.query_type { _ => { // For transfer queries, query data looks like `[{"field:"transfer.recipient", "op":"eq", "value":"some_address"}]` let query_data: Vec = @@ -586,7 +577,7 @@ fn recipient_deposits_from_tx_body( } fn sudo_response( - deps: DepsMut, + deps: DepsMut, request: RequestPacket, data: Binary, ) -> NeutronResult { @@ -640,7 +631,7 @@ fn sudo_response( } fn sudo_timeout( - deps: DepsMut, + deps: DepsMut, _env: Env, request: RequestPacket, ) -> NeutronResult { @@ -672,7 +663,7 @@ fn sudo_timeout( } fn sudo_error( - deps: DepsMut, + deps: DepsMut, request: RequestPacket, details: String, ) -> NeutronResult { diff --git a/contracts/neutron_validator_test/src/storage.rs b/contracts/neutron_validator_test/src/storage.rs index cd3ca9c..8bbf37a 100644 --- a/contracts/neutron_validator_test/src/storage.rs +++ b/contracts/neutron_validator_test/src/storage.rs @@ -1,6 +1,7 @@ use cosmwasm_std::{from_json, to_json_vec, Binary, StdResult, Storage, Uint128}; use cw_storage_plus::{Item, Map}; use neutron_sdk::bindings::msg::IbcFee; +use neutron_std::types::ibc::applications::fee::v1::Fee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -14,7 +15,7 @@ pub struct SudoPayload { pub const SUDO_PAYLOAD_REPLY_ID: u64 = 1; -pub const IBC_FEE: Item = Item::new("ibc_fee"); +pub const IBC_FEE: Item = Item::new("ibc_fee"); pub const REPLY_ID_STORAGE: Item> = Item::new("reply_queue_id"); pub const SUDO_PAYLOAD: Map<(String, u64), Vec> = Map::new("sudo_payload"); pub const LAST_SEQ_ID: Item = Item::new("last_seq_id"); diff --git a/contracts/oracle/Cargo.toml b/contracts/oracle/Cargo.toml index 603ddc9..1e3e1ef 100644 --- a/contracts/oracle/Cargo.toml +++ b/contracts/oracle/Cargo.toml @@ -36,6 +36,7 @@ cw2 = { workspace = true } schemars = { workspace = true } serde = { version = "1.0.180", default-features = false, features = ["derive"] } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/oracle/src/contract.rs b/contracts/oracle/src/contract.rs index fd78e97..ed0d53a 100644 --- a/contracts/oracle/src/contract.rs +++ b/contracts/oracle/src/contract.rs @@ -2,6 +2,7 @@ use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; +use neutron_std::types::slinky::oracle::v1::OracleQuerier; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -12,14 +13,6 @@ pub struct InstantiateMsg {} #[serde(rename_all = "snake_case")] pub enum ExecuteMsg {} -use neutron_sdk::bindings::{ - msg::NeutronMsg, - oracle::query::{ - GetAllCurrencyPairsResponse, GetPriceResponse, GetPricesResponse, OracleQuery, - }, - query::NeutronQuery, -}; - const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -41,28 +34,29 @@ pub fn execute( _env: Env, _info: MessageInfo, _msg: ExecuteMsg, -) -> StdResult> { +) -> StdResult { Ok(Default::default()) } #[entry_point] -pub fn query(deps: Deps, env: Env, msg: OracleQuery) -> StdResult { +pub fn query(deps: Deps, env: Env, msg: OracleQuery) -> StdResult { query_oracle(deps, env, msg) } -fn query_oracle(deps: Deps, _env: Env, msg: OracleQuery) -> StdResult { +fn query_oracle(deps: Deps, _env: Env, msg: OracleQuery) -> StdResult { + let querier = OracleQuerier::new(&deps.querier); match msg { OracleQuery::GetPrice { .. } => { - let query_response: GetPriceResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + // let query_response: GetPriceResponse = deps.querier.query(&msg.into())?; + to_json_binary(&querier.get_price(&query_response)?) } OracleQuery::GetPrices { .. } => { - let query_response: GetPricesResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + // let query_response: GetPricesResponse = deps.querier.query(&msg.into())?; + to_json_binary(&querier.get_prices()) } OracleQuery::GetAllCurrencyPairs { .. } => { - let query_response: GetAllCurrencyPairsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + // let query_response: GetAllCurrencyPairsResponse = deps.querier.query(&msg.into())?; + to_json_binary(&querier.get_all_currency_pairs()) } } } diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 69bc940..aad7895 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -92,7 +92,7 @@ pub fn execute( } #[entry_point] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { Ok(match msg { QueryMsg::FullDenom { creator_addr, From 8faa2e0bc54af98d0bc991b5c62e3923a5cc217f Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 14 Oct 2024 16:21:04 +0400 Subject: [PATCH 11/34] fix some tokenfactory problems --- Cargo.lock | 1 + contracts/tokenfactory/Cargo.toml | 1 + contracts/tokenfactory/src/contract.rs | 119 +++++++++++++++++-------- contracts/tokenfactory/src/msg.rs | 5 +- 4 files changed, 86 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b9c9a4b..271a539 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1904,6 +1904,7 @@ dependencies = [ "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", "neutron-sdk", + "neutron-std", "schemars", "serde", ] diff --git a/contracts/tokenfactory/Cargo.toml b/contracts/tokenfactory/Cargo.toml index 7fe7cd6..e709cc5 100644 --- a/contracts/tokenfactory/Cargo.toml +++ b/contracts/tokenfactory/Cargo.toml @@ -23,6 +23,7 @@ cosmwasm-std = { workspace = true } serde = { workspace = true } schemars = { workspace = true } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index aad7895..445bca4 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -1,14 +1,10 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; -use cosmwasm_std::{ - coins, entry_point, to_json_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}, - NeutronResult, -}; +use cosmwasm_std::{coins, entry_point, to_json_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; +use neutron_sdk::NeutronError::Std; +use neutron_sdk::NeutronResult; +use neutron_std::types::cosmos::bank::v1beta1::Metadata; +use neutron_std::types::osmosis::tokenfactory::v1beta1::{MsgChangeAdmin, MsgCreateDenom, MsgMint, TokenfactoryQuerier, MsgBurn, MsgSetBeforeSendHook, MsgForceTransfer, MsgSetDenomMetadata}; +use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; #[entry_point] pub fn instantiate( @@ -24,34 +20,59 @@ pub fn instantiate( pub fn execute( _deps: DepsMut, env: Env, - _info: MessageInfo, + info: MessageInfo, msg: ExecuteMsg, -) -> StdResult> { - let msg: CosmosMsg = match msg { - ExecuteMsg::CreateDenom { subdenom } => NeutronMsg::submit_create_denom(subdenom).into(), +) -> StdResult { + let msg: CosmosMsg = match msg { + ExecuteMsg::CreateDenom { subdenom } => { + MsgCreateDenom{ + sender: env.contract.address.to_string(), + subdenom, + }.into() + }, ExecuteMsg::ChangeAdmin { denom, new_admin_address, - } => NeutronMsg::submit_change_admin(denom, new_admin_address).into(), + } => { + MsgChangeAdmin{ + sender: env.contract.address.to_string(), + denom, + new_admin: new_admin_address + }.into() + }, ExecuteMsg::MintTokens { denom, amount, mint_to_address, - } => NeutronMsg::submit_mint_tokens( - denom, - amount, - mint_to_address.unwrap_or(env.contract.address.into()), - ) - .into(), + } => { + MsgMint{ + sender: info.sender.to_string(), // FIXME + amount: Some(CosmosCoin{ denom, amount: amount.to_string() }), + mint_to_address: mint_to_address.unwrap_or(env.contract.address.into()), + } + .into() + }, ExecuteMsg::BurnTokens { denom, amount, burn_from_address, - } => NeutronMsg::submit_burn_tokens(denom, amount, burn_from_address).into(), + } => { + MsgBurn{ + sender: info.sender.to_string(), + amount: Some(CosmosCoin{ denom, amount: amount.to_string() }), + burn_from_address: burn_from_address.unwrap_or(env.contract.address.into()), + }.into() + }, ExecuteMsg::SetBeforeSendHook { denom, contract_addr, - } => NeutronMsg::submit_set_before_send_hook(denom, contract_addr).into(), + } => { + MsgSetBeforeSendHook{ + sender: info.sender.to_string(), + denom, + contract_addr + }.into() + }, ExecuteMsg::SendTokens { recipient, denom, @@ -66,7 +87,14 @@ pub fn execute( amount, from, to, - } => NeutronMsg::submit_force_transfer(denom, amount, from, to).into(), + } => { + MsgForceTransfer{ + sender: info.sender.to_string(), + amount: Some(CosmosCoin{ denom, amount: amount.to_string() }), + transfer_from_address: from, + transfer_to_address: to, + }.into() + }, ExecuteMsg::SetDenomMetadata { description, denom_units, @@ -76,31 +104,44 @@ pub fn execute( symbol, uri, uri_hash, - } => NeutronMsg::submit_set_denom_metadata( - description, - denom_units, - base, - display, - name, - symbol, - uri, - uri_hash, - ) - .into(), + } => { + MsgSetDenomMetadata{ + sender: info.sender.to_string(), + metadata: Some( + Metadata { + description, + denom_units, + base, + display, + name, + symbol, + uri, + uri_hash, + } + ) + }.into() + }, }; Ok(Response::new().add_message(msg)) } #[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { + let querier = TokenfactoryQuerier::new(&deps.querier); Ok(match msg { QueryMsg::FullDenom { creator_addr, subdenom, - } => to_json_binary(&query_full_denom(deps, creator_addr, subdenom)?)?, - QueryMsg::DenomAdmin { subdenom } => to_json_binary(&query_denom_admin(deps, subdenom)?)?, - QueryMsg::BeforeSendHook { denom } => { - to_json_binary(&query_before_send_hook(deps, denom)?)? + } => { + // TODO + to_json_binary(&query_full_denom(deps, creator_addr, subdenom)?)? + }, + QueryMsg::DenomAdmin { creator, subdenom } => { + let authority = querier.denom_authority_metadata(creator, subdenom)?; + to_json_binary(&authority.authority_metadata.ok_or(Std(StdError::generic_err("authority metadata not found")))?.admin?)? + }, + QueryMsg::BeforeSendHook { creator, denom } => { + to_json_binary(&querier.before_send_hook_address(creator, denom)?)? } }) } diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index 64da292..c4dcecc 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -1,4 +1,5 @@ -use cosmwasm_std::{DenomUnit, Uint128}; +use cosmwasm_std::Uint128; +use neutron_std::types::cosmos::bank::v1beta1::DenomUnit; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -60,9 +61,11 @@ pub enum QueryMsg { subdenom: String, }, DenomAdmin { + creator: String, subdenom: String, }, BeforeSendHook { + creator: String, denom: String, }, } From 6d7d7d2aa0d0804eeee1146592aa052da4184904 Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 13:00:18 +0400 Subject: [PATCH 12/34] fix oracle, tokenfactory, ibc_transfer contracts after changes --- Cargo.lock | 52 ++++++++++++++++--- Cargo.toml | 2 +- contracts/ibc_transfer/src/contract.rs | 10 ++-- .../neutron_validator_test/src/contract.rs | 10 ++-- contracts/oracle/src/contract.rs | 24 +++++---- contracts/oracle/src/lib.rs | 1 + contracts/oracle/src/msg.rs | 17 ++++++ contracts/tokenfactory/src/contract.rs | 14 ++--- 8 files changed, 95 insertions(+), 35 deletions(-) create mode 100644 contracts/oracle/src/msg.rs diff --git a/Cargo.lock b/Cargo.lock index 271a539..0dfbb25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -773,7 +773,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", "prost 0.12.6", "prost-types 0.12.6", "schemars", @@ -967,7 +967,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", "prost 0.12.6", "schemars", "serde", @@ -1032,7 +1032,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -1134,7 +1134,7 @@ dependencies = [ "cosmos-sdk-proto 0.20.0", "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028)", "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings)", "prost 0.12.6", "prost-types 0.12.6", @@ -1173,6 +1173,30 @@ dependencies = [ "thiserror", ] +[[package]] +name = "neutron-std" +version = "4.2.2-rc" +source = "git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c#f8168e5727bf8d397b144e700b9c22af40c9710c" +dependencies = [ + "bech32 0.9.1", + "chrono", + "cosmos-sdk-proto 0.20.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "prost 0.12.6", + "prost-types 0.12.6", + "protobuf", + "schemars", + "serde", + "serde-cw-value", + "serde-json-wasm 1.0.1", + "serde_json", + "speedate", + "tendermint-proto 0.34.1", + "thiserror", +] + [[package]] name = "neutron-std-derive" version = "0.20.1" @@ -1197,6 +1221,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "neutron-std-derive" +version = "0.20.1" +source = "git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c#f8168e5727bf8d397b144e700b9c22af40c9710c" +dependencies = [ + "itertools 0.10.5", + "proc-macro2", + "prost-types 0.12.6", + "quote", + "syn 1.0.109", +] + [[package]] name = "neutron_interchain_queries" version = "0.1.0" @@ -1208,7 +1244,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", "prost 0.12.6", "schemars", "serde", @@ -1242,7 +1278,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -1313,7 +1349,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", "schemars", "serde", ] @@ -1904,7 +1940,7 @@ dependencies = [ "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", "neutron-sdk", - "neutron-std", + "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", "schemars", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 85f9928..0d2ae38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ overflow-checks = true [workspace.dependencies] neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/clean-bindings" } -neutron-std = { git = "https://github.com/neutron-org/neutron-std", rev = "cc49ece967353bcae7ad29ce04f75d2cc167b028" } +neutron-std = { git = "https://github.com/neutron-org/neutron-std", rev = "f8168e5727bf8d397b144e700b9c22af40c9710c" } prost = "0.12.4" prost-types = "0.12.4" diff --git a/contracts/ibc_transfer/src/contract.rs b/contracts/ibc_transfer/src/contract.rs index 4fc1cea..f58990c 100644 --- a/contracts/ibc_transfer/src/contract.rs +++ b/contracts/ibc_transfer/src/contract.rs @@ -13,6 +13,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; use neutron_std::types::ibc::core::client::v1::Height; +use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; use crate::state::{ read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE, IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM, @@ -102,7 +103,7 @@ pub fn execute( denom, } => execute_set_fees(deps, recv_fee, ack_fee, timeout_fee, denom), - ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, failure_id), + ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, env, failure_id), // Used only in integration tests framework to simulate failures. // After executing this message, contract fail, all of this happening @@ -281,8 +282,11 @@ fn execute_send( Ok(Response::default().add_submessages(vec![submsg1, submsg2])) } -fn execute_resubmit_failure(_: DepsMut, failure_id: u64) -> StdResult { - let msg = NeutronMsg::submit_resubmit_failure(failure_id); +fn execute_resubmit_failure(deps: DepsMut, env: Env, failure_id: u64) -> StdResult { + let msg = MsgResubmitFailure{ + sender: env.contract.address.to_string(), + failure_id, + }.into(); Ok(Response::default().add_message(msg)) } diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index bef6611..85ebfb6 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -51,7 +51,7 @@ use crate::storage::{ IBC_FEE, INTERCHAIN_ACCOUNTS, LAST_SEQ_ID, RECIPIENT_TXS, SUDO_PAYLOAD_REPLY_ID, }; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; -use neutron_std::types::neutron::interchaintxs::v1::MsgSubmitTxResponse; +use neutron_std::types::neutron::interchaintxs::v1::{InterchaintxsQuerier, MsgSubmitTxResponse}; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -176,8 +176,8 @@ pub fn query_interchain_address( interchain_account_id: String, connection_id: String, ) -> NeutronResult { - let querier = InterchainqueriesQuerier::new(deps.querier); - let res = querier.interchain_account_address(owner_address: env.contract.address.to_string(), interchain_account_id, connection_id) // TODO + let querier = InterchaintxsQuerier::new(&deps.querier); + let res = querier.interchain_account_address(env.contract.address.to_string(), interchain_account_id, connection_id)?; Ok(to_json_binary(&res)?) } @@ -420,7 +420,7 @@ pub fn register_transfers_query( recipient: String, update_period: u64, min_height: Option, -) -> NeutronResult> { +) -> NeutronResult { let msg = new_register_transfers_query_msg(contract, connection_id, recipient, update_period, min_height)?; @@ -428,7 +428,7 @@ pub fn register_transfers_query( } pub fn remove_interchain_query(contract: Addr, query_id: u64) -> NeutronResult { - let remove_msg = remove_interchain_query(contract, query_id)?; + let remove_msg = remove_interchain_query_helper(contract, query_id)?; Ok(Response::new().add_message(remove_msg)) } diff --git a/contracts/oracle/src/contract.rs b/contracts/oracle/src/contract.rs index ed0d53a..72df65d 100644 --- a/contracts/oracle/src/contract.rs +++ b/contracts/oracle/src/contract.rs @@ -3,8 +3,10 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; use neutron_std::types::slinky::oracle::v1::OracleQuerier; +use neutron_std::types::slinky::types::v1::CurrencyPair; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use crate::msg::QueryMsg; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct InstantiateMsg {} @@ -39,24 +41,24 @@ pub fn execute( } #[entry_point] -pub fn query(deps: Deps, env: Env, msg: OracleQuery) -> StdResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { query_oracle(deps, env, msg) } -fn query_oracle(deps: Deps, _env: Env, msg: OracleQuery) -> StdResult { +fn query_oracle(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { let querier = OracleQuerier::new(&deps.querier); match msg { - OracleQuery::GetPrice { .. } => { - // let query_response: GetPriceResponse = deps.querier.query(&msg.into())?; - to_json_binary(&querier.get_price(&query_response)?) + QueryMsg::GetPrice { base, quote } => { + to_json_binary(&querier.get_price(Some(CurrencyPair{ + base, + quote, + }))?) } - OracleQuery::GetPrices { .. } => { - // let query_response: GetPricesResponse = deps.querier.query(&msg.into())?; - to_json_binary(&querier.get_prices()) + QueryMsg::GetPrices { currency_pair_ids } => { + to_json_binary(&querier.get_prices(currency_pair_ids)?) } - OracleQuery::GetAllCurrencyPairs { .. } => { - // let query_response: GetAllCurrencyPairsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&querier.get_all_currency_pairs()) + QueryMsg::GetAllCurrencyPairs { .. } => { + to_json_binary(&querier.get_all_currency_pairs()?) } } } diff --git a/contracts/oracle/src/lib.rs b/contracts/oracle/src/lib.rs index 2943dbb..37088ba 100644 --- a/contracts/oracle/src/lib.rs +++ b/contracts/oracle/src/lib.rs @@ -1 +1,2 @@ pub mod contract; +mod msg; diff --git a/contracts/oracle/src/msg.rs b/contracts/oracle/src/msg.rs new file mode 100644 index 0000000..8a72c68 --- /dev/null +++ b/contracts/oracle/src/msg.rs @@ -0,0 +1,17 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum QueryMsg { + GetPrice { + base: String, + quote: String, + }, + GetPrices { + currency_pair_ids: Vec, + }, + GetAllCurrencyPairs { + + }, +} \ No newline at end of file diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 445bca4..38644d1 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -25,8 +25,8 @@ pub fn execute( ) -> StdResult { let msg: CosmosMsg = match msg { ExecuteMsg::CreateDenom { subdenom } => { - MsgCreateDenom{ - sender: env.contract.address.to_string(), + MsgCreateDenom { + sender: info.sender.to_string(), subdenom, }.into() }, @@ -35,7 +35,7 @@ pub fn execute( new_admin_address, } => { MsgChangeAdmin{ - sender: env.contract.address.to_string(), + sender: info.sender.to_string(), denom, new_admin: new_admin_address }.into() @@ -46,7 +46,7 @@ pub fn execute( mint_to_address, } => { MsgMint{ - sender: info.sender.to_string(), // FIXME + sender: info.sender.to_string(), amount: Some(CosmosCoin{ denom, amount: amount.to_string() }), mint_to_address: mint_to_address.unwrap_or(env.contract.address.into()), } @@ -133,12 +133,12 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { creator_addr, subdenom, } => { - // TODO - to_json_binary(&query_full_denom(deps, creator_addr, subdenom)?)? + let res = &querier.full_denom(creator_addr, subdenom)?; + to_json_binary(res)? }, QueryMsg::DenomAdmin { creator, subdenom } => { let authority = querier.denom_authority_metadata(creator, subdenom)?; - to_json_binary(&authority.authority_metadata.ok_or(Std(StdError::generic_err("authority metadata not found")))?.admin?)? + to_json_binary(&authority.authority_metadata.ok_or(Std(StdError::generic_err("authority metadata not found")))?)? }, QueryMsg::BeforeSendHook { creator, denom } => { to_json_binary(&querier.before_send_hook_address(creator, denom)?)? From 584a4117d294d47ca82b14ff5135949f010d235a Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 14:36:42 +0400 Subject: [PATCH 13/34] fix interchain queries --- Cargo.lock | 62 ++++--------------- Cargo.toml | 2 +- .../src/contract.rs | 48 +++++++------- .../src/integration_tests_mock_handlers.rs | 2 - .../neutron_interchain_queries/src/msg.rs | 4 +- 5 files changed, 43 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0dfbb25..8dfc848 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -773,7 +773,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "schemars", @@ -967,7 +967,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "neutron-std", "prost 0.12.6", "schemars", "serde", @@ -1032,7 +1032,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -1127,14 +1127,14 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a097d934ce27531be3bb7368f5fac90268a52f22" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#716ae7cf4913b1cfea34d49a9d74f898b3b1c179" dependencies = [ "bech32 0.9.1", "chrono", "cosmos-sdk-proto 0.20.0", "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028)", + "neutron-std", "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings)", "prost 0.12.6", "prost-types 0.12.6", @@ -1152,14 +1152,14 @@ dependencies = [ [[package]] name = "neutron-std" version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028#cc49ece967353bcae7ad29ce04f75d2cc167b028" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#f8168e5727bf8d397b144e700b9c22af40c9710c" dependencies = [ "bech32 0.9.1", "chrono", "cosmos-sdk-proto 0.20.0", "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", - "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028)", + "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings)", "prost 0.12.6", "prost-types 0.12.6", "protobuf", @@ -1173,46 +1173,10 @@ dependencies = [ "thiserror", ] -[[package]] -name = "neutron-std" -version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c#f8168e5727bf8d397b144e700b9c22af40c9710c" -dependencies = [ - "bech32 0.9.1", - "chrono", - "cosmos-sdk-proto 0.20.0", - "cosmwasm-schema 2.1.4", - "cosmwasm-std 2.1.4", - "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", - "prost 0.12.6", - "prost-types 0.12.6", - "protobuf", - "schemars", - "serde", - "serde-cw-value", - "serde-json-wasm 1.0.1", - "serde_json", - "speedate", - "tendermint-proto 0.34.1", - "thiserror", -] - -[[package]] -name = "neutron-std-derive" -version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a097d934ce27531be3bb7368f5fac90268a52f22" -dependencies = [ - "itertools 0.10.5", - "proc-macro2", - "prost-types 0.12.6", - "quote", - "syn 1.0.109", -] - [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?rev=cc49ece967353bcae7ad29ce04f75d2cc167b028#cc49ece967353bcae7ad29ce04f75d2cc167b028" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#716ae7cf4913b1cfea34d49a9d74f898b3b1c179" dependencies = [ "itertools 0.10.5", "proc-macro2", @@ -1224,7 +1188,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c#f8168e5727bf8d397b144e700b9c22af40c9710c" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#f8168e5727bf8d397b144e700b9c22af40c9710c" dependencies = [ "itertools 0.10.5", "proc-macro2", @@ -1244,7 +1208,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "neutron-std", "prost 0.12.6", "schemars", "serde", @@ -1278,7 +1242,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "neutron-std", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -1349,7 +1313,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "neutron-std", "schemars", "serde", ] @@ -1940,7 +1904,7 @@ dependencies = [ "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", "neutron-sdk", - "neutron-std 4.2.2-rc (git+https://github.com/neutron-org/neutron-std?rev=f8168e5727bf8d397b144e700b9c22af40c9710c)", + "neutron-std", "schemars", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 0d2ae38..fe22cd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ overflow-checks = true [workspace.dependencies] neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/clean-bindings" } -neutron-std = { git = "https://github.com/neutron-org/neutron-std", rev = "f8168e5727bf8d397b144e700b9c22af40c9710c" } +neutron-std = { git = "https://github.com/neutron-org/neutron-std", branch = "feat/clean-bindings" } prost = "0.12.4" prost-types = "0.12.4" diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index 4644400..e325529 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -29,6 +29,7 @@ use neutron_sdk::interchain_queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; +use neutron_sdk::interchain_queries::helpers::register_interchain_query; use neutron_sdk::interchain_queries::v045::types::HEIGHT_FIELD; use neutron_sdk::interchain_queries::v047::queries::{ query_balance, query_bank_total, query_delegations, query_distribution_fee_pool, @@ -50,7 +51,9 @@ use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; use neutron_sdk::bindings::types::Height; +use neutron_std::types::neutron::interchainqueries::KvKey; use prost::Message as ProstMessage; +use neutron_sdk::interchain_queries::helpers::{update_interchain_query as helpers_update_interchain_query, remove_interchain_query as helpers_remove_interchain_query}; /// defines the incoming transfers limit to make a case of failed callback possible. const MAX_ALLOWED_TRANSFER: u64 = 20000; @@ -145,14 +148,14 @@ pub fn execute( recipients, update_period, min_height, - } => register_transfers_query(connection_id, recipients, update_period, min_height), + } => register_transfers_query(env.contract.address, connection_id, recipients, update_period, min_height), ExecuteMsg::UpdateInterchainQuery { query_id, new_keys, new_update_period, new_recipient, - } => update_interchain_query(query_id, new_keys, new_update_period, new_recipient), - ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(query_id), + } => update_interchain_query(env.contract.address, query_id, new_keys, new_update_period, new_recipient), + ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(env.contract.address, query_id), ExecuteMsg::IntegrationTestsSetQueryMock {} => set_query_mock(deps), ExecuteMsg::IntegrationTestsUnsetQueryMock {} => unset_query_mock(deps), ExecuteMsg::IntegrationTestsRegisterQueryEmptyId { connection_id } => { @@ -293,6 +296,7 @@ pub fn register_validators_signing_infos_query( } pub fn register_transfers_query( + contract: Addr, connection_id: String, recipients: Vec, update_period: u64, @@ -316,6 +320,7 @@ pub fn register_transfers_query( } let msg = register_interchain_query( + contract, QueryPayload::TX(query_data), connection_id, update_period, @@ -326,46 +331,47 @@ pub fn register_transfers_query( pub fn register_query_empty_id( _: DepsMut, - _: Env, + env: Env, connection_id: String, ) -> NeutronResult { - let kv_key = KVKey { + let kv_key = KvKey { path: "test".to_string(), - key: Binary::new(vec![]), + key: vec![], }; let msg = - register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + register_interchain_query(env.contract.address, QueryPayload::KV(vec![kv_key]), connection_id, 10)?; Ok(Response::new().add_message(msg)) } pub fn register_query_empty_path( _: DepsMut, - _: Env, + env: Env, connection_id: String, ) -> NeutronResult { - let kv_key = KVKey { + let kv_key = KvKey { path: "".to_string(), - key: Binary::new("test".as_bytes().to_vec()), + key: "test".as_bytes().to_vec(), }; let msg = - register_interchain_query(QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + register_interchain_query(env.contract.address, QueryPayload::KV(vec![kv_key]), connection_id, 10)?; Ok(Response::new().add_message(msg)) } pub fn register_query_empty_keys( _: DepsMut, - _: Env, + env: Env, connection_id: String, ) -> NeutronResult { - let msg = register_interchain_query(QueryPayload::KV(vec![]), connection_id, 10)?; + let msg = register_interchain_query(env.contract.address, QueryPayload::KV(vec![]), connection_id, 10)?; Ok(Response::new().add_message(msg)) } pub fn update_interchain_query( + contract: Addr, query_id: u64, - new_keys: Option>, - new_update_period: Option, + new_keys: Vec, + new_update_period: u64, new_recipient: Option, ) -> NeutronResult { let new_filter = new_recipient.map(|recipient| { @@ -377,12 +383,12 @@ pub fn update_interchain_query( }); let update_msg = - update_interchain_query(query_id, new_keys, new_update_period, new_filter)?; + helpers_update_interchain_query(contract, query_id, new_keys, new_update_period, new_filter)?; Ok(Response::new().add_message(update_msg)) } -pub fn remove_interchain_query(query_id: u64) -> NeutronResult { - let remove_msg = remove_interchain_query(query_id); +pub fn remove_interchain_query(contract: Addr, query_id: u64) -> NeutronResult { + let remove_msg = helpers_remove_interchain_query(contract, query_id)?; Ok(Response::new().add_message(remove_msg)) } @@ -487,9 +493,9 @@ pub fn sudo_tx_query_result( let body: TxBody = TxBody::decode(tx.body_bytes.as_slice())?; // Get the registered query by ID and retrieve the raw query string - let registered_query: QueryRegisteredQueryResponse = + let registered_query = get_registered_query(deps.as_ref(), query_id)?; - let transactions_filter = registered_query.registered_query.transactions_filter; + let transactions_filter = registered_query.transactions_filter; #[allow(clippy::match_single_binding)] // Depending of the query type, check the transaction data to see whether is satisfies @@ -497,7 +503,7 @@ pub fn sudo_tx_query_result( // all submitted results will be treated as valid. // // TODO: come up with solution to determine transactions filter type - match registered_query.registered_query.query_type { + match registered_query.query_type { _ => { // For transfer queries, query data looks like `[{"field:"transfer.recipient", "op":"eq", "value":"some_address"}]` let query_data: Vec = diff --git a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs index 47b546c..356cd6f 100644 --- a/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs +++ b/contracts/neutron_interchain_queries/src/integration_tests_mock_handlers.rs @@ -1,7 +1,5 @@ use crate::state::{IntegrationTestsQueryMock, INTEGRATION_TESTS_QUERY_MOCK}; use cosmwasm_std::{DepsMut, Response}; -use neutron_sdk::bindings::msg::NeutronMsg; -use neutron_sdk::bindings::query::NeutronQuery; use neutron_sdk::NeutronResult; pub fn set_query_mock(deps: DepsMut) -> NeutronResult { diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index ef413cd..dc069c9 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -65,8 +65,8 @@ pub enum ExecuteMsg { }, UpdateInterchainQuery { query_id: u64, - new_keys: Option>, - new_update_period: Option, + new_keys: Vec, + new_update_period: u64, new_recipient: Option, }, RemoveInterchainQuery { From f7f850c2a7f2bb1dec05fd6a3671946d26364c67 Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 15:28:08 +0400 Subject: [PATCH 14/34] fix marketmap queries --- Cargo.lock | 5 ++-- contracts/marketmap/Cargo.toml | 1 + contracts/marketmap/src/contract.rs | 27 +++++++++---------- contracts/marketmap/src/lib.rs | 1 + contracts/marketmap/src/query.rs | 14 ++++++++++ .../neutron_validator_test/src/contract.rs | 11 ++++---- 6 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 contracts/marketmap/src/query.rs diff --git a/Cargo.lock b/Cargo.lock index 8dfc848..9fb8b2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1090,6 +1090,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", ] @@ -1152,7 +1153,7 @@ dependencies = [ [[package]] name = "neutron-std" version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#f8168e5727bf8d397b144e700b9c22af40c9710c" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#1e61039a6c59bc58292029c00bf4f7758dc31b4f" dependencies = [ "bech32 0.9.1", "chrono", @@ -1188,7 +1189,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#f8168e5727bf8d397b144e700b9c22af40c9710c" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#1e61039a6c59bc58292029c00bf4f7758dc31b4f" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/marketmap/Cargo.toml b/contracts/marketmap/Cargo.toml index a18ca2d..9153ceb 100644 --- a/contracts/marketmap/Cargo.toml +++ b/contracts/marketmap/Cargo.toml @@ -36,6 +36,7 @@ cw2 = { workspace = true } schemars = { workspace = true } serde = { version = "1.0.180", default-features = false, features = ["derive"] } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index eee9e82..66e6f40 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -2,8 +2,10 @@ use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; +use neutron_std::types::slinky::marketmap::v1::MarketmapQuerier; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use crate::query::QueryMsg; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct InstantiateMsg {} @@ -38,27 +40,24 @@ pub fn execute( } #[entry_point] -pub fn query(deps: Deps, env: Env, msg: MarketMapQuery) -> StdResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { query_marketmap(deps, env, msg) } -fn query_marketmap(deps: Deps, _env: Env, msg: MarketMapQuery) -> StdResult { +fn query_marketmap(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + let querier = MarketmapQuerier::new(&deps.querier); match msg { - MarketMapQuery::Params { .. } => { - let query_response: ParamsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::Params { .. } => { + to_json_binary(&querier.params()?) } - MarketMapQuery::LastUpdated { .. } => { - let query_response: LastUpdatedResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::LastUpdated { .. } => { + to_json_binary(&querier.last_updated()?) } - MarketMapQuery::MarketMap { .. } => { - let query_response: MarketMapResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::MarketMap { .. } => { + to_json_binary(&querier.market_map()?) } - MarketMapQuery::Market { .. } => { - let query_response: MarketResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::Market { currency_pair } => { + to_json_binary(&querier.market(Some(currency_pair))?) } } } diff --git a/contracts/marketmap/src/lib.rs b/contracts/marketmap/src/lib.rs index 2943dbb..f43d2b3 100644 --- a/contracts/marketmap/src/lib.rs +++ b/contracts/marketmap/src/lib.rs @@ -1 +1,2 @@ pub mod contract; +mod query; diff --git a/contracts/marketmap/src/query.rs b/contracts/marketmap/src/query.rs new file mode 100644 index 0000000..0140fb0 --- /dev/null +++ b/contracts/marketmap/src/query.rs @@ -0,0 +1,14 @@ +use neutron_std::types::slinky::types::v1::CurrencyPair; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum QueryMsg { + Params { }, + LastUpdated { }, + MarketMap { }, + Market { + currency_pair: CurrencyPair, + }, +} \ No newline at end of file diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 85ebfb6..38def28 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -27,7 +27,6 @@ use cosmwasm_std::{coin, to_json_binary, Addr, Binary, CosmosMsg, CustomQuery, D use cw2::set_contract_version; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; - use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use neutron_sdk::interchain_queries::queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ @@ -38,7 +37,7 @@ use neutron_sdk::interchain_queries::v045::types::{COSMOS_SDK_TRANSFER_MSG_URL, use neutron_sdk::interchain_queries::v045::{ new_register_balances_query_msg, new_register_transfers_query_msg, }; -use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id}; +use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id, register_interchain_account}; use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; @@ -52,6 +51,7 @@ use crate::storage::{ }; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; use neutron_std::types::neutron::interchaintxs::v1::{InterchaintxsQuerier, MsgSubmitTxResponse}; +use neutron_sdk::interchain_queries::helpers::{update_interchain_query as helpers_update_interchain_query, remove_interchain_query as helpers_remove_interchain_query}; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -258,11 +258,12 @@ fn execute_register_ica( interchain_account_id: String, ) -> NeutronResult { let register = register_interchain_account( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), - None, + vec![], Some(ChannelOrdering::OrderOrdered), - ); + )?; let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; Ok(Response::new().add_message(register)) @@ -428,7 +429,7 @@ pub fn register_transfers_query( } pub fn remove_interchain_query(contract: Addr, query_id: u64) -> NeutronResult { - let remove_msg = remove_interchain_query_helper(contract, query_id)?; + let remove_msg = helpers_remove_interchain_query(contract, query_id)?; Ok(Response::new().add_message(remove_msg)) } From d5a5258fee857c4350eafd1438b3ca7ead27bb4a Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 15:36:22 +0400 Subject: [PATCH 15/34] update neutron-sdk --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9fb8b2f..bdb0864 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#716ae7cf4913b1cfea34d49a9d74f898b3b1c179" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a329bd96f9ed2d4d43fe01582f0e4d5a61820c67" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#716ae7cf4913b1cfea34d49a9d74f898b3b1c179" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a329bd96f9ed2d4d43fe01582f0e4d5a61820c67" dependencies = [ "itertools 0.10.5", "proc-macro2", From 31b5fcb7b4c39dba77e0bfb38deb86757bd1bd78 Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 16:15:58 +0400 Subject: [PATCH 16/34] fix all build errors left --- Cargo.lock | 5 +- contracts/dex_grpc/src/contract.rs | 6 +- contracts/dex_grpc/src/msg.rs | 5 +- contracts/grpc_querier/src/contract.rs | 12 +- contracts/grpc_querier/src/grpc.rs | 17 -- contracts/grpc_querier/src/lib.rs | 1 - contracts/ibc_transfer/src/contract.rs | 60 ++++--- .../src/integration_tests_mock_handlers.rs | 1 - contracts/marketmap/src/contract.rs | 18 +-- contracts/marketmap/src/query.rs | 12 +- contracts/msg_receiver/src/contract.rs | 12 +- .../src/contract.rs | 151 ++++++++++++++---- .../neutron_interchain_queries/src/msg.rs | 2 +- .../src/testing/mock_querier.rs | 9 +- .../src/testing/tests.rs | 4 +- contracts/neutron_interchain_txs/Cargo.toml | 1 + .../neutron_interchain_txs/src/contract.rs | 146 ++++++++--------- .../src/integration_tests_mock_handlers.rs | 9 +- .../neutron_interchain_txs/src/storage.rs | 9 +- .../src/testing/tests.rs | 3 +- .../neutron_validator_test/src/contract.rs | 104 +++++++----- .../neutron_validator_test/src/storage.rs | 3 +- contracts/oracle/src/contract.rs | 11 +- contracts/oracle/src/msg.rs | 15 +- contracts/reflect/src/contract.rs | 10 +- contracts/tokenfactory/src/contract.rs | 139 ++++++++-------- 26 files changed, 413 insertions(+), 352 deletions(-) delete mode 100644 contracts/grpc_querier/src/grpc.rs diff --git a/Cargo.lock b/Cargo.lock index bdb0864..2507365 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a329bd96f9ed2d4d43fe01582f0e4d5a61820c67" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4841d0231fae18e6ac39571e9b8b2b1bcf67faf9" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#a329bd96f9ed2d4d43fe01582f0e4d5a61820c67" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4841d0231fae18e6ac39571e9b8b2b1bcf67faf9" dependencies = [ "itertools 0.10.5", "proc-macro2", @@ -1226,6 +1226,7 @@ dependencies = [ "cw-storage-plus 2.0.0", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "prost 0.12.6", "prost-types 0.12.6", "schemars", diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index 82c8523..552d234 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -5,7 +5,10 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; use neutron_sdk::sudo::msg::SudoMsg; -use neutron_std::types::neutron::dex::{DexQuerier, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, MsgWithdrawFilledLimitOrder, MsgWithdrawal}; +use neutron_std::types::neutron::dex::{ + DexQuerier, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, + MsgWithdrawFilledLimitOrder, MsgWithdrawal, +}; const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -96,6 +99,7 @@ pub fn execute( order_type, expiration_time, max_amount_out, + min_average_sell_price: "".to_string(), // TODO })), ), ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => Ok(Response::new().add_message( diff --git a/contracts/dex_grpc/src/msg.rs b/contracts/dex_grpc/src/msg.rs index 5a156a4..27aafb5 100644 --- a/contracts/dex_grpc/src/msg.rs +++ b/contracts/dex_grpc/src/msg.rs @@ -1,6 +1,9 @@ use neutron_std::shim::Timestamp; use neutron_std::types::cosmos::base::query::v1beta1::PageRequest; -use neutron_std::types::neutron::dex::{DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute}; +use neutron_std::types::neutron::dex::{ + DepositOptions, MsgCancelLimitOrder, MsgDeposit, MsgMultiHopSwap, MsgPlaceLimitOrder, + MsgWithdrawFilledLimitOrder, MsgWithdrawal, MultiHopRoute, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/contracts/grpc_querier/src/contract.rs b/contracts/grpc_querier/src/contract.rs index e68c462..6ef3da6 100644 --- a/contracts/grpc_querier/src/contract.rs +++ b/contracts/grpc_querier/src/contract.rs @@ -3,20 +3,20 @@ use cosmwasm_std::{ entry_point, to_json_binary, Binary, ContractResult, Deps, DepsMut, Empty, Env, MessageInfo, QueryRequest, Response, StdError, StdResult, SystemResult, }; -use std::str::from_utf8; -use crate::grpc; use cw2::set_contract_version; use neutron_std::types::cosmos::auth::v1beta1::AuthQuerier; use neutron_std::types::cosmos::bank::v1beta1::BankQuerier; use neutron_std::types::ibc::applications::transfer::v1::TransferQuerier; use neutron_std::types::ibc::core::client::v1::ClientQuerier; use neutron_std::types::ibc::core::connection::v1::ConnectionQuerier; +use neutron_std::types::neutron::contractmanager::QueryFailuresRequest; use neutron_std::types::neutron::feeburner::FeeburnerQuerier; use neutron_std::types::neutron::interchainqueries::InterchainqueriesQuerier; use neutron_std::types::neutron::interchaintxs::v1::InterchaintxsQuerier; use neutron_std::types::osmosis::tokenfactory::v1beta1::TokenfactoryQuerier; use prost::Message; use serde_json_wasm::to_vec; +use std::str::from_utf8; const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -137,7 +137,10 @@ pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> StdResult { // Can be refactored after https://hadronlabs.atlassian.net/browse/NTRN-359 is done fn query_contractmanager_query_address_failures(deps: Deps, address: String) -> StdResult { - let msg = grpc::contractmanager::QueryAddressFailuresRequest { address }; + let msg = QueryFailuresRequest { + address, + pagination: None, + }; let mut bytes = Vec::new(); Message::encode(&msg, &mut bytes).map_err(|_| StdError::generic_err("cannot encode proto"))?; @@ -150,9 +153,8 @@ fn query_contractmanager_query_address_failures(deps: Deps, address: String) -> to_json_binary(&resp) } -// Can be refactored after https://hadronlabs.atlassian.net/browse/NTRN-359 is done fn query_contractmanager_query_failures(deps: Deps, address: String) -> StdResult { - let msg = grpc::contractmanager::QueryFailuresRequest { + let msg = QueryFailuresRequest { address, pagination: None, }; diff --git a/contracts/grpc_querier/src/grpc.rs b/contracts/grpc_querier/src/grpc.rs deleted file mode 100644 index 647311e..0000000 --- a/contracts/grpc_querier/src/grpc.rs +++ /dev/null @@ -1,17 +0,0 @@ -pub mod contractmanager { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryAddressFailuresRequest { - #[prost(string, tag = "1")] - pub address: ::prost::alloc::string::String, - } - - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QueryFailuresRequest { - #[prost(string, tag = "1")] - pub address: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub pagination: ::core::option::Option< - ::neutron_sdk::proto_types::cosmos::base::query::v1beta1::PageRequest, - >, - } -} diff --git a/contracts/grpc_querier/src/lib.rs b/contracts/grpc_querier/src/lib.rs index 98ab7aa..c7a7772 100644 --- a/contracts/grpc_querier/src/lib.rs +++ b/contracts/grpc_querier/src/lib.rs @@ -15,5 +15,4 @@ #![warn(clippy::unwrap_used, clippy::expect_used)] pub mod contract; -mod grpc; pub mod msg; diff --git a/contracts/ibc_transfer/src/contract.rs b/contracts/ibc_transfer/src/contract.rs index f58990c..4be0dc9 100644 --- a/contracts/ibc_transfer/src/contract.rs +++ b/contracts/ibc_transfer/src/contract.rs @@ -1,23 +1,21 @@ +use crate::state::{ + read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE, + IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM, +}; use cosmwasm_std::{ - coin, entry_point, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, - StdError, StdResult, SubMsg, Uint128, + entry_point, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, + StdResult, SubMsg, Uint128, }; use cw2::set_contract_version; use neutron_sdk::interchain_txs::helpers::decode_message_response; -use neutron_sdk::{ - sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, TransferSudoMsg}, -}; +use neutron_sdk::sudo::msg::{RequestPacket, TransferSudoMsg}; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; +use neutron_std::types::ibc::core::client::v1::Height; +use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; use neutron_std::types::neutron::feerefunder::Fee; use neutron_std::types::neutron::transfer::{MsgTransfer, MsgTransferResponse}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; -use neutron_std::types::ibc::core::client::v1::Height; -use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; -use crate::state::{ - read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, IBC_FEE, - IBC_SUDO_ID_RANGE_END, IBC_SUDO_ID_RANGE_START, TEST_COUNTER_ITEM, -}; use crate::{ integration_tests_mock_handlers::{set_sudo_failure_mock, unset_sudo_failure_mock}, @@ -76,12 +74,7 @@ pub enum ExecuteMsg { } #[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - _: MessageInfo, - msg: ExecuteMsg, -) -> StdResult { +pub fn execute(deps: DepsMut, env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -103,7 +96,9 @@ pub fn execute( denom, } => execute_set_fees(deps, recv_fee, ack_fee, timeout_fee, denom), - ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, env, failure_id), + ExecuteMsg::ResubmitFailure { failure_id } => { + execute_resubmit_failure(deps, env, failure_id) + } // Used only in integration tests framework to simulate failures. // After executing this message, contract fail, all of this happening @@ -189,7 +184,7 @@ fn get_fee_item(denom: String, amount: Uint128) -> Vec { } else { let coin = StdCoin { amount: amount.to_string(), - denom + denom, }; vec![coin] } @@ -225,7 +220,7 @@ fn execute_send( let fee = IBC_FEE.load(deps.storage)?; let coin1 = StdCoin { amount: amount.to_string(), - denom: denom.clone() + denom: denom.clone(), }; let msg1 = MsgTransfer { source_port: "transfer".to_string(), @@ -242,21 +237,21 @@ fn execute_send( memo: "".to_string(), }; let coin2 = StdCoin { - amount: (2 * amount).to_string(), - denom: denom.clone() + amount: (amount * Uint128::new(2)).to_string(), + denom: denom.clone(), }; let msg2 = MsgTransfer { source_port: "transfer".to_string(), source_channel: channel, sender: env.contract.address.to_string(), receiver: to, - token: coin2, - timeout_height: RequestPacketTimeoutHeight { - revision_number: Some(2), - revision_height: timeout_height.or(Some(DEFAULT_TIMEOUT_HEIGHT)), - }, + token: Some(coin2), + timeout_height: Some(Height { + revision_number: 2, + revision_height: timeout_height.unwrap_or(DEFAULT_TIMEOUT_HEIGHT), + }), timeout_timestamp: 0, - fee, + fee: Some(fee), memo: "".to_string(), }; let submsg1 = msg_with_sudo_callback( @@ -282,11 +277,12 @@ fn execute_send( Ok(Response::default().add_submessages(vec![submsg1, submsg2])) } -fn execute_resubmit_failure(deps: DepsMut, env: Env, failure_id: u64) -> StdResult { - let msg = MsgResubmitFailure{ +fn execute_resubmit_failure(_: DepsMut, env: Env, failure_id: u64) -> StdResult { + let msg: CosmosMsg = MsgResubmitFailure { sender: env.contract.address.to_string(), failure_id, - }.into(); + } + .into(); Ok(Response::default().add_message(msg)) } diff --git a/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs b/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs index 493908c..be10ff6 100644 --- a/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs +++ b/contracts/ibc_transfer/src/integration_tests_mock_handlers.rs @@ -1,6 +1,5 @@ use crate::state::{IntegrationTestsSudoFailureMock, INTEGRATION_TESTS_SUDO_FAILURE_MOCK}; use cosmwasm_std::{DepsMut, Response, StdResult}; -use neutron_sdk::bindings::msg::NeutronMsg; pub fn set_sudo_failure_mock( deps: DepsMut, diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index 66e6f40..5ce50c2 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -1,3 +1,4 @@ +use crate::query::QueryMsg; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; @@ -5,7 +6,6 @@ use cw2::set_contract_version; use neutron_std::types::slinky::marketmap::v1::MarketmapQuerier; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::query::QueryMsg; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct InstantiateMsg {} @@ -47,17 +47,9 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { fn query_marketmap(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { let querier = MarketmapQuerier::new(&deps.querier); match msg { - QueryMsg::Params { .. } => { - to_json_binary(&querier.params()?) - } - QueryMsg::LastUpdated { .. } => { - to_json_binary(&querier.last_updated()?) - } - QueryMsg::MarketMap { .. } => { - to_json_binary(&querier.market_map()?) - } - QueryMsg::Market { currency_pair } => { - to_json_binary(&querier.market(Some(currency_pair))?) - } + QueryMsg::Params { .. } => to_json_binary(&querier.params()?), + QueryMsg::LastUpdated { .. } => to_json_binary(&querier.last_updated()?), + QueryMsg::MarketMap { .. } => to_json_binary(&querier.market_map()?), + QueryMsg::Market { currency_pair } => to_json_binary(&querier.market(Some(currency_pair))?), } } diff --git a/contracts/marketmap/src/query.rs b/contracts/marketmap/src/query.rs index 0140fb0..2f6ea25 100644 --- a/contracts/marketmap/src/query.rs +++ b/contracts/marketmap/src/query.rs @@ -5,10 +5,8 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - Params { }, - LastUpdated { }, - MarketMap { }, - Market { - currency_pair: CurrencyPair, - }, -} \ No newline at end of file + Params {}, + LastUpdated {}, + MarketMap {}, + Market { currency_pair: CurrencyPair }, +} diff --git a/contracts/msg_receiver/src/contract.rs b/contracts/msg_receiver/src/contract.rs index 6ee543e..dc7c36f 100644 --- a/contracts/msg_receiver/src/contract.rs +++ b/contracts/msg_receiver/src/contract.rs @@ -5,7 +5,6 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::NeutronMsg; use crate::state::TEST_ARGS; @@ -25,12 +24,7 @@ pub fn instantiate( } #[entry_point] -pub fn execute( - deps: DepsMut, - _: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, _: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -55,7 +49,7 @@ fn execute_test_arg( info: MessageInfo, return_err: bool, arg: String, -) -> StdResult> { +) -> StdResult { if return_err { return Err(StdError::generic_err("return error")); } @@ -76,7 +70,7 @@ fn execute_test_arg( Ok(Response::default().add_attribute("arg", arg)) } -fn execute_call_staking(deps: DepsMut) -> StdResult> { +fn execute_call_staking(deps: DepsMut) -> StdResult { deps.querier.query_bonded_denom()?; // should fail since Neutron does not have staking module Ok(Response::default()) } diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index e325529..8c4656d 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -23,13 +23,20 @@ use crate::state::{ }; use cosmos_sdk_proto::cosmos::bank::v1beta1::MsgSend; use cosmos_sdk_proto::cosmos::tx::v1beta1::{TxBody, TxRaw}; -use cosmwasm_std::{entry_point, to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; +use cosmwasm_std::{ + entry_point, to_json_binary, Addr, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, + StdResult, +}; use cw2::set_contract_version; use neutron_sdk::interchain_queries::get_registered_query; +use neutron_sdk::interchain_queries::helpers::register_interchain_query; +use neutron_sdk::interchain_queries::helpers::{ + remove_interchain_query as helpers_remove_interchain_query, + update_interchain_query as helpers_update_interchain_query, +}; use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; -use neutron_sdk::interchain_queries::helpers::register_interchain_query; use neutron_sdk::interchain_queries::v045::types::HEIGHT_FIELD; use neutron_sdk::interchain_queries::v047::queries::{ query_balance, query_bank_total, query_delegations, query_distribution_fee_pool, @@ -50,10 +57,9 @@ use neutron_sdk::interchain_queries::v047::register_queries::{ use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; -use neutron_sdk::bindings::types::Height; +use neutron_std::types::ibc::core::client::v1::Height; use neutron_std::types::neutron::interchainqueries::KvKey; use prost::Message as ProstMessage; -use neutron_sdk::interchain_queries::helpers::{update_interchain_query as helpers_update_interchain_query, remove_interchain_query as helpers_remove_interchain_query}; /// defines the incoming transfers limit to make a case of failed callback possible. const MAX_ALLOWED_TRANSFER: u64 = 20000; @@ -87,21 +93,39 @@ pub fn execute( addr, denoms, update_period, - } => register_balances_query(env.contract.address, connection_id, addr, denoms, update_period), + } => register_balances_query( + env.contract.address, + connection_id, + addr, + denoms, + update_period, + ), ExecuteMsg::RegisterBankTotalSupplyQuery { connection_id, denoms, update_period, - } => register_bank_total_supply_query(env.contract.address, connection_id, denoms, update_period), + } => register_bank_total_supply_query( + env.contract.address, + connection_id, + denoms, + update_period, + ), ExecuteMsg::RegisterDistributionFeePoolQuery { connection_id, update_period, - } => register_distribution_fee_pool_query(env.contract.address, connection_id, update_period), + } => { + register_distribution_fee_pool_query(env.contract.address, connection_id, update_period) + } ExecuteMsg::RegisterGovernmentProposalsQuery { connection_id, proposals_ids, update_period, - } => register_gov_proposal_query(env.contract.address, connection_id, proposals_ids, update_period), + } => register_gov_proposal_query( + env.contract.address, + connection_id, + proposals_ids, + update_period, + ), ExecuteMsg::RegisterGovernmentProposalVotesQuery { connection_id, proposals_ids, @@ -119,13 +143,24 @@ pub fn execute( connection_id, validators, update_period, - } => register_staking_validators_query(env.contract.address, connection_id, validators, update_period), + } => register_staking_validators_query( + env.contract.address, + connection_id, + validators, + update_period, + ), ExecuteMsg::RegisterDelegatorDelegationsQuery { connection_id, delegator, validators, update_period, - } => register_delegations_query(env.contract.address, connection_id, delegator, validators, update_period), + } => register_delegations_query( + env.contract.address, + connection_id, + delegator, + validators, + update_period, + ), ExecuteMsg::RegisterDelegatorUnbondingDelegationsQuery { connection_id, delegator, @@ -142,20 +177,39 @@ pub fn execute( connection_id, validators, update_period, - } => register_validators_signing_infos_query(env.contract.address, connection_id, validators, update_period), + } => register_validators_signing_infos_query( + env.contract.address, + connection_id, + validators, + update_period, + ), ExecuteMsg::RegisterTransfersQuery { connection_id, recipients, update_period, min_height, - } => register_transfers_query(env.contract.address, connection_id, recipients, update_period, min_height), + } => register_transfers_query( + env.contract.address, + connection_id, + recipients, + update_period, + min_height, + ), ExecuteMsg::UpdateInterchainQuery { query_id, new_keys, new_update_period, new_recipient, - } => update_interchain_query(env.contract.address, query_id, new_keys, new_update_period, new_recipient), - ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(env.contract.address, query_id), + } => update_interchain_query( + env.contract.address, + query_id, + new_keys, + new_update_period, + new_recipient, + ), + ExecuteMsg::RemoveInterchainQuery { query_id } => { + remove_interchain_query(env.contract.address, query_id) + } ExecuteMsg::IntegrationTestsSetQueryMock {} => set_query_mock(deps), ExecuteMsg::IntegrationTestsUnsetQueryMock {} => unset_query_mock(deps), ExecuteMsg::IntegrationTestsRegisterQueryEmptyId { connection_id } => { @@ -177,7 +231,8 @@ pub fn register_balances_query( denoms: Vec, update_period: u64, ) -> NeutronResult { - let msg = new_register_balances_query_msg(contract, connection_id, addr, denoms, update_period)?; + let msg = + new_register_balances_query_msg(contract, connection_id, addr, denoms, update_period)?; Ok(Response::new().add_message(msg)) } @@ -188,7 +243,8 @@ pub fn register_bank_total_supply_query( denoms: Vec, update_period: u64, ) -> NeutronResult { - let msg = new_register_bank_total_supply_query_msg(contract, connection_id, denoms, update_period)?; + let msg = + new_register_bank_total_supply_query_msg(contract, connection_id, denoms, update_period)?; Ok(Response::new().add_message(msg)) } @@ -209,7 +265,12 @@ pub fn register_gov_proposal_query( proposals_ids: Vec, update_period: u64, ) -> NeutronResult { - let msg = new_register_gov_proposals_query_msg(contract, connection_id, proposals_ids, update_period)?; + let msg = new_register_gov_proposals_query_msg( + contract, + connection_id, + proposals_ids, + update_period, + )?; Ok(Response::new().add_message(msg)) } @@ -242,7 +303,12 @@ pub fn register_staking_validators_query( validators: Vec, update_period: u64, ) -> NeutronResult { - let msg = new_register_staking_validators_query_msg(contract, connection_id, validators, update_period)?; + let msg = new_register_staking_validators_query_msg( + contract, + connection_id, + validators, + update_period, + )?; Ok(Response::new().add_message(msg)) } @@ -289,8 +355,12 @@ pub fn register_validators_signing_infos_query( validators: Vec, update_period: u64, ) -> NeutronResult { - let msg = - new_register_validators_signing_infos_query_msg(contract, connection_id, validators, update_period)?; + let msg = new_register_validators_signing_infos_query_msg( + contract, + connection_id, + validators, + update_period, + )?; Ok(Response::new().add_message(msg)) } @@ -338,8 +408,12 @@ pub fn register_query_empty_id( path: "test".to_string(), key: vec![], }; - let msg = - register_interchain_query(env.contract.address, QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + let msg = register_interchain_query( + env.contract.address, + QueryPayload::KV(vec![kv_key]), + connection_id, + 10, + )?; Ok(Response::new().add_message(msg)) } @@ -353,8 +427,12 @@ pub fn register_query_empty_path( path: "".to_string(), key: "test".as_bytes().to_vec(), }; - let msg = - register_interchain_query(env.contract.address, QueryPayload::KV(vec![kv_key]), connection_id, 10)?; + let msg = register_interchain_query( + env.contract.address, + QueryPayload::KV(vec![kv_key]), + connection_id, + 10, + )?; Ok(Response::new().add_message(msg)) } @@ -363,7 +441,12 @@ pub fn register_query_empty_keys( env: Env, connection_id: String, ) -> NeutronResult { - let msg = register_interchain_query(env.contract.address, QueryPayload::KV(vec![]), connection_id, 10)?; + let msg = register_interchain_query( + env.contract.address, + QueryPayload::KV(vec![]), + connection_id, + 10, + )?; Ok(Response::new().add_message(msg)) } @@ -382,8 +465,13 @@ pub fn update_interchain_query( }] }); - let update_msg = - helpers_update_interchain_query(contract, query_id, new_keys, new_update_period, new_filter)?; + let update_msg = helpers_update_interchain_query( + contract, + query_id, + new_keys, + new_update_period, + new_filter, + )?; Ok(Response::new().add_message(update_msg)) } @@ -493,8 +581,7 @@ pub fn sudo_tx_query_result( let body: TxBody = TxBody::decode(tx.body_bytes.as_slice())?; // Get the registered query by ID and retrieve the raw query string - let registered_query = - get_registered_query(deps.as_ref(), query_id)?; + let registered_query = get_registered_query(deps.as_ref(), query_id)?; let transactions_filter = registered_query.transactions_filter; #[allow(clippy::match_single_binding)] @@ -601,11 +688,7 @@ fn check_deposits_size(deposits: &Vec) -> StdResult<()> { /// sudo_kv_query_result is the contract's callback for KV query results. Note that only the query /// id is provided, so you need to read the query result from the state. -pub fn sudo_kv_query_result( - deps: DepsMut, - env: Env, - query_id: u64, -) -> NeutronResult { +pub fn sudo_kv_query_result(deps: DepsMut, env: Env, query_id: u64) -> NeutronResult { deps.api.debug( format!( "WASMDEBUG: sudo_kv_query_result received; query_id: {:?}", diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index dc069c9..a83b7ea 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -1,5 +1,5 @@ -use neutron_std::types::neutron::interchainqueries::KvKey; use crate::state::Transfer; +use neutron_std::types::neutron::interchainqueries::KvKey; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index 5474688..2ab44e6 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -20,7 +20,6 @@ use cosmwasm_std::{ from_json, Binary, Coin, ContractResult, CustomQuery, FullDelegation, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, Validator, }; -use neutron_sdk::bindings::query::NeutronQuery; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -35,7 +34,7 @@ impl CustomQuery for CustomQueryWrapper {} pub fn mock_dependencies( contract_balance: &[Coin], -) -> OwnedDeps { +) -> OwnedDeps { let contract_addr = MOCK_CONTRACT_ADDR; let custom_querier: WasmMockQuerier = WasmMockQuerier::new(MockQuerier::new(&[(contract_addr, contract_balance)])); @@ -49,14 +48,14 @@ pub fn mock_dependencies( } pub struct WasmMockQuerier { - base: MockQuerier, + base: MockQuerier, query_responses: HashMap, registered_queries: HashMap, } impl Querier for WasmMockQuerier { fn raw_query(&self, bin_request: &[u8]) -> QuerierResult { - let request: QueryRequest = match from_json(bin_request) { + let request: QueryRequest = match from_json(bin_request) { Ok(v) => v, Err(e) => { return QuerierResult::Err(SystemError::InvalidRequest { @@ -124,7 +123,7 @@ pub struct TokenQuerier { } impl WasmMockQuerier { - pub fn new(base: MockQuerier) -> Self { + pub fn new(base: MockQuerier) -> Self { WasmMockQuerier { base, query_responses: HashMap::new(), diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index d0ee479..536d7ea 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -35,9 +35,7 @@ use cosmwasm_std::{ use neutron_sdk::bindings::query::{ NeutronQuery, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, }; -use neutron_sdk::bindings::types::{ - decode_hex, Height, InterchainQueryResult, KVKey, KVKeys, RegisteredQuery, StorageValue, -}; +use neutron_sdk::bindings::types::{decode_hex, Height}; use neutron_sdk::interchain_queries::helpers::decode_and_convert; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, diff --git a/contracts/neutron_interchain_txs/Cargo.toml b/contracts/neutron_interchain_txs/Cargo.toml index 6ab180b..738dcc3 100644 --- a/contracts/neutron_interchain_txs/Cargo.toml +++ b/contracts/neutron_interchain_txs/Cargo.toml @@ -27,6 +27,7 @@ serde-json-wasm = { workspace = true } cw-storage-plus = { workspace = true } cosmos-sdk-proto = { workspace = true } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } prost = { workspace = true } prost-types = { workspace = true } diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index e28e12b..2b70a66 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -19,10 +19,11 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::{ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - coins, to_json_binary, Binary, Coin as CosmosCoin, CosmosMsg, CustomQuery, Deps, DepsMut, Env, - MessageInfo, Reply, ReplyOn, Response, StdError, StdResult, SubMsg, Uint128, + to_json_binary, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo, Reply, + ReplyOn, Response, StdError, StdResult, SubMsg, Uint128, }; use cw2::set_contract_version; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; use prost::Message; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -34,17 +35,6 @@ use crate::integration_tests_mock_handlers::{ use crate::msg::{ AcknowledgementResultsResponse, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, }; -use neutron_sdk::bindings::msg::{ChannelOrdering, IbcFee, NeutronMsg}; -use neutron_sdk::bindings::query::{NeutronQuery, QueryInterchainAccountAddressResponse}; -use neutron_sdk::bindings::types::ProtobufAny; -use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id}; -use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; -use neutron_sdk::proto_types::neutron::interchaintxs::v1::{ - MsgRegisterInterchainAccountResponse, MsgSubmitTxResponse, -}; -use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; -use neutron_sdk::NeutronResult; - use crate::storage::{ add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, AcknowledgementResult, DoubleDelegateInfo, @@ -53,6 +43,19 @@ use crate::storage::{ INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK, INTERCHAIN_ACCOUNTS, REGISTER_FEE, REGISTER_ICA_REPLY_ID, SUDO_FAILING_SUBMSG_REPLY_ID, SUDO_PAYLOAD_REPLY_ID, TEST_COUNTER_ITEM, }; +use neutron_sdk::bindings::msg::ChannelOrdering; +use neutron_sdk::interchain_txs::helpers::{ + decode_message_response, get_port_id, register_interchain_account, submit_tx, +}; +use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; +use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; +use neutron_sdk::NeutronResult; +use neutron_std::shim::Any; +use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; +use neutron_std::types::neutron::feerefunder::Fee; +use neutron_std::types::neutron::interchaintxs::v1::{ + InterchaintxsQuerier, MsgRegisterInterchainAccountResponse, MsgSubmitTxResponse, +}; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -88,20 +91,21 @@ pub fn instantiate( _env: Env, _info: MessageInfo, _msg: InstantiateMsg, -) -> NeutronResult> { +) -> NeutronResult { deps.api.debug("WASMDEBUG: instantiate"); set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - REGISTER_FEE.save(deps.storage, &coins(1_000_000, "untrn"))?; + REGISTER_FEE.save( + deps.storage, + &vec![StdCoin { + amount: 1_000_000.to_string(), + denom: "untrn".to_string(), + }], + )?; Ok(Response::default()) } #[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - _: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { @@ -173,7 +177,9 @@ pub fn execute( timeout_fee, } => execute_set_fees(deps, denom, recv_fee, ack_fee, timeout_fee), ExecuteMsg::CleanAckResults {} => execute_clean_ack_results(deps), - ExecuteMsg::ResubmitFailure { failure_id } => execute_resubmit_failure(deps, failure_id), + ExecuteMsg::ResubmitFailure { failure_id } => { + execute_resubmit_failure(deps, env, failure_id) + } // The section below is used only in integration tests framework to simulate failures. ExecuteMsg::IntegrationTestsSetSudoFailureMock { state } => { @@ -215,13 +221,12 @@ pub fn query_interchain_address( interchain_account_id: String, connection_id: String, ) -> NeutronResult { - let query = NeutronQuery::InterchainAccountAddress { - owner_address: env.contract.address.to_string(), + let querier = InterchaintxsQuerier::new(&deps.querier); + let res = querier.interchain_account_address( + env.contract.address.to_string(), interchain_account_id, connection_id, - }; - - let res: QueryInterchainAccountAddressResponse = deps.querier.query(&query.into())?; + )?; Ok(to_json_binary(&res)?) } @@ -284,19 +289,19 @@ fn execute_set_fees( recv_fee: Uint128, ack_fee: Uint128, timeout_fee: Uint128, -) -> StdResult> { - let fees = IbcFee { - recv_fee: vec![CosmosCoin { +) -> StdResult { + let fees = Fee { + recv_fee: vec![StdCoin { denom: denom.clone(), - amount: recv_fee, + amount: recv_fee.to_string(), }], - ack_fee: vec![CosmosCoin { + ack_fee: vec![StdCoin { denom: denom.clone(), - amount: ack_fee, + amount: ack_fee.to_string(), }], - timeout_fee: vec![CosmosCoin { + timeout_fee: vec![StdCoin { denom, - amount: timeout_fee, + amount: timeout_fee.to_string(), }], }; IBC_FEE.save(deps.storage, &fees)?; @@ -309,12 +314,13 @@ fn execute_register_ica( connection_id: String, interchain_account_id: String, ordering: Option, -) -> StdResult> { +) -> StdResult { let register_fee = REGISTER_FEE.load(deps.storage)?; - let register = NeutronMsg::register_interchain_account( + let register = register_interchain_account( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), - Option::from(register_fee), + register_fee, ordering, ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); @@ -322,11 +328,7 @@ fn execute_register_ica( Ok(Response::new().add_submessage(SubMsg::reply_on_success(register, REGISTER_ICA_REPLY_ID))) } -fn execute_delegate( - deps: DepsMut, - env: Env, - info: ExecuteDelegateInfo, -) -> StdResult> { +fn execute_delegate(deps: DepsMut, env: Env, info: ExecuteDelegateInfo) -> StdResult { do_delegate(deps, env, info) } @@ -338,7 +340,7 @@ fn execute_undelegate( amount: Uint128, denom: String, timeout: Option, -) -> StdResult> { +) -> StdResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &interchain_account_id)?; let delegate_msg = MsgUndelegate { @@ -356,12 +358,13 @@ fn execute_undelegate( return Err(StdError::generic_err(format!("Encode error: {}", e))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgUndelegate".to_string(), - value: Binary::from(buf), + value: buf, }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), vec![any_msg], @@ -387,15 +390,11 @@ fn execute_delegate_double_ack( deps: DepsMut, env: Env, info: ExecuteDelegateInfo, -) -> StdResult> { +) -> StdResult { do_delegate(deps, env, info) } -fn do_delegate( - mut deps: DepsMut, - env: Env, - info: ExecuteDelegateInfo, -) -> StdResult> { +fn do_delegate(mut deps: DepsMut, env: Env, info: ExecuteDelegateInfo) -> StdResult { let fee = IBC_FEE.load(deps.storage)?; let (delegator, connection_id) = get_ica(deps.as_ref(), &env, &info.interchain_account_id)?; let delegate_msg = MsgDelegate { @@ -413,12 +412,13 @@ fn do_delegate( return Err(StdError::generic_err(format!("Encode error: {}", e))); } - let any_msg = ProtobufAny { + let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgDelegate".to_string(), - value: Binary::from(buf), + value: buf, }; - let cosmos_msg = NeutronMsg::submit_tx( + let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, info.interchain_account_id.clone(), vec![any_msg], @@ -442,7 +442,7 @@ fn do_delegate( Ok(Response::default().add_submessages(vec![submsg])) } -fn execute_clean_ack_results(deps: DepsMut) -> StdResult> { +fn execute_clean_ack_results(deps: DepsMut) -> StdResult { let keys: Vec> = ACKNOWLEDGEMENT_RESULTS .keys(deps.storage, None, None, cosmwasm_std::Order::Descending) .collect(); @@ -452,12 +452,16 @@ fn execute_clean_ack_results(deps: DepsMut) -> StdResult> { Ok(Response::default()) } -fn execute_resubmit_failure(_: DepsMut, failure_id: u64) -> StdResult> { - let msg = NeutronMsg::submit_resubmit_failure(failure_id); +fn execute_resubmit_failure(_: DepsMut, env: Env, failure_id: u64) -> StdResult { + let msg: CosmosMsg = MsgResubmitFailure { + sender: env.contract.address.to_string(), + failure_id, + } + .into(); Ok(Response::default().add_message(msg)) } -fn integration_tests_sudo_submsg(deps: DepsMut) -> StdResult> { +fn integration_tests_sudo_submsg(deps: DepsMut) -> StdResult { if let Some(IntegrationTestsSudoSubmsgFailureMock::Enabled {}) = INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.may_load(deps.storage)? { @@ -473,10 +477,10 @@ fn integration_tests_sudo_submsg(deps: DepsMut) -> StdResult StdResult> { +pub fn sudo(mut deps: DepsMut, env: Env, msg: SudoMsg) -> StdResult { let api = deps.api; api.debug(format!("WASMDEBUG: sudo: received sudo msg: {:?}", msg).as_str()); @@ -488,7 +492,7 @@ pub fn sudo(mut deps: DepsMut, env: Env, msg: SudoMsg) -> StdResult = match msg.clone() { + let mut resp: Response = match msg.clone() { SudoMsg::Response { request, data } => { sudo_response(deps.branch(), env.clone(), request, data)? } @@ -575,7 +579,7 @@ fn sudo_open_ack( channel_id: String, _counterparty_channel_id: String, counterparty_version: String, -) -> StdResult> { +) -> StdResult { let expected_channel_id = ICA_CHANNELS.load(deps.storage, port_id.clone())?; if channel_id != expected_channel_id { @@ -603,7 +607,7 @@ fn sudo_response( env: Env, request: RequestPacket, data: Binary, -) -> StdResult> { +) -> StdResult { deps.api.debug( format!( "WASMDEBUG: sudo_response: sudo received: {:?} {:?}", @@ -715,11 +719,7 @@ fn sudo_response( Ok(Response::default()) } -fn sudo_timeout( - deps: DepsMut, - _env: Env, - request: RequestPacket, -) -> StdResult> { +fn sudo_timeout(deps: DepsMut, _env: Env, request: RequestPacket) -> StdResult { deps.api .debug(format!("WASMDEBUG: sudo timeout request: {:?}", request).as_str()); @@ -754,11 +754,7 @@ fn sudo_timeout( Ok(Response::default()) } -fn sudo_error( - deps: DepsMut, - request: RequestPacket, - details: String, -) -> StdResult> { +fn sudo_error(deps: DepsMut, request: RequestPacket, details: String) -> StdResult { deps.api .debug(format!("WASMDEBUG: sudo error: {}", details).as_str()); deps.api diff --git a/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs b/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs index 2648c6c..6b99bb4 100644 --- a/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs +++ b/contracts/neutron_interchain_txs/src/integration_tests_mock_handlers.rs @@ -3,17 +3,16 @@ use crate::storage::{ INTEGRATION_TESTS_SUDO_FAILURE_MOCK, INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK, }; use cosmwasm_std::{DepsMut, Response, StdResult}; -use neutron_sdk::bindings::msg::NeutronMsg; pub fn set_sudo_failure_mock( deps: DepsMut, state: IntegrationTestsSudoFailureMock, -) -> StdResult> { +) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK.save(deps.storage, &state)?; Ok(Response::default()) } -pub fn set_sudo_submsg_failure_mock(deps: DepsMut) -> StdResult> { +pub fn set_sudo_submsg_failure_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.save( deps.storage, &IntegrationTestsSudoSubmsgFailureMock::Enabled, @@ -21,7 +20,7 @@ pub fn set_sudo_submsg_failure_mock(deps: DepsMut) -> StdResult StdResult> { +pub fn set_sudo_submsg_failure_in_reply_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.save( deps.storage, &IntegrationTestsSudoSubmsgFailureMock::EnabledInReply, @@ -29,7 +28,7 @@ pub fn set_sudo_submsg_failure_in_reply_mock(deps: DepsMut) -> StdResult StdResult> { +pub fn unset_sudo_failure_mock(deps: DepsMut) -> StdResult { INTEGRATION_TESTS_SUDO_FAILURE_MOCK .save(deps.storage, &IntegrationTestsSudoFailureMock::Disabled)?; INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK.save( diff --git a/contracts/neutron_interchain_txs/src/storage.rs b/contracts/neutron_interchain_txs/src/storage.rs index 5665ca2..fb95feb 100644 --- a/contracts/neutron_interchain_txs/src/storage.rs +++ b/contracts/neutron_interchain_txs/src/storage.rs @@ -1,7 +1,8 @@ use cosmwasm_std::Uint128; -use cosmwasm_std::{from_json, to_json_vec, Binary, Coin, Order, StdResult, Storage}; +use cosmwasm_std::{from_json, to_json_vec, Binary, Order, StdResult, Storage}; use cw_storage_plus::{Item, Map}; -use neutron_sdk::bindings::msg::IbcFee; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; +use neutron_std::types::neutron::feerefunder::Fee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -27,8 +28,8 @@ pub const SUDO_FAILING_SUBMSG_REPLY_ID: u64 = 2; // only used to make sure `sudo()` handler gets OpenAck message with correct port_id and channel_id pub const REGISTER_ICA_REPLY_ID: u64 = 3; -pub const IBC_FEE: Item = Item::new("ibc_fee"); -pub const REGISTER_FEE: Item> = Item::new("register_fee"); +pub const IBC_FEE: Item = Item::new("ibc_fee"); +pub const REGISTER_FEE: Item> = Item::new("register_fee"); pub const REPLY_ID_STORAGE: Item> = Item::new("reply_queue_id"); pub const SUDO_PAYLOAD: Map<(String, u64), Vec> = Map::new("sudo_payload"); pub const INTERCHAIN_ACCOUNTS: Map> = diff --git a/contracts/neutron_interchain_txs/src/testing/tests.rs b/contracts/neutron_interchain_txs/src/testing/tests.rs index 2bbbd2f..0d9f324 100644 --- a/contracts/neutron_interchain_txs/src/testing/tests.rs +++ b/contracts/neutron_interchain_txs/src/testing/tests.rs @@ -22,11 +22,10 @@ use cosmwasm_std::testing::{ MockStorage, }; use cosmwasm_std::{from_json, Addr, OwnedDeps, StdError}; -use neutron_sdk::bindings::query::NeutronQuery; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use std::marker::PhantomData; -pub fn mock_dependencies() -> OwnedDeps { +pub fn mock_dependencies() -> OwnedDeps { OwnedDeps { storage: MockStorage::default(), api: MockApi::default(), diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 38def28..831c3ee 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -12,6 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use crate::storage::{ + read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, + AcknowledgementResult, GetRecipientTxsResponse, SudoPayload, Transfer, ACKNOWLEDGEMENT_RESULTS, + IBC_FEE, INTERCHAIN_ACCOUNTS, LAST_SEQ_ID, RECIPIENT_TXS, SUDO_PAYLOAD_REPLY_ID, +}; use cosmos_sdk_proto::{ cosmos::{ bank::v1beta1::MsgSend, @@ -23,11 +29,13 @@ use cosmos_sdk_proto::{ }; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; -use cosmwasm_std::{coin, to_json_binary, Addr, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult, SubMsg, Uint128}; +use cosmwasm_std::{ + to_json_binary, Addr, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo, Reply, + Response, StdError, StdResult, SubMsg, Uint128, +}; use cw2::set_contract_version; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use neutron_sdk::bindings::msg::ChannelOrdering; +use neutron_sdk::interchain_queries::helpers::remove_interchain_query as helpers_remove_interchain_query; use neutron_sdk::interchain_queries::queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, @@ -37,21 +45,20 @@ use neutron_sdk::interchain_queries::v045::types::{COSMOS_SDK_TRANSFER_MSG_URL, use neutron_sdk::interchain_queries::v045::{ new_register_balances_query_msg, new_register_transfers_query_msg, }; -use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id, register_interchain_account}; +use neutron_sdk::interchain_txs::helpers::{ + decode_message_response, get_port_id, register_interchain_account, submit_tx, +}; use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; -use neutron_sdk::bindings::msg::ChannelOrdering; -use neutron_std::types::ibc::applications::fee::v1::Fee; -use neutron_std::types::neutron::interchainqueries::{InterchainqueriesQuerier, QueryRegisteredQueryResponse, RegisteredQuery}; -use crate::storage::{ - read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, - AcknowledgementResult, GetRecipientTxsResponse, SudoPayload, Transfer, ACKNOWLEDGEMENT_RESULTS, - IBC_FEE, INTERCHAIN_ACCOUNTS, LAST_SEQ_ID, RECIPIENT_TXS, SUDO_PAYLOAD_REPLY_ID, -}; +use neutron_std::shim::Any; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; +use neutron_std::types::ibc::core::client::v1::Height; +use neutron_std::types::neutron::feerefunder::Fee; +use neutron_std::types::neutron::interchainqueries::RegisteredQuery; use neutron_std::types::neutron::interchaintxs::v1::{InterchaintxsQuerier, MsgSubmitTxResponse}; -use neutron_sdk::interchain_queries::helpers::{update_interchain_query as helpers_update_interchain_query, remove_interchain_query as helpers_remove_interchain_query}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -139,14 +146,28 @@ pub fn execute( addr, denom, update_period, - } => register_balance_query(connection_id, addr, denom, update_period), + } => register_balance_query( + env.contract.address, + connection_id, + addr, + denom, + update_period, + ), ExecuteMsg::RegisterTransfersQuery { connection_id, recipient, update_period, min_height, - } => register_transfers_query(connection_id, recipient, update_period, min_height), - ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(query_id), + } => register_transfers_query( + env.contract.address, + connection_id, + recipient, + update_period, + min_height, + ), + ExecuteMsg::RemoveInterchainQuery { query_id } => { + remove_interchain_query(env.contract.address, query_id) + } } } @@ -177,7 +198,11 @@ pub fn query_interchain_address( connection_id: String, ) -> NeutronResult { let querier = InterchaintxsQuerier::new(&deps.querier); - let res = querier.interchain_account_address(env.contract.address.to_string(), interchain_account_id, connection_id)?; + let res = querier.interchain_account_address( + env.contract.address.to_string(), + interchain_account_id, + connection_id, + )?; Ok(to_json_binary(&res)?) } @@ -229,7 +254,10 @@ fn get_fee_item(denom: String, amount: Uint128) -> Vec { if amount == Uint128::new(0) { vec![] } else { - vec![CosmosCoin { amount: amount.to_string(), denom }] + vec![CosmosCoin { + amount: amount.to_string(), + denom, + }] } } @@ -263,7 +291,7 @@ fn execute_register_ica( interchain_account_id.clone(), vec![], Some(ChannelOrdering::OrderOrdered), - )?; + ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; Ok(Response::new().add_message(register)) @@ -299,10 +327,11 @@ fn execute_delegate( let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgDelegate".to_string(), - value: Binary::from(buf), + value: buf, }; let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), vec![any_msg], @@ -357,10 +386,11 @@ fn execute_undelegate( let any_msg = Any { type_url: "/cosmos.staking.v1beta1.MsgUndelegate".to_string(), - value: Binary::from(buf), + value: buf, }; let cosmos_msg = submit_tx( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), vec![any_msg], @@ -410,7 +440,8 @@ pub fn register_balance_query( denom: String, update_period: u64, ) -> NeutronResult { - let msg = new_register_balances_query_msg(contract, connection_id, addr, vec![denom], update_period)?; + let msg = + new_register_balances_query_msg(contract, connection_id, addr, vec![denom], update_period)?; Ok(Response::new().add_message(msg)) } @@ -422,8 +453,13 @@ pub fn register_transfers_query( update_period: u64, min_height: Option, ) -> NeutronResult { - let msg = - new_register_transfers_query_msg(contract, connection_id, recipient, update_period, min_height)?; + let msg = new_register_transfers_query_msg( + contract, + connection_id, + recipient, + update_period, + min_height, + )?; Ok(Response::new().add_message(msg)) } @@ -577,11 +613,7 @@ fn recipient_deposits_from_tx_body( Ok(deposits) } -fn sudo_response( - deps: DepsMut, - request: RequestPacket, - data: Binary, -) -> NeutronResult { +fn sudo_response(deps: DepsMut, request: RequestPacket, data: Binary) -> NeutronResult { deps.api.debug( format!( "WASMDEBUG: sudo_response: sudo received: {:?} {:?}", @@ -631,11 +663,7 @@ fn sudo_response( Ok(Response::default()) } -fn sudo_timeout( - deps: DepsMut, - _env: Env, - request: RequestPacket, -) -> NeutronResult { +fn sudo_timeout(deps: DepsMut, _env: Env, request: RequestPacket) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: sudo timeout request: {:?}", request).as_str()); @@ -663,11 +691,7 @@ fn sudo_timeout( Ok(Response::default()) } -fn sudo_error( - deps: DepsMut, - request: RequestPacket, - details: String, -) -> NeutronResult { +fn sudo_error(deps: DepsMut, request: RequestPacket, details: String) -> NeutronResult { deps.api .debug(format!("WASMDEBUG: sudo error: {}", details).as_str()); deps.api diff --git a/contracts/neutron_validator_test/src/storage.rs b/contracts/neutron_validator_test/src/storage.rs index 8bbf37a..8914345 100644 --- a/contracts/neutron_validator_test/src/storage.rs +++ b/contracts/neutron_validator_test/src/storage.rs @@ -1,7 +1,6 @@ use cosmwasm_std::{from_json, to_json_vec, Binary, StdResult, Storage, Uint128}; use cw_storage_plus::{Item, Map}; -use neutron_sdk::bindings::msg::IbcFee; -use neutron_std::types::ibc::applications::fee::v1::Fee; +use neutron_std::types::neutron::feerefunder::Fee; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/contracts/oracle/src/contract.rs b/contracts/oracle/src/contract.rs index 72df65d..c7460d2 100644 --- a/contracts/oracle/src/contract.rs +++ b/contracts/oracle/src/contract.rs @@ -1,3 +1,4 @@ +use crate::msg::QueryMsg; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; @@ -6,7 +7,6 @@ use neutron_std::types::slinky::oracle::v1::OracleQuerier; use neutron_std::types::slinky::types::v1::CurrencyPair; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::msg::QueryMsg; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct InstantiateMsg {} @@ -49,16 +49,11 @@ fn query_oracle(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { let querier = OracleQuerier::new(&deps.querier); match msg { QueryMsg::GetPrice { base, quote } => { - to_json_binary(&querier.get_price(Some(CurrencyPair{ - base, - quote, - }))?) + to_json_binary(&querier.get_price(Some(CurrencyPair { base, quote }))?) } QueryMsg::GetPrices { currency_pair_ids } => { to_json_binary(&querier.get_prices(currency_pair_ids)?) } - QueryMsg::GetAllCurrencyPairs { .. } => { - to_json_binary(&querier.get_all_currency_pairs()?) - } + QueryMsg::GetAllCurrencyPairs { .. } => to_json_binary(&querier.get_all_currency_pairs()?), } } diff --git a/contracts/oracle/src/msg.rs b/contracts/oracle/src/msg.rs index 8a72c68..506253f 100644 --- a/contracts/oracle/src/msg.rs +++ b/contracts/oracle/src/msg.rs @@ -4,14 +4,7 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - GetPrice { - base: String, - quote: String, - }, - GetPrices { - currency_pair_ids: Vec, - }, - GetAllCurrencyPairs { - - }, -} \ No newline at end of file + GetPrice { base: String, quote: String }, + GetPrices { currency_pair_ids: Vec }, + GetAllCurrencyPairs {}, +} diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index cf4033c..54210f5 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -5,7 +5,6 @@ use cosmwasm_std::{ Uint128, }; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::NeutronMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -34,19 +33,14 @@ pub fn instantiate( #[serde(rename_all = "snake_case")] pub enum ExecuteMsg { Send { to: String, amount: Uint128 }, - ReflectMsg { msgs: Vec> }, + ReflectMsg { msgs: Vec }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct MigrateMsg {} #[entry_point] -pub fn execute( - deps: DepsMut, - _env: Env, - _: MessageInfo, - msg: ExecuteMsg, -) -> StdResult> { +pub fn execute(deps: DepsMut, _env: Env, _: MessageInfo, msg: ExecuteMsg) -> StdResult { deps.api .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 38644d1..5272cb4 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -1,10 +1,16 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; -use cosmwasm_std::{coins, entry_point, to_json_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; +use cosmwasm_std::{ + coins, entry_point, to_json_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, + MessageInfo, Response, StdError, StdResult, +}; use neutron_sdk::NeutronError::Std; use neutron_sdk::NeutronResult; use neutron_std::types::cosmos::bank::v1beta1::Metadata; -use neutron_std::types::osmosis::tokenfactory::v1beta1::{MsgChangeAdmin, MsgCreateDenom, MsgMint, TokenfactoryQuerier, MsgBurn, MsgSetBeforeSendHook, MsgForceTransfer, MsgSetDenomMetadata}; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; +use neutron_std::types::osmosis::tokenfactory::v1beta1::{ + MsgBurn, MsgChangeAdmin, MsgCreateDenom, MsgForceTransfer, MsgMint, MsgSetBeforeSendHook, + MsgSetDenomMetadata, TokenfactoryQuerier, +}; #[entry_point] pub fn instantiate( @@ -24,55 +30,55 @@ pub fn execute( msg: ExecuteMsg, ) -> StdResult { let msg: CosmosMsg = match msg { - ExecuteMsg::CreateDenom { subdenom } => { - MsgCreateDenom { - sender: info.sender.to_string(), - subdenom, - }.into() - }, + ExecuteMsg::CreateDenom { subdenom } => MsgCreateDenom { + sender: info.sender.to_string(), + subdenom, + } + .into(), ExecuteMsg::ChangeAdmin { denom, new_admin_address, - } => { - MsgChangeAdmin{ - sender: info.sender.to_string(), - denom, - new_admin: new_admin_address - }.into() - }, + } => MsgChangeAdmin { + sender: info.sender.to_string(), + denom, + new_admin: new_admin_address, + } + .into(), ExecuteMsg::MintTokens { denom, amount, mint_to_address, - } => { - MsgMint{ - sender: info.sender.to_string(), - amount: Some(CosmosCoin{ denom, amount: amount.to_string() }), - mint_to_address: mint_to_address.unwrap_or(env.contract.address.into()), - } - .into() - }, + } => MsgMint { + sender: info.sender.to_string(), + amount: Some(CosmosCoin { + denom, + amount: amount.to_string(), + }), + mint_to_address: mint_to_address.unwrap_or(env.contract.address.into()), + } + .into(), ExecuteMsg::BurnTokens { denom, amount, burn_from_address, - } => { - MsgBurn{ - sender: info.sender.to_string(), - amount: Some(CosmosCoin{ denom, amount: amount.to_string() }), - burn_from_address: burn_from_address.unwrap_or(env.contract.address.into()), - }.into() - }, + } => MsgBurn { + sender: info.sender.to_string(), + amount: Some(CosmosCoin { + denom, + amount: amount.to_string(), + }), + burn_from_address: burn_from_address.unwrap_or(env.contract.address.into()), + } + .into(), ExecuteMsg::SetBeforeSendHook { denom, contract_addr, - } => { - MsgSetBeforeSendHook{ - sender: info.sender.to_string(), - denom, - contract_addr - }.into() - }, + } => MsgSetBeforeSendHook { + sender: info.sender.to_string(), + denom, + contract_addr, + } + .into(), ExecuteMsg::SendTokens { recipient, denom, @@ -87,14 +93,16 @@ pub fn execute( amount, from, to, - } => { - MsgForceTransfer{ - sender: info.sender.to_string(), - amount: Some(CosmosCoin{ denom, amount: amount.to_string() }), - transfer_from_address: from, - transfer_to_address: to, - }.into() - }, + } => MsgForceTransfer { + sender: info.sender.to_string(), + amount: Some(CosmosCoin { + denom, + amount: amount.to_string(), + }), + transfer_from_address: from, + transfer_to_address: to, + } + .into(), ExecuteMsg::SetDenomMetadata { description, denom_units, @@ -104,23 +112,20 @@ pub fn execute( symbol, uri, uri_hash, - } => { - MsgSetDenomMetadata{ - sender: info.sender.to_string(), - metadata: Some( - Metadata { - description, - denom_units, - base, - display, - name, - symbol, - uri, - uri_hash, - } - ) - }.into() - }, + } => MsgSetDenomMetadata { + sender: info.sender.to_string(), + metadata: Some(Metadata { + description, + denom_units, + base, + display, + name, + symbol, + uri, + uri_hash, + }), + } + .into(), }; Ok(Response::new().add_message(msg)) } @@ -135,11 +140,15 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { } => { let res = &querier.full_denom(creator_addr, subdenom)?; to_json_binary(res)? - }, + } QueryMsg::DenomAdmin { creator, subdenom } => { let authority = querier.denom_authority_metadata(creator, subdenom)?; - to_json_binary(&authority.authority_metadata.ok_or(Std(StdError::generic_err("authority metadata not found")))?)? - }, + to_json_binary( + &authority + .authority_metadata + .ok_or(Std(StdError::generic_err("authority metadata not found")))?, + )? + } QueryMsg::BeforeSendHook { creator, denom } => { to_json_binary(&querier.before_send_hook_address(creator, denom)?)? } From c31f4db1d1f8f421d89ad01206b572e280c033a0 Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 16:51:34 +0400 Subject: [PATCH 17/34] use neutron-std Order type for channels; fix some schema generation --- Cargo.lock | 4 ++-- contracts/marketmap/examples/schema.rs | 3 +-- contracts/marketmap/src/contract.rs | 11 +---------- contracts/marketmap/src/lib.rs | 2 +- contracts/marketmap/src/{query.rs => msg.rs} | 7 +++++++ .../neutron_interchain_queries/src/testing/tests.rs | 7 ++----- .../examples/neutron_interchain_txs-schema.rs | 2 +- contracts/neutron_interchain_txs/src/contract.rs | 4 ++-- contracts/neutron_interchain_txs/src/msg.rs | 4 ++-- .../examples/neutron_validator_test-schema.rs | 2 +- contracts/neutron_validator_test/src/contract.rs | 4 ++-- contracts/oracle/examples/schema.rs | 4 ++-- contracts/oracle/src/contract.rs | 11 +---------- contracts/oracle/src/lib.rs | 2 +- contracts/oracle/src/msg.rs | 7 +++++++ 15 files changed, 33 insertions(+), 41 deletions(-) rename contracts/marketmap/src/{query.rs => msg.rs} (60%) diff --git a/Cargo.lock b/Cargo.lock index 2507365..a1e93d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4841d0231fae18e6ac39571e9b8b2b1bcf67faf9" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#82e4e338ba92c3bd4d6f2f22c10aa597c09a7e3c" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4841d0231fae18e6ac39571e9b8b2b1bcf67faf9" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#82e4e338ba92c3bd4d6f2f22c10aa597c09a7e3c" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/marketmap/examples/schema.rs b/contracts/marketmap/examples/schema.rs index d83d7f1..f1eb66b 100644 --- a/contracts/marketmap/examples/schema.rs +++ b/contracts/marketmap/examples/schema.rs @@ -17,7 +17,6 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use marketmap::contract::InstantiateMsg; -use neutron_sdk::bindings::marketmap::query::MarketMapQuery; fn main() { let mut out_dir = current_dir().unwrap(); @@ -26,5 +25,5 @@ fn main() { remove_schemas(&out_dir).unwrap(); export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(MarketMapQuery), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); } diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index 5ce50c2..7c55ee2 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -1,18 +1,9 @@ -use crate::query::QueryMsg; +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; use neutron_std::types::slinky::marketmap::v1::MarketmapQuerier; -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)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg {} const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/contracts/marketmap/src/lib.rs b/contracts/marketmap/src/lib.rs index f43d2b3..37088ba 100644 --- a/contracts/marketmap/src/lib.rs +++ b/contracts/marketmap/src/lib.rs @@ -1,2 +1,2 @@ pub mod contract; -mod query; +mod msg; diff --git a/contracts/marketmap/src/query.rs b/contracts/marketmap/src/msg.rs similarity index 60% rename from contracts/marketmap/src/query.rs rename to contracts/marketmap/src/msg.rs index 2f6ea25..95edcaa 100644 --- a/contracts/marketmap/src/query.rs +++ b/contracts/marketmap/src/msg.rs @@ -2,6 +2,13 @@ use neutron_std::types::slinky::types::v1::CurrencyPair; 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)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 536d7ea..00ec3fe 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -32,10 +32,6 @@ use cosmwasm_std::{ from_json, to_json_binary, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, Uint128, }; -use neutron_sdk::bindings::query::{ - NeutronQuery, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, -}; -use neutron_sdk::bindings::types::{decode_hex, Height}; use neutron_sdk::interchain_queries::helpers::decode_and_convert; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, @@ -55,12 +51,13 @@ use neutron_sdk::interchain_queries::v047::types::{ ValidatorSigningInfo, WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; use neutron_sdk::NeutronError; +use neutron_std::types::neutron::interchainqueries::KvKey; use prost::Message as ProstMessage; use schemars::_serde_json::to_string; use std::ops::Mul; enum QueryParam { - Keys(Vec), + Keys(Vec), TransactionsFilter(String), } diff --git a/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs b/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs index 9169e7a..fad1537 100644 --- a/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs +++ b/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs @@ -14,8 +14,8 @@ use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use neutron_interchain_txs::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; -use neutron_sdk::bindings::query::QueryInterchainAccountAddressResponse; use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::interchaintxs::v1::QueryInterchainAccountAddressResponse; use std::env::current_dir; use std::fs::create_dir_all; diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 2b70a66..702f850 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -43,7 +43,6 @@ use crate::storage::{ INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK, INTERCHAIN_ACCOUNTS, REGISTER_FEE, REGISTER_ICA_REPLY_ID, SUDO_FAILING_SUBMSG_REPLY_ID, SUDO_PAYLOAD_REPLY_ID, TEST_COUNTER_ITEM, }; -use neutron_sdk::bindings::msg::ChannelOrdering; use neutron_sdk::interchain_txs::helpers::{ decode_message_response, get_port_id, register_interchain_account, submit_tx, }; @@ -51,6 +50,7 @@ use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::NeutronResult; use neutron_std::shim::Any; +use neutron_std::types::ibc::core::channel::v1::Order; use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; use neutron_std::types::neutron::feerefunder::Fee; use neutron_std::types::neutron::interchaintxs::v1::{ @@ -313,7 +313,7 @@ fn execute_register_ica( env: Env, connection_id: String, interchain_account_id: String, - ordering: Option, + ordering: Option, ) -> StdResult { let register_fee = REGISTER_FEE.load(deps.storage)?; let register = register_interchain_account( diff --git a/contracts/neutron_interchain_txs/src/msg.rs b/contracts/neutron_interchain_txs/src/msg.rs index a6ed4b0..7dd4d87 100644 --- a/contracts/neutron_interchain_txs/src/msg.rs +++ b/contracts/neutron_interchain_txs/src/msg.rs @@ -1,6 +1,6 @@ use crate::storage::{AcknowledgementResult, IntegrationTestsSudoFailureMock}; use cosmwasm_std::Uint128; -use neutron_sdk::bindings::msg::ChannelOrdering; +use neutron_std::types::ibc::core::channel::v1::Order; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -39,7 +39,7 @@ pub enum ExecuteMsg { Register { connection_id: String, interchain_account_id: String, - ordering: Option, + ordering: Option, }, SetFees { denom: String, diff --git a/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs b/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs index cb365a0..9b83441 100644 --- a/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs +++ b/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs @@ -13,8 +13,8 @@ // limitations under the License. use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use neutron_sdk::bindings::query::QueryInterchainAccountAddressResponse; use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::interchaintxs::v1::QueryInterchainAccountAddressResponse; use neutron_validators_test::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use std::env::current_dir; use std::fs::create_dir_all; diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 831c3ee..1924e24 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -34,7 +34,6 @@ use cosmwasm_std::{ Response, StdError, StdResult, SubMsg, Uint128, }; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::ChannelOrdering; use neutron_sdk::interchain_queries::helpers::remove_interchain_query as helpers_remove_interchain_query; use neutron_sdk::interchain_queries::queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ @@ -53,6 +52,7 @@ use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; use neutron_std::shim::Any; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; +use neutron_std::types::ibc::core::channel::v1::Order; use neutron_std::types::ibc::core::client::v1::Height; use neutron_std::types::neutron::feerefunder::Fee; use neutron_std::types::neutron::interchainqueries::RegisteredQuery; @@ -290,7 +290,7 @@ fn execute_register_ica( connection_id, interchain_account_id.clone(), vec![], - Some(ChannelOrdering::OrderOrdered), + Some(Order::Ordered), ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; diff --git a/contracts/oracle/examples/schema.rs b/contracts/oracle/examples/schema.rs index 5217d6d..8b54f90 100644 --- a/contracts/oracle/examples/schema.rs +++ b/contracts/oracle/examples/schema.rs @@ -16,8 +16,8 @@ use std::env::current_dir; use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use neutron_sdk::bindings::oracle::query::OracleQuery; use oracle::contract::InstantiateMsg; +use oracle::msg::QueryMsg; fn main() { let mut out_dir = current_dir().unwrap(); @@ -26,5 +26,5 @@ fn main() { remove_schemas(&out_dir).unwrap(); export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(OracleQuery), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); } diff --git a/contracts/oracle/src/contract.rs b/contracts/oracle/src/contract.rs index c7460d2..eb683c1 100644 --- a/contracts/oracle/src/contract.rs +++ b/contracts/oracle/src/contract.rs @@ -1,19 +1,10 @@ -use crate::msg::QueryMsg; +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; use neutron_std::types::slinky::oracle::v1::OracleQuerier; use neutron_std::types::slinky::types::v1::CurrencyPair; -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)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg {} const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/contracts/oracle/src/lib.rs b/contracts/oracle/src/lib.rs index 37088ba..112ecad 100644 --- a/contracts/oracle/src/lib.rs +++ b/contracts/oracle/src/lib.rs @@ -1,2 +1,2 @@ pub mod contract; -mod msg; +pub mod msg; diff --git a/contracts/oracle/src/msg.rs b/contracts/oracle/src/msg.rs index 506253f..98eb798 100644 --- a/contracts/oracle/src/msg.rs +++ b/contracts/oracle/src/msg.rs @@ -1,6 +1,13 @@ 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)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { From f516e52ec1e9a3e5960e7b4c797518d7f0f0bda4 Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 16:53:04 +0400 Subject: [PATCH 18/34] make schema --- contracts/dex_grpc/schema/query_msg.json | 5 + .../schema/execute_msg.json | 36 +- .../schema/execute_msg.json | 35 +- ...y_interchain_account_address_response.json | 3 +- .../schema/sudo_msg.json | 9 +- ...y_interchain_account_address_response.json | 3 +- .../schema/sudo_msg.json | 9 +- contracts/reflect/schema/execute_msg.json | 1795 +---------------- .../tokenfactory/schema/execute_msg.json | 5 +- contracts/tokenfactory/schema/query_msg.json | 8 + 10 files changed, 118 insertions(+), 1790 deletions(-) diff --git a/contracts/dex_grpc/schema/query_msg.json b/contracts/dex_grpc/schema/query_msg.json index 3bc7e5e..7122ae1 100644 --- a/contracts/dex_grpc/schema/query_msg.json +++ b/contracts/dex_grpc/schema/query_msg.json @@ -842,6 +842,7 @@ "creator", "limit_sell_price", "max_amount_out", + "min_average_sell_price", "order_type", "receiver", "tick_index_in_to_out", @@ -872,6 +873,10 @@ "max_amount_out": { "type": "string" }, + "min_average_sell_price": { + "description": "min_average_sell_price is an optional parameter that sets a required minimum average price for the entire trade. if the min_average_sell_price is not met the trade will fail. If min_average_sell_price is omitted limit_sell_price will be used instead", + "type": "string" + }, "order_type": { "type": "integer", "format": "int32" diff --git a/contracts/neutron_interchain_queries/schema/execute_msg.json b/contracts/neutron_interchain_queries/schema/execute_msg.json index 0faca5d..a8bfe55 100644 --- a/contracts/neutron_interchain_queries/schema/execute_msg.json +++ b/contracts/neutron_interchain_queries/schema/execute_msg.json @@ -375,16 +375,15 @@ "update_interchain_query": { "type": "object", "required": [ + "new_keys", + "new_update_period", "query_id" ], "properties": { "new_keys": { - "type": [ - "array", - "null" - ], + "type": "array", "items": { - "$ref": "#/definitions/KVKey" + "$ref": "#/definitions/KvKey" } }, "new_recipient": { @@ -394,10 +393,7 @@ ] }, "new_update_period": { - "type": [ - "integer", - "null" - ], + "type": "integer", "format": "uint64", "minimum": 0.0 }, @@ -531,12 +527,7 @@ } ], "definitions": { - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", - "type": "string" - }, - "KVKey": { - "description": "Describes a KV key for which you want to get value from the storage on remote chain", + "KvKey": { "type": "object", "required": [ "key", @@ -544,15 +535,16 @@ ], "properties": { "key": { - "description": "*key** is a key you want to read from the storage", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] + "description": "Key you want to read from the storage", + "type": "array", + "items": { + "type": "integer", + "format": "uint8", + "minimum": 0.0 + } }, "path": { - "description": "*path** is a path to the storage (storage prefix) where you want to read value by key (usually name of cosmos-packages module: 'staking', 'bank', etc.)", + "description": "Path (storage prefix) to the storage where you want to read value by key (usually name of cosmos-sdk module: 'staking', 'bank', etc.)", "type": "string" } }, diff --git a/contracts/neutron_interchain_txs/schema/execute_msg.json b/contracts/neutron_interchain_txs/schema/execute_msg.json index d80aedf..297efea 100644 --- a/contracts/neutron_interchain_txs/schema/execute_msg.json +++ b/contracts/neutron_interchain_txs/schema/execute_msg.json @@ -24,7 +24,7 @@ "ordering": { "anyOf": [ { - "$ref": "#/definitions/ChannelOrdering" + "$ref": "#/definitions/Order" }, { "type": "null" @@ -309,13 +309,6 @@ } ], "definitions": { - "ChannelOrdering": { - "type": "string", - "enum": [ - "ORDER_ORDERED", - "ORDER_UNORDERED" - ] - }, "IntegrationTestsSudoFailureMock": { "type": "string", "enum": [ @@ -324,6 +317,32 @@ "disabled" ] }, + "Order": { + "description": "Order defines if a channel is ORDERED or UNORDERED", + "oneOf": [ + { + "description": "zero-value for channel ordering", + "type": "string", + "enum": [ + "NoneUnspecified" + ] + }, + { + "description": "packets can be delivered in any order, which may differ from the order in which they were sent.", + "type": "string", + "enum": [ + "Unordered" + ] + }, + { + "description": "packets are delivered exactly in the order which they were sent", + "type": "string", + "enum": [ + "Ordered" + ] + } + ] + }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" diff --git a/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json b/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json index d1314a5..1effeab 100644 --- a/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json +++ b/contracts/neutron_interchain_txs/schema/query_interchain_account_address_response.json @@ -1,13 +1,14 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "QueryInterchainAccountAddressResponse", + "description": "Query response for an interchain account address", "type": "object", "required": [ "interchain_account_address" ], "properties": { "interchain_account_address": { - "description": "*interchain_account_address** is a interchain account address on the remote chain", + "description": "The corresponding interchain account address on the host chain", "type": "string" } }, diff --git a/contracts/neutron_interchain_txs/schema/sudo_msg.json b/contracts/neutron_interchain_txs/schema/sudo_msg.json index de8ad10..da97da0 100644 --- a/contracts/neutron_interchain_txs/schema/sudo_msg.json +++ b/contracts/neutron_interchain_txs/schema/sudo_msg.json @@ -167,18 +167,21 @@ "type": "string" }, "Height": { + "description": "Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients\n\nNormally the RevisionHeight is incremented at each height while keeping RevisionNumber the same. However some consensus algorithms may choose to reset the height in certain conditions e.g. hard forks, state-machine breaking changes In these cases, the RevisionNumber is incremented so that height continues to be monitonically increasing even as the RevisionHeight gets reset", "type": "object", + "required": [ + "revision_height", + "revision_number" + ], "properties": { "revision_height": { - "description": "*height** is a height of remote chain", - "default": 0, + "description": "the height within the given revision", "type": "integer", "format": "uint64", "minimum": 0.0 }, "revision_number": { "description": "the revision that the client is currently on", - "default": 0, "type": "integer", "format": "uint64", "minimum": 0.0 diff --git a/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json b/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json index d1314a5..1effeab 100644 --- a/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json +++ b/contracts/neutron_validator_test/schema/query_interchain_account_address_response.json @@ -1,13 +1,14 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "QueryInterchainAccountAddressResponse", + "description": "Query response for an interchain account address", "type": "object", "required": [ "interchain_account_address" ], "properties": { "interchain_account_address": { - "description": "*interchain_account_address** is a interchain account address on the remote chain", + "description": "The corresponding interchain account address on the host chain", "type": "string" } }, diff --git a/contracts/neutron_validator_test/schema/sudo_msg.json b/contracts/neutron_validator_test/schema/sudo_msg.json index de8ad10..da97da0 100644 --- a/contracts/neutron_validator_test/schema/sudo_msg.json +++ b/contracts/neutron_validator_test/schema/sudo_msg.json @@ -167,18 +167,21 @@ "type": "string" }, "Height": { + "description": "Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients\n\nNormally the RevisionHeight is incremented at each height while keeping RevisionNumber the same. However some consensus algorithms may choose to reset the height in certain conditions e.g. hard forks, state-machine breaking changes In these cases, the RevisionNumber is incremented so that height continues to be monitonically increasing even as the RevisionHeight gets reset", "type": "object", + "required": [ + "revision_height", + "revision_number" + ], "properties": { "revision_height": { - "description": "*height** is a height of remote chain", - "default": 0, + "description": "the height within the given revision", "type": "integer", "format": "uint64", "minimum": 0.0 }, "revision_number": { "description": "the revision that the client is currently on", - "default": 0, "type": "integer", "format": "uint64", "minimum": 0.0 diff --git a/contracts/reflect/schema/execute_msg.json b/contracts/reflect/schema/execute_msg.json index 69c7dd8..a9c70df 100644 --- a/contracts/reflect/schema/execute_msg.json +++ b/contracts/reflect/schema/execute_msg.json @@ -42,7 +42,7 @@ "msgs": { "type": "array", "items": { - "$ref": "#/definitions/CosmosMsg_for_NeutronMsg" + "$ref": "#/definitions/CosmosMsg_for_Empty" } } }, @@ -53,163 +53,6 @@ } ], "definitions": { - "AdminProposal": { - "description": "AdminProposal defines the struct for various proposals which Neutron's Admin Module may accept.", - "oneOf": [ - { - "description": "Proposal to change params. Note that this works for old params. New params has their own `MsgUpdateParams` msgs that can be supplied to `ProposalExecuteMessage`", - "type": "object", - "required": [ - "param_change_proposal" - ], - "properties": { - "param_change_proposal": { - "$ref": "#/definitions/ParamChangeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to upgrade IBC client", - "deprecated": true, - "type": "object", - "required": [ - "upgrade_proposal" - ], - "properties": { - "upgrade_proposal": { - "$ref": "#/definitions/UpgradeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to update IBC client", - "deprecated": true, - "type": "object", - "required": [ - "client_update_proposal" - ], - "properties": { - "client_update_proposal": { - "$ref": "#/definitions/ClientUpdateProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Proposal to execute CosmosMsg.", - "type": "object", - "required": [ - "proposal_execute_message" - ], - "properties": { - "proposal_execute_message": { - "$ref": "#/definitions/ProposalExecuteMessage" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to upgrade network", - "deprecated": true, - "type": "object", - "required": [ - "software_upgrade_proposal" - ], - "properties": { - "software_upgrade_proposal": { - "$ref": "#/definitions/SoftwareUpgradeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to cancel existing software upgrade", - "deprecated": true, - "type": "object", - "required": [ - "cancel_software_upgrade_proposal" - ], - "properties": { - "cancel_software_upgrade_proposal": { - "$ref": "#/definitions/CancelSoftwareUpgradeProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Will fail to execute if you use it. Deprecated. Proposal to pin wasm contract codes", - "deprecated": true, - "type": "object", - "required": [ - "pin_codes_proposal" - ], - "properties": { - "pin_codes_proposal": { - "$ref": "#/definitions/PinCodesProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Deprecated. Proposal to unpin wasm contract codes.", - "deprecated": true, - "type": "object", - "required": [ - "unpin_codes_proposal" - ], - "properties": { - "unpin_codes_proposal": { - "$ref": "#/definitions/UnpinCodesProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to call sudo on contract.", - "deprecated": true, - "type": "object", - "required": [ - "sudo_contract_proposal" - ], - "properties": { - "sudo_contract_proposal": { - "$ref": "#/definitions/SudoContractProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to update contract admin.", - "deprecated": true, - "type": "object", - "required": [ - "update_admin_proposal" - ], - "properties": { - "update_admin_proposal": { - "$ref": "#/definitions/UpdateAdminProposal" - } - }, - "additionalProperties": false - }, - { - "description": "Deprecated. Proposal to clear contract admin.", - "deprecated": true, - "type": "object", - "required": [ - "clear_admin_proposal" - ], - "properties": { - "clear_admin_proposal": { - "$ref": "#/definitions/ClearAdminProposal" - } - }, - "additionalProperties": false - } - ] - }, "AnyMsg": { "description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", "type": "object", @@ -290,88 +133,6 @@ "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", "type": "string" }, - "CancelSoftwareUpgradeProposal": { - "description": "Deprecated. CancelSoftwareUpgradeProposal defines the struct for cancel software upgrade proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal. Non unique.", - "type": "string" - } - }, - "additionalProperties": false - }, - "ChannelOrdering": { - "type": "string", - "enum": [ - "ORDER_ORDERED", - "ORDER_UNORDERED" - ] - }, - "ClearAdminProposal": { - "description": "Deprecated. SudoContractProposal defines the struct for clear admin proposal.", - "deprecated": true, - "type": "object", - "required": [ - "contract", - "description", - "title" - ], - "properties": { - "contract": { - "description": "*contract** is an address of contract admin will be removed.", - "type": "string" - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - }, - "additionalProperties": false - }, - "ClientUpdateProposal": { - "description": "ClientUpdateProposal defines the struct for client update proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "subject_client_id", - "substitute_client_id", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "subject_client_id": { - "description": "*subject_client_id** is a subject client id.", - "type": "string" - }, - "substitute_client_id": { - "description": "*substitute_client_id** is a substitute client id.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - }, - "additionalProperties": false - }, "Coin": { "type": "object", "required": [ @@ -388,7 +149,7 @@ }, "additionalProperties": false }, - "CosmosMsg_for_NeutronMsg": { + "CosmosMsg_for_Empty": { "oneOf": [ { "type": "object", @@ -409,7 +170,7 @@ ], "properties": { "custom": { - "$ref": "#/definitions/NeutronMsg" + "$ref": "#/definitions/Empty" } }, "additionalProperties": false @@ -520,120 +281,24 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, - "DenomUnit": { - "description": "Replicates the cosmos-sdk bank module DenomUnit type", - "type": "object", - "required": [ - "aliases", - "denom", - "exponent" - ], - "properties": { - "aliases": { - "type": "array", - "items": { - "type": "string" - } - }, - "denom": { - "type": "string" - }, - "exponent": { - "type": "integer", - "format": "uint32", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - "DepositOptions": { - "type": "object", - "properties": { - "disable_autoswap": { - "type": [ - "boolean", - "null" - ] - }, - "fail_tx_on_bel": { - "type": [ - "boolean", - "null" - ] - } - }, - "additionalProperties": false - }, - "DexMsg": { + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", "oneOf": [ { - "description": "Deposit provides liquidity to a specific trading pair by depositing tokens at a specific price into one or both sides of the pair in “a liquidity pool”", + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "deposit" + "set_withdraw_address" ], "properties": { - "deposit": { + "set_withdraw_address": { "type": "object", "required": [ - "amounts_a", - "amounts_b", - "fees", - "options", - "receiver", - "tick_indexes_a_to_b", - "token_a", - "token_b" + "address" ], "properties": { - "amounts_a": { - "description": "Amounts of tokenA to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "amounts_b": { - "description": "Amounts of tokenB to deposit", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "fees": { - "description": "Fees to use for each deposit", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "options": { - "description": "Additional deposit options", - "type": "array", - "items": { - "$ref": "#/definitions/DepositOptions" - } - }, - "receiver": { - "description": "The account to which PoolShares will be issued", - "type": "string" - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes to deposit at defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", + "address": { + "description": "The `withdraw_address`", "type": "string" } }, @@ -643,57 +308,20 @@ "additionalProperties": false }, { - "description": "Withdraw is used to redeem PoolShares for the user’s pro-rata portion of tokens within a liquidity pool. Users can withdraw from a pool at any time", + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "withdrawal" + "withdraw_delegator_reward" ], "properties": { - "withdrawal": { + "withdraw_delegator_reward": { "type": "object", "required": [ - "fees", - "receiver", - "shares_to_remove", - "tick_indexes_a_to_b", - "token_a", - "token_b" + "validator" ], "properties": { - "fees": { - "description": "Fee for the target LiquidityPools", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "receiver": { - "description": "The account to which the tokens are credited", - "type": "string" - }, - "shares_to_remove": { - "description": "Amount of shares to remove from each pool", - "type": "array", - "items": { - "$ref": "#/definitions/Uint128" - } - }, - "tick_indexes_a_to_b": { - "description": "Tick indexes of the target LiquidityPools defined in terms of TokenA to TokenB (ie. TokenA is on the left)", - "type": "array", - "items": { - "type": "integer", - "format": "int64" - } - }, - "token_a": { - "description": "Denom for one side of the deposit", - "type": "string" - }, - "token_b": { - "description": "Denom for the opposing side of the deposit", + "validator": { + "description": "The `validator_address`", "type": "string" } }, @@ -703,249 +331,16 @@ "additionalProperties": false }, { - "description": "PlaceLimitOrder provides the primary mechanism for trading on the Duality Dex. Limit orders can provide liquidity to the Dex (“Maker Limit Orders”) and/or can be used to trade against preexisting liquidity (“Taker Limit Orders”)", + "description": "This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2). `depositor` is automatically filled with the current contract's address.", "type": "object", "required": [ - "place_limit_order" + "fund_community_pool" ], "properties": { - "place_limit_order": { + "fund_community_pool": { "type": "object", "required": [ - "amount_in", - "limit_sell_price", - "order_type", - "receiver", - "tick_index_in_to_out", - "token_in", - "token_out" - ], - "properties": { - "amount_in": { - "description": "Amount of TokenIn to be traded", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "expiration_time": { - "description": "Expiration time for order. Only valid for GOOD_TIL_TIME limit orders", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "limit_sell_price": { - "description": "Accepts standard decimals and decimals with scientific notation (ie. 1234.23E-7)", - "type": "string" - }, - "max_amount_out": { - "description": "Maximum amount of TokenB can be bought. For everything except JUST_IN_TIME OrderType", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - }, - "order_type": { - "description": "Type of limit order to be used. Must be one of: GOOD_TIL_CANCELLED, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, JUST_IN_TIME, or GOOD_TIL_TIME", - "allOf": [ - { - "$ref": "#/definitions/LimitOrderType" - } - ] - }, - "receiver": { - "description": "Account to which TokenOut is credited or that will be allowed to withdraw or cancel a maker order", - "type": "string" - }, - "tick_index_in_to_out": { - "description": "Limit tick for a limit order, specified in terms of TokenIn to TokenOut", - "type": "integer", - "format": "int64" - }, - "token_in": { - "description": "Token being “sold”", - "type": "string" - }, - "token_out": { - "description": "Token being “bought”", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "WithdrawFilledLimitOrder. Once a limit order has been filled – either partially or in its entirety, it can be withdrawn at any time. Withdrawing from a limit order credits all available proceeds to the user. Withdraw can be called on a limit order multiple times as new proceeds become available", - "type": "object", - "required": [ - "withdraw_filled_limit_order" - ], - "properties": { - "withdraw_filled_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "CancelLimitOrder. Standard Taker limit orders (Good-til-cancelled & Good-til-Time) can be canceled at any time if they have not been completely filled", - "type": "object", - "required": [ - "cancel_limit_order" - ], - "properties": { - "cancel_limit_order": { - "type": "object", - "required": [ - "tranche_key" - ], - "properties": { - "tranche_key": { - "description": "TrancheKey for the target limit order", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "MultiHopSwap provides a swapping mechanism to achieve better prices by routing through a series of pools", - "type": "object", - "required": [ - "multi_hop_swap" - ], - "properties": { - "multi_hop_swap": { - "type": "object", - "required": [ - "amount_in", - "exit_limit_price", - "pick_best_route", - "receiver", - "routes" - ], - "properties": { - "amount_in": { - "description": "Amount of TokenIn to swap", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "exit_limit_price": { - "description": "Minimum price that that must be satisfied for a route to succeed", - "allOf": [ - { - "$ref": "#/definitions/PrecDec" - } - ] - }, - "pick_best_route": { - "description": "If true all routes are run and the route with the best price is used", - "type": "boolean" - }, - "receiver": { - "description": "Account to which TokenOut is credited", - "type": "string" - }, - "routes": { - "description": "Array of possible routes", - "type": "array", - "items": { - "$ref": "#/definitions/MultiHopRoute" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2). `depositor` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "fund_community_pool" - ], - "properties": { - "fund_community_pool": { - "type": "object", - "required": [ - "amount" + "amount" ], "properties": { "amount": { @@ -963,6 +358,11 @@ } ] }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object", + "additionalProperties": false + }, "GovMsg": { "description": "This message type allows the contract interact with the [x/gov] module in order to cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); use cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::Vote { proposal_id: 4, option: VoteOption::Yes, })) } ```\n\nCast a weighted vote:\n\n``` # use cosmwasm_std::{ # HexBinary, # Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo, # Response, QueryResponse, # }; # type ExecuteMsg = (); # #[cfg(feature = \"cosmwasm_1_2\")] use cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption};\n\n# #[cfg(feature = \"cosmwasm_1_2\")] #[entry_point] pub fn execute( deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { // ... Ok(Response::new().add_message(GovMsg::VoteWeighted { proposal_id: 4, options: vec![ WeightedVoteOption { option: VoteOption::Yes, weight: Decimal::percent(65), }, WeightedVoteOption { option: VoteOption::Abstain, weight: Decimal::percent(35), }, ], })) } ```", "oneOf": [ @@ -1032,39 +432,6 @@ } ] }, - "IbcFee": { - "description": "IbcFee defines struct for fees that refund the relayer for `SudoMsg` messages submission. Unused fee kind will be returned back to message sender. Please refer to these links for more information: IBC transaction structure - General mechanics of fee payments - ", - "type": "object", - "required": [ - "ack_fee", - "recv_fee", - "timeout_fee" - ], - "properties": { - "ack_fee": { - "description": "*ack_fee** is an amount of coins to refund relayer for submitting ack message for a particular IBC packet.", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "recv_fee": { - "description": "**recv_fee** currently is used for compatibility with ICS-29 interface only and must be set to zero (i.e. 0untrn), because Neutron's fee module can't refund relayer for submission of Recv IBC packets due to compatibility with target chains.", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "timeout_fee": { - "description": "*timeout_fee** amount of coins to refund relayer for submitting timeout message for a particular IBC packet.", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -1230,147 +597,28 @@ }, "additionalProperties": false }, - "KVKey": { - "description": "Describes a KV key for which you want to get value from the storage on remote chain", - "type": "object", - "required": [ - "key", - "path" - ], - "properties": { - "key": { - "description": "*key** is a key you want to read from the storage", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "path": { - "description": "*path** is a path to the storage (storage prefix) where you want to read value by key (usually name of cosmos-packages module: 'staking', 'bank', etc.)", - "type": "string" - } - }, - "additionalProperties": false - }, - "LimitOrderType": { - "oneOf": [ - { - "description": "Good-til-Cancelled limit orders are hybrid maker and taker limit orders. They will attempt to trade the supplied AmountIn at the TickIndex or better. However, if they total AmountIn cannot be traded at the limit price they are remaining amount will be placed as a maker limit order. The proceeds from the taker portion are deposited into the user’s account immediately, however, the proceeds from the maker portion must be explicitly withdrawn via WithdrawLimitOrder.", - "type": "string", - "enum": [ - "GOOD_TIL_CANCELLED" - ] - }, - { - "description": "Fill-or-Kill limit orders are taker limit orders that either successfully swap 100% of the supplied AmountIn or return an error. If there is insufficient liquidity to complete the trade at or above the supplied TickIndex a Fill-or-Kill order will return an error `codespace: dex, code: 1134` ( ErrGoodTilOrderWithoutExpiration).", - "type": "string", - "enum": [ - "FILL_OR_KILL" - ] - }, - { - "description": "Immediate-or-Cancel limit orders are taker orders that will swap as much as of the AmountIn as possible given available liquidity above the supplied TickIndex. Unlike Fill-or-Kill orders they will still successfully complete even if they are only able to partially trade through the AmountIn at the TickIndex or better.", - "type": "string", - "enum": [ - "IMMEDIATE_OR_CANCEL" - ] - }, - { - "description": "Just-in-Time limit orders are an advanced maker limit order that provides tradeable liquidity for exactly one block. At the end of the same block in which the Just-in-Time order was submitted the order is canceled and any untraded portion will no longer be usable as active liquidity.", - "type": "string", - "enum": [ - "JUST_IN_TIME" - ] - }, - { - "description": "Good-til-Time limit order function exactly the same as Good-til-Cancelled limit orders first trying to trade as a taker limit order and then placing any remaining amount as a maker limit order. However, the maker portion of the limit order has a specified ExpirationTime. After the ExpirationTime the order will be cancelled and can no longer be traded against. When withdrawing a Good-til-Time limit order the user will receive both the successfully traded portion of the limit order (TokenOut) as well as any remaining untraded amount (TokenIn).", - "type": "string", - "enum": [ - "GOOD_TIL_TIME" - ] - } - ] - }, - "MsgExecuteContract": { - "description": "MsgExecuteContract defines a call to the contract execution", - "type": "object", - "required": [ - "contract", - "msg" - ], - "properties": { - "contract": { - "description": "*contract** is a contract address that will be called", - "type": "string" - }, - "msg": { - "description": "*msg** is a contract call message", - "type": "string" - } - }, - "additionalProperties": false - }, - "MultiHopRoute": { - "type": "object", - "required": [ - "hops" - ], - "properties": { - "hops": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - }, - "NeutronMsg": { - "description": "A number of Custom messages that can call into the Neutron bindings.", + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", "oneOf": [ { - "description": "RegisterInterchainAccount registers an interchain account on remote chain.", + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "register_interchain_account" + "delegate" ], "properties": { - "register_interchain_account": { + "delegate": { "type": "object", "required": [ - "connection_id", - "interchain_account_id" + "amount", + "validator" ], "properties": { - "connection_id": { - "description": "*connection_id** is an IBC connection identifier between Neutron and remote chain.", - "type": "string" + "amount": { + "$ref": "#/definitions/Coin" }, - "interchain_account_id": { - "description": "**interchain_account_id** is an identifier of your new interchain account. Can be any string. This identifier allows contracts to have multiple interchain accounts on remote chains.", + "validator": { "type": "string" - }, - "ordering": { - "description": "**ordering** is an order of channel. Can be ordered or unordered. Set to ordered if not specified.", - "anyOf": [ - { - "$ref": "#/definitions/ChannelOrdering" - }, - { - "type": "null" - } - ] - }, - "register_fee": { - "description": "*register_fee** is a fees required to be payed to register interchain account", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Coin" - } } }, "additionalProperties": false @@ -1379,846 +627,23 @@ "additionalProperties": false }, { - "description": "SubmitTx starts the process of executing any Cosmos-SDK *msgs* on remote chain.", + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", "type": "object", "required": [ - "submit_tx" + "undelegate" ], "properties": { - "submit_tx": { + "undelegate": { "type": "object", "required": [ - "connection_id", - "fee", - "interchain_account_id", - "memo", - "msgs", - "timeout" + "amount", + "validator" ], "properties": { - "connection_id": { - "description": "*connection_id** is an IBC connection identifier between Neutron and remote chain.", - "type": "string" - }, - "fee": { - "description": "**fee** is an ibc fee for the transaction.", - "allOf": [ - { - "$ref": "#/definitions/IbcFee" - } - ] - }, - "interchain_account_id": { - "description": "*interchain_account_id** is an identifier of your interchain account from which you want to execute msgs.", - "type": "string" + "amount": { + "$ref": "#/definitions/Coin" }, - "memo": { - "description": "*memo** is a memo you want to attach to your interchain transaction.It behaves like a memo in usual Cosmos transaction.", - "type": "string" - }, - "msgs": { - "description": "*msgs** is a list of protobuf encoded Cosmos-SDK messages you want to execute on remote chain.", - "type": "array", - "items": { - "$ref": "#/definitions/ProtobufAny" - } - }, - "timeout": { - "description": "*timeout** is a timeout in seconds after which the packet times out.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "RegisterInterchainQuery registers an interchain query.", - "type": "object", - "required": [ - "register_interchain_query" - ], - "properties": { - "register_interchain_query": { - "type": "object", - "required": [ - "connection_id", - "keys", - "query_type", - "transactions_filter", - "update_period" - ], - "properties": { - "connection_id": { - "description": "*connection_id** is an IBC connection identifier between Neutron and remote chain.", - "type": "string" - }, - "keys": { - "description": "*keys** is the KV-storage keys for which we want to get values from remote chain.", - "type": "array", - "items": { - "$ref": "#/definitions/KVKey" - } - }, - "query_type": { - "description": "*query_type** is a query type identifier ('tx' or 'kv' for now).", - "type": "string" - }, - "transactions_filter": { - "description": "*transactions_filter** is the filter for transaction search ICQ.", - "type": "string" - }, - "update_period": { - "description": "*update_period** is used to say how often the query must be updated.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "RegisterInterchainQuery updates an interchain query.", - "type": "object", - "required": [ - "update_interchain_query" - ], - "properties": { - "update_interchain_query": { - "type": "object", - "required": [ - "query_id" - ], - "properties": { - "new_keys": { - "description": "*new_keys** is the new query keys to retrieve.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/KVKey" - } - }, - "new_transactions_filter": { - "description": "*new_transactions_filter** is a new transactions filter of the query.", - "type": [ - "string", - "null" - ] - }, - "new_update_period": { - "description": "*new_update_period** is a new update period of the query.", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "query_id": { - "description": "*query_id** is the ID of the query we want to update.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "RemoveInterchainQuery removes as interchain query.", - "type": "object", - "required": [ - "remove_interchain_query" - ], - "properties": { - "remove_interchain_query": { - "type": "object", - "required": [ - "query_id" - ], - "properties": { - "query_id": { - "description": "*query_id** is ID of the query we want to remove.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "IbcTransfer sends a fungible token packet over IBC.", - "type": "object", - "required": [ - "ibc_transfer" - ], - "properties": { - "ibc_transfer": { - "type": "object", - "required": [ - "fee", - "memo", - "receiver", - "sender", - "source_channel", - "source_port", - "timeout_height", - "timeout_timestamp", - "token" - ], - "properties": { - "fee": { - "$ref": "#/definitions/IbcFee" - }, - "memo": { - "type": "string" - }, - "receiver": { - "type": "string" - }, - "sender": { - "type": "string" - }, - "source_channel": { - "type": "string" - }, - "source_port": { - "type": "string" - }, - "timeout_height": { - "$ref": "#/definitions/RequestPacketTimeoutHeight" - }, - "timeout_timestamp": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "token": { - "$ref": "#/definitions/Coin" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "SubmitAdminProposal sends a proposal to neutron's Admin module. This type of messages can be only executed by Neutron DAO.", - "type": "object", - "required": [ - "submit_admin_proposal" - ], - "properties": { - "submit_admin_proposal": { - "type": "object", - "required": [ - "admin_proposal" - ], - "properties": { - "admin_proposal": { - "$ref": "#/definitions/AdminProposal" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can create denoms, namespaced under the contract's address. A contract may create any number of independent sub-denoms.", - "type": "object", - "required": [ - "create_denom" - ], - "properties": { - "create_denom": { - "type": "object", - "required": [ - "subdenom" - ], - "properties": { - "subdenom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can change the admin of a denom that they are the admin of.", - "type": "object", - "required": [ - "change_admin" - ], - "properties": { - "change_admin": { - "type": "object", - "required": [ - "denom", - "new_admin_address" - ], - "properties": { - "denom": { - "type": "string" - }, - "new_admin_address": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can mint native tokens for an existing factory denom that they are the admin of.", - "type": "object", - "required": [ - "mint_tokens" - ], - "properties": { - "mint_tokens": { - "type": "object", - "required": [ - "amount", - "denom", - "mint_to_address" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - }, - "mint_to_address": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can burn native tokens for an existing factory denom that they are the admin of. Currently, the burn from address must be the admin contract.", - "type": "object", - "required": [ - "burn_tokens" - ], - "properties": { - "burn_tokens": { - "type": "object", - "required": [ - "amount", - "burn_from_address", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "burn_from_address": { - "description": "Must be set to `\"\"` for now", - "type": "string" - }, - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactory message. Contracts can set before send hooks for denoms, namespaced under the contract's address.", - "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 - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactoryMessage Contracts can force specified `amount` of an existing factory denom that they are admin of to a `transfer_to_address` from a `transfer_from_address`.", - "type": "object", - "required": [ - "force_transfer" - ], - "properties": { - "force_transfer": { - "type": "object", - "required": [ - "amount", - "denom", - "transfer_from_address", - "transfer_to_address" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - }, - "transfer_from_address": { - "type": "string" - }, - "transfer_to_address": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "TokenFactoryMessage Contracts can set a metadata for of an existing factory denom that they are admin of.", - "type": "object", - "required": [ - "set_denom_metadata" - ], - "properties": { - "set_denom_metadata": { - "type": "object", - "required": [ - "base", - "denom_units", - "description", - "display", - "name", - "symbol", - "uri", - "uri_hash" - ], - "properties": { - "base": { - "description": "*base** represents the base denom (should be the DenomUnit with exponent = 0).", - "type": "string" - }, - "denom_units": { - "description": "*denom_units** represents the list of DenomUnit's for a given coin", - "type": "array", - "items": { - "$ref": "#/definitions/DenomUnit" - } - }, - "description": { - "description": "*description** description of a token", - "type": "string" - }, - "display": { - "description": "**display** indicates the suggested denom that should be displayed in clients.", - "type": "string" - }, - "name": { - "description": "*name** defines the name of the token (eg: Cosmos Atom)", - "type": "string" - }, - "symbol": { - "description": "**symbol** is the token symbol usually shown on exchanges (eg: ATOM). This can be the same as the display.", - "type": "string" - }, - "uri": { - "description": "*uri** to a document (on or off-chain) that contains additional information. Optional.", - "type": "string" - }, - "uri_hash": { - "description": "**uri_hash** is a sha256 hash of a document pointed by URI. It's used to verify that the document didn't change. Optional.", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "AddSchedule adds new schedule with a given `name`. Until schedule is removed it will execute all `msgs` every `period` blocks. First execution is at least on `current_block + period` block. [Permissioned - DAO Only]", - "type": "object", - "required": [ - "add_schedule" - ], - "properties": { - "add_schedule": { - "type": "object", - "required": [ - "msgs", - "name", - "period" - ], - "properties": { - "msgs": { - "description": "list of cosmwasm messages to be executed", - "type": "array", - "items": { - "$ref": "#/definitions/MsgExecuteContract" - } - }, - "name": { - "description": "Name of a new schedule. Needed to be able to `RemoveSchedule` and to log information about it", - "type": "string" - }, - "period": { - "description": "period in blocks with which `msgs` will be executed", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "RemoveSchedule removes the schedule with a given `name`. [Permissioned - DAO or Security DAO only]", - "type": "object", - "required": [ - "remove_schedule" - ], - "properties": { - "remove_schedule": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Contractmanager message Resubmits failed acknowledgement. Acknowledgement failure is created when contract returns error or acknowledgement is out of gas. [Permissioned - only from contract that is initial caller of IBC transaction]", - "type": "object", - "required": [ - "resubmit_failure" - ], - "properties": { - "resubmit_failure": { - "type": "object", - "required": [ - "failure_id" - ], - "properties": { - "failure_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Dex messages", - "type": "object", - "required": [ - "dex" - ], - "properties": { - "dex": { - "$ref": "#/definitions/DexMsg" - } - }, - "additionalProperties": false - } - ] - }, - "ParamChange": { - "description": "ParamChange defines the struct for parameter change request.", - "type": "object", - "required": [ - "key", - "subspace", - "value" - ], - "properties": { - "key": { - "description": "*key** is a name of parameter. Unique for subspace.", - "type": "string" - }, - "subspace": { - "description": "*subspace** is a key of module to which the parameter to change belongs. Unique for each module.", - "type": "string" - }, - "value": { - "description": "*value** is a new value for given parameter. Non unique.", - "type": "string" - } - }, - "additionalProperties": false - }, - "ParamChangeProposal": { - "description": "ParamChangeProposal defines the struct for single parameter change proposal.", - "type": "object", - "required": [ - "description", - "param_changes", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "param_changes": { - "description": "*param_changes** is a vector of params to be changed. Non unique.", - "type": "array", - "items": { - "$ref": "#/definitions/ParamChange" - } - }, - "title": { - "description": "*title** is a text title of proposal. Non unique.", - "type": "string" - } - }, - "additionalProperties": false - }, - "PinCodesProposal": { - "description": "Deprecated. PinCodesProposal defines the struct for pin contract codes proposal.", - "deprecated": true, - "type": "object", - "required": [ - "code_ids", - "description", - "title" - ], - "properties": { - "code_ids": { - "description": "*code_ids** is an array of codes to be pined.", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - }, - "additionalProperties": false - }, - "Plan": { - "description": "Plan defines the struct for planned upgrade.", - "type": "object", - "required": [ - "height", - "info", - "name" - ], - "properties": { - "height": { - "description": "*height** is a height at which the upgrade must be performed", - "type": "integer", - "format": "int64" - }, - "info": { - "description": "*info** is any application specific upgrade info to be included on-chain", - "type": "string" - }, - "name": { - "description": "*name** is a name for the upgrade", - "type": "string" - } - }, - "additionalProperties": false - }, - "PrecDec": { - "type": "object", - "required": [ - "i" - ], - "properties": { - "i": { - "type": "string" - } - }, - "additionalProperties": false - }, - "ProposalExecuteMessage": { - "description": "ProposalExecuteMessage defines the struct for sdk47 compatible admin proposal.", - "type": "object", - "required": [ - "message" - ], - "properties": { - "message": { - "description": "*message** is a json representing an sdk message passed to admin module to execute.", - "type": "string" - } - }, - "additionalProperties": false - }, - "ProtobufAny": { - "description": "Type for wrapping any protobuf message", - "type": "object", - "required": [ - "type_url", - "value" - ], - "properties": { - "type_url": { - "description": "*type_url** describes the type of the serialized message", - "type": "string" - }, - "value": { - "description": "*value** must be a valid serialized protocol buffer of the above specified type", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - }, - "additionalProperties": false - }, - "RequestPacketTimeoutHeight": { - "type": "object", - "properties": { - "revision_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "revision_number": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - "SoftwareUpgradeProposal": { - "description": "Deprecated. SoftwareUpgradeProposal defines the struct for software upgrade proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "plan", - "title" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal. Non unique.", - "type": "string" - }, - "plan": { - "description": "*plan** is a plan of upgrade.", - "allOf": [ - { - "$ref": "#/definitions/Plan" - } - ] - }, - "title": { - "description": "*title** is a text title of proposal. Non unique.", - "type": "string" - } - }, - "additionalProperties": false - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { + "validator": { "type": "string" } }, @@ -2259,40 +684,6 @@ } ] }, - "SudoContractProposal": { - "description": "Deprecated. SudoContractProposal defines the struct for sudo execution proposal.", - "deprecated": true, - "type": "object", - "required": [ - "contract", - "description", - "msg", - "title" - ], - "properties": { - "contract": { - "description": "*contract** is an address of contract to be executed.", - "type": "string" - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "msg": { - "description": "**msg*** is a sudo message.", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - }, - "additionalProperties": false - }, "Timestamp": { "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", "allOf": [ @@ -2309,104 +700,6 @@ "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", "type": "string" }, - "UnpinCodesProposal": { - "description": "Deprecated. UnpinCodesProposal defines the struct for unpin contract codes proposal.", - "deprecated": true, - "type": "object", - "required": [ - "code_ids", - "description", - "title" - ], - "properties": { - "code_ids": { - "description": "*code_ids** is an array of codes to be unpined.", - "type": "array", - "items": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - }, - "additionalProperties": false - }, - "UpdateAdminProposal": { - "description": "Deprecated. UpdateAdminProposal defines the struct for update admin proposal.", - "deprecated": true, - "type": "object", - "required": [ - "contract", - "description", - "new_admin", - "title" - ], - "properties": { - "contract": { - "description": "*contract** is an address of contract to update admin.", - "type": "string" - }, - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "new_admin": { - "description": "**new_admin*** is an address of new admin", - "type": "string" - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - } - }, - "additionalProperties": false - }, - "UpgradeProposal": { - "description": "UpgradeProposal defines the struct for IBC upgrade proposal.", - "deprecated": true, - "type": "object", - "required": [ - "description", - "plan", - "title", - "upgraded_client_state" - ], - "properties": { - "description": { - "description": "*description** is a text description of proposal.", - "type": "string" - }, - "plan": { - "description": "*plan** is a plan of upgrade.", - "allOf": [ - { - "$ref": "#/definitions/Plan" - } - ] - }, - "title": { - "description": "*title** is a text title of proposal.", - "type": "string" - }, - "upgraded_client_state": { - "description": "*upgraded_client_state** is an upgraded client state.", - "allOf": [ - { - "$ref": "#/definitions/ProtobufAny" - } - ] - } - }, - "additionalProperties": false - }, "VoteOption": { "type": "string", "enum": [ diff --git a/contracts/tokenfactory/schema/execute_msg.json b/contracts/tokenfactory/schema/execute_msg.json index ce3284f..71dfbee 100644 --- a/contracts/tokenfactory/schema/execute_msg.json +++ b/contracts/tokenfactory/schema/execute_msg.json @@ -252,7 +252,7 @@ ], "definitions": { "DenomUnit": { - "description": "Replicates the cosmos-sdk bank module DenomUnit type", + "description": "DenomUnit represents a struct that describes a given denomination unit of the basic token.", "type": "object", "required": [ "aliases", @@ -261,15 +261,18 @@ ], "properties": { "aliases": { + "description": "aliases is a list of string aliases for the given denom", "type": "array", "items": { "type": "string" } }, "denom": { + "description": "denom represents the string name of the given denom unit (e.g uatom).", "type": "string" }, "exponent": { + "description": "exponent represents power of 10 exponent that one must raise the base_denom to in order to equal the given DenomUnit's denom 1 denom = 10^exponent base_denom (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with exponent = 6, thus: 1 atom = 10^6 uatom).", "type": "integer", "format": "uint32", "minimum": 0.0 diff --git a/contracts/tokenfactory/schema/query_msg.json b/contracts/tokenfactory/schema/query_msg.json index 117bfc9..dc71bfa 100644 --- a/contracts/tokenfactory/schema/query_msg.json +++ b/contracts/tokenfactory/schema/query_msg.json @@ -36,9 +36,13 @@ "denom_admin": { "type": "object", "required": [ + "creator", "subdenom" ], "properties": { + "creator": { + "type": "string" + }, "subdenom": { "type": "string" } @@ -57,9 +61,13 @@ "before_send_hook": { "type": "object", "required": [ + "creator", "denom" ], "properties": { + "creator": { + "type": "string" + }, "denom": { "type": "string" } From 544f5b7010d0c7b7361e0d813e11e4eb3abbd47e Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 18:37:50 +0400 Subject: [PATCH 19/34] start fixing unit tests --- Cargo.lock | 4 +- .../src/testing/mock_querier.rs | 96 ++++++--- .../src/testing/tests.rs | 186 +++++++++++------- 3 files changed, 177 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1e93d3..e5e5af3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#82e4e338ba92c3bd4d6f2f22c10aa597c09a7e3c" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#25bdfbd340e78510f792d5b816bd2855a67301ff" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#82e4e338ba92c3bd4d6f2f22c10aa597c09a7e3c" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#25bdfbd340e78510f792d5b816bd2855a67301ff" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index 2ab44e6..1a0e2a0 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -16,10 +16,8 @@ use std::collections::HashMap; use std::marker::PhantomData; use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage}; -use cosmwasm_std::{ - from_json, Binary, Coin, ContractResult, CustomQuery, FullDelegation, OwnedDeps, Querier, - QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, Validator, -}; +use cosmwasm_std::{from_json, Binary, Coin, ContractResult, CustomQuery, FullDelegation, GrpcQuery, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, Validator}; +use neutron_std::types::neutron::interchainqueries::{QueryRegisteredQueriesRequest, QueryRegisteredQueryRequest, QueryRegisteredQueryResultRequest, QueryRegisteredQueryResultResponse, QueryResult}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -69,41 +67,75 @@ impl Querier for WasmMockQuerier { } impl WasmMockQuerier { - pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { + pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { match &request { - QueryRequest::Custom(NeutronQuery::InterchainQueryResult { query_id }) => { - SystemResult::Ok(ContractResult::Ok( - (*self.query_responses.get(query_id).unwrap()).clone(), - )) - } - QueryRequest::Custom(NeutronQuery::RegisteredInterchainQuery { query_id }) => { - SystemResult::Ok(ContractResult::Ok( - (*self.registered_queries.get(query_id).unwrap()).clone(), - )) - } - QueryRequest::Custom(NeutronQuery::RegisteredInterchainQueries { - owners: _owners, - connection_id: _connection_id, - pagination: _pagination, - }) => { - todo!() - } - QueryRequest::Custom(NeutronQuery::InterchainAccountAddress { .. }) => { - todo!() + QueryRequest::Grpc(GrpcQuery{ path, data, }) => { + let quoted_path = path.trim_matches('"').to_string(); + if quoted_path == "/neutron.interchainqueries.Query/QueryResult".to_string() { + let request: QueryRegisteredQueryResultRequest = ::prost::Message::decode(&data[..]).unwrap(); + println!("AAAAOKAAAAY"); + SystemResult::Ok(ContractResult::Ok( + (*self.query_responses.get(&request.query_id).unwrap()).clone(), + )) + } else if quoted_path == "/neutron.interchainqueries.Query/RegisteredQuery".to_string() { + let request: QueryRegisteredQueryRequest = ::prost::Message::decode(&data[..]).unwrap(); + println!("BBBBOKAAAAY"); + SystemResult::Ok(ContractResult::Ok( + (*self.registered_queries.get(&request.query_id).unwrap()).clone(), + )) + } else if quoted_path == QueryRegisteredQueriesRequest::TYPE_URL.to_string() { + todo!() + } else { + println!("PATH: {}", quoted_path); + println!("SHOULD BE: {}", QueryRegisteredQueryRequest::TYPE_URL); + self.base.handle_query(&request) + } } _ => self.base.handle_query(request), } - } - pub fn _update_staking( - &mut self, - denom: &str, - validators: &[Validator], - delegations: &[FullDelegation], - ) { - self.base.staking.update(denom, validators, delegations); + + + // TODO: remove + // match &request { + // QueryRequest::Grpc(GrpcQuery{ path: ref type_url, data: _, }) => { + // SystemResult::Ok(ContractResult::Ok( + // (*self.query_responses.get(query_id).unwrap()).clone(), + // )) + // } + // QueryRequest::Custom(NeutronQuery::InterchainQueryResult { query_id }) => { + // SystemResult::Ok(ContractResult::Ok( + // (*self.query_responses.get(query_id).unwrap()).clone(), + // )) + // } + // QueryRequest::Custom(NeutronQuery::RegisteredInterchainQuery { query_id }) => { + // SystemResult::Ok(ContractResult::Ok( + // (*self.registered_queries.get(query_id).unwrap()).clone(), + // )) + // } + // QueryRequest::Custom(NeutronQuery::RegisteredInterchainQueries { + // owners: _owners, + // connection_id: _connection_id, + // pagination: _pagination, + // }) => { + // todo!() + // } + // QueryRequest::Custom(NeutronQuery::InterchainAccountAddress { .. }) => { + // todo!() + // } + // _ => self.base.handle_query(request), + // } } + // pub fn _update_staking( + // &mut self, + // denom: &str, + // validators: &[Validator], + // delegations: &[FullDelegation], + // ) { + // self.base.staking.update(denom, validators, delegations); + // } + pub fn add_query_response(&mut self, query_id: u64, response: Binary) { self.query_responses.insert(query_id, response); } diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 00ec3fe..db3e3a5 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -32,7 +32,7 @@ use cosmwasm_std::{ from_json, to_json_binary, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, Uint128, }; -use neutron_sdk::interchain_queries::helpers::decode_and_convert; +use neutron_sdk::interchain_queries::helpers::{decode_and_convert, kv_key_from_string}; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -41,6 +41,7 @@ use neutron_sdk::interchain_queries::v047::helpers::{ create_gov_proposal_votes_key, create_total_denom_key, create_validator_key, create_validator_signing_info_key, }; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; use neutron_sdk::interchain_queries::v047::queries::{ BalanceResponse, DelegatorDelegationsResponse, FeePoolResponse, ProposalResponse, ProposalVotesResponse, TotalSupplyResponse, ValidatorResponse, ValidatorSigningInfoResponse, @@ -51,10 +52,12 @@ use neutron_sdk::interchain_queries::v047::types::{ ValidatorSigningInfo, WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; use neutron_sdk::NeutronError; -use neutron_std::types::neutron::interchainqueries::KvKey; +use neutron_std::types::neutron::interchainqueries::{KvKey, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, QueryResult, RegisteredQuery, StorageValue}; use prost::Message as ProstMessage; use schemars::_serde_json::to_string; use std::ops::Mul; +use neutron_sdk::interchain_queries::hex::decode_hex; +use neutron_std::types::ibc::core::client::v1::Height; enum QueryParam { Keys(Vec), @@ -67,34 +70,37 @@ fn build_registered_query_response( query_type: QueryType, last_submitted_result_local_height: u64, ) -> Binary { - let mut resp = QueryRegisteredQueryResponse { - registered_query: RegisteredQuery { + let mut registered_keys = vec![]; + let mut transactions_filter = "".to_string(); + match param { + QueryParam::Keys(keys) => registered_keys = keys, + QueryParam::TransactionsFilter(filter) => { + transactions_filter = filter + } + } + + let resp = QueryRegisteredQueryResponse { + registered_query: Some(RegisteredQuery { id, owner: "".to_string(), - keys: vec![], - query_type, - transactions_filter: "".to_string(), + keys: registered_keys, + query_type: query_type.into(), + transactions_filter, connection_id: "".to_string(), update_period: 0, last_submitted_result_local_height, - last_submitted_result_remote_height: Height { + last_submitted_result_remote_height: Some(Height { revision_number: 0, revision_height: 0, - }, - deposit: Vec::from([Coin { + }), + deposit: Vec::from([StdCoin { denom: "stake".to_string(), - amount: Uint128::from_str("100").unwrap(), + amount: "100".to_string(), }]), submit_timeout: 0, registered_at_height: 0, - }, + }), }; - match param { - QueryParam::Keys(keys) => resp.registered_query.keys = keys, - QueryParam::TransactionsFilter(transactions_filter) => { - resp.registered_query.transactions_filter = transactions_filter - } - } Binary::from(to_string(&resp).unwrap().as_bytes()) } @@ -106,8 +112,9 @@ fn build_interchain_query_bank_total_denom_value(denom: String, amount: String) StorageValue { storage_prefix: "".to_string(), - key: Binary::new(bank_total_key), - value: Binary::new(amount), + key: bank_total_key, + value: amount, + proof: None, } } @@ -128,16 +135,19 @@ fn build_interchain_query_distribution_fee_pool_response(denom: String, amount: let s = StorageValue { storage_prefix: "".to_string(), - key: Binary::new(fee_pool_key), - value: Binary::new(fee_pool.encode_to_vec()), + key: fee_pool_key, + value: fee_pool.encode_to_vec(), + proof: None, }; Binary::from( to_string(&QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results: vec![s], + block: None, height: 123456, revision: 1, - }, + allow_kv_callbacks: false, + }), }) .unwrap() .as_bytes(), @@ -167,8 +177,9 @@ fn build_interchain_query_staking_validator_value(validator: String) -> StorageV StorageValue { storage_prefix: "".to_string(), - key: Binary::new(validator_key), - value: Binary::new(validator.encode_to_vec()), + key: validator_key, + value: validator.encode_to_vec(), + proof: None, } } @@ -187,8 +198,9 @@ fn build_interchain_query_validator_signing_info_value(validator: String) -> Sto StorageValue { storage_prefix: "".to_string(), - key: Binary::new(validator_key), - value: Binary::new(validator.encode_to_vec()), + key: validator_key, + value: validator.encode_to_vec(), + proof: None, } } @@ -220,8 +232,9 @@ fn build_interchain_query_gov_proposal_value(proposal_id: u64) -> StorageValue { StorageValue { storage_prefix: "".to_string(), - key: Binary::new(proposal_key), - value: Binary::new(proposal.encode_to_vec()), + key: proposal_key, + value: proposal.encode_to_vec(), + proof: None, } } @@ -241,8 +254,9 @@ fn build_interchain_query_gov_proposal_votes_value(proposal_id: u64) -> StorageV StorageValue { storage_prefix: "".to_string(), - key: Binary::new(votes_key), - value: Binary::new(vote.encode_to_vec()), + key: votes_key, + value: vote.encode_to_vec(), + proof: None, } } @@ -257,19 +271,22 @@ fn build_interchain_query_balances_response(addr: Addr, balances: Vec) -> .unwrap(); StorageValue { storage_prefix: "".to_string(), - key: Binary::new(balance_key), - value: Binary::new(c.amount.to_string().into_bytes()), + key: balance_key, + value: c.amount.to_string().into_bytes(), + proof: None, } }) .collect(); Binary::from( to_string(&QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results: s, + block: None, height: 123456, revision: 2, - }, + allow_kv_callbacks: false, + }), }) .unwrap() .as_bytes(), @@ -278,19 +295,19 @@ fn build_interchain_query_balances_response(addr: Addr, balances: Vec) -> // registers an interchain query fn register_query( - deps: &mut OwnedDeps, + deps: &mut OwnedDeps, env: Env, info: MessageInfo, msg: ExecuteMsg, -) -> KVKeys { +) -> Vec { let reg_msgs = execute(deps.as_mut(), env, info, msg).unwrap(); for attr in reg_msgs.attributes { if attr.key == "kv_keys" && !attr.value.is_empty() { - return KVKeys::from_string(attr.value).unwrap(); + return vec![kv_key_from_string(attr.value).unwrap()]; } } - KVKeys(vec![]) + vec![] } #[test] @@ -312,7 +329,7 @@ fn test_query_balance() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier.add_registered_queries(1, registered_query); deps.querier.add_query_response( @@ -355,7 +372,7 @@ fn test_query_balances() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier.add_registered_queries(1, registered_query); deps.querier.add_query_response( @@ -405,7 +422,7 @@ fn test_bank_total_supply_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -416,11 +433,13 @@ fn test_bank_total_supply_query() { } let total_supply_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); @@ -461,7 +480,7 @@ fn test_distribution_fee_pool_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier.add_registered_queries(1, registered_query); deps.querier.add_query_response( @@ -505,7 +524,7 @@ fn test_gov_proposals_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -515,11 +534,13 @@ fn test_gov_proposals_query() { } let proposals_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); @@ -623,7 +644,7 @@ fn test_gov_proposal_votes_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 325); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 325); let mut kv_results: Vec = vec![]; @@ -633,11 +654,13 @@ fn test_gov_proposal_votes_query() { } let proposals_votes_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); @@ -705,7 +728,7 @@ fn test_staking_validators_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -715,11 +738,13 @@ fn test_staking_validators_query() { } let validators_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); @@ -804,7 +829,7 @@ fn test_validators_signing_infos_query() { ); let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); let mut kv_results: Vec = vec![]; @@ -814,11 +839,13 @@ fn test_validators_signing_infos_query() { } let validators_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { kv_results, + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; deps.querier.add_registered_queries(1, registered_query); @@ -878,7 +905,7 @@ fn test_query_delegator_delegations() { ); let delegations_response = QueryRegisteredQueryResultResponse { - result: InterchainQueryResult { + result: Some(QueryResult { // response for `RegisterDelegatorDelegationsQuery` with necessary KV values to test reconstruction logic. // The values are taken from osmosis network kv_results: vec![ @@ -886,8 +913,9 @@ fn test_query_delegator_delegations() { // value: Params StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(BASE64_STANDARD.decode("UQ==").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CgQIgN9uEGQYByCQTioFdWF0b20yATA6FC0xMDAwMDAwMDAwMDAwMDAwMDAwQhMxMDAwMDAwMDAwMDAwMDAwMDAwShMxMDAwMDAwMDAwMDAwMDAwMDAw").unwrap()), + key: BASE64_STANDARD.decode("UQ==").unwrap(), + value: BASE64_STANDARD.decode("CgQIgN9uEGQYByCQTioFdWF0b20yATA6FC0xMDAwMDAwMDAwMDAwMDAwMDAwQhMxMDAwMDAwMDAwMDAwMDAwMDAwShMxMDAwMDAwMDAwMDAwMDAwMDAw").unwrap(), + proof: None, }, // delegation // from: osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs @@ -895,16 +923,18 @@ fn test_query_delegator_delegations() { // delegation_shares: "5177628000000000000000000" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b8141ab940697a73dd080edafeb538ad408b5cae0264").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxoZNTE3NzYyODAwMDAwMDAwMDAwMDAwMDAwMA==").unwrap()), + key: decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b8141ab940697a73dd080edafeb538ad408b5cae0264").unwrap(), + value: BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxoZNTE3NzYyODAwMDAwMDAwMDAwMDAwMDAwMA==").unwrap(), + proof: None, }, // validator: osmovaloper1r2u5q6t6w0wssrk6l66n3t2q3dw2uqny4gj2e3 // delegator_shares: "2845862840643000000000000000000" // total tokens: "2845862840643" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("21141ab940697a73dd080edafeb538ad408b5cae0264").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiCaZhCbacCetQorko3LfUUJX2UEyX38qBGVri8GyH8lcCADKg0yODQ1ODYyODQwNjQzMh8yODQ1ODYyODQwNjQzMDAwMDAwMDAwMDAwMDAwMDAwOqQCChRzdHJhbmdlbG92ZS12ZW50dXJlcxIQRDBEOEI4MEYxQzVDNzBCNRocaHR0cHM6Ly9zdHJhbmdlbG92ZS52ZW50dXJlcyrbAScuLi5iZWNhdXNlIG9mIHRoZSBhdXRvbWF0ZWQgYW5kIGlycmV2b2NhYmxlIGRlY2lzaW9uLW1ha2luZyBwcm9jZXNzIHdoaWNoIHJ1bGVzIG91dCBodW1hbiBtZWRkbGluZywgdGhlIERvb21zZGF5IG1hY2hpbmUgaXMgdGVycmlmeWluZyBhbmQgc2ltcGxlIHRvIHVuZGVyc3RhbmQgYW5kIGNvbXBsZXRlbHkgY3JlZGlibGUgYW5kIGNvbnZpbmNpbmcuJyAtIERyLiBTdHJhbmdlbG92ZUoAUkwKPAoRNTAwMDAwMDAwMDAwMDAwMDASEzEwMDAwMDAwMDAwMDAwMDAwMDAaEjUwMDAwMDAwMDAwMDAwMDAwMBIMCPetyYYGEKPoosUCWgEx").unwrap()), + key: decode_hex("21141ab940697a73dd080edafeb538ad408b5cae0264").unwrap(), + value: BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFyMnU1cTZ0Nncwd3Nzcms2bDY2bjN0MnEzZHcydXFueTRnajJlMxJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiCaZhCbacCetQorko3LfUUJX2UEyX38qBGVri8GyH8lcCADKg0yODQ1ODYyODQwNjQzMh8yODQ1ODYyODQwNjQzMDAwMDAwMDAwMDAwMDAwMDAwOqQCChRzdHJhbmdlbG92ZS12ZW50dXJlcxIQRDBEOEI4MEYxQzVDNzBCNRocaHR0cHM6Ly9zdHJhbmdlbG92ZS52ZW50dXJlcyrbAScuLi5iZWNhdXNlIG9mIHRoZSBhdXRvbWF0ZWQgYW5kIGlycmV2b2NhYmxlIGRlY2lzaW9uLW1ha2luZyBwcm9jZXNzIHdoaWNoIHJ1bGVzIG91dCBodW1hbiBtZWRkbGluZywgdGhlIERvb21zZGF5IG1hY2hpbmUgaXMgdGVycmlmeWluZyBhbmQgc2ltcGxlIHRvIHVuZGVyc3RhbmQgYW5kIGNvbXBsZXRlbHkgY3JlZGlibGUgYW5kIGNvbnZpbmNpbmcuJyAtIERyLiBTdHJhbmdlbG92ZUoAUkwKPAoRNTAwMDAwMDAwMDAwMDAwMDASEzEwMDAwMDAwMDAwMDAwMDAwMDAaEjUwMDAwMDAwMDAwMDAwMDAwMBIMCPetyYYGEKPoosUCWgEx").unwrap(), + proof: None, }, // delegation // from: osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs @@ -912,16 +942,18 @@ fn test_query_delegator_delegations() { // delegation_shares: "29620221000000000000000000" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814cc9598513212c12c36a1775e2233b962e4d5128e").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBoaMjk2MjAyMjEwMDAwMDAwMDAwMDAwMDAwMDA=").unwrap()), + key: decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814cc9598513212c12c36a1775e2233b962e4d5128e").unwrap(), + value: BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBoaMjk2MjAyMjEwMDAwMDAwMDAwMDAwMDAwMDA=").unwrap(), + proof: None, }, // validator: osmovaloper1ej2es5fjztqjcd4pwa0zyvaevtjd2y5w37wr9t // delegator_shares: "3054477259038000000000000000000" // total tokens: "3054477259038" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("2114cc9598513212c12c36a1775e2233b962e4d5128e").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiA27dgAuZV/uS9FdsILGWLBw8eYPy+ZEyv1Df2VsrjXDiADKg0zMDU0NDc3MjU5MDM4Mh8zMDU0NDc3MjU5MDM4MDAwMDAwMDAwMDAwMDAwMDAwOoEBChFGcmVucyAo8J+knSzwn6SdKRIQQzQ3ODQ1MjI2NjYyQUY0NxoSaHR0cHM6Ly9mcmVucy5hcm15IhtzZWN1cml0eUBraWRzb250aGVibG9jay54eXoqKVlvdXIgZnJpZW5kbHkgdmFsaWRhdG9yIGZvciBjb3Ntb3MgY2hhaW5zQP3HpQFKCwj3zq6PBhCfrO86UkoKOgoRNTAwMDAwMDAwMDAwMDAwMDASEjUwMDAwMDAwMDAwMDAwMDAwMBoRNTAwMDAwMDAwMDAwMDAwMDASDAjg1rSQBhDkudCDAVoDNTAw").unwrap()), + key: decode_hex("2114cc9598513212c12c36a1775e2233b962e4d5128e").unwrap(), + value: BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFlajJlczVmanp0cWpjZDRwd2Ewenl2YWV2dGpkMnk1dzM3d3I5dBJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiA27dgAuZV/uS9FdsILGWLBw8eYPy+ZEyv1Df2VsrjXDiADKg0zMDU0NDc3MjU5MDM4Mh8zMDU0NDc3MjU5MDM4MDAwMDAwMDAwMDAwMDAwMDAwOoEBChFGcmVucyAo8J+knSzwn6SdKRIQQzQ3ODQ1MjI2NjYyQUY0NxoSaHR0cHM6Ly9mcmVucy5hcm15IhtzZWN1cml0eUBraWRzb250aGVibG9jay54eXoqKVlvdXIgZnJpZW5kbHkgdmFsaWRhdG9yIGZvciBjb3Ntb3MgY2hhaW5zQP3HpQFKCwj3zq6PBhCfrO86UkoKOgoRNTAwMDAwMDAwMDAwMDAwMDASEjUwMDAwMDAwMDAwMDAwMDAwMBoRNTAwMDAwMDAwMDAwMDAwMDASDAjg1rSQBhDkudCDAVoDNTAw").unwrap(), + proof: None, }, // delegation // from: osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs @@ -929,25 +961,29 @@ fn test_query_delegator_delegations() { // delegation_shares: "219920000000000000000000" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRoYMjE5OTIwMDAwMDAwMDAwMDAwMDAwMDAw").unwrap()), + key: decode_hex("311420a959e0d22e201f727137f2d7c41a5dc63b90b814f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap(), + value: BASE64_STANDARD.decode("Citvc21vMXl6NTRuY3hqOWNzcDd1bjN4bGVkMDNxNnRocnJoeTljenRrZnpzEjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRoYMjE5OTIwMDAwMDAwMDAwMDAwMDAwMDAw").unwrap(), + proof: None, }, // validator: osmovaloper1lzhlnpahvznwfv4jmay2tgaha5kmz5qxwmj9we // delegator_shares: "3201438898476000000000000000000" // total tokens: "3201438898476" StorageValue { storage_prefix: "staking".to_string(), - key: Binary::from(decode_hex("2114f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap()), - value: Binary::from(BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiBPXCnkQvO+pU6oGbp4ZiJBBZ7RNoLYtXYFOEdpXGH+uSADKg0zMjAxNDM4ODk4NDc2Mh8zMjAxNDM4ODk4NDc2MDAwMDAwMDAwMDAwMDAwMDAwOp8CCgtDaXRhZGVsLm9uZRIQRUJCMDNFQjRCQjRDRkNBNxoTaHR0cHM6Ly9jaXRhZGVsLm9uZSroAUNpdGFkZWwub25lIGlzIGEgbXVsdGktYXNzZXQgbm9uLWN1c3RvZGlhbCBzdGFraW5nIHBsYXRmb3JtIHRoYXQgbGV0cyBhbnlvbmUgYmVjb21lIGEgcGFydCBvZiBkZWNlbnRyYWxpemVkIGluZnJhc3RydWN0dXJlIGFuZCBlYXJuIHBhc3NpdmUgaW5jb21lLiBTdGFrZSB3aXRoIG91ciBub2RlcyBvciBhbnkgb3RoZXIgdmFsaWRhdG9yIGFjcm9zcyBtdWx0aXBsZSBuZXR3b3JrcyBpbiBhIGZldyBjbGlja3NKAFJECjoKETUwMDAwMDAwMDAwMDAwMDAwEhIyMDAwMDAwMDAwMDAwMDAwMDAaETMwMDAwMDAwMDAwMDAwMDAwEgYIkKKzhgZaATE=").unwrap()), + key: decode_hex("2114f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap(), + value: BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiBPXCnkQvO+pU6oGbp4ZiJBBZ7RNoLYtXYFOEdpXGH+uSADKg0zMjAxNDM4ODk4NDc2Mh8zMjAxNDM4ODk4NDc2MDAwMDAwMDAwMDAwMDAwMDAwOp8CCgtDaXRhZGVsLm9uZRIQRUJCMDNFQjRCQjRDRkNBNxoTaHR0cHM6Ly9jaXRhZGVsLm9uZSroAUNpdGFkZWwub25lIGlzIGEgbXVsdGktYXNzZXQgbm9uLWN1c3RvZGlhbCBzdGFraW5nIHBsYXRmb3JtIHRoYXQgbGV0cyBhbnlvbmUgYmVjb21lIGEgcGFydCBvZiBkZWNlbnRyYWxpemVkIGluZnJhc3RydWN0dXJlIGFuZCBlYXJuIHBhc3NpdmUgaW5jb21lLiBTdGFrZSB3aXRoIG91ciBub2RlcyBvciBhbnkgb3RoZXIgdmFsaWRhdG9yIGFjcm9zcyBtdWx0aXBsZSBuZXR3b3JrcyBpbiBhIGZldyBjbGlja3NKAFJECjoKETUwMDAwMDAwMDAwMDAwMDAwEhIyMDAwMDAwMDAwMDAwMDAwMDAaETMwMDAwMDAwMDAwMDAwMDAwEgYIkKKzhgZaATE=").unwrap(), + proof: None, }, ], + block: None, height: 0, revision: 0, - }, + allow_kv_callbacks: false, + }), }; let registered_query = - build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); + build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier .add_query_response(1, to_json_binary(&delegations_response).unwrap()); From 68af7b6b641660282d65d740af6791cd9b79a6fc Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 16 Oct 2024 16:26:21 +0400 Subject: [PATCH 20/34] fix neutron-Interchain-queries contracts --- .../src/testing/mock_querier.rs | 43 ------------ .../src/testing/tests.rs | 69 +++++++++---------- 2 files changed, 33 insertions(+), 79 deletions(-) diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index 1a0e2a0..3d2b4bb 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -73,13 +73,11 @@ impl WasmMockQuerier { let quoted_path = path.trim_matches('"').to_string(); if quoted_path == "/neutron.interchainqueries.Query/QueryResult".to_string() { let request: QueryRegisteredQueryResultRequest = ::prost::Message::decode(&data[..]).unwrap(); - println!("AAAAOKAAAAY"); SystemResult::Ok(ContractResult::Ok( (*self.query_responses.get(&request.query_id).unwrap()).clone(), )) } else if quoted_path == "/neutron.interchainqueries.Query/RegisteredQuery".to_string() { let request: QueryRegisteredQueryRequest = ::prost::Message::decode(&data[..]).unwrap(); - println!("BBBBOKAAAAY"); SystemResult::Ok(ContractResult::Ok( (*self.registered_queries.get(&request.query_id).unwrap()).clone(), )) @@ -93,49 +91,8 @@ impl WasmMockQuerier { } _ => self.base.handle_query(request), } - - - - // TODO: remove - // match &request { - // QueryRequest::Grpc(GrpcQuery{ path: ref type_url, data: _, }) => { - // SystemResult::Ok(ContractResult::Ok( - // (*self.query_responses.get(query_id).unwrap()).clone(), - // )) - // } - // QueryRequest::Custom(NeutronQuery::InterchainQueryResult { query_id }) => { - // SystemResult::Ok(ContractResult::Ok( - // (*self.query_responses.get(query_id).unwrap()).clone(), - // )) - // } - // QueryRequest::Custom(NeutronQuery::RegisteredInterchainQuery { query_id }) => { - // SystemResult::Ok(ContractResult::Ok( - // (*self.registered_queries.get(query_id).unwrap()).clone(), - // )) - // } - // QueryRequest::Custom(NeutronQuery::RegisteredInterchainQueries { - // owners: _owners, - // connection_id: _connection_id, - // pagination: _pagination, - // }) => { - // todo!() - // } - // QueryRequest::Custom(NeutronQuery::InterchainAccountAddress { .. }) => { - // todo!() - // } - // _ => self.base.handle_query(request), - // } } - // pub fn _update_staking( - // &mut self, - // denom: &str, - // validators: &[Validator], - // delegations: &[FullDelegation], - // ) { - // self.base.staking.update(denom, validators, delegations); - // } - pub fn add_query_response(&mut self, query_id: u64, response: Binary) { self.query_responses.insert(query_id, response); } diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index db3e3a5..17624f3 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -29,7 +29,7 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::Validator as CosmosValidator; use cosmos_sdk_proto::Any; use cosmwasm_std::testing::{message_info, mock_env, MockApi, MockStorage}; use cosmwasm_std::{ - from_json, to_json_binary, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, + from_json, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, Uint128, }; use neutron_sdk::interchain_queries::helpers::{decode_and_convert, kv_key_from_string}; @@ -101,8 +101,8 @@ fn build_registered_query_response( registered_at_height: 0, }), }; - - Binary::from(to_string(&resp).unwrap().as_bytes()) + let res = ::prost::Message::encode_to_vec(&resp); + Binary::from(res.as_slice()) } fn build_interchain_query_bank_total_denom_value(denom: String, amount: String) -> StorageValue { @@ -139,19 +139,17 @@ fn build_interchain_query_distribution_fee_pool_response(denom: String, amount: value: fee_pool.encode_to_vec(), proof: None, }; - Binary::from( - to_string(&QueryRegisteredQueryResultResponse { - result: Some(QueryResult { - kv_results: vec![s], - block: None, - height: 123456, - revision: 1, - allow_kv_callbacks: false, - }), - }) - .unwrap() - .as_bytes(), - ) + + let res = ::prost::Message::encode_to_vec(&QueryRegisteredQueryResultResponse { + result: Some(QueryResult { + kv_results: vec![s], + block: None, + height: 123456, + revision: 1, + allow_kv_callbacks: false, + }), + }); + Binary::from(res.as_slice()) } fn build_interchain_query_staking_validator_value(validator: String) -> StorageValue { @@ -278,19 +276,17 @@ fn build_interchain_query_balances_response(addr: Addr, balances: Vec) -> }) .collect(); - Binary::from( - to_string(&QueryRegisteredQueryResultResponse { - result: Some(QueryResult { - kv_results: s, - block: None, - height: 123456, - revision: 2, - allow_kv_callbacks: false, - }), - }) - .unwrap() - .as_bytes(), - ) + let resp = QueryRegisteredQueryResultResponse { + result: Some(QueryResult { + kv_results: s, + block: None, + height: 123456, + revision: 2, + allow_kv_callbacks: false, + }), + }; + let res = ::prost::Message::encode_to_vec(&resp); + Binary::from(res.as_slice()) } // registers an interchain query @@ -386,8 +382,9 @@ fn test_query_balances() { ), ); let query_balance = QueryMsg::Balance { query_id: 1 }; + let res = query(deps.as_ref(), mock_env(), query_balance); let resp: BalanceResponse = - from_json(query(deps.as_ref(), mock_env(), query_balance).unwrap()).unwrap(); + from_json(res.unwrap()).unwrap(); assert_eq!( resp, BalanceResponse { @@ -444,7 +441,7 @@ fn test_bank_total_supply_query() { deps.querier.add_registered_queries(1, registered_query); deps.querier - .add_query_response(1, to_json_binary(&total_supply_response).unwrap()); + .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&total_supply_response).as_slice())); let bank_total_balance = QueryMsg::BankTotalSupply { query_id: 1 }; let resp: TotalSupplyResponse = @@ -545,7 +542,7 @@ fn test_gov_proposals_query() { deps.querier.add_registered_queries(1, registered_query); deps.querier - .add_query_response(1, to_json_binary(&proposals_response).unwrap()); + .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&proposals_response).as_slice())); let government_proposal = QueryMsg::GovernmentProposals { query_id: 1 }; let resp: ProposalResponse = @@ -665,7 +662,7 @@ fn test_gov_proposal_votes_query() { deps.querier.add_registered_queries(1, registered_query); deps.querier - .add_query_response(1, to_json_binary(&proposals_votes_response).unwrap()); + .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&proposals_votes_response).as_slice())); let government_proposal_votes = QueryMsg::GovernmentProposalVotes { query_id: 1 }; let resp: ProposalVotesResponse = @@ -749,7 +746,7 @@ fn test_staking_validators_query() { deps.querier.add_registered_queries(1, registered_query); deps.querier - .add_query_response(1, to_json_binary(&validators_response).unwrap()); + .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice())); let staking_validators = QueryMsg::StakingValidators { query_id: 1 }; let resp: ValidatorResponse = from_json(query(deps.as_ref(), mock_env(), staking_validators).unwrap()).unwrap(); @@ -850,7 +847,7 @@ fn test_validators_signing_infos_query() { deps.querier.add_registered_queries(1, registered_query); deps.querier - .add_query_response(1, to_json_binary(&validators_response).unwrap()); + .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice())); let validators_signing_infos = QueryMsg::ValidatorsSigningInfos { query_id: 1 }; let resp: ValidatorSigningInfoResponse = from_json(query(deps.as_ref(), mock_env(), validators_signing_infos).unwrap()).unwrap(); @@ -986,7 +983,7 @@ fn test_query_delegator_delegations() { build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); deps.querier - .add_query_response(1, to_json_binary(&delegations_response).unwrap()); + .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&delegations_response).as_slice())); deps.querier.add_registered_queries(1, registered_query); let query_delegations = QueryMsg::GetDelegations { query_id: 1 }; From c01fb30153a0389890c44d22f9b16a50af909c94 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 16 Oct 2024 16:28:39 +0400 Subject: [PATCH 21/34] fix schema --- contracts/marketmap/examples/schema.rs | 2 +- contracts/marketmap/src/lib.rs | 2 +- .../src/testing/mock_querier.rs | 22 +++++-- .../src/testing/tests.rs | 57 +++++++++++-------- contracts/oracle/examples/schema.rs | 3 +- 5 files changed, 53 insertions(+), 33 deletions(-) diff --git a/contracts/marketmap/examples/schema.rs b/contracts/marketmap/examples/schema.rs index f1eb66b..b938f17 100644 --- a/contracts/marketmap/examples/schema.rs +++ b/contracts/marketmap/examples/schema.rs @@ -16,7 +16,7 @@ use std::env::current_dir; use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use marketmap::contract::InstantiateMsg; +use marketmap::msg::{InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); diff --git a/contracts/marketmap/src/lib.rs b/contracts/marketmap/src/lib.rs index 37088ba..112ecad 100644 --- a/contracts/marketmap/src/lib.rs +++ b/contracts/marketmap/src/lib.rs @@ -1,2 +1,2 @@ pub mod contract; -mod msg; +pub mod msg; diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index 3d2b4bb..8447073 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -16,8 +16,14 @@ use std::collections::HashMap; use std::marker::PhantomData; use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage}; -use cosmwasm_std::{from_json, Binary, Coin, ContractResult, CustomQuery, FullDelegation, GrpcQuery, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, Validator}; -use neutron_std::types::neutron::interchainqueries::{QueryRegisteredQueriesRequest, QueryRegisteredQueryRequest, QueryRegisteredQueryResultRequest, QueryRegisteredQueryResultResponse, QueryResult}; +use cosmwasm_std::{ + from_json, Binary, Coin, ContractResult, CustomQuery, FullDelegation, GrpcQuery, OwnedDeps, + Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, Validator, +}; +use neutron_std::types::neutron::interchainqueries::{ + QueryRegisteredQueriesRequest, QueryRegisteredQueryRequest, QueryRegisteredQueryResultRequest, + QueryRegisteredQueryResultResponse, QueryResult, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -69,15 +75,19 @@ impl Querier for WasmMockQuerier { impl WasmMockQuerier { pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { match &request { - QueryRequest::Grpc(GrpcQuery{ path, data, }) => { + QueryRequest::Grpc(GrpcQuery { path, data }) => { let quoted_path = path.trim_matches('"').to_string(); if quoted_path == "/neutron.interchainqueries.Query/QueryResult".to_string() { - let request: QueryRegisteredQueryResultRequest = ::prost::Message::decode(&data[..]).unwrap(); + let request: QueryRegisteredQueryResultRequest = + ::prost::Message::decode(&data[..]).unwrap(); SystemResult::Ok(ContractResult::Ok( (*self.query_responses.get(&request.query_id).unwrap()).clone(), )) - } else if quoted_path == "/neutron.interchainqueries.Query/RegisteredQuery".to_string() { - let request: QueryRegisteredQueryRequest = ::prost::Message::decode(&data[..]).unwrap(); + } else if quoted_path + == "/neutron.interchainqueries.Query/RegisteredQuery".to_string() + { + let request: QueryRegisteredQueryRequest = + ::prost::Message::decode(&data[..]).unwrap(); SystemResult::Ok(ContractResult::Ok( (*self.registered_queries.get(&request.query_id).unwrap()).clone(), )) diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 17624f3..e4acd4e 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -29,10 +29,10 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::Validator as CosmosValidator; use cosmos_sdk_proto::Any; use cosmwasm_std::testing::{message_info, mock_env, MockApi, MockStorage}; use cosmwasm_std::{ - from_json, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, - Uint128, + from_json, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, Uint128, }; use neutron_sdk::interchain_queries::helpers::{decode_and_convert, kv_key_from_string}; +use neutron_sdk::interchain_queries::hex::decode_hex; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -41,7 +41,6 @@ use neutron_sdk::interchain_queries::v047::helpers::{ create_gov_proposal_votes_key, create_total_denom_key, create_validator_key, create_validator_signing_info_key, }; -use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; use neutron_sdk::interchain_queries::v047::queries::{ BalanceResponse, DelegatorDelegationsResponse, FeePoolResponse, ProposalResponse, ProposalVotesResponse, TotalSupplyResponse, ValidatorResponse, ValidatorSigningInfoResponse, @@ -52,12 +51,15 @@ use neutron_sdk::interchain_queries::v047::types::{ ValidatorSigningInfo, WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; use neutron_sdk::NeutronError; -use neutron_std::types::neutron::interchainqueries::{KvKey, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, QueryResult, RegisteredQuery, StorageValue}; +use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; +use neutron_std::types::ibc::core::client::v1::Height; +use neutron_std::types::neutron::interchainqueries::{ + KvKey, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, QueryResult, + RegisteredQuery, StorageValue, +}; use prost::Message as ProstMessage; use schemars::_serde_json::to_string; use std::ops::Mul; -use neutron_sdk::interchain_queries::hex::decode_hex; -use neutron_std::types::ibc::core::client::v1::Height; enum QueryParam { Keys(Vec), @@ -74,9 +76,7 @@ fn build_registered_query_response( let mut transactions_filter = "".to_string(); match param { QueryParam::Keys(keys) => registered_keys = keys, - QueryParam::TransactionsFilter(filter) => { - transactions_filter = filter - } + QueryParam::TransactionsFilter(filter) => transactions_filter = filter, } let resp = QueryRegisteredQueryResponse { @@ -383,8 +383,7 @@ fn test_query_balances() { ); let query_balance = QueryMsg::Balance { query_id: 1 }; let res = query(deps.as_ref(), mock_env(), query_balance); - let resp: BalanceResponse = - from_json(res.unwrap()).unwrap(); + let resp: BalanceResponse = from_json(res.unwrap()).unwrap(); assert_eq!( resp, BalanceResponse { @@ -440,8 +439,10 @@ fn test_bank_total_supply_query() { }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&total_supply_response).as_slice())); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&total_supply_response).as_slice()), + ); let bank_total_balance = QueryMsg::BankTotalSupply { query_id: 1 }; let resp: TotalSupplyResponse = @@ -541,8 +542,10 @@ fn test_gov_proposals_query() { }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&proposals_response).as_slice())); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&proposals_response).as_slice()), + ); let government_proposal = QueryMsg::GovernmentProposals { query_id: 1 }; let resp: ProposalResponse = @@ -661,8 +664,10 @@ fn test_gov_proposal_votes_query() { }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&proposals_votes_response).as_slice())); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&proposals_votes_response).as_slice()), + ); let government_proposal_votes = QueryMsg::GovernmentProposalVotes { query_id: 1 }; let resp: ProposalVotesResponse = @@ -745,8 +750,10 @@ fn test_staking_validators_query() { }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice())); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice()), + ); let staking_validators = QueryMsg::StakingValidators { query_id: 1 }; let resp: ValidatorResponse = from_json(query(deps.as_ref(), mock_env(), staking_validators).unwrap()).unwrap(); @@ -846,8 +853,10 @@ fn test_validators_signing_infos_query() { }; deps.querier.add_registered_queries(1, registered_query); - deps.querier - .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice())); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&validators_response).as_slice()), + ); let validators_signing_infos = QueryMsg::ValidatorsSigningInfos { query_id: 1 }; let resp: ValidatorSigningInfoResponse = from_json(query(deps.as_ref(), mock_env(), validators_signing_infos).unwrap()).unwrap(); @@ -982,8 +991,10 @@ fn test_query_delegator_delegations() { let registered_query = build_registered_query_response(1, QueryParam::Keys(keys), QueryType::KV, 987); - deps.querier - .add_query_response(1, Binary::from(::prost::Message::encode_to_vec(&delegations_response).as_slice())); + deps.querier.add_query_response( + 1, + Binary::from(::prost::Message::encode_to_vec(&delegations_response).as_slice()), + ); deps.querier.add_registered_queries(1, registered_query); let query_delegations = QueryMsg::GetDelegations { query_id: 1 }; diff --git a/contracts/oracle/examples/schema.rs b/contracts/oracle/examples/schema.rs index 8b54f90..9df07e3 100644 --- a/contracts/oracle/examples/schema.rs +++ b/contracts/oracle/examples/schema.rs @@ -16,8 +16,7 @@ use std::env::current_dir; use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use oracle::contract::InstantiateMsg; -use oracle::msg::QueryMsg; +use oracle::msg::{InstantiateMsg, QueryMsg}; fn main() { let mut out_dir = current_dir().unwrap(); From d57d8e4c5e1f50893766b2e93c1d3d538b08c42d Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 16 Oct 2024 16:30:55 +0400 Subject: [PATCH 22/34] fix clippy --- .../src/testing/mock_querier.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index 8447073..5335288 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -17,12 +17,11 @@ use std::marker::PhantomData; use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage}; use cosmwasm_std::{ - from_json, Binary, Coin, ContractResult, CustomQuery, FullDelegation, GrpcQuery, OwnedDeps, - Querier, QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, Validator, + from_json, Binary, Coin, ContractResult, CustomQuery, GrpcQuery, OwnedDeps, Querier, + QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, }; use neutron_std::types::neutron::interchainqueries::{ - QueryRegisteredQueriesRequest, QueryRegisteredQueryRequest, QueryRegisteredQueryResultRequest, - QueryRegisteredQueryResultResponse, QueryResult, + QueryRegisteredQueryRequest, QueryRegisteredQueryResultRequest, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -77,26 +76,21 @@ impl WasmMockQuerier { match &request { QueryRequest::Grpc(GrpcQuery { path, data }) => { let quoted_path = path.trim_matches('"').to_string(); - if quoted_path == "/neutron.interchainqueries.Query/QueryResult".to_string() { + if "ed_path == "/neutron.interchainqueries.Query/QueryResult" { let request: QueryRegisteredQueryResultRequest = ::prost::Message::decode(&data[..]).unwrap(); SystemResult::Ok(ContractResult::Ok( (*self.query_responses.get(&request.query_id).unwrap()).clone(), )) - } else if quoted_path - == "/neutron.interchainqueries.Query/RegisteredQuery".to_string() - { + } else if "ed_path == "/neutron.interchainqueries.Query/RegisteredQuery" { let request: QueryRegisteredQueryRequest = ::prost::Message::decode(&data[..]).unwrap(); SystemResult::Ok(ContractResult::Ok( (*self.registered_queries.get(&request.query_id).unwrap()).clone(), )) - } else if quoted_path == QueryRegisteredQueriesRequest::TYPE_URL.to_string() { - todo!() } else { println!("PATH: {}", quoted_path); - println!("SHOULD BE: {}", QueryRegisteredQueryRequest::TYPE_URL); - self.base.handle_query(&request) + self.base.handle_query(request) } } _ => self.base.handle_query(request), From 1420a744bbe2c4db6b9203fdec6e466a0dc6b281 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 16 Oct 2024 17:24:21 +0400 Subject: [PATCH 23/34] update neutron-sdk --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5e5af3..cd50e0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#25bdfbd340e78510f792d5b816bd2855a67301ff" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#599d9ad8186c596ce7daf1ea590647ac32faac97" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#25bdfbd340e78510f792d5b816bd2855a67301ff" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#599d9ad8186c596ce7daf1ea590647ac32faac97" dependencies = [ "itertools 0.10.5", "proc-macro2", From ea15a0e8cc32b6927aa90cf5f978324a4da93ca5 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 16 Oct 2024 17:26:26 +0400 Subject: [PATCH 24/34] make schema --- .../{market_map_query.json => query_msg.json} | 12 ++--- .../{oracle_query.json => query_msg.json} | 44 +++++++------------ 2 files changed, 21 insertions(+), 35 deletions(-) rename contracts/marketmap/schema/{market_map_query.json => query_msg.json} (86%) rename contracts/oracle/schema/{oracle_query.json => query_msg.json} (72%) diff --git a/contracts/marketmap/schema/market_map_query.json b/contracts/marketmap/schema/query_msg.json similarity index 86% rename from contracts/marketmap/schema/market_map_query.json rename to contracts/marketmap/schema/query_msg.json index 35df8e8..10bd1f0 100644 --- a/contracts/marketmap/schema/market_map_query.json +++ b/contracts/marketmap/schema/query_msg.json @@ -1,9 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "MarketMapQuery", + "title": "QueryMsg", "oneOf": [ { - "description": "Parameters queries the parameters of the module.", "type": "object", "required": [ "params" @@ -66,16 +65,17 @@ ], "definitions": { "CurrencyPair": { + "description": "CurrencyPair is the standard representation of a pair of assets, where one (Base) is priced in terms of the other (Quote)", "type": "object", "required": [ - "Base", - "Quote" + "base", + "quote" ], "properties": { - "Base": { + "base": { "type": "string" }, - "Quote": { + "quote": { "type": "string" } }, diff --git a/contracts/oracle/schema/oracle_query.json b/contracts/oracle/schema/query_msg.json similarity index 72% rename from contracts/oracle/schema/oracle_query.json rename to contracts/oracle/schema/query_msg.json index c337977..38d0902 100644 --- a/contracts/oracle/schema/oracle_query.json +++ b/contracts/oracle/schema/query_msg.json @@ -1,20 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "OracleQuery", + "title": "QueryMsg", "oneOf": [ - { - "type": "object", - "required": [ - "get_all_currency_pairs" - ], - "properties": { - "get_all_currency_pairs": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -24,11 +11,15 @@ "get_price": { "type": "object", "required": [ - "currency_pair" + "base", + "quote" ], "properties": { - "currency_pair": { - "$ref": "#/definitions/CurrencyPair" + "base": { + "type": "string" + }, + "quote": { + "type": "string" } }, "additionalProperties": false @@ -59,24 +50,19 @@ } }, "additionalProperties": false - } - ], - "definitions": { - "CurrencyPair": { + }, + { "type": "object", "required": [ - "Base", - "Quote" + "get_all_currency_pairs" ], "properties": { - "Base": { - "type": "string" - }, - "Quote": { - "type": "string" + "get_all_currency_pairs": { + "type": "object", + "additionalProperties": false } }, "additionalProperties": false } - } + ] } From 6c17bc85830e852a74cd469398530ad2c958215f Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 16 Oct 2024 17:57:35 +0400 Subject: [PATCH 25/34] cleanup --- Cargo.lock | 4 ++-- contracts/balance-tracker/.cargo/config | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cd50e0e..858d0a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#599d9ad8186c596ce7daf1ea590647ac32faac97" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#08b4e767a8147edf1f80d00d7d49067fae538103" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#599d9ad8186c596ce7daf1ea590647ac32faac97" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#08b4e767a8147edf1f80d00d7d49067fae538103" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/balance-tracker/.cargo/config b/contracts/balance-tracker/.cargo/config index 52fc65f..444af15 100644 --- a/contracts/balance-tracker/.cargo/config +++ b/contracts/balance-tracker/.cargo/config @@ -3,4 +3,3 @@ wasm = "build --release --target wasm32-unknown-unknown" wasm-debug = "build --target wasm32-unknown-unknown" unit-test = "test --lib" integration-test = "test --test integration" -schema = "run --example tokenfactory_tracker_schema" From 766672c1e7514860a896c94c56fb7b0a9631820d Mon Sep 17 00:00:00 2001 From: nhpd Date: Thu, 17 Oct 2024 18:48:02 +0400 Subject: [PATCH 26/34] fix queries Height struct used in sudo calls --- Cargo.lock | 4 ++-- contracts/neutron_interchain_queries/src/contract.rs | 2 +- .../neutron_interchain_queries/src/testing/tests.rs | 5 +++-- contracts/neutron_interchain_txs/schema/sudo_msg.json | 9 +++------ contracts/neutron_validator_test/schema/sudo_msg.json | 9 +++------ contracts/neutron_validator_test/src/contract.rs | 2 +- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 858d0a9..e85c20b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#08b4e767a8147edf1f80d00d7d49067fae538103" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#b3095f3719c05268ca796bdcf7b77d3589bab394" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#08b4e767a8147edf1f80d00d7d49067fae538103" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#b3095f3719c05268ca796bdcf7b77d3589bab394" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index 8c4656d..e9aac7c 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -34,6 +34,7 @@ use neutron_sdk::interchain_queries::helpers::{ remove_interchain_query as helpers_remove_interchain_query, update_interchain_query as helpers_update_interchain_query, }; +use neutron_sdk::interchain_queries::sudo::Height; use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -57,7 +58,6 @@ use neutron_sdk::interchain_queries::v047::register_queries::{ use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; -use neutron_std::types::ibc::core::client::v1::Height; use neutron_std::types::neutron::interchainqueries::KvKey; use prost::Message as ProstMessage; diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index e4acd4e..504e8a7 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -33,6 +33,7 @@ use cosmwasm_std::{ }; use neutron_sdk::interchain_queries::helpers::{decode_and_convert, kv_key_from_string}; use neutron_sdk::interchain_queries::hex::decode_hex; +use neutron_sdk::interchain_queries::sudo::Height as QueriesHeight; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -1032,7 +1033,7 @@ fn test_sudo_tx_query_result_callback() { let env = mock_env(); let watched_addr: String = "neutron1fj6yqrkpw6fmp7f7jhj57dujfpwal4m25dafzx".to_string(); let query_id: u64 = 1u64; - let height = Height { + let height = QueriesHeight { revision_number: 0u64, revision_height: 1u64, }; @@ -1136,7 +1137,7 @@ fn test_sudo_tx_query_result_min_height_callback() { let env = mock_env(); let watched_addr: String = "neutron1fj6yqrkpw6fmp7f7jhj57dujfpwal4m25dafzx".to_string(); let query_id: u64 = 1u64; - let height = Height { + let height = QueriesHeight { revision_number: 0u64, revision_height: 1u64, }; diff --git a/contracts/neutron_interchain_txs/schema/sudo_msg.json b/contracts/neutron_interchain_txs/schema/sudo_msg.json index da97da0..de8ad10 100644 --- a/contracts/neutron_interchain_txs/schema/sudo_msg.json +++ b/contracts/neutron_interchain_txs/schema/sudo_msg.json @@ -167,21 +167,18 @@ "type": "string" }, "Height": { - "description": "Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients\n\nNormally the RevisionHeight is incremented at each height while keeping RevisionNumber the same. However some consensus algorithms may choose to reset the height in certain conditions e.g. hard forks, state-machine breaking changes In these cases, the RevisionNumber is incremented so that height continues to be monitonically increasing even as the RevisionHeight gets reset", "type": "object", - "required": [ - "revision_height", - "revision_number" - ], "properties": { "revision_height": { - "description": "the height within the given revision", + "description": "*height** is a height of remote chain", + "default": 0, "type": "integer", "format": "uint64", "minimum": 0.0 }, "revision_number": { "description": "the revision that the client is currently on", + "default": 0, "type": "integer", "format": "uint64", "minimum": 0.0 diff --git a/contracts/neutron_validator_test/schema/sudo_msg.json b/contracts/neutron_validator_test/schema/sudo_msg.json index da97da0..de8ad10 100644 --- a/contracts/neutron_validator_test/schema/sudo_msg.json +++ b/contracts/neutron_validator_test/schema/sudo_msg.json @@ -167,21 +167,18 @@ "type": "string" }, "Height": { - "description": "Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients\n\nNormally the RevisionHeight is incremented at each height while keeping RevisionNumber the same. However some consensus algorithms may choose to reset the height in certain conditions e.g. hard forks, state-machine breaking changes In these cases, the RevisionNumber is incremented so that height continues to be monitonically increasing even as the RevisionHeight gets reset", "type": "object", - "required": [ - "revision_height", - "revision_number" - ], "properties": { "revision_height": { - "description": "the height within the given revision", + "description": "*height** is a height of remote chain", + "default": 0, "type": "integer", "format": "uint64", "minimum": 0.0 }, "revision_number": { "description": "the revision that the client is currently on", + "default": 0, "type": "integer", "format": "uint64", "minimum": 0.0 diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 1924e24..ec5863f 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -36,6 +36,7 @@ use cosmwasm_std::{ use cw2::set_contract_version; use neutron_sdk::interchain_queries::helpers::remove_interchain_query as helpers_remove_interchain_query; use neutron_sdk::interchain_queries::queries::get_registered_query; +use neutron_sdk::interchain_queries::sudo::Height; use neutron_sdk::interchain_queries::types::{ TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -53,7 +54,6 @@ use neutron_sdk::{NeutronError, NeutronResult}; use neutron_std::shim::Any; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; use neutron_std::types::ibc::core::channel::v1::Order; -use neutron_std::types::ibc::core::client::v1::Height; use neutron_std::types::neutron::feerefunder::Fee; use neutron_std::types::neutron::interchainqueries::RegisteredQuery; use neutron_std::types::neutron::interchaintxs::v1::{InterchaintxsQuerier, MsgSubmitTxResponse}; From 4362c2988aa232acac8088778277fcf233ac804e Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 03:46:48 +0400 Subject: [PATCH 27/34] cleanup contracts --- contracts/cron/.cargo/config | 6 ++++++ contracts/dex_grpc/src/contract.rs | 29 +++++++++++++------------- contracts/tokenfactory/src/contract.rs | 12 +++++------ 3 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 contracts/cron/.cargo/config diff --git a/contracts/cron/.cargo/config b/contracts/cron/.cargo/config new file mode 100644 index 0000000..11c14fd --- /dev/null +++ b/contracts/cron/.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" +integration-test = "test --test integration" +schema = "run --example schema" \ No newline at end of file diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index 552d234..241ff1a 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -1,6 +1,6 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cosmwasm_std::{ - entry_point, to_json_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, + entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; @@ -32,8 +32,7 @@ pub fn execute( _info: MessageInfo, msg: ExecuteMsg, ) -> StdResult { - deps.api - .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); + deps.api.debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { ExecuteMsg::Deposit { receiver, @@ -45,7 +44,7 @@ pub fn execute( fees, options, } => Ok( - Response::new().add_message(Into::::into(MsgDeposit { + Response::new().add_message(MsgDeposit { creator: env.contract.address.to_string(), receiver, token_a, @@ -55,7 +54,7 @@ pub fn execute( tick_indexes_a_to_b, fees, options, - })), + }), ), ExecuteMsg::Withdrawal { @@ -66,7 +65,7 @@ pub fn execute( tick_indexes_a_to_b, fees, } => Ok( - Response::new().add_message(Into::::into(MsgWithdrawal { + Response::new().add_message(MsgWithdrawal { creator: env.contract.address.to_string(), receiver, token_a, @@ -74,7 +73,7 @@ pub fn execute( shares_to_remove, tick_indexes_a_to_b, fees, - })), + }), ), #[allow(deprecated)] ExecuteMsg::PlaceLimitOrder { @@ -88,7 +87,7 @@ pub fn execute( expiration_time, max_amount_out, } => Ok( - Response::new().add_message(Into::::into(MsgPlaceLimitOrder { + Response::new().add_message(MsgPlaceLimitOrder { creator: env.contract.address.to_string(), receiver, token_in, @@ -100,21 +99,21 @@ pub fn execute( expiration_time, max_amount_out, min_average_sell_price: "".to_string(), // TODO - })), + }), ), ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => Ok(Response::new().add_message( - Into::::into(MsgWithdrawFilledLimitOrder { + MsgWithdrawFilledLimitOrder { creator: env.contract.address.to_string(), tranche_key, - }), + }, )), ExecuteMsg::CancelLimitOrder { tranche_key } => { Ok( - Response::new().add_message(Into::::into(MsgCancelLimitOrder { + Response::new().add_message(MsgCancelLimitOrder { creator: env.contract.address.to_string(), tranche_key, - })), + }), ) } @@ -125,14 +124,14 @@ pub fn execute( exit_limit_price, pick_best_route, } => Ok( - Response::new().add_message(Into::::into(MsgMultiHopSwap { + Response::new().add_message(MsgMultiHopSwap { creator: env.contract.address.to_string(), receiver, routes, amount_in, exit_limit_price, pick_best_route, - })), + }), ), } } diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 5272cb4..0794928 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -31,7 +31,7 @@ pub fn execute( ) -> StdResult { let msg: CosmosMsg = match msg { ExecuteMsg::CreateDenom { subdenom } => MsgCreateDenom { - sender: info.sender.to_string(), + sender: env.contract.address.to_string(), subdenom, } .into(), @@ -39,7 +39,7 @@ pub fn execute( denom, new_admin_address, } => MsgChangeAdmin { - sender: info.sender.to_string(), + sender: env.contract.address.to_string(), denom, new_admin: new_admin_address, } @@ -49,7 +49,7 @@ pub fn execute( amount, mint_to_address, } => MsgMint { - sender: info.sender.to_string(), + sender: env.contract.address.to_string(), amount: Some(CosmosCoin { denom, amount: amount.to_string(), @@ -62,7 +62,7 @@ pub fn execute( amount, burn_from_address, } => MsgBurn { - sender: info.sender.to_string(), + sender: env.contract.address.to_string(), amount: Some(CosmosCoin { denom, amount: amount.to_string(), @@ -74,7 +74,7 @@ pub fn execute( denom, contract_addr, } => MsgSetBeforeSendHook { - sender: info.sender.to_string(), + sender: env.contract.address.to_string(), denom, contract_addr, } @@ -113,7 +113,7 @@ pub fn execute( uri, uri_hash, } => MsgSetDenomMetadata { - sender: info.sender.to_string(), + sender: env.contract.address.to_string(), metadata: Some(Metadata { description, denom_units, From 6707ecd744256c84e7487109e82fadeeb36ef0a3 Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 12:45:48 +0400 Subject: [PATCH 28/34] unify tokenfactory contract messages --- contracts/dex_grpc/src/contract.rs | 114 +++++++++++-------------- contracts/tokenfactory/src/contract.rs | 11 +-- contracts/tokenfactory/src/msg.rs | 15 +--- 3 files changed, 59 insertions(+), 81 deletions(-) diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index 241ff1a..a294027 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -1,7 +1,6 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cosmwasm_std::{ - entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, - StdResult, + entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; use neutron_sdk::sudo::msg::SudoMsg; @@ -32,7 +31,8 @@ pub fn execute( _info: MessageInfo, msg: ExecuteMsg, ) -> StdResult { - deps.api.debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); + deps.api + .debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str()); match msg { ExecuteMsg::Deposit { receiver, @@ -43,19 +43,17 @@ pub fn execute( tick_indexes_a_to_b, fees, options, - } => Ok( - Response::new().add_message(MsgDeposit { - creator: env.contract.address.to_string(), - receiver, - token_a, - token_b, - amounts_a, - amounts_b, - tick_indexes_a_to_b, - fees, - options, - }), - ), + } => Ok(Response::new().add_message(MsgDeposit { + creator: env.contract.address.to_string(), + receiver, + token_a, + token_b, + amounts_a, + amounts_b, + tick_indexes_a_to_b, + fees, + options, + })), ExecuteMsg::Withdrawal { receiver, @@ -64,17 +62,15 @@ pub fn execute( shares_to_remove, tick_indexes_a_to_b, fees, - } => Ok( - Response::new().add_message(MsgWithdrawal { - creator: env.contract.address.to_string(), - receiver, - token_a, - token_b, - shares_to_remove, - tick_indexes_a_to_b, - fees, - }), - ), + } => Ok(Response::new().add_message(MsgWithdrawal { + creator: env.contract.address.to_string(), + receiver, + token_a, + token_b, + shares_to_remove, + tick_indexes_a_to_b, + fees, + })), #[allow(deprecated)] ExecuteMsg::PlaceLimitOrder { receiver, @@ -86,35 +82,31 @@ pub fn execute( order_type, expiration_time, max_amount_out, - } => Ok( - Response::new().add_message(MsgPlaceLimitOrder { - creator: env.contract.address.to_string(), - receiver, - token_in, - token_out, - tick_index_in_to_out, - limit_sell_price, - amount_in, - order_type, - expiration_time, - max_amount_out, - min_average_sell_price: "".to_string(), // TODO - }), - ), - ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => Ok(Response::new().add_message( - MsgWithdrawFilledLimitOrder { + } => Ok(Response::new().add_message(MsgPlaceLimitOrder { + creator: env.contract.address.to_string(), + receiver, + token_in, + token_out, + tick_index_in_to_out, + limit_sell_price, + amount_in, + order_type, + expiration_time, + max_amount_out, + min_average_sell_price: "".to_string(), // TODO + })), + ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => { + Ok(Response::new().add_message(MsgWithdrawFilledLimitOrder { creator: env.contract.address.to_string(), tranche_key, - }, - )), + })) + } ExecuteMsg::CancelLimitOrder { tranche_key } => { - Ok( - Response::new().add_message(MsgCancelLimitOrder { - creator: env.contract.address.to_string(), - tranche_key, - }), - ) + Ok(Response::new().add_message(MsgCancelLimitOrder { + creator: env.contract.address.to_string(), + tranche_key, + })) } ExecuteMsg::MultiHopSwap { @@ -123,16 +115,14 @@ pub fn execute( amount_in, exit_limit_price, pick_best_route, - } => Ok( - Response::new().add_message(MsgMultiHopSwap { - creator: env.contract.address.to_string(), - receiver, - routes, - amount_in, - exit_limit_price, - pick_best_route, - }), - ), + } => Ok(Response::new().add_message(MsgMultiHopSwap { + creator: env.contract.address.to_string(), + receiver, + routes, + amount_in, + exit_limit_price, + pick_best_route, + })), } } diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 0794928..497012a 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -134,11 +134,8 @@ pub fn execute( pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { let querier = TokenfactoryQuerier::new(&deps.querier); Ok(match msg { - QueryMsg::FullDenom { - creator_addr, - subdenom, - } => { - let res = &querier.full_denom(creator_addr, subdenom)?; + QueryMsg::FullDenom { creator, subdenom } => { + let res = &querier.full_denom(creator, subdenom)?; to_json_binary(res)? } QueryMsg::DenomAdmin { creator, subdenom } => { @@ -149,8 +146,8 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult { .ok_or(Std(StdError::generic_err("authority metadata not found")))?, )? } - QueryMsg::BeforeSendHook { creator, denom } => { - to_json_binary(&querier.before_send_hook_address(creator, denom)?)? + QueryMsg::BeforeSendHook { creator, subdenom } => { + to_json_binary(&querier.before_send_hook_address(creator, subdenom)?)? } }) } diff --git a/contracts/tokenfactory/src/msg.rs b/contracts/tokenfactory/src/msg.rs index c4dcecc..73b68cc 100644 --- a/contracts/tokenfactory/src/msg.rs +++ b/contracts/tokenfactory/src/msg.rs @@ -56,18 +56,9 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - FullDenom { - creator_addr: String, - subdenom: String, - }, - DenomAdmin { - creator: String, - subdenom: String, - }, - BeforeSendHook { - creator: String, - denom: String, - }, + FullDenom { creator: String, subdenom: String }, + DenomAdmin { creator: String, subdenom: String }, + BeforeSendHook { creator: String, subdenom: String }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] From f578c389550e9ce6396261ba6ce60d7556318554 Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 13:18:40 +0400 Subject: [PATCH 29/34] fix tokenfactory --- contracts/tokenfactory/schema/query_msg.json | 8 ++++---- contracts/tokenfactory/src/contract.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/tokenfactory/schema/query_msg.json b/contracts/tokenfactory/schema/query_msg.json index dc71bfa..d86ed5d 100644 --- a/contracts/tokenfactory/schema/query_msg.json +++ b/contracts/tokenfactory/schema/query_msg.json @@ -11,11 +11,11 @@ "full_denom": { "type": "object", "required": [ - "creator_addr", + "creator", "subdenom" ], "properties": { - "creator_addr": { + "creator": { "type": "string" }, "subdenom": { @@ -62,13 +62,13 @@ "type": "object", "required": [ "creator", - "denom" + "subdenom" ], "properties": { "creator": { "type": "string" }, - "denom": { + "subdenom": { "type": "string" } }, diff --git a/contracts/tokenfactory/src/contract.rs b/contracts/tokenfactory/src/contract.rs index 497012a..c9960b8 100644 --- a/contracts/tokenfactory/src/contract.rs +++ b/contracts/tokenfactory/src/contract.rs @@ -26,7 +26,7 @@ pub fn instantiate( pub fn execute( _deps: DepsMut, env: Env, - info: MessageInfo, + _info: MessageInfo, msg: ExecuteMsg, ) -> StdResult { let msg: CosmosMsg = match msg { @@ -94,7 +94,7 @@ pub fn execute( from, to, } => MsgForceTransfer { - sender: info.sender.to_string(), + sender: env.contract.address.to_string(), amount: Some(CosmosCoin { denom, amount: amount.to_string(), From 3e73b7f034986c805a56948e08607afff37e4ede Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 18 Oct 2024 14:49:52 +0400 Subject: [PATCH 30/34] update neutron std --- Cargo.lock | 17 ++--------------- .../neutron_interchain_queries/src/contract.rs | 2 +- .../src/testing/tests.rs | 2 +- .../neutron_interchain_txs/schema/sudo_msg.json | 1 + .../neutron_validator_test/schema/sudo_msg.json | 1 + .../neutron_validator_test/src/contract.rs | 2 +- 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e85c20b..be54b29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#b3095f3719c05268ca796bdcf7b77d3589bab394" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#c0fdaa1dbe82e28d738bf106f2c9acb1e4bd3e71" dependencies = [ "bech32 0.9.1", "chrono", @@ -1136,7 +1136,6 @@ dependencies = [ "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", "neutron-std", - "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings)", "prost 0.12.6", "prost-types 0.12.6", "protobuf", @@ -1160,7 +1159,7 @@ dependencies = [ "cosmos-sdk-proto 0.20.0", "cosmwasm-schema 2.1.4", "cosmwasm-std 2.1.4", - "neutron-std-derive 0.20.1 (git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings)", + "neutron-std-derive", "prost 0.12.6", "prost-types 0.12.6", "protobuf", @@ -1174,18 +1173,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "neutron-std-derive" -version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#b3095f3719c05268ca796bdcf7b77d3589bab394" -dependencies = [ - "itertools 0.10.5", - "proc-macro2", - "prost-types 0.12.6", - "quote", - "syn 1.0.109", -] - [[package]] name = "neutron-std-derive" version = "0.20.1" diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index e9aac7c..3027540 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -34,7 +34,6 @@ use neutron_sdk::interchain_queries::helpers::{ remove_interchain_query as helpers_remove_interchain_query, update_interchain_query as helpers_update_interchain_query, }; -use neutron_sdk::interchain_queries::sudo::Height; use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -56,6 +55,7 @@ use neutron_sdk::interchain_queries::v047::register_queries::{ new_register_validators_signing_infos_query_msg, }; use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; +use neutron_sdk::sudo::msg::Height; use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; use neutron_std::types::neutron::interchainqueries::KvKey; diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 504e8a7..a9f8552 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -33,7 +33,6 @@ use cosmwasm_std::{ }; use neutron_sdk::interchain_queries::helpers::{decode_and_convert, kv_key_from_string}; use neutron_sdk::interchain_queries::hex::decode_hex; -use neutron_sdk::interchain_queries::sudo::Height as QueriesHeight; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -51,6 +50,7 @@ use neutron_sdk::interchain_queries::v047::types::{ SigningInfo, StakingValidator, StdDelegation, TallyResult, TotalSupply, Validator, ValidatorSigningInfo, WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; +use neutron_sdk::sudo::msg::Height as QueriesHeight; use neutron_sdk::NeutronError; use neutron_std::types::cosmos::base::v1beta1::Coin as StdCoin; use neutron_std::types::ibc::core::client::v1::Height; diff --git a/contracts/neutron_interchain_txs/schema/sudo_msg.json b/contracts/neutron_interchain_txs/schema/sudo_msg.json index de8ad10..9c5fab7 100644 --- a/contracts/neutron_interchain_txs/schema/sudo_msg.json +++ b/contracts/neutron_interchain_txs/schema/sudo_msg.json @@ -167,6 +167,7 @@ "type": "string" }, "Height": { + "description": "Height is used for sudo call for `TxQueryResult` enum variant type", "type": "object", "properties": { "revision_height": { diff --git a/contracts/neutron_validator_test/schema/sudo_msg.json b/contracts/neutron_validator_test/schema/sudo_msg.json index de8ad10..9c5fab7 100644 --- a/contracts/neutron_validator_test/schema/sudo_msg.json +++ b/contracts/neutron_validator_test/schema/sudo_msg.json @@ -167,6 +167,7 @@ "type": "string" }, "Height": { + "description": "Height is used for sudo call for `TxQueryResult` enum variant type", "type": "object", "properties": { "revision_height": { diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index ec5863f..57728fe 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -36,7 +36,6 @@ use cosmwasm_std::{ use cw2::set_contract_version; use neutron_sdk::interchain_queries::helpers::remove_interchain_query as helpers_remove_interchain_query; use neutron_sdk::interchain_queries::queries::get_registered_query; -use neutron_sdk::interchain_queries::sudo::Height; use neutron_sdk::interchain_queries::types::{ TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; @@ -49,6 +48,7 @@ use neutron_sdk::interchain_txs::helpers::{ decode_message_response, get_port_id, register_interchain_account, submit_tx, }; use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; +use neutron_sdk::sudo::msg::Height; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; use neutron_std::shim::Any; From 215d9affb748808aba7e02fe334ffe49c72fe7d5 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 28 Oct 2024 19:18:35 +0400 Subject: [PATCH 31/34] update neutron-std --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be54b29..7306fb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1152,7 +1152,7 @@ dependencies = [ [[package]] name = "neutron-std" version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#1e61039a6c59bc58292029c00bf4f7758dc31b4f" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e4e54dcf999dcafa1b71040c5c75d58f82c9122b" dependencies = [ "bech32 0.9.1", "chrono", @@ -1176,7 +1176,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#1e61039a6c59bc58292029c00bf4f7758dc31b4f" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e4e54dcf999dcafa1b71040c5c75d58f82c9122b" dependencies = [ "itertools 0.10.5", "proc-macro2", From 8851b4459e14baf357bb3e96bea709ca5da9f2bb Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 28 Oct 2024 21:19:52 +0400 Subject: [PATCH 32/34] cleanup path trims and TODO message --- Cargo.lock | 2 +- contracts/dex_grpc/src/contract.rs | 2 +- .../neutron_interchain_queries/src/testing/mock_querier.rs | 6 ++---- contracts/neutron_interchain_queries/src/testing/tests.rs | 5 +++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7306fb8..0e71ad6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#c0fdaa1dbe82e28d738bf106f2c9acb1e4bd3e71" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#67f20b6c7cf3521a2aad01fea94b324d71f556a7" dependencies = [ "bech32 0.9.1", "chrono", diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index a294027..00dba8f 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -93,7 +93,7 @@ pub fn execute( order_type, expiration_time, max_amount_out, - min_average_sell_price: "".to_string(), // TODO + min_average_sell_price: "".to_string(), })), ExecuteMsg::WithdrawFilledLimitOrder { tranche_key } => { Ok(Response::new().add_message(MsgWithdrawFilledLimitOrder { diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index 5335288..4c3d490 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -75,21 +75,19 @@ impl WasmMockQuerier { pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { match &request { QueryRequest::Grpc(GrpcQuery { path, data }) => { - let quoted_path = path.trim_matches('"').to_string(); - if "ed_path == "/neutron.interchainqueries.Query/QueryResult" { + if path == "/neutron.interchainqueries.Query/QueryResult" { let request: QueryRegisteredQueryResultRequest = ::prost::Message::decode(&data[..]).unwrap(); SystemResult::Ok(ContractResult::Ok( (*self.query_responses.get(&request.query_id).unwrap()).clone(), )) - } else if "ed_path == "/neutron.interchainqueries.Query/RegisteredQuery" { + } else if path == "/neutron.interchainqueries.Query/RegisteredQuery" { let request: QueryRegisteredQueryRequest = ::prost::Message::decode(&data[..]).unwrap(); SystemResult::Ok(ContractResult::Ok( (*self.registered_queries.get(&request.query_id).unwrap()).clone(), )) } else { - println!("PATH: {}", quoted_path); self.base.handle_query(request) } } diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index a9f8552..0f347f6 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -31,8 +31,9 @@ use cosmwasm_std::testing::{message_info, mock_env, MockApi, MockStorage}; use cosmwasm_std::{ from_json, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, Uint128, }; -use neutron_sdk::interchain_queries::helpers::{decode_and_convert, kv_key_from_string}; -use neutron_sdk::interchain_queries::hex::decode_hex; +use neutron_sdk::interchain_queries::helpers::{ + decode_and_convert, decode_hex, kv_key_from_string, +}; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; From f61ecf42f24f09093f8d7a2028e4115b719fdf00 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 30 Oct 2024 19:06:06 +0400 Subject: [PATCH 33/34] update neutron-sdk and neutron-std --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e71ad6..a648061 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#67f20b6c7cf3521a2aad01fea94b324d71f556a7" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4353f650827964661bac61d66f597b52a2af5fe2" dependencies = [ "bech32 0.9.1", "chrono", @@ -1152,7 +1152,7 @@ dependencies = [ [[package]] name = "neutron-std" version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e4e54dcf999dcafa1b71040c5c75d58f82c9122b" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e196be936045944c3b8625d4f172eb96c78faa20" dependencies = [ "bech32 0.9.1", "chrono", @@ -1176,7 +1176,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e4e54dcf999dcafa1b71040c5c75d58f82c9122b" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e196be936045944c3b8625d4f172eb96c78faa20" dependencies = [ "itertools 0.10.5", "proc-macro2", From b6d26188d0da7b1052ee58590792a6f7f9434e99 Mon Sep 17 00:00:00 2001 From: nhpd Date: Thu, 31 Oct 2024 14:44:26 +0400 Subject: [PATCH 34/34] set std and sdk to main branch --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a648061..c068646 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4353f650827964661bac61d66f597b52a2af5fe2" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#b83c182e8688f826c313cae318ff8ae908b87c81" dependencies = [ "bech32 0.9.1", "chrono", @@ -1151,8 +1151,8 @@ dependencies = [ [[package]] name = "neutron-std" -version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e196be936045944c3b8625d4f172eb96c78faa20" +version = "5.0.0" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#25e0d0c1e7f56d40ba62908d9e2c03b5d3779bd2" dependencies = [ "bech32 0.9.1", "chrono", @@ -1176,7 +1176,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#e196be936045944c3b8625d4f172eb96c78faa20" +source = "git+https://github.com/neutron-org/neutron-std?branch=main#25e0d0c1e7f56d40ba62908d9e2c03b5d3779bd2" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index fe22cd6..f9dfd2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ incremental = false overflow-checks = true [workspace.dependencies] -neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/clean-bindings" } -neutron-std = { git = "https://github.com/neutron-org/neutron-std", branch = "feat/clean-bindings" } +neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" } +neutron-std = { git = "https://github.com/neutron-org/neutron-std", branch = "main" } prost = "0.12.4" prost-types = "0.12.4"