@cmts-dev/carmentis-sdk-core 1.2.4 → 1.2.6
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/dist/blockchain/microblock/Microblock.d.ts +4 -0
- package/dist/blockchain/microblock/Microblock.d.ts.map +1 -1
- package/dist/blockchain/structureCheckers/AccountMicroblockStructureChecker.d.ts.map +1 -1
- package/dist/blockchain/structureCheckers/ApplicationLedgerMicroblockStructureChecker.d.ts.map +1 -1
- package/dist/blockchain/structureCheckers/ApplicationMicroblockStructureChecker.d.ts.map +1 -1
- package/dist/blockchain/structureCheckers/ValidatorNodeMicroblockStructureChecker.d.ts.map +1 -1
- package/dist/carmentis-sdk-core.cjs +2 -2
- package/dist/carmentis-sdk-core.es +39 -5
- package/package.json +1 -1
|
@@ -11821,6 +11821,31 @@ var { NEVER: hx, ALWAYS: gx, DECIMAL_ROUND: _x, DECIMAL_FIT: vx } = Rb, yx = 204
|
|
|
11821
11821
|
}, o = X.encodeMicroblockHeader(a);
|
|
11822
11822
|
return await t.sign(o);
|
|
11823
11823
|
}
|
|
11824
|
+
async verifySignature(e) {
|
|
11825
|
+
let t = this.sections.filter((e) => e.type === D.SIGNATURE);
|
|
11826
|
+
if (t.length === 0) throw new a("The current microblock has no SIGNATURE section");
|
|
11827
|
+
if (t.length !== 1) throw new a("There are several SIGNATURE sections");
|
|
11828
|
+
if (this.sections[this.sections.length - 1].type !== D.SIGNATURE) throw new a("The SIGNATURE section is not the last one");
|
|
11829
|
+
return this.verifySignatureOfSections(e, !0, this.sections.length - 1);
|
|
11830
|
+
}
|
|
11831
|
+
async verifyAuxiliarySignature(e, t) {
|
|
11832
|
+
let n = this.sections.filter((e) => e.type === D.AUXILIARY_SIGNATURE && e.tag === t);
|
|
11833
|
+
if (n.length === 0) throw new a(`The current microblock has no AUXILIARY_SIGNATURE section with tag '${t}'`);
|
|
11834
|
+
if (n.length !== 1) throw new a(`The current microblock has several AUXILIARY_SIGNATURE section with tag '${t}'`);
|
|
11835
|
+
let r = this.sections.findIndex((e) => e.type === D.AUXILIARY_SIGNATURE && e.tag === t);
|
|
11836
|
+
return this.verifySignatureOfSections(e, !1, r);
|
|
11837
|
+
}
|
|
11838
|
+
async verifySignatureOfSections(t, n, r) {
|
|
11839
|
+
let i = this.sections[r];
|
|
11840
|
+
if (i.type !== D.SIGNATURE && i.type !== D.AUXILIARY_SIGNATURE) throw new a("Attempt to verify the signature of a non-signature section");
|
|
11841
|
+
let o = this.sections.slice(0, r), s = {
|
|
11842
|
+
...this.header,
|
|
11843
|
+
gas: n ? this.header.gas : 0,
|
|
11844
|
+
gasPrice: n ? this.header.gasPrice : 0,
|
|
11845
|
+
bodyHash: e.computeBodyHashFromSections(o)
|
|
11846
|
+
}, c = X.encodeMicroblockHeader(s), l = i.signature;
|
|
11847
|
+
return t.verify(c, l);
|
|
11848
|
+
}
|
|
11824
11849
|
async verify(t, n = {
|
|
11825
11850
|
includeGas: !0,
|
|
11826
11851
|
verifiedSignatureIndex: "last"
|
|
@@ -12197,12 +12222,17 @@ var { NEVER: hx, ALWAYS: gx, DECIMAL_ROUND: _x, DECIMAL_FIT: vx } = Rb, yx = 204
|
|
|
12197
12222
|
checkMicroblockStructure(e) {
|
|
12198
12223
|
try {
|
|
12199
12224
|
let t = new Xx(e);
|
|
12200
|
-
return !t.isFirstBlock() && t.expects(Z.AT_MOST_ONE, D.ACCOUNT_ESCROW_SETTLEMENT) === 1 || (t.expects(t.isFirstBlock() ? Z.ONE : Z.AT_MOST_ONE, D.ACCOUNT_PUBLIC_KEY), t.isFirstBlock() ? t.group(Z.ONE, [
|
|
12225
|
+
return !t.isFirstBlock() && t.expects(Z.AT_MOST_ONE, D.ACCOUNT_ESCROW_SETTLEMENT) === 1 || (t.expects(t.isFirstBlock() ? Z.ONE : Z.AT_MOST_ONE, D.ACCOUNT_PUBLIC_KEY), t.isFirstBlock() ? t.group(Z.ONE, [
|
|
12226
|
+
[Z.AT_MOST_ONE, D.ACCOUNT_TOKEN_ISSUANCE],
|
|
12227
|
+
[Z.AT_MOST_ONE, D.ACCOUNT_CREATION],
|
|
12228
|
+
[Z.ANY, D.CUSTOM]
|
|
12229
|
+
]) : t.group(Z.AT_LEAST_ONE, [
|
|
12201
12230
|
[Z.ANY, D.ACCOUNT_TRANSFER],
|
|
12202
12231
|
[Z.ANY, D.ACCOUNT_VESTING_TRANSFER],
|
|
12203
12232
|
[Z.ANY, D.ACCOUNT_STAKE],
|
|
12204
12233
|
[Z.ANY, D.ACCOUNT_UNSTAKE],
|
|
12205
|
-
[Z.ANY, D.ACCOUNT_ESCROW_TRANSFER]
|
|
12234
|
+
[Z.ANY, D.ACCOUNT_ESCROW_TRANSFER],
|
|
12235
|
+
[Z.ANY, D.CUSTOM]
|
|
12206
12236
|
])), t.expects(Z.ONE, D.SIGNATURE), t.endsHere(), !0;
|
|
12207
12237
|
} catch (e) {
|
|
12208
12238
|
return e instanceof Error && (e instanceof s ? this.logger.error(`Invalid microblock structure: ${e.message}`) : this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)), !1;
|
|
@@ -12270,7 +12300,7 @@ var { NEVER: hx, ALWAYS: gx, DECIMAL_ROUND: _x, DECIMAL_FIT: vx } = Rb, yx = 204
|
|
|
12270
12300
|
checkMicroblockStructure(e) {
|
|
12271
12301
|
try {
|
|
12272
12302
|
let t = new Xx(e);
|
|
12273
|
-
return t.expects(t.isFirstBlock() ? Z.ONE : Z.ZERO, D.APP_CREATION), t.group(Z.AT_LEAST_ONE, [[Z.AT_MOST_ONE, D.APP_DESCRIPTION]]), t.expects(Z.ONE, D.SIGNATURE), t.endsHere(), !0;
|
|
12303
|
+
return t.expects(t.isFirstBlock() ? Z.ONE : Z.ZERO, D.APP_CREATION), t.group(Z.AT_LEAST_ONE, [[Z.AT_MOST_ONE, D.APP_DESCRIPTION], [Z.ANY, D.CUSTOM]]), t.expects(Z.ONE, D.SIGNATURE), t.endsHere(), !0;
|
|
12274
12304
|
} catch (e) {
|
|
12275
12305
|
return e instanceof Error && (e instanceof s ? this.logger.error(`Invalid microblock structure: ${e.message}`) : this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)), !1;
|
|
12276
12306
|
}
|
|
@@ -12313,7 +12343,11 @@ var { NEVER: hx, ALWAYS: gx, DECIMAL_ROUND: _x, DECIMAL_FIT: vx } = Rb, yx = 204
|
|
|
12313
12343
|
checkMicroblockStructure(e) {
|
|
12314
12344
|
try {
|
|
12315
12345
|
let t = new Xx(e), n = !t.isFirstBlock() && t.expects(Z.AT_MOST_ONE, D.VN_APPROVAL) === 1, r = !n && !t.isFirstBlock() && t.expects(Z.AT_MOST_ONE, D.VN_SLASHING_CANCELLATION) === 1;
|
|
12316
|
-
return !n && !r && (t.expects(t.isFirstBlock() ? Z.ONE : Z.ZERO, D.VN_CREATION), t.group(Z.AT_LEAST_ONE, [
|
|
12346
|
+
return !n && !r && (t.expects(t.isFirstBlock() ? Z.ONE : Z.ZERO, D.VN_CREATION), t.group(Z.AT_LEAST_ONE, [
|
|
12347
|
+
[Z.AT_MOST_ONE, D.VN_COMETBFT_PUBLIC_KEY_DECLARATION],
|
|
12348
|
+
[Z.AT_MOST_ONE, D.VN_RPC_ENDPOINT],
|
|
12349
|
+
[Z.ANY, D.CUSTOM]
|
|
12350
|
+
])), t.expects(Z.ONE, D.SIGNATURE), t.endsHere(), !0;
|
|
12317
12351
|
} catch (e) {
|
|
12318
12352
|
return e instanceof Error && (e instanceof s ? this.logger.error(`Invalid microblock structure: ${e.message}`) : this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)), !1;
|
|
12319
12353
|
}
|
|
@@ -12434,7 +12468,7 @@ var { NEVER: hx, ALWAYS: gx, DECIMAL_ROUND: _x, DECIMAL_FIT: vx } = Rb, yx = 204
|
|
|
12434
12468
|
[Z.ANY, D.APP_LEDGER_CHANNEL_CREATION],
|
|
12435
12469
|
[Z.ANY, D.APP_LEDGER_CHANNEL_INVITATION],
|
|
12436
12470
|
[Z.ANY, D.ALLOWED_ADDITIONAL_WRITER]
|
|
12437
|
-
]), t.expects(Z.
|
|
12471
|
+
]), t.expects(Z.ANY, D.AUXILIARY_SIGNATURE), t.expects(Z.ONE, D.SIGNATURE), t.endsHere(), !0;
|
|
12438
12472
|
} catch (e) {
|
|
12439
12473
|
return typeof e == "string" && this.logger.error(`Microblock structure error details: ${e}`), e instanceof Error && (e instanceof s ? this.logger.error(`Microblock structure error: ${e.message}`) : this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)), !1;
|
|
12440
12474
|
}
|