Skip to content

Commit caa887e

Browse files
authored
Merge pull request #5 from findtoni:dev
update prod
2 parents 61bd7d3 + 52d81d5 commit caa887e

File tree

7 files changed

+52
-26
lines changed

7 files changed

+52
-26
lines changed

src/App.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ import AWaveLogo from './components/AWaveLogo.vue';
44
import AWaveIntro from './components/AWaveIntro.vue';
55
import AWaveInfo from './components/AWaveInfo.vue';
66
import AWaveRepo from './components/AWaveRepo.vue';
7+
import { useStore } from './store';
8+
const store = useStore();
9+
store.initialize();
710
</script>
811

912
<template>
1013
<div class="waveportal w-full h-full">
1114
<AWaveLogo />
1215
<AWaveIntro />
1316
<AWaveLog />
14-
<!-- <div class="w-5/6 md:w-3/4 mx-auto py-10">
15-
<div class="flex justify-between items-center mx-auto left-0 right-0 bottom-4 w-11/12 md:w-8/12">
16-
<AWaveRepo />
17-
<AWaveInfo />
18-
</div>
19-
</div> -->
17+
<div class="fixed bottom-[25px] md:bottom-[40px] left-[110px] md:left-[180px] mx-auto">
18+
<AWaveRepo />
19+
</div>
20+
<div class="fixed bottom-[20px] md:bottom-[40px] right-[-80px] md:right-[10px] w-64 mx-auto">
21+
<AWaveInfo />
22+
</div>
2023
</div>
2124
</template>
2225

