From 0345a26eb5464758a2e746d72decf36116d41b42 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 23 Oct 2024 11:01:23 +0200 Subject: [PATCH 01/16] chore: build protocol-kit with cjs and esm targets --- packages/protocol-kit/package.json | 14 ++- yarn.lock | 150 +++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 2 deletions(-) diff --git a/packages/protocol-kit/package.json b/packages/protocol-kit/package.json index 7c26a1ea3..f84d7f890 100644 --- a/packages/protocol-kit/package.json +++ b/packages/protocol-kit/package.json @@ -2,8 +2,14 @@ "name": "@safe-global/protocol-kit", "version": "5.0.4", "description": "SDK that facilitates the interaction with Safe Smart Accounts", - "main": "dist/src/index.js", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.mjs", "types": "dist/src/index.d.ts", + "exports": { + "types": "./dist/src/index.d.ts", + "require": "./dist/cjs/index.cjs", + "import": "./dist/esm/index.mjs" + }, "keywords": [ "Ethereum", "Wallet", @@ -35,7 +41,10 @@ "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "unbuild": "rimraf dist artifacts deployments cache .nyc_output *.tsbuildinfo", - "build": "yarn unbuild && yarn check-safe-deployments && NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" + "build": "yarn unbuild && yarn check-safe-deployments && yarn build:esm && yarn build:cjs && yarn build:types", + "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", + "build:cjs": "esbuild ./src/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 --declaration" }, "repository": { "type": "git", @@ -59,6 +68,7 @@ "chai": "^4.3.10", "chai-as-promised": "^7.1.1", "dotenv": "^16.4.5", + "esbuild": "^0.24.0", "ethers": "^6.13.2", "mocha": "^10.2.0", "nyc": "^15.1.0", diff --git a/yarn.lock b/yarn.lock index 904bf6e2a..03fea73b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -327,6 +327,126 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" +"@esbuild/aix-ppc64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz#b57697945b50e99007b4c2521507dc613d4a648c" + integrity sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw== + +"@esbuild/android-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz#1add7e0af67acefd556e407f8497e81fddad79c0" + integrity sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w== + +"@esbuild/android-arm@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.24.0.tgz#ab7263045fa8e090833a8e3c393b60d59a789810" + integrity sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew== + +"@esbuild/android-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.24.0.tgz#e8f8b196cfdfdd5aeaebbdb0110983460440e705" + integrity sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ== + +"@esbuild/darwin-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz#2d0d9414f2acbffd2d86e98253914fca603a53dd" + integrity sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw== + +"@esbuild/darwin-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz#33087aab31a1eb64c89daf3d2cf8ce1775656107" + integrity sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA== + +"@esbuild/freebsd-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz#bb76e5ea9e97fa3c753472f19421075d3a33e8a7" + integrity sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA== + +"@esbuild/freebsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz#e0e2ce9249fdf6ee29e5dc3d420c7007fa579b93" + integrity sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ== + +"@esbuild/linux-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz#d1b2aa58085f73ecf45533c07c82d81235388e75" + integrity sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g== + +"@esbuild/linux-arm@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz#8e4915df8ea3e12b690a057e77a47b1d5935ef6d" + integrity sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw== + +"@esbuild/linux-ia32@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz#8200b1110666c39ab316572324b7af63d82013fb" + integrity sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA== + +"@esbuild/linux-loong64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz#6ff0c99cf647504df321d0640f0d32e557da745c" + integrity sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g== + +"@esbuild/linux-mips64el@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz#3f720ccd4d59bfeb4c2ce276a46b77ad380fa1f3" + integrity sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA== + +"@esbuild/linux-ppc64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz#9d6b188b15c25afd2e213474bf5f31e42e3aa09e" + integrity sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ== + +"@esbuild/linux-riscv64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz#f989fdc9752dfda286c9cd87c46248e4dfecbc25" + integrity sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw== + +"@esbuild/linux-s390x@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz#29ebf87e4132ea659c1489fce63cd8509d1c7319" + integrity sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g== + +"@esbuild/linux-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz#4af48c5c0479569b1f359ffbce22d15f261c0cef" + integrity sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA== + +"@esbuild/netbsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz#1ae73d23cc044a0ebd4f198334416fb26c31366c" + integrity sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg== + +"@esbuild/openbsd-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz#5d904a4f5158c89859fd902c427f96d6a9e632e2" + integrity sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg== + +"@esbuild/openbsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz#4c8aa88c49187c601bae2971e71c6dc5e0ad1cdf" + integrity sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q== + +"@esbuild/sunos-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz#8ddc35a0ea38575fa44eda30a5ee01ae2fa54dd4" + integrity sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA== + +"@esbuild/win32-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz#6e79c8543f282c4539db684a207ae0e174a9007b" + integrity sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA== + +"@esbuild/win32-ia32@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz#057af345da256b7192d18b676a02e95d0fa39103" + integrity sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw== + +"@esbuild/win32-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz#168ab1c7e1c318b922637fad8f339d48b01e1244" + integrity sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA== + "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz" @@ -3707,6 +3827,36 @@ es6-error@^4.0.1: resolved "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz" integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== +esbuild@^0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.24.0.tgz#f2d470596885fcb2e91c21eb3da3b3c89c0b55e7" + integrity sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ== + optionalDependencies: + "@esbuild/aix-ppc64" "0.24.0" + "@esbuild/android-arm" "0.24.0" + "@esbuild/android-arm64" "0.24.0" + "@esbuild/android-x64" "0.24.0" + "@esbuild/darwin-arm64" "0.24.0" + "@esbuild/darwin-x64" "0.24.0" + "@esbuild/freebsd-arm64" "0.24.0" + "@esbuild/freebsd-x64" "0.24.0" + "@esbuild/linux-arm" "0.24.0" + "@esbuild/linux-arm64" "0.24.0" + "@esbuild/linux-ia32" "0.24.0" + "@esbuild/linux-loong64" "0.24.0" + "@esbuild/linux-mips64el" "0.24.0" + "@esbuild/linux-ppc64" "0.24.0" + "@esbuild/linux-riscv64" "0.24.0" + "@esbuild/linux-s390x" "0.24.0" + "@esbuild/linux-x64" "0.24.0" + "@esbuild/netbsd-x64" "0.24.0" + "@esbuild/openbsd-arm64" "0.24.0" + "@esbuild/openbsd-x64" "0.24.0" + "@esbuild/sunos-x64" "0.24.0" + "@esbuild/win32-arm64" "0.24.0" + "@esbuild/win32-ia32" "0.24.0" + "@esbuild/win32-x64" "0.24.0" + escalade@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" From 8da43de7628bedf4908b9ab6bcc9820f189d2634 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Tue, 12 Nov 2024 14:32:26 +0100 Subject: [PATCH 02/16] migrate relay kit build --- packages/protocol-kit/package.json | 2 +- packages/relay-kit/package.json | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/protocol-kit/package.json b/packages/protocol-kit/package.json index f84d7f890..828f8e99d 100644 --- a/packages/protocol-kit/package.json +++ b/packages/protocol-kit/package.json @@ -2,9 +2,9 @@ "name": "@safe-global/protocol-kit", "version": "5.0.4", "description": "SDK that facilitates the interaction with Safe Smart Accounts", + "types": "dist/src/index.d.ts", "main": "dist/cjs/index.cjs", "module": "dist/esm/index.mjs", - "types": "dist/src/index.d.ts", "exports": { "types": "./dist/src/index.d.ts", "require": "./dist/cjs/index.cjs", diff --git a/packages/relay-kit/package.json b/packages/relay-kit/package.json index 5e5be690d..9d5974066 100644 --- a/packages/relay-kit/package.json +++ b/packages/relay-kit/package.json @@ -2,8 +2,14 @@ "name": "@safe-global/relay-kit", "version": "3.2.4", "description": "SDK for Safe Smart Accounts with support for ERC-4337 and Relay", - "main": "dist/src/index.js", - "typings": "dist/src/index.d.ts", + "types": "dist/src/index.d.ts", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.mjs", + "exports": { + "types": "./dist/src/index.d.ts", + "require": "./dist/cjs/index.cjs", + "import": "./dist/esm/index.mjs" + }, "keywords": [ "Ethereum", "Wallet", @@ -19,7 +25,10 @@ "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "unbuild": "rimraf dist .nyc_output cache", - "build": "yarn unbuild && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" + "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", + "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", + "build:cjs": "esbuild ./src/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 --declaration" }, "repository": { "type": "git", @@ -43,5 +52,8 @@ "@safe-global/safe-modules-deployments": "^2.2.4", "@safe-global/types-kit": "^1.0.0", "viem": "^2.21.8" + }, + "devDependencies": { + "esbuild": "^0.24.0" } } From 1676b47a385a42c9af698fa4c9713a09bf094839 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Tue, 12 Nov 2024 14:34:40 +0100 Subject: [PATCH 03/16] update build of api-kit --- packages/api-kit/package.json | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/api-kit/package.json b/packages/api-kit/package.json index 8ec5b808b..4fd790e79 100644 --- a/packages/api-kit/package.json +++ b/packages/api-kit/package.json @@ -2,8 +2,14 @@ "name": "@safe-global/api-kit", "version": "2.5.4", "description": "SDK that facilitates the interaction with the Safe Transaction Service API", - "main": "dist/src/index.js", - "typings": "dist/src/index.d.ts", + "types": "dist/src/index.d.ts", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.mjs", + "exports": { + "types": "./dist/src/index.d.ts", + "require": "./dist/cjs/index.cjs", + "import": "./dist/esm/index.mjs" + }, "keywords": [ "Ethereum", "Wallet", @@ -23,7 +29,10 @@ "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "unbuild": "rimraf dist .nyc_output cache", - "build": "yarn unbuild && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" + "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", + "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", + "build:cjs": "esbuild ./src/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 --declaration" }, "repository": { "type": "git", @@ -48,6 +57,7 @@ "@types/sinon-chai": "^3.2.11", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", + "esbuild": "^0.24.0", "ethers": "^6.13.2", "mocha": "^10.2.0", "nyc": "^15.1.0", From 3ca41109f3700703d6e27860c4c1f9bcd4c8e678 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Tue, 12 Nov 2024 14:36:18 +0100 Subject: [PATCH 04/16] update build of sdk-starter-kit --- packages/sdk-starter-kit/package.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/sdk-starter-kit/package.json b/packages/sdk-starter-kit/package.json index e9443b1b5..130d868c7 100644 --- a/packages/sdk-starter-kit/package.json +++ b/packages/sdk-starter-kit/package.json @@ -2,8 +2,14 @@ "name": "@safe-global/sdk-starter-kit", "version": "1.0.4", "description": "SDK that provides the basic tools to interact with the Safe Smart Account.", - "main": "dist/src/index.js", - "typings": "dist/src/index.d.ts", + "types": "dist/src/index.d.ts", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.mjs", + "exports": { + "types": "./dist/src/index.d.ts", + "require": "./dist/cjs/index.cjs", + "import": "./dist/esm/index.mjs" + }, "keywords": [ "Ethereum", "Wallet", @@ -14,7 +20,10 @@ ], "scripts": { "unbuild": "rimraf dist", - "build": "yarn unbuild && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", + "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", + "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", + "build:cjs": "esbuild ./src/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 --declaration", "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "test": "jest src --coverage" @@ -41,5 +50,8 @@ "@safe-global/relay-kit": "^3.2.4", "@safe-global/types-kit": "^1.0.0", "viem": "^2.21.8" + }, + "devDependencies": { + "esbuild": "^0.24.0" } } From c8478ec83bef35bff52e22051d35f2b353961e81 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Tue, 12 Nov 2024 14:37:32 +0100 Subject: [PATCH 05/16] update build of testing-kit --- packages/testing-kit/package.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/testing-kit/package.json b/packages/testing-kit/package.json index 0541fb4c8..8fcfb0d99 100644 --- a/packages/testing-kit/package.json +++ b/packages/testing-kit/package.json @@ -2,8 +2,14 @@ "name": "@safe-global/testing-kit", "version": "0.1.1", "description": "Helper package providing testing utilities", - "main": "dist/src/index.js", "types": "dist/src/index.d.ts", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.mjs", + "exports": { + "types": "./dist/src/index.d.ts", + "require": "./dist/cjs/index.cjs", + "import": "./dist/esm/index.mjs" + }, "keywords": [ "Ethereum", "Wallet", @@ -16,7 +22,10 @@ "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "unbuild": "rimraf dist artifacts deployments cache .nyc_output *.tsbuildinfo", - "build": "yarn unbuild && hardhat compile && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", + "build": "yarn unbuild && hardhat compile && yarn build:esm && yarn build:cjs && yarn build:types", + "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", + "build:cjs": "esbuild ./src/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 --declaration", "deploy": "hardhat deploy", "compile": "hardhat compile", "test": "hardhat test" @@ -42,6 +51,7 @@ "@safe-global/safe-passkey": "0.2.0-alpha.1", "@safe-global/types-kit": "^1.0.0", "@types/semver": "^7.5.8", + "esbuild": "^0.24.0", "hardhat": "^2.19.3", "hardhat-deploy": "^0.12.4", "tsconfig-paths": "^4.2.0" From 75f15f2737bf9739baca6aaca9fcb77f4d5f858c Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Tue, 12 Nov 2024 14:38:28 +0100 Subject: [PATCH 06/16] update build of types-kit --- packages/types-kit/package.json | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/types-kit/package.json b/packages/types-kit/package.json index 6ad1e7c6e..9c2dbbaed 100644 --- a/packages/types-kit/package.json +++ b/packages/types-kit/package.json @@ -2,8 +2,14 @@ "name": "@safe-global/types-kit", "version": "1.0.0", "description": "Types for use with the Safe Core SDK packages", - "main": "dist/src/index.js", "types": "dist/src/index.d.ts", + "main": "dist/cjs/index.cjs", + "module": "dist/esm/index.mjs", + "exports": { + "types": "./dist/src/index.d.ts", + "require": "./dist/cjs/index.cjs", + "import": "./dist/esm/index.mjs" + }, "keywords": [ "Ethereum", "Wallet", @@ -15,7 +21,10 @@ "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "unbuild": "rimraf dist *.tsbuildinfo", - "build": "yarn unbuild && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" + "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", + "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", + "build:cjs": "esbuild ./src/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 --declaration" }, "repository": { "type": "git", @@ -32,5 +41,8 @@ "homepage": "https://github.com/safe-global/safe-core-sdk#readme", "dependencies": { "abitype": "^1.0.2" + }, + "devDependencies": { + "esbuild": "^0.24.0" } } From 3bc8252e4acf06947d980f6a9d57d1ac44f490ae Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Tue, 12 Nov 2024 20:25:11 +0100 Subject: [PATCH 07/16] update typescript setup --- package.json | 2 +- packages/protocol-kit/package.json | 2 +- packages/protocol-kit/tests/e2e/utils/passkeys.ts | 6 +++++- packages/protocol-kit/tsconfig.build.json | 8 ++++---- packages/protocol-kit/tsconfig.json | 9 ++++++--- tsconfig.settings.json | 2 -- yarn.lock | 7 ++++++- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 0bc603c7d..c6e8882bd 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "ts-jest": "^29.1.5", "ts-node": "^10.9.2", "tsc-alias": "^1.8.8", - "typescript": "^5.3.3" + "typescript": "5.6.3" }, "lint-staged": { "./packages/**/*.{js,jsx,ts,tsx}": [ diff --git a/packages/protocol-kit/package.json b/packages/protocol-kit/package.json index 828f8e99d..4d346db95 100644 --- a/packages/protocol-kit/package.json +++ b/packages/protocol-kit/package.json @@ -44,7 +44,7 @@ "build": "yarn unbuild && yarn check-safe-deployments && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly" }, "repository": { "type": "git", diff --git a/packages/protocol-kit/tests/e2e/utils/passkeys.ts b/packages/protocol-kit/tests/e2e/utils/passkeys.ts index 2053af959..0aa1c1bf0 100644 --- a/packages/protocol-kit/tests/e2e/utils/passkeys.ts +++ b/packages/protocol-kit/tests/e2e/utils/passkeys.ts @@ -1,4 +1,8 @@ -import { PasskeyArgType, PasskeyClient, extractPasskeyCoordinates } from '@safe-global/protocol-kit' +import { + PasskeyArgType, + PasskeyClient, + extractPasskeyCoordinates +} from '@safe-global/protocol-kit/index' import { WebAuthnCredentials } from './webauthnShim' import { WalletClient, keccak256, toBytes, Transport, Chain, Account } from 'viem' import { asHex } from '@safe-global/protocol-kit/utils/types' diff --git a/packages/protocol-kit/tsconfig.build.json b/packages/protocol-kit/tsconfig.build.json index c05e497c4..6abe53b8e 100644 --- a/packages/protocol-kit/tsconfig.build.json +++ b/packages/protocol-kit/tsconfig.build.json @@ -1,8 +1,8 @@ { - "extends": "../../tsconfig.settings.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "outDir": "dist/src" }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["dist", "test"] } diff --git a/packages/protocol-kit/tsconfig.json b/packages/protocol-kit/tsconfig.json index 5f6bc90a7..c24b6ffe7 100644 --- a/packages/protocol-kit/tsconfig.json +++ b/packages/protocol-kit/tsconfig.json @@ -1,8 +1,11 @@ { "extends": "../../tsconfig.settings.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "baseUrl": "./", + "paths": { + "@safe-global/protocol-kit/*": ["./src/*"] + } }, - "include": ["src/**/*", "tests/**/*", "hardhat/**/*", "hardhat.config.ts"] + "include": ["src/**/*", "tests/**/*", "hardhat/**/*", "hardhat.config.ts"], + "exclude": ["dist"] } diff --git a/tsconfig.settings.json b/tsconfig.settings.json index df950e2b4..097d4e1d2 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -3,7 +3,6 @@ "target": "ES2020" /* Specify ECMAScript target version: 'ES5' (default), 'ES2019', 'ES2020', 'ES2021', 'ES2022', 'ES2023' or 'ESNEXT'. */, "module": "CommonJS" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, "allowJs": false /* Allow javascript files to be compiled. */, - "declaration": true /* Generates corresponding '.d.ts' file. */, "sourceMap": true /* Generates corresponding '.map' file. */, "strict": true /* Enable all strict type-checking options. */, "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, @@ -22,7 +21,6 @@ "baseUrl": "./", "paths": { "@safe-global/api-kit/*": ["./packages/api-kit/src/*"], - "@safe-global/protocol-kit/*": ["./packages/protocol-kit/src/*"], "@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"], "@safe-global/relay-kit/*": ["./packages/relay-kit/src/*"], "@safe-global/types-kit/*": ["./packages/types-kit/src/*"], diff --git a/yarn.lock b/yarn.lock index 03fea73b0..c1f4d9442 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8453,7 +8453,12 @@ typedarray@^0.0.6: resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== -"typescript@>=3 < 6", typescript@^5.3.3: +typescript@5.6.3: + version "5.6.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b" + integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw== + +"typescript@>=3 < 6": version "5.3.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== From 5c3394cb925e205518ac161978cd49e514eb42ec Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 09:35:03 +0100 Subject: [PATCH 08/16] update ts setup for api-kit --- packages/api-kit/package.json | 2 +- packages/api-kit/tsconfig.build.json | 8 ++++---- packages/api-kit/tsconfig.json | 9 ++++++--- tsconfig.settings.json | 1 - 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/api-kit/package.json b/packages/api-kit/package.json index 4fd790e79..b3ec12e65 100644 --- a/packages/api-kit/package.json +++ b/packages/api-kit/package.json @@ -32,7 +32,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly" }, "repository": { "type": "git", diff --git a/packages/api-kit/tsconfig.build.json b/packages/api-kit/tsconfig.build.json index c05e497c4..6abe53b8e 100644 --- a/packages/api-kit/tsconfig.build.json +++ b/packages/api-kit/tsconfig.build.json @@ -1,8 +1,8 @@ { - "extends": "../../tsconfig.settings.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "outDir": "dist/src" }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["dist", "test"] } diff --git a/packages/api-kit/tsconfig.json b/packages/api-kit/tsconfig.json index 18bfaf51a..fe5e15882 100644 --- a/packages/api-kit/tsconfig.json +++ b/packages/api-kit/tsconfig.json @@ -1,8 +1,11 @@ { "extends": "../../tsconfig.settings.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "baseUrl": "./", + "paths": { + "@safe-global/api-kit/*": ["./src/*"] + } }, - "include": ["src/**/*", "tests/**/*"] + "include": ["src/**/*", "tests/**/*"], + "exclude": ["dist"] } diff --git a/tsconfig.settings.json b/tsconfig.settings.json index 097d4e1d2..e1734ccab 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -20,7 +20,6 @@ "resolveJsonModule": true, "baseUrl": "./", "paths": { - "@safe-global/api-kit/*": ["./packages/api-kit/src/*"], "@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"], "@safe-global/relay-kit/*": ["./packages/relay-kit/src/*"], "@safe-global/types-kit/*": ["./packages/types-kit/src/*"], From b287c1d5adb696dcbaf41860a863b8be215364ca Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 09:37:30 +0100 Subject: [PATCH 09/16] adjust relay-kit ts setup --- packages/relay-kit/package.json | 2 +- packages/relay-kit/tsconfig.build.json | 7 +++---- packages/relay-kit/tsconfig.json | 9 ++++++--- tsconfig.settings.json | 1 - 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/relay-kit/package.json b/packages/relay-kit/package.json index 9d5974066..3f11f8a90 100644 --- a/packages/relay-kit/package.json +++ b/packages/relay-kit/package.json @@ -28,7 +28,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly" }, "repository": { "type": "git", diff --git a/packages/relay-kit/tsconfig.build.json b/packages/relay-kit/tsconfig.build.json index cc22498f1..f9dc6a2e7 100644 --- a/packages/relay-kit/tsconfig.build.json +++ b/packages/relay-kit/tsconfig.build.json @@ -1,9 +1,8 @@ { - "extends": "../../tsconfig.settings.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "outDir": "dist/src" }, "include": ["src/**/*"], - "exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"] + "exclude": ["dist", "src/**/*.test.ts", "src/**/*.test-d.ts"] } diff --git a/packages/relay-kit/tsconfig.json b/packages/relay-kit/tsconfig.json index c05e497c4..de8a38bd8 100644 --- a/packages/relay-kit/tsconfig.json +++ b/packages/relay-kit/tsconfig.json @@ -1,8 +1,11 @@ { "extends": "../../tsconfig.settings.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "baseUrl": "./", + "paths": { + "@safe-global/relay-kit/*": ["./src/*"] + } }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["dist"] } diff --git a/tsconfig.settings.json b/tsconfig.settings.json index e1734ccab..57d3cc857 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -21,7 +21,6 @@ "baseUrl": "./", "paths": { "@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"], - "@safe-global/relay-kit/*": ["./packages/relay-kit/src/*"], "@safe-global/types-kit/*": ["./packages/types-kit/src/*"], "@safe-global/sdk-starter-kit/*": ["./packages/sdk-starter-kit/src/*"] } From 3c336b273b20bfce99fe9dfe1d670240236f2581 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 09:43:29 +0100 Subject: [PATCH 10/16] update ts setup for sdk-starter-kit --- packages/sdk-starter-kit/package.json | 2 +- packages/sdk-starter-kit/tsconfig.build.json | 7 +++---- packages/sdk-starter-kit/tsconfig.json | 9 ++++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/sdk-starter-kit/package.json b/packages/sdk-starter-kit/package.json index 130d868c7..6f04db05f 100644 --- a/packages/sdk-starter-kit/package.json +++ b/packages/sdk-starter-kit/package.json @@ -23,7 +23,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration", + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly", "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "test": "jest src --coverage" diff --git a/packages/sdk-starter-kit/tsconfig.build.json b/packages/sdk-starter-kit/tsconfig.build.json index cc22498f1..f9dc6a2e7 100644 --- a/packages/sdk-starter-kit/tsconfig.build.json +++ b/packages/sdk-starter-kit/tsconfig.build.json @@ -1,9 +1,8 @@ { - "extends": "../../tsconfig.settings.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "outDir": "dist/src" }, "include": ["src/**/*"], - "exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"] + "exclude": ["dist", "src/**/*.test.ts", "src/**/*.test-d.ts"] } diff --git a/packages/sdk-starter-kit/tsconfig.json b/packages/sdk-starter-kit/tsconfig.json index c05e497c4..84ac71795 100644 --- a/packages/sdk-starter-kit/tsconfig.json +++ b/packages/sdk-starter-kit/tsconfig.json @@ -1,8 +1,11 @@ { "extends": "../../tsconfig.settings.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "baseUrl": "./", + "paths": { + "@safe-global/sdk-starter-kit/*": ["./src/*"] + } }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["dist"] } From 3bfa53b534eb2d1965dc254476833508e45a17be Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 09:43:46 +0100 Subject: [PATCH 11/16] update tsconfig.settings --- tsconfig.settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsconfig.settings.json b/tsconfig.settings.json index 57d3cc857..a5bccc494 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -21,8 +21,7 @@ "baseUrl": "./", "paths": { "@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"], - "@safe-global/types-kit/*": ["./packages/types-kit/src/*"], - "@safe-global/sdk-starter-kit/*": ["./packages/sdk-starter-kit/src/*"] + "@safe-global/types-kit/*": ["./packages/types-kit/src/*"] } }, "exclude": ["**/dist", "**/node_modules"] From 638cd198b0e1570c27dbef6589d0c4b7d3d7d6d7 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 09:45:31 +0100 Subject: [PATCH 12/16] update testing-kit ts setup --- packages/testing-kit/package.json | 2 +- packages/testing-kit/tsconfig.build.json | 6 +++--- packages/testing-kit/tsconfig.json | 7 ++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/testing-kit/package.json b/packages/testing-kit/package.json index 8fcfb0d99..0806f5ac6 100644 --- a/packages/testing-kit/package.json +++ b/packages/testing-kit/package.json @@ -25,7 +25,7 @@ "build": "yarn unbuild && hardhat compile && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration", + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly", "deploy": "hardhat deploy", "compile": "hardhat compile", "test": "hardhat test" diff --git a/packages/testing-kit/tsconfig.build.json b/packages/testing-kit/tsconfig.build.json index 21c0f1779..0d942e270 100644 --- a/packages/testing-kit/tsconfig.build.json +++ b/packages/testing-kit/tsconfig.build.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.settings.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "outDir": "dist/src" }, "include": ["src/**/*"], + "exclude": ["dist"], "files": ["./hardhat.config.ts"] } diff --git a/packages/testing-kit/tsconfig.json b/packages/testing-kit/tsconfig.json index c05e497c4..11e9d0a15 100644 --- a/packages/testing-kit/tsconfig.json +++ b/packages/testing-kit/tsconfig.json @@ -1,8 +1,5 @@ { "extends": "../../tsconfig.settings.json", - "compilerOptions": { - "composite": true, - "outDir": "dist" - }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["dist"] } From c4de45003be254a33e3b65699692ac0d3ed1db8c Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 09:47:16 +0100 Subject: [PATCH 13/16] update ts setup of types-kit --- packages/types-kit/package.json | 2 +- packages/types-kit/tsconfig.build.json | 8 ++++---- packages/types-kit/tsconfig.json | 9 ++++++--- tsconfig.settings.json | 3 +-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/types-kit/package.json b/packages/types-kit/package.json index 9c2dbbaed..09dca77ec 100644 --- a/packages/types-kit/package.json +++ b/packages/types-kit/package.json @@ -24,7 +24,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly" }, "repository": { "type": "git", diff --git a/packages/types-kit/tsconfig.build.json b/packages/types-kit/tsconfig.build.json index c05e497c4..33b38b245 100644 --- a/packages/types-kit/tsconfig.build.json +++ b/packages/types-kit/tsconfig.build.json @@ -1,8 +1,8 @@ { - "extends": "../../tsconfig.settings.json", + "extends": "./tsconfig.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "outDir": "dist/src" }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["dist"] } diff --git a/packages/types-kit/tsconfig.json b/packages/types-kit/tsconfig.json index c05e497c4..27ee7ecc9 100644 --- a/packages/types-kit/tsconfig.json +++ b/packages/types-kit/tsconfig.json @@ -1,8 +1,11 @@ { "extends": "../../tsconfig.settings.json", "compilerOptions": { - "composite": true, - "outDir": "dist" + "baseUrl": "./", + "paths": { + "@safe-global/types-kit/*": ["./src/*"] + } }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "exclude": ["dist"] } diff --git a/tsconfig.settings.json b/tsconfig.settings.json index a5bccc494..91acaf0c9 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -20,8 +20,7 @@ "resolveJsonModule": true, "baseUrl": "./", "paths": { - "@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"], - "@safe-global/types-kit/*": ["./packages/types-kit/src/*"] + "@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"] } }, "exclude": ["**/dist", "**/node_modules"] From 48411005569fd203403ce5c1fec7df0a3ee85ad7 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 09:55:04 +0100 Subject: [PATCH 14/16] unwrap all path aliases on build --- packages/api-kit/package.json | 2 +- packages/protocol-kit/package.json | 2 +- packages/relay-kit/package.json | 2 +- packages/sdk-starter-kit/package.json | 2 +- packages/testing-kit/package.json | 2 +- tsconfig.settings.json | 5 +---- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/api-kit/package.json b/packages/api-kit/package.json index b3ec12e65..1cd921754 100644 --- a/packages/api-kit/package.json +++ b/packages/api-kit/package.json @@ -32,7 +32,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/protocol-kit/package.json b/packages/protocol-kit/package.json index 4d346db95..7f290bf8f 100644 --- a/packages/protocol-kit/package.json +++ b/packages/protocol-kit/package.json @@ -44,7 +44,7 @@ "build": "yarn unbuild && yarn check-safe-deployments && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/relay-kit/package.json b/packages/relay-kit/package.json index 3f11f8a90..5cd14c231 100644 --- a/packages/relay-kit/package.json +++ b/packages/relay-kit/package.json @@ -28,7 +28,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/sdk-starter-kit/package.json b/packages/sdk-starter-kit/package.json index 6f04db05f..958f3ae35 100644 --- a/packages/sdk-starter-kit/package.json +++ b/packages/sdk-starter-kit/package.json @@ -23,7 +23,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly", + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json", "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "test": "jest src --coverage" diff --git a/packages/testing-kit/package.json b/packages/testing-kit/package.json index 0806f5ac6..d992960d8 100644 --- a/packages/testing-kit/package.json +++ b/packages/testing-kit/package.json @@ -25,7 +25,7 @@ "build": "yarn unbuild && hardhat compile && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly", + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json", "deploy": "hardhat deploy", "compile": "hardhat compile", "test": "hardhat test" diff --git a/tsconfig.settings.json b/tsconfig.settings.json index 91acaf0c9..2af7ffd03 100644 --- a/tsconfig.settings.json +++ b/tsconfig.settings.json @@ -18,10 +18,7 @@ "skipLibCheck": true /* Skip type checking of declaration files. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "resolveJsonModule": true, - "baseUrl": "./", - "paths": { - "@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"] - } + "baseUrl": "./" }, "exclude": ["**/dist", "**/node_modules"] } From 00cd60748279b640ddc56401f61383cba8a211d8 Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 10:05:28 +0100 Subject: [PATCH 15/16] emit declaration maps to make go to source work --- packages/api-kit/package.json | 2 +- packages/api-kit/tsconfig.build.json | 3 +++ packages/protocol-kit/package.json | 2 +- packages/protocol-kit/tsconfig.build.json | 3 +++ packages/relay-kit/package.json | 2 +- packages/relay-kit/tsconfig.build.json | 3 +++ packages/sdk-starter-kit/package.json | 2 +- packages/sdk-starter-kit/tsconfig.build.json | 3 +++ packages/testing-kit/package.json | 2 +- packages/testing-kit/tsconfig.build.json | 3 +++ packages/types-kit/package.json | 2 +- packages/types-kit/tsconfig.build.json | 3 +++ 12 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/api-kit/package.json b/packages/api-kit/package.json index 1cd921754..8a4a312e3 100644 --- a/packages/api-kit/package.json +++ b/packages/api-kit/package.json @@ -32,7 +32,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/api-kit/tsconfig.build.json b/packages/api-kit/tsconfig.build.json index 6abe53b8e..00513d17b 100644 --- a/packages/api-kit/tsconfig.build.json +++ b/packages/api-kit/tsconfig.build.json @@ -1,6 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, "outDir": "dist/src" }, "include": ["src/**/*"], diff --git a/packages/protocol-kit/package.json b/packages/protocol-kit/package.json index 7f290bf8f..39d3083b2 100644 --- a/packages/protocol-kit/package.json +++ b/packages/protocol-kit/package.json @@ -44,7 +44,7 @@ "build": "yarn unbuild && yarn check-safe-deployments && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/protocol-kit/tsconfig.build.json b/packages/protocol-kit/tsconfig.build.json index 6abe53b8e..00513d17b 100644 --- a/packages/protocol-kit/tsconfig.build.json +++ b/packages/protocol-kit/tsconfig.build.json @@ -1,6 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, "outDir": "dist/src" }, "include": ["src/**/*"], diff --git a/packages/relay-kit/package.json b/packages/relay-kit/package.json index 5cd14c231..b816b6ff4 100644 --- a/packages/relay-kit/package.json +++ b/packages/relay-kit/package.json @@ -28,7 +28,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/relay-kit/tsconfig.build.json b/packages/relay-kit/tsconfig.build.json index f9dc6a2e7..fb93df610 100644 --- a/packages/relay-kit/tsconfig.build.json +++ b/packages/relay-kit/tsconfig.build.json @@ -1,6 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, "outDir": "dist/src" }, "include": ["src/**/*"], diff --git a/packages/sdk-starter-kit/package.json b/packages/sdk-starter-kit/package.json index 958f3ae35..586f6126a 100644 --- a/packages/sdk-starter-kit/package.json +++ b/packages/sdk-starter-kit/package.json @@ -23,7 +23,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json", + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "test": "jest src --coverage" diff --git a/packages/sdk-starter-kit/tsconfig.build.json b/packages/sdk-starter-kit/tsconfig.build.json index f9dc6a2e7..fb93df610 100644 --- a/packages/sdk-starter-kit/tsconfig.build.json +++ b/packages/sdk-starter-kit/tsconfig.build.json @@ -1,6 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, "outDir": "dist/src" }, "include": ["src/**/*"], diff --git a/packages/testing-kit/package.json b/packages/testing-kit/package.json index d992960d8..062dd1cd5 100644 --- a/packages/testing-kit/package.json +++ b/packages/testing-kit/package.json @@ -25,7 +25,7 @@ "build": "yarn unbuild && hardhat compile && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.build.json", + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", "deploy": "hardhat deploy", "compile": "hardhat compile", "test": "hardhat test" diff --git a/packages/testing-kit/tsconfig.build.json b/packages/testing-kit/tsconfig.build.json index 0d942e270..5283975a2 100644 --- a/packages/testing-kit/tsconfig.build.json +++ b/packages/testing-kit/tsconfig.build.json @@ -1,6 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, "outDir": "dist/src" }, "include": ["src/**/*"], diff --git a/packages/types-kit/package.json b/packages/types-kit/package.json index 09dca77ec..c83e56702 100644 --- a/packages/types-kit/package.json +++ b/packages/types-kit/package.json @@ -24,7 +24,7 @@ "build": "yarn unbuild && yarn build:esm && yarn build:cjs && yarn build:types", "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", "build:cjs": "esbuild ./src/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 --declaration --emitDeclarationOnly" + "build:types": "NODE_OPTIONS=--max-old-space-size=8192 tsc -p tsconfig.build.json" }, "repository": { "type": "git", diff --git a/packages/types-kit/tsconfig.build.json b/packages/types-kit/tsconfig.build.json index 33b38b245..c4f78f857 100644 --- a/packages/types-kit/tsconfig.build.json +++ b/packages/types-kit/tsconfig.build.json @@ -1,6 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, "outDir": "dist/src" }, "include": ["src/**/*"], From 2acda8fc34a2cce89080e7d4089da31c0bc9abdb Mon Sep 17 00:00:00 2001 From: Philipp Giese Date: Wed, 13 Nov 2024 10:36:35 +0100 Subject: [PATCH 16/16] adjust test setup after build changes --- .../tests/e2e/addSafeOperation.test.ts | 10 +++---- .../tests/e2e/confirmSafeOperation.test.ts | 16 +++++------ packages/protocol-kit/package.json | 21 +++++++++----- packages/protocol-kit/test-utils/index.ts | 2 ++ .../e2e/utils => test-utils}/passkeys.ts | 8 ++---- .../e2e/utils => test-utils}/webauthnShim.ts | 0 .../protocol-kit/tests/e2e/passkey.test.ts | 6 +++- .../tests/e2e/safeProvider.test.ts | 2 +- packages/protocol-kit/tsconfig.build.json | 4 +-- packages/relay-kit/jest.config.js | 2 +- packages/relay-kit/package.json | 28 +++++++++++++------ .../src/packs/safe-4337/Safe4337Pack.test.ts | 10 ++++--- .../src/packs/safe-4337/SafeOperation.test.ts | 2 +- .../estimators/PimlicoFeeEstimator.test.ts | 2 +- .../testing-utils => test-utils}/fixtures.ts | 2 +- .../testing-utils => test-utils}/helpers.ts | 4 +-- packages/relay-kit/test-utils/index.ts | 7 +++++ packages/relay-kit/tsconfig.build.json | 7 ++--- packages/testing-kit/bin/testing-kit.js | 2 ++ packages/testing-kit/package.json | 4 +-- 20 files changed, 84 insertions(+), 55 deletions(-) create mode 100644 packages/protocol-kit/test-utils/index.ts rename packages/protocol-kit/{tests/e2e/utils => test-utils}/passkeys.ts (94%) rename packages/protocol-kit/{tests/e2e/utils => test-utils}/webauthnShim.ts (100%) rename packages/relay-kit/{src/packs/safe-4337/testing-utils => test-utils}/fixtures.ts (99%) rename packages/relay-kit/{src/packs/safe-4337/testing-utils => test-utils}/helpers.ts (87%) create mode 100644 packages/relay-kit/test-utils/index.ts diff --git a/packages/api-kit/tests/e2e/addSafeOperation.test.ts b/packages/api-kit/tests/e2e/addSafeOperation.test.ts index 09cb2f33d..e32c6dee0 100644 --- a/packages/api-kit/tests/e2e/addSafeOperation.test.ts +++ b/packages/api-kit/tests/e2e/addSafeOperation.test.ts @@ -6,14 +6,14 @@ 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' -import { generateTransferCallData } from '@safe-global/relay-kit/packs/safe-4337/testing-utils/helpers' +// @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 -} from '@safe-global/relay-kit/packs/safe-4337/constants' -// 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' +} from '@safe-global/relay-kit/test-utils' import { getKits } from '../utils/setupKits' chai.use(chaiAsPromised) @@ -41,7 +41,7 @@ describe('addSafeOperation', () => { const requestStub = sinon.stub() // Setup mocks for the bundler client before(async () => { - sinon.stub(safe4337Utils, 'getEip4337BundlerProvider').returns({ + 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 075febbe5..57c750d26 100644 --- a/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts +++ b/packages/api-kit/tests/e2e/confirmSafeOperation.test.ts @@ -3,17 +3,17 @@ import chaiAsPromised from 'chai-as-promised' import sinon from 'sinon' import sinonChai from 'sinon-chai' import { BundlerClient, Safe4337InitOptions, Safe4337Pack } from '@safe-global/relay-kit' -import { generateTransferCallData } from '@safe-global/relay-kit/packs/safe-4337/testing-utils/helpers' +import { + generateTransferCallData, + ENTRYPOINT_ADDRESS_V06, + 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' -// 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' -import { - ENTRYPOINT_ADDRESS_V06, - RPC_4337_CALLS -} from '@safe-global/relay-kit/packs/safe-4337/constants' chai.use(chaiAsPromised) chai.use(sinonChai) @@ -73,7 +73,7 @@ describe('confirmSafeOperation', () => { const requestStub = sinon.stub() before(async () => { - sinon.stub(safe4337Utils, 'getEip4337BundlerProvider').returns({ + sinon.stub(utils, 'getEip4337BundlerProvider').returns({ request: requestStub } as unknown as BundlerClient) diff --git a/packages/protocol-kit/package.json b/packages/protocol-kit/package.json index 39d3083b2..f131f533c 100644 --- a/packages/protocol-kit/package.json +++ b/packages/protocol-kit/package.json @@ -3,12 +3,19 @@ "version": "5.0.4", "description": "SDK that facilitates the interaction with Safe Smart Accounts", "types": "dist/src/index.d.ts", - "main": "dist/cjs/index.cjs", - "module": "dist/esm/index.mjs", + "main": "dist/cjs/src/index.cjs", + "module": "dist/esm/src/index.mjs", "exports": { - "types": "./dist/src/index.d.ts", - "require": "./dist/cjs/index.cjs", - "import": "./dist/esm/index.mjs" + ".": { + "types": "./dist/src/index.d.ts", + "require": "./dist/cjs/src/index.cjs", + "import": "./dist/esm/src/index.mjs" + }, + "./test-utils": { + "types": "./dist/test-utils/index.d.ts", + "require": "./dist/cjs/test-utils/index.cjs", + "import": "./dist/esm/test-utils/index.mjs" + } }, "keywords": [ "Ethereum", @@ -42,8 +49,8 @@ "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", "unbuild": "rimraf dist artifacts deployments cache .nyc_output *.tsbuildinfo", "build": "yarn unbuild && yarn check-safe-deployments && yarn build:esm && yarn build:cjs && yarn build:types", - "build:esm": "esbuild ./src/index --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", - "build:cjs": "esbuild ./src/index --format=cjs --bundle --packages=external --outdir=dist/cjs --out-extension:.js=.cjs", + "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" }, "repository": { diff --git a/packages/protocol-kit/test-utils/index.ts b/packages/protocol-kit/test-utils/index.ts new file mode 100644 index 000000000..cc35fc2ca --- /dev/null +++ b/packages/protocol-kit/test-utils/index.ts @@ -0,0 +1,2 @@ +export * from './passkeys' +export * from './webauthnShim' diff --git a/packages/protocol-kit/tests/e2e/utils/passkeys.ts b/packages/protocol-kit/test-utils/passkeys.ts similarity index 94% rename from packages/protocol-kit/tests/e2e/utils/passkeys.ts rename to packages/protocol-kit/test-utils/passkeys.ts index 0aa1c1bf0..6db62ad92 100644 --- a/packages/protocol-kit/tests/e2e/utils/passkeys.ts +++ b/packages/protocol-kit/test-utils/passkeys.ts @@ -1,11 +1,7 @@ -import { - PasskeyArgType, - PasskeyClient, - extractPasskeyCoordinates -} from '@safe-global/protocol-kit/index' +import { PasskeyArgType, PasskeyClient, extractPasskeyCoordinates } from '../src' +import { asHex } from '../src/utils/types' import { WebAuthnCredentials } from './webauthnShim' import { WalletClient, keccak256, toBytes, Transport, Chain, Account } from 'viem' -import { asHex } from '@safe-global/protocol-kit/utils/types' let singleInstance: WebAuthnCredentials diff --git a/packages/protocol-kit/tests/e2e/utils/webauthnShim.ts b/packages/protocol-kit/test-utils/webauthnShim.ts similarity index 100% rename from packages/protocol-kit/tests/e2e/utils/webauthnShim.ts rename to packages/protocol-kit/test-utils/webauthnShim.ts diff --git a/packages/protocol-kit/tests/e2e/passkey.test.ts b/packages/protocol-kit/tests/e2e/passkey.test.ts index a8ba67645..7be0e1762 100644 --- a/packages/protocol-kit/tests/e2e/passkey.test.ts +++ b/packages/protocol-kit/tests/e2e/passkey.test.ts @@ -23,7 +23,11 @@ import { } from '@safe-global/protocol-kit/contracts/safeDeploymentContracts' import { getEip1193Provider } from './utils/setupProvider' import { waitSafeTxReceipt } from './utils/transactions' -import { createMockPasskey, getWebAuthnCredentials, deployPasskeysContract } from './utils/passkeys' +import { + createMockPasskey, + getWebAuthnCredentials, + deployPasskeysContract +} from '@safe-global/protocol-kit/test-utils' chai.use(chaiAsPromised) chai.use(sinonChai) diff --git a/packages/protocol-kit/tests/e2e/safeProvider.test.ts b/packages/protocol-kit/tests/e2e/safeProvider.test.ts index 089b01ac4..60bd7e67a 100644 --- a/packages/protocol-kit/tests/e2e/safeProvider.test.ts +++ b/packages/protocol-kit/tests/e2e/safeProvider.test.ts @@ -5,7 +5,7 @@ import { getEip1193Provider } from './utils/setupProvider' import { SafeProvider } from '@safe-global/protocol-kit/index' import sinon from 'sinon' import sinonChai from 'sinon-chai' -import { createMockPasskey, getWebAuthnCredentials } from './utils/passkeys' +import { createMockPasskey, getWebAuthnCredentials } from '@safe-global/protocol-kit/test-utils' import { publicActions, walletActions } from 'viem' chai.use(chaiAsPromised) diff --git a/packages/protocol-kit/tsconfig.build.json b/packages/protocol-kit/tsconfig.build.json index 00513d17b..1a132aac0 100644 --- a/packages/protocol-kit/tsconfig.build.json +++ b/packages/protocol-kit/tsconfig.build.json @@ -4,8 +4,8 @@ "declaration": true, "emitDeclarationOnly": true, "declarationMap": true, - "outDir": "dist/src" + "outDir": "dist" }, - "include": ["src/**/*"], + "include": ["src/**/*", "test-utils/**/*"], "exclude": ["dist", "test"] } diff --git a/packages/relay-kit/jest.config.js b/packages/relay-kit/jest.config.js index fdc6f4885..0934a355c 100644 --- a/packages/relay-kit/jest.config.js +++ b/packages/relay-kit/jest.config.js @@ -6,7 +6,7 @@ const config = { }, moduleNameMapper: { '^@safe-global/protocol-kit/tests/(.*)$': '/../protocol-kit/tests/$1', - '^@safe-global/protocol-kit/(.*)$': '/../protocol-kit/src/$1', + '^@safe-global/relay-kit/test-utils$': '/test-utils', '^@safe-global/relay-kit/(.*)$': '/src/$1' }, testTimeout: 20000 diff --git a/packages/relay-kit/package.json b/packages/relay-kit/package.json index b816b6ff4..aaa489dd6 100644 --- a/packages/relay-kit/package.json +++ b/packages/relay-kit/package.json @@ -3,12 +3,24 @@ "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/index.cjs", - "module": "dist/esm/index.mjs", + "main": "dist/cjs/src/index.js", + "module": "dist/esm/src/index.js", "exports": { - "types": "./dist/src/index.d.ts", - "require": "./dist/cjs/index.cjs", - "import": "./dist/esm/index.mjs" + ".": { + "types": "./dist/src/index.d.ts", + "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.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": [ "Ethereum", @@ -26,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 --format=esm --bundle --packages=external --outdir=dist/esm --out-extension:.js=.mjs", - "build:cjs": "esbuild ./src/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/src/packs/safe-4337/Safe4337Pack.test.ts b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts index 117d32fe8..273151250 100644 --- a/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts +++ b/packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts @@ -2,8 +2,7 @@ import crypto from 'crypto' import dotenv from 'dotenv' import * as viem from 'viem' import Safe, * as protocolKit from '@safe-global/protocol-kit' -import { WebAuthnCredentials } from '@safe-global/protocol-kit/tests/e2e/utils/webauthnShim' -import { createMockPasskey } from '@safe-global/protocol-kit/tests/e2e/utils/passkeys' +import { WebAuthnCredentials, createMockPasskey } from '@safe-global/protocol-kit/test-utils' import { getAddModulesLibDeployment, getSafe4337ModuleDeployment @@ -12,9 +11,12 @@ import { MetaTransactionData, OperationType } from '@safe-global/types-kit' import { Safe4337Pack } from './Safe4337Pack' import EthSafeOperation from './SafeOperation' import * as constants from './constants' -import * as fixtures from './testing-utils/fixtures' -import { createSafe4337Pack, generateTransferCallData } from './testing-utils/helpers' import * as utils from './utils' +import { + fixtures, + createSafe4337Pack, + generateTransferCallData +} from '@safe-global/relay-kit/test-utils' dotenv.config() diff --git a/packages/relay-kit/src/packs/safe-4337/SafeOperation.test.ts b/packages/relay-kit/src/packs/safe-4337/SafeOperation.test.ts index 9ea2645dd..6dd6753ce 100644 --- a/packages/relay-kit/src/packs/safe-4337/SafeOperation.test.ts +++ b/packages/relay-kit/src/packs/safe-4337/SafeOperation.test.ts @@ -1,7 +1,7 @@ import { Hex, encodePacked } from 'viem' import { EthSafeSignature } from '@safe-global/protocol-kit' import EthSafeOperation from './SafeOperation' -import * as fixtures from './testing-utils/fixtures' +import { fixtures } from '@safe-global/relay-kit/test-utils' describe('SafeOperation', () => { it('should create a SafeOperation from an UserOperation', () => { diff --git a/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.test.ts b/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.test.ts index c6f263ef7..0d5e3d9d0 100644 --- a/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.test.ts +++ b/packages/relay-kit/src/packs/safe-4337/estimators/PimlicoFeeEstimator.test.ts @@ -1,5 +1,5 @@ import { PimlicoFeeEstimator } from './PimlicoFeeEstimator' -import * as fixtures from '../testing-utils/fixtures' +import { fixtures } from '@safe-global/relay-kit/test-utils' import * as constants from '../constants' jest.mock('../utils', () => ({ diff --git a/packages/relay-kit/src/packs/safe-4337/testing-utils/fixtures.ts b/packages/relay-kit/test-utils/fixtures.ts similarity index 99% rename from packages/relay-kit/src/packs/safe-4337/testing-utils/fixtures.ts rename to packages/relay-kit/test-utils/fixtures.ts index 706238353..f937a0036 100644 --- a/packages/relay-kit/src/packs/safe-4337/testing-utils/fixtures.ts +++ b/packages/relay-kit/test-utils/fixtures.ts @@ -1,4 +1,4 @@ -import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from '../constants' +import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from '../src/packs/safe-4337/constants' export const OWNER_1 = '0xFfAC5578BE8AC1B2B9D13b34cAf4A074B96B8A1b' export const OWNER_2 = '0x3059EfD1BCe33be41eeEfd5fb6D520d7fEd54E43' diff --git a/packages/relay-kit/src/packs/safe-4337/testing-utils/helpers.ts b/packages/relay-kit/test-utils/helpers.ts similarity index 87% rename from packages/relay-kit/src/packs/safe-4337/testing-utils/helpers.ts rename to packages/relay-kit/test-utils/helpers.ts index 15f7d29f6..539ca1003 100644 --- a/packages/relay-kit/src/packs/safe-4337/testing-utils/helpers.ts +++ b/packages/relay-kit/test-utils/helpers.ts @@ -1,6 +1,6 @@ import { encodeFunctionData, parseAbi } from 'viem' -import { Safe4337InitOptions } from '../types' -import { Safe4337Pack } from '../Safe4337Pack' +import { Safe4337InitOptions } from '../src/packs/safe-4337/types' +import { Safe4337Pack } from '../src/packs/safe-4337/Safe4337Pack' import * as fixtures from './fixtures' export const generateTransferCallData = (to: string, value: bigint) => { diff --git a/packages/relay-kit/test-utils/index.ts b/packages/relay-kit/test-utils/index.ts new file mode 100644 index 000000000..d9baaeb65 --- /dev/null +++ b/packages/relay-kit/test-utils/index.ts @@ -0,0 +1,7 @@ +export * as fixtures from './fixtures' +export * from './helpers' +export { + ENTRYPOINT_ABI, + ENTRYPOINT_ADDRESS_V06, + RPC_4337_CALLS +} from '../src/packs/safe-4337/constants' diff --git a/packages/relay-kit/tsconfig.build.json b/packages/relay-kit/tsconfig.build.json index fb93df610..a49ad22fa 100644 --- a/packages/relay-kit/tsconfig.build.json +++ b/packages/relay-kit/tsconfig.build.json @@ -1,11 +1,8 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "declarationMap": true, - "outDir": "dist/src" + "outDir": "dist" }, - "include": ["src/**/*"], + "include": ["src/**/*", "test-utils/**/*"], "exclude": ["dist", "src/**/*.test.ts", "src/**/*.test-d.ts"] } diff --git a/packages/testing-kit/bin/testing-kit.js b/packages/testing-kit/bin/testing-kit.js index bbc371e4c..33cb85ff4 100755 --- a/packages/testing-kit/bin/testing-kit.js +++ b/packages/testing-kit/bin/testing-kit.js @@ -37,6 +37,8 @@ if (!fs.existsSync(hardhatConfigPath)) { } try { + process.env.TS_NODE_PROJECT = `${projectRoot}/tsconfig.json` + if (command === 'test' && directory) { execSync(`yarn ${command} ${path.join(projectRoot, directory)}`, { stdio: 'inherit' }) } else { diff --git a/packages/testing-kit/package.json b/packages/testing-kit/package.json index 062dd1cd5..6e61bdb6b 100644 --- a/packages/testing-kit/package.json +++ b/packages/testing-kit/package.json @@ -2,11 +2,11 @@ "name": "@safe-global/testing-kit", "version": "0.1.1", "description": "Helper package providing testing utilities", - "types": "dist/src/index.d.ts", + "types": "dist/src/src/index.d.ts", "main": "dist/cjs/index.cjs", "module": "dist/esm/index.mjs", "exports": { - "types": "./dist/src/index.d.ts", + "types": "./dist/src/src/index.d.ts", "require": "./dist/cjs/index.cjs", "import": "./dist/esm/index.mjs" },