Skip to content

Commit

Permalink
Start cw20-ics20 as copy of cw20-escrow
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Mar 10, 2021
1 parent 1ee46d1 commit f0ea193
Show file tree
Hide file tree
Showing 21 changed files with 1,689 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ workflows:
- contract_cw20_base
- contract_cw20_bonding
- contract_cw20_escrow
- contract_cw20_ics20
- contract_cw20_staking
- contract_cw721_base
- package_controllers
Expand Down Expand Up @@ -390,6 +391,47 @@ jobs:
- target
key: cargocache-cw20-escrow-rust:1.50.0-{{ checksum "~/project/Cargo.lock" }}

contract_cw20_ics20:
docker:
- image: rust:1.50.0
working_directory: ~/project/contracts/cw20-ics20
steps:
- checkout:
path: ~/project
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-cw20-ics20-rust:1.50.0-{{ checksum "~/project/Cargo.lock" }}
- run:
name: Unit Tests
env: RUST_BACKTRACE=1
command: cargo unit-test --locked
- run:
name: Build and run schema generator
command: cargo schema --locked
- run:
name: Integration Tests
command: |
rustup target add wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown --locked
cargo test --test integration --locked
- run:
name: Ensure checked-in schemas are up-to-date
command: |
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
- save_cache:
paths:
- /usr/local/cargo/registry
- target
key: cargocache-cw20-ics20-rust:1.50.0-{{ checksum "~/project/Cargo.lock" }}

contract_cw20_staking:
docker:
- image: rust:1.50.0
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ incremental = false
codegen-units = 1
incremental = false

[profile.release.package.cw20-ics20]
codegen-units = 1
incremental = false

[profile.release.package.cw20-staking]
codegen-units = 1
incremental = false
Expand Down
6 changes: 6 additions & 0 deletions contracts/cw20-ics20/.cargo/config
Original file line number Diff line number Diff line change
@@ -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"
33 changes: 33 additions & 0 deletions contracts/cw20-ics20/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "cw20-ics20"
version = "0.5.0"
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2018"
description = "IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain"
license = "Apache-2.0"
repository = "https://github.com/CosmWasm/cosmwasm-plus"
homepage = "https://cosmwasm.com"
documentation = "https://docs.cosmwasm.com"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all init/handle/query exports
library = []

[dependencies]
cw0 = { path = "../../packages/cw0", version = "0.5.0" }
cw2 = { path = "../../packages/cw2", version = "0.5.0" }
cw20 = { path = "../../packages/cw20", version = "0.5.0" }
cosmwasm-std = { version = "0.14.0-alpha2", features = ["iterator"] }
cosmwasm-storage = { version = "0.14.0-alpha2", features = ["iterator"] }
schemars = "0.7"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.20" }

[dev-dependencies]
cosmwasm-schema = { version = "0.14.0-alpha2" }
cw-multi-test = { path = "../../packages/multi-test", version = "0.5.0" }
cw20-base = { path = "../cw20-base", version = "0.5.0", features = ["library"] }
14 changes: 14 additions & 0 deletions contracts/cw20-ics20/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CW20-ICS20: IBC Enabled contracts that receives CW20 tokens and sends them over ICS20 to a remote chain
Copyright (C) 2020 Confio OÜ

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.
4 changes: 4 additions & 0 deletions contracts/cw20-ics20/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# CW20 ICS20

TODO: Define this protocol

20 changes: 20 additions & 0 deletions contracts/cw20-ics20/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::env::current_dir;
use std::fs::create_dir_all;

use cosmwasm_schema::{export_schema, remove_schemas, schema_for};

use cw20_ics20::msg::{DetailsResponse, HandleMsg, InitMsg, ListResponse, QueryMsg, ReceiveMsg};

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!(InitMsg), &out_dir);
export_schema(&schema_for!(HandleMsg), &out_dir);
export_schema(&schema_for!(QueryMsg), &out_dir);
export_schema(&schema_for!(ReceiveMsg), &out_dir);
export_schema(&schema_for!(DetailsResponse), &out_dir);
export_schema(&schema_for!(ListResponse), &out_dir);
}
121 changes: 121 additions & 0 deletions contracts/cw20-ics20/schema/details_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "DetailsResponse",
"type": "object",
"required": [
"arbiter",
"cw20_balance",
"cw20_whitelist",
"id",
"native_balance",
"recipient",
"source"
],
"properties": {
"arbiter": {
"description": "arbiter can decide to approve or refund the escrow",
"allOf": [
{
"$ref": "#/definitions/HumanAddr"
}
]
},
"cw20_balance": {
"description": "Balance in cw20 tokens",
"type": "array",
"items": {
"$ref": "#/definitions/Cw20CoinHuman"
}
},
"cw20_whitelist": {
"description": "Whitelisted cw20 tokens",
"type": "array",
"items": {
"$ref": "#/definitions/HumanAddr"
}
},
"end_height": {
"description": "When end height set and block height exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"end_time": {
"description": "When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and block time exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"id": {
"description": "id of this escrow",
"type": "string"
},
"native_balance": {
"description": "Balance in native tokens",
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"recipient": {
"description": "if approved, funds go to the recipient",
"allOf": [
{
"$ref": "#/definitions/HumanAddr"
}
]
},
"source": {
"description": "if refunded, funds go to the source",
"allOf": [
{
"$ref": "#/definitions/HumanAddr"
}
]
}
},
"definitions": {
"Coin": {
"type": "object",
"required": [
"amount",
"denom"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"denom": {
"type": "string"
}
}
},
"Cw20CoinHuman": {
"type": "object",
"required": [
"address",
"amount"
],
"properties": {
"address": {
"$ref": "#/definitions/HumanAddr"
},
"amount": {
"$ref": "#/definitions/Uint128"
}
}
},
"HumanAddr": {
"type": "string"
},
"Uint128": {
"type": "string"
}
}
}
Loading

0 comments on commit f0ea193

Please sign in to comment.