Files
f28484ac04 feat(web): use backend as source of truth for counterfactual safes (#7875)
* feat(cf): counterfactual backend persistence

* fix(cf): normalize nullable address fields from CGW response

paymentReceiver, fallbackHandler, and to are nullable in the CGW
counterfactual-safes schema but typed as required strings downstream.
The previous code papered over this with an `as unknown as` cast,
which would surface null at runtime if the backend returned one.
Coerce null to ZERO_ADDRESS at the sync boundary instead.

* fix(cf): bounded retry, rollback-failure queue, multichain CF lookup

- useCounterfactualSafeSync: retry the CF sync once after a 2s backoff
  before settling cfSafeSynced=true. A single transient GET failure was
  leaving space-mates' CF safes unreachable via direct URL until sign-out.
- persistCounterfactualSafe: when the space POST and the rollback DELETE
  both fail, enqueue a pendingCfDelete so the next sync flushes the
  orphan instead of re-surfacing it as "Not activated".
- useSpaceAccountsData: search across all chains in a multichain group
  for a CF entry rather than only consulting safe.safes[0].chainId.

* fix(cf): address vmosharova review — schema-aligned DTO, deployed-safe loading, spaceId guard, shared session lifetime

- counterfactualSafeMapper: BackendCfSafeDto now marks fallbackHandler,
  to, paymentReceiver as `?: string | null` to match the CGW OpenAPI
  schema; fromBackendDto centralizes the null → ZERO_ADDRESS coercion
  so callers no longer need per-field normalization spreads.
- useLoadSafeInfo: `loading` no longer waits on CF sync once cgwData has
  arrived — deployed Safes render immediately even while the CF GET is
  in flight (or has 5xx-failed and is in its bounded retry window).
- parseSpaceId helper + call-site guards in useCounterfactualSafeSync
  and persistCounterfactualSafe so a non-numeric persisted lastUsedSpace
  skips the space-scoped API call instead of hitting it with NaN.
- SESSION_LIFETIME_MS exported from authSlice and reused across
  PayNowPayLater, SignInButton, useHomeAuth, and reconcileAuth to keep
  the 24h session window in sync.

---------

Co-authored-by: Hanzo Dev <[email protected]>
2026-05-22 10:18:31 +02:00

92 lines
2.9 KiB
TypeScript

import type { ConfigFile } from '@rtk-query/codegen-openapi'
const config: ConfigFile = {
schemaFile: './api-schema/schema.json',
prettierConfigFile: '../../../.prettierrc',
apiFile: '../src/gateway/cgwClient.ts',
apiImport: 'cgwClient',
exportName: 'cgwApi',
hooks: { queries: true, lazyQueries: true, mutations: true },
filterEndpoints: [/^(?!.*delegates).*/],
tag: true,
outputFiles: {
'../src/gateway/AUTO_GENERATED/about.ts': {
filterEndpoints: [/^about/],
},
'../src/gateway/AUTO_GENERATED/auth.ts': {
filterEndpoints: [/^(auth|oidcAuth)/],
},
'../src/gateway/AUTO_GENERATED/balances.ts': {
filterEndpoints: [/^balances/],
},
'../src/gateway/AUTO_GENERATED/chains.ts': {
filterEndpoints: [/^chains/],
},
'../src/gateway/AUTO_GENERATED/collectibles.ts': {
filterEndpoints: [/^collectibles/],
},
'../src/gateway/AUTO_GENERATED/community.ts': {
filterEndpoints: [/^community/],
},
'../src/gateway/AUTO_GENERATED/contracts.ts': {
filterEndpoints: [/^contracts/],
},
'../src/gateway/AUTO_GENERATED/data-decoded.ts': {
filterEndpoints: [/^dataDecoded/],
},
'../src/gateway/AUTO_GENERATED/delegates.ts': {
filterEndpoints: [/^delegates(?!DeleteSafeDelegateV1)/],
},
'../src/gateway/AUTO_GENERATED/estimations.ts': {
filterEndpoints: [/^estimations/],
},
'../src/gateway/AUTO_GENERATED/csv-export.ts': {
filterEndpoints: [/^csvExport/],
},
'../src/gateway/AUTO_GENERATED/messages.ts': {
filterEndpoints: [/^messages/],
},
'../src/gateway/AUTO_GENERATED/notifications.ts': {
filterEndpoints: [/^notifications/],
},
'../src/gateway/AUTO_GENERATED/owners.ts': {
filterEndpoints: [/^owners/],
},
'../src/gateway/AUTO_GENERATED/relay.ts': {
filterEndpoints: [/^relay/],
},
'../src/gateway/AUTO_GENERATED/safe-apps.ts': {
filterEndpoints: [/^safeApps/],
},
'../src/gateway/AUTO_GENERATED/safes.ts': {
filterEndpoints: [/^safes/],
},
'../src/gateway/AUTO_GENERATED/targeted-messages.ts': {
filterEndpoints: [/^targetedMessaging/],
},
'../src/gateway/AUTO_GENERATED/transactions.ts': {
filterEndpoints: [/^transactions/],
},
'../src/gateway/AUTO_GENERATED/users.ts': {
filterEndpoints: [/^users/],
},
'../src/gateway/AUTO_GENERATED/spaces.ts': {
filterEndpoints: [/^(spaces|members|spaceSafes|spaceCounterfactualSafes|addressBook|userAddressBook)/],
},
'../src/gateway/AUTO_GENERATED/counterfactual-safes.ts': {
filterEndpoints: [/^counterfactualSafes/],
},
'../src/gateway/AUTO_GENERATED/positions.ts': {
filterEndpoints: [/^positions/],
},
'../src/gateway/AUTO_GENERATED/portfolios.ts': {
filterEndpoints: [/^portfolio/],
},
'../src/gateway/AUTO_GENERATED/safe-shield.ts': {
filterEndpoints: [/^safeShield/],
},
},
}
export default config