Skip to content

Commit e73c247

Browse files
committed
Merge branch 'develop' into release/1.24.0
2 parents 64cad89 + de7888c commit e73c247

File tree

15 files changed

+119
-86
lines changed

15 files changed

+119
-86
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@cvbb/eth-keyring": "^1.1.0",
5757
"@ledgerhq/hw-app-eth": "^5.21.0",
5858
"@ledgerhq/hw-transport-u2f": "^5.21.0",
59-
"@portis/web3": "^2.0.0-beta.57",
59+
"@portis/web3": "^4.0.0",
6060
"@toruslabs/torus-embed": "^1.9.2",
6161
"@walletconnect/web3-provider": "^1.4.1",
6262
"authereum": "^0.1.12",

src/components/Wallets.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { onDestroy } from 'svelte'
33
import Button from '../elements/Button.svelte'
44
import IconButton from '../elements/IconButton.svelte'
5-
import { app, wallet } from '../stores'
5+
import { wallet } from '../stores'
66
import {
77
WalletSelectModalData,
88
WalletModule,
@@ -13,6 +13,8 @@
1313
export let loadingWallet: string | undefined
1414
export let showingAllWalletModules: boolean = false
1515
export let showAllWallets: () => void
16+
export let walletsDisabled: boolean = false
17+
1618
let selectedWallet: WritableStore
1719
1820
const unsubscribe = wallet.subscribe(wallet => (selectedWallet = wallet))
@@ -68,7 +70,7 @@
6870
{#each modalData.primaryWallets as wallet, i (wallet.name)}
6971
<li>
7072
<IconButton
71-
disabled={!$app.termsAgreed}
73+
disabled={walletsDisabled}
7274
onclick={() => handleWalletSelect(wallet)}
7375
iconSrc={wallet.iconSrc}
7476
iconSrcSet={wallet.iconSrcSet}
@@ -82,7 +84,7 @@
8284

8385
{#if modalData.secondaryWallets && modalData.secondaryWallets.length && !showingAllWalletModules}
8486
<div>
85-
<Button disabled={!$app.termsAgreed} onclick={showAllWallets}
87+
<Button disabled={walletsDisabled} onclick={showAllWallets}
8688
>Show More</Button
8789
>
8890
</div>
@@ -92,7 +94,7 @@
9294
{#each modalData.secondaryWallets as wallet, i (wallet.name)}
9395
<li>
9496
<IconButton
95-
disabled={!$app.termsAgreed}
97+
disabled={walletsDisabled}
9698
onclick={() => handleWalletSelect(wallet)}
9799
iconSrc={wallet.iconSrc}
98100
iconSrcSet={wallet.iconSrcSet}

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StorageKeys } from './interfaces'
22

33
export const STORAGE_KEYS: StorageKeys = {
4-
TERMS_AGREED: 'onboard.js:termsAgreed'
4+
TERMS_AGREEMENT: 'onboard.js:agreement'
55
}

src/elements/Button.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { app } from '../stores'
33
export let onclick: () => void = () => {}
4-
export let position: string
4+
export let position: string = ''
55
export let disabled: boolean = false
66
</script>
77

src/interfaces.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ export interface WalletSelectModuleOptions {
2323
description?: string
2424
wallets?: Array<WalletModule | WalletInitOptions>
2525
explanation?: string
26-
termsOfServiceUrl?: string
27-
privacyPolicyUrl?: string
26+
agreement?: TermsOfServiceAgreementOptions
2827
}
2928

3029
export interface WalletSelectModule {
3130
heading: string
3231
description: string
3332
wallets: Array<WalletModule | WalletInitOptions>
3433
explanation?: string
35-
termsOfServiceUrl: string
36-
privacyPolicyUrl: string
34+
agreement?: TermsOfServiceAgreementOptions
35+
}
36+
37+
export interface TermsOfServiceAgreementOptions {
38+
version: string
39+
termsUrl?: string
40+
privacyUrl?: string
3741
}
3842

3943
export interface WalletCheckModule {
@@ -484,13 +488,23 @@ export interface AppState {
484488
walletSelectDisplayedUI: boolean
485489
walletCheckDisplayedUI: boolean
486490
displayBranding: boolean
487-
termsAgreed: boolean
491+
agreement: TermsOfServiceAgreementOptions
488492
}
489493

490494
export interface CancelablePromise extends Promise<any> {
491495
cancel: () => void
492496
}
493497

494498
export interface StorageKeys {
495-
TERMS_AGREED: string
499+
TERMS_AGREEMENT: string
500+
}
501+
502+
/**
503+
* The object that will be stored in local storage to track
504+
* user's agreement to the terms.
505+
*/
506+
export interface TermsAgreementState {
507+
version: string
508+
terms?: boolean
509+
privacy?: boolean
496510
}

src/modules/check/network.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
WalletCheckCustomOptions
66
} from '../../interfaces'
77
import { networkIcon } from './icons'
8-
import { app } from './../../stores'
9-
import { get } from 'svelte/store'
108

119
function network(
1210
options: WalletCheckCustomOptions = {}

src/modules/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export default function initializeModules(
2626
heading = defaultHeading,
2727
description = defaultDescription,
2828
explanation = defaultWalletExplanation,
29-
termsOfServiceUrl = '',
30-
privacyPolicyUrl = ''
29+
agreement = {}
3130
} = walletSelectOptions || {}
3231

3332
return {
@@ -36,8 +35,7 @@ export default function initializeModules(
3635
description,
3736
wallets,
3837
explanation,
39-
termsOfServiceUrl,
40-
privacyPolicyUrl
38+
agreement
4139
},
4240
walletCheck: check(walletCheck, networkId)
4341
}

src/modules/select/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import { isWalletInit } from '../../validation'
77

88
// wallets that qualify for default wallets need to have no
99
// init parameters that are required for full functionality
10-
const desktopDefaultWalletNames = ['metamask', 'authereum', 'torus', 'opera']
10+
const desktopDefaultWalletNames = ['metamask', 'torus', 'opera', 'liquality']
1111

1212
const mobileDefaultWalletNames = [
1313
'metamask',
14-
'authereum',
1514
'coinbase',
1615
'trust',
1716
'torus',
@@ -24,7 +23,8 @@ const mobileDefaultWalletNames = [
2423
'atoken',
2524
'liquality',
2625
'alphawallet',
27-
'ownbit'
26+
'ownbit',
27+
'authereum'
2828
]
2929

3030
function select(

src/modules/select/wallets/cobovault.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async function cobovaultProvider(options: {
7070

7171
const BASE_PATH = "m/44'/60'/0'/0"
7272

73-
const { networkId, appName, rpcUrl, BigNumber, networkName } = options
73+
const { networkId, rpcUrl, BigNumber, networkName } = options
7474

7575
const keyring = AirGapedKeyring.getEmptyKeyring()
7676

src/modules/select/wallets/lattice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async function latticeProvider(options: {
156156
return addressList
157157
}
158158

159-
function setPrimaryAccount(address: string) {
159+
function setPrimaryAccount() {
160160
return
161161
}
162162

src/onboard.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
} from './interfaces'
3232

3333
import initializeModules from './modules'
34-
import { STORAGE_KEYS } from './constants'
3534

3635
let onboard: any
3736

@@ -78,13 +77,6 @@ function init(initialization: Initialization): API {
7877
displayBranding = false
7978
}
8079
}
81-
const { termsOfServiceUrl, privacyPolicyUrl } =
82-
initialization.walletSelect || {}
83-
84-
const termsAgreed =
85-
termsOfServiceUrl || privacyPolicyUrl
86-
? localStorage.getItem(STORAGE_KEYS.TERMS_AGREED) == 'true'
87-
: true
8880

8981
app.update((store: AppState) => ({
9082
...store,
@@ -100,7 +92,7 @@ function init(initialization: Initialization): API {
10092
displayBranding,
10193
checkModules: initializedModules.walletCheck,
10294
blockPollingInterval,
103-
termsAgreed
95+
agreement: initialization.walletSelect?.agreement || null
10496
}))
10597

10698
initializeStores()

src/stores.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const app: WritableStore = writable({
3535
walletCheckDisplayedUI: false,
3636
displayBranding: false,
3737
blockPollingInterval: 4000,
38-
termsAgreed: false
38+
agreement: {}
3939
})
4040

4141
export const stateSyncStatus: {

src/validation.ts

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
WalletInterface,
99
WalletInitOptions,
1010
WalletCheckInit,
11-
WalletSelectModuleOptions
11+
WalletSelectModuleOptions,
12+
TermsOfServiceAgreementOptions
1213
} from './interfaces'
1314

1415
const validSubscriptionKeys = ['address', 'network', 'balance', 'wallet']
@@ -81,7 +82,8 @@ export function validateInit(init: Initialization): never | void {
8182
'darkMode',
8283
'apiUrl',
8384
'hideBranding',
84-
'blockPollingInterval'
85+
'blockPollingInterval',
86+
'agreement'
8587
],
8688
'init'
8789
)
@@ -202,21 +204,13 @@ function validateWalletSelect(
202204
description,
203205
explanation,
204206
wallets,
205-
termsOfServiceUrl,
206-
privacyPolicyUrl,
207+
agreement,
207208
...otherParams
208209
} = walletSelect
209210

210211
invalidParams(
211212
otherParams,
212-
[
213-
'heading',
214-
'description',
215-
'explanation',
216-
'termsOfServiceUrl',
217-
'privacyPolicyUrl',
218-
'wallets'
219-
],
213+
['heading', 'description', 'explanation', 'wallets', 'agreement'],
220214
'walletSelect'
221215
)
222216

@@ -241,23 +235,44 @@ function validateWalletSelect(
241235
optional: true
242236
})
243237

238+
if (Array.isArray(wallets)) {
239+
wallets.forEach(validateWallet)
240+
}
241+
244242
validateType({
245-
name: 'termsOfServiceUrl',
246-
value: termsOfServiceUrl,
247-
type: 'string',
243+
name: 'agreement',
244+
value: agreement,
245+
type: 'object',
248246
optional: true
249247
})
250248

249+
if (agreement) {
250+
validateAgreement(agreement)
251+
}
252+
}
253+
254+
const validateAgreement = (agreement: TermsOfServiceAgreementOptions) => {
255+
const { version, termsUrl, privacyUrl } = agreement
256+
validateType({
257+
name: 'version',
258+
value: version,
259+
type: 'string',
260+
optional: false
261+
})
262+
251263
validateType({
252-
name: 'privacyPolicyUrl',
253-
value: privacyPolicyUrl,
264+
name: 'termsUrl',
265+
value: termsUrl,
254266
type: 'string',
255267
optional: true
256268
})
257269

258-
if (Array.isArray(wallets)) {
259-
wallets.forEach(validateWallet)
260-
}
270+
validateType({
271+
name: 'privacyUrl',
272+
value: privacyUrl,
273+
type: 'string',
274+
optional: true
275+
})
261276
}
262277

263278
export function isWalletModule(obj: any): obj is WalletModule {

src/views/WalletCheck.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@
347347
</Button>
348348
{/if}
349349
{#if errorMsg}
350-
<Button position={!activeModal.button && 'left'} onclick={doAction}>
350+
<Button position={!activeModal.button ? 'left' : ''} onclick={doAction}>
351351
Try Again
352352
</Button>
353353
{:else}

0 commit comments

Comments
 (0)