java.lang.Object
net.finmath.smartcontracts.representablestate.xml.EvmXmlRenderer
All Implemented Interfaces:
ContractStateXmlRenderer

public class EvmXmlRenderer extends Object implements ContractStateXmlRenderer
Reference implementation of an XML renderer for IXMLRepresentableState and IXMLRepresentableStatePart Supported XML Schemata:
  • Core scalar profile
  • State-part callbacks with the renderer-provided $partId argument
  • Multi-binding attributes (evmstate:calls)
  • Array binding profile for scalar and tuple arrays via evmstate:item-element + evmstate:item-field
  • External template includes profile via XInclude (xi:include) with evmstate:integrity verification
  • ERC-4804/6860 web3:// and w3:// XInclude resources (address-based, same-chain)
Supported Contract Templates
  • XML-Complete state: stateXmlTemplate()
  • Partial state: statePartXmlTemplate(uint256 partId)
Author:
Christian Fries
  • Constructor Details

    • EvmXmlRenderer

      public EvmXmlRenderer(String rpcUrl)
      Instantiate a renderer connected to a given chain's RPC URL. XInclude processing is enabled with default options.
      Parameters:
      rpcUrl - The RPC URL of the chain.
    • EvmXmlRenderer

      public EvmXmlRenderer(String rpcUrl, EvmXmlRenderer.XIncludeOptions xincludeOptions)
      Instantiate a renderer connected to a given chain's RPC URL, with explicit XInclude options.
      Parameters:
      rpcUrl - The RPC URL of the chain.
      xincludeOptions - Options controlling XInclude expansion and fetching. If null, defaults are used.
  • Method Details

    • fromWeb3j

      public static EvmXmlRenderer fromWeb3j(org.web3j.protocol.Web3j web3)
      Creates a renderer using an existing Web3j client.
      Parameters:
      web3 - Web3j client used for every renderer RPC call.
      Returns:
      Renderer sharing the supplied client.
    • render

      public String render(String contractAddress) throws Exception
      Description copied from interface: ContractStateXmlRenderer
      Extract the XML from a given contract address, executing the required calls to populate the bindings.
      Specified by:
      render in interface ContractStateXmlRenderer
      Parameters:
      contractAddress - A given contract address as hex 0x1234567...
      Returns:
      The XML representing the current contract state.
      Throws:
      Exception - An exception.
    • render

      public String render(String contractAddress, BigInteger blockNumber) throws Exception
      Description copied from interface: ContractStateXmlRenderer
      Extract the XML from a given contract address, executing the required calls to populate the bindings.
      Specified by:
      render in interface ContractStateXmlRenderer
      Parameters:
      contractAddress - A given contract address as hex 0x1234567...
      blockNumber - The block number to fix for receiving the template and the state values.
      Returns:
      The XML representing the current contract state.
      Throws:
      Exception - An exception.
    • renderPart

      public String renderPart(String contractAddress, BigInteger partId) throws Exception
      Description copied from interface: ContractStateXmlRenderer
      Extract the XML from a given contract address, executing the required calls to populate the bindings.
      Specified by:
      renderPart in interface ContractStateXmlRenderer
      Parameters:
      contractAddress - A given contract address as hex 0x1234567...
      partId - State-part identifier. Must not be null; the on-chain type is uint256.
      Returns:
      The XML representing the current contract state.
      Throws:
      Exception - An exception.
    • renderTemplate

      public String renderTemplate(String contractAddress, boolean resolveXIncludes) throws Exception
      Return the contract's XML template, optionally expanding all XIncludes but without evaluating any evmstate bindings.
      Parameters:
      contractAddress - The contract address.
      resolveXIncludes - Whether XIncludes should be expanded recursively.
      Returns:
      The XML template.
      Throws:
      Exception - Any exception that occurs while loading or expanding the template.
    • renderTemplate

      public String renderTemplate(String contractAddress, BigInteger blockNumber, boolean resolveXIncludes) throws Exception
      Return the contract's XML template at a given block, optionally expanding all XIncludes but without evaluating any evmstate bindings.
      Parameters:
      contractAddress - The contract address.
      blockNumber - The block number to fix for loading the template and its includes.
      resolveXIncludes - Whether XIncludes should be expanded recursively.
      Returns:
      The XML template.
      Throws:
      Exception - Any exception that occurs while loading or expanding the template.
    • probeStateWitness

      public Optional<EvmXmlRenderer.StateWitness> probeStateWitness(String contractAddress, BigInteger blockNumber)
      Probes the optional representable-state witness at one fixed block.

      stateVersion() is required for a reusable witness. stateHash() strengthens the identity when available. Unsupported, reverting, malformed, or failed probes make the corresponding optional value unavailable and never turn this cache optimization into a rendering failure.

      Parameters:
      contractAddress - Contract whose optional interfaces are probed.
      blockNumber - Fixed block used for both probes.
      Returns:
      A version witness, optionally strengthened by a state hash.
    • render

      public String render(String contractAddress, BigInteger blockNumber, BigInteger partId) throws Exception
      Description copied from interface: ContractStateXmlRenderer
      Extract the XML representing the state (either xml-complete or partial) from a given contract address at a given block, executing the required calls to populate the bindings.
      Specified by:
      render in interface ContractStateXmlRenderer
      Parameters:
      contractAddress - A given contract address as hex 0x1234567...
      blockNumber - The block number to fix for receiving the template and the state values.
      partId - If null, use the complete-state template; otherwise use the state-part template. The on-chain type is uint256.
      Returns:
      The XML representing the current contract state.
      Throws:
      Exception - An exception.