Skip to content

Commit

Permalink
feat(): update dapp example
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasGassmann committed Oct 6, 2023
1 parent d4775d1 commit 5ec493e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/docs/getting-started/first-dapp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ import { DAppClient } from "@airgap/beacon-sdk";

const dAppClient = new DAppClient({ name: "Beacon Docs" });

// Listen for all the active account changes
dAppClient.subscribeToEvent(BeaconEvent.ACTIVE_ACCOUNT_SET, async (account) => {
// An active account has been set, update the dApp UI
console.log(`${BeaconEvent.ACTIVE_ACCOUNT_SET} triggered: `, account);
});

try {
console.log("Requesting permissions...");
const permissions = await dAppClient.requestPermissions();
Expand All @@ -77,6 +83,15 @@ const wallet = new BeaconWallet({ name: "Beacon Docs Taquito" });

Tezos.setWalletProvider(wallet);

// Listen for all the active account changes
wallet.client.subscribeToEvent(
BeaconEvent.ACTIVE_ACCOUNT_SET,
async (account) => {
// An active account has been set, update the dApp UI
console.log(`${BeaconEvent.ACTIVE_ACCOUNT_SET} triggered: `, account);
}
);

try {
console.log("Requesting permissions...");
const permissions = await wallet.client.requestPermissions();
Expand Down Expand Up @@ -395,7 +410,7 @@ wallet.client.subscribeToEvent(
]);

console.log(response);
},
}
);

// Check if we are connected. If not, do a permission request first.
Expand Down

0 comments on commit 5ec493e

Please sign in to comment.