Skip to content

Commit

Permalink
Merge pull request #1204 from aeternity/feature/update-aepp
Browse files Browse the repository at this point in the history
Update example aepp
  • Loading branch information
mradkov authored May 31, 2021
2 parents 3f09321 + ae7e823 commit ef3b505
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
16 changes: 7 additions & 9 deletions examples/browser/aepp/src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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}`)) {
Expand All @@ -320,17 +319,14 @@
}
}
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()
this.client = await RpcAepp({
name: 'Simple Aepp',
nodes: [
Expand All @@ -354,7 +350,9 @@
})
this.height = await this.client.height()
// Start looking for wallets
await this.scanForWallets()
this.scanForWallets()
// Open iframe with Wallet if run in top window
if (window === window.parent) this.openReverseIframe()
}
}
</script>
2 changes: 1 addition & 1 deletion src/utils/aepp-wallet-communication/rpc/wallet-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/aepp-wallet-communication/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const RPC_STATUS = {
}

export const ERRORS = {
broadcastFailde: (error = {}) => ({
broadcastFailed: (error = {}) => ({
code: 3,
data: error,
message: 'Broadcast failed'
Expand Down

0 comments on commit ef3b505

Please sign in to comment.