diff --git a/contract_wasm_interface_parser/__init__.py b/contract_wasm_interface_parser/__init__.py index c6cdcf7..4b14f91 100644 --- a/contract_wasm_interface_parser/__init__.py +++ b/contract_wasm_interface_parser/__init__.py @@ -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) @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 97cb7b5..6e21ff0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 <4catcode@gmail.com>"] license = "Apache License 2.0" diff --git a/tests/__init__.py b/tests/__init__.py index bf6edc4..8fdfc93 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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") @@ -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,