From dc0a7ad376aab2fc14c2f85a5ecebc09939cb270 Mon Sep 17 00:00:00 2001 From: nenadV91 Date: Wed, 29 Mar 2023 18:47:23 +0200 Subject: [PATCH] Block wallet integration --- .../modules/wallet/api/assets/block.png | Bin 0 -> 3243 bytes src/cow-react/modules/wallet/api/types.ts | 1 + .../modules/wallet/api/utils/connection.ts | 2 + .../wallet/web3-react/connection/block.tsx | 45 ++++++++++++++++++ .../wallet/web3-react/connection/index.tsx | 7 +++ src/state/connection/reducer.ts | 1 + 6 files changed, 56 insertions(+) create mode 100644 src/cow-react/modules/wallet/api/assets/block.png create mode 100644 src/cow-react/modules/wallet/web3-react/connection/block.tsx diff --git a/src/cow-react/modules/wallet/api/assets/block.png b/src/cow-react/modules/wallet/api/assets/block.png new file mode 100644 index 0000000000000000000000000000000000000000..69ab296471156152abdffed0b9dca5c6d0939b26 GIT binary patch literal 3243 zcmV;c3{>-pP)ou5o!uWlto#DSizRIEDDjb7b#m?sO~4D1p*fez;y_s4w!xI#F{7r_Mo*seL{;fm=c;1ypyu4tb2k39=)%_)zALY+~^xf=x_N@@fL6ua7^e8A~v|; z(>&lw1C7&KEc0I)8itk3Xg~hGx#Yb?)Yu4I2b}D8M@vDuZ^HS&b_0#BQ^OU@`Jp$Y zq-(SUnuHPI@rO!FkUv$po$vL0~Z1lLvL(}&P}|3YoPIzEw0dn-nK5_ zTwslX#!}Y!H*i|$h9JZB_`On(8E7Di592;yPUwaqFwKvHLpKOT{dh$4lQ5AJ85_FMl*KtZmeG;11vnve<0&#X*Z4UwXkcS2;>CNw*F!g?B64$$B?dOI zBAxiN<|gUr^1Vjr4XQ{#wx~Br?ivFdQju+36uOahq8S=el`0nbQ-dUevkh!8MgHN2 zTqlNZeAb=f|4^YfmLg270}c<}2rb$JSfE|F3coA(GGMpRjnay4zi2?{4WqCX3qv*3pS{JJic-Sx7DbmVv;8T8%nyaq7 zKhPJ)-6{@g!?Au&QuxKzr}zv0LwDPX&WvSw54Z9hV)goe;1M}~rW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l: WALLET_LINK, + searchKeywords: ['isBlock', 'isBlockWallet'], + }) +) +export const blockWalletConnection: Web3ReactConnection = { + connector: blockWallet, + hooks: blockWalletHooks, + type: ConnectionType.BLOCK, +} + +export function BlockWalletOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) { + const isActive = useIsActiveWallet(blockWalletConnection) + + return ( + tryActivation(blockWalletConnection.connector)} + header={getConnectionName(ConnectionType.BLOCK)} + /> + ) +} diff --git a/src/cow-react/modules/wallet/web3-react/connection/index.tsx b/src/cow-react/modules/wallet/web3-react/connection/index.tsx index 32bb831490..f66f38656e 100644 --- a/src/cow-react/modules/wallet/web3-react/connection/index.tsx +++ b/src/cow-react/modules/wallet/web3-react/connection/index.tsx @@ -22,6 +22,7 @@ import { AmbireOption } from './ambire' import { AlphaOption } from './alpha' import { tallyWalletConnection, TallyWalletOption } from './tally' import { trustWalletConnection, TrustWalletOption } from './trust' +import { blockWalletConnection, BlockWalletOption } from './block' const CONNECTIONS: Web3ReactConnection[] = [ gnosisSafeConnection, @@ -32,6 +33,7 @@ const CONNECTIONS: Web3ReactConnection[] = [ networkConnection, tallyWalletConnection, trustWalletConnection, + blockWalletConnection, ] export function isChainAllowed(connector: Connector, chainId: number) { @@ -45,6 +47,7 @@ export function isChainAllowed(connector: Connector, chainId: number) { case gnosisSafeConnection.connector: case tallyWalletConnection.connector: case trustWalletConnection.connector: + case blockWalletConnection.connector: return ALL_SUPPORTED_CHAIN_IDS.includes(chainId) default: return false @@ -82,6 +85,8 @@ export function getWeb3ReactConnection(c: Connector | ConnectionType): Web3React return tallyWalletConnection case ConnectionType.TRUST: return trustWalletConnection + case ConnectionType.BLOCK: + return blockWalletConnection } } } @@ -128,6 +133,7 @@ export function ConnectWalletOptions({ tryActivation }: { tryActivation: TryActi const tallyOption = (!isInjectedMobileBrowser && isChrome && !isChromeMobile && ) ?? null + const blockOption = (!isInjectedMobileBrowser && ) ?? null return ( <> @@ -139,6 +145,7 @@ export function ConnectWalletOptions({ tryActivation }: { tryActivation: TryActi {alphaOption} {tallyOption} {trustOption} + {blockOption} ) } diff --git a/src/state/connection/reducer.ts b/src/state/connection/reducer.ts index 6103492725..44d831c6ed 100644 --- a/src/state/connection/reducer.ts +++ b/src/state/connection/reducer.ts @@ -18,6 +18,7 @@ export const initialState: ConnectionState = { [ConnectionType.ALPHA]: undefined, [ConnectionType.TALLY]: undefined, [ConnectionType.TRUST]: undefined, + [ConnectionType.BLOCK]: undefined, }, }