Skip to content

Commit f4059b0

Browse files
1.19.2-0.1.0: network display name option (#502)
* Adds optional networkName * Remove redundant 'network' text
1 parent 3c53d4b commit f4059b0

File tree

7 files changed

+20
-5
lines changed

7 files changed

+20
-5
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.2",
3+
"version": "1.19.2-0.1.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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export interface Initialization {
22
dappId?: string
33
networkId: number
4+
networkName?: string
45
subscriptions?: Subscriptions
56
walletSelect?: WalletSelectModuleOptions
67
walletCheck?: Array<WalletCheckModule | WalletCheckInit>
@@ -464,6 +465,7 @@ export type OS = {
464465
export interface AppState {
465466
dappId: string
466467
networkId: number
468+
networkName: string
467469
version: string
468470
mobileDevice: boolean
469471
os: OS

src/modules/check/network.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function network(
4646
network
4747
)}</b> to <b>${networkName(
4848
appNetworkId
49-
)} network</b> for this Dapp. <br><br> <i style="font-size: inherit; font-family: inherit;">*Some wallets may not support changing networks. If you can not change networks in your wallet you may consider switching to a different wallet.</i>`,
49+
)}</b> for this Dapp. <br><br> <i style="font-size: inherit; font-family: inherit;">*Some wallets may not support changing networks. If you can not change networks in your wallet you may consider switching to a different wallet.</i>`,
5050
eventCode: 'networkFail',
5151
button: button || {
5252
onclick: () => {

src/onboard.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function init(initialization: Initialization): API {
4646
subscriptions,
4747
dappId,
4848
networkId,
49+
networkName,
4950
darkMode,
5051
apiUrl,
5152
hideBranding,
@@ -82,6 +83,7 @@ function init(initialization: Initialization): API {
8283
dappId,
8384
apiUrl,
8485
networkId,
86+
networkName,
8587
version,
8688
mobileDevice: isMobile,
8789
os,

src/stores.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const app: WritableStore = writable({
1818
dappId: '',
1919
apiUrl: '',
2020
networkId: 1,
21+
networkName: '',
2122
version: '',
2223
mobileDevice: false,
2324
os: '',
@@ -32,7 +33,7 @@ export const app: WritableStore = writable({
3233
walletSelectDisplayedUI: false,
3334
walletCheckDisplayedUI: false,
3435
displayBranding: false,
35-
blockPollingInterval: 4000,
36+
blockPollingInterval: 4000
3637
})
3738

3839
export const stateSyncStatus: {

src/utilities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import bowser from 'bowser'
22
import BigNumber from 'bignumber.js'
33

44
import { WalletInterface } from './interfaces'
5+
import { app } from './stores'
6+
import { get } from 'svelte/store'
57

68
export function getNetwork(provider: any): Promise<number | any> {
79
return new Promise((resolve, reject) => {
@@ -298,7 +300,7 @@ export function networkName(id: number): string {
298300
case 100:
299301
return 'xdai'
300302
default:
301-
return 'local'
303+
return get(app).networkName || 'local'
302304
}
303305
}
304306

src/validation.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export function validateInit(init: Initialization): never | void {
5858
const {
5959
dappId,
6060
networkId,
61+
networkName,
6162
subscriptions,
6263
walletSelect,
6364
walletCheck,
@@ -73,6 +74,7 @@ export function validateInit(init: Initialization): never | void {
7374
[
7475
'dappId',
7576
'networkId',
77+
'networkName',
7678
'subscriptions',
7779
'walletSelect',
7880
'walletCheck',
@@ -91,6 +93,12 @@ export function validateInit(init: Initialization): never | void {
9193
optional: true
9294
})
9395
validateType({ name: 'networkId', value: networkId, type: 'number' })
96+
validateType({
97+
name: 'networkName',
98+
value: networkName,
99+
type: 'string',
100+
optional: true
101+
})
94102
validateType({
95103
name: 'darkMode',
96104
value: darkMode,
@@ -648,7 +656,7 @@ export function validateWalletInit(
648656
'rpcUri',
649657
'webUri',
650658
'xsUri',
651-
'blockedPopupRedirect',
659+
'blockedPopupRedirect'
652660
],
653661
'walletInitObject'
654662
)

0 commit comments

Comments
 (0)