Skip to content

Commit 314a9a7

Browse files
Add Enkrypt and MEW Wallet DApp browser as SDKs (#1291)
* devop: add enkrypt and mew wallet * chore: update version * update packages with necessary changes to fit current W3O patterns(versioning, injected packages changes, routing for docs) * Remove enkrypt from injected provider labels * Remove yarn lock within mew package * Mark mew package as deprecated * devop: remove unused packages * devop: move tsconfig to the right places, fix build * devop: remove tsconfig in the wrong place * Update docs and deploy for new mew-wallet package * Update enkrypt injected provider * Update injected, MEW Wallet and Enkrypt packages * Update handling of ChainIds * fix: throw error for unsupported chains * chore: make mew wallet throw error on unsupported chains * devop: add check for ios unsupported chains * chore: change error * chore: change error * chore: change error * chore: remove console * chore: remove hex conversion code * Remove package level yarn.lock files * Remove unused mew icon from injected package * Add yarn options to readmes * Clean up log * Bump mew package version to display deprecated warning * chore: update logo * Update packages/enkrypt/README.md * Prettier formatting * Apply suggestions from code review * Refine mew package.json Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
1 parent 95ad7d7 commit 314a9a7

File tree

24 files changed

+501
-10
lines changed

24 files changed

+501
-10
lines changed

.circleci/config.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ jobs:
219219
working_directory: ~/web3-onboard-monorepo/packages/mew
220220
steps:
221221
- node-build-steps
222+
build-mew-wallet:
223+
docker:
224+
- image: cimg/node:16.13.1
225+
working_directory: ~/web3-onboard-monorepo/packages/mew-wallet
226+
steps:
227+
- node-build-steps
222228
build-portis:
223229
docker:
224230
- image: cimg/node:16.13.1
@@ -309,6 +315,12 @@ jobs:
309315
working_directory: ~/web3-onboard-monorepo/packages/tallyho
310316
steps:
311317
- node-build-steps
318+
build-enkrypt:
319+
docker:
320+
- image: cimg/node:16.13.1
321+
working_directory: ~/web3-onboard-monorepo/packages/enkrypt
322+
steps:
323+
- node-build-steps
312324

313325
# Build staging/Alpha releases
314326
build-staging-core:
@@ -365,6 +377,12 @@ jobs:
365377
working_directory: ~/web3-onboard-monorepo/packages/mew
366378
steps:
367379
- node-staging-build-steps
380+
build-staging-mew-wallet:
381+
docker:
382+
- image: cimg/node:16.13.1
383+
working_directory: ~/web3-onboard-monorepo/packages/mew-wallet
384+
steps:
385+
- node-staging-build-steps
368386
build-staging-portis:
369387
docker:
370388
- image: cimg/node:16.13.1
@@ -455,6 +473,12 @@ jobs:
455473
working_directory: ~/web3-onboard-monorepo/packages/tallyho
456474
steps:
457475
- node-staging-build-steps
476+
build-staging-enkrypt:
477+
docker:
478+
- image: cimg/node:16.13.1
479+
working_directory: ~/web3-onboard-monorepo/packages/enkrypt
480+
steps:
481+
- node-staging-build-steps
458482

459483
workflows:
460484
version: 2
@@ -513,6 +537,12 @@ workflows:
513537
<<: *deploy_production_filters
514538
- build-staging-mew:
515539
<<: *deploy_staging_filters
540+
mew-wallet:
541+
jobs:
542+
- build-mew-wallet:
543+
<<: *deploy_production_filters
544+
- build-staging-mew-wallet:
545+
<<: *deploy_staging_filters
516546
portis:
517547
jobs:
518548
- build-portis:
@@ -603,3 +633,9 @@ workflows:
603633
<<: *deploy_production_filters
604634
- build-staging-tallyho:
605635
<<: *deploy_staging_filters
636+
enkrypt:
637+
jobs:
638+
- build-enkrypt:
639+
<<: *deploy_production_filters
640+
- build-staging-enkrypt:
641+
<<: *deploy_staging_filters

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ For full documentation, check out the README.md for each package:
9393
- [Magic](packages/magic/README.md)
9494
- [Fortmatic](packages/fortmatic/README.md)
9595
- [Portis](packages/portis/README.md)
96-
- [MEW](packages/mew/README.md)
96+
- [MEW-Wallet](packages/mew-wallet/README.md)
9797
- [Web3Auth](packages/web3auth/README.md)
9898
- [Sequence](packages/sequence/README.md)
9999
- [TallyHo](packages/tallyho/README.md)
100+
- [Enkrypt](packages/enkrypt/README.md)
100101

101102
**Hardware Wallets**
102103

packages/demo/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@web3-onboard/fortmatic": "^2.0.14",
2929
"@web3-onboard/gas": "^2.1.3",
3030
"@web3-onboard/gnosis": "^2.1.3",
31-
"@web3-onboard/injected-wallets": "^2.3.0",
31+
"@web3-onboard/injected-wallets": "^2.4.0-alpha.1",
3232
"@web3-onboard/keepkey": "^2.3.2",
3333
"@web3-onboard/keystone": "^2.3.2",
3434
"@web3-onboard/ledger": "^2.3.2",
@@ -40,6 +40,8 @@
4040
"@web3-onboard/tallyho": "^2.0.1",
4141
"@web3-onboard/walletconnect": "^2.2.0-alpha.1",
4242
"@web3-onboard/web3auth": "^2.1.3",
43+
"@web3-onboard/enkrypt": "^2.0.0-alpha.1",
44+
"@web3-onboard/mew-wallet": "^2.0.0-alpha.1",
4345
"vconsole": "^3.9.5"
4446
},
4547
"license": "MIT",

