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

feat: block hash methods #716

Merged
merged 1 commit into from
Mar 7, 2023
Merged
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
20 changes: 12 additions & 8 deletions fluent/ExtrinsicStatusRune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class ExtrinsicStatusRune<out U1, out U2, out C extends Chain = Chain>
.flatMap((events) => events.into(ValueRune).filter(isTerminal))
}

inBlock() {
const hash = this.transactionStatuses((status) =>
inBlockHash() {
return this.transactionStatuses((status) =>
known.TransactionStatus.isTerminal(status)
|| (typeof status !== "string" ? !!status.inBlock : false)
)
Expand All @@ -38,21 +38,25 @@ export class ExtrinsicStatusRune<out U1, out U2, out C extends Chain = Chain>
)
.singular()
.unhandle(NeverInBlockError)
return this.extrinsic.chain
.block(hash)
.into(BlockRune, this.extrinsic.chain, hash)
}

finalized() {
const hash = this.transactionStatuses(known.TransactionStatus.isTerminal)
inBlock() {
return this.extrinsic.chain.block(this.inBlockHash())
}

finalizedHash() {
return this.transactionStatuses(known.TransactionStatus.isTerminal)
.map((status) =>
typeof status !== "string" && status.finalized
? status.finalized
: new NeverFinalizedError()
)
.singular()
.unhandle(NeverFinalizedError)
return this.extrinsic.chain.block(hash)
}

finalized() {
return this.extrinsic.chain.block(this.finalizedHash())
}

inBlockEvents() {
Expand Down