Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of FinoaConnect wallet connector service into Web3Onboard #2188

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e013ece
impl: integration into existing package
finoaamukherjee May 6, 2024
95532ce
Update packages/finoaconnect/package.json
Adamj1232 May 6, 2024
5f5f8ea
Update packages/demo/package.json
Adamj1232 May 6, 2024
b1584db
Update .circleci/config.yml
Adamj1232 May 6, 2024
92ecbe6
fix: added comments and mock examplers in packages//README
finoaamukherjee May 7, 2024
abc102a
chore: update comment on unhandled error
finoaamukherjee May 7, 2024
ebdb835
Update +page.md
Adamj1232 May 13, 2024
bbd8052
Update README.md
Adamj1232 May 13, 2024
054e8c6
Update packages/finoaconnect/README.md
Adamj1232 May 13, 2024
73585bb
Update docs/src/routes/docs/[...4]wallets/[...36]finoaconnect/+page.md
Adamj1232 May 13, 2024
1e02ea2
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 May 13, 2024
1f8234a
fix: renamed icon name to FinoaConnect and added finoaconnect to serv…
finoaamukherjee May 15, 2024
4988b23
fix: update typescript version in finoaconnect package
finoaamukherjee May 15, 2024
c42ec26
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 May 15, 2024
9729859
fix: all unsupported methods to return error code 4200
finoaamukherjee Jun 6, 2024
4432f6a
chore: cleaned up commented code and unnecessary lock files
finoaamukherjee Jun 6, 2024
5eef9f9
Merge branch 'develop' into feature/finoa-web3-onboard-integration
finoaamukherjee Jun 12, 2024
eaf2d7b
chore: removed unused code
finoaamukherjee Jun 13, 2024
deb91bc
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 Jun 13, 2024
ff4ce6a
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 Jun 13, 2024
4f62901
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 Jun 14, 2024
3d17e9c
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 Jun 17, 2024
0e9836a
Merge branch 'blocknative:develop' into feature/finoa-web3-onboard-in…
finoaamukherjee Jun 18, 2024
c4f3485
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 Jun 19, 2024
e5d4ab8
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 Jun 24, 2024
5e9f04e
Merge branch 'develop' into feature/finoa-web3-onboard-integration
finoaamukherjee Jun 25, 2024
55ef4ce
fix: updated finoaconnect sdk version
finoaamukherjee Jun 28, 2024
6d8ab05
Merge branch 'develop' into feature/finoa-web3-onboard-integration
Adamj1232 Aug 14, 2024
5506f27
Merge in upstream and yarn
Adamj1232 Aug 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,13 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/particle-network
steps:
- node-build-steps

build-finoaconnect:
docker:
- image: cimg/node:18.0.0
working_directory: ~/web3-onboard-monorepo/packages/finoaconnect
steps:
- node-build-steps

# Build staging/Alpha releases
build-staging-core:
docker:
Expand Down Expand Up @@ -732,6 +738,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/particle-network
steps:
- node-staging-build-steps
build-staging-finoaconnect:
docker:
- image: cimg/node:18.0.0
working_directory: ~/web3-onboard-monorepo/packages/finoaconnect
steps:
- node-staging-build-steps

