Skip to content

Commit

Permalink
Merge pull request #1047 from frontendphil/development
Browse files Browse the repository at this point in the history
chore: update build for the whole repo
  • Loading branch information
dasanra authored Nov 15, 2024
2 parents 32b408b + 2acda8f commit 2e3a569
Show file tree
Hide file tree
Showing 36 changed files with 370 additions and 97 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}": [
Expand Down
16 changes: 13 additions & 3 deletions packages/api-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 && tsc-alias -p tsconfig.build.json"
},
"repository": {
"type": "git",
Expand All @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions packages/api-kit/tests/e2e/addSafeOperation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions packages/api-kit/tests/e2e/confirmSafeOperation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
11 changes: 7 additions & 4 deletions packages/api-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"extends": "../../tsconfig.settings.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "dist"
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true,
"outDir": "dist/src"
},
"include": ["src/**/*"]
"include": ["src/**/*"],
"exclude": ["dist", "test"]
}
9 changes: 6 additions & 3 deletions packages/api-kit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
21 changes: 19 additions & 2 deletions packages/protocol-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@
"name": "@safe-global/protocol-kit",
"version": "5.0.4",
"description": "SDK that facilitates the interaction with Safe Smart Accounts",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"main": "dist/cjs/src/index.cjs",
"module": "dist/esm/src/index.mjs",
"exports": {
".": {
"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",
"Wallet",
Expand Down Expand Up @@ -35,7 +48,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 ./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": {
"type": "git",
Expand All @@ -59,6 +75,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",
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol-kit/test-utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './passkeys'
export * from './webauthnShim'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PasskeyArgType, PasskeyClient, extractPasskeyCoordinates } from '@safe-global/protocol-kit'
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

Expand Down
6 changes: 5 additions & 1 deletion packages/protocol-kit/tests/e2e/passkey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-kit/tests/e2e/safeProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions packages/protocol-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"extends": "../../tsconfig.settings.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true,
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true,
"outDir": "dist"
},
"include": ["src/**/*"]
"include": ["src/**/*", "test-utils/**/*"],
"exclude": ["dist", "test"]
}
9 changes: 6 additions & 3 deletions packages/protocol-kit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion packages/relay-kit/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config = {
},
moduleNameMapper: {
'^@safe-global/protocol-kit/tests/(.*)$': '<rootDir>/../protocol-kit/tests/$1',
'^@safe-global/protocol-kit/(.*)$': '<rootDir>/../protocol-kit/src/$1',
'^@safe-global/relay-kit/test-utils$': '<rootDir>/test-utils',
'^@safe-global/relay-kit/(.*)$': '<rootDir>/src/$1'
},
testTimeout: 20000
Expand Down
30 changes: 27 additions & 3 deletions packages/relay-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@
"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/src/index.js",
"module": "dist/esm/src/index.js",
"exports": {
".": {
"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",
"Wallet",
Expand All @@ -19,7 +37,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": "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 All @@ -43,5 +64,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"
}
}
10 changes: 6 additions & 4 deletions packages/relay-kit/src/packs/safe-4337/Safe4337Pack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
7 changes: 7 additions & 0 deletions packages/relay-kit/test-utils/index.ts
Original file line number Diff line number Diff line change
@@ -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'
7 changes: 3 additions & 4 deletions packages/relay-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"extends": "../../tsconfig.settings.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "dist"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"]
"include": ["src/**/*", "test-utils/**/*"],
"exclude": ["dist", "src/**/*.test.ts", "src/**/*.test-d.ts"]
}
9 changes: 6 additions & 3 deletions packages/relay-kit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
Loading

0 comments on commit 2e3a569

Please sign in to comment.