Skip to content

Commit 40898a9

Browse files
David FuAdamj1232
David Fu
andauthored
feat: add Venly connector to packages (#1660)
* feat: add venly connector * chore: add venly.md to docs * Update docs/src/routes/docs/[...4]wallets/venly.md Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> * Update packages/venly/README.md Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> * Update packages/venly/package.json Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> * dynamically import @venly/web3-provider * add details for VenlyProviderOptions * environment as optional param * add VenlyProviderOptions details to package README.md * simplify VenlyOptions - only clientId required. update documentation to match * update @venly/web3-provider to latest release * add environment option with typescript documentation * add venly to demo-app. update config and core.md for zlib * update demo clientId. update README. fix issues with switching environment * Add venly to internal demo and test * update web3-provider to 3.1.1 which fixes/updates chain switching. Update README with list of supported networks --------- Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
1 parent 809ddb5 commit 40898a9

File tree

11 files changed

+415
-14
lines changed

11 files changed

+415
-14
lines changed

docs/src/routes/docs/[...3]modules/[...1]core/+page.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,8 @@ module.exports = {
14761476
os: 'os-browserify/browser',
14771477
process: 'process/browser',
14781478
stream: 'stream-browserify',
1479-
util: 'util'
1479+
util: 'util',
1480+
zlib: 'browserify-zlib'
14801481
}
14811482
},
14821483
experiments: {
@@ -1525,7 +1526,8 @@ module.exports = function override(config) {
15251526
process: require.resolve('process/browser'),
15261527
stream: require.resolve('stream-browserify'),
15271528
url: require.resolve('url'),
1528-
util: require.resolve('util')
1529+
util: require.resolve('util'),
1530+
zlib: require.resolve('browserify-zlib')
15291531
})
15301532
config.resolve.fallback = fallback
15311533
config.resolve.alias = {
@@ -1564,7 +1566,7 @@ module.exports = function override(config) {
15641566

15651567
Add the following dev dependencies:
15661568

1567-
`yarn add rollup-plugin-polyfill-node crypto-browserify stream-browserify assert -D`
1569+
`yarn add rollup-plugin-polyfill-node crypto-browserify stream-browserify assert browserify-zlib -D`
15681570

15691571
Then add the following to your `svelte.config.js` file:
15701572

@@ -1594,7 +1596,8 @@ const config = {
15941596
alias: {
15951597
crypto: 'crypto-browserify',
15961598
stream: 'stream-browserify',
1597-
assert: 'assert'
1599+
assert: 'assert',
1600+
zlib: 'browserify-zlib'
15981601
}
15991602
},
16001603
build: {
@@ -1629,7 +1632,7 @@ Checkout a boilerplate example [here](https://github.com/blocknative/web3-onboar
16291632

16301633
Add the following dev dependencies:
16311634

1632-
`yarn add rollup-plugin-polyfill-node crypto-browserify stream-browserify assert -D`
1635+
`yarn add rollup-plugin-polyfill-node crypto-browserify stream-browserify assert browserify-zlib -D`
16331636

16341637
Then add the following to your `svelte.config.js` file:
16351638

@@ -1677,7 +1680,8 @@ const config: UserConfig = {
16771680
alias: {
16781681
crypto: 'crypto-browserify',
16791682
stream: 'stream-browserify',
1680-
assert: 'assert'
1683+
assert: 'assert',
1684+
zlib: 'browserify-zlib'
16811685
}
16821686
},
16831687
build: {
@@ -1742,7 +1746,7 @@ Checkout a boilerplate example for Vite-React [here](https://github.com/blocknat
17421746

17431747
Add the following dev dependencies:
17441748

1745-
`npm i --save-dev rollup-plugin-polyfill-node crypto-browserify stream-browserify assert`
1749+
`npm i --save-dev rollup-plugin-polyfill-node crypto-browserify stream-browserify assert browserify-zlib`
17461750

17471751
Then add the following to your `vite.config.js` file:
17481752

@@ -1764,7 +1768,8 @@ export default {
17641768
alias: {
17651769
crypto: 'crypto-browserify',
17661770
stream: 'stream-browserify',
1767-
assert: 'assert'
1771+
assert: 'assert',
1772+
zlib: 'browserify-zlib'
17681773
}
17691774
},
17701775
build: {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Venly
2+
3+
Wallet module for connecting Venly Wallet SDK to web3-onboard. Check out the [Venly Docs](https://docs.venly.io/) for more information.
4+
## Install
5+
6+
<Tabs values={['yarn', 'npm']}>
7+
<TabPanel value="yarn">
8+
9+
```sh copy
10+
yarn add @web3-onboard/venly
11+
```
12+
13+
</TabPanel>
14+
<TabPanel value="npm">
15+
16+
```sh copy
17+
npm install @web3-onboard/venly
18+
```
19+
20+
</TabPanel>
21+
</Tabs>
22+
23+
## Options
24+
25+
```typescript
26+
type VenlyOptions = {
27+
clientId: string
28+
environment?: string
29+
}
30+
```
31+
32+
`clientId` - The Client ID used to connect with Venly. More information can be found [here](https://docs.venly.io/widget/deep-dive/authentication#client-id).
33+
`environment` - The environment to which you want to connect, possible values are 'staging' and 'production'. Defaults to 'production'.
34+
35+
**NOTE**: Production environment handles main networks while Staging handles test networks. List of supported networks can be found [here](https://docs.venly.io/api/deep-dive-1/environments-and-networks#blockchain-networks).
36+
37+
## Usage
38+
39+
```typescript
40+
import Onboard from '@web3-onboard/core'
41+
import venlyModule from '@web3-onboard/venly'
42+
43+
// initialize the module with options
44+
const venly = venlyModule({
45+
clientId: 'YOUR_CLIENT_ID',
46+
})
47+
48+
const onboard = Onboard({
49+
// ... other Onboard options
50+
wallets: [
51+
venly
52+
//... other wallets
53+
]
54+
})
55+
56+
const connectedWallets = await onboard.connectWallet()
57+
console.log(connectedWallets)
58+
```
59+
60+
## Build Environments
61+
For build env configurations and setups please see the Build Env section [here](/docs/modules/core#build-environments)

packages/demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@web3-onboard/trezor": "^2.4.2",
5151
"@web3-onboard/trust": "^2.0.3",
5252
"@web3-onboard/uauth": "^2.0.4",
53+
"@web3-onboard/venly": "^2.0.0-alpha.1",
5354
"@web3-onboard/walletconnect": "^2.3.8",
5455
"@web3-onboard/web3auth": "^2.2.2",
5556
"@web3-onboard/xdefi": "^2.0.3",

packages/demo/src/App.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import trustModule from '@web3-onboard/trust'
3030
import frontierModule from '@web3-onboard/frontier'
3131
import cedeStoreModule from '@web3-onboard/cede-store'
32+
import venlyModule from '@web3-onboard/venly'
3233
import {
3334
recoverAddress,
3435
arrayify,
@@ -179,6 +180,10 @@
179180
const transactionPreview = transactionPreviewModule({
180181
requireTransactionApproval: true
181182
})
183+
const venly = venlyModule({
184+
clientId: 'blocknative',
185+
environment: 'staging'
186+
})
182187
183188
const onboard = Onboard({
184189
wallets: [
@@ -208,7 +213,8 @@
208213
frontier,
209214
xdefi,
210215
frameWallet,
211-
cedeStore
216+
cedeStore,
217+
venly
212218
],
213219
transactionPreview,
214220
gas,

packages/demo/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ module.exports = {
2222
os: 'os-browserify/browser',
2323
process: 'process/browser',
2424
stream: 'stream-browserify',
25-
util: 'util'
25+
util: 'util',
26+
zlib: 'browserify-zlib'
2627
},
2728
extensions: ['.mjs', '.js', '.svelte'],
2829
mainFields: ['svelte', 'browser', 'module', 'main']

packages/venly/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# @web3-onboard/venly
2+
3+
## Wallet module for connecting Venly SDK to web3-onboard
4+
See [Venly SDK Docs](https://docs.venly.io/widget/) for complete documentation of Venly usage
5+
6+
### Install
7+
8+
`npm install @web3-onboard/venly`
9+
10+
## Options
11+
12+
```typescript
13+
type VenlyOptions = {
14+
clientId: string
15+
environment?: string
16+
}
17+
```
18+
19+
`clientId` - The Client ID used to connect with Venly. More information can be found [here](https://docs.venly.io/widget/deep-dive/authentication#client-id).
20+
`environment` - The environment to which you want to connect, possible values are 'staging' and 'production'. Defaults to 'production'.
21+
22+
**NOTE**: Production environment handles main networks while Staging handles test networks. List of supported networks can be found [here](https://docs.venly.io/api/deep-dive-1/environments-and-networks#blockchain-networks).
23+
24+
## Usage
25+
26+
```typescript
27+
import Onboard from '@web3-onboard/core'
28+
import venlyModule from '@web3-onboard/venly'
29+
30+
// initialize the module with options
31+
const venly = venlyModule({
32+
clientId: 'YOUR_CLIENT_ID'
33+
})
34+
35+
const onboard = Onboard({
36+
// ... other Onboard options
37+
wallets: [
38+
venly
39+
//... other wallets
40+
]
41+
})
42+
43+
const connectedWallets = await onboard.connectWallet()
44+
console.log(connectedWallets)
45+
```

packages/venly/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@web3-onboard/venly",
3+
"version": "2.0.0-alpha.1",
4+
"description": "Venly wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
5+
"keywords": [
6+
"Ethereum",
7+
"Web3",
8+
"EVM",
9+
"dapp",
10+
"Multichain",
11+
"Wallet",
12+
"Transaction",
13+
"Provider",
14+
"Notifications",
15+
"React",
16+
"Venly",
17+
"Connect Wallet",
18+
"Ethereum Hooks",
19+
"Blocknative",
20+
"Crypto",
21+
"Crypto Wallet"
22+
],
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/blocknative/web3-onboard.git",
26+
"directory": "packages/venly"
27+
},
28+
"homepage": "https://onboard.blocknative.com",
29+
"bugs": "https://github.com/blocknative/web3-onboard/issues",
30+
"module": "dist/index.js",
31+
"browser": "dist/index.js",
32+
"main": "dist/index.js",
33+
"type": "module",
34+
"typings": "dist/index.d.ts",
35+
"files": [
36+
"dist"
37+
],
38+
"scripts": {
39+
"build": "tsc",
40+
"dev": "tsc -w",
41+
"type-check": "tsc --noEmit"
42+
},
43+
"license": "MIT",
44+
"devDependencies": {
45+
"typescript": "^4.5.5"
46+
},
47+
"dependencies": {
48+
"@venly/web3-provider": "^3.1.1",
49+
"@web3-onboard/common": "^2.3.1"
50+
}
51+
}

packages/venly/src/icon.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default `
2+
<svg width="100%" height="100%" viewBox="0 0 1080 1080" fill="none" xmlns="http://www.w3.org/2000/svg">
3+
<rect width="1080" height="1080" fill="url(#paint0_linear)" rx="20%"/>
4+
<path d="M834.167 474.367L760.572 502.319C757.478 503.445 754.478 500.443 755.79 497.348L837.823 298.208C839.042 295.206 836.135 292.111 833.135 293.237L677.227 347.829C674.227 348.861 671.789 351.206 670.57 354.207L564.913 620.884C563.6 624.261 566.882 627.638 570.257 626.418L636.257 602.218C639.914 600.904 643.289 604.844 641.32 608.315L544.381 772.936C542.319 776.5 537.069 776.5 535.006 772.936L438.067 608.221C436.098 604.844 439.38 600.811 443.13 602.124L509.131 626.324C512.506 627.544 515.787 624.167 514.475 620.79L408.723 354.207C407.504 351.206 405.16 348.954 402.067 347.829L246.346 293.237C243.252 292.205 240.439 295.206 241.658 298.208L323.597 497.348C324.816 500.35 321.816 503.445 318.815 502.319L245.689 474.367C241.939 472.96 238.564 476.993 240.627 480.464L458.317 841.035C460.474 844.6 464.318 846.757 468.536 846.757H611.226C615.351 846.757 619.288 844.6 621.445 841.035L839.51 480.464C841.292 476.993 837.917 472.96 834.167 474.367Z" fill="white"/>
5+
<defs>
6+
<linearGradient id="paint0_linear" x1="435.874" y1="-3.23691e-05" x2="1146.57" y2="178.471" gradientUnits="userSpaceOnUse">
7+
<stop stop-color="#7735E8"/>
8+
<stop offset="1" stop-color="#C62CF1"/>
9+
</linearGradient>
10+
</defs>
11+
</svg>
12+
`

packages/venly/src/index.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { WalletInit } from '@web3-onboard/common'
2+
3+
interface VenlyOptions {
4+
/** @property {string} clientId - The Client ID used to connect with Venly. More information at https://docs.venly.io/widget/deep-dive/authentication#client-id */
5+
clientId: string
6+
/** @property {string} environment - The environment to which you want to connect, possible values are 'staging' and 'production'. Defaults to 'production' */
7+
environment?: string
8+
}
9+
10+
function venly(options: VenlyOptions): WalletInit {
11+
return () => {
12+
return {
13+
label: 'Venly',
14+
getIcon: async () => (await import('./icon.js')).default,
15+
getInterface: async ({ chains }) => {
16+
const { VenlyProvider, SECRET_TYPES } = await import('@venly/web3-provider')
17+
18+
const chainId = +chains[0].id
19+
const chain = SECRET_TYPES[chainId]
20+
if (!chain)
21+
throw new Error('Chain not supported')
22+
23+
const providerOptions = { ...options, secretType: chain.secretType }
24+
if (!options.environment)
25+
providerOptions.environment = chain.env
26+
27+
const instance = new VenlyProvider()
28+
const provider = await instance.createProvider(providerOptions)
29+
30+
return {
31+
provider,
32+
instance
33+
}
34+
}
35+
}
36+
}
37+
}
38+
39+
export default venly

packages/venly/tsconfig.json

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

0 commit comments

Comments
 (0)