Skip to content

Commit 8a9f127

Browse files
authored
Merge pull request #422 from blocknative/develop
Release 1.11.1
2 parents 3b24626 + 38b3378 commit 8a9f127

File tree

11 files changed

+105
-19
lines changed

11 files changed

+105
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.11.0",
3+
"version": "1.11.1",
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",

src/components/Modal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/* .bn-onboard-modal */
1414
aside {
1515
display: flex;
16-
font-family: 'Helvetica Neue';
16+
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
1717
justify-content: center;
1818
align-items: center;
1919
position: fixed;

src/interfaces.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,7 @@ export interface WalletLinkOptions extends CommonWalletOptions {
321321
rpcUrl: string
322322
}
323323

324-
export interface ImTokenOptions extends CommonWalletOptions {
325-
rpcUrl?: string
326-
}
327-
328-
export interface TrustWalletOptions extends CommonWalletOptions {
324+
export interface InjectedWithBalanceOptions extends CommonWalletOptions {
329325
rpcUrl?: string
330326
}
331327

@@ -337,8 +333,7 @@ export type WalletInitOptions =
337333
| TrezorOptions
338334
| AuthereumOptions
339335
| LedgerOptions
340-
| ImTokenOptions
341-
| TrustWalletOptions
336+
| InjectedWithBalanceOptions
342337

343338
export type AllWalletInitOptions = CommonWalletOptions &
344339
SdkWalletOptions &
@@ -348,8 +343,7 @@ export type AllWalletInitOptions = CommonWalletOptions &
348343
AuthereumOptions &
349344
LedgerOptions &
350345
WalletLinkOptions &
351-
ImTokenOptions &
352-
TrustWalletOptions & { networkId: number }
346+
InjectedWithBalanceOptions & { networkId: number }
353347

354348
export interface WalletCheckCustomOptions {
355349
heading?: string

src/modules/select/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { WalletModule, WalletInitOptions } from '../../interfaces'
22
import { isWalletInit } from '../../validation'
33

44
// wallets that qualify for default wallets need to have no
5-
// init parameters that are required
5+
// init parameters that are required for full functionality
66
const defaultWalletNames = [
77
'metamask',
88
'dapper',
@@ -92,6 +92,8 @@ function getModule(name: string): Promise<any> | undefined {
9292
return import('./wallets/imtoken')
9393
case 'unilogin':
9494
return import('./wallets/unilogin')
95+
case 'mykey':
96+
return import('./wallets/mykey')
9597
default:
9698
return
9799
}
2.16 KB
Loading
Loading

src/modules/select/wallets/imtoken.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { mobileWalletInstallMessage } from '../content'
2-
import { WalletModule, Helpers, ImTokenOptions } from '../../../interfaces'
2+
import {
3+
WalletModule,
4+
Helpers,
5+
InjectedWithBalanceOptions
6+
} from '../../../interfaces'
37

48
import imTokenIcon from '../wallet-icons/icon-imtoken'
59

6-
function imtoken(options: ImTokenOptions): WalletModule {
10+
function imtoken(options: InjectedWithBalanceOptions): WalletModule {
711
const { preferred, label, iconSrc, svg, rpcUrl } = options
812

913
return {

src/modules/select/wallets/meetone.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { extensionInstallMessage } from '../content'
1+
import { mobileWalletInstallMessage } from '../content'
22
import { WalletModule, Helpers, CommonWalletOptions } from '../../../interfaces'
33

44
import meetoneIcon from '../wallet-icons/icon-meetone.png'
@@ -29,7 +29,7 @@ function meetone(options: CommonWalletOptions): WalletModule {
2929
},
3030
type: 'injected',
3131
link: 'https://meet.one',
32-
installMessage: extensionInstallMessage,
32+
installMessage: mobileWalletInstallMessage,
3333
mobile: true,
3434
preferred
3535
}

src/modules/select/wallets/mykey.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { mobileWalletInstallMessage } from '../content'
2+
import {
3+
WalletModule,
4+
Helpers,
5+
InjectedWithBalanceOptions
6+
} from '../../../interfaces'
7+
8+
import mykeyIcon from '../wallet-icons/icon-mykey.png'
9+
import mykeyIcon2x from '../wallet-icons/icon-mykey@2x.png'
10+
11+
function mykey(options: InjectedWithBalanceOptions): WalletModule {
12+
const { preferred, label, iconSrc, svg, rpcUrl } = options
13+
14+
return {
15+
name: label || 'MYKEY',
16+
iconSrc: iconSrc || mykeyIcon,
17+
iconSrcSet: iconSrc || mykeyIcon2x,
18+
svg,
19+
wallet: async (helpers: Helpers) => {
20+
const { getProviderName, getAddress, getNetwork, getBalance } = helpers
21+
const myKeyProvider =
22+
(window as any).ethereum ||
23+
((window as any).web3 && (window as any).web3.currentProvider)
24+
25+
const isMyKey = getProviderName(myKeyProvider) === 'MYKEY'
26+
let createProvider
27+
28+
if (isMyKey && rpcUrl) {
29+
createProvider = (await import('./providerEngine')).default
30+
}
31+
32+
const provider = createProvider ? createProvider({ rpcUrl }) : null
33+
34+
let warned = false
35+
36+
return {
37+
provider: myKeyProvider,
38+
interface: isMyKey
39+
? {
40+
address: {
41+
get: () => getAddress(myKeyProvider)
42+
},
43+
network: {
44+
get: () => getNetwork(myKeyProvider)
45+
},
46+
balance: {
47+
get: async () => {
48+
if (!provider) {
49+
if (!warned) {
50+
console.warn(
51+
'The MYKEY provider does not allow rpc calls preventing Onboard.js from getting the balance. You can pass in a "rpcUrl" to the MYKEY wallet initialization object to get the balance.'
52+
)
53+
warned = true
54+
}
55+
56+
return null
57+
}
58+
59+
const address = await getAddress(myKeyProvider)
60+
61+
return getBalance(provider, address)
62+
}
63+
},
64+
name: getProviderName(myKeyProvider)
65+
}
66+
: null
67+
}
68+
},
69+
type: 'injected',
70+
link: 'https://mykey.org/download',
71+
installMessage: mobileWalletInstallMessage,
72+
mobile: true,
73+
preferred
74+
}
75+
}
76+
77+
export default mykey

src/modules/select/wallets/trust.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { mobileWalletInstallMessage } from '../content'
2-
import { WalletModule, Helpers, TrustWalletOptions } from '../../../interfaces'
2+
import {
3+
WalletModule,
4+
Helpers,
5+
InjectedWithBalanceOptions
6+
} from '../../../interfaces'
37

48
import trustIcon from '../wallet-icons/icon-trust'
59

6-
function trust(options: TrustWalletOptions): WalletModule {
10+
function trust(options: InjectedWithBalanceOptions): WalletModule {
711
const { preferred, label, iconSrc, svg, rpcUrl } = options
812

913
return {
@@ -13,7 +17,8 @@ function trust(options: TrustWalletOptions): WalletModule {
1317
wallet: async (helpers: Helpers) => {
1418
const { getProviderName, getAddress, getNetwork, getBalance } = helpers
1519
const trustProvider =
16-
(window as any).web3 && (window as any).web3.currentProvider
20+
(window as any).ethereum ||
21+
((window as any).web3 && (window as any).web3.currentProvider)
1722

1823
const isTrust = getProviderName(trustProvider) === 'Trust'
1924
let createProvider

src/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ export function getProviderName(provider: any): string | undefined {
211211
return 'MetaMask'
212212
}
213213

214+
if (provider.isMYKEY) {
215+
return 'MYKEY'
216+
}
217+
214218
if (provider.host && provider.host.indexOf('localhost') !== -1) {
215219
return 'localhost'
216220
}

0 commit comments

Comments
 (0)