Class ContractMeta
Entries are stored in module order and exposed as an unmodifiable list. Construct with raw
SCMetaEntry values, decode from contract Wasm bytes via fromWasm(byte[]), or
decode from a SEP-0046 XDR stream via fromXdrBytes(byte[]).
This wrapper is shallow immutable: the entry list cannot be modified, but the contained SCMetaEntry objects are the underlying mutable XDR types. Do not mutate them after construction;
doing so also affects equals(Object), hashCode(), and the decoded views.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic ContractMetafromWasm(byte[] wasm) Creates aContractMetafrom contract Wasm bytes by decoding eachcontractmetav0custom section as a self-contained XDR stream and appending the resulting entries in module order.static ContractMetafromWasmFile(Path path) Creates aContractMetafrom a contract Wasm file.static ContractMetafromXdrBytes(byte[] data) Creates aContractMetafrom a SEP-0046 XDR stream ofSCMetaEntryvalues.Returns the firstSC_META_V0value forkey.Returns allSC_META_V0values forkeyin entry order.inthashCode()booleanimplementsSep(int sep) Returns whether the contract declares support forsepvia SEP-0047.items()ReturnsSC_META_V0key/value pairs decoded as UTF-8, in entry order.Returns SEP-0047 SEP identifiers declared viasepmetadata entries.supportedSeps(boolean strict) Returns SEP-0047 SEP identifiers declared viasepmetadata entries.toString()byte[]Serializes the entries as a SEP-0046 XDR stream.
-
Constructor Details
-
ContractMeta
public ContractMeta() -
ContractMeta
-
-
Method Details
-
fromWasm
Creates aContractMetafrom contract Wasm bytes by decoding eachcontractmetav0custom section as a self-contained XDR stream and appending the resulting entries in module order. Per SEP-0046, an entry never spans two sections.- Parameters:
wasm- contract Wasm bytes- Throws:
InvalidWasmException- if the Wasm module or metadata section cannot be decoded
-
fromWasmFile
Creates aContractMetafrom a contract Wasm file.- Parameters:
path- path to the contract Wasm file- Throws:
IOException- if the file cannot be readInvalidWasmException- if the Wasm module or metadata section cannot be decoded
-
fromXdrBytes
Creates aContractMetafrom a SEP-0046 XDR stream ofSCMetaEntryvalues.- Parameters:
data- XDR stream bytes- Throws:
InvalidWasmException- if the XDR stream cannot be decoded
-
toXdrBytes
public byte[] toXdrBytes()Serializes the entries as a SEP-0046 XDR stream. -
items
ReturnsSC_META_V0key/value pairs decoded as UTF-8, in entry order.- Throws:
InvalidWasmException- if a key or value is not valid UTF-8
-
get
Returns the firstSC_META_V0value forkey.- Throws:
InvalidWasmException- if a key or value is not valid UTF-8
-
getAll
Returns allSC_META_V0values forkeyin entry order.- Throws:
InvalidWasmException- if a key or value is not valid UTF-8
-
supportedSeps
Returns SEP-0047 SEP identifiers declared viasepmetadata entries. Invalid identifiers are skipped.SEP-0047 treats the declared identifiers as an unordered set: the value "may be in any order" and the same identifier may be repeated across entries. The returned set is de-duplicated; its iteration order is the first-seen order purely for deterministic output and carries no meaning.
-
supportedSeps
Returns SEP-0047 SEP identifiers declared viasepmetadata entries.- Parameters:
strict- when true, invalid identifiers cause anIllegalArgumentExceptionrather than being skipped- Throws:
IllegalArgumentException- ifstrictis true and an identifier is invalidInvalidWasmException- if a key or value is not valid UTF-8
-
implementsSep
public boolean implementsSep(int sep) Returns whether the contract declares support forsepvia SEP-0047. -
getEntries
-
equals
-
hashCode
public int hashCode() -
toString
-