@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.
@@ -0,0 +1,237 @@
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_proto021_1 = require("../constants-proto021");
5
+ const core_1 = require("@taquito/core");
6
+ const errors_1 = require("../errors");
7
+ exports.ManagerOperationSchema = {
8
+ branch: constants_proto021_1.CODEC.BRANCH,
9
+ contents: [constants_proto021_1.CODEC.OPERATION],
10
+ };
11
+ exports.ActivationSchema = {
12
+ pkh: constants_proto021_1.CODEC.TZ1,
13
+ secret: constants_proto021_1.CODEC.SECRET,
14
+ };
15
+ exports.RevealSchema = {
16
+ source: constants_proto021_1.CODEC.PKH,
17
+ fee: constants_proto021_1.CODEC.ZARITH,
18
+ counter: constants_proto021_1.CODEC.ZARITH,
19
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
20
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
21
+ public_key: constants_proto021_1.CODEC.PUBLIC_KEY,
22
+ };
23
+ exports.DelegationSchema = {
24
+ source: constants_proto021_1.CODEC.PKH,
25
+ fee: constants_proto021_1.CODEC.ZARITH,
26
+ counter: constants_proto021_1.CODEC.ZARITH,
27
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
28
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
29
+ delegate: constants_proto021_1.CODEC.DELEGATE,
30
+ };
31
+ exports.TransactionSchema = {
32
+ source: constants_proto021_1.CODEC.PKH,
33
+ fee: constants_proto021_1.CODEC.ZARITH,
34
+ counter: constants_proto021_1.CODEC.ZARITH,
35
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
36
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
37
+ amount: constants_proto021_1.CODEC.ZARITH,
38
+ destination: constants_proto021_1.CODEC.ADDRESS,
39
+ parameters: constants_proto021_1.CODEC.PARAMETERS,
40
+ };
41
+ exports.OriginationSchema = {
42
+ source: constants_proto021_1.CODEC.PKH,
43
+ fee: constants_proto021_1.CODEC.ZARITH,
44
+ counter: constants_proto021_1.CODEC.ZARITH,
45
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
46
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
47
+ balance: constants_proto021_1.CODEC.ZARITH,
48
+ delegate: constants_proto021_1.CODEC.DELEGATE,
49
+ script: constants_proto021_1.CODEC.SCRIPT,
50
+ };
51
+ exports.BallotSchema = {
52
+ source: constants_proto021_1.CODEC.PKH,
53
+ period: constants_proto021_1.CODEC.INT32,
54
+ proposal: constants_proto021_1.CODEC.PROPOSAL,
55
+ ballot: constants_proto021_1.CODEC.BALLOT_STATEMENT,
56
+ };
57
+ exports.AttestationSchema = {
58
+ slot: constants_proto021_1.CODEC.INT16,
59
+ level: constants_proto021_1.CODEC.INT32,
60
+ round: constants_proto021_1.CODEC.INT32,
61
+ block_payload_hash: constants_proto021_1.CODEC.BLOCK_PAYLOAD_HASH,
62
+ };
63
+ exports.AttestationWithDalSchema = {
64
+ slot: constants_proto021_1.CODEC.INT16,
65
+ level: constants_proto021_1.CODEC.INT32,
66
+ round: constants_proto021_1.CODEC.INT32,
67
+ block_payload_hash: constants_proto021_1.CODEC.BLOCK_PAYLOAD_HASH,
68
+ dal_attestation: constants_proto021_1.CODEC.ZARITH,
69
+ };
70
+ exports.SeedNonceRevelationSchema = {
71
+ level: constants_proto021_1.CODEC.INT32,
72
+ nonce: constants_proto021_1.CODEC.RAW,
73
+ };
74
+ exports.ProposalsSchema = {
75
+ source: constants_proto021_1.CODEC.PKH,
76
+ period: constants_proto021_1.CODEC.INT32,
77
+ proposals: constants_proto021_1.CODEC.PROPOSAL_ARR,
78
+ };
79
+ exports.RegisterGlobalConstantSchema = {
80
+ source: constants_proto021_1.CODEC.PKH,
81
+ fee: constants_proto021_1.CODEC.ZARITH,
82
+ counter: constants_proto021_1.CODEC.ZARITH,
83
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
84
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
85
+ value: constants_proto021_1.CODEC.VALUE,
86
+ };
87
+ exports.TransferTicketSchema = {
88
+ source: constants_proto021_1.CODEC.PKH,
89
+ fee: constants_proto021_1.CODEC.ZARITH,
90
+ counter: constants_proto021_1.CODEC.ZARITH,
91
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
92
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
93
+ ticket_contents: constants_proto021_1.CODEC.VALUE,
94
+ ticket_ty: constants_proto021_1.CODEC.VALUE,
95
+ ticket_ticketer: constants_proto021_1.CODEC.ADDRESS,
96
+ ticket_amount: constants_proto021_1.CODEC.ZARITH,
97
+ destination: constants_proto021_1.CODEC.ADDRESS,
98
+ entrypoint: constants_proto021_1.CODEC.ENTRYPOINT,
99
+ };
100
+ exports.IncreasePaidStorageSchema = {
101
+ source: constants_proto021_1.CODEC.PKH,
102
+ fee: constants_proto021_1.CODEC.ZARITH,
103
+ counter: constants_proto021_1.CODEC.ZARITH,
104
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
105
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
106
+ amount: constants_proto021_1.CODEC.ZARITH,
107
+ destination: constants_proto021_1.CODEC.SMART_CONTRACT_ADDRESS,
108
+ };
109
+ exports.UpdateConsensusKeySchema = {
110
+ source: constants_proto021_1.CODEC.PKH,
111
+ fee: constants_proto021_1.CODEC.ZARITH,
112
+ counter: constants_proto021_1.CODEC.ZARITH,
113
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
114
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
115
+ pk: constants_proto021_1.CODEC.PUBLIC_KEY,
116
+ };
117
+ exports.DrainDelegateSchema = {
118
+ consensus_key: constants_proto021_1.CODEC.PKH,
119
+ delegate: constants_proto021_1.CODEC.PKH,
120
+ destination: constants_proto021_1.CODEC.PKH,
121
+ };
122
+ exports.SetDepositsLimitSchema = {
123
+ source: constants_proto021_1.CODEC.PKH,
124
+ fee: constants_proto021_1.CODEC.ZARITH,
125
+ counter: constants_proto021_1.CODEC.ZARITH,
126
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
127
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
128
+ limit: constants_proto021_1.CODEC.DEPOSITS_LIMIT,
129
+ };
130
+ exports.SmartRollupOriginateSchema = {
131
+ source: constants_proto021_1.CODEC.PKH,
132
+ fee: constants_proto021_1.CODEC.ZARITH,
133
+ counter: constants_proto021_1.CODEC.ZARITH,
134
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
135
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
136
+ pvm_kind: constants_proto021_1.CODEC.PVM_KIND,
137
+ kernel: constants_proto021_1.CODEC.PADDED_BYTES,
138
+ parameters_ty: constants_proto021_1.CODEC.VALUE,
139
+ whitelist: constants_proto021_1.CODEC.PKH_ARR,
140
+ };
141
+ exports.SmartRollupAddMessagesSchema = {
142
+ source: constants_proto021_1.CODEC.PKH,
143
+ fee: constants_proto021_1.CODEC.ZARITH,
144
+ counter: constants_proto021_1.CODEC.ZARITH,
145
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
146
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
147
+ message: constants_proto021_1.CODEC.SMART_ROLLUP_MESSAGE,
148
+ };
149
+ exports.SmartRollupExecuteOutboxMessageSchema = {
150
+ source: constants_proto021_1.CODEC.PKH,
151
+ fee: constants_proto021_1.CODEC.ZARITH,
152
+ counter: constants_proto021_1.CODEC.ZARITH,
153
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
154
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
155
+ rollup: constants_proto021_1.CODEC.SMART_ROLLUP_ADDRESS,
156
+ cemented_commitment: constants_proto021_1.CODEC.SMART_ROLLUP_COMMITMENT_HASH,
157
+ output_proof: constants_proto021_1.CODEC.PADDED_BYTES,
158
+ };
159
+ exports.DalPublishCommitmentSchema = {
160
+ source: constants_proto021_1.CODEC.PKH,
161
+ fee: constants_proto021_1.CODEC.ZARITH,
162
+ counter: constants_proto021_1.CODEC.ZARITH,
163
+ gas_limit: constants_proto021_1.CODEC.ZARITH,
164
+ storage_limit: constants_proto021_1.CODEC.ZARITH,
165
+ slot_header: constants_proto021_1.CODEC.SLOT_HEADER,
166
+ };
167
+ exports.FailingNoopSchema = {
168
+ arbitrary: constants_proto021_1.CODEC.PADDED_BYTES,
169
+ };
170
+ const operationEncoder = (encoders) => (operation) => {
171
+ if (!(operation.kind in encoders) || !(operation.kind in constants_proto021_1.kindMappingReverse)) {
172
+ throw new core_1.InvalidOperationKindError(operation.kind);
173
+ }
174
+ return constants_proto021_1.kindMappingReverse[operation.kind] + encoders[operation.kind](operation);
175
+ };
176
+ exports.operationEncoder = operationEncoder;
177
+ const operationDecoder = (decoders) => (value) => {
178
+ const op = value.consume(1);
179
+ const operationName = constants_proto021_1.kindMapping[op[0]];
180
+ if (operationName === undefined) {
181
+ throw new errors_1.UnsupportedOperationError(op[0].toString());
182
+ }
183
+ const decodedObj = decoders[operationName](value);
184
+ if (typeof decodedObj !== 'object') {
185
+ throw new errors_1.OperationDecodingError('Invalid operation, cannot be decoded.');
186
+ }
187
+ return Object.assign({ kind: operationName }, decodedObj);
188
+ };
189
+ exports.operationDecoder = operationDecoder;
190
+ const schemaEncoder = (encoders) => (schema) => (value) => {
191
+ const keys = Object.keys(schema);
192
+ return keys.reduce((prev, key) => {
193
+ const valueToEncode = schema[key];
194
+ if (value && Array.isArray(valueToEncode)) {
195
+ const encoder = encoders[valueToEncode[0]];
196
+ const values = value[key];
197
+ if (!Array.isArray(values)) {
198
+ throw new errors_1.OperationEncodingError(`Invalid operation value "${JSON.stringify(values)}" of key "${key}, expected value to be Array.`);
199
+ }
200
+ return (prev + values.reduce((prevBytes, current) => prevBytes + encoder(current), ''));
201
+ }
202
+ else {
203
+ const encoder = encoders[valueToEncode];
204
+ return prev + encoder(value[key]);
205
+ }
206
+ }, '');
207
+ };
208
+ exports.schemaEncoder = schemaEncoder;
209
+ const schemaDecoder = (decoders) => (schema) => (value) => {
210
+ const keys = Object.keys(schema);
211
+ return keys.reduce((prev, key) => {
212
+ const valueToEncode = schema[key];
213
+ if (Array.isArray(valueToEncode)) {
214
+ const decoder = decoders[valueToEncode[0]];
215
+ const decoded = [];
216
+ const lastLength = value.length();
217
+ while (value.length() > 0) {
218
+ decoded.push(decoder(value));
219
+ if (lastLength === value.length()) {
220
+ throw new errors_1.OperationDecodingError('Unable to decode value');
221
+ }
222
+ }
223
+ return Object.assign(Object.assign({}, prev), { [key]: decoded });
224
+ }
225
+ else {
226
+ const decoder = decoders[valueToEncode];
227
+ const result = decoder(value);
228
+ if (typeof result !== 'undefined') {
229
+ return Object.assign(Object.assign({}, prev), { [key]: result });
230
+ }
231
+ else {
232
+ return Object.assign({}, prev);
233
+ }
234
+ }
235
+ }, {});
236
+ };
237
+ exports.schemaDecoder = schemaDecoder;
@@ -113,6 +113,7 @@ exports.UpdateConsensusKeySchema = {
113
113
  gas_limit: constants_1.CODEC.ZARITH,
114
114
  storage_limit: constants_1.CODEC.ZARITH,
115
115
  pk: constants_1.CODEC.PUBLIC_KEY,
116
+ proof: constants_1.CODEC.SIGNATURE_PROOF,
116
117
  };
