Skip to content

Commit a8872dd

Browse files
authored
Merge pull request #523 from blocknative/release/1.22.0
Release 1.22.0
2 parents 26610a0 + ae63627 commit a8872dd

File tree

9 files changed

+80
-12
lines changed

9 files changed

+80
-12
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.21.0",
3+
"version": "1.22.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",

src/interfaces.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ export interface CommonWalletOptions {
171171
label?: string
172172
iconSrc?: string
173173
svg?: string
174-
isMobile: boolean
175174
}
176175

177176
export interface SdkWalletOptions extends CommonWalletOptions {
@@ -366,7 +365,7 @@ export type AllWalletInitOptions = CommonWalletOptions &
366365
AuthereumOptions &
367366
LedgerOptions &
368367
WalletLinkOptions &
369-
InjectedWithBalanceOptions & { networkId: number }
368+
InjectedWithBalanceOptions & { networkId: number } & { isMobile: boolean }
370369

371370
export interface WalletCheckCustomOptions {
372371
heading?: string

src/modules/check/network.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
WalletCheckCustomOptions
66
} from '../../interfaces'
77
import { networkIcon } from './icons'
8+
import { app } from './../../stores'
9+
import { get } from 'svelte/store'
810

911
function network(
1012
options: WalletCheckCustomOptions = {}
@@ -30,7 +32,7 @@ function network(
3032
setTimeout(() => {
3133
if (network === null) {
3234
// if prom isn't resolving after 500ms, then stop waiting
33-
resolve()
35+
resolve(undefined)
3436
}
3537
}, 500)
3638
})

src/modules/select/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { WalletModule, WalletInitOptions } from '../../interfaces'
1+
import {
2+
WalletModule,
3+
WalletInitOptions,
4+
AllWalletInitOptions
5+
} from '../../interfaces'
26
import { isWalletInit } from '../../validation'
37

48
// wallets that qualify for default wallets need to have no
@@ -18,7 +22,8 @@ const mobileDefaultWalletNames = [
1822
'tokenpocket',
1923
'dcent',
2024
'atoken',
21-
'liquality'
25+
'liquality',
26+
'ownbit'
2227
]
2328

2429
function select(
@@ -64,7 +69,7 @@ function select(
6469
function getModule(
6570
name: string
6671
): Promise<{
67-
default: (options: any) => WalletModule
72+
default: (options: AllWalletInitOptions) => WalletModule
6873
}> {
6974
switch (name) {
7075
// Deprecated wallets
@@ -129,6 +134,8 @@ function getModule(
129134
return import('./wallets/liquality')
130135
case 'frame':
131136
return import('./wallets/frame')
137+
case 'ownbit':
138+
return import('./wallets/ownbit')
132139
default:
133140
throw new Error(`${name} is not a valid walletName.`)
134141
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const ownbitIcon = `
2+
<svg width="40px" height="40px" viewBox="0 0 132 132" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3+
<title>Shape Copy</title>
4+
<desc>Created with Sketch.</desc>
5+
<defs>
6+
<linearGradient x1="15.8%" y1="84.9%" x2="106.3%" y2="-17.2%" id="linearGradient-1">
7+
<stop stop-color="#0877FF" offset="0%"></stop>
8+
<stop stop-color="#3CCEF9" offset="100%"></stop>
9+
</linearGradient>
10+
</defs>
11+
<g id="Page-2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
12+
<path d="M65.8599735,0.000607031223 C64.4416737,0.000607031223 63.0363726,0.0454744869 61.6440701,0.135209398 C59.3754119,0.301605871 57.6214113,2.19771449 57.6274798,4.47722124 L57.6274798,32.8001645 C57.6294466,34.0359685 58.1568063,35.2123819 59.0774227,36.0346405 C59.9980391,36.8568991 61.224677,37.2470878 62.4499879,37.1074402 C63.5818523,36.9749894 64.7204182,36.9083004 65.8599735,36.9077077 C77.6016631,36.9077077 88.1871903,43.995619 92.6805403,54.8663598 C97.1738904,65.7371006 94.690175,78.2498645 86.3875466,86.5699693 C78.0849183,94.8900741 65.5984376,97.3790175 54.7505309,92.8762093 C43.9026243,88.373401 36.8296011,77.765592 36.8296011,65.999187 L36.8296011,19.2231276 C36.8304083,16.5637094 35.3161377,14.1371901 32.9297089,12.9738059 C30.54328,11.8104217 27.7035052,12.1143438 25.6160782,13.7565347 C9.44722987,26.2414401 -0.0174670853,45.544213 2.42011117e-05,65.999187 C2.42011117e-05,102.411298 30.0832892,132.297366 66.4189165,131.997767 C102.792362,131.843094 132.153742,102.169136 131.999394,65.7191272 C131.845046,29.269118 102.233419,-0.154065705 65.8599735,0.000607031223 Z" id="Shape-Copy" fill="url(#linearGradient-1)" fill-rule="nonzero"></path>
13+
</g>
14+
</svg>
15+
`
16+
17+
export default ownbitIcon

src/modules/select/wallets/metamask.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { WalletModule, Helpers, CommonWalletOptions } from '../../../interfaces'
44
import metamaskIcon from '../wallet-icons/icon-metamask.png'
55
import metamaskIcon2x from '../wallet-icons/icon-metamask@2x.png'
66

7-
function metamask(options: CommonWalletOptions): WalletModule {
7+
function metamask(
8+
options: CommonWalletOptions & { isMobile: boolean }
9+
): WalletModule {
810
const { preferred, label, iconSrc, svg, isMobile } = options
911

1012
return {

src/modules/select/wallets/ownbit.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { mobileWalletInstallMessage } from '../content'
2+
import { WalletModule, Helpers, CommonWalletOptions } from '../../../interfaces'
3+
4+
import ownbitIcon from '../wallet-icons/icon-ownbit'
5+
6+
function ownbit(options: CommonWalletOptions): WalletModule {
7+
const { preferred, label, iconSrc, svg } = options
8+
9+
return {
10+
name: label || 'Ownbit',
11+
iconSrc,
12+
svg: svg || ownbitIcon,
13+
wallet: async (helpers: Helpers) => {
14+
const { getProviderName, createModernProviderInterface } = helpers
15+
16+
const provider =
17+
(window as any).ethereum ||
18+
((window as any).web3 && (window as any).web3.currentProvider)
19+
20+
return {
21+
provider,
22+
interface:
23+
(getProviderName(provider) === 'Ownbit' &&
24+
createModernProviderInterface(provider)) ||
25+
null
26+
}
27+
},
28+
type: 'injected',
29+
link: 'https://ownbit.io',
30+
installMessage: mobileWalletInstallMessage,
31+
mobile: true,
32+
preferred
33+
}
34+
}
35+
36+
export default ownbit

src/stores.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function createWalletStateSliceStore(options: {
260260
if (onChange) {
261261
stateSyncStatus[parameter] = new Promise(resolve => {
262262
onChange(newVal => {
263-
resolve()
263+
resolve(undefined)
264264
if (newVal || currentState !== initialState) {
265265
set(newVal)
266266
}

src/utilities.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import bowser from 'bowser'
22
import BigNumber from 'bignumber.js'
3+
import { get } from 'svelte/store'
34

4-
import { WalletInterface } from './interfaces'
55
import { app } from './stores'
6-
import { get } from 'svelte/store'
6+
import { WalletInterface } from './interfaces'
77

88
export function getNetwork(provider: any): Promise<number | any> {
99
return new Promise((resolve, reject) => {
@@ -199,6 +199,10 @@ export function getProviderName(provider: any): string | undefined {
199199
return 'TokenPocket'
200200
}
201201

202+
if (provider.isOwnbit) {
203+
return 'Ownbit'
204+
}
205+
202206
if (provider.wallet === 'MEETONE') {
203207
return 'MEETONE'
204208
}
@@ -300,7 +304,8 @@ export function networkName(id: number): string {
300304
case 100:
301305
return 'xdai'
302306
default:
303-
return get(app).networkName || 'local'
307+
const { networkId, networkName } = get(app)
308+
return (networkId === id && networkName) || 'unknown'
304309
}
305310
}
306311

0 commit comments

Comments
 (0)