Skip to content

Commit 5cb654c

Browse files
authored
Merge pull request #451 from blocknative/develop
Release 1.16.0
2 parents bedb7cd + 90e8b19 commit 5cb654c

File tree

6 files changed

+77
-5
lines changed

6 files changed

+77
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.15.0",
3+
"version": "1.16.0",
44
"description": "Onboard users to web3 by allowing them to select a wallet, get that wallet ready to transact and have access to synced wallet state.",
55
"keywords": [
66
"ethereum",
@@ -50,7 +50,7 @@
5050
"@portis/web3": "^2.0.0-beta.57",
5151
"@toruslabs/torus-embed": "^1.8.2",
5252
"@unilogin/provider": "^0.6.1",
53-
"@walletconnect/web3-provider": "^1.1.0",
53+
"@walletconnect/web3-provider": "^1.3.1",
5454
"authereum": "^0.0.4-beta.157",
5555
"bignumber.js": "^9.0.0",
5656
"bnc-sdk": "^2.1.4",

src/modules/select/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const defaultWalletNames = [
1515
'status',
1616
'hyperpay',
1717
'unilogin',
18-
'tokenpocket'
18+
'tokenpocket',
19+
'dcent'
1920
]
2021

2122
function select(
@@ -106,6 +107,8 @@ function getModule(name: string): Promise<any> | undefined {
106107
return import('./wallets/hyperpay')
107108
case 'tokenpocket':
108109
return import('./wallets/tokenpocket')
110+
case 'dcent':
111+
return import('./wallets/dcent')
109112
default:
110113
return
111114
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const dcentIcon = `
2+
<svg xmlns="http://www.w3.org/2000/svg" id="구성_요소_171_4" width="48" height="48" viewBox="0 0 48 48">
3+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4+
viewBox="0 0 62.27 71.11" style="enable-background:new 0 0 62.27 71.11;" xml:space="preserve">
5+
<style type="text/css">
6+
.st0{fill:#B3B5B5;}
7+
.st1{fill:#72BFBC;}
8+
.st2{fill:#6D6E70;}
9+
</style>
10+
<g>
11+
<polygon class="st0" points="32.04,13.43 37.34,10.37 37.34,3.06 32.04,0 32.04,0 "/>
12+
<path class="st1" d="M12.53,45.25V24.69l17.71-10.22V0L0.9,16.94C0.34,17.26,0,17.86,0,18.5v33.88c0,0.03,0.01,0.07,0.01,0.1
13+
L12.53,45.25z"/>
14+
<path class="st2" d="M48.86,46.69L31.14,56.93L13.52,46.75L0.99,53.99l29.25,16.89c0.28,0.16,0.59,0.24,0.9,0.24
15+
c0.31,0,0.62-0.08,0.9-0.24l29.34-16.94c0.01,0,0.01-0.01,0.02-0.01L48.86,46.69z"/>
16+
<g>
17+
<path class="st0" d="M61.38,16.94l-11.63-6.71v7.3l-12.5,7.22l12.5,7.21v13.16l12.53,7.23V18.5
18+
C62.27,17.86,61.93,17.26,61.38,16.94z"/>
19+
</g>
20+
<polygon class="st2" points="24.93,31.85 24.94,46.18 37.1,39.16 37.1,24.83 "/>
21+
</g>
22+
</svg>
23+
`
24+
25+
export default dcentIcon

src/modules/select/wallets/dcent.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { extensionInstallMessage } from '../content'
2+
import { WalletModule, Helpers, CommonWalletOptions } from '../../../interfaces'
3+
4+
import dcentIcon from '../wallet-icons/icon-dcent'
5+
6+
function dcent(options: CommonWalletOptions): WalletModule {
7+
const { preferred, label, iconSrc, svg } = options
8+
const url = (window as any).location.origin || (window as any).location.host
9+
const encodedUrl = encodeURIComponent(url)
10+
return {
11+
name: label || 'D\'CENT',
12+
svg: svg || dcentIcon,
13+
iconSrc,
14+
wallet: async (helpers: Helpers) => {
15+
const {
16+
getProviderName,
17+
createModernProviderInterface,
18+
createLegacyProviderInterface
19+
} = helpers
20+
21+
const provider = (window as any).ethereum ||
22+
(window as any).web3 && (window as any).web3.currentProvider
23+
24+
return {
25+
provider,
26+
interface:
27+
provider && getProviderName(provider) === 'D\'CENT'
28+
? typeof provider.enable === 'function'
29+
? createModernProviderInterface(provider)
30+
: createLegacyProviderInterface(provider)
31+
: null
32+
}
33+
},
34+
type: 'injected',
35+
link: 'https://link.dcentwallet.com/DAppBrowser/?url='+ encodedUrl ,
36+
installMessage: extensionInstallMessage,
37+
mobile: true,
38+
preferred
39+
}
40+
}
41+
42+
export default dcent

src/modules/select/wallets/metamask.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function metamask(options: CommonWalletOptions): WalletModule {
3434
}
3535
},
3636
type: 'injected',
37-
link: 'https://metamask.io/',
37+
link: `https://metamask.app.link/dapp/${window.location.host}`,
3838
installMessage: extensionInstallMessage,
3939
desktop: true,
4040
mobile: true,

src/utilities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ export function getProviderName(provider: any): string | undefined {
191191
if (provider.isWalletIO) {
192192
return 'wallet.io'
193193
}
194-
194+
if (provider.isDcentWallet) {
195+
return 'D\'CENT'
196+
}
195197
if (provider.isTokenPocket) {
196198
return 'TokenPocket'
197199
}

0 commit comments

Comments
 (0)