-
Notifications
You must be signed in to change notification settings - Fork 118
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
ARC0047: Logic Signature Templates #226
Conversation
This great ARC will open the doors to so many new UX improvements! Thank you Joe! |
Before going to final we'll need to add a section for wallet communication (perhaps a new WC method?), but there doesn't seem to be any objections to what is currently in the ARC. |
dApps would need to send wallets both the ARC47 JSON and the variable values. Could be done in a payload like the following that is then processed by the wallet (substitute variables in TEAL, compile, and then sign the program) {
"arc47":{
"name":"Address Opt-In",
"description":"This program allows a given address to opt in the signer to any asset provided it's approved by the associated application",
"program":"I3ByYWdtYSB2ZXJzaW9uIDgKI2RlZmluZSBNYXN0ZXJBcHBDYWxsIGxvYWQgMAoKLy8gU2F2ZSBNYXN0ZXJBcHBDYWxsCnR4biBHcm91cEluZGV4CmludCAxCisKc3RvcmUgMAoKLy8gVmVyaWZ5IGFtb3VudCBpcyAwCnR4biBBc3NldEFtb3VudAppbnQgMAo9PQphc3NlcnQKCi8vIFZlcmlmeSBzZW5kZXIgPT0gcmVjZWl2ZXIKdHhuIEFzc2V0UmVjZWl2ZXIKdHhuIFNlbmRlcgo9PQphc3NlcnQKCi8vIFZlcmlmeSBmZWUgaXMgMCAoY292ZXJlZCBieSBzZW5kZXIpCnR4biBGZWUKaW50IDAKPT0KYXNzZXJ0CgovLyBWZXJpZnkgYXNzZXRDbG9zZVRvIGlzIG5vdCBzZXQKdHhuIEFzc2V0Q2xvc2VUbwpnbG9iYWwgWmVyb0FkZHJlc3MKPT0KYXNzZXJ0CgovLyBWZXJpZnkgY2FsbGVkIGF0b21pY2FsbHkgd2l0aCBtYXN0ZXIgYXBwCk1hc3RlckFwcENhbGwKZ3R4bnMgQXBwbGljYXRpb25JRAppbnQgVE1QTF9ERUxFR0FURURfT1BUSU5fQVBQX0lECj09CmFzc2VydAoKLy8gVmVyaWZ5IHRoZSBjb3JyZWN0IG1ldGhvZCBpcyBiZWluZyBjYWxsZWQKTWFzdGVyQXBwQ2FsbApndHhuc2EgQXBwbGljYXRpb25BcmdzIDAKbWV0aG9kICJhZGRyZXNzT3B0SW4ocGF5LGF4ZmVyKXZvaWQiCj09CmFzc2VydAoKLy8gVmVyaWZ5IHRoZSBzZW5kZXIgaXMgdGhlIGNvcnJlY3QgYWRkcmVzcwpNYXN0ZXJBcHBDYWxsCmd0eG5zIFNlbmRlcgphZGRyIFRNUExfQVVUSE9SSVpFRF9BRERSRVNTCj09",
"variables":[
{
"variable":"TMPL_DELEGATED_OPTIN_APP_ID",
"name":"Delegated opt-in app ID",
"type":"application",
"description":"The ID of the application that will be used for verifying opt ins"
},
{
"variable":"TMPL_AUTHORIZED_ADDRESS",
"name":"Aurhotized address",
"type":"address",
"description":"The address that will be allowed to opt the signer into assets provided it's approved by the associated application"
}
]
},
"values":{
"TMPL_DELEGATED_OPTIN_APP_ID":1337,
"TMPL_AUTHORIZED_ADDRESS":"46XYR7OTRZXISI2TRSBDWPUVQT4ECBWNI7TFWPPS6EKAPJ7W5OBXSNG66M"
}
} |
ARCs/arc-draft-lsig_templates.md
Outdated
| --- | ----------- | | ||
| `name` | The name of the logic signature. **SHOULD** be short and descriptive | | ||
| `description` | A description of what the logic signature does | | ||
| `program` | base64 encoding of the TEAL program source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to base64 encode teal programs. They are unicode and so is JSON.
ARCs/arc-0047.md
Outdated
|
||
#### Types | ||
|
||
Any valid ABI type encoded in base16 (without the leading `0x`) with the following exceptions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the type being encoded in hex? It's human readable unicode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current wording made it unclear that I was referencing the value rather than the type itself. See if b02fc9c makes more sense
#pragma version 9 | ||
byte "Hello, TMPL_NAME" | ||
``` | ||
|
||
This is not valid because `TMPL_NAME` is not the full immediate argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example drives home that it's a big ask for the wallet to parse TEAL. According to these rules, it needs to accept:
byte TMPL_NAME; int 7
, byteblock "hello\" " TEMPL_NAME
for example.
I think we need to spec out the exact local rules that would allow a program to accept. I admit that's not easy.
Perhaps we should restrict things much more strongly. Only things that can be be properly escaped by the wallet, and result in a single byte X
or int X
instruction, for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah didn't think about constant blocks. I think enforcing byte x
/int x
is reasonable.
I also didn't think about ;
. How about enforcing that any usage of a variable must match this regex /^(byte|int) TMPL_/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or probably /^\s*(byte|int) TMPL_/
to account for indented lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd allow pushint
and pushbyte
as well. I think there are good reasons to use them in templates, so that the inserted bytes end up exactly where you expect them.
(int
and byte
do some funny business around optimization, and moving the constants into constant blocks.)
dd02345
to
f0a5af2
Compare
ARC has become excellent, please merge it ASAP Joe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to have any rules for the names of template arguments?
#pragma version 9 | ||
byte "Hello, TMPL_NAME" | ||
``` | ||
|
||
This is not valid because `TMPL_NAME` is not the full immediate argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd allow pushint
and pushbyte
as well. I think there are good reasons to use them in templates, so that the inserted bytes end up exactly where you expect them.
(int
and byte
do some funny business around optimization, and moving the constants into constant blocks.)
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a .gitignore
in here?
Co-authored-by: John Jannotti <[email protected]>
Provides a standardized way to define logic signatures so wallets can safely inform users what they are signing