parent
c9f83fe8bc
commit
6dbdc87713
@ -0,0 +1,541 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>ComposableObservableStore - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">ComposableObservableStore</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
|
||||
<header> |
||||
|
||||
<h2> |
||||
ComposableObservableStore |
||||
</h2> |
||||
|
||||
<div class="class-description"><p>An ObservableStore that can composes a flat |
||||
structure of child stores based on configuration</p></div> |
||||
|
||||
|
||||
</header> |
||||
|
||||
<article> |
||||
<div class="container-overview"> |
||||
|
||||
|
||||
|
||||
|
||||
<h2>Constructor</h2> |
||||
|
||||
|
||||
<h4 class="name" id="ComposableObservableStore"><span class="type-signature"></span>new ComposableObservableStore<span class="signature">(initState<span class="signature-attributes">opt</span>, config<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="lib_ComposableObservableStore.js.html">lib/ComposableObservableStore.js</a>, <a href="lib_ComposableObservableStore.js.html#line7">line 7</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Create a new store</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5> |
||||
|
||||
|
||||
<table class="params"> |
||||
<thead> |
||||
<tr> |
||||
|
||||
<th>Name</th> |
||||
|
||||
|
||||
<th>Type</th> |
||||
|
||||
|
||||
<th>Attributes</th> |
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th> |
||||
</tr> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>initState</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
<td class="attributes"> |
||||
|
||||
<optional><br> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>The initial store state</p></td> |
||||
</tr> |
||||
|
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>config</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
<td class="attributes"> |
||||
|
||||
<optional><br> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Map of internal state keys to child stores</p></td> |
||||
</tr> |
||||
|
||||
|
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="getFlatState"><span class="type-signature"></span>getFlatState<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="lib_ComposableObservableStore.js.html">lib/ComposableObservableStore.js</a>, <a href="lib_ComposableObservableStore.js.html#line40">line 40</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Merges all child store state into a single object rather than |
||||
returning an object keyed by child store class name</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5> |
||||
|
||||
|
||||
<div class="param-desc"> |
||||
<ul> |
||||
<li>Object containing merged child store state</li> |
||||
</ul> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<dl class="param-type"> |
||||
<dt> |
||||
Type |
||||
</dt> |
||||
<dd> |
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
</dd> |
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="updateStructure"><span class="type-signature"></span>updateStructure<span class="signature">(config<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="lib_ComposableObservableStore.js.html">lib/ComposableObservableStore.js</a>, <a href="lib_ComposableObservableStore.js.html#line24">line 24</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Composes a new internal store subscription structure</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5> |
||||
|
||||
|
||||
<table class="params"> |
||||
<thead> |
||||
<tr> |
||||
|
||||
<th>Name</th> |
||||
|
||||
|
||||
<th>Type</th> |
||||
|
||||
|
||||
<th>Attributes</th> |
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th> |
||||
</tr> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>config</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
<td class="attributes"> |
||||
|
||||
<optional><br> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Map of internal state keys to child stores</p></td> |
||||
</tr> |
||||
|
||||
|
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article> |
||||
|
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,545 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>EdgeEncryptor - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">EdgeEncryptor</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
|
||||
<header> |
||||
|
||||
<h2> |
||||
EdgeEncryptor |
||||
</h2> |
||||
|
||||
<div class="class-description"><p>A Microsoft Edge-specific encryption class that exposes |
||||
the interface expected by eth-keykeyring-controller</p></div> |
||||
|
||||
|
||||
</header> |
||||
|
||||
<article> |
||||
<div class="container-overview"> |
||||
|
||||
|
||||
|
||||
|
||||
<h2>Constructor</h2> |
||||
|
||||
|
||||
<h4 class="name" id="EdgeEncryptor"><span class="type-signature"></span>new EdgeEncryptor<span class="signature">()</span><span class="type-signature"></span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="edge-encryptor.js.html">edge-encryptor.js</a>, <a href="edge-encryptor.js.html#line8">line 8</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="decrypt"><span class="type-signature"></span>decrypt<span class="signature">(password, text)</span><span class="type-signature"> → {Promise.<Object>}</span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="edge-encryptor.js.html">edge-encryptor.js</a>, <a href="edge-encryptor.js.html#line43">line 43</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Decrypts an arbitrary JavaScript object from cypher text</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5> |
||||
|
||||
|
||||
<table class="params"> |
||||
<thead> |
||||
<tr> |
||||
|
||||
<th>Name</th> |
||||
|
||||
|
||||
<th>Type</th> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th> |
||||
</tr> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>password</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">string</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Password used to unlock a cryptographic key</p></td> |
||||
</tr> |
||||
|
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>text</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">string</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Cypher text of an encrypted JavaScript object</p></td> |
||||
</tr> |
||||
|
||||
|
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5> |
||||
|
||||
|
||||
<div class="param-desc"> |
||||
<p>Promise resolving to copy of decrypted JavaScript object</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<dl class="param-type"> |
||||
<dt> |
||||
Type |
||||
</dt> |
||||
<dd> |
||||
|
||||
<span class="param-type">Promise.<Object></span> |
||||
|
||||
|
||||
</dd> |
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="encrypt"><span class="type-signature"></span>encrypt<span class="signature">(password, dataObject)</span><span class="type-signature"> → {Object}</span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="edge-encryptor.js.html">edge-encryptor.js</a>, <a href="edge-encryptor.js.html#line16">line 16</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Encrypts an arbitrary JavaScript object to cypher text</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5> |
||||
|
||||
|
||||
<table class="params"> |
||||
<thead> |
||||
<tr> |
||||
|
||||
<th>Name</th> |
||||
|
||||
|
||||
<th>Type</th> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th> |
||||
</tr> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>password</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">string</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Password used to unlock a cryptographic key</p></td> |
||||
</tr> |
||||
|
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>dataObject</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Data to encrypt</p></td> |
||||
</tr> |
||||
|
||||
|
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5> |
||||
|
||||
|
||||
<div class="param-desc"> |
||||
<p>Object containing cypher text, generation vectors, and salt</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<dl class="param-type"> |
||||
<dt> |
||||
Type |
||||
</dt> |
||||
<dd> |
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
</dd> |
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article> |
||||
|
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,682 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>TokenRatesController - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">TokenRatesController</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
|
||||
<header> |
||||
|
||||
<h2> |
||||
TokenRatesController |
||||
</h2> |
||||
|
||||
<div class="class-description"><p>A controller that polls for token exchange |
||||
rates based on a user's current token list</p></div> |
||||
|
||||
|
||||
</header> |
||||
|
||||
<article> |
||||
<div class="container-overview"> |
||||
|
||||
|
||||
|
||||
|
||||
<h2>Constructor</h2> |
||||
|
||||
|
||||
<h4 class="name" id="TokenRatesController"><span class="type-signature"></span>new TokenRatesController<span class="signature">(config<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="controllers_token-rates.js.html">controllers/token-rates.js</a>, <a href="controllers_token-rates.js.html#line10">line 10</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Creates a TokenRatesController</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5> |
||||
|
||||
|
||||
<table class="params"> |
||||
<thead> |
||||
<tr> |
||||
|
||||
<th>Name</th> |
||||
|
||||
|
||||
<th>Type</th> |
||||
|
||||
|
||||
<th>Attributes</th> |
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th> |
||||
</tr> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>config</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
<td class="attributes"> |
||||
|
||||
<optional><br> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Options to configure controller</p></td> |
||||
</tr> |
||||
|
||||
|
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Members</h3> |
||||
|
||||
|
||||
|
||||
<h4 class="name" id="interval"><span class="type-signature"></span>interval<span class="type-signature"> :Number</span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="controllers_token-rates.js.html">controllers/token-rates.js</a>, <a href="controllers_token-rates.js.html#line51">line 51</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Type:</h5> |
||||
<ul> |
||||
<li> |
||||
|
||||
<span class="param-type">Number</span> |
||||
|
||||
|
||||
</li> |
||||
</ul> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="preferences"><span class="type-signature"></span>preferences<span class="type-signature"> :Object</span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="controllers_token-rates.js.html">controllers/token-rates.js</a>, <a href="controllers_token-rates.js.html#line60">line 60</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Type:</h5> |
||||
<ul> |
||||
<li> |
||||
|
||||
<span class="param-type">Object</span> |
||||
|
||||
|
||||
</li> |
||||
</ul> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="tokens"><span class="type-signature"></span>tokens<span class="type-signature"> :Array</span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="controllers_token-rates.js.html">controllers/token-rates.js</a>, <a href="controllers_token-rates.js.html#line71">line 71</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Type:</h5> |
||||
<ul> |
||||
<li> |
||||
|
||||
<span class="param-type">Array</span> |
||||
|
||||
|
||||
</li> |
||||
</ul> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="fetchExchangeRate"><span class="type-signature">(async) </span>fetchExchangeRate<span class="signature">(address)</span><span class="type-signature"></span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="controllers_token-rates.js.html">controllers/token-rates.js</a>, <a href="controllers_token-rates.js.html#line40">line 40</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Fetches a token exchange rate by address</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5> |
||||
|
||||
|
||||
<table class="params"> |
||||
<thead> |
||||
<tr> |
||||
|
||||
<th>Name</th> |
||||
|
||||
|
||||
<th>Type</th> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th> |
||||
</tr> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
|
||||
|
||||
<tr> |
||||
|
||||
<td class="name"><code>address</code></td> |
||||
|
||||
|
||||
<td class="type"> |
||||
|
||||
|
||||
<span class="param-type">String</span> |
||||
|
||||
|
||||
|
||||
</td> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"><p>Token contract address</p></td> |
||||
</tr> |
||||
|
||||
|
||||
</tbody> |
||||
</table> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="updateExchangeRates"><span class="type-signature">(async) </span>updateExchangeRates<span class="signature">()</span><span class="type-signature"></span></h4> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details"> |
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt> |
||||
<dd class="tag-source"><ul class="dummy"><li> |
||||
<a href="controllers_token-rates.js.html">controllers/token-rates.js</a>, <a href="controllers_token-rates.js.html#line25">line 25</a> |
||||
</li></ul></dd> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description"> |
||||
<p>Updates exchange rates for all tokens</p> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article> |
||||
|
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,148 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>config.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">config.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask' |
||||
const ROPSTEN_RPC_URL = 'https://ropsten.infura.io/metamask' |
||||
const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask' |
||||
const RINKEBY_RPC_URL = 'https://rinkeby.infura.io/metamask' |
||||
const LOCALHOST_RPC_URL = 'http://localhost:8545' |
||||
|
||||
const MAINET_RPC_URL_BETA = 'https://mainnet.infura.io/metamask2' |
||||
const ROPSTEN_RPC_URL_BETA = 'https://ropsten.infura.io/metamask2' |
||||
const KOVAN_RPC_URL_BETA = 'https://kovan.infura.io/metamask2' |
||||
const RINKEBY_RPC_URL_BETA = 'https://rinkeby.infura.io/metamask2' |
||||
|
||||
const DEFAULT_RPC = 'rinkeby' |
||||
const OLD_UI_NETWORK_TYPE = 'network' |
||||
const BETA_UI_NETWORK_TYPE = 'networkBeta' |
||||
|
||||
global.METAMASK_DEBUG = process.env.METAMASK_DEBUG |
||||
|
||||
/** |
||||
* @typedef {Object} UrlConfig |
||||
* @property {string} localhost URL of local RPC provider |
||||
* @property {string} mainnet URL of mainnet RPC provider |
||||
* @property {string} ropsten URL of Ropsten testnet RPC provider |
||||
* @property {string} kovan URL of Kovan testnet RPC provider |
||||
* @property {string} rinkeby URL of Rinkeby testnet RPC provider |
||||
*/ |
||||
|
||||
/** |
||||
* @typedef {Object} NameConfig |
||||
* @property {string} 3 URL of local RPC provider |
||||
* @property {string} 4 URL of mainnet RPC provider |
||||
* @property {string} 42 URL of Ropsten testnet RPC provider |
||||
*/ |
||||
|
||||
/** |
||||
* @typedef {Object} EnumConfig |
||||
* @property {string} DEFAULT_RPC Default network provider URL |
||||
* @property {string} OLD_UI_NETWORK_TYPE |
||||
* @property {string} BETA_UI_NETWORK_TYPE |
||||
*/ |
||||
|
||||
/** |
||||
* @typedef {Object} Config |
||||
* @property {UrlConfig} network Network configuration parameters |
||||
* @property {UrlConfig} networkBeta Beta UI network configuration parameters |
||||
* @property {NameConfig} networkNames Network name configuration parameters |
||||
* @property {EnumConfig} enums Application-wide string constants |
||||
*/ |
||||
|
||||
/** |
||||
* @type {Config} |
||||
**/ |
||||
const config = { |
||||
network: { |
||||
localhost: LOCALHOST_RPC_URL, |
||||
mainnet: MAINET_RPC_URL, |
||||
ropsten: ROPSTEN_RPC_URL, |
||||
kovan: KOVAN_RPC_URL, |
||||
rinkeby: RINKEBY_RPC_URL, |
||||
}, |
||||
networkBeta: { |
||||
localhost: LOCALHOST_RPC_URL, |
||||
mainnet: MAINET_RPC_URL_BETA, |
||||
ropsten: ROPSTEN_RPC_URL_BETA, |
||||
kovan: KOVAN_RPC_URL_BETA, |
||||
rinkeby: RINKEBY_RPC_URL_BETA, |
||||
}, |
||||
networkNames: { |
||||
3: 'Ropsten', |
||||
4: 'Rinkeby', |
||||
42: 'Kovan', |
||||
}, |
||||
enums: { |
||||
DEFAULT_RPC, |
||||
OLD_UI_NETWORK_TYPE, |
||||
BETA_UI_NETWORK_TYPE, |
||||
}, |
||||
} |
||||
|
||||
module.exports = config |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,265 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>contentscript.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">contentscript.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>const fs = require('fs') |
||||
const path = require('path') |
||||
const pump = require('pump') |
||||
const LocalMessageDuplexStream = require('post-message-stream') |
||||
const PongStream = require('ping-pong-stream/pong') |
||||
const ObjectMultiplex = require('obj-multiplex') |
||||
const extension = require('extensionizer') |
||||
const PortStream = require('./lib/port-stream.js') |
||||
|
||||
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString() |
||||
const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n' |
||||
const inpageBundle = inpageContent + inpageSuffix |
||||
|
||||
// Eventually this streaming injection could be replaced with: |
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction |
||||
// |
||||
// But for now that is only Firefox |
||||
// If we create a FireFox-only code path using that API, |
||||
// MetaMask will be much faster loading and performant on Firefox. |
||||
|
||||
if (shouldInjectWeb3()) { |
||||
setupInjection() |
||||
setupStreams() |
||||
} |
||||
|
||||
/** |
||||
* Creates a script tag that injects inpage.js |
||||
*/ |
||||
function setupInjection () { |
||||
try { |
||||
// inject in-page script |
||||
var scriptTag = document.createElement('script') |
||||
scriptTag.textContent = inpageBundle |
||||
scriptTag.onload = function () { this.parentNode.removeChild(this) } |
||||
var container = document.head || document.documentElement |
||||
// append as first child |
||||
container.insertBefore(scriptTag, container.children[0]) |
||||
} catch (e) { |
||||
console.error('Metamask injection failed.', e) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Sets up two-way communication streams between the |
||||
* browser extension and local per-page browser context |
||||
*/ |
||||
function setupStreams () { |
||||
// setup communication to page and plugin |
||||
const pageStream = new LocalMessageDuplexStream({ |
||||
name: 'contentscript', |
||||
target: 'inpage', |
||||
}) |
||||
const pluginPort = extension.runtime.connect({ name: 'contentscript' }) |
||||
const pluginStream = new PortStream(pluginPort) |
||||
|
||||
// forward communication plugin->inpage |
||||
pump( |
||||
pageStream, |
||||
pluginStream, |
||||
pageStream, |
||||
(err) => logStreamDisconnectWarning('MetaMask Contentscript Forwarding', err) |
||||
) |
||||
|
||||
// setup local multistream channels |
||||
const mux = new ObjectMultiplex() |
||||
mux.setMaxListeners(25) |
||||
|
||||
pump( |
||||
mux, |
||||
pageStream, |
||||
mux, |
||||
(err) => logStreamDisconnectWarning('MetaMask Inpage', err) |
||||
) |
||||
pump( |
||||
mux, |
||||
pluginStream, |
||||
mux, |
||||
(err) => logStreamDisconnectWarning('MetaMask Background', err) |
||||
) |
||||
|
||||
// connect ping stream |
||||
const pongStream = new PongStream({ objectMode: true }) |
||||
pump( |
||||
mux, |
||||
pongStream, |
||||
mux, |
||||
(err) => logStreamDisconnectWarning('MetaMask PingPongStream', err) |
||||
) |
||||
|
||||
// connect phishing warning stream |
||||
const phishingStream = mux.createStream('phishing') |
||||
phishingStream.once('data', redirectToPhishingWarning) |
||||
|
||||
// ignore unused channels (handled by background, inpage) |
||||
mux.ignoreStream('provider') |
||||
mux.ignoreStream('publicConfig') |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Error handler for page to plugin stream disconnections |
||||
* |
||||
* @param {string} remoteLabel Remote stream name |
||||
* @param {Error} err Stream connection error |
||||
*/ |
||||
function logStreamDisconnectWarning (remoteLabel, err) { |
||||
let warningMsg = `MetamaskContentscript - lost connection to ${remoteLabel}` |
||||
if (err) warningMsg += '\n' + err.stack |
||||
console.warn(warningMsg) |
||||
} |
||||
|
||||
/** |
||||
* Determines if Web3 should be injected |
||||
* |
||||
* @returns {boolean} True of Web3 should be injected |
||||
*/ |
||||
function shouldInjectWeb3 () { |
||||
return doctypeCheck() && suffixCheck() |
||||
&& documentElementCheck() && !blacklistedDomainCheck() |
||||
} |
||||
|
||||
/** |
||||
* Checks the doctype of the current document if it exists |
||||
* |
||||
* @returns {boolean} True if the doctype is html or if none exists |
||||
*/ |
||||
function doctypeCheck () { |
||||
const doctype = window.document.doctype |
||||
if (doctype) { |
||||
return doctype.name === 'html' |
||||
} else { |
||||
return true |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Checks the current document extension |
||||
* |
||||
* @returns {boolean} True if the current extension is not prohibited |
||||
*/ |
||||
function suffixCheck () { |
||||
var prohibitedTypes = ['xml', 'pdf'] |
||||
var currentUrl = window.location.href |
||||
var currentRegex |
||||
for (let i = 0; i < prohibitedTypes.length; i++) { |
||||
currentRegex = new RegExp(`\\.${prohibitedTypes[i]}$`) |
||||
if (currentRegex.test(currentUrl)) { |
||||
return false |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
/** |
||||
* Checks the documentElement of the current document |
||||
* |
||||
* @returns {boolean} True if the documentElement is an html node or if none exists |
||||
*/ |
||||
function documentElementCheck () { |
||||
var documentElement = document.documentElement.nodeName |
||||
if (documentElement) { |
||||
return documentElement.toLowerCase() === 'html' |
||||
} |
||||
return true |
||||
} |
||||
|
||||
/** |
||||
* Checks if the current domain is blacklisted |
||||
* |
||||
* @returns {boolean} True if the current domain is blacklisted |
||||
*/ |
||||
function blacklistedDomainCheck () { |
||||
var blacklistedDomains = [ |
||||
'uscourts.gov', |
||||
'dropbox.com', |
||||
'webbyawards.com', |
||||
] |
||||
var currentUrl = window.location.href |
||||
var currentRegex |
||||
for (let i = 0; i < blacklistedDomains.length; i++) { |
||||
const blacklistedDomain = blacklistedDomains[i].replace('.', '\\.') |
||||
currentRegex = new RegExp(`(?:https?:\\/\\/)(?:(?!${blacklistedDomain}).)*$`) |
||||
if (!currentRegex.test(currentUrl)) { |
||||
return true |
||||
} |
||||
} |
||||
return false |
||||
} |
||||
|
||||
/** |
||||
* Redirects the current page to a phishing information page |
||||
*/ |
||||
function redirectToPhishingWarning () { |
||||
console.log('MetaMask - redirecting to phishing warning') |
||||
window.location.href = 'https://metamask.io/phishing.html' |
||||
} |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,146 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>controllers/token-rates.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">controllers/token-rates.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>const ObservableStore = require('obs-store') |
||||
|
||||
// By default, poll every 3 minutes |
||||
const DEFAULT_INTERVAL = 180 * 1000 |
||||
|
||||
/** |
||||
* A controller that polls for token exchange |
||||
* rates based on a user's current token list |
||||
*/ |
||||
class TokenRatesController { |
||||
/** |
||||
* Creates a TokenRatesController |
||||
* |
||||
* @param {Object} [config] - Options to configure controller |
||||
*/ |
||||
constructor ({ interval = DEFAULT_INTERVAL, preferences } = {}) { |
||||
this.store = new ObservableStore() |
||||
this.preferences = preferences |
||||
this.interval = interval |
||||
} |
||||
|
||||
/** |
||||
* Updates exchange rates for all tokens |
||||
*/ |
||||
async updateExchangeRates () { |
||||
if (!this.isActive) { return } |
||||
const contractExchangeRates = {} |
||||
for (const i in this._tokens) { |
||||
const address = this._tokens[i].address |
||||
contractExchangeRates[address] = await this.fetchExchangeRate(address) |
||||
} |
||||
this.store.putState({ contractExchangeRates }) |
||||
} |
||||
|
||||
/** |
||||
* Fetches a token exchange rate by address |
||||
* |
||||
* @param {String} address - Token contract address |
||||
*/ |
||||
async fetchExchangeRate (address) { |
||||
try { |
||||
const response = await fetch(`https://exchanges.balanc3.net/prices?from=${address}&to=ETH&autoConversion=false&summaryOnly=true`) |
||||
const json = await response.json() |
||||
return json && json.length ? json[0].averagePrice : 0 |
||||
} catch (error) { } |
||||
} |
||||
|
||||
/** |
||||
* @type {Number} |
||||
*/ |
||||
set interval (interval) { |
||||
this._handle && clearInterval(this._handle) |
||||
if (!interval) { return } |
||||
this._handle = setInterval(() => { this.updateExchangeRates() }, interval) |
||||
} |
||||
|
||||
/** |
||||
* @type {Object} |
||||
*/ |
||||
set preferences (preferences) { |
||||
this._preferences && this._preferences.unsubscribe() |
||||
if (!preferences) { return } |
||||
this._preferences = preferences |
||||
this.tokens = preferences.getState().tokens |
||||
preferences.subscribe(({ tokens = [] }) => { this.tokens = tokens }) |
||||
} |
||||
|
||||
/** |
||||
* @type {Array} |
||||
*/ |
||||
set tokens (tokens) { |
||||
this._tokens = tokens |
||||
this.updateExchangeRates() |
||||
} |
||||
} |
||||
|
||||
module.exports = TokenRatesController |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,166 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>edge-encryptor.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">edge-encryptor.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>const asmcrypto = require('asmcrypto.js') |
||||
const Unibabel = require('browserify-unibabel') |
||||
|
||||
/** |
||||
* A Microsoft Edge-specific encryption class that exposes |
||||
* the interface expected by eth-keykeyring-controller |
||||
*/ |
||||
class EdgeEncryptor { |
||||
/** |
||||
* Encrypts an arbitrary JavaScript object to cypher text |
||||
* |
||||
* @param {string} password Password used to unlock a cryptographic key |
||||
* @param {Object} dataObject Data to encrypt |
||||
* @returns {Object} Object containing cypher text, generation vectors, and salt |
||||
*/ |
||||
encrypt (password, dataObject) { |
||||
var salt = this._generateSalt() |
||||
return this._keyFromPassword(password, salt) |
||||
.then(function (key) { |
||||
var data = JSON.stringify(dataObject) |
||||
var dataBuffer = Unibabel.utf8ToBuffer(data) |
||||
var vector = global.crypto.getRandomValues(new Uint8Array(16)) |
||||
var resultbuffer = asmcrypto.AES_GCM.encrypt(dataBuffer, key, vector) |
||||
|
||||
var buffer = new Uint8Array(resultbuffer) |
||||
var vectorStr = Unibabel.bufferToBase64(vector) |
||||
var vaultStr = Unibabel.bufferToBase64(buffer) |
||||
return JSON.stringify({ |
||||
data: vaultStr, |
||||
iv: vectorStr, |
||||
salt: salt, |
||||
}) |
||||
}) |
||||
} |
||||
|
||||
/** |
||||
* Decrypts an arbitrary JavaScript object from cypher text |
||||
* |
||||
* @param {string} password Password used to unlock a cryptographic key |
||||
* @param {string} text Cypher text of an encrypted JavaScript object |
||||
* @returns {Promise<Object>} Promise resolving to copy of decrypted JavaScript object |
||||
*/ |
||||
decrypt (password, text) { |
||||
const payload = JSON.parse(text) |
||||
const salt = payload.salt |
||||
return this._keyFromPassword(password, salt) |
||||
.then(function (key) { |
||||
const encryptedData = Unibabel.base64ToBuffer(payload.data) |
||||
const vector = Unibabel.base64ToBuffer(payload.iv) |
||||
return new Promise((resolve, reject) => { |
||||
var result |
||||
try { |
||||
result = asmcrypto.AES_GCM.decrypt(encryptedData, key, vector) |
||||
} catch (err) { |
||||
return reject(new Error('Incorrect password')) |
||||
} |
||||
const decryptedData = new Uint8Array(result) |
||||
const decryptedStr = Unibabel.bufferToUtf8(decryptedData) |
||||
const decryptedObj = JSON.parse(decryptedStr) |
||||
resolve(decryptedObj) |
||||
}) |
||||
}) |
||||
} |
||||
|
||||
/** |
||||
* Retrieves a cryptographic key using a password |
||||
* |
||||
* @private |
||||
* @param {string} password Password used to unlock a cryptographic key |
||||
* @param {string} salt Random base-64 data |
||||
* @returns {Promise<Object>} Promise resolving to a derived key |
||||
*/ |
||||
_keyFromPassword (password, salt) { |
||||
|
||||
var passBuffer = Unibabel.utf8ToBuffer(password) |
||||
var saltBuffer = Unibabel.base64ToBuffer(salt) |
||||
return new Promise((resolve) => { |
||||
var key = asmcrypto.PBKDF2_HMAC_SHA256.bytes(passBuffer, saltBuffer, 10000) |
||||
resolve(key) |
||||
}) |
||||
} |
||||
|
||||
/** |
||||
* Generates random base-64 encoded data |
||||
* |
||||
* @private |
||||
* @returns {string} Randomized base-64 encoded data |
||||
*/ |
||||
_generateSalt (byteCount = 32) { |
||||
var view = new Uint8Array(byteCount) |
||||
global.crypto.getRandomValues(view) |
||||
var b64encoded = btoa(String.fromCharCode.apply(null, view)) |
||||
return b64encoded |
||||
} |
||||
} |
||||
|
||||
module.exports = EdgeEncryptor |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,92 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>first-time-state.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">first-time-state.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>// test and development environment variables |
||||
const env = process.env.METAMASK_ENV |
||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG |
||||
|
||||
/** |
||||
* @typedef {Object} FirstTimeState |
||||
* @property {Object} config Initial configuration parameters |
||||
* @property {Object} NetworkController Network controller state |
||||
*/ |
||||
|
||||
/** |
||||
* @type {FirstTimeState} |
||||
*/ |
||||
const initialState = { |
||||
config: {}, |
||||
NetworkController: { |
||||
provider: { |
||||
type: (METAMASK_DEBUG || env === 'test') ? 'rinkeby' : 'mainnet', |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
module.exports = initialState |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,144 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>inpage.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">inpage.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>/*global Web3*/ |
||||
cleanContextForImports() |
||||
require('web3/dist/web3.min.js') |
||||
const log = require('loglevel') |
||||
const LocalMessageDuplexStream = require('post-message-stream') |
||||
const setupDappAutoReload = require('./lib/auto-reload.js') |
||||
const MetamaskInpageProvider = require('./lib/inpage-provider.js') |
||||
restoreContextAfterImports() |
||||
|
||||
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn') |
||||
|
||||
// |
||||
// setup plugin communication |
||||
// |
||||
|
||||
// setup background connection |
||||
var metamaskStream = new LocalMessageDuplexStream({ |
||||
name: 'inpage', |
||||
target: 'contentscript', |
||||
}) |
||||
|
||||
// compose the inpage provider |
||||
var inpageProvider = new MetamaskInpageProvider(metamaskStream) |
||||
|
||||
// |
||||
// setup web3 |
||||
// |
||||
|
||||
if (typeof window.web3 !== 'undefined') { |
||||
throw new Error(`MetaMask detected another web3. |
||||
MetaMask will not work reliably with another web3 extension. |
||||
This usually happens if you have two MetaMasks installed, |
||||
or MetaMask and another web3 extension. Please remove one |
||||
and try again.`) |
||||
} |
||||
var web3 = new Web3(inpageProvider) |
||||
web3.setProvider = function () { |
||||
log.debug('MetaMask - overrode web3.setProvider') |
||||
} |
||||
log.debug('MetaMask - injected web3') |
||||
// export global web3, with usage-detection |
||||
setupDappAutoReload(web3, inpageProvider.publicConfigStore) |
||||
|
||||
// set web3 defaultAccount |
||||
inpageProvider.publicConfigStore.subscribe(function (state) { |
||||
web3.eth.defaultAccount = state.selectedAddress |
||||
}) |
||||
|
||||
// need to make sure we aren't affected by overlapping namespaces |
||||
// and that we dont affect the app with our namespace |
||||
// mostly a fix for web3's BigNumber if AMD's "define" is defined... |
||||
var __define |
||||
|
||||
/** |
||||
* Caches reference to global define object and deletes it |
||||
*/ |
||||
function cleanContextForImports () { |
||||
__define = global.define |
||||
try { |
||||
global.define = undefined |
||||
} catch (_) { |
||||
console.warn('MetaMask - global.define could not be deleted.') |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Restores global define object from cached reference |
||||
*/ |
||||
function restoreContextAfterImports () { |
||||
try { |
||||
global.define = __define |
||||
} catch (_) { |
||||
console.warn('MetaMask - global.define could not be overwritten.') |
||||
} |
||||
} |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,118 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>lib/ComposableObservableStore.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">lib/ComposableObservableStore.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>const ObservableStore = require('obs-store') |
||||
|
||||
/** |
||||
* An ObservableStore that can composes a flat |
||||
* structure of child stores based on configuration |
||||
*/ |
||||
class ComposableObservableStore extends ObservableStore { |
||||
/** |
||||
* Create a new store |
||||
* |
||||
* @param {Object} [initState] - The initial store state |
||||
* @param {Object} [config] - Map of internal state keys to child stores |
||||
*/ |
||||
constructor (initState, config) { |
||||
super(initState) |
||||
this.updateStructure(config) |
||||
} |
||||
|
||||
/** |
||||
* Composes a new internal store subscription structure |
||||
* |
||||
* @param {Object} [config] - Map of internal state keys to child stores |
||||
*/ |
||||
updateStructure (config) { |
||||
this.config = config |
||||
this.removeAllListeners() |
||||
for (const key in config) { |
||||
config[key].subscribe((state) => { |
||||
this.updateState({ [key]: state }) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Merges all child store state into a single object rather than |
||||
* returning an object keyed by child store class name |
||||
* |
||||
* @returns {Object} - Object containing merged child store state |
||||
*/ |
||||
getFlatState () { |
||||
let flatState = {} |
||||
for (const key in this.config) { |
||||
flatState = { ...flatState, ...this.config[key].getState() } |
||||
} |
||||
return flatState |
||||
} |
||||
} |
||||
|
||||
module.exports = ComposableObservableStore |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,146 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="google" content="notranslate"> |
||||
<meta http-equiv="Content-Language" content="en"> |
||||
<title>popup-core.js - Documentation</title> |
||||
|
||||
<script src="scripts/prettify/prettify.js"></script> |
||||
<script src="scripts/prettify/lang-css.js"></script> |
||||
<script |
||||
src="https://code.jquery.com/jquery-3.1.1.min.js" |
||||
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" |
||||
crossorigin="anonymous"></script> |
||||
<script src="scripts/semantic.min.js"></script> |
||||
<!--[if lt IE 9]> |
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
||||
<![endif]--> |
||||
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/prettify.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/semantic.min.css"> |
||||
<link type="text/css" rel="stylesheet" href="styles/override.css"> |
||||
</head> |
||||
<body> |
||||
|
||||
<input type="checkbox" id="nav-trigger" class="nav-trigger" /> |
||||
<label for="nav-trigger" class="navicon-button x"> |
||||
<div class="navicon"></div> |
||||
</label> |
||||
|
||||
<label for="nav-trigger" class="overlay"></label> |
||||
|
||||
<nav> |
||||
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="ComposableObservableStore.html">ComposableObservableStore</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="ComposableObservableStore.html#getFlatState">getFlatState</a></li><li data-type='method'><a href="ComposableObservableStore.html#updateStructure">updateStructure</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="EdgeEncryptor.html">EdgeEncryptor</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="EdgeEncryptor.html#decrypt">decrypt</a></li><li data-type='method'><a href="EdgeEncryptor.html#encrypt">encrypt</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="dropdown icon"></i><a href="TokenRatesController.html">TokenRatesController</a></div></div></div><div class="content"><ul class='methods'><li data-type='method'><a href="TokenRatesController.html#fetchExchangeRate">fetchExchangeRate</a></li><li data-type='method'><a href="TokenRatesController.html#updateExchangeRates">updateExchangeRates</a></li></ul></div></li></div><div class="ui vertical accordion"><div class="title"><div class="ui list"><div class="item"><i class="inverted dropdown icon"></i><a href="module.exports_module.exports.html">exports</a></div></div></div></li></div></ul><h3>Global</h3><ul><li><a href="global.html#blacklistedDomainCheck">blacklistedDomainCheck</a></li><li><a href="global.html#cleanContextForImports">cleanContextForImports</a></li><li><a href="global.html#config">config</a></li><li><a href="global.html#connectToAccountManager">connectToAccountManager</a></li><li><a href="global.html#doctypeCheck">doctypeCheck</a></li><li><a href="global.html#documentElementCheck">documentElementCheck</a></li><li><a href="global.html#initializePopup">initializePopup</a></li><li><a href="global.html#initialState">initialState</a></li><li><a href="global.html#logStreamDisconnectWarning">logStreamDisconnectWarning</a></li><li><a href="global.html#redirectToPhishingWarning">redirectToPhishingWarning</a></li><li><a href="global.html#restoreContextAfterImports">restoreContextAfterImports</a></li><li><a href="global.html#setupControllerConnection">setupControllerConnection</a></li><li><a href="global.html#setupInjection">setupInjection</a></li><li><a href="global.html#setupStreams">setupStreams</a></li><li><a href="global.html#setupWeb3Connection">setupWeb3Connection</a></li><li><a href="global.html#shouldInjectWeb3">shouldInjectWeb3</a></li><li><a href="global.html#suffixCheck">suffixCheck</a></li></ul> |
||||
</nav> |
||||
|
||||
<div id="main"> |
||||
|
||||
<h1 class="page-title">popup-core.js</h1> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section> |
||||
<article> |
||||
<pre class="prettyprint source linenums"><code>const EventEmitter = require('events').EventEmitter |
||||
const async = require('async') |
||||
const Dnode = require('dnode') |
||||
const Eth = require('ethjs') |
||||
const EthQuery = require('eth-query') |
||||
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([ |
||||
(cb) => connectToAccountManager(connectionStream, cb), |
||||
(accountManager, cb) => launchMetamaskUi({ container, accountManager }, 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 |
||||
var mx = setupMultiplex(connectionStream) |
||||
// connect features |
||||
setupControllerConnection(mx.createStream('controller'), 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) |
||||
connectionStream.on('error', console.error.bind(console)) |
||||
providerStream.on('error', console.error.bind(console)) |
||||
global.ethereumProvider = providerStream |
||||
global.ethQuery = new EthQuery(providerStream) |
||||
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 |
||||
var eventEmitter = new EventEmitter() |
||||
var accountManagerDnode = Dnode({ |
||||
sendUpdate: function (state) { |
||||
eventEmitter.emit('update', state) |
||||
}, |
||||
}) |
||||
connectionStream.pipe(accountManagerDnode).pipe(connectionStream) |
||||
accountManagerDnode.once('remote', function (accountManager) { |
||||
// setup push events |
||||
accountManager.on = eventEmitter.on.bind(eventEmitter) |
||||
cb(null, accountManager) |
||||
}) |
||||
} |
||||
</code></pre> |
||||
</article> |
||||
</section> |
||||
|
||||
|
||||
|
||||
|
||||
</div> |
||||
|
||||
<br class="clear"> |
||||
|
||||
<footer> |
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 18 2018 17:21:38 GMT-0400 (EDT) using the radgrad jsdoc theme. Derived from docdash. |
||||
</footer> |
||||
|
||||
<script>prettyPrint();</script> |
||||
<script src="scripts/linenumber.js"></script> |
||||
<script>$('.ui.accordion').accordion();</script> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue