diff --git a/src/components/tx/SignOrExecuteForm/ExecuteForm.tsx b/src/components/tx/SignOrExecuteForm/ExecuteForm.tsx index 61d3acbd32..ea19347871 100644 --- a/src/components/tx/SignOrExecuteForm/ExecuteForm.tsx +++ b/src/components/tx/SignOrExecuteForm/ExecuteForm.tsx @@ -66,7 +66,7 @@ export const ExecuteForm = ({ // SC wallets can relay fully signed transactions const [walletCanRelay] = useWalletCanRelay(safeTx) - const relays = useRelaysBySafe(origin) + const relays = useRelaysBySafe() // The transaction can/will be relayed const canRelay = walletCanRelay && hasRemainingRelays(relays[0]) const willRelay = canRelay && executionMethod === ExecutionMethod.RELAY diff --git a/src/hooks/__tests__/useRemainingRelays.test.ts b/src/hooks/__tests__/useRemainingRelays.test.ts index 9be3ed1f44..87b3c1fddd 100644 --- a/src/hooks/__tests__/useRemainingRelays.test.ts +++ b/src/hooks/__tests__/useRemainingRelays.test.ts @@ -52,46 +52,6 @@ describe('fetch remaining relays hooks', () => { expect(mockFetch).toHaveBeenCalledTimes(2) }) - - it('should not do a network request if only swaps are supported but the tx is not a swap', () => { - jest.spyOn(useChains, 'useCurrentChain').mockReturnValue( - chainBuilder() - // @ts-expect-error - using local FEATURES enum - .with({ features: [FEATURES.RELAY_NATIVE_SWAPS] }) - .build(), - ) - - const mockFetch = jest.spyOn(gateway, 'getRelayCount') - - renderHook(() => useRelaysBySafe(JSON.stringify({ url: 'https://some.url', name: 'Some app' }))) - expect(mockFetch).toHaveBeenCalledTimes(0) - }) - - it('should do a network request if only swaps are supported and the tx is a swap', async () => { - jest.spyOn(useChains, 'useCurrentChain').mockReturnValue( - chainBuilder() - // @ts-expect-error - using local FEATURES enum - .with({ features: [FEATURES.RELAY_NATIVE_SWAPS] }) - .build(), - ) - - const mockFetch = jest.spyOn(gateway, 'getRelayCount').mockResolvedValue({ - limit: 5, - remaining: 3, - }) - - const { result } = renderHook(() => - useRelaysBySafe(JSON.stringify({ url: 'https://some.url', name: 'Safe Swap' })), - ) - - await waitFor(() => { - expect(mockFetch).toHaveBeenCalledTimes(1) - expect(result.current[0]).toEqual({ - limit: 5, - remaining: 3, - }) - }) - }) }) describe('useLeastRemainingRelays hook', () => { diff --git a/src/hooks/useRemainingRelays.ts b/src/hooks/useRemainingRelays.ts index 9903453847..5ea0f6e5ba 100644 --- a/src/hooks/useRemainingRelays.ts +++ b/src/hooks/useRemainingRelays.ts @@ -6,16 +6,13 @@ import { getRelayCount } from '@safe-global/safe-gateway-typescript-sdk' export const MAX_HOUR_RELAYS = 5 -export const useRelaysBySafe = (txOrigin?: string) => { +export const useRelaysBySafe = () => { const chain = useCurrentChain() const { safe, safeAddress } = useSafeInfo() return useAsync(() => { if (!safeAddress || !chain) return - if ( - hasFeature(chain, FEATURES.RELAYING) || - (hasFeature(chain, FEATURES.RELAY_NATIVE_SWAPS) && txOrigin && JSON.parse(txOrigin).name === 'Safe Swap') - ) { + if (hasFeature(chain, FEATURES.RELAYING)) { return getRelayCount(chain.chainId, safeAddress) } // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/utils/chains.ts b/src/utils/chains.ts index 0e5179df62..9887934f20 100644 --- a/src/utils/chains.ts +++ b/src/utils/chains.ts @@ -31,7 +31,6 @@ export enum FEATURES { NATIVE_SWAPS = 'NATIVE_SWAPS', NATIVE_SWAPS_USE_COW_STAGING_SERVER = 'NATIVE_SWAPS_USE_COW_STAGING_SERVER', NATIVE_SWAPS_FEE_ENABLED = 'NATIVE_SWAPS_FEE_ENABLED', - RELAY_NATIVE_SWAPS = 'RELAY_NATIVE_SWAPS', ZODIAC_ROLES = 'ZODIAC_ROLES', SAFE_141 = 'SAFE_141', STAKING = 'STAKING',