Skip to content

Commit

Permalink
Merge pull request #22 from enigmampc/query-balance-prmit
Browse files Browse the repository at this point in the history
Query with a signed permit instead of a viewing key
  • Loading branch information
assafmo authored Oct 19, 2021
2 parents 8e1e18a + 2d1d606 commit bf165a5
Show file tree
Hide file tree
Showing 11 changed files with 752 additions and 88 deletions.
226 changes: 161 additions & 65 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ name = "snip20-reference-impl"
version = "0.1.0"
authors = ["Itzik <[email protected]>"]
edition = "2018"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

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

Expand All @@ -31,23 +29,24 @@ overflow-checks = true
# for more explicit tests, cargo test --features=backtraces
#default = ["debug-print"]
backtraces = ["cosmwasm-std/backtraces"]
debug-print = ["cosmwasm-std/debug-print"]

# debug-print = ["cosmwasm-std/debug-print"]
[dependencies]
cosmwasm-std = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
cosmwasm-storage = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
secret-toolkit = { git = "https://github.com/enigmampc/secret-toolkit", rev = "v0.1.1-debug-print" }
cosmwasm-std = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.0" }
cosmwasm-storage = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.0" }
secret-toolkit = { git = "https://github.com/enigmampc/secret-toolkit", rev = "52df67c2becf98510fa55bdad5edf0e2dd11f5a6" }
schemars = "0.7"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
snafu = { version = "0.6.3" }
bincode2 = "2.0.1"
subtle = { version = "2.2.3", default-features = false }
base64 = "0.12.3"
hex = "0.4.2"

rand_chacha = { version = "0.2.2", default-features = false }
rand_core = { version = "0.5.1", default-features = false }
rand_core = { version = "0.5.1", default-features = false }
sha2 = { version = "0.9.1", default-features = false }
ripemd160 = "0.9.1"
secp256k1 = "0.19.0"

[dev-dependencies]
cosmwasm-schema = { version = "0.9.2" }
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ contract.wasm.gz: contract.wasm
.PHONY: start-server
start-server: # CTRL+C to stop
docker run -it --rm \
-p 26657:26657 -p 26656:26656 -p 1317:1317 \
-p 26657:26657 -p 26656:26656 -p 1337:1337 \
-v $$(pwd):/root/code \
--name secretdev enigmampc/secret-network-sw-dev:v1.0.4-3
--name secretdev enigmampc/secret-network-sw-dev:v1.0.4-5

.PHONY: schema
schema:
Expand Down
19 changes: 19 additions & 0 deletions schema/handle_answer.json
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,25 @@
}
}
}
},
{
"type": "object",
"required": [
"revoke_pemit"
],
"properties": {
"revoke_pemit": {
"type": "object",
"required": [
"status"
],
"properties": {
"status": {
"$ref": "#/definitions/ResponseStatus"
}
}
}
}
}
],
"definitions": {
Expand Down
43 changes: 43 additions & 0 deletions schema/handle_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
},
"recipient": {
"$ref": "#/definitions/HumanAddr"
},
"recipient_code_hash": {
"type": [
"string",
"null"
]
}
}
}
Expand Down Expand Up @@ -451,6 +457,12 @@
},
"recipient": {
"$ref": "#/definitions/HumanAddr"
},
"recipient_code_hash": {
"type": [
"string",
"null"
]
}
}
}
Expand Down Expand Up @@ -771,6 +783,25 @@
}
}
}
},
{
"type": "object",
"required": [
"revoke_permit"
],
"properties": {
"revoke_permit": {
"type": "object",
"required": [
"permit_name"
],
"properties": {
"permit_name": {
"type": "string"
}
}
}
}
}
],
"definitions": {
Expand Down Expand Up @@ -859,6 +890,12 @@
},
"recipient": {
"$ref": "#/definitions/HumanAddr"
},
"recipient_code_hash": {
"type": [
"string",
"null"
]
}
}
},
Expand Down Expand Up @@ -894,6 +931,12 @@
},
"recipient": {
"$ref": "#/definitions/HumanAddr"
},
"recipient_code_hash": {
"type": [
"string",
"null"
]
}
}
},
Expand Down
212 changes: 212 additions & 0 deletions schema/query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,223 @@
"type": "object"
}
}
},
{
"type": "object",
"required": [
"with_permit"
],
"properties": {
"with_permit": {
"type": "object",
"required": [
"permit",
"query"
],
"properties": {
"permit": {
"$ref": "#/definitions/Permit"
},
"query": {
"$ref": "#/definitions/QueryWithPermit"
}
}
}
}
}
],
"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"
},
"HumanAddr": {
"type": "string"
},
"Permission": {
"type": "string",
"enum": [
"allowance",
"balance",
"history",
"owner"
]
},
"Permit": {
"type": "object",
"required": [
"params",
"signature"
],
"properties": {
"params": {
"$ref": "#/definitions/PermitParams"
},
"signature": {
"$ref": "#/definitions/PermitSignature"
}
}
},
"PermitParams": {
"type": "object",
"required": [
"allowed_tokens",
"chain_id",
"permissions",
"permit_name"
],
"properties": {
"allowed_tokens": {
"type": "array",
"items": {
"$ref": "#/definitions/HumanAddr"
}
},
"chain_id": {
"type": "string"
},
"permissions": {
"type": "array",
"items": {
"$ref": "#/definitions/Permission"
}
},
"permit_name": {
"type": "string"
}
}
},
"PermitSignature": {
"type": "object",
"required": [
"pub_key",
"signature"
],
"properties": {
"pub_key": {
"$ref": "#/definitions/PubKey"
},
"signature": {
"$ref": "#/definitions/Binary"
}
}
},
"PubKey": {
"type": "object",
"required": [
"type",
"value"
],
"properties": {
"type": {
"description": "ignored, but must be \"tendermint/PubKeySecp256k1\" otherwise the verification will fail",
"type": "string"
},
"value": {
"description": "Secp256k1 PubKey",
"allOf": [
{
"$ref": "#/definitions/Binary"
}
]
}
}
},
"QueryWithPermit": {
"anyOf": [
{
"type": "object",
"required": [
"allowance"
],
"properties": {
"allowance": {
"type": "object",
"required": [
"owner",
"spender"
],
"properties": {
"owner": {
"$ref": "#/definitions/HumanAddr"
},
"spender": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"type": "object",
"required": [
"balance"
],
"properties": {
"balance": {
"type": "object"
}
}
},
{
"type": "object",
"required": [
"transfer_history"
],
"properties": {
"transfer_history": {
"type": "object",
"required": [
"page_size"
],
"properties": {
"page": {
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0.0
},
"page_size": {
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
}
}
}
},
{
"type": "object",
"required": [
"transaction_history"
],
"properties": {
"transaction_history": {
"type": "object",
"required": [
"page_size"
],
"properties": {
"page": {
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0.0
},
"page_size": {
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
}
}
}
}
]
}
}
}
Loading

0 comments on commit bf165a5

Please sign in to comment.