Skip to content

Commit

Permalink
release: 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Jun 24, 2024
1 parent 5d71962 commit 9d5412d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions contract_wasm_interface_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
class ContractMetaData:
"""The contract metadata parsed from the Stellar Contract WASM."""

env_meta_base64: Optional[bytes] = None
env_meta_bytes: Optional[bytes] = None
env_meta: List[SCEnvMetaEntry] = dataclasses.field(default_factory=list)
meta_base64: Optional[bytes] = None
meta_bytes: Optional[bytes] = None
meta: List[SCMetaEntry] = dataclasses.field(default_factory=list)
spec_base64: Optional[bytes] = None
spec_bytes: Optional[bytes] = None
spec: List[SCSpecEntry] = dataclasses.field(default_factory=list)


Expand All @@ -31,13 +31,13 @@ def parse_contract_metadata(wasm: Union[bytes, str]) -> ContractMetaData:
metadata = ContractMetaData()
for name, content in custom_sections:
if name == "contractenvmetav0":
metadata.env_meta_base64 = content
metadata.env_meta_bytes = content
metadata.env_meta = parse_entries(content, SCEnvMetaEntry)
if name == "contractspecv0":
metadata.spec_base64 = content
metadata.spec_bytes = content
metadata.spec = parse_entries(content, SCSpecEntry)
if name == "contractmetav0":
metadata.meta_base64 = content
metadata.meta_bytes = content
metadata.meta = parse_entries(content, SCMetaEntry)
return metadata

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "contract-wasm-interface-parser"
version = "0.1.0"
version = "0.2.0"
description = "Contract interface metadata parser for binary Stellar WASM"
authors = ["overcat <[email protected]>"]
license = "Apache License 2.0"
Expand Down
6 changes: 3 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def test_parser(self):
wasm = "AGFzbQEAAAABFQRgAn5+AX5gA35+fgF+YAABfmAAAAIZBAFsATAAAAFsATEAAAFsAV8AAQFsATgAAAMFBAIDAwMFAwEAEAYZA38BQYCAwAALfwBBgIDAAAt/AEGAgMAACwc1BQZtZW1vcnkCAAlpbmNyZW1lbnQABAFfAAcKX19kYXRhX2VuZAMBC19faGVhcF9iYXNlAwIKpwEEkgECAX8BfkEAIQACQAJAAkBCjrrQr4bUOUICEICAgIAAQgFSDQBCjrrQr4bUOUICEIGAgIAAIgFC/wGDQgRSDQEgAUIgiKchAAsgAEEBaiIARQ0BQo660K+G1DkgAK1CIIZCBIQiAUICEIKAgIAAGkKEgICAoAZChICAgMAMEIOAgIAAGiABDwsAAAsQhYCAgAAACwkAEIaAgIAAAAsEAAAACwIACwBzDmNvbnRyYWN0c3BlY3YwAAAAAAAAAEBJbmNyZW1lbnQgaW5jcmVtZW50cyBhbiBpbnRlcm5hbCBjb3VudGVyLCBhbmQgcmV0dXJucyB0aGUgdmFsdWUuAAAACWluY3JlbWVudAAAAAAAAAAAAAABAAAABAAeEWNvbnRyYWN0ZW52bWV0YXYwAAAAAAAAABQAAAAAAG8OY29udHJhY3RtZXRhdjAAAAAAAAAABXJzdmVyAAAAAAAABjEuNzguMAAAAAAAAAAAAAhyc3Nka3ZlcgAAAC8yMC4zLjEjYmEwNDVhNTdhZjk3MWZjODNlNDc1NzQ2YjU5YTUwM2I3ZWY0MTY0OQA="
metadata = parse_contract_metadata(wasm)
expected = ContractMetaData(
env_meta_base64=b"\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00",
env_meta_bytes=b"\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00",
env_meta=[
SCEnvMetaEntry(
kind=SCEnvMetaKind.SC_ENV_META_KIND_INTERFACE_VERSION,
interface_version=Uint64(uint64=85899345920),
)
],
meta_base64=b"\x00\x00\x00\x00\x00\x00\x00\x05rsver\x00\x00\x00\x00\x00\x00\x061.78.0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08rssdkver\x00\x00\x00/20.3.1#ba045a57af971fc83e475746b59a503b7ef41649\x00",
meta_bytes=b"\x00\x00\x00\x00\x00\x00\x00\x05rsver\x00\x00\x00\x00\x00\x00\x061.78.0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08rssdkver\x00\x00\x00/20.3.1#ba045a57af971fc83e475746b59a503b7ef41649\x00",
meta=[
SCMetaEntry(
kind=SCMetaKind.SC_META_V0, v0=SCMetaV0(key=b"rsver", val=b"1.78.0")
Expand All @@ -30,7 +30,7 @@ def test_parser(self):
),
),
],
spec_base64=b"\x00\x00\x00\x00\x00\x00\x00@Increment increments an internal counter, and returns the value.\x00\x00\x00\tincrement\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x04",
spec_bytes=b"\x00\x00\x00\x00\x00\x00\x00@Increment increments an internal counter, and returns the value.\x00\x00\x00\tincrement\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x04",
spec=[
SCSpecEntry(
kind=SCSpecEntryKind.SC_SPEC_ENTRY_FUNCTION_V0,
Expand Down

0 comments on commit 9d5412d

Please sign in to comment.