Options
All
  • Public
  • Public/Protected
  • All
Menu

The WireDecoder class. Decodes transactions and logs. See below for a method listing.

Hierarchy

  • WireDecoder

Index

Constructors

Protected constructor

  • new WireDecoder(contracts: ContractObject[], provider: Provider): WireDecoder

Properties

Private allocations

allocations: AllocationInfo

Private codeCache

codeCache: CodeCache

Private contexts

contexts: DecoderContexts

Private contractNodes

contractNodes: AstNodes

Private contracts

contracts: ContractMapping

Private deployedContexts

deployedContexts: DecoderContexts

Private network

network: string

Private referenceDeclarations

referenceDeclarations: AstNodes

Private userDefinedTypes

userDefinedTypes: TypesById

Private web3

web3: Web3

Methods

abifyCalldataDecoding

  • Takes a CalldataDecoding, which may have been produced in full mode or ABI mode, and converts it to its ABI mode equivalent. See the README for more information.

    Please only use on decodings produced by this same decoder instance; use on decodings produced by other instances may not work consistently.

    Parameters

    Returns CalldataDecoding

abifyLogDecoding

  • Takes a LogDecoding, which may have been produced in full mode or ABI mode, and converts it to its ABI mode equivalent. See the README for more information.

    Please only use on decodings produced by this same decoder instance; use on decodings produced by other instances may not work consistently.

    Parameters

    Returns LogDecoding

Private collectUserDefinedTypes

  • collectUserDefinedTypes(): object

decodeLog

  • This method is asynchronous.

    Takes a Log object and decodes it. Logs can be ambiguous, so this so this function returns an array of LogDecodings.

    Note that logs are decoded in strict mode, so (with one exception) none of the decodings should contain errors; if a decoding would contain an error, instead it is simply excluded from the list of possible decodings. The one exception to this is that indexed parameters of reference type cannot meaningfully be decoded, so those will decode to an error.

    If there are multiple possible decodings, they will always be listed in the following order:

    1. A non-anonymous event coming from the contract itself (there can be at most one of these)
    2. Non-anonymous events coming from libraries
    3. Anonymous events coming from the contract itself
    4. Anonymous events coming from libraries

    You can check the kind and class.contractKind fields to distinguish between these.

    If no possible decodings are found, the returned array of decodings will be empty.

    Note that different decodings may use different decoding modes.

    Parameters

    • log: Log

      The log to be decoded.

    Returns Promise<LogDecoding[]>

Protected decodeLogWithAdditionalOptions

decodeTransaction

  • This method is asynchronous.

    Takes a Transaction object and decodes it. The result is a CalldataDecoding; see the documentation on that interface for more.

    Note that decoding of transactions sent to libraries is presently not supported and may have unreliable results. Limited support for this is planned for future versions.

    Parameters

    • transaction: Transaction

      The transaction to be decoded.

    Returns Promise<CalldataDecoding>

Protected decodeTransactionWithAdditionalContexts

events

  • This method is asynchronous.

    Gets all events meeting certain conditions and decodes them. This function is fairly rudimentary at the moment but more functionality will be added in the future.

    example

    events({name: "TestEvent"}) -- get events named "TestEvent" from the most recent block

    Parameters

    • Default value options: EventOptions = {}

      Used to determine what events to fetch; see the documentation on the EventOptions type for more.

    Returns Promise<DecodedLog[]>

    An array of DecodedLogs. These consist of a log together with its possible decodings; see that type for more info. And see decodeLog for more info on how log decoding works in general.

Protected eventsWithAdditionalContexts

forArtifact

  • This method is asynchronous.

    Constructs a contract decoder for a given contract artifact.

    Parameters

    • artifact: ContractObject

      The artifact for the contract.

      A contract constructor object may be substituted for the artifact, so if you're not sure which you're dealing with, it's OK.

      Note: The artifact must be one of the ones used to initialize the wire decoder; otherwise you will have problems.

    Returns Promise<ContractDecoder>

forInstance

  • This method is asynchronous.

    Constructs a contract instance decoder for a given instance of a contract in this project.

    Parameters

    • artifact: ContractObject

      The artifact for the contract.

      A contract constructor object may be substituted for the artifact, so if you're not sure which you're dealing with, it's OK.

      Note: The artifact must be one of the ones used to initialize the wire decoder; otherwise you will have problems.

    • Optional address: string

      The address of the contract instance decode. If left out, it will be autodetected. If an invalid address is provided, this method will throw an exception.

    Returns Promise<ContractInstanceDecoder>

Protected getAllocations

Protected getCode

  • getCode(address: string, block: DecoderTypes.RegularizedBlockSpecifier): Promise<Uint8Array>
  • Parameters

    • address: string
    • block: DecoderTypes.RegularizedBlockSpecifier

    Returns Promise<Uint8Array>

Private getContextByAddress

  • getContextByAddress(address: string, block: DecoderTypes.RegularizedBlockSpecifier, constructorBinary?: string, additionalContexts?: DecoderContexts): Promise<DecoderContext | null>

Protected getDeployedContexts

Protected getReferenceDeclarations

Protected getUserDefinedTypes

Protected getWeb3

  • getWeb3(): Web3

Protected regularizeBlock

  • regularizeBlock(block: DecoderTypes.BlockSpecifier | null): Promise<DecoderTypes.RegularizedBlockSpecifier>
  • Parameters

    • block: DecoderTypes.BlockSpecifier | null

    Returns Promise<DecoderTypes.RegularizedBlockSpecifier>

Generated using TypeDoc