-
Notifications
You must be signed in to change notification settings - Fork 2
/
Transaction.ts
44 lines (36 loc) · 955 Bytes
/
Transaction.ts
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
import { Block, BlockType } from './Block';
import { SigPublicKey } from './Keys';
import { StorageId } from './Storage';
import { AssetSymbol } from './Blockchain';
export class Transaction {
id: StorageId;
blocks: Block[] = [];
constructor(symbol?: AssetSymbol) {
this.assetSymbol = symbol || AssetSymbol.TXL;
}
/**
* Is always the public signature key of the related blockchain.
*/
publicSig: SigPublicKey;
/**
* Network slot when the transaction was accepted.
*/
slot: number;
/**
* Unix timestamp when the tx was accepted.
*/
networkApprovalAt?: number;
/**
* Explicitly use this asset.
*/
assetSymbol: AssetSymbol;
/**
* Return true if transaction wants to create a new blockchain.
*/
containsOpeningBlock(): boolean {
if (!Array.isArray(this.blocks)) {
return false;
}
return this.blocks.some((block) => block.type === BlockType.OPENING && !block.prev);
}
}