Skip to content

Commit

Permalink
switch up relay-kit build to get invasive test working
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Nov 13, 2024
1 parent 5c221f2 commit 3fc1b6d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 30 deletions.
7 changes: 4 additions & 3 deletions packages/api-kit/tests/e2e/addSafeOperation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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()
Expand Down
7 changes: 4 additions & 3 deletions packages/api-kit/tests/e2e/confirmSafeOperation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)

Expand Down
23 changes: 14 additions & 9 deletions packages/relay-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/relay-kit/test-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export {
ENTRYPOINT_ADDRESS_V06,
RPC_4337_CALLS
} from '../src/packs/safe-4337/constants'
export { mockGetEip4337BundlerProvider } from './mockGetEip4337BundlerProvider'
11 changes: 0 additions & 11 deletions packages/relay-kit/test-utils/mockGetEip4337BundlerProvider.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/relay-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true,
"outDir": "dist"
},
"include": ["src/**/*", "test-utils/**/*"],
Expand Down

0 comments on commit 3fc1b6d

Please sign in to comment.