Skip to content

Commit

Permalink
feat(wallet-detector): allow to connect wallet to aepp between iframes
Browse files Browse the repository at this point in the history
By using message source in all cases.
  • Loading branch information
davidyuk committed Jul 22, 2020
1 parent 0e2c2a6 commit 3f74a05
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions es/utils/aepp-wallet-communication/wallet-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import AsyncInit from '../async-init'
import BrowserWindowMessageConnection from './connection/browser-window-message'
import { MESSAGE_DIRECTION, METHODS } from './schema'
import { isInIframe } from './helpers'

const wallets = {}

Expand All @@ -38,13 +37,6 @@ const getOrigin = ({ isExtension, origin }) => {
return origin
}

const getTarget = ({ isExtension, source }) => {
if (isExtension) {
return source
}
return isInIframe() ? window.parent : source
}

const handleDetection = (onDetected) => ({ method, params }, origin, source) => {
if (!method || !params) return
const ifExist = Object.prototype.hasOwnProperty.call(wallets, params.id)
Expand All @@ -55,12 +47,11 @@ const handleDetection = (onDetected) => ({ method, params }, origin, source) =>
// if detect extension wallet or page wallet
const isExtension = this.type === 'extension'
const origin = getOrigin({ isExtension, origin: this.origin })
const target = getTarget({ isExtension, source })
return BrowserWindowMessageConnection({
connectionInfo: this,
sendDirection: isExtension ? MESSAGE_DIRECTION.to_waellet : undefined,
receiveDirection: isExtension ? MESSAGE_DIRECTION.to_aepp : undefined,
target,
target: source,
origin
})
}
Expand Down

0 comments on commit 3f74a05

Please sign in to comment.