diff --git a/examples/smart_contract.ts b/examples/smart_contract.ts index b5cf39f56..5c3d64ef9 100644 --- a/examples/smart_contract.ts +++ b/examples/smart_contract.ts @@ -39,16 +39,14 @@ const tx = C.contracts.instantiate(client)({ salt, sender: T.alice.address, }).signed(T.alice.sign) -const finalizedIn = tx.watch(({ end }) => - (status) => { - if (typeof status !== "string" && (status.inBlock ?? status.finalized)) { - return end(status.inBlock ?? status.finalized) - } else if (C.rpc.known.TransactionStatus.isTerminal(status)) { - return end(new Error()) - } - return +const finalizedIn = tx.watch(({ end }) => (status) => { + if (typeof status !== "string" && (status.inBlock ?? status.finalized)) { + return end(status.inBlock ?? status.finalized) + } else if (C.rpc.known.TransactionStatus.isTerminal(status)) { + return end(new Error()) } -) + return +}) const contractAddress = U.throwIfError( await C .events(tx, finalizedIn) diff --git a/fluent/Contract.ts b/fluent/Contract.ts index 5e4d681cd..a581a32cd 100644 --- a/fluent/Contract.ts +++ b/fluent/Contract.ts @@ -53,16 +53,14 @@ export class Contract> { ...this.#basePayload(props.sender, props.messageLabel, props.args), value: props.value, }).signed(props.sign) - const finalizedIn = tx.watch(({ end }) => - (status) => { - if (typeof status !== "string" && (status.inBlock ?? status.finalized)) { - return end(status.inBlock ?? status.finalized) - } else if (rpc.known.TransactionStatus.isTerminal(status)) { - return end(new Error()) - } - return + const finalizedIn = tx.watch(({ end }) => (status) => { + if (typeof status !== "string" && (status.inBlock ?? status.finalized)) { + return end(status.inBlock ?? status.finalized) + } else if (rpc.known.TransactionStatus.isTerminal(status)) { + return end(new Error()) } - ) + return + }) const events_ = events(tx, finalizedIn) const contractEvents = contracts.events(this.contractMetadata, events_) return Z.ls(finalizedIn, events_, contractEvents)