Skip to content

Commit bfd325a

Browse files
authored
Merge pull request #270 from blocknative/enhancement/wallet-explanation
Modify walletSelect explanation, make customizable. Closes #269
2 parents 9f32f23 + a2a90a4 commit bfd325a

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

src/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface WalletSelectModule {
1818
heading: string
1919
description: string
2020
wallets: Array<WalletModule | WalletInitOptions>
21+
explanation?: string
2122
}
2223

2324
export interface WalletCheckModule {
@@ -48,6 +49,7 @@ export interface WalletCheckModal {
4849
export interface WalletSelectModalData {
4950
heading: string
5051
description: string
52+
explanation?: string
5153
primaryWallets: WalletModule[]
5254
secondaryWallets: WalletModule[] | undefined
5355
}

src/modules/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88

99
const defaultHeading = 'Select a Wallet'
1010
const defaultDescription = 'Please select a wallet to connect to this dapp:'
11+
const defaultWalletExplanation = `Wallets are used to send, receive, and store digital assets like Ether. Wallets come in many forms. They are either built into your browser, an extension added to your browser, a piece of hardware plugged into your computer or even an app on your phone. For more information about wallets, see <a style="color: #4a90e2; font-size: 0.889rem; font-family: inherit;" class="bn-onboard-clickable" href="https://docs.ethhub.io/using-ethereum/wallets/intro-to-ethereum-wallets/" target="_blank" rel="noopener noreferrer">this explanation</a>.`
1112

1213
export default function initializeModules(
1314
networkId: number,
@@ -21,7 +22,9 @@ export default function initializeModules(
2122
heading: (walletSelect && walletSelect.heading) || defaultHeading,
2223
description:
2324
(walletSelect && walletSelect.description) || defaultDescription,
24-
wallets
25+
wallets,
26+
explanation:
27+
(walletSelect && walletSelect.explanation) || defaultWalletExplanation
2528
},
2629
walletCheck: check(walletCheck, networkId)
2730
}

src/validation.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,17 @@ function validateSubscriptions(subscriptions: Subscriptions): never | void {
158158
function validateWalletSelect(walletSelect: WalletSelectModule): never | void {
159159
validateType({ name: 'walletSelect', value: walletSelect, type: 'object' })
160160

161-
const { heading, description, wallets, ...otherParams } = walletSelect
161+
const {
162+
heading,
163+
description,
164+
explanation,
165+
wallets,
166+
...otherParams
167+
} = walletSelect
162168

163169
invalidParams(
164170
otherParams,
165-
['heading', 'description', 'wallets'],
171+
['heading', 'description', 'explanation', 'wallets'],
166172
'walletSelect'
167173
)
168174

@@ -172,13 +178,21 @@ function validateWalletSelect(walletSelect: WalletSelectModule): never | void {
172178
type: 'string',
173179
optional: true
174180
})
181+
175182
validateType({
176183
name: 'description',
177184
value: description,
178185
type: 'string',
179186
optional: true
180187
})
181188

189+
validateType({
190+
name: 'explanation',
191+
value: explanation,
192+
type: 'string',
193+
optional: true
194+
})
195+
182196
if (Array.isArray(wallets)) {
183197
wallets.forEach(validateWallet)
184198
}

src/views/WalletSelect.svelte

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
let selectedWalletModule: WalletModule
4848
4949
const { mobileDevice, os } = get(app)
50-
let { heading, description, wallets } = module
50+
let { heading, description, explanation, wallets } = module
5151
5252
let primaryWallets: WalletModule[]
5353
let secondaryWallets: WalletModule[] | undefined
@@ -102,6 +102,7 @@
102102
modalData = {
103103
heading,
104104
description,
105+
explanation,
105106
primaryWallets,
106107
secondaryWallets
107108
}
@@ -248,12 +249,7 @@
248249
<p
249250
in:fade
250251
class="bn-onboard-custom bn-onboard-select-wallet-definition">
251-
Wallets are used to send, receive, and store digital assets like
252-
Ethereum. Wallets come in many forms. They are either built into your
253-
browser, an extension added to your browser, a piece of hardware
254-
plugged into your computer or even an app on your phone. They are
255-
hyper secure, and can be used for any other blockchain application you
256-
may want to use.
252+
{@html modalData.explanation}
257253
</p>
258254
{/if}
259255
{:else}

0 commit comments

Comments
 (0)