All files / src powerup.ts

100% Statements 17/17
75% Branches 6/8
100% Functions 3/3
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 2987x     1x 1x     1x 1x 1x 1x 1x 1x     1x 7x     31x           31x   1x  
import {Asset, Struct, UInt32, UInt8} from '@wharfkit/antelope'
 
import {Resources} from '.'
import {PowerUpStateResourceCPU} from './powerup/cpu'
import {PowerUpStateResourceNET} from './powerup/net'
 
@Struct.type('powerupstate')
export class PowerUpState extends Struct {
    @Struct.field('uint8') version!: UInt8
    @Struct.field(PowerUpStateResourceNET) net!: PowerUpStateResourceNET
    @Struct.field(PowerUpStateResourceCPU) cpu!: PowerUpStateResourceCPU
    @Struct.field('uint32') powerup_days!: UInt32
    @Struct.field('asset') min_powerup_fee!: Asset
}
 
export class PowerUpAPI {
    constructor(private parent: Resources) {}
 
    async get_state(): Promise<PowerUpState> {
        const response = await this.parent.api.v1.chain.get_table_rows({
            code: 'eosio',
            scope: '',
            table: 'powup.state',
            type: PowerUpState,
        })
        return response.rows[0]
    }
}