packages/demo/src/App.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import dcentModule from '@web3-onboard/dcent'
1818
import sequenceModule from '@web3-onboard/sequence'
1919
import tallyHoModule from '@web3-onboard/tallyho'
20+
import enkryptModule from '@web3-onboard/enkrypt'
21+
import mewWalletModule from '@web3-onboard/mew-wallet'
2022
import {
2123
recoverAddress,
2224
arrayify,
@@ -107,13 +109,18 @@
107109
108110
const sequence = sequenceModule()
109111
112+
const enrkypt = enkryptModule()
113+
const mewWallet = mewWalletModule()
114+
110115
const onboard = Onboard({
111116
wallets: [
112117
injected,
113118
web3auth,
114119
ledger,
115120
trezor,
116121
walletConnect,
122+
enrkypt,
123+
mewWallet,
117124
keepkey,
118125
keystone,
119126
coinbaseWallet,

packages/enkrypt/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# @web3-onboard/enkrypt
2+
3+
## Wallet module for connecting Enkrypt wallet through web3-onboard
4+
5+
### Install
6+
7+
**NPM**
8+
`npm i @web3-onboard/core @web3-onboard/enkrypt`
9+
10+
**Yarn**
11+
`yarn add @web3-onboard/core @web3-onboard/enkrypt`
12+
13+
## Usage
14+
15+
```typescript
16+
import Onboard from '@web3-onboard/core'
17+
import enrkypt from '@web3-onboard/enkrypt'
18+
19+
const enrkyptModule = enrkypt()
20+
21+
const onboard = Onboard({
22+
// ... other Onboard options
23+
wallets: [
24+
enrkyptModule
25+
//... other wallets
26+
]
27+
})
28+
29+
const connectedWallets = await onboard.connectWallet()
30+
console.log(connectedWallets)
31+
```

packages/enkrypt/package.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "@web3-onboard/enkrypt",
3+
"version": "2.0.0-alpha.1",
4+
"description": "Enkrypt SDK 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+
"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+
"Enkrypt"
36+
],
37+
"repository": {
38+
"type": "git",
39+
"url": "https://github.com/blocknative/web3-onboard.git",
40+
"directory": "packages/core"
41+
},
42+
"homepage": "https://www.blocknative.com/onboard",
43+
"bugs": "https://github.com/blocknative/web3-onboard/issues",
44+
"module": "dist/index.js",
45+
"browser": "dist/index.js",
46+
"main": "dist/index.js",
47+
"type": "module",
48+
"typings": "dist/index.d.ts",
49+
"files": [
50+
"dist"
51+
],
52+
"scripts": {
53+
"build": "tsc",
54+
"dev": "tsc -w",
55+
"type-check": "tsc --noEmit"
56+
},
57+
"license": "MIT",
58+
"devDependencies": {
59+
"@ethersproject/providers": "^5.5.0",
60+
"@types/node": "^17.0.21",
61+
"ts-node": "^10.2.1",
62+
"typescript": "^4.5.5",
63+
"window": "^4.2.7"
64+
},
65+
"dependencies": {
66+
"@web3-onboard/common": "^2.2.2"
67+
}
68+
}

packages/enkrypt/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="81" height="81" viewBox="0 0 81 81" fill="none" xmlns="http://www.w3.org/2000/svg">
3+
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.0057 17.0062C18.9303 15.0816 21.5405 14.0004 24.2622 14.0004L67.3296 14V21.8741C67.3296 23.8305 66.5523 25.7067 65.169 27.09C63.7857 28.4733 61.9095 29.2504 59.9532 29.2504H39.7045C36.9828 29.2504 34.3726 30.3316 32.448 32.2561C30.5235 34.1807 29.4423 36.7909 29.4423 39.5126V42.1242C29.4423 44.8459 30.5235 47.4561 32.448 49.3806C34.3726 51.3051 36.9828 52.3863 39.7045 52.3863H59.9532C61.9095 52.3863 63.7857 53.1635 65.169 54.5468C66.5523 55.9301 67.3296 57.8063 67.3296 59.7626V67.33H24.2622C21.5405 67.33 18.9303 66.2488 17.0057 64.3243C15.0812 62.3997 14 59.7895 14 57.0678V24.2626C14 21.5409 15.0812 18.9307 17.0057 17.0062ZM40.1479 33.5423H60.9157C64.458 33.5423 67.3295 36.4138 67.3295 39.9561V41.6816C67.3295 45.2238 64.458 48.0954 60.9157 48.0954H40.1479C36.6057 48.0954 33.7341 45.2238 33.7341 41.6816V39.9561C33.7341 36.4138 36.6057 33.5423 40.1479 33.5423Z" fill="url(#paint0_linear_287_2359)"/>
4+
<defs>
5+
<linearGradient id="paint0_linear_287_2359" x1="19.3602" y1="14" x2="56.7696" y2="69.8005" gradientUnits="userSpaceOnUse">
6+
<stop stop-color="#C549FF"/>
7+
<stop offset="1" stop-color="#654BFF"/>
8+
</linearGradient>
9+
</defs>
10+
</svg>
11+
12+
`

packages/enkrypt/src/index.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type {
2+
WalletInit,
3+
SimpleEventEmitter,
4+
EIP1193Provider
5+
} from '@web3-onboard/common'
6+
import { createEIP1193Provider } from '@web3-onboard/common'
7+
import { CustomWindow } from './types.js'
8+
declare const window: CustomWindow
9+
10+
function enkrypt(): WalletInit {
11+
if (typeof window === 'undefined') return () => null
12+
return () => {
13+
return {
14+
label: 'Enkrypt',
15+
getIcon: async () => (await import('./icon.js')).default,
16+
getInterface: async () => {
17+
const enkryptExists = window.hasOwnProperty('enkrypt')
18+
19+
if (enkryptExists) {
20+
const enkryptProvider: EIP1193Provider = window.enkrypt.providers
21+
.ethereum as EIP1193Provider
22+
const addListener: SimpleEventEmitter['on'] =
23+
enkryptProvider.on.bind(enkryptProvider)
24+
25+
enkryptProvider.on = (event, func) => {
26+
addListener(event, func)
27+
}
28+
29+
const provider = createEIP1193Provider(enkryptProvider)
30+
31+
provider.removeListener = (event, func) => {}
32+
33+
return {
34+
provider
35+
}
36+
} else {
37+
window.open('https://enkrypt.com', '_blank')
38+
throw new Error('Please Install Enkrypt to use this wallet')
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
export default enkrypt

packages/enkrypt/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { ExternalProvider } from '@ethersproject/providers'
2+
export interface CustomWindow extends Window {
3+
enkrypt: {
4+
providers: { ethereum: ExternalProvider }
5+
}
6+
}

packages/enkrypt/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+
"paths": {
11+
"*": ["./src/*", "./node_modules/*"]
12+
},
13+
"typeRoots": ["node_modules/@types"]
14+
}
15+
}

0 commit comments

Comments
 (0)