diff --git a/src/components/DAppTable.tsx b/src/components/DAppTable.tsx index 83d394af..f1395b26 100644 --- a/src/components/DAppTable.tsx +++ b/src/components/DAppTable.tsx @@ -19,7 +19,7 @@ const isGreater = (a: any, b: any) => { undefined, { numeric: true, - } + }, ) === 1 ? -1 : 1; diff --git a/src/docs/getting-started/first-dapp.mdx b/src/docs/getting-started/first-dapp.mdx index 9f9d4ce5..1478b002 100644 --- a/src/docs/getting-started/first-dapp.mdx +++ b/src/docs/getting-started/first-dapp.mdx @@ -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); }); diff --git a/src/examples/getting-started-active-account-events.taquito.ts b/src/examples/getting-started-active-account-events.taquito.ts index 916f4246..fa8fe468 100644 --- a/src/examples/getting-started-active-account-events.taquito.ts +++ b/src/examples/getting-started-active-account-events.taquito.ts @@ -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); }); diff --git a/src/examples/getting-started-permission-request.beacon.ts b/src/examples/getting-started-permission-request.beacon.ts index a7a9e634..83db7746 100644 --- a/src/examples/getting-started-permission-request.beacon.ts +++ b/src/examples/getting-started-permission-request.beacon.ts @@ -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 @@ -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(); diff --git a/src/examples/getting-started-permission-request.taquito.ts b/src/examples/getting-started-permission-request.taquito.ts index e3003ab5..fa6580f5 100644 --- a/src/examples/getting-started-permission-request.taquito.ts +++ b/src/examples/getting-started-permission-request.taquito.ts @@ -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 @@ -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();