@taquito/local-forging 12.0.0 → 12.0.3
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/lib/error.js +28 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/taquito-local-forging.js +29 -0
- package/dist/lib/taquito-local-forging.js.map +1 -1
- package/dist/lib/validator.js +46 -0
- package/dist/lib/validator.js.map +1 -0
- package/dist/lib/version.js +2 -2
- package/dist/taquito-local-forging.es6.js +91 -3
- package/dist/taquito-local-forging.es6.js.map +1 -1
- package/dist/taquito-local-forging.umd.js +90 -2
- package/dist/taquito-local-forging.umd.js.map +1 -1
- package/dist/types/error.d.ts +15 -0
- package/dist/types/validator.d.ts +11 -0
- package/package.json +4 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidOperationKindError = exports.InvalidOperationSchemaError = exports.InvalidBlockHashError = void 0;
|
|
4
|
+
class InvalidBlockHashError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.message = message;
|
|
8
|
+
this.name = 'InvalidBlockHashError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.InvalidBlockHashError = InvalidBlockHashError;
|
|
12
|
+
class InvalidOperationSchemaError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.message = message;
|
|
16
|
+
this.name = 'InvalidOperationSchemaError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.InvalidOperationSchemaError = InvalidOperationSchemaError;
|
|
20
|
+
class InvalidOperationKindError extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.message = message;
|
|
24
|
+
this.name = 'InvalidOperationKindError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.InvalidOperationKindError = InvalidOperationKindError;
|
|
28
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAE9C,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAD3B,SAAI,GAAG,uBAAuB,CAAC;IAGtC,CAAC;CACF;AALD,sDAKC;AAED,MAAa,2BAA4B,SAAQ,KAAK;IAEpD,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAD3B,SAAI,GAAG,6BAA6B,CAAC;IAG5C,CAAC;CACF;AALD,kEAKC;AAED,MAAa,yBAA0B,SAAQ,KAAK;IAElD,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAD3B,SAAI,GAAG,2BAA2B,CAAC;IAG1C,CAAC;CACF;AALD,8DAKC"}
|
|
@@ -21,6 +21,9 @@ const encoder_1 = require("./encoder");
|
|
|
21
21
|
const uint8array_consumer_1 = require("./uint8array-consumer");
|
|
22
22
|
const decoder_2 = require("./proto12-ithaca/decoder");
|
|
23
23
|
const encoder_2 = require("./proto12-ithaca/encoder");
|
|
24
|
+
const utils_1 = require("@taquito/utils");
|
|
25
|
+
const error_1 = require("./error");
|
|
26
|
+
const validator_1 = require("./validator");
|
|
24
27
|
var constants_2 = require("./constants");
|
|
25
28
|
Object.defineProperty(exports, "CODEC", { enumerable: true, get: function () { return constants_2.CODEC; } });
|
|
26
29
|
Object.defineProperty(exports, "ProtocolsHash", { enumerable: true, get: function () { return constants_2.ProtocolsHash; } });
|
|
@@ -57,6 +60,32 @@ class LocalForger {
|
|
|
57
60
|
this.codec = getCodec(constants_1.CODEC.MANAGER, this.protocolHash);
|
|
58
61
|
}
|
|
59
62
|
forge(params) {
|
|
63
|
+
if (utils_1.validateBlock(params.branch) !== utils_1.ValidationResult.VALID) {
|
|
64
|
+
throw new error_1.InvalidBlockHashError(`The block hash ${params.branch} is invalid`);
|
|
65
|
+
}
|
|
66
|
+
for (const content of params.contents) {
|
|
67
|
+
if (!validator_1.validateOperationKind(content.kind)) {
|
|
68
|
+
throw new error_1.InvalidOperationKindError(`The operation kind '${content.kind}' does not exist`);
|
|
69
|
+
}
|
|
70
|
+
const diff = validator_1.validateMissingProperty(content);
|
|
71
|
+
if (diff.length === 1) {
|
|
72
|
+
if (content.kind === 'delegation' && diff[0] === 'delegate') {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
else if (content.kind === 'origination' && diff[0] === 'delegate') {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
else if (content.kind === 'transaction' && diff[0] === 'parameters') {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new error_1.InvalidOperationSchemaError(`Missing properties: ${diff.join(', ').toString()}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (diff.length > 1) {
|
|
86
|
+
throw new error_1.InvalidOperationSchemaError(`Missing properties: ${diff.join(', ').toString()}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
60
89
|
return Promise.resolve(this.codec.encoder(params));
|
|
61
90
|
}
|
|
62
91
|
parse(hex) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-local-forging.js","sourceRoot":"","sources":["../../src/taquito-local-forging.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAGH,2CAAmD;AACnD,uCAAqC;AACrC,uCAAqC;AACrC,+DAA2D;AAC3D,sDAA2D;AAC3D,sDAA2D;
|
|
1
|
+
{"version":3,"file":"taquito-local-forging.js","sourceRoot":"","sources":["../../src/taquito-local-forging.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAGH,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AAK,CAAC,OAAO,CAAC,GAAG,CAAgB,CAAC,CAAC;IACjE,CAAC;CACF;AAvCD,kCAuCC;AAEY,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateMissingProperty = exports.validateOperationKind = void 0;
|
|
4
|
+
const operation_1 = require("./schema/operation");
|
|
5
|
+
const OperationKindMapping = {
|
|
6
|
+
activate_account: operation_1.ActivationSchema,
|
|
7
|
+
reveal: operation_1.RevealSchema,
|
|
8
|
+
delegation: operation_1.DelegationSchema,
|
|
9
|
+
transaction: operation_1.TransactionSchema,
|
|
10
|
+
origination: operation_1.OriginationSchema,
|
|
11
|
+
ballot: operation_1.BallotSchema,
|
|
12
|
+
endorsement: operation_1.EndorsementSchema,
|
|
13
|
+
seed_nonce_revelation: operation_1.SeedNonceRevelationSchema,
|
|
14
|
+
proposals: operation_1.ProposalsSchema,
|
|
15
|
+
register_global_constant: operation_1.RegisterGlobalConstantSchema,
|
|
16
|
+
};
|
|
17
|
+
// Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa
|
|
18
|
+
const getArrayDifference = (arr1, arr2) => {
|
|
19
|
+
return arr2.filter((x) => !arr1.includes(x));
|
|
20
|
+
};
|
|
21
|
+
const deleteArrayElementByValue = (array, item) => {
|
|
22
|
+
return array.filter((e) => e !== item);
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* @returns A boolean value to indicate whether the operation kind is valid or not
|
|
26
|
+
*/
|
|
27
|
+
const validateOperationKind = (opKind) => {
|
|
28
|
+
const opKindList = Object.keys(OperationKindMapping);
|
|
29
|
+
return opKindList.includes(opKind);
|
|
30
|
+
};
|
|
31
|
+
exports.validateOperationKind = validateOperationKind;
|
|
32
|
+
/**
|
|
33
|
+
* returns 0 when the two array of properties are identical or the passed property
|
|
34
|
+
* does not have any missing parameters from the corresponding schema
|
|
35
|
+
*
|
|
36
|
+
* @returns array element differences if there are missing required property keys
|
|
37
|
+
*/
|
|
38
|
+
const validateMissingProperty = (operationContent) => {
|
|
39
|
+
const kind = operationContent.kind;
|
|
40
|
+
const keys = Object.keys(operationContent);
|
|
41
|
+
const cleanKeys = deleteArrayElementByValue(keys, 'kind');
|
|
42
|
+
const schemaKeys = Object.keys(OperationKindMapping[kind]);
|
|
43
|
+
return getArrayDifference(cleanKeys, schemaKeys);
|
|
44
|
+
};
|
|
45
|
+
exports.validateMissingProperty = validateMissingProperty;
|
|
46
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":";;;AAAA,kDAW4B;AAc5B,MAAM,oBAAoB,GAAG;IAC3B,gBAAgB,EAAE,4BAAgB;IAClC,MAAM,EAAE,wBAAY;IACpB,UAAU,EAAE,4BAAgB;IAC5B,WAAW,EAAE,6BAAiB;IAC9B,WAAW,EAAE,6BAAiB;IAC9B,MAAM,EAAE,wBAAY;IACpB,WAAW,EAAE,6BAAiB;IAC9B,qBAAqB,EAAE,qCAAyB;IAChD,SAAS,EAAE,2BAAe;IAC1B,wBAAwB,EAAE,wCAA4B;CACvD,CAAC;AAEF,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,CAAC,IAAc,EAAE,IAAc,EAAE,EAAE;IAC5D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,KAAe,EAAE,IAAY,EAAE,EAAE;IAClE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF;;GAEG;AACI,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,EAAE;IACtD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACrD,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAHW,QAAA,qBAAqB,yBAGhC;AAEF;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CAAC,gBAAqB,EAAE,EAAE;IAC/D,MAAM,IAAI,GAAkB,gBAAgB,CAAC,IAAI,CAAC;IAElD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,yBAAyB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE1D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IAE3D,OAAO,kBAAkB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC,CAAC;AATW,QAAA,uBAAuB,2BASlC"}
|
package/dist/lib/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "12.0.
|
|
6
|
+
"commitHash": "02ebaa8ef1920e8b6a81f0d0978f28cff0a2d256",
|
|
7
|
+
"version": "12.0.3"
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Prefix, prefixLength, b58cencode, prefix, buf2hex, b58cdecode } from '@taquito/utils';
|
|
1
|
+
import { Prefix, prefixLength, b58cencode, prefix, buf2hex, b58cdecode, validateBlock, ValidationResult } from '@taquito/utils';
|
|
2
2
|
import BigNumber$1, { BigNumber } from 'bignumber.js';
|
|
3
3
|
|
|
4
4
|
const toHexString = (bytes) => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
|
|
@@ -1093,10 +1093,72 @@ encodersProto12[CODEC.OP_REVEAL] = (val) => schemaEncoder(encodersProto12)(Revea
|
|
|
1093
1093
|
encodersProto12[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encodersProto12)(RegisterGlobalConstantSchema)(val);
|
|
1094
1094
|
encodersProto12[CODEC.MANAGER] = schemaEncoder(encodersProto12)(ManagerOperationSchema);
|
|
1095
1095
|
|
|
1096
|
+
class InvalidBlockHashError extends Error {
|
|
1097
|
+
constructor(message) {
|
|
1098
|
+
super(message);
|
|
1099
|
+
this.message = message;
|
|
1100
|
+
this.name = 'InvalidBlockHashError';
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
class InvalidOperationSchemaError extends Error {
|
|
1104
|
+
constructor(message) {
|
|
1105
|
+
super(message);
|
|
1106
|
+
this.message = message;
|
|
1107
|
+
this.name = 'InvalidOperationSchemaError';
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
class InvalidOperationKindError extends Error {
|
|
1111
|
+
constructor(message) {
|
|
1112
|
+
super(message);
|
|
1113
|
+
this.message = message;
|
|
1114
|
+
this.name = 'InvalidOperationKindError';
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
const OperationKindMapping = {
|
|
1119
|
+
activate_account: ActivationSchema,
|
|
1120
|
+
reveal: RevealSchema,
|
|
1121
|
+
delegation: DelegationSchema,
|
|
1122
|
+
transaction: TransactionSchema,
|
|
1123
|
+
origination: OriginationSchema,
|
|
1124
|
+
ballot: BallotSchema,
|
|
1125
|
+
endorsement: EndorsementSchema,
|
|
1126
|
+
seed_nonce_revelation: SeedNonceRevelationSchema,
|
|
1127
|
+
proposals: ProposalsSchema,
|
|
1128
|
+
register_global_constant: RegisterGlobalConstantSchema,
|
|
1129
|
+
};
|
|
1130
|
+
// Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa
|
|
1131
|
+
const getArrayDifference = (arr1, arr2) => {
|
|
1132
|
+
return arr2.filter((x) => !arr1.includes(x));
|
|
1133
|
+
};
|
|
1134
|
+
const deleteArrayElementByValue = (array, item) => {
|
|
1135
|
+
return array.filter((e) => e !== item);
|
|
1136
|
+
};
|
|
1137
|
+
/**
|
|
1138
|
+
* @returns A boolean value to indicate whether the operation kind is valid or not
|
|
1139
|
+
*/
|
|
1140
|
+
const validateOperationKind = (opKind) => {
|
|
1141
|
+
const opKindList = Object.keys(OperationKindMapping);
|
|
1142
|
+
return opKindList.includes(opKind);
|
|
1143
|
+
};
|
|
1144
|
+
/**
|
|
1145
|
+
* returns 0 when the two array of properties are identical or the passed property
|
|
1146
|
+
* does not have any missing parameters from the corresponding schema
|
|
1147
|
+
*
|
|
1148
|
+
* @returns array element differences if there are missing required property keys
|
|
1149
|
+
*/
|
|
1150
|
+
const validateMissingProperty = (operationContent) => {
|
|
1151
|
+
const kind = operationContent.kind;
|
|
1152
|
+
const keys = Object.keys(operationContent);
|
|
1153
|
+
const cleanKeys = deleteArrayElementByValue(keys, 'kind');
|
|
1154
|
+
const schemaKeys = Object.keys(OperationKindMapping[kind]);
|
|
1155
|
+
return getArrayDifference(cleanKeys, schemaKeys);
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1096
1158
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
1097
1159
|
const VERSION = {
|
|
1098
|
-
"commitHash": "
|
|
1099
|
-
"version": "12.0.
|
|
1160
|
+
"commitHash": "02ebaa8ef1920e8b6a81f0d0978f28cff0a2d256",
|
|
1161
|
+
"version": "12.0.3"
|
|
1100
1162
|
};
|
|
1101
1163
|
|
|
1102
1164
|
/**
|
|
@@ -1129,6 +1191,32 @@ class LocalForger {
|
|
|
1129
1191
|
this.codec = getCodec(CODEC.MANAGER, this.protocolHash);
|
|
1130
1192
|
}
|
|
1131
1193
|
forge(params) {
|
|
1194
|
+
if (validateBlock(params.branch) !== ValidationResult.VALID) {
|
|
1195
|
+
throw new InvalidBlockHashError(`The block hash ${params.branch} is invalid`);
|
|
1196
|
+
}
|
|
1197
|
+
for (const content of params.contents) {
|
|
1198
|
+
if (!validateOperationKind(content.kind)) {
|
|
1199
|
+
throw new InvalidOperationKindError(`The operation kind '${content.kind}' does not exist`);
|
|
1200
|
+
}
|
|
1201
|
+
const diff = validateMissingProperty(content);
|
|
1202
|
+
if (diff.length === 1) {
|
|
1203
|
+
if (content.kind === 'delegation' && diff[0] === 'delegate') {
|
|
1204
|
+
continue;
|
|
1205
|
+
}
|
|
1206
|
+
else if (content.kind === 'origination' && diff[0] === 'delegate') {
|
|
1207
|
+
continue;
|
|
1208
|
+
}
|
|
1209
|
+
else if (content.kind === 'transaction' && diff[0] === 'parameters') {
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
else {
|
|
1213
|
+
throw new InvalidOperationSchemaError(`Missing properties: ${diff.join(', ').toString()}`);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
else if (diff.length > 1) {
|
|
1217
|
+
throw new InvalidOperationSchemaError(`Missing properties: ${diff.join(', ').toString()}`);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1132
1220
|
return Promise.resolve(this.codec.encoder(params));
|
|
1133
1221
|
}
|
|
1134
1222
|
parse(hex) {
|