@taquito/local-forging 21.0.4-beta.2 → 22.0.0-beta.0
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-proto021.js +515 -0
- package/dist/lib/codec.js +50 -2
- package/dist/lib/constants-proto021.js +285 -0
- package/dist/lib/constants.js +1 -0
- package/dist/lib/decoder-proto021.js +62 -0
- package/dist/lib/decoder.js +1 -0
- package/dist/lib/encoder-proto021.js +61 -0
- package/dist/lib/encoder.js +1 -0
- package/dist/lib/protocols.js +3 -1
- package/dist/lib/schema/operation-proto021.js +237 -0
- package/dist/lib/schema/operation.js +1 -0
- package/dist/lib/taquito-local-forging.js +33 -9
- package/dist/lib/version.js +2 -2
- package/dist/taquito-local-forging.es6.js +1446 -276
- package/dist/taquito-local-forging.es6.js.map +1 -1
- package/dist/taquito-local-forging.umd.js +1545 -375
- package/dist/taquito-local-forging.umd.js.map +1 -1
- package/dist/types/codec-proto021.d.ts +77 -0
- package/dist/types/codec.d.ts +2 -0
- package/dist/types/constants-proto021.d.ts +73 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/decoder-proto021.d.ts +5 -0
- package/dist/types/encoder-proto021.d.ts +4 -0
- package/dist/types/protocols.d.ts +1 -0
- package/dist/types/schema/operation-proto021.d.ts +187 -0
- package/dist/types/schema/operation.d.ts +1 -0
- package/dist/types/taquito-local-forging.d.ts +3 -2
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Prefix, buf2hex, b58cdecode, prefix, prefixLength, b58cencode, InvalidKeyHashError, invalidDetail, ValidationResult, InvalidPublicKeyError, validateBlock } from '@taquito/utils';
|
|
2
|
-
import { ParameterValidationError, InvalidHexStringError, InvalidAddressError, InvalidContractAddressError, InvalidOperationKindError, InvalidBlockHashError } from '@taquito/core';
|
|
2
|
+
import { ParameterValidationError, InvalidHexStringError, InvalidAddressError, InvalidContractAddressError, InvalidSignatureError, ProhibitedActionError, InvalidOperationKindError, InvalidBlockHashError } from '@taquito/core';
|
|
3
3
|
import BigNumber$1, { BigNumber } from 'bignumber.js';
|
|
4
4
|
|
|
5
5
|
const toHexString = (bytes) => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
|
|
@@ -12,8 +12,8 @@ const pad = (num, paddingLen = 8) => {
|
|
|
12
12
|
* Copyright (c) 2018 Andrew Kishino
|
|
13
13
|
*/
|
|
14
14
|
// See: https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
15
|
-
const ENTRYPOINT_MAX_LENGTH = 31;
|
|
16
|
-
var CODEC;
|
|
15
|
+
const ENTRYPOINT_MAX_LENGTH$1 = 31;
|
|
16
|
+
var CODEC$1;
|
|
17
17
|
(function (CODEC) {
|
|
18
18
|
CODEC["SECRET"] = "secret";
|
|
19
19
|
CODEC["RAW"] = "raw";
|
|
@@ -58,6 +58,7 @@ var CODEC;
|
|
|
58
58
|
CODEC["BURN_LIMIT"] = "burn_limit";
|
|
59
59
|
CODEC["OP_INCREASE_PAID_STORAGE"] = "increase_paid_storage";
|
|
60
60
|
CODEC["OP_UPDATE_CONSENSUS_KEY"] = "update_consensus_key";
|
|
61
|
+
CODEC["SIGNATURE_PROOF"] = "signature_proof";
|
|
61
62
|
CODEC["OP_DRAIN_DELEGATE"] = "drain_delegate";
|
|
62
63
|
CODEC["DEPOSITS_LIMIT"] = "deposits_limit";
|
|
63
64
|
CODEC["OP_SET_DEPOSITS_LIMIT"] = "set_deposits_limit";
|
|
@@ -67,9 +68,9 @@ var CODEC;
|
|
|
67
68
|
CODEC["OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE"] = "smart_rollup_execute_outbox_message";
|
|
68
69
|
CODEC["OP_DAL_PUBLISH_COMMITMENT"] = "dal_publish_commitment";
|
|
69
70
|
CODEC["SLOT_HEADER"] = "slot_header";
|
|
70
|
-
})(CODEC || (CODEC = {}));
|
|
71
|
+
})(CODEC$1 || (CODEC$1 = {}));
|
|
71
72
|
// See https://tezos.gitlab.io/shell/p2p_api.html#alpha-michelson-v1-primitives-enumeration-unsigned-8-bit-integer
|
|
72
|
-
const opMapping = {
|
|
73
|
+
const opMapping$1 = {
|
|
73
74
|
'00': 'parameter',
|
|
74
75
|
'01': 'storage',
|
|
75
76
|
'02': 'code',
|
|
@@ -231,13 +232,13 @@ const opMapping = {
|
|
|
231
232
|
};
|
|
232
233
|
const opMappingReverse = (() => {
|
|
233
234
|
const result = {};
|
|
234
|
-
Object.keys(opMapping).forEach((key) => {
|
|
235
|
-
result[opMapping[key]] = key;
|
|
235
|
+
Object.keys(opMapping$1).forEach((key) => {
|
|
236
|
+
result[opMapping$1[key]] = key;
|
|
236
237
|
});
|
|
237
238
|
return result;
|
|
238
239
|
})();
|
|
239
240
|
// See https://tezos.gitlab.io/shell/p2p_api.html
|
|
240
|
-
const kindMapping = {
|
|
241
|
+
const kindMapping$1 = {
|
|
241
242
|
0x04: 'activate_account',
|
|
242
243
|
0x6b: 'reveal',
|
|
243
244
|
0x6e: 'delegation',
|
|
@@ -260,16 +261,16 @@ const kindMapping = {
|
|
|
260
261
|
0xe6: 'dal_publish_commitment',
|
|
261
262
|
0x11: 'failing_noop',
|
|
262
263
|
};
|
|
263
|
-
const kindMappingReverse = (() => {
|
|
264
|
+
const kindMappingReverse$1 = (() => {
|
|
264
265
|
const result = {};
|
|
265
|
-
Object.keys(kindMapping).forEach((key) => {
|
|
266
|
+
Object.keys(kindMapping$1).forEach((key) => {
|
|
266
267
|
const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
|
|
267
|
-
result[kindMapping[keyNum]] = pad(keyNum, 2);
|
|
268
|
+
result[kindMapping$1[keyNum]] = pad(keyNum, 2);
|
|
268
269
|
});
|
|
269
270
|
return result;
|
|
270
271
|
})();
|
|
271
272
|
// See https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
272
|
-
const entrypointMapping = {
|
|
273
|
+
const entrypointMapping$1 = {
|
|
273
274
|
'00': 'default',
|
|
274
275
|
'01': 'root',
|
|
275
276
|
'02': 'do',
|
|
@@ -281,10 +282,10 @@ const entrypointMapping = {
|
|
|
281
282
|
'08': 'finalize_unstake',
|
|
282
283
|
'09': 'set_delegate_parameters',
|
|
283
284
|
};
|
|
284
|
-
const entrypointMappingReverse = (() => {
|
|
285
|
+
const entrypointMappingReverse$1 = (() => {
|
|
285
286
|
const result = {};
|
|
286
|
-
Object.keys(entrypointMapping).forEach((key) => {
|
|
287
|
-
result[entrypointMapping[key]] = key;
|
|
287
|
+
Object.keys(entrypointMapping$1).forEach((key) => {
|
|
288
|
+
result[entrypointMapping$1[key]] = key;
|
|
288
289
|
});
|
|
289
290
|
return result;
|
|
290
291
|
})();
|
|
@@ -311,7 +312,7 @@ class OversizedEntryPointError extends ParameterValidationError {
|
|
|
311
312
|
super();
|
|
312
313
|
this.entrypoint = entrypoint;
|
|
313
314
|
this.name = 'OversizedEntryPointError';
|
|
314
|
-
this.message = `Invalid entrypoint length "${entrypoint.length}", maximum length is "${ENTRYPOINT_MAX_LENGTH}".`;
|
|
315
|
+
this.message = `Invalid entrypoint length "${entrypoint.length}", maximum length is "${ENTRYPOINT_MAX_LENGTH$1}".`;
|
|
315
316
|
}
|
|
316
317
|
}
|
|
317
318
|
/**
|
|
@@ -666,12 +667,12 @@ const primDecoder = (value, preamble) => {
|
|
|
666
667
|
let argsCount = Math.floor((preamble[0] - 0x03) / 2);
|
|
667
668
|
const op = value.consume(1)[0].toString(16).padStart(2, '0');
|
|
668
669
|
const result = {
|
|
669
|
-
prim: opMapping[op],
|
|
670
|
+
prim: opMapping$1[op],
|
|
670
671
|
};
|
|
671
|
-
if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
|
|
672
|
+
if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
|
|
672
673
|
value.consume(4);
|
|
673
674
|
}
|
|
674
|
-
if (opMapping[op] === 'view') {
|
|
675
|
+
if (opMapping$1[op] === 'view') {
|
|
675
676
|
if (argsCount != 0) {
|
|
676
677
|
return primViewDecoder(value, result);
|
|
677
678
|
}
|
|
@@ -681,13 +682,13 @@ const primDecoder = (value, preamble) => {
|
|
|
681
682
|
}
|
|
682
683
|
let combPairArgs;
|
|
683
684
|
let combPairAnnots;
|
|
684
|
-
if ((opMapping[op] === 'pair' || opMapping[op] === 'Pair') && argsCount > 2) {
|
|
685
|
+
if ((opMapping$1[op] === 'pair' || opMapping$1[op] === 'Pair') && argsCount > 2) {
|
|
685
686
|
combPairArgs = decodeCombPair(value);
|
|
686
687
|
argsCount = 0;
|
|
687
688
|
combPairAnnots = decodeAnnots(value);
|
|
688
689
|
}
|
|
689
690
|
const args = new Array(argsCount).fill(0).map(() => valueDecoder(value));
|
|
690
|
-
if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
|
|
691
|
+
if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
|
|
691
692
|
value.consume(4);
|
|
692
693
|
}
|
|
693
694
|
if (combPairArgs) {
|
|
@@ -736,59 +737,62 @@ const decodeAnnots = (val) => {
|
|
|
736
737
|
};
|
|
737
738
|
|
|
738
739
|
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
|
|
739
|
-
const prefixEncoder = (prefix$1) => (str) => {
|
|
740
|
+
const prefixEncoder$1 = (prefix$1) => (str) => {
|
|
740
741
|
return buf2hex(Buffer.from(b58cdecode(str, prefix[prefix$1])));
|
|
741
742
|
};
|
|
742
|
-
const prefixDecoder = (pre) => (str) => {
|
|
743
|
+
const prefixDecoder$1 = (pre) => (str) => {
|
|
743
744
|
const val = str.consume(prefixLength[pre]);
|
|
744
745
|
return b58cencode(val, prefix[pre]);
|
|
745
746
|
};
|
|
746
|
-
const tz1Decoder = prefixDecoder(Prefix.TZ1);
|
|
747
|
-
const branchDecoder = prefixDecoder(Prefix.B);
|
|
748
|
-
const publicKeyHashDecoder = (val) => {
|
|
747
|
+
const tz1Decoder$1 = prefixDecoder$1(Prefix.TZ1);
|
|
748
|
+
const branchDecoder$1 = prefixDecoder$1(Prefix.B);
|
|
749
|
+
const publicKeyHashDecoder$1 = (val) => {
|
|
749
750
|
const prefix = val.consume(1);
|
|
750
751
|
if (prefix[0] === 0x00) {
|
|
751
|
-
return prefixDecoder(Prefix.TZ1)(val);
|
|
752
|
+
return prefixDecoder$1(Prefix.TZ1)(val);
|
|
752
753
|
}
|
|
753
754
|
else if (prefix[0] === 0x01) {
|
|
754
|
-
return prefixDecoder(Prefix.TZ2)(val);
|
|
755
|
+
return prefixDecoder$1(Prefix.TZ2)(val);
|
|
755
756
|
}
|
|
756
757
|
else if (prefix[0] === 0x02) {
|
|
757
|
-
return prefixDecoder(Prefix.TZ3)(val);
|
|
758
|
+
return prefixDecoder$1(Prefix.TZ3)(val);
|
|
759
|
+
}
|
|
760
|
+
else if (prefix[0] === 0x03) {
|
|
761
|
+
return prefixDecoder$1(Prefix.TZ4)(val);
|
|
758
762
|
}
|
|
759
763
|
};
|
|
760
|
-
const publicKeyHashesDecoder = (val) => {
|
|
761
|
-
if (!boolDecoder(val)) {
|
|
762
|
-
return
|
|
764
|
+
const publicKeyHashesDecoder$1 = (val) => {
|
|
765
|
+
if (!boolDecoder$1(val)) {
|
|
766
|
+
return;
|
|
763
767
|
}
|
|
764
768
|
const publicKeyHashes = [];
|
|
765
769
|
val.consume(4);
|
|
766
770
|
while (val.length() > 0) {
|
|
767
|
-
publicKeyHashes.push(publicKeyHashDecoder(val));
|
|
771
|
+
publicKeyHashes.push(publicKeyHashDecoder$1(val));
|
|
768
772
|
}
|
|
769
773
|
return publicKeyHashes;
|
|
770
774
|
};
|
|
771
|
-
const branchEncoder = prefixEncoder(Prefix.B);
|
|
772
|
-
const tz1Encoder = prefixEncoder(Prefix.TZ1);
|
|
773
|
-
const boolEncoder = (bool) => (bool ? 'ff' : '00');
|
|
774
|
-
const proposalEncoder = (proposal) => {
|
|
775
|
-
return prefixEncoder(Prefix.P)(proposal);
|
|
775
|
+
const branchEncoder$1 = prefixEncoder$1(Prefix.B);
|
|
776
|
+
const tz1Encoder$1 = prefixEncoder$1(Prefix.TZ1);
|
|
777
|
+
const boolEncoder$1 = (bool) => (bool ? 'ff' : '00');
|
|
778
|
+
const proposalEncoder$1 = (proposal) => {
|
|
779
|
+
return prefixEncoder$1(Prefix.P)(proposal);
|
|
776
780
|
};
|
|
777
|
-
const proposalDecoder = (proposal) => {
|
|
778
|
-
return prefixDecoder(Prefix.P)(proposal);
|
|
781
|
+
const proposalDecoder$1 = (proposal) => {
|
|
782
|
+
return prefixDecoder$1(Prefix.P)(proposal);
|
|
779
783
|
};
|
|
780
|
-
const proposalsDecoder = (proposal) => {
|
|
784
|
+
const proposalsDecoder$1 = (proposal) => {
|
|
781
785
|
const proposals = [];
|
|
782
786
|
proposal.consume(4);
|
|
783
787
|
while (proposal.length() > 0) {
|
|
784
|
-
proposals.push(proposalDecoder(proposal));
|
|
788
|
+
proposals.push(proposalDecoder$1(proposal));
|
|
785
789
|
}
|
|
786
790
|
return proposals;
|
|
787
791
|
};
|
|
788
|
-
const proposalsEncoder = (proposals) => {
|
|
789
|
-
return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder(x)).join('');
|
|
792
|
+
const proposalsEncoder$1 = (proposals) => {
|
|
793
|
+
return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder$1(x)).join('');
|
|
790
794
|
};
|
|
791
|
-
const ballotEncoder = (ballot) => {
|
|
795
|
+
const ballotEncoder$1 = (ballot) => {
|
|
792
796
|
switch (ballot) {
|
|
793
797
|
case 'yay':
|
|
794
798
|
return '00';
|
|
@@ -800,7 +804,7 @@ const ballotEncoder = (ballot) => {
|
|
|
800
804
|
throw new InvalidBallotValueError(ballot);
|
|
801
805
|
}
|
|
802
806
|
};
|
|
803
|
-
const ballotDecoder = (ballot) => {
|
|
807
|
+
const ballotDecoder$1 = (ballot) => {
|
|
804
808
|
const value = ballot.consume(1);
|
|
805
809
|
switch (value[0]) {
|
|
806
810
|
case 0x00:
|
|
@@ -813,7 +817,7 @@ const ballotDecoder = (ballot) => {
|
|
|
813
817
|
throw new DecodeBallotValueError(value[0].toString());
|
|
814
818
|
}
|
|
815
819
|
};
|
|
816
|
-
const pvmKindEncoder = (pvm) => {
|
|
820
|
+
const pvmKindEncoder$1 = (pvm) => {
|
|
817
821
|
switch (pvm) {
|
|
818
822
|
case 'arith':
|
|
819
823
|
return '00';
|
|
@@ -825,7 +829,7 @@ const pvmKindEncoder = (pvm) => {
|
|
|
825
829
|
throw new UnsupportedPvmKindError(pvm);
|
|
826
830
|
}
|
|
827
831
|
};
|
|
828
|
-
const pvmKindDecoder = (pvm) => {
|
|
832
|
+
const pvmKindDecoder$1 = (pvm) => {
|
|
829
833
|
const value = pvm.consume(1);
|
|
830
834
|
switch (value[0]) {
|
|
831
835
|
case 0x00:
|
|
@@ -838,15 +842,15 @@ const pvmKindDecoder = (pvm) => {
|
|
|
838
842
|
throw new DecodePvmKindError(value[0].toString());
|
|
839
843
|
}
|
|
840
844
|
};
|
|
841
|
-
const delegateEncoder = (val) => {
|
|
845
|
+
const delegateEncoder$1 = (val) => {
|
|
842
846
|
if (val) {
|
|
843
|
-
return boolEncoder(true) + publicKeyHashEncoder(val);
|
|
847
|
+
return boolEncoder$1(true) + publicKeyHashEncoder$1(val);
|
|
844
848
|
}
|
|
845
849
|
else {
|
|
846
|
-
return boolEncoder(false);
|
|
850
|
+
return boolEncoder$1(false);
|
|
847
851
|
}
|
|
848
852
|
};
|
|
849
|
-
const int32Encoder = (val) => {
|
|
853
|
+
const int32Encoder$1 = (val) => {
|
|
850
854
|
const num = parseInt(String(val), 10);
|
|
851
855
|
const byte = [];
|
|
852
856
|
for (let i = 0; i < 4; i++) {
|
|
@@ -855,7 +859,7 @@ const int32Encoder = (val) => {
|
|
|
855
859
|
}
|
|
856
860
|
return Buffer.from(byte).toString('hex');
|
|
857
861
|
};
|
|
858
|
-
const int32Decoder = (val) => {
|
|
862
|
+
const int32Decoder$1 = (val) => {
|
|
859
863
|
const num = val.consume(4);
|
|
860
864
|
let finalNum = 0;
|
|
861
865
|
for (let i = 0; i < num.length; i++) {
|
|
@@ -863,7 +867,7 @@ const int32Decoder = (val) => {
|
|
|
863
867
|
}
|
|
864
868
|
return finalNum;
|
|
865
869
|
};
|
|
866
|
-
const int16Encoder = (val) => {
|
|
870
|
+
const int16Encoder$1 = (val) => {
|
|
867
871
|
const num = parseInt(String(val), 10);
|
|
868
872
|
const byte = [];
|
|
869
873
|
for (let i = 0; i < 2; i++) {
|
|
@@ -872,7 +876,7 @@ const int16Encoder = (val) => {
|
|
|
872
876
|
}
|
|
873
877
|
return Buffer.from(byte).toString('hex');
|
|
874
878
|
};
|
|
875
|
-
const int16Decoder = (val) => {
|
|
879
|
+
const int16Decoder$1 = (val) => {
|
|
876
880
|
const num = val.consume(2);
|
|
877
881
|
let finalNum = 0;
|
|
878
882
|
for (let i = 0; i < num.length; i++) {
|
|
@@ -880,113 +884,117 @@ const int16Decoder = (val) => {
|
|
|
880
884
|
}
|
|
881
885
|
return finalNum;
|
|
882
886
|
};
|
|
883
|
-
const boolDecoder = (val) => {
|
|
887
|
+
const boolDecoder$1 = (val) => {
|
|
884
888
|
const bool = val.consume(1);
|
|
885
889
|
return bool[0] === 0xff;
|
|
886
890
|
};
|
|
887
|
-
const delegateDecoder = (val) => {
|
|
888
|
-
const hasDelegate = boolDecoder(val);
|
|
891
|
+
const delegateDecoder$1 = (val) => {
|
|
892
|
+
const hasDelegate = boolDecoder$1(val);
|
|
889
893
|
if (hasDelegate) {
|
|
890
|
-
return publicKeyHashDecoder(val);
|
|
894
|
+
return publicKeyHashDecoder$1(val);
|
|
891
895
|
}
|
|
892
896
|
};
|
|
893
|
-
const publicKeyHashEncoder = (val) => {
|
|
897
|
+
const publicKeyHashEncoder$1 = (val) => {
|
|
894
898
|
const pubkeyPrefix = val.substring(0, 3);
|
|
895
899
|
switch (pubkeyPrefix) {
|
|
896
900
|
case Prefix.TZ1:
|
|
897
|
-
return '00' + prefixEncoder(Prefix.TZ1)(val);
|
|
901
|
+
return '00' + prefixEncoder$1(Prefix.TZ1)(val);
|
|
898
902
|
case Prefix.TZ2:
|
|
899
|
-
return '01' + prefixEncoder(Prefix.TZ2)(val);
|
|
903
|
+
return '01' + prefixEncoder$1(Prefix.TZ2)(val);
|
|
900
904
|
case Prefix.TZ3:
|
|
901
|
-
return '02' + prefixEncoder(Prefix.TZ3)(val);
|
|
905
|
+
return '02' + prefixEncoder$1(Prefix.TZ3)(val);
|
|
902
906
|
case Prefix.TZ4:
|
|
903
|
-
return '03' + prefixEncoder(Prefix.TZ4)(val);
|
|
907
|
+
return '03' + prefixEncoder$1(Prefix.TZ4)(val);
|
|
904
908
|
default:
|
|
905
909
|
throw new InvalidKeyHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
906
910
|
` expecting one for the following "${Prefix.TZ1}", "${Prefix.TZ2}", "${Prefix.TZ3}" or "${Prefix.TZ4}".`);
|
|
907
911
|
}
|
|
908
912
|
};
|
|
909
|
-
const publicKeyHashesEncoder = (val) => {
|
|
913
|
+
const publicKeyHashesEncoder$1 = (val) => {
|
|
910
914
|
if (!val) {
|
|
911
|
-
return boolEncoder(false);
|
|
915
|
+
return boolEncoder$1(false);
|
|
912
916
|
}
|
|
913
917
|
if (val.length === 0) {
|
|
914
|
-
return boolEncoder(true) + pad(0);
|
|
918
|
+
return boolEncoder$1(true) + pad(0);
|
|
915
919
|
}
|
|
916
920
|
const publicKeyHashes = val.reduce((prev, curr) => {
|
|
917
|
-
return prev + publicKeyHashEncoder(curr);
|
|
921
|
+
return prev + publicKeyHashEncoder$1(curr);
|
|
918
922
|
}, '');
|
|
919
|
-
return boolEncoder(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
|
|
923
|
+
return boolEncoder$1(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
|
|
920
924
|
};
|
|
921
|
-
const publicKeyEncoder = (val) => {
|
|
925
|
+
const publicKeyEncoder$1 = (val) => {
|
|
922
926
|
const pubkeyPrefix = val.substring(0, 4);
|
|
923
927
|
switch (pubkeyPrefix) {
|
|
924
928
|
case Prefix.EDPK:
|
|
925
|
-
return '00' + prefixEncoder(Prefix.EDPK)(val);
|
|
929
|
+
return '00' + prefixEncoder$1(Prefix.EDPK)(val);
|
|
926
930
|
case Prefix.SPPK:
|
|
927
|
-
return '01' + prefixEncoder(Prefix.SPPK)(val);
|
|
931
|
+
return '01' + prefixEncoder$1(Prefix.SPPK)(val);
|
|
928
932
|
case Prefix.P2PK:
|
|
929
|
-
return '02' + prefixEncoder(Prefix.P2PK)(val);
|
|
933
|
+
return '02' + prefixEncoder$1(Prefix.P2PK)(val);
|
|
934
|
+
case Prefix.BLPK:
|
|
935
|
+
return '03' + prefixEncoder$1(Prefix.BLPK)(val);
|
|
930
936
|
default:
|
|
931
937
|
throw new InvalidPublicKeyError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
932
938
|
` expecting one of the following '${Prefix.EDPK}', '${Prefix.SPPK}', '${Prefix.P2PK}' or '${Prefix.BLPK}'.`);
|
|
933
939
|
}
|
|
934
940
|
};
|
|
935
|
-
const addressEncoder = (val) => {
|
|
941
|
+
const addressEncoder$1 = (val) => {
|
|
936
942
|
const pubkeyPrefix = val.substring(0, 3);
|
|
937
943
|
switch (pubkeyPrefix) {
|
|
938
944
|
case Prefix.TZ1:
|
|
939
945
|
case Prefix.TZ2:
|
|
940
946
|
case Prefix.TZ3:
|
|
941
947
|
case Prefix.TZ4:
|
|
942
|
-
return '00' + publicKeyHashEncoder(val);
|
|
948
|
+
return '00' + publicKeyHashEncoder$1(val);
|
|
943
949
|
case Prefix.KT1:
|
|
944
|
-
return '01' + prefixEncoder(Prefix.KT1)(val) + '00';
|
|
950
|
+
return '01' + prefixEncoder$1(Prefix.KT1)(val) + '00';
|
|
945
951
|
default:
|
|
946
952
|
throw new InvalidAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
947
953
|
` expecting one of the following prefix '${Prefix.TZ1}', ${Prefix.TZ2}', '${Prefix.TZ3}', '${Prefix.TZ4}' or '${Prefix.KT1}'.`);
|
|
948
954
|
}
|
|
949
955
|
};
|
|
950
|
-
const smartRollupAddressEncoder = (val) => {
|
|
956
|
+
const smartRollupAddressEncoder$1 = (val) => {
|
|
951
957
|
if (val.substring(0, 3) !== Prefix.SR1) {
|
|
952
958
|
throw new InvalidSmartRollupAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SR1}'.`);
|
|
953
959
|
}
|
|
954
|
-
return prefixEncoder(Prefix.SR1)(val);
|
|
960
|
+
return prefixEncoder$1(Prefix.SR1)(val);
|
|
955
961
|
};
|
|
956
|
-
const smartContractAddressEncoder = (val) => {
|
|
962
|
+
const smartContractAddressEncoder$1 = (val) => {
|
|
957
963
|
const prefix = val.substring(0, 3);
|
|
958
964
|
if (prefix === Prefix.KT1) {
|
|
959
|
-
return '01' + prefixEncoder(Prefix.KT1)(val) + '00';
|
|
965
|
+
return '01' + prefixEncoder$1(Prefix.KT1)(val) + '00';
|
|
960
966
|
}
|
|
961
967
|
throw new InvalidContractAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.KT1}'.`);
|
|
962
968
|
};
|
|
963
|
-
const publicKeyDecoder = (val) => {
|
|
969
|
+
const publicKeyDecoder$1 = (val) => {
|
|
964
970
|
const preamble = val.consume(1);
|
|
965
971
|
switch (preamble[0]) {
|
|
966
972
|
case 0x00:
|
|
967
|
-
return prefixDecoder(Prefix.EDPK)(val);
|
|
973
|
+
return prefixDecoder$1(Prefix.EDPK)(val);
|
|
968
974
|
case 0x01:
|
|
969
|
-
return prefixDecoder(Prefix.SPPK)(val);
|
|
975
|
+
return prefixDecoder$1(Prefix.SPPK)(val);
|
|
970
976
|
case 0x02:
|
|
971
|
-
return prefixDecoder(Prefix.P2PK)(val);
|
|
977
|
+
return prefixDecoder$1(Prefix.P2PK)(val);
|
|
978
|
+
case 0x03:
|
|
979
|
+
return prefixDecoder$1(Prefix.BLPK)(val);
|
|
972
980
|
default:
|
|
973
981
|
throw new InvalidPublicKeyError(val.toString(), invalidDetail(ValidationResult.NO_PREFIX_MATCHED));
|
|
974
982
|
}
|
|
975
983
|
};
|
|
976
|
-
const smartRollupCommitmentHashEncoder = (val) => {
|
|
984
|
+
const smartRollupCommitmentHashEncoder$1 = (val) => {
|
|
977
985
|
const prefix = val.substring(0, 4);
|
|
978
986
|
if (prefix === Prefix.SRC1) {
|
|
979
|
-
return prefixEncoder(Prefix.SRC1)(val);
|
|
987
|
+
return prefixEncoder$1(Prefix.SRC1)(val);
|
|
980
988
|
}
|
|
981
989
|
throw new InvalidSmartRollupCommitmentHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
982
990
|
};
|
|
983
|
-
const addressDecoder = (val) => {
|
|
991
|
+
const addressDecoder$1 = (val) => {
|
|
984
992
|
const preamble = val.consume(1);
|
|
985
993
|
switch (preamble[0]) {
|
|
986
994
|
case 0x00:
|
|
987
|
-
return publicKeyHashDecoder(val);
|
|
995
|
+
return publicKeyHashDecoder$1(val);
|
|
988
996
|
case 0x01: {
|
|
989
|
-
const address = prefixDecoder(Prefix.KT1)(val);
|
|
997
|
+
const address = prefixDecoder$1(Prefix.KT1)(val);
|
|
990
998
|
val.consume(1);
|
|
991
999
|
return address;
|
|
992
1000
|
}
|
|
@@ -994,30 +1002,30 @@ const addressDecoder = (val) => {
|
|
|
994
1002
|
throw new InvalidAddressError(val.toString(), ': Unable to decode.');
|
|
995
1003
|
}
|
|
996
1004
|
};
|
|
997
|
-
const smartRollupAddressDecoder = (val) => {
|
|
998
|
-
const address = prefixDecoder(Prefix.SR1)(val);
|
|
1005
|
+
const smartRollupAddressDecoder$1 = (val) => {
|
|
1006
|
+
const address = prefixDecoder$1(Prefix.SR1)(val);
|
|
999
1007
|
if (address.substring(0, 3) !== Prefix.SR1) {
|
|
1000
1008
|
throw new InvalidSmartRollupAddressError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SR1}'.`);
|
|
1001
1009
|
}
|
|
1002
1010
|
return address;
|
|
1003
1011
|
};
|
|
1004
|
-
const smartContractAddressDecoder = (val) => {
|
|
1012
|
+
const smartContractAddressDecoder$1 = (val) => {
|
|
1005
1013
|
const preamble = val.consume(1);
|
|
1006
1014
|
if (preamble[0] === 0x01) {
|
|
1007
|
-
const scAddress = prefixDecoder(Prefix.KT1)(val);
|
|
1015
|
+
const scAddress = prefixDecoder$1(Prefix.KT1)(val);
|
|
1008
1016
|
val.consume(1);
|
|
1009
1017
|
return scAddress;
|
|
1010
1018
|
}
|
|
1011
1019
|
throw new InvalidContractAddressError(val.toString(), invalidDetail(ValidationResult.NO_PREFIX_MATCHED));
|
|
1012
1020
|
};
|
|
1013
|
-
const smartRollupCommitmentHashDecoder = (val) => {
|
|
1014
|
-
const address = prefixDecoder(Prefix.SRC1)(val);
|
|
1021
|
+
const smartRollupCommitmentHashDecoder$1 = (val) => {
|
|
1022
|
+
const address = prefixDecoder$1(Prefix.SRC1)(val);
|
|
1015
1023
|
if (address.substring(0, 4) !== Prefix.SRC1) {
|
|
1016
1024
|
throw new InvalidSmartRollupCommitmentHashError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
1017
1025
|
}
|
|
1018
1026
|
return address;
|
|
1019
1027
|
};
|
|
1020
|
-
const zarithEncoder = (n) => {
|
|
1028
|
+
const zarithEncoder$1 = (n) => {
|
|
1021
1029
|
const fn = [];
|
|
1022
1030
|
let nn = new BigNumber$1(n, 10);
|
|
1023
1031
|
if (nn.isNaN()) {
|
|
@@ -1041,7 +1049,7 @@ const zarithEncoder = (n) => {
|
|
|
1041
1049
|
}
|
|
1042
1050
|
return fn.join('');
|
|
1043
1051
|
};
|
|
1044
|
-
const zarithDecoder = (n) => {
|
|
1052
|
+
const zarithDecoder$1 = (n) => {
|
|
1045
1053
|
let mostSignificantByte = 0;
|
|
1046
1054
|
while (mostSignificantByte < n.length() && (n.get(mostSignificantByte) & 128) !== 0) {
|
|
1047
1055
|
mostSignificantByte += 1;
|
|
@@ -1055,27 +1063,27 @@ const zarithDecoder = (n) => {
|
|
|
1055
1063
|
n.consume(mostSignificantByte + 1);
|
|
1056
1064
|
return new BigNumber$1(num).toString();
|
|
1057
1065
|
};
|
|
1058
|
-
const entrypointDecoder = (value) => {
|
|
1066
|
+
const entrypointDecoder$1 = (value) => {
|
|
1059
1067
|
const preamble = pad(value.consume(1)[0], 2);
|
|
1060
|
-
if (preamble in entrypointMapping) {
|
|
1061
|
-
return entrypointMapping[preamble];
|
|
1068
|
+
if (preamble in entrypointMapping$1) {
|
|
1069
|
+
return entrypointMapping$1[preamble];
|
|
1062
1070
|
}
|
|
1063
1071
|
else {
|
|
1064
1072
|
const entry = extractRequiredLen(value, 1);
|
|
1065
1073
|
const entrypoint = Buffer.from(entry).toString('utf8');
|
|
1066
|
-
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
|
|
1074
|
+
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
|
|
1067
1075
|
throw new OversizedEntryPointError(entrypoint);
|
|
1068
1076
|
}
|
|
1069
1077
|
return entrypoint;
|
|
1070
1078
|
}
|
|
1071
1079
|
};
|
|
1072
|
-
const parametersDecoder = (val) => {
|
|
1080
|
+
const parametersDecoder$1 = (val) => {
|
|
1073
1081
|
const preamble = val.consume(1);
|
|
1074
1082
|
if (preamble[0] === 0x00) {
|
|
1075
1083
|
return;
|
|
1076
1084
|
}
|
|
1077
1085
|
else {
|
|
1078
|
-
const encodedEntrypoint = entrypointDecoder(val);
|
|
1086
|
+
const encodedEntrypoint = entrypointDecoder$1(val);
|
|
1079
1087
|
const params = extractRequiredLen(val);
|
|
1080
1088
|
const parameters = valueDecoder(new Uint8ArrayConsumer(params));
|
|
1081
1089
|
return {
|
|
@@ -1084,171 +1092,1227 @@ const parametersDecoder = (val) => {
|
|
|
1084
1092
|
};
|
|
1085
1093
|
}
|
|
1086
1094
|
};
|
|
1087
|
-
const entrypointEncoder = (entrypoint) => {
|
|
1088
|
-
if (entrypoint in entrypointMappingReverse) {
|
|
1089
|
-
return `${entrypointMappingReverse[entrypoint]}`;
|
|
1095
|
+
const entrypointEncoder$1 = (entrypoint) => {
|
|
1096
|
+
if (entrypoint in entrypointMappingReverse$1) {
|
|
1097
|
+
return `${entrypointMappingReverse$1[entrypoint]}`;
|
|
1090
1098
|
}
|
|
1091
1099
|
else {
|
|
1092
|
-
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
|
|
1100
|
+
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
|
|
1093
1101
|
throw new OversizedEntryPointError(entrypoint);
|
|
1094
1102
|
}
|
|
1095
1103
|
const value = { string: entrypoint };
|
|
1096
1104
|
return `ff${valueEncoder(value).slice(8)}`;
|
|
1097
1105
|
}
|
|
1098
1106
|
};
|
|
1099
|
-
const parametersEncoder = (val) => {
|
|
1107
|
+
const parametersEncoder$1 = (val) => {
|
|
1100
1108
|
if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
|
|
1101
1109
|
return '00';
|
|
1102
1110
|
}
|
|
1103
|
-
const encodedEntrypoint = entrypointEncoder(val.entrypoint);
|
|
1111
|
+
const encodedEntrypoint = entrypointEncoder$1(val.entrypoint);
|
|
1104
1112
|
const parameters = valueEncoder(val.value);
|
|
1105
1113
|
const length = pad(parameters.length / 2);
|
|
1106
1114
|
return `ff${encodedEntrypoint}${length}${parameters}`;
|
|
1107
1115
|
};
|
|
1108
|
-
const valueParameterEncoder = (value) => {
|
|
1116
|
+
const valueParameterEncoder$1 = (value) => {
|
|
1109
1117
|
const valueEncoded = valueEncoder(value);
|
|
1110
1118
|
return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
|
|
1111
1119
|
};
|
|
1112
|
-
const valueParameterDecoder = (val) => {
|
|
1120
|
+
const valueParameterDecoder$1 = (val) => {
|
|
1113
1121
|
const value = extractRequiredLen(val);
|
|
1114
1122
|
return valueDecoder(new Uint8ArrayConsumer(value));
|
|
1115
1123
|
};
|
|
1116
|
-
const blockPayloadHashEncoder = prefixEncoder(Prefix.VH);
|
|
1117
|
-
const blockPayloadHashDecoder = prefixDecoder(Prefix.VH);
|
|
1118
|
-
const entrypointNameEncoder = (entrypoint) => {
|
|
1124
|
+
const blockPayloadHashEncoder$1 = prefixEncoder$1(Prefix.VH);
|
|
1125
|
+
const blockPayloadHashDecoder$1 = prefixDecoder$1(Prefix.VH);
|
|
1126
|
+
const entrypointNameEncoder$1 = (entrypoint) => {
|
|
1119
1127
|
const value = { string: entrypoint };
|
|
1120
1128
|
return `${valueEncoder(value).slice(2)}`;
|
|
1121
1129
|
};
|
|
1122
|
-
const entrypointNameDecoder = (val) => {
|
|
1130
|
+
const entrypointNameDecoder$1 = (val) => {
|
|
1123
1131
|
const entry = extractRequiredLen(val);
|
|
1124
1132
|
return Buffer.from(entry).toString('utf8');
|
|
1125
1133
|
};
|
|
1126
|
-
const burnLimitEncoder = (val) => {
|
|
1127
|
-
return !val ? '00' : `ff${zarithEncoder(val)}`;
|
|
1134
|
+
const burnLimitEncoder$1 = (val) => {
|
|
1135
|
+
return !val ? '00' : `ff${zarithEncoder$1(val)}`;
|
|
1128
1136
|
};
|
|
1129
|
-
const burnLimitDecoder = (value) => {
|
|
1137
|
+
const burnLimitDecoder$1 = (value) => {
|
|
1130
1138
|
const prefix = value.consume(1);
|
|
1131
1139
|
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
1132
|
-
return zarithDecoder(value);
|
|
1140
|
+
return zarithDecoder$1(value);
|
|
1133
1141
|
}
|
|
1134
1142
|
};
|
|
1135
|
-
const depositsLimitEncoder = (val) => {
|
|
1136
|
-
return !val ? '00' : `ff${zarithEncoder(val)}`;
|
|
1143
|
+
const depositsLimitEncoder$1 = (val) => {
|
|
1144
|
+
return !val ? '00' : `ff${zarithEncoder$1(val)}`;
|
|
1137
1145
|
};
|
|
1138
|
-
const depositsLimitDecoder = (value) => {
|
|
1146
|
+
const depositsLimitDecoder$1 = (value) => {
|
|
1139
1147
|
const prefix = value.consume(1);
|
|
1140
1148
|
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
1141
|
-
return zarithDecoder(value);
|
|
1149
|
+
return zarithDecoder$1(value);
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
const signatureV1Encoder = (val) => {
|
|
1153
|
+
const signaturePrefix = val.substring(0, 5);
|
|
1154
|
+
switch (signaturePrefix) {
|
|
1155
|
+
case Prefix.EDSIG:
|
|
1156
|
+
return paddedBytesEncoder$1(prefixEncoder$1(Prefix.EDSIG)(val));
|
|
1157
|
+
case Prefix.SPSIG:
|
|
1158
|
+
return paddedBytesEncoder$1(prefixEncoder$1(Prefix.SPSIG)(val));
|
|
1159
|
+
case Prefix.P2SIG:
|
|
1160
|
+
return paddedBytesEncoder$1(prefixEncoder$1(Prefix.P2SIG)(val));
|
|
1161
|
+
case Prefix.BLSIG:
|
|
1162
|
+
return paddedBytesEncoder$1(prefixEncoder$1(Prefix.BLSIG)(val));
|
|
1163
|
+
default:
|
|
1164
|
+
throw new InvalidSignatureError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
1165
|
+
` expecting one of the following '${Prefix.EDSIG}', '${Prefix.SPSIG}', '${Prefix.P2SIG}' or '${Prefix.BLSIG}'.`);
|
|
1142
1166
|
}
|
|
1143
1167
|
};
|
|
1144
|
-
const
|
|
1168
|
+
const signatureV1Decoder = (val) => {
|
|
1169
|
+
val.consume(4);
|
|
1170
|
+
if (val.length().toString() === '96') {
|
|
1171
|
+
return prefixDecoder$1(Prefix.BLSIG)(val);
|
|
1172
|
+
}
|
|
1173
|
+
else {
|
|
1174
|
+
throw new ProhibitedActionError('currently we only support decoding of BLSIG signatures');
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
const signatureProofEncoder = (val) => {
|
|
1178
|
+
if (val) {
|
|
1179
|
+
return boolEncoder$1(true) + signatureV1Encoder(val);
|
|
1180
|
+
}
|
|
1181
|
+
else {
|
|
1182
|
+
return boolEncoder$1(false);
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
const signatureProofDecoder = (value) => {
|
|
1186
|
+
const hasProof = boolDecoder$1(value);
|
|
1187
|
+
if (hasProof) {
|
|
1188
|
+
return signatureV1Decoder(value);
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
const paddedBytesEncoder$1 = (val, paddingLength = 8) => {
|
|
1145
1192
|
return `${pad(val.length / 2, paddingLength)}${val}`;
|
|
1146
1193
|
};
|
|
1147
|
-
const paddedBytesDecoder = (val) => {
|
|
1194
|
+
const paddedBytesDecoder$1 = (val) => {
|
|
1148
1195
|
const value = extractRequiredLen(val);
|
|
1149
1196
|
return Buffer.from(value).toString('hex');
|
|
1150
1197
|
};
|
|
1151
|
-
const smartRollupMessageEncoder = (val) => {
|
|
1198
|
+
const smartRollupMessageEncoder$1 = (val) => {
|
|
1152
1199
|
const message = val.reduce((prev, curr) => {
|
|
1153
1200
|
return prev + `${pad(curr.length / 2)}${curr}`;
|
|
1154
1201
|
}, '');
|
|
1155
1202
|
return `${pad(message.length / 2)}${message}`;
|
|
1156
1203
|
};
|
|
1157
|
-
const smartRollupMessageDecoder = (val) => {
|
|
1204
|
+
const smartRollupMessageDecoder$1 = (val) => {
|
|
1158
1205
|
const valueArray = extractRequiredLen(val);
|
|
1159
1206
|
const ret = stripLengthPrefixFromBytes(new Uint8ArrayConsumer(valueArray));
|
|
1160
1207
|
return ret.map((value) => Buffer.from(value).toString('hex'));
|
|
1161
1208
|
};
|
|
1162
|
-
const dalCommitmentEncoder = (val) => {
|
|
1209
|
+
const dalCommitmentEncoder$1 = (val) => {
|
|
1163
1210
|
const prefix = val.substring(0, 2);
|
|
1164
1211
|
if (prefix === Prefix.SH) {
|
|
1165
|
-
return prefixEncoder(Prefix.SH)(val);
|
|
1212
|
+
return prefixEncoder$1(Prefix.SH)(val);
|
|
1166
1213
|
}
|
|
1167
1214
|
throw new InvalidDalCommitmentError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
1168
1215
|
};
|
|
1169
|
-
const dalCommitmentDecoder = (val) => {
|
|
1170
|
-
const commitment = prefixDecoder(Prefix.SH)(val);
|
|
1216
|
+
const dalCommitmentDecoder$1 = (val) => {
|
|
1217
|
+
const commitment = prefixDecoder$1(Prefix.SH)(val);
|
|
1171
1218
|
if (commitment.substring(0, 2) !== Prefix.SH) {
|
|
1172
1219
|
throw new InvalidDalCommitmentError(commitment, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
1173
1220
|
}
|
|
1174
1221
|
return commitment;
|
|
1175
1222
|
};
|
|
1176
|
-
const slotHeaderEncoder = (val) => {
|
|
1177
|
-
return pad(val.slot_index, 2) + dalCommitmentEncoder(val.commitment) + val.commitment_proof;
|
|
1223
|
+
const slotHeaderEncoder$1 = (val) => {
|
|
1224
|
+
return pad(val.slot_index, 2) + dalCommitmentEncoder$1(val.commitment) + val.commitment_proof;
|
|
1178
1225
|
};
|
|
1179
|
-
const slotHeaderDecoder = (val) => {
|
|
1226
|
+
const slotHeaderDecoder$1 = (val) => {
|
|
1180
1227
|
const preamble = val.consume(1);
|
|
1181
1228
|
return {
|
|
1182
1229
|
slot_index: Number(preamble[0].toString(10)),
|
|
1183
|
-
commitment: dalCommitmentDecoder(val),
|
|
1230
|
+
commitment: dalCommitmentDecoder$1(val),
|
|
1184
1231
|
commitment_proof: toHexString(val.consume(96)), // rpcForger expect commitment_proof bytes to be len 96
|
|
1185
1232
|
};
|
|
1186
1233
|
};
|
|
1187
1234
|
|
|
1188
|
-
const ManagerOperationSchema = {
|
|
1189
|
-
branch: CODEC.BRANCH,
|
|
1190
|
-
contents: [CODEC.OPERATION],
|
|
1191
|
-
};
|
|
1192
|
-
const ActivationSchema = {
|
|
1193
|
-
pkh: CODEC.TZ1,
|
|
1194
|
-
secret: CODEC.SECRET,
|
|
1195
|
-
};
|
|
1196
|
-
const RevealSchema = {
|
|
1197
|
-
source: CODEC.PKH,
|
|
1198
|
-
fee: CODEC.ZARITH,
|
|
1199
|
-
counter: CODEC.ZARITH,
|
|
1200
|
-
gas_limit: CODEC.ZARITH,
|
|
1201
|
-
storage_limit: CODEC.ZARITH,
|
|
1202
|
-
public_key: CODEC.PUBLIC_KEY,
|
|
1203
|
-
};
|
|
1204
|
-
const DelegationSchema = {
|
|
1205
|
-
source: CODEC.PKH,
|
|
1206
|
-
fee: CODEC.ZARITH,
|
|
1207
|
-
counter: CODEC.ZARITH,
|
|
1208
|
-
gas_limit: CODEC.ZARITH,
|
|
1209
|
-
storage_limit: CODEC.ZARITH,
|
|
1210
|
-
delegate: CODEC.DELEGATE,
|
|
1211
|
-
};
|
|
1212
|
-
const TransactionSchema = {
|
|
1213
|
-
source: CODEC.PKH,
|
|
1214
|
-
fee: CODEC.ZARITH,
|
|
1215
|
-
counter: CODEC.ZARITH,
|
|
1216
|
-
gas_limit: CODEC.ZARITH,
|
|
1217
|
-
storage_limit: CODEC.ZARITH,
|
|
1218
|
-
amount: CODEC.ZARITH,
|
|
1219
|
-
destination: CODEC.ADDRESS,
|
|
1220
|
-
parameters: CODEC.PARAMETERS,
|
|
1221
|
-
};
|
|
1222
|
-
const OriginationSchema = {
|
|
1223
|
-
source: CODEC.PKH,
|
|
1224
|
-
fee: CODEC.ZARITH,
|
|
1225
|
-
counter: CODEC.ZARITH,
|
|
1226
|
-
gas_limit: CODEC.ZARITH,
|
|
1227
|
-
storage_limit: CODEC.ZARITH,
|
|
1228
|
-
balance: CODEC.ZARITH,
|
|
1229
|
-
delegate: CODEC.DELEGATE,
|
|
1230
|
-
script: CODEC.SCRIPT,
|
|
1235
|
+
const ManagerOperationSchema$1 = {
|
|
1236
|
+
branch: CODEC$1.BRANCH,
|
|
1237
|
+
contents: [CODEC$1.OPERATION],
|
|
1238
|
+
};
|
|
1239
|
+
const ActivationSchema$1 = {
|
|
1240
|
+
pkh: CODEC$1.TZ1,
|
|
1241
|
+
secret: CODEC$1.SECRET,
|
|
1242
|
+
};
|
|
1243
|
+
const RevealSchema$1 = {
|
|
1244
|
+
source: CODEC$1.PKH,
|
|
1245
|
+
fee: CODEC$1.ZARITH,
|
|
1246
|
+
counter: CODEC$1.ZARITH,
|
|
1247
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1248
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1249
|
+
public_key: CODEC$1.PUBLIC_KEY,
|
|
1250
|
+
};
|
|
1251
|
+
const DelegationSchema$1 = {
|
|
1252
|
+
source: CODEC$1.PKH,
|
|
1253
|
+
fee: CODEC$1.ZARITH,
|
|
1254
|
+
counter: CODEC$1.ZARITH,
|
|
1255
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1256
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1257
|
+
delegate: CODEC$1.DELEGATE,
|
|
1258
|
+
};
|
|
1259
|
+
const TransactionSchema$1 = {
|
|
1260
|
+
source: CODEC$1.PKH,
|
|
1261
|
+
fee: CODEC$1.ZARITH,
|
|
1262
|
+
counter: CODEC$1.ZARITH,
|
|
1263
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1264
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1265
|
+
amount: CODEC$1.ZARITH,
|
|
1266
|
+
destination: CODEC$1.ADDRESS,
|
|
1267
|
+
parameters: CODEC$1.PARAMETERS,
|
|
1268
|
+
};
|
|
1269
|
+
const OriginationSchema$1 = {
|
|
1270
|
+
source: CODEC$1.PKH,
|
|
1271
|
+
fee: CODEC$1.ZARITH,
|
|
1272
|
+
counter: CODEC$1.ZARITH,
|
|
1273
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1274
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1275
|
+
balance: CODEC$1.ZARITH,
|
|
1276
|
+
delegate: CODEC$1.DELEGATE,
|
|
1277
|
+
script: CODEC$1.SCRIPT,
|
|
1278
|
+
};
|
|
1279
|
+
const BallotSchema$1 = {
|
|
1280
|
+
source: CODEC$1.PKH,
|
|
1281
|
+
period: CODEC$1.INT32,
|
|
1282
|
+
proposal: CODEC$1.PROPOSAL,
|
|
1283
|
+
ballot: CODEC$1.BALLOT_STATEMENT,
|
|
1284
|
+
};
|
|
1285
|
+
const AttestationSchema$1 = {
|
|
1286
|
+
slot: CODEC$1.INT16,
|
|
1287
|
+
level: CODEC$1.INT32,
|
|
1288
|
+
round: CODEC$1.INT32,
|
|
1289
|
+
block_payload_hash: CODEC$1.BLOCK_PAYLOAD_HASH,
|
|
1290
|
+
};
|
|
1291
|
+
const AttestationWithDalSchema$1 = {
|
|
1292
|
+
slot: CODEC$1.INT16,
|
|
1293
|
+
level: CODEC$1.INT32,
|
|
1294
|
+
round: CODEC$1.INT32,
|
|
1295
|
+
block_payload_hash: CODEC$1.BLOCK_PAYLOAD_HASH,
|
|
1296
|
+
dal_attestation: CODEC$1.ZARITH,
|
|
1297
|
+
};
|
|
1298
|
+
const SeedNonceRevelationSchema$1 = {
|
|
1299
|
+
level: CODEC$1.INT32,
|
|
1300
|
+
nonce: CODEC$1.RAW,
|
|
1301
|
+
};
|
|
1302
|
+
const ProposalsSchema$1 = {
|
|
1303
|
+
source: CODEC$1.PKH,
|
|
1304
|
+
period: CODEC$1.INT32,
|
|
1305
|
+
proposals: CODEC$1.PROPOSAL_ARR,
|
|
1306
|
+
};
|
|
1307
|
+
const RegisterGlobalConstantSchema$1 = {
|
|
1308
|
+
source: CODEC$1.PKH,
|
|
1309
|
+
fee: CODEC$1.ZARITH,
|
|
1310
|
+
counter: CODEC$1.ZARITH,
|
|
1311
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1312
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1313
|
+
value: CODEC$1.VALUE,
|
|
1314
|
+
};
|
|
1315
|
+
const TransferTicketSchema$1 = {
|
|
1316
|
+
source: CODEC$1.PKH,
|
|
1317
|
+
fee: CODEC$1.ZARITH,
|
|
1318
|
+
counter: CODEC$1.ZARITH,
|
|
1319
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1320
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1321
|
+
ticket_contents: CODEC$1.VALUE,
|
|
1322
|
+
ticket_ty: CODEC$1.VALUE,
|
|
1323
|
+
ticket_ticketer: CODEC$1.ADDRESS,
|
|
1324
|
+
ticket_amount: CODEC$1.ZARITH,
|
|
1325
|
+
destination: CODEC$1.ADDRESS,
|
|
1326
|
+
entrypoint: CODEC$1.ENTRYPOINT,
|
|
1327
|
+
};
|
|
1328
|
+
const IncreasePaidStorageSchema$1 = {
|
|
1329
|
+
source: CODEC$1.PKH,
|
|
1330
|
+
fee: CODEC$1.ZARITH,
|
|
1331
|
+
counter: CODEC$1.ZARITH,
|
|
1332
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1333
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1334
|
+
amount: CODEC$1.ZARITH,
|
|
1335
|
+
destination: CODEC$1.SMART_CONTRACT_ADDRESS,
|
|
1336
|
+
};
|
|
1337
|
+
const UpdateConsensusKeySchema$1 = {
|
|
1338
|
+
source: CODEC$1.PKH,
|
|
1339
|
+
fee: CODEC$1.ZARITH,
|
|
1340
|
+
counter: CODEC$1.ZARITH,
|
|
1341
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1342
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1343
|
+
pk: CODEC$1.PUBLIC_KEY,
|
|
1344
|
+
proof: CODEC$1.SIGNATURE_PROOF,
|
|
1345
|
+
};
|
|
1346
|
+
const DrainDelegateSchema$1 = {
|
|
1347
|
+
consensus_key: CODEC$1.PKH,
|
|
1348
|
+
delegate: CODEC$1.PKH,
|
|
1349
|
+
destination: CODEC$1.PKH,
|
|
1350
|
+
};
|
|
1351
|
+
const SetDepositsLimitSchema$1 = {
|
|
1352
|
+
source: CODEC$1.PKH,
|
|
1353
|
+
fee: CODEC$1.ZARITH,
|
|
1354
|
+
counter: CODEC$1.ZARITH,
|
|
1355
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1356
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1357
|
+
limit: CODEC$1.DEPOSITS_LIMIT,
|
|
1358
|
+
};
|
|
1359
|
+
const SmartRollupOriginateSchema$1 = {
|
|
1360
|
+
source: CODEC$1.PKH,
|
|
1361
|
+
fee: CODEC$1.ZARITH,
|
|
1362
|
+
counter: CODEC$1.ZARITH,
|
|
1363
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1364
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1365
|
+
pvm_kind: CODEC$1.PVM_KIND,
|
|
1366
|
+
kernel: CODEC$1.PADDED_BYTES,
|
|
1367
|
+
parameters_ty: CODEC$1.VALUE,
|
|
1368
|
+
whitelist: CODEC$1.PKH_ARR,
|
|
1369
|
+
};
|
|
1370
|
+
const SmartRollupAddMessagesSchema$1 = {
|
|
1371
|
+
source: CODEC$1.PKH,
|
|
1372
|
+
fee: CODEC$1.ZARITH,
|
|
1373
|
+
counter: CODEC$1.ZARITH,
|
|
1374
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1375
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1376
|
+
message: CODEC$1.SMART_ROLLUP_MESSAGE,
|
|
1377
|
+
};
|
|
1378
|
+
const SmartRollupExecuteOutboxMessageSchema$1 = {
|
|
1379
|
+
source: CODEC$1.PKH,
|
|
1380
|
+
fee: CODEC$1.ZARITH,
|
|
1381
|
+
counter: CODEC$1.ZARITH,
|
|
1382
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1383
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1384
|
+
rollup: CODEC$1.SMART_ROLLUP_ADDRESS,
|
|
1385
|
+
cemented_commitment: CODEC$1.SMART_ROLLUP_COMMITMENT_HASH,
|
|
1386
|
+
output_proof: CODEC$1.PADDED_BYTES,
|
|
1387
|
+
};
|
|
1388
|
+
const DalPublishCommitmentSchema$1 = {
|
|
1389
|
+
source: CODEC$1.PKH,
|
|
1390
|
+
fee: CODEC$1.ZARITH,
|
|
1391
|
+
counter: CODEC$1.ZARITH,
|
|
1392
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1393
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1394
|
+
slot_header: CODEC$1.SLOT_HEADER,
|
|
1395
|
+
};
|
|
1396
|
+
const FailingNoopSchema$1 = {
|
|
1397
|
+
arbitrary: CODEC$1.PADDED_BYTES,
|
|
1398
|
+
};
|
|
1399
|
+
const operationEncoder$1 = (encoders) => (operation) => {
|
|
1400
|
+
if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse$1)) {
|
|
1401
|
+
throw new InvalidOperationKindError(operation.kind);
|
|
1402
|
+
}
|
|
1403
|
+
return kindMappingReverse$1[operation.kind] + encoders[operation.kind](operation);
|
|
1231
1404
|
};
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1405
|
+
const operationDecoder$1 = (decoders) => (value) => {
|
|
1406
|
+
const op = value.consume(1);
|
|
1407
|
+
const operationName = kindMapping$1[op[0]];
|
|
1408
|
+
if (operationName === undefined) {
|
|
1409
|
+
throw new UnsupportedOperationError(op[0].toString());
|
|
1410
|
+
}
|
|
1411
|
+
const decodedObj = decoders[operationName](value);
|
|
1412
|
+
if (typeof decodedObj !== 'object') {
|
|
1413
|
+
throw new OperationDecodingError('Invalid operation, cannot be decoded.');
|
|
1414
|
+
}
|
|
1415
|
+
return Object.assign({ kind: operationName }, decodedObj);
|
|
1237
1416
|
};
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1417
|
+
const schemaEncoder$1 = (encoders) => (schema) => (value) => {
|
|
1418
|
+
const keys = Object.keys(schema);
|
|
1419
|
+
return keys.reduce((prev, key) => {
|
|
1420
|
+
const valueToEncode = schema[key];
|
|
1421
|
+
if (value && Array.isArray(valueToEncode)) {
|
|
1422
|
+
const encoder = encoders[valueToEncode[0]];
|
|
1423
|
+
const values = value[key];
|
|
1424
|
+
if (!Array.isArray(values)) {
|
|
1425
|
+
throw new OperationEncodingError(`Invalid operation value "${JSON.stringify(values)}" of key "${key}, expected value to be Array.`);
|
|
1426
|
+
}
|
|
1427
|
+
return (prev + values.reduce((prevBytes, current) => prevBytes + encoder(current), ''));
|
|
1428
|
+
}
|
|
1429
|
+
else {
|
|
1430
|
+
const encoder = encoders[valueToEncode];
|
|
1431
|
+
return prev + encoder(value[key]);
|
|
1432
|
+
}
|
|
1433
|
+
}, '');
|
|
1243
1434
|
};
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1435
|
+
const schemaDecoder$1 = (decoders) => (schema) => (value) => {
|
|
1436
|
+
const keys = Object.keys(schema);
|
|
1437
|
+
return keys.reduce((prev, key) => {
|
|
1438
|
+
const valueToEncode = schema[key];
|
|
1439
|
+
if (Array.isArray(valueToEncode)) {
|
|
1440
|
+
const decoder = decoders[valueToEncode[0]];
|
|
1441
|
+
const decoded = [];
|
|
1442
|
+
const lastLength = value.length();
|
|
1443
|
+
while (value.length() > 0) {
|
|
1444
|
+
decoded.push(decoder(value));
|
|
1445
|
+
if (lastLength === value.length()) {
|
|
1446
|
+
throw new OperationDecodingError('Unable to decode value');
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
return Object.assign(Object.assign({}, prev), { [key]: decoded });
|
|
1450
|
+
}
|
|
1451
|
+
else {
|
|
1452
|
+
const decoder = decoders[valueToEncode];
|
|
1453
|
+
const result = decoder(value);
|
|
1454
|
+
if (typeof result !== 'undefined') {
|
|
1455
|
+
return Object.assign(Object.assign({}, prev), { [key]: result });
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
return Object.assign({}, prev);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}, {});
|
|
1250
1462
|
};
|
|
1251
|
-
|
|
1463
|
+
|
|
1464
|
+
const decoders = {
|
|
1465
|
+
[CODEC$1.SECRET]: (val) => toHexString(val.consume(20)),
|
|
1466
|
+
[CODEC$1.RAW]: (val) => toHexString(val.consume(32)),
|
|
1467
|
+
[CODEC$1.TZ1]: tz1Decoder$1,
|
|
1468
|
+
[CODEC$1.BRANCH]: branchDecoder$1,
|
|
1469
|
+
[CODEC$1.ZARITH]: zarithDecoder$1,
|
|
1470
|
+
[CODEC$1.PUBLIC_KEY]: publicKeyDecoder$1,
|
|
1471
|
+
[CODEC$1.PKH]: publicKeyHashDecoder$1,
|
|
1472
|
+
[CODEC$1.PKH_ARR]: publicKeyHashesDecoder$1,
|
|
1473
|
+
[CODEC$1.DELEGATE]: delegateDecoder$1,
|
|
1474
|
+
[CODEC$1.INT32]: int32Decoder$1,
|
|
1475
|
+
[CODEC$1.SCRIPT]: scriptDecoder,
|
|
1476
|
+
[CODEC$1.BALLOT_STATEMENT]: ballotDecoder$1,
|
|
1477
|
+
[CODEC$1.PROPOSAL]: proposalDecoder$1,
|
|
1478
|
+
[CODEC$1.PROPOSAL_ARR]: proposalsDecoder$1,
|
|
1479
|
+
[CODEC$1.PARAMETERS]: parametersDecoder$1,
|
|
1480
|
+
[CODEC$1.ADDRESS]: addressDecoder$1,
|
|
1481
|
+
[CODEC$1.SMART_ROLLUP_ADDRESS]: smartRollupAddressDecoder$1,
|
|
1482
|
+
[CODEC$1.SMART_CONTRACT_ADDRESS]: smartContractAddressDecoder$1,
|
|
1483
|
+
[CODEC$1.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashDecoder$1,
|
|
1484
|
+
[CODEC$1.VALUE]: valueParameterDecoder$1,
|
|
1485
|
+
[CODEC$1.INT16]: int16Decoder$1,
|
|
1486
|
+
[CODEC$1.BLOCK_PAYLOAD_HASH]: blockPayloadHashDecoder$1,
|
|
1487
|
+
[CODEC$1.ENTRYPOINT]: entrypointNameDecoder$1,
|
|
1488
|
+
[CODEC$1.BURN_LIMIT]: burnLimitDecoder$1,
|
|
1489
|
+
[CODEC$1.DEPOSITS_LIMIT]: depositsLimitDecoder$1,
|
|
1490
|
+
[CODEC$1.SIGNATURE_PROOF]: signatureProofDecoder,
|
|
1491
|
+
[CODEC$1.PVM_KIND]: pvmKindDecoder$1,
|
|
1492
|
+
[CODEC$1.PADDED_BYTES]: paddedBytesDecoder$1,
|
|
1493
|
+
[CODEC$1.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder$1,
|
|
1494
|
+
[CODEC$1.SLOT_HEADER]: slotHeaderDecoder$1,
|
|
1495
|
+
};
|
|
1496
|
+
decoders[CODEC$1.OPERATION] = operationDecoder$1(decoders);
|
|
1497
|
+
decoders[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder$1(decoders)(ActivationSchema$1)(val);
|
|
1498
|
+
decoders[CODEC$1.OP_FAILING_NOOP] = (val) => schemaDecoder$1(decoders)(FailingNoopSchema$1)(val);
|
|
1499
|
+
decoders[CODEC$1.OP_DELEGATION] = (val) => schemaDecoder$1(decoders)(DelegationSchema$1)(val);
|
|
1500
|
+
decoders[CODEC$1.OP_TRANSACTION] = (val) => schemaDecoder$1(decoders)(TransactionSchema$1)(val);
|
|
1501
|
+
decoders[CODEC$1.OP_ORIGINATION] = (val) => schemaDecoder$1(decoders)(OriginationSchema$1)(val);
|
|
1502
|
+
decoders[CODEC$1.OP_BALLOT] = (val) => schemaDecoder$1(decoders)(BallotSchema$1)(val);
|
|
1503
|
+
decoders[CODEC$1.OP_ATTESTATION] = (val) => schemaDecoder$1(decoders)(AttestationSchema$1)(val);
|
|
1504
|
+
decoders[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder$1(decoders)(AttestationWithDalSchema$1)(val);
|
|
1505
|
+
decoders[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder$1(decoders)(SeedNonceRevelationSchema$1)(val);
|
|
1506
|
+
decoders[CODEC$1.OP_PROPOSALS] = (val) => schemaDecoder$1(decoders)(ProposalsSchema$1)(val);
|
|
1507
|
+
decoders[CODEC$1.OP_REVEAL] = (val) => schemaDecoder$1(decoders)(RevealSchema$1)(val);
|
|
1508
|
+
decoders[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder$1(decoders)(RegisterGlobalConstantSchema$1)(val);
|
|
1509
|
+
decoders[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaDecoder$1(decoders)(TransferTicketSchema$1)(val);
|
|
1510
|
+
decoders[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder$1(decoders)(IncreasePaidStorageSchema$1)(val);
|
|
1511
|
+
decoders[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder$1(decoders)(UpdateConsensusKeySchema$1)(val);
|
|
1512
|
+
decoders[CODEC$1.OP_DRAIN_DELEGATE] = (val) => schemaDecoder$1(decoders)(DrainDelegateSchema$1)(val);
|
|
1513
|
+
decoders[CODEC$1.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder$1(decoders)(SmartRollupOriginateSchema$1)(val);
|
|
1514
|
+
decoders[CODEC$1.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder$1(decoders)(SmartRollupAddMessagesSchema$1)(val);
|
|
1515
|
+
decoders[CODEC$1.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder$1(decoders)(SmartRollupExecuteOutboxMessageSchema$1)(val);
|
|
1516
|
+
decoders[CODEC$1.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder$1(decoders)(DalPublishCommitmentSchema$1)(val);
|
|
1517
|
+
decoders[CODEC$1.MANAGER] = schemaDecoder$1(decoders)(ManagerOperationSchema$1);
|
|
1518
|
+
decoders[CODEC$1.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder$1(decoders)(SetDepositsLimitSchema$1)(val);
|
|
1519
|
+
|
|
1520
|
+
/*
|
|
1521
|
+
* Some code in this file is originally from sotez
|
|
1522
|
+
* Copyright (c) 2018 Andrew Kishino
|
|
1523
|
+
*/
|
|
1524
|
+
// See: https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
1525
|
+
const ENTRYPOINT_MAX_LENGTH = 31;
|
|
1526
|
+
var CODEC;
|
|
1527
|
+
(function (CODEC) {
|
|
1528
|
+
CODEC["SECRET"] = "secret";
|
|
1529
|
+
CODEC["RAW"] = "raw";
|
|
1530
|
+
CODEC["TZ1"] = "tz1";
|
|
1531
|
+
CODEC["BRANCH"] = "branch";
|
|
1532
|
+
CODEC["ZARITH"] = "zarith";
|
|
1533
|
+
CODEC["PUBLIC_KEY"] = "public_key";
|
|
1534
|
+
CODEC["PKH"] = "pkh";
|
|
1535
|
+
CODEC["PKH_ARR"] = "pkhArr";
|
|
1536
|
+
CODEC["DELEGATE"] = "delegate";
|
|
1537
|
+
CODEC["SCRIPT"] = "script";
|
|
1538
|
+
CODEC["BALLOT_STATEMENT"] = "ballotStmt";
|
|
1539
|
+
CODEC["PROPOSAL"] = "proposal";
|
|
1540
|
+
CODEC["PROPOSAL_ARR"] = "proposalArr";
|
|
1541
|
+
CODEC["INT32"] = "int32";
|
|
1542
|
+
CODEC["INT16"] = "int16";
|
|
1543
|
+
CODEC["PARAMETERS"] = "parameters";
|
|
1544
|
+
CODEC["ADDRESS"] = "address";
|
|
1545
|
+
CODEC["SMART_CONTRACT_ADDRESS"] = "smart_contract_address";
|
|
1546
|
+
CODEC["SMART_ROLLUP_ADDRESS"] = "smart_rollup_address";
|
|
1547
|
+
CODEC["SMART_ROLLUP_COMMITMENT_HASH"] = "smart_rollup_commitment_hash";
|
|
1548
|
+
CODEC["VALUE"] = "value";
|
|
1549
|
+
CODEC["PADDED_BYTES"] = "padded_bytes";
|
|
1550
|
+
CODEC["SMART_ROLLUP_MESSAGE"] = "smart_rollup_message";
|
|
1551
|
+
CODEC["MANAGER"] = "manager";
|
|
1552
|
+
CODEC["BLOCK_PAYLOAD_HASH"] = "blockPayloadHash";
|
|
1553
|
+
CODEC["ENTRYPOINT"] = "entrypoint";
|
|
1554
|
+
CODEC["OPERATION"] = "operation";
|
|
1555
|
+
CODEC["OP_ACTIVATE_ACCOUNT"] = "activate_account";
|
|
1556
|
+
CODEC["OP_DELEGATION"] = "delegation";
|
|
1557
|
+
CODEC["OP_TRANSACTION"] = "transaction";
|
|
1558
|
+
CODEC["OP_ORIGINATION"] = "origination";
|
|
1559
|
+
CODEC["OP_BALLOT"] = "ballot";
|
|
1560
|
+
CODEC["OP_FAILING_NOOP"] = "failing_noop";
|
|
1561
|
+
CODEC["OP_ATTESTATION"] = "attestation";
|
|
1562
|
+
CODEC["OP_ATTESTATION_WITH_DAL"] = "attestation_with_dal";
|
|
1563
|
+
CODEC["OP_SEED_NONCE_REVELATION"] = "seed_nonce_revelation";
|
|
1564
|
+
CODEC["OP_REVEAL"] = "reveal";
|
|
1565
|
+
CODEC["OP_PROPOSALS"] = "proposals";
|
|
1566
|
+
CODEC["OP_REGISTER_GLOBAL_CONSTANT"] = "register_global_constant";
|
|
1567
|
+
CODEC["OP_TRANSFER_TICKET"] = "transfer_ticket";
|
|
1568
|
+
CODEC["BURN_LIMIT"] = "burn_limit";
|
|
1569
|
+
CODEC["OP_INCREASE_PAID_STORAGE"] = "increase_paid_storage";
|
|
1570
|
+
CODEC["OP_UPDATE_CONSENSUS_KEY"] = "update_consensus_key";
|
|
1571
|
+
CODEC["OP_DRAIN_DELEGATE"] = "drain_delegate";
|
|
1572
|
+
CODEC["DEPOSITS_LIMIT"] = "deposits_limit";
|
|
1573
|
+
CODEC["OP_SET_DEPOSITS_LIMIT"] = "set_deposits_limit";
|
|
1574
|
+
CODEC["OP_SMART_ROLLUP_ORIGINATE"] = "smart_rollup_originate";
|
|
1575
|
+
CODEC["PVM_KIND"] = "pvm_kind";
|
|
1576
|
+
CODEC["OP_SMART_ROLLUP_ADD_MESSAGES"] = "smart_rollup_add_messages";
|
|
1577
|
+
CODEC["OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE"] = "smart_rollup_execute_outbox_message";
|
|
1578
|
+
CODEC["OP_DAL_PUBLISH_COMMITMENT"] = "dal_publish_commitment";
|
|
1579
|
+
CODEC["SLOT_HEADER"] = "slot_header";
|
|
1580
|
+
})(CODEC || (CODEC = {}));
|
|
1581
|
+
// See https://tezos.gitlab.io/shell/p2p_api.html#alpha-michelson-v1-primitives-enumeration-unsigned-8-bit-integer
|
|
1582
|
+
const opMapping = {
|
|
1583
|
+
'00': 'parameter',
|
|
1584
|
+
'01': 'storage',
|
|
1585
|
+
'02': 'code',
|
|
1586
|
+
'03': 'False',
|
|
1587
|
+
'04': 'Elt',
|
|
1588
|
+
'05': 'Left',
|
|
1589
|
+
'06': 'None',
|
|
1590
|
+
'07': 'Pair',
|
|
1591
|
+
'08': 'Right',
|
|
1592
|
+
'09': 'Some',
|
|
1593
|
+
'0a': 'True',
|
|
1594
|
+
'0b': 'Unit',
|
|
1595
|
+
'0c': 'PACK',
|
|
1596
|
+
'0d': 'UNPACK',
|
|
1597
|
+
'0e': 'BLAKE2B',
|
|
1598
|
+
'0f': 'SHA256',
|
|
1599
|
+
'10': 'SHA512',
|
|
1600
|
+
'11': 'ABS',
|
|
1601
|
+
'12': 'ADD',
|
|
1602
|
+
'13': 'AMOUNT',
|
|
1603
|
+
'14': 'AND',
|
|
1604
|
+
'15': 'BALANCE',
|
|
1605
|
+
'16': 'CAR',
|
|
1606
|
+
'17': 'CDR',
|
|
1607
|
+
'18': 'CHECK_SIGNATURE',
|
|
1608
|
+
'19': 'COMPARE',
|
|
1609
|
+
'1a': 'CONCAT',
|
|
1610
|
+
'1b': 'CONS',
|
|
1611
|
+
'1c': 'CREATE_ACCOUNT', // Removed in Edo
|
|
1612
|
+
'1d': 'CREATE_CONTRACT', // Removed in Edo
|
|
1613
|
+
'1e': 'IMPLICIT_ACCOUNT',
|
|
1614
|
+
'1f': 'DIP',
|
|
1615
|
+
'20': 'DROP',
|
|
1616
|
+
'21': 'DUP',
|
|
1617
|
+
'22': 'EDIV',
|
|
1618
|
+
'23': 'EMPTY_MAP',
|
|
1619
|
+
'24': 'EMPTY_SET',
|
|
1620
|
+
'25': 'EQ',
|
|
1621
|
+
'26': 'EXEC',
|
|
1622
|
+
'27': 'FAILWITH',
|
|
1623
|
+
'28': 'GE',
|
|
1624
|
+
'29': 'GET',
|
|
1625
|
+
'2a': 'GT',
|
|
1626
|
+
'2b': 'HASH_KEY',
|
|
1627
|
+
'2c': 'IF',
|
|
1628
|
+
'2d': 'IF_CONS',
|
|
1629
|
+
'2e': 'IF_LEFT',
|
|
1630
|
+
'2f': 'IF_NONE',
|
|
1631
|
+
'30': 'INT',
|
|
1632
|
+
'31': 'LAMBDA',
|
|
1633
|
+
'32': 'LE',
|
|
1634
|
+
'33': 'LEFT',
|
|
1635
|
+
'34': 'LOOP',
|
|
1636
|
+
'35': 'LSL',
|
|
1637
|
+
'36': 'LSR',
|
|
1638
|
+
'37': 'LT',
|
|
1639
|
+
'38': 'MAP',
|
|
1640
|
+
'39': 'MEM',
|
|
1641
|
+
'3a': 'MUL',
|
|
1642
|
+
'3b': 'NEG',
|
|
1643
|
+
'3c': 'NEQ',
|
|
1644
|
+
'3d': 'NIL',
|
|
1645
|
+
'3e': 'NONE',
|
|
1646
|
+
'3f': 'NOT',
|
|
1647
|
+
'40': 'NOW',
|
|
1648
|
+
'41': 'OR',
|
|
1649
|
+
'42': 'PAIR',
|
|
1650
|
+
'43': 'PUSH',
|
|
1651
|
+
'44': 'RIGHT',
|
|
1652
|
+
'45': 'SIZE',
|
|
1653
|
+
'46': 'SOME',
|
|
1654
|
+
'47': 'SOURCE',
|
|
1655
|
+
'48': 'SENDER',
|
|
1656
|
+
'49': 'SELF',
|
|
1657
|
+
'4a': 'STEPS_TO_QUOTA', // Removed in Edo
|
|
1658
|
+
'4b': 'SUB',
|
|
1659
|
+
'4c': 'SWAP',
|
|
1660
|
+
'4d': 'TRANSFER_TOKENS',
|
|
1661
|
+
'4e': 'SET_DELEGATE',
|
|
1662
|
+
'4f': 'UNIT',
|
|
1663
|
+
'50': 'UPDATE',
|
|
1664
|
+
'51': 'XOR',
|
|
1665
|
+
'52': 'ITER',
|
|
1666
|
+
'53': 'LOOP_LEFT',
|
|
1667
|
+
'54': 'ADDRESS',
|
|
1668
|
+
'55': 'CONTRACT',
|
|
1669
|
+
'56': 'ISNAT',
|
|
1670
|
+
'57': 'CAST',
|
|
1671
|
+
'58': 'RENAME',
|
|
1672
|
+
'59': 'bool',
|
|
1673
|
+
'5a': 'contract',
|
|
1674
|
+
'5b': 'int',
|
|
1675
|
+
'5c': 'key',
|
|
1676
|
+
'5d': 'key_hash',
|
|
1677
|
+
'5e': 'lambda',
|
|
1678
|
+
'5f': 'list',
|
|
1679
|
+
'60': 'map',
|
|
1680
|
+
'61': 'big_map',
|
|
1681
|
+
'62': 'nat',
|
|
1682
|
+
'63': 'option',
|
|
1683
|
+
'64': 'or',
|
|
1684
|
+
'65': 'pair',
|
|
1685
|
+
'66': 'set',
|
|
1686
|
+
'67': 'signature',
|
|
1687
|
+
'68': 'string',
|
|
1688
|
+
'69': 'bytes',
|
|
1689
|
+
'6a': 'mutez',
|
|
1690
|
+
'6b': 'timestamp',
|
|
1691
|
+
'6c': 'unit',
|
|
1692
|
+
'6d': 'operation',
|
|
1693
|
+
'6e': 'address',
|
|
1694
|
+
'6f': 'SLICE',
|
|
1695
|
+
'70': 'DIG',
|
|
1696
|
+
'71': 'DUG',
|
|
1697
|
+
'72': 'EMPTY_BIG_MAP',
|
|
1698
|
+
'73': 'APPLY',
|
|
1699
|
+
'74': 'chain_id',
|
|
1700
|
+
'75': 'CHAIN_ID',
|
|
1701
|
+
'76': 'LEVEL',
|
|
1702
|
+
'77': 'SELF_ADDRESS',
|
|
1703
|
+
'78': 'never',
|
|
1704
|
+
'79': 'NEVER',
|
|
1705
|
+
'7a': 'UNPAIR',
|
|
1706
|
+
'7b': 'VOTING_POWER',
|
|
1707
|
+
'7c': 'TOTAL_VOTING_POWER',
|
|
1708
|
+
'7d': 'KECCAK',
|
|
1709
|
+
'7e': 'SHA3',
|
|
1710
|
+
'7f': 'PAIRING_CHECK',
|
|
1711
|
+
'80': 'bls12_381_g1',
|
|
1712
|
+
'81': 'bls12_381_g2',
|
|
1713
|
+
'82': 'bls12_381_fr',
|
|
1714
|
+
'83': 'sapling_state',
|
|
1715
|
+
'84': 'sapling_transaction_deprecated',
|
|
1716
|
+
'85': 'SAPLING_EMPTY_STATE',
|
|
1717
|
+
'86': 'SAPLING_VERIFY_UPDATE',
|
|
1718
|
+
'87': 'ticket',
|
|
1719
|
+
'88': 'TICKET_DEPRECATED',
|
|
1720
|
+
'89': 'READ_TICKET',
|
|
1721
|
+
'8a': 'SPLIT_TICKET',
|
|
1722
|
+
'8b': 'JOIN_TICKETS',
|
|
1723
|
+
'8c': 'GET_AND_UPDATE',
|
|
1724
|
+
'8d': 'chest',
|
|
1725
|
+
'8e': 'chest_key',
|
|
1726
|
+
'8f': 'OPEN_CHEST',
|
|
1727
|
+
'90': 'VIEW',
|
|
1728
|
+
'91': 'view',
|
|
1729
|
+
'92': 'constant',
|
|
1730
|
+
'93': 'SUB_MUTEZ',
|
|
1731
|
+
'94': 'tx_rollup_l2_address',
|
|
1732
|
+
'95': 'MIN_BLOCK_TIME',
|
|
1733
|
+
'96': 'sapling_transaction',
|
|
1734
|
+
'97': 'EMIT',
|
|
1735
|
+
'98': 'Lambda_rec',
|
|
1736
|
+
'99': 'LAMBDA_REC',
|
|
1737
|
+
'9a': 'TICKET',
|
|
1738
|
+
'9b': 'BYTES',
|
|
1739
|
+
'9c': 'NAT',
|
|
1740
|
+
'9d': 'Ticket',
|
|
1741
|
+
};
|
|
1742
|
+
(() => {
|
|
1743
|
+
const result = {};
|
|
1744
|
+
Object.keys(opMapping).forEach((key) => {
|
|
1745
|
+
result[opMapping[key]] = key;
|
|
1746
|
+
});
|
|
1747
|
+
return result;
|
|
1748
|
+
})();
|
|
1749
|
+
// See https://tezos.gitlab.io/shell/p2p_api.html
|
|
1750
|
+
const kindMapping = {
|
|
1751
|
+
0x04: 'activate_account',
|
|
1752
|
+
0x6b: 'reveal',
|
|
1753
|
+
0x6e: 'delegation',
|
|
1754
|
+
0x6c: 'transaction',
|
|
1755
|
+
0x6d: 'origination',
|
|
1756
|
+
0x06: 'ballot',
|
|
1757
|
+
0x15: 'attestation',
|
|
1758
|
+
0x17: 'attestation_with_dal',
|
|
1759
|
+
0x01: 'seed_nonce_revelation',
|
|
1760
|
+
0x05: 'proposals',
|
|
1761
|
+
0x6f: 'register_global_constant',
|
|
1762
|
+
0x9e: 'transfer_ticket',
|
|
1763
|
+
0x70: 'set_deposits_limit',
|
|
1764
|
+
0x71: 'increase_paid_storage',
|
|
1765
|
+
0x72: 'update_consensus_key',
|
|
1766
|
+
0x09: 'drain_delegate',
|
|
1767
|
+
0xc8: 'smart_rollup_originate',
|
|
1768
|
+
0xc9: 'smart_rollup_add_messages',
|
|
1769
|
+
0xce: 'smart_rollup_execute_outbox_message',
|
|
1770
|
+
0xe6: 'dal_publish_commitment',
|
|
1771
|
+
0x11: 'failing_noop',
|
|
1772
|
+
};
|
|
1773
|
+
const kindMappingReverse = (() => {
|
|
1774
|
+
const result = {};
|
|
1775
|
+
Object.keys(kindMapping).forEach((key) => {
|
|
1776
|
+
const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
|
|
1777
|
+
result[kindMapping[keyNum]] = pad(keyNum, 2);
|
|
1778
|
+
});
|
|
1779
|
+
return result;
|
|
1780
|
+
})();
|
|
1781
|
+
// See https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
1782
|
+
const entrypointMapping = {
|
|
1783
|
+
'00': 'default',
|
|
1784
|
+
'01': 'root',
|
|
1785
|
+
'02': 'do',
|
|
1786
|
+
'03': 'set_delegate',
|
|
1787
|
+
'04': 'remove_delegate',
|
|
1788
|
+
'05': 'deposit',
|
|
1789
|
+
'06': 'stake',
|
|
1790
|
+
'07': 'unstake',
|
|
1791
|
+
'08': 'finalize_unstake',
|
|
1792
|
+
'09': 'set_delegate_parameters',
|
|
1793
|
+
};
|
|
1794
|
+
const entrypointMappingReverse = (() => {
|
|
1795
|
+
const result = {};
|
|
1796
|
+
Object.keys(entrypointMapping).forEach((key) => {
|
|
1797
|
+
result[entrypointMapping[key]] = key;
|
|
1798
|
+
});
|
|
1799
|
+
return result;
|
|
1800
|
+
})();
|
|
1801
|
+
|
|
1802
|
+
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
|
|
1803
|
+
const prefixEncoder = (prefix$1) => (str) => {
|
|
1804
|
+
return buf2hex(Buffer.from(b58cdecode(str, prefix[prefix$1])));
|
|
1805
|
+
};
|
|
1806
|
+
const prefixDecoder = (pre) => (str) => {
|
|
1807
|
+
const val = str.consume(prefixLength[pre]);
|
|
1808
|
+
return b58cencode(val, prefix[pre]);
|
|
1809
|
+
};
|
|
1810
|
+
const tz1Decoder = prefixDecoder(Prefix.TZ1);
|
|
1811
|
+
const branchDecoder = prefixDecoder(Prefix.B);
|
|
1812
|
+
const publicKeyHashDecoder = (val) => {
|
|
1813
|
+
const prefix = val.consume(1);
|
|
1814
|
+
if (prefix[0] === 0x00) {
|
|
1815
|
+
return prefixDecoder(Prefix.TZ1)(val);
|
|
1816
|
+
}
|
|
1817
|
+
else if (prefix[0] === 0x01) {
|
|
1818
|
+
return prefixDecoder(Prefix.TZ2)(val);
|
|
1819
|
+
}
|
|
1820
|
+
else if (prefix[0] === 0x02) {
|
|
1821
|
+
return prefixDecoder(Prefix.TZ3)(val);
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1824
|
+
const publicKeyHashesDecoder = (val) => {
|
|
1825
|
+
if (!boolDecoder(val)) {
|
|
1826
|
+
return undefined;
|
|
1827
|
+
}
|
|
1828
|
+
const publicKeyHashes = [];
|
|
1829
|
+
val.consume(4);
|
|
1830
|
+
while (val.length() > 0) {
|
|
1831
|
+
publicKeyHashes.push(publicKeyHashDecoder(val));
|
|
1832
|
+
}
|
|
1833
|
+
return publicKeyHashes;
|
|
1834
|
+
};
|
|
1835
|
+
const branchEncoder = prefixEncoder(Prefix.B);
|
|
1836
|
+
const tz1Encoder = prefixEncoder(Prefix.TZ1);
|
|
1837
|
+
const boolEncoder = (bool) => (bool ? 'ff' : '00');
|
|
1838
|
+
const proposalEncoder = (proposal) => {
|
|
1839
|
+
return prefixEncoder(Prefix.P)(proposal);
|
|
1840
|
+
};
|
|
1841
|
+
const proposalDecoder = (proposal) => {
|
|
1842
|
+
return prefixDecoder(Prefix.P)(proposal);
|
|
1843
|
+
};
|
|
1844
|
+
const proposalsDecoder = (proposal) => {
|
|
1845
|
+
const proposals = [];
|
|
1846
|
+
proposal.consume(4);
|
|
1847
|
+
while (proposal.length() > 0) {
|
|
1848
|
+
proposals.push(proposalDecoder(proposal));
|
|
1849
|
+
}
|
|
1850
|
+
return proposals;
|
|
1851
|
+
};
|
|
1852
|
+
const proposalsEncoder = (proposals) => {
|
|
1853
|
+
return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder(x)).join('');
|
|
1854
|
+
};
|
|
1855
|
+
const ballotEncoder = (ballot) => {
|
|
1856
|
+
switch (ballot) {
|
|
1857
|
+
case 'yay':
|
|
1858
|
+
return '00';
|
|
1859
|
+
case 'nay':
|
|
1860
|
+
return '01';
|
|
1861
|
+
case 'pass':
|
|
1862
|
+
return '02';
|
|
1863
|
+
default:
|
|
1864
|
+
throw new InvalidBallotValueError(ballot);
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
const ballotDecoder = (ballot) => {
|
|
1868
|
+
const value = ballot.consume(1);
|
|
1869
|
+
switch (value[0]) {
|
|
1870
|
+
case 0x00:
|
|
1871
|
+
return 'yay';
|
|
1872
|
+
case 0x01:
|
|
1873
|
+
return 'nay';
|
|
1874
|
+
case 0x02:
|
|
1875
|
+
return 'pass';
|
|
1876
|
+
default:
|
|
1877
|
+
throw new DecodeBallotValueError(value[0].toString());
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
const pvmKindEncoder = (pvm) => {
|
|
1881
|
+
switch (pvm) {
|
|
1882
|
+
case 'arith':
|
|
1883
|
+
return '00';
|
|
1884
|
+
case 'wasm_2_0_0':
|
|
1885
|
+
return '01';
|
|
1886
|
+
case 'riscv':
|
|
1887
|
+
return '02';
|
|
1888
|
+
default:
|
|
1889
|
+
throw new UnsupportedPvmKindError(pvm);
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
const pvmKindDecoder = (pvm) => {
|
|
1893
|
+
const value = pvm.consume(1);
|
|
1894
|
+
switch (value[0]) {
|
|
1895
|
+
case 0x00:
|
|
1896
|
+
return 'arith';
|
|
1897
|
+
case 0x01:
|
|
1898
|
+
return 'wasm_2_0_0';
|
|
1899
|
+
case 0x02:
|
|
1900
|
+
return 'riscv';
|
|
1901
|
+
default:
|
|
1902
|
+
throw new DecodePvmKindError(value[0].toString());
|
|
1903
|
+
}
|
|
1904
|
+
};
|
|
1905
|
+
const delegateEncoder = (val) => {
|
|
1906
|
+
if (val) {
|
|
1907
|
+
return boolEncoder(true) + publicKeyHashEncoder(val);
|
|
1908
|
+
}
|
|
1909
|
+
else {
|
|
1910
|
+
return boolEncoder(false);
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
const int32Encoder = (val) => {
|
|
1914
|
+
const num = parseInt(String(val), 10);
|
|
1915
|
+
const byte = [];
|
|
1916
|
+
for (let i = 0; i < 4; i++) {
|
|
1917
|
+
const shiftBy = (4 - (i + 1)) * 8;
|
|
1918
|
+
byte.push((num & (0xff << shiftBy)) >> shiftBy);
|
|
1919
|
+
}
|
|
1920
|
+
return Buffer.from(byte).toString('hex');
|
|
1921
|
+
};
|
|
1922
|
+
const int32Decoder = (val) => {
|
|
1923
|
+
const num = val.consume(4);
|
|
1924
|
+
let finalNum = 0;
|
|
1925
|
+
for (let i = 0; i < num.length; i++) {
|
|
1926
|
+
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
|
|
1927
|
+
}
|
|
1928
|
+
return finalNum;
|
|
1929
|
+
};
|
|
1930
|
+
const int16Encoder = (val) => {
|
|
1931
|
+
const num = parseInt(String(val), 10);
|
|
1932
|
+
const byte = [];
|
|
1933
|
+
for (let i = 0; i < 2; i++) {
|
|
1934
|
+
const shiftBy = (2 - (i + 1)) * 8;
|
|
1935
|
+
byte.push((num & (0xff << shiftBy)) >> shiftBy);
|
|
1936
|
+
}
|
|
1937
|
+
return Buffer.from(byte).toString('hex');
|
|
1938
|
+
};
|
|
1939
|
+
const int16Decoder = (val) => {
|
|
1940
|
+
const num = val.consume(2);
|
|
1941
|
+
let finalNum = 0;
|
|
1942
|
+
for (let i = 0; i < num.length; i++) {
|
|
1943
|
+
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
|
|
1944
|
+
}
|
|
1945
|
+
return finalNum;
|
|
1946
|
+
};
|
|
1947
|
+
const boolDecoder = (val) => {
|
|
1948
|
+
const bool = val.consume(1);
|
|
1949
|
+
return bool[0] === 0xff;
|
|
1950
|
+
};
|
|
1951
|
+
const delegateDecoder = (val) => {
|
|
1952
|
+
const hasDelegate = boolDecoder(val);
|
|
1953
|
+
if (hasDelegate) {
|
|
1954
|
+
return publicKeyHashDecoder(val);
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
const publicKeyHashEncoder = (val) => {
|
|
1958
|
+
const pubkeyPrefix = val.substring(0, 3);
|
|
1959
|
+
switch (pubkeyPrefix) {
|
|
1960
|
+
case Prefix.TZ1:
|
|
1961
|
+
return '00' + prefixEncoder(Prefix.TZ1)(val);
|
|
1962
|
+
case Prefix.TZ2:
|
|
1963
|
+
return '01' + prefixEncoder(Prefix.TZ2)(val);
|
|
1964
|
+
case Prefix.TZ3:
|
|
1965
|
+
return '02' + prefixEncoder(Prefix.TZ3)(val);
|
|
1966
|
+
case Prefix.TZ4:
|
|
1967
|
+
return '03' + prefixEncoder(Prefix.TZ4)(val);
|
|
1968
|
+
default:
|
|
1969
|
+
throw new InvalidKeyHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
1970
|
+
` expecting one for the following "${Prefix.TZ1}", "${Prefix.TZ2}", "${Prefix.TZ3}" or "${Prefix.TZ4}".`);
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
const publicKeyHashesEncoder = (val) => {
|
|
1974
|
+
if (!val) {
|
|
1975
|
+
return boolEncoder(false);
|
|
1976
|
+
}
|
|
1977
|
+
if (val.length === 0) {
|
|
1978
|
+
return boolEncoder(true) + pad(0);
|
|
1979
|
+
}
|
|
1980
|
+
const publicKeyHashes = val.reduce((prev, curr) => {
|
|
1981
|
+
return prev + publicKeyHashEncoder(curr);
|
|
1982
|
+
}, '');
|
|
1983
|
+
return boolEncoder(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
|
|
1984
|
+
};
|
|
1985
|
+
const publicKeyEncoder = (val) => {
|
|
1986
|
+
const pubkeyPrefix = val.substring(0, 4);
|
|
1987
|
+
switch (pubkeyPrefix) {
|
|
1988
|
+
case Prefix.EDPK:
|
|
1989
|
+
return '00' + prefixEncoder(Prefix.EDPK)(val);
|
|
1990
|
+
case Prefix.SPPK:
|
|
1991
|
+
return '01' + prefixEncoder(Prefix.SPPK)(val);
|
|
1992
|
+
case Prefix.P2PK:
|
|
1993
|
+
return '02' + prefixEncoder(Prefix.P2PK)(val);
|
|
1994
|
+
default:
|
|
1995
|
+
throw new InvalidPublicKeyError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
1996
|
+
` expecting one of the following '${Prefix.EDPK}', '${Prefix.SPPK}', '${Prefix.P2PK}' or '${Prefix.BLPK}'.`);
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
const addressEncoder = (val) => {
|
|
2000
|
+
const pubkeyPrefix = val.substring(0, 3);
|
|
2001
|
+
switch (pubkeyPrefix) {
|
|
2002
|
+
case Prefix.TZ1:
|
|
2003
|
+
case Prefix.TZ2:
|
|
2004
|
+
case Prefix.TZ3:
|
|
2005
|
+
case Prefix.TZ4:
|
|
2006
|
+
return '00' + publicKeyHashEncoder(val);
|
|
2007
|
+
case Prefix.KT1:
|
|
2008
|
+
return '01' + prefixEncoder(Prefix.KT1)(val) + '00';
|
|
2009
|
+
default:
|
|
2010
|
+
throw new InvalidAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
2011
|
+
` expecting one of the following prefix '${Prefix.TZ1}', ${Prefix.TZ2}', '${Prefix.TZ3}', '${Prefix.TZ4}' or '${Prefix.KT1}'.`);
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
const smartRollupAddressEncoder = (val) => {
|
|
2015
|
+
if (val.substring(0, 3) !== Prefix.SR1) {
|
|
2016
|
+
throw new InvalidSmartRollupAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SR1}'.`);
|
|
2017
|
+
}
|
|
2018
|
+
return prefixEncoder(Prefix.SR1)(val);
|
|
2019
|
+
};
|
|
2020
|
+
const smartContractAddressEncoder = (val) => {
|
|
2021
|
+
const prefix = val.substring(0, 3);
|
|
2022
|
+
if (prefix === Prefix.KT1) {
|
|
2023
|
+
return '01' + prefixEncoder(Prefix.KT1)(val) + '00';
|
|
2024
|
+
}
|
|
2025
|
+
throw new InvalidContractAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.KT1}'.`);
|
|
2026
|
+
};
|
|
2027
|
+
const publicKeyDecoder = (val) => {
|
|
2028
|
+
const preamble = val.consume(1);
|
|
2029
|
+
switch (preamble[0]) {
|
|
2030
|
+
case 0x00:
|
|
2031
|
+
return prefixDecoder(Prefix.EDPK)(val);
|
|
2032
|
+
case 0x01:
|
|
2033
|
+
return prefixDecoder(Prefix.SPPK)(val);
|
|
2034
|
+
case 0x02:
|
|
2035
|
+
return prefixDecoder(Prefix.P2PK)(val);
|
|
2036
|
+
default:
|
|
2037
|
+
throw new InvalidPublicKeyError(val.toString(), invalidDetail(ValidationResult.NO_PREFIX_MATCHED));
|
|
2038
|
+
}
|
|
2039
|
+
};
|
|
2040
|
+
const smartRollupCommitmentHashEncoder = (val) => {
|
|
2041
|
+
const prefix = val.substring(0, 4);
|
|
2042
|
+
if (prefix === Prefix.SRC1) {
|
|
2043
|
+
return prefixEncoder(Prefix.SRC1)(val);
|
|
2044
|
+
}
|
|
2045
|
+
throw new InvalidSmartRollupCommitmentHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
2046
|
+
};
|
|
2047
|
+
const addressDecoder = (val) => {
|
|
2048
|
+
const preamble = val.consume(1);
|
|
2049
|
+
switch (preamble[0]) {
|
|
2050
|
+
case 0x00:
|
|
2051
|
+
return publicKeyHashDecoder(val);
|
|
2052
|
+
case 0x01: {
|
|
2053
|
+
const address = prefixDecoder(Prefix.KT1)(val);
|
|
2054
|
+
val.consume(1);
|
|
2055
|
+
return address;
|
|
2056
|
+
}
|
|
2057
|
+
default:
|
|
2058
|
+
throw new InvalidAddressError(val.toString(), ': Unable to decode.');
|
|
2059
|
+
}
|
|
2060
|
+
};
|
|
2061
|
+
const smartRollupAddressDecoder = (val) => {
|
|
2062
|
+
const address = prefixDecoder(Prefix.SR1)(val);
|
|
2063
|
+
if (address.substring(0, 3) !== Prefix.SR1) {
|
|
2064
|
+
throw new InvalidSmartRollupAddressError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SR1}'.`);
|
|
2065
|
+
}
|
|
2066
|
+
return address;
|
|
2067
|
+
};
|
|
2068
|
+
const smartContractAddressDecoder = (val) => {
|
|
2069
|
+
const preamble = val.consume(1);
|
|
2070
|
+
if (preamble[0] === 0x01) {
|
|
2071
|
+
const scAddress = prefixDecoder(Prefix.KT1)(val);
|
|
2072
|
+
val.consume(1);
|
|
2073
|
+
return scAddress;
|
|
2074
|
+
}
|
|
2075
|
+
throw new InvalidContractAddressError(val.toString(), invalidDetail(ValidationResult.NO_PREFIX_MATCHED));
|
|
2076
|
+
};
|
|
2077
|
+
const smartRollupCommitmentHashDecoder = (val) => {
|
|
2078
|
+
const address = prefixDecoder(Prefix.SRC1)(val);
|
|
2079
|
+
if (address.substring(0, 4) !== Prefix.SRC1) {
|
|
2080
|
+
throw new InvalidSmartRollupCommitmentHashError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
2081
|
+
}
|
|
2082
|
+
return address;
|
|
2083
|
+
};
|
|
2084
|
+
const zarithEncoder = (n) => {
|
|
2085
|
+
const fn = [];
|
|
2086
|
+
let nn = new BigNumber$1(n, 10);
|
|
2087
|
+
if (nn.isNaN()) {
|
|
2088
|
+
throw new TypeError(`Invalid zarith number ${n}`);
|
|
2089
|
+
}
|
|
2090
|
+
// eslint-disable-next-line no-constant-condition
|
|
2091
|
+
while (true) {
|
|
2092
|
+
if (nn.lt(128)) {
|
|
2093
|
+
if (nn.lt(16))
|
|
2094
|
+
fn.push('0');
|
|
2095
|
+
fn.push(nn.toString(16));
|
|
2096
|
+
break;
|
|
2097
|
+
}
|
|
2098
|
+
else {
|
|
2099
|
+
let b = nn.mod(128);
|
|
2100
|
+
nn = nn.minus(b);
|
|
2101
|
+
nn = nn.dividedBy(128);
|
|
2102
|
+
b = b.plus(128);
|
|
2103
|
+
fn.push(b.toString(16));
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
return fn.join('');
|
|
2107
|
+
};
|
|
2108
|
+
const zarithDecoder = (n) => {
|
|
2109
|
+
let mostSignificantByte = 0;
|
|
2110
|
+
while (mostSignificantByte < n.length() && (n.get(mostSignificantByte) & 128) !== 0) {
|
|
2111
|
+
mostSignificantByte += 1;
|
|
2112
|
+
}
|
|
2113
|
+
let num = new BigNumber$1(0);
|
|
2114
|
+
for (let i = mostSignificantByte; i >= 0; i -= 1) {
|
|
2115
|
+
const tmp = n.get(i) & 0x7f;
|
|
2116
|
+
num = num.multipliedBy(128);
|
|
2117
|
+
num = num.plus(tmp);
|
|
2118
|
+
}
|
|
2119
|
+
n.consume(mostSignificantByte + 1);
|
|
2120
|
+
return new BigNumber$1(num).toString();
|
|
2121
|
+
};
|
|
2122
|
+
const entrypointDecoder = (value) => {
|
|
2123
|
+
const preamble = pad(value.consume(1)[0], 2);
|
|
2124
|
+
if (preamble in entrypointMapping) {
|
|
2125
|
+
return entrypointMapping[preamble];
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
const entry = extractRequiredLen(value, 1);
|
|
2129
|
+
const entrypoint = Buffer.from(entry).toString('utf8');
|
|
2130
|
+
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
|
|
2131
|
+
throw new OversizedEntryPointError(entrypoint);
|
|
2132
|
+
}
|
|
2133
|
+
return entrypoint;
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
const parametersDecoder = (val) => {
|
|
2137
|
+
const preamble = val.consume(1);
|
|
2138
|
+
if (preamble[0] === 0x00) {
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
else {
|
|
2142
|
+
const encodedEntrypoint = entrypointDecoder(val);
|
|
2143
|
+
const params = extractRequiredLen(val);
|
|
2144
|
+
const parameters = valueDecoder(new Uint8ArrayConsumer(params));
|
|
2145
|
+
return {
|
|
2146
|
+
entrypoint: encodedEntrypoint,
|
|
2147
|
+
value: parameters,
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
const entrypointEncoder = (entrypoint) => {
|
|
2152
|
+
if (entrypoint in entrypointMappingReverse) {
|
|
2153
|
+
return `${entrypointMappingReverse[entrypoint]}`;
|
|
2154
|
+
}
|
|
2155
|
+
else {
|
|
2156
|
+
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
|
|
2157
|
+
throw new OversizedEntryPointError(entrypoint);
|
|
2158
|
+
}
|
|
2159
|
+
const value = { string: entrypoint };
|
|
2160
|
+
return `ff${valueEncoder(value).slice(8)}`;
|
|
2161
|
+
}
|
|
2162
|
+
};
|
|
2163
|
+
const parametersEncoder = (val) => {
|
|
2164
|
+
if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
|
|
2165
|
+
return '00';
|
|
2166
|
+
}
|
|
2167
|
+
const encodedEntrypoint = entrypointEncoder(val.entrypoint);
|
|
2168
|
+
const parameters = valueEncoder(val.value);
|
|
2169
|
+
const length = pad(parameters.length / 2);
|
|
2170
|
+
return `ff${encodedEntrypoint}${length}${parameters}`;
|
|
2171
|
+
};
|
|
2172
|
+
const valueParameterEncoder = (value) => {
|
|
2173
|
+
const valueEncoded = valueEncoder(value);
|
|
2174
|
+
return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
|
|
2175
|
+
};
|
|
2176
|
+
const valueParameterDecoder = (val) => {
|
|
2177
|
+
const value = extractRequiredLen(val);
|
|
2178
|
+
return valueDecoder(new Uint8ArrayConsumer(value));
|
|
2179
|
+
};
|
|
2180
|
+
const blockPayloadHashEncoder = prefixEncoder(Prefix.VH);
|
|
2181
|
+
const blockPayloadHashDecoder = prefixDecoder(Prefix.VH);
|
|
2182
|
+
const entrypointNameEncoder = (entrypoint) => {
|
|
2183
|
+
const value = { string: entrypoint };
|
|
2184
|
+
return `${valueEncoder(value).slice(2)}`;
|
|
2185
|
+
};
|
|
2186
|
+
const entrypointNameDecoder = (val) => {
|
|
2187
|
+
const entry = extractRequiredLen(val);
|
|
2188
|
+
return Buffer.from(entry).toString('utf8');
|
|
2189
|
+
};
|
|
2190
|
+
const burnLimitEncoder = (val) => {
|
|
2191
|
+
return !val ? '00' : `ff${zarithEncoder(val)}`;
|
|
2192
|
+
};
|
|
2193
|
+
const burnLimitDecoder = (value) => {
|
|
2194
|
+
const prefix = value.consume(1);
|
|
2195
|
+
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
2196
|
+
return zarithDecoder(value);
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2199
|
+
const depositsLimitEncoder = (val) => {
|
|
2200
|
+
return !val ? '00' : `ff${zarithEncoder(val)}`;
|
|
2201
|
+
};
|
|
2202
|
+
const depositsLimitDecoder = (value) => {
|
|
2203
|
+
const prefix = value.consume(1);
|
|
2204
|
+
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
2205
|
+
return zarithDecoder(value);
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
const paddedBytesEncoder = (val, paddingLength = 8) => {
|
|
2209
|
+
return `${pad(val.length / 2, paddingLength)}${val}`;
|
|
2210
|
+
};
|
|
2211
|
+
const paddedBytesDecoder = (val) => {
|
|
2212
|
+
const value = extractRequiredLen(val);
|
|
2213
|
+
return Buffer.from(value).toString('hex');
|
|
2214
|
+
};
|
|
2215
|
+
const smartRollupMessageEncoder = (val) => {
|
|
2216
|
+
const message = val.reduce((prev, curr) => {
|
|
2217
|
+
return prev + `${pad(curr.length / 2)}${curr}`;
|
|
2218
|
+
}, '');
|
|
2219
|
+
return `${pad(message.length / 2)}${message}`;
|
|
2220
|
+
};
|
|
2221
|
+
const smartRollupMessageDecoder = (val) => {
|
|
2222
|
+
const valueArray = extractRequiredLen(val);
|
|
2223
|
+
const ret = stripLengthPrefixFromBytes(new Uint8ArrayConsumer(valueArray));
|
|
2224
|
+
return ret.map((value) => Buffer.from(value).toString('hex'));
|
|
2225
|
+
};
|
|
2226
|
+
const dalCommitmentEncoder = (val) => {
|
|
2227
|
+
const prefix = val.substring(0, 2);
|
|
2228
|
+
if (prefix === Prefix.SH) {
|
|
2229
|
+
return prefixEncoder(Prefix.SH)(val);
|
|
2230
|
+
}
|
|
2231
|
+
throw new InvalidDalCommitmentError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
2232
|
+
};
|
|
2233
|
+
const dalCommitmentDecoder = (val) => {
|
|
2234
|
+
const commitment = prefixDecoder(Prefix.SH)(val);
|
|
2235
|
+
if (commitment.substring(0, 2) !== Prefix.SH) {
|
|
2236
|
+
throw new InvalidDalCommitmentError(commitment, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
2237
|
+
}
|
|
2238
|
+
return commitment;
|
|
2239
|
+
};
|
|
2240
|
+
const slotHeaderEncoder = (val) => {
|
|
2241
|
+
return pad(val.slot_index, 2) + dalCommitmentEncoder(val.commitment) + val.commitment_proof;
|
|
2242
|
+
};
|
|
2243
|
+
const slotHeaderDecoder = (val) => {
|
|
2244
|
+
const preamble = val.consume(1);
|
|
2245
|
+
return {
|
|
2246
|
+
slot_index: Number(preamble[0].toString(10)),
|
|
2247
|
+
commitment: dalCommitmentDecoder(val),
|
|
2248
|
+
commitment_proof: toHexString(val.consume(96)), // rpcForger expect commitment_proof bytes to be len 96
|
|
2249
|
+
};
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
const ManagerOperationSchema = {
|
|
2253
|
+
branch: CODEC.BRANCH,
|
|
2254
|
+
contents: [CODEC.OPERATION],
|
|
2255
|
+
};
|
|
2256
|
+
const ActivationSchema = {
|
|
2257
|
+
pkh: CODEC.TZ1,
|
|
2258
|
+
secret: CODEC.SECRET,
|
|
2259
|
+
};
|
|
2260
|
+
const RevealSchema = {
|
|
2261
|
+
source: CODEC.PKH,
|
|
2262
|
+
fee: CODEC.ZARITH,
|
|
2263
|
+
counter: CODEC.ZARITH,
|
|
2264
|
+
gas_limit: CODEC.ZARITH,
|
|
2265
|
+
storage_limit: CODEC.ZARITH,
|
|
2266
|
+
public_key: CODEC.PUBLIC_KEY,
|
|
2267
|
+
};
|
|
2268
|
+
const DelegationSchema = {
|
|
2269
|
+
source: CODEC.PKH,
|
|
2270
|
+
fee: CODEC.ZARITH,
|
|
2271
|
+
counter: CODEC.ZARITH,
|
|
2272
|
+
gas_limit: CODEC.ZARITH,
|
|
2273
|
+
storage_limit: CODEC.ZARITH,
|
|
2274
|
+
delegate: CODEC.DELEGATE,
|
|
2275
|
+
};
|
|
2276
|
+
const TransactionSchema = {
|
|
2277
|
+
source: CODEC.PKH,
|
|
2278
|
+
fee: CODEC.ZARITH,
|
|
2279
|
+
counter: CODEC.ZARITH,
|
|
2280
|
+
gas_limit: CODEC.ZARITH,
|
|
2281
|
+
storage_limit: CODEC.ZARITH,
|
|
2282
|
+
amount: CODEC.ZARITH,
|
|
2283
|
+
destination: CODEC.ADDRESS,
|
|
2284
|
+
parameters: CODEC.PARAMETERS,
|
|
2285
|
+
};
|
|
2286
|
+
const OriginationSchema = {
|
|
2287
|
+
source: CODEC.PKH,
|
|
2288
|
+
fee: CODEC.ZARITH,
|
|
2289
|
+
counter: CODEC.ZARITH,
|
|
2290
|
+
gas_limit: CODEC.ZARITH,
|
|
2291
|
+
storage_limit: CODEC.ZARITH,
|
|
2292
|
+
balance: CODEC.ZARITH,
|
|
2293
|
+
delegate: CODEC.DELEGATE,
|
|
2294
|
+
script: CODEC.SCRIPT,
|
|
2295
|
+
};
|
|
2296
|
+
const BallotSchema = {
|
|
2297
|
+
source: CODEC.PKH,
|
|
2298
|
+
period: CODEC.INT32,
|
|
2299
|
+
proposal: CODEC.PROPOSAL,
|
|
2300
|
+
ballot: CODEC.BALLOT_STATEMENT,
|
|
2301
|
+
};
|
|
2302
|
+
const AttestationSchema = {
|
|
2303
|
+
slot: CODEC.INT16,
|
|
2304
|
+
level: CODEC.INT32,
|
|
2305
|
+
round: CODEC.INT32,
|
|
2306
|
+
block_payload_hash: CODEC.BLOCK_PAYLOAD_HASH,
|
|
2307
|
+
};
|
|
2308
|
+
const AttestationWithDalSchema = {
|
|
2309
|
+
slot: CODEC.INT16,
|
|
2310
|
+
level: CODEC.INT32,
|
|
2311
|
+
round: CODEC.INT32,
|
|
2312
|
+
block_payload_hash: CODEC.BLOCK_PAYLOAD_HASH,
|
|
2313
|
+
dal_attestation: CODEC.ZARITH,
|
|
2314
|
+
};
|
|
2315
|
+
const SeedNonceRevelationSchema = {
|
|
1252
2316
|
level: CODEC.INT32,
|
|
1253
2317
|
nonce: CODEC.RAW,
|
|
1254
2318
|
};
|
|
@@ -1413,7 +2477,7 @@ const schemaDecoder = (decoders) => (schema) => (value) => {
|
|
|
1413
2477
|
}, {});
|
|
1414
2478
|
};
|
|
1415
2479
|
|
|
1416
|
-
const
|
|
2480
|
+
const decodersProto021 = {
|
|
1417
2481
|
[CODEC.SECRET]: (val) => toHexString(val.consume(20)),
|
|
1418
2482
|
[CODEC.RAW]: (val) => toHexString(val.consume(32)),
|
|
1419
2483
|
[CODEC.TZ1]: tz1Decoder,
|
|
@@ -1444,31 +2508,87 @@ const decoders = {
|
|
|
1444
2508
|
[CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder,
|
|
1445
2509
|
[CODEC.SLOT_HEADER]: slotHeaderDecoder,
|
|
1446
2510
|
};
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
2511
|
+
decodersProto021[CODEC.OPERATION] = operationDecoder(decodersProto021);
|
|
2512
|
+
decodersProto021[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder(decodersProto021)(ActivationSchema)(val);
|
|
2513
|
+
decodersProto021[CODEC.OP_FAILING_NOOP] = (val) => schemaDecoder(decodersProto021)(FailingNoopSchema)(val);
|
|
2514
|
+
decodersProto021[CODEC.OP_DELEGATION] = (val) => schemaDecoder(decodersProto021)(DelegationSchema)(val);
|
|
2515
|
+
decodersProto021[CODEC.OP_TRANSACTION] = (val) => schemaDecoder(decodersProto021)(TransactionSchema)(val);
|
|
2516
|
+
decodersProto021[CODEC.OP_ORIGINATION] = (val) => schemaDecoder(decodersProto021)(OriginationSchema)(val);
|
|
2517
|
+
decodersProto021[CODEC.OP_BALLOT] = (val) => schemaDecoder(decodersProto021)(BallotSchema)(val);
|
|
2518
|
+
decodersProto021[CODEC.OP_ATTESTATION] = (val) => schemaDecoder(decodersProto021)(AttestationSchema)(val);
|
|
2519
|
+
decodersProto021[CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder(decodersProto021)(AttestationWithDalSchema)(val);
|
|
2520
|
+
decodersProto021[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder(decodersProto021)(SeedNonceRevelationSchema)(val);
|
|
2521
|
+
decodersProto021[CODEC.OP_PROPOSALS] = (val) => schemaDecoder(decodersProto021)(ProposalsSchema)(val);
|
|
2522
|
+
decodersProto021[CODEC.OP_REVEAL] = (val) => schemaDecoder(decodersProto021)(RevealSchema)(val);
|
|
2523
|
+
decodersProto021[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decodersProto021)(RegisterGlobalConstantSchema)(val);
|
|
2524
|
+
decodersProto021[CODEC.OP_TRANSFER_TICKET] = (val) => schemaDecoder(decodersProto021)(TransferTicketSchema)(val);
|
|
2525
|
+
decodersProto021[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder(decodersProto021)(IncreasePaidStorageSchema)(val);
|
|
2526
|
+
decodersProto021[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder(decodersProto021)(UpdateConsensusKeySchema)(val);
|
|
2527
|
+
decodersProto021[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaDecoder(decodersProto021)(DrainDelegateSchema)(val);
|
|
2528
|
+
decodersProto021[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder(decodersProto021)(SmartRollupOriginateSchema)(val);
|
|
2529
|
+
decodersProto021[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder(decodersProto021)(SmartRollupAddMessagesSchema)(val);
|
|
2530
|
+
decodersProto021[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder(decodersProto021)(SmartRollupExecuteOutboxMessageSchema)(val);
|
|
2531
|
+
decodersProto021[CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder(decodersProto021)(DalPublishCommitmentSchema)(val);
|
|
2532
|
+
decodersProto021[CODEC.MANAGER] = schemaDecoder(decodersProto021)(ManagerOperationSchema);
|
|
2533
|
+
decodersProto021[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder(decodersProto021)(SetDepositsLimitSchema)(val);
|
|
1470
2534
|
|
|
1471
2535
|
const encoders = {
|
|
2536
|
+
[CODEC$1.SECRET]: (val) => val,
|
|
2537
|
+
[CODEC$1.RAW]: (val) => val,
|
|
2538
|
+
[CODEC$1.TZ1]: tz1Encoder$1,
|
|
2539
|
+
[CODEC$1.BRANCH]: branchEncoder$1,
|
|
2540
|
+
[CODEC$1.ZARITH]: zarithEncoder$1,
|
|
2541
|
+
[CODEC$1.PUBLIC_KEY]: publicKeyEncoder$1,
|
|
2542
|
+
[CODEC$1.PKH]: publicKeyHashEncoder$1,
|
|
2543
|
+
[CODEC$1.PKH_ARR]: publicKeyHashesEncoder$1,
|
|
2544
|
+
[CODEC$1.DELEGATE]: delegateEncoder$1,
|
|
2545
|
+
[CODEC$1.SCRIPT]: scriptEncoder,
|
|
2546
|
+
[CODEC$1.BALLOT_STATEMENT]: ballotEncoder$1,
|
|
2547
|
+
[CODEC$1.PROPOSAL]: proposalEncoder$1,
|
|
2548
|
+
[CODEC$1.PROPOSAL_ARR]: proposalsEncoder$1,
|
|
2549
|
+
[CODEC$1.INT32]: int32Encoder$1,
|
|
2550
|
+
[CODEC$1.PARAMETERS]: parametersEncoder$1,
|
|
2551
|
+
[CODEC$1.ADDRESS]: addressEncoder$1,
|
|
2552
|
+
[CODEC$1.SMART_ROLLUP_ADDRESS]: smartRollupAddressEncoder$1,
|
|
2553
|
+
[CODEC$1.SMART_CONTRACT_ADDRESS]: smartContractAddressEncoder$1,
|
|
2554
|
+
[CODEC$1.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashEncoder$1,
|
|
2555
|
+
[CODEC$1.VALUE]: valueParameterEncoder$1,
|
|
2556
|
+
[CODEC$1.INT16]: int16Encoder$1,
|
|
2557
|
+
[CODEC$1.BLOCK_PAYLOAD_HASH]: blockPayloadHashEncoder$1,
|
|
2558
|
+
[CODEC$1.ENTRYPOINT]: entrypointNameEncoder$1,
|
|
2559
|
+
[CODEC$1.BURN_LIMIT]: burnLimitEncoder$1,
|
|
2560
|
+
[CODEC$1.DEPOSITS_LIMIT]: depositsLimitEncoder$1,
|
|
2561
|
+
[CODEC$1.SIGNATURE_PROOF]: signatureProofEncoder,
|
|
2562
|
+
[CODEC$1.PVM_KIND]: pvmKindEncoder$1,
|
|
2563
|
+
[CODEC$1.PADDED_BYTES]: paddedBytesEncoder$1,
|
|
2564
|
+
[CODEC$1.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder$1,
|
|
2565
|
+
[CODEC$1.SLOT_HEADER]: slotHeaderEncoder$1,
|
|
2566
|
+
};
|
|
2567
|
+
encoders[CODEC$1.OPERATION] = operationEncoder$1(encoders);
|
|
2568
|
+
encoders[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder$1(encoders)(ActivationSchema$1)(val);
|
|
2569
|
+
encoders[CODEC$1.OP_DELEGATION] = (val) => schemaEncoder$1(encoders)(DelegationSchema$1)(val);
|
|
2570
|
+
encoders[CODEC$1.OP_TRANSACTION] = (val) => schemaEncoder$1(encoders)(TransactionSchema$1)(val);
|
|
2571
|
+
encoders[CODEC$1.OP_ORIGINATION] = (val) => schemaEncoder$1(encoders)(OriginationSchema$1)(val);
|
|
2572
|
+
encoders[CODEC$1.OP_BALLOT] = (val) => schemaEncoder$1(encoders)(BallotSchema$1)(val);
|
|
2573
|
+
encoders[CODEC$1.OP_ATTESTATION] = (val) => schemaEncoder$1(encoders)(AttestationSchema$1)(val);
|
|
2574
|
+
encoders[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder$1(encoders)(AttestationWithDalSchema$1)(val);
|
|
2575
|
+
encoders[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder$1(encoders)(SeedNonceRevelationSchema$1)(val);
|
|
2576
|
+
encoders[CODEC$1.OP_PROPOSALS] = (val) => schemaEncoder$1(encoders)(ProposalsSchema$1)(val);
|
|
2577
|
+
encoders[CODEC$1.OP_REVEAL] = (val) => schemaEncoder$1(encoders)(RevealSchema$1)(val);
|
|
2578
|
+
encoders[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder$1(encoders)(RegisterGlobalConstantSchema$1)(val);
|
|
2579
|
+
encoders[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaEncoder$1(encoders)(TransferTicketSchema$1)(val);
|
|
2580
|
+
encoders[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder$1(encoders)(IncreasePaidStorageSchema$1)(val);
|
|
2581
|
+
encoders[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder$1(encoders)(UpdateConsensusKeySchema$1)(val);
|
|
2582
|
+
encoders[CODEC$1.OP_DRAIN_DELEGATE] = (val) => schemaEncoder$1(encoders)(DrainDelegateSchema$1)(val);
|
|
2583
|
+
encoders[CODEC$1.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder$1(encoders)(SmartRollupOriginateSchema$1)(val);
|
|
2584
|
+
encoders[CODEC$1.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder$1(encoders)(SmartRollupAddMessagesSchema$1)(val);
|
|
2585
|
+
encoders[CODEC$1.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder$1(encoders)(SmartRollupExecuteOutboxMessageSchema$1)(val);
|
|
2586
|
+
encoders[CODEC$1.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder$1(encoders)(DalPublishCommitmentSchema$1)(val);
|
|
2587
|
+
encoders[CODEC$1.MANAGER] = schemaEncoder$1(encoders)(ManagerOperationSchema$1);
|
|
2588
|
+
encoders[CODEC$1.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder$1(encoders)(SetDepositsLimitSchema$1)(val);
|
|
2589
|
+
encoders[CODEC$1.OP_FAILING_NOOP] = (val) => schemaEncoder$1(encoders)(FailingNoopSchema$1)(val);
|
|
2590
|
+
|
|
2591
|
+
const encodersProto021 = {
|
|
1472
2592
|
[CODEC.SECRET]: (val) => val,
|
|
1473
2593
|
[CODEC.RAW]: (val) => val,
|
|
1474
2594
|
[CODEC.TZ1]: tz1Encoder,
|
|
@@ -1499,52 +2619,52 @@ const encoders = {
|
|
|
1499
2619
|
[CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder,
|
|
1500
2620
|
[CODEC.SLOT_HEADER]: slotHeaderEncoder,
|
|
1501
2621
|
};
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
2622
|
+
encodersProto021[CODEC.OPERATION] = operationEncoder(encodersProto021);
|
|
2623
|
+
encodersProto021[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder(encodersProto021)(ActivationSchema)(val);
|
|
2624
|
+
encodersProto021[CODEC.OP_DELEGATION] = (val) => schemaEncoder(encodersProto021)(DelegationSchema)(val);
|
|
2625
|
+
encodersProto021[CODEC.OP_TRANSACTION] = (val) => schemaEncoder(encodersProto021)(TransactionSchema)(val);
|
|
2626
|
+
encodersProto021[CODEC.OP_ORIGINATION] = (val) => schemaEncoder(encodersProto021)(OriginationSchema)(val);
|
|
2627
|
+
encodersProto021[CODEC.OP_BALLOT] = (val) => schemaEncoder(encodersProto021)(BallotSchema)(val);
|
|
2628
|
+
encodersProto021[CODEC.OP_ATTESTATION] = (val) => schemaEncoder(encodersProto021)(AttestationSchema)(val);
|
|
2629
|
+
encodersProto021[CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder(encodersProto021)(AttestationWithDalSchema)(val);
|
|
2630
|
+
encodersProto021[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder(encodersProto021)(SeedNonceRevelationSchema)(val);
|
|
2631
|
+
encodersProto021[CODEC.OP_PROPOSALS] = (val) => schemaEncoder(encodersProto021)(ProposalsSchema)(val);
|
|
2632
|
+
encodersProto021[CODEC.OP_REVEAL] = (val) => schemaEncoder(encodersProto021)(RevealSchema)(val);
|
|
2633
|
+
encodersProto021[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encodersProto021)(RegisterGlobalConstantSchema)(val);
|
|
2634
|
+
encodersProto021[CODEC.OP_TRANSFER_TICKET] = (val) => schemaEncoder(encodersProto021)(TransferTicketSchema)(val);
|
|
2635
|
+
encodersProto021[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder(encodersProto021)(IncreasePaidStorageSchema)(val);
|
|
2636
|
+
encodersProto021[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder(encodersProto021)(UpdateConsensusKeySchema)(val);
|
|
2637
|
+
encodersProto021[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaEncoder(encodersProto021)(DrainDelegateSchema)(val);
|
|
2638
|
+
encodersProto021[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder(encodersProto021)(SmartRollupOriginateSchema)(val);
|
|
2639
|
+
encodersProto021[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder(encodersProto021)(SmartRollupAddMessagesSchema)(val);
|
|
2640
|
+
encodersProto021[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder(encodersProto021)(SmartRollupExecuteOutboxMessageSchema)(val);
|
|
2641
|
+
encodersProto021[CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder(encodersProto021)(DalPublishCommitmentSchema)(val);
|
|
2642
|
+
encodersProto021[CODEC.MANAGER] = schemaEncoder(encodersProto021)(ManagerOperationSchema);
|
|
2643
|
+
encodersProto021[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder(encodersProto021)(SetDepositsLimitSchema)(val);
|
|
2644
|
+
encodersProto021[CODEC.OP_FAILING_NOOP] = (val) => schemaEncoder(encodersProto021)(FailingNoopSchema)(val);
|
|
1525
2645
|
|
|
1526
2646
|
const OperationKindMapping = {
|
|
1527
|
-
activate_account: ActivationSchema,
|
|
1528
|
-
reveal: RevealSchema,
|
|
1529
|
-
delegation: DelegationSchema,
|
|
1530
|
-
transaction: TransactionSchema,
|
|
1531
|
-
origination: OriginationSchema,
|
|
1532
|
-
ballot: BallotSchema,
|
|
1533
|
-
attestation: AttestationSchema,
|
|
1534
|
-
attestation_with_dal: AttestationWithDalSchema,
|
|
1535
|
-
seed_nonce_revelation: SeedNonceRevelationSchema,
|
|
1536
|
-
proposals: ProposalsSchema,
|
|
1537
|
-
register_global_constant: RegisterGlobalConstantSchema,
|
|
1538
|
-
transfer_ticket: TransferTicketSchema,
|
|
1539
|
-
increase_paid_storage: IncreasePaidStorageSchema,
|
|
1540
|
-
update_consensus_key: UpdateConsensusKeySchema,
|
|
1541
|
-
drain_delegate: DrainDelegateSchema,
|
|
1542
|
-
set_deposits_limit: SetDepositsLimitSchema,
|
|
1543
|
-
smart_rollup_originate: SmartRollupOriginateSchema,
|
|
1544
|
-
smart_rollup_add_messages: SmartRollupAddMessagesSchema,
|
|
1545
|
-
smart_rollup_execute_outbox_message: SmartRollupExecuteOutboxMessageSchema,
|
|
1546
|
-
dal_publish_commitment: DalPublishCommitmentSchema,
|
|
1547
|
-
failing_noop: FailingNoopSchema,
|
|
2647
|
+
activate_account: ActivationSchema$1,
|
|
2648
|
+
reveal: RevealSchema$1,
|
|
2649
|
+
delegation: DelegationSchema$1,
|
|
2650
|
+
transaction: TransactionSchema$1,
|
|
2651
|
+
origination: OriginationSchema$1,
|
|
2652
|
+
ballot: BallotSchema$1,
|
|
2653
|
+
attestation: AttestationSchema$1,
|
|
2654
|
+
attestation_with_dal: AttestationWithDalSchema$1,
|
|
2655
|
+
seed_nonce_revelation: SeedNonceRevelationSchema$1,
|
|
2656
|
+
proposals: ProposalsSchema$1,
|
|
2657
|
+
register_global_constant: RegisterGlobalConstantSchema$1,
|
|
2658
|
+
transfer_ticket: TransferTicketSchema$1,
|
|
2659
|
+
increase_paid_storage: IncreasePaidStorageSchema$1,
|
|
2660
|
+
update_consensus_key: UpdateConsensusKeySchema$1,
|
|
2661
|
+
drain_delegate: DrainDelegateSchema$1,
|
|
2662
|
+
set_deposits_limit: SetDepositsLimitSchema$1,
|
|
2663
|
+
smart_rollup_originate: SmartRollupOriginateSchema$1,
|
|
2664
|
+
smart_rollup_add_messages: SmartRollupAddMessagesSchema$1,
|
|
2665
|
+
smart_rollup_execute_outbox_message: SmartRollupExecuteOutboxMessageSchema$1,
|
|
2666
|
+
dal_publish_commitment: DalPublishCommitmentSchema$1,
|
|
2667
|
+
failing_noop: FailingNoopSchema$1,
|
|
1548
2668
|
};
|
|
1549
2669
|
// Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa
|
|
1550
2670
|
const getArrayDifference = (arr1, arr2) => {
|
|
@@ -1596,34 +2716,81 @@ var ProtocolsHash;
|
|
|
1596
2716
|
ProtocolsHash["PtParisBx"] = "PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ";
|
|
1597
2717
|
ProtocolsHash["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
|
|
1598
2718
|
ProtocolsHash["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
|
|
2719
|
+
ProtocolsHash["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
|
|
1599
2720
|
ProtocolsHash["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
|
|
1600
2721
|
})(ProtocolsHash || (ProtocolsHash = {}));
|
|
2722
|
+
const protoLevel = {
|
|
2723
|
+
Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd: 4,
|
|
2724
|
+
PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU: 5,
|
|
2725
|
+
PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS: 5,
|
|
2726
|
+
PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb: 6,
|
|
2727
|
+
PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo: 7,
|
|
2728
|
+
PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA: 8,
|
|
2729
|
+
PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i: 9,
|
|
2730
|
+
PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV: 10,
|
|
2731
|
+
PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx: 11,
|
|
2732
|
+
Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A: 12,
|
|
2733
|
+
PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY: 13,
|
|
2734
|
+
PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg: 14,
|
|
2735
|
+
PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW: 15,
|
|
2736
|
+
PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc: 16,
|
|
2737
|
+
PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1: 16,
|
|
2738
|
+
PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf: 17,
|
|
2739
|
+
ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH: 19,
|
|
2740
|
+
PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ: 20,
|
|
2741
|
+
PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi: 20,
|
|
2742
|
+
PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg: 21,
|
|
2743
|
+
PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7: 22,
|
|
2744
|
+
ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 23,
|
|
2745
|
+
};
|
|
2746
|
+
function ProtoInferiorTo(a, b) {
|
|
2747
|
+
return protoLevel[a] < protoLevel[b];
|
|
2748
|
+
}
|
|
1601
2749
|
|
|
1602
2750
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
1603
2751
|
const VERSION = {
|
|
1604
|
-
"commitHash": "
|
|
1605
|
-
"version": "
|
|
2752
|
+
"commitHash": "f0eb755ed1e0de4d1cd86623df4496f76efd0caf",
|
|
2753
|
+
"version": "22.0.0-beta.0"
|
|
1606
2754
|
};
|
|
1607
2755
|
|
|
1608
2756
|
/**
|
|
1609
2757
|
* @packageDocumentation
|
|
1610
2758
|
* @module @taquito/local-forging
|
|
1611
2759
|
*/
|
|
1612
|
-
const PROTOCOL_CURRENT = ProtocolsHash.
|
|
2760
|
+
const PROTOCOL_CURRENT = ProtocolsHash.PsRiotuma;
|
|
1613
2761
|
function getCodec(codec, _proto) {
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
2762
|
+
// use encodersProto021 & decodersProto021 if it's quebec or prior
|
|
2763
|
+
if (_proto === ProtocolsHash.PsQuebecn || ProtoInferiorTo(_proto, ProtocolsHash.PsQuebecn)) {
|
|
2764
|
+
return {
|
|
2765
|
+
encoder: encodersProto021[codec],
|
|
2766
|
+
decoder: (hex) => {
|
|
2767
|
+
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
2768
|
+
return decodersProto021[codec](consumer);
|
|
2769
|
+
},
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
else {
|
|
2773
|
+
return {
|
|
2774
|
+
encoder: encoders[codec],
|
|
2775
|
+
decoder: (hex) => {
|
|
2776
|
+
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
2777
|
+
return decoders[codec](consumer);
|
|
2778
|
+
},
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
// TODO: Remove above if else once mainnet migrated into rio protocol and uncommon the return block below
|
|
2782
|
+
// return {
|
|
2783
|
+
// encoder: encoders[codec],
|
|
2784
|
+
// decoder: (hex: string) => {
|
|
2785
|
+
// const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
2786
|
+
// return decoders[codec](consumer) as any;
|
|
2787
|
+
// },
|
|
2788
|
+
// };
|
|
1621
2789
|
}
|
|
1622
|
-
//
|
|
1623
2790
|
class LocalForger {
|
|
1624
2791
|
constructor(protocolHash = PROTOCOL_CURRENT) {
|
|
1625
2792
|
this.protocolHash = protocolHash;
|
|
1626
|
-
this.codec = getCodec(CODEC.MANAGER, this.protocolHash);
|
|
2793
|
+
this.codec = getCodec(CODEC$1.MANAGER, this.protocolHash);
|
|
1627
2794
|
}
|
|
1628
2795
|
forge(params) {
|
|
1629
2796
|
const branchValidation = validateBlock(params.branch);
|
|
@@ -1651,6 +2818,9 @@ class LocalForger {
|
|
|
1651
2818
|
else if (content.kind === 'smart_rollup_originate' && diff[0] === 'whitelist') {
|
|
1652
2819
|
continue;
|
|
1653
2820
|
}
|
|
2821
|
+
else if (content.kind === 'update_consensus_key' && diff[0] === 'proof') {
|
|
2822
|
+
continue;
|
|
2823
|
+
}
|
|
1654
2824
|
else {
|
|
1655
2825
|
throw new InvalidOperationSchemaError(content, `missing properties "${diff.join(', ')}"`);
|
|
1656
2826
|
}
|
|
@@ -1668,5 +2838,5 @@ class LocalForger {
|
|
|
1668
2838
|
}
|
|
1669
2839
|
const localForger = new LocalForger();
|
|
1670
2840
|
|
|
1671
|
-
export { CODEC, LocalForger, ProtocolsHash, Uint8ArrayConsumer, VERSION, decoders, encoders, getCodec, localForger, opMapping, opMappingReverse };
|
|
2841
|
+
export { CODEC$1 as CODEC, LocalForger, ProtocolsHash, Uint8ArrayConsumer, VERSION, decoders, encoders, getCodec, localForger, opMapping$1 as opMapping, opMappingReverse };
|
|
1672
2842
|
//# sourceMappingURL=taquito-local-forging.es6.js.map
|