diff --git a/package-lock.json b/package-lock.json index eb0f590..3f7a29f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,23 +1,31 @@ { "name": "spire", - "version": "2.1.0", + "version": "2.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@airgap/beacon-sdk": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@airgap/beacon-sdk/-/beacon-sdk-2.0.0.tgz", - "integrity": "sha512-RvcuG7WDssKF3Qqks+pNpFDBGHv8Bk2376qMEr2jIQw4nWHtYkt+qYxRjBNj4PkwY9SzBc7JjIRykSX33cUfIA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@airgap/beacon-sdk/-/beacon-sdk-2.2.1.tgz", + "integrity": "sha512-kGPb/QJmGRay/4dEjSqQtCLNZPROuySSY2UImOYuN5kxbkeSyVirOI5jsgIvpGl09JHdz7Dguov7rO/pl4nPgg==", "requires": { "@types/chrome": "0.0.115", "@types/libsodium-wrappers": "0.7.7", - "axios": "0.19.2", + "axios": "0.21.1", "bignumber.js": "9.0.0", "bs58check": "2.1.2", "libsodium-wrappers": "0.7.8", "qrcode-generator": "1.4.4" }, "dependencies": { + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "libsodium": { "version": "0.7.8", "resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.8.tgz", @@ -8524,8 +8532,7 @@ "follow-redirects": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz", - "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==", - "dev": true + "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==" }, "for-in": { "version": "1.0.2", diff --git a/package.json b/package.json index b252abb..2d16bca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spire", - "version": "2.1.0", + "version": "2.2.0", "author": "AirGap", "homepage": "https://airgap.it/", "scripts": { @@ -25,7 +25,7 @@ }, "private": true, "dependencies": { - "@airgap/beacon-sdk": "2.0.0", + "@airgap/beacon-sdk": "2.2.1", "@airgap/coinlib-core": "0.10.0-beta.3", "@angular/common": "^11.0.3", "@angular/core": "^11.0.3", diff --git a/src/app/pages/add-wallet-connection/add-wallet-connection.page.ts b/src/app/pages/add-wallet-connection/add-wallet-connection.page.ts index d2b90fe..b02cf3d 100644 --- a/src/app/pages/add-wallet-connection/add-wallet-connection.page.ts +++ b/src/app/pages/add-wallet-connection/add-wallet-connection.page.ts @@ -9,7 +9,7 @@ import { ModalController, ToastController } from '@ionic/angular' export class AddWalletConnectionPage { public handshakeData: string | undefined - constructor(private readonly modalController: ModalController, private readonly toastController: ToastController) { } + constructor(private readonly modalController: ModalController, private readonly toastController: ToastController) {} public async dismiss(): Promise { await this.modalController.dismiss() diff --git a/src/app/pages/settings/settings.page.html b/src/app/pages/settings/settings.page.html index 07008aa..5b0585a 100644 --- a/src/app/pages/settings/settings.page.html +++ b/src/app/pages/settings/settings.page.html @@ -16,7 +16,8 @@ Active Network Mainnet - Carthagenet + Delphinet + Edonet Custom diff --git a/src/app/services/settings.service.ts b/src/app/services/settings.service.ts index 85409e5..f100e33 100644 --- a/src/app/services/settings.service.ts +++ b/src/app/services/settings.service.ts @@ -40,40 +40,40 @@ export class SettingsService { public async getProtocolForNetwork(network: Network): Promise { const rpcUrls: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'https://tezos-node.prod.gke.papers.tech', - [NetworkType.CARTHAGENET]: 'https://tezos-carthagenet-node.prod.gke.papers.tech', [NetworkType.DELPHINET]: 'https://tezos-delphinet-node.prod.gke.papers.tech', + [NetworkType.EDONET]: 'https://tezos-edonet-node.prod.gke.papers.tech', [NetworkType.CUSTOM]: '' } const apiUrls: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'https://tezos-mainnet-conseil.prod.gke.papers.tech', - [NetworkType.CARTHAGENET]: 'https://tezos-carthagenet-conseil.prod.gke.papers.tech', [NetworkType.DELPHINET]: 'https://tezos-delphinet-conseil.prod.gke.papers.tech', + [NetworkType.EDONET]: 'https://tezos-edonet-conseil.prod.gke.papers.tech', [NetworkType.CUSTOM]: '' } const names: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'Mainnet', - [NetworkType.CARTHAGENET]: 'Carthagenet', [NetworkType.DELPHINET]: 'Delphinet', + [NetworkType.EDONET]: 'Edonet', [NetworkType.CUSTOM]: 'Custom' } const airgapNetworks: { [key in NetworkType]: AirGapNetworkType } = { [NetworkType.MAINNET]: AirGapNetworkType.MAINNET, - [NetworkType.CARTHAGENET]: AirGapNetworkType.TESTNET, [NetworkType.DELPHINET]: AirGapNetworkType.TESTNET, + [NetworkType.EDONET]: AirGapNetworkType.TESTNET, [NetworkType.CUSTOM]: AirGapNetworkType.CUSTOM } const blockExplorers: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'https://tezblock.io', - [NetworkType.CARTHAGENET]: 'https://carthagenet.tezblock.io', [NetworkType.DELPHINET]: 'https://delphinet.tezblock.io', - [NetworkType.CUSTOM]: 'https://delphinet.tezblock.io' + [NetworkType.EDONET]: 'https://edonet.tezblock.io', + [NetworkType.CUSTOM]: 'https://edonet.tezblock.io' } const tezosNetworks: { [key in NetworkType]: TezosNetwork } = { [NetworkType.MAINNET]: TezosNetwork.MAINNET, - [NetworkType.CARTHAGENET]: TezosNetwork.DELPHINET, [NetworkType.DELPHINET]: TezosNetwork.DELPHINET, - [NetworkType.CUSTOM]: TezosNetwork.DELPHINET + [NetworkType.EDONET]: TezosNetwork.EDONET, + [NetworkType.CUSTOM]: TezosNetwork.EDONET } const name: string = names[network.type] diff --git a/src/extension/extension-client/ExtensionClient.ts b/src/extension/extension-client/ExtensionClient.ts index 50e4555..9032e3a 100644 --- a/src/extension/extension-client/ExtensionClient.ts +++ b/src/extension/extension-client/ExtensionClient.ts @@ -144,42 +144,42 @@ export class ExtensionClient extends BeaconClient { data: ExtensionMessage>, connectionContext: ConnectionContext ): Promise => { - logger.log('handleMessage', data, connectionContext) - const handler: ActionHandlerFunction = await new ActionMessageHandler().getHandler(data.payload.action) - - const p2pConnectedCallback = async (newPeer: ExtendedP2PPairingResponse): Promise => { - console.log('CONNECTED') - if (newPeer) { - const walletInfo: WalletInfo = { - address: '', - publicKey: '', - type: WalletType.P2P, - added: new Date().getTime(), - info: newPeer - } - await this.addWallet(walletInfo) - await this.storage.set('ACTIVE_WALLET' as any, walletInfo) + logger.log('handleMessage', data, connectionContext) + const handler: ActionHandlerFunction = await new ActionMessageHandler().getHandler(data.payload.action) + + const p2pConnectedCallback = async (newPeer: ExtendedP2PPairingResponse): Promise => { + console.log('CONNECTED') + if (newPeer) { + const walletInfo: WalletInfo = { + address: '', + publicKey: '', + type: WalletType.P2P, + added: new Date().getTime(), + info: newPeer } - - this.popupManager - .sendToActivePopup({ - target: ExtensionMessageTarget.EXTENSION, - sender: 'background', - payload: { beaconEvent: BeaconEvent.P2P_CHANNEL_CONNECT_SUCCESS } - }) - .catch(console.error) + await this.addWallet(walletInfo) + await this.storage.set('ACTIVE_WALLET' as any, walletInfo) } - await handler({ - data: data.payload, - sendResponse: connectionContext.extras ? connectionContext.extras.sendResponse : () => undefined, - client: this, - p2pTransport: this.p2pTransport, - p2pTransportConnectedCallback: p2pConnectedCallback, - storage: this.storage - }) + this.popupManager + .sendToActivePopup({ + target: ExtensionMessageTarget.EXTENSION, + sender: 'background', + payload: { beaconEvent: BeaconEvent.PAIR_SUCCESS } + }) + .catch(console.error) } + await handler({ + data: data.payload, + sendResponse: connectionContext.extras ? connectionContext.extras.sendResponse : () => undefined, + client: this, + p2pTransport: this.p2pTransport, + p2pTransportConnectedCallback: p2pConnectedCallback, + storage: this.storage + }) + } + public async addListener(listener: Function): Promise { this.listeners.push(listener) } @@ -307,9 +307,9 @@ export class ExtensionClient extends BeaconClient { const request: | { message: BeaconMessage; connectionContext: ConnectionContext } | undefined = this.pendingRequests.find( - (requestElement: { message: BeaconMessage; connectionContext: ConnectionContext }) => - requestElement.message.id === response.id - ) + (requestElement: { message: BeaconMessage; connectionContext: ConnectionContext }) => + requestElement.message.id === response.id + ) if (!request) { throw new Error('Matching request not found') } @@ -321,13 +321,7 @@ export class ExtensionClient extends BeaconClient { } const errorData = (beaconMessage as any).errorData as unknown - if ( - errorData && - ( - !Array.isArray(errorData) || - !errorData.every((item) => Boolean(item.kind) && Boolean(item.id)) - ) - ) { + if (errorData && (!Array.isArray(errorData) || !errorData.every(item => Boolean(item.kind) && Boolean(item.id)))) { logger.warn( 'ErrorData provided is not in correct format. It needs to be an array of RPC errors. It will not be included in the message sent to the dApp' ) @@ -335,7 +329,7 @@ export class ExtensionClient extends BeaconClient { } // TODO: Remove v1 compatibility in later version - ; (beaconMessage as any).beaconId = beaconMessage.senderId + ;(beaconMessage as any).beaconId = beaconMessage.senderId const serialized = await new Serializer().serialize(beaconMessage) diff --git a/src/extension/extension-client/beacon-message-handler/operation-request-handler.ts b/src/extension/extension-client/beacon-message-handler/operation-request-handler.ts index 8df36d5..9f27198 100644 --- a/src/extension/extension-client/beacon-message-handler/operation-request-handler.ts +++ b/src/extension/extension-client/beacon-message-handler/operation-request-handler.ts @@ -37,14 +37,14 @@ export const operationRequestHandler: (client: ExtensionClient, logger: Logger) const sendError: (error: Error, errorType: BeaconErrorType) => Promise = async ( error: Error, - errorType: BeaconErrorType, + errorType: BeaconErrorType ): Promise => { logger.log('operationRequestHandler', 'error ', error) responseInput = { id: operationRequest.id, type: BeaconMessageType.OperationResponse, errorType, - errorData: (error as any as AxiosResponse).data + errorData: ((error as any) as AxiosResponse).data } as any const response: OperationResponse = { diff --git a/src/extension/extension-client/beacon-message-handler/permission-request-handler.ts b/src/extension/extension-client/beacon-message-handler/permission-request-handler.ts index b042215..1a677c8 100644 --- a/src/extension/extension-client/beacon-message-handler/permission-request-handler.ts +++ b/src/extension/extension-client/beacon-message-handler/permission-request-handler.ts @@ -43,6 +43,10 @@ export const permissionRequestHandler: (client: ExtensionClient, logger: Logger) const response: PermissionResponse = { senderId: await getSenderId(await client.beaconId), + appMetadata: { + senderId: await getSenderId(await client.beaconId), + name: await client.name + }, version: BEACON_VERSION, ...responseInput } diff --git a/src/extension/extension-client/chrome-message-transport/ChromeMessageTransport.ts b/src/extension/extension-client/chrome-message-transport/ChromeMessageTransport.ts index 7b3672f..3f4bed8 100644 --- a/src/extension/extension-client/chrome-message-transport/ChromeMessageTransport.ts +++ b/src/extension/extension-client/chrome-message-transport/ChromeMessageTransport.ts @@ -32,7 +32,7 @@ export class ChromeMessageTransport< public readonly type: TransportType = TransportType.CHROME_MESSAGE constructor(name: string, keyPair: sodium.KeyPair, storage: Storage, storageKey: K) { - super(name, new ChromeMessageClient(name, keyPair, false), new PeerManager(storage, storageKey)) + super(name, new ChromeMessageClient(name, keyPair), new PeerManager(storage, storageKey)) this.init().catch(error => console.error(error)) this.connect().catch(error => console.error(error)) } diff --git a/src/extension/extension-client/message-handler/ToExtensionMessageHandler.ts b/src/extension/extension-client/message-handler/ToExtensionMessageHandler.ts index 40c8cc5..e72d661 100644 --- a/src/extension/extension-client/message-handler/ToExtensionMessageHandler.ts +++ b/src/extension/extension-client/message-handler/ToExtensionMessageHandler.ts @@ -78,7 +78,9 @@ export class ToExtensionMessageHandler extends MessageHandler { ): Promise => { logger.log('handle', 'error', error) - const errorData = (error as any as AxiosResponse).data.data || (error as any as AxiosResponse).data + const errorData = ((error as any) as AxiosResponse).data + ? ((error as any) as AxiosResponse).data.data || ((error as any) as AxiosResponse).data + : ((error as any) as AxiosResponse).data const responseInput = { id: deserialized.id, @@ -114,7 +116,7 @@ export class ToExtensionMessageHandler extends MessageHandler { if (deserialized.type === BeaconMessageType.OperationRequest) { // Intercept Operation request and enrich it with information - ; (async (): Promise => { + ;(async (): Promise => { const operationRequest: OperationRequestOutput = enriched.res as OperationRequestOutput const wallet: WalletInfo | undefined = await this.client.getWalletByAddress(operationRequest.sourceAddress) diff --git a/src/extension/extension-client/utils.ts b/src/extension/extension-client/utils.ts index 7047ebf..a03f7eb 100644 --- a/src/extension/extension-client/utils.ts +++ b/src/extension/extension-client/utils.ts @@ -14,14 +14,14 @@ export const getRpcUrlForNetwork: (network: Network) => Promise<{ rpcUrl: string ): Promise<{ rpcUrl: string; apiUrl: string }> => { const rpcUrls: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'https://tezos-node.prod.gke.papers.tech', - [NetworkType.CARTHAGENET]: 'https://tezos-carthagenet-node.prod.gke.papers.tech', [NetworkType.DELPHINET]: 'https://tezos-delphinet-node.prod.gke.papers.tech', + [NetworkType.EDONET]: 'https://tezos-edonet-node.prod.gke.papers.tech', [NetworkType.CUSTOM]: '' } const apiUrls: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'https://tezos-mainnet-conseil.prod.gke.papers.tech', - [NetworkType.CARTHAGENET]: 'https://tezos-carthagenet-conseil.prod.gke.papers.tech', [NetworkType.DELPHINET]: 'https://tezos-delphinet-conseil.prod.gke.papers.tech', + [NetworkType.EDONET]: 'https://tezos-edonet-conseil.prod.gke.papers.tech', [NetworkType.CUSTOM]: '' } @@ -38,27 +38,27 @@ export const getProtocolForNetwork: (network: Network) => Promise const names: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'Mainnet', - [NetworkType.CARTHAGENET]: 'Carthagenet', [NetworkType.DELPHINET]: 'Delphinet', + [NetworkType.EDONET]: 'Edonet', [NetworkType.CUSTOM]: 'Custom' } const airgapNetworks: { [key in NetworkType]: AirGapNetworkType } = { [NetworkType.MAINNET]: AirGapNetworkType.MAINNET, - [NetworkType.CARTHAGENET]: AirGapNetworkType.TESTNET, [NetworkType.DELPHINET]: AirGapNetworkType.TESTNET, + [NetworkType.EDONET]: AirGapNetworkType.TESTNET, [NetworkType.CUSTOM]: AirGapNetworkType.CUSTOM } const blockExplorers: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'https://tezblock.io', - [NetworkType.CARTHAGENET]: 'https://carthagenet.tezblock.io', [NetworkType.DELPHINET]: 'https://delphinet.tezblock.io', - [NetworkType.CUSTOM]: 'https://delphinet.tezblock.io' + [NetworkType.EDONET]: 'https://edonet.tezblock.io', + [NetworkType.CUSTOM]: 'https://edonet.tezblock.io' } const tezosNetworks: { [key in NetworkType]: TezosNetwork } = { [NetworkType.MAINNET]: TezosNetwork.MAINNET, - [NetworkType.CARTHAGENET]: TezosNetwork.DELPHINET, [NetworkType.DELPHINET]: TezosNetwork.DELPHINET, - [NetworkType.CUSTOM]: TezosNetwork.DELPHINET + [NetworkType.EDONET]: TezosNetwork.EDONET, + [NetworkType.CUSTOM]: TezosNetwork.EDONET } const name: string = names[network.type] @@ -86,8 +86,8 @@ export const getTezblockLinkForNetwork: (network: Network | undefined) => Promis const urls: { [key in NetworkType]: string } = { [NetworkType.MAINNET]: 'https://tezblock.io/account/', - [NetworkType.CARTHAGENET]: 'https://carthagenet.tezblock.io/account/', [NetworkType.DELPHINET]: 'https://delphinet.tezblock.io/account/', + [NetworkType.EDONET]: 'https://edonet.tezblock.io/account/', [NetworkType.CUSTOM]: 'http://localhost:8100/account/' } const url: string = urls[network ? network.type : NetworkType.MAINNET] diff --git a/src/manifest.json b/src/manifest.json index e199a3c..bfaa5fc 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Spire", - "version": "2.1.0", + "version": "2.2.0", "description": "Spire allows you to interact with Tezos dApps that support the Beacon SDK.", "icons": { "16": "assets/icon/spire-logo-16px.png",