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 1 commit
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
15 changes: 9 additions & 6 deletions fluent/ExtrinsicStatusRune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ export class ExtrinsicStatusRune<out U1, out U2, out C extends Chain = Chain>
}

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)
return Rune
.tuple([this.into(ValueRune), ...prefix])
.map(([rune, ...prefix]) =>
rune.into(ValueRune).map((value) => {
console.log(...prefix, value)
return value
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use .log()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

@harrysolovay harrysolovay Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, does the placement of the prefix rune list matter (inside the inner Runes vs. wrapping this and Rune.tuple(prefixes) in another Rune.tuple, and then mapping their results into the inner runes)?

Copy link
Contributor

@tjjfvi tjjfvi Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, the solution is to have a .trackMap or .metaMap or whatever on MetaRune and use that, but that can wait for later.

)
.into(ExtrinsicStatusRune, this.extrinsic)
}

terminalTransactionStatuses() {
Expand Down
13 changes: 10 additions & 3 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,8 +115,15 @@ export class ValueRune<out T, out U = never> extends Rune<T, U> {
return ValueRune.new(RunSingular, this)
}

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

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