• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

proximax-storage / tsjs-xpx-chain-sdk / 8778928347

22 Apr 2024 05:20AM UTC coverage: 67.306% (-3.7%) from 71.021%
8778928347

push

github

web-flow
Merge pull request #172 from proximax-storage/next

Add new transactions and new node API fetch

1207 of 2739 branches covered (44.07%)

Branch coverage included in aggregate %.

359 of 1167 new or added lines in 63 files covered. (30.76%)

2 existing lines in 1 file now uncovered.

8977 of 12392 relevant lines covered (72.44%)

140180.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.88
/src/model/transaction/NetworkConfigAbsoluteHeightTransaction.ts
1
// Copyright 2019 ProximaX Limited. All rights reserved.
2
// Use of this source code is governed by the Apache 2.0
3
// license that can be found in the LICENSE file
4

5
import { Transaction, TransactionBuilder } from './Transaction';
1✔
6
import { TransactionType } from './TransactionType';
1✔
7
import { NetworkType } from '../blockchain/NetworkType';
8
import { Deadline } from './Deadline';
9
import { UInt64 } from '../UInt64';
10
import { PublicAccount } from '../account/PublicAccount';
11
import { TransactionInfo } from './TransactionInfo';
12
import { Builder } from '../../infrastructure/builders/NetworkConfigAbsoluteHeightTransaction';
1✔
13
import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction';
14
import { TransactionTypeVersion } from './TransactionTypeVersion';
1✔
15
import { calculateFee, FeeCalculationStrategy } from './FeeCalculationStrategy';
1✔
16

17
export class NetworkConfigAbsoluteHeightTransaction extends Transaction {
1✔
18
    /**
19
     * @param networkType
20
     * @param version
21
     * @param deadline
22
     * @param maxFee
23
     * @param applyHeight
24
     * @param networkConfig,
25
     * @param supportedEntityVersions,
26
     * @param signature
27
     * @param signer
28
     * @param transactionInfo
29
     */
30
    constructor(networkType: NetworkType,
31
        version: number,
32
        deadline: Deadline,
33
        maxFee: UInt64,
NEW
34
        public readonly applyHeight: UInt64,
×
NEW
35
        public readonly networkConfig: string,
×
NEW
36
        public readonly supportedEntityVersions: string,
×
37
        signature?: string,
38
        signer?: PublicAccount,
39
        transactionInfo?: TransactionInfo) {
NEW
40
            super(TransactionType.NetworkConfig_Absolute_Height, networkType, version, deadline, maxFee, signature, signer, transactionInfo);
×
41
    }
42

43
    public static create(deadline: Deadline,
44
        applyHeight: UInt64,
45
        networkConfig: string,
46
        supportedEntityVersions: string,
47
        networkType: NetworkType,
48
        maxFee?: UInt64): NetworkConfigAbsoluteHeightTransaction {
NEW
49
        return new NetworkConfigAbsoluteHeightTransactionBuilder()
×
50
            .networkType(networkType)
51
            .deadline(deadline)
52
            .maxFee(maxFee)
53
            .applyHeight(applyHeight)
54
            .networkConfig(networkConfig)
55
            .supportedEntityVersions(supportedEntityVersions)
56
            .build();
57
    }
58

59
    /**
60
     * @override Transaction.size()
61
     * @description get the byte size of a transaction
62
     * @returns {number}
63
     * @memberof Transaction
64
     */
65
    public get size(): number {
NEW
66
        return NetworkConfigAbsoluteHeightTransaction.calculateSize(this.networkConfig.length, this.supportedEntityVersions.length);
×
67
    }
68

69
    public static calculateSize(networkConfigLength: number, supportedEntityVersionsLength: number): number {
NEW
70
        const byteSize = Transaction.getHeaderSize()
×
71
            + 8 // applyHeight
72
            + 2 // networkConfigSize
73
            + 2 // supportedEntityVersionsSize
74
            + networkConfigLength //networkConfig
75
            + supportedEntityVersionsLength // supportedEntityVersions
NEW
76
        return byteSize;
×
77
    }
78

79
    /**
80
     * @override Transaction.toJSON()
81
     * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON()
82
     * @return {Object}
83
     * @memberof NetworkConfigAbsoluteHeightTransaction
84
     */
85
    public toJSON() {
NEW
86
        const parent = super.toJSON();
×
NEW
87
        return {
×
88
            ...parent,
89
            transaction: {
90
                ...parent.transaction,
91
                applyHeight: this.applyHeight.toDTO(),
92
                networkConfig: this.networkConfig,
93
                supportedEntityVersions: this.supportedEntityVersions
94
            }
95
        }
96
    }
97

98
    /**
99
    * @internal
100
    * @returns {VerifiableTransaction}
101
    */
102
    protected buildTransaction(): VerifiableTransaction {
NEW
103
        return new Builder()
×
104
            .addSize(this.size)
105
            .addDeadline(this.deadline.toDTO())
106
            .addMaxFee(this.maxFee.toDTO())
107
            .addVersion(this.versionToDTO())
108
            .addApplyHeight(this.applyHeight.toDTO())
109
            .addNetworkConfig(this.networkConfig)
110
            .addSupportedEntityVersions(this.supportedEntityVersions)
111
            .build();
112
    }
113
}
114

115
export class NetworkConfigAbsoluteHeightTransactionBuilder extends TransactionBuilder {
1✔
116
    private _applyHeight: UInt64;
117
    private _networkConfig: string;
118
    private _supportedEntityVersions: string;
119

120
    constructor() {
NEW
121
        super();
×
122
    }
123

124
    public applyHeight(applyHeight: UInt64) {
NEW
125
        this._applyHeight = applyHeight;
×
NEW
126
        return this;
×
127
    }
128

129
    public networkConfig(networkConfig: string) {
NEW
130
        this._networkConfig = networkConfig;
×
NEW
131
        return this;
×
132
    }
133

134
    public supportedEntityVersions(supportedEntityVersions: string) {
NEW
135
        this._supportedEntityVersions = supportedEntityVersions;
×
NEW
136
        return this;
×
137
    }
138

139
    public build(): NetworkConfigAbsoluteHeightTransaction {
NEW
140
        return new NetworkConfigAbsoluteHeightTransaction(
×
141
            this._networkType,
142
            this._version || TransactionTypeVersion.NetworkConfig_Absolute_Height,
×
143
            this._deadline ? this._deadline : this._createNewDeadlineFn(),
×
144
            this._maxFee ? this._maxFee : calculateFee(NetworkConfigAbsoluteHeightTransaction.calculateSize(this._networkConfig.length, this._supportedEntityVersions.length), this._feeCalculationStrategy),
×
145
            this._applyHeight,
146
            this._networkConfig,
147
            this._supportedEntityVersions,
148
            this._signature,
149
            this._signer,
150
            this._transactionInfo
151
        );
152
    }
153
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc