Skip to content

Commit 177f345

Browse files
authored
Merge branch 'develop' into master
2 parents 2d2308b + 33a85e4 commit 177f345

File tree

11 files changed

+591
-208
lines changed

11 files changed

+591
-208
lines changed

.circleci/config.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ jobs:
4040
- run: sudo npm i -g add npm-cli-login
4141
- run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login
4242
- run: npm publish
43+
deploy_demo:
44+
docker:
45+
- image: circleci/node:8.15-browsers
46+
user: root
47+
steps:
48+
- checkout
49+
- run: sh ./trigger-demo-build.sh $CIRCLE_TOKEN
50+
4351
workflows:
4452
version: 2
4553
test_build:
@@ -59,3 +67,8 @@ workflows:
5967
branches:
6068
only:
6169
- master
70+
- deploy_demo:
71+
filters:
72+
branches:
73+
only:
74+
- develop

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.7.4",
3+
"version": "1.7.5",
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",
@@ -61,6 +61,7 @@
6161
},
6262
"scripts": {
6363
"build": "rimraf dist && rollup -c && babel dist/cjs --out-dir dist/cjs && babel dist/esm --out-dir dist/esm",
64-
"test": "echo \"TBD\" && exit 0"
64+
"test": "echo \"TBD\" && exit 0",
65+
"prepare": "npm run build"
6566
}
6667
}

src/interfaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface Initialization {
55
walletSelect: WalletSelectModule
66
walletCheck: Array<WalletCheckModule | WalletCheckInit>
77
darkMode?: boolean
8+
apiUrl?: string
89
}
910

1011
export interface Subscriptions {
@@ -167,6 +168,10 @@ export interface SdkWalletOptions {
167168

168169
export interface WalletConnectOptions {
169170
infuraKey: string
171+
rpc: {
172+
[key: string]: string
173+
}
174+
bridge: string
170175
}
171176

172177
export interface TrezorOptions {

src/modules/check/connect.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ function connect(
2121
if (address === null) {
2222
// wait for address sync if is still on initial value
2323
if (stateSyncStatus.address) {
24-
try {
25-
await stateSyncStatus.address
26-
} catch (error) {}
24+
await new Promise(resolve => {
25+
stateSyncStatus.address && stateSyncStatus.address.then(resolve)
26+
27+
setTimeout(() => {
28+
if (address === null) {
29+
// if prom isn't resolving after 250ms, then stop waiting
30+
resolve()
31+
}
32+
}, 250)
33+
})
2734
}
2835
}
2936

src/modules/check/network.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@ function network(
2424
if (network === null) {
2525
// wait for network sync if is still on initial value
2626
if (stateSyncStatus.network) {
27-
try {
28-
await stateSyncStatus.network
29-
} catch (error) {}
27+
await new Promise(resolve => {
28+
stateSyncStatus.network && stateSyncStatus.network.then(resolve)
29+
30+
setTimeout(() => {
31+
if (network === null) {
32+
// if prom isn't resolving after 250ms, then stop waiting
33+
resolve()
34+
}
35+
}, 250)
36+
})
3037
}
3138
}
3239

src/modules/select/wallets/wallet-connect.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import walletConnectIcon from '../wallet-icons/icon-wallet-connect'
1010
function walletConnect(
1111
options: WalletConnectOptions & CommonWalletOptions
1212
): WalletModule {
13-
const { infuraKey, preferred, label, iconSrc, svg } = options
13+
const { infuraKey, rpc, bridge, preferred, label, iconSrc, svg } = options
1414

1515
return {
1616
name: label || 'WalletConnect',
@@ -24,7 +24,9 @@ function walletConnect(
2424
)
2525

2626
const provider = new WalletConnectProvider({
27-
infuraId: infuraKey
27+
infuraId: infuraKey,
28+
rpc,
29+
bridge
2830
})
2931

3032
provider.autoRefreshOnNetworkChange = false

src/onboard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ function init(initialization: Initialization): API {
4242

4343
validateInit(initialization)
4444

45-
const { subscriptions, dappId, networkId, darkMode } = initialization
45+
const { subscriptions, dappId, networkId, darkMode, apiUrl } = initialization
4646

47-
initializeBlocknative(dappId, networkId)
47+
initializeBlocknative(dappId, networkId, apiUrl)
4848

4949
const { os, isMobile } = getDeviceInfo()
5050

src/services.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import BlocknativeApi from 'bnc-sdk'
22

33
let blocknative: any
44

5-
export function initializeBlocknative(dappId: string, networkId: number): any {
5+
export function initializeBlocknative(
6+
dappId: string,
7+
networkId: number,
8+
apiUrl?: string
9+
): any {
610
blocknative = new BlocknativeApi({
711
dappId,
812
networkId,
9-
name: 'Onboard'
13+
name: 'Onboard',
14+
apiUrl
1015
})
1116

1217
return blocknative

src/validation.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export function validateInit(init: Initialization): never | void {
6262
walletSelect,
6363
walletCheck,
6464
darkMode,
65+
apiUrl,
6566
...otherParams
6667
} = init
6768

@@ -73,7 +74,8 @@ export function validateInit(init: Initialization): never | void {
7374
'subscriptions',
7475
'walletSelect',
7576
'walletCheck',
76-
'darkMode'
77+
'darkMode',
78+
'apiUrl'
7779
],
7880
'init'
7981
)
@@ -86,6 +88,12 @@ export function validateInit(init: Initialization): never | void {
8688
type: 'boolean',
8789
optional: true
8890
})
91+
validateType({
92+
name: 'apiUrl',
93+
value: apiUrl,
94+
type: 'string',
95+
optional: true
96+
})
8997

9098
validateType({
9199
name: 'subscriptions',
@@ -534,6 +542,8 @@ export function validateWalletInit(
534542
apiKey,
535543
networkId,
536544
infuraKey,
545+
rpc,
546+
bridge,
537547
preferred,
538548
label,
539549
iconSrc,
@@ -559,6 +569,8 @@ export function validateWalletInit(
559569
'apiKey',
560570
'networkId',
561571
'infuraKey',
572+
'rpc',
573+
'bridge',
562574
'preferred',
563575
'label',
564576
'iconSrc',
@@ -604,6 +616,20 @@ export function validateWalletInit(
604616
optional: true
605617
})
606618

619+
validateType({
620+
name: 'walletInit.rpc',
621+
value: rpc,
622+
type: 'object',
623+
optional: true
624+
})
625+
626+
validateType({
627+
name: 'walletInit.bridge',
628+
value: bridge,
629+
type: 'string',
630+
optional: true
631+
})
632+
607633
validateType({
608634
name: 'walletInit.preferred',
609635
value: preferred,

trigger-demo-build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -X POST --header "Content-Type: application/json" -d '{"build_parameters": {"CIRCLE_JOB": "deploy_stage"}}' https://circleci.com/api/v1/project/blocknative/react-demo/tree/develop?circle-token=$1

0 commit comments

Comments
 (0)