Skip to content

Commit

Permalink
fix: removed todos
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Feb 8, 2024
1 parent 01790b5 commit 0b13efe
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 93 deletions.
3 changes: 3 additions & 0 deletions scripts/fix-beacon-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const fs = require("fs");
// fs.writeFileSync("./node_modules/@airgap/beacon-sdk/package.json", newContent, {
// encoding: "utf8",
// });
window.addEventListener('unhandledrejection', function (e) {
console.warn('Error occurred: ' + e.reason.message)
})

content = fs.readFileSync(
"./node_modules/@airgap/beacon-sdk/dist/walletbeacon.min.js",
Expand Down
10 changes: 4 additions & 6 deletions src/docs/advanced/ui-elements.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,9 @@ import {
NetworkType,
WalletConnectPairingRequest,
AnalyticsInterface,
} from "@airgap/beacon-sdk";

} from "@airgap/beacon-sdk";

const dAppClient = new DAppClient({
const dAppClient = new DAppClient({
name: "Beacon Docs",
eventHandlers: {
[BeaconEvent.PAIR_INIT]: {
Expand Down Expand Up @@ -396,10 +395,9 @@ import {
NetworkType,
WalletConnectPairingRequest,
AnalyticsInterface,
} from "@airgap/beacon-sdk";

} from "@airgap/beacon-sdk";

const Tezos = new TezosToolkit("https://mainnet.api.tez.ie");
const Tezos = new TezosToolkit("https://mainnet.api.tez.ie");
const wallet = new BeaconWallet({
name: "Beacon Docs Taquito",
eventHandlers: {
Expand Down
7 changes: 2 additions & 5 deletions src/docs/blockchains/blockchain-substrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,8 @@ export interface SubstrateSignPayloadRequest
isMutable: boolean;
dataType: "bytes" | "payload";
data: string;


mode: "submit" | "submit-and-return" | "return";

}
mode: "submit" | "submit-and-return" | "return";
}
```
### Sign Payload Response
Expand Down
4 changes: 1 addition & 3 deletions src/docs/blockchains/blockchain-tezos-sapling.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export interface TezosSaplingPermissionRequest
type: NetworkType;
name?: string;
rpcUrl?: string;


}
}
```
### Permission Response
Expand Down
5 changes: 1 addition & 4 deletions src/docs/blockchains/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ client.connect(async (message) => {
"3b92229274683b338cf8b040cf91ac0f8e19e410f06eda5537ef077e718e0024",
},
],
},


// Send response back to dApp
}, // Send response back to dApp
client.respond(response);
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/docs/getting-started/advanced-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ const explorerLink = await dAppClient.blockExplorer.getTransactionLink(

console.log("Block Explorer:", explorerLink);

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

// If you want to "disconnect" a wallet, clear the active account.
// This means the next time the active account is checked or a permission request is triggered, it will be like it's the users first interaction.
await dAppClient.clearActiveAccount();
Expand Down Expand Up @@ -180,9 +177,6 @@ const explorerLink = await wallet.client.blockExplorer.getTransactionLink(

console.log("Block Explorer:", explorerLink);

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

// If you want to "disconnect" a wallet, clear the active account.
// This means the next time the active account is checked or a permission request is triggered, it will be like it's the users first interaction.
await wallet.clearActiveAccount();
Expand Down
11 changes: 1 addition & 10 deletions src/docs/guides/disconnecting-a-wallet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ import TabItem from "@theme/TabItem";

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


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

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));
import { DAppClient } from "@airgap/beacon-sdk"; const dAppClient = new DAppClient({ name: "Beacon Docs" });

dAppClient.clearActiveAccount().then(
const account = await dAppClient.getActiveAccount();
Expand All @@ -47,9 +41,6 @@ const wallet = new BeaconWallet({ name: "Beacon Docs Taquito" });

Tezos.setWalletProvider(wallet);

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

await wallet.clearActiveAccount();

try {
Expand Down
1 change: 0 additions & 1 deletion src/docs/guides/standalone-delegation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ You can do this with python: `python -m SimpleHTTPServer 8080`
],
});
// Add event listener to the button
document.getElementById("connect").addEventListener("click", () => {
// Check if we have an active account
Expand Down
6 changes: 0 additions & 6 deletions src/docs/guides/subscribe-to-event.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const dAppClient = new DAppClient({
name: "Beacon Docs",
});

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

await dAppClient.clearActiveAccount();

console.log(await dAppClient.getActiveAccount());
Expand All @@ -52,9 +49,6 @@ const wallet = new BeaconWallet({ name: "Beacon Docs Taquito" });

Tezos.setWalletProvider(wallet);

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

await wallet.clearActiveAccount();

console.log(await wallet.client.getActiveAccount());
Expand Down
42 changes: 8 additions & 34 deletions src/docs/wallet/getting-started/web/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,49 +37,34 @@ const connectApp = async (): Promise<void> => {
switch (message.type) {
case BeaconMessageType.PermissionRequest:
// Prompt user for permissions. If multiple accounts are available, let user choose one of them

response = {
type: BeaconMessageType.PermissionResponse,
network: message.network, // Use the same network that the user requested
scopes: message.scopes,
id: message.id,
publicKey:
"3b92229274683b311cf8b040cf91ac0f8e19e410f06eda5537ef077e718e0024",


// Optional
"3b92229274683b311cf8b040cf91ac0f8e19e410f06eda5537ef077e718e0024", // Optional
// If the user aborts an action at any time, you can send back an error:
response = {
type: BeaconMessageType.Error,
id: message.id,
errorType: BeaconErrorType.ABORTED_ERROR,


break;
errorType: BeaconErrorType.ABORTED_ERROR, break;
case BeaconMessageType.SignPayloadRequest:
// Sign message.payload and return signature

response = {
type: BeaconMessageType.SignPayloadResponse,
id: message.id,
signingType: message.signingType,
signature: "edsig...",


break;
signature: "edsig...", break;
case BeaconMessageType.OperationRequest:
// Prepare transaction based on the details give in message.operationDetails
// message.operationDetails only contains a partial tezos transaction. Not all fields are mandatory
// The fields that are not present (eg. counter, fee, gas_limit) have to be set by the wallet
// If one of the optional fields is set, then that one should be used and not replaced by the wallet

response = {
type: BeaconMessageType.OperationResponse,
id: message.id,
transactionHash: "op...",


// Optional
transactionHash: "op...", // Optional
// If the transaction cannot be prepared, (eg. run_operations fails), an error containing the rpc error can be returned
let error = [
{
Expand All @@ -94,32 +79,22 @@ const connectApp = async (): Promise<void> => {
type: BeaconMessageType.Error,
id: message.id,
errorType: BeaconErrorType.TRANSACTION_INVALID_ERROR,
errorData: error,


break;
errorData: error, break;
case BeaconMessageType.BroadcastRequest:
response = {
type: BeaconMessageType.OperationResponse,
id: message.id,
transactionHash: "op...",


break;
transactionHash: "op...", break;
default:
response = {
type: BeaconMessageType.Error,
id: message.id,
errorType: BeaconErrorType.ABORTED_ERROR,

}

client.respond(response);
})
.catch((error) => console.error("connect error", error));


connectApp().catch((error) => console.error("connect error", error));
.catch((error) => console.error("connect error", error));connectApp().catch((error) => console.error("connect error", error));
```
By adding the code above, our app is now ready to receive messages. Now all that is left for us to do is connecting to a dApp.
Expand All @@ -136,8 +111,7 @@ const isBeaconMessage: (obj: unknown) => obj is P2PPairingRequest = (
typeof (obj as P2PPairingRequest).publicKey === "string" &&
typeof (obj as P2PPairingRequest).relayServer === "string"
);



const handshakeMessage = ""; // This was received from the dApp, eg. through QR scanning or deeplink

const deserialized = await new Serializer().deserialize(handshakeMessage);
Expand Down
3 changes: 0 additions & 3 deletions src/examples/disconnect-wallet.beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const disconnectWalletBeacon = async (loggerFun: Function) => {
/// START
const dAppClient = new DAppClient({ name: "Beacon Docs" });

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

dAppClient.clearActiveAccount().then(async () => {
const account = await dAppClient.getActiveAccount();

Expand Down
3 changes: 0 additions & 3 deletions src/examples/disconnect-wallet.taquito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const disconnectWalletTaquito = async (loggerFun: Function) => {

Tezos.setWalletProvider(wallet);

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

await wallet.clearActiveAccount();

try {
Expand Down
3 changes: 0 additions & 3 deletions src/examples/example-advanced.beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ const exampleAdvancedBeacon = async (loggerFun: Function) => {
return;
}

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

// If you want to "disconnect" a wallet, clear the active account.
// This means the next time the active account is checked or a permission request is triggered, it will be like it's the users first interaction.
await dAppClient.clearActiveAccount();
Expand Down
3 changes: 0 additions & 3 deletions src/examples/example-advanced.taquito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ const exampleAdvancedTaquito = async (loggerFun: Function) => {
return;
}

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

// If you want to "disconnect" a wallet, clear the active account.
// This means the next time the active account is checked or a permission request is triggered, it will be like it's the users first interaction.
await wallet.clearActiveAccount();
Expand Down
3 changes: 0 additions & 3 deletions src/examples/subscribe-to-event.beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const subscribeToEventBeacon = async (loggerFun: Function) => {
name: "Beacon Docs",
});

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

await dAppClient.clearActiveAccount();

logger.log("Active account: ", await dAppClient.getActiveAccount());
Expand Down
3 changes: 0 additions & 3 deletions src/examples/subscribe-to-event.taquito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ const subscribeToEventTaquito = async (loggerFun: Function) => {

Tezos.setWalletProvider(wallet);

// TODO: Remove temporary workaround in sandbox
await new Promise((resolve) => setTimeout(resolve, 1000));

await wallet.clearActiveAccount();

logger.log("Active account: ", await wallet.client.getActiveAccount());
Expand Down

0 comments on commit 0b13efe

Please sign in to comment.