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