@taquito/local-forging 23.0.3 → 24.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/constants.js +2 -0
- package/dist/lib/protocols.js +3 -1
- package/dist/lib/taquito-local-forging.js +8 -30
- package/dist/lib/version.js +2 -2
- package/dist/taquito-local-forging.es6.js +320 -1738
- package/dist/taquito-local-forging.es6.js.map +1 -1
- package/dist/taquito-local-forging.umd.js +393 -1811
- package/dist/taquito-local-forging.umd.js.map +1 -1
- package/dist/types/protocols.d.ts +1 -0
- package/dist/types/taquito-local-forging.d.ts +2 -3
- package/package.json +10 -8
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-local-forging.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taquito-local-forging.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -21,6 +21,7 @@ export declare enum ProtocolsHash {
|
|
|
21
21
|
PsQuebecn = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",
|
|
22
22
|
PsRiotuma = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",
|
|
23
23
|
PtSeouLou = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",
|
|
24
|
+
PtTALLiNt = "PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",
|
|
24
25
|
ProtoALpha = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"
|
|
25
26
|
}
|
|
26
27
|
export declare function ProtoInferiorTo(a: ProtocolsHash, b: ProtocolsHash): boolean;
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import 'fast-text-encoding';
|
|
6
6
|
import { ForgeParams, Forger } from './interface';
|
|
7
7
|
import { CODEC } from './constants';
|
|
8
|
-
import { CODEC as CODECPROTO022 } from './constants-proto022';
|
|
9
8
|
import { ProtocolsHash } from './protocols';
|
|
10
9
|
export { CODEC, opMapping, opMappingReverse } from './constants';
|
|
11
10
|
export * from './decoder';
|
|
@@ -14,8 +13,8 @@ export * from './uint8array-consumer';
|
|
|
14
13
|
export * from './interface';
|
|
15
14
|
export { VERSION } from './version';
|
|
16
15
|
export { ProtocolsHash } from './protocols';
|
|
17
|
-
export declare function getCodec(codec: CODEC
|
|
18
|
-
encoder: import("./encoder
|
|
16
|
+
export declare function getCodec(codec: CODEC, _proto: ProtocolsHash): {
|
|
17
|
+
encoder: import("./encoder").Encoder<any>;
|
|
19
18
|
decoder: (hex: string) => any;
|
|
20
19
|
};
|
|
21
20
|
export declare class LocalForger implements Forger {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taquito/local-forging",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0-RC.0",
|
|
4
4
|
"description": "Provide local forging functionality to be with taquito",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
27
|
+
"node": ">=20"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"test": "jest --coverage",
|
|
@@ -67,18 +67,19 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@taquito/core": "^
|
|
71
|
-
"@taquito/utils": "^
|
|
70
|
+
"@taquito/core": "^24.0.0-RC.0",
|
|
71
|
+
"@taquito/utils": "^24.0.0-RC.0",
|
|
72
72
|
"bignumber.js": "^9.1.2",
|
|
73
|
-
"fast-text-encoding": "^1.0.6"
|
|
73
|
+
"fast-text-encoding": "^1.0.6",
|
|
74
|
+
"whatwg-url": "^15.1.0"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"@taquito/rpc": "^
|
|
77
|
+
"@taquito/rpc": "^24.0.0-RC.0",
|
|
77
78
|
"@types/bluebird": "^3.5.42",
|
|
78
79
|
"@types/estree": "^1.0.5",
|
|
79
80
|
"@types/fast-text-encoding": "^1.0.3",
|
|
80
81
|
"@types/jest": "^29.5.12",
|
|
81
|
-
"@types/node": "^
|
|
82
|
+
"@types/node": "^20",
|
|
82
83
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
83
84
|
"@typescript-eslint/parser": "^6.21.0",
|
|
84
85
|
"colors": "^1.4.0",
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
"rimraf": "^6.0.1",
|
|
96
97
|
"rollup": "^4.22.4",
|
|
97
98
|
"rollup-plugin-json": "^4.0.0",
|
|
99
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
98
100
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
99
101
|
"shelljs": "^0.8.5",
|
|
100
102
|
"stream-browserify": "^3.0.0",
|
|
@@ -106,5 +108,5 @@
|
|
|
106
108
|
"webpack": "^5.94.0",
|
|
107
109
|
"webpack-cli": "^5.1.4"
|
|
108
110
|
},
|
|
109
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "784d536e73487529e402a3379be899bc5ac0342c"
|
|
110
112
|
}
|
|
@@ -1,563 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.burnLimitDecoder = exports.burnLimitEncoder = exports.entrypointNameDecoder = exports.entrypointNameEncoder = exports.blockPayloadHashDecoder = exports.blockPayloadHashEncoder = exports.valueParameterDecoder = exports.valueParameterEncoder = exports.parametersEncoder = exports.entrypointEncoder = exports.parametersDecoder = exports.entrypointDecoder = exports.zarithDecoder = exports.zarithEncoder = exports.smartRollupCommitmentHashDecoder = exports.smartContractAddressDecoder = exports.smartRollupAddressDecoder = exports.addressDecoder = exports.smartRollupCommitmentHashEncoder = exports.publicKeyDecoder = exports.smartContractAddressEncoder = exports.smartRollupAddressEncoder = exports.addressEncoder = exports.publicKeyEncoder = exports.publicKeyHashesEncoder = exports.publicKeyHashEncoder = exports.delegateDecoder = exports.boolDecoder = exports.int16Decoder = exports.int16Encoder = exports.int32Decoder = exports.int32Encoder = exports.delegateEncoder = exports.pvmKindDecoder = exports.pvmKindEncoder = exports.ballotDecoder = exports.ballotEncoder = exports.proposalsEncoder = exports.proposalsDecoder = exports.proposalDecoder = exports.proposalEncoder = exports.boolEncoder = exports.tz1Encoder = exports.branchEncoder = exports.publicKeyHashesDecoder = exports.publicKeyHashDecoder = exports.branchDecoder = exports.tz1Decoder = exports.prefixDecoder = exports.prefixEncoder = void 0;
|
|
4
|
-
exports.slotHeaderDecoder = exports.slotHeaderEncoder = exports.dalCommitmentDecoder = exports.dalCommitmentEncoder = exports.smartRollupMessageDecoder = exports.smartRollupMessageEncoder = exports.paddedBytesDecoder = exports.paddedBytesEncoder = exports.signatureProofDecoder = exports.signatureProofEncoder = exports.depositsLimitDecoder = exports.depositsLimitEncoder = void 0;
|
|
5
|
-
const utils_1 = require("@taquito/utils");
|
|
6
|
-
const errors_1 = require("./errors");
|
|
7
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
8
|
-
const constants_proto022_1 = require("./constants-proto022");
|
|
9
|
-
const codec_proto022_1 = require("./michelson/codec-proto022");
|
|
10
|
-
const uint8array_consumer_1 = require("./uint8array-consumer");
|
|
11
|
-
const utils_2 = require("./utils");
|
|
12
|
-
const core_1 = require("@taquito/core");
|
|
13
|
-
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
|
|
14
|
-
const prefixEncoder = (prefix) => (str) => {
|
|
15
|
-
return (0, utils_1.buf2hex)(Buffer.from((0, utils_1.b58cdecode)(str, utils_1.prefix[prefix])));
|
|
16
|
-
};
|
|
17
|
-
exports.prefixEncoder = prefixEncoder;
|
|
18
|
-
const prefixDecoder = (pre) => (str) => {
|
|
19
|
-
const val = str.consume(utils_1.prefixLength[pre]);
|
|
20
|
-
return (0, utils_1.b58cencode)(val, utils_1.prefix[pre]);
|
|
21
|
-
};
|
|
22
|
-
exports.prefixDecoder = prefixDecoder;
|
|
23
|
-
exports.tz1Decoder = (0, exports.prefixDecoder)(utils_1.Prefix.TZ1);
|
|
24
|
-
exports.branchDecoder = (0, exports.prefixDecoder)(utils_1.Prefix.B);
|
|
25
|
-
const publicKeyHashDecoder = (val) => {
|
|
26
|
-
const prefix = val.consume(1);
|
|
27
|
-
if (prefix[0] === 0x00) {
|
|
28
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.TZ1)(val);
|
|
29
|
-
}
|
|
30
|
-
else if (prefix[0] === 0x01) {
|
|
31
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.TZ2)(val);
|
|
32
|
-
}
|
|
33
|
-
else if (prefix[0] === 0x02) {
|
|
34
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.TZ3)(val);
|
|
35
|
-
}
|
|
36
|
-
else if (prefix[0] === 0x03) {
|
|
37
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.TZ4)(val);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
exports.publicKeyHashDecoder = publicKeyHashDecoder;
|
|
41
|
-
const publicKeyHashesDecoder = (val) => {
|
|
42
|
-
if (!(0, exports.boolDecoder)(val)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const publicKeyHashes = [];
|
|
46
|
-
val.consume(4);
|
|
47
|
-
while (val.length() > 0) {
|
|
48
|
-
publicKeyHashes.push((0, exports.publicKeyHashDecoder)(val));
|
|
49
|
-
}
|
|
50
|
-
return publicKeyHashes;
|
|
51
|
-
};
|
|
52
|
-
exports.publicKeyHashesDecoder = publicKeyHashesDecoder;
|
|
53
|
-
exports.branchEncoder = (0, exports.prefixEncoder)(utils_1.Prefix.B);
|
|
54
|
-
exports.tz1Encoder = (0, exports.prefixEncoder)(utils_1.Prefix.TZ1);
|
|
55
|
-
const boolEncoder = (bool) => (bool ? 'ff' : '00');
|
|
56
|
-
exports.boolEncoder = boolEncoder;
|
|
57
|
-
const proposalEncoder = (proposal) => {
|
|
58
|
-
return (0, exports.prefixEncoder)(utils_1.Prefix.P)(proposal);
|
|
59
|
-
};
|
|
60
|
-
exports.proposalEncoder = proposalEncoder;
|
|
61
|
-
const proposalDecoder = (proposal) => {
|
|
62
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.P)(proposal);
|
|
63
|
-
};
|
|
64
|
-
exports.proposalDecoder = proposalDecoder;
|
|
65
|
-
const proposalsDecoder = (proposal) => {
|
|
66
|
-
const proposals = [];
|
|
67
|
-
proposal.consume(4);
|
|
68
|
-
while (proposal.length() > 0) {
|
|
69
|
-
proposals.push((0, exports.proposalDecoder)(proposal));
|
|
70
|
-
}
|
|
71
|
-
return proposals;
|
|
72
|
-
};
|
|
73
|
-
exports.proposalsDecoder = proposalsDecoder;
|
|
74
|
-
const proposalsEncoder = (proposals) => {
|
|
75
|
-
return (0, utils_2.pad)(32 * proposals.length) + proposals.map((x) => (0, exports.proposalEncoder)(x)).join('');
|
|
76
|
-
};
|
|
77
|
-
exports.proposalsEncoder = proposalsEncoder;
|
|
78
|
-
const ballotEncoder = (ballot) => {
|
|
79
|
-
switch (ballot) {
|
|
80
|
-
case 'yay':
|
|
81
|
-
return '00';
|
|
82
|
-
case 'nay':
|
|
83
|
-
return '01';
|
|
84
|
-
case 'pass':
|
|
85
|
-
return '02';
|
|
86
|
-
default:
|
|
87
|
-
throw new errors_1.InvalidBallotValueError(ballot);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
exports.ballotEncoder = ballotEncoder;
|
|
91
|
-
const ballotDecoder = (ballot) => {
|
|
92
|
-
const value = ballot.consume(1);
|
|
93
|
-
switch (value[0]) {
|
|
94
|
-
case 0x00:
|
|
95
|
-
return 'yay';
|
|
96
|
-
case 0x01:
|
|
97
|
-
return 'nay';
|
|
98
|
-
case 0x02:
|
|
99
|
-
return 'pass';
|
|
100
|
-
default:
|
|
101
|
-
throw new errors_1.DecodeBallotValueError(value[0].toString());
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
exports.ballotDecoder = ballotDecoder;
|
|
105
|
-
const pvmKindEncoder = (pvm) => {
|
|
106
|
-
switch (pvm) {
|
|
107
|
-
case 'arith':
|
|
108
|
-
return '00';
|
|
109
|
-
case 'wasm_2_0_0':
|
|
110
|
-
return '01';
|
|
111
|
-
case 'riscv':
|
|
112
|
-
return '02';
|
|
113
|
-
default:
|
|
114
|
-
throw new errors_1.UnsupportedPvmKindError(pvm);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
exports.pvmKindEncoder = pvmKindEncoder;
|
|
118
|
-
const pvmKindDecoder = (pvm) => {
|
|
119
|
-
const value = pvm.consume(1);
|
|
120
|
-
switch (value[0]) {
|
|
121
|
-
case 0x00:
|
|
122
|
-
return 'arith';
|
|
123
|
-
case 0x01:
|
|
124
|
-
return 'wasm_2_0_0';
|
|
125
|
-
case 0x02:
|
|
126
|
-
return 'riscv';
|
|
127
|
-
default:
|
|
128
|
-
throw new errors_1.DecodePvmKindError(value[0].toString());
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
exports.pvmKindDecoder = pvmKindDecoder;
|
|
132
|
-
const delegateEncoder = (val) => {
|
|
133
|
-
if (val) {
|
|
134
|
-
return (0, exports.boolEncoder)(true) + (0, exports.publicKeyHashEncoder)(val);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return (0, exports.boolEncoder)(false);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
exports.delegateEncoder = delegateEncoder;
|
|
141
|
-
const int32Encoder = (val) => {
|
|
142
|
-
const num = parseInt(String(val), 10);
|
|
143
|
-
const byte = [];
|
|
144
|
-
for (let i = 0; i < 4; i++) {
|
|
145
|
-
const shiftBy = (4 - (i + 1)) * 8;
|
|
146
|
-
byte.push((num & (0xff << shiftBy)) >> shiftBy);
|
|
147
|
-
}
|
|
148
|
-
return Buffer.from(byte).toString('hex');
|
|
149
|
-
};
|
|
150
|
-
exports.int32Encoder = int32Encoder;
|
|
151
|
-
const int32Decoder = (val) => {
|
|
152
|
-
const num = val.consume(4);
|
|
153
|
-
let finalNum = 0;
|
|
154
|
-
for (let i = 0; i < num.length; i++) {
|
|
155
|
-
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
|
|
156
|
-
}
|
|
157
|
-
return finalNum;
|
|
158
|
-
};
|
|
159
|
-
exports.int32Decoder = int32Decoder;
|
|
160
|
-
const int16Encoder = (val) => {
|
|
161
|
-
const num = parseInt(String(val), 10);
|
|
162
|
-
const byte = [];
|
|
163
|
-
for (let i = 0; i < 2; i++) {
|
|
164
|
-
const shiftBy = (2 - (i + 1)) * 8;
|
|
165
|
-
byte.push((num & (0xff << shiftBy)) >> shiftBy);
|
|
166
|
-
}
|
|
167
|
-
return Buffer.from(byte).toString('hex');
|
|
168
|
-
};
|
|
169
|
-
exports.int16Encoder = int16Encoder;
|
|
170
|
-
const int16Decoder = (val) => {
|
|
171
|
-
const num = val.consume(2);
|
|
172
|
-
let finalNum = 0;
|
|
173
|
-
for (let i = 0; i < num.length; i++) {
|
|
174
|
-
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
|
|
175
|
-
}
|
|
176
|
-
return finalNum;
|
|
177
|
-
};
|
|
178
|
-
exports.int16Decoder = int16Decoder;
|
|
179
|
-
const boolDecoder = (val) => {
|
|
180
|
-
const bool = val.consume(1);
|
|
181
|
-
return bool[0] === 0xff;
|
|
182
|
-
};
|
|
183
|
-
exports.boolDecoder = boolDecoder;
|
|
184
|
-
const delegateDecoder = (val) => {
|
|
185
|
-
const hasDelegate = (0, exports.boolDecoder)(val);
|
|
186
|
-
if (hasDelegate) {
|
|
187
|
-
return (0, exports.publicKeyHashDecoder)(val);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
exports.delegateDecoder = delegateDecoder;
|
|
191
|
-
const publicKeyHashEncoder = (val) => {
|
|
192
|
-
const pubkeyPrefix = val.substring(0, 3);
|
|
193
|
-
switch (pubkeyPrefix) {
|
|
194
|
-
case utils_1.Prefix.TZ1:
|
|
195
|
-
return '00' + (0, exports.prefixEncoder)(utils_1.Prefix.TZ1)(val);
|
|
196
|
-
case utils_1.Prefix.TZ2:
|
|
197
|
-
return '01' + (0, exports.prefixEncoder)(utils_1.Prefix.TZ2)(val);
|
|
198
|
-
case utils_1.Prefix.TZ3:
|
|
199
|
-
return '02' + (0, exports.prefixEncoder)(utils_1.Prefix.TZ3)(val);
|
|
200
|
-
case utils_1.Prefix.TZ4:
|
|
201
|
-
return '03' + (0, exports.prefixEncoder)(utils_1.Prefix.TZ4)(val);
|
|
202
|
-
default:
|
|
203
|
-
throw new utils_1.InvalidKeyHashError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
204
|
-
` expecting one for the following "${utils_1.Prefix.TZ1}", "${utils_1.Prefix.TZ2}", "${utils_1.Prefix.TZ3}" or "${utils_1.Prefix.TZ4}".`);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
exports.publicKeyHashEncoder = publicKeyHashEncoder;
|
|
208
|
-
const publicKeyHashesEncoder = (val) => {
|
|
209
|
-
if (!val) {
|
|
210
|
-
return (0, exports.boolEncoder)(false);
|
|
211
|
-
}
|
|
212
|
-
if (val.length === 0) {
|
|
213
|
-
return (0, exports.boolEncoder)(true) + (0, utils_2.pad)(0);
|
|
214
|
-
}
|
|
215
|
-
const publicKeyHashes = val.reduce((prev, curr) => {
|
|
216
|
-
return prev + (0, exports.publicKeyHashEncoder)(curr);
|
|
217
|
-
}, '');
|
|
218
|
-
return (0, exports.boolEncoder)(true) + (0, utils_2.pad)(publicKeyHashes.length / 2) + publicKeyHashes;
|
|
219
|
-
};
|
|
220
|
-
exports.publicKeyHashesEncoder = publicKeyHashesEncoder;
|
|
221
|
-
const publicKeyEncoder = (val) => {
|
|
222
|
-
const pubkeyPrefix = val.substring(0, 4);
|
|
223
|
-
switch (pubkeyPrefix) {
|
|
224
|
-
case utils_1.Prefix.EDPK:
|
|
225
|
-
return '00' + (0, exports.prefixEncoder)(utils_1.Prefix.EDPK)(val);
|
|
226
|
-
case utils_1.Prefix.SPPK:
|
|
227
|
-
return '01' + (0, exports.prefixEncoder)(utils_1.Prefix.SPPK)(val);
|
|
228
|
-
case utils_1.Prefix.P2PK:
|
|
229
|
-
return '02' + (0, exports.prefixEncoder)(utils_1.Prefix.P2PK)(val);
|
|
230
|
-
case utils_1.Prefix.BLPK:
|
|
231
|
-
return '03' + (0, exports.prefixEncoder)(utils_1.Prefix.BLPK)(val);
|
|
232
|
-
default:
|
|
233
|
-
throw new utils_1.InvalidPublicKeyError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
234
|
-
` expecting one of the following '${utils_1.Prefix.EDPK}', '${utils_1.Prefix.SPPK}', '${utils_1.Prefix.P2PK}' or '${utils_1.Prefix.BLPK}'.`);
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
exports.publicKeyEncoder = publicKeyEncoder;
|
|
238
|
-
const addressEncoder = (val) => {
|
|
239
|
-
const pubkeyPrefix = val.substring(0, 3);
|
|
240
|
-
switch (pubkeyPrefix) {
|
|
241
|
-
case utils_1.Prefix.TZ1:
|
|
242
|
-
case utils_1.Prefix.TZ2:
|
|
243
|
-
case utils_1.Prefix.TZ3:
|
|
244
|
-
case utils_1.Prefix.TZ4:
|
|
245
|
-
return '00' + (0, exports.publicKeyHashEncoder)(val);
|
|
246
|
-
case utils_1.Prefix.KT1:
|
|
247
|
-
return '01' + (0, exports.prefixEncoder)(utils_1.Prefix.KT1)(val) + '00';
|
|
248
|
-
default:
|
|
249
|
-
throw new core_1.InvalidAddressError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
250
|
-
` expecting one of the following prefix '${utils_1.Prefix.TZ1}', ${utils_1.Prefix.TZ2}', '${utils_1.Prefix.TZ3}', '${utils_1.Prefix.TZ4}' or '${utils_1.Prefix.KT1}'.`);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
exports.addressEncoder = addressEncoder;
|
|
254
|
-
const smartRollupAddressEncoder = (val) => {
|
|
255
|
-
if (val.substring(0, 3) !== utils_1.Prefix.SR1) {
|
|
256
|
-
throw new errors_1.InvalidSmartRollupAddressError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils_1.Prefix.SR1}'.`);
|
|
257
|
-
}
|
|
258
|
-
return (0, exports.prefixEncoder)(utils_1.Prefix.SR1)(val);
|
|
259
|
-
};
|
|
260
|
-
exports.smartRollupAddressEncoder = smartRollupAddressEncoder;
|
|
261
|
-
const smartContractAddressEncoder = (val) => {
|
|
262
|
-
const prefix = val.substring(0, 3);
|
|
263
|
-
if (prefix === utils_1.Prefix.KT1) {
|
|
264
|
-
return '01' + (0, exports.prefixEncoder)(utils_1.Prefix.KT1)(val) + '00';
|
|
265
|
-
}
|
|
266
|
-
throw new core_1.InvalidContractAddressError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils_1.Prefix.KT1}'.`);
|
|
267
|
-
};
|
|
268
|
-
exports.smartContractAddressEncoder = smartContractAddressEncoder;
|
|
269
|
-
const publicKeyDecoder = (val) => {
|
|
270
|
-
const preamble = val.consume(1);
|
|
271
|
-
switch (preamble[0]) {
|
|
272
|
-
case 0x00:
|
|
273
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.EDPK)(val);
|
|
274
|
-
case 0x01:
|
|
275
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.SPPK)(val);
|
|
276
|
-
case 0x02:
|
|
277
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.P2PK)(val);
|
|
278
|
-
case 0x03:
|
|
279
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.BLPK)(val);
|
|
280
|
-
default:
|
|
281
|
-
throw new utils_1.InvalidPublicKeyError(val.toString(), (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED));
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
exports.publicKeyDecoder = publicKeyDecoder;
|
|
285
|
-
const smartRollupCommitmentHashEncoder = (val) => {
|
|
286
|
-
const prefix = val.substring(0, 4);
|
|
287
|
-
if (prefix === utils_1.Prefix.SRC1) {
|
|
288
|
-
return (0, exports.prefixEncoder)(utils_1.Prefix.SRC1)(val);
|
|
289
|
-
}
|
|
290
|
-
throw new errors_1.InvalidSmartRollupCommitmentHashError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils_1.Prefix.SRC1}'`);
|
|
291
|
-
};
|
|
292
|
-
exports.smartRollupCommitmentHashEncoder = smartRollupCommitmentHashEncoder;
|
|
293
|
-
const addressDecoder = (val) => {
|
|
294
|
-
const preamble = val.consume(1);
|
|
295
|
-
switch (preamble[0]) {
|
|
296
|
-
case 0x00:
|
|
297
|
-
return (0, exports.publicKeyHashDecoder)(val);
|
|
298
|
-
case 0x01: {
|
|
299
|
-
const address = (0, exports.prefixDecoder)(utils_1.Prefix.KT1)(val);
|
|
300
|
-
val.consume(1);
|
|
301
|
-
return address;
|
|
302
|
-
}
|
|
303
|
-
default:
|
|
304
|
-
throw new core_1.InvalidAddressError(val.toString(), ': Unable to decode.');
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
exports.addressDecoder = addressDecoder;
|
|
308
|
-
const smartRollupAddressDecoder = (val) => {
|
|
309
|
-
const address = (0, exports.prefixDecoder)(utils_1.Prefix.SR1)(val);
|
|
310
|
-
if (address.substring(0, 3) !== utils_1.Prefix.SR1) {
|
|
311
|
-
throw new errors_1.InvalidSmartRollupAddressError(address, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils_1.Prefix.SR1}'.`);
|
|
312
|
-
}
|
|
313
|
-
return address;
|
|
314
|
-
};
|
|
315
|
-
exports.smartRollupAddressDecoder = smartRollupAddressDecoder;
|
|
316
|
-
const smartContractAddressDecoder = (val) => {
|
|
317
|
-
const preamble = val.consume(1);
|
|
318
|
-
if (preamble[0] === 0x01) {
|
|
319
|
-
const scAddress = (0, exports.prefixDecoder)(utils_1.Prefix.KT1)(val);
|
|
320
|
-
val.consume(1);
|
|
321
|
-
return scAddress;
|
|
322
|
-
}
|
|
323
|
-
throw new core_1.InvalidContractAddressError(val.toString(), (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED));
|
|
324
|
-
};
|
|
325
|
-
exports.smartContractAddressDecoder = smartContractAddressDecoder;
|
|
326
|
-
const smartRollupCommitmentHashDecoder = (val) => {
|
|
327
|
-
const address = (0, exports.prefixDecoder)(utils_1.Prefix.SRC1)(val);
|
|
328
|
-
if (address.substring(0, 4) !== utils_1.Prefix.SRC1) {
|
|
329
|
-
throw new errors_1.InvalidSmartRollupCommitmentHashError(address, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils_1.Prefix.SRC1}'`);
|
|
330
|
-
}
|
|
331
|
-
return address;
|
|
332
|
-
};
|
|
333
|
-
exports.smartRollupCommitmentHashDecoder = smartRollupCommitmentHashDecoder;
|
|
334
|
-
const zarithEncoder = (n) => {
|
|
335
|
-
const fn = [];
|
|
336
|
-
let nn = new bignumber_js_1.default(n, 10);
|
|
337
|
-
if (nn.isNaN()) {
|
|
338
|
-
throw new TypeError(`Invalid zarith number ${n}`);
|
|
339
|
-
}
|
|
340
|
-
// eslint-disable-next-line no-constant-condition
|
|
341
|
-
while (true) {
|
|
342
|
-
if (nn.lt(128)) {
|
|
343
|
-
if (nn.lt(16))
|
|
344
|
-
fn.push('0');
|
|
345
|
-
fn.push(nn.toString(16));
|
|
346
|
-
break;
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
let b = nn.mod(128);
|
|
350
|
-
nn = nn.minus(b);
|
|
351
|
-
nn = nn.dividedBy(128);
|
|
352
|
-
b = b.plus(128);
|
|
353
|
-
fn.push(b.toString(16));
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return fn.join('');
|
|
357
|
-
};
|
|
358
|
-
exports.zarithEncoder = zarithEncoder;
|
|
359
|
-
const zarithDecoder = (n) => {
|
|
360
|
-
let mostSignificantByte = 0;
|
|
361
|
-
while (mostSignificantByte < n.length() && (n.get(mostSignificantByte) & 128) !== 0) {
|
|
362
|
-
mostSignificantByte += 1;
|
|
363
|
-
}
|
|
364
|
-
let num = new bignumber_js_1.default(0);
|
|
365
|
-
for (let i = mostSignificantByte; i >= 0; i -= 1) {
|
|
366
|
-
const tmp = n.get(i) & 0x7f;
|
|
367
|
-
num = num.multipliedBy(128);
|
|
368
|
-
num = num.plus(tmp);
|
|
369
|
-
}
|
|
370
|
-
n.consume(mostSignificantByte + 1);
|
|
371
|
-
return new bignumber_js_1.default(num).toString();
|
|
372
|
-
};
|
|
373
|
-
exports.zarithDecoder = zarithDecoder;
|
|
374
|
-
const entrypointDecoder = (value) => {
|
|
375
|
-
const preamble = (0, utils_2.pad)(value.consume(1)[0], 2);
|
|
376
|
-
if (preamble in constants_proto022_1.entrypointMapping) {
|
|
377
|
-
return constants_proto022_1.entrypointMapping[preamble];
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
const entry = (0, codec_proto022_1.extractRequiredLen)(value, 1);
|
|
381
|
-
const entrypoint = Buffer.from(entry).toString('utf8');
|
|
382
|
-
if (entrypoint.length > constants_proto022_1.ENTRYPOINT_MAX_LENGTH) {
|
|
383
|
-
throw new errors_1.OversizedEntryPointError(entrypoint);
|
|
384
|
-
}
|
|
385
|
-
return entrypoint;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
exports.entrypointDecoder = entrypointDecoder;
|
|
389
|
-
const parametersDecoder = (val) => {
|
|
390
|
-
const preamble = val.consume(1);
|
|
391
|
-
if (preamble[0] === 0x00) {
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
const encodedEntrypoint = (0, exports.entrypointDecoder)(val);
|
|
396
|
-
const params = (0, codec_proto022_1.extractRequiredLen)(val);
|
|
397
|
-
const parameters = (0, codec_proto022_1.valueDecoder)(new uint8array_consumer_1.Uint8ArrayConsumer(params));
|
|
398
|
-
return {
|
|
399
|
-
entrypoint: encodedEntrypoint,
|
|
400
|
-
value: parameters,
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
exports.parametersDecoder = parametersDecoder;
|
|
405
|
-
const entrypointEncoder = (entrypoint) => {
|
|
406
|
-
if (entrypoint in constants_proto022_1.entrypointMappingReverse) {
|
|
407
|
-
return `${constants_proto022_1.entrypointMappingReverse[entrypoint]}`;
|
|
408
|
-
}
|
|
409
|
-
else {
|
|
410
|
-
if (entrypoint.length > constants_proto022_1.ENTRYPOINT_MAX_LENGTH) {
|
|
411
|
-
throw new errors_1.OversizedEntryPointError(entrypoint);
|
|
412
|
-
}
|
|
413
|
-
const value = { string: entrypoint };
|
|
414
|
-
return `ff${(0, codec_proto022_1.valueEncoder)(value).slice(8)}`;
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
exports.entrypointEncoder = entrypointEncoder;
|
|
418
|
-
const parametersEncoder = (val) => {
|
|
419
|
-
if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
|
|
420
|
-
return '00';
|
|
421
|
-
}
|
|
422
|
-
const encodedEntrypoint = (0, exports.entrypointEncoder)(val.entrypoint);
|
|
423
|
-
const parameters = (0, codec_proto022_1.valueEncoder)(val.value);
|
|
424
|
-
const length = (0, utils_2.pad)(parameters.length / 2);
|
|
425
|
-
return `ff${encodedEntrypoint}${length}${parameters}`;
|
|
426
|
-
};
|
|
427
|
-
exports.parametersEncoder = parametersEncoder;
|
|
428
|
-
const valueParameterEncoder = (value) => {
|
|
429
|
-
const valueEncoded = (0, codec_proto022_1.valueEncoder)(value);
|
|
430
|
-
return `${(0, utils_2.pad)(valueEncoded.length / 2)}${valueEncoded}`;
|
|
431
|
-
};
|
|
432
|
-
exports.valueParameterEncoder = valueParameterEncoder;
|
|
433
|
-
const valueParameterDecoder = (val) => {
|
|
434
|
-
const value = (0, codec_proto022_1.extractRequiredLen)(val);
|
|
435
|
-
return (0, codec_proto022_1.valueDecoder)(new uint8array_consumer_1.Uint8ArrayConsumer(value));
|
|
436
|
-
};
|
|
437
|
-
exports.valueParameterDecoder = valueParameterDecoder;
|
|
438
|
-
exports.blockPayloadHashEncoder = (0, exports.prefixEncoder)(utils_1.Prefix.VH);
|
|
439
|
-
exports.blockPayloadHashDecoder = (0, exports.prefixDecoder)(utils_1.Prefix.VH);
|
|
440
|
-
const entrypointNameEncoder = (entrypoint) => {
|
|
441
|
-
const value = { string: entrypoint };
|
|
442
|
-
return `${(0, codec_proto022_1.valueEncoder)(value).slice(2)}`;
|
|
443
|
-
};
|
|
444
|
-
exports.entrypointNameEncoder = entrypointNameEncoder;
|
|
445
|
-
const entrypointNameDecoder = (val) => {
|
|
446
|
-
const entry = (0, codec_proto022_1.extractRequiredLen)(val);
|
|
447
|
-
return Buffer.from(entry).toString('utf8');
|
|
448
|
-
};
|
|
449
|
-
exports.entrypointNameDecoder = entrypointNameDecoder;
|
|
450
|
-
const burnLimitEncoder = (val) => {
|
|
451
|
-
return !val ? '00' : `ff${(0, exports.zarithEncoder)(val)}`;
|
|
452
|
-
};
|
|
453
|
-
exports.burnLimitEncoder = burnLimitEncoder;
|
|
454
|
-
const burnLimitDecoder = (value) => {
|
|
455
|
-
const prefix = value.consume(1);
|
|
456
|
-
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
457
|
-
return (0, exports.zarithDecoder)(value);
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
exports.burnLimitDecoder = burnLimitDecoder;
|
|
461
|
-
const depositsLimitEncoder = (val) => {
|
|
462
|
-
return !val ? '00' : `ff${(0, exports.zarithEncoder)(val)}`;
|
|
463
|
-
};
|
|
464
|
-
exports.depositsLimitEncoder = depositsLimitEncoder;
|
|
465
|
-
const depositsLimitDecoder = (value) => {
|
|
466
|
-
const prefix = value.consume(1);
|
|
467
|
-
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
468
|
-
return (0, exports.zarithDecoder)(value);
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
exports.depositsLimitDecoder = depositsLimitDecoder;
|
|
472
|
-
const signatureV1Encoder = (val) => {
|
|
473
|
-
const signaturePrefix = val.substring(0, 5);
|
|
474
|
-
switch (signaturePrefix) {
|
|
475
|
-
case utils_1.Prefix.EDSIG:
|
|
476
|
-
return (0, exports.paddedBytesEncoder)((0, exports.prefixEncoder)(utils_1.Prefix.EDSIG)(val));
|
|
477
|
-
case utils_1.Prefix.SPSIG:
|
|
478
|
-
return (0, exports.paddedBytesEncoder)((0, exports.prefixEncoder)(utils_1.Prefix.SPSIG)(val));
|
|
479
|
-
case utils_1.Prefix.P2SIG:
|
|
480
|
-
return (0, exports.paddedBytesEncoder)((0, exports.prefixEncoder)(utils_1.Prefix.P2SIG)(val));
|
|
481
|
-
case utils_1.Prefix.BLSIG:
|
|
482
|
-
return (0, exports.paddedBytesEncoder)((0, exports.prefixEncoder)(utils_1.Prefix.BLSIG)(val));
|
|
483
|
-
default:
|
|
484
|
-
throw new core_1.InvalidSignatureError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) +
|
|
485
|
-
` expecting one of the following '${utils_1.Prefix.EDSIG}', '${utils_1.Prefix.SPSIG}', '${utils_1.Prefix.P2SIG}' or '${utils_1.Prefix.BLSIG}'.`);
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
const signatureV1Decoder = (val) => {
|
|
489
|
-
val.consume(4);
|
|
490
|
-
if (val.length().toString() === '96') {
|
|
491
|
-
return (0, exports.prefixDecoder)(utils_1.Prefix.BLSIG)(val);
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
throw new core_1.ProhibitedActionError('currently we only support decoding of BLSIG signatures');
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
const signatureProofEncoder = (val) => {
|
|
498
|
-
if (val) {
|
|
499
|
-
return (0, exports.boolEncoder)(true) + signatureV1Encoder(val);
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
return (0, exports.boolEncoder)(false);
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
exports.signatureProofEncoder = signatureProofEncoder;
|
|
506
|
-
const signatureProofDecoder = (value) => {
|
|
507
|
-
const hasProof = (0, exports.boolDecoder)(value);
|
|
508
|
-
if (hasProof) {
|
|
509
|
-
return signatureV1Decoder(value);
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
exports.signatureProofDecoder = signatureProofDecoder;
|
|
513
|
-
const paddedBytesEncoder = (val, paddingLength = 8) => {
|
|
514
|
-
return `${(0, utils_2.pad)(val.length / 2, paddingLength)}${val}`;
|
|
515
|
-
};
|
|
516
|
-
exports.paddedBytesEncoder = paddedBytesEncoder;
|
|
517
|
-
const paddedBytesDecoder = (val) => {
|
|
518
|
-
const value = (0, codec_proto022_1.extractRequiredLen)(val);
|
|
519
|
-
return Buffer.from(value).toString('hex');
|
|
520
|
-
};
|
|
521
|
-
exports.paddedBytesDecoder = paddedBytesDecoder;
|
|
522
|
-
const smartRollupMessageEncoder = (val) => {
|
|
523
|
-
const message = val.reduce((prev, curr) => {
|
|
524
|
-
return prev + `${(0, utils_2.pad)(curr.length / 2)}${curr}`;
|
|
525
|
-
}, '');
|
|
526
|
-
return `${(0, utils_2.pad)(message.length / 2)}${message}`;
|
|
527
|
-
};
|
|
528
|
-
exports.smartRollupMessageEncoder = smartRollupMessageEncoder;
|
|
529
|
-
const smartRollupMessageDecoder = (val) => {
|
|
530
|
-
const valueArray = (0, codec_proto022_1.extractRequiredLen)(val);
|
|
531
|
-
const ret = (0, codec_proto022_1.stripLengthPrefixFromBytes)(new uint8array_consumer_1.Uint8ArrayConsumer(valueArray));
|
|
532
|
-
return ret.map((value) => Buffer.from(value).toString('hex'));
|
|
533
|
-
};
|
|
534
|
-
exports.smartRollupMessageDecoder = smartRollupMessageDecoder;
|
|
535
|
-
const dalCommitmentEncoder = (val) => {
|
|
536
|
-
const prefix = val.substring(0, 2);
|
|
537
|
-
if (prefix === utils_1.Prefix.SH) {
|
|
538
|
-
return (0, exports.prefixEncoder)(utils_1.Prefix.SH)(val);
|
|
539
|
-
}
|
|
540
|
-
throw new errors_1.InvalidDalCommitmentError(val, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils_1.Prefix.SH}'`);
|
|
541
|
-
};
|
|
542
|
-
exports.dalCommitmentEncoder = dalCommitmentEncoder;
|
|
543
|
-
const dalCommitmentDecoder = (val) => {
|
|
544
|
-
const commitment = (0, exports.prefixDecoder)(utils_1.Prefix.SH)(val);
|
|
545
|
-
if (commitment.substring(0, 2) !== utils_1.Prefix.SH) {
|
|
546
|
-
throw new errors_1.InvalidDalCommitmentError(commitment, (0, utils_1.invalidDetail)(utils_1.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils_1.Prefix.SH}'`);
|
|
547
|
-
}
|
|
548
|
-
return commitment;
|
|
549
|
-
};
|
|
550
|
-
exports.dalCommitmentDecoder = dalCommitmentDecoder;
|
|
551
|
-
const slotHeaderEncoder = (val) => {
|
|
552
|
-
return (0, utils_2.pad)(val.slot_index, 2) + (0, exports.dalCommitmentEncoder)(val.commitment) + val.commitment_proof;
|
|
553
|
-
};
|
|
554
|
-
exports.slotHeaderEncoder = slotHeaderEncoder;
|
|
555
|
-
const slotHeaderDecoder = (val) => {
|
|
556
|
-
const preamble = val.consume(1);
|
|
557
|
-
return {
|
|
558
|
-
slot_index: Number(preamble[0].toString(10)),
|
|
559
|
-
commitment: (0, exports.dalCommitmentDecoder)(val),
|
|
560
|
-
commitment_proof: (0, utils_2.toHexString)(val.consume(96)), // rpcForger expect commitment_proof bytes to be len 96
|
|
561
|
-
};
|
|
562
|
-
};
|
|
563
|
-
exports.slotHeaderDecoder = slotHeaderDecoder;
|