All files abi.ts

100% Statements 62/62
80% Branches 8/10
100% Functions 6/6
100% Lines 38/38

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 103421x                         1x   1x     1x     1x     1x 1x       1x 1x 1x       1x         1x         1x         38x     23x       8x     7x       30x   22x   8x           1x 1x 1x       1x 1x 1x 1x 1x 1x       1x 1x 1x 1x 1x 1x       2x 1x 1x    
/** SigningRequest ABI and typedefs. */
 
import {
    Action,
    Bytes,
    Name,
    PermissionLevel,
    Signature,
    Struct,
    Transaction,
    TypeAlias,
    UInt8,
    Variant,
} from '@wharfkit/antelope'
 
import {ChainIdVariant} from './chain-id'
 
@TypeAlias('account_name')
export class AccountName extends Name {}
 
@TypeAlias('permission_name')
export class PermissionName extends Name {}
 
@Struct.type('identity')
export class IdentityV2 extends Struct {
    @Struct.field(PermissionLevel, {optional: true}) permission?: PermissionLevel
}
 
@Struct.type('identity')
export class IdentityV3 extends Struct {
    @Struct.field('name') scope!: Name
    @Struct.field(PermissionLevel, {optional: true}) permission?: PermissionLevel
}
 
@Variant.type('variant_req', [Action, {type: Action, array: true}, Transaction, IdentityV2])
export class RequestVariantV2 extends Variant {
    value!: Action | Action[] | Transaction | IdentityV2
}
 
@Variant.type('variant_req', [Action, {type: Action, array: true}, Transaction, IdentityV3])
export class RequestVariantV3 extends Variant {
    value!: Action | Action[] | Transaction | IdentityV3
}
 
@TypeAlias('request_flags')
export class RequestFlags extends UInt8 {
    static broadcast = 1 << 0
    static background = 1 << 1
 
    get broadcast() {
        return (Number(this) & RequestFlags.broadcast) !== 0
    }
    set broadcast(enabled: boolean) {
        this.setFlag(RequestFlags.broadcast, enabled)
    }
 
    get background() {
        return (Number(this) & RequestFlags.background) !== 0
    }
    set background(enabled: boolean) {
        this.setFlag(RequestFlags.background, enabled)
    }
 
    private setFlag(flag: number, enabled: boolean) {
        if (enabled) {
            // TODO: implement bitwise operators in core, bn.js setbit does not work
            this.value = UInt8.from(Number(this) | flag).value
        } else {
            this.value = UInt8.from(Number(this) & ~flag).value
        }
    }
}
 
@Struct.type('info_pair')
export class InfoPair extends Struct {
    @Struct.field('string') key!: string
    @Struct.field('bytes') value!: Bytes
}
 
@Struct.type('signing_request')
export class RequestDataV2 extends Struct {
    @Struct.field(ChainIdVariant) chain_id!: ChainIdVariant
    @Struct.field(RequestVariantV2) req!: RequestVariantV2
    @Struct.field(RequestFlags) flags!: RequestFlags
    @Struct.field('string') callback!: string
    @Struct.field(InfoPair, {array: true}) info!: InfoPair[]
}
 
@Struct.type('signing_request')
export class RequestDataV3 extends Struct {
    @Struct.field(ChainIdVariant) chain_id!: ChainIdVariant
    @Struct.field(RequestVariantV3) req!: RequestVariantV3
    @Struct.field(RequestFlags) flags!: RequestFlags
    @Struct.field('string') callback!: string
    @Struct.field(InfoPair, {array: true}) info!: InfoPair[]
}
 
@Struct.type('request_signature')
export class RequestSignature extends Struct {
    @Struct.field('name') signer!: Name
    @Struct.field('signature') signature!: Signature
}