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

Commit

Permalink
Merge pull request #178 from statechannels/log-userOp
Browse files Browse the repository at this point in the history
add intermediary logging of L1tx
  • Loading branch information
NiloCK authored Oct 20, 2023
2 parents 75052ce + 33133b7 commit 01224e4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion clients/IntermediaryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export class IntermediaryClient extends StateChannelWallet {
}

private async handleUserOp(userOp: UserOperationStruct): Promise<void> {
this.coordinator.uiLog(`received user op in ` + this.scBridgeWalletAddress);
// Only sign if the amount transferred is under owner's balance
const decodedData = IAccount.decodeFunctionData("execute", userOp.callData);
const value = decodedData[1] as bigint;
Expand All @@ -253,6 +254,7 @@ export class IntermediaryClient extends StateChannelWallet {

if (value > balanceWEI) {
// todo: account for expected gas consumption? ( out of scope for hackathon )
this.coordinator.uiLog("insufficient balance to execute user op");
throw new Error("Transfer amount exceeds owner balance");
}
const ownerSig = userOp.signature;
Expand All @@ -274,7 +276,10 @@ export class IntermediaryClient extends StateChannelWallet {
this.signer.address,
);
// Waiting for the transaction to be mined let's us catch the error
await result.wait();
const tx = await result.wait();
if (tx !== null) {
this.coordinator.uiLog("user op mined: " + tx.hash);
}
this.ack(userOp.signature);
}
}

0 comments on commit 01224e4

Please sign in to comment.