Skip to content

Commit

Permalink
docs(aepp): add Discover Accounts button in example
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Oct 25, 2024
1 parent f5e47c0 commit 3a514af
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/browser/aepp/src/components/ConnectLedger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<button @click="disconnect">Disconnect</button>
<button @click="addAccount">Add Account</button>
<button v-if="accounts.length > 1" @click="switchAccount">Switch Account</button>
<button @click="discoverAccounts">Discover Accounts</button>
<button @click="switchNode">Switch Node</button>
<div v-if="accounts.length">
<div>Accounts</div>
Expand Down Expand Up @@ -71,6 +72,12 @@ export default {
this.accounts.push(this.accounts.shift());
this.setAccount(this.accounts[0]);
},
async discoverAccounts() {
this.status = 'Discovering accounts';
this.accounts = await this.accountFactory.discover(this.aeSdk.api);
this.setAccount(this.accounts[0]);
this.status = '';
},
async switchNode() {
const networkId = this.$store.state.networkId === 'ae_mainnet' ? 'ae_uat' : 'ae_mainnet';
const [{ name }] = (await this.aeSdk.getNodesInPool()).filter(
Expand Down
7 changes: 7 additions & 0 deletions examples/browser/aepp/src/components/ConnectMetamask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<button @click="installSnap">Install Aeternity Snap</button>
<button @click="addAccount">Add Account</button>
<button v-if="accounts.length > 1" @click="switchAccount">Switch Account</button>
<button @click="discoverAccounts">Discover Accounts</button>
<button @click="switchNode">Switch Node</button>
<div v-if="accounts.length">
<div>Accounts</div>
Expand Down Expand Up @@ -85,6 +86,12 @@ export default {
this.accounts.push(this.accounts.shift());
this.setAccount(this.accounts[0]);
},
async discoverAccounts() {
this.status = 'Discovering accounts';
this.accounts = await this.accountFactory.discover(this.aeSdk.api);
this.setAccount(this.accounts[0]);
this.status = '';
},
async switchNode() {
const networkId = this.$store.state.networkId === 'ae_mainnet' ? 'ae_uat' : 'ae_mainnet';
const [{ name }] = (await this.aeSdk.getNodesInPool()).filter(
Expand Down
7 changes: 7 additions & 0 deletions examples/browser/aepp/src/components/ConnectMnemonic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<button @click="disconnect">Disconnect</button>
<button @click="addAccount">Add Account</button>
<button v-if="accounts.length > 1" @click="switchAccount">Switch Account</button>
<button @click="discoverAccounts">Discover Accounts</button>
<button @click="switchNode">Switch Node</button>
<div v-if="accounts.length">
<div>Accounts</div>
Expand Down Expand Up @@ -74,6 +75,12 @@ export default {
this.accounts.push(this.accounts.shift());
this.setAccount(toRaw(this.accounts[0]));
},
async discoverAccounts() {
this.status = 'Discovering accounts';
this.accounts = await this.accountFactory.discover(this.aeSdk.api);
this.setAccount(toRaw(this.accounts[0]));
this.status = '';
},
async switchNode() {
const networkId = this.$store.state.networkId === 'ae_mainnet' ? 'ae_uat' : 'ae_mainnet';
const [{ name }] = (await this.aeSdk.getNodesInPool()).filter(
Expand Down

0 comments on commit 3a514af

Please sign in to comment.