Skip to content

Commit d547aa6

Browse files
authored
Merge pull request #339 from blocknative/develop
Release 1.8.0
2 parents e5d8fa5 + 47d583c commit d547aa6

File tree

9 files changed

+315
-183
lines changed

9 files changed

+315
-183
lines changed

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.7.8",
3+
"version": "1.8.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",
@@ -19,9 +19,6 @@
1919
"type": "git",
2020
"url": "https://github.com/blocknative/onboard"
2121
},
22-
"resolutions": {
23-
"moment": "2.24.0"
24-
},
2522
"license": "MIT",
2623
"devDependencies": {
2724
"@babel/cli": "^7.7.0",
@@ -54,7 +51,7 @@
5451
"@toruslabs/torus-embed": "^1.3.0",
5552
"@unilogin/provider": "^0.5.21",
5653
"@walletconnect/web3-provider": "^1.0.0-beta.47",
57-
"authereum": "^0.0.4-beta.131",
54+
"authereum": "^0.0.4-beta.141",
5855
"bignumber.js": "^9.0.0",
5956
"bnc-sdk": "2.1.1",
6057
"bowser": "^2.5.2",

src/components/Modal.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import { fade } from 'svelte/transition'
33
import { app } from '../stores'
4+
import Branding from '../elements/Branding.svelte'
45
export let closeModal: () => void
56
export let closeable: boolean = true
67
@@ -78,6 +79,10 @@
7879
.bn-onboard-dark-mode-close-background:hover {
7980
background: #00222c;
8081
}
82+
83+
.no-padding-branding {
84+
padding-bottom: 0;
85+
}
8186
</style>
8287

8388
<aside
@@ -86,9 +91,13 @@
8691
on:click={closeModal}>
8792
<section
8893
class:bn-onboard-dark-mode={$app.darkMode}
94+
class:no-padding-branding={$app.displayBranding}
8995
class="bn-onboard-custom bn-onboard-modal-content"
9096
on:click={e => e.stopPropagation()}>
9197
<slot />
98+
{#if $app.displayBranding}
99+
<Branding darkMode={$app.darkMode} />
100+
{/if}
92101
{#if closeable}
93102
<div
94103
class="bn-onboard-custom bn-onboard-modal-content-close"

src/elements/Branding.svelte

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<script>
2+
export let darkMode
3+
</script>
4+
5+
<style>
6+
.bn-branding {
7+
font-size: 0.75rem;
8+
font-family: inherit;
9+
margin: 0.4rem;
10+
display: flex;
11+
justify-content: center;
12+
width: 100%;
13+
align-items: center;
14+
}
15+
16+
span {
17+
opacity: 0.3;
18+
}
19+
20+
a {
21+
color: inherit;
22+
display: flex;
23+
margin-left: 0.25rem;
24+
align-items: center;
25+
}
26+
27+
.bn-logo {
28+
height: 1.1rem;
29+
margin-left: 0.25rem;
30+
margin-bottom: 0.1rem;
31+
}
32+
33+
svg {
34+
height: 100%;
35+
width: auto;
36+
}
37+
</style>
38+
39+
<div class="bn-branding">
40+
<span>Powered by</span>
41+
<a
42+
href="https://hubs.ly/H0qh2g10"
43+
class="bn-onboard-clickable"
44+
target="_blank"
45+
rel="noopener noreferrer">
46+
<span>Blocknative</span>
47+
<div class="bn-logo">
48+
{#if darkMode}
49+
<svg
50+
height="130"
51+
viewBox="0 0 91 130"
52+
width="91"
53+
xmlns="http://www.w3.org/2000/svg">
54+
<g
55+
style="stroke:#fff;stroke-width:2.70793;fill:none;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round"
56+
transform="translate(1.818182 .909091)">
57+
<path
58+
d="m1.35473654 25.2695268
59+
41.68515786-24.21771792c.5647044-.32807482 1.2619836-.32807795
60+
1.8266909-.00000821l19.9275013
61+
11.57698923c.5635938.3274228.9088026.9314826.9048094
62+
1.5832707l-.1501112 24.5017756 20.8472716
63+
12.1113348c.5601525.3254236.9048434.9243111.9048434
64+
1.5721317v48.4560123c0 .647825-.3446953 1.246715-.9048537
65+
1.572138l-41.6835092
66+
24.215895c-.5655731.328567-1.2640448.328023-1.8291052-.001426l-41.5311197-24.21401c-.5587764-.325785-.90240476-.923899-.90240476-1.570712v-49.505258-24.5082917c0-.6478147.34468473-1.2466978.9048293-1.5721235z" />
67+
<path
68+
d="m22.0428451 114.442824v-25.2731141l-21.59284788-12.5449388
69+
42.75014288 24.6551909c.5648507.325765 1.260898.324109
70+
1.8241926-.004339l42.2766571-24.6508519-21.5955473
71+
12.6370084v-24.2248276c0-.6488012-.3457266-1.2484405-.9072187-1.5735092l-20.9222804-12.1126883
72+
21.6729314-12.6370084-42.4525958
73+
24.4763352c-.5545159.3197099-1.236865.3218902-1.7934127.0057303l-20.85286908-11.8459598" />
74+
</g>
75+
</svg>
76+
{:else}
77+
<svg
78+
height="130"
79+
viewBox="0 0 91 130"
80+
width="91"
81+
xmlns="http://www.w3.org/2000/svg">
82+
<g
83+
style="stroke:#000;stroke-width:2.70793;fill:none;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round"
84+
transform="translate(1.818182 .909091)">
85+
<path
86+
d="m1.35473654 25.2695268
87+
41.68515786-24.21771792c.5647044-.32807482 1.2619836-.32807795
88+
1.8266909-.00000821l19.9275013
89+
11.57698923c.5635938.3274228.9088026.9314826.9048094
90+
1.5832707l-.1501112 24.5017756 20.8472716
91+
12.1113348c.5601525.3254236.9048434.9243111.9048434
92+
1.5721317v48.4560123c0 .647825-.3446953 1.246715-.9048537
93+
1.572138l-41.6835092
94+
24.215895c-.5655731.328567-1.2640448.328023-1.8291052-.001426l-41.5311197-24.21401c-.5587764-.325785-.90240476-.923899-.90240476-1.570712v-49.505258-24.5082917c0-.6478147.34468473-1.2466978.9048293-1.5721235z" />
95+
<path
96+
d="m22.0428451 114.442824v-25.2731141l-21.59284788-12.5449388
97+
42.75014288 24.6551909c.5648507.325765 1.260898.324109
98+
1.8241926-.004339l42.2766571-24.6508519-21.5955473
99+
12.6370084v-24.2248276c0-.6488012-.3457266-1.2484405-.9072187-1.5735092l-20.9222804-12.1126883
100+
21.6729314-12.6370084-42.4525958
101+
24.4763352c-.5545159.3197099-1.236865.3218902-1.7934127.0057303l-20.85286908-11.8459598" />
102+
</g>
103+
</svg>
104+
{/if}
105+
</div>
106+
</a>
107+
</div>

src/interfaces.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export interface Initialization {
2-
dappId: string
2+
dappId?: string
33
networkId: number
44
subscriptions?: Subscriptions
55
walletSelect?: WalletSelectModuleOptions
66
walletCheck?: Array<WalletCheckModule | WalletCheckInit>
77
darkMode?: boolean
88
apiUrl?: string
9+
hideBranding?: boolean
910
}
1011

1112
export interface Subscriptions {
@@ -93,7 +94,7 @@ export interface StateAndHelpers extends UserState {
9394
stateStore: {
9495
address: WalletStateSliceStore
9596
network: WalletStateSliceStore
96-
balance: BalanceStore
97+
balance: BalanceStore | WalletStateSliceStore
9798
}
9899
}
99100

@@ -286,6 +287,10 @@ export interface WritableStore {
286287
subscribe: (subscriber: (store: any) => any) => () => void
287288
}
288289

290+
export interface ReadableStore {
291+
subscribe: (subscriber: (store: any) => any) => () => void
292+
}
293+
289294
export interface WalletInterfaceStore {
290295
subscribe: (subscriber: (store: any) => void) => () => void
291296
update: (
@@ -325,6 +330,7 @@ export interface AppState {
325330
accountSelectInProgress: boolean
326331
walletSelectDisplayedUI: boolean
327332
walletCheckDisplayedUI: boolean
333+
displayBranding: boolean
328334
}
329335

330336
export interface CancelablePromise extends Promise<any> {

src/onboard.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
wallet,
1313
state,
1414
walletInterface,
15-
resetWalletState
15+
resetWalletState,
16+
initializeStores
1617
} from './stores'
1718

1819
import { getDeviceInfo } from './utilities'
@@ -42,9 +43,14 @@ function init(initialization: Initialization): API {
4243

4344
validateInit(initialization)
4445

45-
const { subscriptions, dappId, networkId, darkMode, apiUrl } = initialization
46-
47-
initializeBlocknative(dappId, networkId, apiUrl)
46+
const {
47+
subscriptions,
48+
dappId,
49+
networkId,
50+
darkMode,
51+
apiUrl,
52+
hideBranding
53+
} = initialization
4854

4955
const { os, isMobile } = getDeviceInfo()
5056

@@ -54,6 +60,22 @@ function init(initialization: Initialization): API {
5460
initialization.walletCheck
5561
)
5662

63+
let displayBranding: boolean
64+
65+
if (dappId) {
66+
if (hideBranding !== false) {
67+
displayBranding = false
68+
} else {
69+
displayBranding = true
70+
}
71+
} else {
72+
if (hideBranding !== true) {
73+
displayBranding = true
74+
} else {
75+
displayBranding = false
76+
}
77+
}
78+
5779
app.update((store: AppState) => ({
5880
...store,
5981
dappId,
@@ -62,9 +84,16 @@ function init(initialization: Initialization): API {
6284
mobileDevice: isMobile,
6385
os,
6486
darkMode,
87+
displayBranding,
6588
checkModules: initializedModules.walletCheck
6689
}))
6790

91+
initializeStores()
92+
93+
if (dappId) {
94+
initializeBlocknative(dappId, networkId, apiUrl)
95+
}
96+
6897
onboard = new Onboard({
6998
target: document.body,
7099
props: {

0 commit comments

Comments
 (0)