Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

[WIP] Support Variables in Syntax#4

Open
michaeljklein wants to merge 87 commits intomainfrom
feat/pretty-parsing
Open

[WIP] Support Variables in Syntax#4
michaeljklein wants to merge 87 commits intomainfrom
feat/pretty-parsing

Conversation

@michaeljklein
Copy link
Contributor

Support an assignment-based syntax for manipulating the stack: we compile to the stack-based language by keeping track of a context of variables mapped to the stack.

The result currently looks like this:

input_json = unpack_json(INPUT)

queries = unpack_json(lookup("queries", input_json))
first_query = unpack_json(index("0", queries))

_ = assert(check_eq(unpack_json(lookup("action", first_query)), "tokenbalance"))
_ = assert(check_eq(unpack_json(lookup("contractaddress", first_query)), "0x57d90b64a1a57749b0f932f1a3395792e12e7055"))
_ = assert(check_eq(unpack_json(lookup("result"), unpack_json(lookup("response", first_query))), "135499"))

prompts = unpack_json(lookup("prompts", input_json))
first_prompt = unpack_json(lookup("0", prompts))

_ = assert(check_eq(unpack_json(lookup("action", first_prompt)), "siwe"))
_ = assert(check_eq(unpack_json(lookup("version", first_prompt)), "1.1.0"))
_ = assert(check_eq(unpack_json(lookup("address", unpack_json(lookup("fields", unpack_json(lookup("data", first_prompt)))))), "0xe04f27eb70e025b78871a2ad7eabe85e61212761"))

message_hash = hash_sha256(string_to_bytes(unpack_json(lookup("message", unpack_json(lookup("data", first_prompt))))))
address_hash = hash_sha256(string_to_bytes(unpack_json(lookup("address", unpack_json(lookup("fields", unpack_json(lookup("data", first_prompt))))))))

// Comments look like this
_ = assert(check_eq(hash_sha256(concat(message_hash, address_hash)), "0x35a3b28b7abbab2f2a87afb0f00b0a98e4ee6acd8444504fbc367cf261841f8b"))

…nd of file not being accepted, add integration test, begin converting to untyped instructions
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant