aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-09-22 06:56:44 +0800
committerDan Finlay <dan@danfinlay.com>2017-09-22 06:56:47 +0800
commitb25d4d5cfbf9a49e2669188198abd7377e697206 (patch)
tree7cf7e0cc6fcf2e5e90ce331a2201823cc51283fd /docs
parentbd117d6b7134a17df9d51d1fd62ec19e5258c973 (diff)
downloadtangerine-wallet-browser-b25d4d5cfbf9a49e2669188198abd7377e697206.tar
tangerine-wallet-browser-b25d4d5cfbf9a49e2669188198abd7377e697206.tar.gz
tangerine-wallet-browser-b25d4d5cfbf9a49e2669188198abd7377e697206.tar.bz2
tangerine-wallet-browser-b25d4d5cfbf9a49e2669188198abd7377e697206.tar.lz
tangerine-wallet-browser-b25d4d5cfbf9a49e2669188198abd7377e697206.tar.xz
tangerine-wallet-browser-b25d4d5cfbf9a49e2669188198abd7377e697206.tar.zst
tangerine-wallet-browser-b25d4d5cfbf9a49e2669188198abd7377e697206.zip
Add platform docs including encryptor param
Diffstat (limited to 'docs')
-rw-r--r--docs/porting_to_new_environment.md29
1 files changed, 25 insertions, 4 deletions
diff --git a/docs/porting_to_new_environment.md b/docs/porting_to_new_environment.md
index 85670efa7..c6336b9f9 100644
--- a/docs/porting_to_new_environment.md
+++ b/docs/porting_to_new_environment.md
@@ -6,10 +6,31 @@ MetaMask has been under continuous development for nearly two years now, and weâ
The core functionality of MetaMask all lives in what we call [The MetaMask Controller](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/metamask-controller.js). Our goal for this file is for it to eventually be its own javascript module that can be imported into any JS-compatible context, allowing it to fully manage an app's relationship to Ethereum.
-The MM Controller exposes most of its functionality via two methods:
+#### Constructor
-- [metamask.getState()](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/metamask-controller.js#L241) - This method returns a javascript object representing the current MetaMask state. This includes things like known accounts, sent transactions, current exchange rates, and more! The controller is also an event emitter, so you can subscribe to state updates via `metamask.on('update', handleStateUpdate)`. State examples available [here](https://github.com/MetaMask/metamask-extension/tree/master/development/states) under the `metamask` key. (Warning: some are outdated)
-- [metamask.getApi()](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/metamask-controller.js#L274-L335) - Returns a JavaScript object filled with callback functions representing every operation our user interface ever performs. Everything from creating new accounts, changing the current network, to sending a transaction, is provided via these API methods. We export this external API on an object because it allows us to easily expose this API over a port using [dnode](https://www.npmjs.com/package/dnode), which is how our WebExtension's UI works!
+When calling `new MetaMask(opts)`, many platform-specific options are configured. The keys on `opts` are as follows:
+
+- initState: The last emitted state, used for restoring persistent state between sessions.
+- platform: The `platform` object defines a variety of platform-specific functions, including opening the confirmation view, and customizing the encryption method.
+
+##### Platform Options
+
+The `platform` object has a variety of options:
+
+- reload (function) - Will be called when MetaMask would like to reload its own context.
+- openWindow ({ url }) - Will be called when MetaMask would like to open a web page. It will be passed a single `options` object with a `url` key, with a string value.
+- getVersion() - Should return the current MetaMask version, as described in the current `CHANGELOG.md` or `app/manifest.json`.
+- encryptor - An object that includes two methods:
+ - encrypt(password, object) - returns a Promise of a string that is ready for storage.
+ - decrypt(password, encryptedString) - Accepts the encrypted output of `encrypt` and returns a Promise of a restored `object` as it was encrypted.
+
+#### [metamask.getState()](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/metamask-controller.js#L241)
+
+This method returns a javascript object representing the current MetaMask state. This includes things like known accounts, sent transactions, current exchange rates, and more! The controller is also an event emitter, so you can subscribe to state updates via `metamask.on('update', handleStateUpdate)`. State examples available [here](https://github.com/MetaMask/metamask-extension/tree/master/development/states) under the `metamask` key. (Warning: some are outdated)
+
+#### [metamask.getApi()](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/metamask-controller.js#L274-L335)
+
+Returns a JavaScript object filled with callback functions representing every operation our user interface ever performs. Everything from creating new accounts, changing the current network, to sending a transaction, is provided via these API methods. We export this external API on an object because it allows us to easily expose this API over a port using [dnode](https://www.npmjs.com/package/dnode), which is how our WebExtension's UI works!
### The UI
@@ -62,4 +83,4 @@ If streams seem new and confusing to you, that's ok, they can seem strange at fi
## Conclusion
-I hope this has been helpful to you! If you have any other questionsm, or points you think need clarification in this guide, please [open an issue on our GitHub](https://github.com/MetaMask/metamask-plugin/issues/new)! \ No newline at end of file
+I hope this has been helpful to you! If you have any other questionsm, or points you think need clarification in this guide, please [open an issue on our GitHub](https://github.com/MetaMask/metamask-plugin/issues/new)!