@mainsail/crypto-commit 0.0.1-evm.4 → 0.0.1-evm.41
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/deserializer.d.ts +2 -3
- package/distribution/deserializer.d.ts.map +1 -1
- package/distribution/deserializer.js +7 -5
- package/distribution/deserializer.js.map +1 -1
- package/distribution/factory.d.ts +4 -3
- package/distribution/factory.d.ts.map +1 -1
- package/distribution/factory.js +28 -7
- package/distribution/factory.js.map +1 -1
- package/distribution/index.d.ts.map +1 -1
- package/distribution/index.js +18 -3
- package/distribution/index.js.map +1 -1
- package/distribution/serializer.d.ts +3 -4
- package/distribution/serializer.d.ts.map +1 -1
- package/distribution/serializer.js +14 -8
- package/distribution/serializer.js.map +1 -1
- package/package.json +23 -22
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { Contracts } from "@mainsail/contracts";
|
|
1
|
+
import type { Contracts } from "@mainsail/contracts";
|
|
3
2
|
export declare class Deserializer implements Contracts.Crypto.CommitDeserializer {
|
|
4
3
|
private readonly serializer;
|
|
5
|
-
private readonly
|
|
4
|
+
private readonly proofSize;
|
|
6
5
|
deserializeCommitProof(serialized: Buffer): Promise<Contracts.Crypto.CommitProof>;
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=deserializer.d.ts.map
|
|
@@ -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":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,qBACa,YAAa,YAAW,SAAS,CAAC,MAAM,CAAC,kBAAkB;IAEvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAG9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAE7B,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC;CAsB9F"}
|
|
@@ -7,15 +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
|
+
import { Identifiers } from "@mainsail/constants";
|
|
10
11
|
import { inject, injectable } from "@mainsail/container";
|
|
11
|
-
import { Contracts, Identifiers } from "@mainsail/contracts";
|
|
12
12
|
import { ByteBuffer } from "@mainsail/utils";
|
|
13
13
|
let Deserializer = class Deserializer {
|
|
14
|
+
serializer;
|
|
15
|
+
proofSize;
|
|
14
16
|
async deserializeCommitProof(serialized) {
|
|
15
17
|
const buffer = ByteBuffer.fromBuffer(serialized);
|
|
16
18
|
const proof = {};
|
|
17
19
|
await this.serializer.deserialize(buffer, proof, {
|
|
18
|
-
length: this.
|
|
20
|
+
length: this.proofSize(),
|
|
19
21
|
schema: {
|
|
20
22
|
round: {
|
|
21
23
|
type: "uint32",
|
|
@@ -36,9 +38,9 @@ __decorate([
|
|
|
36
38
|
__metadata("design:type", Object)
|
|
37
39
|
], Deserializer.prototype, "serializer", void 0);
|
|
38
40
|
__decorate([
|
|
39
|
-
inject(Identifiers.Cryptography.Commit.
|
|
40
|
-
__metadata("design:type",
|
|
41
|
-
], Deserializer.prototype, "
|
|
41
|
+
inject(Identifiers.Cryptography.Commit.ProofSize),
|
|
42
|
+
__metadata("design:type", Function)
|
|
43
|
+
], Deserializer.prototype, "proofSize", void 0);
|
|
42
44
|
Deserializer = __decorate([
|
|
43
45
|
injectable()
|
|
44
46
|
], Deserializer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializer.js","sourceRoot":"","sources":["../source/deserializer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"deserializer.js","sourceRoot":"","sources":["../source/deserializer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGtC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEP,UAAU,CAAmC;IAG7C,SAAS,CAAgB;IAEnC,KAAK,CAAC,sBAAsB,CAAC,UAAkB;QACrD,MAAM,MAAM,GAAe,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAE7D,MAAM,KAAK,GAAG,EAAkC,CAAC;QAEjD,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAA+B,MAAM,EAAE,KAAK,EAAE;YAC9E,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE;YACxB,MAAM,EAAE;gBACP,KAAK,EAAE;oBACN,IAAI,EAAE,QAAQ;iBACd;gBACD,SAAS,EAAE;oBACV,IAAI,EAAE,oBAAoB;iBAC1B;gBACD,UAAU,EAAE;oBACX,IAAI,EAAE,cAAc;iBACpB;aACD;SACD,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAA;AA3BiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC;;gDACkB;AAG7C;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;;+CACR;AAL9B,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CA6BxB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { Contracts } from "@mainsail/contracts";
|
|
1
|
+
import type { Contracts } from "@mainsail/contracts";
|
|
3
2
|
export declare class CommitFactory implements Contracts.Crypto.CommitFactory {
|
|
4
3
|
private readonly blockFactory;
|
|
5
|
-
private readonly commitSerializer;
|
|
6
4
|
private readonly commitDeserializer;
|
|
5
|
+
private readonly configuration;
|
|
6
|
+
private readonly proofSize;
|
|
7
7
|
fromBytes(buff: Buffer): Promise<Contracts.Crypto.Commit>;
|
|
8
|
+
fromStorage(data: Contracts.Evm.CommitStorageData): Promise<Contracts.Crypto.Commit>;
|
|
8
9
|
fromJson(json: Contracts.Crypto.CommitJson): Promise<Contracts.Crypto.Commit>;
|
|
9
10
|
}
|
|
10
11
|
//# 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":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,qBACa,aAAc,YAAW,SAAS,CAAC,MAAM,CAAC,aAAa;IAEnE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiC;IAG9D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAuC;IAG1E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAkC;IAGhE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAE7B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;IAezD,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;IAgBpF,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;CAQ1F"}
|
package/distribution/factory.js
CHANGED
|
@@ -7,13 +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
|
+
import { Identifiers } from "@mainsail/constants";
|
|
10
11
|
import { inject, injectable } from "@mainsail/container";
|
|
11
|
-
import {
|
|
12
|
-
import { ByteBuffer } from "@mainsail/utils";
|
|
12
|
+
import { ByteBuffer, validatorSetUnpack } from "@mainsail/utils";
|
|
13
13
|
let CommitFactory = class CommitFactory {
|
|
14
|
+
blockFactory;
|
|
15
|
+
commitDeserializer;
|
|
16
|
+
configuration;
|
|
17
|
+
proofSize;
|
|
14
18
|
async fromBytes(buff) {
|
|
15
19
|
const buffer = ByteBuffer.fromBuffer(buff);
|
|
16
|
-
const proofBuffer = buffer.readBytes(this.
|
|
20
|
+
const proofBuffer = buffer.readBytes(this.proofSize());
|
|
17
21
|
const proof = await this.commitDeserializer.deserializeCommitProof(proofBuffer);
|
|
18
22
|
const block = await this.blockFactory.fromBytes(buffer.getRemainder());
|
|
19
23
|
return {
|
|
@@ -22,6 +26,19 @@ let CommitFactory = class CommitFactory {
|
|
|
22
26
|
serialized: buff.toString("hex"),
|
|
23
27
|
};
|
|
24
28
|
}
|
|
29
|
+
async fromStorage(data) {
|
|
30
|
+
const block = await this.blockFactory.fromStorage(data.header, data.transactions);
|
|
31
|
+
const { roundValidators } = this.configuration.getMilestone(block.header.number);
|
|
32
|
+
return {
|
|
33
|
+
block,
|
|
34
|
+
proof: {
|
|
35
|
+
round: data.proof.round,
|
|
36
|
+
signature: data.proof.signature,
|
|
37
|
+
validators: validatorSetUnpack(data.proof.validatorSet, roundValidators),
|
|
38
|
+
},
|
|
39
|
+
serialized: "",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
25
42
|
async fromJson(json) {
|
|
26
43
|
const block = await this.blockFactory.fromJson(json.block);
|
|
27
44
|
return {
|
|
@@ -35,14 +52,18 @@ __decorate([
|
|
|
35
52
|
inject(Identifiers.Cryptography.Block.Factory),
|
|
36
53
|
__metadata("design:type", Object)
|
|
37
54
|
], CommitFactory.prototype, "blockFactory", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
inject(Identifiers.Cryptography.Commit.Serializer),
|
|
40
|
-
__metadata("design:type", Object)
|
|
41
|
-
], CommitFactory.prototype, "commitSerializer", void 0);
|
|
42
55
|
__decorate([
|
|
43
56
|
inject(Identifiers.Cryptography.Commit.Deserializer),
|
|
44
57
|
__metadata("design:type", Object)
|
|
45
58
|
], CommitFactory.prototype, "commitDeserializer", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
inject(Identifiers.Cryptography.Configuration),
|
|
61
|
+
__metadata("design:type", Object)
|
|
62
|
+
], CommitFactory.prototype, "configuration", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
inject(Identifiers.Cryptography.Commit.ProofSize),
|
|
65
|
+
__metadata("design:type", Function)
|
|
66
|
+
], CommitFactory.prototype, "proofSize", void 0);
|
|
46
67
|
CommitFactory = __decorate([
|
|
47
68
|
injectable()
|
|
48
69
|
], CommitFactory);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../source/factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../source/factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,IAAM,aAAa,GAAnB,MAAM,aAAa;IAER,YAAY,CAAiC;IAG7C,kBAAkB,CAAuC;IAGzD,aAAa,CAAkC;IAG/C,SAAS,CAAgB;IAEnC,KAAK,CAAC,SAAS,CAAC,IAAY;QAClC,MAAM,MAAM,G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AAC;CACD,CAAA;AAlDiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;;mDACe;AAG7C;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC;;yDACqB;AAGzD;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC;;oDACiB;AAG/C;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;;gDACR;AAX9B,aAAa;IADzB,UAAU,EAAE;GACA,aAAa,CAoDzB"}
|
|
@@ -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":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAM7C,qBACa,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAetC"}
|
package/distribution/index.js
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
|
|
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";
|
|
2
9
|
import { Providers } from "@mainsail/kernel";
|
|
3
10
|
import { Deserializer } from "./deserializer.js";
|
|
4
11
|
import { CommitFactory } from "./factory.js";
|
|
5
12
|
import { Serializer } from "./serializer.js";
|
|
6
|
-
|
|
13
|
+
let ServiceProvider = class ServiceProvider extends Providers.ServiceProvider {
|
|
7
14
|
async register() {
|
|
15
|
+
this.app.bind(Identifiers.Cryptography.Commit.ProofSize).toConstantValue(() => 4 + // round
|
|
16
|
+
this.app.getTagged(Identifiers.Cryptography.Signature.Size, "type", "consensus") + // signature
|
|
17
|
+
1 +
|
|
18
|
+
8);
|
|
8
19
|
this.app.bind(Identifiers.Cryptography.Commit.Serializer).to(Serializer).inSingletonScope();
|
|
9
20
|
this.app.bind(Identifiers.Cryptography.Commit.Deserializer).to(Deserializer).inSingletonScope();
|
|
10
21
|
this.app.bind(Identifiers.Cryptography.Commit.Factory).to(CommitFactory).inSingletonScope();
|
|
11
22
|
}
|
|
12
|
-
}
|
|
23
|
+
};
|
|
24
|
+
ServiceProvider = __decorate([
|
|
25
|
+
injectable()
|
|
26
|
+
], ServiceProvider);
|
|
27
|
+
export { ServiceProvider };
|
|
13
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACj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
2
|
export declare class Serializer implements Contracts.Crypto.CommitSerializer {
|
|
4
3
|
private readonly serializer;
|
|
5
|
-
private readonly
|
|
6
|
-
proofSize
|
|
4
|
+
private readonly blockSerializer;
|
|
5
|
+
private readonly proofSize;
|
|
7
6
|
serializeCommitProof(commit: Contracts.Crypto.CommitProof): Promise<Buffer>;
|
|
8
7
|
serializeCommit(commit: Contracts.Crypto.CommitSerializable): Promise<Buffer>;
|
|
9
8
|
}
|
|
@@ -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":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,qBACa,UAAW,YAAW,SAAS,CAAC,MAAM,CAAC,gBAAgB;IAEnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAG9D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoC;IAGpE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAE7B,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAkB3E,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;CAU1F"}
|
|
@@ -7,13 +7,12 @@ 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
|
+
import { Identifiers } from "@mainsail/constants";
|
|
10
11
|
import { inject, injectable } from "@mainsail/container";
|
|
11
|
-
import { Contracts, Identifiers } from "@mainsail/contracts";
|
|
12
12
|
let Serializer = class Serializer {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
serializer;
|
|
14
|
+
blockSerializer;
|
|
15
|
+
proofSize;
|
|
17
16
|
async serializeCommitProof(commit) {
|
|
18
17
|
return this.serializer.serialize(commit, {
|
|
19
18
|
length: this.proofSize(),
|
|
@@ -33,7 +32,10 @@ let Serializer = class Serializer {
|
|
|
33
32
|
}
|
|
34
33
|
async serializeCommit(commit) {
|
|
35
34
|
const serializedProof = await this.serializeCommitProof(commit.proof);
|
|
36
|
-
|
|
35
|
+
let serializedBlock = Buffer.from(commit.block.serialized, "hex");
|
|
36
|
+
if (serializedBlock.byteLength === 0) {
|
|
37
|
+
serializedBlock = await this.blockSerializer.serializeWithTransactions(commit.block.data);
|
|
38
|
+
}
|
|
37
39
|
return Buffer.concat([serializedProof, serializedBlock]);
|
|
38
40
|
}
|
|
39
41
|
};
|
|
@@ -42,9 +44,13 @@ __decorate([
|
|
|
42
44
|
__metadata("design:type", Object)
|
|
43
45
|
], Serializer.prototype, "serializer", void 0);
|
|
44
46
|
__decorate([
|
|
45
|
-
inject(Identifiers.Cryptography.
|
|
47
|
+
inject(Identifiers.Cryptography.Block.Serializer),
|
|
46
48
|
__metadata("design:type", Object)
|
|
47
|
-
], Serializer.prototype, "
|
|
49
|
+
], Serializer.prototype, "blockSerializer", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
inject(Identifiers.Cryptography.Commit.ProofSize),
|
|
52
|
+
__metadata("design:type", Function)
|
|
53
|
+
], Serializer.prototype, "proofSize", void 0);
|
|
48
54
|
Serializer = __decorate([
|
|
49
55
|
injectable()
|
|
50
56
|
], Serializer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":";;;;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;;mDACkB;AAGnD;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;;6CACR;AAR9B,UAAU;IADtB,UAAU,EAAE;GACA,UAAU,CAsCtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mainsail/crypto-commit",
|
|
3
|
-
"version": "0.0.1-evm.
|
|
3
|
+
"version": "0.0.1-evm.41",
|
|
4
4
|
"description": "Commit utilities for the Mainsail blockchain",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"contributors": [],
|
|
@@ -11,37 +11,38 @@
|
|
|
11
11
|
"/distribution"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@mainsail/
|
|
15
|
-
"@mainsail/
|
|
16
|
-
"@mainsail/
|
|
17
|
-
"@mainsail/
|
|
14
|
+
"@mainsail/constants": "0.0.1-evm.41",
|
|
15
|
+
"@mainsail/kernel": "0.0.1-evm.41",
|
|
16
|
+
"@mainsail/utils": "0.0.1-evm.41",
|
|
17
|
+
"@mainsail/container": "0.0.1-evm.41"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"uvu": "
|
|
21
|
-
"@mainsail/
|
|
22
|
-
"@mainsail/crypto-
|
|
23
|
-
"@mainsail/crypto-
|
|
24
|
-
"@mainsail/crypto-
|
|
25
|
-
"@mainsail/crypto-
|
|
26
|
-
"@mainsail/crypto-
|
|
27
|
-
"@mainsail/crypto-
|
|
28
|
-
"@mainsail/crypto-
|
|
29
|
-
"@mainsail/crypto-
|
|
30
|
-
"@mainsail/crypto-
|
|
31
|
-
"@mainsail/crypto-
|
|
32
|
-
"@mainsail/
|
|
33
|
-
"@mainsail/
|
|
20
|
+
"uvu": "0.5.6",
|
|
21
|
+
"@mainsail/contracts": "0.0.1-evm.41",
|
|
22
|
+
"@mainsail/crypto-address-base58": "0.0.1-evm.41",
|
|
23
|
+
"@mainsail/crypto-address-keccak256": "0.0.1-evm.41",
|
|
24
|
+
"@mainsail/crypto-config": "0.0.1-evm.41",
|
|
25
|
+
"@mainsail/crypto-consensus-bls12-381": "0.0.1-evm.41",
|
|
26
|
+
"@mainsail/crypto-hash-bcrypto": "0.0.1-evm.41",
|
|
27
|
+
"@mainsail/crypto-key-pair-schnorr": "0.0.1-evm.41",
|
|
28
|
+
"@mainsail/crypto-messages": "0.0.1-evm.41",
|
|
29
|
+
"@mainsail/crypto-block": "0.0.1-evm.41",
|
|
30
|
+
"@mainsail/crypto-signature-ecdsa": "0.0.1-evm.41",
|
|
31
|
+
"@mainsail/crypto-transaction": "0.0.1-evm.41",
|
|
32
|
+
"@mainsail/crypto-validation": "0.0.1-evm.41",
|
|
33
|
+
"@mainsail/crypto-wif": "0.0.1-evm.41",
|
|
34
|
+
"@mainsail/serializer": "0.0.1-evm.41",
|
|
35
|
+
"@mainsail/validation": "0.0.1-evm.41"
|
|
34
36
|
},
|
|
35
37
|
"engines": {
|
|
36
38
|
"node": ">=20.x"
|
|
37
39
|
},
|
|
38
40
|
"scripts": {
|
|
39
|
-
"build": "
|
|
41
|
+
"build": "tsc -b",
|
|
40
42
|
"build:watch": "pnpm run clean && tsc -w",
|
|
41
|
-
"clean": "del distribution",
|
|
42
43
|
"release": "pnpm publish --access public",
|
|
43
44
|
"test": "pnpm run uvu source .test.ts",
|
|
44
|
-
"test:coverage": "c8 pnpm run test",
|
|
45
|
+
"test:coverage": "c8 -r=text -r=lcov --all pnpm run test",
|
|
45
46
|
"test:coverage:html": "c8 -r html --all pnpm run test",
|
|
46
47
|
"test:file": "pnpm run uvu source",
|
|
47
48
|
"uvu": "tsx --tsconfig ../../tsconfig.test.json ./node_modules/uvu/bin.js"
|