From c70e7ab5d1469ecf47463b9ccc69a26f34d529fd Mon Sep 17 00:00:00 2001 From: schmanu Date: Tue, 6 Feb 2024 13:58:29 +0100 Subject: [PATCH] fix: lint issues --- .../safe-apps/AppFrame/useAppCommunicator.ts | 4 ++-- .../tx/SignOrExecuteForm/hooks.test.ts | 7 +++++++ src/hooks/wallets/useInitWeb3.ts | 7 +++---- src/hooks/wallets/web3.ts | 16 ++++------------ .../tx/__tests__/encodeSignatures.test.ts | 3 +++ 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/components/safe-apps/AppFrame/useAppCommunicator.ts b/src/components/safe-apps/AppFrame/useAppCommunicator.ts index 2716066ebc..e87a09472f 100644 --- a/src/components/safe-apps/AppFrame/useAppCommunicator.ts +++ b/src/components/safe-apps/AppFrame/useAppCommunicator.ts @@ -28,11 +28,11 @@ import type { Permission, PermissionRequest } from '@safe-global/safe-apps-sdk/d import type { SafeSettings } from '@safe-global/safe-apps-sdk' import AppCommunicator from '@/services/safe-apps/AppCommunicator' import { Errors, logError } from '@/services/exceptions' -import { createSafeAppsWeb3Provider } from '@/hooks/wallets/web3' import type { SafePermissionsRequest } from '@/hooks/safe-apps/permissions' import { SAFE_APPS_EVENTS, trackSafeAppEvent } from '@/services/analytics' import { useAppSelector } from '@/store' import { selectRpc } from '@/store/settingsSlice' +import { createSafeAppsWeb3Provider } from '@/hooks/wallets/web3' export enum CommunicatorMessages { REJECT_TRANSACTION_MESSAGE = 'Transaction was rejected', @@ -79,7 +79,7 @@ const useAppCommunicator = ( return } - return createSafeAppsWeb3Provider(chain.chainId, chain.rpcUri, customRpc?.[chain.chainId]) + return createSafeAppsWeb3Provider(chain, customRpc?.[chain.chainId]) }, [chain, customRpc]) useEffect(() => { diff --git a/src/components/tx/SignOrExecuteForm/hooks.test.ts b/src/components/tx/SignOrExecuteForm/hooks.test.ts index b2ede6cbb6..d0bb6f7125 100644 --- a/src/components/tx/SignOrExecuteForm/hooks.test.ts +++ b/src/components/tx/SignOrExecuteForm/hooks.test.ts @@ -410,6 +410,7 @@ describe('SignOrExecute hooks', () => { data: '0x0001', staticPart: () => '', dynamicPart: () => '', + isContractSignature: false, }) const id = await executeTx({ gasPrice: 1 }, tx, '123', 'origin.com', true) @@ -442,6 +443,7 @@ describe('SignOrExecute hooks', () => { data: '0x0001', staticPart: () => '', dynamicPart: () => '', + isContractSignature: false, }) const proposeSpy = jest @@ -453,6 +455,7 @@ describe('SignOrExecute hooks', () => { data: '0x0001', staticPart: () => '', dynamicPart: () => '', + isContractSignature: false, }) return Promise.resolve(tx) }) @@ -492,6 +495,7 @@ describe('SignOrExecute hooks', () => { data: '0x0001', staticPart: () => '', dynamicPart: () => '', + isContractSignature: false, }) const proposeSpy = jest @@ -503,6 +507,7 @@ describe('SignOrExecute hooks', () => { data: '0x0001', staticPart: () => '', dynamicPart: () => '', + isContractSignature: false, }) return Promise.resolve(tx) }) @@ -535,6 +540,7 @@ describe('SignOrExecute hooks', () => { data: '0x0001', staticPart: () => '', dynamicPart: () => '', + isContractSignature: false, }) const { result } = renderHook(() => useAlreadySigned(tx)) expect(result.current).toEqual(true) @@ -554,6 +560,7 @@ describe('SignOrExecute hooks', () => { data: '0x0001', staticPart: () => '', dynamicPart: () => '', + isContractSignature: false, }) const { result } = renderHook(() => useAlreadySigned(tx)) expect(result.current).toEqual(false) diff --git a/src/hooks/wallets/useInitWeb3.ts b/src/hooks/wallets/useInitWeb3.ts index 0759993906..e9e897ef35 100644 --- a/src/hooks/wallets/useInitWeb3.ts +++ b/src/hooks/wallets/useInitWeb3.ts @@ -9,7 +9,6 @@ import { selectRpc } from '@/store/settingsSlice' export const useInitWeb3 = () => { const chain = useCurrentChain() const chainId = chain?.chainId - const rpcUri = chain?.rpcUri const wallet = useWallet() const customRpc = useAppSelector(selectRpc) const customRpcUrl = chain ? customRpc?.[chain.chainId] : undefined @@ -24,11 +23,11 @@ export const useInitWeb3 = () => { }, [wallet, chainId]) useEffect(() => { - if (!rpcUri) { + if (!chain) { setWeb3ReadOnly(undefined) return } - const web3ReadOnly = createWeb3ReadOnly(chain, rpcUri, customRpcUrl) + const web3ReadOnly = createWeb3ReadOnly(chain, customRpcUrl) setWeb3ReadOnly(web3ReadOnly) - }, [chain, rpcUri, customRpcUrl]) + }, [chain, customRpcUrl]) } diff --git a/src/hooks/wallets/web3.ts b/src/hooks/wallets/web3.ts index 57887dc61e..3ac3a6792e 100644 --- a/src/hooks/wallets/web3.ts +++ b/src/hooks/wallets/web3.ts @@ -20,12 +20,8 @@ export const getRpcServiceUrl = (rpcUri: RpcUri): string => { return formatRpcServiceUrl(rpcUri, INFURA_TOKEN) } -export const createWeb3ReadOnly = ( - chain: ChainInfo, - rpcUri: RpcUri, - customRpc?: string, -): JsonRpcProvider | undefined => { - const url = customRpc || getRpcServiceUrl(rpcUri) +export const createWeb3ReadOnly = (chain: ChainInfo, customRpc?: string): JsonRpcProvider | undefined => { + const url = customRpc || getRpcServiceUrl(chain.rpcUri) if (!url) return return new JsonRpcProvider(url, new Network(chain.chainName, chain.chainId), { staticNetwork: true, @@ -36,12 +32,8 @@ export const createWeb3 = (walletProvider: Eip1193Provider): BrowserProvider => return new BrowserProvider(walletProvider) } -export const createSafeAppsWeb3Provider = ( - chain: ChainInfo, - safeAppsRpcUri: RpcUri, - customRpc?: string, -): JsonRpcProvider | undefined => { - const url = customRpc || formatRpcServiceUrl(safeAppsRpcUri, SAFE_APPS_INFURA_TOKEN) +export const createSafeAppsWeb3Provider = (chain: ChainInfo, customRpc?: string): JsonRpcProvider | undefined => { + const url = customRpc || formatRpcServiceUrl(chain.rpcUri, SAFE_APPS_INFURA_TOKEN) if (!url) return return new JsonRpcProvider(url, new Network(chain.chainName, chain.chainId), { staticNetwork: true, diff --git a/src/services/tx/__tests__/encodeSignatures.test.ts b/src/services/tx/__tests__/encodeSignatures.test.ts index 28a7271806..c66c44bd41 100644 --- a/src/services/tx/__tests__/encodeSignatures.test.ts +++ b/src/services/tx/__tests__/encodeSignatures.test.ts @@ -32,6 +32,7 @@ describe('encodeSignatures', () => { data: '0xEEE', staticPart: () => '0xEEE', dynamicPart: () => '', + isContractSignature: false, }) safeTx.addSignature({ @@ -39,6 +40,7 @@ describe('encodeSignatures', () => { data: '0xAAA', staticPart: () => '0xAAA', dynamicPart: () => '', + isContractSignature: false, }) const owner = '0x123' @@ -57,6 +59,7 @@ describe('encodeSignatures', () => { data: '0xAAA', staticPart: () => '0xAAA', dynamicPart: () => '', + isContractSignature: false, }) const owner = '0x123'