aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/popup-core.js
diff options
context:
space:
mode:
authorbitpshr <mail@bitpshr.net>2018-04-19 05:02:08 +0800
committerbitpshr <mail@bitpshr.net>2018-04-19 05:02:08 +0800
commitc9f83fe8bc60a87876242a2dfb5350fceafffca1 (patch)
tree2def53846824b39fde470931cf36ee67a8e4a03b /app/scripts/popup-core.js
parent7e21fc2aa780ccb4ffb2f642156385db22c47a52 (diff)
downloadtangerine-wallet-browser-c9f83fe8bc60a87876242a2dfb5350fceafffca1.tar
tangerine-wallet-browser-c9f83fe8bc60a87876242a2dfb5350fceafffca1.tar.gz
tangerine-wallet-browser-c9f83fe8bc60a87876242a2dfb5350fceafffca1.tar.bz2
tangerine-wallet-browser-c9f83fe8bc60a87876242a2dfb5350fceafffca1.tar.lz
tangerine-wallet-browser-c9f83fe8bc60a87876242a2dfb5350fceafffca1.tar.xz
tangerine-wallet-browser-c9f83fe8bc60a87876242a2dfb5350fceafffca1.tar.zst
tangerine-wallet-browser-c9f83fe8bc60a87876242a2dfb5350fceafffca1.zip
Add JSDoc to various background scripts
Diffstat (limited to 'app/scripts/popup-core.js')
-rw-r--r--app/scripts/popup-core.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/app/scripts/popup-core.js b/app/scripts/popup-core.js
index 2e4334bb1..5a5fa95f9 100644
--- a/app/scripts/popup-core.js
+++ b/app/scripts/popup-core.js
@@ -7,10 +7,14 @@ const launchMetamaskUi = require('../../ui')
const StreamProvider = require('web3-stream-provider')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
-
module.exports = initializePopup
-
+/**
+ * Asynchronously initializes the MetaMask popup UI
+ *
+ * @param {{ container: Element, connectionStream: any }} config Popup configuration object
+ * @param {Function} cb Called when initialization is comlete
+ */
function initializePopup ({ container, connectionStream }, cb) {
// setup app
async.waterfall([
@@ -19,6 +23,12 @@ function initializePopup ({ container, connectionStream }, cb) {
], cb)
}
+/**
+ * Establishes streamed connections to background scripts and a Web3 provider
+ *
+ * @param {any} connectionStream PortStream instance establishing a background connection
+ * @param {Function} cb Called when controller connection is established
+ */
function connectToAccountManager (connectionStream, cb) {
// setup communication with background
// setup multiplexing
@@ -28,6 +38,11 @@ function connectToAccountManager (connectionStream, cb) {
setupWeb3Connection(mx.createStream('provider'))
}
+/**
+ * Establishes a streamed connection to a Web3 provider
+ *
+ * @param {any} connectionStream PortStream instance establishing a background connection
+ */
function setupWeb3Connection (connectionStream) {
var providerStream = new StreamProvider()
providerStream.pipe(connectionStream).pipe(providerStream)
@@ -38,6 +53,12 @@ function setupWeb3Connection (connectionStream) {
global.eth = new Eth(providerStream)
}
+/**
+ * Establishes a streamed connection to the background account manager
+ *
+ * @param {any} connectionStream PortStream instance establishing a background connection
+ * @param {Function} cb Called when the remote account manager connection is established
+ */
function setupControllerConnection (connectionStream, cb) {
// this is a really sneaky way of adding EventEmitter api
// to a bi-directional dnode instance