1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Clean up JSDoc for background scripts

This commit is contained in:
bitpshr 2018-04-19 15:12:04 -04:00
parent 9c7eafc86f
commit 8636f3bae5
7 changed files with 32 additions and 24 deletions

View File

@ -34,8 +34,8 @@ global.METAMASK_DEBUG = process.env.METAMASK_DEBUG
/** /**
* @typedef {Object} EnumConfig * @typedef {Object} EnumConfig
* @property {string} DEFAULT_RPC Default network provider URL * @property {string} DEFAULT_RPC Default network provider URL
* @property {string} OLD_UI_NETWORK_TYPE * @property {string} OLD_UI_NETWORK_TYPE Network associated with old UI
* @property {string} BETA_UI_NETWORK_TYPE * @property {string} BETA_UI_NETWORK_TYPE Network associated with new UI
*/ */
/** /**

View File

@ -112,7 +112,7 @@ function logStreamDisconnectWarning (remoteLabel, err) {
/** /**
* Determines if Web3 should be injected * Determines if Web3 should be injected
* *
* @returns {boolean} True of Web3 should be injected * @returns {boolean} {@code true} if Web3 should be injected
*/ */
function shouldInjectWeb3 () { function shouldInjectWeb3 () {
return doctypeCheck() && suffixCheck() return doctypeCheck() && suffixCheck()
@ -122,7 +122,7 @@ function shouldInjectWeb3 () {
/** /**
* Checks the doctype of the current document if it exists * Checks the doctype of the current document if it exists
* *
* @returns {boolean} True if the doctype is html or if none exists * @returns {boolean} {@code true} if the doctype is html or if none exists
*/ */
function doctypeCheck () { function doctypeCheck () {
const doctype = window.document.doctype const doctype = window.document.doctype
@ -136,7 +136,7 @@ function doctypeCheck () {
/** /**
* Checks the current document extension * Checks the current document extension
* *
* @returns {boolean} True if the current extension is not prohibited * @returns {boolean} {@code true} if the current extension is not prohibited
*/ */
function suffixCheck () { function suffixCheck () {
var prohibitedTypes = ['xml', 'pdf'] var prohibitedTypes = ['xml', 'pdf']
@ -154,7 +154,7 @@ function suffixCheck () {
/** /**
* Checks the documentElement of the current document * Checks the documentElement of the current document
* *
* @returns {boolean} True if the documentElement is an html node or if none exists * @returns {boolean} {@code true} if the documentElement is an html node or if none exists
*/ */
function documentElementCheck () { function documentElementCheck () {
var documentElement = document.documentElement.nodeName var documentElement = document.documentElement.nodeName
@ -167,7 +167,7 @@ function documentElementCheck () {
/** /**
* Checks if the current domain is blacklisted * Checks if the current domain is blacklisted
* *
* @returns {boolean} True if the current domain is blacklisted * @returns {boolean} {@code true} if the current domain is blacklisted
*/ */
function blacklistedDomainCheck () { function blacklistedDomainCheck () {
var blacklistedDomains = [ var blacklistedDomains = [

View File

@ -2,6 +2,14 @@ const ObservableStore = require('obs-store')
const extend = require('xtend') const extend = require('xtend')
const BalanceController = require('./balance') const BalanceController = require('./balance')
/**
* @typedef {Object} ComputedBalancesOptions
* @property {Object} accountTracker Account tracker store reference
* @property {Object} txController Token controller reference
* @property {Object} blockTracker Block tracker reference
* @property {Object} initState Initial state to populate this internal store with
*/
/** /**
* Background controller responsible for syncing * Background controller responsible for syncing
* and computing ETH balances for all accounts * and computing ETH balances for all accounts
@ -10,7 +18,7 @@ class ComputedbalancesController {
/** /**
* Creates a new controller instance * Creates a new controller instance
* *
* @param {Object} [opts] Controller configuration parameters * @param {ComputedBalancesOptions} [opts] Controller configuration parameters
*/ */
constructor (opts = {}) { constructor (opts = {}) {
const { accountTracker, txController, blockTracker } = opts const { accountTracker, txController, blockTracker } = opts
@ -52,7 +60,7 @@ class ComputedbalancesController {
* Uses current account state to sync and track all * Uses current account state to sync and track all
* addresses associated with the current account * addresses associated with the current account
* *
* @param {Object} store Account tracking state * @param {{ accounts: Object }} store Account tracking state
*/ */
syncAllAccountsFromStore (store) { syncAllAccountsFromStore (store) {
const upstream = Object.keys(store.accounts) const upstream = Object.keys(store.accounts)

View File

@ -7,11 +7,11 @@ const Unibabel = require('browserify-unibabel')
*/ */
class EdgeEncryptor { class EdgeEncryptor {
/** /**
* Encrypts an arbitrary JavaScript object to ciphertext * Encrypts an arbitrary object to ciphertext
* *
* @param {string} password Used to generate a key to encrypt the data * @param {string} password Used to generate a key to encrypt the data
* @param {Object} dataObject Data to encrypt * @param {Object} dataObject Data to encrypt
* @returns {Promise<Object>} Promise resolving to an object with ciphertext * @returns {Promise<string>} Promise resolving to an object with ciphertext
*/ */
encrypt (password, dataObject) { encrypt (password, dataObject) {
var salt = this._generateSalt() var salt = this._generateSalt()
@ -34,11 +34,11 @@ class EdgeEncryptor {
} }
/** /**
* Decrypts an arbitrary JavaScript object from ciphertext * Decrypts an arbitrary object from ciphertext
* *
* @param {string} password Used to generate a key to decrypt the data * @param {string} password Used to generate a key to decrypt the data
* @param {string} text Ciphertext of an encrypted JavaScript object * @param {string} text Ciphertext of an encrypted object
* @returns {Promise<Object>} Promise resolving to copy of decrypted JavaScript object * @returns {Promise<Object>} Promise resolving to copy of decrypted object
*/ */
decrypt (password, text) { decrypt (password, text) {
const payload = JSON.parse(text) const payload = JSON.parse(text)
@ -67,7 +67,7 @@ class EdgeEncryptor {
* *
* @private * @private
* @param {string} password Password used to unlock a cryptographic key * @param {string} password Password used to unlock a cryptographic key
* @param {string} salt Random base-64 data * @param {string} salt Random base64 data
* @returns {Promise<Object>} Promise resolving to a derived key * @returns {Promise<Object>} Promise resolving to a derived key
*/ */
_keyFromPassword (password, salt) { _keyFromPassword (password, salt) {
@ -81,10 +81,10 @@ class EdgeEncryptor {
} }
/** /**
* Generates random base-64 encoded data * Generates random base64 encoded data
* *
* @private * @private
* @returns {string} Randomized base-64 encoded data * @returns {string} Randomized base64 encoded data
*/ */
_generateSalt (byteCount = 32) { _generateSalt (byteCount = 32) {
var view = new Uint8Array(byteCount) var view = new Uint8Array(byteCount)

View File

@ -8,7 +8,7 @@ inherits(PortDuplexStream, Duplex)
/** /**
* Creates a stream that's both readable and writable. * Creates a stream that's both readable and writable.
* The stream supports arbitrary JavaScript objects. * The stream supports arbitrary objects.
* *
* @class * @class
* @param {Object} port Remote Port object * @param {Object} port Remote Port object
@ -60,7 +60,7 @@ PortDuplexStream.prototype._read = noop
* this writable stream. * this writable stream.
* *
* @private * @private
* @param {*} msg Arbitrary JavaScript object to write * @param {*} msg Arbitrary object to write
* @param {string} encoding Encoding to use when writing payload * @param {string} encoding Encoding to use when writing payload
* @param {Function} cb Called when writing is complete or an error occurs * @param {Function} cb Called when writing is complete or an error occurs
*/ */

View File

@ -2,7 +2,7 @@
module.exports = setupMetamaskMeshMetrics module.exports = setupMetamaskMeshMetrics
/** /**
* Injects an iframe into the curerent document for testing * Injects an iframe into the current document for testing
*/ */
function setupMetamaskMeshMetrics() { function setupMetamaskMeshMetrics() {
const testingContainer = document.createElement('iframe') const testingContainer = document.createElement('iframe')

View File

@ -13,7 +13,7 @@ module.exports = initializePopup
* Asynchronously initializes the MetaMask popup UI * Asynchronously initializes the MetaMask popup UI
* *
* @param {{ container: Element, connectionStream: * }} config Popup configuration object * @param {{ container: Element, connectionStream: * }} config Popup configuration object
* @param {Function} cb Called when initialization is comlete * @param {Function} cb Called when initialization is complete
*/ */
function initializePopup ({ container, connectionStream }, cb) { function initializePopup ({ container, connectionStream }, cb) {
// setup app // setup app
@ -26,7 +26,7 @@ function initializePopup ({ container, connectionStream }, cb) {
/** /**
* Establishes streamed connections to background scripts and a Web3 provider * Establishes streamed connections to background scripts and a Web3 provider
* *
* @param {*} connectionStream PortStream instance establishing a background connection * @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection
* @param {Function} cb Called when controller connection is established * @param {Function} cb Called when controller connection is established
*/ */
function connectToAccountManager (connectionStream, cb) { function connectToAccountManager (connectionStream, cb) {
@ -41,7 +41,7 @@ function connectToAccountManager (connectionStream, cb) {
/** /**
* Establishes a streamed connection to a Web3 provider * Establishes a streamed connection to a Web3 provider
* *
* @param {*} connectionStream PortStream instance establishing a background connection * @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection
*/ */
function setupWeb3Connection (connectionStream) { function setupWeb3Connection (connectionStream) {
var providerStream = new StreamProvider() var providerStream = new StreamProvider()
@ -56,7 +56,7 @@ function setupWeb3Connection (connectionStream) {
/** /**
* Establishes a streamed connection to the background account manager * Establishes a streamed connection to the background account manager
* *
* @param {*} connectionStream PortStream instance establishing a background connection * @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection
* @param {Function} cb Called when the remote account manager connection is established * @param {Function} cb Called when the remote account manager connection is established
*/ */
function setupControllerConnection (connectionStream, cb) { function setupControllerConnection (connectionStream, cb) {