Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Paymaster Gas Estimates #60

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/popup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@
"luxon": "^3.5.0",
"next": "^14.2.5",
"next-themes": "^0.3.0",
"permissionless": "0.2.21",
"postgres": "^3.4.4",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.53.0",
"siwe": "^2.3.2",
"universal-data": "workspace:*",
"universal-credential-sdk": "workspace:*",
"universal-data": "workspace:*",
"universal-delegations-sdk": "workspace:*",
"universal-identity-sdk": "workspace:*",
"universal-sdk": "workspace:*",
"universal-wallet-connector": "workspace:*",
"universal-wallet-sdk": "workspace:*",
"universal-sdk": "workspace:*",
"universal-wallet-ui": "workspace:*",
"usehooks-ts": "^3.1.0",
"viem": "^2.21.6",
Expand Down
20 changes: 19 additions & 1 deletion apps/popup/src/lib/client/bundler-client.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
import { env } from '@/env';
import { createPimlicoClient } from 'permissionless/clients/pimlico';
import type { ValidChain } from 'universal-data';
import { http } from 'viem';
import {
createBundlerClient,
createPaymasterClient,
entryPoint07Address,
} from 'viem/account-abstraction';
import { base, baseSepolia } from 'viem/chains';
import { basePublicClient, baseSepoliaPublicClient } from './public-client';
import type { ValidChain } from 'universal-data';

function getBundlerUrl(chain: ValidChain) {
return `/api/bundler/${chain.id}`;
}

const pimlicoBaseUrl = `https://api.pimlico.io/v2/8453/rpc?apikey=${env.NEXT_PUBLIC_PIMLICO_API_KEY}`;

const pimlicoBaseClient = createPimlicoClient({
transport: http(pimlicoBaseUrl),
entryPoint: {
address: entryPoint07Address,
version: '0.7',
},
});

export const baseBundlerClient = createBundlerClient({
client: basePublicClient,
chain: base,
transport: http(getBundlerUrl(base)),
paymaster: createPaymasterClient({
transport: http(getBundlerUrl(base)),
}),
userOperation: {
estimateFeesPerGas: async () => {
return (await pimlicoBaseClient.getUserOperationGasPrice()).standard;
},
},
});

export const baseSepoliaBundlerClient = createBundlerClient({
Expand Down
Loading
Loading