Skip to content

Commit

Permalink
Migrate SafePack to Viem (#53)
Browse files Browse the repository at this point in the history
We no longer require ethers in the lib/utils directory. This is a move toward a bit more type safety, consistency and detanglement from the network client and the contract instances.

Last step to remove ethers entirely will be to replace the ethers.JsonRpcProvider with PublicClient in lib/bundler. Then we can move ethers to a dev dependency and use it for unit testing our encodings.
  • Loading branch information
bh2smith committed Sep 17, 2024
1 parent e39d0c3 commit 5c2f528
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 150 deletions.
7 changes: 6 additions & 1 deletion examples/send-tx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dotenv from "dotenv";
import { ethers } from "ethers";
import { isAddress } from "viem";

import { loadArgs, loadEnv } from "./cli";
import { TransactionManager } from "../src";
Expand Down Expand Up @@ -29,7 +30,11 @@ async function main(): Promise<void> {
},
];
// Add Recovery if safe not deployed & recoveryAddress was provided.
if (!(await txManager.safeDeployed(chainId)) && recoveryAddress) {
if (
!(await txManager.safeDeployed(chainId)) &&
recoveryAddress &&
isAddress(recoveryAddress)
) {
const recoveryTx = txManager.addOwnerTx(recoveryAddress);
// This would happen (sequentially) after the userTx, but all executed in a single
transactions.push(recoveryTx);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export class Erc4337Bundler {
this.entryPointAddress = entryPointAddress;
this.apiKey = apiKey;
this.chainId = chainId;
this.provider = new ethers.JsonRpcProvider(bundlerUrl(chainId, this.apiKey));
this.provider = new ethers.JsonRpcProvider(
bundlerUrl(chainId, this.apiKey)
);
}

async getPaymasterData(
Expand Down
Loading

0 comments on commit 5c2f528

Please sign in to comment.