Extractor

public struct Extractor

Internal Struct to encapsulate helpers methods needed to extract critical information from an array of operations, needed for processing decisions like “do i display a send token screen, or a send NFt screen”, fetching total XTZ sent in 1 action etc

  • Extract rpc amount (without decimal info) a tokenId, and the destination from a michelson FA1.2 / FA2 transfer payload

    Declaration

    Swift

    public static func tokenIdAndAmountFromSendMichelson(michelson: Any) -> (rpcAmount: String, tokenId: Decimal?, destination: String)?
  • Extract details from a payload in order to present to the user what it is they are trying to send

    Declaration

    Swift

    public static func faTokenDetailsFrom(transaction: OperationTransaction) -> (tokenContract: String, rpcAmount: String, tokenId: Decimal?, destination: String)?
  • Helper to call faTokenDetailsFrom(transaction: OperationTransaction) on the first OperationTransaction in an array of operations. Allows to more easily parse an array of operations that may include approval‘s or update_operator calls

    Declaration

    Swift

    public static func faTokenDetailsFrom(operations: [Operation]) -> (tokenContract: String, rpcAmount: String, tokenId: Decimal?, destination: String)?
  • Return true if

    • contains 1 operation with a non-zero amount, with no parameters

    Declaration

    Swift

    public static func isTezTransfer(operations: [Operation]) -> Bool
  • Easy way to extract the first non-approval or update_operator transaction

    Declaration

    Swift

    public static func firstTransferEntrypointOperation(operations: [Operation]) -> OperationTransaction?
  • Return the entrypoint and address of the first operation, that doesn’t equal approve, update_operator or transfer

    Declaration

    Swift

    public static func isContractCall(operations: [Operation]) -> (entrypoint: String, address: String)?
  • Return the first operation where entrypoint doesn’t equal approve, update_operator or transfer

    Declaration

    Swift

    public static func firstContractCallOperation(operations: [Operation]) -> OperationTransaction?
  • Run through list of operations and extract .amount from any OperationTransaction

    Declaration

    Swift

    public static func totalXTZAmountForContractCall(operations: [Operation]) -> XTZAmount