Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PersistentMarket

Hierarchy

  • PersistentMarket

Index

Constructors

Methods

Constructors

constructor

  • Parameters

    • prefix: string

      A prefix to use for every key of this map

    Returns PersistentMarket

Methods

add

  • add(tokenId: TokenId, accountId: AccountId, bid: Bid): void
  • Add a bid to the given token

    Basic usage example:

    Assume an account/user with account id = alice.test.near, want to add the bid B1, to the token with token id = jenny911038,

    const persistent_market = new PersistentMarket('pm')
    persistent_market.add("jenny911038" , "alice.test.near", B1 );
    

    Note: This overwrites any present bids.

    Parameters

    • tokenId: TokenId

      Id of the token

    • accountId: AccountId

      ID of the account who sets the bid

    • bid: Bid

      Bid to be added to the token and account/user

    Returns void

get

  • Get bids for a given token

    Basic usage example:

    Assume we need to get the bids for the token with token id = jenny911038,

    const persistent_market = new PersistentMarket('pm')
    const bids = persistent_market.get("jenny911038");
    

    Parameters

    • tokenId: TokenId

      ID of the token

    Returns BidsByBidder

    A Map of TokenId to Bid

get_by_bidder

  • get_by_bidder(accountId: AccountId): Bid[]
  • Get bids created by a given account/user

    Basic usage example:

    Assume we need to get the bids created by account/user with account id = alice.test.near,

    const persistent_market = new PersistentMarket('pm')
    const bids = persistent_market.get_by_bidder("alice.test.near");
    

    Parameters

    • accountId: AccountId

      ID of the account/user to retrieve bids

    Returns Bid[]

    An Array of bids made by the given account/user

has

  • has(token_id: TokenId): bool
  • Check if the relevant token has bids or not

    Basic usage example:

    Assume we need to check if the token with token id = jenny911038 has bids,

    const persistent_market = new PersistentMarket('pm')
    const is_bids_exists = persistent_market.has("jenny911038");
    

    Parameters

    • token_id: TokenId

      ID of the token to check

    Returns bool

    true if bids exists, false otherwise

remove

  • remove(tokenId: TokenId, accountId: AccountId): void
  • Remove a bid from a given token

    Basic usage example:

    Assume an account/user with account id = alice.test.near, want to remove the bid he made to the token with token id = jenny911038,

    const persistent_market = new PersistentMarket('pm')
    persistent_market.remove("jenny911038" , "alice.test.near");
    

    Parameters

    • tokenId: TokenId

      Id of the token

    • accountId: AccountId

      ID of the account

    Returns void

Generated using TypeDoc