src/components/AConnectWallet.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ async function connectWallet(network) {
2626
<img src="/wallet.svg" width="20" height="auto" alt="wallet" class="inline-flex mr-1 pb-1">
2727
Connect Wallet
2828
</button>
29-
<span v-if="store.isConnected && store.isWrongNetwork" class="w-auto inline-flex mx-auto items-center text-center px-2 py-0.5 rounded text-xs font-medium text-gray-300">
30-
<svg class="mr-1.5 h-2 w-2 text-purple-300" fill="currentColor" viewBox="0 0 8 8">
31-
<circle cx="4" cy="4" r="3" />
32-
</svg>
33-
Switch network to ropsten
34-
</span>
3529
</div>
3630
<AModal title="Connect a wallet" :open="open" @close="open = false">
3731
<div class="flex flex-col space-y-3 pt-5">

src/components/ASendWave.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup>
22
import { ref, computed } from 'vue';
33
import { useStore } from '../store';
4-
import { CheckIcon, SelectorIcon, CheckCircleIcon, ExternalLinkIcon } from '@heroicons/vue/solid';
4+
import { CheckIcon, SelectorIcon, CheckCircleIcon, ExternalLinkIcon, RefreshIcon } from '@heroicons/vue/solid';
55
import { Combobox, ComboboxButton, ComboboxInput, ComboboxLabel, ComboboxOption, ComboboxOptions } from '@headlessui/vue';
66
import { Listbox, ListboxButton, ListboxLabel, ListboxOption, ListboxOptions } from '@headlessui/vue';
77
import AModal from './base/AModal.vue';
@@ -31,6 +31,7 @@ const emojis = [
3131
const open = ref(false);
3232
const loading = ref(false);
3333
const hash = ref(null);
34+
const bePatient = ref(false);
3435
const wave = ref({ message: 'Hello!', emoji: '👋' });
3536
const query = ref('');
3637
const filtered = computed(() =>
@@ -43,6 +44,7 @@ const filtered = computed(() =>
4344
4445
async function sendWave() {
4546
loading.value = true;
47+
setTimeout(() => bePatient.value = true, 10000);
4648
hash.value = await store.sendWave(wave.value);
4749
loading.value = false;
4850
}
@@ -52,12 +54,6 @@ async function sendWave() {
5254
<div class="w-full">
5355
<button v-if="store.isWrongNetwork" class="w-full wave-button cursor-not-allowed bg-gray-300 rounded font-semibold h-10 mb-2">Wave at me!</button>
5456
<button v-else @click="open = true" class="w-full wave-button bg-white rounded font-semibold h-10 mb-2 transition ease-in-out delay-150 hover:scale-105">Wave at me!</button>
55-
<span v-if="store.isWrongNetwork" class="flex justify-center items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800">
56-
<svg class="mr-1.5 h-2 w-2 text-purple-400" fill="currentColor" viewBox="0 0 8 8">
57-
<circle cx="4" cy="4" r="3" />
58-
</svg>
59-
<span>Switch network to goerli</span>
60-
</span>
6157
<AModal title="Wave at me" :open="open" @close="open = false" :hide="loading || hash">
6258
<div v-if="!loading && !hash" class="w-full flex flex-col space-y-4 pt-4">
6359
<Listbox as="div" v-model="wave.emoji">
@@ -116,13 +112,17 @@ async function sendWave() {
116112
<div v-if="!hash" class="flex flex-col items-center space-y-3">
117113
<ALoading is-large />
118114
<p class="text-white text-lg">Mining transaction...</p>
115+
<p v-if="bePatient" class="text-gray-300">Hang in there, almost done</p>
119116
</div>
120117
<div v-else class="flex flex-col items-center space-y-3">
121118
<CheckCircleIcon class="h-12 w-12 text-green-600" />
122119
<p class="text-white text-lg">Transaction successful!</p>
123120
<a :href="`https://goerli.etherscan.io/tx/${hash}`" target="_blank">
124121
<p class="text-white underline inline-flex">View Transaction<ExternalLinkIcon class="w-4 h-4 mr-2 mt-1" /></p>
125122
</a>
123+
<p @click="window.location.reload()" class="inline-flex text-gray-300 text-xs cursor-pointer">
124+
<RefreshIcon class="w-3 h-3 mt-0.5 mr-1" />Reload to view wave
125+
</p>
126126
</div>
127127
</div>
128128
</AModal>

src/components/AWaveInfo.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ const open = ref(false);
1111
<a href="https://findtoni.dev/blog/ethereum-dev-overview" target="_blank" class="underline">Here's</a>
1212
a quick overview of building on Ethereum</p>
1313
<p class="leading-snug text-sm pt-1">
14-
<a href="https://buildspace.so/p/build-solidity-web3-app" target="_blank" class="underline">Buildspace</a>
15-
created this tutorial and <a href="https://buildspace.so/projects" target="_blank" class="underline">many more</a> awesome web3 dApp tutorials</p>
14+
<a href="https://findtoni.dev/blog/build-solidity-vue-web3-app" target="_blank" class="underline">
15+
Learn how to build this app</a>
16+
</p>
1617
</div>
17-
<QuestionMarkCircleIcon @click="open = !open" class="h-10 w-10 text-gray-300 hover:text-white cursor-pointer" />
18+
<QuestionMarkCircleIcon @click="open = !open" class="h-8 w-8 md:h-10 md:w-10 text-gray-300 hover:text-white cursor-pointer" />
1819
</div>
1920
</template>

src/components/AWaveLog.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ store.fetchWaves();
99
<h3 class="font-sans text-md md:text-xl font-bold text-white text-center pt-20 pb-4 md:pb-5">
1010
See who else waved at me
1111
</h3>
12-
<div class="flex justify-center items-center">
12+
<div v-if="store.isWrongNetwork" class="flex justify-center">
13+
<span @click="store.switchNetwork()" class="flex justify-center items-center px-2 py-0.5 rounded text-sm font-medium text-gray-300 cursor-pointer">
14+
<svg class="mr-1.5 h-2 w-2 text-pink-400" fill="currentColor" viewBox="0 0 8 8">
15+
<circle cx="4" cy="4" r="3" />
16+
</svg>
17+
Switch network to Goerli to view
18+
</span>
19+
</div>
20+
<div v-else class="flex justify-center items-center pb-20 md:pb-10">
1321
<div class="w-full md:w-3/5 lg:w-1/2 flex flex-col space-y-3">
1422
<div v-for="({ waver, message, emoji, timestamp }, index) in store.waves" :key="index" class="flex justify-between items-center border rounded-md p-3 focus-within:md:p-5 border-[#2a2a2a]">
1523
<div class="w-auto">
@@ -20,7 +28,7 @@ store.fetchWaves();
2028
<p class="font-semibold text-sm md:text-lg inline-flex">Waver<span class="ml-2 font-medium text-white">{{ waver.substring(0, 20) + '...' }}</span></p>
2129
<p class="md:hidden font-semibold text-gray-300 text-sm">Waved on<span class="ml-2 font-medium text-white">{{ timestamp }}</span></p>
2230
</div>
23-
<p class="hidden md:inline-flex text-center font-semibold w-1/5 text-gray-300 text-md">{{ timestamp }}</p>
31+
<p class="hidden md:inline-flex text-center font-semibold w-1/5 text-gray-300 text-base">{{ timestamp }}</p>
2432
</div>
2533
</div>
2634
</div>

src/components/AWaveRepo.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
<template>
55
<div class="w-auto">
6-
<img width="120" height="auto" alt="GitHub forks" src="https://img.shields.io/github/forks/findtoni/waveportal?style=social">
6+
<a href="https://github.com/findtoni/waveportal" target="_blank">
7+
<img class="w-20 md:w-22" width="auto" height="auto" alt="GitHub stars" src="https://img.shields.io/github/stars/findtoni/waveportal?style=social">
8+
</a>
79
</div>
810
</template>

src/store/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ export const useStore = defineStore('waveportal', {
3636
isWrongNetwork: state => state.network.chainId ? state.network.chainId !== '0x5' : true,
3737
},
3838
actions: {
39+
async initialize() {
40+
const chainId = await this.ethereum.request({ method: 'eth_chainId' });
41+
this.network.chainId = chainId;
42+
this.ethereum.on('chainChanged', () => {
43+
window.location.reload();
44+
});
45+
},
3946
async connectWallet(network) {
4047
if (network == 'metamask') {
4148
await this.useMetamask();
@@ -51,6 +58,7 @@ export const useStore = defineStore('waveportal', {
5158
const signature = await signer.signMessage(accounts[0]);
5259
this.account = accounts[0];
5360
this.network.chainId = chainId;
61+
if (this.isWrongNetwork) await this.switchNetwork();
5462
} else this.error = 'Install Metamask';
5563
},
5664
async useWalletConnect() {
@@ -61,6 +69,14 @@ export const useStore = defineStore('waveportal', {
6169
const chainId = await web3.eth.getChainId();
6270
this.account = accounts[0];
6371
this.network.chainId = chainId;
72+
if (this.isWrongNetwork) await this.switchNetwork();
73+
},
74+
async switchNetwork() {
75+
await this.ethereum.request({
76+
method: 'wallet_switchEthereumChain',
77+
params: [{ chainId: '0x5' }],
78+
});
79+
window.location.reload();
6480
},
6581
async fetchWaves() {
6682
const waves = await this.wavePortalContract.getAllWaves();
@@ -70,10 +86,12 @@ export const useStore = defineStore('waveportal', {
7086
waver: wave.waver,
7187
message: wave.message,
7288
emoji: wave.emoji,
73-
timestamp: dateFormat(new Date(wave.timestamp * 1000), 'mmmm dS, yyyy'),
89+
timestamp: dateFormat(new Date(wave.timestamp * 1000), 'mmm dS, yyyy'),
90+
rawDate: new Date(wave.timestamp * 1000),
7491
transaction: wave[0]
7592
})
7693
});
94+
this.waves = this.waves.sort((a, b) => b.rawDate - a.rawDate);
7795
},
7896
async sendWave(wave) {
7997
const waveTransaction = await this.wavePortalContract.wave(wave.message, wave.emoji, { gasLimit: this.contract.gasLimit });

0 commit comments

Comments
 (0)