Interface TokenSelection

  • All Implemented Interfaces:

    @DoNotImplement() 
    public interface TokenSelection
    
                        

    Defines a mechanism to allow flows to query the token cache. The query can be either to claim a list of ClaimedToken to spend, or to know the current balance, TokenBalance.

    The platform will provide an instance of TokenSelection to flows via property injection.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • tryClaim

        @Nullable()@Suspendable() abstract TokenClaim tryClaim(@NotNull() TokenClaimCriteria criteria)

        Attempts to claim a set of tokens from the cache that satisfies the specified TokenClaimCriteria. The API allows a flow to query for a target amount of a given state/token type it wishes to spend. If available, a set of tokens will be selected that sum to at least the target amount specified. The tokens will be locked in the cache to prevent other flows from selecting them.

        Parameters:
        criteria - The TokenClaimCriteria used to select tokens.
      • queryBalance

        @Nullable()@Suspendable() abstract TokenBalance queryBalance(@NotNull() TokenBalanceCriteria criteria)

        Calculates the balance of a pool of tokens taking into account only the tokens that satisfy the specified TokenBalanceCriteria. The API allows a flow to query the balance of a set or subset of tokens. Two values are calculated when the query is executed. One represents the available balance which only includes tokens that have not been spent nor claimed. While the other value represents the total balance which includes all tokens that have not been spent, i.e., the total balance is the available balance plus the balance of all claimed tokens.

        Parameters:
        criteria - The TokenBalanceCriteria used to select the tokens that should be used to calculate the balance.