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

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

pending completion
5722694066

push

github

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

add storage transactions support

1167 of 2568 branches covered (45.44%)

Branch coverage included in aggregate %.

1604 of 1604 new or added lines in 66 files covered. (100.0%)

8621 of 11167 relevant lines covered (77.2%)

155987.71 hits per line

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

13.64
/src/model/transaction/storage/DataModificationSingleApprovalTransaction.ts
1
/*
2
 * Copyright 2023 ProximaX
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
import { PublicAccount } from '../../account/PublicAccount';
17
import { NetworkType } from '../../blockchain/NetworkType';
18
import { UInt64 } from '../../UInt64';
19
import { Deadline } from '../Deadline';
20
import { Transaction, TransactionBuilder } from '../Transaction';
1✔
21
import { TransactionInfo } from '../TransactionInfo';
22
import { TransactionType } from '../TransactionType';
1✔
23
import { TransactionTypeVersion } from '../TransactionTypeVersion';
24
import { calculateFee } from '../FeeCalculationStrategy';
25
import { Convert } from '../../../core/format/Convert';
26

27
export class DataModificationSingleApprovalTransaction extends Transaction {
1✔
28

29
    /**
30
     * @param networkType
31
     * @param version
32
     * @param deadline
33
     * @param maxFee
34
     * @param driveKey - Public key of the drive
35
     * @param dataModificationId hash
36
     * @param publicKeysCount
37
     * @param publicKeys
38
     * @param opinions uint64[]
39
     * @param signature
40
     * @param signer
41
     * @param transactionInfo
42
     */
43
    constructor(networkType: NetworkType,
44
                version: number,
45
                deadline: Deadline,
46
                maxFee: UInt64,
47
                public readonly driveKey: PublicAccount,
×
48
                public readonly dataModificationId: string, // hash
×
49
                public readonly publicKeysCount: number, // uint8
×
50
                public readonly publicKeys: PublicAccount[],
×
51
                public readonly opinions: UInt64[],
×
52
                signature?: string,
53
                signer?: PublicAccount,
54
                transactionInfo?: TransactionInfo) {
55

56
        super(TransactionType.Data_Modification_Single_Approval,
×
57
              networkType, version, deadline, maxFee, signature, signer, transactionInfo);
58
    
59
    }
60

61
    /**
62
     * @override Transaction.size()
63
     * @description get the byte size of a DataModificationSingleApprovalTransaction
64
     * @returns {number}
65
     * @memberof DataModificationSingleApprovalTransaction
66
     */
67
    public get size(): number {
68
        return DataModificationSingleApprovalTransaction.calculateSize(this.publicKeys.length, this.opinions.length);
×
69
    }
70

71
    public static calculateSize(publicKeysCount: number, opinionsCount: number): number {
72
        const baseByteSize = Transaction.getHeaderSize();
×
73

74
        // set static byte size fields
75
        const driveKeySize = 32;
×
76
        const dataModificationId = 32;
×
77
        const publicKeysCountSize = 1;
×
78
        const publicKeysSize = 32 * publicKeysCount;
×
79
        const opinionsSize = 8 * opinionsCount;
×
80

81
        return baseByteSize + driveKeySize + dataModificationId + publicKeysCountSize + publicKeysSize + opinionsSize;
×
82
    }
83

84
    /**
85
     * @override Transaction.toJSON()
86
     * @description Serialize a transaction object - add own fields to the result of Transaction.toJSON()
87
     * @return {Object}
88
     * @memberof DataModificationSingleApprovalTransaction
89
     */
90
    public toJSON() {
91
        const parent = super.toJSON();
×
92
        return {
×
93
            ...parent,
94
            transaction: {
95
                ...parent.transaction,
96
                driveKey: this.driveKey.toDTO(),
97
                dataModificationId: this.dataModificationId,
98
                publicKeysCount: this.publicKeysCount,
99
                publicKeys: this.publicKeys.map((pa)=> pa.publicKey),
×
100
                opinions: this.opinions.map((data)=> data.toBigInt())
×
101
            }
102
        }
103
    }
104

105
    /**
106
     * @internal
107
     * @returns {never}
108
     */
109
    protected buildTransaction(): never {
110
        throw new Error("Not yet implemented")
×
111
    }
112
}
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