workflows:
version: 2
Expand Down Expand Up @@ -1018,3 +1030,9 @@ workflows:
<<: *deploy_production_filters
- build-staging-particle:
<<: *deploy_staging_filters
finoaconnect:
jobs:
- build-finoaconnect:
<<: *deploy_production_filters
- build-staging-finoaconnect:
<<: *deploy_staging_filters
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ For full documentation, check out the README.md for each package or the [docs pa
- [Frame](packages/frame/README.md)
- [Blocto](packages/blocto/README.md)
- [Particle Network](packages/particle-network/README.md)
- [FinoaConnect](packages/finoaconnect/README.md)

**Hardware Wallets**

Expand Down
45 changes: 45 additions & 0 deletions docs/src/routes/docs/[...4]wallets/[...36]finoaconnect/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: FinoaConnect
---

## Wallet module for connecting FinoaConnect SDK to web3-onboard

## Install

<Tabs values={['yarn', 'npm']}>
<TabPanel value="yarn">

```sh copy
yarn add @web3-onboard/core @web3-onboard/finoaconnect
```

</TabPanel>
<TabPanel value="npm">

```sh copy
npm install @web3-onboard/core @web3-onboard/finoaconnect
```

</TabPanel>
</Tabs>

## Usage

Adamj1232 marked this conversation as resolved.
Show resolved Hide resolved
```typescript
import Onboard from '@web3-onboard/core'
import finoaConnectModule from '@web3-onboard/finoaconnect'

// initialize the module with options
const finoaConnect = finoaConnectModule()

const onboard = Onboard({
// ... other Onboard options
wallets: [
finoaConnect
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
1 change: 1 addition & 0 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@web3-onboard/coinbase": "^2.2.7",
"@web3-onboard/dcent": "^2.2.7",
"@web3-onboard/enkrypt": "^2.0.3",
"@web3-onboard/finoaconnect": "2.0.0-alpha.1",
"@web3-onboard/fortmatic": "^2.0.18",
"@web3-onboard/frame": "^2.0.2",
"@web3-onboard/frontier": "^2.0.3",
Expand Down
5 changes: 4 additions & 1 deletion packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import venlyModule from '@web3-onboard/venly'
import bitgetModule from '@web3-onboard/bitget'
import particleAuthModule from '@web3-onboard/particle-network'
import finoaConnectModule from '@web3-onboard/finoaconnect'
import capsuleModule, {
Environment,
OAuthMethod,
Expand Down Expand Up @@ -175,6 +176,7 @@
const cedeStore = cedeStoreModule()
const blocto = bloctoModule()
const tallyho = tallyHoModule()
const finoaConnect = finoaConnectModule()

const trezorOptions = {
email: 'test@test.com',
Expand Down Expand Up @@ -268,7 +270,8 @@
arcanaAuth,
blocto,
venly,
particle
particle,
finoaConnect
],
// transactionPreview,
gas,
Expand Down
39 changes: 39 additions & 0 deletions packages/finoaconnect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# @web3-onboard/finoaconnect

## Wallet module for connecting FinoaConnect SDK to web3-onboard

#### Install

`npm i @web3-onboard/core @web3-onboard/finoaconnect`

## Usage

Adamj1232 marked this conversation as resolved.
Show resolved Hide resolved
```typescript
import Onboard from '@web3-onboard/core';
import finoaConnectModule from '@web3-onboard/finoaconnect';

const onboard = Onboard({
// ... other Onboard options
wallets: [
finoaConnectModule()
//... other wallets
]
})

// alternatively to connect to a localised development environment
const onboard = Onboard({
// ... other Onboard options
wallets: [
finoaConnectModule([
{
labelSuffix: 'localhost',
url: 'http://localhost:8080',
}
])
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
66 changes: 66 additions & 0 deletions packages/finoaconnect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "@web3-onboard/finoaconnect",
"version": "2.0.0-alpha.1",
"description": "FinoaConnect enables DApp users to use Finoa's Institutional Custody services.",
"keywords": [
"Ethereum",
"Web3",
"EVM",
"dapp",
"Multichain",
"Wallet",
"Transaction",
"Provider",
"Hardware Wallet",
"Notifications",
"React",
"Svelte",
"Vue",
"Next",
"Nuxt",
"MetaMask",
"Coinbase",
"WalletConnect",
"Ledger",
"Trezor",
"Connect Wallet",
"Ethereum Hooks",
"Blocknative",
"Mempool",
"pending",
"confirmed",
"Injected Wallet",
"Crypto",
"Crypto Wallet",
"Tally Ho",
"FinoaConnect"
],
"repository": {
"type": "git",
"url": "https://github.com/blocknative/web3-onboard.git",
"directory": "packages/finoaconnect"
},
"homepage": "https://onboard.blocknative.com",
"bugs": "https://github.com/blocknative/web3-onboard/issues",
"module": "dist/index.js",
"browser": "dist/index.js",
"main": "dist/index.js",
"type": "module",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"type-check": "tsc --noEmit"
},
"devDependencies": {
"typescript": "5.1.6"
finoaamukherjee marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"@finoa/finoa-connect-sdk": "^1.0.2",
"@web3-onboard/core": "^2.20.4"
}

}
19 changes: 19 additions & 0 deletions packages/finoaconnect/src/fetch-rpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export async function request(url: string, call: object): Promise<any> {
// SOURCE: https://github.com/blocknative/web3-onboard/blob/ddfb620c62202b24adfe41994037d9609a697e0d/packages/hw-common/src/index.ts
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
jsonrpc: '2.0',
id: '42',
...call
})
})
const json = await response.json()
if ('error' in json) {
throw json.error
}
return json.result
}
6 changes: 6 additions & 0 deletions packages/finoaconnect/src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default `
<?xml version="1.0" encoding="utf-8"?>
<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
<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>
</svg>
`
82 changes: 82 additions & 0 deletions packages/finoaconnect/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { FinoaEIP1193Provider } from '@finoa/finoa-connect-sdk'
import type { Chain, WalletInit } from '@web3-onboard/common'

