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
-
Filter reveal operation (if present), and check if what remains is a single OperationTransaction Useful for other functions, such as checking if the list of operations is a single XTZ or token transfer
Declaration
Swift
public static func isSingleTransaction(operations: [Operation]) -> OperationTransaction?
-
Filter and verify only 1 transaction exists thats sending XTZ. If so return this operation, otherwise return false
Declaration
Swift
public static func isTezTransfer(operations: [Operation]) -> OperationTransaction?
-
Filter and verify only 1 transaction exists thats setting a baker. If so return this operation, otherwise return false
Declaration
Swift
public static func isDelegate(operations: [Operation]) -> OperationDelegation?
-
Filter and verify only 1 transaction exists thats sending a token. If so return this operation, otherwise return false
Declaration
Swift
public static func isFaTokenTransfer(operations: [Operation]) -> (operation: OperationTransaction, tokenContract: String, rpcAmount: String, tokenId: Decimal?, destination: String)?
-
Filter and verify only 1 transaction exists its not a transfer operation. If so return this operation, otherwise return false
Declaration
Swift
public static func isSingleContractCall(operations: [Operation]) -> (operation: OperationTransaction, entrypoint: String, address: String)?
-
Extract details from a transfer payload in order to present to the user what it is they are trying to send
Declaration
Swift
public static func faTokenDetailsFromTransfer(transaction: OperationTransaction) -> (tokenContract: String, rpcAmount: String, tokenId: Decimal?, destination: String)?
-
Extract rpc amount (without decimal info) a tokenId, and the destination from a michelson
approve
valueDeclaration
Swift
public static func tokenIdAndAmountFromApproveMichelson(michelson: Any) -> (rpcAmount: String, tokenId: Decimal?, destination: String)?
-
Extract a tokenId, and the destination from a michelson
update_operators
valueDeclaration
Swift
public static func tokenIdFromUpdateOperatorsMichelson(michelson: Any) -> (tokenId: Decimal?, destination: String)?
-
Extract rpc amount (without decimal info) michelson
execute
value for a 3route callDeclaration
Swift
public static func tokenAmountFromExecuteMichelson(michelson: Any, contract: String) -> Decimal?
-
Extract rpc amount (without decimal info) michelson
deposit
value for a crunchy stake callDeclaration
Swift
public static func tokenAmountFromDepositMichelson(michelson: Any) -> Decimal?
-
Extract rpc amount (without decimal info) michelson
offer
value for a OBJKT offer callDeclaration
Swift
public static func tokenAmountFromOfferMichelson(michelson: Any) -> Decimal?
-
Extract rpc amount (without decimal info) michelson
offer
value for a OBJKT offer callDeclaration
Swift
public static func tokenAmountFromBidMichelson(michelson: Any) -> Decimal?
-
Extract rpc amount (without decimal info) a tokenId, and the destination from a michelson FA1.2 / FA2 transfer payload
Declaration
Swift
public static func tokenIdAndAmountFromTransferMichelson(michelson: Any) -> (rpcAmount: String, tokenId: Decimal?, destination: String)?
-
Extract rpc amount (without decimal info) a tokenId, and the destination from a michelson Supports:
- FA1.2 transfer
- FA2 transfer
- 3Route
- Approve operation
- update_operator operation
Declaration
Swift
public static func tokenIdAndAmountFromMichelson(michelson: Any, contract: String) -> (rpcAmount: String, tokenId: Decimal?, destination: String?)?
-
Run through list of operations and extract the first valid
faTokenDetailsFrom(transaction: ...)
In the case of hitting anupdate_operators
, will check for the next transaction to see if it contains the amount Useful for displaying the main token being swapped in a dex aggregator callDeclaration
Swift
public static func firstNonZeroTokenTransferAmount(operations: [Operation]) -> (tokenContract: String, rpcAmount: String, tokenId: Decimal?, destination: String)?
-
Check if the array is only of type OperationTransaction, optionally ignore reveal as its usually supressed from user Useful in situations where you are displaying batch information but can only handle certain opertion types
Declaration
Swift
public static func containsAllOperationTransactions(operations: [Operation], ignoreReveal: Bool = true) -> Bool
-
Check if the array is contains at least 1 OperationUnknown Useful in situations to display fallback UI for unknown cases
Declaration
Swift
public static func containsAnUnknownOperation(operations: [Operation]) -> Bool
-
Check if the operation is a contract call, but ignore entrypoint trasnfer Useful for situations where you want to display different info about contract calls such as claim or mint, compared to transferring a token Return the entrypoint and contract address if so
Declaration
Swift
public static func isNonTransferContractCall(operation: Operation) -> (operation: OperationTransaction, entrypoint: String, address: String)?
-
Check if the operation is a contract call, return the entrypoint and address if so, nil if not
Declaration
Swift
public static func isContractCall(operation: Operation) -> (operation: OperationTransaction, entrypoint: String, address: String)?