From 075dcc4b7630df69e71b0cd8170277ae17f2fa2e Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 16 Apr 2024 10:50:04 +0200 Subject: [PATCH 01/41] fix: signClient cleanup --- .../WalletConnectCommunicationClient.ts | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 4df3a18ca..d417f92aa 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -163,7 +163,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { */ private async refreshState() { this.clearEvents() - this.signClient = undefined + await this.closeSignClient() const client = (await this.getSignClient())! const lastIndex = client.session.keys.length - 1 @@ -221,6 +221,24 @@ export class WalletConnectCommunicationClient extends CommunicationClient { // implementation } + private async closeSignClient() { + if (!this.signClient) { + logger.error('No client active') + return + } + + await this.signClient.core.relayer.transportClose() + this.signClient.core.events.removeAllListeners() + this.signClient.core.relayer.events.removeAllListeners() + this.signClient.core.heartbeat.stop() + this.signClient.core.relayer.provider.events.removeAllListeners() + this.signClient.core.relayer.subscriber.events.removeAllListeners() + this.signClient.core.relayer.provider.connection.events.removeAllListeners() + this.clearEvents() + + this.signClient = undefined + } + private async ping() { const client = await this.getSignClient() @@ -564,14 +582,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient { return } - // const sessions = signClient.session.getAll() - // if (sessions && sessions.length > 0) { - // this.session = sessions[0] - // this.setDefaultAccountAndNetwork() - // this.updateStorageWallet(this.session) - // return undefined - // } - const lastIndex = signClient.session.keys.length - 1 if (lastIndex > -1) { From ff75f2b99df4755654dd060d7980d0ad234e2f8a Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 16 Apr 2024 13:23:12 +0200 Subject: [PATCH 02/41] fix: closeSignClient in closePairing --- .../src/communication-client/WalletConnectCommunicationClient.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index d417f92aa..3e8797eb1 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -939,6 +939,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { )) } + await this.closeSignClient() await this.storage.resetState() this.storage.notify('RESET') } From 4b6ffe538d2816ff4de4632f5bf1e6bf48aafc99 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 16 Apr 2024 14:53:57 +0200 Subject: [PATCH 03/41] fix: removed duplicate --- .../src/communication-client/WalletConnectCommunicationClient.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 3e8797eb1..ad9de2eb1 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -162,7 +162,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient { * differ from a wallet state */ private async refreshState() { - this.clearEvents() await this.closeSignClient() const client = (await this.getSignClient())! From bc5d1d5e88486f89f128378411b61b01e2715c7a Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 16 Apr 2024 17:03:09 +0200 Subject: [PATCH 04/41] feat: refactor --- .../src/storage/IndexedDBStorage.ts | 393 ++++++------------ 1 file changed, 130 insertions(+), 263 deletions(-) diff --git a/packages/beacon-core/src/storage/IndexedDBStorage.ts b/packages/beacon-core/src/storage/IndexedDBStorage.ts index ba34774b0..f8cc8323d 100644 --- a/packages/beacon-core/src/storage/IndexedDBStorage.ts +++ b/packages/beacon-core/src/storage/IndexedDBStorage.ts @@ -4,128 +4,119 @@ import { Logger } from '@airgap/beacon-core' const logger = new Logger('IndexedDBStorage') export class IndexedDBStorage extends Storage { + private db: IDBDatabase | null = null + constructor( private readonly dbName: string = 'WALLET_CONNECT_V2_INDEXED_DB', private readonly storeName: string = 'keyvaluestorage' ) { super() - this.init() - } - - private async init() { - const request = indexedDB.open(this.dbName) - - request.onupgradeneeded = (event: any) => { - const db = event.target?.result - - if (!db.objectStoreNames.contains(this.storeName)) { - db.createObjectStore(this.storeName) - } - } - - request.onsuccess = (event: any) => { - logger.log(`Database ${this.dbName} and store ${this.dbName} are ready for use.`) - const db = event.target?.result - - db.close() - } - - request.onerror = (event: any) => { - logger.error(`Error opening database ${this.dbName}:`, event.target?.error) - } + this.initDB() + .then((db) => (this.db = db)) + .catch((err) => logger.error(err.message)) } - get(key: K): Promise { + private async initDB(): Promise { return new Promise((resolve, reject) => { const request = indexedDB.open(this.dbName) - - request.onsuccess = (event) => { - const db = (event.target as IDBOpenDBRequest).result - - const transaction = db.transaction(this.storeName, 'readonly') - const objectStore = transaction.objectStore(this.storeName) - - const getRequest = objectStore.get(key) - - getRequest.onsuccess = () => { - const result = getRequest.result - resolve(result) + request.onupgradeneeded = (event) => { + const request = event.target as IDBOpenDBRequest + const db = request.result + if (!db.objectStoreNames.contains(this.storeName)) { + db.createObjectStore(this.storeName) } - - getRequest.onerror = (getEvent) => { - logger.error(`Error getting record with key ${key}:`, getEvent.target) - reject(getEvent.target) - } - } - - request.onerror = (event) => { - logger.error('Error opening database:', event.target) - reject(event.target) } + request.onsuccess = (event: any) => resolve(event.target.result) + request.onerror = (event: any) => reject(event.target.error) }) } - set(key: K, value: StorageKeyReturnType[K]): Promise { + private async transaction( + mode: IDBTransactionMode, + operation: (store: IDBObjectStore) => Promise + ): Promise { return new Promise((resolve, reject) => { - const request = indexedDB.open(this.dbName) - - request.onsuccess = (event) => { - const db = (event.target as IDBOpenDBRequest).result - - const transaction = db.transaction(this.storeName, 'readwrite') - const objectStore = transaction.objectStore(this.storeName) - - const putRequest = objectStore.put(value, key) - - putRequest.onsuccess = () => { - logger.log(`Record with key ${key} updated/inserted successfully`) - resolve() - } - - putRequest.onerror = (putEvent) => { - logger.error(`Error updating/inserting record with key ${key}:`, putEvent.target) - reject(putEvent.target) - } - } - - request.onerror = (event) => { - logger.error('Error opening database:', event.target) - reject(event.target) - } + const transaction = this.db?.transaction(this.storeName, mode) + const objectStore = transaction?.objectStore(this.storeName) + objectStore && operation(objectStore).then(resolve).catch(reject) }) } - delete(key: K): Promise { - return new Promise((resolve, reject) => { - const request = indexedDB.open(this.dbName) + public get(key: K): Promise { + return this.transaction( + 'readonly', + (store) => + new Promise((resolve, reject) => { + const getRequest = store.get(key) + getRequest.onsuccess = () => resolve(getRequest.result) + getRequest.onerror = () => reject(getRequest.error) + }) + ) + } - request.onsuccess = (event) => { - const db = (event.target as IDBOpenDBRequest).result + public set(key: K, value: StorageKeyReturnType[K]): Promise { + return this.transaction( + 'readwrite', + (store) => + new Promise((resolve, reject) => { + const putRequest = store.put(value, key) + putRequest.onsuccess = () => resolve() + putRequest.onerror = () => reject(putRequest.error) + }) + ) + } - const transaction = db.transaction(this.storeName, 'readwrite') - const objectStore = transaction.objectStore(this.storeName) + public delete(key: K): Promise { + return this.transaction( + 'readwrite', + (store) => + new Promise((resolve, reject) => { + const deleteRequest = store.delete(key) + deleteRequest.onsuccess = () => resolve() + deleteRequest.onerror = () => reject(deleteRequest.error) + }) + ) + } - const deleteRequest = objectStore.delete(key) + public getAll(): Promise { + return this.transaction( + 'readonly', + (store) => + new Promise((resolve, reject) => { + const getAllRequest = store.getAll() + getAllRequest.onsuccess = () => resolve(getAllRequest.result) + getAllRequest.onerror = () => reject(getAllRequest.error) + }) + ) + } - deleteRequest.onsuccess = () => { - logger.log(`Record with key ${key} deleted successfully`) - resolve() - } + public getAllKeys(): Promise { + return this.transaction( + 'readonly', + (store) => + new Promise((resolve, reject) => { + const getAllKeysRequest = store.getAllKeys() + getAllKeysRequest.onsuccess = () => resolve(getAllKeysRequest.result) + getAllKeysRequest.onerror = () => reject(getAllKeysRequest.error) + }) + ) + } - deleteRequest.onerror = (deleteEvent: Event) => { - logger.error( - `Error deleting record with key ${key}:`, - (deleteEvent.target as IDBRequest).error - ) - reject((deleteEvent.target as IDBRequest).error) - } - } + public clearStore(): Promise { + return this.transaction( + 'readwrite', + (store) => + new Promise((resolve, reject) => { + const clearRequest = store.clear() + clearRequest.onsuccess = () => resolve() + clearRequest.onerror = () => reject(clearRequest.error) + }) + ) + } - request.onerror = (event: Event) => { - logger.error('Error opening database:', (event.target as IDBRequest).error) - reject((event.target as IDBRequest).error) - } - }) + getPrefixedKey(key: K): string { + logger.debug('getPrefixedKey', key) + throw new Error('Method not implemented.') } subscribeToStorageChanged( @@ -140,187 +131,63 @@ export class IndexedDBStorage extends Storage { throw new Error('Method not implemented.') } - getPrefixedKey(key: K): string { - logger.debug('getPrefixedKey', key) - throw new Error('Method not implemented.') - } - - /** - * @returns all stored values - */ - getAll(): Promise { - return new Promise((resolve, reject) => { - const request = indexedDB.open(this.dbName) - - request.onsuccess = (event) => { - const db = (event.target as IDBOpenDBRequest).result - - const transaction = db.transaction(this.storeName, 'readonly') - const objectStore = transaction.objectStore(this.storeName) - - const getAllRequest = objectStore.getAll() - - getAllRequest.onsuccess = () => { - const results = getAllRequest.result - resolve(results) - } - - getAllRequest.onerror = (getAllEvent) => { - logger.error(`Error getting all records:`, getAllEvent.target) - reject(getAllEvent.target) - } - } - - request.onerror = (event) => { - logger.error('Error opening database:', event.target) - reject(event.target) - } - }) - } - - /** - * @returns all stored keys in store - */ - getAllKeys(): Promise { - return new Promise((resolve, reject) => { - const request = indexedDB.open(this.dbName) - - request.onsuccess = (event) => { - const db = (event.target as IDBOpenDBRequest).result - - const transaction = db.transaction(this.storeName, 'readonly') - const objectStore = transaction.objectStore(this.storeName) - - const getAllRequest = objectStore.getAllKeys() - - getAllRequest.onsuccess = () => { - const results = getAllRequest.result - resolve(results) - } - - getAllRequest.onerror = (getAllEvent) => { - logger.error(`Error getting all records:`, getAllEvent.target) - reject(getAllEvent.target) - } - } - - request.onerror = (event) => { - logger.error('Error opening database:', event.target) - reject(event.target) - } - }) - } - - /** - * @returns clears all stored entries in store - */ - clearStore(): Promise { - return new Promise((resolve, reject) => { - const request = indexedDB.open(this.dbName) - - request.onsuccess = (event) => { - const db = (event.target as IDBOpenDBRequest).result - const transaction = db.transaction(this.storeName, 'readwrite') - const objectStore = transaction.objectStore(this.storeName) - - const clearRequest = objectStore.clear() - - clearRequest.onsuccess = () => { - logger.log(`All entries in ${this.storeName} cleared successfully`) - resolve() - } - - clearRequest.onerror = (clearEvent) => { - logger.error(`Error clearing entries in ${this.storeName}:`, clearEvent.target) - reject(clearEvent.target) - } - } - - request.onerror = (event) => { - logger.error('Error opening database:', event.target) - reject(event.target) - } - }) - } /** * it copies over all key value pairs from a source store into a target one * @param targetDBName the name of the target DB * @param targetStoreName the name of the target store * @param skipKeys all the keys to ignore */ - populateStore( + public async populateStore( targetDBName: string, targetStoreName: string, skipKeys: string[] = [] ): Promise { - return new Promise((resolve, reject) => { - // Open the source database - const openRequest = indexedDB.open(this.dbName) - - openRequest.onsuccess = (e: Event) => { - const db = (e.target as IDBOpenDBRequest).result - if (!db) { - reject(new Error('Failed to open source database.')) - return - } - - const transaction = db.transaction(this.storeName, 'readonly') - const store = transaction.objectStore(this.storeName) - - // Get all keys and values from the source store - const allRecordsRequest = store.getAll() - const allKeysRequest = store.getAllKeys() + const targetDBRequest = indexedDB.open(targetDBName) - allRecordsRequest.onsuccess = () => { - allKeysRequest.onsuccess = () => { - const records = allRecordsRequest.result - const keys = allKeysRequest.result - - // Open the target database - const targetDBRequest = indexedDB.open(targetDBName) - - targetDBRequest.onupgradeneeded = (event: any) => { - const db = event.target?.result - - if (!db.objectStoreNames.contains(targetStoreName)) { - db.createObjectStore(targetStoreName) - } - } - - targetDBRequest.onsuccess = (e: Event) => { - const targetDB = (e.target as IDBOpenDBRequest).result - const targetTransaction = targetDB.transaction(targetStoreName, 'readwrite') - const targetStore = targetTransaction.objectStore(targetStoreName) - - // Copy each key-value pair to the target store - keys - .filter((key) => !skipKeys.includes(key.toString())) - .forEach((key, index) => { - targetStore.put(records[index], key) - }) - - targetTransaction.oncomplete = () => { - logger.log( - `Key-value pairs copied to ${targetStoreName} in ${targetDBName} successfully.` - ) - resolve() - } + targetDBRequest.onerror = (event: any) => { + throw new Error(`Failed to open target database: ${event.target.error}`) + } - targetTransaction.onerror = () => { - reject(new Error('Error copying key-value pairs to the new database.')) - } - } + const targetDB = await new Promise((resolve, reject) => { + targetDBRequest.onsuccess = (event) => resolve((event.target as IDBOpenDBRequest).result) + targetDBRequest.onerror = (event: any) => reject(event.target.error) + }) - targetDBRequest.onerror = () => { - reject(new Error('Error opening target database.')) + // Copy all items from the source store to the target store, skipping specified keys + await this.transaction('readonly', async (sourceStore) => { + const getAllRequest = sourceStore.getAll() + const getAllKeysRequest = sourceStore.getAllKeys() + await new Promise((resolve, reject) => { + getAllRequest.onsuccess = async () => { + getAllKeysRequest.onsuccess = async () => { + const items = getAllRequest.result + const keys = getAllKeysRequest.result + const targetTransaction = targetDB.transaction(targetStoreName, 'readwrite') + const targetStore = targetTransaction.objectStore(targetStoreName) + + keys + .filter((key) => !skipKeys.includes(key.toString())) + .forEach((key, index) => { + targetStore.put(items[index], key) + }) + + targetTransaction.oncomplete = () => resolve() + targetTransaction.onerror = (event: any) => { + console.error('Transaction error: ', event.target.error) + reject(event.target.error) } } } - } - - openRequest.onerror = () => { - reject(new Error('Error opening source database.')) - } + + getAllKeysRequest.onerror = () => { + console.error('Failed to getAllKeys from source:', getAllKeysRequest.error) + reject(getAllRequest.error) + } + getAllRequest.onerror = () => { + console.error('Failed to getAll from source:', getAllRequest.error) + reject(getAllRequest.error) + } + }) }) } } From cfb90f3e28a81b5e5a1da32eaae736482b37ba29 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 16 Apr 2024 17:31:37 +0200 Subject: [PATCH 05/41] fix: check if storage exists --- .../src/storage/IndexedDBStorage.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/beacon-core/src/storage/IndexedDBStorage.ts b/packages/beacon-core/src/storage/IndexedDBStorage.ts index f8cc8323d..ea68d902c 100644 --- a/packages/beacon-core/src/storage/IndexedDBStorage.ts +++ b/packages/beacon-core/src/storage/IndexedDBStorage.ts @@ -16,8 +16,22 @@ export class IndexedDBStorage extends Storage { .catch((err) => logger.error(err.message)) } + private isIndexedDBSupported() { + if ('indexedDB' in window) { + console.log('IndexedDB is supported in this browser.') + return true + } else { + console.log('IndexedDB is not supported in this browser.') + return false + } + } + private async initDB(): Promise { return new Promise((resolve, reject) => { + if (!this.isIndexedDBSupported()) { + reject('IndexedDB is not supported.') + } + const request = indexedDB.open(this.dbName) request.onupgradeneeded = (event) => { const request = event.target as IDBOpenDBRequest @@ -36,6 +50,11 @@ export class IndexedDBStorage extends Storage { operation: (store: IDBObjectStore) => Promise ): Promise { return new Promise((resolve, reject) => { + if (!this.db?.objectStoreNames.contains(this.storeName)) { + logger.error(`${this.storeName} not found.`) + return + } + const transaction = this.db?.transaction(this.storeName, mode) const objectStore = transaction?.objectStore(this.storeName) objectStore && operation(objectStore).then(resolve).catch(reject) @@ -162,6 +181,12 @@ export class IndexedDBStorage extends Storage { getAllKeysRequest.onsuccess = async () => { const items = getAllRequest.result const keys = getAllKeysRequest.result + + if (!targetDB.objectStoreNames.contains(targetStoreName)) { + logger.error(`${this.storeName} not found.`) + return + } + const targetTransaction = targetDB.transaction(targetStoreName, 'readwrite') const targetStore = targetTransaction.objectStore(targetStoreName) @@ -178,7 +203,7 @@ export class IndexedDBStorage extends Storage { } } } - + getAllKeysRequest.onerror = () => { console.error('Failed to getAllKeys from source:', getAllKeysRequest.error) reject(getAllRequest.error) From 82d76ef5021b1f10890a12ae95b2901e07c8e0ce Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Wed, 17 Apr 2024 13:08:03 +0200 Subject: [PATCH 06/41] fix: error handling --- .../src/storage/IndexedDBStorage.ts | 84 ++++++++++--------- packages/beacon-core/src/storage/WCStorage.ts | 2 +- .../beacon-dapp/src/dapp-client/DAppClient.ts | 10 ++- .../WalletConnectCommunicationClient.ts | 2 +- .../src/components/bug-report-form/index.tsx | 19 +++-- 5 files changed, 64 insertions(+), 53 deletions(-) diff --git a/packages/beacon-core/src/storage/IndexedDBStorage.ts b/packages/beacon-core/src/storage/IndexedDBStorage.ts index ea68d902c..b81007cc8 100644 --- a/packages/beacon-core/src/storage/IndexedDBStorage.ts +++ b/packages/beacon-core/src/storage/IndexedDBStorage.ts @@ -5,6 +5,7 @@ const logger = new Logger('IndexedDBStorage') export class IndexedDBStorage extends Storage { private db: IDBDatabase | null = null + private isSupported: boolean = true constructor( private readonly dbName: string = 'WALLET_CONNECT_V2_INDEXED_DB', @@ -18,17 +19,18 @@ export class IndexedDBStorage extends Storage { private isIndexedDBSupported() { if ('indexedDB' in window) { - console.log('IndexedDB is supported in this browser.') + logger.log('isIndexedDBSupported', 'IndexedDB is supported in this browser.') return true } else { - console.log('IndexedDB is not supported in this browser.') + logger.error('isIndexedDBSupported', 'IndexedDB is not supported in this browser.') return false } } private async initDB(): Promise { return new Promise((resolve, reject) => { - if (!this.isIndexedDBSupported()) { + this.isSupported = this.isIndexedDBSupported() + if (!this.isSupported) { reject('IndexedDB is not supported.') } @@ -50,9 +52,12 @@ export class IndexedDBStorage extends Storage { operation: (store: IDBObjectStore) => Promise ): Promise { return new Promise((resolve, reject) => { + if (!this.isSupported) { + reject('IndexedDB is not supported.') + } + if (!this.db?.objectStoreNames.contains(this.storeName)) { - logger.error(`${this.storeName} not found.`) - return + reject(`${this.storeName} not found. error: ${new Error().stack}`) } const transaction = this.db?.transaction(this.storeName, mode) @@ -156,11 +161,16 @@ export class IndexedDBStorage extends Storage { * @param targetStoreName the name of the target store * @param skipKeys all the keys to ignore */ - public async populateStore( + public async fillStore( targetDBName: string, targetStoreName: string, skipKeys: string[] = [] ): Promise { + if (!this.isSupported) { + logger.error('fillStore', 'IndexedDB not supported.') + return + } + const targetDBRequest = indexedDB.open(targetDBName) targetDBRequest.onerror = (event: any) => { @@ -176,43 +186,37 @@ export class IndexedDBStorage extends Storage { await this.transaction('readonly', async (sourceStore) => { const getAllRequest = sourceStore.getAll() const getAllKeysRequest = sourceStore.getAllKeys() - await new Promise((resolve, reject) => { - getAllRequest.onsuccess = async () => { - getAllKeysRequest.onsuccess = async () => { - const items = getAllRequest.result - const keys = getAllKeysRequest.result - - if (!targetDB.objectStoreNames.contains(targetStoreName)) { - logger.error(`${this.storeName} not found.`) - return - } - - const targetTransaction = targetDB.transaction(targetStoreName, 'readwrite') - const targetStore = targetTransaction.objectStore(targetStoreName) - - keys - .filter((key) => !skipKeys.includes(key.toString())) - .forEach((key, index) => { - targetStore.put(items[index], key) - }) - - targetTransaction.oncomplete = () => resolve() - targetTransaction.onerror = (event: any) => { - console.error('Transaction error: ', event.target.error) - reject(event.target.error) - } + + getAllRequest.onsuccess = async () => { + getAllKeysRequest.onsuccess = async () => { + const items = getAllRequest.result + const keys = getAllKeysRequest.result + + if (!targetDB.objectStoreNames.contains(targetStoreName)) { + logger.error(`${this.storeName} not found. ${new Error().stack}`) + return } - } - getAllKeysRequest.onerror = () => { - console.error('Failed to getAllKeys from source:', getAllKeysRequest.error) - reject(getAllRequest.error) - } - getAllRequest.onerror = () => { - console.error('Failed to getAll from source:', getAllRequest.error) - reject(getAllRequest.error) + const targetTransaction = targetDB.transaction(targetStoreName, 'readwrite') + const targetStore = targetTransaction.objectStore(targetStoreName) + + keys + .filter((key) => !skipKeys.includes(key.toString())) + .forEach((key, index) => { + targetStore.put(items[index], key) + }) + + targetTransaction.onerror = (event: any) => { + logger.error('Transaction error: ', event.target.error) + } } - }) + } + getAllKeysRequest.onerror = () => { + logger.error('Failed to getAllKeys from source:', getAllKeysRequest.error) + } + getAllRequest.onerror = () => { + logger.error('Failed to getAll from source:', getAllRequest.error) + } }) } } diff --git a/packages/beacon-core/src/storage/WCStorage.ts b/packages/beacon-core/src/storage/WCStorage.ts index f28d5266e..a5e2187a0 100644 --- a/packages/beacon-core/src/storage/WCStorage.ts +++ b/packages/beacon-core/src/storage/WCStorage.ts @@ -56,7 +56,7 @@ export class WCStorage { backup() { this.indexedDB - .populateStore('beacon', 'bug_report', [StorageKey.WC_2_CORE_KEYCHAIN]) + .fillStore('beacon', 'bug_report', [StorageKey.WC_2_CORE_KEYCHAIN]) .catch((error) => console.error(error.message)) } diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index ef3b5db25..400914952 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -481,15 +481,19 @@ export class DAppClient extends Client { } private async createStateSnapshot() { - if (!localStorage) { + if (!localStorage || !this.enableMetrics) { return } const keys = Object.values(StorageKey).filter( (key) => !key.includes('wc@2') && !key.includes('secret') && !key.includes('account') ) as unknown as StorageKey[] - for (const key of keys) { - this.bugReportStorage.set(key, await this.storage.get(key)) + try { + for (const key of keys) { + await this.bugReportStorage.set(key, await this.storage.get(key)) + } + } catch (err: any) { + logger.error('createStateSnapshot', err.message) } } diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 4df3a18ca..996bdc554 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -706,7 +706,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { } public async close() { - this.storage.backup() + await this.storage.backup() await this.closePairings() } diff --git a/packages/beacon-ui/src/components/bug-report-form/index.tsx b/packages/beacon-ui/src/components/bug-report-form/index.tsx index d328edd0f..55d8536f9 100644 --- a/packages/beacon-ui/src/components/bug-report-form/index.tsx +++ b/packages/beacon-ui/src/components/bug-report-form/index.tsx @@ -63,18 +63,21 @@ const BugReportForm = (props: any) => { const wcResult: StorageObject = {} const beaconResult: StorageObject = {} const db = new IndexedDBStorage('beacon', 'bug_report') + let keys: string[] = [] + let values: string[] = [] try { - const keys = (await db.getAllKeys()).map((key) => key.toString()) - for (const key of keys) { - if (key.includes('beacon')) { - beaconResult[key] = (await db.get(key as StorageKey)) as string - } else { - wcResult[key] = (await db.get(key as StorageKey)) as string - } - } + keys = (await db.getAllKeys()).map((key) => key.toString()) + values = (await db.getAll()).map((value) => value.toString()) } catch (error: any) { console.error(error.message) + return [beaconResult, wcResult] + } + + if (keys.length && values.length && keys.length === values.length) { + keys.forEach( + (key, i) => ((key.includes('beacon') ? beaconResult : wcResult)[key] = values[i]) + ) } return [beaconResult, wcResult] From b7acfdacf79a74c5ca452d22a03513695d98023b Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Wed, 17 Apr 2024 13:12:54 +0200 Subject: [PATCH 07/41] fix: removed await --- .../communication-client/WalletConnectCommunicationClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 996bdc554..4df3a18ca 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -706,7 +706,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { } public async close() { - await this.storage.backup() + this.storage.backup() await this.closePairings() } From a4723b033a2e4a75ebd62d4798554639b488f26d Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Wed, 17 Apr 2024 13:44:19 +0200 Subject: [PATCH 08/41] fix: getAll failed --- .../beacon-ui/src/components/bug-report-form/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/beacon-ui/src/components/bug-report-form/index.tsx b/packages/beacon-ui/src/components/bug-report-form/index.tsx index 55d8536f9..fc06ec539 100644 --- a/packages/beacon-ui/src/components/bug-report-form/index.tsx +++ b/packages/beacon-ui/src/components/bug-report-form/index.tsx @@ -1,9 +1,11 @@ -import { IndexedDBStorage, SDK_VERSION } from '@airgap/beacon-core' +import { IndexedDBStorage, Logger, SDK_VERSION } from '@airgap/beacon-core' import { StorageKey } from '@airgap/beacon-types' import { For, createEffect, createSignal } from 'solid-js' import styles from './styles.css' import { currentBrowser, currentOS } from '../../utils/platform' +const logger = new Logger('BugReport') + interface StorageObject { [key: string]: string | null } @@ -35,6 +37,7 @@ const BugReportForm = (props: any) => { const [didUserAllow, setDidUserAllow] = createSignal(false) const [status, setStatus] = createSignal<'success' | 'error' | null>(null) const [showThankYou, setShowThankYou] = createSignal(false) + const db = new IndexedDBStorage('beacon', 'bug_report') const isTitleValid = () => { const check = title().replace(/ /gi, '').length > 10 @@ -62,15 +65,14 @@ const BugReportForm = (props: any) => { const indexDBToMetadata = async () => { const wcResult: StorageObject = {} const beaconResult: StorageObject = {} - const db = new IndexedDBStorage('beacon', 'bug_report') let keys: string[] = [] let values: string[] = [] try { keys = (await db.getAllKeys()).map((key) => key.toString()) - values = (await db.getAll()).map((value) => value.toString()) + values = await db.getAll() } catch (error: any) { - console.error(error.message) + logger.error('indexDBToMetadata', 'getAll failed: ', error.message) return [beaconResult, wcResult] } From a5567101f0c61c174f80fb83bc13f5d57df3e8e3 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Wed, 17 Apr 2024 15:43:04 +0200 Subject: [PATCH 09/41] fix: window check for ssr --- packages/beacon-core/src/storage/IndexedDBStorage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-core/src/storage/IndexedDBStorage.ts b/packages/beacon-core/src/storage/IndexedDBStorage.ts index b81007cc8..54da990ca 100644 --- a/packages/beacon-core/src/storage/IndexedDBStorage.ts +++ b/packages/beacon-core/src/storage/IndexedDBStorage.ts @@ -18,7 +18,7 @@ export class IndexedDBStorage extends Storage { } private isIndexedDBSupported() { - if ('indexedDB' in window) { + if (typeof window !== 'undefined' && 'indexedDB' in window) { logger.log('isIndexedDBSupported', 'IndexedDB is supported in this browser.') return true } else { From b44c50c05926509a8efc01099128bbcf2aec1f67 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Thu, 18 Apr 2024 10:23:05 +0200 Subject: [PATCH 10/41] fix: add subscriptions tracking --- .../beacon-core/src/clients/client/Client.ts | 44 +++++++++++++------ .../beacon-dapp/src/dapp-client/DAppClient.ts | 2 +- .../beacon-wallet/src/client/WalletClient.ts | 3 ++ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index 1a0624999..3a0a314ba 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -1,4 +1,4 @@ -import { ExposedPromise, ExposedPromiseStatus, generateGUID } from '@airgap/beacon-utils' +import { ExposedPromise, generateGUID } from '@airgap/beacon-utils' import { ConnectionContext, TransportType, @@ -52,6 +52,11 @@ export abstract class Client extends BeaconClient { protected readonly matrixNodes: NodeDistributions + private readonly subscriptions: (( + message: any, + connectionInfo: ConnectionContext + ) => Promise)[] = [] + protected _transport: ExposedPromise> = new ExposedPromise() protected get transport(): Promise> { return this._transport.promise @@ -87,6 +92,13 @@ export abstract class Client extends BeaconClient { } } + protected async cleanup() { + if (this._transport.isResolved()) { + const transport = await this.transport + this.subscriptions.forEach((listener) => transport.removeListener(listener)) + } + } + /** * Return all locally known accounts */ @@ -138,7 +150,7 @@ export abstract class Client extends BeaconClient { * @param transport A transport that can be provided by the user */ public async init(transport: Transport): Promise { - if (this._transport.status === ExposedPromiseStatus.RESOLVED) { + if (this._transport.isResolved()) { return (await this.transport).type } @@ -174,8 +186,10 @@ export abstract class Client extends BeaconClient { } public async destroy(): Promise { - if (this._transport.status === ExposedPromiseStatus.RESOLVED) { - await (await this.transport).disconnect() + if (this._transport.isResolved()) { + const transport = await this.transport + await this.cleanup() + await transport.disconnect() } await super.destroy() } @@ -200,16 +214,18 @@ export abstract class Client extends BeaconClient { } protected async addListener(transport: Transport): Promise { - transport - .addListener(async (message: unknown, connectionInfo: ConnectionContext) => { - if (typeof message === 'string') { - const deserializedMessage = (await new Serializer().deserialize( - message - )) as BeaconRequestMessage - this.handleResponse(deserializedMessage, connectionInfo) - } - }) - .catch((error) => logger.error('addListener', error)) + const subscription = async (message: any, connectionInfo: ConnectionContext) => { + if (typeof message === 'string') { + const deserializedMessage = (await new Serializer().deserialize( + message + )) as BeaconRequestMessage + this.handleResponse(deserializedMessage, connectionInfo) + } + } + + this.subscriptions.push(subscription) + + transport.addListener(subscription).catch((error) => logger.error('addListener', error)) } protected async sendDisconnectToPeer(peer: PeerInfo, transport?: Transport): Promise { diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 400914952..397f91a7d 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -2344,11 +2344,11 @@ export class DAppClient extends Client { await this.createStateSnapshot() this.sendMetrics('performance-metrics/save', await this.buildPayload('disconnect', 'start')) + await this.cleanup() this.postMessageTransport = undefined this.p2pTransport = undefined this.walletConnectTransport = undefined await this.clearActiveAccount() - await transport.disconnect() this.sendMetrics('performance-metrics/save', await this.buildPayload('disconnect', 'success')) } diff --git a/packages/beacon-wallet/src/client/WalletClient.ts b/packages/beacon-wallet/src/client/WalletClient.ts index eb2bac255..52fd43c02 100644 --- a/packages/beacon-wallet/src/client/WalletClient.ts +++ b/packages/beacon-wallet/src/client/WalletClient.ts @@ -465,6 +465,9 @@ export class WalletClient extends Client { await this.removePeer(peer as any) } + await this.cleanup() + await transport.disconnect() + return } } From 61ae7a8eaa2b1d8099663baf909e0de3203ac9c0 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Thu, 18 Apr 2024 11:23:21 +0200 Subject: [PATCH 11/41] fix: example dapp --- examples/dapp.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dapp.html b/examples/dapp.html index c0fe55f13..3bdf2379e 100644 --- a/examples/dapp.html +++ b/examples/dapp.html @@ -275,7 +275,8 @@ }) } - client.subscribeToEvent('ACTIVE_ACCOUNT_SET', () => { + client.subscribeToEvent('ACTIVE_ACCOUNT_SET', (account) => { + console.log('ACTIVE_ACCOUNT_SET received', account) updateActiveAccount() }) @@ -407,7 +408,6 @@ .disconnect() .then(() => console.log('disconnected.')) .catch((err) => console.error(err.message)) - } const requestSimulatedProofOfEventChallenge = () => { From 7d37032b0ce37cc5279e2190036341ed67f0b380 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Thu, 18 Apr 2024 12:02:52 +0200 Subject: [PATCH 12/41] fix: session_update subscription --- .../beacon-dapp/src/dapp-client/DAppClient.ts | 5 +++++ .../WalletConnectCommunicationClient.ts | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 397f91a7d..c82540676 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -425,6 +425,10 @@ export class DAppClient extends Client { } } } + + if (!this.openRequests.has('session_update')) { + this.openRequests.set('session_update', new ExposedPromise()) + } } this.storageValidator @@ -2349,6 +2353,7 @@ export class DAppClient extends Client { this.p2pTransport = undefined this.walletConnectTransport = undefined await this.clearActiveAccount() + await transport.disconnect() this.sendMetrics('performance-metrics/save', await this.buildPayload('disconnect', 'success')) } diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index ad9de2eb1..526fdb601 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -323,7 +323,8 @@ export class WalletConnectCommunicationClient extends CommunicationClient { private async notifyListenersWithPermissionResponse( session: SessionTypes.Struct, - network: Network + network: Network, + sessionEventId?: string ) { let publicKey: string | undefined if ( @@ -378,7 +379,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { publicKey, network, scopes: [PermissionScope.SIGN, PermissionScope.OPERATION_REQUEST], - id: this.messageIds.pop() ?? '', + id: sessionEventId ?? this.messageIds.pop() ?? '', walletType: 'implicit' } @@ -741,9 +742,13 @@ export class WalletConnectCommunicationClient extends CommunicationClient { this.session = session this.updateActiveAccount(event.params.namespaces) - this.notifyListenersWithPermissionResponse(this.session, { - type: this.wcOptions.network - }) + this.notifyListenersWithPermissionResponse( + this.session, + { + type: this.wcOptions.network + }, + 'session_update' + ) }) signClient.on('session_delete', (event) => { From 99ffd0075b4288194fcf4506c16b471f50c3d36f Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Thu, 18 Apr 2024 12:17:03 +0200 Subject: [PATCH 13/41] fix: aborted error --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 4 ++-- .../communication-client/WalletConnectCommunicationClient.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index c82540676..a99c93eb0 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -2348,12 +2348,12 @@ export class DAppClient extends Client { await this.createStateSnapshot() this.sendMetrics('performance-metrics/save', await this.buildPayload('disconnect', 'start')) + await this.clearActiveAccount() await this.cleanup() + await transport.disconnect() this.postMessageTransport = undefined this.p2pTransport = undefined this.walletConnectTransport = undefined - await this.clearActiveAccount() - await transport.disconnect() this.sendMetrics('performance-metrics/save', await this.buildPayload('disconnect', 'success')) } diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 526fdb601..9729e39d3 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -718,6 +718,8 @@ export class WalletConnectCommunicationClient extends CommunicationClient { public async close() { this.storage.backup() await this.closePairings() + this.activeListeners.clear() + this.channelOpeningListeners.clear() } private subscribeToSessionEvents(signClient: Client): void { From b2e06b49982b5b819e8e55b414cd589ed03e5f5d Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Thu, 18 Apr 2024 12:47:20 +0200 Subject: [PATCH 14/41] fix: add session update handler only for WC transport --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index a99c93eb0..2b9045c51 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -426,8 +426,15 @@ export class DAppClient extends Client { } } - if (!this.openRequests.has('session_update')) { - this.openRequests.set('session_update', new ExposedPromise()) + if (this._transport.isResolved()) { + const transport = await this.transport + + if ( + transport instanceof WalletConnectTransport && + !this.openRequests.has('session_update') + ) { + this.openRequests.set('session_update', new ExposedPromise()) + } } } From c0ebfe6b6117d52e36eaf32768664b0fe0fee853 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Thu, 18 Apr 2024 13:13:57 +0200 Subject: [PATCH 15/41] fix: clear subscriptions references --- packages/beacon-core/src/clients/client/Client.ts | 8 +++++++- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index 3a0a314ba..ca7134647 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -93,9 +93,15 @@ export abstract class Client extends BeaconClient { } protected async cleanup() { + if (!this.subscriptions.length) { + return + } + if (this._transport.isResolved()) { const transport = await this.transport - this.subscriptions.forEach((listener) => transport.removeListener(listener)) + await Promise.all( + this.subscriptions.splice(0).map((listener) => transport.removeListener(listener)) + ) } } diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 2b9045c51..ed40463c5 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -872,6 +872,7 @@ export class DAppClient extends Client { const peer = await this.getPeer(account) await this.setActivePeer(peer) } else { + await this.cleanup() await this.setActivePeer(undefined) await this.setTransport(undefined) } @@ -2356,7 +2357,6 @@ export class DAppClient extends Client { await this.createStateSnapshot() this.sendMetrics('performance-metrics/save', await this.buildPayload('disconnect', 'start')) await this.clearActiveAccount() - await this.cleanup() await transport.disconnect() this.postMessageTransport = undefined this.p2pTransport = undefined From 6e883dc5c54f96a1a90ec971d2a3c5fe3bdbb3e4 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Fri, 19 Apr 2024 10:42:19 +0200 Subject: [PATCH 16/41] fix: multiple tabs hang --- .../beacon-core/src/clients/client/Client.ts | 15 +++++++++++++-- .../beacon-dapp/src/dapp-client/DAppClient.ts | 16 +++++++++++++++- .../src/WalletConnectTransport.ts | 5 +++-- .../beacon-wallet/src/client/WalletClient.ts | 1 - 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index ca7134647..14b47d083 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -51,12 +51,13 @@ export abstract class Client extends BeaconClient { protected requestCounter: number[] = [] protected readonly matrixNodes: NodeDistributions - private readonly subscriptions: (( message: any, connectionInfo: ConnectionContext ) => Promise)[] = [] + private activeTransportListeners = new Set() + protected _transport: ExposedPromise> = new ExposedPromise() protected get transport(): Promise> { return this._transport.promise @@ -91,7 +92,6 @@ export abstract class Client extends BeaconClient { ) } } - protected async cleanup() { if (!this.subscriptions.length) { return @@ -220,6 +220,17 @@ export abstract class Client extends BeaconClient { } protected async addListener(transport: Transport): Promise { + // in beacon we subscribe to the transport on client init only + // unsubscribing from the transport is only beneficial when running + // a single page dApp. + // However while running a multiple tabs setup one of the dApps disconnects + // the others wont't recover until after a page refresh + if (this.activeTransportListeners.has(transport.type)) { + return + } + + this.activeTransportListeners.add(transport.type) + const subscription = async (message: any, connectionInfo: ConnectionContext) => { if (typeof message === 'string') { const deserializedMessage = (await new Serializer().deserialize( diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index ed40463c5..c59c30398 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -862,17 +862,31 @@ export class DAppClient extends Client { // Select the transport that matches the active account if (origin === Origin.EXTENSION) { + if ( + this.postMessageTransport && + this.postMessageTransport.connectionStatus !== TransportStatus.CONNECTED + ) { + await this.postMessageTransport.connect() + } await this.setTransport(this.postMessageTransport) } else if (origin === Origin.P2P) { + if (this.p2pTransport && this.p2pTransport.connectionStatus !== TransportStatus.CONNECTED) { + await this.p2pTransport.connect() + } await this.setTransport(this.p2pTransport) } else if (origin === Origin.WALLETCONNECT) { + if ( + this.walletConnectTransport && + this.walletConnectTransport.connectionStatus !== TransportStatus.CONNECTED + ) { + await this.walletConnectTransport.connect() + } await this.setTransport(this.walletConnectTransport) this.walletConnectTransport?.forceUpdate('INIT') } const peer = await this.getPeer(account) await this.setActivePeer(peer) } else { - await this.cleanup() await this.setActivePeer(undefined) await this.setTransport(undefined) } diff --git a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts index 0b1e36405..e154f7291 100644 --- a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts +++ b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts @@ -9,7 +9,8 @@ import { StorageKey, WalletConnectPairingRequest, NetworkType, - AccountInfo + AccountInfo, + TransportType } from '@airgap/beacon-types' import { Transport, PeerManager } from '@airgap/beacon-core' import { SignClientTypes } from '@walletconnect/types' @@ -24,7 +25,7 @@ export class WalletConnectTransport< T extends WalletConnectPairingRequest | ExtendedWalletConnectPairingResponse, K extends StorageKey.TRANSPORT_WALLETCONNECT_PEERS_DAPP > extends Transport { - // public readonly type: TransportType = TransportType.WALLETCONNECT + public readonly type: TransportType = TransportType.WALLETCONNECT constructor( name: string, diff --git a/packages/beacon-wallet/src/client/WalletClient.ts b/packages/beacon-wallet/src/client/WalletClient.ts index 52fd43c02..b34e9622c 100644 --- a/packages/beacon-wallet/src/client/WalletClient.ts +++ b/packages/beacon-wallet/src/client/WalletClient.ts @@ -465,7 +465,6 @@ export class WalletClient extends Client { await this.removePeer(peer as any) } - await this.cleanup() await transport.disconnect() return From 0995c82397dcac6a9d577178ca0b0288adbb7d51 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Fri, 19 Apr 2024 10:48:17 +0200 Subject: [PATCH 17/41] fix: disconnect current transport --- .../beacon-dapp/src/dapp-client/DAppClient.ts | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index c59c30398..1dfe367c9 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -862,28 +862,20 @@ export class DAppClient extends Client { // Select the transport that matches the active account if (origin === Origin.EXTENSION) { - if ( - this.postMessageTransport && - this.postMessageTransport.connectionStatus !== TransportStatus.CONNECTED - ) { - await this.postMessageTransport.connect() - } await this.setTransport(this.postMessageTransport) } else if (origin === Origin.P2P) { - if (this.p2pTransport && this.p2pTransport.connectionStatus !== TransportStatus.CONNECTED) { - await this.p2pTransport.connect() - } await this.setTransport(this.p2pTransport) } else if (origin === Origin.WALLETCONNECT) { - if ( - this.walletConnectTransport && - this.walletConnectTransport.connectionStatus !== TransportStatus.CONNECTED - ) { - await this.walletConnectTransport.connect() - } await this.setTransport(this.walletConnectTransport) this.walletConnectTransport?.forceUpdate('INIT') } + if (this._transport.isResolved()) { + const transport = await this.transport + + if (transport.connectionStatus === TransportStatus.NOT_CONNECTED) { + await transport.connect() + } + } const peer = await this.getPeer(account) await this.setActivePeer(peer) } else { From fea9fd4f65a02a392c3f498f840979fc00a451b0 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Fri, 19 Apr 2024 11:15:54 +0200 Subject: [PATCH 18/41] fix: add listeners map --- .../beacon-core/src/clients/client/Client.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index 14b47d083..e2f3f9c87 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -51,12 +51,11 @@ export abstract class Client extends BeaconClient { protected requestCounter: number[] = [] protected readonly matrixNodes: NodeDistributions - private readonly subscriptions: (( - message: any, - connectionInfo: ConnectionContext - ) => Promise)[] = [] - private activeTransportListeners = new Set() + private transportListeners: Map< + TransportType, + (message: any, connectionInfo: ConnectionContext) => Promise + > = new Map() protected _transport: ExposedPromise> = new ExposedPromise() protected get transport(): Promise> { @@ -93,15 +92,18 @@ export abstract class Client extends BeaconClient { } } protected async cleanup() { - if (!this.subscriptions.length) { + if (!this.transportListeners.size) { return } if (this._transport.isResolved()) { const transport = await this.transport await Promise.all( - this.subscriptions.splice(0).map((listener) => transport.removeListener(listener)) + Array.from(this.transportListeners.values()).map((listener) => + transport.removeListener(listener) + ) ) + this.transportListeners.clear() } } @@ -225,11 +227,10 @@ export abstract class Client extends BeaconClient { // a single page dApp. // However while running a multiple tabs setup one of the dApps disconnects // the others wont't recover until after a page refresh - if (this.activeTransportListeners.has(transport.type)) { - return - } - this.activeTransportListeners.add(transport.type) + if (this.transportListeners.has(transport.type)) { + await transport.removeListener(this.transportListeners.get(transport.type)!) + } const subscription = async (message: any, connectionInfo: ConnectionContext) => { if (typeof message === 'string') { @@ -240,7 +241,7 @@ export abstract class Client extends BeaconClient { } } - this.subscriptions.push(subscription) + this.transportListeners.set(transport.type, subscription) transport.addListener(subscription).catch((error) => logger.error('addListener', error)) } From 1d67ca7d5d4a40d6e598018360eb16d07d68478d Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Fri, 19 Apr 2024 13:55:14 +0200 Subject: [PATCH 19/41] fix: duplicated session_update --- .../WalletConnectCommunicationClient.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 9729e39d3..f3dc49931 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -743,14 +743,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { this.session = session - this.updateActiveAccount(event.params.namespaces) - this.notifyListenersWithPermissionResponse( - this.session, - { - type: this.wcOptions.network - }, - 'session_update' - ) + this.updateActiveAccount(event.params.namespaces, session) }) signClient.on('session_delete', (event) => { @@ -782,7 +775,10 @@ export class WalletConnectCommunicationClient extends CommunicationClient { this.notifyListeners(this.getTopicFromSession(session), acknowledgeResponse) } - private async updateActiveAccount(namespaces: SessionTypes.Namespaces) { + private async updateActiveAccount( + namespaces: SessionTypes.Namespaces, + session: SessionTypes.Struct + ) { try { const accounts = this.getTezosNamespace(namespaces).accounts if (accounts.length) { @@ -814,6 +810,14 @@ export class WalletConnectCommunicationClient extends CommunicationClient { scopes: [PermissionScope.SIGN, PermissionScope.OPERATION_REQUEST], walletType: 'implicit' }) + } else { + this.notifyListenersWithPermissionResponse( + session, + { + type: this.wcOptions.network + }, + 'session_update' + ) } } catch {} } From 4153abe861e2682454ace3e5cfd875ccca3889d5 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Fri, 19 Apr 2024 15:00:13 +0200 Subject: [PATCH 20/41] fix: removed duble subscription --- .../communication-client/WalletConnectCommunicationClient.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index f3dc49931..588353dae 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -169,8 +169,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { if (lastIndex > -1) { this.session = client.session.get(client.session.keys[lastIndex]) - - this.subscribeToSessionEvents(client) + this.updateStorageWallet(this.session) this.setDefaultAccountAndNetwork() } else { From 09ce9365fd93f1ac6d76352c68b0824162234ea9 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Fri, 19 Apr 2024 17:10:10 +0200 Subject: [PATCH 21/41] fix: debounced event --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 11 +++++++++-- packages/beacon-utils/src/utils/crypto.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 1dfe367c9..928fb20a1 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -221,6 +221,8 @@ export class DAppClient extends Client { private readonly bugReportStorage = new IndexedDBStorage('beacon', 'bug_report') + private debounceEventResponse: boolean = false + constructor(config: DAppClientOptions) { super({ storage: config && config.storage ? config.storage : new LocalStorage(), @@ -353,6 +355,7 @@ export class DAppClient extends Client { await this.events.emit(BeaconEvent.CHANNEL_CLOSED) } } else if (typedMessage.message?.type === BeaconMessageType.ChangeAccountRequest) { + console.log('onNewAccount called.', 1) await this.onNewAccount(typedMessage.message as ChangeAccountRequest, connectionInfo) } else { logger.error('handleResponse', 'no request found for id ', message.id, message) @@ -419,7 +422,11 @@ export class DAppClient extends Client { await this.events.emit(BeaconEvent.CHANNEL_CLOSED) } } else if (typedMessage.type === BeaconMessageType.ChangeAccountRequest) { - await this.onNewAccount(typedMessage, connectionInfo) + if (!this.debounceEventResponse) { + this.debounceEventResponse = true + await this.onNewAccount(typedMessage, connectionInfo) + this.debounceEventResponse = false + } } else { logger.error('handleResponse', 'no request found for id ', message.id, message) } @@ -2452,7 +2459,7 @@ export class DAppClient extends Client { const tempPK: string | undefined = message.publicKey || (message as any).pubkey || (message as any).pubKey - const publicKey = !!tempPK ? await prefixPublicKey(tempPK) : undefined + const publicKey = !!tempPK ? prefixPublicKey(tempPK) : undefined if (!publicKey && !message.address) { throw new Error('PublicKey or Address must be defined') diff --git a/packages/beacon-utils/src/utils/crypto.ts b/packages/beacon-utils/src/utils/crypto.ts index 141d16fe1..f8fb81453 100644 --- a/packages/beacon-utils/src/utils/crypto.ts +++ b/packages/beacon-utils/src/utils/crypto.ts @@ -204,7 +204,7 @@ export async function getAddressFromPublicKey(publicKey: string): Promise { +export function prefixPublicKey(publicKey: string): string { if (publicKey.length !== 64) { return publicKey } From e9f05941a80e0ad328cd048cb3f6a797eb884db0 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 22 Apr 2024 08:30:22 +0200 Subject: [PATCH 22/41] chore: add comment --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 928fb20a1..ef0c916bd 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -624,6 +624,12 @@ export class DAppClient extends Client { await this.destroy() } + /** + * Destroy the instance. + * WARNING: Call `destroy` whenever you no longer need dAppClient, + * as it frees internal subscriptions to the transport and therefore the instance may no longer work properly. + * If you wish to disconnect your dApp, use `disconnect` instead. + */ async destroy(): Promise { await this.createStateSnapshot() await super.destroy() From 09e7b489aa59a858fc00d9bbcb65a961316ed9e8 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 22 Apr 2024 08:31:48 +0200 Subject: [PATCH 23/41] chore: add new line --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index ef0c916bd..77b01ad92 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -626,6 +626,7 @@ export class DAppClient extends Client { /** * Destroy the instance. + * * WARNING: Call `destroy` whenever you no longer need dAppClient, * as it frees internal subscriptions to the transport and therefore the instance may no longer work properly. * If you wish to disconnect your dApp, use `disconnect` instead. From 0d6d41afe121b6e0a63980d432a15a3dcf886e1d Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 22 Apr 2024 12:53:24 +0200 Subject: [PATCH 24/41] fix: remove console.log --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 77b01ad92..4ff136f8f 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -355,7 +355,6 @@ export class DAppClient extends Client { await this.events.emit(BeaconEvent.CHANNEL_CLOSED) } } else if (typedMessage.message?.type === BeaconMessageType.ChangeAccountRequest) { - console.log('onNewAccount called.', 1) await this.onNewAccount(typedMessage.message as ChangeAccountRequest, connectionInfo) } else { logger.error('handleResponse', 'no request found for id ', message.id, message) From 73f4cb141e294dd9111d405e04361e865f88613e Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 22 Apr 2024 12:59:43 +0200 Subject: [PATCH 25/41] fix: typo --- packages/beacon-core/src/clients/client/Client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index e2f3f9c87..98535e742 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -225,7 +225,7 @@ export abstract class Client extends BeaconClient { // in beacon we subscribe to the transport on client init only // unsubscribing from the transport is only beneficial when running // a single page dApp. - // However while running a multiple tabs setup one of the dApps disconnects + // However, while running a multiple tabs setup, if one of the dApps disconnects // the others wont't recover until after a page refresh if (this.transportListeners.has(transport.type)) { From d4c5ae309f106654b85ee0d1cf3f6d110c6b7688 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 23 Apr 2024 09:04:19 +0200 Subject: [PATCH 26/41] fix: WC sbscriptions cleanuo --- packages/beacon-core/src/clients/client/Client.ts | 3 +++ .../src/WalletConnectTransport.ts | 4 ++++ .../WalletConnectCommunicationClient.ts | 7 ++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index 98535e742..96b656622 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -198,6 +198,9 @@ export abstract class Client extends BeaconClient { const transport = await this.transport await this.cleanup() await transport.disconnect() + if (transport.type === TransportType.WALLETCONNECT) { + await (transport as any).doClientCleanup() // any because I cannot import type definition + } } await super.destroy() } diff --git a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts index e154f7291..a00a0c5eb 100644 --- a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts +++ b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts @@ -129,6 +129,10 @@ export class WalletConnectTransport< // } + async doClientCleanup() { + await this.client.unsubscribeFromEncryptedMessages() + } + public getPairingRequestInfo(): Promise { return this.client.getPairingRequestInfo() } diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 588353dae..5b58627d6 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -169,7 +169,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient { if (lastIndex > -1) { this.session = client.session.get(client.session.keys[lastIndex]) - this.updateStorageWallet(this.session) this.setDefaultAccountAndNetwork() } else { @@ -212,7 +211,8 @@ export class WalletConnectCommunicationClient extends CommunicationClient { } async unsubscribeFromEncryptedMessages(): Promise { - // implementation + this.activeListeners.clear() + this.channelOpeningListeners.clear() } async unsubscribeFromEncryptedMessage(_senderPublicKey: string): Promise { @@ -585,7 +585,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient { if (lastIndex > -1) { this.session = signClient.session.get(signClient.session.keys[lastIndex]) - this.updateStorageWallet(this.session) this.setDefaultAccountAndNetwork() @@ -717,8 +716,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient { public async close() { this.storage.backup() await this.closePairings() - this.activeListeners.clear() - this.channelOpeningListeners.clear() } private subscribeToSessionEvents(signClient: Client): void { From fcda0de8d55ba51c756d19f692ef8ec58e5a0699 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 23 Apr 2024 09:07:54 +0200 Subject: [PATCH 27/41] fix: typo --- packages/beacon-core/src/clients/client/Client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-core/src/clients/client/Client.ts b/packages/beacon-core/src/clients/client/Client.ts index 96b656622..60ad83a1a 100644 --- a/packages/beacon-core/src/clients/client/Client.ts +++ b/packages/beacon-core/src/clients/client/Client.ts @@ -199,7 +199,7 @@ export abstract class Client extends BeaconClient { await this.cleanup() await transport.disconnect() if (transport.type === TransportType.WALLETCONNECT) { - await (transport as any).doClientCleanup() // any because I cannot import type definition + await (transport as any).doClientCleanup() // any because I cannot import the type definition } } await super.destroy() From 210ca71aff366a19fe760c3c36d254c67554dec5 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 29 Apr 2024 11:55:59 +0200 Subject: [PATCH 28/41] fix: add disconnection --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 4ff136f8f..3e51d71f1 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -625,7 +625,7 @@ export class DAppClient extends Client { /** * Destroy the instance. - * + * * WARNING: Call `destroy` whenever you no longer need dAppClient, * as it frees internal subscriptions to the transport and therefore the instance may no longer work properly. * If you wish to disconnect your dApp, use `disconnect` instead. @@ -849,7 +849,7 @@ export class DAppClient extends Client { } if (transport instanceof WalletConnectTransport) { - await transport.closeActiveSession(activeAccount) + await transport.disconnect() } } @@ -2376,7 +2376,9 @@ export class DAppClient extends Client { await this.createStateSnapshot() this.sendMetrics('performance-metrics/save', await this.buildPayload('disconnect', 'start')) await this.clearActiveAccount() - await transport.disconnect() + if (!(transport instanceof WalletConnectTransport)) { + await transport.disconnect() + } this.postMessageTransport = undefined this.p2pTransport = undefined this.walletConnectTransport = undefined From 742835e9725ab4fb6e7fb67928c7f20b779c75ff Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 29 Apr 2024 12:06:08 +0200 Subject: [PATCH 29/41] fix: add debouncer --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 3e51d71f1..6ce435835 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -223,6 +223,8 @@ export class DAppClient extends Client { private debounceEventResponse: boolean = false + private debounceSetActiveAccount: boolean = false + constructor(config: DAppClientOptions) { super({ storage: config && config.storage ? config.storage : new LocalStorage(), @@ -848,8 +850,10 @@ export class DAppClient extends Client { return } - if (transport instanceof WalletConnectTransport) { + if (!this.debounceSetActiveAccount && transport instanceof WalletConnectTransport) { + this.debounceSetActiveAccount = true await transport.disconnect() + this.debounceSetActiveAccount = false } } From 3e1322cc2549e46396a0997818a97ca60549cae2 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 29 Apr 2024 12:45:49 +0200 Subject: [PATCH 30/41] fix: comment --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 6ce435835..6e81b5683 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -628,7 +628,7 @@ export class DAppClient extends Client { /** * Destroy the instance. * - * WARNING: Call `destroy` whenever you no longer need dAppClient, + * WARNING: Call `destroy` whenever you no longer need dAppClient * as it frees internal subscriptions to the transport and therefore the instance may no longer work properly. * If you wish to disconnect your dApp, use `disconnect` instead. */ From 5f6b4607c00a14f7863caf4194409189f6da5e0a Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 29 Apr 2024 15:04:38 +0200 Subject: [PATCH 31/41] fix: logging --- examples/dapp.html | 2 +- .../beacon-dapp/src/dapp-client/DAppClient.ts | 63 ++++++++++--------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/examples/dapp.html b/examples/dapp.html index 3bdf2379e..a2ff931e8 100644 --- a/examples/dapp.html +++ b/examples/dapp.html @@ -184,7 +184,7 @@ el.innerText = `'time' ${start} ${label}` el.setAttribute('style', 'background-color: grey') document.getElementById('logger-output').appendChild(el) - console.time(label) + start ? console.time(label) : console.timeEnd(label) } timeLog(method, ...args) { diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 6e81b5683..e65ee1f26 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -307,7 +307,6 @@ export class DAppClient extends Client { if (openRequest && typedMessage.message?.type === BeaconMessageType.Acknowledge) { this.analytics.track('event', 'DAppClient', 'Acknowledge received from Wallet') logger.log('handleResponse', `acknowledge message received for ${message.id}`) - logger.timeLog('handleResponse', message.id, 'acknowledge') this.events .emit(BeaconEvent.ACKNOWLEDGE_RECEIVED, { @@ -324,9 +323,6 @@ export class DAppClient extends Client { await this.appMetadataManager.addAppMetadata(appMetadata) } - logger.timeLog('handleResponse', typedMessage.id, 'response') - logger.time(false, typedMessage.id) - if (typedMessage.message?.type === BeaconMessageType.Error) { openRequest.reject(typedMessage.message as ErrorResponse) } else { @@ -369,8 +365,6 @@ export class DAppClient extends Client { logger.log('handleResponse', `acknowledge message received for ${message.id}`) this.analytics.track('event', 'DAppClient', 'Acknowledge received from Wallet') - logger.timeLog('handleResponse', message.id, 'acknowledge') - this.events .emit(BeaconEvent.ACKNOWLEDGE_RECEIVED, { message: typedMessage, @@ -386,9 +380,6 @@ export class DAppClient extends Client { await this.appMetadataManager.addAppMetadata(typedMessage.appMetadata) } - logger.timeLog('handleResponse', typedMessage.id, 'response') - logger.time(false, typedMessage.id) - if (typedMessage.type === BeaconMessageType.Error || (message as any).errorType) { // TODO: Remove "any" once we remove support for v1 wallets openRequest.reject(typedMessage as any) @@ -1219,6 +1210,8 @@ export class DAppClient extends Client { this.sendMetrics('performance-metrics/save', await this.buildPayload('connect', 'start')) + const logId = `makeRequestV3 ${Date.now()}` + logger.time(true, logId) const { message: response, connectionInfo } = await this.makeRequestV3< PermissionRequestV3, BeaconMessageWrapper> @@ -1226,9 +1219,11 @@ export class DAppClient extends Client { requestError.errorType === BeaconErrorType.ABORTED_ERROR ? this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'abort')) : this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'error')) + logger.time(false, logId) throw new Error('TODO') // throw await this.handleRequestError(request, requestError) }) + logger.time(false, logId) this.sendMetrics('performance-metrics/save', await this.buildPayload('connect', 'start')) @@ -1302,6 +1297,8 @@ export class DAppClient extends Client { this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'start')) + const logId = `makeRequestV3 ${Date.now()}` + logger.time(true, logId) const { message: response, connectionInfo } = await this.makeRequestV3< BlockchainRequestV3, BeaconMessageWrapper> @@ -1310,10 +1307,11 @@ export class DAppClient extends Client { requestError.errorType === BeaconErrorType.ABORTED_ERROR ? this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'abort')) : this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'error')) + logger.time(false, logId) throw new Error('TODO') // throw await this.handleRequestError(request, requestError) }) - + logger.time(false, logId) this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'success')) await blockchain.handleResponse({ @@ -1360,6 +1358,8 @@ export class DAppClient extends Client { this.sendMetrics('performance-metrics/save', await this.buildPayload('connect', 'start')) + const logId = `makeRequest ${Date.now()}` + logger.time(true, logId) const { message, connectionInfo } = await this.makeRequest< PermissionRequest, PermissionResponse @@ -1367,9 +1367,10 @@ export class DAppClient extends Client { requestError.errorType === BeaconErrorType.ABORTED_ERROR ? this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'abort')) : this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'error')) + logger.time(false, logId) throw await this.handleRequestError(request, requestError) }) - + logger.time(false, logId) this.sendMetrics('performance-metrics/save', await this.buildPayload('connect', 'success')) logger.log('requestPermissions', '######## MESSAGE #######') @@ -1432,7 +1433,8 @@ export class DAppClient extends Client { } this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'start')) - + const logId = `makeRequest ${Date.now()}` + logger.time(true, logId) const { message, connectionInfo } = await this.makeRequest< ProofOfEventChallengeRequest, ProofOfEventChallengeResponse @@ -1440,9 +1442,10 @@ export class DAppClient extends Client { requestError.errorType === BeaconErrorType.ABORTED_ERROR ? this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'abort')) : this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'error')) + logger.time(false, logId) throw await this.handleRequestError(request, requestError) }) - + logger.time(false, logId) this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'success')) this.analytics.track( @@ -1491,14 +1494,16 @@ export class DAppClient extends Client { contractAddress: activeAccount.address, ...input } - + const logId = `makeRequest ${Date.now()}` + logger.time(true, logId) const { message, connectionInfo } = await this.makeRequest< SimulatedProofOfEventChallengeRequest, SimulatedProofOfEventChallengeResponse >(request).catch(async (requestError: ErrorResponse) => { + logger.time(false, logId) throw await this.handleRequestError(request, requestError) }) - + logger.time(false, logId) this.analytics.track( 'event', 'DAppClient', @@ -1576,7 +1581,8 @@ export class DAppClient extends Client { } this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'start')) - + const logId = `makeRequest ${Date.now()}` + logger.time(true, logId) const { message, connectionInfo } = await this.makeRequest< SignPayloadRequest, SignPayloadResponse @@ -1584,9 +1590,10 @@ export class DAppClient extends Client { requestError.errorType === BeaconErrorType.ABORTED_ERROR ? this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'abort')) : this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'error')) + logger.time(false, logId) throw await this.handleRequestError(request, requestError) }) - + logger.time(false, logId) this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'success')) await this.notifySuccess(request, { @@ -1685,16 +1692,18 @@ export class DAppClient extends Client { this.analytics.track('event', 'DAppClient', 'Operation requested') this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'start')) - + const logId = `makeRequest ${Date.now()}` + logger.time(true, logId) const { message, connectionInfo } = await this.makeRequest( request ).catch(async (requestError: ErrorResponse) => { requestError.errorType === BeaconErrorType.ABORTED_ERROR ? this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'abort')) : this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'error')) + logger.time(false, logId) throw await this.handleRequestError(request, requestError) }) - + logger.time(false, logId) this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'success')) await this.notifySuccess(request, { @@ -1738,16 +1747,18 @@ export class DAppClient extends Client { this.analytics.track('event', 'DAppClient', 'Broadcast requested') this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'start')) - + const logId = `makeRequest ${Date.now()}` + logger.time(true, logId) const { message, connectionInfo } = await this.makeRequest( request ).catch(async (requestError: ErrorResponse) => { requestError.errorType === BeaconErrorType.ABORTED_ERROR ? this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'abort')) : this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'error')) + logger.time(false, logId) throw await this.handleRequestError(request, requestError) }) - + logger.time(false, logId) this.sendMetrics('performance-metrics/save', await this.buildPayload('message', 'success')) await this.notifySuccess(request, { @@ -2144,12 +2155,10 @@ export class DAppClient extends Client { this.hideUI(['toast']) } - logger.time(true, messageId) logger.log('makeRequest', 'starting') this.isInitPending = true await this.init() this.isInitPending = false - logger.timeLog(messageId, 'init done') logger.log('makeRequest', 'after init') if (await this.addRequestAndCheckIfRateLimited()) { @@ -2201,7 +2210,6 @@ export class DAppClient extends Client { const walletInfo = await this.getWalletInfo(peer, account) logger.log('makeRequest', 'sending message', request) - logger.timeLog('makeRequest', messageId, 'sending') try { ;(await this.transport).send(payload, peer) if ( @@ -2223,10 +2231,8 @@ export class DAppClient extends Client { } ] }) - logger.timeLog('makeRequest', messageId, 'send error') throw sendError } - logger.timeLog('makeRequest', messageId, 'sent') this.events .emit(messageEvents[requestInput.type].sent, { @@ -2273,12 +2279,10 @@ export class DAppClient extends Client { } const messageId = await generateGUID() - logger.time(true, messageId) logger.log('makeRequest', 'starting') this.isInitPending = true await this.init() this.isInitPending = false - logger.timeLog('makeRequest', messageId, 'init done') logger.log('makeRequest', 'after init') if (await this.addRequestAndCheckIfRateLimited()) { @@ -2319,7 +2323,6 @@ export class DAppClient extends Client { const walletInfo = await this.getWalletInfo(peer, account) logger.log('makeRequest', 'sending message', request) - logger.timeLog('makeRequest', messageId, 'sending') try { ;(await this.transport).send(payload, peer) if ( @@ -2341,10 +2344,8 @@ export class DAppClient extends Client { } ] }) - logger.timeLog('makeRequest', messageId, 'send error') throw sendError } - logger.timeLog('makeRequest', messageId, 'sent') const index = requestInput.type as any as BeaconMessageType From e90fdfee7896240e31c3b6bcbdd3cacd2e1079e6 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 29 Apr 2024 15:38:39 +0200 Subject: [PATCH 32/41] fix: disconnect --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 6 ++++++ .../WalletConnectCommunicationClient.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index e65ee1f26..c8c7a75bd 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -765,6 +765,10 @@ export class DAppClient extends Client { // p2pTransport.disconnect(), do not abort connection manually walletConnectTransport.disconnect() ]) + this.postMessageTransport = + this.walletConnectTransport = + this.p2pTransport = + undefined this._activeAccount.isResolved() && this.clearActiveAccount() this._initPromise = undefined }, @@ -843,6 +847,8 @@ export class DAppClient extends Client { if (!this.debounceSetActiveAccount && transport instanceof WalletConnectTransport) { this.debounceSetActiveAccount = true + this._initPromise = undefined + this.postMessageTransport = this.p2pTransport = this.walletConnectTransport = undefined await transport.disconnect() this.debounceSetActiveAccount = false } diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 5b58627d6..10ac83a31 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -716,6 +716,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { public async close() { this.storage.backup() await this.closePairings() + this.unsubscribeFromEncryptedMessages() } private subscribeToSessionEvents(signClient: Client): void { From c6cee619a007329d12d135900865bf9cdf06d7ed Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 30 Apr 2024 10:35:43 +0200 Subject: [PATCH 33/41] fix: disconnect multi tab --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 2 +- .../src/WalletConnectTransport.ts | 11 ----------- .../WalletConnectCommunicationClient.ts | 13 ++++++++----- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index c8c7a75bd..7207257bd 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -613,7 +613,7 @@ export class DAppClient extends Client { await this.events.emit(BeaconEvent.CHANNEL_CLOSED) this.setActiveAccount(undefined) - await this.destroy() + await this.disconnect() } /** diff --git a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts index a00a0c5eb..93094e3db 100644 --- a/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts +++ b/packages/beacon-transport-walletconnect/src/WalletConnectTransport.ts @@ -9,7 +9,6 @@ import { StorageKey, WalletConnectPairingRequest, NetworkType, - AccountInfo, TransportType } from '@airgap/beacon-types' import { Transport, PeerManager } from '@airgap/beacon-core' @@ -90,16 +89,6 @@ export class WalletConnectTransport< this.client.storage.notify(type) } - public async closeActiveSession(account: AccountInfo) { - if (!(await this.hasPairings()) || !(await this.hasPairings())) { - await this.disconnect() - } else { - await this.client.closeActiveSession(account.address) - } - - this.forceUpdate('CLEAR_ACTIVE_ACCOUNT') - } - public async getPeers(): Promise { const client = WalletConnectCommunicationClient.getInstance(this.wcOptions) const session = client.currentSession() diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index 10ac83a31..feedb7163 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -188,9 +188,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { private onStorageMessageHandler(type: string) { logger.debug('onStorageMessageHandler', type) - this.refreshState() - - if (type === 'CLEAR_ACTIVE_ACCOUNT') { + if (type === 'RESET') { if (this.messageIds.length) { const errorResponse: any = { type: BeaconMessageType.Disconnect, @@ -200,10 +198,15 @@ export class WalletConnectCommunicationClient extends CommunicationClient { this.session && this.notifyListeners(this.getTopicFromSession(this.session), errorResponse) this.messageIds = [] // reset } - this.session = undefined - this.activeAccount = undefined + this.clearEvents() + // no need to invoke `closeSignClinet` as the other tab already closed the connection + this.signClient = undefined + this.clearState() + return } + + this.refreshState() } private onStorageErrorHandler(data: any) { From 4518c782b249f5a6253a475fe22ac177360b2056 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 30 Apr 2024 13:04:06 +0200 Subject: [PATCH 34/41] fix: ui notification --- .../WalletConnectCommunicationClient.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts index feedb7163..52c3ef20c 100644 --- a/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts +++ b/packages/beacon-transport-walletconnect/src/communication-client/WalletConnectCommunicationClient.ts @@ -185,19 +185,25 @@ export class WalletConnectCommunicationClient extends CommunicationClient { this.signClient?.core.pairing.events.removeAllListeners('pairing_expire') } + private abortErrorBuilder() { + if (!this.messageIds.length) { + return + } + + const errorResponse: any = { + type: BeaconMessageType.Disconnect, + id: this.messageIds.pop(), + errorType: BeaconErrorType.ABORTED_ERROR + } + this.session && this.notifyListeners(this.getTopicFromSession(this.session), errorResponse) + this.messageIds = [] // reset + } + private onStorageMessageHandler(type: string) { logger.debug('onStorageMessageHandler', type) if (type === 'RESET') { - if (this.messageIds.length) { - const errorResponse: any = { - type: BeaconMessageType.Disconnect, - id: this.messageIds.pop(), - errorType: BeaconErrorType.ABORTED_ERROR - } - this.session && this.notifyListeners(this.getTopicFromSession(this.session), errorResponse) - this.messageIds = [] // reset - } + this.abortErrorBuilder() this.clearEvents() // no need to invoke `closeSignClinet` as the other tab already closed the connection this.signClient = undefined @@ -718,6 +724,7 @@ export class WalletConnectCommunicationClient extends CommunicationClient { public async close() { this.storage.backup() + this.abortErrorBuilder() await this.closePairings() this.unsubscribeFromEncryptedMessages() } From 937a622b3c27aab7ea3a0b57d06b9d96e5ff413e Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 30 Apr 2024 16:13:03 +0200 Subject: [PATCH 35/41] feat: init parisnet --- packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts | 1 + packages/beacon-types/src/types/beacon/NetworkType.ts | 1 + packages/beacon-types/src/types/ui.ts | 1 + scripts/blockchains/tezos-sapling.ts | 1 + scripts/blockchains/tezos.ts | 10 +++++++--- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts b/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts index 5ce860645..d2b1ae1c1 100644 --- a/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts +++ b/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts @@ -20,6 +20,7 @@ export class TzktBlockExplorer extends BlockExplorer { [NetworkType.MUMBAINET]: 'https://mumbainet.tzkt.io', [NetworkType.NAIROBINET]: 'https://nairobinet.tzkt.io', [NetworkType.OXFORDNET]: 'https://oxfordnet.tzkt.io', + [NetworkType.PARISNET]: 'https://parisnet.tzkt.io', [NetworkType.CUSTOM]: 'https://oxfordnet.tzkt.io' } ) { diff --git a/packages/beacon-types/src/types/beacon/NetworkType.ts b/packages/beacon-types/src/types/beacon/NetworkType.ts index 3b6381f0f..bc7dfc3ce 100644 --- a/packages/beacon-types/src/types/beacon/NetworkType.ts +++ b/packages/beacon-types/src/types/beacon/NetworkType.ts @@ -15,5 +15,6 @@ export enum NetworkType { MUMBAINET = 'mumbainet', NAIROBINET = 'nairobinet', OXFORDNET = 'oxfordnet', + PARISNET = 'parisnet', CUSTOM = 'custom' } diff --git a/packages/beacon-types/src/types/ui.ts b/packages/beacon-types/src/types/ui.ts index 88c45d5a6..5e3b064eb 100644 --- a/packages/beacon-types/src/types/ui.ts +++ b/packages/beacon-types/src/types/ui.ts @@ -32,6 +32,7 @@ export interface WebApp extends AppBase { [NetworkType.MUMBAINET]?: string [NetworkType.NAIROBINET]?: string [NetworkType.OXFORDNET]?: string + [NetworkType.PARISNET]?: string [NetworkType.CUSTOM]?: string } } diff --git a/scripts/blockchains/tezos-sapling.ts b/scripts/blockchains/tezos-sapling.ts index 38e8b958f..70cdba84f 100644 --- a/scripts/blockchains/tezos-sapling.ts +++ b/scripts/blockchains/tezos-sapling.ts @@ -18,6 +18,7 @@ export enum NetworkType { MUMBAINET = 'mumbainet', NAIROBINET = 'nairobinet', OXFORDNET = 'oxfordnet', + PARISNET = 'parisnet', CUSTOM = 'custom' } diff --git a/scripts/blockchains/tezos.ts b/scripts/blockchains/tezos.ts index f174681e7..2980ef7d9 100644 --- a/scripts/blockchains/tezos.ts +++ b/scripts/blockchains/tezos.ts @@ -18,6 +18,7 @@ export enum NetworkType { MUMBAINET = 'mumbainet', NAIROBINET = 'nairobinet', OXFORDNET = 'oxfordnet', + PARISNET = 'parisnet', CUSTOM = 'custom' } @@ -74,7 +75,8 @@ export const tezosWebList: WebApp[] = [ [NetworkType.LIMANET]: 'https://metamask.tezos.com/', [NetworkType.MUMBAINET]: 'https://metamask.tezos.com/', [NetworkType.NAIROBINET]: 'https://metamask.tezos.com/', - [NetworkType.OXFORDNET]: 'https://metamask.tezos.com/' + [NetworkType.OXFORDNET]: 'https://metamask.tezos.com/', + [NetworkType.PARISNET]: 'https://metamask.tezos.com/' } }, { @@ -100,7 +102,8 @@ export const tezosWebList: WebApp[] = [ [NetworkType.LIMANET]: 'https://limanet.kukai.app', [NetworkType.MUMBAINET]: 'https://mumbainet.kukai.app', [NetworkType.NAIROBINET]: 'https://nairobinet.kukai.app', - [NetworkType.OXFORDNET]: 'https://oxfordnet.kukai.app' + [NetworkType.OXFORDNET]: 'https://oxfordnet.kukai.app', + [NetworkType.PARISNET]: 'https://parisnet.kukai.app' } }, @@ -126,7 +129,8 @@ export const tezosWebList: WebApp[] = [ [NetworkType.LIMANET]: 'https://ghostnet.tzsafe.marigold.dev', [NetworkType.MUMBAINET]: 'https://ghostnet.tzsafe.marigold.dev', [NetworkType.NAIROBINET]: 'https://ghostnet.tzsafe.marigold.dev', - [NetworkType.OXFORDNET]: 'https://ghostnet.tzsafe.marigold.dev' + [NetworkType.OXFORDNET]: 'https://ghostnet.tzsafe.marigold.dev', + [NetworkType.PARISNET]: 'https://ghostnet.tzsafe.marigold.dev' } } ] From 2b5a16ed4ddc64debf83c676bb8876e4e7705ae3 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Wed, 24 Apr 2024 14:26:55 +0200 Subject: [PATCH 36/41] fix: remove keyPair --- packages/beacon-dapp/src/dapp-client/DAppClient.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index 7207257bd..ca91a9550 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -1811,7 +1811,17 @@ export class DAppClient extends Client { const result = super.setTransport(transport) - await this.events.emit(BeaconEvent.ACTIVE_TRANSPORT_SET, transport) + const event = transport ? { ...(transport as any) } : undefined + + // remove keyPair, to prevent dApps from accidentaly leaking the privateKey + if (event) { + event.client = { + ...event.client, + keyPair: undefined + } + } + + await this.events.emit(BeaconEvent.ACTIVE_TRANSPORT_SET, event) return result } From 38673bfd18741e05c08cde678069f449101150dc Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Mon, 13 May 2024 11:46:16 +0200 Subject: [PATCH 37/41] fix: multitab send --- .../src/communication-client/P2PCommunicationClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-transport-matrix/src/communication-client/P2PCommunicationClient.ts b/packages/beacon-transport-matrix/src/communication-client/P2PCommunicationClient.ts index 032359db9..eec92668a 100644 --- a/packages/beacon-transport-matrix/src/communication-client/P2PCommunicationClient.ts +++ b/packages/beacon-transport-matrix/src/communication-client/P2PCommunicationClient.ts @@ -541,7 +541,7 @@ export class P2PCommunicationClient extends CommunicationClient { const roomId = await this.getRelevantRoom(recipient) // Before we send the message, we have to wait for the join to be accepted. - await this.waitForJoin(roomId) // TODO: This can probably be removed because we are now waiting inside the get room method + // await this.waitForJoin(roomId) // TODO: This can probably be removed because we are now waiting inside the get room method const encryptedMessage = await encryptCryptoboxPayload(message, sharedKey.send) From d6c1c9ecfaa809a45517d89f2c4be3f3c0cd1893 Mon Sep 17 00:00:00 2001 From: Ajinkya Rajandekar Date: Mon, 13 May 2024 16:50:25 +0100 Subject: [PATCH 38/41] Add support for newly launched parisnet in tezos protocol. --- packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts | 3 ++- packages/beacon-types/src/types/beacon/NetworkType.ts | 1 + packages/beacon-types/src/types/ui.ts | 1 + scripts/blockchains/tezos-sapling.ts | 1 + scripts/blockchains/tezos.ts | 11 ++++++++--- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts b/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts index 5ce860645..ffae6fe40 100644 --- a/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts +++ b/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts @@ -20,7 +20,8 @@ export class TzktBlockExplorer extends BlockExplorer { [NetworkType.MUMBAINET]: 'https://mumbainet.tzkt.io', [NetworkType.NAIROBINET]: 'https://nairobinet.tzkt.io', [NetworkType.OXFORDNET]: 'https://oxfordnet.tzkt.io', - [NetworkType.CUSTOM]: 'https://oxfordnet.tzkt.io' + [NetworkType.PARISNET]: 'https://parisnet.tzkt.io', + [NetworkType.CUSTOM]: 'https://parisnet.tzkt.io' } ) { super(rpcUrls) diff --git a/packages/beacon-types/src/types/beacon/NetworkType.ts b/packages/beacon-types/src/types/beacon/NetworkType.ts index 3b6381f0f..5e712f06d 100644 --- a/packages/beacon-types/src/types/beacon/NetworkType.ts +++ b/packages/beacon-types/src/types/beacon/NetworkType.ts @@ -15,5 +15,6 @@ export enum NetworkType { MUMBAINET = 'mumbainet', NAIROBINET = 'nairobinet', OXFORDNET = 'oxfordnet', + PARISNET = 'parisnet', CUSTOM = 'custom' } diff --git a/packages/beacon-types/src/types/ui.ts b/packages/beacon-types/src/types/ui.ts index 88c45d5a6..5e3b064eb 100644 --- a/packages/beacon-types/src/types/ui.ts +++ b/packages/beacon-types/src/types/ui.ts @@ -32,6 +32,7 @@ export interface WebApp extends AppBase { [NetworkType.MUMBAINET]?: string [NetworkType.NAIROBINET]?: string [NetworkType.OXFORDNET]?: string + [NetworkType.PARISNET]?: string [NetworkType.CUSTOM]?: string } } diff --git a/scripts/blockchains/tezos-sapling.ts b/scripts/blockchains/tezos-sapling.ts index 38e8b958f..70cdba84f 100644 --- a/scripts/blockchains/tezos-sapling.ts +++ b/scripts/blockchains/tezos-sapling.ts @@ -18,6 +18,7 @@ export enum NetworkType { MUMBAINET = 'mumbainet', NAIROBINET = 'nairobinet', OXFORDNET = 'oxfordnet', + PARISNET = 'parisnet', CUSTOM = 'custom' } diff --git a/scripts/blockchains/tezos.ts b/scripts/blockchains/tezos.ts index f174681e7..8e21058d0 100644 --- a/scripts/blockchains/tezos.ts +++ b/scripts/blockchains/tezos.ts @@ -18,6 +18,7 @@ export enum NetworkType { MUMBAINET = 'mumbainet', NAIROBINET = 'nairobinet', OXFORDNET = 'oxfordnet', + PARISNET = 'parisnet', CUSTOM = 'custom' } @@ -74,7 +75,8 @@ export const tezosWebList: WebApp[] = [ [NetworkType.LIMANET]: 'https://metamask.tezos.com/', [NetworkType.MUMBAINET]: 'https://metamask.tezos.com/', [NetworkType.NAIROBINET]: 'https://metamask.tezos.com/', - [NetworkType.OXFORDNET]: 'https://metamask.tezos.com/' + [NetworkType.OXFORDNET]: 'https://metamask.tezos.com/', + [NetworkType.PARISNET]: 'https://metamask.tezos.com/' } }, { @@ -100,7 +102,9 @@ export const tezosWebList: WebApp[] = [ [NetworkType.LIMANET]: 'https://limanet.kukai.app', [NetworkType.MUMBAINET]: 'https://mumbainet.kukai.app', [NetworkType.NAIROBINET]: 'https://nairobinet.kukai.app', - [NetworkType.OXFORDNET]: 'https://oxfordnet.kukai.app' + [NetworkType.OXFORDNET]: 'https://oxfordnet.kukai.app', + [NetworkType.PARISNET]: 'https://parisnet.kukai.app', + } }, @@ -126,7 +130,8 @@ export const tezosWebList: WebApp[] = [ [NetworkType.LIMANET]: 'https://ghostnet.tzsafe.marigold.dev', [NetworkType.MUMBAINET]: 'https://ghostnet.tzsafe.marigold.dev', [NetworkType.NAIROBINET]: 'https://ghostnet.tzsafe.marigold.dev', - [NetworkType.OXFORDNET]: 'https://ghostnet.tzsafe.marigold.dev' + [NetworkType.OXFORDNET]: 'https://ghostnet.tzsafe.marigold.dev', + [NetworkType.PARISNET]: 'https://ghostnet.tzsafe.marigold.dev' } } ] From 5c31766a0c4904b760df3a928ab0d695c81a33b0 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 14 May 2024 09:06:55 +0200 Subject: [PATCH 39/41] fix: NetworkType.CUSTOM parisnet --- packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts b/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts index d2b1ae1c1..ffae6fe40 100644 --- a/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts +++ b/packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts @@ -21,7 +21,7 @@ export class TzktBlockExplorer extends BlockExplorer { [NetworkType.NAIROBINET]: 'https://nairobinet.tzkt.io', [NetworkType.OXFORDNET]: 'https://oxfordnet.tzkt.io', [NetworkType.PARISNET]: 'https://parisnet.tzkt.io', - [NetworkType.CUSTOM]: 'https://oxfordnet.tzkt.io' + [NetworkType.CUSTOM]: 'https://parisnet.tzkt.io' } ) { super(rpcUrls) From 36dfd775df2131d784048611f32b2be2adf03e7d Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Tue, 14 May 2024 16:57:28 +0200 Subject: [PATCH 40/41] feat: types --- packages/beacon-types/src/index.ts | 36 +++++++++++++++++-- .../src/types/tezos/OperationTypes.ts | 4 +-- .../src/types/tezos/PartialTezosOperation.ts | 7 ++++ .../tezos/operations/DalPublishCommitment.ts | 15 ++++++++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 packages/beacon-types/src/types/tezos/operations/DalPublishCommitment.ts diff --git a/packages/beacon-types/src/index.ts b/packages/beacon-types/src/index.ts index 2f6468f99..ac0c06506 100644 --- a/packages/beacon-types/src/index.ts +++ b/packages/beacon-types/src/index.ts @@ -99,7 +99,7 @@ import { BroadcastRequestOutput, BeaconRequestOutputMessage, ProofOfEventChallengeRequestOutput, - SimulatedProofOfEventChallengeRequestOutput, + SimulatedProofOfEventChallengeRequestOutput } from './types/beacon/messages/BeaconRequestOutputMessage' import { PermissionInfo } from './types/PermissionInfo' import { ConnectionContext } from './types/ConnectionContext' @@ -109,7 +109,21 @@ import { PartialTezosOperation, PartialTezosDelegationOperation, PartialTezosOriginationOperation, - PartialTezosRevealOperation + PartialTezosRevealOperation, + PartialTezosSmartRollupOriginateOperation, + PartialTezosSmartRollupAddMessagesOperation, + PartialTezosSmartRollupExecuteOutboxMessageOperation, + PartialTezosSmartRollupPublishOperation, + PartialTezosSmartRollupCementOperation, + PartialTezosSmartRollupRecoverBondOperation, + PartialTezosSmartRollupRefuteOperation, + PartialTezosSmartRollupTimeoutOperation, + PartialTezosDalPublishCommitmentOperation, + PartialTezosIncreasePaidStorageOperation, + PartialTezosRegisterGlobalConstantOperation, + PartialTezosTransferTicketOperation, + PartialTezosUpdateConsensusKeyOperation, + PartialTezosSetDepositsLimitOperation } from './types/tezos/PartialTezosOperation' import { ExtendedPeerInfo, PeerInfo, PeerInfoType } from './types/PeerInfo' import { AcknowledgeResponse } from './types/beacon/messages/AcknowledgeResponse' @@ -163,6 +177,7 @@ import { TezosVdfRevelationOperation } from './types/tezos/operations/VdfRevelat import { TezosDoublePreAttestationEvidenceOperation } from './types/tezos/operations/DoublePreAttestationEvidence' import { TezosSmartRollupCementOperation } from './types/tezos/operations/SmartRollupCement' import { TezosSmartRollupOriginateOperation } from './types/tezos/operations/SmartRollupOriginate' +import { TezosDalPublishCommitmentOperation } from './types/tezos/operations/DalPublishCommitment' export * from './types/AnalyticsInterface' @@ -201,6 +216,20 @@ export { PartialTezosDelegationOperation, PartialTezosOriginationOperation, PartialTezosRevealOperation, + PartialTezosSmartRollupOriginateOperation, + PartialTezosSmartRollupAddMessagesOperation, + PartialTezosSmartRollupExecuteOutboxMessageOperation, + PartialTezosSmartRollupPublishOperation, + PartialTezosSmartRollupCementOperation, + PartialTezosSmartRollupRecoverBondOperation, + PartialTezosSmartRollupRefuteOperation, + PartialTezosSmartRollupTimeoutOperation, + PartialTezosDalPublishCommitmentOperation, + PartialTezosRegisterGlobalConstantOperation, + PartialTezosTransferTicketOperation, + PartialTezosIncreasePaidStorageOperation, + PartialTezosUpdateConsensusKeyOperation, + PartialTezosSetDepositsLimitOperation, TezosAttestationOperation, TezosPreAttestationOperation, TezosSetDepositsLimitOperation, @@ -223,7 +252,8 @@ export { TezosSmartRollupCementOperation, TezosSmartRollupRecoverBondOperation, TezosSmartRollupRefuteOperation, - TezosSmartRollupTimeoutOperation + TezosSmartRollupTimeoutOperation, + TezosDalPublishCommitmentOperation } // Beacon diff --git a/packages/beacon-types/src/types/tezos/OperationTypes.ts b/packages/beacon-types/src/types/tezos/OperationTypes.ts index ab14b9258..e646fd240 100644 --- a/packages/beacon-types/src/types/tezos/OperationTypes.ts +++ b/packages/beacon-types/src/types/tezos/OperationTypes.ts @@ -14,7 +14,6 @@ export enum TezosOperationType { DOUBLE_BAKING_EVIDENCE = 'double_baking_evidence', PROPOSALS = 'proposals', BALLOT = 'ballot', - // --- ATTESTATION = 'attestation', PREATTESTATION = 'preattestation', PREENDORSEMENT = 'preendorsement', @@ -40,5 +39,6 @@ export enum TezosOperationType { SMART_ROLLUP_CEMENT = 'smart_rollup_cement', SMART_ROLLUP_RECOVER_BOND = 'smart_rollup_recover_bond', SMART_ROLLUP_REFUTE = 'smart_rollup_refute', - SMART_ROLLUP_TIMEOUT = 'smart_rollup_timeout' + SMART_ROLLUP_TIMEOUT = 'smart_rollup_timeout', + DAL_PUBLISH_COMMITMENT = 'dal_publish_commitment' } diff --git a/packages/beacon-types/src/types/tezos/PartialTezosOperation.ts b/packages/beacon-types/src/types/tezos/PartialTezosOperation.ts index 23fe77906..40a9013a1 100644 --- a/packages/beacon-types/src/types/tezos/PartialTezosOperation.ts +++ b/packages/beacon-types/src/types/tezos/PartialTezosOperation.ts @@ -34,6 +34,7 @@ import { TezosRevealOperation } from './operations/Reveal' import { TezosSeedNonceRevelationOperation } from './operations/SeedNonceRevelation' import { TezosTransactionOperation } from './operations/Transaction' import { TezosPreEndorsementOperation } from './operations/PreEndorsement' +import { TezosDalPublishCommitmentOperation } from './operations/DalPublishCommitment' /** * @publicapi @@ -172,6 +173,11 @@ export type PartialTezosSmartRollupTimeoutOperation = Optional< omittedProperties > +export type PartialTezosDalPublishCommitmentOperation = Optional< + TezosDalPublishCommitmentOperation, + omittedProperties +> + /** * @publicapi * @category Tezos @@ -211,3 +217,4 @@ export type PartialTezosOperation = | PartialTezosSmartRollupRecoverBondOperation | PartialTezosSmartRollupRefuteOperation | PartialTezosSmartRollupTimeoutOperation + | PartialTezosDalPublishCommitmentOperation diff --git a/packages/beacon-types/src/types/tezos/operations/DalPublishCommitment.ts b/packages/beacon-types/src/types/tezos/operations/DalPublishCommitment.ts new file mode 100644 index 000000000..23abbf29c --- /dev/null +++ b/packages/beacon-types/src/types/tezos/operations/DalPublishCommitment.ts @@ -0,0 +1,15 @@ +import { TezosOperationType } from '../OperationTypes' + +export interface TezosDalPublishCommitmentOperation { + kind: TezosOperationType.DAL_PUBLISH_COMMITMENT + source: string + fee: string + counter: string + gas_limit: string + storage_limit: string + slot_header: { + slot_index: number + commitment: string + commitment_proof: string + } +} From 15a98485fb03995726482abf09e6a43103b72aa3 Mon Sep 17 00:00:00 2001 From: IsaccoSordo Date: Wed, 15 May 2024 10:45:17 +0200 Subject: [PATCH 41/41] chore: release --- examples/dapp.html | 2 +- lerna.json | 2 +- package-lock.json | 102 +++++++++--------- .../beacon-blockchain-substrate/package.json | 6 +- .../package.json | 6 +- packages/beacon-blockchain-tezos/package.json | 6 +- packages/beacon-core/package.json | 6 +- packages/beacon-core/src/constants.ts | 2 +- packages/beacon-dapp/package.json | 12 +-- packages/beacon-sdk/package.json | 22 ++-- packages/beacon-transport-matrix/package.json | 6 +- .../beacon-transport-postmessage/package.json | 8 +- .../package.json | 8 +- packages/beacon-types/package.json | 2 +- packages/beacon-ui/package.json | 10 +- packages/beacon-utils/package.json | 2 +- packages/beacon-wallet/package.json | 8 +- 17 files changed, 105 insertions(+), 105 deletions(-) diff --git a/examples/dapp.html b/examples/dapp.html index a2ff931e8..8f33e4a2c 100644 --- a/examples/dapp.html +++ b/examples/dapp.html @@ -234,7 +234,7 @@ }, featuredWallets: ['kukai', 'metamask', 'airgap'], network: { - type: beacon.NetworkType.GHOSTNET + type: beacon.NetworkType.MAINNET }, enableMetrics: true // matrixNodes: ['test.papers.tech', 'test2.papers.tech', 'matrix.papers.tech'] diff --git a/lerna.json b/lerna.json index 3f8ca3613..fbd1321c7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { - "version": "4.2.1", + "version": "4.2.2", "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/package-lock.json b/package-lock.json index 2fa6f9468..bb27da85a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25390,38 +25390,38 @@ }, "packages/beacon-blockchain-substrate": { "name": "@airgap/beacon-blockchain-substrate", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } }, "packages/beacon-blockchain-tezos": { "name": "@airgap/beacon-blockchain-tezos", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } }, "packages/beacon-blockchain-tezos-sapling": { "name": "@airgap/beacon-blockchain-tezos-sapling", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } }, "packages/beacon-core": { "name": "@airgap/beacon-core", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "@stablelib/ed25519": "^1.0.3", "@stablelib/nacl": "^1.0.4", "@stablelib/utf8": "^1.0.1", @@ -25431,67 +25431,67 @@ }, "packages/beacon-dapp": { "name": "@airgap/beacon-dapp", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-transport-matrix": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1", - "@airgap/beacon-transport-walletconnect": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-transport-matrix": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2", + "@airgap/beacon-transport-walletconnect": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } }, "packages/beacon-sdk": { "name": "@airgap/beacon-sdk", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-blockchain-substrate": "4.2.1", - "@airgap/beacon-blockchain-tezos": "4.2.1", - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-dapp": "4.2.1", - "@airgap/beacon-transport-matrix": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1", - "@airgap/beacon-utils": "4.2.1", - "@airgap/beacon-wallet": "4.2.1" + "@airgap/beacon-blockchain-substrate": "4.2.2", + "@airgap/beacon-blockchain-tezos": "4.2.2", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-dapp": "4.2.2", + "@airgap/beacon-transport-matrix": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2", + "@airgap/beacon-utils": "4.2.2", + "@airgap/beacon-wallet": "4.2.2" } }, "packages/beacon-transport-matrix": { "name": "@airgap/beacon-transport-matrix", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "axios": "^1.6.2" } }, "packages/beacon-transport-postmessage": { "name": "@airgap/beacon-transport-postmessage", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1" + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2" } }, "packages/beacon-transport-walletconnect": { "name": "@airgap/beacon-transport-walletconnect", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "@walletconnect/sign-client": "2.11.2" } }, "packages/beacon-types": { "name": "@airgap/beacon-types", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { "@types/chrome": "0.0.246" @@ -25499,13 +25499,13 @@ }, "packages/beacon-ui": { "name": "@airgap/beacon-ui", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "@walletconnect/utils": "2.11.2", "qrcode-svg": "^1.1.0", "solid-js": "^1.7.11" @@ -25528,7 +25528,7 @@ }, "packages/beacon-utils": { "name": "@airgap/beacon-utils", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { "@stablelib/ed25519": "^1.0.3", @@ -25540,12 +25540,12 @@ }, "packages/beacon-wallet": { "name": "@airgap/beacon-wallet", - "version": "4.2.1", + "version": "4.2.2", "license": "ISC", "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-transport-matrix": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1" + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-transport-matrix": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2" } } } diff --git a/packages/beacon-blockchain-substrate/package.json b/packages/beacon-blockchain-substrate/package.json index 9aec6d23d..ea72f9a92 100644 --- a/packages/beacon-blockchain-substrate/package.json +++ b/packages/beacon-blockchain-substrate/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-blockchain-substrate", - "version": "4.2.1", + "version": "4.2.2", "description": "This package adds support for `substrate` based blockchains. It can be used in combination with the `@airgap/beacon-dapp` or `@airgap/beacon-wallet` packages.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -34,7 +34,7 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } } diff --git a/packages/beacon-blockchain-tezos-sapling/package.json b/packages/beacon-blockchain-tezos-sapling/package.json index 4ae7c7f86..7c681836d 100644 --- a/packages/beacon-blockchain-tezos-sapling/package.json +++ b/packages/beacon-blockchain-tezos-sapling/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-blockchain-tezos-sapling", - "version": "4.2.1", + "version": "4.2.2", "description": "This package adds support for `tezos-sapling`, the sapling integration on the Tezos blockchain. It can be used in combination with the `@airgap/beacon-dapp` or `@airgap/beacon-wallet` packages.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -34,7 +34,7 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } } diff --git a/packages/beacon-blockchain-tezos/package.json b/packages/beacon-blockchain-tezos/package.json index bc94739da..4c10ef3e5 100644 --- a/packages/beacon-blockchain-tezos/package.json +++ b/packages/beacon-blockchain-tezos/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-blockchain-tezos", - "version": "4.2.1", + "version": "4.2.2", "description": "This package adds support for the `tezos` blockchain. It can be used in combination with the `@airgap/beacon-dapp` or `@airgap/beacon-wallet` packages.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -34,7 +34,7 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } } diff --git a/packages/beacon-core/package.json b/packages/beacon-core/package.json index 3559f088d..c4bcd8b1b 100644 --- a/packages/beacon-core/package.json +++ b/packages/beacon-core/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-core", - "version": "4.2.1", + "version": "4.2.2", "description": "This package contains internal methods that are used by both the dApp and wallet client.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -34,8 +34,8 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "@stablelib/ed25519": "^1.0.3", "@stablelib/nacl": "^1.0.4", "@stablelib/utf8": "^1.0.1", diff --git a/packages/beacon-core/src/constants.ts b/packages/beacon-core/src/constants.ts index 2696e1e02..8aef4d515 100644 --- a/packages/beacon-core/src/constants.ts +++ b/packages/beacon-core/src/constants.ts @@ -1,4 +1,4 @@ -export const SDK_VERSION: string = '4.2.1' +export const SDK_VERSION: string = '4.2.2' export const BEACON_VERSION: string = '3' export const NOTIFICATION_ORACLE_URL: string = diff --git a/packages/beacon-dapp/package.json b/packages/beacon-dapp/package.json index 81199f85e..9b9718afd 100644 --- a/packages/beacon-dapp/package.json +++ b/packages/beacon-dapp/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-dapp", - "version": "4.2.1", + "version": "4.2.2", "description": "Use this package on your dApp to instanciate a DAppClient object and communicate to wallets.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -35,10 +35,10 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-transport-matrix": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1", - "@airgap/beacon-transport-walletconnect": "4.2.1", - "@airgap/beacon-ui": "4.2.1" + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-transport-matrix": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2", + "@airgap/beacon-transport-walletconnect": "4.2.2", + "@airgap/beacon-ui": "4.2.2" } } diff --git a/packages/beacon-sdk/package.json b/packages/beacon-sdk/package.json index b848d3daa..5dfe31337 100644 --- a/packages/beacon-sdk/package.json +++ b/packages/beacon-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-sdk", - "version": "4.2.1", + "version": "4.2.2", "description": "The `beacon-sdk` simplifies and abstracts the communication between dApps and wallets over different transport layers.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -35,15 +35,15 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-blockchain-substrate": "4.2.1", - "@airgap/beacon-blockchain-tezos": "4.2.1", - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-dapp": "4.2.1", - "@airgap/beacon-transport-matrix": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-ui": "4.2.1", - "@airgap/beacon-utils": "4.2.1", - "@airgap/beacon-wallet": "4.2.1" + "@airgap/beacon-blockchain-substrate": "4.2.2", + "@airgap/beacon-blockchain-tezos": "4.2.2", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-dapp": "4.2.2", + "@airgap/beacon-transport-matrix": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-ui": "4.2.2", + "@airgap/beacon-utils": "4.2.2", + "@airgap/beacon-wallet": "4.2.2" } } diff --git a/packages/beacon-transport-matrix/package.json b/packages/beacon-transport-matrix/package.json index 9e95ba233..31799b77e 100644 --- a/packages/beacon-transport-matrix/package.json +++ b/packages/beacon-transport-matrix/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-transport-matrix", - "version": "4.2.1", + "version": "4.2.2", "description": "This package contains methods to facilitate communication over the Beacon network, a decentralised P2P network that is based on the matrix protocol.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -34,8 +34,8 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "axios": "^1.6.2" } } diff --git a/packages/beacon-transport-postmessage/package.json b/packages/beacon-transport-postmessage/package.json index cf3f1a7a2..1d110c278 100644 --- a/packages/beacon-transport-postmessage/package.json +++ b/packages/beacon-transport-postmessage/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-transport-postmessage", - "version": "4.2.1", + "version": "4.2.2", "description": "This package contains methods to facilitate communication over the postmessage interface of the browser to talk to browser extensions.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -34,8 +34,8 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1" + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2" } } diff --git a/packages/beacon-transport-walletconnect/package.json b/packages/beacon-transport-walletconnect/package.json index 93b53f6fa..f2e0293f5 100644 --- a/packages/beacon-transport-walletconnect/package.json +++ b/packages/beacon-transport-walletconnect/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-transport-walletconnect", - "version": "4.2.1", + "version": "4.2.2", "description": "This package contains methods to facilitate communication over the WalletConnect network.", "author": "Papers AG", "homepage": "https://walletbeacon.io", @@ -34,9 +34,9 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "@walletconnect/sign-client": "2.11.2" } } diff --git a/packages/beacon-types/package.json b/packages/beacon-types/package.json index 051e3f8c9..a32e9656f 100644 --- a/packages/beacon-types/package.json +++ b/packages/beacon-types/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-types", - "version": "4.2.1", + "version": "4.2.2", "description": "This package contains types that are used throughout the Beacon SDK.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", diff --git a/packages/beacon-ui/package.json b/packages/beacon-ui/package.json index a8fcffee7..60b32bf56 100644 --- a/packages/beacon-ui/package.json +++ b/packages/beacon-ui/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-ui", - "version": "4.2.1", + "version": "4.2.2", "description": "This package contains the UI part (alerts and toasts) of the Beacon SDK.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -34,10 +34,10 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1", - "@airgap/beacon-types": "4.2.1", - "@airgap/beacon-utils": "4.2.1", + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2", + "@airgap/beacon-types": "4.2.2", + "@airgap/beacon-utils": "4.2.2", "@walletconnect/utils": "2.11.2", "qrcode-svg": "^1.1.0", "solid-js": "^1.7.11" diff --git a/packages/beacon-utils/package.json b/packages/beacon-utils/package.json index d9aabcfee..77dd85924 100644 --- a/packages/beacon-utils/package.json +++ b/packages/beacon-utils/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-utils", - "version": "4.2.1", + "version": "4.2.2", "description": "This package contains utility functions that are used throughout the beacon-sdk", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", diff --git a/packages/beacon-wallet/package.json b/packages/beacon-wallet/package.json index 9849b68e9..1bd6c1285 100644 --- a/packages/beacon-wallet/package.json +++ b/packages/beacon-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@airgap/beacon-wallet", - "version": "4.2.1", + "version": "4.2.2", "description": "Use this package in your wallet to instanciate a WalletClient object and communicate to dApps.", "author": "Andreas Gassmann ", "homepage": "https://walletbeacon.io", @@ -35,8 +35,8 @@ "url": "https://github.com/airgap-it/beacon-sdk/issues" }, "dependencies": { - "@airgap/beacon-core": "4.2.1", - "@airgap/beacon-transport-matrix": "4.2.1", - "@airgap/beacon-transport-postmessage": "4.2.1" + "@airgap/beacon-core": "4.2.2", + "@airgap/beacon-transport-matrix": "4.2.2", + "@airgap/beacon-transport-postmessage": "4.2.2" } }