@taquito/local-forging 22.0.0-beta.0 → 23.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/lib/{codec-proto021.js → codec-proto022.js} +71 -23
  2. package/dist/lib/codec.js +5 -12
  3. package/dist/lib/{constants-proto021.js → constants-proto022.js} +1 -0
  4. package/dist/lib/constants.js +3 -0
  5. package/dist/lib/decoder-proto022.js +63 -0
  6. package/dist/lib/decoder.js +1 -0
  7. package/dist/lib/encoder-proto022.js +62 -0
  8. package/dist/lib/encoder.js +1 -0
  9. package/dist/lib/michelson/codec-proto022.js +283 -0
  10. package/dist/lib/protocols.js +2 -0
  11. package/dist/lib/schema/operation-proto022.js +238 -0
  12. package/dist/lib/schema/operation.js +11 -1
  13. package/dist/lib/taquito-local-forging.js +13 -7
  14. package/dist/lib/validator-proto022.js +56 -0
  15. package/dist/lib/validator.js +1 -0
  16. package/dist/lib/version.js +2 -2
  17. package/dist/taquito-local-forging.es6.js +521 -201
  18. package/dist/taquito-local-forging.es6.js.map +1 -1
  19. package/dist/taquito-local-forging.umd.js +522 -202
  20. package/dist/taquito-local-forging.umd.js.map +1 -1
  21. package/dist/types/{codec-proto021.d.ts → codec-proto022.d.ts} +3 -1
  22. package/dist/types/{constants-proto021.d.ts → constants-proto022.d.ts} +1 -0
  23. package/dist/types/constants.d.ts +1 -0
  24. package/dist/types/{decoder-proto021.d.ts → decoder-proto022.d.ts} +1 -1
  25. package/dist/types/{encoder-proto021.d.ts → encoder-proto022.d.ts} +1 -1
  26. package/dist/types/michelson/codec-proto022.d.ts +49 -0
  27. package/dist/types/michelson/codec.d.ts +1 -1
  28. package/dist/types/protocols.d.ts +1 -0
  29. package/dist/types/schema/{operation-proto021.d.ts → operation-proto022.d.ts} +3 -2
  30. package/dist/types/schema/operation.d.ts +10 -0
  31. package/dist/types/taquito-local-forging.d.ts +3 -3
  32. package/dist/types/validator-proto022.d.ts +13 -0
  33. package/package.json +5 -5
  34. package/dist/lib/decoder-proto021.js +0 -62
  35. package/dist/lib/encoder-proto021.js +0 -61
  36. package/dist/lib/schema/operation-proto021.js +0 -237
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeAnnots = exports.encodeAnnots = exports.decodeCombPair = exports.primViewDecoder = exports.primDecoder = exports.primEncoder = exports.intDecoder = exports.intEncoder = exports.stringDecoder = exports.stringEncoder = exports.bytesDecoder = exports.bytesEncoder = exports.stripLengthPrefixFromBytes = exports.extractRequiredLen = exports.valueDecoder = exports.valueEncoder = exports.scriptDecoder = exports.scriptEncoder = exports.isInt = exports.isString = exports.isBytes = exports.isPrim = void 0;
4
+ const bignumber_js_1 = require("bignumber.js");
5
+ const uint8array_consumer_1 = require("../uint8array-consumer");
6
+ const constants_proto022_1 = require("../constants-proto022");
7
+ const utils_1 = require("../utils");
8
+ const errors_1 = require("../errors");
9
+ const core_1 = require("@taquito/core");
10
+ const isPrim = (value) => {
11
+ return 'prim' in value;
12
+ };
13
+ exports.isPrim = isPrim;
14
+ const isBytes = (value) => {
15
+ return 'bytes' in value && typeof value.bytes === 'string';
16
+ };
17
+ exports.isBytes = isBytes;
18
+ const isString = (value) => {
19
+ return 'string' in value && typeof value.string === 'string';
20
+ };
21
+ exports.isString = isString;
22
+ const isInt = (value) => {
23
+ return 'int' in value && typeof value.int === 'string';
24
+ };
25
+ exports.isInt = isInt;
26
+ const scriptEncoder = (script) => {
27
+ const code = (0, exports.valueEncoder)(script.code);
28
+ const storage = (0, exports.valueEncoder)(script.storage);
29
+ return `${(0, utils_1.pad)(code.length / 2, 8)}${code}${(0, utils_1.pad)(storage.length / 2, 8)}${storage}`;
30
+ };
31
+ exports.scriptEncoder = scriptEncoder;
32
+ const scriptDecoder = (value) => {
33
+ const code = (0, exports.extractRequiredLen)(value);
34
+ const storage = (0, exports.extractRequiredLen)(value);
35
+ return {
36
+ code: (0, exports.valueDecoder)(new uint8array_consumer_1.Uint8ArrayConsumer(code)),
37
+ storage: (0, exports.valueDecoder)(new uint8array_consumer_1.Uint8ArrayConsumer(storage)),
38
+ };
39
+ };
40
+ exports.scriptDecoder = scriptDecoder;
41
+ const valueEncoder = (value) => {
42
+ if (Array.isArray(value)) {
43
+ const encoded = value.map((x) => (0, exports.valueEncoder)(x)).join('');
44
+ const len = encoded.length / 2;
45
+ return `02${(0, utils_1.pad)(len)}${encoded}`;
46
+ }
47
+ else if ((0, exports.isPrim)(value)) {
48
+ return (0, exports.primEncoder)(value);
49
+ }
50
+ else if ((0, exports.isBytes)(value)) {
51
+ return (0, exports.bytesEncoder)(value);
52
+ }
53
+ else if ((0, exports.isString)(value)) {
54
+ return (0, exports.stringEncoder)(value);
55
+ }
56
+ else if ((0, exports.isInt)(value)) {
57
+ return (0, exports.intEncoder)(value);
58
+ }
59
+ throw new errors_1.UnexpectedMichelsonValueError(JSON.stringify(value));
60
+ };
61
+ exports.valueEncoder = valueEncoder;
62
+ const valueDecoder = (value) => {
63
+ const preamble = value.consume(1);
64
+ switch (preamble[0]) {
65
+ case 0x0a:
66
+ return (0, exports.bytesDecoder)(value);
67
+ case 0x01:
68
+ return (0, exports.stringDecoder)(value);
69
+ case 0x00:
70
+ return (0, exports.intDecoder)(value);
71
+ case 0x02: {
72
+ const val = new uint8array_consumer_1.Uint8ArrayConsumer((0, exports.extractRequiredLen)(value));
73
+ const results = [];
74
+ while (val.length() > 0) {
75
+ results.push((0, exports.valueDecoder)(val));
76
+ }
77
+ return results;
78
+ }
79
+ default:
80
+ return (0, exports.primDecoder)(value, preamble);
81
+ }
82
+ };
83
+ exports.valueDecoder = valueDecoder;
84
+ const extractRequiredLen = (value, bytesLength = 4) => {
85
+ const len = value.consume(bytesLength);
86
+ const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
87
+ return value.consume(valueLen);
88
+ };
89
+ exports.extractRequiredLen = extractRequiredLen;
90
+ /**
91
+ * @description parse bytes into multiple items of an array
92
+ * @param value Uint8ArrayConsumer class of forged segment to parse
93
+ * @param bytesLength default 4 bytes for length of variable bytes
94
+ * @returns array of Uint8Array values for each array item
95
+ */
96
+ const stripLengthPrefixFromBytes = (value, bytesLength = 4) => {
97
+ const ret = [];
98
+ let values = value;
99
+ while (values.length()) {
100
+ const len = values.consume(bytesLength);
101
+ const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
102
+ ret.push(values.consume(valueLen));
103
+ values = values.slice(valueLen + bytesLength);
104
+ }
105
+ return ret;
106
+ };
107
+ exports.stripLengthPrefixFromBytes = stripLengthPrefixFromBytes;
108
+ const bytesEncoder = (value) => {
109
+ if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
110
+ throw new core_1.InvalidHexStringError(value.bytes);
111
+ }
112
+ const len = value.bytes.length / 2;
113
+ return `0a${(0, utils_1.pad)(len)}${value.bytes}`;
114
+ };
115
+ exports.bytesEncoder = bytesEncoder;
116
+ const bytesDecoder = (value) => {
117
+ const bytes = (0, exports.extractRequiredLen)(value);
118
+ return {
119
+ bytes: Buffer.from(bytes).toString('hex'),
120
+ };
121
+ };
122
+ exports.bytesDecoder = bytesDecoder;
123
+ const stringEncoder = (value) => {
124
+ const str = Buffer.from(value.string, 'utf8').toString('hex');
125
+ const hexLength = str.length / 2;
126
+ return `01${(0, utils_1.pad)(hexLength)}${str}`;
127
+ };
128
+ exports.stringEncoder = stringEncoder;
129
+ const stringDecoder = (value) => {
130
+ const str = (0, exports.extractRequiredLen)(value);
131
+ return {
132
+ string: Buffer.from(str).toString('utf8'),
133
+ };
134
+ };
135
+ exports.stringDecoder = stringDecoder;
136
+ const intEncoder = ({ int }) => {
137
+ const num = new bignumber_js_1.BigNumber(int, 10);
138
+ const positiveMark = num.toString(2)[0] === '-' ? '1' : '0';
139
+ const binary = num.toString(2).replace(/-/g, '');
140
+ const pad = binary.length <= 6
141
+ ? 6
142
+ : (binary.length - 6) % 7
143
+ ? binary.length + 7 - ((binary.length - 6) % 7)
144
+ : binary.length;
145
+ const splitted = binary.padStart(pad, '0').match(/\d{6,7}/g);
146
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
147
+ const reversed = splitted.reverse();
148
+ reversed[0] = positiveMark + reversed[0];
149
+ const numHex = reversed.map((x, i) =>
150
+ // Add one to the last chunk
151
+ parseInt((i === reversed.length - 1 ? '0' : '1') + x, 2)
152
+ .toString(16)
153
+ .padStart(2, '0'));
154
+ return `00${numHex.join('')}`;
155
+ };
156
+ exports.intEncoder = intEncoder;
157
+ const intDecoder = (value) => {
158
+ let c = value.consume(1)[0];
159
+ const hexNumber = [];
160
+ const isNotLastChunkMask = 1 << 7;
161
+ while (c & isNotLastChunkMask) {
162
+ hexNumber.push(c);
163
+ c = value.consume(1)[0];
164
+ }
165
+ hexNumber.push(c);
166
+ const isNegative = !!((1 << 6) & hexNumber[0]);
167
+ hexNumber[0] = hexNumber[0] & 0b1111111;
168
+ const numBin = hexNumber
169
+ .map((x, i) => x
170
+ .toString(2)
171
+ .slice(i === 0 ? -6 : -7)
172
+ .padStart(i === 0 ? 6 : 7, '0'))
173
+ .reverse();
174
+ let num = new bignumber_js_1.BigNumber(numBin.join(''), 2);
175
+ if (isNegative) {
176
+ num = num.times(-1);
177
+ }
178
+ return {
179
+ int: num.toFixed(),
180
+ };
181
+ };
182
+ exports.intDecoder = intDecoder;
183
+ const primEncoder = (value) => {
184
+ const hasAnnot = +Array.isArray(value.annots);
185
+ const argsCount = Array.isArray(value.args) ? value.args.length : 0;
186
+ // Specify the number of args max is 3 without annotation
187
+ const preamble = (0, utils_1.pad)(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
188
+ const op = constants_proto022_1.opMappingReverse[value.prim];
189
+ let encodedArgs = (value.args || []).map((arg) => (0, exports.valueEncoder)(arg)).join('');
190
+ const encodedAnnots = Array.isArray(value.annots) ? (0, exports.encodeAnnots)(value.annots) : '';
191
+ if ((value.prim === 'LAMBDA' || value.prim === 'LAMBDA_REC') && argsCount) {
192
+ encodedArgs = (0, utils_1.pad)(encodedArgs.length / 2) + encodedArgs + (0, utils_1.pad)(0);
193
+ }
194
+ if ((value.prim === 'pair' || value.prim === 'Pair') && argsCount > 2) {
195
+ encodedArgs =
196
+ encodedAnnots === ''
197
+ ? (0, utils_1.pad)(encodedArgs.length / 2) + encodedArgs + (0, utils_1.pad)(0)
198
+ : (0, utils_1.pad)(encodedArgs.length / 2) + encodedArgs;
199
+ }
200
+ if (value.prim === 'view' && value.args) {
201
+ encodedArgs = (0, utils_1.pad)(encodedArgs.length / 2) + encodedArgs + (0, utils_1.pad)(0);
202
+ }
203
+ return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
204
+ };
205
+ exports.primEncoder = primEncoder;
206
+ const primDecoder = (value, preamble) => {
207
+ const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
208
+ let argsCount = Math.floor((preamble[0] - 0x03) / 2);
209
+ const op = value.consume(1)[0].toString(16).padStart(2, '0');
210
+ const result = {
211
+ prim: constants_proto022_1.opMapping[op],
212
+ };
213
+ if (constants_proto022_1.opMapping[op] === 'LAMBDA' || constants_proto022_1.opMapping[op] === 'LAMBDA_REC') {
214
+ value.consume(4);
215
+ }
216
+ if (constants_proto022_1.opMapping[op] === 'view') {
217
+ if (argsCount != 0) {
218
+ return (0, exports.primViewDecoder)(value, result);
219
+ }
220
+ else {
221
+ return result;
222
+ }
223
+ }
224
+ let combPairArgs;
225
+ let combPairAnnots;
226
+ if ((constants_proto022_1.opMapping[op] === 'pair' || constants_proto022_1.opMapping[op] === 'Pair') && argsCount > 2) {
227
+ combPairArgs = (0, exports.decodeCombPair)(value);
228
+ argsCount = 0;
229
+ combPairAnnots = (0, exports.decodeAnnots)(value);
230
+ }
231
+ const args = new Array(argsCount).fill(0).map(() => (0, exports.valueDecoder)(value));
232
+ if (constants_proto022_1.opMapping[op] === 'LAMBDA' || constants_proto022_1.opMapping[op] === 'LAMBDA_REC') {
233
+ value.consume(4);
234
+ }
235
+ if (combPairArgs) {
236
+ result['args'] = combPairArgs;
237
+ }
238
+ else if (args.length) {
239
+ result['args'] = args;
240
+ }
241
+ if (combPairAnnots && combPairAnnots[0] !== '') {
242
+ result['annots'] = combPairAnnots;
243
+ }
244
+ else if (hasAnnot) {
245
+ result['annots'] = (0, exports.decodeAnnots)(value);
246
+ }
247
+ return result;
248
+ };
249
+ exports.primDecoder = primDecoder;
250
+ const primViewDecoder = (value, result) => {
251
+ value.consume(4);
252
+ result['args'] = new Array(4).fill(0).map(() => (0, exports.valueDecoder)(value));
253
+ value.consume(4);
254
+ return result;
255
+ };
256
+ exports.primViewDecoder = primViewDecoder;
257
+ const decodeCombPair = (val) => {
258
+ const array = new uint8array_consumer_1.Uint8ArrayConsumer((0, exports.extractRequiredLen)(val));
259
+ const args = [];
260
+ while (array.length() > 0) {
261
+ args.push((0, exports.valueDecoder)(array));
262
+ }
263
+ return args;
264
+ };
265
+ exports.decodeCombPair = decodeCombPair;
266
+ const encodeAnnots = (value) => {
267
+ const mergedAnnot = value
268
+ .map((x) => {
269
+ return Buffer.from(x, 'utf8').toString('hex');
270
+ })
271
+ .join('20');
272
+ const len = mergedAnnot.length / 2;
273
+ return `${(0, utils_1.pad)(len)}${mergedAnnot}`;
274
+ };
275
+ exports.encodeAnnots = encodeAnnots;
276
+ const decodeAnnots = (val) => {
277
+ const len = val.consume(4);
278
+ const annotLen = parseInt(Buffer.from(len).toString('hex'), 16);
279
+ const restOfAnnot = val.consume(annotLen);
280
+ const restOfAnnotHex = Buffer.from(restOfAnnot).toString('hex');
281
+ return restOfAnnotHex.split('20').map((x) => Buffer.from(x, 'hex').toString('utf8'));
282
+ };
283
+ exports.decodeAnnots = decodeAnnots;
@@ -25,6 +25,7 @@ var ProtocolsHash;
25
25
  ProtocolsHash["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
26
26
  ProtocolsHash["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
27
27
  ProtocolsHash["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
28
+ ProtocolsHash["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
28
29
  ProtocolsHash["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
29
30
  })(ProtocolsHash || (exports.ProtocolsHash = ProtocolsHash = {}));
30
31
  const protoLevel = {
@@ -49,6 +50,7 @@ const protoLevel = {
49
50
  PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi: 20,
50
51
  PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg: 21,
51
52
  PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7: 22,
53
+ PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh: 23,
52
54
  ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 23,
53
55
  };
54
56
  function ProtoInferiorTo(a, b) {
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schemaDecoder = exports.schemaEncoder = exports.operationDecoder = exports.operationEncoder = exports.FailingNoopSchema = exports.DalPublishCommitmentSchema = exports.SmartRollupExecuteOutboxMessageSchema = exports.SmartRollupAddMessagesSchema = exports.SmartRollupOriginateSchema = exports.SetDepositsLimitSchema = exports.DrainDelegateSchema = exports.UpdateConsensusKeySchema = exports.IncreasePaidStorageSchema = exports.TransferTicketSchema = exports.RegisterGlobalConstantSchema = exports.ProposalsSchema = exports.SeedNonceRevelationSchema = exports.AttestationWithDalSchema = exports.AttestationSchema = exports.BallotSchema = exports.OriginationSchema = exports.TransactionSchema = exports.DelegationSchema = exports.RevealSchema = exports.ActivationSchema = exports.ManagerOperationSchema = void 0;
4
+ const constants_proto022_1 = require("../constants-proto022");
5
+ const core_1 = require("@taquito/core");
6
+ const errors_1 = require("../errors");
7
+ exports.ManagerOperationSchema = {
8
+ branch: constants_proto022_1.CODEC.BRANCH,
9
+ contents: [constants_proto022_1.CODEC.OPERATION],
10
+ };
11
+ exports.ActivationSchema = {
12
+ pkh: constants_proto022_1.CODEC.TZ1,
13
+ secret: constants_proto022_1.CODEC.SECRET,
14
+ };
15
+ exports.RevealSchema = {
16
+ source: constants_proto022_1.CODEC.PKH,
17
+ fee: constants_proto022_1.CODEC.ZARITH,
18
+ counter: constants_proto022_1.CODEC.ZARITH,
19
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
20
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
21
+ public_key: constants_proto022_1.CODEC.PUBLIC_KEY,
22
+ };
23
+ exports.DelegationSchema = {
24
+ source: constants_proto022_1.CODEC.PKH,
25
+ fee: constants_proto022_1.CODEC.ZARITH,
26
+ counter: constants_proto022_1.CODEC.ZARITH,
27
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
28
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
29
+ delegate: constants_proto022_1.CODEC.DELEGATE,
30
+ };
31
+ exports.TransactionSchema = {
32
+ source: constants_proto022_1.CODEC.PKH,
33
+ fee: constants_proto022_1.CODEC.ZARITH,
34
+ counter: constants_proto022_1.CODEC.ZARITH,
35
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
36
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
37
+ amount: constants_proto022_1.CODEC.ZARITH,
38
+ destination: constants_proto022_1.CODEC.ADDRESS,
39
+ parameters: constants_proto022_1.CODEC.PARAMETERS,
40
+ };
41
+ exports.OriginationSchema = {
42
+ source: constants_proto022_1.CODEC.PKH,
43
+ fee: constants_proto022_1.CODEC.ZARITH,
44
+ counter: constants_proto022_1.CODEC.ZARITH,
45
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
46
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
47
+ balance: constants_proto022_1.CODEC.ZARITH,
48
+ delegate: constants_proto022_1.CODEC.DELEGATE,
49
+ script: constants_proto022_1.CODEC.SCRIPT,
50
+ };
51
+ exports.BallotSchema = {
52
+ source: constants_proto022_1.CODEC.PKH,
53
+ period: constants_proto022_1.CODEC.INT32,
54
+ proposal: constants_proto022_1.CODEC.PROPOSAL,
55
+ ballot: constants_proto022_1.CODEC.BALLOT_STATEMENT,
56
+ };
57
+ exports.AttestationSchema = {
58
+ slot: constants_proto022_1.CODEC.INT16,
59
+ level: constants_proto022_1.CODEC.INT32,
60
+ round: constants_proto022_1.CODEC.INT32,
61
+ block_payload_hash: constants_proto022_1.CODEC.BLOCK_PAYLOAD_HASH,
62
+ };
63
+ exports.AttestationWithDalSchema = {
64
+ slot: constants_proto022_1.CODEC.INT16,
65
+ level: constants_proto022_1.CODEC.INT32,
66
+ round: constants_proto022_1.CODEC.INT32,
67
+ block_payload_hash: constants_proto022_1.CODEC.BLOCK_PAYLOAD_HASH,
68
+ dal_attestation: constants_proto022_1.CODEC.ZARITH,
69
+ };
70
+ exports.SeedNonceRevelationSchema = {
71
+ level: constants_proto022_1.CODEC.INT32,
72
+ nonce: constants_proto022_1.CODEC.RAW,
73
+ };
74
+ exports.ProposalsSchema = {
75
+ source: constants_proto022_1.CODEC.PKH,
76
+ period: constants_proto022_1.CODEC.INT32,
77
+ proposals: constants_proto022_1.CODEC.PROPOSAL_ARR,
78
+ };
79
+ exports.RegisterGlobalConstantSchema = {
80
+ source: constants_proto022_1.CODEC.PKH,
81
+ fee: constants_proto022_1.CODEC.ZARITH,
82
+ counter: constants_proto022_1.CODEC.ZARITH,
83
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
84
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
85
+ value: constants_proto022_1.CODEC.VALUE,
86
+ };
87
+ exports.TransferTicketSchema = {
88
+ source: constants_proto022_1.CODEC.PKH,
89
+ fee: constants_proto022_1.CODEC.ZARITH,
90
+ counter: constants_proto022_1.CODEC.ZARITH,
91
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
92
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
93
+ ticket_contents: constants_proto022_1.CODEC.VALUE,
94
+ ticket_ty: constants_proto022_1.CODEC.VALUE,
95
+ ticket_ticketer: constants_proto022_1.CODEC.ADDRESS,
96
+ ticket_amount: constants_proto022_1.CODEC.ZARITH,
97
+ destination: constants_proto022_1.CODEC.ADDRESS,
98
+ entrypoint: constants_proto022_1.CODEC.ENTRYPOINT,
99
+ };
100
+ exports.IncreasePaidStorageSchema = {
101
+ source: constants_proto022_1.CODEC.PKH,
102
+ fee: constants_proto022_1.CODEC.ZARITH,
103
+ counter: constants_proto022_1.CODEC.ZARITH,
104
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
105
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
106
+ amount: constants_proto022_1.CODEC.ZARITH,
107
+ destination: constants_proto022_1.CODEC.SMART_CONTRACT_ADDRESS,
108
+ };
109
+ exports.UpdateConsensusKeySchema = {
110
+ source: constants_proto022_1.CODEC.PKH,
111
+ fee: constants_proto022_1.CODEC.ZARITH,
112
+ counter: constants_proto022_1.CODEC.ZARITH,
113
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
114
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
115
+ pk: constants_proto022_1.CODEC.PUBLIC_KEY,
116
+ proof: constants_proto022_1.CODEC.SIGNATURE_PROOF,
117
+ };
118
+ exports.DrainDelegateSchema = {
119
+ consensus_key: constants_proto022_1.CODEC.PKH,
120
+ delegate: constants_proto022_1.CODEC.PKH,
121
+ destination: constants_proto022_1.CODEC.PKH,
122
+ };
123
+ exports.SetDepositsLimitSchema = {
124
+ source: constants_proto022_1.CODEC.PKH,
125
+ fee: constants_proto022_1.CODEC.ZARITH,
126
+ counter: constants_proto022_1.CODEC.ZARITH,
127
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
128
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
129
+ limit: constants_proto022_1.CODEC.DEPOSITS_LIMIT,
130
+ };
131
+ exports.SmartRollupOriginateSchema = {
132
+ source: constants_proto022_1.CODEC.PKH,
133
+ fee: constants_proto022_1.CODEC.ZARITH,
134
+ counter: constants_proto022_1.CODEC.ZARITH,
135
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
136
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
137
+ pvm_kind: constants_proto022_1.CODEC.PVM_KIND,
138
+ kernel: constants_proto022_1.CODEC.PADDED_BYTES,
139
+ parameters_ty: constants_proto022_1.CODEC.VALUE,
140
+ whitelist: constants_proto022_1.CODEC.PKH_ARR,
141
+ };
142
+ exports.SmartRollupAddMessagesSchema = {
143
+ source: constants_proto022_1.CODEC.PKH,
144
+ fee: constants_proto022_1.CODEC.ZARITH,
145
+ counter: constants_proto022_1.CODEC.ZARITH,
146
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
147
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
148
+ message: constants_proto022_1.CODEC.SMART_ROLLUP_MESSAGE,
149
+ };
150
+ exports.SmartRollupExecuteOutboxMessageSchema = {
151
+ source: constants_proto022_1.CODEC.PKH,
152
+ fee: constants_proto022_1.CODEC.ZARITH,
153
+ counter: constants_proto022_1.CODEC.ZARITH,
154
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
155
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
156
+ rollup: constants_proto022_1.CODEC.SMART_ROLLUP_ADDRESS,
157
+ cemented_commitment: constants_proto022_1.CODEC.SMART_ROLLUP_COMMITMENT_HASH,
158
+ output_proof: constants_proto022_1.CODEC.PADDED_BYTES,
159
+ };
160
+ exports.DalPublishCommitmentSchema = {
161
+ source: constants_proto022_1.CODEC.PKH,
162
+ fee: constants_proto022_1.CODEC.ZARITH,
163
+ counter: constants_proto022_1.CODEC.ZARITH,
164
+ gas_limit: constants_proto022_1.CODEC.ZARITH,
165
+ storage_limit: constants_proto022_1.CODEC.ZARITH,
166
+ slot_header: constants_proto022_1.CODEC.SLOT_HEADER,
167
+ };
168
+ exports.FailingNoopSchema = {
169
+ arbitrary: constants_proto022_1.CODEC.PADDED_BYTES,
170
+ };
171
+ const operationEncoder = (encoders) => (operation) => {
172
+ if (!(operation.kind in encoders) || !(operation.kind in constants_proto022_1.kindMappingReverse)) {
173
+ throw new core_1.InvalidOperationKindError(operation.kind);
174
+ }
175
+ return constants_proto022_1.kindMappingReverse[operation.kind] + encoders[operation.kind](operation);
176
+ };
177
+ exports.operationEncoder = operationEncoder;
178
+ const operationDecoder = (decoders) => (value) => {
179
+ const op = value.consume(1);
180
+ const operationName = constants_proto022_1.kindMapping[op[0]];
181
+ if (operationName === undefined) {
182
+ throw new errors_1.UnsupportedOperationError(op[0].toString());
183
+ }
184
+ const decodedObj = decoders[operationName](value);
185
+ if (typeof decodedObj !== 'object') {
186
+ throw new errors_1.OperationDecodingError('Invalid operation, cannot be decoded.');
187
+ }
188
+ return Object.assign({ kind: operationName }, decodedObj);
189
+ };
190
+ exports.operationDecoder = operationDecoder;
191
+ const schemaEncoder = (encoders) => (schema) => (value) => {
192
+ const keys = Object.keys(schema);
193
+ return keys.reduce((prev, key) => {
194
+ const valueToEncode = schema[key];
195
+ if (value && Array.isArray(valueToEncode)) {
196
+ const encoder = encoders[valueToEncode[0]];
197
+ const values = value[key];
198
+ if (!Array.isArray(values)) {
199
+ throw new errors_1.OperationEncodingError(`Invalid operation value "${JSON.stringify(values)}" of key "${key}, expected value to be Array.`);
200
+ }
201
+ return (prev + values.reduce((prevBytes, current) => prevBytes + encoder(current), ''));
202
+ }
203
+ else {
204
+ const encoder = encoders[valueToEncode];
205
+ return prev + encoder(value[key]);
206
+ }
207
+ }, '');
208
+ };
209
+ exports.schemaEncoder = schemaEncoder;
210
+ const schemaDecoder = (decoders) => (schema) => (value) => {
211
+ const keys = Object.keys(schema);
212
+ return keys.reduce((prev, key) => {
213
+ const valueToEncode = schema[key];
214
+ if (Array.isArray(valueToEncode)) {
215
+ const decoder = decoders[valueToEncode[0]];
216
+ const decoded = [];
217
+ const lastLength = value.length();
218
+ while (value.length() > 0) {
219
+ decoded.push(decoder(value));
220
+ if (lastLength === value.length()) {
221
+ throw new errors_1.OperationDecodingError('Unable to decode value');
222
+ }
223
+ }
224
+ return Object.assign(Object.assign({}, prev), { [key]: decoded });
225
+ }
226
+ else {
227
+ const decoder = decoders[valueToEncode];
228
+ const result = decoder(value);
229
+ if (typeof result !== 'undefined') {
230
+ return Object.assign(Object.assign({}, prev), { [key]: result });
231
+ }
232
+ else {
233
+ return Object.assign({}, prev);
234
+ }
235
+ }
236
+ }, {});
237
+ };
238
+ exports.schemaDecoder = schemaDecoder;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.schemaDecoder = exports.schemaEncoder = exports.operationDecoder = exports.operationEncoder = exports.FailingNoopSchema = exports.DalPublishCommitmentSchema = exports.SmartRollupExecuteOutboxMessageSchema = exports.SmartRollupAddMessagesSchema = exports.SmartRollupOriginateSchema = exports.SetDepositsLimitSchema = exports.DrainDelegateSchema = exports.UpdateConsensusKeySchema = exports.IncreasePaidStorageSchema = exports.TransferTicketSchema = exports.RegisterGlobalConstantSchema = exports.ProposalsSchema = exports.SeedNonceRevelationSchema = exports.AttestationWithDalSchema = exports.AttestationSchema = exports.BallotSchema = exports.OriginationSchema = exports.TransactionSchema = exports.DelegationSchema = exports.RevealSchema = exports.ActivationSchema = exports.ManagerOperationSchema = void 0;
3
+ exports.schemaDecoder = exports.schemaEncoder = exports.operationDecoder = exports.operationEncoder = exports.FailingNoopSchema = exports.DalPublishCommitmentSchema = exports.SmartRollupExecuteOutboxMessageSchema = exports.SmartRollupAddMessagesSchema = exports.SmartRollupOriginateSchema = exports.SetDepositsLimitSchema = exports.DrainDelegateSchema = exports.UpdateCompanionKeySchema = exports.UpdateConsensusKeySchema = exports.IncreasePaidStorageSchema = exports.TransferTicketSchema = exports.RegisterGlobalConstantSchema = exports.ProposalsSchema = exports.SeedNonceRevelationSchema = exports.AttestationWithDalSchema = exports.AttestationSchema = exports.BallotSchema = exports.OriginationSchema = exports.TransactionSchema = exports.DelegationSchema = exports.RevealSchema = exports.ActivationSchema = exports.ManagerOperationSchema = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  const core_1 = require("@taquito/core");
6
6
  const errors_1 = require("../errors");
@@ -19,6 +19,7 @@ exports.RevealSchema = {
19
19
  gas_limit: constants_1.CODEC.ZARITH,
20
20
  storage_limit: constants_1.CODEC.ZARITH,
21
21
  public_key: constants_1.CODEC.PUBLIC_KEY,
22
+ proof: constants_1.CODEC.SIGNATURE_PROOF,
22
23
  };
23
24
  exports.DelegationSchema = {
24
25
  source: constants_1.CODEC.PKH,
@@ -115,6 +116,15 @@ exports.UpdateConsensusKeySchema = {
115
116
  pk: constants_1.CODEC.PUBLIC_KEY,
116
117
  proof: constants_1.CODEC.SIGNATURE_PROOF,
117
118
  };
119
+ exports.UpdateCompanionKeySchema = {
120
+ source: constants_1.CODEC.PKH,
121
+ fee: constants_1.CODEC.ZARITH,
122
+ counter: constants_1.CODEC.ZARITH,
123
+ gas_limit: constants_1.CODEC.ZARITH,
124
+ storage_limit: constants_1.CODEC.ZARITH,
125
+ pk: constants_1.CODEC.PUBLIC_KEY,
126
+ proof: constants_1.CODEC.SIGNATURE_PROOF,
127
+ };
118
128
  exports.DrainDelegateSchema = {
119
129
  consensus_key: constants_1.CODEC.PKH,
120
130
  delegate: constants_1.CODEC.PKH,
@@ -22,9 +22,9 @@ exports.localForger = exports.LocalForger = exports.ProtocolsHash = exports.VERS
22
22
  exports.getCodec = getCodec;
23
23
  const constants_1 = require("./constants");
24
24
  const decoder_1 = require("./decoder");
25
- const decoder_proto021_1 = require("./decoder-proto021");
25
+ const decoder_proto022_1 = require("./decoder-proto022");
26
26
  const encoder_1 = require("./encoder");
27
- const encoder_proto021_1 = require("./encoder-proto021");
27
+ const encoder_proto022_1 = require("./encoder-proto022");
28
28
  const uint8array_consumer_1 = require("./uint8array-consumer");
29
29
  const utils_1 = require("@taquito/utils");
30
30
  const errors_1 = require("./errors");
@@ -43,15 +43,15 @@ var version_1 = require("./version");
43
43
  Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
44
44
  var protocols_2 = require("./protocols");
45
45
  Object.defineProperty(exports, "ProtocolsHash", { enumerable: true, get: function () { return protocols_2.ProtocolsHash; } });
46
- const PROTOCOL_CURRENT = protocols_1.ProtocolsHash.PsRiotuma;
46
+ const PROTOCOL_CURRENT = protocols_1.ProtocolsHash.PtSeouLou;
47
47
  function getCodec(codec, _proto) {
48
- // use encodersProto021 & decodersProto021 if it's quebec or prior
49
- if (_proto === protocols_1.ProtocolsHash.PsQuebecn || (0, protocols_1.ProtoInferiorTo)(_proto, protocols_1.ProtocolsHash.PsQuebecn)) {
48
+ // use encodersProto022 & decodersProto022 if it's rio or prior
49
+ if (_proto === protocols_1.ProtocolsHash.PsRiotuma || (0, protocols_1.ProtoInferiorTo)(_proto, protocols_1.ProtocolsHash.PsRiotuma)) {
50
50
  return {
51
- encoder: encoder_proto021_1.encodersProto021[codec],
51
+ encoder: encoder_proto022_1.encoders[codec],
52
52
  decoder: (hex) => {
53
53
  const consumer = uint8array_consumer_1.Uint8ArrayConsumer.fromHexString(hex);
54
- return decoder_proto021_1.decodersProto021[codec](consumer);
54
+ return decoder_proto022_1.decoders[codec](consumer);
55
55
  },
56
56
  };
57
57
  }
@@ -107,6 +107,12 @@ class LocalForger {
107
107
  else if (content.kind === 'update_consensus_key' && diff[0] === 'proof') {
108
108
  continue;
109
109
  }
110
+ else if (content.kind === 'update_companion_key' && diff[0] === 'proof') {
111
+ continue;
112
+ }
113
+ else if (content.kind === 'reveal' && diff[0] === 'proof') {
114
+ continue;
115
+ }
110
116
  else {
111
117
  throw new errors_1.InvalidOperationSchemaError(content, `missing properties "${diff.join(', ')}"`);
112
118
  }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateMissingProperty = exports.validateOperationKind = void 0;
4
+ const operation_proto022_1 = require("./schema/operation-proto022");
5
+ const OperationKindMapping = {
6
+ activate_account: operation_proto022_1.ActivationSchema,
7
+ reveal: operation_proto022_1.RevealSchema,
8
+ delegation: operation_proto022_1.DelegationSchema,
9
+ transaction: operation_proto022_1.TransactionSchema,
10
+ origination: operation_proto022_1.OriginationSchema,
11
+ ballot: operation_proto022_1.BallotSchema,
12
+ attestation: operation_proto022_1.AttestationSchema,
13
+ attestation_with_dal: operation_proto022_1.AttestationWithDalSchema,
14
+ seed_nonce_revelation: operation_proto022_1.SeedNonceRevelationSchema,
15
+ proposals: operation_proto022_1.ProposalsSchema,
16
+ register_global_constant: operation_proto022_1.RegisterGlobalConstantSchema,
17
+ transfer_ticket: operation_proto022_1.TransferTicketSchema,
18
+ increase_paid_storage: operation_proto022_1.IncreasePaidStorageSchema,
19
+ update_consensus_key: operation_proto022_1.UpdateConsensusKeySchema,
20
+ drain_delegate: operation_proto022_1.DrainDelegateSchema,
21
+ set_deposits_limit: operation_proto022_1.SetDepositsLimitSchema,
22
+ smart_rollup_originate: operation_proto022_1.SmartRollupOriginateSchema,
23
+ smart_rollup_add_messages: operation_proto022_1.SmartRollupAddMessagesSchema,
24
+ smart_rollup_execute_outbox_message: operation_proto022_1.SmartRollupExecuteOutboxMessageSchema,
25
+ dal_publish_commitment: operation_proto022_1.DalPublishCommitmentSchema,
26
+ failing_noop: operation_proto022_1.FailingNoopSchema,
27
+ };
28
+ // Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa
29
+ const getArrayDifference = (arr1, arr2) => {
30
+ return arr2.filter((x) => !arr1.includes(x));
31
+ };
32
+ const deleteArrayElementByValue = (array, item) => {
33
+ return array.filter((e) => e !== item);
34
+ };
35
+ /**
36
+ * @returns A boolean value to indicate whether the operation kind is valid or not
37
+ */
38
+ const validateOperationKind = (opKind) => {
39
+ const opKindList = Object.keys(OperationKindMapping);
40
+ return opKindList.includes(opKind);
41
+ };
42
+ exports.validateOperationKind = validateOperationKind;
43
+ /**
44
+ * returns 0 when the two array of properties are identical or the passed property
45
+ * does not have any missing parameters from the corresponding schema
46
+ *
47
+ * @returns array element differences if there are missing required property keys
48
+ */
49
+ const validateMissingProperty = (operationContent) => {
50
+ const kind = operationContent.kind;
51
+ const keys = Object.keys(operationContent);
52
+ const cleanKeys = deleteArrayElementByValue(keys, 'kind');
53
+ const schemaKeys = Object.keys(OperationKindMapping[kind]);
54
+ return getArrayDifference(cleanKeys, schemaKeys);
55
+ };
56
+ exports.validateMissingProperty = validateMissingProperty;
@@ -17,6 +17,7 @@ const OperationKindMapping = {
17
17
  transfer_ticket: operation_1.TransferTicketSchema,
18
18
  increase_paid_storage: operation_1.IncreasePaidStorageSchema,
19
19
  update_consensus_key: operation_1.UpdateConsensusKeySchema,
20
+ update_companion_key: operation_1.UpdateCompanionKeySchema,
20
21
  drain_delegate: operation_1.DrainDelegateSchema,
21
22
  set_deposits_limit: operation_1.SetDepositsLimitSchema,
22
23
  smart_rollup_originate: operation_1.SmartRollupOriginateSchema,