From 9c9604b58a87d12f12c8a55faff610c2971a1750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Scho=CC=88nba=CC=88chler?= Date: Wed, 24 Sep 2025 15:07:39 +0200 Subject: [PATCH 01/45] feat(wallet): add full signing capabilities --- examples/abstracted-account.html | 2 +- examples/dapp.html | 64 +- examples/wallet.html | 743 +++++++++++++++--- package.json | 1 + .../beacon-core/src/clients/client/Client.ts | 21 +- 5 files changed, 715 insertions(+), 116 deletions(-) diff --git a/examples/abstracted-account.html b/examples/abstracted-account.html index cf6bde37a..d46afd33e 100644 --- a/examples/abstracted-account.html +++ b/examples/abstracted-account.html @@ -291,7 +291,7 @@ preferredNetwork: beacon.NetworkType.GHOSTNET }) - const Tezos = new taquito.TezosToolkit('https://ghostnet.tezos.marigold.dev/') + const Tezos = new taquito.TezosToolkit('https://rpc.ghostnet.teztnets.com/') Tezos.setWalletProvider(new BeaconWallet(dappClient)) const updateActiveAccount = () => { diff --git a/examples/dapp.html b/examples/dapp.html index a2ff931e8..6afdc0396 100644 --- a/examples/dapp.html +++ b/examples/dapp.html @@ -50,6 +50,11 @@

+ + Network: + + +



@@ -205,8 +210,40 @@ x.error('Error occurred: ' + e.reason.message) }) - // Initiate DAppClient - const client = beacon.getDAppClientInstance({ + // Network selection functions + const getSelectedNetwork = () => { + return localStorage.getItem('selectedNetwork') || 'mainnet' + } + + const saveSelectedNetwork = (network) => { + localStorage.setItem('selectedNetwork', network) + } + + // Populate network select + const populateNetworkSelect = () => { + const select = document.getElementById('networkSelect') + Object.values(beacon.NetworkType).forEach(network => { + const option = document.createElement('option') + option.value = network + option.text = network.toUpperCase() + select.appendChild(option) + }) + select.value = getSelectedNetwork() + } + + // Initialize client with selected network + let client + + const initClient = async () => { + const selectedNetwork = getSelectedNetwork() + console.log('Initializing client with network:', selectedNetwork) + + if (client) { + console.log('Destroying old client') + await client.destroy() + } + + client = new beacon.DAppClient({ name: 'Example DApp', // Name of the DApp, disclaimerText: 'This is an optional disclaimer.', appUrl: 'http://localhost:8080', @@ -234,14 +271,23 @@ }, featuredWallets: ['kukai', 'metamask', 'airgap'], network: { - type: beacon.NetworkType.GHOSTNET + type: selectedNetwork }, enableMetrics: true // matrixNodes: ['test.papers.tech', 'test2.papers.tech', 'matrix.papers.tech'] // matrixNodes: ['beacon-node-0.papers.tech:8448'] // matrixNodes: ['matrix.papers.tech'] // matrixNodes: ['beacon.tztip.me'] - }) + }) + + // Set up event listeners for the new client + client.subscribeToEvent('ACTIVE_ACCOUNT_SET', (account) => { + console.log('ACTIVE_ACCOUNT_SET received', account) + updateActiveAccount() + }) + + console.log('Client initialized with network:', selectedNetwork) + } // Display the active account in the UI const updateActiveAccount = () => { @@ -275,8 +321,14 @@ }) } - client.subscribeToEvent('ACTIVE_ACCOUNT_SET', (account) => { - console.log('ACTIVE_ACCOUNT_SET received', account) + // Initialize on page load + populateNetworkSelect() + initClient() + + // Add network change handler + document.getElementById('networkSelect').addEventListener('change', async (e) => { + saveSelectedNetwork(e.target.value) + await initClient() updateActiveAccount() }) diff --git a/examples/wallet.html b/examples/wallet.html index fe3510318..69d917b51 100644 --- a/examples/wallet.html +++ b/examples/wallet.html @@ -14,17 +14,6 @@ window.beaconSdkDebugEnabled = true - - - @@ -32,6 +21,32 @@ Beacon Example Wallet

+ + Network: + + +

+


@@ -39,6 +54,14 @@ ---

+
+ Peers +

No peers connected.

+ +


---

@@ -47,31 +70,484 @@

