Skip to content

Commit b9eb4d8

Browse files
authored
Merge pull request #280 from blocknative/enhancement/wallet-settings
Enhancement: Wallet Settings. Closes #278
2 parents 4433b5e + bcf95f0 commit b9eb4d8

File tree

9 files changed

+29
-22
lines changed

9 files changed

+29
-22
lines changed

src/interfaces.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export interface WalletModule {
8484
}>
8585
type: 'hardware' | 'injected' | 'sdk'
8686
link?: string
87-
url?: string
8887
installMessage?: (wallets: {
8988
currentWallet: string | undefined
9089
selectedWallet: string
@@ -117,6 +116,7 @@ export interface WalletInterface {
117116
address: StateSyncer
118117
network: StateSyncer
119118
balance: StateSyncer
119+
settings?: () => void
120120
}
121121

122122
export interface StateSyncer {
@@ -130,6 +130,7 @@ export interface Wallet {
130130
type: 'hardware' | 'injected' | 'sdk'
131131
instance?: any
132132
connect?: () => Promise<{ message: string } | undefined>
133+
settings?: () => void
133134
}
134135

135136
export interface CommonWalletOptions {

src/modules/select/wallets/authereum.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import authereumIcon from '../wallet-icons/icon-authereum.png'
2-
import { networkName } from '../../../utilities'
2+
import { networkName, openLink } from '../../../utilities'
33
import {
44
WalletModule,
55
AuthereumOptions,
@@ -31,8 +31,6 @@ function authereum(
3131

3232
const provider = instance.getProvider()
3333

34-
console.log({ instance, provider })
35-
3634
return {
3735
provider,
3836
instance,
@@ -53,16 +51,19 @@ function authereum(
5351
const loggedIn = await instance.isAuthenticated()
5452
return loggedIn && instance.getBalance()
5553
}
56-
}
54+
},
55+
settings: () =>
56+
openLink(
57+
`https://${
58+
networkId !== 1 ? `${networkName(networkId)}.` : ''
59+
}authereum.com/`
60+
)
5761
}
5862
}
5963
},
6064
type: 'sdk',
6165
desktop: true,
6266
mobile: true,
63-
url: `https://${
64-
networkId !== 1 ? `${networkName(networkId)}.` : ''
65-
}authereum.com/`,
6667
preferred
6768
}
6869
}

src/modules/select/wallets/portis.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { networkName } from '../../../utilities'
1+
import { networkName, openLink } from '../../../utilities'
22
import {
33
SdkWalletOptions,
44
WalletModule,
@@ -65,14 +65,14 @@ function portis(options: SdkWalletOptions & CommonWalletOptions): WalletModule {
6565
)
6666
}, 1)
6767
})
68-
}
68+
},
69+
settings: () => openLink('https://wallet.portis.io/')
6970
}
7071
}
7172
},
7273
type: 'sdk',
7374
desktop: true,
7475
mobile: true,
75-
url: 'https://wallet.portis.io/',
7676
preferred
7777
}
7878
}

src/modules/select/wallets/squarelink.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { networkName, networkToId } from '../../../utilities'
1+
import { networkName, networkToId, openLink } from '../../../utilities'
22
import {
33
SdkWalletOptions,
44
CommonWalletOptions,
@@ -60,14 +60,14 @@ function squarelink(
6060
}
6161
)
6262
})
63-
}
63+
},
64+
settings: () => openLink('https://app.squarelink.com/')
6465
}
6566
}
6667
},
6768
type: 'sdk',
6869
desktop: true,
6970
mobile: true,
70-
url: 'https://app.squarelink.com/',
7171
preferred
7272
}
7373
}

src/modules/select/wallets/torus.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { networkName } from '../../../utilities'
1+
import { networkName, openLink } from '../../../utilities'
22
import {
33
TorusOptions,
44
CommonWalletOptions,
@@ -76,14 +76,14 @@ function torus(options: TorusOptions & CommonWalletOptions): WalletModule {
7676
}
7777
)
7878
})
79-
}
79+
},
80+
settings: () => openLink('https://app.tor.us/')
8081
}
8182
}
8283
},
8384
type: 'sdk',
8485
desktop: true,
8586
mobile: true,
86-
url: 'https://app.tor.us/',
8787
preferred
8888
}
8989
}

src/modules/select/wallets/unilogin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function unilogin(options: CommonWalletOptions): WalletModule {
2323
disconnect: () =>
2424
new Promise(resolve =>
2525
provider.send({ method: 'ul_disconnect' }, resolve)
26-
)
26+
),
27+
settings: () => provider.openDashboard()
2728
}
2829
}
2930
},

src/stores.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const wallet: WritableStore = writable({
5151
provider: null,
5252
connect: null,
5353
instance: null,
54-
url: null,
54+
settings: null,
5555
type: null
5656
})
5757

@@ -119,7 +119,7 @@ export function resetWalletState(options?: {
119119
provider: undefined,
120120
connect: undefined,
121121
instance: undefined,
122-
url: undefined
122+
settings: undefined
123123
}))
124124

125125
currentInterface.disconnect && currentInterface.disconnect()
@@ -136,7 +136,7 @@ export function resetWalletState(options?: {
136136
provider: undefined,
137137
connect: undefined,
138138
instance: undefined,
139-
url: undefined
139+
settings: undefined
140140
}))
141141

142142
!disconnected &&

src/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,7 @@ export function createInterval(func: any, interval: number) {
283283
}
284284
}
285285
}
286+
287+
export function openLink(url: string) {
288+
window.open(url)
289+
}

src/views/WalletSelect.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
wallet.set({
176176
provider,
177177
instance,
178-
url: module.url,
178+
settings: selectedWalletInterface.settings,
179179
name: module.name,
180180
connect: selectedWalletInterface.connect,
181181
type: module.type

0 commit comments

Comments
 (0)