/** Optional object provided to the initiation of the wallet connector.
* When not included, the wallet connector service connects to FinoaConnect production systems.
* @field {url} URL of the FinoaConnect backend systems to be used
* @field {labelSuffix} arbitrary string label to denote the context of the URL field */
export interface FinoaWalletOption {
Adamj1232 marked this conversation as resolved.
Show resolved Hide resolved
url?: string
labelSuffix?: string
}

function finoaConnect(option?: string | FinoaWalletOption): WalletInit {
const { url, labelSuffix }: FinoaWalletOption =
typeof option === 'string' ? { url: option } : !option ? {} : option

return () => {
return {
label: `Finoa Wallet${labelSuffix == null ? '' : ' - ' + labelSuffix}`,
getIcon: async () => (await import('./icon')).default,
getInterface: async ({ chains }) => {
const {
FinoaEIP1193Provider,
FinoaBrowserClient,
UnsupportedRequestError
} = await import('@finoa/finoa-connect-sdk')

const { request } = await import('./fetch-rpc')

const client = new FinoaBrowserClient({
windowUrl: url
})
const provider = new FinoaEIP1193Provider({
client
})

const proxyProvider = new Proxy(provider, {
get(target, property: keyof FinoaEIP1193Provider) {
const source = target[property]
if (property === 'request') {
return async function (
this: FinoaEIP1193Provider,
...args: Parameters<FinoaEIP1193Provider['request']>
) {
try {
return await (source as FinoaEIP1193Provider['request']).call(
this,
...args
)
} catch (err) {
if (err instanceof UnsupportedRequestError) {
let chain: Chain | undefined
try {
const chainIdN = BigInt(err.chainId)
chain = chains.find(
chain => BigInt(chain.id) === chainIdN
)
} catch {
/* Not handled: the chain id in the error is not a valid one */
}
if (chain?.rpcUrl == null) {
throw err
}
return await request(chain.rpcUrl, ...args)
}
throw err
}
}
}
return source
}
})

return {
provider: proxyProvider
}
}
}
}
}

export default finoaConnect
15 changes: 15 additions & 0 deletions packages/finoaconnect/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],

"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"declaration": true,
"declarationDir": "dist",
"allowSyntheticDefaultImports": true,
"paths": {
"*": ["./src/*", "./node_modules/*"]
}
}
}
15 changes: 10 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,11 @@
dependencies:
keccak "^3.0.0"

"@finoa/finoa-connect-sdk@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@finoa/finoa-connect-sdk/-/finoa-connect-sdk-1.0.2.tgz#17dc743f1bb93bb365254f4ab262c1ebaf05fd80"
integrity sha512-RMpJjsic+xKz6CnasF+/JvMvtcfQphFjCS6H7OdPj2FSXCyimqVXMHbTzUFONKITgZO6iolxT+UY99ujEVHv0w==

"@formatjs/ecma402-abstract@1.11.3":
version "1.11.3"
resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-1.11.3.tgz#f25276dfd4ef3dac90da667c3961d8aa9732e384"
Expand Down Expand Up @@ -15060,16 +15065,16 @@ typescript@*, typescript@^4.5.5:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==

typescript@5.1.6, typescript@^5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==

typescript@^4.6.2:
version "4.6.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9"
integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==

typescript@^5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==

typescript@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
Expand Down