@taquito/local-forging 11.2.0 → 12.0.1
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/codec.js +20 -1
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/constants.js +17 -2
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/error.js +28 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/interface.js +3 -0
- package/dist/lib/interface.js.map +1 -0
- package/dist/lib/proto12-ithaca/codec.js +8 -0
- package/dist/lib/proto12-ithaca/codec.js.map +1 -0
- package/dist/lib/proto12-ithaca/constants.js +27 -0
- package/dist/lib/proto12-ithaca/constants.js.map +1 -0
- package/dist/lib/proto12-ithaca/decoder.js +23 -0
- package/dist/lib/proto12-ithaca/decoder.js.map +1 -0
- package/dist/lib/proto12-ithaca/encoder.js +23 -0
- package/dist/lib/proto12-ithaca/encoder.js.map +1 -0
- package/dist/lib/proto12-ithaca/schema.js +33 -0
- package/dist/lib/proto12-ithaca/schema.js.map +1 -0
- package/dist/lib/schema/operation.js +1 -1
- package/dist/lib/schema/operation.js.map +1 -1
- package/dist/lib/taquito-local-forging.js +58 -13
- 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 +245 -17
- package/dist/taquito-local-forging.es6.js.map +1 -1
- package/dist/taquito-local-forging.umd.js +243 -15
- package/dist/taquito-local-forging.umd.js.map +1 -1
- package/dist/types/codec.d.ts +2 -0
- package/dist/types/constants.d.ts +14 -0
- package/dist/types/error.d.ts +15 -0
- package/dist/types/interface.d.ts +9 -0
- package/dist/types/proto12-ithaca/codec.d.ts +2 -0
- package/dist/types/proto12-ithaca/constants.d.ts +9 -0
- package/dist/types/proto12-ithaca/decoder.d.ts +4 -0
- package/dist/types/proto12-ithaca/encoder.d.ts +4 -0
- package/dist/types/proto12-ithaca/schema.d.ts +18 -0
- package/dist/types/taquito-local-forging.d.ts +8 -5
- package/dist/types/validator.d.ts +11 -0
- package/package.json +4 -4
|
@@ -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'), '');
|
|
@@ -27,6 +27,7 @@ var CODEC;
|
|
|
27
27
|
CODEC["PROPOSAL"] = "proposal";
|
|
28
28
|
CODEC["PROPOSAL_ARR"] = "proposalArr";
|
|
29
29
|
CODEC["INT32"] = "int32";
|
|
30
|
+
CODEC["INT16"] = "int16";
|
|
30
31
|
CODEC["PARAMETERS"] = "parameters";
|
|
31
32
|
CODEC["ADDRESS"] = "address";
|
|
32
33
|
CODEC["OPERATION"] = "operation";
|
|
@@ -212,7 +213,7 @@ const kindMapping = {
|
|
|
212
213
|
0x00: 'endorsement',
|
|
213
214
|
0x01: 'seed_nonce_revelation',
|
|
214
215
|
0x05: 'proposals',
|
|
215
|
-
0x6f: 'register_global_constant'
|
|
216
|
+
0x6f: 'register_global_constant',
|
|
216
217
|
};
|
|
217
218
|
const kindMappingReverse = (() => {
|
|
218
219
|
const result = {};
|
|
@@ -236,7 +237,21 @@ const entrypointMappingReverse = (() => {
|
|
|
236
237
|
result[entrypointMapping[key]] = key;
|
|
237
238
|
});
|
|
238
239
|
return result;
|
|
239
|
-
})();
|
|
240
|
+
})();
|
|
241
|
+
var ProtocolsHash;
|
|
242
|
+
(function (ProtocolsHash) {
|
|
243
|
+
ProtocolsHash["Pt24m4xi"] = "Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd";
|
|
244
|
+
ProtocolsHash["PsBABY5H"] = "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU";
|
|
245
|
+
ProtocolsHash["PsBabyM1"] = "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS";
|
|
246
|
+
ProtocolsHash["PsCARTHA"] = "PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb";
|
|
247
|
+
ProtocolsHash["PsDELPH1"] = "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo";
|
|
248
|
+
ProtocolsHash["PtEdo2Zk"] = "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA";
|
|
249
|
+
ProtocolsHash["PsFLorena"] = "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i";
|
|
250
|
+
ProtocolsHash["PtGRANADs"] = "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV";
|
|
251
|
+
ProtocolsHash["PtHangz2"] = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx";
|
|
252
|
+
ProtocolsHash["PsiThaCa"] = "PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP";
|
|
253
|
+
ProtocolsHash["Psithaca2"] = "Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A";
|
|
254
|
+
})(ProtocolsHash || (ProtocolsHash = {}));
|
|
240
255
|
|
|
241
256
|
class Uint8ArrayConsumer {
|
|
242
257
|
constructor(arr, offset = 0) {
|
|
@@ -593,6 +608,23 @@ const int32Decoder = (val) => {
|
|
|
593
608
|
}
|
|
594
609
|
return finalNum;
|
|
595
610
|
};
|
|
611
|
+
const int16Encoder = (val) => {
|
|
612
|
+
const num = parseInt(String(val), 10);
|
|
613
|
+
const byte = [];
|
|
614
|
+
for (let i = 0; i < 2; i++) {
|
|
615
|
+
const shiftBy = (2 - (i + 1)) * 8;
|
|
616
|
+
byte.push((num & (0xff << shiftBy)) >> shiftBy);
|
|
617
|
+
}
|
|
618
|
+
return Buffer.from(byte).toString('hex');
|
|
619
|
+
};
|
|
620
|
+
const int16Decoder = (val) => {
|
|
621
|
+
const num = val.consume(2);
|
|
622
|
+
let finalNum = 0;
|
|
623
|
+
for (let i = 0; i < num.length; i++) {
|
|
624
|
+
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
|
|
625
|
+
}
|
|
626
|
+
return finalNum;
|
|
627
|
+
};
|
|
596
628
|
const boolDecoder = (val) => {
|
|
597
629
|
const bool = val.consume(1);
|
|
598
630
|
return bool[0] === 0xff;
|
|
@@ -893,7 +925,7 @@ const schemaDecoder = (decoders) => (schema) => (value) => {
|
|
|
893
925
|
else {
|
|
894
926
|
const decoder = decoders[valueToEncode];
|
|
895
927
|
const result = decoder(value);
|
|
896
|
-
if (result) {
|
|
928
|
+
if (typeof result !== 'undefined') {
|
|
897
929
|
return Object.assign(Object.assign({}, prev), { [key]: result });
|
|
898
930
|
}
|
|
899
931
|
else {
|
|
@@ -965,30 +997,226 @@ encoders[CODEC.OP_REVEAL] = (val) => schemaEncoder(encoders)(RevealSchema)(val);
|
|
|
965
997
|
encoders[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encoders)(RegisterGlobalConstantSchema)(val);
|
|
966
998
|
encoders[CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema);
|
|
967
999
|
|
|
1000
|
+
const blockPayloadHashEncoder = prefixEncoder(Prefix.VH);
|
|
1001
|
+
const blockPayloadHashDecoder = prefixDecoder(Prefix.VH);
|
|
1002
|
+
|
|
1003
|
+
/*! *****************************************************************************
|
|
1004
|
+
Copyright (c) Microsoft Corporation.
|
|
1005
|
+
|
|
1006
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1007
|
+
purpose with or without fee is hereby granted.
|
|
1008
|
+
|
|
1009
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1010
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1011
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1012
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1013
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1014
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1015
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1016
|
+
***************************************************************************** */
|
|
1017
|
+
|
|
1018
|
+
function __rest(s, e) {
|
|
1019
|
+
var t = {};
|
|
1020
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1021
|
+
t[p] = s[p];
|
|
1022
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1023
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1024
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1025
|
+
t[p[i]] = s[p[i]];
|
|
1026
|
+
}
|
|
1027
|
+
return t;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
const kindMappingNoEndorsement = __rest(kindMapping, ["0"]);
|
|
1031
|
+
const kindMappingProto12 = Object.assign(Object.assign({}, kindMappingNoEndorsement), { 0x15: 'endorsement' });
|
|
1032
|
+
const kindMappingReverseProto12 = (() => {
|
|
1033
|
+
const result = {};
|
|
1034
|
+
Object.keys(kindMappingProto12).forEach((key) => {
|
|
1035
|
+
const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
|
|
1036
|
+
result[kindMappingProto12[keyNum]] = pad(keyNum, 2);
|
|
1037
|
+
});
|
|
1038
|
+
return result;
|
|
1039
|
+
})();
|
|
1040
|
+
|
|
1041
|
+
const EndorsementSchemaProto12 = {
|
|
1042
|
+
slot: 'int16',
|
|
1043
|
+
level: 'int32',
|
|
1044
|
+
round: 'int32',
|
|
1045
|
+
block_payload_hash: 'blockPayloadHash',
|
|
1046
|
+
};
|
|
1047
|
+
const operationEncoderProto12 = (encoders) => (operation) => {
|
|
1048
|
+
if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverseProto12)) {
|
|
1049
|
+
throw new Error(`Unsupported operation kind: ${operation.kind}`);
|
|
1050
|
+
}
|
|
1051
|
+
return kindMappingReverseProto12[operation.kind] + encoders[operation.kind](operation);
|
|
1052
|
+
};
|
|
1053
|
+
const operationDecoderProto12 = (decoders) => (value) => {
|
|
1054
|
+
const op = value.consume(1);
|
|
1055
|
+
const operationName = kindMappingProto12[op[0]];
|
|
1056
|
+
const decodedObj = decoders[operationName](value);
|
|
1057
|
+
if (typeof decodedObj !== 'object') {
|
|
1058
|
+
throw new Error('Decoded invalid operation');
|
|
1059
|
+
}
|
|
1060
|
+
if (operationName) {
|
|
1061
|
+
return Object.assign({ kind: operationName }, decodedObj);
|
|
1062
|
+
}
|
|
1063
|
+
else {
|
|
1064
|
+
throw new Error(`Unsupported operation ${op[0]}`);
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
const decodersProto12 = Object.assign(Object.assign({}, decoders), { [CODEC.INT16]: int16Decoder, ["blockPayloadHash" /* BLOCK_PAYLOAD_HASH */]: blockPayloadHashDecoder });
|
|
1069
|
+
decodersProto12[CODEC.OPERATION] = operationDecoderProto12(decodersProto12);
|
|
1070
|
+
decodersProto12[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder(decodersProto12)(ActivationSchema)(val);
|
|
1071
|
+
decodersProto12[CODEC.OP_DELEGATION] = (val) => schemaDecoder(decodersProto12)(DelegationSchema)(val);
|
|
1072
|
+
decodersProto12[CODEC.OP_TRANSACTION] = (val) => schemaDecoder(decodersProto12)(TransactionSchema)(val);
|
|
1073
|
+
decodersProto12[CODEC.OP_ORIGINATION] = (val) => schemaDecoder(decodersProto12)(OriginationSchema)(val);
|
|
1074
|
+
decodersProto12[CODEC.OP_BALLOT] = (val) => schemaDecoder(decodersProto12)(BallotSchema)(val);
|
|
1075
|
+
decodersProto12[CODEC.OP_ENDORSEMENT] = (val) => schemaDecoder(decodersProto12)(EndorsementSchemaProto12)(val);
|
|
1076
|
+
decodersProto12[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder(decodersProto12)(SeedNonceRevelationSchema)(val);
|
|
1077
|
+
decodersProto12[CODEC.OP_PROPOSALS] = (val) => schemaDecoder(decodersProto12)(ProposalsSchema)(val);
|
|
1078
|
+
decodersProto12[CODEC.OP_REVEAL] = (val) => schemaDecoder(decodersProto12)(RevealSchema)(val);
|
|
1079
|
+
decodersProto12[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decodersProto12)(RegisterGlobalConstantSchema)(val);
|
|
1080
|
+
decodersProto12[CODEC.MANAGER] = schemaDecoder(decodersProto12)(ManagerOperationSchema);
|
|
1081
|
+
|
|
1082
|
+
const encodersProto12 = Object.assign(Object.assign({}, encoders), { [CODEC.INT16]: int16Encoder, ["blockPayloadHash" /* BLOCK_PAYLOAD_HASH */]: blockPayloadHashEncoder });
|
|
1083
|
+
encodersProto12[CODEC.OPERATION] = operationEncoderProto12(encodersProto12);
|
|
1084
|
+
encodersProto12[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder(encodersProto12)(ActivationSchema)(val);
|
|
1085
|
+
encodersProto12[CODEC.OP_DELEGATION] = (val) => schemaEncoder(encodersProto12)(DelegationSchema)(val);
|
|
1086
|
+
encodersProto12[CODEC.OP_TRANSACTION] = (val) => schemaEncoder(encodersProto12)(TransactionSchema)(val);
|
|
1087
|
+
encodersProto12[CODEC.OP_ORIGINATION] = (val) => schemaEncoder(encodersProto12)(OriginationSchema)(val);
|
|
1088
|
+
encodersProto12[CODEC.OP_BALLOT] = (val) => schemaEncoder(encodersProto12)(BallotSchema)(val);
|
|
1089
|
+
encodersProto12[CODEC.OP_ENDORSEMENT] = (val) => schemaEncoder(encodersProto12)(EndorsementSchemaProto12)(val);
|
|
1090
|
+
encodersProto12[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder(encodersProto12)(SeedNonceRevelationSchema)(val);
|
|
1091
|
+
encodersProto12[CODEC.OP_PROPOSALS] = (val) => schemaEncoder(encodersProto12)(ProposalsSchema)(val);
|
|
1092
|
+
encodersProto12[CODEC.OP_REVEAL] = (val) => schemaEncoder(encodersProto12)(RevealSchema)(val);
|
|
1093
|
+
encodersProto12[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encodersProto12)(RegisterGlobalConstantSchema)(val);
|
|
1094
|
+
encodersProto12[CODEC.MANAGER] = schemaEncoder(encodersProto12)(ManagerOperationSchema);
|
|
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
|
+
|
|
968
1158
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
969
1159
|
const VERSION = {
|
|
970
|
-
"commitHash": "
|
|
971
|
-
"version": "
|
|
1160
|
+
"commitHash": "8203ea7669c742797022f1b61f2577bcac50ca55",
|
|
1161
|
+
"version": "12.0.1"
|
|
972
1162
|
};
|
|
973
1163
|
|
|
974
1164
|
/**
|
|
975
1165
|
* @packageDocumentation
|
|
976
1166
|
* @module @taquito/local-forging
|
|
977
1167
|
*/
|
|
978
|
-
function getCodec(codec) {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1168
|
+
function getCodec(codec, proto) {
|
|
1169
|
+
if (proto === ProtocolsHash.Psithaca2) {
|
|
1170
|
+
return {
|
|
1171
|
+
encoder: encodersProto12[codec],
|
|
1172
|
+
decoder: (hex) => {
|
|
1173
|
+
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
1174
|
+
return decodersProto12[codec](consumer);
|
|
1175
|
+
},
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
return {
|
|
1180
|
+
encoder: encoders[codec],
|
|
1181
|
+
decoder: (hex) => {
|
|
1182
|
+
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
1183
|
+
return decoders[codec](consumer);
|
|
1184
|
+
},
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
986
1187
|
}
|
|
987
1188
|
class LocalForger {
|
|
988
|
-
constructor() {
|
|
989
|
-
this.
|
|
1189
|
+
constructor(protocolHash = ProtocolsHash.Psithaca2) {
|
|
1190
|
+
this.protocolHash = protocolHash;
|
|
1191
|
+
this.codec = getCodec(CODEC.MANAGER, this.protocolHash);
|
|
990
1192
|
}
|
|
991
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
|
+
}
|
|
992
1220
|
return Promise.resolve(this.codec.encoder(params));
|
|
993
1221
|
}
|
|
994
1222
|
parse(hex) {
|
|
@@ -997,5 +1225,5 @@ class LocalForger {
|
|
|
997
1225
|
}
|
|
998
1226
|
const localForger = new LocalForger();
|
|
999
1227
|
|
|
1000
|
-
export { CODEC, LocalForger, Uint8ArrayConsumer, VERSION, decoders, encoders, getCodec, localForger };
|
|
1228
|
+
export { CODEC, LocalForger, ProtocolsHash, Uint8ArrayConsumer, VERSION, decoders, encoders, getCodec, localForger };
|
|
1001
1229
|
//# sourceMappingURL=taquito-local-forging.es6.js.map
|