Skip to content

Commit

Permalink
remove hardcoded gas
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Nov 9, 2024
1 parent e8cf1c3 commit c1d240e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/cli/src/deploy/getDeployClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { transactionQueue } from "@latticexyz/common/actions";
import { rhodolite } from "@latticexyz/common/chains";
import { claimGasPass, getAllowance, hasPassIssuer, gasEstimator } from "@latticexyz/paymaster/internal";
import { claimGasPass, getAllowance, hasPassIssuer } from "@latticexyz/paymaster/internal";
import { wiresaw } from "@latticexyz/wiresaw/internal";
import { smartAccountActions } from "permissionless";
import { toSimpleSmartAccount } from "permissionless/accounts";
Expand Down Expand Up @@ -61,8 +61,7 @@ export async function getDeployClient(opts: {
const account = await toSimpleSmartAccount({ client, owner: opts.account });
const bundlerClient = createBundlerClient({
chain,
// TODO: figure out how to remove gas estimator (currently times out if not present)
transport: gasEstimator(wiresaw(http(bundlerHttpUrl))),
transport: wiresaw(http(bundlerHttpUrl)),
account,
paymaster: {
getPaymasterData: async () => ({
Expand Down
4 changes: 2 additions & 2 deletions packages/entrykit/src/getBundlerTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { transactionQueue } from "@latticexyz/common/actions";
import { Chain, createClient, fallback, http, webSocket } from "viem";
import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
import { wiresaw } from "@latticexyz/wiresaw/internal";
import { gasEstimator, userOpExecutor } from "@latticexyz/paymaster/internal";
import { userOpExecutor } from "@latticexyz/paymaster/internal";

export function getBundlerTransport(chain: Chain) {
const bundlerHttpUrl = chain.rpcUrls.bundler?.http[0];
// TODO: bundler websocket
const bundlerTransport = bundlerHttpUrl
? gasEstimator(wiresaw(http(bundlerHttpUrl)))
? wiresaw(http(bundlerHttpUrl))
: chain.id === 31337
? userOpExecutor({
executor: createClient({
Expand Down
9 changes: 9 additions & 0 deletions packages/entrykit/src/onboarding/useSetupSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ export function useSetupSession({ userClient }: { userClient: ConnectedClient })

if (!calls.length) return;

// if (!(await userClient.account.isDeployed())) {
// // send empty tx to create the smart account, otherwise the first tx may fail due to bad gas estimation
// console.log("creating smart account at", userClient.account.address);
// const hash = await getAction(userClient, sendUserOperation, "sendUserOperation")({ calls: [] });
// console.log("tx:", hash);
// const receipt = await getAction(userClient, waitForTransactionReceipt, "waitForTransactionReceipt")({ hash });
// console.log("receipt:", receipt.status);
// }

console.log("setting up account with", calls, userClient);
const hash = await getAction(userClient, sendUserOperation, "sendUserOperation")({ calls });
console.log("got user op hash", hash);
Expand Down

0 comments on commit c1d240e

Please sign in to comment.