Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNIP-24 - Query Permits #22

Merged
merged 41 commits into from Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cd78f1e
Working prototype :tada:
assafmo Sep 25, 2021
e299b4d
Validate permit message
assafmo Sep 25, 2021
7065602
Rename account to query_balance_of
assafmo Sep 25, 2021
4dd5088
Fix permit's content serialization to bytes
assafmo Sep 26, 2021
468eda9
Update make start-server
assafmo Sep 26, 2021
0582c62
Refactor, make permit API UX better
assafmo Sep 26, 2021
476c043
remain::sorted on SignedPermit
assafmo Sep 26, 2021
2365946
Query with permit for all authenticated queries
assafmo Sep 26, 2021
7d8a365
Refactor some var/func names
assafmo Sep 26, 2021
e3ac874
Implement revoke permit
assafmo Sep 26, 2021
b1f3d46
Clean makefile
assafmo Sep 26, 2021
ca14f16
Refactor RevokedPermits storage
assafmo Sep 27, 2021
7c0d408
:shrug:
assafmo Sep 27, 2021
a8dace9
simplified permit query interface
reuvenpo Sep 27, 2021
c3071e9
Fix permit for query_allowance
assafmo Sep 29, 2021
d986d2e
Rename struct SignedPermit -> PermitParams
assafmo Sep 29, 2021
8a8d419
A small refactor
assafmo Sep 29, 2021
2323bf4
Code comment rephrase
assafmo Sep 29, 2021
e14e857
cargo schema
reuvenpo Sep 29, 2021
3844f6c
Simplify return logic of is_permit_revoked()
assafmo Sep 29, 2021
934452e
Merge branch 'query-balance-prmit' of github.com:enigmampc/snip20-ref…
assafmo Sep 29, 2021
38bc240
Merge pull request #23 from enigmampc/query-balance-prmit-2
assafmo Sep 29, 2021
37b191f
Fix merge conflict
assafmo Sep 29, 2021
1ce2de6
Rename query_with_permit() -> permit_queries()
assafmo Sep 29, 2021
716ee8a
Rename permit.signed -> permit.params
assafmo Sep 29, 2021
7af1d05
cargo schema
reuvenpo Sep 29, 2021
736a0d9
Query permit permissions
assafmo Sep 29, 2021
128e3f7
Add prefix for RevokedPemits storage keys
assafmo Oct 4, 2021
c9b53b5
Test permits for wrong token
assafmo Oct 8, 2021
59d61c7
Permit: make errors more readable for humans
assafmo Oct 13, 2021
7a27a75
Permits: test every failure scenario
assafmo Oct 13, 2021
0384401
Permit: test query balance
assafmo Oct 13, 2021
60b4c53
Permit: test query history & allowance
assafmo Oct 13, 2021
8e16bb4
Restore all the other tests
assafmo Oct 13, 2021
0400dcb
Move permit operations to secret-toolkit
assafmo Oct 14, 2021
942debd
Fix secret-toolkit dependency
assafmo Oct 17, 2021
ea27639
Pass storage key prefix to RevokedPemits
assafmo Oct 18, 2021
caa8ab7
RevokedPemits -> RevokedPermits
assafmo Oct 18, 2021
b2f764e
Use cosmwasm-std v1.0.0
assafmo Oct 18, 2021
bae405b
Update secret-toolkit
assafmo Oct 19, 2021
2d1d606
cargo schema
assafmo Oct 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
226 changes: 161 additions & 65 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions Cargo.toml
Expand Up @@ -3,15 +3,13 @@ name = "snip20-reference-impl"
version = "0.1.0"
authors = ["Itzik <itzik@keytango.io>"]
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
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
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
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
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
}
}
}
}
}
]
}
}
}