tealish
tealish copied to clipboard
Addr literal
Similar to hex looking for 0x... in #60, this looks for addr(...) where the contents are valid b32 strings.
const bytes ADMIN_ADDR = addr(RIKLQ5HEVXAOAWYSW2LGQFYGWVO4J6LIAQQ72ZRULHZ4KS5NRPCCKYPCUU)
This also changes the const map to allow Union[ConstValue, Literal] where Literal is the AST Node type, this way we can use the write_teal defined on the Literal itself (important for LiteralAddress to write addr ...)
Note: this also includes the LiteralHex changes, so if that gets merged this will look cleaner
Marked as draft for now until syntax is decided.
I'm wondering if this is somewhere where we should depart from Teal. This syntax is a bit odd to me. I feel like it would be more useful to have a addr(LiteralBytes): e.g. const bytes ADMIN_ADDR = addr("RIKLQ5HEVXAOAWYSW2LGQFYGWVO4J6LIAQQ72ZRULHZ4KS5NRPCCKYPCUU")
In this case it would be a Tealish builtin function rather than a language feature. It could still compile to addr RIKLQ5HEV...
What do you think? I don't have strong feelings about this. It's just an observation.
I'm not crazy about it either TBH.
Ideally I think something like the following might be nicer but would need other considerations
const addr admin_acct = RIKLQ5HEVXAOAWYSW2LGQFYGWVO4J6LIAQQ72ZRULHZ4KS5NRPCCKYPCUU
Where addr is a sort of alias for AVMType.bytes (+ extra processing)
This would also be useful in the case of
const bigint large_prime = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab
Where bigint is also an alias for AVMType.bytes (+ mapping fn calls like +/-/* to the bytemath equivalent)
An explicit address type also makes it nicer for code legibility when we can do things like: addr dest_account = Txn.ApplicationArgs[1] as opposed to using bytes for everything. It would also be cleaner in structs for eg.