All files / src/endpoints/market v2.ts

100% Statements 13/13
87.5% Branches 7/8
100% Functions 5/5
100% Lines 13/13

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 107171x     1x 1x 1x                                                                                                     1x 12x     1x   1x                   1x   1x                                         1x   1x               1x  
import type {APIClient} from '@wharfkit/antelope'
import type {Float64Type, Int32Type, NameType, UInt64Type} from '@wharfkit/antelope'
import type {SaleState} from '../../types'
import {CountResponseStruct} from '../../types'
import * as Market from './types'
import {buildBodyParams, pathSegment} from '../utils'
 
export interface GetSalesOptions {
    state?: SaleState[]
    hide_templates_by_accounts?: NameType[]
    max_assets?: UInt64Type
    min_assets?: UInt64Type
    show_seller_contracts?: boolean
    contract_whitelist?: NameType[]
    seller_blacklist?: NameType[]
    buyer_blacklist?: NameType[]
    asset_id?: UInt64Type[]
    marketplace?: string[]
    maker_marketplace?: string[]
    taker_marketplace?: string[]
    symbol?: string
    account?: NameType[]
    seller?: NameType[]
    buyer?: NameType[]
    min_price?: Float64Type
    max_price?: Float64Type
    min_template_mint?: UInt64Type
    max_template_mint?: UInt64Type
    collection_name?: NameType[]
    schema_name?: NameType[]
    template_id?: Int32Type[]
    burned?: boolean
    owner?: NameType[]
    match?: string
    search?: string
    match_immutable_name?: string
    match_mutable_name?: string
    is_transferable?: boolean
    is_burnable?: boolean
    minter?: NameType[]
    burner?: NameType[]
    initial_receiver?: NameType[]
    collection_blacklist?: NameType[]
    collection_whitelist?: NameType[]
    sale_id?: UInt64Type[]
    ids?: UInt64Type[]
    lower_bound?: string
    upper_bound?: string
    before?: number
    after?: number
    page?: number
    limit?: number
    order?: 'asc' | 'desc'
    sort?: 'created' | 'updated' | 'sale_id' | 'price' | 'template_mint' | 'name'
}
 
export class MarketV2APIClient {
    constructor(private client: APIClient) {}
 
    async get_sales(options?: GetSalesOptions, extra_options?: {[key: string]: string}) {
        const bodyParams = buildBodyParams(options, extra_options)
 
        return this.client.call({
            path: `/atomicmarket/v2/sales`,
            method: 'POST',
            params: bodyParams,
            headers: {'Content-Type': 'application/json'},
            responseType: Market.GetSalesResponse,
        })
    }
 
    async get_sales_count(options?: GetSalesOptions, extra_options?: {[key: string]: string}) {
        const bodyParams = buildBodyParams(options, extra_options)
 
        return this.client.call({
            path: `/atomicmarket/v2/sales/_count`,
            method: 'POST',
            params: bodyParams,
            headers: {'Content-Type': 'application/json'},
            responseType: CountResponseStruct,
        })
    }
 
    async get_stats_schemas(
        collection_name: NameType,
        options: {
            symbol: string
            before?: number
            after?: number
            page?: number
            limit?: number
            order?: 'asc' | 'desc'
            sort?: 'volume' | 'sales'
        }
    ) {
        const bodyParams = buildBodyParams(options)
 
        return this.client.call({
            path: `/atomicmarket/v2/stats/schemas/${pathSegment(collection_name)}`,
            method: 'POST',
            params: bodyParams,
            headers: {'Content-Type': 'application/json'},
            responseType: Market.GetStatsSchemasV2Response,
        })
    }
}