Skip to content

Commit

Permalink
fix Generate getProtocolKitVersion dynamically via prebuild script (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniSomoza authored Jan 16, 2025
1 parent 6d75e96 commit fdfb6c7
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 26 deletions.
1 change: 1 addition & 0 deletions packages/protocol-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"",
"format": "prettier --write \"*/**/*.{js,json,md,ts}\"",
"unbuild": "rimraf dist artifacts deployments cache .nyc_output *.tsbuildinfo",
"prebuild": "node -p \"'export const getProtocolKitVersion = () => \\'' + require('./package.json').version.split('-')[0] + '\\''\" > src/utils/getProtocolKitVersion.ts",
"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"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-kit/src/Safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import { Hash, Hex, SendTransactionParameters } from 'viem'
import getPasskeyOwnerAddress from './utils/passkeys/getPasskeyOwnerAddress'
import createPasskeyDeploymentTransaction from './utils/passkeys/createPasskeyDeploymentTransaction'
import generateOnChainIdentifier from './utils/on-chain-tracking/generateOnChainIdentifier'
import getProtocolKitVersion from './utils/getProtocolKitVersion'
import { getProtocolKitVersion } from './utils/getProtocolKitVersion'

const EQ_OR_GT_1_4_1 = '>=1.4.1'
const EQ_OR_GT_1_3_0 = '>=1.3.0'
Expand Down
8 changes: 1 addition & 7 deletions packages/protocol-kit/src/utils/getProtocolKitVersion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import packageJson from '../../package.json'

function getProtocolKitVersion(): string {
return packageJson.version
}

export default getProtocolKitVersion
export const getProtocolKitVersion = () => '5.1.1'
5 changes: 3 additions & 2 deletions packages/protocol-kit/tests/e2e/onChainIdentifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Sinon from 'sinon'
import chaiAsPromised from 'chai-as-promised'

import { generateHash } from '@safe-global/protocol-kit/utils/on-chain-tracking/generateOnChainIdentifier'
import getProtocolKitVersion, * as getProtocolKitVersionModule from '@safe-global/protocol-kit/utils/getProtocolKitVersion'
import * as getProtocolKitVersionModule from '@safe-global/protocol-kit/utils/getProtocolKitVersion'
import { getProtocolKitVersion } from '@safe-global/protocol-kit/utils/getProtocolKitVersion'
import { getEip1193Provider } from './utils/setupProvider'
import { waitSafeTxReceipt } from './utils/transactions'

Expand Down Expand Up @@ -47,7 +48,7 @@ describe('On-chain analytics', () => {
platform: 'Web'
}

const stub = Sinon.stub(getProtocolKitVersionModule, 'default').returns('5.0.4')
const stub = Sinon.stub(getProtocolKitVersionModule, 'getProtocolKitVersion').returns('5.0.4')

const { safe, contractNetworks } = await setupTests()
const safeAddress = safe.address
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"resolveJsonModule": true,
"composite": true,
"outDir": "dist"
},
"include": ["src/**/*", "package.json"]
"include": ["src/**/*"]
}
3 changes: 1 addition & 2 deletions packages/protocol-kit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"resolveJsonModule": true,
"composite": true,
"outDir": "dist"
},
"include": ["package.json", "src/**/*", "tests/**/*", "hardhat/**/*", "hardhat.config.ts"]
"include": ["src/**/*", "tests/**/*", "hardhat/**/*", "hardhat.config.ts"]
}
1 change: 1 addition & 0 deletions packages/relay-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"",
"format": "prettier --write \"*/**/*.{js,json,md,ts}\"",
"unbuild": "rimraf dist .nyc_output cache",
"prebuild": "node -p \"'export const getRelayKitVersion = () => \\'' + require('./package.json').version.split('-')[0] + '\\''\" > src/packs/safe-4337/utils/getRelayKitVersion.ts",
"build": "yarn unbuild && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
} from './utils'
import { entryPointToSafeModules, EQ_OR_GT_0_3_0 } from './utils/entrypoint'
import { PimlicoFeeEstimator } from './estimators/PimlicoFeeEstimator'
import getRelayKitVersion from './utils/getRelayKitVersion'
import { getRelayKitVersion } from './utils/getRelayKitVersion'

const MAX_ERC20_AMOUNT_TO_APPROVE =
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import packageJson from '../../../../package.json'

function getRelayKitVersion(): string {
return packageJson.version
}

export default getRelayKitVersion
export const getRelayKitVersion = () => '3.3.1'
3 changes: 1 addition & 2 deletions packages/relay-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"resolveJsonModule": true,
"composite": true,
"outDir": "dist"
},
"include": ["src/**/*", "package.json"],
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"]
}
3 changes: 1 addition & 2 deletions packages/relay-kit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"resolveJsonModule": true,
"composite": true,
"outDir": "dist"
},
"include": ["src/**/*", "package.json"]
"include": ["src/**/*"]
}

0 comments on commit fdfb6c7

Please sign in to comment.