All files / src/objects collection.ts

100% Statements 25/25
75% Branches 6/8
100% Functions 21/21
100% Lines 23/23

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 104432x 1x         1x         17x       206x 206x       28x       3x       3x       76x       18x       3x       6x       1x       1x       1x             1x             1x             1x             1x             1x             1x       1x  
import type {Action, Float64Type, NameType} from '@wharfkit/antelope'
import {Float64, Name} from '@wharfkit/antelope'
import type {CollectionObject} from '../types'
import type * as AtomicAssetsContract from '../contracts/atomicassets'
import type {KitUtility} from '../utility'
 
export class Collection {
    readonly data: CollectionObject
    readonly utility: KitUtility
 
    static from(collectionObject: CollectionObject, utility: KitUtility) {
        return new this(utility, collectionObject)
    }
 
    constructor(utility: KitUtility, data: CollectionObject) {
        this.utility = utility
        this.data = data
    }
 
    get collectionName() {
        return Name.from(this.data.collection_name)
    }
 
    get author() {
        return Name.from(this.data.author)
    }
 
    get allowNotify() {
        return this.data.allow_notify
    }
 
    get authorizedAccounts() {
        return this.data.authorized_accounts.map((a) => Name.from(a))
    }
 
    get notifyAccounts() {
        return this.data.notify_accounts.map((a) => Name.from(a))
    }
 
    get marketFee() {
        return Float64.from(this.data.market_fee)
    }
 
    get collectionData() {
        return this.data.data
    }
 
    get name() {
        return this.data.name
    }
 
    get image() {
        return this.data.img
    }
 
    addAuth(account: NameType): Action {
        return this.utility.assetsContract.action('addcolauth', {
            collection_name: this.collectionName,
            account_to_add: account,
        })
    }
 
    removeAuth(account: NameType): Action {
        return this.utility.assetsContract.action('remcolauth', {
            collection_name: this.collectionName,
            account_to_remove: account,
        })
    }
 
    setData(data: AtomicAssetsContract.ActionParams.Type.pair_string_ATOMIC_ATTRIBUTE[]): Action {
        return this.utility.assetsContract.action('setcoldata', {
            collection_name: this.collectionName,
            data,
        })
    }
 
    addNotifyAccount(account: NameType): Action {
        return this.utility.assetsContract.action('addnotifyacc', {
            collection_name: this.collectionName,
            account_to_add: account,
        })
    }
 
    removeNotifyAccount(account: NameType): Action {
        return this.utility.assetsContract.action('remnotifyacc', {
            collection_name: this.collectionName,
            account_to_remove: account,
        })
    }
 
    setMarketFee(fee: Float64Type): Action {
        return this.utility.assetsContract.action('setmarketfee', {
            collection_name: this.collectionName,
            market_fee: fee,
        })
    }
 
    forbidnotify(): Action {
        return this.utility.assetsContract.action('forbidnotify', {
            collection_name: this.collectionName,
        })
    }
}