From ae0cfcbeab1d5bf39316e0dcd9b84d039df0a922 Mon Sep 17 00:00:00 2001 From: Austrian <114922365+0xAustrian@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:51:50 -0300 Subject: [PATCH] feat: add entry point as optional parameter (#9) --- src/gasless-provider.ts | 3 ++- src/index.ts | 1 + src/type-extensions.ts | 2 ++ test/fixture-projects/hardhat-project/hardhat.config.ts | 1 + test/project.test.ts | 6 +++++- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gasless-provider.ts b/src/gasless-provider.ts index 4d71cd8..b40e685 100644 --- a/src/gasless-provider.ts +++ b/src/gasless-provider.ts @@ -41,8 +41,9 @@ export class GaslessProvider extends ProviderWrapper { bundlerClient: PimlicoBundlerClient, paymasterClient: PimlicoPaymasterClient, publicClient: ReturnType, + customEntryPoint: `0x${string}` | undefined, ) { - const entryPoint = '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789'; + const entryPoint = customEntryPoint !== undefined ? customEntryPoint : '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789'; const simpleAccountFactoryAddress = '0x9406Cc6185a346906296840746125a0E44976454'; const owner = privateKeyToAccount(_signerPk); diff --git a/src/index.ts b/src/index.ts index c674755..fe936a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,5 +54,6 @@ extendProvider(async (provider, config, networkName) => { bundlerClient, paymasterClient, publicClient, + netConfig.entryPoint, ); }); diff --git a/src/type-extensions.ts b/src/type-extensions.ts index aebb7dd..935e94f 100644 --- a/src/type-extensions.ts +++ b/src/type-extensions.ts @@ -4,9 +4,11 @@ import 'hardhat/types/runtime'; declare module 'hardhat/types/config' { export interface HttpNetworkUserConfig { pimlicoApiKey?: string; + entryPoint?: `0x${string}`; } export interface HttpNetworkConfig { pimlicoApiKey?: string; + entryPoint?: `0x${string}`; } } diff --git a/test/fixture-projects/hardhat-project/hardhat.config.ts b/test/fixture-projects/hardhat-project/hardhat.config.ts index 5aa3d20..429f8e4 100644 --- a/test/fixture-projects/hardhat-project/hardhat.config.ts +++ b/test/fixture-projects/hardhat-project/hardhat.config.ts @@ -9,6 +9,7 @@ const config: HardhatUserConfig = { networks: { localhost: { pimlicoApiKey: 'foo', + entryPoint: '0x0576a174D229E3cFA37253523E645A78A0C91B57', }, }, }; diff --git a/test/project.test.ts b/test/project.test.ts index 001485a..8fac992 100644 --- a/test/project.test.ts +++ b/test/project.test.ts @@ -6,8 +6,12 @@ describe('Integration tests examples', function () { describe('HardhatConfig extension', function () { useEnvironment('hardhat-project'); - it('Should add the sponsoredUrl to the config', function () { + it('Should add the pimlicoApiKey to the config', function () { assert.equal(this.hre.config.networks.localhost.pimlicoApiKey, 'foo'); }); + + it('Should add the entryPoint to the config', function () { + assert.equal(this.hre.config.networks.localhost.entryPoint, '0x0576a174D229E3cFA37253523E645A78A0C91B57'); + }); }); });