Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/dedupe-refinement…
Browse files Browse the repository at this point in the history
…-logs
  • Loading branch information
iamacook committed Mar 3, 2025
2 parents 4fcdd52 + 835c120 commit dbcaec9
Show file tree
Hide file tree
Showing 14 changed files with 898 additions and 750 deletions.
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ compressionLevel: mixed

enableGlobalCache: false

enableScripts: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.1.cjs
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
#
FROM node:22.14.0 as base
ENV NODE_ENV production
ENV YARN_CACHE_FOLDER /root/.yarn
WORKDIR /app
COPY --chown=node:node .yarn/releases ./.yarn/releases
COPY --chown=node:node package.json yarn.lock .yarnrc.yml tsconfig*.json ./
COPY --chown=node:node scripts/generate-abis.js ./scripts/generate-abis.js
RUN --mount=type=cache,target=/root/.yarn yarn
COPY --chown=node:node assets ./assets
COPY --chown=node:node migrations ./migrations
COPY --chown=node:node src ./src
RUN --mount=type=cache,target=/root/.yarn yarn run build \
&& rm -rf ./node_modules \
&& yarn workspaces focus --production
RUN yarn install --immutable \
&& yarn run build \
&& rm -rf ./node_modules \
&& yarn workspaces focus --production

#
# PRODUCTION CONTAINER
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Safe Ecosystem Foundation
Copyright (c) 2022-2025 Safe Ecosystem Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
108 changes: 54 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,66 +30,66 @@
"migration:revert": "yarn typeorm migration:revert"
},
"dependencies": {
"@aws-sdk/client-kms": "^3.750.0",
"@aws-sdk/client-s3": "^3.750.0",
"@fingerprintjs/fingerprintjs-pro-server-api": "^6.1.0",
"@nestjs/cli": "^10.4.9",
"@nestjs/common": "^11.0.10",
"@nestjs/config": "^4.0.0",
"@nestjs/core": "^11.0.10",
"@nestjs/platform-express": "^11.0.10",
"@nestjs/schedule": "^5.0.1",
"@nestjs/serve-static": "^5.0.1",
"@nestjs/swagger": "^11.0.3",
"@nestjs/typeorm": "^11.0.0",
"@safe-global/safe-deployments": "^1.37.30",
"amqp-connection-manager": "^4.1.14",
"amqplib": "^0.10.5",
"cookie-parser": "^1.4.7",
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"nestjs-cls": "^4.5.0",
"pg": "^8.13.3",
"postgres": "^3.4.5",
"redis": "^4.7.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"sanitize-html": "^2.14.0",
"semver": "^7.6.3",
"typeorm": "^0.3.20",
"viem": "^2.22.8",
"winston": "^3.17.0",
"zod": "^3.24.1"
"@aws-sdk/client-kms": "3.750.0",
"@aws-sdk/client-s3": "3.750.0",
"@fingerprintjs/fingerprintjs-pro-server-api": "6.1.0",
"@nestjs/cli": "11.0.4",
"@nestjs/common": "11.0.10",
"@nestjs/config": "4.0.0",
"@nestjs/core": "11.0.10",
"@nestjs/platform-express": "11.0.10",
"@nestjs/schedule": "5.0.1",
"@nestjs/serve-static": "5.0.3",
"@nestjs/swagger": "11.0.3",
"@nestjs/typeorm": "11.0.0",
"@safe-global/safe-deployments": "1.37.30",
"amqp-connection-manager": "4.1.14",
"amqplib": "0.10.5",
"cookie-parser": "1.4.7",
"jsonwebtoken": "9.0.2",
"lodash": "4.17.21",
"nestjs-cls": "5.4.0",
"pg": "8.13.3",
"postgres": "3.4.5",
"redis": "4.7.0",
"reflect-metadata": "0.2.2",
"rxjs": "7.8.1",
"sanitize-html": "2.14.0",
"semver": "7.6.3",
"typeorm": "0.3.20",
"viem": "2.22.8",
"winston": "3.17.0",
"zod": "3.24.1"
},
"devDependencies": {
"@faker-js/faker": "^9.3.0",
"@nestjs/schematics": "^11.0.0",
"@nestjs/testing": "^11.0.10",
"@smithy/util-stream": "^4.0.2",
"@types/amqplib": "^0",
"@types/cookie-parser": "^1.4.8",
"@types/express": "^5.0.0",
"@faker-js/faker": "9.3.0",
"@nestjs/schematics": "11.0.0",
"@nestjs/testing": "11.0.10",
"@smithy/util-stream": "4.1.2",
"@types/amqplib": "0",
"@types/cookie-parser": "1.4.8",
"@types/express": "5.0.0",
"@types/jest": "29.5.14",
"@types/jsonwebtoken": "^9",
"@types/lodash": "^4.17.14",
"@types/node": "^22.13.1",
"@types/sanitize-html": "^2",
"@types/semver": "^7.5.8",
"@types/supertest": "^6.0.2",
"aws-sdk-client-mock": "^4.1.0",
"eslint": "^9.20.1",
"eslint-config-prettier": "^10.0.1",
"husky": "^9.1.7",
"@types/jsonwebtoken": "9",
"@types/lodash": "4.17.14",
"@types/node": "22.13.5",
"@types/sanitize-html": "2",
"@types/semver": "7.5.8",
"@types/supertest": "6.0.2",
"aws-sdk-client-mock": "4.1.0",
"eslint": "9.20.1",
"eslint-config-prettier": "10.0.1",
"husky": "9.1.7",
"jest": "29.7.0",
"prettier": "^3.5.0",
"source-map-support": "^0.5.20",
"supertest": "^7.0.0",
"prettier": "3.5.0",
"source-map-support": "0.5.20",
"supertest": "7.0.0",
"ts-jest": "29.2.5",
"ts-loader": "^9.5.2",
"ts-node": "^10.9.2",
"ts-loader": "9.5.2",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.19.0"
"typescript": "5.7.2",
"typescript-eslint": "8.19.0"
},
"jest": {
"moduleFileExtensions": [
Expand Down
23 changes: 19 additions & 4 deletions src/domain/common/utils/__tests__/safe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ describe('Safe', () => {
'safeTxGas',
'baseGas',
'gasPrice',
'gasToken',
'refundReceiver',
])('should throw if the %s is not present', (key) => {
const chainId = faker.string.numeric();
const safe = safeBuilder().build();
Expand Down Expand Up @@ -304,12 +302,29 @@ describe('Safe', () => {
expect(result.message.data).toEqual('0x');
});

it.each<keyof BaseMultisigTransaction>(['gasToken', 'refundReceiver'])(
'should default a missing %s to a zero address if not present',
(key) => {
const transaction = safeTxHashMultisigTransactionBuilder()
.with(key, null)
.build();
const version = faker.helpers.arrayElement(TYPES_WITH_BASEGAS_VERSIONS);

const result = _getSafeTxTypesAndMessage({
transaction,
version,
});

expect(result.message[key]).toEqual(
'0x0000000000000000000000000000000000000000',
);
},
);

it.each<keyof BaseMultisigTransaction>([
'safeTxGas',
'baseGas',
'gasPrice',
'gasToken',
'refundReceiver',
])('should throw if %s is not present', (key) => {
const transaction = safeTxHashMultisigTransactionBuilder()
.with(key, null)
Expand Down
30 changes: 11 additions & 19 deletions src/domain/common/utils/safe.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import semverSatisfies from 'semver/functions/satisfies';
import { hashMessage, hashTypedData, type TypedDataDefinition } from 'viem';
import {
hashMessage,
hashTypedData,
zeroAddress,
type TypedDataDefinition,
} from 'viem';
import { MessageSchema } from '@/domain/messages/entities/message.entity';
import type { MultisigTransaction } from '@/domain/safe/entities/multisig-transaction.entity';
import type { Safe } from '@/domain/safe/entities/safe.entity';
Expand Down Expand Up @@ -132,28 +137,15 @@ export function _getSafeTxTypesAndMessage(args: {
transaction: BaseMultisigTransaction;
version: NonNullable<Safe['version']>;
}) {
const {
to,
value,
operation,
safeTxGas,
baseGas,
gasPrice,
gasToken,
refundReceiver,
nonce,
} = args.transaction;
const { to, value, operation, safeTxGas, baseGas, gasPrice, nonce } =
args.transaction;

// Transfer of funds has no data
const data = args.transaction.data || '0x';
const gasToken = args.transaction.gasToken || zeroAddress;
const refundReceiver = args.transaction.refundReceiver || zeroAddress;

if (
safeTxGas === null ||
baseGas === null ||
gasPrice === null ||
gasToken === null ||
refundReceiver === null
) {
if (safeTxGas === null || baseGas === null || gasPrice === null) {
throw new Error('Transaction data is incomplete');
}

Expand Down
10 changes: 5 additions & 5 deletions src/domain/common/utils/signatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ export function normalizeEthSignSignature(
return `0x${r.slice(2)}${s.slice(2)}${(v - ETH_SIGN_V_ADJUSTMENT).toString(16)}`;
}

export function isApprovedHashV(v: Signature['v']): boolean {
return v === 1;
}

export function isContractSignatureV(v: Signature['v']): boolean {
return v === 0;
}

export function isApprovedHashV(v: Signature['v']): boolean {
return v === 1;
}

export function isEoaV(v: Signature['v']): boolean {
return v === 27 || v === 28;
}

export function isEthSignV(v: Signature['v']): boolean {
return v === 31 || v === 32;
return v > 30;
}
9 changes: 9 additions & 0 deletions src/domain/hooks/helpers/event-cache.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ export class EventCacheHelper {
this.unsupportedChains = [];
}

@Cron(CronExpression.EVERY_MINUTE, {
disabled: process.env.NODE_ENV === 'test',
})
public clearSupportedChainsMemo(): void {
if (this.isSupportedChainMemo.cache.clear) {
this.isSupportedChainMemo.cache.clear();
}
}

// Transaction Service events

private onTransactionEventPendingMultisigTransaction(
Expand Down
Loading

0 comments on commit dbcaec9

Please sign in to comment.