From 3fc1b6d9bb09bff85fdb6a397ce9bca8d5f3f1b3 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 13:20:18 +0100 Subject: [PATCH] switch up relay-kit build to get invasive test working --- .../tests/e2e/addSafeOperation.test.ts | 7 +++--- .../tests/e2e/confirmSafeOperation.test.ts | 7 +++--- packages/relay-kit/package.json | 23 +++++++++++-------- packages/relay-kit/test-utils/index.ts | 1 - .../mockGetEip4337BundlerProvider.ts | 11 --------- packages/relay-kit/tsconfig.build.json | 3 --- 6 files changed, 22 insertions(+), 30 deletions(-) delete mode 100644 packages/relay-kit/test-utils/mockGetEip4337BundlerProvider.ts diff --git a/packages/api-kit/tests/e2e/addSafeOperation.test.ts b/packages/api-kit/tests/e2e/addSafeOperation.test.ts index b7943e399..e32c6dee0 100644 --- a/packages/api-kit/tests/e2e/addSafeOperation.test.ts +++ b/packages/api-kit/tests/e2e/addSafeOperation.test.ts @@ -6,12 +6,13 @@ import Safe from '@safe-global/protocol-kit' import SafeApiKit from '@safe-global/api-kit/index' import { getAddSafeOperationProps } from '@safe-global/api-kit/utils/safeOperation' import { BundlerClient, Safe4337Pack } from '@safe-global/relay-kit' +// @ts-expect-error crazy hack to get test working +import * as utils from '@safe-global/relay-kit/dist/cjs/src/packs/safe-4337/utils' import { generateTransferCallData, ENTRYPOINT_ABI, ENTRYPOINT_ADDRESS_V06, - RPC_4337_CALLS, - mockGetEip4337BundlerProvider + RPC_4337_CALLS } from '@safe-global/relay-kit/test-utils' import { getKits } from '../utils/setupKits' @@ -40,7 +41,7 @@ describe('addSafeOperation', () => { const requestStub = sinon.stub() // Setup mocks for the bundler client before(async () => { - mockGetEip4337BundlerProvider().mockReturnValue({ + sinon.stub(utils, 'getEip4337BundlerProvider').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 6a9abc8c3..57c750d26 100644 --- a/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts +++ b/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts @@ -6,9 +6,10 @@ import { BundlerClient, Safe4337InitOptions, Safe4337Pack } from '@safe-global/r import { generateTransferCallData, ENTRYPOINT_ADDRESS_V06, - RPC_4337_CALLS, - mockGetEip4337BundlerProvider + RPC_4337_CALLS } from '@safe-global/relay-kit/test-utils' +// @ts-expect-error crazy hack to get test working +import * as utils from '@safe-global/relay-kit/dist/cjs/src/packs/safe-4337/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' @@ -72,7 +73,7 @@ describe('confirmSafeOperation', () => { const requestStub = sinon.stub() before(async () => { - mockGetEip4337BundlerProvider().mockReturnValue({ + sinon.stub(utils, 'getEip4337BundlerProvider').returns({ request: requestStub } as unknown as BundlerClient) diff --git a/packages/relay-kit/package.json b/packages/relay-kit/package.json index 169ae4d49..aaa489dd6 100644 --- a/packages/relay-kit/package.json +++ b/packages/relay-kit/package.json @@ -3,18 +3,23 @@ "version": "3.2.4", "description": "SDK for Safe Smart Accounts with support for ERC-4337 and Relay", "types": "dist/src/index.d.ts", - "main": "dist/cjs/src/index.cjs", - "module": "dist/esm/src/index.mjs", + "main": "dist/cjs/src/index.js", + "module": "dist/esm/src/index.js", "exports": { ".": { "types": "./dist/src/index.d.ts", - "require": "./dist/cjs/src/index.cjs", - "import": "./dist/esm/src/index.mjs" + "require": "./dist/cjs/src/index.js", + "import": "./dist/esm/src/index.js" }, "./test-utils": { "types": "./dist/test-utils/index.d.ts", - "require": "./dist/cjs/test-utils/index.cjs", - "import": "./dist/esm/test-utils/index.mjs" + "require": "./dist/cjs/test-utils/index.js", + "import": "./dist/esm/test-utils/index.js" + }, + "./dist/cjs/src/packs/safe-4337/utils": { + "types": "./dist/src/packs/safe-4337/utils.d.ts", + "require": "./dist/cjs/src/packs/safe-4337/utils.js", + "import": "./dist/esm/src/packs/safe-4337/utils.js" } }, "keywords": [ @@ -33,9 +38,9 @@ "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "unbuild": "rimraf dist .nyc_output cache", "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", - "build:esm": "esbuild ./src/index ./test-utils/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", - "build:cjs": "esbuild ./src/index ./test-utils/index --format=cjs --bundle --packages=external --outdir=dist/cjs --out-extension:.js=.cjs", - "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" + "build:esm": "tsc -p tsconfig.build.json --module esnext --outDir dist/esm && tsc-alias -p tsconfig.build.json --outDir dist/esm", + "build:cjs": "tsc -p tsconfig.build.json --outDir dist/cjs && tsc-alias -p tsconfig.build.json --outDir dist/cjs", + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --declarationMap --emitDeclarationOnly && tsc-alias -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/relay-kit/test-utils/index.ts b/packages/relay-kit/test-utils/index.ts index a9a815b6b..d9baaeb65 100644 --- a/packages/relay-kit/test-utils/index.ts +++ b/packages/relay-kit/test-utils/index.ts @@ -5,4 +5,3 @@ export { 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 deleted file mode 100644 index 24bbb34c3..000000000 --- a/packages/relay-kit/test-utils/mockGetEip4337BundlerProvider.ts +++ /dev/null @@ -1,11 +0,0 @@ -import * as utils from '../src/packs/safe-4337/utils' - -const mockedGetEip4337BundlerProvider = jest.fn(utils.getEip4337BundlerProvider) - -jest.mock('../src/packs/safe-4337/utils', () => ({ - ...jest.requireActual('../src/packs/safe-4337/utils'), - - getEip4337BundlerProvider: mockedGetEip4337BundlerProvider -})) - -export const mockGetEip4337BundlerProvider = () => mockedGetEip4337BundlerProvider diff --git a/packages/relay-kit/tsconfig.build.json b/packages/relay-kit/tsconfig.build.json index e4e2e30f7..a49ad22fa 100644 --- a/packages/relay-kit/tsconfig.build.json +++ b/packages/relay-kit/tsconfig.build.json @@ -1,9 +1,6 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "declarationMap": true, "outDir": "dist" }, "include": ["src/**/*", "test-utils/**/*"],