Skip to content

Commit b8d6cb5

Browse files
authored
Merge pull request #30 from blocknative/develop
Release 0.2.1
2 parents 9ac2878 + 710d353 commit b8d6cb5

File tree

10 files changed

+437
-31
lines changed

10 files changed

+437
-31
lines changed

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"main": "dist/cjs/index.js",
55
"module": "dist/esm/index.js",
66
"files": [
@@ -9,25 +9,26 @@
99
],
1010
"types": "./types.d.ts",
1111
"devDependencies": {
12+
"@babel/core": "^7.5.5",
13+
"@babel/preset-env": "^7.5.5",
14+
"@joseph184/rollup-plugin-node-builtins": "^2.1.4",
15+
"babel-eslint": "^7.1.1",
16+
"babel-plugin-external-helpers": "^6.18.0",
1217
"rollup": "^1.12.0",
18+
"rollup-plugin-babel": "^4.3.3",
1319
"rollup-plugin-commonjs": "^10.0.0",
1420
"rollup-plugin-img": "^1.1.0",
1521
"rollup-plugin-json": "^4.0.0",
1622
"rollup-plugin-livereload": "^1.0.0",
17-
"@joseph184/rollup-plugin-node-builtins": "^2.1.4",
18-
"rollup-plugin-babel": "^4.3.3",
23+
"rollup-plugin-node-globals": "^1.4.0",
1924
"rollup-plugin-node-resolve": "^5.2.0",
2025
"rollup-plugin-svelte": "^5.0.3",
21-
"rollup-plugin-terser": "^4.0.4",
22-
"rollup-plugin-node-globals": "^1.4.0",
23-
"@babel/core": "^7.5.5",
24-
"@babel/preset-env": "^7.5.5",
25-
"babel-eslint": "^7.1.1",
26-
"babel-plugin-external-helpers": "^6.18.0"
26+
"rollup-plugin-terser": "^4.0.4"
2727
},
2828
"dependencies": {
2929
"@portis/web3": "^2.0.0-beta.42",
3030
"@walletconnect/web3-provider": "^1.0.0-beta.36",
31+
"authereum": "^0.0.4-beta.26",
3132
"bignumber.js": "^9.0.0",
3233
"bnc-sdk": "0.2.1",
3334
"bowser": "^2.5.2",

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export default [
5151
"@portis/web3",
5252
"@walletconnect/web3-provider",
5353
"fortmatic",
54+
"authereum"
5455
],
5556
plugins: [
5657
svelte(),

src/elements/Spinner.svelte

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<style>
2+
.bn-onboard-loading {
3+
display: inline-block;
4+
position: relative;
5+
width: 2rem;
6+
height: 2rem;
7+
}
8+
.bn-onboard-loading div {
9+
box-sizing: border-box;
10+
display: block;
11+
position: absolute;
12+
width: 2rem;
13+
height: 2rem;
14+
border: 3px solid #4a90e2;
15+
border-radius: 50%;
16+
animation: bn-onboard-loading 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
17+
border-color: #4a90e2 transparent transparent transparent;
18+
}
19+
.bn-onboard-loading div:nth-child(1) {
20+
animation-delay: -0.45s;
21+
}
22+
.bn-onboard-loading div:nth-child(2) {
23+
animation-delay: -0.3s;
24+
}
25+
.bn-onboard-loading div:nth-child(3) {
26+
animation-delay: -0.15s;
27+
}
28+
@keyframes bn-onboard-loading {
29+
0% {
30+
transform: rotate(0deg);
31+
}
32+
100% {
33+
transform: rotate(360deg);
34+
}
35+
}
36+
</style>
37+
38+
<div class="bn-onboard-custom bn-onboard-loading">
39+
<div />
40+
<div />
41+
<div />
42+
<div />
43+
</div>

src/modules/ready/connect.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function connect() {
66
description: `This dapp requires access to your wallet, please login and authorize access to your ${wallet.name} accounts to continue.`,
77
eventCode: "loginFail",
88
action: wallet.connect,
9+
loading: wallet.loading,
910
icon: `
1011
<svg height="14" viewBox="0 0 18 14" width="18" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor"><path d="m10.29375 4.05351563c0-.04921875 0-.09140625 0-.13007813 0-1.0546875 0-2.109375 0-3.1640625 0-.43945312.3480469-.76992188.7804688-.7453125.2003906.01054688.3585937.10546875.4992187.24609375.5800781.58359375 1.1566406 1.16367188 1.7367187 1.74023438 1.4695313 1.46953125 2.9390625 2.93906249 4.4050782 4.40859375.1335937.13359375.2425781.27421875.2707031.46757812.0351562.20742188-.0246094.421875-.1652344.58007813-.0246094.028125-.0492187.05273437-.0738281.08085937-2.0601563 2.06367188-4.1203125 4.1238281-6.1804688 6.1875-.2109375.2109375-.4570312.3023438-.7453125.2179688-.2707031-.0808594-.4464843-.2707032-.5132812-.5484375-.0140625-.0738282-.0175781-.1441407-.0140625-.2179688 0-1.0335937 0-2.0707031 0-3.1042969 0-.0386719 0-.08085935 0-.13359372h-5.06953125c-.49570313 0-.80507813-.309375-.80507813-.80859375 0-1.42382813 0-2.84414063 0-4.26796875 0-.49570313.30585938-.8015625.8015625-.8015625h4.93593748z"/><path d="m5.69882812 13.978125h-4.01132812c-.928125 0-1.6875-.8753906-1.6875-1.9511719v-10.06171872c0-1.07578125.75585938-1.95117188 1.6875-1.95117188h4.01132812c.34101563 0 .61523438.31992188.61523438.71015625 0 .39023438-.27421875.71015625-.61523438.71015625h-4.01132812c-.253125 0-.45703125.23554688-.45703125.52734375v10.06171875c0 .2917969.20390625.5273437.45703125.5273437h4.01132812c.34101563 0 .61523438.3199219.61523438.7101563s-.27773438.7171875-.61523438.7171875z"/></g></svg>
1112
`

src/modules/select/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import coinbase from "./wallets/coinbase"
55
import trust from "./wallets/trust"
66
import portis from "./wallets/portis"
77
import fortmatic from "./wallets/fortmatic"
8+
import authereum from "./wallets/authereum"
89
import squarelink from "./wallets/squarelink"
910

1011
function defaults({
@@ -43,6 +44,9 @@ function defaults({
4344
mobileModules.push(squarelink({ ...squarelinkInit, networkId }))
4445
}
4546

47+
desktopModules.push(authereum({ networkId }))
48+
mobileModules.push(authereum({ networkId }))
49+
4650
return {
4751
heading: heading || "Select a Wallet",
4852
description:
@@ -64,5 +68,6 @@ export default {
6468
trust,
6569
portis,
6670
fortmatic,
71+
authereum,
6772
squarelink
6873
}
4.47 KB
Loading
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Authereum from "authereum"
2+
import authereumIcon from "../wallet-icons/authereum.png"
3+
4+
import { networkName } from "../../../utilities"
5+
6+
function authereum(options) {
7+
if (!options || typeof options !== "object") {
8+
throw new Error(
9+
"An options object is required to initialize fortmatic module"
10+
)
11+
}
12+
13+
const { networkId } = options
14+
15+
if (!networkId || typeof networkId !== "number") {
16+
throw new Error(
17+
"A networkId of type number is required to initialize fortmatic module"
18+
)
19+
}
20+
21+
return {
22+
name: "Authereum",
23+
iconSrc: authereumIcon,
24+
wallet: () => {
25+
const authereum = new Authereum({
26+
networkName: networkName(networkId),
27+
disableNotifications: true
28+
})
29+
30+
const provider = authereum.getProvider()
31+
32+
return {
33+
provider,
34+
interface: {
35+
name: "Authereum",
36+
connect: () => provider.enable(),
37+
disconnect: () => authereum.logout(),
38+
loading: () =>
39+
new Promise(resolve => {
40+
authereum.on("openPopup", resolve)
41+
}),
42+
address: {
43+
get: () => authereum.getAccountAddress()
44+
},
45+
network: {
46+
get: () => Promise.resolve(networkId)
47+
},
48+
balance: {
49+
get: async () => {
50+
const loggedIn = await authereum.isAuthenticated()
51+
return loggedIn && authereum.getBalance()
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
58+
}
59+
60+
export default authereum

src/views/WalletReady.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import Modal from "../components/Modal.svelte";
1212
import ModalHeader from "../components/ModalHeader.svelte";
1313
import Button from "../elements/Button.svelte";
14+
import Spinner from "../elements/Spinner.svelte";
1415
1516
export let modules;
1617
export let walletSelect;
@@ -23,6 +24,7 @@
2324
let pollingInterval;
2425
let checkingModule;
2526
let actionResolved;
27+
let loading;
2628
2729
// recheck modules if below conditions
2830
$: if (!activeModal && !checkingModule) {
@@ -61,6 +63,11 @@
6163
doAction();
6264
}
6365
66+
if (activeModal.loading) {
67+
loading = true;
68+
activeModal.loading().then(() => (loading = false));
69+
}
70+
6471
// poll to automatically to check if condition has been met
6572
pollingInterval = setInterval(async () => {
6673
const invalid = await invalidState(currentModule, get(state));
@@ -199,6 +206,9 @@
199206
{:else}
200207
<div />
201208
{/if}
209+
{#if loading}
210+
<Spinner />
211+
{/if}
202212
<Button onclick={handleExit}>Dismiss</Button>
203213
</div>
204214
</Modal>

src/views/WalletSelect.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
provider,
9696
instance,
9797
name: module.name,
98-
connect: selectedWalletInterface.connect
98+
connect: selectedWalletInterface.connect,
99+
loading: selectedWalletInterface.loading
99100
});
100101
101102
finish({ completed: true });

0 commit comments

Comments
 (0)