-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fetch schema #328
base: main
Are you sure you want to change the base?
Fetch schema #328
Conversation
…de/decode LEB128U integers.
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.
Looks pretty good. But I think we should add support for legacy schemas as well for completeness.
@@ -83,6 +86,17 @@ public static WasmModule from(final byte[] bytes) { | |||
return from(moduleBytes, version); | |||
} | |||
|
|||
/** | |||
* Create {@link WasmModule} from compiled module WASM file. Passed module should have version prefixed. |
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.
Clarify that this is the module format produced by cargo-concordium.
// We've incremented the buffer by reading the length of the name and the name. | ||
remainingSectionLength = remainingSectionLength - nameLengthBytes - nameLength; | ||
|
||
if (name.equals("concordium-schema")) { |
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.
In principle there are also concordium-schema-v1
and concordium-schema-v2
, see https://docs.rs/axum/latest/axum/struct.Router.html#method.fallback_service https://github.com/Concordium/concordium-base/blob/87a752f185869ea567387baac384e0e5bc997fd9/smart-contracts/wasm-chain-integration/src/utils.rs#L583
which would be great to support since the Schema class does as well as far as I understand.
The difference is that the concordium-schema
section contains the schema that is versioned inside.
Whereas the new (old,legacy) -v1
and -v2
sections, the contents is the unversioned schema and the version is in the name (v0 and v1).
Purpose
Add convenience method to exctract a
Schema
from aWasmModule
if embedded.Changes
I added the class
LEB128U
to encode/decode LEB128U encoded integers and refactoredTokenAmount
to use this.I added the method
getSchema
toWasmModule
that parses the underlying wasm bytes and exctract aSchema
if found.I added a test extracting a
Schema
and asserting it works.Checklist
hard-to-understand areas.