-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
48fa68f
commit 89a05b4
Showing
13 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
docs/src/routes/docs/[...4]wallets/[...36]finoaconnect/+page.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
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 | ||
|
||
Optional initialization object | ||
```typescript | ||
/** 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 { | ||
url?: string | ||
labelSuffix?: string | ||
} | ||
``` | ||
|
||
```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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# @web3-onboard/finoaconnect | ||
|
||
## Wallet module for connecting FinoaConnect SDK to web3-onboard | ||
|
||
#### Install | ||
|
||
`npm i @web3-onboard/core @web3-onboard/finoaconnect` | ||
|
||
## Usage | ||
|
||
Optional initialization object | ||
```typescript | ||
/** 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 { | ||
url?: string | ||
labelSuffix?: string | ||
} | ||
``` | ||
|
||
```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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.4.5" | ||
}, | ||
"dependencies": { | ||
"@finoa/finoa-connect-sdk": "^1.0.4", | ||
"@web3-onboard/core": "^2.20.4" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { FinoaEIP1193Provider } from '@finoa/finoa-connect-sdk' | ||
import { ProviderRpcError, ProviderRpcErrorCode, type 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 { | ||
url?: string | ||
labelSuffix?: string | ||
} | ||
|
||
function finoaConnect(option?: string | FinoaWalletOption): WalletInit { | ||
const { url, labelSuffix }: FinoaWalletOption = | ||
typeof option === 'string' ? { url: option } : !option ? {} : option | ||
|
||
return () => { | ||
return { | ||
label: `FinoaConnect${labelSuffix == null ? '' : ' - ' + labelSuffix}`, | ||
getIcon: async () => (await import('./icon')).default, | ||
getInterface: async ({ chains }) => { | ||
const { | ||
FinoaEIP1193Provider, | ||
FinoaBrowserClient, | ||
UnsupportedRequestError | ||
} = await import('@finoa/finoa-connect-sdk') | ||
|
||
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) { | ||
throw new ProviderRpcError({ | ||
code: ProviderRpcErrorCode.UNSUPPORTED_METHOD, | ||
message: `FinoaConnect Provider does not support the requested method: ${args[0].method}` | ||
}) | ||
} | ||
throw err | ||
} | ||
} | ||
} | ||
return source | ||
} | ||
}) | ||
|
||
return { | ||
provider: proxyProvider | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default finoaConnect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/*"] | ||
} | ||
} | ||
} |
Oops, something went wrong.