Skip to content

Commit 89a05b4

Browse files
Integration of FinoaConnect wallet connector service into Web3Onboard (#2188)
* impl: integration into existing package * Update packages/finoaconnect/package.json * Update packages/demo/package.json * Update .circleci/config.yml * fix: added comments and mock examplers in packages//README * chore: update comment on unhandled error * Update +page.md * Update README.md * Update packages/finoaconnect/README.md * Update docs/src/routes/docs/[...4]wallets/[...36]finoaconnect/+page.md * fix: renamed icon name to FinoaConnect and added finoaconnect to services/onboard for choice in dapp * fix: update typescript version in finoaconnect package * fix: all unsupported methods to return error code 4200 * chore: cleaned up commented code and unnecessary lock files * chore: removed unused code * fix: updated finoaconnect sdk version * Merge in upstream and yarn --------- Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
1 parent 48fa68f commit 89a05b4

File tree

13 files changed

+314
-0
lines changed

13 files changed

+314
-0
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@ jobs:
454454
working_directory: ~/web3-onboard-monorepo/packages/particle-network
455455
steps:
456456
- node-build-steps
457+
build-finoaconnect:
458+
docker:
459+
- image: cimg/node:18.0.0
460+
working_directory: ~/web3-onboard-monorepo/packages/finoaconnect
461+
steps:
462+
- node-build-steps
457463
build-wagmi:
458464
docker:
459465
- image: cimg/node:18.0.0
@@ -780,6 +786,12 @@ jobs:
780786
working_directory: ~/web3-onboard-monorepo/packages/bloom
781787
steps:
782788
- node-staging-build-steps
789+
build-staging-finoaconnect:
790+
docker:
791+
- image: cimg/node:18.0.0
792+
working_directory: ~/web3-onboard-monorepo/packages/finoaconnect
793+
steps:
794+
- node-staging-build-steps
783795

784796
workflows:
785797
version: 2
@@ -1091,3 +1103,9 @@ workflows:
10911103
<<: *deploy_production_filters
10921104
- build-staging-bloom:
10931105
<<: *deploy_staging_filters
1106+
finoaconnect:
1107+
jobs:
1108+
- build-finoaconnect:
1109+
<<: *deploy_production_filters
1110+
- build-staging-finoaconnect:
1111+
<<: *deploy_staging_filters

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ For full documentation, check out the README.md for each package or the [docs pa
129129
- [Particle Network](packages/particle-network/README.md)
130130
- [MetaMask](packages/metamask/README.md)
131131
- [Bitget](packages/bitget/README.md)
132+
- [FinoaConnect](packages/finoaconnect/README.md)
132133

133134
**Hardware Wallets**
134135

docs/src/lib/services/onboard.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const intiOnboard = async (theme) => {
5959
const { default: bloctoModule } = await import('@web3-onboard/blocto')
6060
const { default: venlyModule } = await import('@web3-onboard/venly')
6161
const { default: bitgetModule } = await import('@web3-onboard/bitget')
62+
const { default: finoaConnectModule } = await import('@web3-onboard/finoaconnect')
6263
const { default: capsuleModule, Environment } = await import('@web3-onboard/capsule')
6364
const { default: particleAuthModule } = await import('@web3-onboard/particle-network')
6465
const INFURA_ID = '8b60d52405694345a99bcb82e722e0af'
@@ -113,6 +114,9 @@ const intiOnboard = async (theme) => {
113114
}
114115
const trezor = trezorModule(trezorOptions)
115116

117+
const finoaConnectOptions = {};
118+
const finoaconnect = finoaConnectModule(finoaConnectOptions);
119+
116120
const uauthOptions = {
117121
clientID: 'a25c3a65-a1f2-46cc-a515-a46fe7acb78c',
118122
redirectUri: 'http://localhost:8080/',
@@ -177,6 +181,7 @@ const intiOnboard = async (theme) => {
177181
blocto,
178182
particle,
179183
venly,
184+
finoaconnect,
180185
capsule
181186
],
182187
chains: [
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: FinoaConnect
3+
---
4+
5+
## Wallet module for connecting FinoaConnect SDK to web3-onboard
6+
7+
## Install
8+
9+
<Tabs values={['yarn', 'npm']}>
10+
<TabPanel value="yarn">
11+
12+
```sh copy
13+
yarn add @web3-onboard/core @web3-onboard/finoaconnect
14+
```
15+
16+
</TabPanel>
17+
<TabPanel value="npm">
18+
19+
```sh copy
20+
npm install @web3-onboard/core @web3-onboard/finoaconnect
21+
```
22+
23+
</TabPanel>
24+
</Tabs>
25+
26+
## Usage
27+
28+
Optional initialization object
29+
```typescript
30+
/** Optional object provided to the initiation of the wallet connector.
31+
* When not included, the wallet connector service connects to FinoaConnect production systems.
32+
* @field {url} URL of the FinoaConnect backend systems to be used
33+
* @field {labelSuffix} arbitrary string label to denote the context of the URL field */
34+
export interface FinoaWalletOption {
35+
url?: string
36+
labelSuffix?: string
37+
}
38+
```
39+
40+
```typescript
41+
import Onboard from '@web3-onboard/core'
42+
import finoaConnectModule from '@web3-onboard/finoaconnect'
43+
44+
// initialize the module with options
45+
const finoaConnect = finoaConnectModule()
46+
47+
const onboard = Onboard({
48+
// ... other Onboard options
49+
wallets: [
50+
finoaConnect
51+
//... other wallets
52+
]
53+
})
54+
55+
const connectedWallets = await onboard.connectWallet()
56+
console.log(connectedWallets)
57+
```

docs/yarn.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,20 @@
25442544
resolved "https://registry.yarnpkg.com/@metamask/safe-event-emitter/-/safe-event-emitter-3.1.1.tgz#e89b840a7af8097a8ed4953d8dc8470d1302d3ef"
25452545
integrity sha512-ihb3B0T/wJm1eUuArYP4lCTSEoZsClHhuWyfo/kMX3m/odpqNcPfsz5O2A3NT7dXCAgWPGDQGPqygCpgeniKMw==
25462546

2547+
"@metamask/sdk-communication-layer@0.14.3":
2548+
version "0.14.3"
2549+
resolved "https://registry.yarnpkg.com/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.14.3.tgz#0e7ec8e472641273da5802f3b357687ce12369c3"
2550+
integrity sha512-yjSbj8y7fFbQXv2HBzUX6D9C8BimkCYP6BDV7hdw53W8b/GlYCtXVxUFajQ9tuO1xPTRjR/xt/dkdr2aCi6WGw==
2551+
dependencies:
2552+
bufferutil "^4.0.8"
2553+
cross-fetch "^3.1.5"
2554+
date-fns "^2.29.3"
2555+
eciesjs "^0.3.16"
2556+
eventemitter2 "^6.4.5"
2557+
socket.io-client "^4.5.1"
2558+
utf-8-validate "^6.0.3"
2559+
uuid "^8.3.2"
2560+
25472561
"@metamask/sdk-communication-layer@0.20.2":
25482562
version "0.20.2"
25492563
resolved "https://registry.yarnpkg.com/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.20.2.tgz#7f7fd334b2d26abd1a5a1ec1ffadf823a9589344"

packages/demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@web3-onboard/coinbase": "^2.4.1",
3939
"@web3-onboard/dcent": "^2.2.7",
4040
"@web3-onboard/enkrypt": "^2.1.1",
41+
"@web3-onboard/finoaconnect": "2.0.0-alpha.1",
4142
"@web3-onboard/fortmatic": "^2.1.1",
4243
"@web3-onboard/frame": "^2.1.1",
4344
"@web3-onboard/frontier": "^2.1.1",

packages/demo/src/App.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import bitgetModule from '@web3-onboard/bitget'
3939
import bloomModule from '@web3-onboard/bloom'
4040
import particleAuthModule from '@web3-onboard/particle-network'
41+
import finoaConnectModule from '@web3-onboard/finoaconnect'
4142
import keplrModule from '@web3-onboard/keplr'
4243
import capsuleModule, {
4344
Environment,
@@ -228,6 +229,7 @@
228229
fallbackProvider: '' // insert your alchemy / infura url here
229230
// encryptionSecret: '' // encryption secret is optional, but advised to securely store values in browser storage
230231
})
232+
const finoaConnect = finoaConnectModule()
231233
232234
const trezorOptions = {
233235
email: 'test@test.com',
@@ -325,6 +327,7 @@
325327
venly,
326328
particle,
327329
passport,
330+
finoaConnect,
328331
keplr
329332
],
330333
transactionPreview,

packages/finoaconnect/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# @web3-onboard/finoaconnect
2+
3+
## Wallet module for connecting FinoaConnect SDK to web3-onboard
4+
5+
#### Install
6+
7+
`npm i @web3-onboard/core @web3-onboard/finoaconnect`
8+
9+
## Usage
10+
11+
Optional initialization object
12+
```typescript
13+
/** Optional object provided to the initiation of the wallet connector.
14+
* When not included, the wallet connector service connects to FinoaConnect production systems.
15+
* @field {url} URL of the FinoaConnect backend systems to be used
16+
* @field {labelSuffix} arbitrary string label to denote the context of the URL field */
17+
export interface FinoaWalletOption {
18+
url?: string
19+
labelSuffix?: string
20+
}
21+
```
22+
23+
```typescript
24+
import Onboard from '@web3-onboard/core';
25+
import finoaConnectModule from '@web3-onboard/finoaconnect';
26+
27+
const onboard = Onboard({
28+
// ... other Onboard options
29+
wallets: [
30+
finoaConnectModule()
31+
//... other wallets
32+
]
33+
})
34+
35+
// alternatively to connect to a localised development environment
36+
const onboard = Onboard({
37+
// ... other Onboard options
38+
wallets: [
39+
finoaConnectModule([
40+
{
41+
labelSuffix: 'localhost',
42+
url: 'http://localhost:8080',
43+
}
44+
])
45+
//... other wallets
46+
]
47+
})
48+
49+
const connectedWallets = await onboard.connectWallet()
50+
console.log(connectedWallets)
51+
```

packages/finoaconnect/package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "@web3-onboard/finoaconnect",
3+
"version": "2.0.0-alpha.1",
4+
"description": "FinoaConnect enables DApp users to use Finoa's Institutional Custody services.",
5+
"keywords": [
6+
"Ethereum",
7+
"Web3",
8+
"EVM",
9+
"dapp",
10+
"Multichain",
11+
"Wallet",
12+
"Transaction",
13+
"Provider",
14+
"Hardware Wallet",
15+
"Notifications",
16+
"React",
17+
"Svelte",
18+
"Vue",
19+
"Next",
20+
"Nuxt",
21+
"MetaMask",
22+
"Coinbase",
23+
"WalletConnect",
24+
"Ledger",
25+
"Trezor",
26+
"Connect Wallet",
27+
"Ethereum Hooks",
28+
"Blocknative",
29+
"Mempool",
30+
"pending",
31+
"confirmed",
32+
"Injected Wallet",
33+
"Crypto",
34+
"Crypto Wallet",
35+
"Tally Ho",
36+
"FinoaConnect"
37+
],
38+
"repository": {
39+
"type": "git",
40+
"url": "https://github.com/blocknative/web3-onboard.git",
41+
"directory": "packages/finoaconnect"
42+
},
43+
"homepage": "https://onboard.blocknative.com",
44+
"bugs": "https://github.com/blocknative/web3-onboard/issues",
45+
"module": "dist/index.js",
46+
"browser": "dist/index.js",
47+
"main": "dist/index.js",
48+
"type": "module",
49+
"typings": "dist/index.d.ts",
50+
"files": [
51+
"dist"
52+
],
53+
"scripts": {
54+
"build": "tsc",
55+
"dev": "tsc -w",
56+
"type-check": "tsc --noEmit"
57+
},
58+
"devDependencies": {
59+
"typescript": "^5.4.5"
60+
},
61+
"dependencies": {
62+
"@finoa/finoa-connect-sdk": "^1.0.4",
63+
"@web3-onboard/core": "^2.20.4"
64+
}
65+
66+
}

packages/finoaconnect/src/icon.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default `
2+
<?xml version="1.0" encoding="utf-8"?>
3+
<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
4+
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.029 0A4.029 4.029 0 0 0 0 4.029V19.97A4.029 4.029 0 0 0 4.029 24H19.97A4.029 4.029 0 0 0 24 19.971V4.03A4.029 4.029 0 0 0 19.971 0H4.03ZM9.71 15.252a2.277 2.277 0 0 0 2.275 2.273 2.277 2.277 0 0 0 1.668-3.818l-1.668-1.668-1.363-1.362-2.488-2.489 2.068-2.067 2.005-2.004L13.5 5.41l-2.71 2.71 1.196 1.194 2.208-2.17.719.716.646.644-2.212 2.172 1.696 1.696a4.198 4.198 0 0 1-3.057 7.081 4.205 4.205 0 0 1-4.203-4.2c0-1.061.397-2.073 1.117-2.852l.937-.937 1.363 1.362-.91.91c-.364.394-.58.942-.58 1.517Z" fill="#32C6A1"></path>
5+
</svg>
6+
`

packages/finoaconnect/src/index.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { FinoaEIP1193Provider } from '@finoa/finoa-connect-sdk'
2+
import { ProviderRpcError, ProviderRpcErrorCode, type WalletInit } from '@web3-onboard/common'
3+
4+
/** Optional object provided to the initiation of the wallet connector.
5+
* When not included, the wallet connector service connects to FinoaConnect production systems.
6+
* @field {url} URL of the FinoaConnect backend systems to be used
7+
* @field {labelSuffix} arbitrary string label to denote the context of the URL field */
8+
export interface FinoaWalletOption {
9+
url?: string
10+
labelSuffix?: string
11+
}
12+
13+
function finoaConnect(option?: string | FinoaWalletOption): WalletInit {
14+
const { url, labelSuffix }: FinoaWalletOption =
15+
typeof option === 'string' ? { url: option } : !option ? {} : option
16+
17+
return () => {
18+
return {
19+
label: `FinoaConnect${labelSuffix == null ? '' : ' - ' + labelSuffix}`,
20+
getIcon: async () => (await import('./icon')).default,
21+
getInterface: async ({ chains }) => {
22+
const {
23+
FinoaEIP1193Provider,
24+
FinoaBrowserClient,
25+
UnsupportedRequestError
26+
} = await import('@finoa/finoa-connect-sdk')
27+
28+
const client = new FinoaBrowserClient({
29+
windowUrl: url
30+
})
31+
const provider = new FinoaEIP1193Provider({
32+
client
33+
})
34+
35+
const proxyProvider = new Proxy(provider, {
36+
get(target, property: keyof FinoaEIP1193Provider) {
37+
const source = target[property]
38+
if (property === 'request') {
39+
return async function (
40+
this: FinoaEIP1193Provider,
41+
...args: Parameters<FinoaEIP1193Provider['request']>
42+
) {
43+
44+
try {
45+
return await (source as FinoaEIP1193Provider['request']).call(
46+
this,
47+
...args
48+
)
49+
} catch (err) {
50+
if (err instanceof UnsupportedRequestError) {
51+
throw new ProviderRpcError({
52+
code: ProviderRpcErrorCode.UNSUPPORTED_METHOD,
53+
message: `FinoaConnect Provider does not support the requested method: ${args[0].method}`
54+
})
55+
}
56+
throw err
57+
}
58+
}
59+
}
60+
return source
61+
}
62+
})
63+
64+
return {
65+
provider: proxyProvider
66+
}
67+
}
68+
}
69+
}
70+
}
71+
72+
export default finoaConnect

packages/finoaconnect/tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["src/**/*"],
4+
5+
"compilerOptions": {
6+
"outDir": "dist",
7+
"rootDir": "src",
8+
"declaration": true,
9+
"declarationDir": "dist",
10+
"allowSyntheticDefaultImports": true,
11+
"paths": {
12+
"*": ["./src/*", "./node_modules/*"]
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)