All files / src/objects template.ts

95% Statements 19/20
75% Branches 6/8
90% Functions 9/10
95% Lines 19/20

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 59274x 1x   1x 1x     1x             9x 9x 9x       127x 127x 127x 127x       7x       1x       1x       1x       2x               1x           1x  
import type {Action, NameType} from '@wharfkit/antelope'
import {Int32, UInt32} from '@wharfkit/antelope'
import type {TemplateObject} from '../types'
import {Collection} from './collection'
import {Schema} from './schema'
import type {KitUtility} from '../utility'
 
export class Template {
    readonly data: TemplateObject
    readonly collection: Collection
    readonly schema: Schema
    readonly utility: KitUtility
 
    static from(templateObject: TemplateObject, utility: KitUtility) {
        const collection = new Collection(utility, templateObject.collection)
        const schema = new Schema(utility, templateObject.schema, collection)
        return new this(utility, templateObject, collection, schema)
    }
 
    constructor(utility: KitUtility, data: TemplateObject, collection: Collection, schema: Schema) {
        this.utility = utility
        this.data = data
        this.collection = collection
        this.schema = schema
    }
 
    get templateId() {
        return Int32.from(this.data.template_id)
    }
 
    get transferable() {
        return this.data.is_transferable
    }
 
    get burnable() {
        return this.data.is_burnable
    }
 
    get issuedSupply() {
        return UInt32.from(this.data.issued_supply)
    }
 
    get maxSupply() {
        return UInt32.from(this.data.max_supply)
    }
 
    get immutableData() {
        return this.data.immutable_data
    }
 
    lock(authorizedEditor: NameType): Action {
        return this.utility.assetsContract.action('locktemplate', {
            authorized_editor: authorizedEditor,
            collection_name: this.collection.collectionName,
            template_id: this.templateId,
        })
    }
}