All files / src utility.ts

100% Statements 15/15
83.33% Branches 15/18
100% Functions 2/2
100% Lines 14/14

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 43134x       1x   1x 1x 1x                   1x                   18x 18x 18x 18x     18x   18x   18x     1x  
import {APIClient, FetchProvider} from '@wharfkit/antelope'
import type {Contract} from '@wharfkit/contract'
import type {ChainDefinition} from '@wharfkit/common'
 
import {AtomicAssetsAPIClient} from './endpoints'
 
import * as AtomicAssetsContract from './contracts/atomicassets'
import * as AtomicMarketContract from './contracts/atomicmarket'
import * as AtomicToolsContract from './contracts/atomictoolsx'
 
export interface KitOptions {
    assetsContract?: Contract
    marketContract?: Contract
    toolsContract?: Contract
    client?: APIClient
    atomicClient?: AtomicAssetsAPIClient
}
 
export class KitUtility {
    readonly url: string
    readonly chain: ChainDefinition
    readonly client: APIClient
    readonly atomicClient: AtomicAssetsAPIClient
    readonly assetsContract: Contract
    readonly marketContract: Contract
    readonly toolsContract: Contract
 
    constructor(url: string, chain: ChainDefinition, options?: KitOptions) {
        this.url = url
        this.chain = chain
        this.client = options?.client || new APIClient({url: this.chain.url})
        this.atomicClient =
            options?.atomicClient ||
            new AtomicAssetsAPIClient(new APIClient({provider: new FetchProvider(this.url)}))
        this.assetsContract =
            options?.assetsContract || new AtomicAssetsContract.Contract({client: this.client})
        this.marketContract =
            options?.marketContract || new AtomicMarketContract.Contract({client: this.client})
        this.toolsContract =
            options?.toolsContract || new AtomicToolsContract.Contract({client: this.client})
    }
}