Skip to content

Commit c80f2cd

Browse files
authored
Merge pull request #492 from blocknative/release/1.19.1
Release/1.19.1
2 parents 148363b + 55c3494 commit c80f2cd

File tree

4 files changed

+53
-24
lines changed

4 files changed

+53
-24
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.19.0",
3+
"version": "1.19.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/interfaces.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ interface LocaleLinks<T> {
274274
ja?: T
275275
ko?: T
276276
de?: T
277-
zh?: T,
278-
es?: T,
277+
zh?: T
278+
es?: T
279279
}
280280

281281
interface ThemeParams {
@@ -307,7 +307,13 @@ export interface TorusOptions extends CommonWalletOptions {
307307
buttonPosition?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left'
308308
modalZIndex?: number
309309
apiKey?: string
310-
buildEnv?: 'production' | 'development' | 'binance' | 'testing' | 'lrc' | 'beta'
310+
buildEnv?:
311+
| 'production'
312+
| 'development'
313+
| 'binance'
314+
| 'testing'
315+
| 'lrc'
316+
| 'beta'
311317
enableLogging?: boolean
312318
enabledVerifiers?: VerifierStatus
313319
loginConfig?: LoginConfig

src/modules/select/wallets/status.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,39 @@ function status(options: CommonWalletOptions): WalletModule {
1212
iconSrcSet: iconSrc,
1313
svg: svg || statusIcon,
1414
wallet: async (helpers: Helpers) => {
15-
const { getProviderName, createModernProviderInterface } = helpers
15+
const { getProviderName, getAddress, getBalance, getNetwork } = helpers
1616

1717
const provider = (window as any).ethereum
18+
let accountsApproved = false
1819

1920
return {
2021
provider,
2122
interface:
2223
provider && getProviderName(provider) === 'Status'
23-
? createModernProviderInterface(provider)
24+
? {
25+
connect: () =>
26+
provider
27+
.request({
28+
method: 'eth_requestAccounts'
29+
})
30+
.then(() => (accountsApproved = true)),
31+
address: {
32+
get: () =>
33+
accountsApproved
34+
? getAddress(provider)
35+
: Promise.resolve(null)
36+
},
37+
balance: {
38+
get: () =>
39+
accountsApproved
40+
? getBalance(provider)
41+
: Promise.resolve(null)
42+
},
43+
network: {
44+
get: () => getNetwork(provider)
45+
},
46+
name: 'Status'
47+
}
2448
: null
2549
}
2650
},

src/utilities.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,23 @@ export function createModernProviderInterface(provider: any): WalletInterface {
148148
balance: {
149149
get: () => getBalance(provider)
150150
},
151-
connect: () =>
152-
new Promise(
153-
(resolve: () => void, reject: (err: { message: string }) => void) => {
154-
const request = provider.request
155-
? getAddress(provider).then((address: string) => {
156-
return address
157-
? address
158-
: provider.request({ method: 'eth_requestAccounts' })
159-
})
160-
: provider.enable()
161-
162-
return request.then(resolve).catch(() =>
163-
reject({
164-
message: 'This dapp needs access to your account information.'
165-
})
166-
)
151+
connect: async () => {
152+
try {
153+
if (provider.request) {
154+
const result = await provider.request({
155+
method: 'eth_requestAccounts'
156+
})
157+
return result
158+
} else {
159+
const result = await provider.enable()
160+
return result
167161
}
168-
),
162+
} catch (e) {
163+
throw {
164+
message: 'This dapp requires access to your account information.'
165+
}
166+
}
167+
},
169168
name: getProviderName(provider)
170169
}
171170
}
@@ -193,7 +192,7 @@ export function getProviderName(provider: any): string | undefined {
193192
}
194193
if (provider.isDcentWallet) {
195194
return 'D\'CENT'
196-
}
195+
}
197196
if (provider.isTokenPocket) {
198197
return 'TokenPocket'
199198
}

0 commit comments

Comments
 (0)