@typeberry/convert 0.5.7 → 0.5.8-0dea783
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/index.js +76 -64
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4615,7 +4615,7 @@ function seeThrough(v) {
|
|
|
4615
4615
|
}
|
|
4616
4616
|
|
|
4617
4617
|
;// CONCATENATED MODULE: ./packages/core/utils/package.json
|
|
4618
|
-
const package_namespaceObject = {"rE":"0.5.
|
|
4618
|
+
const package_namespaceObject = {"rE":"0.5.8"};
|
|
4619
4619
|
;// CONCATENATED MODULE: ./packages/core/utils/result.ts
|
|
4620
4620
|
|
|
4621
4621
|
/**
|
|
@@ -10187,16 +10187,24 @@ const guaranteesExtrinsicCodec = codecWithContext((context) => codecKnownSizeArr
|
|
|
10187
10187
|
|
|
10188
10188
|
|
|
10189
10189
|
|
|
10190
|
-
function tryAsTicketAttempt(x) {
|
|
10190
|
+
function tryAsTicketAttempt(x, chainSpec) {
|
|
10191
|
+
if (x >= chainSpec.ticketsPerValidator) {
|
|
10192
|
+
throw new Error(`Ticket attempt ${x} is out of bounds [0, ${chainSpec.ticketsPerValidator})`);
|
|
10193
|
+
}
|
|
10191
10194
|
return opaque_asOpaqueType(tryAsU8(x));
|
|
10192
10195
|
}
|
|
10196
|
+
const ticketAttemptCodec = codecWithContext((context) => {
|
|
10197
|
+
return codec_codec.varU32.convert((x) => {
|
|
10198
|
+
tryAsTicketAttempt(x, context);
|
|
10199
|
+
return numbers_tryAsU32(x);
|
|
10200
|
+
}, (x) => tryAsTicketAttempt(x, context));
|
|
10201
|
+
});
|
|
10193
10202
|
/* Bandersnatch-signed ticket contest entry. */
|
|
10194
10203
|
class SignedTicket extends WithDebug {
|
|
10195
10204
|
attempt;
|
|
10196
10205
|
signature;
|
|
10197
10206
|
static Codec = codec_codec.Class(SignedTicket, {
|
|
10198
|
-
|
|
10199
|
-
attempt: codec_codec.u8.asOpaque(),
|
|
10207
|
+
attempt: ticketAttemptCodec,
|
|
10200
10208
|
signature: codec_codec.bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
10201
10209
|
});
|
|
10202
10210
|
static create({ attempt, signature }) {
|
|
@@ -10218,8 +10226,7 @@ class Ticket extends WithDebug {
|
|
|
10218
10226
|
attempt;
|
|
10219
10227
|
static Codec = codec_codec.Class(Ticket, {
|
|
10220
10228
|
id: codec_codec.bytes(hash_HASH_SIZE),
|
|
10221
|
-
|
|
10222
|
-
attempt: codec_codec.u8.asOpaque(),
|
|
10229
|
+
attempt: ticketAttemptCodec,
|
|
10223
10230
|
});
|
|
10224
10231
|
static create({ id, attempt }) {
|
|
10225
10232
|
return new Ticket(id, attempt);
|
|
@@ -10857,11 +10864,8 @@ var fromJson;
|
|
|
10857
10864
|
fromJson.bytesBlob = json.fromString(bytes_BytesBlob.parseBlob);
|
|
10858
10865
|
fromJson.bytesBlobNoPrefix = json.fromString(bytes_BytesBlob.parseBlobNoPrefix);
|
|
10859
10866
|
fromJson.ed25519Signature = json.fromString((v) => bytes_Bytes.parseBytes(v, 64).asOpaque());
|
|
10860
|
-
fromJson.ticketAttempt = json.fromNumber((v) => {
|
|
10861
|
-
|
|
10862
|
-
throw new Error("Invalid TicketAttempt value.");
|
|
10863
|
-
}
|
|
10864
|
-
return tryAsTicketAttempt(v);
|
|
10867
|
+
fromJson.ticketAttempt = (spec) => json.fromNumber((v) => {
|
|
10868
|
+
return tryAsTicketAttempt(v, spec);
|
|
10865
10869
|
});
|
|
10866
10870
|
fromJson.uint8Array = json.fromAny((v) => {
|
|
10867
10871
|
if (Array.isArray(v)) {
|
|
@@ -11101,11 +11105,13 @@ const preimagesExtrinsicFromJson = json.array(preimageFromJson);
|
|
|
11101
11105
|
|
|
11102
11106
|
|
|
11103
11107
|
|
|
11104
|
-
const
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11108
|
+
const ticketsExtrinsicFromJson = (spec) => {
|
|
11109
|
+
const ticketEnvelopeFromJson = json.object({
|
|
11110
|
+
attempt: fromJson.ticketAttempt(spec),
|
|
11111
|
+
signature: json.fromString((v) => bytes_Bytes.parseBytes(v, BANDERSNATCH_PROOF_BYTES).asOpaque()),
|
|
11112
|
+
}, (x) => SignedTicket.create({ attempt: x.attempt, signature: x.signature }));
|
|
11113
|
+
return json.array(ticketEnvelopeFromJson);
|
|
11114
|
+
};
|
|
11109
11115
|
|
|
11110
11116
|
;// CONCATENATED MODULE: ./packages/jam/block-json/extrinsic.ts
|
|
11111
11117
|
|
|
@@ -11116,7 +11122,7 @@ const ticketsExtrinsicFromJson = json.array(ticketEnvelopeFromJson);
|
|
|
11116
11122
|
|
|
11117
11123
|
|
|
11118
11124
|
const getExtrinsicFromJson = (ctx) => json.object({
|
|
11119
|
-
tickets: ticketsExtrinsicFromJson,
|
|
11125
|
+
tickets: ticketsExtrinsicFromJson(ctx),
|
|
11120
11126
|
preimages: preimagesExtrinsicFromJson,
|
|
11121
11127
|
guarantees: guaranteesExtrinsicFromJson,
|
|
11122
11128
|
assurances: getAssurancesExtrinsicFromJson(ctx),
|
|
@@ -11140,39 +11146,41 @@ const epochMark = json.object({
|
|
|
11140
11146
|
tickets_entropy: fromJson.bytes32(),
|
|
11141
11147
|
validators: json.array(validatorKeysFromJson),
|
|
11142
11148
|
}, (x) => EpochMarker.create({ entropy: x.entropy, ticketsEntropy: x.tickets_entropy, validators: x.validators }));
|
|
11143
|
-
const
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11149
|
+
const headerFromJson = (spec) => {
|
|
11150
|
+
const ticket = json.object({
|
|
11151
|
+
id: fromJson.bytes32(),
|
|
11152
|
+
attempt: fromJson.ticketAttempt(spec),
|
|
11153
|
+
}, (x) => Ticket.create({ id: x.id, attempt: x.attempt }));
|
|
11154
|
+
return json.object({
|
|
11155
|
+
parent: fromJson.bytes32(),
|
|
11156
|
+
parent_state_root: fromJson.bytes32(),
|
|
11157
|
+
extrinsic_hash: fromJson.bytes32(),
|
|
11158
|
+
slot: "number",
|
|
11159
|
+
epoch_mark: json.optional(epochMark),
|
|
11160
|
+
tickets_mark: json.optional(json.array(ticket)),
|
|
11161
|
+
offenders_mark: json.array(fromJson.bytes32()),
|
|
11162
|
+
author_index: "number",
|
|
11163
|
+
entropy_source: bandersnatchVrfSignature,
|
|
11164
|
+
seal: bandersnatchVrfSignature,
|
|
11165
|
+
}, ({ parent, parent_state_root, extrinsic_hash, slot, epoch_mark, tickets_mark, offenders_mark, author_index, entropy_source, seal, }) => {
|
|
11166
|
+
const epochMarker = epoch_mark ?? null;
|
|
11167
|
+
const ticketsMarker = tickets_mark === undefined || tickets_mark === null
|
|
11168
|
+
? null
|
|
11169
|
+
: TicketsMarker.create({ tickets: opaque_asOpaqueType(tickets_mark) });
|
|
11170
|
+
return header_Header.create({
|
|
11171
|
+
parentHeaderHash: parent,
|
|
11172
|
+
priorStateRoot: parent_state_root,
|
|
11173
|
+
extrinsicHash: extrinsic_hash,
|
|
11174
|
+
timeSlotIndex: slot,
|
|
11175
|
+
epochMarker,
|
|
11176
|
+
ticketsMarker,
|
|
11177
|
+
offendersMarker: offenders_mark,
|
|
11178
|
+
bandersnatchBlockAuthorIndex: author_index,
|
|
11179
|
+
entropySource: entropy_source,
|
|
11180
|
+
seal,
|
|
11181
|
+
});
|
|
11174
11182
|
});
|
|
11175
|
-
}
|
|
11183
|
+
};
|
|
11176
11184
|
|
|
11177
11185
|
;// CONCATENATED MODULE: ./packages/jam/block-json/block.ts
|
|
11178
11186
|
|
|
@@ -11180,7 +11188,7 @@ const headerFromJson = json.object({
|
|
|
11180
11188
|
|
|
11181
11189
|
|
|
11182
11190
|
const blockFromJson = (spec) => json.object({
|
|
11183
|
-
header: headerFromJson,
|
|
11191
|
+
header: headerFromJson(spec),
|
|
11184
11192
|
extrinsic: getExtrinsicFromJson(spec),
|
|
11185
11193
|
}, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
|
|
11186
11194
|
const blockViewFromJson = (spec) => {
|
|
@@ -14032,15 +14040,17 @@ const recentBlocksHistoryFromJson = json.object({
|
|
|
14032
14040
|
|
|
14033
14041
|
|
|
14034
14042
|
|
|
14035
|
-
const ticketFromJson = json.object({
|
|
14043
|
+
const ticketFromJson = (spec) => json.object({
|
|
14036
14044
|
id: fromJson.bytes32(),
|
|
14037
|
-
attempt: fromJson.ticketAttempt,
|
|
14045
|
+
attempt: fromJson.ticketAttempt(spec),
|
|
14038
14046
|
}, Ticket.create);
|
|
14039
14047
|
class TicketsOrKeys {
|
|
14040
|
-
static fromJson
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14048
|
+
static fromJson(spec) {
|
|
14049
|
+
return {
|
|
14050
|
+
keys: json.optional(json.array(fromJson.bytes32())),
|
|
14051
|
+
tickets: json.optional(json.array(ticketFromJson(spec))),
|
|
14052
|
+
};
|
|
14053
|
+
}
|
|
14044
14054
|
keys;
|
|
14045
14055
|
tickets;
|
|
14046
14056
|
static toSafroleSealingKeys(data, chainSpec) {
|
|
@@ -14214,8 +14224,8 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
14214
14224
|
beta: json.nullable(recentBlocksHistoryFromJson),
|
|
14215
14225
|
gamma: {
|
|
14216
14226
|
gamma_k: json.array(validatorDataFromJson),
|
|
14217
|
-
gamma_a: json.array(ticketFromJson),
|
|
14218
|
-
gamma_s: TicketsOrKeys.fromJson,
|
|
14227
|
+
gamma_a: json.array(ticketFromJson(spec)),
|
|
14228
|
+
gamma_s: TicketsOrKeys.fromJson(spec),
|
|
14219
14229
|
gamma_z: json.fromString((v) => bytes_Bytes.parseBytes(v, BANDERSNATCH_RING_ROOT_BYTES).asOpaque()),
|
|
14220
14230
|
},
|
|
14221
14231
|
psi: disputesRecordsFromJson,
|
|
@@ -16068,10 +16078,12 @@ class TestState {
|
|
|
16068
16078
|
keyvals;
|
|
16069
16079
|
}
|
|
16070
16080
|
class StateTransitionGenesis {
|
|
16071
|
-
static fromJson = {
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16081
|
+
static fromJson(spec = chain_spec_tinyChainSpec) {
|
|
16082
|
+
return {
|
|
16083
|
+
header: headerFromJson(spec),
|
|
16084
|
+
state: TestState.fromJson,
|
|
16085
|
+
};
|
|
16086
|
+
}
|
|
16075
16087
|
static Codec = codec_codec.object({
|
|
16076
16088
|
header: header_Header.Codec,
|
|
16077
16089
|
state: TestState.Codec,
|
|
@@ -20131,7 +20143,7 @@ const SUPPORTED_TYPES = [
|
|
|
20131
20143
|
name: "header",
|
|
20132
20144
|
encode: header_Header.Codec,
|
|
20133
20145
|
decode: header_Header.Codec,
|
|
20134
|
-
json: (
|
|
20146
|
+
json: (spec) => headerFromJson(spec),
|
|
20135
20147
|
process: {
|
|
20136
20148
|
options: ["as-hash"],
|
|
20137
20149
|
run(spec, data, option, blake2b) {
|
|
@@ -20204,7 +20216,7 @@ const SUPPORTED_TYPES = [
|
|
|
20204
20216
|
name: "stf-genesis",
|
|
20205
20217
|
encode: StateTransitionGenesis.Codec,
|
|
20206
20218
|
decode: StateTransitionGenesis.Codec,
|
|
20207
|
-
json: () => StateTransitionGenesis.fromJson,
|
|
20219
|
+
json: (spec) => StateTransitionGenesis.fromJson(spec),
|
|
20208
20220
|
process: {
|
|
20209
20221
|
options: ["as-state", "as-jip4", "as-fuzz-message"],
|
|
20210
20222
|
run(spec, data, option, blake2b) {
|