-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
sdk/src/utils/errorHandler.ts → sdk/src/utils/simulationErrorHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { BaseError, ContractFunctionRevertedError } from "viem"; | ||
|
||
export function handleError(err: unknown): never { | ||
export function handleSimulationError(err: unknown): never { | ||
if (err instanceof BaseError) { | ||
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError); | ||
if (revertError instanceof ContractFunctionRevertedError) { | ||
const errorName = revertError.data?.errorName ?? ""; | ||
console.error(`Failing with ${errorName}`); | ||
} | ||
} else { | ||
console.error(err); | ||
} | ||
console.error(err); | ||
|
||
throw new Error("Simulation failed"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Hash, WalletClient } from "viem"; | ||
|
||
// TODO: Use correct type for request | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export async function executeTransaction(walletClient: WalletClient, request: any): Promise<Hash> { | ||
const hash: Hash = await walletClient.writeContract(request); | ||
console.log(`Transaction sent with hash ${hash}`); | ||
return hash; | ||
} |