Skip to content

Commit

Permalink
feat: Implement token wrapper library and complete token tester (#7)
Browse files Browse the repository at this point in the history
* feat: Implement token wrapper library and complete token tester

* fix: used enum for target param
  • Loading branch information
shiki-tak authored and loloicci committed Jan 26, 2021
1 parent dedac85 commit 937a12f
Show file tree
Hide file tree
Showing 13 changed files with 1,034 additions and 50 deletions.
5 changes: 5 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_staking",target=/code/contracts/staking/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.9.0 ./contracts/staking

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_token_tester",target=/code/contracts/staking/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.9.0 ./contracts/token-tester
```
2 changes: 2 additions & 0 deletions contracts/token-tester/examples/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::fs::create_dir_all;
use cosmwasm_schema::{export_schema, remove_schemas, schema_for};

use token_tester::msg::{HandleMsg, InitMsg, QueryMsg};
use token_tester::state::State;

fn main() {
let mut out_dir = current_dir().unwrap();
Expand All @@ -14,4 +15,5 @@ fn main() {
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!(State), &out_dir);
}
170 changes: 170 additions & 0 deletions contracts/token-tester/schema/handle_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,176 @@
}
}
}
},
{
"type": "object",
"required": [
"transfer"
],
"properties": {
"transfer": {
"type": "object",
"required": [
"amount",
"contract_id",
"from",
"to"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"contract_id": {
"type": "string"
},
"from": {
"$ref": "#/definitions/HumanAddr"
},
"to": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"mint"
],
"properties": {
"mint": {
"type": "object",
"required": [
"amount",
"contract_id",
"from",
"to"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"contract_id": {
"type": "string"
},
"from": {
"$ref": "#/definitions/HumanAddr"
},
"to": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"burn"
],
"properties": {
"burn": {
"type": "object",
"required": [
"amount",
"contract_id",
"from"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"contract_id": {
"type": "string"
},
"from": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"grant_perm"
],
"properties": {
"grant_perm": {
"type": "object",
"required": [
"contract_id",
"from",
"permission",
"to"
],
"properties": {
"contract_id": {
"type": "string"
},
"from": {
"$ref": "#/definitions/HumanAddr"
},
"permission": {
"type": "string"
},
"to": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"revoke_perm"
],
"properties": {
"revoke_perm": {
"type": "object",
"required": [
"contract_id",
"from",
"permission"
],
"properties": {
"contract_id": {
"type": "string"
},
"from": {
"$ref": "#/definitions/HumanAddr"
},
"permission": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"required": [
"modify"
],
"properties": {
"modify": {
"type": "object",
"required": [
"contract_id",
"owner"
],
"properties": {
"contract_id": {
"type": "string"
},
"owner": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
}
],
"definitions": {
Expand Down
76 changes: 75 additions & 1 deletion contracts/token-tester/schema/query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,80 @@
}
}
}
},
{
"type": "object",
"required": [
"get_balance"
],
"properties": {
"get_balance": {
"type": "object",
"required": [
"address",
"contract_id"
],
"properties": {
"address": {
"$ref": "#/definitions/HumanAddr"
},
"contract_id": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"required": [
"get_total"
],
"properties": {
"get_total": {
"type": "object",
"required": [
"contract_id",
"target"
],
"properties": {
"contract_id": {
"type": "string"
},
"target": {
"type": "string"
}
}
}
}
},
{
"type": "object",
"required": [
"get_perm"
],
"properties": {
"get_perm": {
"type": "object",
"required": [
"address",
"contract_id"
],
"properties": {
"address": {
"$ref": "#/definitions/HumanAddr"
},
"contract_id": {
"type": "string"
}
}
}
}
}
],
"definitions": {
"HumanAddr": {
"type": "string"
}
]
}
}
22 changes: 22 additions & 0 deletions contracts/token-tester/schema/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "State",
"type": "object",
"required": [
"owner"
],
"properties": {
"owner": {
"$ref": "#/definitions/CanonicalAddr"
}
},
"definitions": {
"Binary": {
"description": "Binary is a wrapper around Vec<u8> 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<u8>",
"type": "string"
},
"CanonicalAddr": {
"$ref": "#/definitions/Binary"
}
}
}
Loading

0 comments on commit 937a12f

Please sign in to comment.