Skip to content

Commit

Permalink
feat: integrate finoa connect (#2020)
Browse files Browse the repository at this point in the history
* feat: integrate finoa connect

* use @web3-react/eip1193
  • Loading branch information
JP authored Mar 20, 2024
1 parent ad2f803 commit 2269d8f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
2 changes: 2 additions & 0 deletions centrifuge-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@
"@ethersproject/bignumber": "^5.6.0",
"@ethersproject/networks": "^5.6.0",
"@ethersproject/providers": "^5.6.0",
"@finoa/finoa-connect-sdk": "^1.0.1",
"@polkadot/extension-dapp": "~0.45.5",
"@polkadot/react-identicon": "~3.1.4",
"@subwallet/wallet-connect": "0.2.5",
"@types/bn.js": "^5",
"@walletconnect/ethereum-provider": "^2.8.3",
"@walletconnect/modal": "^2.5.4",
"@web3-react/coinbase-wallet": "8.2.3",
"@web3-react/eip1193": "^8.2.3",
"@web3-react/empty": "8.2.3",
"@web3-react/gnosis-safe": "8.2.4",
"@web3-react/metamask": "8.2.4",
Expand Down
23 changes: 23 additions & 0 deletions centrifuge-react/src/components/WalletProvider/evm/connectors.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { IconArrowRight } from '@centrifuge/fabric'
import coinbasewalletLogo from '@centrifuge/fabric/assets/logos/coinbasewallet.svg'
import finoaLogo from '@centrifuge/fabric/assets/logos/finoa.svg'
import metamaskLogo from '@centrifuge/fabric/assets/logos/metamask.svg'
import walletconnectLogo from '@centrifuge/fabric/assets/logos/walletconnect.svg'
import { FinoaEIP1193Provider } from '@finoa/finoa-connect-sdk'
import subWalletLogo from '@subwallet/wallet-connect/dotsama/predefinedWallet/SubWalletLogo.svg'
import talismanLogo from '@subwallet/wallet-connect/dotsama/predefinedWallet/TalismanLogo.svg'
import { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import { EIP1193 } from '@web3-react/eip1193'
import { GnosisSafe } from '@web3-react/gnosis-safe'
import { MetaMask } from '@web3-react/metamask'
import { WalletConnect as WalletConnectV2 } from '@web3-react/walletconnect-v2'
Expand Down Expand Up @@ -43,6 +46,7 @@ export function getEvmConnectors(
substrateEvmChainId?: number
} = {}
): EvmConnectorMeta[] {
const finoaProvider = new FinoaEIP1193Provider()
const [metaMask] = createConnector((actions) => new MetaMask({ actions }))
const { ['1']: _, ...optional } = urls
const chains = [1, ...Object.keys(optional).map(Number)]
Expand Down Expand Up @@ -76,6 +80,8 @@ export function getEvmConnectors(
)
const [gnosisSafe] = createConnector<GnosisSafe>((actions) => new GnosisSafe({ actions }))

const [finoa] = createConnector<EIP1193>((actions) => new EIP1193({ actions, provider: finoaProvider }))

return [
{
id: 'gnosis-safe',
Expand All @@ -93,6 +99,23 @@ export function getEvmConnectors(
return false
},
},
{
id: 'finoa',
title: 'Finoa',
installUrl: '',
logo: {
src: finoaLogo,
alt: 'Finoa',
},
connector: finoa,
get installed() {
return true
},
get shown() {
return true
},
},

{
id: 'metamask',
get title() {
Expand Down
7 changes: 3 additions & 4 deletions centrifuge-react/src/components/WalletProvider/evm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CurrencyBalance } from '@centrifuge/centrifuge-js'
import type { Networkish } from '@ethersproject/networks'
import type { BaseProvider, Web3Provider } from '@ethersproject/providers'
import { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import { EIP1193 } from '@web3-react/eip1193'
import { EMPTY, Empty } from '@web3-react/empty'
import { GnosisSafe } from '@web3-react/gnosis-safe'
import { MetaMask } from '@web3-react/metamask'
Expand All @@ -13,14 +14,12 @@ import { useQuery } from 'react-query'
import { useWallet } from '../WalletProvider'
import { getChainInfo } from './chains'

export type Connector = MetaMask | WalletConnectV2 | CoinbaseWallet | GnosisSafe | Empty
export type Connector = MetaMask | WalletConnectV2 | CoinbaseWallet | GnosisSafe | Empty | EIP1193

const stores = new WeakMap<Connector, Web3ReactStore>()
const [emptyConnector, emptyStore] = createConnector(() => EMPTY)

export function createConnector<T extends MetaMask | WalletConnectV2 | CoinbaseWallet | GnosisSafe | Empty>(
f: (actions: Actions) => T
): [T, Web3ReactStore] {
export function createConnector<T extends Connector>(f: (actions: Actions) => T): [T, Web3ReactStore] {
const [store, actions] = createWeb3ReactStoreAndActions()
const connector = f(actions)
stores.set(connector, store)
Expand Down
3 changes: 3 additions & 0 deletions fabric/assets/logos/finoa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,7 @@ __metadata:
"@ethersproject/bignumber": ^5.6.0
"@ethersproject/networks": ^5.6.0
"@ethersproject/providers": ^5.6.0
"@finoa/finoa-connect-sdk": ^1.0.1
"@mdx-js/preact": ^2.1.1
"@mdx-js/react": ^1.6.22
"@polkadot/extension-dapp": ~0.45.5
Expand All @@ -1848,6 +1849,7 @@ __metadata:
"@walletconnect/ethereum-provider": ^2.8.3
"@walletconnect/modal": ^2.5.4
"@web3-react/coinbase-wallet": 8.2.3
"@web3-react/eip1193": ^8.2.3
"@web3-react/empty": 8.2.3
"@web3-react/gnosis-safe": 8.2.4
"@web3-react/metamask": 8.2.4
Expand Down Expand Up @@ -3181,6 +3183,13 @@ __metadata:
languageName: node
linkType: hard

"@finoa/finoa-connect-sdk@npm:^1.0.1":
version: 1.0.1
resolution: "@finoa/finoa-connect-sdk@npm:1.0.1"
checksum: 094b0907a55fc8d2c75f1f4d61b7e4ebf59fcc681ff9d739e9170912a190bee6528e1b6d32236c0c4004753b3345e46d3f4a8802f9e49a320a46bd293bed429f
languageName: node
linkType: hard

"@floating-ui/core@npm:^1.0.0":
version: 1.6.0
resolution: "@floating-ui/core@npm:1.6.0"
Expand Down Expand Up @@ -10475,6 +10484,16 @@ __metadata:
languageName: node
linkType: hard

"@web3-react/eip1193@npm:^8.2.3":
version: 8.2.3
resolution: "@web3-react/eip1193@npm:8.2.3"
dependencies:
"@web3-react/types": ^8.2.3
eventemitter3: ^4.0.7
checksum: dadeec1fcfcad555074470ea1afaeef7617b31691961ad093b1e5f7c702f7f308a5e4d13cf8ddf7f9c6c9134b1bf352e0bdc56c52f6872b63e6c04d437ffc735
languageName: node
linkType: hard

"@web3-react/empty@npm:8.2.3":
version: 8.2.3
resolution: "@web3-react/empty@npm:8.2.3"
Expand Down

0 comments on commit 2269d8f

Please sign in to comment.