-
Notifications
You must be signed in to change notification settings - Fork 36
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
Conversation
of querying my balance with a signed permit instead of a viewing key
And rename permit_id to permit_user_id
In order to verify the signature, we need to serialize the permit's content into JSON as UTF8 bytes. Amino encoding requires JSON serialization to sort object fields alphabetically, so to do so inside the contract a reorder of the permit data structs had to be done. Apparently serde_json_wasm keeps this order while serializing to bytes. For reference, this is how it's done by Keplr/cosmjs: https://github.com/enigmampc/cosmjs/blob/b2279928c6d46a568e619cafddc6c1bbd17ec1b0/packages/amino/src/signdoc.ts?plain=1#L31-L51
Does this mean that you will need to sign a tx every time you query a balance? Will this live along side viewing keys as a sort of "one time passcode" for queries that access private state? |
No, you sign it offline (you don't broadcast a tx) and the signature (=permit) is sent with the balance query (like a viewing key) and is reusable for multiple queries. To revoke a permit the user needs to send a "revoke permit" tx.
This is an addition, so viewing keys remain untouched. It's reusable, so not exactly a "one time passcode". |
To make sure it's aligned with Amino encoding
- Balance - TransferHistory - TransactionHistory - Allowance
The query should validate permit from owner or spender, was only owner until now.
…erence-impl into query-balance-prmit
9e937b0
to
942debd
Compare
Omg it's happening. 😍 |
This is used in query permits scrtlabs/snip20-reference-impl#22
A way to do authenticated queries without needing to set a viewing key first. 👀
Docs: https://github.com/SecretFoundation/SNIPs/blob/master/SNIP-24.md
Keplr example (SNIP-20):
Keplr example (SNIP-721):
CLI example (SNIP-20):