@mainsail/crypto-block 0.0.1-rc.8 → 0.0.1-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/distribution/block.d.ts +23 -2
- package/distribution/block.d.ts.map +1 -1
- package/distribution/block.js +65 -12
- package/distribution/block.js.map +1 -1
- package/distribution/deserializer.d.ts +0 -2
- package/distribution/deserializer.d.ts.map +1 -1
- package/distribution/deserializer.js +15 -101
- package/distribution/deserializer.js.map +1 -1
- package/distribution/factory.d.ts +4 -2
- package/distribution/factory.d.ts.map +1 -1
- package/distribution/factory.js +61 -71
- package/distribution/factory.js.map +1 -1
- package/distribution/hash.factory.d.ts.map +1 -1
- package/distribution/hash.factory.js +1 -2
- package/distribution/hash.factory.js.map +1 -1
- package/distribution/index.d.ts +1 -4
- package/distribution/index.d.ts.map +1 -1
- package/distribution/index.js +1 -47
- package/distribution/index.js.map +1 -1
- package/distribution/schemas.d.ts +1 -1
- package/distribution/schemas.d.ts.map +1 -1
- package/distribution/schemas.js +43 -17
- package/distribution/schemas.js.map +1 -1
- package/distribution/serializer-schemas.d.ts +5 -0
- package/distribution/serializer-schemas.d.ts.map +1 -0
- package/distribution/serializer-schemas.js +57 -0
- package/distribution/serializer-schemas.js.map +1 -0
- package/distribution/serializer.d.ts +2 -2
- package/distribution/serializer.d.ts.map +1 -1
- package/distribution/serializer.js +3 -92
- package/distribution/serializer.js.map +1 -1
- package/distribution/service-provider.d.ts +5 -0
- package/distribution/service-provider.d.ts.map +1 -0
- package/distribution/service-provider.js +48 -0
- package/distribution/service-provider.js.map +1 -0
- package/package.json +24 -21
package/distribution/block.d.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import type { Contracts } from "@mainsail/contracts";
|
|
2
|
+
import type { BigNumber } from "@mainsail/utils";
|
|
2
3
|
interface BlockArguments {
|
|
3
|
-
data: Contracts.Crypto.
|
|
4
|
+
data: Contracts.Crypto.BlockHeader;
|
|
4
5
|
serialized: string;
|
|
5
6
|
transactions: Contracts.Crypto.Transaction[];
|
|
6
7
|
}
|
|
7
|
-
export declare
|
|
8
|
+
export declare class Block implements Contracts.Crypto.Block {
|
|
9
|
+
readonly timestamp: number;
|
|
10
|
+
readonly version: number;
|
|
11
|
+
readonly number: number;
|
|
12
|
+
readonly round: number;
|
|
13
|
+
readonly parentHash: string;
|
|
14
|
+
readonly stateRoot: string;
|
|
15
|
+
readonly logsBloom: string;
|
|
16
|
+
readonly transactionsCount: number;
|
|
17
|
+
readonly gasUsed: number;
|
|
18
|
+
readonly fee: BigNumber;
|
|
19
|
+
readonly reward: BigNumber;
|
|
20
|
+
readonly payloadSize: number;
|
|
21
|
+
readonly transactionsRoot: string;
|
|
22
|
+
readonly proposer: string;
|
|
23
|
+
readonly hash: string;
|
|
24
|
+
readonly serialized: string;
|
|
25
|
+
readonly transactions: Contracts.Crypto.BlockTransaction[];
|
|
26
|
+
constructor({ data, serialized, transactions }: BlockArguments);
|
|
27
|
+
toData(): Contracts.Crypto.BlockData;
|
|
28
|
+
}
|
|
8
29
|
export {};
|
|
9
30
|
//# sourceMappingURL=block.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../source/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../source/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,UAAU,cAAc;IACvB,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;CAC7C;AAED,qBAAa,KAAM,YAAW,SAAS,CAAC,MAAM,CAAC,KAAK;IACnD,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAC1C,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,GAAG,EAAE,SAAS,CAAC;IAC/B,SAAgB,MAAM,EAAE,SAAS,CAAC;IAClC,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,gBAAgB,EAAE,MAAM,CAAC;IACzC,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBAE/C,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,cAAc;IA6BrE,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,SAAS;CAsBpC"}
|
package/distribution/block.js
CHANGED
|
@@ -1,13 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { BlockTransaction } from "@mainsail/crypto-transaction";
|
|
2
|
+
export class Block {
|
|
3
|
+
timestamp;
|
|
4
|
+
version;
|
|
5
|
+
number;
|
|
6
|
+
round;
|
|
7
|
+
parentHash;
|
|
8
|
+
stateRoot;
|
|
9
|
+
logsBloom;
|
|
10
|
+
transactionsCount;
|
|
11
|
+
gasUsed;
|
|
12
|
+
fee;
|
|
13
|
+
reward;
|
|
14
|
+
payloadSize;
|
|
15
|
+
transactionsRoot;
|
|
16
|
+
proposer;
|
|
17
|
+
hash;
|
|
18
|
+
serialized;
|
|
19
|
+
transactions;
|
|
20
|
+
constructor({ data, serialized, transactions }) {
|
|
21
|
+
this.timestamp = data.timestamp;
|
|
22
|
+
this.version = data.version;
|
|
23
|
+
this.number = data.number;
|
|
24
|
+
this.round = data.round;
|
|
25
|
+
this.parentHash = data.parentHash;
|
|
26
|
+
this.stateRoot = data.stateRoot;
|
|
27
|
+
this.logsBloom = data.logsBloom;
|
|
28
|
+
this.transactionsCount = data.transactionsCount;
|
|
29
|
+
this.gasUsed = data.gasUsed;
|
|
30
|
+
this.fee = data.fee;
|
|
31
|
+
this.reward = data.reward;
|
|
32
|
+
this.payloadSize = data.payloadSize;
|
|
33
|
+
this.transactionsRoot = data.transactionsRoot;
|
|
34
|
+
this.proposer = data.proposer;
|
|
35
|
+
this.hash = data.hash;
|
|
36
|
+
this.serialized = serialized;
|
|
37
|
+
this.transactions = transactions.map((transaction, index) => new BlockTransaction(transaction, transaction.serialized, {
|
|
38
|
+
blockHash: this.hash,
|
|
39
|
+
blockNumber: this.number,
|
|
40
|
+
transactionIndex: index,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
toData() {
|
|
44
|
+
return {
|
|
45
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
46
|
+
timestamp: this.timestamp,
|
|
47
|
+
version: this.version,
|
|
48
|
+
number: this.number,
|
|
49
|
+
round: this.round,
|
|
50
|
+
parentHash: this.parentHash,
|
|
51
|
+
stateRoot: this.stateRoot,
|
|
52
|
+
logsBloom: this.logsBloom,
|
|
53
|
+
transactionsCount: this.transactionsCount,
|
|
54
|
+
gasUsed: this.gasUsed,
|
|
55
|
+
fee: this.fee,
|
|
56
|
+
reward: this.reward,
|
|
57
|
+
payloadSize: this.payloadSize,
|
|
58
|
+
transactionsRoot: this.transactionsRoot,
|
|
59
|
+
proposer: this.proposer,
|
|
60
|
+
hash: this.hash,
|
|
61
|
+
transactions: this.transactions.map((transaction) => transaction.toData()),
|
|
62
|
+
/* eslint-enable perfectionist/sort-objects */
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
13
66
|
//# sourceMappingURL=block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.js","sourceRoot":"","sources":["../source/block.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"block.js","sourceRoot":"","sources":["../source/block.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAQhE,MAAM,OAAO,KAAK;IACD,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,SAAS,CAAS;IAClB,iBAAiB,CAAS;IAC1B,OAAO,CAAS;IAChB,GAAG,CAAY;IACf,MAAM,CAAY;IAClB,WAAW,CAAS;IACpB,gBAAgB,CAAS;IACzB,QAAQ,CAAS;IACjB,IAAI,CAAS;IACb,UAAU,CAAS;IACnB,YAAY,CAAsC;IAElE,YAAmB,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAkB;QACpE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IA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CAAC,WAAW;YAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAC1E,8CAA8C;SAC9C,CAAC;IACH,CAAC;CACD"}
|
|
@@ -3,10 +3,8 @@ export declare class Deserializer implements Contracts.Crypto.BlockDeserializer
|
|
|
3
3
|
#private;
|
|
4
4
|
private readonly hashFactory;
|
|
5
5
|
private readonly transactionFactory;
|
|
6
|
-
private readonly transactionDeserializer;
|
|
7
6
|
private readonly serializer;
|
|
8
7
|
private readonly headerSize;
|
|
9
|
-
private readonly workerPool;
|
|
10
8
|
deserializeHeader(serialized: Buffer): Promise<Contracts.Crypto.BlockHeader>;
|
|
11
9
|
deserializeWithTransactions(serialized: Buffer): Promise<Contracts.Crypto.BlockWithTransactions>;
|
|
12
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../source/deserializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../source/deserializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUrD,qBACa,YAAa,YAAW,SAAS,CAAC,MAAM,CAAC,iBAAiB;;IAEtE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAG3C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAuC;IAG1E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAG9D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAE9B,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC;IAW5E,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC;CA8D7G"}
|
|
@@ -7,19 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
11
10
|
import { Identifiers } from "@mainsail/constants";
|
|
12
|
-
import { inject, injectable
|
|
13
|
-
import {
|
|
14
|
-
import { ByteBuffer
|
|
11
|
+
import { inject, injectable } from "@mainsail/container";
|
|
12
|
+
import { InvalidBlockBytesError } from "@mainsail/exceptions";
|
|
13
|
+
import { ByteBuffer } from "@mainsail/utils";
|
|
15
14
|
import { HashFactory } from "./hash.factory.js";
|
|
15
|
+
import { blockHeaderSchema, transactionsSchema } from "./serializer-schemas.js";
|
|
16
16
|
let Deserializer = class Deserializer {
|
|
17
17
|
hashFactory;
|
|
18
18
|
transactionFactory;
|
|
19
|
-
transactionDeserializer;
|
|
20
19
|
serializer;
|
|
21
20
|
headerSize;
|
|
22
|
-
workerPool;
|
|
23
21
|
async deserializeHeader(serialized) {
|
|
24
22
|
const buffer = ByteBuffer.fromBuffer(serialized);
|
|
25
23
|
const header = await this.#deserializeBufferHeader(buffer);
|
|
@@ -35,108 +33,33 @@ let Deserializer = class Deserializer {
|
|
|
35
33
|
if (buffer.getRemainderLength() > 0) {
|
|
36
34
|
transactions = await this.#deserializeTransactions(header, buffer);
|
|
37
35
|
}
|
|
36
|
+
if (buffer.getRemainderLength() !== 0) {
|
|
37
|
+
throw new InvalidBlockBytesError(`Found trailing bytes of length ${buffer.getRemainderLength()}`);
|
|
38
|
+
}
|
|
38
39
|
return {
|
|
39
40
|
data: {
|
|
40
41
|
...header,
|
|
41
42
|
hash: await this.hashFactory.make(header),
|
|
42
|
-
transactions: transactions.map((tx) => tx.data),
|
|
43
43
|
},
|
|
44
44
|
transactions,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
async #deserializeBufferHeader(buffer) {
|
|
48
|
-
|
|
48
|
+
const header = await this.serializer.deserialize(buffer, {}, {
|
|
49
49
|
length: this.headerSize(),
|
|
50
|
-
schema:
|
|
51
|
-
version: {
|
|
52
|
-
type: "uint8",
|
|
53
|
-
},
|
|
54
|
-
timestamp: {
|
|
55
|
-
type: "uint48",
|
|
56
|
-
},
|
|
57
|
-
number: {
|
|
58
|
-
type: "uint32",
|
|
59
|
-
},
|
|
60
|
-
round: {
|
|
61
|
-
type: "uint32",
|
|
62
|
-
},
|
|
63
|
-
parentHash: {
|
|
64
|
-
type: "hash",
|
|
65
|
-
},
|
|
66
|
-
stateRoot: {
|
|
67
|
-
type: "hash",
|
|
68
|
-
},
|
|
69
|
-
logsBloom: {
|
|
70
|
-
type: "hash",
|
|
71
|
-
size: 256,
|
|
72
|
-
},
|
|
73
|
-
transactionsCount: {
|
|
74
|
-
type: "uint16",
|
|
75
|
-
},
|
|
76
|
-
gasUsed: {
|
|
77
|
-
type: "uint32",
|
|
78
|
-
},
|
|
79
|
-
fee: {
|
|
80
|
-
type: "uint256",
|
|
81
|
-
},
|
|
82
|
-
reward: {
|
|
83
|
-
type: "uint256",
|
|
84
|
-
},
|
|
85
|
-
payloadSize: {
|
|
86
|
-
type: "uint32",
|
|
87
|
-
},
|
|
88
|
-
transactionsRoot: {
|
|
89
|
-
type: "hash",
|
|
90
|
-
},
|
|
91
|
-
proposer: {
|
|
92
|
-
type: "address",
|
|
93
|
-
},
|
|
94
|
-
},
|
|
50
|
+
schema: blockHeaderSchema,
|
|
95
51
|
});
|
|
52
|
+
if (buffer.getRemainderLength() !== header.payloadSize) {
|
|
53
|
+
throw new InvalidBlockBytesError(`Payload size ${header.payloadSize} does not match actual payload size ${buffer.getRemainderLength()}`);
|
|
54
|
+
}
|
|
55
|
+
return header;
|
|
96
56
|
}
|
|
97
57
|
async #deserializeTransactions(header, buf) {
|
|
98
58
|
const block = await this.serializer.deserialize(buf, { ...header }, {
|
|
99
59
|
length: header.payloadSize,
|
|
100
|
-
schema:
|
|
101
|
-
transactions: {
|
|
102
|
-
type: "transactions",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
60
|
+
schema: transactionsSchema,
|
|
105
61
|
});
|
|
106
|
-
|
|
107
|
-
* After unpacking we need to turn the transactions into DTOs!
|
|
108
|
-
*
|
|
109
|
-
* We keep this behavior out of the (de)serializer because it
|
|
110
|
-
* is very specific to this bit of code in this specific class.
|
|
111
|
-
*/
|
|
112
|
-
const transactions = Array.from({ length: block.transactionsCount });
|
|
113
|
-
await Promise.all(block.transactions.map(async (serialized, index) => {
|
|
114
|
-
const transaction = await this.transactionDeserializer.deserialize(serialized);
|
|
115
|
-
if (index % 20 === 0) {
|
|
116
|
-
await sleep(0);
|
|
117
|
-
}
|
|
118
|
-
const computed = await this.#computeCryptoData(transaction.data);
|
|
119
|
-
if (computed.schemaError) {
|
|
120
|
-
throw new TransactionSchemaError(computed.schemaError);
|
|
121
|
-
}
|
|
122
|
-
transaction.data.data = transaction.data.data.startsWith("0x")
|
|
123
|
-
? transaction.data.data.slice(2)
|
|
124
|
-
: transaction.data.data;
|
|
125
|
-
transaction.data.hash = computed.hash;
|
|
126
|
-
transaction.data.from = computed.address;
|
|
127
|
-
transaction.data.senderPublicKey = computed.publicKey;
|
|
128
|
-
transaction.data.senderLegacyAddress = computed.legacyAddress;
|
|
129
|
-
transactions[index] = transaction;
|
|
130
|
-
block.transactions[index] = transaction.data;
|
|
131
|
-
}));
|
|
132
|
-
return transactions;
|
|
133
|
-
}
|
|
134
|
-
async #computeCryptoData(transaction) {
|
|
135
|
-
if (this.workerPool) {
|
|
136
|
-
const worker = await this.workerPool.getWorker();
|
|
137
|
-
return worker.transactionFactory("computeCryptoData", transaction);
|
|
138
|
-
}
|
|
139
|
-
return this.transactionFactory.computeCryptoData(transaction);
|
|
62
|
+
return Promise.all(block.transactions.map(async (serialized) => this.transactionFactory.fromBytes(serialized)));
|
|
140
63
|
}
|
|
141
64
|
};
|
|
142
65
|
__decorate([
|
|
@@ -147,10 +70,6 @@ __decorate([
|
|
|
147
70
|
inject(Identifiers.Cryptography.Transaction.Factory),
|
|
148
71
|
__metadata("design:type", Object)
|
|
149
72
|
], Deserializer.prototype, "transactionFactory", void 0);
|
|
150
|
-
__decorate([
|
|
151
|
-
inject(Identifiers.Cryptography.Transaction.Deserializer),
|
|
152
|
-
__metadata("design:type", Object)
|
|
153
|
-
], Deserializer.prototype, "transactionDeserializer", void 0);
|
|
154
73
|
__decorate([
|
|
155
74
|
inject(Identifiers.Cryptography.Serializer),
|
|
156
75
|
__metadata("design:type", Object)
|
|
@@ -159,11 +78,6 @@ __decorate([
|
|
|
159
78
|
inject(Identifiers.Cryptography.Block.HeaderSize),
|
|
160
79
|
__metadata("design:type", Function)
|
|
161
80
|
], Deserializer.prototype, "headerSize", void 0);
|
|
162
|
-
__decorate([
|
|
163
|
-
inject(Identifiers.CryptoWorker.WorkerPool),
|
|
164
|
-
optional(),
|
|
165
|
-
__metadata("design:type", Object)
|
|
166
|
-
], Deserializer.prototype, "workerPool", void 0);
|
|
167
81
|
Deserializer = __decorate([
|
|
168
82
|
injectable()
|
|
169
83
|
], Deserializer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializer.js","sourceRoot":"","sources":["../source/deserializer.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"deserializer.js","sourceRoot":"","sources":["../source/deserializer.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE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UAAU,CAAC;;gDACP;AAX/B,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAsFxB"}
|
|
@@ -6,11 +6,13 @@ export declare class BlockFactory implements Contracts.Crypto.BlockFactory {
|
|
|
6
6
|
private readonly hashFactory;
|
|
7
7
|
private readonly transactionFactory;
|
|
8
8
|
private readonly validator;
|
|
9
|
-
make(data: Contracts.Crypto.
|
|
9
|
+
make(data: Contracts.Crypto.BlockHeaderRaw, transactions: Contracts.Crypto.Transaction[]): Promise<Contracts.Crypto.Block>;
|
|
10
10
|
fromHex(hex: string): Promise<Contracts.Crypto.Block>;
|
|
11
11
|
fromBytes(buff: Buffer): Promise<Contracts.Crypto.Block>;
|
|
12
|
+
fromStorage(header: Contracts.Evm.BlockHeaderStorageData, transactions: Contracts.Evm.TransactionStorageData[]): Promise<Contracts.Crypto.Block>;
|
|
13
|
+
headerFromBytes(serialized: Buffer): Promise<Contracts.Crypto.BlockHeader>;
|
|
14
|
+
headerFromStorage(header: Contracts.Evm.BlockHeaderStorageData): Promise<Contracts.Crypto.BlockHeader>;
|
|
12
15
|
fromJson(json: Contracts.Crypto.BlockJson): Promise<Contracts.Crypto.Block>;
|
|
13
16
|
fromData(data: Contracts.Crypto.BlockData): Promise<Contracts.Crypto.Block>;
|
|
14
|
-
fromStorage(header: Contracts.Evm.BlockHeaderStorageData, transactions: Contracts.Evm.TransactionStorageData[]): Promise<Contracts.Crypto.Block>;
|
|
15
17
|
}
|
|
16
18
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../source/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../source/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUrD,qBACa,YAAa,YAAW,SAAS,CAAC,MAAM,CAAC,YAAY;;IAEjE,OAA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|
@@ -11,7 +11,7 @@ import { Identifiers } from "@mainsail/constants";
|
|
|
11
11
|
import { inject, injectable } from "@mainsail/container";
|
|
12
12
|
import { BlockSchemaError } from "@mainsail/exceptions";
|
|
13
13
|
import { BigNumber } from "@mainsail/utils";
|
|
14
|
-
import {
|
|
14
|
+
import { Block } from "./block.js";
|
|
15
15
|
import { HashFactory } from "./hash.factory.js";
|
|
16
16
|
let BlockFactory = class BlockFactory {
|
|
17
17
|
serializer;
|
|
@@ -21,8 +21,9 @@ let BlockFactory = class BlockFactory {
|
|
|
21
21
|
validator;
|
|
22
22
|
async make(data, transactions) {
|
|
23
23
|
const block = { ...data, hash: await this.hashFactory.make(data) };
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
await this.#verify("block", { ...block, transactions });
|
|
25
|
+
const serialized = await this.serializer.serializeWithTransactions({ ...data, transactions });
|
|
26
|
+
return new Block({
|
|
26
27
|
data: block,
|
|
27
28
|
serialized: serialized.toString("hex"),
|
|
28
29
|
transactions,
|
|
@@ -34,89 +35,78 @@ let BlockFactory = class BlockFactory {
|
|
|
34
35
|
async fromBytes(buff) {
|
|
35
36
|
return this.#fromSerialized(buff);
|
|
36
37
|
}
|
|
38
|
+
async fromStorage(header, transactions) {
|
|
39
|
+
const parsedTransactions = await Promise.all(transactions.map((tx) => this.transactionFactory.fromStorage({ ...tx, blockHash: header.hash })));
|
|
40
|
+
const data = await this.headerFromStorage(header);
|
|
41
|
+
const serialized = await this.serializer.serializeWithTransactions({
|
|
42
|
+
...data,
|
|
43
|
+
transactions: parsedTransactions,
|
|
44
|
+
});
|
|
45
|
+
return new Block({
|
|
46
|
+
data,
|
|
47
|
+
serialized: serialized.toString("hex"),
|
|
48
|
+
transactions: parsedTransactions,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async headerFromBytes(serialized) {
|
|
52
|
+
const blockHeader = await this.deserializer.deserializeHeader(serialized);
|
|
53
|
+
await this.#verify("blockHeader", blockHeader);
|
|
54
|
+
return blockHeader;
|
|
55
|
+
}
|
|
56
|
+
async headerFromStorage(header) {
|
|
57
|
+
return {
|
|
58
|
+
fee: BigNumber.make(header.fee),
|
|
59
|
+
gasUsed: header.gasUsed,
|
|
60
|
+
hash: header.hash,
|
|
61
|
+
logsBloom: header.logsBloom,
|
|
62
|
+
number: header.number,
|
|
63
|
+
parentHash: header.parentHash,
|
|
64
|
+
payloadSize: header.payloadSize,
|
|
65
|
+
proposer: header.proposer,
|
|
66
|
+
reward: BigNumber.make(header.reward),
|
|
67
|
+
round: header.round,
|
|
68
|
+
stateRoot: header.stateRoot,
|
|
69
|
+
timestamp: Number(header.timestamp),
|
|
70
|
+
transactionsCount: header.transactionsCount,
|
|
71
|
+
transactionsRoot: header.transactionsRoot,
|
|
72
|
+
version: header.version,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
37
75
|
async fromJson(json) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}
|
|
76
|
+
const data = {
|
|
77
|
+
...json,
|
|
78
|
+
fee: BigNumber.make(json.fee),
|
|
79
|
+
reward: BigNumber.make(json.reward),
|
|
80
|
+
transactions: json.transactions.map((tx) => ({
|
|
81
|
+
...tx,
|
|
82
|
+
nonce: BigNumber.make(tx.nonce),
|
|
83
|
+
value: BigNumber.make(tx.value),
|
|
84
|
+
})),
|
|
85
|
+
};
|
|
48
86
|
return this.fromData(data);
|
|
49
87
|
}
|
|
50
88
|
async fromData(data) {
|
|
51
|
-
await this.#
|
|
52
|
-
const
|
|
53
|
-
|
|
89
|
+
await this.#verify("block", data);
|
|
90
|
+
const transactions = await Promise.all(data.transactions.map((tx) => this.transactionFactory.fromData(tx, false)));
|
|
91
|
+
const serialized = await this.serializer.serializeWithTransactions({ ...data, transactions });
|
|
92
|
+
return new Block({
|
|
54
93
|
...(await this.deserializer.deserializeWithTransactions(serialized)),
|
|
55
94
|
serialized: serialized.toString("hex"),
|
|
56
95
|
});
|
|
57
96
|
}
|
|
58
|
-
async fromStorage(header, transactions) {
|
|
59
|
-
const parsedTransactions = await Promise.all(transactions.map((tx) => this.transactionFactory.fromStorage(tx)));
|
|
60
|
-
return sealBlock({
|
|
61
|
-
data: {
|
|
62
|
-
fee: BigNumber.make(header.fee),
|
|
63
|
-
gasUsed: header.gasUsed,
|
|
64
|
-
hash: header.hash,
|
|
65
|
-
logsBloom: header.logsBloom,
|
|
66
|
-
number: header.number,
|
|
67
|
-
parentHash: header.parentHash,
|
|
68
|
-
payloadSize: header.payloadSize,
|
|
69
|
-
proposer: header.proposer,
|
|
70
|
-
reward: BigNumber.make(header.reward),
|
|
71
|
-
round: header.round,
|
|
72
|
-
stateRoot: header.stateRoot,
|
|
73
|
-
timestamp: Number(header.timestamp),
|
|
74
|
-
transactions: parsedTransactions.map((tx) => tx.data),
|
|
75
|
-
transactionsCount: header.transactionsCount,
|
|
76
|
-
transactionsRoot: header.transactionsRoot,
|
|
77
|
-
version: header.version,
|
|
78
|
-
},
|
|
79
|
-
serialized: "",
|
|
80
|
-
transactions: parsedTransactions,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
97
|
async #fromSerialized(serialized) {
|
|
84
98
|
const deserialized = await this.deserializer.deserializeWithTransactions(serialized);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
deserialized.data = validated;
|
|
88
|
-
}
|
|
89
|
-
return sealBlock({
|
|
99
|
+
await this.#verify("block", { ...deserialized.data, transactions: deserialized.transactions });
|
|
100
|
+
return new Block({
|
|
90
101
|
...deserialized,
|
|
91
102
|
serialized: serialized.toString("hex"),
|
|
92
103
|
});
|
|
93
104
|
}
|
|
94
|
-
async #
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
for (const error of result.errors ?? []) {
|
|
100
|
-
let fatal = false;
|
|
101
|
-
const match = error.instancePath.match(/\.transactions\[(\d+)]/);
|
|
102
|
-
if (match === null) {
|
|
103
|
-
fatal = true;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
if (data.transactions) {
|
|
107
|
-
const txIndex = Number(match[1]);
|
|
108
|
-
const tx = data.transactions[txIndex];
|
|
109
|
-
if (tx.hash === undefined) {
|
|
110
|
-
fatal = true;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (fatal) {
|
|
115
|
-
throw new BlockSchemaError(data.number, `Invalid data${error.instancePath ? " at " + error.instancePath : ""}: ` +
|
|
116
|
-
`${error.message}: ${JSON.stringify(error.data)}`);
|
|
117
|
-
}
|
|
105
|
+
async #verify(schema, data) {
|
|
106
|
+
const { error } = this.validator.validate(schema, data);
|
|
107
|
+
if (error) {
|
|
108
|
+
throw new BlockSchemaError(data.number, error);
|
|
118
109
|
}
|
|
119
|
-
return result.value;
|
|
120
110
|
}
|
|
121
111
|
};
|
|
122
112
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../source/factory.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../source/factory.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGzC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEP,UAAU,CAAoC;IAG9C,YAAY,CAAsC;IAGlD,WAAW,CAAe;IAG1B,kBAAkB,CAAuC;IAGzD,SAAS,C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ErF,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;QAE/F,OAAO,IAAI,KAAK,CAAC;YAChB,GAAG,YAAY;YACf,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;SACtC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAA+D;QAC5F,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAExD,IAAI,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;IACF,CAAC;CACD,CAAA;AAzIiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC;;gDACa;AAG9C;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC;;kDACe;AAGlD;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC;8BACpB,WAAW;iDAAC;AAG1B;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC;;wDACqB;AAGzD;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC;;+CACa;AAd5C,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CA2IxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.factory.d.ts","sourceRoot":"","sources":["../source/hash.factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.factory.d.ts","sourceRoot":"","sources":["../source/hash.factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD,qBACa,WAAW;IAEvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgC;IAG5D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAElD,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;CAGzE"}
|
|
@@ -13,8 +13,7 @@ let HashFactory = class HashFactory {
|
|
|
13
13
|
hashFactory;
|
|
14
14
|
serializer;
|
|
15
15
|
async make(data) {
|
|
16
|
-
|
|
17
|
-
return buffer.toString("hex");
|
|
16
|
+
return this.hashFactory.sha256(await this.serializer.serializeHeader(data)).toString("hex");
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
19
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.factory.js","sourceRoot":"","sources":["../source/hash.factory.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"hash.factory.js","sourceRoot":"","sources":["../source/hash.factory.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGlD,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEN,WAAW,CAAgC;IAG3C,UAAU,CAAoC;IAExD,KAAK,CAAC,IAAI,CAAC,IAAqC;QACtD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7F,CAAC;CACD,CAAA;AARiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;;gDACc;AAG3C;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC;;+CACa;AALnD,WAAW;IADvB,UAAU,EAAE;GACA,WAAW,CAUvB"}
|
package/distribution/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { Providers } from "@mainsail/kernel";
|
|
2
1
|
export * from "./deserializer.js";
|
|
3
2
|
export * from "./factory.js";
|
|
4
3
|
export * from "./hash.factory.js";
|
|
5
4
|
export * from "./schemas.js";
|
|
6
5
|
export * from "./serializer.js";
|
|
7
|
-
export
|
|
8
|
-
register(): Promise<void>;
|
|
9
|
-
}
|
|
6
|
+
export * from "./service-provider.js";
|
|
10
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
|
package/distribution/index.js
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Identifiers } from "@mainsail/constants";
|
|
8
|
-
import { injectable } from "@mainsail/container";
|
|
9
|
-
import { Providers } from "@mainsail/kernel";
|
|
10
|
-
import { Deserializer } from "./deserializer.js";
|
|
11
|
-
import { BlockFactory } from "./factory.js";
|
|
12
|
-
import { HashFactory } from "./hash.factory.js";
|
|
13
|
-
import { schemas } from "./schemas.js";
|
|
14
|
-
import { Serializer } from "./serializer.js";
|
|
15
1
|
export * from "./deserializer.js";
|
|
16
2
|
export * from "./factory.js";
|
|
17
3
|
export * from "./hash.factory.js";
|
|
18
4
|
export * from "./schemas.js";
|
|
19
5
|
export * from "./serializer.js";
|
|
20
|
-
|
|
21
|
-
async register() {
|
|
22
|
-
this.app.bind(Identifiers.Cryptography.Block.HeaderSize).toConstantValue(() => {
|
|
23
|
-
const hashByteLength = this.app.get(Identifiers.Cryptography.Hash.Size.SHA256);
|
|
24
|
-
const generatorAddressByteLength = this.app.get(Identifiers.Cryptography.Identity.Address.Size);
|
|
25
|
-
return (1 + // version
|
|
26
|
-
6 + // timestamp
|
|
27
|
-
4 + // height
|
|
28
|
-
4 + // round
|
|
29
|
-
hashByteLength + // previousBlock
|
|
30
|
-
hashByteLength + // stateRoot
|
|
31
|
-
256 + // logsBloom
|
|
32
|
-
2 + // transactionsCount
|
|
33
|
-
4 + // totalGasUsed
|
|
34
|
-
32 + // totalFee
|
|
35
|
-
32 + // reward
|
|
36
|
-
4 + // payloadLength
|
|
37
|
-
hashByteLength + // payloadHash
|
|
38
|
-
generatorAddressByteLength);
|
|
39
|
-
});
|
|
40
|
-
this.app.bind(Identifiers.Cryptography.Block.Deserializer).to(Deserializer).inSingletonScope();
|
|
41
|
-
this.app.bind(Identifiers.Cryptography.Block.Factory).to(BlockFactory).inSingletonScope();
|
|
42
|
-
this.app.bind(Identifiers.Cryptography.Block.HashFactory).to(HashFactory).inSingletonScope();
|
|
43
|
-
this.app.bind(Identifiers.Cryptography.Block.Serializer).to(Serializer).inSingletonScope();
|
|
44
|
-
for (const schema of Object.values(schemas)) {
|
|
45
|
-
this.app.get(Identifiers.Cryptography.Validator).addSchema(schema);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
ServiceProvider = __decorate([
|
|
50
|
-
injectable()
|
|
51
|
-
], ServiceProvider);
|
|
52
|
-
export { ServiceProvider };
|
|
6
|
+
export * from "./service-provider.js";
|
|
53
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AnySchemaObject } from "ajv";
|
|
2
|
-
export declare const schemas: Record<"block" | "blockHash" | "prefixedBlockHash" | "blockHeader" | "logsBloom", AnySchemaObject>;
|
|
2
|
+
export declare const schemas: Record<"block" | "blockHash" | "prefixedBlockHash" | "blockHeader" | "logsBloom" | "stateRoot" | "transactionsRoot", AnySchemaObject>;
|
|
3
3
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../source/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAE3C,eAAO,MAAM,OAAO,EAAE,MAAM,CAC3B,OAAO,GAAG,WAAW,GAAG,mBAAmB,GAAG,aAAa,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../source/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAE3C,eAAO,MAAM,OAAO,EAAE,MAAM,CAC3B,OAAO,GAAG,WAAW,GAAG,mBAAmB,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,kBAAkB,EAC5G,eAAe,CA8Gf,CAAC"}
|
package/distribution/schemas.js
CHANGED
|
@@ -26,36 +26,40 @@ export const schemas = {
|
|
|
26
26
|
blockHeader: {
|
|
27
27
|
$id: "blockHeader",
|
|
28
28
|
properties: {
|
|
29
|
-
|
|
30
|
-
gasUsed: { minimum: 0, type: "integer" },
|
|
29
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
31
30
|
hash: { $ref: "blockHash" },
|
|
32
|
-
|
|
31
|
+
version: { enum: [1] },
|
|
32
|
+
timestamp: { maximum: 2 ** 48 - 1, minimum: 0, type: "integer" },
|
|
33
33
|
number: { minimum: 0, type: "integer" },
|
|
34
|
+
round: { minimum: 0, type: "integer" },
|
|
34
35
|
parentHash: { $ref: "blockHash" },
|
|
36
|
+
stateRoot: { $ref: "stateRoot" },
|
|
37
|
+
logsBloom: { $ref: "logsBloom" },
|
|
38
|
+
transactionsCount: { minimum: 0, type: "integer" },
|
|
39
|
+
gasUsed: { minimum: 0, type: "integer" },
|
|
40
|
+
fee: { bignumber: { minimum: 0 } },
|
|
41
|
+
reward: { bignumber: { minimum: 0 } },
|
|
35
42
|
payloadSize: { minimum: 0, type: "integer" },
|
|
43
|
+
transactionsRoot: { $ref: "transactionsRoot" },
|
|
36
44
|
proposer: { $ref: "address" },
|
|
37
|
-
|
|
38
|
-
stateRoot: { $ref: "hex" },
|
|
39
|
-
timestamp: { maximum: 2 ** 48 - 1, minimum: 0, type: "integer" },
|
|
40
|
-
transactionsCount: { minimum: 0, type: "integer" },
|
|
41
|
-
transactionsRoot: { $ref: "hex" },
|
|
42
|
-
version: { enum: [1] },
|
|
45
|
+
/* eslint-enable perfectionist/sort-objects */
|
|
43
46
|
},
|
|
44
47
|
required: [
|
|
45
|
-
"fee",
|
|
46
|
-
"gasUsed",
|
|
47
48
|
"hash",
|
|
48
|
-
"
|
|
49
|
+
"version",
|
|
50
|
+
"timestamp",
|
|
49
51
|
"number",
|
|
52
|
+
"round",
|
|
50
53
|
"parentHash",
|
|
51
|
-
"payloadSize",
|
|
52
|
-
"proposer",
|
|
53
|
-
"reward",
|
|
54
54
|
"stateRoot",
|
|
55
|
-
"
|
|
55
|
+
"logsBloom",
|
|
56
56
|
"transactionsCount",
|
|
57
|
+
"gasUsed",
|
|
58
|
+
"fee",
|
|
59
|
+
"reward",
|
|
60
|
+
"payloadSize",
|
|
57
61
|
"transactionsRoot",
|
|
58
|
-
"
|
|
62
|
+
"proposer",
|
|
59
63
|
],
|
|
60
64
|
type: "object",
|
|
61
65
|
},
|
|
@@ -81,5 +85,27 @@ export const schemas = {
|
|
|
81
85
|
],
|
|
82
86
|
type: "string",
|
|
83
87
|
},
|
|
88
|
+
stateRoot: {
|
|
89
|
+
$id: "stateRoot",
|
|
90
|
+
allOf: [
|
|
91
|
+
{
|
|
92
|
+
$ref: "hex",
|
|
93
|
+
maxLength: 64,
|
|
94
|
+
minLength: 64,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
type: "string",
|
|
98
|
+
},
|
|
99
|
+
transactionsRoot: {
|
|
100
|
+
$id: "transactionsRoot",
|
|
101
|
+
allOf: [
|
|
102
|
+
{
|
|
103
|
+
$ref: "hex",
|
|
104
|
+
maxLength: 64,
|
|
105
|
+
minLength: 64,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
type: "string",
|
|
109
|
+
},
|
|
84
110
|
};
|
|
85
111
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../source/schemas.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAGhB;IACH,KAAK,EAAE;QACN,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE;YACX,YAAY,EAAE;gBACb,IAAI,EAAE,cAAc;gBACpB,QAAQ,EAA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,EAAE;QAClB,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE;YACN;gBACC,IAAI,EAAE,qBAAqB;gBAC3B,SAAS,EAAE,EAAE;gBACb,SAAS,EAAE,EAAE;aACb;SACD;QACD,IAAI,EAAE,QAAQ;KACd;IACD,SAAS,EAAE;QACV,GAAG,EAAE,WAAW;QAChB,KAAK,EAAE;YACN;gBACC,IAAI,EAAE,KAAK;gBACX,SAAS,EAAE,EAAE;gBACb,SAAS,EAAE,EAAE;aACb;SACD;QACD,IAAI,EAAE,QAAQ;KACd;IACD,gBAAgB,EAAE;QACjB,GAAG,EAAE,kBAAkB;QACvB,KAAK,EAAE;YACN;gBACC,IAAI,EAAE,KAAK;gBACX,SAAS,EAAE,EAAE;gBACb,SAAS,EAAE,EAAE;aACb;SACD;QACD,IAAI,EAAE,QAAQ;KACd;CACD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Contracts } from "@mainsail/contracts";
|
|
2
|
+
export declare const blockHeaderSchema: Record<string, Contracts.Serializer.DeserializationSchema>;
|
|
3
|
+
export declare const transactionsSchema: Record<string, Contracts.Serializer.SerializationSchema>;
|
|
4
|
+
export declare const blockSchema: Record<string, Contracts.Serializer.SerializationSchema>;
|
|
5
|
+
//# sourceMappingURL=serializer-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer-schemas.d.ts","sourceRoot":"","sources":["../source/serializer-schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,qBAAqB,CA4CxF,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,mBAAmB,CAIvF,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,mBAAmB,CAKhF,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const blockHeaderSchema = {
|
|
2
|
+
version: {
|
|
3
|
+
type: "uint8",
|
|
4
|
+
},
|
|
5
|
+
timestamp: {
|
|
6
|
+
type: "uint48",
|
|
7
|
+
},
|
|
8
|
+
number: {
|
|
9
|
+
type: "uint32",
|
|
10
|
+
},
|
|
11
|
+
round: {
|
|
12
|
+
type: "uint32",
|
|
13
|
+
},
|
|
14
|
+
parentHash: {
|
|
15
|
+
type: "hash",
|
|
16
|
+
},
|
|
17
|
+
stateRoot: {
|
|
18
|
+
type: "hash",
|
|
19
|
+
},
|
|
20
|
+
logsBloom: {
|
|
21
|
+
type: "hash",
|
|
22
|
+
size: 256,
|
|
23
|
+
},
|
|
24
|
+
transactionsCount: {
|
|
25
|
+
type: "uint16",
|
|
26
|
+
},
|
|
27
|
+
gasUsed: {
|
|
28
|
+
type: "uint32",
|
|
29
|
+
},
|
|
30
|
+
fee: {
|
|
31
|
+
type: "uint256",
|
|
32
|
+
},
|
|
33
|
+
reward: {
|
|
34
|
+
type: "uint256",
|
|
35
|
+
},
|
|
36
|
+
payloadSize: {
|
|
37
|
+
type: "uint32",
|
|
38
|
+
},
|
|
39
|
+
transactionsRoot: {
|
|
40
|
+
type: "hash",
|
|
41
|
+
},
|
|
42
|
+
proposer: {
|
|
43
|
+
type: "address",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export const transactionsSchema = {
|
|
47
|
+
transactions: {
|
|
48
|
+
type: "transactions",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export const blockSchema = {
|
|
52
|
+
...blockHeaderSchema,
|
|
53
|
+
transactions: {
|
|
54
|
+
type: "transactions",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=serializer-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer-schemas.js","sourceRoot":"","sources":["../source/serializer-schemas.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,iBAAiB,GAA+D;IAC5F,OAAO,EAAE;QACR,IAAI,EAAE,OAAO;KACb;IACD,SAAS,EAAE;QACV,IAAI,EAAE,QAAQ;KACd;IACD,MAAM,EAAE;QACP,IAAI,EAAE,QAAQ;KACd;IACD,KAAK,EAAE;QACN,IAAI,EAAE,QAAQ;KACd;IACD,UAAU,EAAE;QACX,IAAI,EAAE,MAAM;KACZ;IACD,SAAS,EAAE;QACV,IAAI,EAAE,MAAM;KACZ;IACD,SAAS,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,GAAG;KACT;IACD,iBAAiB,EAAE;QAClB,IAAI,EAAE,QAAQ;KACd;IACD,OAAO,EAAE;QACR,IAAI,EAAE,QAAQ;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,SAAS;KACf;IACD,MAAM,EAAE;QACP,IAAI,EAAE,SAAS;KACf;IACD,WAAW,EAAE;QACZ,IAAI,EAAE,QAAQ;KACd;IACD,gBAAgB,EAAE;QACjB,IAAI,EAAE,MAAM;KACZ;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,SAAS;KACf;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA6D;IAC3F,YAAY,EAAE;QACb,IAAI,EAAE,cAAc;KACpB;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA6D;IACpF,GAAG,iBAAiB;IACpB,YAAY,EAAE;QACb,IAAI,EAAE,cAAc;KACpB;CACD,CAAC"}
|
|
@@ -2,8 +2,8 @@ import type { Contracts } from "@mainsail/contracts";
|
|
|
2
2
|
export declare class Serializer implements Contracts.Crypto.BlockSerializer {
|
|
3
3
|
private readonly serializer;
|
|
4
4
|
private readonly headerSize;
|
|
5
|
-
totalSize(block: Contracts.Crypto.
|
|
5
|
+
totalSize(block: Contracts.Crypto.BlockHeaderRaw): number;
|
|
6
6
|
serializeHeader(header: Contracts.Crypto.BlockHeaderRaw): Promise<Buffer>;
|
|
7
|
-
serializeWithTransactions(block: Contracts.Crypto.
|
|
7
|
+
serializeWithTransactions(block: Contracts.Crypto.BlockSerializable): Promise<Buffer>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=serializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAOrD,qBACa,UAAW,YAAW,SAAS,CAAC,MAAM,CAAC,eAAe;IAElE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAG9D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAEpC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,GAAG,MAAM;IAInD,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzE,yBAAyB,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;CAOlG"}
|
|
@@ -7,9 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
11
10
|
import { Identifiers } from "@mainsail/constants";
|
|
12
11
|
import { inject, injectable } from "@mainsail/container";
|
|
12
|
+
import { blockHeaderSchema, blockSchema } from "./serializer-schemas.js";
|
|
13
13
|
let Serializer = class Serializer {
|
|
14
14
|
serializer;
|
|
15
15
|
headerSize;
|
|
@@ -19,104 +19,15 @@ let Serializer = class Serializer {
|
|
|
19
19
|
async serializeHeader(header) {
|
|
20
20
|
return this.serializer.serialize(header, {
|
|
21
21
|
length: this.headerSize(),
|
|
22
|
+
schema: blockHeaderSchema,
|
|
22
23
|
skip: 0,
|
|
23
|
-
schema: {
|
|
24
|
-
version: {
|
|
25
|
-
type: "uint8",
|
|
26
|
-
},
|
|
27
|
-
timestamp: {
|
|
28
|
-
type: "uint48",
|
|
29
|
-
},
|
|
30
|
-
number: {
|
|
31
|
-
type: "uint32",
|
|
32
|
-
},
|
|
33
|
-
round: {
|
|
34
|
-
type: "uint32",
|
|
35
|
-
},
|
|
36
|
-
parentHash: {
|
|
37
|
-
type: "hash",
|
|
38
|
-
},
|
|
39
|
-
stateRoot: {
|
|
40
|
-
type: "hash",
|
|
41
|
-
},
|
|
42
|
-
logsBloom: {
|
|
43
|
-
type: "hash",
|
|
44
|
-
},
|
|
45
|
-
transactionsCount: {
|
|
46
|
-
type: "uint16",
|
|
47
|
-
},
|
|
48
|
-
gasUsed: {
|
|
49
|
-
type: "uint32",
|
|
50
|
-
},
|
|
51
|
-
fee: {
|
|
52
|
-
type: "uint256",
|
|
53
|
-
},
|
|
54
|
-
reward: {
|
|
55
|
-
type: "uint256",
|
|
56
|
-
},
|
|
57
|
-
payloadSize: {
|
|
58
|
-
type: "uint32",
|
|
59
|
-
},
|
|
60
|
-
transactionsRoot: {
|
|
61
|
-
type: "hash",
|
|
62
|
-
},
|
|
63
|
-
proposer: {
|
|
64
|
-
type: "address",
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
24
|
});
|
|
68
25
|
}
|
|
69
26
|
async serializeWithTransactions(block) {
|
|
70
27
|
return this.serializer.serialize(block, {
|
|
71
28
|
length: this.totalSize(block),
|
|
29
|
+
schema: blockSchema,
|
|
72
30
|
skip: 0,
|
|
73
|
-
schema: {
|
|
74
|
-
version: {
|
|
75
|
-
type: "uint8",
|
|
76
|
-
},
|
|
77
|
-
timestamp: {
|
|
78
|
-
type: "uint48",
|
|
79
|
-
},
|
|
80
|
-
number: {
|
|
81
|
-
type: "uint32",
|
|
82
|
-
},
|
|
83
|
-
round: {
|
|
84
|
-
type: "uint32",
|
|
85
|
-
},
|
|
86
|
-
parentHash: {
|
|
87
|
-
type: "hash",
|
|
88
|
-
},
|
|
89
|
-
stateRoot: {
|
|
90
|
-
type: "hash",
|
|
91
|
-
},
|
|
92
|
-
logsBloom: {
|
|
93
|
-
type: "hash",
|
|
94
|
-
},
|
|
95
|
-
transactionsCount: {
|
|
96
|
-
type: "uint16",
|
|
97
|
-
},
|
|
98
|
-
gasUsed: {
|
|
99
|
-
type: "uint32",
|
|
100
|
-
},
|
|
101
|
-
fee: {
|
|
102
|
-
type: "uint256",
|
|
103
|
-
},
|
|
104
|
-
reward: {
|
|
105
|
-
type: "uint256",
|
|
106
|
-
},
|
|
107
|
-
payloadSize: {
|
|
108
|
-
type: "uint32",
|
|
109
|
-
},
|
|
110
|
-
transactionsRoot: {
|
|
111
|
-
type: "hash",
|
|
112
|
-
},
|
|
113
|
-
proposer: {
|
|
114
|
-
type: "address",
|
|
115
|
-
},
|
|
116
|
-
transactions: {
|
|
117
|
-
type: "transactions",
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
31
|
});
|
|
121
32
|
}
|
|
122
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGlE,IAAM,UAAU,GAAhB,MAAM,UAAU;IAEL,UAAU,CAAmC;IAG7C,UAAU,CAAgB;IAEpC,SAAS,CAAC,KAAsC;QACtD,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAuC;QACnE,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE;YACxC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE;YACzB,MAAM,EAAE,iBAAiB;YACzB,IAAI,EAAE,CAAC;SACP,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,yBAAyB,CAAC,KAAyC;QAC/E,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE;YACvC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC7B,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE,CAAC;SACP,CAAC,CAAC;IACJ,CAAC;CACD,CAAA;AAxBiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC;;8CACkB;AAG7C;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC;;8CACP;AAL/B,UAAU;IADtB,UAAU,EAAE;GACA,UAAU,CA0BtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-provider.d.ts","sourceRoot":"","sources":["../source/service-provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQ7C,qBACa,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAgCtC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Identifiers } from "@mainsail/constants";
|
|
8
|
+
import { injectable } from "@mainsail/container";
|
|
9
|
+
import { Providers } from "@mainsail/kernel";
|
|
10
|
+
import { Deserializer } from "./deserializer.js";
|
|
11
|
+
import { BlockFactory } from "./factory.js";
|
|
12
|
+
import { HashFactory } from "./hash.factory.js";
|
|
13
|
+
import { schemas } from "./schemas.js";
|
|
14
|
+
import { Serializer } from "./serializer.js";
|
|
15
|
+
let ServiceProvider = class ServiceProvider extends Providers.ServiceProvider {
|
|
16
|
+
async register() {
|
|
17
|
+
this.app.bind(Identifiers.Cryptography.Block.HeaderSize).toConstantValue(() => {
|
|
18
|
+
const hashByteLength = this.app.get(Identifiers.Cryptography.Hash.Size.SHA256);
|
|
19
|
+
const generatorAddressByteLength = this.app.get(Identifiers.Cryptography.Identity.Address.Size);
|
|
20
|
+
return (1 + // version
|
|
21
|
+
6 + // timestamp
|
|
22
|
+
4 + // height
|
|
23
|
+
4 + // round
|
|
24
|
+
hashByteLength + // previousBlock
|
|
25
|
+
hashByteLength + // stateRoot
|
|
26
|
+
256 + // logsBloom
|
|
27
|
+
2 + // transactionsCount
|
|
28
|
+
4 + // totalGasUsed
|
|
29
|
+
32 + // totalFee
|
|
30
|
+
32 + // reward
|
|
31
|
+
4 + // payloadLength
|
|
32
|
+
hashByteLength + // payloadHash
|
|
33
|
+
generatorAddressByteLength);
|
|
34
|
+
});
|
|
35
|
+
this.app.bind(Identifiers.Cryptography.Block.Deserializer).to(Deserializer).inSingletonScope();
|
|
36
|
+
this.app.bind(Identifiers.Cryptography.Block.Factory).to(BlockFactory).inSingletonScope();
|
|
37
|
+
this.app.bind(Identifiers.Cryptography.Block.HashFactory).to(HashFactory).inSingletonScope();
|
|
38
|
+
this.app.bind(Identifiers.Cryptography.Block.Serializer).to(Serializer).inSingletonScope();
|
|
39
|
+
for (const schema of Object.values(schemas)) {
|
|
40
|
+
this.app.get(Identifiers.Cryptography.Validator).addSchema(schema);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
ServiceProvider = __decorate([
|
|
45
|
+
injectable()
|
|
46
|
+
], ServiceProvider);
|
|
47
|
+
export { ServiceProvider };
|
|
48
|
+
//# sourceMappingURL=service-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-provider.js","sourceRoot":"","sources":["../source/service-provider.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGtC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,SAAS,CAAC,eAAe;IACtD,KAAK,CAAC,QAAQ;QACpB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE;YAC7E,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAS,WAAW,CAAC,YAAY,CAAC,I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CAAC;YAC7C,IAAI,CAAC,GAAG,CAAC,GAAG,CAA6B,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAChG,CAAC;IACF,CAAC;CACD,CAAA;AAjCY,eAAe;IAD3B,UAAU,EAAE;GACA,eAAe,CAiC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mainsail/crypto-block",
|
|
3
|
-
"version": "0.0.1-rc.
|
|
3
|
+
"version": "0.0.1-rc.9",
|
|
4
4
|
"description": "Block utilities for the Mainsail blockchain",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"contributors": [],
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
"/distribution"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"ajv": "8.
|
|
15
|
-
"@mainsail/
|
|
16
|
-
"@mainsail/
|
|
17
|
-
"@mainsail/kernel": "0.0.1-rc.
|
|
18
|
-
"@mainsail/
|
|
19
|
-
"@mainsail/
|
|
14
|
+
"ajv": "8.18.0",
|
|
15
|
+
"@mainsail/constants": "0.0.1-rc.9",
|
|
16
|
+
"@mainsail/crypto-transaction": "0.0.1-rc.9",
|
|
17
|
+
"@mainsail/kernel": "0.0.1-rc.9",
|
|
18
|
+
"@mainsail/exceptions": "0.0.1-rc.9",
|
|
19
|
+
"@mainsail/container": "0.0.1-rc.9",
|
|
20
|
+
"@mainsail/utils": "0.0.1-rc.9"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@types/lodash.clone": "4.5.9",
|
|
@@ -24,22 +25,23 @@
|
|
|
24
25
|
"lodash.clone": "4.5.0",
|
|
25
26
|
"lodash.clonedeep": "4.5.0",
|
|
26
27
|
"uvu": "0.5.6",
|
|
27
|
-
"@mainsail/contracts": "0.0.1-rc.
|
|
28
|
-
"@mainsail/crypto-address-base58": "0.0.1-rc.
|
|
29
|
-
"@mainsail/crypto-address-keccak256": "0.0.1-rc.
|
|
30
|
-
"@mainsail/crypto-
|
|
31
|
-
"@mainsail/crypto-
|
|
32
|
-
"@mainsail/crypto-
|
|
33
|
-
"@mainsail/crypto-
|
|
34
|
-
"@mainsail/crypto-
|
|
35
|
-
"@mainsail/
|
|
36
|
-
"@mainsail/crypto-validation": "0.0.1-rc.
|
|
37
|
-
"@mainsail/
|
|
38
|
-
"@mainsail/
|
|
39
|
-
"@mainsail/
|
|
28
|
+
"@mainsail/contracts": "0.0.1-rc.9",
|
|
29
|
+
"@mainsail/crypto-address-base58": "0.0.1-rc.9",
|
|
30
|
+
"@mainsail/crypto-address-keccak256": "0.0.1-rc.9",
|
|
31
|
+
"@mainsail/crypto-hash-bcrypto": "0.0.1-rc.9",
|
|
32
|
+
"@mainsail/crypto-key-pair-bls12-381": "0.0.1-rc.9",
|
|
33
|
+
"@mainsail/crypto-key-pair-ecdsa": "0.0.1-rc.9",
|
|
34
|
+
"@mainsail/crypto-signature-ecdsa": "0.0.1-rc.9",
|
|
35
|
+
"@mainsail/crypto-config": "0.0.1-rc.9",
|
|
36
|
+
"@mainsail/test-runner": "0.0.1-rc.9",
|
|
37
|
+
"@mainsail/crypto-validation": "0.0.1-rc.9",
|
|
38
|
+
"@mainsail/validation": "0.0.1-rc.9",
|
|
39
|
+
"@mainsail/crypto-wif": "0.0.1-rc.9",
|
|
40
|
+
"@mainsail/serializer": "0.0.1-rc.9",
|
|
41
|
+
"@mainsail/crypto-signature-bls12-381": "0.0.1-rc.9"
|
|
40
42
|
},
|
|
41
43
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
44
|
+
"node": ">=24"
|
|
43
45
|
},
|
|
44
46
|
"scripts": {
|
|
45
47
|
"build": "tsc -b",
|
|
@@ -47,6 +49,7 @@
|
|
|
47
49
|
"release": "pnpm publish --access public",
|
|
48
50
|
"test": "pnpm run uvu source .test.ts",
|
|
49
51
|
"test:coverage": "c8 -r=text -r=lcov --all pnpm run test",
|
|
52
|
+
"test:coverage:file": "c8 -r=text -r=lcov --all pnpm run test:file",
|
|
50
53
|
"test:coverage:html": "c8 -r html --all pnpm run test",
|
|
51
54
|
"test:file": "pnpm run uvu source",
|
|
52
55
|
"uvu": "tsx --tsconfig ../../tsconfig.test.json ./node_modules/uvu/bin.js"
|