Skip to content

Commit

Permalink
show nonce number in navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed May 15, 2024
1 parent c246e55 commit 63ff831
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@

<button v-if="!isActivated" class="btn btn-primary navbar-menu-btn ms-2" data-bs-toggle="modal" data-bs-target="#connectModal">Connect wallet</button>

<!-- Temp: Nonce number -->
<span
class="btn btn-primary ms-2 navbar-menu-btn"
v-if="isActivated && nonce"
>{{ nonce }}</span>

<!-- Block Explorer -->
<a
class="btn btn-primary ms-2 navbar-menu-btn"
Expand Down Expand Up @@ -92,6 +98,12 @@ import useChainHelpers from "../hooks/useChainHelpers";
export default {
name: "Navbar",
data() {
return {
nonce: null
}
},
computed: {
...mapGetters("user", ["getUserShortAddress", "getUserSelectedName"]),
...mapGetters("network", ["getNetworkName", "getSupportedNetworks", "getSupportedNetworkNames"]),
Expand All @@ -111,6 +123,12 @@ export default {
this.switchOrAddChain(window.ethereum, networkName);
},
async fetchNonce() {
console.log(this.signer.provider);
this.nonce = await this.signer.provider.getTransactionCount(this.address);
console.log("Nonce: ", this.nonce);
},
logout() {
this.disconnect();
localStorage.clear();
Expand All @@ -125,11 +143,17 @@ export default {
setup() {
const { open } = useBoard();
const { disconnect } = useWallet();
const { address, isActivated } = useEthers();
const { address, isActivated, signer } = useEthers();
const { switchOrAddChain } = useChainHelpers();
return {
address, isActivated, disconnect, open, switchOrAddChain
address, isActivated, disconnect, open, signer, switchOrAddChain
}
},
watch: {
address() {
this.fetchNonce();
}
}
}
Expand Down

0 comments on commit 63ff831

Please sign in to comment.