Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
fix: watch blocks (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi authored Sep 27, 2022
1 parent 406ca84 commit acbb3ec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions _tasks/dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ await Promise.all([
}],
outDir,
mappings: {
"https://deno.land/x/[email protected].0/mod.ts": {
"https://deno.land/x/[email protected].3/mod.ts": {
name: "parity-scale-codec",
version: "^0.5.0",
version: "^0.5.3",
},
"deps/smoldot_phantom.ts": {
name: "@substrate/smoldot-light",
Expand Down
2 changes: 1 addition & 1 deletion deps/scale.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/x/[email protected].0/mod.ts";
export * from "https://deno.land/x/[email protected].3/mod.ts";
2 changes: 1 addition & 1 deletion effect/std/watchBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function watchBlocks(
const block = await readBlock(config, blockHash as unknown as U.HashHexString).run(); // STOP THIS MADNESS
if (block instanceof Error) {
// TODO: subscription runtime error channel
throw new Error();
throw block;
}
watchHandler(block.block);
};
Expand Down
14 changes: 14 additions & 0 deletions examples/watch_blocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as C from "../mod.ts";

console.log(
await C.watchBlocks(C.westend, (stop) => {
let i = 0;
return ({ block }) => {
console.log(block.header);
if (i === 2) {
stop();
}
i++;
};
}).run(),
);
6 changes: 3 additions & 3 deletions frame_metadata/Codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function DeriveCodec(tys: M.Ty[]): DeriveCodec {
return $.tuple(...members.map((x) => this.visit(x)));
},
objectStruct(ty) {
return $.object(...ty.fields.map((x): $.Field => [x.name!, this.visit(x.ty)]));
return $.object(...ty.fields.map((x): $.AnyField => [x.name!, this.visit(x.ty)]));
},
option(_ty, some) {
return $.option(this.visit(some));
Expand All @@ -43,9 +43,9 @@ export function DeriveCodec(tys: M.Ty[]): DeriveCodec {
return $.stringUnion(members);
},
taggedUnion(ty) {
const members: Record<number, $.TaggedUnionMember> = {};
const members: Record<number, $.AnyTaggedUnionMember> = {};
for (const { fields, name: type, index } of ty.members) {
let member: $.TaggedUnionMember;
let member: $.AnyTaggedUnionMember;
if (fields.length === 0) {
member = [type];
} else if (fields[0]!.name === undefined) {
Expand Down

0 comments on commit acbb3ec

Please sign in to comment.