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

chore: get rid of .log, rename .logStatus to .dbgStatus #628

Merged
merged 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions examples/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const batch = Utility.batch({
})
.signed({ sender: alice })
.sent()
.logStatus("Batch tx:")
.dbgStatus("Batch tx:")
.finalized()

await logBalances()
Expand All @@ -24,6 +24,6 @@ await logBalances()
function logBalances() {
return Rune.tuple(recipients.map(([name, { publicKey }]) => {
const free = System.Account.entry([publicKey]).access("data", "free")
return free.log(Rune.str`${name} balance:`)
return free.dbg(Rune.str`${name} balance:`)
}))
}
2 changes: 1 addition & 1 deletion examples/identity_cr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ await Identity
.setIdentity({ info })
.signed({ sender: alice })
.sent()
.logStatus()
.dbgStatus()
.finalized()
.run()

Expand Down
7 changes: 4 additions & 3 deletions examples/indices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ const claim = Indices
.claim({ index })
.signed({ sender: alice })
.sent()
.logStatus()
.dbgStatus()
.finalized()

await claim
const result = await claim
.into(ValueRune)
.chain(() => Indices.Accounts.entry([index]).access(0))
.log(`Index ${index} mapped to`)
.run()

console.log(`Index ${index} mapped to ${result}}`)
4 changes: 2 additions & 2 deletions examples/ink_e2e/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (!address) {
})
.signed({ sender: alice })
.sent()
.logStatus("Contract deployment status:")
.dbgStatus("Contract deployment status:")
.txEvents()
.map((events) =>
events.find(isInstantiatedEvent) ?? new FailedToFindContractInstantiatedError()
Expand All @@ -51,7 +51,7 @@ console.log(
.tx({ sender, method: "flip" })
.signed({ sender: alice })
.sent()
.logStatus("Flip status:")
.dbgStatus("Flip status:")
.txEvents()
.pipe(contract.filterContractEvents)
.run(),
Expand Down
2 changes: 1 addition & 1 deletion examples/polkadot_js_signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ console.log(
},
})
.sent()
.logStatus()
.dbgStatus()
.txEvents()
.run(),
)
2 changes: 1 addition & 1 deletion examples/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const result = await Balances
})
.signed({ sender: alice })
.sent()
.logStatus()
.dbgStatus()
.txEvents()
.run()

Expand Down
4 changes: 2 additions & 2 deletions examples/transfer_sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function balances() {
bob: balance(bob),
charlie: balance(charlie),
})
.log("Balances:")
.dbg("Balances:")
}

function balance(user: Sr25519) {
Expand All @@ -31,6 +31,6 @@ function transfer(name: string, user: Sr25519) {
})
.signed({ sender: alice })
.sent()
.logStatus(`Transfer to ${name}:`)
.dbgStatus(`Transfer to ${name}:`)
.finalized()
}
8 changes: 4 additions & 4 deletions examples/xcm_asset_teleportation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const initiatedEvent = XcmPallet
})
.signed({ sender: alice })
.sent()
.logStatus("Teleportation status:")
.dbgStatus("Teleportation status:")
.txEvents()
.map((events) =>
events.find((e) =>
Expand All @@ -56,7 +56,7 @@ const initiatedEvent = XcmPallet
) ?? new CannotFindAttemptError()
)
.unhandle(CannotFindAttemptError)
.log("Initiated event:")
.dbg("Initiated event:")

const processedEvent = System.Events
.entry([], chain.latestBlock.hash)
Expand All @@ -67,7 +67,7 @@ const processedEvent = System.Events
)
)
.filter((event) => !!event)
.log("Processed events:")
.dbg("Processed events:")

// TODO: have the recipient associate the downward message with the sender
await logAliceBalance()
Expand All @@ -76,5 +76,5 @@ await logAliceBalance()
.run()

function logAliceBalance() {
return System.Account.entry([alice.publicKey]).access("data", "free").log("Alice balance:")
return System.Account.entry([alice.publicKey]).access("data", "free").dbg("Alice balance:")
}
4 changes: 2 additions & 2 deletions fluent/ExtrinsicStatusRune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export class ExtrinsicStatusRune<out U1, out U2, out C extends Chain = Chain>
super(_prime)
}

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

Expand Down
9 changes: 0 additions & 9 deletions rune/ValueRune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@ export class ValueRune<out T, out U = never> extends Rune<T, U> {
})
}

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> {
return ValueRune.new(RunChain, this, fn(this as never))
}
Expand Down