Skip to content

Commit

Permalink
fix: refactor examples
Browse files Browse the repository at this point in the history
  • Loading branch information
isordo committed Oct 5, 2023
1 parent 1c5268f commit 986a2eb
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 35 deletions.
22 changes: 22 additions & 0 deletions src/ExecuteExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import requestOperationBeacon from "./examples/getting-started-operation-request
import requestOperationTaquito from "./examples/getting-started-operation-request.taquito";
import requestPermissionsBeacon from "./examples/getting-started-permission-request.beacon";
import requestPermissionsTaquito from "./examples/getting-started-permission-request.taquito";
import infoConnectionBeacon from "./examples/info-connection.beacon";
import infoConnectionTaquito from "./examples/info-connection.taquito";
import infoVersionBeacon from "./examples/info-version.beacon";
import infoVersionTaquito from "./examples/info-version.taquito";
import networkCustomBeacon from "./examples/network-custom-network.beacon";
import networkCustomTaquito from "./examples/network-custom-network.taquito";
import networkEdonetWithRpcBeacon from "./examples/network-edonet-with-url.beacon";
Expand Down Expand Up @@ -194,6 +198,24 @@ export class ExecuteExample {
case "taquito different node":
await differentNodeTaquito(updateLogs);
break;
case "beacon sdk version":
await infoVersionBeacon(updateLogs);
break;
case "taquito sdk version":
await infoVersionTaquito(updateLogs);
break;
case "beacon sdk client":
await infoVersionBeacon(updateLogs);
break;
case "taquito sdk client":
await infoVersionTaquito(updateLogs);
break;
case "beacon sdk connection":
await infoConnectionBeacon(updateLogs);
break;
case "taquito sdk connection":
await infoConnectionTaquito(updateLogs);
break;
default:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions src/docs/advanced/sdk-info.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import TabItem from "@theme/TabItem";
<TabItem value="beacon">

```ts live
// beacon sdk version
import { BEACON_VERSION, SDK_VERSION } from "@airgap/beacon-sdk";

console.log("SDK Version", SDK_VERSION);
Expand All @@ -27,6 +28,7 @@ console.log("Beacon Version", BEACON_VERSION);
<TabItem value="taquito">

```ts live
// taquito sdk version
import { BEACON_VERSION, SDK_VERSION } from "@airgap/beacon-sdk";

console.log("SDK Version", SDK_VERSION);
Expand All @@ -47,6 +49,7 @@ console.log("Beacon Version", BEACON_VERSION);
<TabItem value="beacon">

```ts live
// beacon sdk client
import { DAppClient } from "@airgap/beacon-sdk";

const dAppClient = new DAppClient({ name: "Beacon Docs" });
Expand All @@ -60,6 +63,7 @@ console.log(`Connected Peers:`, await dAppClient.getPeers());
<TabItem value="taquito">

```ts live
// taquito sdk client
import { TezosToolkit } from "@taquito/taquito";
import { BeaconWallet } from "@taquito/beacon-wallet";

Expand All @@ -86,6 +90,7 @@ console.log(`Connected Peers:`, await wallet.client.getPeers());
<TabItem value="beacon">

```ts live
// beacon sdk connection
import { DAppClient, NetworkType } from "@airgap/beacon-sdk";

const dAppClient = new DAppClient({ name: "Beacon Docs" });
Expand Down Expand Up @@ -121,6 +126,7 @@ console.log("Own Metadata:", ownMetadata);
<TabItem value="taquito">

```ts live
// taquito sdk connection
import { TezosToolkit } from "@taquito/taquito";
import { BeaconWallet } from "@taquito/beacon-wallet";
import { DAppClient, NetworkType } from "@airgap/beacon-sdk";
Expand Down
9 changes: 6 additions & 3 deletions src/examples/info-client.beacon.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/// START
import { DAppClient } from "../node_modules/beacon-sdk/dist/cjs";
import Logger from "../Logger";
/// END

async () => {
const infoClientBeacon = async (loggerFun: Function) => {
const logger = new Logger(loggerFun);
/// START
const dAppClient = new DAppClient({ name: "Beacon Docs" });

console.log(`Connected Accounts:`, await dAppClient.getAccounts());
console.log(`Connected Peers:`, await dAppClient.getPeers());
logger.log(`Connected Accounts:`, await dAppClient.getAccounts());
logger.log(`Connected Peers:`, await dAppClient.getPeers());
/// END
};
export default infoClientBeacon;
9 changes: 6 additions & 3 deletions src/examples/info-client.taquito.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/// START
import { TezosToolkit } from "@taquito/taquito";
import { BeaconWallet } from "@taquito/beacon-wallet";
import Logger from "../Logger";
/// END

async () => {
const infoVersionTaquito = async (loggerFun: Function) => {
const logger = new Logger(loggerFun);
/// START
const Tezos = new TezosToolkit("https://mainnet-tezos.giganode.io");
const wallet = new BeaconWallet({ name: "Beacon Docs Taquito" });

Tezos.setWalletProvider(wallet);

console.log(`Connected Accounts:`, await wallet.client.getAccounts());
console.log(`Connected Peers:`, await wallet.client.getPeers());
logger.log(`Connected Accounts:`, await wallet.client.getAccounts());
logger.log(`Connected Peers:`, await wallet.client.getPeers());
/// END
};
export default infoVersionTaquito;
25 changes: 14 additions & 11 deletions src/examples/info-connection.beacon.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
/// START
import { DAppClient, NetworkType } from "../node_modules/beacon-sdk/dist/cjs";
import Logger from "../Logger";
/// END

async () => {
const infoConnectionBeacon = async (loggerFun: Function) => {
const logger = new Logger(loggerFun);
/// START
const dAppClient = new DAppClient({ name: "Beacon Docs" });

const addressLink = await dAppClient.blockExplorer.getAddressLink(
"tz1MJx9vhaNRSimcuXPK2rW4fLccQnDAnVKJ",
{ type: NetworkType.MAINNET },
);
console.log("Address Link", addressLink);
logger.log("Address Link", addressLink);

const txLink = await dAppClient.blockExplorer.getTransactionLink(
"onzCRJhQ9zPC38TLGhBTghCW7WAJpfUJ2NpwbbQKbW6LeEL8RfK",
{ type: NetworkType.MAINNET },
);
console.log("Transaction Link", txLink);
logger.log("Transaction Link", txLink);

console.log("\n\nConnection Info:\n");
console.log("Status:", dAppClient.connectionStatus);
logger.log("\n\nConnection Info:\n");
logger.log("Status:", dAppClient.connectionStatus);
const accounts = await dAppClient.getAccounts();
console.log("Accounts:", accounts);
logger.log("Accounts:", accounts);
const peers = await dAppClient.getPeers();
console.log("Peers:", peers);
logger.log("Peers:", peers);

console.log("\n\nDebug:\n");
console.log("Local Beacon ID:", await dAppClient.beaconId);
logger.log("\n\nDebug:\n");
logger.log("Local Beacon ID:", await dAppClient.beaconId);
const colorMode = await dAppClient.getColorMode();
console.log("Color Mode:", colorMode);
logger.log("Color Mode:", colorMode);
const ownMetadata = await dAppClient.getOwnAppMetadata();
console.log("Own Metadata:", ownMetadata);
logger.log("Own Metadata:", ownMetadata);
/// END
};
export default infoConnectionBeacon;
27 changes: 15 additions & 12 deletions src/examples/info-connection.taquito.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/// START
import { TezosToolkit } from "@taquito/taquito";
import { BeaconWallet } from "@taquito/beacon-wallet";
import { DAppClient, NetworkType } from "../node_modules/beacon-sdk/dist/cjs";
import { NetworkType } from "../node_modules/beacon-sdk/dist/cjs";
import Logger from "../Logger";
/// END

async () => {
const infoConnectionTaquito = async (loggerFun: Function) => {
const logger = new Logger(loggerFun);
/// START
const Tezos = new TezosToolkit("https://mainnet-tezos.giganode.io");
const wallet = new BeaconWallet({ name: "Beacon Docs Taquito" });
Expand All @@ -15,26 +17,27 @@ async () => {
"tz1MJx9vhaNRSimcuXPK2rW4fLccQnDAnVKJ",
{ type: NetworkType.MAINNET },
);
console.log("Address Link", addressLink);
logger.log("Address Link", addressLink);

const txLink = await wallet.client.blockExplorer.getTransactionLink(
"onzCRJhQ9zPC38TLGhBTghCW7WAJpfUJ2NpwbbQKbW6LeEL8RfK",
{ type: NetworkType.MAINNET },
);
console.log("Transaction Link", txLink);
logger.log("Transaction Link", txLink);

console.log("\n\nConnection Info:\n");
console.log("Status:", wallet.client.connectionStatus);
logger.log("\n\nConnection Info:\n");
logger.log("Status:", wallet.client.connectionStatus);
const accounts = await wallet.client.getAccounts();
console.log("Accounts:", accounts);
logger.log("Accounts:", accounts);
const peers = await wallet.client.getPeers();
console.log("Peers:", peers);
logger.log("Peers:", peers);

console.log("\n\nDebug:\n");
console.log("Local Beacon ID:", await wallet.client.beaconId);
logger.log("\n\nDebug:\n");
logger.log("Local Beacon ID:", await wallet.client.beaconId);
const colorMode = await wallet.client.getColorMode();
console.log("Color Mode:", colorMode);
logger.log("Color Mode:", colorMode);
const ownMetadata = await wallet.client.getOwnAppMetadata();
console.log("Own Metadata:", ownMetadata);
logger.log("Own Metadata:", ownMetadata);
/// END
};
export default infoConnectionTaquito;
9 changes: 6 additions & 3 deletions src/examples/info-version.beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import {
BEACON_VERSION,
SDK_VERSION,
} from "../node_modules/beacon-sdk/dist/cjs";
import Logger from "../Logger";
/// END

async () => {
const infoVersionBeacon = async (loggerFun: Function) => {
const logger = new Logger(loggerFun);
/// START
console.log("SDK Version", SDK_VERSION);
console.log("Beacon Version", BEACON_VERSION);
logger.log("SDK Version", SDK_VERSION);
logger.log("Beacon Version", BEACON_VERSION);
/// END
};
export default infoVersionBeacon;
9 changes: 6 additions & 3 deletions src/examples/info-version.taquito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import {
BEACON_VERSION,
SDK_VERSION,
} from "../node_modules/beacon-sdk/dist/cjs";
import Logger from "../Logger";
/// END

async () => {
const infoVersionTaquito = async (loggerFun: Function) => {
const logger = new Logger(loggerFun);
/// START
console.log("SDK Version", SDK_VERSION);
console.log("Beacon Version", BEACON_VERSION);
logger.log("SDK Version", SDK_VERSION);
logger.log("Beacon Version", BEACON_VERSION);
/// END
};
export default infoVersionTaquito;

0 comments on commit 986a2eb

Please sign in to comment.