Skip to content
This repository has been archived by the owner on Mar 26, 2023. It is now read-only.

Commit

Permalink
wallet working with vue
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstevens19 committed Sep 14, 2020
1 parent 6990451 commit f736eae
Show file tree
Hide file tree
Showing 18 changed files with 2,566 additions and 831 deletions.
2,794 changes: 2,040 additions & 754 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
"version": "0.1.0",
"private": true,
"scripts": {
"start": "vue-cli-service serve --port 3001",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@funfair-tech/wallet-sdk": "^2.1.1",
"core-js": "^3.6.5",
"vue": "^2.6.11"
"rxjs": "^6.6.3",
"vue": "^2.6.11",
"web3": "^1.2.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/cli-service": "~4.0.0",
"webpack-dev-server": "3.8.2",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
Expand Down
18 changes: 13 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title>
<script
src="https://wallet.funfair.io/assets/sdk/fun-wallet-sdk.js"
type="text/JavaScript"
></script>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
properly without JavaScript enabled. Please enable it to
continue.</strong
>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
Expand Down
148 changes: 136 additions & 12 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,152 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<WalletLeader
:registerWalletEventsCallback="this.registerWalletEventsCallback"
/>
<div class="App">
<div class="App-container">
<img class="App-logo" src="./assets/logo.svg" />
<p v-if="loading">Loading please wait</p>
<div class="action-buttons">
<div v-if="!loading && !isLoggedIn">
<LoggedOutActions />
</div>
<div v-if="!loading && isLoggedIn">
<LoggedInActions />
</div>
</div>
<div class="wallet-follower" v-if="!loading && isLoggedIn">
<WalletFollower />
</div>
</div>
</div>
</div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'
import { login, logout } from './services/wallet-service';
import WalletLeader from './components/Wallet-Leader.vue';
import { registerEventListeners } from './services/wallet-service';
import WalletFollower from './components/Wallet-Follower.vue';
import LoggedInActions from './components/Logged-In-Actions.vue';
import LoggedOutActions from './components/Logged-Out-Actions.vue';
import {
isAuthenticated$,
restoreAuthenticationTaskCompleted$,
} from './services/store';
export default {
name: 'App',
components: {
HelloWorld
}
}
WalletLeader,
LoggedInActions,
LoggedOutActions,
WalletFollower,
},
data: () => {
return { isLoggedIn: false, loading: true };
},
methods: {
registerWalletEventsCallback: function() {
registerEventListeners();
},
login: function() {
login();
},
logout: function() {
logout();
},
},
created: function() {
const _this = this;
isAuthenticated$.subscribe((value) => {
_this.$data.isLoggedIn = value;
});
restoreAuthenticationTaskCompleted$.subscribe((value) => {
if (value) {
_this.$data.loading = false;
}
});
},
};
</script>

<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
body {
margin: 0px;
}
.App {
text-align: center;
padding-bottom: 75px;
background-color: #242424;
}
.App-logo {
pointer-events: none;
width: 200px;
height: 100px;
}
.App-container {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.wallet-follower {
margin-top: 10px;
width: 100%;
}
.action-buttons button {
margin-left: 10px;
}
.action-buttons {
margin-bottom: 20px;
}
@media only screen and (max-width: 510px) {
.action-buttons .logged-in {
display: grid;
}
.action-buttons button {
margin-bottom: 10px;
}
}
button {
background: linear-gradient(to bottom, #f7a2c6 0%, #ea166f 2px, #bc1159 100%);
color: #fff;
box-sizing: border-box;
position: relative;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: pointer;
outline: none;
border: none;
-webkit-tap-highlight-color: transparent;
display: inline-block;
white-space: nowrap;
text-decoration: none;
vertical-align: baseline;
text-align: center;
color: #2c3e50;
margin-top: 60px;
margin: 0;
min-width: 64px;
line-height: 36px;
padding: 0 16px;
border-radius: 4px;
overflow: visible;
transform: translate3d(0, 0, 0);
transition: background 400ms cubic-bezier(0.25, 0.8, 0.25, 1),
box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
</style>
Binary file removed src/assets/logo.png
Binary file not shown.
40 changes: 40 additions & 0 deletions src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 0 additions & 58 deletions src/components/HelloWorld.vue

This file was deleted.

46 changes: 46 additions & 0 deletions src/components/Logged-In-Actions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<div className="logged-in">
<button @click="signAMessage">Sign message</button>
<button @click="sendSignedTransaction">
Send signed transaction
</button>
<button @click="openKycProcess">Start KYC</button>
<button @click="logout">Logout</button>
</div>
</template>

<script>
import {
logout,
openKycProcess,
sendTransaction,
signAMessage,
} from '../services/wallet-service';
export default {
name: 'LoggedInActions',
methods: {
async signAMessage() {
const signature = await signAMessage('TESTME');
console.log('Sign message complete. sig -', signature);
},
async sendSignedTransaction() {
const signature = await sendTransaction({
to: '0x45Cd08334aeedd8a06265B2Ae302E3597d8fAA28',
value: '0x00', // 0x38d7ea4c68000 if you want to add some value 0.002 ETH
});
console.log('Send signed transaction complete. sig -', signature);
},
logout() {
logout();
},
async openKycProcess() {
await openKycProcess();
},
},
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped></style>
21 changes: 21 additions & 0 deletions src/components/Logged-Out-Actions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div className="logged-out">
<button @click="login">Login</button>
</div>
</template>

<script>
import { login } from '../services/wallet-service';
export default {
name: 'LoggedOutActions',
methods: {
login() {
login();
},
},
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped></style>
Loading

0 comments on commit f736eae

Please sign in to comment.