diff --git a/cypress/e2e/prodhealthcheck/tx_history.cy.js b/cypress/e2e/prodhealthcheck/tx_history.cy.js index 77482c11f7..8cd2dcfbd5 100644 --- a/cypress/e2e/prodhealthcheck/tx_history.cy.js +++ b/cypress/e2e/prodhealthcheck/tx_history.cy.js @@ -27,7 +27,7 @@ describe('Tx history tests 1', () => { constants.stagingCGWSafes }${staticSafes.SEP_STATIC_SAFE_7.substring(4)}/transactions/history**`, (req) => { - req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone_offset=7200000&trusted=false&cursor=limit=100&offset=1` + req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone=Europe/Berlin&trusted=false&cursor=limit=100&offset=1` req.continue() }, ).as('allTransactions') diff --git a/cypress/e2e/prodhealthcheck/tx_history_2.cy.js b/cypress/e2e/prodhealthcheck/tx_history_2.cy.js index aa7bd17692..faa6f50bf0 100644 --- a/cypress/e2e/prodhealthcheck/tx_history_2.cy.js +++ b/cypress/e2e/prodhealthcheck/tx_history_2.cy.js @@ -30,7 +30,7 @@ describe('Tx history tests 2', () => { constants.stagingCGWSafes }${staticSafes.SEP_STATIC_SAFE_7.substring(4)}/transactions/history**`, (req) => { - req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone_offset=7200000&trusted=false&cursor=limit=100&offset=1` + req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone=Europe/Berlin&trusted=false&cursor=limit=100&offset=1` req.continue() }, ).as('allTransactions') diff --git a/cypress/e2e/regression/tx_history.cy.js b/cypress/e2e/regression/tx_history.cy.js index eb154b0d6a..d528a9a925 100644 --- a/cypress/e2e/regression/tx_history.cy.js +++ b/cypress/e2e/regression/tx_history.cy.js @@ -27,7 +27,7 @@ describe('Tx history tests 1', () => { constants.stagingCGWSafes }${staticSafes.SEP_STATIC_SAFE_7.substring(4)}/transactions/history**`, (req) => { - req.url = `https://safe-client.staging.5afe.dev/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone_offset=7200000&trusted=false&cursor=limit=100&offset=1` + req.url = `https://safe-client.staging.5afe.dev/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone=Europe/Berlin&trusted=false&cursor=limit=100&offset=1` req.continue() }, ).as('allTransactions') diff --git a/cypress/e2e/regression/tx_history_2.cy.js b/cypress/e2e/regression/tx_history_2.cy.js index 409250449f..4d36ce8c02 100644 --- a/cypress/e2e/regression/tx_history_2.cy.js +++ b/cypress/e2e/regression/tx_history_2.cy.js @@ -30,7 +30,7 @@ describe('Tx history tests 2', () => { constants.stagingCGWSafes }${staticSafes.SEP_STATIC_SAFE_7.substring(4)}/transactions/history**`, (req) => { - req.url = `https://safe-client.staging.5afe.dev/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone_offset=7200000&trusted=false&cursor=limit=100&offset=1` + req.url = `https://safe-client.staging.5afe.dev/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone=Europe/Berlin&trusted=false&cursor=limit=100&offset=1` req.continue() }, ).as('allTransactions') diff --git a/cypress/support/utils/txquery.js b/cypress/support/utils/txquery.js index c4845de5ff..844501610b 100644 --- a/cypress/support/utils/txquery.js +++ b/cypress/support/utils/txquery.js @@ -9,7 +9,7 @@ function buildQueryUrl({ chainId, safeAddress, transactionType, ...params }) { const defaultParams = { safe: `sep:${safeAddress}`, - timezone_offset: '7200000', + timezone: 'Europe/Berlin', trusted: 'false', } diff --git a/package.json b/package.json index f2adfc11cb..939757ef4e 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@safe-global/protocol-kit": "^4.1.0", "@safe-global/safe-apps-sdk": "^9.1.0", "@safe-global/safe-deployments": "^1.37.3", - "@safe-global/safe-gateway-typescript-sdk": "3.22.2", + "@safe-global/safe-gateway-typescript-sdk": "3.22.4-beta.1", "@safe-global/safe-modules-deployments": "^1.2.0", "@sentry/react": "^7.91.0", "@spindl-xyz/attribution-lite": "^1.4.0", diff --git a/src/services/transactions/index.tests.ts b/src/services/transactions/index.tests.ts index 7b2634e075..d0310a8db0 100644 --- a/src/services/transactions/index.tests.ts +++ b/src/services/transactions/index.tests.ts @@ -1,8 +1,9 @@ -import { getTimezoneOffset } from '.' +import { getTimezone } from '.' -describe('getTimezoneOffset', () => { - it('should return timezone offset in milliseconds', () => { - const CET = 60 * 60 * 1000 // tests are run in CET - expect(getTimezoneOffset()).toBe(-CET) +describe('getTimezone', () => { + it('should return timezone', () => { + const result = getTimezone() + + expect(result).toBeDefined() }) }) diff --git a/src/services/transactions/index.ts b/src/services/transactions/index.ts index bf4d7a39b1..9712dc9d89 100644 --- a/src/services/transactions/index.ts +++ b/src/services/transactions/index.ts @@ -1,6 +1,6 @@ import { getModuleTransactions, getTransactionHistory } from '@safe-global/safe-gateway-typescript-sdk' -export const getTimezoneOffset = () => new Date().getTimezoneOffset() * 60 * -1000 +export const getTimezone = () => Intl.DateTimeFormat().resolvedOptions().timeZone export const getTxHistory = ( chainId: string, @@ -13,7 +13,7 @@ export const getTxHistory = ( chainId, safeAddress, { - timezone_offset: getTimezoneOffset(), // used for grouping txs by date + timezone: getTimezone(), // used for grouping txs by date // Untrusted and imitation txs are filtered together in the UI trusted: hideUntrustedTxs, // if false, include transactions marked untrusted in the UI imitation: !hideImitationTxs, // If true, include transactions marked imitation in the UI diff --git a/src/utils/__tests__/tx-history-filter.test.ts b/src/utils/__tests__/tx-history-filter.test.ts index 1c06e308f1..a2efaafd7a 100644 --- a/src/utils/__tests__/tx-history-filter.test.ts +++ b/src/utils/__tests__/tx-history-filter.test.ts @@ -19,6 +19,7 @@ import { import { renderHook } from '@/tests/test-utils' import type { NextRouter } from 'next/router' import { type TxFilterFormState } from '@/components/transactions/TxFilterForm' +import { getTimezone } from '@/services/transactions' MockDate.set('2021-01-01T00:00:00.000Z') @@ -395,7 +396,7 @@ describe('tx-history-filter', () => { expect(getIncomingTransfers).toHaveBeenCalledWith( '4', '0x123', - { value: '123', executed: undefined, timezone_offset: 3600000, trusted: false, imitation: true }, + { value: '123', executed: undefined, timezone: getTimezone(), trusted: false, imitation: true }, 'pageUrl1', ) @@ -422,7 +423,7 @@ describe('tx-history-filter', () => { { execution_date__gte: '1970-01-01T00:00:00.000Z', executed: 'true', - timezone_offset: 3600000, + timezone: getTimezone(), trusted: false, imitation: true, }, @@ -446,7 +447,7 @@ describe('tx-history-filter', () => { expect(getModuleTransactions).toHaveBeenCalledWith( '1', '0x789', - { to: '0x123', executed: undefined, timezone_offset: 3600000, trusted: false, imitation: true }, + { to: '0x123', executed: undefined, timezone: getTimezone(), trusted: false, imitation: true }, 'pageUrl3', ) diff --git a/src/utils/tx-history-filter.ts b/src/utils/tx-history-filter.ts index 016d1cd0f7..e6f4b8e1db 100644 --- a/src/utils/tx-history-filter.ts +++ b/src/utils/tx-history-filter.ts @@ -12,7 +12,7 @@ import { startOfDay, endOfDay } from 'date-fns' import type { TxFilterFormState } from '@/components/transactions/TxFilterForm' import { safeFormatUnits, safeParseUnits } from '@/utils/formatters' -import { getTimezoneOffset } from '@/services/transactions' +import { getTimezone } from '@/services/transactions' type IncomingTxFilter = NonNullable type MultisigTxFilter = NonNullable @@ -126,7 +126,7 @@ export const fetchFilteredTxHistory = async ( const fetchPage = () => { const query = { ...filterData.filter, - timezone_offset: getTimezoneOffset(), + timezone: getTimezone(), trusted: hideUntrustedTxs, imitation: !hideImitationTxs, executed: filterData.type === TxFilterType.MULTISIG ? 'true' : undefined, diff --git a/yarn.lock b/yarn.lock index 29c9a0c59f..2039d231b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4183,10 +4183,10 @@ dependencies: semver "^7.6.2" -"@safe-global/safe-gateway-typescript-sdk@3.22.2": - version "3.22.2" - resolved "https://registry.yarnpkg.com/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.22.2.tgz#d4ff9972e58f9344fc95f8d41b2ec6517baa8e79" - integrity sha512-Y0yAxRaB98LFp2Dm+ACZqBSdAmI3FlpH/LjxOZ94g/ouuDJecSq0iR26XZ5QDuEL8Rf+L4jBJaoDC08CD0KkJw== +"@safe-global/safe-gateway-typescript-sdk@3.22.4-beta.1": + version "3.22.4-beta.1" + resolved "https://registry.yarnpkg.com/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.22.4-beta.1.tgz#ef8d0506d8c747124fae721a9baf99dda71af189" + integrity sha512-adxHiSeUc47MqkW7BM50U5xy6144rDEf0jyftzGXrBkG+nv/oL55SZQ/DdAsxyI1Mns02gzawa3Up+MfA8SKCQ== "@safe-global/safe-gateway-typescript-sdk@^3.5.3": version "3.21.2"