117
118
  exports.DrainDelegateSchema = {
118
119
  consensus_key: constants_1.CODEC.PKH,
@@ -22,7 +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
26
  const encoder_1 = require("./encoder");
27
+ const encoder_proto021_1 = require("./encoder-proto021");
26
28
  const uint8array_consumer_1 = require("./uint8array-consumer");
27
29
  const utils_1 = require("@taquito/utils");
28
30
  const errors_1 = require("./errors");
@@ -41,17 +43,36 @@ var version_1 = require("./version");
41
43
  Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
42
44
  var protocols_2 = require("./protocols");
43
45
  Object.defineProperty(exports, "ProtocolsHash", { enumerable: true, get: function () { return protocols_2.ProtocolsHash; } });
44
- const PROTOCOL_CURRENT = protocols_1.ProtocolsHash.PsQuebecn;
46
+ const PROTOCOL_CURRENT = protocols_1.ProtocolsHash.PsRiotuma;
45
47
  function getCodec(codec, _proto) {
46
- return {
47
- encoder: encoder_1.encoders[codec],
48
- decoder: (hex) => {
49
- const consumer = uint8array_consumer_1.Uint8ArrayConsumer.fromHexString(hex);
50
- return decoder_1.decoders[codec](consumer);
51
- },
52
- };
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)) {
50
+ return {
51
+ encoder: encoder_proto021_1.encodersProto021[codec],
52
+ decoder: (hex) => {
53
+ const consumer = uint8array_consumer_1.Uint8ArrayConsumer.fromHexString(hex);
54
+ return decoder_proto021_1.decodersProto021[codec](consumer);
55
+ },
56
+ };
57
+ }
58
+ else {
59
+ return {
60
+ encoder: encoder_1.encoders[codec],
61
+ decoder: (hex) => {
62
+ const consumer = uint8array_consumer_1.Uint8ArrayConsumer.fromHexString(hex);
63
+ return decoder_1.decoders[codec](consumer);
64
+ },
65
+ };
66
+ }
67
+ // TODO: Remove above if else once mainnet migrated into rio protocol and uncommon the return block below
68
+ // return {
69
+ // encoder: encoders[codec],
70
+ // decoder: (hex: string) => {
71
+ // const consumer = Uint8ArrayConsumer.fromHexString(hex);
72
+ // return decoders[codec](consumer) as any;
73
+ // },
74
+ // };
53
75
  }
54
- //
55
76
  class LocalForger {
56
77
  constructor(protocolHash = PROTOCOL_CURRENT) {
57
78
  this.protocolHash = protocolHash;
@@ -83,6 +104,9 @@ class LocalForger {
83
104
  else if (content.kind === 'smart_rollup_originate' && diff[0] === 'whitelist') {
84
105
  continue;
85
106
  }
107
+ else if (content.kind === 'update_consensus_key' && diff[0] === 'proof') {
108
+ continue;
109
+ }
86
110
  else {
87
111
  throw new errors_1.InvalidOperationSchemaError(content, `missing properties "${diff.join(', ')}"`);
88
112
  }
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  exports.VERSION = {
6
- "commitHash": "d4e23f5c1329a03dc8e79a586c80c159559d70fb",
7
- "version": "21.0.4"
6
+ "commitHash": "6936d6bc71e6a805f6d5568b60b1a0f6595a375d",
7
+ "version": "22.0.0-RC.0"
8
8
  };