From 15062e76997ce43a2911f0b2399d711432819600 Mon Sep 17 00:00:00 2001 From: kaimen-sano Date: Sat, 6 Apr 2024 23:09:00 +1300 Subject: [PATCH] refactor(schemas): simplify generating schemas --- .cargo/config.toml | 4 + .github/workflows/ci-test-fmt-check.yaml | 7 - .github/workflows/validate-schemas.yml | 34 + Cargo.lock | 11 + Cargo.toml | 28 +- .../liquidity_hub/epoch-manager/.cargo/config | 1 - .../src/bin/epoch_manager_schema.rs | 12 - .../liquidity_hub/fee_collector/.cargo/config | 1 - .../fee_collector/schema/fee_collector.json | 4 +- .../src/bin/fee_collector_schema.rs | 14 - .../fee_distributor/.cargo/config | 1 - .../src/bin/fee_distributor_schema.rs | 11 - .../liquidity_hub/pool-manager/.cargo/config | 1 - .../pool-manager/schema/pool-manager.json | 34 +- .../pool-manager/schema/raw/execute.json | 20 +- .../pool-manager/schema/raw/migrate.json | 7 + .../schema/raw/response_to_pair.json | 4 +- .../pool-manager/src/bin/schema.rs | 11 - .../frontend_helper/.cargo/config | 1 - .../frontend_helper/examples/schema.rs | 13 - .../schema/frontend-helper.json | 61 +- .../frontend_helper/schema/raw/query.json | 115 +-- .../schema/raw/response_to_config.json | 134 +-- .../pool-network/incentive/.cargo/config | 1 - .../incentive/examples/incentive_schema.rs | 14 - .../incentive/schema/incentive.json | 4 +- .../schema/incentive-factory.json | 4 +- .../schema/terraswap-factory.json | 4 +- .../terraswap_pair/schema/terraswap-pair.json | 4 +- .../schema/terraswap-router.json | 4 +- .../schema/raw/instantiate.json | 111 +-- .../schema/terraswap-token.json | 115 +-- .../terraswap_token/src/contract.rs | 3 +- .../liquidity_hub/vault-manager/.cargo/config | 1 - .../vault-manager/src/bin/schema.rs | 11 - .../src/bin/vault_manager_schema.rs | 11 - .../vault-network/vault/.cargo/config | 1 - .../vault-network/vault/schema/vault.json | 4 +- .../vault/src/bin/vault_schema.rs | 13 - .../vault-network/vault_factory/.cargo/config | 1 - .../vault-network/vault_factory/Cargo.toml | 2 +- .../vault_factory/schema/vault_factory.json | 4 +- .../src/bin/vault_factory_schema.rs | 16 - .../vault-network/vault_router/.cargo/config | 1 - .../vault-network/vault_router/Cargo.toml | 2 +- .../vault_router/schema/vault_router.json | 4 +- .../src/bin/vault_router_schema.rs | 16 - .../liquidity_hub/whale_lair/.cargo/config | 1 - contracts/liquidity_hub/whale_lair/Cargo.toml | 6 +- .../whale_lair/src/bin/whale_lair_schema.rs | 11 - .../whale_lair/src/schema/whale-lair.json | 834 ------------------ packages/white-whale-std/Cargo.toml | 11 +- .../white-whale-std/src/pool_network/token.rs | 4 + scripts/build_schemas.sh | 50 +- xtask/Cargo.toml | 19 + xtask/src/main.rs | 187 ++++ 56 files changed, 410 insertions(+), 1593 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 .github/workflows/validate-schemas.yml delete mode 100644 contracts/liquidity_hub/epoch-manager/src/bin/epoch_manager_schema.rs delete mode 100644 contracts/liquidity_hub/fee_collector/src/bin/fee_collector_schema.rs delete mode 100644 contracts/liquidity_hub/fee_distributor/src/bin/fee_distributor_schema.rs create mode 100644 contracts/liquidity_hub/pool-manager/schema/raw/migrate.json delete mode 100644 contracts/liquidity_hub/pool-manager/src/bin/schema.rs delete mode 100644 contracts/liquidity_hub/pool-network/frontend_helper/examples/schema.rs delete mode 100644 contracts/liquidity_hub/pool-network/incentive/examples/incentive_schema.rs delete mode 100644 contracts/liquidity_hub/vault-manager/src/bin/schema.rs delete mode 100644 contracts/liquidity_hub/vault-manager/src/bin/vault_manager_schema.rs delete mode 100644 contracts/liquidity_hub/vault-network/vault/src/bin/vault_schema.rs delete mode 100644 contracts/liquidity_hub/vault-network/vault_factory/src/bin/vault_factory_schema.rs delete mode 100644 contracts/liquidity_hub/vault-network/vault_router/src/bin/vault_router_schema.rs delete mode 100644 contracts/liquidity_hub/whale_lair/src/bin/whale_lair_schema.rs delete mode 100644 contracts/liquidity_hub/whale_lair/src/schema/whale-lair.json create mode 100644 xtask/Cargo.toml create mode 100644 xtask/src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..3339360ea --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ +# define x-task aliases +# see https://github.com/matklad/cargo-xtask +[alias] +xtask = "run --package xtask --" diff --git a/.github/workflows/ci-test-fmt-check.yaml b/.github/workflows/ci-test-fmt-check.yaml index a5a59e877..582557dc6 100644 --- a/.github/workflows/ci-test-fmt-check.yaml +++ b/.github/workflows/ci-test-fmt-check.yaml @@ -17,7 +17,6 @@ jobs: test_and_check-token_factory_feature: name: Test and check Token factory feature runs-on: ubuntu-latest - steps: # Cancel any existing runs to save on CI time # - name: Cancel Previous Runs @@ -70,12 +69,6 @@ jobs: command: fmt args: --all -- --check - - name: Generate Schemas and Exit on uncommitted changes - run: | - chmod +x ./scripts/build_schemas.sh - ./scripts/build_schemas.sh -f token_factory -d true - shell: bash - test_and_check-token_injective_feature: name: Test and check Injective feature runs-on: ubuntu-latestq diff --git a/.github/workflows/validate-schemas.yml b/.github/workflows/validate-schemas.yml new file mode 100644 index 000000000..15e9ce060 --- /dev/null +++ b/.github/workflows/validate-schemas.yml @@ -0,0 +1,34 @@ +name: Validate schemas + +on: + pull_request: + push: + branches: + - main + +jobs: + validate_schemas: + name: Validate schemas are up to date + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - uses: dtolnay/rust-toolchain@stable + + - name: Validate schemas are up to date + run: | + chmod +x ./scripts/build_schemas.sh + ./scripts/build_schemas.sh -d true + + - name: Add comment if failed + if: ${{ failure() }} + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Schema generation failed. Please run `just schemas` locally and upload the generated schemas.' + }) diff --git a/Cargo.lock b/Cargo.lock index de075a938..08be48f66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1744,6 +1744,7 @@ dependencies = [ "cw-storage-plus", "cw2", "cw20", + "cw20-base", "osmosis-std-derive", "prost 0.11.9", "prost-types", @@ -1893,6 +1894,16 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +[[package]] +name = "xtask" +version = "0.0.0" +dependencies = [ + "cosmwasm-schema", + "serde", + "serde_json", + "white-whale-std", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/Cargo.toml b/Cargo.toml index 51d355ebb..e100f997b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,15 +2,16 @@ resolver = "2" members = [ - "packages/*", - "contracts/liquidity_hub/pool-network/*", - "contracts/liquidity_hub/fee_collector", - "contracts/liquidity_hub/fee_distributor", - "contracts/liquidity_hub/whale_lair", - "contracts/liquidity_hub/vault-network/*", - "contracts/liquidity_hub/pool-manager", - "contracts/liquidity_hub/epoch-manager", - "contracts/liquidity_hub/vault-manager", + "packages/*", + "contracts/liquidity_hub/pool-network/*", + "contracts/liquidity_hub/fee_collector", + "contracts/liquidity_hub/fee_distributor", + "contracts/liquidity_hub/whale_lair", + "contracts/liquidity_hub/vault-network/*", + "contracts/liquidity_hub/pool-manager", + "contracts/liquidity_hub/epoch-manager", + "contracts/liquidity_hub/vault-manager", + "xtask", ] [workspace.package] @@ -20,13 +21,14 @@ documentation = "https://docs.whitewhale.money/white-whale" license = "MIT" repository = "https://github.com/White-Whale-Defi-Platform/migaloo-core" publish = false +authors = ["White Whale Defi"] [workspace.dependencies] cosmwasm-schema = { version = "1.5.3" } cosmwasm-std = { version = "1.1.4", features = [ - "iterator", - "cosmwasm_1_2", - "stargate", + "iterator", + "cosmwasm_1_2", + "stargate", ] } cw2 = { version = "1.0.1" } cw20 = { version = "1.0.1" } @@ -52,7 +54,7 @@ sha2 = { version = "=0.10.8" } sha256 = { version = "1.4.0" } protobuf = { version = "=3.2.0", features = ["with-bytes"] } prost = { version = "0.11.9", default-features = false, features = [ - "prost-derive", + "prost-derive", ] } test-case = { version = "3.3.1" } diff --git a/contracts/liquidity_hub/epoch-manager/.cargo/config b/contracts/liquidity_hub/epoch-manager/.cargo/config index e5e6b50ea..4f96ce061 100644 --- a/contracts/liquidity_hub/epoch-manager/.cargo/config +++ b/contracts/liquidity_hub/epoch-manager/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --lib --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin epoch_manager_schema" diff --git a/contracts/liquidity_hub/epoch-manager/src/bin/epoch_manager_schema.rs b/contracts/liquidity_hub/epoch-manager/src/bin/epoch_manager_schema.rs deleted file mode 100644 index e9b7f7d45..000000000 --- a/contracts/liquidity_hub/epoch-manager/src/bin/epoch_manager_schema.rs +++ /dev/null @@ -1,12 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::epoch_manager::epoch_manager::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -#[cfg(not(tarpaulin_include))] -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/liquidity_hub/fee_collector/.cargo/config b/contracts/liquidity_hub/fee_collector/.cargo/config index 4bfcbb525..f31de6c2a 100644 --- a/contracts/liquidity_hub/fee_collector/.cargo/config +++ b/contracts/liquidity_hub/fee_collector/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin fee_collector_schema" diff --git a/contracts/liquidity_hub/fee_collector/schema/fee_collector.json b/contracts/liquidity_hub/fee_collector/schema/fee_collector.json index 8552cba16..510d7b686 100644 --- a/contracts/liquidity_hub/fee_collector/schema/fee_collector.json +++ b/contracts/liquidity_hub/fee_collector/schema/fee_collector.json @@ -1,6 +1,6 @@ { - "contract_name": "fee_collector", - "contract_version": "1.0.2", + "contract_name": "xtask", + "contract_version": "1.1.4", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/fee_collector/src/bin/fee_collector_schema.rs b/contracts/liquidity_hub/fee_collector/src/bin/fee_collector_schema.rs deleted file mode 100644 index 5c872c2b5..000000000 --- a/contracts/liquidity_hub/fee_collector/src/bin/fee_collector_schema.rs +++ /dev/null @@ -1,14 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::fee_collector::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; - -fn main() { - write_api! { - name: "fee_collector", - version: "1.0.2", - instantiate: InstantiateMsg, - query: QueryMsg, - execute: ExecuteMsg, - migrate: MigrateMsg, - } -} diff --git a/contracts/liquidity_hub/fee_distributor/.cargo/config b/contracts/liquidity_hub/fee_distributor/.cargo/config index 21a8880bc..4f96ce061 100644 --- a/contracts/liquidity_hub/fee_distributor/.cargo/config +++ b/contracts/liquidity_hub/fee_distributor/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --lib --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin fee_distributor_schema" diff --git a/contracts/liquidity_hub/fee_distributor/src/bin/fee_distributor_schema.rs b/contracts/liquidity_hub/fee_distributor/src/bin/fee_distributor_schema.rs deleted file mode 100644 index 34a9927e9..000000000 --- a/contracts/liquidity_hub/fee_distributor/src/bin/fee_distributor_schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::fee_distributor::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/liquidity_hub/pool-manager/.cargo/config b/contracts/liquidity_hub/pool-manager/.cargo/config index af5698e58..4f96ce061 100644 --- a/contracts/liquidity_hub/pool-manager/.cargo/config +++ b/contracts/liquidity_hub/pool-manager/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --lib --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin schema" diff --git a/contracts/liquidity_hub/pool-manager/schema/pool-manager.json b/contracts/liquidity_hub/pool-manager/schema/pool-manager.json index 1d6146294..e419109cf 100644 --- a/contracts/liquidity_hub/pool-manager/schema/pool-manager.json +++ b/contracts/liquidity_hub/pool-manager/schema/pool-manager.json @@ -1,5 +1,5 @@ { - "contract_name": "pool-manager", + "contract_name": "xtask", "contract_version": "0.1.0", "idl_version": "1.0.0", "instantiate": { @@ -60,8 +60,7 @@ "required": [ "asset_denoms", "pair_type", - "pool_fees", - "token_factory_lp" + "pool_fees" ], "properties": { "asset_denoms": { @@ -81,9 +80,6 @@ }, "pool_fees": { "$ref": "#/definitions/PoolFee" - }, - "token_factory_lp": { - "type": "boolean" } }, "additionalProperties": false @@ -101,16 +97,9 @@ "provide_liquidity": { "type": "object", "required": [ - "assets", "pair_identifier" ], "properties": { - "assets": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "pair_identifier": { "type": "string" }, @@ -201,16 +190,9 @@ "withdraw_liquidity": { "type": "object", "required": [ - "assets", "pair_identifier" ], "properties": { - "assets": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "pair_identifier": { "type": "string" } @@ -785,7 +767,13 @@ } } }, - "migrate": null, + "migrate": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MigrateMsg", + "description": "The migrate message", + "type": "object", + "additionalProperties": false + }, "sudo": null, "responses": { "native_token_decimals": { @@ -908,7 +896,7 @@ "asset_denoms", "assets", "balances", - "liquidity_token", + "lp_denom", "pair_type", "pool_fees" ], @@ -939,7 +927,7 @@ "$ref": "#/definitions/Uint128" } }, - "liquidity_token": { + "lp_denom": { "type": "string" }, "pair_type": { diff --git a/contracts/liquidity_hub/pool-manager/schema/raw/execute.json b/contracts/liquidity_hub/pool-manager/schema/raw/execute.json index aa46593c0..eb439e1d6 100644 --- a/contracts/liquidity_hub/pool-manager/schema/raw/execute.json +++ b/contracts/liquidity_hub/pool-manager/schema/raw/execute.json @@ -13,8 +13,7 @@ "required": [ "asset_denoms", "pair_type", - "pool_fees", - "token_factory_lp" + "pool_fees" ], "properties": { "asset_denoms": { @@ -34,9 +33,6 @@ }, "pool_fees": { "$ref": "#/definitions/PoolFee" - }, - "token_factory_lp": { - "type": "boolean" } }, "additionalProperties": false @@ -54,16 +50,9 @@ "provide_liquidity": { "type": "object", "required": [ - "assets", "pair_identifier" ], "properties": { - "assets": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "pair_identifier": { "type": "string" }, @@ -154,16 +143,9 @@ "withdraw_liquidity": { "type": "object", "required": [ - "assets", "pair_identifier" ], "properties": { - "assets": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, "pair_identifier": { "type": "string" } diff --git a/contracts/liquidity_hub/pool-manager/schema/raw/migrate.json b/contracts/liquidity_hub/pool-manager/schema/raw/migrate.json new file mode 100644 index 000000000..be217b7d3 --- /dev/null +++ b/contracts/liquidity_hub/pool-manager/schema/raw/migrate.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MigrateMsg", + "description": "The migrate message", + "type": "object", + "additionalProperties": false +} diff --git a/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pair.json b/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pair.json index 511ccb51a..bbebbea98 100644 --- a/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pair.json +++ b/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pair.json @@ -7,7 +7,7 @@ "asset_denoms", "assets", "balances", - "liquidity_token", + "lp_denom", "pair_type", "pool_fees" ], @@ -38,7 +38,7 @@ "$ref": "#/definitions/Uint128" } }, - "liquidity_token": { + "lp_denom": { "type": "string" }, "pair_type": { diff --git a/contracts/liquidity_hub/pool-manager/src/bin/schema.rs b/contracts/liquidity_hub/pool-manager/src/bin/schema.rs deleted file mode 100644 index 5cdcba991..000000000 --- a/contracts/liquidity_hub/pool-manager/src/bin/schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::pool_manager::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/liquidity_hub/pool-network/frontend_helper/.cargo/config b/contracts/liquidity_hub/pool-network/frontend_helper/.cargo/config index 8d4bc738b..444af157c 100644 --- a/contracts/liquidity_hub/pool-network/frontend_helper/.cargo/config +++ b/contracts/liquidity_hub/pool-network/frontend_helper/.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 schema" diff --git a/contracts/liquidity_hub/pool-network/frontend_helper/examples/schema.rs b/contracts/liquidity_hub/pool-network/frontend_helper/examples/schema.rs deleted file mode 100644 index ced137c7f..000000000 --- a/contracts/liquidity_hub/pool-network/frontend_helper/examples/schema.rs +++ /dev/null @@ -1,13 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::pool_network::frontend_helper::{ExecuteMsg, InstantiateMsg, MigrateMsg}; - -fn main() { - write_api! { - name: "frontend-helper", - version: "1.0.0", - instantiate: InstantiateMsg, - execute: ExecuteMsg, - migrate: MigrateMsg, - } -} diff --git a/contracts/liquidity_hub/pool-network/frontend_helper/schema/frontend-helper.json b/contracts/liquidity_hub/pool-network/frontend_helper/schema/frontend-helper.json index ea6a79cde..0d3f33c26 100644 --- a/contracts/liquidity_hub/pool-network/frontend_helper/schema/frontend-helper.json +++ b/contracts/liquidity_hub/pool-network/frontend_helper/schema/frontend-helper.json @@ -1,5 +1,5 @@ { - "contract_name": "frontend-helper", + "contract_name": "xtask", "contract_version": "1.0.0", "idl_version": "1.0.0", "instantiate": { @@ -177,7 +177,26 @@ } } }, - "query": null, + "query": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "description": "Retrieves the current contract configuration.", + "type": "object", + "required": [ + "config" + ], + "properties": { + "config": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, "migrate": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "MigrateMsg", @@ -185,5 +204,41 @@ "additionalProperties": false }, "sudo": null, - "responses": null + "responses": { + "config": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Config", + "description": "Stores the configuration of the frontend helper.", + "type": "object", + "required": [ + "incentive_factory_addr", + "owner" + ], + "properties": { + "incentive_factory_addr": { + "description": "The address of the incentive factory.", + "allOf": [ + { + "$ref": "#/definitions/Addr" + } + ] + }, + "owner": { + "description": "The owner of the of the frontend helper.", + "allOf": [ + { + "$ref": "#/definitions/Addr" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + } + } + } + } } diff --git a/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/query.json b/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/query.json index c4b6db69b..f62496f58 100644 --- a/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/query.json +++ b/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/query.json @@ -3,7 +3,7 @@ "title": "QueryMsg", "oneOf": [ { - "description": "Retrieves the config of the incentive factory.", + "description": "Retrieves the current contract configuration.", "type": "object", "required": [ "config" @@ -15,117 +15,6 @@ } }, "additionalProperties": false - }, - { - "description": "Retrieves a specific incentive address.", - "type": "object", - "required": [ - "incentive" - ], - "properties": { - "incentive": { - "type": "object", - "required": [ - "lp_address" - ], - "properties": { - "lp_address": { - "description": "The address of the LP token.", - "allOf": [ - { - "$ref": "#/definitions/AssetInfo" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "incentives" - ], - "properties": { - "incentives": { - "type": "object", - "properties": { - "limit": { - "description": "The amount of incentive contracts to return.\n\nIf unspecified, will default to a value specified by the contract.", - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "description": "An optional parameter specifying what incentive contract to start searching after.", - "anyOf": [ - { - "$ref": "#/definitions/AssetInfo" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ], - "definitions": { - "AssetInfo": { - "description": "AssetInfo contract_addr is usually passed from the cw20 hook so we can trust the contract_addr is properly validated.", - "oneOf": [ - { - "type": "object", - "required": [ - "token" - ], - "properties": { - "token": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "native_token" - ], - "properties": { - "native_token": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] } - } + ] } diff --git a/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/response_to_config.json b/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/response_to_config.json index 708022aab..b4da722a9 100644 --- a/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/response_to_config.json +++ b/contracts/liquidity_hub/pool-network/frontend_helper/schema/raw/response_to_config.json @@ -1,148 +1,34 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Config", - "description": "Stores the configuration of the incentive factory.", + "description": "Stores the configuration of the frontend helper.", "type": "object", "required": [ - "create_flow_fee", - "fee_collector_addr", - "incentive_code_id", - "max_concurrent_flows", - "max_flow_start_time_buffer", - "max_unbonding_duration", - "min_unbonding_duration", + "incentive_factory_addr", "owner" ], "properties": { - "create_flow_fee": { - "description": "The fee that must be paid each time a user wants to create a flow.", + "incentive_factory_addr": { + "description": "The address of the incentive factory.", "allOf": [ { - "$ref": "#/definitions/Asset" + "$ref": "#/definitions/Addr" } ] }, - "fee_collector_addr": { - "description": "The address to send fees to.", + "owner": { + "description": "The owner of the of the frontend helper.", "allOf": [ { - "$ref": "#/definitions/CanonicalAddr" + "$ref": "#/definitions/Addr" } ] - }, - "incentive_code_id": { - "description": "The code ID of the incentive contract.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "max_concurrent_flows": { - "description": "The maximum amount of flows that can exist at any one time.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "max_flow_start_time_buffer": { - "description": "The maximum amount of time in the future a new flow is allowed to start in.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "max_unbonding_duration": { - "description": "The maximum amount of seconds that a user must bond their tokens for.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "min_unbonding_duration": { - "description": "The minimum amount of seconds that a user must bond their tokens for.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "owner": { - "$ref": "#/definitions/CanonicalAddr" } }, "additionalProperties": false, "definitions": { - "Asset": { - "type": "object", - "required": [ - "amount", - "info" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "info": { - "$ref": "#/definitions/AssetInfo" - } - }, - "additionalProperties": false - }, - "AssetInfo": { - "description": "AssetInfo contract_addr is usually passed from the cw20 hook so we can trust the contract_addr is properly validated.", - "oneOf": [ - { - "type": "object", - "required": [ - "token" - ], - "properties": { - "token": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "native_token" - ], - "properties": { - "native_token": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] - }, - "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" - }, - "CanonicalAddr": { - "description": "A blockchain address in its binary form.\n\nThe specific implementation is up to the underlying chain and CosmWasm as well as contracts should not make assumptions on that data. In Ethereum for example, an `Addr` would contain a user visible address like 0x14d3cc818735723ab86eaf9502376e847a64ddad and the corresponding `CanonicalAddr` would store the 20 bytes 0x14, 0xD3, ..., 0xAD. In Cosmos, the bech32 format is used for `Addr`s and the `CanonicalAddr` holds the encoded bech32 data without the checksum. Typical sizes are 20 bytes for externally owned addresses and 32 bytes for module addresses (such as x/wasm contract addresses). That being said, a chain might decide to use any size other than 20 or 32 bytes.\n\nThe safe way to obtain a valid `CanonicalAddr` is using `Api::addr_canonicalize`. In addition to that there are many unsafe ways to convert any binary data into an instance. So the type shoud be treated as a marker to express the intended data type, not as a validity guarantee of any sort.", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "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); ```", + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", "type": "string" } } diff --git a/contracts/liquidity_hub/pool-network/incentive/.cargo/config b/contracts/liquidity_hub/pool-network/incentive/.cargo/config index 79bd37dbf..444af157c 100644 --- a/contracts/liquidity_hub/pool-network/incentive/.cargo/config +++ b/contracts/liquidity_hub/pool-network/incentive/.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 incentive_schema" diff --git a/contracts/liquidity_hub/pool-network/incentive/examples/incentive_schema.rs b/contracts/liquidity_hub/pool-network/incentive/examples/incentive_schema.rs deleted file mode 100644 index 58e9f9901..000000000 --- a/contracts/liquidity_hub/pool-network/incentive/examples/incentive_schema.rs +++ /dev/null @@ -1,14 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::pool_network::incentive::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; - -fn main() { - write_api! { - name: "incentive", - version: "1.0.0", - instantiate: InstantiateMsg, - query: QueryMsg, - execute: ExecuteMsg, - migrate: MigrateMsg, - } -} diff --git a/contracts/liquidity_hub/pool-network/incentive/schema/incentive.json b/contracts/liquidity_hub/pool-network/incentive/schema/incentive.json index 87061140c..76a0102df 100644 --- a/contracts/liquidity_hub/pool-network/incentive/schema/incentive.json +++ b/contracts/liquidity_hub/pool-network/incentive/schema/incentive.json @@ -1,6 +1,6 @@ { - "contract_name": "incentive", - "contract_version": "1.0.0", + "contract_name": "xtask", + "contract_version": "1.0.6", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/pool-network/incentive_factory/schema/incentive-factory.json b/contracts/liquidity_hub/pool-network/incentive_factory/schema/incentive-factory.json index ab9ada6f4..2ed9842ea 100644 --- a/contracts/liquidity_hub/pool-network/incentive_factory/schema/incentive-factory.json +++ b/contracts/liquidity_hub/pool-network/incentive_factory/schema/incentive-factory.json @@ -1,6 +1,6 @@ { - "contract_name": "incentive-factory", - "contract_version": "1.0.0", + "contract_name": "xtask", + "contract_version": "1.0.1", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/pool-network/terraswap_factory/schema/terraswap-factory.json b/contracts/liquidity_hub/pool-network/terraswap_factory/schema/terraswap-factory.json index 96fc8c4e6..984aac76a 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_factory/schema/terraswap-factory.json +++ b/contracts/liquidity_hub/pool-network/terraswap_factory/schema/terraswap-factory.json @@ -1,6 +1,6 @@ { - "contract_name": "terraswap-factory", - "contract_version": "1.0.3", + "contract_name": "xtask", + "contract_version": "1.2.3", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/schema/terraswap-pair.json b/contracts/liquidity_hub/pool-network/terraswap_pair/schema/terraswap-pair.json index 2320ca5f7..cf689a0f0 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/schema/terraswap-pair.json +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/schema/terraswap-pair.json @@ -1,6 +1,6 @@ { - "contract_name": "terraswap-pair", - "contract_version": "1.0.1", + "contract_name": "xtask", + "contract_version": "1.3.5", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/pool-network/terraswap_router/schema/terraswap-router.json b/contracts/liquidity_hub/pool-network/terraswap_router/schema/terraswap-router.json index e48336853..1b35ac03e 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_router/schema/terraswap-router.json +++ b/contracts/liquidity_hub/pool-network/terraswap_router/schema/terraswap-router.json @@ -1,6 +1,6 @@ { - "contract_name": "terraswap-router", - "contract_version": "1.0.0", + "contract_name": "xtask", + "contract_version": "1.1.1", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/pool-network/terraswap_token/schema/raw/instantiate.json b/contracts/liquidity_hub/pool-network/terraswap_token/schema/raw/instantiate.json index 4a5407359..26ea2cda2 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_token/schema/raw/instantiate.json +++ b/contracts/liquidity_hub/pool-network/terraswap_token/schema/raw/instantiate.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", + "description": "TokenContract InstantiateMsg", "type": "object", "required": [ "decimals", @@ -20,16 +21,6 @@ "$ref": "#/definitions/Cw20Coin" } }, - "marketing": { - "anyOf": [ - { - "$ref": "#/definitions/InstantiateMarketingInfo" - }, - { - "type": "null" - } - ] - }, "mint": { "anyOf": [ { @@ -49,10 +40,6 @@ }, "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" - }, "Cw20Coin": { "type": "object", "required": [ @@ -69,102 +56,6 @@ }, "additionalProperties": false }, - "EmbeddedLogo": { - "description": "This is used to store the logo on the blockchain in an accepted format. Enforce maximum size of 5KB on all variants.", - "oneOf": [ - { - "description": "Store the Logo as an SVG file. The content must conform to the spec at https://en.wikipedia.org/wiki/Scalable_Vector_Graphics (The contract should do some light-weight sanity-check validation)", - "type": "object", - "required": [ - "svg" - ], - "properties": { - "svg": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - }, - { - "description": "Store the Logo as a PNG file. This will likely only support up to 64x64 or so within the 5KB limit.", - "type": "object", - "required": [ - "png" - ], - "properties": { - "png": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - } - ] - }, - "InstantiateMarketingInfo": { - "type": "object", - "properties": { - "description": { - "type": [ - "string", - "null" - ] - }, - "logo": { - "anyOf": [ - { - "$ref": "#/definitions/Logo" - }, - { - "type": "null" - } - ] - }, - "marketing": { - "type": [ - "string", - "null" - ] - }, - "project": { - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, - "Logo": { - "description": "This is used for uploading logo data, or setting it in InstantiateData", - "oneOf": [ - { - "description": "A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL.", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "description": "Logo content stored on the blockchain. Enforce maximum size of 5KB on all variants", - "type": "object", - "required": [ - "embedded" - ], - "properties": { - "embedded": { - "$ref": "#/definitions/EmbeddedLogo" - } - }, - "additionalProperties": false - } - ] - }, "MinterResponse": { "type": "object", "required": [ diff --git a/contracts/liquidity_hub/pool-network/terraswap_token/schema/terraswap-token.json b/contracts/liquidity_hub/pool-network/terraswap_token/schema/terraswap-token.json index c971bc13e..029456cf1 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_token/schema/terraswap-token.json +++ b/contracts/liquidity_hub/pool-network/terraswap_token/schema/terraswap-token.json @@ -1,10 +1,11 @@ { - "contract_name": "terraswap-token", - "contract_version": "1.0.0", + "contract_name": "xtask", + "contract_version": "1.0.2", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "InstantiateMsg", + "description": "TokenContract InstantiateMsg", "type": "object", "required": [ "decimals", @@ -24,16 +25,6 @@ "$ref": "#/definitions/Cw20Coin" } }, - "marketing": { - "anyOf": [ - { - "$ref": "#/definitions/InstantiateMarketingInfo" - }, - { - "type": "null" - } - ] - }, "mint": { "anyOf": [ { @@ -53,10 +44,6 @@ }, "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" - }, "Cw20Coin": { "type": "object", "required": [ @@ -73,102 +60,6 @@ }, "additionalProperties": false }, - "EmbeddedLogo": { - "description": "This is used to store the logo on the blockchain in an accepted format. Enforce maximum size of 5KB on all variants.", - "oneOf": [ - { - "description": "Store the Logo as an SVG file. The content must conform to the spec at https://en.wikipedia.org/wiki/Scalable_Vector_Graphics (The contract should do some light-weight sanity-check validation)", - "type": "object", - "required": [ - "svg" - ], - "properties": { - "svg": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - }, - { - "description": "Store the Logo as a PNG file. This will likely only support up to 64x64 or so within the 5KB limit.", - "type": "object", - "required": [ - "png" - ], - "properties": { - "png": { - "$ref": "#/definitions/Binary" - } - }, - "additionalProperties": false - } - ] - }, - "InstantiateMarketingInfo": { - "type": "object", - "properties": { - "description": { - "type": [ - "string", - "null" - ] - }, - "logo": { - "anyOf": [ - { - "$ref": "#/definitions/Logo" - }, - { - "type": "null" - } - ] - }, - "marketing": { - "type": [ - "string", - "null" - ] - }, - "project": { - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, - "Logo": { - "description": "This is used for uploading logo data, or setting it in InstantiateData", - "oneOf": [ - { - "description": "A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL.", - "type": "object", - "required": [ - "url" - ], - "properties": { - "url": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "description": "Logo content stored on the blockchain. Enforce maximum size of 5KB on all variants", - "type": "object", - "required": [ - "embedded" - ], - "properties": { - "embedded": { - "$ref": "#/definitions/EmbeddedLogo" - } - }, - "additionalProperties": false - } - ] - }, "MinterResponse": { "type": "object", "required": [ diff --git a/contracts/liquidity_hub/pool-network/terraswap_token/src/contract.rs b/contracts/liquidity_hub/pool-network/terraswap_token/src/contract.rs index c6a76abed..51d49c58d 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_token/src/contract.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_token/src/contract.rs @@ -3,11 +3,10 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; use cw2::set_contract_version; use cw20_base::contract::{create_accounts, execute as cw20_execute, query as cw20_query}; -use cw20_base::msg::{ExecuteMsg, QueryMsg}; use cw20_base::state::{MinterData, TokenInfo, TOKEN_INFO}; use cw20_base::ContractError; -use white_whale_std::pool_network::token::InstantiateMsg; +use white_whale_std::pool_network::token::{ExecuteMsg, InstantiateMsg, QueryMsg}; // version info for migration info const CONTRACT_NAME: &str = "white_whale-cw20_token"; diff --git a/contracts/liquidity_hub/vault-manager/.cargo/config b/contracts/liquidity_hub/vault-manager/.cargo/config index 21608f3c7..4f96ce061 100644 --- a/contracts/liquidity_hub/vault-manager/.cargo/config +++ b/contracts/liquidity_hub/vault-manager/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --lib --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin vault_manager_schema" diff --git a/contracts/liquidity_hub/vault-manager/src/bin/schema.rs b/contracts/liquidity_hub/vault-manager/src/bin/schema.rs deleted file mode 100644 index ae4176a7b..000000000 --- a/contracts/liquidity_hub/vault-manager/src/bin/schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::vault_manager::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/liquidity_hub/vault-manager/src/bin/vault_manager_schema.rs b/contracts/liquidity_hub/vault-manager/src/bin/vault_manager_schema.rs deleted file mode 100644 index ae4176a7b..000000000 --- a/contracts/liquidity_hub/vault-manager/src/bin/vault_manager_schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::vault_manager::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/liquidity_hub/vault-network/vault/.cargo/config b/contracts/liquidity_hub/vault-network/vault/.cargo/config index 52bb9370f..f31de6c2a 100644 --- a/contracts/liquidity_hub/vault-network/vault/.cargo/config +++ b/contracts/liquidity_hub/vault-network/vault/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin vault_schema" diff --git a/contracts/liquidity_hub/vault-network/vault/schema/vault.json b/contracts/liquidity_hub/vault-network/vault/schema/vault.json index 4c1c59a39..0c621a631 100644 --- a/contracts/liquidity_hub/vault-network/vault/schema/vault.json +++ b/contracts/liquidity_hub/vault-network/vault/schema/vault.json @@ -1,6 +1,6 @@ { - "contract_name": "vault", - "contract_version": "1.1.1", + "contract_name": "xtask", + "contract_version": "1.2.6", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/vault-network/vault/src/bin/vault_schema.rs b/contracts/liquidity_hub/vault-network/vault/src/bin/vault_schema.rs deleted file mode 100644 index 4084c843a..000000000 --- a/contracts/liquidity_hub/vault-network/vault/src/bin/vault_schema.rs +++ /dev/null @@ -1,13 +0,0 @@ -use cosmwasm_schema::write_api; -use white_whale_std::vault_network::vault::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; - -fn main() { - write_api! { - name: "vault", - version: "1.1.1", - instantiate: InstantiateMsg, - query: QueryMsg, - execute: ExecuteMsg, - migrate: MigrateMsg, - } -} diff --git a/contracts/liquidity_hub/vault-network/vault_factory/.cargo/config b/contracts/liquidity_hub/vault-network/vault_factory/.cargo/config index 499ef64bd..f31de6c2a 100644 --- a/contracts/liquidity_hub/vault-network/vault_factory/.cargo/config +++ b/contracts/liquidity_hub/vault-network/vault_factory/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin vault_factory_schema" diff --git a/contracts/liquidity_hub/vault-network/vault_factory/Cargo.toml b/contracts/liquidity_hub/vault-network/vault_factory/Cargo.toml index 0a0495142..846712256 100644 --- a/contracts/liquidity_hub/vault-network/vault_factory/Cargo.toml +++ b/contracts/liquidity_hub/vault-network/vault_factory/Cargo.toml @@ -2,7 +2,7 @@ name = "vault_factory" version = "1.1.3" authors = [ - "kaimen-sano , Kerber0x ", + "kaimen-sano , Kerber0x ", ] edition.workspace = true description = "Contract to facilitate the vault network" diff --git a/contracts/liquidity_hub/vault-network/vault_factory/schema/vault_factory.json b/contracts/liquidity_hub/vault-network/vault_factory/schema/vault_factory.json index a417bd825..7ab2f3059 100644 --- a/contracts/liquidity_hub/vault-network/vault_factory/schema/vault_factory.json +++ b/contracts/liquidity_hub/vault-network/vault_factory/schema/vault_factory.json @@ -1,6 +1,6 @@ { - "contract_name": "vault_factory", - "contract_version": "1.0.7", + "contract_name": "xtask", + "contract_version": "1.1.3", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/vault-network/vault_factory/src/bin/vault_factory_schema.rs b/contracts/liquidity_hub/vault-network/vault_factory/src/bin/vault_factory_schema.rs deleted file mode 100644 index 755b07b49..000000000 --- a/contracts/liquidity_hub/vault-network/vault_factory/src/bin/vault_factory_schema.rs +++ /dev/null @@ -1,16 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::vault_network::vault_factory::{ - ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, -}; - -fn main() { - write_api! { - name: "vault_factory", - version: "1.0.7", - instantiate: InstantiateMsg, - query: QueryMsg, - execute: ExecuteMsg, - migrate: MigrateMsg, - } -} diff --git a/contracts/liquidity_hub/vault-network/vault_router/.cargo/config b/contracts/liquidity_hub/vault-network/vault_router/.cargo/config index 8bc3e2f67..f31de6c2a 100644 --- a/contracts/liquidity_hub/vault-network/vault_router/.cargo/config +++ b/contracts/liquidity_hub/vault-network/vault_router/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin vault_router_schema" diff --git a/contracts/liquidity_hub/vault-network/vault_router/Cargo.toml b/contracts/liquidity_hub/vault-network/vault_router/Cargo.toml index 500d9e124..710383f1f 100644 --- a/contracts/liquidity_hub/vault-network/vault_router/Cargo.toml +++ b/contracts/liquidity_hub/vault-network/vault_router/Cargo.toml @@ -2,7 +2,7 @@ name = "vault_router" version = "1.1.6" authors = [ - "kaimen-sano , Kerber0x ", + "kaimen-sano , Kerber0x ", ] edition.workspace = true description = "Contract to facilitate flash-loans in the vault network" diff --git a/contracts/liquidity_hub/vault-network/vault_router/schema/vault_router.json b/contracts/liquidity_hub/vault-network/vault_router/schema/vault_router.json index dca64b122..24ea44a1f 100644 --- a/contracts/liquidity_hub/vault-network/vault_router/schema/vault_router.json +++ b/contracts/liquidity_hub/vault-network/vault_router/schema/vault_router.json @@ -1,6 +1,6 @@ { - "contract_name": "vault_router", - "contract_version": "1.0.0", + "contract_name": "xtask", + "contract_version": "1.1.6", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/contracts/liquidity_hub/vault-network/vault_router/src/bin/vault_router_schema.rs b/contracts/liquidity_hub/vault-network/vault_router/src/bin/vault_router_schema.rs deleted file mode 100644 index 7d7b6c982..000000000 --- a/contracts/liquidity_hub/vault-network/vault_router/src/bin/vault_router_schema.rs +++ /dev/null @@ -1,16 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::vault_network::vault_router::{ - ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, -}; - -fn main() { - write_api! { - name: "vault_router", - version: "1.0.0", - instantiate: InstantiateMsg, - query: QueryMsg, - execute: ExecuteMsg, - migrate: MigrateMsg, - } -} diff --git a/contracts/liquidity_hub/whale_lair/.cargo/config b/contracts/liquidity_hub/whale_lair/.cargo/config index a090a5605..4f96ce061 100644 --- a/contracts/liquidity_hub/whale_lair/.cargo/config +++ b/contracts/liquidity_hub/whale_lair/.cargo/config @@ -1,4 +1,3 @@ [alias] wasm = "build --release --lib --target wasm32-unknown-unknown" unit-test = "test --lib" -schema = "run --bin whale_lair_schema" diff --git a/contracts/liquidity_hub/whale_lair/Cargo.toml b/contracts/liquidity_hub/whale_lair/Cargo.toml index 26f4ffaf9..fc66f04c9 100644 --- a/contracts/liquidity_hub/whale_lair/Cargo.toml +++ b/contracts/liquidity_hub/whale_lair/Cargo.toml @@ -11,9 +11,9 @@ documentation.workspace = true publish.workspace = true 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", + # 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 diff --git a/contracts/liquidity_hub/whale_lair/src/bin/whale_lair_schema.rs b/contracts/liquidity_hub/whale_lair/src/bin/whale_lair_schema.rs deleted file mode 100644 index cb2d7d75f..000000000 --- a/contracts/liquidity_hub/whale_lair/src/bin/whale_lair_schema.rs +++ /dev/null @@ -1,11 +0,0 @@ -use cosmwasm_schema::write_api; - -use white_whale_std::whale_lair::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } -} diff --git a/contracts/liquidity_hub/whale_lair/src/schema/whale-lair.json b/contracts/liquidity_hub/whale_lair/src/schema/whale-lair.json deleted file mode 100644 index a3fc2ba26..000000000 --- a/contracts/liquidity_hub/whale_lair/src/schema/whale-lair.json +++ /dev/null @@ -1,834 +0,0 @@ -{ - "contract_name": "whale-lair", - "contract_version": "1.0.0", - "idl_version": "1.0.0", - "instantiate": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "bonding_assets", - "growth_rate", - "unbonding_period" - ], - "properties": { - "bonding_assets": { - "description": "[AssetInfo] of the assets that can be bonded.", - "type": "array", - "items": { - "$ref": "#/definitions/AssetInfo" - } - }, - "growth_rate": { - "description": "Weight grow rate. Needs to be between 0 and 1.", - "allOf": [ - { - "$ref": "#/definitions/Decimal" - } - ] - }, - "unbonding_period": { - "description": "Unbonding period in nanoseconds.", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "AssetInfo": { - "description": "AssetInfo contract_addr is usually passed from the cw20 hook so we can trust the contract_addr is properly validated.", - "oneOf": [ - { - "type": "object", - "required": [ - "token" - ], - "properties": { - "token": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "native_token" - ], - "properties": { - "native_token": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] - }, - "Decimal": { - "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" - }, - "Uint64": { - "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" - } - } - }, - "execute": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Bonds the specified [Asset].", - "type": "object", - "required": [ - "bond" - ], - "properties": { - "bond": { - "type": "object", - "required": [ - "asset" - ], - "properties": { - "asset": { - "$ref": "#/definitions/Asset" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Unbonds the specified [Asset].", - "type": "object", - "required": [ - "unbond" - ], - "properties": { - "unbond": { - "type": "object", - "required": [ - "asset" - ], - "properties": { - "asset": { - "$ref": "#/definitions/Asset" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Sends withdrawable unbonded tokens to the user.", - "type": "object", - "required": [ - "withdraw" - ], - "properties": { - "withdraw": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Updates the [Config] of the contract.", - "type": "object", - "required": [ - "update_config" - ], - "properties": { - "update_config": { - "type": "object", - "properties": { - "growth_rate": { - "anyOf": [ - { - "$ref": "#/definitions/Decimal" - }, - { - "type": "null" - } - ] - }, - "owner": { - "type": [ - "string", - "null" - ] - }, - "unbonding_period": { - "anyOf": [ - { - "$ref": "#/definitions/Uint64" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Asset": { - "type": "object", - "required": [ - "amount", - "info" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "info": { - "$ref": "#/definitions/AssetInfo" - } - }, - "additionalProperties": false - }, - "AssetInfo": { - "description": "AssetInfo contract_addr is usually passed from the cw20 hook so we can trust the contract_addr is properly validated.", - "oneOf": [ - { - "type": "object", - "required": [ - "token" - ], - "properties": { - "token": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "native_token" - ], - "properties": { - "native_token": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] - }, - "Decimal": { - "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" - }, - "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" - }, - "Uint64": { - "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" - } - } - }, - "query": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Returns the [Config] of te contract.", - "type": "object", - "required": [ - "config" - ], - "properties": { - "config": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Returns the amount of tokens that have been bonded by the specified address.", - "type": "object", - "required": [ - "bonded" - ], - "properties": { - "bonded": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Returns the amount of tokens of the given denom that are been unbonded by the specified address. Allows pagination with start_after and limit.", - "type": "object", - "required": [ - "unbonding" - ], - "properties": { - "unbonding": { - "type": "object", - "required": [ - "address", - "denom" - ], - "properties": { - "address": { - "type": "string" - }, - "denom": { - "type": "string" - }, - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint8", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Returns the amount of unbonding tokens of the given denom for the specified address that can be withdrawn, i.e. that have passed the unbonding period.", - "type": "object", - "required": [ - "withdrawable" - ], - "properties": { - "withdrawable": { - "type": "object", - "required": [ - "address", - "denom" - ], - "properties": { - "address": { - "type": "string" - }, - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Returns the weight of the address.", - "type": "object", - "required": [ - "weight" - ], - "properties": { - "weight": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] - }, - "migrate": null, - "sudo": null, - "responses": { - "bonded": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BondedResponse", - "description": "Response for the Bonded query", - "type": "object", - "required": [ - "bonded_assets", - "total_bonded" - ], - "properties": { - "bonded_assets": { - "type": "array", - "items": { - "$ref": "#/definitions/Asset" - } - }, - "total_bonded": { - "$ref": "#/definitions/Uint128" - } - }, - "additionalProperties": false, - "definitions": { - "Asset": { - "type": "object", - "required": [ - "amount", - "info" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "info": { - "$ref": "#/definitions/AssetInfo" - } - }, - "additionalProperties": false - }, - "AssetInfo": { - "description": "AssetInfo contract_addr is usually passed from the cw20 hook so we can trust the contract_addr is properly validated.", - "oneOf": [ - { - "type": "object", - "required": [ - "token" - ], - "properties": { - "token": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "native_token" - ], - "properties": { - "native_token": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "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" - } - } - }, - "config": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Config", - "type": "object", - "required": [ - "bonding_assets", - "growth_rate", - "owner", - "unbonding_period" - ], - "properties": { - "bonding_assets": { - "description": "Denom of the asset to be bonded. Can't only be set at instantiation.", - "type": "array", - "items": { - "$ref": "#/definitions/AssetInfo" - } - }, - "growth_rate": { - "description": "A fraction that controls the effect of time on the weight of a bond. If the growth rate is set to zero, time will have no impact on the weight.", - "allOf": [ - { - "$ref": "#/definitions/Decimal" - } - ] - }, - "owner": { - "description": "Owner of the contract.", - "allOf": [ - { - "$ref": "#/definitions/Addr" - } - ] - }, - "unbonding_period": { - "description": "Unbonding period in nanoseconds.", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "Addr": { - "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", - "type": "string" - }, - "AssetInfo": { - "description": "AssetInfo contract_addr is usually passed from the cw20 hook so we can trust the contract_addr is properly validated.", - "oneOf": [ - { - "type": "object", - "required": [ - "token" - ], - "properties": { - "token": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "native_token" - ], - "properties": { - "native_token": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] - }, - "Decimal": { - "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" - }, - "Uint64": { - "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" - } - } - }, - "unbonding": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "UnbondingResponse", - "description": "Response for the Unstaking query", - "type": "object", - "required": [ - "total_amount", - "unbonding_requests" - ], - "properties": { - "total_amount": { - "$ref": "#/definitions/Uint128" - }, - "unbonding_requests": { - "type": "array", - "items": { - "$ref": "#/definitions/Bond" - } - } - }, - "additionalProperties": false, - "definitions": { - "Asset": { - "type": "object", - "required": [ - "amount", - "info" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "info": { - "$ref": "#/definitions/AssetInfo" - } - }, - "additionalProperties": false - }, - "AssetInfo": { - "description": "AssetInfo contract_addr is usually passed from the cw20 hook so we can trust the contract_addr is properly validated.", - "oneOf": [ - { - "type": "object", - "required": [ - "token" - ], - "properties": { - "token": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "native_token" - ], - "properties": { - "native_token": { - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ] - }, - "Bond": { - "type": "object", - "required": [ - "asset", - "timestamp", - "weight" - ], - "properties": { - "asset": { - "description": "The amount of bonded tokens.", - "allOf": [ - { - "$ref": "#/definitions/Asset" - } - ] - }, - "timestamp": { - "description": "The timestamp at which the bond was done.", - "allOf": [ - { - "$ref": "#/definitions/Timestamp" - } - ] - }, - "weight": { - "description": "The weight of the bond at the given block height.", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - } - }, - "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": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "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" - }, - "Uint64": { - "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" - } - } - }, - "weight": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "BondingWeightResponse", - "description": "Response for the Weight query.", - "type": "object", - "required": [ - "address", - "global_weight", - "share", - "timestamp", - "weight" - ], - "properties": { - "address": { - "type": "string" - }, - "global_weight": { - "$ref": "#/definitions/Uint128" - }, - "share": { - "$ref": "#/definitions/Decimal" - }, - "timestamp": { - "$ref": "#/definitions/Timestamp" - }, - "weight": { - "$ref": "#/definitions/Uint128" - } - }, - "additionalProperties": false, - "definitions": { - "Decimal": { - "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" - }, - "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": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "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" - }, - "Uint64": { - "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" - } - } - }, - "withdrawable": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "WithdrawableResponse", - "description": "Response for the Withdrawable query", - "type": "object", - "required": [ - "withdrawable_amount" - ], - "properties": { - "withdrawable_amount": { - "$ref": "#/definitions/Uint128" - } - }, - "additionalProperties": false, - "definitions": { - "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/packages/white-whale-std/Cargo.toml b/packages/white-whale-std/Cargo.toml index 60c6d994e..d6b003d25 100644 --- a/packages/white-whale-std/Cargo.toml +++ b/packages/white-whale-std/Cargo.toml @@ -3,10 +3,10 @@ name = "white-whale-std" version = "1.1.3" edition.workspace = true authors = [ - "Kerber0x ", - "0xFable <0xfabledev@gmail.com>", - "kaimen-sano ", - "White Whale ", + "Kerber0x ", + "0xFable <0xfabledev@gmail.com>", + "kaimen-sano ", + "White Whale ", ] description = "Common White Whale types and utils" license.workspace = true @@ -20,7 +20,7 @@ injective = ["token_factory"] osmosis = ["osmosis_token_factory"] token_factory = [] osmosis_token_factory = [ - "token_factory", + "token_factory", ] # this is for the osmosis token factory proto definitions, which defer from the standard token factory :) backtraces = ["cosmwasm-std/backtraces"] @@ -42,6 +42,7 @@ anybuf.workspace = true cw-controllers.workspace = true anyhow.workspace = true thiserror.workspace = true +cw20-base.workspace = true [dev-dependencies] cw-multi-test.workspace = true diff --git a/packages/white-whale-std/src/pool_network/token.rs b/packages/white-whale-std/src/pool_network/token.rs index 25a7598eb..0a580c23e 100644 --- a/packages/white-whale-std/src/pool_network/token.rs +++ b/packages/white-whale-std/src/pool_network/token.rs @@ -36,6 +36,10 @@ impl InstantiateMsg { } } +pub type ExecuteMsg = cw20_base::msg::ExecuteMsg; +pub type QueryMsg = cw20_base::msg::QueryMsg; +pub type MigrateMsg = cw20_base::msg::MigrateMsg; + fn is_valid_name(name: &str) -> bool { let bytes = name.as_bytes(); if bytes.len() < 3 || bytes.len() > 50 { diff --git a/scripts/build_schemas.sh b/scripts/build_schemas.sh index 07715ea2f..cce175010 100755 --- a/scripts/build_schemas.sh +++ b/scripts/build_schemas.sh @@ -6,26 +6,21 @@ function display_usage() { echo "Schema generator" echo -e "\nUsage: $0 [flags].\n" echo -e "Available flags:\n" - echo -e " -f \tSpecify the feature to use (token_factory|osmosis_token_factory|...)" - echo -e " -d \tEnable diff check (true|false)" + echo -e " -d \tEnable diff check (true|false), defaults to false" + echo -e " -h \tDisplay this help menu" } -if [ -z $1 ]; then - display_usage - exit 0 -fi - -feature_flag="" fail_diff_flag=false while getopts ":f:d:" opt; do case $opt in - f) - feature_flag="$OPTARG" - ;; d) fail_diff_flag="$OPTARG" ;; + h) + display_usage + exit 0 + ;; \?) echo "Invalid option: -$OPTARG" >&2 display_usage @@ -43,32 +38,9 @@ fi projectRootPath=$(realpath "$0" | sed 's|\(.*\)/.*|\1|' | cd ../ | pwd) -# Generates schemas for contracts in the liquidity_hub -for component in "$projectRootPath"/contracts/liquidity_hub/*/; do - echo "Generating schemas for $(basename $component)..." - if [[ -f "$component/Cargo.toml" ]]; then - # it was a single contract (such as fee_collector) - - if [[ $(basename $component) == "fee_collector_integration" || $(basename $component) == "whale_lair_integration" ]]; then - echo "Skipping $component" - continue - fi +# Generates schemas for contracts +cargo xtask generate_schemas - echo "generating for $component" - cd $component && cargo schema --locked - else - echo "folder $component" - - # it was a directory (such as pool_network), do it for all files inside the directory - for contract in "$component"*/; do - echo "generating for $contract" - - cd $contract && cargo schema --locked - - # Optionally fail on any unaccounted changes in json schema files - if [[ "$fail_diff_flag" == true ]]; then - git diff --exit-code -- '*.json' - fi - done - fi -done +if [[ "$fail_diff_flag" == true ]]; then + git diff --exit-code -- '*.json' +fi diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml new file mode 100644 index 000000000..320a4d428 --- /dev/null +++ b/xtask/Cargo.toml @@ -0,0 +1,19 @@ +# see https://github.com/matklad/cargo-xtask for more details about this package. +# it is a helper to run rust binary tasks on the repository. +# for instance, we can use it to generate all schemas for each contract. + +[package] +name = "xtask" +description = "Generate cosmwasm schemas for white-whale-core workspace members" +authors.workspace = true +edition.workspace = true +publish.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true + +[dependencies] +cosmwasm-schema.workspace = true +serde.workspace = true +serde_json = "1.0.115" +white-whale-std.workspace = true diff --git a/xtask/src/main.rs b/xtask/src/main.rs new file mode 100644 index 000000000..bed4fe0a9 --- /dev/null +++ b/xtask/src/main.rs @@ -0,0 +1,187 @@ +use std::{env, error::Error}; + +/// Traverses through the workspace and generates schemas +/// Expects to be ran at the workspace. + +pub mod tasks { + use std::{ + collections::HashMap, + env, + fs::{create_dir_all, write}, + path::{Path, PathBuf}, + process::Command, + }; + + use cosmwasm_schema::{generate_api, remove_schemas}; + + use serde::Deserialize; + use white_whale_std::{ + pool_network::{frontend_helper, incentive, incentive_factory}, + vault_network::{vault, vault_factory, vault_router}, + *, + }; + + fn project_root() -> PathBuf { + Path::new(&env!("CARGO_MANIFEST_DIR")) + .ancestors() + .nth(1) + .unwrap() + .to_path_buf() + } + + #[derive(Deserialize)] + struct CargoPackage { + name: String, + version: String, + manifest_path: String, + } + + #[derive(Deserialize)] + struct CargoMetadataOutput { + packages: Vec, + } + + pub fn generate_schemas() { + macro_rules! generate_schema { + ($contract:expr, $api_ref: expr) => { + ( + $contract.to_string(), + generate_api! { + instantiate: $api_ref::InstantiateMsg, + query: $api_ref::QueryMsg, + execute: $api_ref::ExecuteMsg, + migrate: $api_ref::MigrateMsg, + }, + ) + }; + } + + let mut schemas = HashMap::from([ + generate_schema!("epoch-manager", epoch_manager::epoch_manager), + generate_schema!("fee_collector", fee_collector), + generate_schema!("fee_distributor", fee_distributor), + generate_schema!("pool-manager", pool_manager), + generate_schema!("frontend-helper", frontend_helper), + generate_schema!("incentive", incentive), + generate_schema!("incentive-factory", incentive_factory), + generate_schema!("terraswap-factory", pool_network::factory), + generate_schema!("terraswap-pair", pool_network::pair), + generate_schema!("terraswap-router", pool_network::router), + generate_schema!("terraswap-token", pool_network::token), + generate_schema!("vault-manager", vault_manager), + generate_schema!("vault", vault), + generate_schema!("vault_factory", vault_factory), + generate_schema!("vault_router", vault_router), + generate_schema!("whale-lair", whale_lair), + ]); + + let cargo = env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); + let metadata = Command::new(cargo) + .current_dir(project_root()) + .args(&["metadata", "--no-deps", "--format-version", "1"]) + .output() + .expect("Failed to fetch workspace metadata"); + + let metadata = serde_json::from_slice::(&metadata.stdout) + .expect("Failed to parse `cargo metadata` output"); + + let contracts = metadata + .packages + .into_iter() + .filter(|member| member.manifest_path.contains("contracts")) + .filter(|member| { + member.name != "fee-distributor-mock" + && member.name != "stableswap-3pool" + && member.name != "stable-swap-sim" + }); + + for contract in contracts { + let contract_path = Path::new(&contract.manifest_path) + .parent() + .expect("Failed to get parent of contract manifest"); + + // generate correct schema version + let mut schema = schemas.remove(&contract.name).unwrap_or_else(|| { + panic!( + "Missing contract {} defined in xtask generate schemas", + contract.name + ) + }); + schema.contract_version = contract.version; + + let mut out_dir = contract_path.to_path_buf(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap_or_else(|e| { + panic!( + "Failed to create out dir for contract {}: {e}", + contract.name + ) + }); + remove_schemas(&out_dir).unwrap_or_else(|e| { + panic!( + "Failed to create out dir for contract {}: {e}", + contract.name + ) + }); + + let api = schema.render(); + let path = out_dir.join(format!("{}.json", contract.name)); + let json = api.to_string().unwrap_or_else(|e| { + panic!( + "Failed to serialize JsonApi when generating schema for {}: {}", + contract.name, e + ) + }); + write(&path, json + "\n").unwrap_or_else(|e| { + panic!( + "Failed to write JsonApi when generating schema for {}: {}", + contract.name, e + ) + }); + println!("Generated schemas for {}", contract.name); + + let raw_dir = out_dir.join("raw"); + create_dir_all(&raw_dir).unwrap_or_else(|e| { + panic!( + "Failed to create raw schema directory for {}: {}", + contract.name, e + ) + }); + for (filename, json) in api.to_schema_files().unwrap_or_else(|e| { + panic!("Failed to get schema files for {}: {}", contract.name, e) + }) { + let path = raw_dir.join(&filename); + + write(&path, json + "\n").unwrap_or_else(|e| { + panic!("Failed to write raw schema file to {}: {}", filename, e) + }); + } + } + } + + pub fn print_help() { + println!( + " +Usage: Run with `cargo xtask `, eg. `cargo xtask generate_schemas`. + + Tasks: + generate_schemas: Generate schemas for each contract. +" + ); + } +} + +// reference: https://github.com/helix-editor/helix/blob/master/xtask/src/main.rs +fn main() -> Result<(), Box> { + let task = env::args().nth(1); + + match task { + None => tasks::print_help(), + Some(t) => match t.as_str() { + "generate_schemas" => tasks::generate_schemas(), + invalid => return Err(format!("Invalid task name: {}", invalid).into()), + }, + }; + + Ok(()) +}