Skip to content

Commit

Permalink
fix(AEX-2): Fix firefox compatibility issue (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
nduchak committed Jan 29, 2020
1 parent 0f53991 commit 2e16e10
Show file tree
Hide file tree
Showing 3 changed files with 13,677 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function disconnect () {
* @return {void}
*/
function connect (onMessage, onDisconnect) {
if (this.port.onMessage.hasListeners()) throw new Error('You already connected')
if (typeof this.port.onMessage.hasListeners === 'function' && this.port.onMessage.hasListeners()) throw new Error('You already connected')
this.port.onMessage.addListener((msg, source) => {
if (this.debug) console.log('Receive message: ', msg)
onMessage(msg, source)
Expand Down
65 changes: 42 additions & 23 deletions examples/browser/extension/src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,54 @@ async function init () {
accounts,
// Hook for sdk registration
onConnection (aepp, action) {
if (confirm(`Client ${aepp.info.name} with id ${aepp.id} want to connect`)) {
action.accept()
} else {
action.deny()
}
// if (confirm(`Client ${aepp.info.name} with id ${aepp.id} want to connect`)) {
// action.accept()
// } else {
// action.deny()
// }
console.log('connection request')
console.log(aepp)
console.log(action)
console.log('------------------------')
action.accept()
},
onDisconnect (masg, client) {
debugger
onDisconnect (msg, client) {
console.log('Disconnect client: ', client)
},
onSubscription (aepp, action) {
if (confirm(`Aepp ${aepp.info.name} with id ${aepp.id} want to subscribe for accounts`)) {
action.accept()
} else {
action.deny()
}
// if (confirm(`Aepp ${aepp.info.name} with id ${aepp.id} want to subscribe for accounts`)) {
// action.accept()
// } else {
// action.deny()
// }
console.log('sign transaction')
console.log(aepp)
console.log(action)
console.log('------------------------')
action.accept()
},
onSign (aepp, action) {
if (confirm(`Aepp ${aepp.info.name} with id ${aepp.id} want to sign tx ${action.params.tx}`)) {
action.accept()
} else {
action.deny()
}
// if (confirm(`Aepp ${aepp.info.name} with id ${aepp.id} want to sign tx ${action.params.tx}`)) {
// action.accept()
// } else {
// action.deny()
// }
console.log('sign transaction')
console.log(aepp)
console.log(action)
console.log('------------------------')
action.accept()
},
onAskAccounts (aepp, { accept, deny }) {
if (confirm(`Client ${aepp.info.name} with id ${aepp.id} want to get accounts`)) {
accept()
} else {
deny()
}
onAskAccounts (aepp, action) {
// if (confirm(`Client ${aepp.info.name} with id ${aepp.id} want to get accounts`)) {
// accept()
// } else {
// deny()
// }
console.log(aepp)
console.log(action)
console.log('------------------------')
action.accept()
}
}).then(wallet => {
chrome.runtime.onConnect.addListener(async function (port) {
Expand Down
Loading

0 comments on commit 2e16e10

Please sign in to comment.