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

chore: log util cleanup #586

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions fluent/ExtrinsicStatusRune.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { known } from "../rpc/mod.ts"
import { MetaRune, Rune, ValueRune } from "../rune/mod.ts"
import { MetaRune, Rune, RunicArgs, ValueRune } from "../rune/mod.ts"
import { BlockRune } from "./BlockRune.ts"
import { Chain } from "./ClientRune.ts"
import { SignedExtrinsicRune } from "./SignedExtrinsicRune.ts"
Expand All @@ -14,13 +14,11 @@ export class ExtrinsicStatusRune<out U1, out U2, out C extends Chain = Chain>
super(_prime)
}

logStatus(...prefix: unknown[]): ExtrinsicStatusRune<U1, U2, C> {
return this.into(ValueRune).map((rune) =>
rune.into(ValueRune).map((value) => {
console.log(...prefix, value)
return value
})
).into(ExtrinsicStatusRune, this.extrinsic)
logStatus<X>(...prefix: RunicArgs<X, unknown[]>): ExtrinsicStatusRune<U1, U2, C> {
return this
.into(ValueRune)
.map((rune) => rune.into(ValueRune).log(...prefix))
.into(ExtrinsicStatusRune, this.extrinsic)
}

terminalTransactionStatuses() {
Expand Down
23 changes: 17 additions & 6 deletions rune/ValueRune.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PromiseOr } from "../util/types.ts"
import { Batch, Run, Rune, Unhandled } from "./Rune.ts"
import { Batch, Run, Rune, RunicArgs, Unhandled } from "./Rune.ts"
import { Receipt } from "./Timeline.ts"

type NonIndexSignatureKeys<T> = T extends T ? keyof {
Expand Down Expand Up @@ -115,11 +115,22 @@ export class ValueRune<out T, out U = never> extends Rune<T, U> {
return ValueRune.new(RunSingular, this)
}

dbg(...prefix: unknown[]) {
return this.map((value) => {
console.log(...prefix, value)
return value
})
dbg<X>(...prefix: RunicArgs<X, unknown[]>) {
return Rune
.tuple([this, Rune.tuple(prefix).lazy()])
.map(([value, prefix]) => {
console.log(...prefix, value)
return value
})
}

log<X>(...prefix: RunicArgs<X, unknown[]>) {
return Rune
.tuple([this, Rune.tuple(prefix).lazy()])
.map(([value, prefix]) => {
console.log(...prefix, value)
return value
})
}

chain<T2, U2>(fn: (result: ValueRune<T, never>) => Rune<T2, U2>): ValueRune<T2, U | U2> {
Expand Down