diff --git a/packages/api-kit/tests/e2e/addSafeOperation.test.ts b/packages/api-kit/tests/e2e/addSafeOperation.test.ts index 2b5f7fa69..e4d2703f8 100644 --- a/packages/api-kit/tests/e2e/addSafeOperation.test.ts +++ b/packages/api-kit/tests/e2e/addSafeOperation.test.ts @@ -10,11 +10,9 @@ import { generateTransferCallData, ENTRYPOINT_ABI, ENTRYPOINT_ADDRESS_V06, - RPC_4337_CALLS + RPC_4337_CALLS, + mockGetEip4337BundlerProvider } from '@safe-global/relay-kit/test-utils' - -// Needs to be imported from dist folder in order to mock the getEip4337BundlerProvider function -import * as safe4337Utils from '@safe-global/relay-kit/dist/src/packs/safe-4337/utils' import { getKits } from '../utils/setupKits' chai.use(chaiAsPromised) @@ -42,7 +40,7 @@ describe('addSafeOperation', () => { const requestStub = sinon.stub() // Setup mocks for the bundler client before(async () => { - sinon.stub(safe4337Utils, 'getEip4337BundlerProvider').returns({ + mockGetEip4337BundlerProvider().returns({ request: requestStub, readContract: sinon .stub() diff --git a/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts b/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts index e7fd937b6..6824f8b1a 100644 --- a/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts +++ b/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts @@ -6,13 +6,12 @@ import { BundlerClient, Safe4337InitOptions, Safe4337Pack } from '@safe-global/r import { generateTransferCallData, ENTRYPOINT_ADDRESS_V06, - RPC_4337_CALLS + RPC_4337_CALLS, + mockGetEip4337BundlerProvider } from '@safe-global/relay-kit/test-utils' import SafeApiKit from '@safe-global/api-kit/index' import { getAddSafeOperationProps } from '@safe-global/api-kit/utils/safeOperation' import { SafeOperation } from '@safe-global/types-kit' -// Needs to be imported from dist folder in order to mock the getEip4337BundlerProvider function -import * as safe4337Utils from '@safe-global/relay-kit/dist/src/packs/safe-4337/utils' import { getApiKit, getEip1193Provider } from '../utils/setupKits' chai.use(chaiAsPromised) @@ -73,7 +72,7 @@ describe('confirmSafeOperation', () => { const requestStub = sinon.stub() before(async () => { - sinon.stub(safe4337Utils, 'getEip4337BundlerProvider').returns({ + mockGetEip4337BundlerProvider().returns({ request: requestStub } as unknown as BundlerClient) diff --git a/packages/relay-kit/test-utils/index.ts b/packages/relay-kit/test-utils/index.ts index 828165182..a9a815b6b 100644 --- a/packages/relay-kit/test-utils/index.ts +++ b/packages/relay-kit/test-utils/index.ts @@ -1,8 +1,8 @@ export * as fixtures from './fixtures' export * from './helpers' - export { ENTRYPOINT_ABI, ENTRYPOINT_ADDRESS_V06, RPC_4337_CALLS } from '../src/packs/safe-4337/constants' +export { mockGetEip4337BundlerProvider } from './mockGetEip4337BundlerProvider' diff --git a/packages/relay-kit/test-utils/mockGetEip4337BundlerProvider.ts b/packages/relay-kit/test-utils/mockGetEip4337BundlerProvider.ts new file mode 100644 index 000000000..43e2f1241 --- /dev/null +++ b/packages/relay-kit/test-utils/mockGetEip4337BundlerProvider.ts @@ -0,0 +1,4 @@ +import sinon from 'sinon' +import * as utils from '../src/packs/safe-4337/utils' + +export const mockGetEip4337BundlerProvider = () => sinon.stub(utils, 'getEip4337BundlerProvider')