Skip to content

Commit

Permalink
feat(): add event to example
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasGassmann committed Oct 6, 2023
1 parent 306e7f6 commit fe6dea2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/DAppTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const isGreater = (a: any, b: any) => {
undefined,
{
numeric: true,
}
},
) === 1
? -1
: 1;
Expand Down
2 changes: 1 addition & 1 deletion src/docs/getting-started/first-dapp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const wallet = new BeaconWallet({ name: "Beacon Docs Taquito" });
Tezos.setWalletProvider(wallet);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getActiveAccountTaquitoWithEvents = async (loggerFun: Function) => {
Tezos.setWalletProvider(wallet);

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

Expand Down
11 changes: 10 additions & 1 deletion src/examples/getting-started-permission-request.beacon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// START
import { DAppClient } from "../node_modules/beacon-sdk/dist/cjs";
import { BeaconEvent, DAppClient } from "../node_modules/beacon-sdk/dist/cjs";
import Logger from "../Logger";
/// END

Expand All @@ -8,6 +8,15 @@ const requestPermissionsBeacon = async (loggerFun: Function) => {
/// START
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 {
logger.log("Requesting permissions...");
const permissions = await dAppClient.requestPermissions();
Expand Down
7 changes: 7 additions & 0 deletions src/examples/getting-started-permission-request.taquito.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// START
import { TezosToolkit } from "@taquito/taquito";
import { BeaconWallet } from "@taquito/beacon-wallet";
import { BeaconEvent } from "../node_modules/beacon-sdk/dist/cjs";
import Logger from "../Logger";
/// END

Expand All @@ -12,6 +13,12 @@ const requestPermissionsTaquito = async (loggerFun: Function) => {

Tezos.setWalletProvider(wallet);

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

try {
logger.log("Requesting permissions...");
const permissions = await wallet.client.requestPermissions();
Expand Down

0 comments on commit fe6dea2

Please sign in to comment.