Test input: - diff --git a/package.json b/package.json index 0b3c7cff2..21aba1585 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "scripts": { "prebuild": "ts-node --project tsconfig-cjs.json scripts/generate-wallet-list.ts", "build": "npm run check-version && lerna run tsc && npm run webpack:all", + "serve": "static-server examples --port 8080", "webpack:all": "npm run webpack:sdk && npm run webpack:dapp && npm run webpack:wallet", "webpack:sdk": "webpack --mode=development --config webpack.config.js --entry=./packages/beacon-sdk/dist/cjs/index.js --output-path ./webpack_builds/sdk && terser --ecma=12 ./webpack_builds/sdk/main.js -o ./packages/beacon-sdk/dist/walletbeacon.min.js && cp ./packages/beacon-sdk/dist/walletbeacon.min.js ./examples/walletbeacon.min.js", "webpack:dapp": "webpack --mode=development --entry=./packages/beacon-dapp/dist/cjs/index.js --output-path ./webpack_builds/dapp && terser --ecma=12 ./webpack_builds/dapp/main.js -o ./packages/beacon-dapp/dist/walletbeacon.dapp.min.js", diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index eb8f54ece..1d905a98c 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -251,13 +251,28 @@ export abstract class Client extends BeaconClient { } protected async sendDisconnectToPeer(peer: PeerInfo, transport?: Transport): Promise { - const request: DisconnectMessage = { - id: await generateGUID(), + const id = await generateGUID() + const senderId = await getSenderId(await this.beaconId) + + const disconnectMessage: DisconnectMessage = { + id, version: peer.version, - senderId: await getSenderId(await this.beaconId), + senderId, type: BeaconMessageType.Disconnect } + const request = + peer.version === '3' + ? { + id, + version: peer.version, + senderId, + message: { + type: disconnectMessage.type + } + } + : disconnectMessage + const payload = await new Serializer().serialize(request) const selectedTransport = transport ?? (await this.transport) From 16da66c793e4264c38d47473906a7b2aac9d5c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Scho=CC=88nba=CC=88chler?= Date: Wed, 24 Sep 2025 18:07:24 +0200 Subject: [PATCH 02/45] fix(flow): fix reconnect flow --- examples/dapp.html | 38 ++++++++----- .../beacon-dapp/src/dapp-client/DAppClient.ts | 22 +++++++- .../P2PCommunicationClient.ts | 56 +++++++++++++------ .../src/matrix-client/MatrixClient.ts | 5 ++ .../src/matrix-client/MatrixHttpClient.ts | 25 +++++++-- .../beacon-wallet/src/client/WalletClient.ts | 2 - 6 files changed, 110 insertions(+), 38 deletions(-) diff --git a/examples/dapp.html b/examples/dapp.html index 6afdc0396..7b943ce9d 100644 --- a/examples/dapp.html +++ b/examples/dapp.html @@ -14,18 +14,6 @@ window.beaconSdkDebugEnabled = true - - - - - - Beacon Example -

- - Active account: - - - - -

- - Network: - - -

- - Preferred Protocol (max): - - -

- - Negotiated Protocol: - - -

- -

- -

- -

- -

- -

- -

- -

- -

- -

- -

- -

- -

- -

- -

- - -

- - -

- - -

- - -

- --- -

- -

- --- -

- -

- --- -

- -

- --- -

- -

- -

- -

- --- -

- Reproducing bugs: -

- -

- -

- --- -

- -

- --- -

- - Color Mode: - - -

- -

- -

- --- -

- -

- - -

- --- - - -

- --- - -
- -

-

End of page

+ +
+ +
+

Beacon Example DApp

+

Test Beacon SDK integration and wallet interactions

+
+ + +
+ +
+

Configuration

+ +
+ +
+ + +
+ + +
+ + +
+ + +
+ +
+ +
+
+ + +
+ + +
+
+
+ + +
+
+

Active Account

+ +
+ +
+ +
+
Address
+
+ Not connected + +
+
+ + + + + +
+
+
Balance
+
+
+
+
Network
+ +
+
+
Transport
+ +
+
+ + + +
+
+
+ + +
+ +
+

Send Tezos

+
+
+ +
+ + +
+
+
+ + +
+ +
+
+ + +
+

Signing

+
+ + + + +
+
+
+ + +
+ + +
+

Contract Deployment

+
+ + + + + + + +
+
+ +
+ +
+
+ No value loaded +
+ +
+
+ + +
+ +
+ + +
+
+ + + +
+
+
+
+ + +
+

Performance Tests

+
+ +
+ + +
+ + +
+ + +
+
+
+
+ + +
+ +
+

Account Management

+
+ + + + + +
+
+ + +
+

Utilities

+
+ + + +
+ UI: + + +
+
+
+ Color Mode: +
+
+
+ + +
+ +
+

Testing & Debug

+
+ + + + + +
+
+ + +
+

Serialization Tools

+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+

Logger Output

+
+
+
diff --git a/examples/wallet.html b/examples/wallet.html index 1f19d9c65..46a551b45 100644 --- a/examples/wallet.html +++ b/examples/wallet.html @@ -1,12 +1,11 @@ - - + + - + - Beacon Example Wallet - + - - - Beacon Example Wallet -

- - Network: - - -

- - Preferred Protocol (max): - - -

-

-