@taquito/local-forging 23.0.2 → 23.1.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/taquito-local-forging.js +7 -29
- package/dist/lib/version.js +2 -2
- package/dist/taquito-local-forging.es6.js +315 -1736
- package/dist/taquito-local-forging.es6.js.map +1 -1
- package/dist/taquito-local-forging.umd.js +389 -1810
- package/dist/taquito-local-forging.umd.js.map +1 -1
- package/dist/types/taquito-local-forging.d.ts +2 -3
- package/package.json +8 -7
- package/dist/lib/codec-proto022.js +0 -563
- package/dist/lib/constants-proto022.js +0 -286
- package/dist/lib/decoder-proto022.js +0 -63
- package/dist/lib/encoder-proto022.js +0 -62
- package/dist/lib/michelson/codec-proto022.js +0 -283
- package/dist/lib/schema/operation-proto022.js +0 -238
- package/dist/lib/validator-proto022.js +0 -56
- package/dist/types/codec-proto022.d.ts +0 -79
- package/dist/types/constants-proto022.d.ts +0 -74
- package/dist/types/decoder-proto022.d.ts +0 -5
- package/dist/types/encoder-proto022.d.ts +0 -4
- package/dist/types/michelson/codec-proto022.d.ts +0 -49
- package/dist/types/schema/operation-proto022.d.ts +0 -188
- package/dist/types/validator-proto022.d.ts +0 -13
|
@@ -1,283 +0,0 @@
|
|
|
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;
|
|
@@ -1,238 +0,0 @@
|
|
|
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,56 +0,0 @@
|
|
|
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;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Prefix } from '@taquito/utils';
|
|
2
|
-
import { MichelsonValue } from './michelson/codec-proto022';
|
|
3
|
-
import { Uint8ArrayConsumer } from './uint8array-consumer';
|
|
4
|
-
export declare const prefixEncoder: (prefix: Prefix) => (str: string) => string;
|
|
5
|
-
export declare const prefixDecoder: (pre: Prefix) => (str: Uint8ArrayConsumer) => string;
|
|
6
|
-
export declare const tz1Decoder: (str: Uint8ArrayConsumer) => string;
|
|
7
|
-
export declare const branchDecoder: (str: Uint8ArrayConsumer) => string;
|
|
8
|
-
export declare const publicKeyHashDecoder: (val: Uint8ArrayConsumer) => string | undefined;
|
|
9
|
-
export declare const publicKeyHashesDecoder: (val: Uint8ArrayConsumer) => (string | undefined)[] | undefined;
|
|
10
|
-
export declare const branchEncoder: (str: string) => string;
|
|
11
|
-
export declare const tz1Encoder: (str: string) => string;
|
|
12
|
-
export declare const boolEncoder: (bool: unknown) => string;
|
|
13
|
-
export declare const proposalEncoder: (proposal: string) => string;
|
|
14
|
-
export declare const proposalDecoder: (proposal: Uint8ArrayConsumer) => string;
|
|
15
|
-
export declare const proposalsDecoder: (proposal: Uint8ArrayConsumer) => string[];
|
|
16
|
-
export declare const proposalsEncoder: (proposals: string[]) => string;
|
|
17
|
-
export declare const ballotEncoder: (ballot: string) => string;
|
|
18
|
-
export declare const ballotDecoder: (ballot: Uint8ArrayConsumer) => string;
|
|
19
|
-
export declare const pvmKindEncoder: (pvm: string) => string;
|
|
20
|
-
export declare const pvmKindDecoder: (pvm: Uint8ArrayConsumer) => string;
|
|
21
|
-
export declare const delegateEncoder: (val: string) => string;
|
|
22
|
-
export declare const int32Encoder: (val: number | string) => string;
|
|
23
|
-
export declare const int32Decoder: (val: Uint8ArrayConsumer) => number;
|
|
24
|
-
export declare const int16Encoder: (val: number | string) => string;
|
|
25
|
-
export declare const int16Decoder: (val: Uint8ArrayConsumer) => number;
|
|
26
|
-
export declare const boolDecoder: (val: Uint8ArrayConsumer) => boolean;
|
|
27
|
-
export declare const delegateDecoder: (val: Uint8ArrayConsumer) => string | undefined;
|
|
28
|
-
export declare const publicKeyHashEncoder: (val: string) => string;
|
|
29
|
-
export declare const publicKeyHashesEncoder: (val?: string[]) => string;
|
|
30
|
-
export declare const publicKeyEncoder: (val: string) => string;
|
|
31
|
-
export declare const addressEncoder: (val: string) => string;
|
|
32
|
-
export declare const smartRollupAddressEncoder: (val: string) => string;
|
|
33
|
-
export declare const smartContractAddressEncoder: (val: string) => string;
|
|
34
|
-
export declare const publicKeyDecoder: (val: Uint8ArrayConsumer) => string;
|
|
35
|
-
export declare const smartRollupCommitmentHashEncoder: (val: string) => string;
|
|
36
|
-
export declare const addressDecoder: (val: Uint8ArrayConsumer) => string | undefined;
|
|
37
|
-
export declare const smartRollupAddressDecoder: (val: Uint8ArrayConsumer) => string;
|
|
38
|
-
export declare const smartContractAddressDecoder: (val: Uint8ArrayConsumer) => string;
|
|
39
|
-
export declare const smartRollupCommitmentHashDecoder: (val: Uint8ArrayConsumer) => string;
|
|
40
|
-
export declare const zarithEncoder: (n: string) => string;
|
|
41
|
-
export declare const zarithDecoder: (n: Uint8ArrayConsumer) => string;
|
|
42
|
-
export declare const entrypointDecoder: (value: Uint8ArrayConsumer) => string;
|
|
43
|
-
export declare const parametersDecoder: (val: Uint8ArrayConsumer) => {
|
|
44
|
-
entrypoint: string;
|
|
45
|
-
value: string | number | object | undefined;
|
|
46
|
-
} | undefined;
|
|
47
|
-
export declare const entrypointEncoder: (entrypoint: string) => string;
|
|
48
|
-
export declare const parametersEncoder: (val: {
|
|
49
|
-
entrypoint: string;
|
|
50
|
-
value: MichelsonValue;
|
|
51
|
-
}) => string;
|
|
52
|
-
export declare const valueParameterEncoder: (value: MichelsonValue) => string;
|
|
53
|
-
export declare const valueParameterDecoder: (val: Uint8ArrayConsumer) => string | number | object | undefined;
|
|
54
|
-
export declare const blockPayloadHashEncoder: (str: string) => string;
|
|
55
|
-
export declare const blockPayloadHashDecoder: (str: Uint8ArrayConsumer) => string;
|
|
56
|
-
export declare const entrypointNameEncoder: (entrypoint: string) => string;
|
|
57
|
-
export declare const entrypointNameDecoder: (val: Uint8ArrayConsumer) => string;
|
|
58
|
-
export declare const burnLimitEncoder: (val: string) => string;
|
|
59
|
-
export declare const burnLimitDecoder: (value: Uint8ArrayConsumer) => string | undefined;
|
|
60
|
-
export declare const depositsLimitEncoder: (val: string) => string;
|
|
61
|
-
export declare const depositsLimitDecoder: (value: Uint8ArrayConsumer) => string | undefined;
|
|
62
|
-
export declare const signatureProofEncoder: (val: string) => string;
|
|
63
|
-
export declare const signatureProofDecoder: (value: Uint8ArrayConsumer) => string | undefined;
|
|
64
|
-
export declare const paddedBytesEncoder: (val: string, paddingLength?: number) => string;
|
|
65
|
-
export declare const paddedBytesDecoder: (val: Uint8ArrayConsumer) => string;
|
|
66
|
-
export declare const smartRollupMessageEncoder: (val: string[]) => string;
|
|
67
|
-
export declare const smartRollupMessageDecoder: (val: Uint8ArrayConsumer) => string[];
|
|
68
|
-
export declare const dalCommitmentEncoder: (val: string) => string;
|
|
69
|
-
export declare const dalCommitmentDecoder: (val: Uint8ArrayConsumer) => string;
|
|
70
|
-
export declare const slotHeaderEncoder: (val: {
|
|
71
|
-
slot_index: number;
|
|
72
|
-
commitment: string;
|
|
73
|
-
commitment_proof: string;
|
|
74
|
-
}) => string;
|
|
75
|
-
export declare const slotHeaderDecoder: (val: Uint8ArrayConsumer) => {
|
|
76
|
-
slot_index: number;
|
|
77
|
-
commitment: string;
|
|
78
|
-
commitment_proof: string;
|
|
79
|
-
};
|