Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | 58x 1x 1x 1x 1x 1x 19x 19x 19x 19x 19x 19x 19x 19x 13x 3x 2x 1x 1x 1x 1x 1x 4x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import type {Action, AssetType, NameType} from '@wharfkit/antelope' import {Asset as AntelopeAsset, ExtendedAsset, Name, UInt64} from '@wharfkit/antelope' import type {AuctionObject} from '../types' import {AuctionState} from '../types' import {Collection} from './collection' import {Asset} from './asset' import type {KitUtility} from '../utility' export class Auction { readonly data: AuctionObject readonly collection: Collection readonly assets: Asset[] readonly price: ExtendedAsset readonly utility: KitUtility static from(auctionObject: AuctionObject, utility: KitUtility) { const collection = new Collection(utility, auctionObject.collection) const assets = auctionObject.assets.map((a) => Asset.from(a, utility)) return new this(utility, auctionObject, collection, assets) } constructor(utility: KitUtility, data: AuctionObject, collection: Collection, assets: Asset[]) { this.utility = utility this.data = data this.collection = collection this.assets = assets this.price = ExtendedAsset.from({ quantity: AntelopeAsset.fromUnits( this.data.price.amount, AntelopeAsset.Symbol.from( `${this.data.price.token_precision},${this.data.price.token_symbol}` ) ), contract: this.data.price.token_contract, }) } get auctionId() { return UInt64.from(this.data.auction_id) } get seller() { return Name.from(this.data.seller) } get buyer() { return this.data.buyer ? Name.from(this.data.buyer) : null } get endTime() { return this.data.end_time } get bids() { return this.data.bids } get state() { return AuctionState[AuctionState[this.data.state.toNumber()]] } get claimedBySeller() { return this.data.claimed_by_seller } get claimedByBuyer() { return this.data.claimed_by_buyer } /** * Always a Name, unlike takerMarketplace, which is null until a listing * executes. A maker marketplace is fixed when the listing is created, and * the API reports the default marketplace as null rather than the empty * name it holds on chain. */ get makerMarketplace() { return Name.from(this.data.maker_marketplace ?? '') } get takerMarketplace() { return this.data.taker_marketplace ? Name.from(this.data.taker_marketplace) : null } get isSellerContract() { return this.data.is_seller_contract } assert(): Action { return this.utility.marketContract.action('assertauct', { auction_id: this.auctionId, asset_ids_to_assert: this.assets.map((a) => a.assetId), }) } claimBuy(): Action { return this.utility.marketContract.action('auctclaimbuy', { auction_id: this.auctionId, }) } claimSell(): Action { return this.utility.marketContract.action('auctclaimsel', { auction_id: this.auctionId, }) } bid(bidder: NameType, bid: AssetType, takerMarketplace: NameType): Action { return this.utility.marketContract.action('auctionbid', { bidder, auction_id: this.auctionId, bid, taker_marketplace: takerMarketplace, }) } cancel(): Action { return this.utility.marketContract.action('cancelauct', { auction_id: this.auctionId, }) } payram(payer: NameType): Action { return this.utility.marketContract.action('payauctram', { payer, auction_id: this.auctionId, }) } } |