Skip to content

Commit

Permalink
refactor(schemas): simplify generating schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
kaimen-sano committed Apr 6, 2024
1 parent 4a71d8b commit 15062e7
Show file tree
Hide file tree
Showing 56 changed files with 410 additions and 1,593 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# define x-task aliases
# see https://github.com/matklad/cargo-xtask
[alias]
xtask = "run --package xtask --"
7 changes: 0 additions & 7 deletions .github/workflows/ci-test-fmt-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/validate-schemas.yml
Original file line number Diff line number Diff line change
@@ -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.'
})
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 15 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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" }
Expand All @@ -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" }

Expand Down
1 change: 0 additions & 1 deletion contracts/liquidity_hub/epoch-manager/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin epoch_manager_schema"

This file was deleted.

1 change: 0 additions & 1 deletion contracts/liquidity_hub/fee_collector/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin fee_collector_schema"
Original file line number Diff line number Diff line change
@@ -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#",
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion contracts/liquidity_hub/fee_distributor/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin fee_distributor_schema"

This file was deleted.

1 change: 0 additions & 1 deletion contracts/liquidity_hub/pool-manager/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin schema"
34 changes: 11 additions & 23 deletions contracts/liquidity_hub/pool-manager/schema/pool-manager.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"contract_name": "pool-manager",
"contract_name": "xtask",
"contract_version": "0.1.0",
"idl_version": "1.0.0",
"instantiate": {
Expand Down Expand Up @@ -60,8 +60,7 @@
"required": [
"asset_denoms",
"pair_type",
"pool_fees",
"token_factory_lp"
"pool_fees"
],
"properties": {
"asset_denoms": {
Expand All @@ -81,9 +80,6 @@
},
"pool_fees": {
"$ref": "#/definitions/PoolFee"
},
"token_factory_lp": {
"type": "boolean"
}
},
"additionalProperties": false
Expand All @@ -101,16 +97,9 @@
"provide_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
},
Expand Down Expand Up @@ -201,16 +190,9 @@
"withdraw_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
}
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -908,7 +896,7 @@
"asset_denoms",
"assets",
"balances",
"liquidity_token",
"lp_denom",
"pair_type",
"pool_fees"
],
Expand Down Expand Up @@ -939,7 +927,7 @@
"$ref": "#/definitions/Uint128"
}
},
"liquidity_token": {
"lp_denom": {
"type": "string"
},
"pair_type": {
Expand Down
20 changes: 1 addition & 19 deletions contracts/liquidity_hub/pool-manager/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"required": [
"asset_denoms",
"pair_type",
"pool_fees",
"token_factory_lp"
"pool_fees"
],
"properties": {
"asset_denoms": {
Expand All @@ -34,9 +33,6 @@
},
"pool_fees": {
"$ref": "#/definitions/PoolFee"
},
"token_factory_lp": {
"type": "boolean"
}
},
"additionalProperties": false
Expand All @@ -54,16 +50,9 @@
"provide_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
},
Expand Down Expand Up @@ -154,16 +143,9 @@
"withdraw_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
}
Expand Down
7 changes: 7 additions & 0 deletions contracts/liquidity_hub/pool-manager/schema/raw/migrate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MigrateMsg",
"description": "The migrate message",
"type": "object",
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"asset_denoms",
"assets",
"balances",
"liquidity_token",
"lp_denom",
"pair_type",
"pool_fees"
],
Expand Down Expand Up @@ -38,7 +38,7 @@
"$ref": "#/definitions/Uint128"
}
},
"liquidity_token": {
"lp_denom": {
"type": "string"
},
"pair_type": {
Expand Down
11 changes: 0 additions & 11 deletions contracts/liquidity_hub/pool-manager/src/bin/schema.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading

0 comments on commit 15062e7

Please sign in to comment.