From eec3f335484775674f477add577ff2b9db8b9d54 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Mon, 31 May 2021 14:46:05 +0300 Subject: [PATCH 1/3] refactor: simplify example aepp --- examples/browser/aepp/src/components/Home.vue | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/browser/aepp/src/components/Home.vue b/examples/browser/aepp/src/components/Home.vue index 680e2e43de..72c7239b54 100644 --- a/examples/browser/aepp/src/components/Home.vue +++ b/examples/browser/aepp/src/components/Home.vue @@ -291,12 +291,11 @@ await this.client.disconnectWallet() setTimeout(() => this.scanForWallets(), 1000) }, - async getReverseWindow() { + openReverseIframe() { const iframe = document.createElement('iframe') iframe.src = prompt('Enter wallet URL', 'http://localhost:9000') iframe.style.display = 'none' document.body.appendChild(iframe) - return iframe.contentWindow }, async connectToWallet (wallet) { await this.client.connectToWallet(await wallet.getConnection()) @@ -310,7 +309,7 @@ this.nodeInfoResponse = await errorAsField(this.client.getNodeInfo()) this.compilerVersionResponse = await errorAsField(this.client.getCompilerVersion()) }, - async scanForWallets () { + scanForWallets () { const handleWallets = async function ({ wallets, newWallet }) { newWallet = newWallet || Object.values(wallets)[0] if (confirm(`Do you want to connect to wallet ${newWallet.name}`)) { @@ -320,16 +319,16 @@ } } - const scannerConnection = await BrowserWindowMessageConnection({ + const scannerConnection = BrowserWindowMessageConnection({ connectionInfo: { id: 'spy' } }) - this.detector = await Detector({ connection: scannerConnection }) + this.detector = Detector({ connection: scannerConnection }) this.detector.scan(handleWallets.bind(this)) } }, async created () { // Open iframe with Wallet if run in top window - window !== window.parent || await this.getReverseWindow() + if (window === window.parent) this.openReverseIframe() this.client = await RpcAepp({ name: 'Simple Aepp', @@ -354,7 +353,7 @@ }) this.height = await this.client.height() // Start looking for wallets - await this.scanForWallets() + this.scanForWallets() } } From 4872eb979330f1676241dfefc434c0eeafcf5eab Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Mon, 31 May 2021 14:54:55 +0300 Subject: [PATCH 2/3] fix(examlple-aepp): open only when ready to accept connection --- examples/browser/aepp/src/components/Home.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/browser/aepp/src/components/Home.vue b/examples/browser/aepp/src/components/Home.vue index 72c7239b54..f6302fe1d1 100644 --- a/examples/browser/aepp/src/components/Home.vue +++ b/examples/browser/aepp/src/components/Home.vue @@ -327,9 +327,6 @@ } }, async created () { - // Open iframe with Wallet if run in top window - if (window === window.parent) this.openReverseIframe() - this.client = await RpcAepp({ name: 'Simple Aepp', nodes: [ @@ -354,6 +351,8 @@ this.height = await this.client.height() // Start looking for wallets this.scanForWallets() + // Open iframe with Wallet if run in top window + if (window === window.parent) this.openReverseIframe() } } From ae7e8238c378e0aa2095328577ef0ce2bd518e49 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Mon, 31 May 2021 14:55:55 +0300 Subject: [PATCH 3/3] fix: typo name of broadcast failed error generator --- src/utils/aepp-wallet-communication/rpc/wallet-rpc.js | 2 +- src/utils/aepp-wallet-communication/schema.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js b/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js index b7aa7807f0..2a5bcc9f82 100644 --- a/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +++ b/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js @@ -128,7 +128,7 @@ const REQUESTS = { const validationResult = await instance.unpackAndVerify(rawTx || tx) if (validationResult.validation.length) return { error: ERRORS.invalidTransaction(validationResult) } // Send broadcast failed error to aepp - return { error: ERRORS.broadcastFailde(e.message) } + return { error: ERRORS.broadcastFailed(e.message) } } throw e } diff --git a/src/utils/aepp-wallet-communication/schema.js b/src/utils/aepp-wallet-communication/schema.js index 2e73decbb8..bea20eb42f 100644 --- a/src/utils/aepp-wallet-communication/schema.js +++ b/src/utils/aepp-wallet-communication/schema.js @@ -62,7 +62,7 @@ export const RPC_STATUS = { } export const ERRORS = { - broadcastFailde: (error = {}) => ({ + broadcastFailed: (error = {}) => ({ code: 3, data: error, message: 'Broadcast failed'