Soroban Contract Parser
This release adds a soroban contract parser that allows you to access the contract info stored in the contract bytecode.
You can access the environment metadata, contract spec and contract meta.
The environment metadata holds the interface version that should match the version of the soroban environment host functions supported.
The contract spec contains a SCSpecEntryXDR
for every function, struct, and union exported by the contract.
In the contract meta, contracts may store any metadata in the entries that can be used by applications and tooling off-network.
You can access the parser directly if you have the contract bytecode:
let byteCode = FileManager.default.contents(atPath: 'path to .wasm file')
let contractInfo = try SorobanContractParser.parseContractByteCode(byteCode: byteCode)
Or you can use SorobanServer
methods to load the contract code form the network and parse it.
By contract id:
sorobanServer.getContractInfoForContractId(contractId: contractId) { (response) -> (Void) in
switch response {
case .success(let contractInfo):
// ...
case .rpcFailure(let error):
// ...
case .parsingFailure (let error):
// ...
}
}
By wasm id:
sorobanServer.getContractInfoForWasmId(wasmId: wasmId) { (response) -> (Void) in
switch response {
case .success(let contractInfo):
// ...
case .rpcFailure(let error):
// ...
case .parsingFailure (let error):
// ...
}
}
The parser returns a SorobanContractInfo
object containing the parsed data.
In SorobanParserTest.swift you can find a detailed example of how you can access the parsed data.
SEP improvements
SEP-06: allow extra fields to be added in the deposit and withdrawal requests.
SEP-06: add the new userActionRequired
field to the transaction response object.
SEP-24: add the new userActionRequired
field to the transaction response object.