upstream from MM 4.11.0
This commit is contained in:
commit
9c0b5661e2
2
.babelrc
2
.babelrc
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"presets": [["env", { "debug": true }], "react", "stage-0"],
|
"presets": [["env", { "targets": { "browsers": [">0.25%", "not ie 11", "not op_mini all"] } } ], "react", "stage-0"],
|
||||||
"plugins": ["transform-runtime", "transform-async-to-generator", "transform-class-properties"]
|
"plugins": ["transform-runtime", "transform-async-to-generator", "transform-class-properties"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo "Checking if firefox was already downloaded"
|
|
||||||
if [ -d "firefox" ]
|
|
||||||
then
|
|
||||||
echo "Firefox found. No need to download"
|
|
||||||
else
|
|
||||||
FIREFOX_VERSION="61.0.2"
|
|
||||||
FIREFOX_BINARY="firefox-$FIREFOX_VERSION.tar.bz2"
|
|
||||||
echo "Downloading firefox..."
|
|
||||||
wget "https://ftp.mozilla.org/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/$FIREFOX_BINARY" \
|
|
||||||
&& tar xjf "$FIREFOX_BINARY"
|
|
||||||
echo "firefox download complete"
|
|
||||||
fi
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
FIREFOX_VERSION='62.0'
|
||||||
|
FIREFOX_BINARY="firefox-${FIREFOX_VERSION}.tar.bz2"
|
||||||
|
FIREFOX_BINARY_URL="https://ftp.mozilla.org/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/${FIREFOX_BINARY}"
|
||||||
|
FIREFOX_PATH='/opt/firefox'
|
||||||
|
|
||||||
|
printf '%s\n' "Removing old Firefox installation"
|
||||||
|
|
||||||
|
sudo rm -r "${FIREFOX_PATH}"
|
||||||
|
|
||||||
|
printf '%s\n' "Downloading & installing Firefox ${FIREFOX_VERSION}"
|
||||||
|
|
||||||
|
wget --quiet --show-progress -O- "${FIREFOX_BINARY_URL}" | sudo tar xj -C /opt
|
||||||
|
|
||||||
|
printf '%s\n' "Firefox ${FIREFOX_VERSION} installed"
|
||||||
|
|
||||||
|
{
|
||||||
|
printf '%s\n' 'pref("general.config.filename", "firefox.cfg");'
|
||||||
|
printf '%s\n' 'pref("general.config.obscure_value", 0);'
|
||||||
|
} | sudo tee "${FIREFOX_PATH}/defaults/pref/autoconfig.js"
|
||||||
|
|
||||||
|
sudo cp .circleci/scripts/firefox.cfg "${FIREFOX_PATH}"
|
||||||
|
|
||||||
|
printf '%s\n' "Firefox ${FIREFOX_VERSION} configured"
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
echo "Installing firefox..."
|
|
||||||
sudo rm -r /opt/firefox
|
|
||||||
sudo mv firefox /opt/firefox61
|
|
||||||
sudo mv /usr/bin/firefox /usr/bin/firefox-old
|
|
||||||
sudo ln -s /opt/firefox61/firefox /usr/bin/firefox
|
|
||||||
echo "Firefox installed."
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// IMPORTANT: Start your code on the 2nd line
|
||||||
|
|
||||||
|
lockPref("app.update.enabled", false);
|
||||||
|
lockPref("app.update.auto", false);
|
||||||
|
lockPref("app.update.mode", 0);
|
||||||
|
lockPref("app.update.service.enabled", false);
|
||||||
|
|
||||||
|
pref("browser.rights.3.shown", true);
|
||||||
|
|
||||||
|
pref("browser.startup.homepage_override.mstone","ignore");
|
||||||
|
|
||||||
|
lockPref("plugins.hide_infobar_for_outdated_plugin", true);
|
||||||
|
clearPref("plugins.update.url");
|
|
@ -9,6 +9,7 @@ package
|
||||||
# IDEs
|
# IDEs
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
|
.sublime-project
|
||||||
|
|
||||||
# VIM
|
# VIM
|
||||||
*.swp
|
*.swp
|
||||||
|
@ -20,6 +21,7 @@ temp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
app/.DS_Store
|
app/.DS_Store
|
||||||
|
|
||||||
|
coverage/
|
||||||
dist
|
dist
|
||||||
builds/
|
builds/
|
||||||
disc/
|
disc/
|
||||||
|
@ -34,6 +36,7 @@ test/bundle.js
|
||||||
test/test-bundle.js
|
test/test-bundle.js
|
||||||
|
|
||||||
test-artifacts
|
test-artifacts
|
||||||
|
test-builds
|
||||||
|
|
||||||
#ignore css output and sourcemaps
|
#ignore css output and sourcemaps
|
||||||
ui/app/css/output/
|
ui/app/css/output/
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"generator-mocha": {}
|
|
||||||
}
|
|
49
CHANGELOG.md
49
CHANGELOG.md
|
@ -64,6 +64,55 @@
|
||||||
- Allow to remove accounts (Imported and Hardware Wallets)
|
- Allow to remove accounts (Imported and Hardware Wallets)
|
||||||
- [#4840](https://github.com/MetaMask/metamask-extension/pull/4840): Now shows notifications when transactions are completed.
|
- [#4840](https://github.com/MetaMask/metamask-extension/pull/4840): Now shows notifications when transactions are completed.
|
||||||
- [#4855](https://github.com/MetaMask/metamask-extension/pull/4855): network.js: convert rpc protocol to lower case.
|
- [#4855](https://github.com/MetaMask/metamask-extension/pull/4855): network.js: convert rpc protocol to lower case.
|
||||||
|
## Current Develop Branch
|
||||||
|
|
||||||
|
## 4.10.0 Mon Sep 17 2018
|
||||||
|
|
||||||
|
- [#4803](https://github.com/MetaMask/metamask-extension/pull/4803): Implement EIP-712: Sign typed data, but continue to support v1.
|
||||||
|
- [#4898](https://github.com/MetaMask/metamask-extension/pull/4898): Restore multiple consecutive accounts with balances.
|
||||||
|
- [#4279](https://github.com/MetaMask/metamask-extension/pull/4279): New BlockTracker and Json-Rpc-Engine based Provider.
|
||||||
|
- [#5050](https://github.com/MetaMask/metamask-extension/pull/5050): Add Ledger hardware wallet support.
|
||||||
|
- [#4919](https://github.com/MetaMask/metamask-extension/pull/4919): Refactor and Redesign Transaction List.
|
||||||
|
- [#5182](https://github.com/MetaMask/metamask-extension/pull/5182): Add Transaction Details to the Transaction List view.
|
||||||
|
- [#5229](https://github.com/MetaMask/metamask-extension/pull/5229): Clear old seed words when importing new seed words.
|
||||||
|
- [#5264](https://github.com/MetaMask/metamask-extension/pull/5264): Improve click area for adjustment arrows buttons.
|
||||||
|
- [#4606](https://github.com/MetaMask/metamask-extension/pull/4606): Add new metamask_watchAsset method.
|
||||||
|
- [#5189](https://github.com/MetaMask/metamask-extension/pull/5189): Fix bug where Ropsten loading message is shown when connecting to Kovan.
|
||||||
|
- [#5256](https://github.com/MetaMask/metamask-extension/pull/5256): Add mock EIP-1102 support
|
||||||
|
|
||||||
|
## 4.9.3 Wed Aug 15 2018
|
||||||
|
|
||||||
|
- [#4897](https://github.com/MetaMask/metamask-extension/pull/4897): QR code scan for recipient addresses.
|
||||||
|
- [#4961](https://github.com/MetaMask/metamask-extension/pull/4961): Add a download seed phrase link.
|
||||||
|
- [#5060](https://github.com/MetaMask/metamask-extension/pull/5060): Fix bug where gas was not updating properly.
|
||||||
|
|
||||||
|
## 4.9.2 Mon Aug 09 2018
|
||||||
|
|
||||||
|
- [#5020](https://github.com/MetaMask/metamask-extension/pull/5020): Fix bug in migration #28 ( moving tokens to specific accounts )
|
||||||
|
|
||||||
|
## 4.9.1 Mon Aug 09 2018
|
||||||
|
|
||||||
|
- [#4884](https://github.com/MetaMask/metamask-extension/pull/4884): Allow to have tokens per account and network.
|
||||||
|
- [#4989](https://github.com/MetaMask/metamask-extension/pull/4989): Continue to use original signedTypedData.
|
||||||
|
- [#5010](https://github.com/MetaMask/metamask-extension/pull/5010): Fix ENS resolution issues.
|
||||||
|
- [#5000](https://github.com/MetaMask/metamask-extension/pull/5000): Show error while allowing confirmation of tx where simulation fails.
|
||||||
|
- [#4995](https://github.com/MetaMask/metamask-extension/pull/4995): Shows retry button on dApp initialized transactions.
|
||||||
|
|
||||||
|
## 4.9.0 Mon Aug 07 2018
|
||||||
|
|
||||||
|
- [#4926](https://github.com/MetaMask/metamask-extension/pull/4926): Show retry button on the latest tx of the earliest nonce.
|
||||||
|
- [#4888](https://github.com/MetaMask/metamask-extension/pull/4888): Suggest using the new user interface.
|
||||||
|
- [#4947](https://github.com/MetaMask/metamask-extension/pull/4947): Prevent sending multiple transasctions on multiple confirm clicks.
|
||||||
|
- [#4844](https://github.com/MetaMask/metamask-extension/pull/4844): Add new tokens auto detection.
|
||||||
|
- [#4667](https://github.com/MetaMask/metamask-extension/pull/4667): Remove rejected transactions from transaction history.
|
||||||
|
- [#4625](https://github.com/MetaMask/metamask-extension/pull/4625): Add Trezor Support.
|
||||||
|
- [#4625](https://github.com/MetaMask/metamask-extension/pull/4625/commits/523cf9ad33d88719520ae5e7293329d133b64d4d): Allow to remove accounts (Imported and Hardware Wallets)
|
||||||
|
- [#4814](https://github.com/MetaMask/metamask-extension/pull/4814): Add hex data input to send screen.
|
||||||
|
- [#4691](https://github.com/MetaMask/metamask-extension/pull/4691): Redesign of the Confirm Transaction Screen.
|
||||||
|
- [#4840](https://github.com/MetaMask/metamask-extension/pull/4840): Now shows notifications when transactions are completed.
|
||||||
|
- [#4855](https://github.com/MetaMask/metamask-extension/pull/4855): Allow the use of HTTP prefix for custom rpc urls.
|
||||||
|
- [#4855](https://github.com/MetaMask/metamask-extension/pull/4855): network.js: convert rpc protocol to lower case.
|
||||||
|
- [#4898](https://github.com/MetaMask/metamask-extension/pull/4898): Restore multiple consecutive accounts with balances.
|
||||||
|
|
||||||
## 4.8.0 Thur Jun 14 2018
|
## 4.8.0 Thur Jun 14 2018
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,12 @@ If you're a web dapp developer, we've got two types of guides for you:
|
||||||
|
|
||||||
Uncompressed builds can be found in `/dist`, compressed builds can be found in `/builds` once they're built.
|
Uncompressed builds can be found in `/dist`, compressed builds can be found in `/builds` once they're built.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
You can read [our internal docs here](https://metamask.github.io/metamask-extension/).
|
||||||
|
|
||||||
|
You can re-generate the docs locally by running `npm run doc`, and contributors can update the hosted docs by running `npm run publish-docs`.
|
||||||
|
|
||||||
### Running Tests
|
### Running Tests
|
||||||
|
|
||||||
Requires `mocha` installed. Run `npm install -g mocha`.
|
Requires `mocha` installed. Run `npm install -g mocha`.
|
||||||
|
|
|
@ -802,7 +802,7 @@
|
||||||
"message": "Testovací faucet"
|
"message": "Testovací faucet"
|
||||||
},
|
},
|
||||||
"to": {
|
"to": {
|
||||||
"message": "Komu: "
|
"message": "Komu"
|
||||||
},
|
},
|
||||||
"toETHviaShapeShift": {
|
"toETHviaShapeShift": {
|
||||||
"message": "$1 na ETH přes ShapeShift",
|
"message": "$1 na ETH přes ShapeShift",
|
||||||
|
|
|
@ -781,7 +781,7 @@
|
||||||
"message": "Testfaucet"
|
"message": "Testfaucet"
|
||||||
},
|
},
|
||||||
"to": {
|
"to": {
|
||||||
"message": "An:"
|
"message": "An"
|
||||||
},
|
},
|
||||||
"toETHviaShapeShift": {
|
"toETHviaShapeShift": {
|
||||||
"message": "$1 an ETH via ShapeShift",
|
"message": "$1 an ETH via ShapeShift",
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
"accountSelectionRequired": {
|
"accountSelectionRequired": {
|
||||||
"message": "You need to select an account!"
|
"message": "You need to select an account!"
|
||||||
},
|
},
|
||||||
|
"activityLog": {
|
||||||
|
"message": "activity log"
|
||||||
|
},
|
||||||
"address": {
|
"address": {
|
||||||
"message": "Address"
|
"message": "Address"
|
||||||
},
|
},
|
||||||
|
@ -29,6 +32,9 @@
|
||||||
"addTokens": {
|
"addTokens": {
|
||||||
"message": "Add Tokens"
|
"message": "Add Tokens"
|
||||||
},
|
},
|
||||||
|
"addSuggestedTokens": {
|
||||||
|
"message": "Add Suggested Tokens"
|
||||||
|
},
|
||||||
"addAcquiredTokens": {
|
"addAcquiredTokens": {
|
||||||
"message": "Add the tokens you've acquired using Nifty Wallet"
|
"message": "Add the tokens you've acquired using Nifty Wallet"
|
||||||
},
|
},
|
||||||
|
@ -210,6 +216,9 @@
|
||||||
"currentConversion": {
|
"currentConversion": {
|
||||||
"message": "Current Conversion"
|
"message": "Current Conversion"
|
||||||
},
|
},
|
||||||
|
"currentLanguage": {
|
||||||
|
"message": "Current Language"
|
||||||
|
},
|
||||||
"currentNetwork": {
|
"currentNetwork": {
|
||||||
"message": "Current Network"
|
"message": "Current Network"
|
||||||
},
|
},
|
||||||
|
@ -451,6 +460,9 @@
|
||||||
"hideTokenPrompt": {
|
"hideTokenPrompt": {
|
||||||
"message": "Hide Token?"
|
"message": "Hide Token?"
|
||||||
},
|
},
|
||||||
|
"history": {
|
||||||
|
"message": "History"
|
||||||
|
},
|
||||||
"howToDeposit": {
|
"howToDeposit": {
|
||||||
"message": "How would you like to deposit Ether?"
|
"message": "How would you like to deposit Ether?"
|
||||||
},
|
},
|
||||||
|
@ -587,6 +599,9 @@
|
||||||
"metamaskSeedWords": {
|
"metamaskSeedWords": {
|
||||||
"message": "Nifty Wallet Seed Words"
|
"message": "Nifty Wallet Seed Words"
|
||||||
},
|
},
|
||||||
|
"metamaskVersion": {
|
||||||
|
"message": "MetaMask Version"
|
||||||
|
},
|
||||||
"min": {
|
"min": {
|
||||||
"message": "Minimum"
|
"message": "Minimum"
|
||||||
},
|
},
|
||||||
|
@ -651,7 +666,7 @@
|
||||||
"message": "No transaction history."
|
"message": "No transaction history."
|
||||||
},
|
},
|
||||||
"noTransactions": {
|
"noTransactions": {
|
||||||
"message": "No Transactions"
|
"message": "You have no transactions"
|
||||||
},
|
},
|
||||||
"notFound": {
|
"notFound": {
|
||||||
"message": "Not Found"
|
"message": "Not Found"
|
||||||
|
@ -702,6 +717,9 @@
|
||||||
"pasteSeed": {
|
"pasteSeed": {
|
||||||
"message": "Paste your seed phrase here!"
|
"message": "Paste your seed phrase here!"
|
||||||
},
|
},
|
||||||
|
"pending": {
|
||||||
|
"message": "pending"
|
||||||
|
},
|
||||||
"personalAddressDetected": {
|
"personalAddressDetected": {
|
||||||
"message": "Personal address detected. Input the token contract address."
|
"message": "Personal address detected. Input the token contract address."
|
||||||
},
|
},
|
||||||
|
@ -730,6 +748,9 @@
|
||||||
"qrCode": {
|
"qrCode": {
|
||||||
"message": "Show QR Code"
|
"message": "Show QR Code"
|
||||||
},
|
},
|
||||||
|
"queue": {
|
||||||
|
"message": "Queue"
|
||||||
|
},
|
||||||
"readdToken": {
|
"readdToken": {
|
||||||
"message": "You can add this token back in the future by going go to “Add token” in your accounts options menu."
|
"message": "You can add this token back in the future by going go to “Add token” in your accounts options menu."
|
||||||
},
|
},
|
||||||
|
@ -851,6 +872,9 @@
|
||||||
"save": {
|
"save": {
|
||||||
"message": "Save"
|
"message": "Save"
|
||||||
},
|
},
|
||||||
|
"speedUp": {
|
||||||
|
"message": "speed up"
|
||||||
|
},
|
||||||
"speedUpTitle": {
|
"speedUpTitle": {
|
||||||
"message": "Speed Up Transaction"
|
"message": "Speed Up Transaction"
|
||||||
},
|
},
|
||||||
|
@ -876,6 +900,12 @@
|
||||||
"secretPhrase": {
|
"secretPhrase": {
|
||||||
"message": "Enter your secret twelve word phrase here to restore your vault."
|
"message": "Enter your secret twelve word phrase here to restore your vault."
|
||||||
},
|
},
|
||||||
|
"showHexData": {
|
||||||
|
"message": "Show Hex Data"
|
||||||
|
},
|
||||||
|
"showHexDataDescription": {
|
||||||
|
"message": "Select this to show the hex data field on the send screen"
|
||||||
|
},
|
||||||
"newPassword8Chars": {
|
"newPassword8Chars": {
|
||||||
"message": "New Password (min 8 chars)"
|
"message": "New Password (min 8 chars)"
|
||||||
},
|
},
|
||||||
|
@ -888,6 +918,9 @@
|
||||||
"selectCurrency": {
|
"selectCurrency": {
|
||||||
"message": "Select Currency"
|
"message": "Select Currency"
|
||||||
},
|
},
|
||||||
|
"selectLocale": {
|
||||||
|
"message": "Select Locale"
|
||||||
|
},
|
||||||
"selectService": {
|
"selectService": {
|
||||||
"message": "Select Service"
|
"message": "Select Service"
|
||||||
},
|
},
|
||||||
|
@ -903,6 +936,12 @@
|
||||||
"sendTokens": {
|
"sendTokens": {
|
||||||
"message": "Send Tokens"
|
"message": "Send Tokens"
|
||||||
},
|
},
|
||||||
|
"sentEther": {
|
||||||
|
"message": "sent ether"
|
||||||
|
},
|
||||||
|
"sentTokens": {
|
||||||
|
"message": "sent tokens"
|
||||||
|
},
|
||||||
"separateEachWord": {
|
"separateEachWord": {
|
||||||
"message": "Separate each word with a single space"
|
"message": "Separate each word with a single space"
|
||||||
},
|
},
|
||||||
|
@ -916,6 +955,9 @@
|
||||||
"orderOneHere": {
|
"orderOneHere": {
|
||||||
"message": "Order a Trezor or Ledger and keep your funds in cold storage"
|
"message": "Order a Trezor or Ledger and keep your funds in cold storage"
|
||||||
},
|
},
|
||||||
|
"outgoing": {
|
||||||
|
"message": "Outgoing"
|
||||||
|
},
|
||||||
"searchTokens": {
|
"searchTokens": {
|
||||||
"message": "Search Tokens"
|
"message": "Search Tokens"
|
||||||
},
|
},
|
||||||
|
@ -979,6 +1021,9 @@
|
||||||
"sign": {
|
"sign": {
|
||||||
"message": "Sign"
|
"message": "Sign"
|
||||||
},
|
},
|
||||||
|
"signatureRequest": {
|
||||||
|
"message": "Signature Request"
|
||||||
|
},
|
||||||
"signed": {
|
"signed": {
|
||||||
"message": "Signed"
|
"message": "Signed"
|
||||||
},
|
},
|
||||||
|
@ -1031,7 +1076,7 @@
|
||||||
"message": "Test Faucet"
|
"message": "Test Faucet"
|
||||||
},
|
},
|
||||||
"to": {
|
"to": {
|
||||||
"message": "To: "
|
"message": "To"
|
||||||
},
|
},
|
||||||
"toETHviaShapeShift": {
|
"toETHviaShapeShift": {
|
||||||
"message": "$1 to ETH via ShapeShift",
|
"message": "$1 to ETH via ShapeShift",
|
||||||
|
@ -1061,6 +1106,27 @@
|
||||||
"total": {
|
"total": {
|
||||||
"message": "Total"
|
"message": "Total"
|
||||||
},
|
},
|
||||||
|
"transaction": {
|
||||||
|
"message": "transaction"
|
||||||
|
},
|
||||||
|
"transactionConfirmed": {
|
||||||
|
"message": "Transaction confirmed on $2."
|
||||||
|
},
|
||||||
|
"transactionCreated": {
|
||||||
|
"message": "Transaction created with a value of $1 on $2."
|
||||||
|
},
|
||||||
|
"transactionDropped": {
|
||||||
|
"message": "Transaction dropped on $2."
|
||||||
|
},
|
||||||
|
"transactionSubmitted": {
|
||||||
|
"message": "Transaction submitted on $2."
|
||||||
|
},
|
||||||
|
"transactionUpdated": {
|
||||||
|
"message": "Transaction updated on $2."
|
||||||
|
},
|
||||||
|
"transactionUpdatedGas": {
|
||||||
|
"message": "Transaction updated with a gas price of $1 on $2."
|
||||||
|
},
|
||||||
"transactions": {
|
"transactions": {
|
||||||
"message": "transactions"
|
"message": "transactions"
|
||||||
},
|
},
|
||||||
|
@ -1107,6 +1173,9 @@
|
||||||
"unavailable": {
|
"unavailable": {
|
||||||
"message": "Unavailable"
|
"message": "Unavailable"
|
||||||
},
|
},
|
||||||
|
"units": {
|
||||||
|
"message": "units"
|
||||||
|
},
|
||||||
"unknown": {
|
"unknown": {
|
||||||
"message": "Unknown"
|
"message": "Unknown"
|
||||||
},
|
},
|
||||||
|
@ -1134,6 +1203,9 @@
|
||||||
"unlockMessage": {
|
"unlockMessage": {
|
||||||
"message": "The decentralized web awaits"
|
"message": "The decentralized web awaits"
|
||||||
},
|
},
|
||||||
|
"updatedWithDate": {
|
||||||
|
"message": "Updated $1"
|
||||||
|
},
|
||||||
"uriErrorMsg": {
|
"uriErrorMsg": {
|
||||||
"message": "URIs require the appropriate HTTP/HTTPS prefix."
|
"message": "URIs require the appropriate HTTP/HTTPS prefix."
|
||||||
},
|
},
|
||||||
|
|
|
@ -778,7 +778,7 @@
|
||||||
"message": "Probar Faucet"
|
"message": "Probar Faucet"
|
||||||
},
|
},
|
||||||
"to": {
|
"to": {
|
||||||
"message": "Para:"
|
"message": "Para"
|
||||||
},
|
},
|
||||||
"toETHviaShapeShift": {
|
"toETHviaShapeShift": {
|
||||||
"message": "$1 a ETH via ShapeShift",
|
"message": "$1 a ETH via ShapeShift",
|
||||||
|
|
|
@ -493,7 +493,7 @@
|
||||||
"message": "Sélectionner un service"
|
"message": "Sélectionner un service"
|
||||||
},
|
},
|
||||||
"send": {
|
"send": {
|
||||||
"message": "Envoyé"
|
"message": "Envoyer"
|
||||||
},
|
},
|
||||||
"sendTokens": {
|
"sendTokens": {
|
||||||
"message": "Envoyer des jetons"
|
"message": "Envoyer des jetons"
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -790,7 +790,7 @@
|
||||||
"message": "Тестовый кран"
|
"message": "Тестовый кран"
|
||||||
},
|
},
|
||||||
"to": {
|
"to": {
|
||||||
"message": "Получатель: "
|
"message": "Получатель"
|
||||||
},
|
},
|
||||||
"toETHviaShapeShift": {
|
"toETHviaShapeShift": {
|
||||||
"message": "$1 в ETH через ShapeShift",
|
"message": "$1 в ETH через ShapeShift",
|
||||||
|
|
|
@ -802,7 +802,7 @@
|
||||||
"message": "சோதனை குழாய்"
|
"message": "சோதனை குழாய்"
|
||||||
},
|
},
|
||||||
"to": {
|
"to": {
|
||||||
"message": "பெறுநர்: "
|
"message": "பெறுநர்"
|
||||||
},
|
},
|
||||||
"toETHviaShapeShift": {
|
"toETHviaShapeShift": {
|
||||||
"message": "$ 1 முதல் ETH வரை வடிவம்",
|
"message": "$ 1 முதல் ETH வரை வடிவம்",
|
||||||
|
|
|
@ -802,7 +802,7 @@
|
||||||
"message": "Test Musluğu"
|
"message": "Test Musluğu"
|
||||||
},
|
},
|
||||||
"to": {
|
"to": {
|
||||||
"message": "Kime: "
|
"message": "Kime"
|
||||||
},
|
},
|
||||||
"toETHviaShapeShift": {
|
"toETHviaShapeShift": {
|
||||||
"message": "ShapeShift üstünden $1'dan ETH'e",
|
"message": "ShapeShift üstünden $1'dan ETH'e",
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
"addTokens": {
|
"addTokens": {
|
||||||
"message": "添加代币"
|
"message": "添加代币"
|
||||||
},
|
},
|
||||||
|
"addAcquiredTokens": {
|
||||||
|
"message": "在Metamask上添加已用的代币"
|
||||||
|
},
|
||||||
"amount": {
|
"amount": {
|
||||||
"message": "数量"
|
"message": "数量"
|
||||||
},
|
},
|
||||||
|
@ -116,6 +119,9 @@
|
||||||
"confirmTransaction": {
|
"confirmTransaction": {
|
||||||
"message": "确认交易"
|
"message": "确认交易"
|
||||||
},
|
},
|
||||||
|
"connectHardwareWallet": {
|
||||||
|
"message": "链接硬件钱包"
|
||||||
|
},
|
||||||
"continue": {
|
"continue": {
|
||||||
"message": "继续"
|
"message": "继续"
|
||||||
},
|
},
|
||||||
|
@ -720,6 +726,9 @@
|
||||||
"search": {
|
"search": {
|
||||||
"message": "搜索"
|
"message": "搜索"
|
||||||
},
|
},
|
||||||
|
"searchResults": {
|
||||||
|
"message": "搜索结果"
|
||||||
|
},
|
||||||
"secretPhrase": {
|
"secretPhrase": {
|
||||||
"message": "输入12位助记词以恢复金库."
|
"message": "输入12位助记词以恢复金库."
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M8.67589 0.641872C8.65169 0.642635 8.62756 0.644749 8.6036 0.648202H4.79279C4.55863 0.644896 4.34082 0.767704 4.22278 0.969601C4.10473 1.1715 4.10473 1.4212 4.22278 1.6231C4.34082 1.825 4.55863 1.9478 4.79279 1.9445H7.12113L0.437932 8.61587C0.268309 8.77843 0.19998 9.01984 0.259298 9.24697C0.318616 9.47411 0.496311 9.65149 0.723852 9.71071C0.951393 9.76992 1.19322 9.70171 1.35608 9.53239L8.03927 2.86102V5.18524C8.03596 5.41898 8.15899 5.6364 8.36124 5.75424C8.56349 5.87208 8.81364 5.87208 9.0159 5.75424C9.21815 5.6364 9.34118 5.41898 9.33787 5.18524V1.37863C9.36404 1.18976 9.30558 0.998955 9.17804 0.857009C9.0505 0.715062 8.86682 0.636369 8.67589 0.641872Z" fill="#359BDD"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 795 B |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
|
@ -0,0 +1,115 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns:ev="http://www.w3.org/2001/xml-events"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1672.1 241.2"
|
||||||
|
style="enable-background:new 0 0 1672.1 241.2;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{fill:#161616;}
|
||||||
|
.st1{fill:#E17726;stroke:#E17726;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st2{fill:#E27625;stroke:#E27625;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st3{fill:#D5BFB2;stroke:#D5BFB2;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st4{fill:#233447;stroke:#233447;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st5{fill:#CC6228;stroke:#CC6228;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st6{fill:#E27525;stroke:#E27525;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st7{fill:#F5841F;stroke:#F5841F;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st8{fill:#C0AC9D;stroke:#C0AC9D;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st9{fill:#161616;stroke:#161616;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st10{fill:#763E1A;stroke:#763E1A;stroke-linecap:round;stroke-linejoin:round;}
|
||||||
|
.st11{fill:#F5841F;}
|
||||||
|
</style>
|
||||||
|
<g>
|
||||||
|
<path class="st0" d="M1157.7,121.9c-6.8-4.5-14.3-7.7-21.4-11.7c-4.6-2.6-9.5-4.9-13.5-8.2c-6.8-5.6-5.4-16.6,1.7-21.4
|
||||||
|
c10.2-6.8,27.1-3,28.9,10.9c0,0.3,0.3,0.5,0.6,0.5h15.4c0.4,0,0.7-0.3,0.6-0.7c-0.8-9.6-4.5-17.6-11.3-22.7
|
||||||
|
c-6.5-4.9-13.9-7.5-21.8-7.5c-40.7,0-44.4,43.1-22.5,56.7c2.5,1.6,24,12.4,31.6,17.1s10,13.3,6.7,20.1c-3,6.2-10.8,10.5-18.6,10
|
||||||
|
c-8.5-0.5-15.1-5.1-17.4-12.3c-0.4-1.3-0.6-3.8-0.6-4.9c0-0.3-0.3-0.6-0.6-0.6h-16.7c-0.3,0-0.6,0.3-0.6,0.6
|
||||||
|
c0,12.1,3,18.8,11.2,24.9c7.7,5.8,16.1,8.2,24.8,8.2c22.8,0,34.6-12.9,37-26.3C1173.3,141.5,1169.4,129.7,1157.7,121.9z"/>
|
||||||
|
<path class="st0" d="M432.6,63.3h-7.4h-8.1c-0.3,0-0.5,0.2-0.6,0.4l-13.7,45.2c-0.2,0.6-1,0.6-1.2,0l-13.7-45.2
|
||||||
|
c-0.1-0.3-0.3-0.4-0.6-0.4h-8.1h-7.4h-10c-0.3,0-0.6,0.3-0.6,0.6v115.4c0,0.3,0.3,0.6,0.6,0.6h16.7c0.3,0,0.6-0.3,0.6-0.6V91.6
|
||||||
|
c0-0.7,1-0.8,1.2-0.2l13.8,45.5l1,3.2c0.1,0.3,0.3,0.4,0.6,0.4h12.8c0.3,0,0.5-0.2,0.6-0.4l1-3.2l13.8-45.5
|
||||||
|
c0.2-0.7,1.2-0.5,1.2,0.2v87.7c0,0.3,0.3,0.6,0.6,0.6h16.7c0.3,0,0.6-0.3,0.6-0.6V63.9c0-0.3-0.3-0.6-0.6-0.6L432.6,63.3
|
||||||
|
L432.6,63.3z"/>
|
||||||
|
<path class="st0" d="M902,63.3c-0.3,0-0.5,0.2-0.6,0.4l-13.7,45.2c-0.2,0.6-1,0.6-1.2,0l-13.7-45.2c-0.1-0.3-0.3-0.4-0.6-0.4h-25.4
|
||||||
|
c-0.3,0-0.6,0.3-0.6,0.6v115.4c0,0.3,0.3,0.6,0.6,0.6h16.7c0.3,0,0.6-0.3,0.6-0.6V91.6c0-0.7,1-0.8,1.2-0.2l13.8,45.5l1,3.2
|
||||||
|
c0.1,0.3,0.3,0.4,0.6,0.4h12.8c0.3,0,0.5-0.2,0.6-0.4l1-3.2l13.8-45.5c0.2-0.7,1.2-0.5,1.2,0.2v87.7c0,0.3,0.3,0.6,0.6,0.6h16.7
|
||||||
|
c0.3,0,0.6-0.3,0.6-0.6V63.9c0-0.3-0.3-0.6-0.6-0.6L902,63.3L902,63.3z"/>
|
||||||
|
<path class="st0" d="M686.6,63.3h-31.1h-16.7h-31.1c-0.3,0-0.6,0.3-0.6,0.6v14.4c0,0.3,0.3,0.6,0.6,0.6h30.5v100.4
|
||||||
|
c0,0.3,0.3,0.6,0.6,0.6h16.7c0.3,0,0.6-0.3,0.6-0.6V78.9h30.5c0.3,0,0.6-0.3,0.6-0.6V63.9C687.2,63.6,687,63.3,686.6,63.3z"/>
|
||||||
|
<path class="st0" d="M785.1,179.9h15.2c0.4,0,0.7-0.4,0.6-0.8L769.5,63.3c-0.1-0.3-0.3-0.4-0.6-0.4h-5.8h-10.2h-5.8
|
||||||
|
c-0.3,0-0.5,0.2-0.6,0.4l-31.4,115.8c-0.1,0.4,0.2,0.8,0.6,0.8h15.2c0.3,0,0.5-0.2,0.6-0.4l9.1-33.7c0.1-0.3,0.3-0.4,0.6-0.4h33.6
|
||||||
|
c0.3,0,0.5,0.2,0.6,0.4l9.1,33.7C784.6,179.7,784.9,179.9,785.1,179.9z M745.2,128.9l12.2-45.1c0.2-0.6,1-0.6,1.2,0l12.2,45.1
|
||||||
|
c0.1,0.4-0.2,0.8-0.6,0.8h-24.4C745.4,129.7,745.1,129.3,745.2,128.9z"/>
|
||||||
|
<path class="st0" d="M1044.3,179.9h15.2c0.4,0,0.7-0.4,0.6-0.8l-31.4-115.8c-0.1-0.3-0.3-0.4-0.6-0.4h-5.8h-10.2h-5.8
|
||||||
|
c-0.3,0-0.5,0.2-0.6,0.4l-31.4,115.8c-0.1,0.4,0.2,0.8,0.6,0.8h15.2c0.3,0,0.5-0.2,0.6-0.4l9.1-33.7c0.1-0.3,0.3-0.4,0.6-0.4h33.6
|
||||||
|
c0.3,0,0.5,0.2,0.6,0.4l9.1,33.7C1043.8,179.7,1044,179.9,1044.3,179.9z M1004.4,128.9l12.2-45.1c0.2-0.6,1-0.6,1.2,0l12.2,45.1
|
||||||
|
c0.1,0.4-0.2,0.8-0.6,0.8H1005C1004.6,129.7,1004.3,129.3,1004.4,128.9z"/>
|
||||||
|
<path class="st0" d="M510.8,162.8V127c0-0.3,0.3-0.6,0.6-0.6h44.5c0.3,0,0.6-0.3,0.6-0.6v-14.4c0-0.3-0.3-0.6-0.6-0.6h-44.5
|
||||||
|
c-0.3,0-0.6-0.3-0.6-0.6V79.6c0-0.3,0.3-0.6,0.6-0.6H562c0.3,0,0.6-0.3,0.6-0.6V64c0-0.3-0.3-0.6-0.6-0.6h-51.2h-17.3
|
||||||
|
c-0.3,0-0.6,0.3-0.6,0.6v15v31.9v15.6v37v15.8c0,0.3,0.3,0.6,0.6,0.6h17.3h53.3c0.3,0,0.6-0.3,0.6-0.6v-15.2c0-0.3-0.3-0.6-0.6-0.6
|
||||||
|
h-52.8C511,163.4,510.8,163.2,510.8,162.8z"/>
|
||||||
|
<path class="st0" d="M1310.3,178.9l-57.8-59.7c-0.2-0.2-0.2-0.6,0-0.8l52-54c0.4-0.4,0.1-1-0.4-1h-21.3c-0.2,0-0.3,0.1-0.4,0.2
|
||||||
|
l-44.1,45.8c-0.4,0.4-1,0.1-1-0.4V64c0-0.3-0.3-0.6-0.6-0.6H1220c-0.3,0-0.6,0.3-0.6,0.6v115.4c0,0.3,0.3,0.6,0.6,0.6h16.7
|
||||||
|
c0.3,0,0.6-0.3,0.6-0.6v-50.8c0-0.5,0.7-0.8,1-0.4l50,51.6c0.1,0.1,0.3,0.2,0.4,0.2h21.3C1310.4,179.9,1310.7,179.2,1310.3,178.9z"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<polygon class="st1" points="247.1,1.2 146,76.2 164.8,32 "/>
|
||||||
|
<g>
|
||||||
|
<polygon class="st2" points="13.9,1.2 114.1,76.9 96.2,32 "/>
|
||||||
|
<polygon class="st2" points="210.7,175.1 183.8,216.3 241.4,232.2 257.9,176 "/>
|
||||||
|
<polygon class="st2" points="3.2,176 19.6,232.2 77.1,216.3 50.3,175.1 "/>
|
||||||
|
<polygon class="st2" points="74,105.5 58,129.7 115,132.3 113.1,70.8 "/>
|
||||||
|
<polygon class="st2" points="187,105.5 147.3,70.1 146,132.3 203,129.7 "/>
|
||||||
|
<polygon class="st2" points="77.1,216.3 111.6,199.6 81.9,176.4 "/>
|
||||||
|
<polygon class="st2" points="149.4,199.6 183.8,216.3 179.1,176.4 "/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<polygon class="st3" points="183.8,216.3 149.4,199.6 152.2,222 151.9,231.5 "/>
|
||||||
|
<polygon class="st3" points="77.1,216.3 109.1,231.5 108.9,222 111.6,199.6 "/>
|
||||||
|
</g>
|
||||||
|
<polygon class="st4" points="109.7,161.6 81.1,153.2 101.3,143.9 "/>
|
||||||
|
<polygon class="st4" points="151.3,161.6 159.7,143.9 180,153.2 "/>
|
||||||
|
<g>
|
||||||
|
<polygon class="st5" points="77.1,216.3 82.1,175.1 50.3,176 "/>
|
||||||
|
<polygon class="st5" points="178.9,175.1 183.8,216.3 210.7,176 "/>
|
||||||
|
<polygon class="st5" points="203,129.7 146,132.3 151.3,161.6 159.7,143.9 180,153.2 "/>
|
||||||
|
<polygon class="st5" points="81.1,153.2 101.3,143.9 109.7,161.6 115,132.3 58,129.7 "/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<polygon class="st6" points="58,129.7 81.9,176.4 81.1,153.2 "/>
|
||||||
|
<polygon class="st6" points="180,153.2 179.1,176.4 203,129.7 "/>
|
||||||
|
<polygon class="st6" points="115,132.3 109.7,161.6 116.4,196.2 117.9,150.6 "/>
|
||||||
|
<polygon class="st6" points="146,132.3 143.2,150.5 144.6,196.2 151.3,161.6 "/>
|
||||||
|
</g>
|
||||||
|
<polygon class="st7" points="151.3,161.6 144.6,196.2 149.4,199.6 179.1,176.4 180,153.2 "/>
|
||||||
|
<polygon class="st7" points="81.1,153.2 81.9,176.4 111.6,199.6 116.4,196.2 109.7,161.6 "/>
|
||||||
|
<polygon class="st8" points="151.9,231.5 152.2,222 149.6,219.8 111.4,219.8 108.9,222 109.1,231.5 77.1,216.3 88.3,225.5
|
||||||
|
111,241.2 149.9,241.2 172.7,225.5 183.8,216.3 "/>
|
||||||
|
<polygon class="st9" points="149.4,199.6 144.6,196.2 116.4,196.2 111.6,199.6 108.9,222 111.4,219.8 149.6,219.8 152.2,222 "/>
|
||||||
|
<g>
|
||||||
|
<polygon class="st10" points="251.4,81.1 259.9,39.7 247.1,1.2 149.4,73.7 187,105.5 240.1,121 251.8,107.3 246.7,103.6
|
||||||
|
254.8,96.2 248.6,91.4 256.7,85.2 "/>
|
||||||
|
<polygon class="st10" points="1.1,39.7 9.7,81.1 4.2,85.2 12.4,91.4 6.2,96.2 14.3,103.6 9.2,107.3 20.9,121 74,105.5 111.6,73.7
|
||||||
|
13.9,1.2 "/>
|
||||||
|
</g>
|
||||||
|
<polygon class="st7" points="240.1,121 187,105.5 203,129.7 179.1,176.4 210.7,176 257.9,176 "/>
|
||||||
|
<polygon class="st7" points="74,105.5 20.9,121 3.2,176 50.3,176 81.9,176.4 58,129.7 "/>
|
||||||
|
<polygon class="st7" points="146,132.3 149.4,73.7 164.8,32 96.2,32 111.6,73.7 115,132.3 116.3,150.7 116.4,196.2 144.6,196.2
|
||||||
|
144.7,150.7 "/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path class="st7" d="M1409.7,92.6V32.1h19.3c2.9,0,5.6,0.4,8.2,1c2.5,0.6,4.7,1.6,6.6,2.9c1.9,1.3,3.4,3,4.5,5.1
|
||||||
|
c1.1,2.1,1.6,4.5,1.6,7.3c0,3-0.9,5.5-2.5,7.7c-1.6,2.1-3.8,3.8-6.6,4.9c1.7,0.5,3.2,1.1,4.5,2c1.3,0.9,2.4,1.9,3.3,3.1
|
||||||
|
c0.9,1.2,1.6,2.6,2,4c0.5,1.5,0.7,3.1,0.7,4.7c0,2.9-0.5,5.4-1.6,7.6c-1.1,2.2-2.5,4-4.4,5.5c-1.9,1.5-4.1,2.6-6.6,3.3
|
||||||
|
c-2.6,0.8-5.3,1.2-8.3,1.2H1409.7z M1419.8,57.6h9.6c1.5,0,2.9-0.2,4.2-0.6c1.3-0.4,2.4-0.9,3.3-1.7c0.9-0.7,1.7-1.6,2.2-2.7
|
||||||
|
c0.6-1.1,0.8-2.3,0.8-3.7c0-1.5-0.3-2.8-0.8-3.9c-0.5-1.1-1.3-2-2.2-2.7c-1-0.7-2.1-1.2-3.4-1.5c-1.3-0.3-2.7-0.5-4.3-0.5h-9.5
|
||||||
|
V57.6z M1419.8,65.2v19.3h10.9c1.6,0,3-0.3,4.3-0.7c1.3-0.5,2.4-1.1,3.4-1.9c0.9-0.8,1.7-1.8,2.2-2.9c0.5-1.2,0.8-2.5,0.8-3.9
|
||||||
|
c0-1.5-0.2-2.9-0.7-4.1c-0.5-1.2-1.1-2.2-2-3.1c-0.9-0.8-2-1.5-3.2-1.9c-1.3-0.5-2.7-0.7-4.3-0.7H1419.8z"/>
|
||||||
|
<path class="st7" d="M1506.3,65.5h-24.9v19h29.1v8.1h-39.1V32.1h38.8v8.2h-28.8v17.1h24.9V65.5z"/>
|
||||||
|
<path class="st7" d="M1574.8,40.4h-18.6v52.2h-9.9V40.4h-18.4v-8.2h46.9V40.4z"/>
|
||||||
|
<path class="st7" d="M1615.2,78.6h-18.9l-4.2,14h-10.3l19.6-60.5h8.8l19.3,60.5h-10.3L1615.2,78.6z M1598.9,70h13.9l-6.9-23.7
|
||||||
|
L1598.9,70z"/>
|
||||||
|
</g>
|
||||||
|
<path class="st11" d="M1644.3,8c10.7,0,19.5,8.7,19.5,19.5v69.8c0,10.7-8.7,19.5-19.5,19.5H1395c-10.7,0-19.5-8.7-19.5-19.5V27.5
|
||||||
|
c0-10.7,8.7-19.5,19.5-19.5H1644.3 M1644.3,0H1395c-15.2,0-27.5,12.3-27.5,27.5v69.8c0,15.2,12.3,27.5,27.5,27.5h249.2
|
||||||
|
c15.2,0,27.5-12.3,27.5-27.5V27.5C1671.7,12.3,1659.4,0,1644.3,0L1644.3,0z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 8.7 KiB |
|
@ -43,7 +43,7 @@
|
||||||
ga('create', 'UA-68598031-1', 'auto' {'allowLinker':true});
|
ga('create', 'UA-68598031-1', 'auto' {'allowLinker':true});
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
ga('require', 'linker');
|
ga('require', 'linker');
|
||||||
ga('linker:autoLink', ['harrydenley.com', 'metamask.io'], false, true);
|
ga('linker:autoLink', ['metamask.io'], false, true);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -15,11 +15,11 @@ const asStream = require('obs-store/lib/asStream')
|
||||||
const ExtensionPlatform = require('./platforms/extension')
|
const ExtensionPlatform = require('./platforms/extension')
|
||||||
const Migrator = require('./lib/migrator/')
|
const Migrator = require('./lib/migrator/')
|
||||||
const migrations = require('./migrations/')
|
const migrations = require('./migrations/')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('extension-port-stream')
|
||||||
const createStreamSink = require('./lib/createStreamSink')
|
const createStreamSink = require('./lib/createStreamSink')
|
||||||
const NotificationManager = require('./lib/notification-manager.js')
|
const NotificationManager = require('./lib/notification-manager.js')
|
||||||
const MetamaskController = require('./metamask-controller')
|
const MetamaskController = require('./metamask-controller')
|
||||||
const firstTimeState = require('./first-time-state')
|
const rawFirstTimeState = require('./first-time-state')
|
||||||
const setupRaven = require('./lib/setupRaven')
|
const setupRaven = require('./lib/setupRaven')
|
||||||
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
|
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
|
||||||
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
|
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
|
||||||
|
@ -34,6 +34,9 @@ const {
|
||||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
ENVIRONMENT_TYPE_FULLSCREEN,
|
||||||
} = require('./lib/enums')
|
} = require('./lib/enums')
|
||||||
|
|
||||||
|
// METAMASK_TEST_CONFIG is used in e2e tests to set the default network to localhost
|
||||||
|
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG)
|
||||||
|
|
||||||
const STORAGE_KEY = 'metamask-config'
|
const STORAGE_KEY = 'metamask-config'
|
||||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
||||||
|
|
||||||
|
@ -253,6 +256,7 @@ function setupController (initState, initLangCode) {
|
||||||
showUnconfirmedMessage: triggerUi,
|
showUnconfirmedMessage: triggerUi,
|
||||||
unlockAccountMessage: triggerUi,
|
unlockAccountMessage: triggerUi,
|
||||||
showUnapprovedTx: triggerUi,
|
showUnapprovedTx: triggerUi,
|
||||||
|
showWatchAssetUi: showWatchAssetUi,
|
||||||
// initial state
|
// initial state
|
||||||
initState,
|
initState,
|
||||||
// initial locale code
|
// initial locale code
|
||||||
|
@ -445,3 +449,28 @@ function triggerUi () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the browser popup for user confirmation of watchAsset
|
||||||
|
* then it waits until user interact with the UI
|
||||||
|
*/
|
||||||
|
function showWatchAssetUi () {
|
||||||
|
triggerUi()
|
||||||
|
return new Promise(
|
||||||
|
(resolve) => {
|
||||||
|
var interval = setInterval(() => {
|
||||||
|
if (!notificationIsOpen) {
|
||||||
|
clearInterval(interval)
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// On first install, open a window to MetaMask website to how-it-works.
|
||||||
|
extension.runtime.onInstalled.addListener(function (details) {
|
||||||
|
if ((details.reason === 'install') && (!METAMASK_DEBUG)) {
|
||||||
|
extension.tabs.create({url: 'https://metamask.io/#how-it-works'})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
|
@ -5,7 +5,7 @@ const LocalMessageDuplexStream = require('post-message-stream')
|
||||||
const PongStream = require('ping-pong-stream/pong')
|
const PongStream = require('ping-pong-stream/pong')
|
||||||
const ObjectMultiplex = require('obj-multiplex')
|
const ObjectMultiplex = require('obj-multiplex')
|
||||||
const extension = require('extensionizer')
|
const extension = require('extensionizer')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('extension-port-stream')
|
||||||
|
|
||||||
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString()
|
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString()
|
||||||
const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n'
|
const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n'
|
||||||
|
|
|
@ -80,7 +80,7 @@ class BalanceController {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.accountTracker.store.subscribe(update)
|
this.accountTracker.store.subscribe(update)
|
||||||
this.blockTracker.on('block', update)
|
this.blockTracker.on('latest', update)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware')
|
||||||
|
const createBlockReEmitMiddleware = require('eth-json-rpc-middleware/block-reemit')
|
||||||
|
const createBlockCacheMiddleware = require('eth-json-rpc-middleware/block-cache')
|
||||||
|
const createInflightMiddleware = require('eth-json-rpc-middleware/inflight-cache')
|
||||||
|
const createBlockTrackerInspectorMiddleware = require('eth-json-rpc-middleware/block-tracker-inspector')
|
||||||
|
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware')
|
||||||
|
const createInfuraMiddleware = require('eth-json-rpc-infura')
|
||||||
|
const BlockTracker = require('eth-block-tracker')
|
||||||
|
|
||||||
|
module.exports = createInfuraClient
|
||||||
|
|
||||||
|
function createInfuraClient ({ network }) {
|
||||||
|
const infuraMiddleware = createInfuraMiddleware({ network })
|
||||||
|
const blockProvider = providerFromMiddleware(infuraMiddleware)
|
||||||
|
const blockTracker = new BlockTracker({ provider: blockProvider })
|
||||||
|
|
||||||
|
const networkMiddleware = mergeMiddleware([
|
||||||
|
createBlockCacheMiddleware({ blockTracker }),
|
||||||
|
createInflightMiddleware(),
|
||||||
|
createBlockReEmitMiddleware({ blockTracker, provider: blockProvider }),
|
||||||
|
createBlockTrackerInspectorMiddleware({ blockTracker }),
|
||||||
|
infuraMiddleware,
|
||||||
|
])
|
||||||
|
return { networkMiddleware, blockTracker }
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware')
|
||||||
|
const createFetchMiddleware = require('eth-json-rpc-middleware/fetch')
|
||||||
|
const createBlockRefMiddleware = require('eth-json-rpc-middleware/block-ref')
|
||||||
|
const createBlockCacheMiddleware = require('eth-json-rpc-middleware/block-cache')
|
||||||
|
const createInflightMiddleware = require('eth-json-rpc-middleware/inflight-cache')
|
||||||
|
const createBlockTrackerInspectorMiddleware = require('eth-json-rpc-middleware/block-tracker-inspector')
|
||||||
|
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware')
|
||||||
|
const BlockTracker = require('eth-block-tracker')
|
||||||
|
|
||||||
|
module.exports = createJsonRpcClient
|
||||||
|
|
||||||
|
function createJsonRpcClient ({ rpcUrl }) {
|
||||||
|
const fetchMiddleware = createFetchMiddleware({ rpcUrl })
|
||||||
|
const blockProvider = providerFromMiddleware(fetchMiddleware)
|
||||||
|
const blockTracker = new BlockTracker({ provider: blockProvider })
|
||||||
|
|
||||||
|
const networkMiddleware = mergeMiddleware([
|
||||||
|
createBlockRefMiddleware({ blockTracker }),
|
||||||
|
createBlockCacheMiddleware({ blockTracker }),
|
||||||
|
createInflightMiddleware(),
|
||||||
|
createBlockTrackerInspectorMiddleware({ blockTracker }),
|
||||||
|
fetchMiddleware,
|
||||||
|
])
|
||||||
|
return { networkMiddleware, blockTracker }
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware')
|
||||||
|
const createFetchMiddleware = require('eth-json-rpc-middleware/fetch')
|
||||||
|
const createBlockRefMiddleware = require('eth-json-rpc-middleware/block-ref')
|
||||||
|
const createBlockTrackerInspectorMiddleware = require('eth-json-rpc-middleware/block-tracker-inspector')
|
||||||
|
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware')
|
||||||
|
const BlockTracker = require('eth-block-tracker')
|
||||||
|
|
||||||
|
module.exports = createLocalhostClient
|
||||||
|
|
||||||
|
function createLocalhostClient () {
|
||||||
|
const fetchMiddleware = createFetchMiddleware({ rpcUrl: 'http://localhost:8545/' })
|
||||||
|
const blockProvider = providerFromMiddleware(fetchMiddleware)
|
||||||
|
const blockTracker = new BlockTracker({ provider: blockProvider, pollingInterval: 1000 })
|
||||||
|
|
||||||
|
const networkMiddleware = mergeMiddleware([
|
||||||
|
createBlockRefMiddleware({ blockTracker }),
|
||||||
|
createBlockTrackerInspectorMiddleware({ blockTracker }),
|
||||||
|
fetchMiddleware,
|
||||||
|
])
|
||||||
|
return { networkMiddleware, blockTracker }
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware')
|
||||||
|
const createScaffoldMiddleware = require('json-rpc-engine/src/createScaffoldMiddleware')
|
||||||
|
const createAsyncMiddleware = require('json-rpc-engine/src/createAsyncMiddleware')
|
||||||
|
const createWalletSubprovider = require('eth-json-rpc-middleware/wallet')
|
||||||
|
|
||||||
|
module.exports = createMetamaskMiddleware
|
||||||
|
|
||||||
|
function createMetamaskMiddleware ({
|
||||||
|
version,
|
||||||
|
getAccounts,
|
||||||
|
processTransaction,
|
||||||
|
processEthSignMessage,
|
||||||
|
processTypedMessage,
|
||||||
|
processPersonalMessage,
|
||||||
|
getPendingNonce,
|
||||||
|
}) {
|
||||||
|
const metamaskMiddleware = mergeMiddleware([
|
||||||
|
createScaffoldMiddleware({
|
||||||
|
// staticSubprovider
|
||||||
|
eth_syncing: false,
|
||||||
|
web3_clientVersion: `MetaMask/v${version}`,
|
||||||
|
}),
|
||||||
|
createWalletSubprovider({
|
||||||
|
getAccounts,
|
||||||
|
processTransaction,
|
||||||
|
processEthSignMessage,
|
||||||
|
processTypedMessage,
|
||||||
|
processPersonalMessage,
|
||||||
|
}),
|
||||||
|
createPendingNonceMiddleware({ getPendingNonce }),
|
||||||
|
])
|
||||||
|
return metamaskMiddleware
|
||||||
|
}
|
||||||
|
|
||||||
|
function createPendingNonceMiddleware ({ getPendingNonce }) {
|
||||||
|
return createAsyncMiddleware(async (req, res, next) => {
|
||||||
|
if (req.method !== 'eth_getTransactionCount') return next()
|
||||||
|
const address = req.params[0]
|
||||||
|
const blockRef = req.params[1]
|
||||||
|
if (blockRef !== 'pending') return next()
|
||||||
|
req.result = await getPendingNonce(address)
|
||||||
|
})
|
||||||
|
}
|
|
@ -1,15 +1,17 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const createMetamaskProvider = require('web3-provider-engine/zero.js')
|
|
||||||
const SubproviderFromProvider = require('web3-provider-engine/subproviders/provider.js')
|
|
||||||
const createInfuraProvider = require('eth-json-rpc-infura/src/createProvider')
|
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const ComposedStore = require('obs-store/lib/composed')
|
const ComposedStore = require('obs-store/lib/composed')
|
||||||
const extend = require('xtend')
|
|
||||||
const EthQuery = require('eth-query')
|
const EthQuery = require('eth-query')
|
||||||
const createEventEmitterProxy = require('../../lib/events-proxy.js')
|
const JsonRpcEngine = require('json-rpc-engine')
|
||||||
|
const providerFromEngine = require('eth-json-rpc-middleware/providerFromEngine')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const urlUtil = require('url')
|
const createMetamaskMiddleware = require('./createMetamaskMiddleware')
|
||||||
|
const createInfuraClient = require('./createInfuraClient')
|
||||||
|
const createJsonRpcClient = require('./createJsonRpcClient')
|
||||||
|
const createLocalhostClient = require('./createLocalhostClient')
|
||||||
|
const { createSwappableProxy, createEventEmitterProxy } = require('swappable-obj-proxy')
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ROPSTEN,
|
ROPSTEN,
|
||||||
RINKEBY,
|
RINKEBY,
|
||||||
|
@ -20,7 +22,6 @@ const {
|
||||||
POA,
|
POA,
|
||||||
DAI,
|
DAI,
|
||||||
} = require('./enums')
|
} = require('./enums')
|
||||||
const LOCALHOST_RPC_URL = 'http://localhost:8545'
|
|
||||||
const POA_RPC_URL = 'https://core.poa.network'
|
const POA_RPC_URL = 'https://core.poa.network'
|
||||||
const DAI_RPC_URL = 'https://dai.poa.network'
|
const DAI_RPC_URL = 'https://dai.poa.network'
|
||||||
const SOKOL_RPC_URL = 'https://sokol.poa.network'
|
const SOKOL_RPC_URL = 'https://sokol.poa.network'
|
||||||
|
@ -45,21 +46,27 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
this.providerStore = new ObservableStore(providerConfig)
|
this.providerStore = new ObservableStore(providerConfig)
|
||||||
this.networkStore = new ObservableStore('loading')
|
this.networkStore = new ObservableStore('loading')
|
||||||
this.store = new ComposedStore({ provider: this.providerStore, network: this.networkStore })
|
this.store = new ComposedStore({ provider: this.providerStore, network: this.networkStore })
|
||||||
// create event emitter proxy
|
|
||||||
this._proxy = createEventEmitterProxy()
|
|
||||||
|
|
||||||
this.on('networkDidChange', this.lookupNetwork)
|
this.on('networkDidChange', this.lookupNetwork)
|
||||||
|
// provider and block tracker
|
||||||
|
this._provider = null
|
||||||
|
this._blockTracker = null
|
||||||
|
// provider and block tracker proxies - because the network changes
|
||||||
|
this._providerProxy = null
|
||||||
|
this._blockTrackerProxy = null
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeProvider (_providerParams) {
|
initializeProvider (providerParams) {
|
||||||
this._baseProviderParams = _providerParams
|
this._baseProviderParams = providerParams
|
||||||
const { type, rpcTarget } = this.providerStore.getState()
|
const { type, rpcTarget } = this.providerStore.getState()
|
||||||
this._configureProvider({ type, rpcTarget })
|
this._configureProvider({ type, rpcTarget })
|
||||||
this._proxy.on('block', this._logBlock.bind(this))
|
|
||||||
this._proxy.on('error', this.verifyNetwork.bind(this))
|
|
||||||
this.ethQuery = new EthQuery(this._proxy)
|
|
||||||
this.lookupNetwork()
|
this.lookupNetwork()
|
||||||
return this._proxy
|
}
|
||||||
|
|
||||||
|
// return the proxies so the references will always be good
|
||||||
|
getProviderAndBlockTracker () {
|
||||||
|
const provider = this._providerProxy
|
||||||
|
const blockTracker = this._blockTrackerProxy
|
||||||
|
return { provider, blockTracker }
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyNetwork () {
|
verifyNetwork () {
|
||||||
|
@ -81,10 +88,11 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
|
|
||||||
lookupNetwork () {
|
lookupNetwork () {
|
||||||
// Prevent firing when provider is not defined.
|
// Prevent firing when provider is not defined.
|
||||||
if (!this.ethQuery || !this.ethQuery.sendAsync) {
|
if (!this._provider) {
|
||||||
return log.warn('NetworkController - lookupNetwork aborted due to missing ethQuery')
|
return log.warn('NetworkController - lookupNetwork aborted due to missing provider')
|
||||||
}
|
}
|
||||||
this.ethQuery.sendAsync({ method: 'net_version' }, (err, network) => {
|
const ethQuery = new EthQuery(this._provider)
|
||||||
|
ethQuery.sendAsync({ method: 'net_version' }, (err, network) => {
|
||||||
if (err) return this.setNetworkState('loading')
|
if (err) return this.setNetworkState('loading')
|
||||||
log.info('web3.getNetwork returned ' + network)
|
log.info('web3.getNetwork returned ' + network)
|
||||||
this.setNetworkState(network)
|
this.setNetworkState(network)
|
||||||
|
@ -143,7 +151,7 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
} else if (type === POA_SOKOL) {
|
} else if (type === POA_SOKOL) {
|
||||||
this._configureStandardProvider({ rpcUrl: SOKOL_RPC_URL })
|
this._configureStandardProvider({ rpcUrl: SOKOL_RPC_URL })
|
||||||
} else if (type === LOCALHOST) {
|
} else if (type === LOCALHOST) {
|
||||||
this._configureStandardProvider({ rpcUrl: LOCALHOST_RPC_URL })
|
this._configureLocalhostProvider()
|
||||||
// url-based rpc endpoints
|
// url-based rpc endpoints
|
||||||
} else if (type === 'rpc') {
|
} else if (type === 'rpc') {
|
||||||
this._configureStandardProvider({ rpcUrl: rpcTarget })
|
this._configureStandardProvider({ rpcUrl: rpcTarget })
|
||||||
|
@ -153,49 +161,47 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
_configureInfuraProvider ({ type }) {
|
_configureInfuraProvider ({ type }) {
|
||||||
log.info('_configureInfuraProvider', type)
|
log.info('NetworkController - configureInfuraProvider', type)
|
||||||
const infuraProvider = createInfuraProvider({ network: type })
|
const networkClient = createInfuraClient({ network: type })
|
||||||
const infuraSubprovider = new SubproviderFromProvider(infuraProvider)
|
this._setNetworkClient(networkClient)
|
||||||
const providerParams = extend(this._baseProviderParams, {
|
}
|
||||||
engineParams: {
|
|
||||||
pollingInterval: 8000,
|
_configureLocalhostProvider () {
|
||||||
blockTrackerProvider: infuraProvider,
|
log.info('NetworkController - configureLocalhostProvider')
|
||||||
},
|
const networkClient = createLocalhostClient()
|
||||||
dataSubprovider: infuraSubprovider,
|
this._setNetworkClient(networkClient)
|
||||||
})
|
|
||||||
const provider = createMetamaskProvider(providerParams)
|
|
||||||
this._setProvider(provider)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_configureStandardProvider ({ rpcUrl }) {
|
_configureStandardProvider ({ rpcUrl }) {
|
||||||
// urlUtil handles malformed urls
|
log.info('NetworkController - configureStandardProvider', rpcUrl)
|
||||||
rpcUrl = urlUtil.parse(rpcUrl).format()
|
const networkClient = createJsonRpcClient({ rpcUrl })
|
||||||
const providerParams = extend(this._baseProviderParams, {
|
this._setNetworkClient(networkClient)
|
||||||
rpcUrl,
|
|
||||||
engineParams: {
|
|
||||||
pollingInterval: 8000,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
const provider = createMetamaskProvider(providerParams)
|
|
||||||
this._setProvider(provider)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_setProvider (provider) {
|
_setNetworkClient ({ networkMiddleware, blockTracker }) {
|
||||||
// collect old block tracker events
|
const metamaskMiddleware = createMetamaskMiddleware(this._baseProviderParams)
|
||||||
const oldProvider = this._provider
|
const engine = new JsonRpcEngine()
|
||||||
let blockTrackerHandlers
|
engine.push(metamaskMiddleware)
|
||||||
if (oldProvider) {
|
engine.push(networkMiddleware)
|
||||||
// capture old block handlers
|
const provider = providerFromEngine(engine)
|
||||||
blockTrackerHandlers = oldProvider._blockTracker.proxyEventHandlers
|
this._setProviderAndBlockTracker({ provider, blockTracker })
|
||||||
// tear down
|
|
||||||
oldProvider.removeAllListeners()
|
|
||||||
oldProvider.stop()
|
|
||||||
}
|
}
|
||||||
// override block tracler
|
|
||||||
provider._blockTracker = createEventEmitterProxy(provider._blockTracker, blockTrackerHandlers)
|
_setProviderAndBlockTracker ({ provider, blockTracker }) {
|
||||||
// set as new provider
|
// update or intialize proxies
|
||||||
|
if (this._providerProxy) {
|
||||||
|
this._providerProxy.setTarget(provider)
|
||||||
|
} else {
|
||||||
|
this._providerProxy = createSwappableProxy(provider)
|
||||||
|
}
|
||||||
|
if (this._blockTrackerProxy) {
|
||||||
|
this._blockTrackerProxy.setTarget(blockTracker)
|
||||||
|
} else {
|
||||||
|
this._blockTrackerProxy = createEventEmitterProxy(blockTracker, { eventFilter: 'skipInternal' })
|
||||||
|
}
|
||||||
|
// set new provider and blockTracker
|
||||||
this._provider = provider
|
this._provider = provider
|
||||||
this._proxy.setTarget(provider)
|
this._blockTracker = blockTracker
|
||||||
}
|
}
|
||||||
|
|
||||||
_logBlock (block) {
|
_logBlock (block) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const normalizeAddress = require('eth-sig-util').normalize
|
const normalizeAddress = require('eth-sig-util').normalize
|
||||||
|
const { isValidAddress } = require('ethereumjs-util')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ class PreferencesController {
|
||||||
* @property {string} store.currentAccountTab Indicates the selected tab in the ui
|
* @property {string} store.currentAccountTab Indicates the selected tab in the ui
|
||||||
* @property {array} store.tokens The tokens the user wants display in their token lists
|
* @property {array} store.tokens The tokens the user wants display in their token lists
|
||||||
* @property {object} store.accountTokens The tokens stored per account and then per network type
|
* @property {object} store.accountTokens The tokens stored per account and then per network type
|
||||||
|
* @property {object} store.assetImages Contains assets objects related to assets added
|
||||||
* @property {boolean} store.useBlockie The users preference for blockie identicons within the UI
|
* @property {boolean} store.useBlockie The users preference for blockie identicons within the UI
|
||||||
* @property {object} store.featureFlags A key-boolean map, where keys refer to features and booleans to whether the
|
* @property {object} store.featureFlags A key-boolean map, where keys refer to features and booleans to whether the
|
||||||
* user wishes to see that feature
|
* user wishes to see that feature
|
||||||
|
@ -26,21 +28,42 @@ class PreferencesController {
|
||||||
frequentRpcList: [],
|
frequentRpcList: [],
|
||||||
currentAccountTab: 'history',
|
currentAccountTab: 'history',
|
||||||
accountTokens: {},
|
accountTokens: {},
|
||||||
|
assetImages: {},
|
||||||
tokens: [],
|
tokens: [],
|
||||||
|
suggestedTokens: {},
|
||||||
useBlockie: false,
|
useBlockie: false,
|
||||||
featureFlags: {},
|
featureFlags: {},
|
||||||
currentLocale: opts.initLangCode,
|
currentLocale: opts.initLangCode,
|
||||||
identities: {},
|
identities: {},
|
||||||
lostIdentities: {},
|
lostIdentities: {},
|
||||||
|
seedWords: null,
|
||||||
|
forgottenPassword: false,
|
||||||
}, opts.initState)
|
}, opts.initState)
|
||||||
|
|
||||||
this.diagnostics = opts.diagnostics
|
this.diagnostics = opts.diagnostics
|
||||||
this.network = opts.network
|
this.network = opts.network
|
||||||
this.store = new ObservableStore(initState)
|
this.store = new ObservableStore(initState)
|
||||||
|
this.showWatchAssetUi = opts.showWatchAssetUi
|
||||||
this._subscribeProviderType()
|
this._subscribeProviderType()
|
||||||
}
|
}
|
||||||
// PUBLIC METHODS
|
// PUBLIC METHODS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@code forgottenPassword} state property
|
||||||
|
* @param {boolean} forgottenPassword whether or not the user has forgotten their password
|
||||||
|
*/
|
||||||
|
setPasswordForgotten (forgottenPassword) {
|
||||||
|
this.store.updateState({ forgottenPassword })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@code seedWords} seed words
|
||||||
|
* @param {string|null} seedWords the seed words
|
||||||
|
*/
|
||||||
|
setSeedWords (seedWords) {
|
||||||
|
this.store.updateState({ seedWords })
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the `useBlockie` property
|
* Setter for the `useBlockie` property
|
||||||
*
|
*
|
||||||
|
@ -51,6 +74,53 @@ class PreferencesController {
|
||||||
this.store.updateState({ useBlockie: val })
|
this.store.updateState({ useBlockie: val })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSuggestedTokens () {
|
||||||
|
return this.store.getState().suggestedTokens
|
||||||
|
}
|
||||||
|
|
||||||
|
getAssetImages () {
|
||||||
|
return this.store.getState().assetImages
|
||||||
|
}
|
||||||
|
|
||||||
|
addSuggestedERC20Asset (tokenOpts) {
|
||||||
|
this._validateERC20AssetParams(tokenOpts)
|
||||||
|
const suggested = this.getSuggestedTokens()
|
||||||
|
const { rawAddress, symbol, decimals, image } = tokenOpts
|
||||||
|
const address = normalizeAddress(rawAddress)
|
||||||
|
const newEntry = { address, symbol, decimals, image }
|
||||||
|
suggested[address] = newEntry
|
||||||
|
this.store.updateState({ suggestedTokens: suggested })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RPC engine middleware for requesting new asset added
|
||||||
|
*
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param {Function} - next
|
||||||
|
* @param {Function} - end
|
||||||
|
*/
|
||||||
|
async requestWatchAsset (req, res, next, end) {
|
||||||
|
if (req.method === 'metamask_watchAsset') {
|
||||||
|
const { type, options } = req.params
|
||||||
|
switch (type) {
|
||||||
|
case 'ERC20':
|
||||||
|
const result = await this._handleWatchAssetERC20(options)
|
||||||
|
if (result instanceof Error) {
|
||||||
|
end(result)
|
||||||
|
} else {
|
||||||
|
res.result = result
|
||||||
|
end()
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
end(new Error(`Asset of type ${type} not supported`))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the `useBlockie` property
|
* Getter for the `useBlockie` property
|
||||||
*
|
*
|
||||||
|
@ -186,6 +256,13 @@ class PreferencesController {
|
||||||
return selected
|
return selected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeSuggestedTokens () {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.store.updateState({ suggestedTokens: {} })
|
||||||
|
resolve({})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the `selectedAddress` property
|
* Setter for the `selectedAddress` property
|
||||||
*
|
*
|
||||||
|
@ -232,11 +309,12 @@ class PreferencesController {
|
||||||
* @returns {Promise<array>} Promises the new array of AddedToken objects.
|
* @returns {Promise<array>} Promises the new array of AddedToken objects.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async addToken (rawAddress, symbol, decimals, network) {
|
async addToken (rawAddress, symbol, decimals, image, network) {
|
||||||
const address = normalizeAddress(rawAddress)
|
const address = normalizeAddress(rawAddress)
|
||||||
const newEntry = { address, symbol, decimals, network }
|
const newEntry = { address, symbol, decimals, network }
|
||||||
|
|
||||||
const tokens = this.store.getState().tokens
|
const tokens = this.store.getState().tokens
|
||||||
|
const assetImages = this.getAssetImages()
|
||||||
const previousEntry = tokens.find((token, index) => {
|
const previousEntry = tokens.find((token, index) => {
|
||||||
return (token.address === address && parseInt(token.network) === parseInt(network))
|
return (token.address === address && parseInt(token.network) === parseInt(network))
|
||||||
})
|
})
|
||||||
|
@ -247,7 +325,8 @@ class PreferencesController {
|
||||||
} else {
|
} else {
|
||||||
tokens.push(newEntry)
|
tokens.push(newEntry)
|
||||||
}
|
}
|
||||||
this._updateAccountTokens(tokens)
|
assetImages[address] = image
|
||||||
|
this._updateAccountTokens(tokens, assetImages)
|
||||||
return Promise.resolve(tokens)
|
return Promise.resolve(tokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,8 +339,10 @@ class PreferencesController {
|
||||||
*/
|
*/
|
||||||
removeToken (rawAddress) {
|
removeToken (rawAddress) {
|
||||||
const tokens = this.store.getState().tokens
|
const tokens = this.store.getState().tokens
|
||||||
|
const assetImages = this.getAssetImages()
|
||||||
const updatedTokens = tokens.filter(token => token.address !== rawAddress)
|
const updatedTokens = tokens.filter(token => token.address !== rawAddress)
|
||||||
this._updateAccountTokens(updatedTokens)
|
delete assetImages[rawAddress]
|
||||||
|
this._updateAccountTokens(updatedTokens, assetImages)
|
||||||
return Promise.resolve(updatedTokens)
|
return Promise.resolve(updatedTokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,6 +479,7 @@ class PreferencesController {
|
||||||
//
|
//
|
||||||
// PRIVATE METHODS
|
// PRIVATE METHODS
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscription to network provider type.
|
* Subscription to network provider type.
|
||||||
*
|
*
|
||||||
|
@ -416,10 +498,10 @@ class PreferencesController {
|
||||||
* @param {array} tokens Array of tokens to be updated.
|
* @param {array} tokens Array of tokens to be updated.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
_updateAccountTokens (tokens) {
|
_updateAccountTokens (tokens, assetImages) {
|
||||||
const { accountTokens, providerType, selectedAddress } = this._getTokenRelatedStates()
|
const { accountTokens, providerType, selectedAddress } = this._getTokenRelatedStates()
|
||||||
accountTokens[selectedAddress][providerType] = tokens
|
accountTokens[selectedAddress][providerType] = tokens
|
||||||
this.store.updateState({ accountTokens, tokens })
|
this.store.updateState({ accountTokens, tokens, assetImages })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -449,6 +531,47 @@ class PreferencesController {
|
||||||
const tokens = accountTokens[selectedAddress][providerType]
|
const tokens = accountTokens[selectedAddress][providerType]
|
||||||
return { tokens, accountTokens, providerType, selectedAddress }
|
return { tokens, accountTokens, providerType, selectedAddress }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the suggestion of an ERC20 asset through `watchAsset`
|
||||||
|
* *
|
||||||
|
* @param {Promise} promise Promise according to addition of ERC20 token
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
async _handleWatchAssetERC20 (options) {
|
||||||
|
const { address, symbol, decimals, image } = options
|
||||||
|
const rawAddress = address
|
||||||
|
try {
|
||||||
|
this._validateERC20AssetParams({ rawAddress, symbol, decimals })
|
||||||
|
} catch (err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
const tokenOpts = { rawAddress, decimals, symbol, image }
|
||||||
|
this.addSuggestedERC20Asset(tokenOpts)
|
||||||
|
return this.showWatchAssetUi().then(() => {
|
||||||
|
const tokenAddresses = this.getTokens().filter(token => token.address === normalizeAddress(rawAddress))
|
||||||
|
return tokenAddresses.length > 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates that the passed options for suggested token have all required properties.
|
||||||
|
*
|
||||||
|
* @param {Object} opts The options object to validate
|
||||||
|
* @throws {string} Throw a custom error indicating that address, symbol and/or decimals
|
||||||
|
* doesn't fulfill requirements
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
_validateERC20AssetParams (opts) {
|
||||||
|
const { rawAddress, symbol, decimals } = opts
|
||||||
|
if (!rawAddress || !symbol || !decimals) throw new Error(`Cannot suggest token without address, symbol, and decimals`)
|
||||||
|
if (!(symbol.length < 6)) throw new Error(`Invalid symbol ${symbol} more than five characters`)
|
||||||
|
const numDecimals = parseInt(decimals, 10)
|
||||||
|
if (isNaN(numDecimals) || numDecimals > 36 || numDecimals < 0) {
|
||||||
|
throw new Error(`Invalid decimals ${decimals} must be at least 0, and not over 36`)
|
||||||
|
}
|
||||||
|
if (!isValidAddress(rawAddress)) throw new Error(`Invalid address ${rawAddress}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PreferencesController
|
module.exports = PreferencesController
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const BN = require('ethereumjs-util').BN
|
|
||||||
const EthQuery = require('eth-query')
|
const EthQuery = require('eth-query')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
|
const pify = require('pify')
|
||||||
|
|
||||||
class RecentBlocksController {
|
class RecentBlocksController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller responsible for storing, updating and managing the recent history of blocks. Blocks are back filled
|
* Controller responsible for storing, updating and managing the recent history of blocks. Blocks are back filled
|
||||||
* upon the controller's construction and then the list is updated when the given block tracker gets a 'block' event
|
* upon the controller's construction and then the list is updated when the given block tracker gets a 'latest' event
|
||||||
* (indicating that there is a new block to process).
|
* (indicating that there is a new block to process).
|
||||||
*
|
*
|
||||||
* @typedef {Object} RecentBlocksController
|
* @typedef {Object} RecentBlocksController
|
||||||
|
@ -16,7 +16,7 @@ class RecentBlocksController {
|
||||||
* @param {BlockTracker} opts.blockTracker Contains objects necessary for tracking blocks and querying the blockchain
|
* @param {BlockTracker} opts.blockTracker Contains objects necessary for tracking blocks and querying the blockchain
|
||||||
* @param {BlockTracker} opts.provider The provider used to create a new EthQuery instance.
|
* @param {BlockTracker} opts.provider The provider used to create a new EthQuery instance.
|
||||||
* @property {BlockTracker} blockTracker Points to the passed BlockTracker. On RecentBlocksController construction,
|
* @property {BlockTracker} blockTracker Points to the passed BlockTracker. On RecentBlocksController construction,
|
||||||
* listens for 'block' events so that new blocks can be processed and added to storage.
|
* listens for 'latest' events so that new blocks can be processed and added to storage.
|
||||||
* @property {EthQuery} ethQuery Points to the EthQuery instance created with the passed provider
|
* @property {EthQuery} ethQuery Points to the EthQuery instance created with the passed provider
|
||||||
* @property {number} historyLength The maximum length of blocks to track
|
* @property {number} historyLength The maximum length of blocks to track
|
||||||
* @property {object} store Stores the recentBlocks
|
* @property {object} store Stores the recentBlocks
|
||||||
|
@ -34,7 +34,13 @@ class RecentBlocksController {
|
||||||
}, opts.initState)
|
}, opts.initState)
|
||||||
this.store = new ObservableStore(initState)
|
this.store = new ObservableStore(initState)
|
||||||
|
|
||||||
this.blockTracker.on('block', this.processBlock.bind(this))
|
this.blockTracker.on('latest', async (newBlockNumberHex) => {
|
||||||
|
try {
|
||||||
|
await this.processBlock(newBlockNumberHex)
|
||||||
|
} catch (err) {
|
||||||
|
log.error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
this.backfill()
|
this.backfill()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +61,11 @@ class RecentBlocksController {
|
||||||
* @param {object} newBlock The new block to modify and add to the recentBlocks array
|
* @param {object} newBlock The new block to modify and add to the recentBlocks array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
processBlock (newBlock) {
|
async processBlock (newBlockNumberHex) {
|
||||||
|
const newBlockNumber = Number.parseInt(newBlockNumberHex, 16)
|
||||||
|
const newBlock = await this.getBlockByNumber(newBlockNumber, true)
|
||||||
|
if (!newBlock) return
|
||||||
|
|
||||||
const block = this.mapTransactionsToPrices(newBlock)
|
const block = this.mapTransactionsToPrices(newBlock)
|
||||||
|
|
||||||
const state = this.store.getState()
|
const state = this.store.getState()
|
||||||
|
@ -108,9 +118,9 @@ class RecentBlocksController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On this.blockTracker's first 'block' event after this RecentBlocksController's instantiation, the store.recentBlocks
|
* On this.blockTracker's first 'latest' event after this RecentBlocksController's instantiation, the store.recentBlocks
|
||||||
* array is populated with this.historyLength number of blocks. The block number of the this.blockTracker's first
|
* array is populated with this.historyLength number of blocks. The block number of the this.blockTracker's first
|
||||||
* 'block' event is used to iteratively generate all the numbers of the previous blocks, which are obtained by querying
|
* 'latest' event is used to iteratively generate all the numbers of the previous blocks, which are obtained by querying
|
||||||
* the blockchain. These blocks are backfilled so that the recentBlocks array is ordered from oldest to newest.
|
* the blockchain. These blocks are backfilled so that the recentBlocks array is ordered from oldest to newest.
|
||||||
*
|
*
|
||||||
* Each iteration over the block numbers is delayed by 100 milliseconds.
|
* Each iteration over the block numbers is delayed by 100 milliseconds.
|
||||||
|
@ -118,18 +128,17 @@ class RecentBlocksController {
|
||||||
* @returns {Promise<void>} Promises undefined
|
* @returns {Promise<void>} Promises undefined
|
||||||
*/
|
*/
|
||||||
async backfill () {
|
async backfill () {
|
||||||
this.blockTracker.once('block', async (block) => {
|
this.blockTracker.once('latest', async (blockNumberHex) => {
|
||||||
const currentBlockNumber = Number.parseInt(block.number, 16)
|
const currentBlockNumber = Number.parseInt(blockNumberHex, 16)
|
||||||
const blocksToFetch = Math.min(currentBlockNumber, this.historyLength)
|
const blocksToFetch = Math.min(currentBlockNumber, this.historyLength)
|
||||||
const prevBlockNumber = currentBlockNumber - 1
|
const prevBlockNumber = currentBlockNumber - 1
|
||||||
const targetBlockNumbers = Array(blocksToFetch).fill().map((_, index) => prevBlockNumber - index)
|
const targetBlockNumbers = Array(blocksToFetch).fill().map((_, index) => prevBlockNumber - index)
|
||||||
await Promise.all(targetBlockNumbers.map(async (targetBlockNumber) => {
|
await Promise.all(targetBlockNumbers.map(async (targetBlockNumber) => {
|
||||||
try {
|
try {
|
||||||
const newBlock = await this.getBlockByNumber(targetBlockNumber)
|
const newBlock = await this.getBlockByNumber(targetBlockNumber, true)
|
||||||
|
if (!newBlock) return
|
||||||
|
|
||||||
if (newBlock) {
|
|
||||||
this.backfillBlock(newBlock)
|
this.backfillBlock(newBlock)
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(e)
|
log.error(e)
|
||||||
}
|
}
|
||||||
|
@ -137,18 +146,6 @@ class RecentBlocksController {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A helper for this.backfill. Provides an easy way to ensure a 100 millisecond delay using await
|
|
||||||
*
|
|
||||||
* @returns {Promise<void>} Promises undefined
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
async wait () {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
setTimeout(resolve, 100)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses EthQuery to get a block that has a given block number.
|
* Uses EthQuery to get a block that has a given block number.
|
||||||
*
|
*
|
||||||
|
@ -157,13 +154,8 @@ class RecentBlocksController {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async getBlockByNumber (number) {
|
async getBlockByNumber (number) {
|
||||||
const bn = new BN(number)
|
const blockNumberHex = '0x' + number.toString(16)
|
||||||
return new Promise((resolve, reject) => {
|
return await pify(this.ethQuery.getBlockByNumber).call(this.ethQuery, blockNumberHex, true)
|
||||||
this.ethQuery.getBlockByNumber('0x' + bn.toString(16), true, (err, block) => {
|
|
||||||
if (err) reject(err)
|
|
||||||
resolve(block)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
const TRANSACTION_TYPE_CANCEL = 'cancel'
|
||||||
|
const TRANSACTION_TYPE_RETRY = 'retry'
|
||||||
|
const TRANSACTION_TYPE_STANDARD = 'standard'
|
||||||
|
|
||||||
|
const TRANSACTION_STATUS_APPROVED = 'approved'
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
TRANSACTION_TYPE_CANCEL,
|
||||||
|
TRANSACTION_TYPE_RETRY,
|
||||||
|
TRANSACTION_TYPE_STANDARD,
|
||||||
|
TRANSACTION_STATUS_APPROVED,
|
||||||
|
}
|
|
@ -11,6 +11,14 @@ const txUtils = require('./lib/util')
|
||||||
const cleanErrorStack = require('../../lib/cleanErrorStack')
|
const cleanErrorStack = require('../../lib/cleanErrorStack')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const recipientBlacklistChecker = require('./lib/recipient-blacklist-checker')
|
const recipientBlacklistChecker = require('./lib/recipient-blacklist-checker')
|
||||||
|
const {
|
||||||
|
TRANSACTION_TYPE_CANCEL,
|
||||||
|
TRANSACTION_TYPE_RETRY,
|
||||||
|
TRANSACTION_TYPE_STANDARD,
|
||||||
|
TRANSACTION_STATUS_APPROVED,
|
||||||
|
} = require('./enums')
|
||||||
|
|
||||||
|
const { hexToBn, bnToHex } = require('../../lib/util')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Transaction Controller is an aggregate of sub-controllers and trackers
|
Transaction Controller is an aggregate of sub-controllers and trackers
|
||||||
|
@ -65,6 +73,7 @@ class TransactionController extends EventEmitter {
|
||||||
this.store = this.txStateManager.store
|
this.store = this.txStateManager.store
|
||||||
this.nonceTracker = new NonceTracker({
|
this.nonceTracker = new NonceTracker({
|
||||||
provider: this.provider,
|
provider: this.provider,
|
||||||
|
blockTracker: this.blockTracker,
|
||||||
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
|
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
|
||||||
getConfirmedTransactions: this.txStateManager.getConfirmedTransactions.bind(this.txStateManager),
|
getConfirmedTransactions: this.txStateManager.getConfirmedTransactions.bind(this.txStateManager),
|
||||||
})
|
})
|
||||||
|
@ -78,13 +87,17 @@ class TransactionController extends EventEmitter {
|
||||||
})
|
})
|
||||||
|
|
||||||
this.txStateManager.store.subscribe(() => this.emit('update:badge'))
|
this.txStateManager.store.subscribe(() => this.emit('update:badge'))
|
||||||
this._setupListners()
|
this._setupListeners()
|
||||||
// memstore is computed from a few different stores
|
// memstore is computed from a few different stores
|
||||||
this._updateMemstore()
|
this._updateMemstore()
|
||||||
this.txStateManager.store.subscribe(() => this._updateMemstore())
|
this.txStateManager.store.subscribe(() => this._updateMemstore())
|
||||||
this.networkStore.subscribe(() => this._updateMemstore())
|
this.networkStore.subscribe(() => this._updateMemstore())
|
||||||
this.preferencesStore.subscribe(() => this._updateMemstore())
|
this.preferencesStore.subscribe(() => this._updateMemstore())
|
||||||
|
|
||||||
|
// request state update to finalize initialization
|
||||||
|
this._updatePendingTxsAfterFirstBlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {number} the chainId*/
|
/** @returns {number} the chainId*/
|
||||||
getChainId () {
|
getChainId () {
|
||||||
const networkState = this.networkStore.getState()
|
const networkState = this.networkStore.getState()
|
||||||
|
@ -155,7 +168,10 @@ class TransactionController extends EventEmitter {
|
||||||
const normalizedTxParams = txUtils.normalizeTxParams(txParams)
|
const normalizedTxParams = txUtils.normalizeTxParams(txParams)
|
||||||
txUtils.validateTxParams(normalizedTxParams)
|
txUtils.validateTxParams(normalizedTxParams)
|
||||||
// construct txMeta
|
// construct txMeta
|
||||||
let txMeta = this.txStateManager.generateTxMeta({ txParams: normalizedTxParams })
|
let txMeta = this.txStateManager.generateTxMeta({
|
||||||
|
txParams: normalizedTxParams,
|
||||||
|
type: TRANSACTION_TYPE_STANDARD,
|
||||||
|
})
|
||||||
this.addTx(txMeta)
|
this.addTx(txMeta)
|
||||||
this.emit('newUnapprovedTx', txMeta)
|
this.emit('newUnapprovedTx', txMeta)
|
||||||
|
|
||||||
|
@ -209,12 +225,46 @@ class TransactionController extends EventEmitter {
|
||||||
txParams: originalTxMeta.txParams,
|
txParams: originalTxMeta.txParams,
|
||||||
lastGasPrice,
|
lastGasPrice,
|
||||||
loadingDefaults: false,
|
loadingDefaults: false,
|
||||||
|
type: TRANSACTION_TYPE_RETRY,
|
||||||
})
|
})
|
||||||
this.addTx(txMeta)
|
this.addTx(txMeta)
|
||||||
this.emit('newUnapprovedTx', txMeta)
|
this.emit('newUnapprovedTx', txMeta)
|
||||||
return txMeta
|
return txMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new approved transaction to attempt to cancel a previously submitted transaction. The
|
||||||
|
* new transaction contains the same nonce as the previous, is a basic ETH transfer of 0x value to
|
||||||
|
* the sender's address, and has a higher gasPrice than that of the previous transaction.
|
||||||
|
* @param {number} originalTxId - the id of the txMeta that you want to attempt to cancel
|
||||||
|
* @param {string=} customGasPrice - the hex value to use for the cancel transaction
|
||||||
|
* @returns {txMeta}
|
||||||
|
*/
|
||||||
|
async createCancelTransaction (originalTxId, customGasPrice) {
|
||||||
|
const originalTxMeta = this.txStateManager.getTx(originalTxId)
|
||||||
|
const { txParams } = originalTxMeta
|
||||||
|
const { gasPrice: lastGasPrice, from, nonce } = txParams
|
||||||
|
const newGasPrice = customGasPrice || bnToHex(hexToBn(lastGasPrice).mul(1.1))
|
||||||
|
const newTxMeta = this.txStateManager.generateTxMeta({
|
||||||
|
txParams: {
|
||||||
|
from,
|
||||||
|
to: from,
|
||||||
|
nonce,
|
||||||
|
gas: '0x5208',
|
||||||
|
value: '0x0',
|
||||||
|
gasPrice: newGasPrice,
|
||||||
|
},
|
||||||
|
lastGasPrice,
|
||||||
|
loadingDefaults: false,
|
||||||
|
status: TRANSACTION_STATUS_APPROVED,
|
||||||
|
type: TRANSACTION_TYPE_CANCEL,
|
||||||
|
})
|
||||||
|
|
||||||
|
this.addTx(newTxMeta)
|
||||||
|
await this.approveTransaction(newTxMeta.id)
|
||||||
|
return newTxMeta
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
updates the txMeta in the txStateManager
|
updates the txMeta in the txStateManager
|
||||||
@param txMeta {Object} - the updated txMeta
|
@param txMeta {Object} - the updated txMeta
|
||||||
|
@ -311,6 +361,11 @@ class TransactionController extends EventEmitter {
|
||||||
this.txStateManager.setTxStatusSubmitted(txId)
|
this.txStateManager.setTxStatusSubmitted(txId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
confirmTransaction (txId) {
|
||||||
|
this.txStateManager.setTxStatusConfirmed(txId)
|
||||||
|
this._markNonceDuplicatesDropped(txId)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Convenience method for the ui thats sets the transaction to rejected
|
Convenience method for the ui thats sets the transaction to rejected
|
||||||
@param txId {number} - the tx's Id
|
@param txId {number} - the tx's Id
|
||||||
|
@ -354,6 +409,14 @@ class TransactionController extends EventEmitter {
|
||||||
this.getFilteredTxList = (opts) => this.txStateManager.getFilteredTxList(opts)
|
this.getFilteredTxList = (opts) => this.txStateManager.getFilteredTxList(opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called once on startup
|
||||||
|
async _updatePendingTxsAfterFirstBlock () {
|
||||||
|
// wait for first block so we know we're ready
|
||||||
|
await this.blockTracker.getLatestBlock()
|
||||||
|
// get status update for all pending transactions (for the current network)
|
||||||
|
await this.pendingTxTracker.updatePendingTxs()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
If transaction controller was rebooted with transactions that are uncompleted
|
If transaction controller was rebooted with transactions that are uncompleted
|
||||||
in steps of the transaction signing or user confirmation process it will either
|
in steps of the transaction signing or user confirmation process it will either
|
||||||
|
@ -375,7 +438,7 @@ class TransactionController extends EventEmitter {
|
||||||
})
|
})
|
||||||
|
|
||||||
this.txStateManager.getFilteredTxList({
|
this.txStateManager.getFilteredTxList({
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUS_APPROVED,
|
||||||
}).forEach((txMeta) => {
|
}).forEach((txMeta) => {
|
||||||
const txSignError = new Error('Transaction found as "approved" during boot - possibly stuck during signing')
|
const txSignError = new Error('Transaction found as "approved" during boot - possibly stuck during signing')
|
||||||
this.txStateManager.setTxStatusFailed(txMeta.id, txSignError)
|
this.txStateManager.setTxStatusFailed(txMeta.id, txSignError)
|
||||||
|
@ -386,14 +449,14 @@ class TransactionController extends EventEmitter {
|
||||||
is called in constructor applies the listeners for pendingTxTracker txStateManager
|
is called in constructor applies the listeners for pendingTxTracker txStateManager
|
||||||
and blockTracker
|
and blockTracker
|
||||||
*/
|
*/
|
||||||
_setupListners () {
|
_setupListeners () {
|
||||||
this.txStateManager.on('tx:status-update', this.emit.bind(this, 'tx:status-update'))
|
this.txStateManager.on('tx:status-update', this.emit.bind(this, 'tx:status-update'))
|
||||||
|
this._setupBlockTrackerListener()
|
||||||
this.pendingTxTracker.on('tx:warning', (txMeta) => {
|
this.pendingTxTracker.on('tx:warning', (txMeta) => {
|
||||||
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:warning')
|
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:warning')
|
||||||
})
|
})
|
||||||
this.pendingTxTracker.on('tx:confirmed', (txId) => this.txStateManager.setTxStatusConfirmed(txId))
|
|
||||||
this.pendingTxTracker.on('tx:confirmed', (txId) => this._markNonceDuplicatesDropped(txId))
|
|
||||||
this.pendingTxTracker.on('tx:failed', this.txStateManager.setTxStatusFailed.bind(this.txStateManager))
|
this.pendingTxTracker.on('tx:failed', this.txStateManager.setTxStatusFailed.bind(this.txStateManager))
|
||||||
|
this.pendingTxTracker.on('tx:confirmed', (txId) => this.confirmTransaction(txId))
|
||||||
this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => {
|
this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => {
|
||||||
if (!txMeta.firstRetryBlockNumber) {
|
if (!txMeta.firstRetryBlockNumber) {
|
||||||
txMeta.firstRetryBlockNumber = latestBlockNumber
|
txMeta.firstRetryBlockNumber = latestBlockNumber
|
||||||
|
@ -405,13 +468,6 @@ class TransactionController extends EventEmitter {
|
||||||
txMeta.retryCount++
|
txMeta.retryCount++
|
||||||
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:retry')
|
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:retry')
|
||||||
})
|
})
|
||||||
|
|
||||||
this.blockTracker.on('block', this.pendingTxTracker.checkForTxInBlock.bind(this.pendingTxTracker))
|
|
||||||
// this is a little messy but until ethstore has been either
|
|
||||||
// removed or redone this is to guard against the race condition
|
|
||||||
this.blockTracker.on('latest', this.pendingTxTracker.resubmitPendingTxs.bind(this.pendingTxTracker))
|
|
||||||
this.blockTracker.on('sync', this.pendingTxTracker.queryPendingTxs.bind(this.pendingTxTracker))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -435,6 +491,40 @@ class TransactionController extends EventEmitter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setupBlockTrackerListener () {
|
||||||
|
let listenersAreActive = false
|
||||||
|
const latestBlockHandler = this._onLatestBlock.bind(this)
|
||||||
|
const blockTracker = this.blockTracker
|
||||||
|
const txStateManager = this.txStateManager
|
||||||
|
|
||||||
|
txStateManager.on('tx:status-update', updateSubscription)
|
||||||
|
updateSubscription()
|
||||||
|
|
||||||
|
function updateSubscription () {
|
||||||
|
const pendingTxs = txStateManager.getPendingTransactions()
|
||||||
|
if (!listenersAreActive && pendingTxs.length > 0) {
|
||||||
|
blockTracker.on('latest', latestBlockHandler)
|
||||||
|
listenersAreActive = true
|
||||||
|
} else if (listenersAreActive && !pendingTxs.length) {
|
||||||
|
blockTracker.removeListener('latest', latestBlockHandler)
|
||||||
|
listenersAreActive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async _onLatestBlock (blockNumber) {
|
||||||
|
try {
|
||||||
|
await this.pendingTxTracker.updatePendingTxs()
|
||||||
|
} catch (err) {
|
||||||
|
log.error(err)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await this.pendingTxTracker.resubmitPendingTxs(blockNumber)
|
||||||
|
} catch (err) {
|
||||||
|
log.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Updates the memStore in transaction controller
|
Updates the memStore in transaction controller
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,8 +12,9 @@ const Mutex = require('await-semaphore').Mutex
|
||||||
*/
|
*/
|
||||||
class NonceTracker {
|
class NonceTracker {
|
||||||
|
|
||||||
constructor ({ provider, getPendingTransactions, getConfirmedTransactions }) {
|
constructor ({ provider, blockTracker, getPendingTransactions, getConfirmedTransactions }) {
|
||||||
this.provider = provider
|
this.provider = provider
|
||||||
|
this.blockTracker = blockTracker
|
||||||
this.ethQuery = new EthQuery(provider)
|
this.ethQuery = new EthQuery(provider)
|
||||||
this.getPendingTransactions = getPendingTransactions
|
this.getPendingTransactions = getPendingTransactions
|
||||||
this.getConfirmedTransactions = getConfirmedTransactions
|
this.getConfirmedTransactions = getConfirmedTransactions
|
||||||
|
@ -34,7 +35,7 @@ class NonceTracker {
|
||||||
* @typedef NonceDetails
|
* @typedef NonceDetails
|
||||||
* @property {number} highestLocallyConfirmed - A hex string of the highest nonce on a confirmed transaction.
|
* @property {number} highestLocallyConfirmed - A hex string of the highest nonce on a confirmed transaction.
|
||||||
* @property {number} nextNetworkNonce - The next nonce suggested by the eth_getTransactionCount method.
|
* @property {number} nextNetworkNonce - The next nonce suggested by the eth_getTransactionCount method.
|
||||||
* @property {number} highetSuggested - The maximum between the other two, the number returned.
|
* @property {number} highestSuggested - The maximum between the other two, the number returned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,15 +81,6 @@ class NonceTracker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _getCurrentBlock () {
|
|
||||||
const blockTracker = this._getBlockTracker()
|
|
||||||
const currentBlock = blockTracker.getCurrentBlock()
|
|
||||||
if (currentBlock) return currentBlock
|
|
||||||
return await new Promise((reject, resolve) => {
|
|
||||||
blockTracker.once('latest', resolve)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async _globalMutexFree () {
|
async _globalMutexFree () {
|
||||||
const globalMutex = this._lookupMutex('global')
|
const globalMutex = this._lookupMutex('global')
|
||||||
const releaseLock = await globalMutex.acquire()
|
const releaseLock = await globalMutex.acquire()
|
||||||
|
@ -114,9 +106,8 @@ class NonceTracker {
|
||||||
// calculate next nonce
|
// calculate next nonce
|
||||||
// we need to make sure our base count
|
// we need to make sure our base count
|
||||||
// and pending count are from the same block
|
// and pending count are from the same block
|
||||||
const currentBlock = await this._getCurrentBlock()
|
const blockNumber = await this.blockTracker.getLatestBlock()
|
||||||
const blockNumber = currentBlock.blockNumber
|
const baseCountBN = await this.ethQuery.getTransactionCount(address, blockNumber)
|
||||||
const baseCountBN = await this.ethQuery.getTransactionCount(address, blockNumber || 'latest')
|
|
||||||
const baseCount = baseCountBN.toNumber()
|
const baseCount = baseCountBN.toNumber()
|
||||||
assert(Number.isInteger(baseCount), `nonce-tracker - baseCount is not an integer - got: (${typeof baseCount}) "${baseCount}"`)
|
assert(Number.isInteger(baseCount), `nonce-tracker - baseCount is not an integer - got: (${typeof baseCount}) "${baseCount}"`)
|
||||||
const nonceDetails = { blockNumber, baseCount }
|
const nonceDetails = { blockNumber, baseCount }
|
||||||
|
@ -165,15 +156,6 @@ class NonceTracker {
|
||||||
return { name: 'local', nonce: highest, details: { startPoint, highest } }
|
return { name: 'local', nonce: highest, details: { startPoint, highest } }
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is a hotfix for the fact that the blockTracker will
|
|
||||||
// change when the network changes
|
|
||||||
|
|
||||||
/**
|
|
||||||
@returns {Object} the current blockTracker
|
|
||||||
*/
|
|
||||||
_getBlockTracker () {
|
|
||||||
return this.provider._blockTracker
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = NonceTracker
|
module.exports = NonceTracker
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const EthQuery = require('ethjs-query')
|
const EthQuery = require('ethjs-query')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Event emitter utility class for tracking the transactions as they<br>
|
Event emitter utility class for tracking the transactions as they<br>
|
||||||
|
@ -23,55 +24,26 @@ class PendingTransactionTracker extends EventEmitter {
|
||||||
super()
|
super()
|
||||||
this.query = new EthQuery(config.provider)
|
this.query = new EthQuery(config.provider)
|
||||||
this.nonceTracker = config.nonceTracker
|
this.nonceTracker = config.nonceTracker
|
||||||
// default is one day
|
|
||||||
this.getPendingTransactions = config.getPendingTransactions
|
this.getPendingTransactions = config.getPendingTransactions
|
||||||
this.getCompletedTransactions = config.getCompletedTransactions
|
this.getCompletedTransactions = config.getCompletedTransactions
|
||||||
this.publishTransaction = config.publishTransaction
|
this.publishTransaction = config.publishTransaction
|
||||||
this._checkPendingTxs()
|
this.confirmTransaction = config.confirmTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
checks if a signed tx is in a block and
|
checks the network for signed txs and releases the nonce global lock if it is
|
||||||
if it is included emits tx status as 'confirmed'
|
|
||||||
@param block {object}, a full block
|
|
||||||
@emits tx:confirmed
|
|
||||||
@emits tx:failed
|
|
||||||
*/
|
*/
|
||||||
checkForTxInBlock (block) {
|
async updatePendingTxs () {
|
||||||
const signedTxList = this.getPendingTransactions()
|
// in order to keep the nonceTracker accurate we block it while updating pending transactions
|
||||||
if (!signedTxList.length) return
|
const nonceGlobalLock = await this.nonceTracker.getGlobalLock()
|
||||||
signedTxList.forEach((txMeta) => {
|
try {
|
||||||
const txHash = txMeta.hash
|
const pendingTxs = this.getPendingTransactions()
|
||||||
const txId = txMeta.id
|
await Promise.all(pendingTxs.map((txMeta) => this._checkPendingTx(txMeta)))
|
||||||
|
} catch (err) {
|
||||||
if (!txHash) {
|
log.error('PendingTransactionTracker - Error updating pending transactions')
|
||||||
const noTxHashErr = new Error('We had an error while submitting this transaction, please try again.')
|
log.error(err)
|
||||||
noTxHashErr.name = 'NoTxHashError'
|
|
||||||
this.emit('tx:failed', txId, noTxHashErr)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
nonceGlobalLock.releaseLock()
|
||||||
|
|
||||||
block.transactions.forEach((tx) => {
|
|
||||||
if (tx.hash === txHash) this.emit('tx:confirmed', txId)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
asks the network for the transaction to see if a block number is included on it
|
|
||||||
if we have skipped/missed blocks
|
|
||||||
@param object - oldBlock newBlock
|
|
||||||
*/
|
|
||||||
queryPendingTxs ({ oldBlock, newBlock }) {
|
|
||||||
// check pending transactions on start
|
|
||||||
if (!oldBlock) {
|
|
||||||
this._checkPendingTxs()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// if we synced by more than one block, check for missed pending transactions
|
|
||||||
const diff = Number.parseInt(newBlock.number, 16) - Number.parseInt(oldBlock.number, 16)
|
|
||||||
if (diff > 1) this._checkPendingTxs()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,11 +51,11 @@ class PendingTransactionTracker extends EventEmitter {
|
||||||
@param block {object} - a block object
|
@param block {object} - a block object
|
||||||
@emits tx:warning
|
@emits tx:warning
|
||||||
*/
|
*/
|
||||||
resubmitPendingTxs (block) {
|
resubmitPendingTxs (blockNumber) {
|
||||||
const pending = this.getPendingTransactions()
|
const pending = this.getPendingTransactions()
|
||||||
// only try resubmitting if their are transactions to resubmit
|
// only try resubmitting if their are transactions to resubmit
|
||||||
if (!pending.length) return
|
if (!pending.length) return
|
||||||
pending.forEach((txMeta) => this._resubmitTx(txMeta, block.number).catch((err) => {
|
pending.forEach((txMeta) => this._resubmitTx(txMeta, blockNumber).catch((err) => {
|
||||||
/*
|
/*
|
||||||
Dont marked as failed if the error is a "known" transaction warning
|
Dont marked as failed if the error is a "known" transaction warning
|
||||||
"there is already a transaction with the same sender-nonce
|
"there is already a transaction with the same sender-nonce
|
||||||
|
@ -145,6 +117,7 @@ class PendingTransactionTracker extends EventEmitter {
|
||||||
this.emit('tx:retry', txMeta)
|
this.emit('tx:retry', txMeta)
|
||||||
return txHash
|
return txHash
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ask the network for the transaction to see if it has been include in a block
|
Ask the network for the transaction to see if it has been include in a block
|
||||||
@param txMeta {Object} - the txMeta object
|
@param txMeta {Object} - the txMeta object
|
||||||
|
@ -174,9 +147,8 @@ class PendingTransactionTracker extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get latest transaction status
|
// get latest transaction status
|
||||||
let txParams
|
|
||||||
try {
|
try {
|
||||||
txParams = await this.query.getTransactionByHash(txHash)
|
const txParams = await this.query.getTransactionByHash(txHash)
|
||||||
if (!txParams) return
|
if (!txParams) return
|
||||||
if (txParams.blockNumber) {
|
if (txParams.blockNumber) {
|
||||||
this.emit('tx:confirmed', txId)
|
this.emit('tx:confirmed', txId)
|
||||||
|
@ -190,27 +162,13 @@ class PendingTransactionTracker extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
checks the network for signed txs and releases the nonce global lock if it is
|
|
||||||
*/
|
|
||||||
async _checkPendingTxs () {
|
|
||||||
const signedTxList = this.getPendingTransactions()
|
|
||||||
// in order to keep the nonceTracker accurate we block it while updating pending transactions
|
|
||||||
const { releaseLock } = await this.nonceTracker.getGlobalLock()
|
|
||||||
try {
|
|
||||||
await Promise.all(signedTxList.map((txMeta) => this._checkPendingTx(txMeta)))
|
|
||||||
} catch (err) {
|
|
||||||
log.error('PendingTransactionWatcher - Error updating pending transactions')
|
|
||||||
log.error(err)
|
|
||||||
}
|
|
||||||
releaseLock()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
checks to see if a confirmed txMeta has the same nonce
|
checks to see if a confirmed txMeta has the same nonce
|
||||||
@param txMeta {Object} - txMeta object
|
@param txMeta {Object} - txMeta object
|
||||||
@returns {boolean}
|
@returns {boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
async _checkIfNonceIsTaken (txMeta) {
|
async _checkIfNonceIsTaken (txMeta) {
|
||||||
const address = txMeta.txParams.from
|
const address = txMeta.txParams.from
|
||||||
const completed = this.getCompletedTransactions(address)
|
const completed = this.getCompletedTransactions(address)
|
||||||
|
|
|
@ -25,7 +25,7 @@ class TxGasUtil {
|
||||||
@returns {object} the txMeta object with the gas written to the txParams
|
@returns {object} the txMeta object with the gas written to the txParams
|
||||||
*/
|
*/
|
||||||
async analyzeGasUsage (txMeta) {
|
async analyzeGasUsage (txMeta) {
|
||||||
const block = await this.query.getBlockByNumber('latest', true)
|
const block = await this.query.getBlockByNumber('latest', false)
|
||||||
let estimatedGasHex
|
let estimatedGasHex
|
||||||
try {
|
try {
|
||||||
estimatedGasHex = await this.estimateTxGas(txMeta, block.gasLimit)
|
estimatedGasHex = await this.estimateTxGas(txMeta, block.gasLimit)
|
||||||
|
|
|
@ -353,6 +353,7 @@ class TransactionStateManager extends EventEmitter {
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
txMeta.err = {
|
txMeta.err = {
|
||||||
message: err.toString(),
|
message: err.toString(),
|
||||||
|
rpc: err.value,
|
||||||
stack: err.stack,
|
stack: err.stack,
|
||||||
}
|
}
|
||||||
this.updateTx(txMeta)
|
this.updateTx(txMeta)
|
||||||
|
|
|
@ -4,7 +4,7 @@ require('web3/dist/web3.min.js')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const LocalMessageDuplexStream = require('post-message-stream')
|
const LocalMessageDuplexStream = require('post-message-stream')
|
||||||
const setupDappAutoReload = require('./lib/auto-reload.js')
|
const setupDappAutoReload = require('./lib/auto-reload.js')
|
||||||
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
|
const MetamaskInpageProvider = require('metamask-inpage-provider')
|
||||||
restoreContextAfterImports()
|
restoreContextAfterImports()
|
||||||
|
|
||||||
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
|
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
|
||||||
|
@ -22,6 +22,25 @@ var metamaskStream = new LocalMessageDuplexStream({
|
||||||
// compose the inpage provider
|
// compose the inpage provider
|
||||||
var inpageProvider = new MetamaskInpageProvider(metamaskStream)
|
var inpageProvider = new MetamaskInpageProvider(metamaskStream)
|
||||||
|
|
||||||
|
// Augment the provider with its enable method
|
||||||
|
inpageProvider.enable = function (options = {}) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (options.mockRejection) {
|
||||||
|
reject('User rejected account access')
|
||||||
|
} else {
|
||||||
|
inpageProvider.sendAsync({ method: 'eth_accounts', params: [] }, (error, response) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error)
|
||||||
|
} else {
|
||||||
|
resolve(response.result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
window.ethereum = inpageProvider
|
||||||
|
|
||||||
//
|
//
|
||||||
// setup web3
|
// setup web3
|
||||||
//
|
//
|
||||||
|
|
|
@ -7,14 +7,13 @@
|
||||||
* on each new block.
|
* on each new block.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const async = require('async')
|
|
||||||
const EthQuery = require('eth-query')
|
const EthQuery = require('eth-query')
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const EventEmitter = require('events').EventEmitter
|
const log = require('loglevel')
|
||||||
function noop () {}
|
const pify = require('pify')
|
||||||
|
|
||||||
|
|
||||||
class AccountTracker extends EventEmitter {
|
class AccountTracker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module is responsible for tracking any number of accounts and caching their current balances & transaction
|
* This module is responsible for tracking any number of accounts and caching their current balances & transaction
|
||||||
|
@ -35,8 +34,6 @@ class AccountTracker extends EventEmitter {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
super()
|
|
||||||
|
|
||||||
const initState = {
|
const initState = {
|
||||||
accounts: {},
|
accounts: {},
|
||||||
currentBlockGasLimit: '',
|
currentBlockGasLimit: '',
|
||||||
|
@ -44,12 +41,29 @@ class AccountTracker extends EventEmitter {
|
||||||
this.store = new ObservableStore(initState)
|
this.store = new ObservableStore(initState)
|
||||||
|
|
||||||
this._provider = opts.provider
|
this._provider = opts.provider
|
||||||
this._query = new EthQuery(this._provider)
|
this._query = pify(new EthQuery(this._provider))
|
||||||
this._blockTracker = opts.blockTracker
|
this._blockTracker = opts.blockTracker
|
||||||
// subscribe to latest block
|
|
||||||
this._blockTracker.on('block', this._updateForBlock.bind(this))
|
|
||||||
// blockTracker.currentBlock may be null
|
// blockTracker.currentBlock may be null
|
||||||
this._currentBlockNumber = this._blockTracker.currentBlock
|
this._currentBlockNumber = this._blockTracker.getCurrentBlock()
|
||||||
|
this._blockTracker.once('latest', blockNumber => {
|
||||||
|
this._currentBlockNumber = blockNumber
|
||||||
|
})
|
||||||
|
// bind function for easier listener syntax
|
||||||
|
this._updateForBlock = this._updateForBlock.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
start () {
|
||||||
|
// remove first to avoid double add
|
||||||
|
this._blockTracker.removeListener('latest', this._updateForBlock)
|
||||||
|
// add listener
|
||||||
|
this._blockTracker.addListener('latest', this._updateForBlock)
|
||||||
|
// fetch account balances
|
||||||
|
this._updateAccounts()
|
||||||
|
}
|
||||||
|
|
||||||
|
stop () {
|
||||||
|
// remove listener
|
||||||
|
this._blockTracker.removeListener('latest', this._updateForBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,49 +81,57 @@ class AccountTracker extends EventEmitter {
|
||||||
const accounts = this.store.getState().accounts
|
const accounts = this.store.getState().accounts
|
||||||
const locals = Object.keys(accounts)
|
const locals = Object.keys(accounts)
|
||||||
|
|
||||||
const toAdd = []
|
const accountsToAdd = []
|
||||||
addresses.forEach((upstream) => {
|
addresses.forEach((upstream) => {
|
||||||
if (!locals.includes(upstream)) {
|
if (!locals.includes(upstream)) {
|
||||||
toAdd.push(upstream)
|
accountsToAdd.push(upstream)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const toRemove = []
|
const accountsToRemove = []
|
||||||
locals.forEach((local) => {
|
locals.forEach((local) => {
|
||||||
if (!addresses.includes(local)) {
|
if (!addresses.includes(local)) {
|
||||||
toRemove.push(local)
|
accountsToRemove.push(local)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
toAdd.forEach(upstream => this.addAccount(upstream))
|
this.addAccounts(accountsToAdd)
|
||||||
toRemove.forEach(local => this.removeAccount(local))
|
this.removeAccount(accountsToRemove)
|
||||||
this._updateAccounts()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new address to this AccountTracker's accounts object, which points to an empty object. This object will be
|
* Adds new addresses to track the balances of
|
||||||
* given a balance as long this._currentBlockNumber is defined.
|
* given a balance as long this._currentBlockNumber is defined.
|
||||||
*
|
*
|
||||||
* @param {string} address A hex address of a new account to store in this AccountTracker's accounts object
|
* @param {array} addresses An array of hex addresses of new accounts to track
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
addAccount (address) {
|
addAccounts (addresses) {
|
||||||
const accounts = this.store.getState().accounts
|
const accounts = this.store.getState().accounts
|
||||||
|
// add initial state for addresses
|
||||||
|
addresses.forEach(address => {
|
||||||
accounts[address] = {}
|
accounts[address] = {}
|
||||||
|
})
|
||||||
|
// save accounts state
|
||||||
this.store.updateState({ accounts })
|
this.store.updateState({ accounts })
|
||||||
|
// fetch balances for the accounts if there is block number ready
|
||||||
if (!this._currentBlockNumber) return
|
if (!this._currentBlockNumber) return
|
||||||
this._updateAccount(address)
|
addresses.forEach(address => this._updateAccount(address))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an account from this AccountTracker's accounts object
|
* Removes accounts from being tracked
|
||||||
*
|
*
|
||||||
* @param {string} address A hex address of a the account to remove
|
* @param {array} an array of hex addresses to stop tracking
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
removeAccount (address) {
|
removeAccount (addresses) {
|
||||||
const accounts = this.store.getState().accounts
|
const accounts = this.store.getState().accounts
|
||||||
|
// remove each state object
|
||||||
|
addresses.forEach(address => {
|
||||||
delete accounts[address]
|
delete accounts[address]
|
||||||
|
})
|
||||||
|
// save accounts state
|
||||||
this.store.updateState({ accounts })
|
this.store.updateState({ accounts })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,72 +140,57 @@ class AccountTracker extends EventEmitter {
|
||||||
* via EthQuery
|
* via EthQuery
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {object} block Data about the block that contains the data to update to.
|
* @param {number} blockNumber the block number to update to.
|
||||||
* @fires 'block' The updated state, if all account updates are successful
|
* @fires 'block' The updated state, if all account updates are successful
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
_updateForBlock (block) {
|
async _updateForBlock (blockNumber) {
|
||||||
this._currentBlockNumber = block.number
|
this._currentBlockNumber = blockNumber
|
||||||
const currentBlockGasLimit = block.gasLimit
|
|
||||||
|
|
||||||
|
// block gasLimit polling shouldn't be in account-tracker shouldn't be here...
|
||||||
|
const currentBlock = await this._query.getBlockByNumber(blockNumber, false)
|
||||||
|
if (!currentBlock) return
|
||||||
|
const currentBlockGasLimit = currentBlock.gasLimit
|
||||||
this.store.updateState({ currentBlockGasLimit })
|
this.store.updateState({ currentBlockGasLimit })
|
||||||
|
|
||||||
async.parallel([
|
try {
|
||||||
this._updateAccounts.bind(this),
|
await this._updateAccounts()
|
||||||
], (err) => {
|
} catch (err) {
|
||||||
if (err) return console.error(err)
|
log.error(err)
|
||||||
this.emit('block', this.store.getState())
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls this._updateAccount for each account in this.store
|
* Calls this._updateAccount for each account in this.store
|
||||||
*
|
*
|
||||||
* @param {Function} cb A callback to pass to this._updateAccount, called after each account is successfully updated
|
* @returns {Promise} after all account balances updated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
_updateAccounts (cb = noop) {
|
async _updateAccounts () {
|
||||||
const accounts = this.store.getState().accounts
|
const accounts = this.store.getState().accounts
|
||||||
const addresses = Object.keys(accounts)
|
const addresses = Object.keys(accounts)
|
||||||
async.each(addresses, this._updateAccount.bind(this), cb)
|
await Promise.all(addresses.map(this._updateAccount.bind(this)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the current balance of an account. Gets an updated balance via this._getAccount.
|
* Updates the current balance of an account.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {string} address A hex address of a the account to be updated
|
* @param {string} address A hex address of a the account to be updated
|
||||||
* @param {Function} cb A callback to call once the account at address is successfully update
|
* @returns {Promise} after the account balance is updated
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
_updateAccount (address, cb = noop) {
|
async _updateAccount (address) {
|
||||||
this._getAccount(address, (err, result) => {
|
// query balance
|
||||||
if (err) return cb(err)
|
const balance = await this._query.getBalance(address)
|
||||||
result.address = address
|
const result = { address, balance }
|
||||||
const accounts = this.store.getState().accounts
|
// update accounts state
|
||||||
|
const { accounts } = this.store.getState()
|
||||||
// only populate if the entry is still present
|
// only populate if the entry is still present
|
||||||
if (accounts[address]) {
|
if (!accounts[address]) return
|
||||||
accounts[address] = result
|
accounts[address] = result
|
||||||
this.store.updateState({ accounts })
|
this.store.updateState({ accounts })
|
||||||
}
|
}
|
||||||
cb(null, result)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current balance of an account via EthQuery.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {string} address A hex address of a the account to query
|
|
||||||
* @param {Function} cb A callback to call once the account at address is successfully update
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
_getAccount (address, cb = noop) {
|
|
||||||
const query = this._query
|
|
||||||
async.parallel({
|
|
||||||
balance: query.getBalance.bind(query, address),
|
|
||||||
}, cb)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,226 +0,0 @@
|
||||||
const ethUtil = require('ethereumjs-util')
|
|
||||||
const normalize = require('eth-sig-util').normalize
|
|
||||||
|
|
||||||
/* The config-manager is a convenience object
|
|
||||||
* wrapping a pojo-migrator.
|
|
||||||
*
|
|
||||||
* It exists mostly to allow the creation of
|
|
||||||
* convenience methods to access and persist
|
|
||||||
* particular portions of the state.
|
|
||||||
*/
|
|
||||||
module.exports = ConfigManager
|
|
||||||
function ConfigManager (opts) {
|
|
||||||
// ConfigManager is observable and will emit updates
|
|
||||||
this._subs = []
|
|
||||||
this.store = opts.store
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setConfig = function (config) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.config = config
|
|
||||||
this.setData(data)
|
|
||||||
this._emitUpdates(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getConfig = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
return data.config
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setData = function (data) {
|
|
||||||
this.store.putState(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getData = function () {
|
|
||||||
return this.store.getState()
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setPasswordForgotten = function (passwordForgottenState) {
|
|
||||||
const data = this.getData()
|
|
||||||
data.forgottenPassword = passwordForgottenState
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getPasswordForgotten = function (passwordForgottenState) {
|
|
||||||
const data = this.getData()
|
|
||||||
return data.forgottenPassword
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setWallet = function (wallet) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.wallet = wallet
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setVault = function (encryptedString) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.vault = encryptedString
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getVault = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
return data.vault
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getKeychains = function () {
|
|
||||||
return this.getData().keychains || []
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setKeychains = function (keychains) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.keychains = keychains
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getSelectedAccount = function () {
|
|
||||||
var config = this.getConfig()
|
|
||||||
return config.selectedAccount
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setSelectedAccount = function (address) {
|
|
||||||
var config = this.getConfig()
|
|
||||||
config.selectedAccount = ethUtil.addHexPrefix(address)
|
|
||||||
this.setConfig(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getWallet = function () {
|
|
||||||
return this.getData().wallet
|
|
||||||
}
|
|
||||||
|
|
||||||
// Takes a boolean
|
|
||||||
ConfigManager.prototype.setShowSeedWords = function (should) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.showSeedWords = should
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ConfigManager.prototype.getShouldShowSeedWords = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
return data.showSeedWords
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setSeedWords = function (words) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.seedWords = words
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getSeedWords = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
return data.seedWords
|
|
||||||
}
|
|
||||||
ConfigManager.prototype.setRpcTarget = function (rpcUrl) {
|
|
||||||
var config = this.getConfig()
|
|
||||||
config.provider = {
|
|
||||||
type: 'rpc',
|
|
||||||
rpcTarget: rpcUrl,
|
|
||||||
}
|
|
||||||
this.setConfig(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setProviderType = function (type) {
|
|
||||||
var config = this.getConfig()
|
|
||||||
config.provider = {
|
|
||||||
type: type,
|
|
||||||
}
|
|
||||||
this.setConfig(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.useEtherscanProvider = function () {
|
|
||||||
var config = this.getConfig()
|
|
||||||
config.provider = {
|
|
||||||
type: 'etherscan',
|
|
||||||
}
|
|
||||||
this.setConfig(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getProvider = function () {
|
|
||||||
var config = this.getConfig()
|
|
||||||
return config.provider
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Tx
|
|
||||||
//
|
|
||||||
|
|
||||||
ConfigManager.prototype.getTxList = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
if (data.transactions !== undefined) {
|
|
||||||
return data.transactions
|
|
||||||
} else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setTxList = function (txList) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.transactions = txList
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// wallet nickname methods
|
|
||||||
|
|
||||||
ConfigManager.prototype.getWalletNicknames = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
const nicknames = ('walletNicknames' in data) ? data.walletNicknames : {}
|
|
||||||
return nicknames
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.nicknameForWallet = function (account) {
|
|
||||||
const address = normalize(account)
|
|
||||||
const nicknames = this.getWalletNicknames()
|
|
||||||
return nicknames[address]
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setNicknameForWallet = function (account, nickname) {
|
|
||||||
const address = normalize(account)
|
|
||||||
const nicknames = this.getWalletNicknames()
|
|
||||||
nicknames[address] = nickname
|
|
||||||
var data = this.getData()
|
|
||||||
data.walletNicknames = nicknames
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// observable
|
|
||||||
|
|
||||||
ConfigManager.prototype.getSalt = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
return data.salt
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setSalt = function (salt) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.salt = salt
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.subscribe = function (fn) {
|
|
||||||
this._subs.push(fn)
|
|
||||||
var unsubscribe = this.unsubscribe.bind(this, fn)
|
|
||||||
return unsubscribe
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.unsubscribe = function (fn) {
|
|
||||||
var index = this._subs.indexOf(fn)
|
|
||||||
if (index !== -1) this._subs.splice(index, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype._emitUpdates = function (state) {
|
|
||||||
this._subs.forEach(function (handler) {
|
|
||||||
handler(state)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.setLostAccounts = function (lostAccounts) {
|
|
||||||
var data = this.getData()
|
|
||||||
data.lostAccounts = lostAccounts
|
|
||||||
this.setData(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.getLostAccounts = function () {
|
|
||||||
var data = this.getData()
|
|
||||||
return data.lostAccounts || []
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
const log = require('loglevel')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON-RPC error object
|
|
||||||
*
|
|
||||||
* @typedef {Object} RpcError
|
|
||||||
* @property {number} code - Indicates the error type that occurred
|
|
||||||
* @property {Object} [data] - Contains additional information about the error
|
|
||||||
* @property {string} [message] - Short description of the error
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Middleware configuration object
|
|
||||||
*
|
|
||||||
* @typedef {Object} MiddlewareConfig
|
|
||||||
* @property {boolean} [override] - Use RPC_ERRORS message in place of provider message
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map of standard and non-standard RPC error codes to messages
|
|
||||||
*/
|
|
||||||
const RPC_ERRORS = {
|
|
||||||
1: 'An unauthorized action was attempted.',
|
|
||||||
2: 'A disallowed action was attempted.',
|
|
||||||
3: 'An execution error occurred.',
|
|
||||||
[-32600]: 'The JSON sent is not a valid Request object.',
|
|
||||||
[-32601]: 'The method does not exist / is not available.',
|
|
||||||
[-32602]: 'Invalid method parameter(s).',
|
|
||||||
[-32603]: 'Internal JSON-RPC error.',
|
|
||||||
[-32700]: 'Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.',
|
|
||||||
internal: 'Internal server error.',
|
|
||||||
unknown: 'Unknown JSON-RPC error.',
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modifies a JSON-RPC error object in-place to add a human-readable message,
|
|
||||||
* optionally overriding any provider-supplied message
|
|
||||||
*
|
|
||||||
* @param {RpcError} error - JSON-RPC error object
|
|
||||||
* @param {boolean} override - Use RPC_ERRORS message in place of provider message
|
|
||||||
*/
|
|
||||||
function sanitizeRPCError (error, override) {
|
|
||||||
if (error.message && !override) { return error }
|
|
||||||
const message = error.code > -31099 && error.code < -32100 ? RPC_ERRORS.internal : RPC_ERRORS[error.code]
|
|
||||||
error.message = message || RPC_ERRORS.unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* json-rpc-engine middleware that both logs standard and non-standard error
|
|
||||||
* messages and ends middleware stack traversal if an error is encountered
|
|
||||||
*
|
|
||||||
* @param {MiddlewareConfig} [config={override:true}] - Middleware configuration
|
|
||||||
* @returns {Function} json-rpc-engine middleware function
|
|
||||||
*/
|
|
||||||
function createErrorMiddleware ({ override = true } = {}) {
|
|
||||||
return (req, res, next) => {
|
|
||||||
next(done => {
|
|
||||||
const { error } = res
|
|
||||||
if (!error) { return done() }
|
|
||||||
sanitizeRPCError(error)
|
|
||||||
log.error(`Nifty Wallet - RPC Error: ${error.message}`, error)
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = createErrorMiddleware
|
|
|
@ -1,42 +0,0 @@
|
||||||
/**
|
|
||||||
* Returns an EventEmitter that proxies events from the given event emitter
|
|
||||||
* @param {any} eventEmitter
|
|
||||||
* @param {object} listeners - The listeners to proxy to
|
|
||||||
* @returns {any}
|
|
||||||
*/
|
|
||||||
module.exports = function createEventEmitterProxy (eventEmitter, listeners) {
|
|
||||||
let target = eventEmitter
|
|
||||||
const eventHandlers = listeners || {}
|
|
||||||
const proxy = /** @type {any} */ (new Proxy({}, {
|
|
||||||
get: (_, name) => {
|
|
||||||
// intercept listeners
|
|
||||||
if (name === 'on') return addListener
|
|
||||||
if (name === 'setTarget') return setTarget
|
|
||||||
if (name === 'proxyEventHandlers') return eventHandlers
|
|
||||||
return (/** @type {any} */ (target))[name]
|
|
||||||
},
|
|
||||||
set: (_, name, value) => {
|
|
||||||
target[name] = value
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
function setTarget (/** @type {EventEmitter} */ eventEmitter) {
|
|
||||||
target = eventEmitter
|
|
||||||
// migrate listeners
|
|
||||||
Object.keys(eventHandlers).forEach((name) => {
|
|
||||||
/** @type {Array<Function>} */ (eventHandlers[name]).forEach((handler) => target.on(name, handler))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Attaches a function to be called whenever the specified event is emitted
|
|
||||||
* @param {string} name
|
|
||||||
* @param {Function} handler
|
|
||||||
*/
|
|
||||||
function addListener (name, handler) {
|
|
||||||
if (!eventHandlers[name]) eventHandlers[name] = []
|
|
||||||
eventHandlers[name].push(handler)
|
|
||||||
target.on(name, handler)
|
|
||||||
}
|
|
||||||
if (listeners) proxy.setTarget(eventEmitter)
|
|
||||||
return proxy
|
|
||||||
}
|
|
|
@ -1,125 +0,0 @@
|
||||||
const pump = require('pump')
|
|
||||||
const RpcEngine = require('json-rpc-engine')
|
|
||||||
const createErrorMiddleware = require('./createErrorMiddleware')
|
|
||||||
const createIdRemapMiddleware = require('json-rpc-engine/src/idRemapMiddleware')
|
|
||||||
const createStreamMiddleware = require('json-rpc-middleware-stream')
|
|
||||||
const LocalStorageStore = require('obs-store')
|
|
||||||
const asStream = require('obs-store/lib/asStream')
|
|
||||||
const ObjectMultiplex = require('obj-multiplex')
|
|
||||||
|
|
||||||
module.exports = MetamaskInpageProvider
|
|
||||||
|
|
||||||
function MetamaskInpageProvider (connectionStream) {
|
|
||||||
const self = this
|
|
||||||
|
|
||||||
// setup connectionStream multiplexing
|
|
||||||
const mux = self.mux = new ObjectMultiplex()
|
|
||||||
pump(
|
|
||||||
connectionStream,
|
|
||||||
mux,
|
|
||||||
connectionStream,
|
|
||||||
(err) => logStreamDisconnectWarning('MetaMask', err)
|
|
||||||
)
|
|
||||||
|
|
||||||
// subscribe to metamask public config (one-way)
|
|
||||||
self.publicConfigStore = new LocalStorageStore({ storageKey: 'MetaMask-Config' })
|
|
||||||
|
|
||||||
pump(
|
|
||||||
mux.createStream('publicConfig'),
|
|
||||||
asStream(self.publicConfigStore),
|
|
||||||
(err) => logStreamDisconnectWarning('Nifty Wallet PublicConfigStore', err)
|
|
||||||
)
|
|
||||||
|
|
||||||
// ignore phishing warning message (handled elsewhere)
|
|
||||||
mux.ignoreStream('phishing')
|
|
||||||
|
|
||||||
// connect to async provider
|
|
||||||
const streamMiddleware = createStreamMiddleware()
|
|
||||||
pump(
|
|
||||||
streamMiddleware.stream,
|
|
||||||
mux.createStream('provider'),
|
|
||||||
streamMiddleware.stream,
|
|
||||||
(err) => logStreamDisconnectWarning('Nifty Wallet RpcProvider', err)
|
|
||||||
)
|
|
||||||
|
|
||||||
// handle sendAsync requests via dapp-side rpc engine
|
|
||||||
const rpcEngine = new RpcEngine()
|
|
||||||
rpcEngine.push(createIdRemapMiddleware())
|
|
||||||
rpcEngine.push(createErrorMiddleware())
|
|
||||||
rpcEngine.push(streamMiddleware)
|
|
||||||
self.rpcEngine = rpcEngine
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle sendAsync requests via asyncProvider
|
|
||||||
// also remap ids inbound and outbound
|
|
||||||
MetamaskInpageProvider.prototype.sendAsync = function (payload, cb) {
|
|
||||||
const self = this
|
|
||||||
|
|
||||||
if (payload.method === 'eth_signTypedData') {
|
|
||||||
console.warn('MetaMask: This experimental version of eth_signTypedData will be deprecated in the next release in favor of the standard as defined in EIP-712. See https://git.io/fNzPl for more information on the new standard.')
|
|
||||||
}
|
|
||||||
|
|
||||||
self.rpcEngine.handle(payload, cb)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MetamaskInpageProvider.prototype.send = function (payload) {
|
|
||||||
const self = this
|
|
||||||
|
|
||||||
let selectedAddress
|
|
||||||
let result = null
|
|
||||||
switch (payload.method) {
|
|
||||||
|
|
||||||
case 'eth_accounts':
|
|
||||||
// read from localStorage
|
|
||||||
selectedAddress = self.publicConfigStore.getState().selectedAddress
|
|
||||||
result = selectedAddress ? [selectedAddress] : []
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'eth_coinbase':
|
|
||||||
// read from localStorage
|
|
||||||
selectedAddress = self.publicConfigStore.getState().selectedAddress
|
|
||||||
result = selectedAddress || null
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'eth_uninstallFilter':
|
|
||||||
self.sendAsync(payload, noop)
|
|
||||||
result = true
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'net_version':
|
|
||||||
const networkVersion = self.publicConfigStore.getState().networkVersion
|
|
||||||
result = networkVersion || null
|
|
||||||
break
|
|
||||||
|
|
||||||
// throw not-supported Error
|
|
||||||
default:
|
|
||||||
var link = 'https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client'
|
|
||||||
var message = `The Nifty Wallet Web3 object does not support synchronous methods like ${payload.method} without a callback parameter. See ${link} for details.`
|
|
||||||
throw new Error(message)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the result
|
|
||||||
return {
|
|
||||||
id: payload.id,
|
|
||||||
jsonrpc: payload.jsonrpc,
|
|
||||||
result: result,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MetamaskInpageProvider.prototype.isConnected = function () {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
MetamaskInpageProvider.prototype.isMetaMask = true
|
|
||||||
|
|
||||||
// util
|
|
||||||
|
|
||||||
function logStreamDisconnectWarning (remoteLabel, err) {
|
|
||||||
let warningMsg = `MetamaskInpageProvider - lost connection to ${remoteLabel}`
|
|
||||||
if (err) warningMsg += '\n' + err.stack
|
|
||||||
console.warn(warningMsg)
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop () {}
|
|
|
@ -34,7 +34,7 @@ module.exports = function (provider) {
|
||||||
return { cancel: true }
|
return { cancel: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension.webRequest.onBeforeRequest.addListener(ipfsContent, {urls: ['*://*.eth/']})
|
extension.webRequest.onErrorOccurred.addListener(ipfsContent, {urls: ['*://*.eth/']})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
remove () {
|
remove () {
|
||||||
|
|
|
@ -69,10 +69,39 @@ module.exports = class MessageManager extends EventEmitter {
|
||||||
* new Message to this.messages, and to save the unapproved Messages from that list to this.memStore.
|
* new Message to this.messages, and to save the unapproved Messages from that list to this.memStore.
|
||||||
*
|
*
|
||||||
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
||||||
|
* @param {Object} req (optional) The original request object possibly containing the origin
|
||||||
|
* @returns {promise} after signature has been
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
addUnapprovedMessageAsync (msgParams, req) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const msgId = this.addUnapprovedMessage(msgParams, req)
|
||||||
|
// await finished
|
||||||
|
this.once(`${msgId}:finished`, (data) => {
|
||||||
|
switch (data.status) {
|
||||||
|
case 'signed':
|
||||||
|
return resolve(data.rawSig)
|
||||||
|
case 'rejected':
|
||||||
|
return reject(new Error('MetaMask Message Signature: User denied message signature.'))
|
||||||
|
default:
|
||||||
|
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Message with an 'unapproved' status using the passed msgParams. this.addMsg is called to add the
|
||||||
|
* new Message to this.messages, and to save the unapproved Messages from that list to this.memStore.
|
||||||
|
*
|
||||||
|
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
||||||
|
* @param {Object} req (optional) The original request object where the origin may be specificied
|
||||||
* @returns {number} The id of the newly created message.
|
* @returns {number} The id of the newly created message.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
addUnapprovedMessage (msgParams) {
|
addUnapprovedMessage (msgParams, req) {
|
||||||
|
// add origin from request
|
||||||
|
if (req) msgParams.origin = req.origin
|
||||||
msgParams.data = normalizeMsgData(msgParams.data)
|
msgParams.data = normalizeMsgData(msgParams.data)
|
||||||
// create txData obj with parameters and meta data
|
// create txData obj with parameters and meta data
|
||||||
var time = (new Date()).getTime()
|
var time = (new Date()).getTime()
|
||||||
|
|
|
@ -73,11 +73,43 @@ module.exports = class PersonalMessageManager extends EventEmitter {
|
||||||
* this.memStore.
|
* this.memStore.
|
||||||
*
|
*
|
||||||
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
||||||
|
* @param {Object} req (optional) The original request object possibly containing the origin
|
||||||
|
* @returns {promise} When the message has been signed or rejected
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
addUnapprovedMessageAsync (msgParams, req) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!msgParams.from) {
|
||||||
|
reject(new Error('MetaMask Message Signature: from field is required.'))
|
||||||
|
}
|
||||||
|
const msgId = this.addUnapprovedMessage(msgParams, req)
|
||||||
|
this.once(`${msgId}:finished`, (data) => {
|
||||||
|
switch (data.status) {
|
||||||
|
case 'signed':
|
||||||
|
return resolve(data.rawSig)
|
||||||
|
case 'rejected':
|
||||||
|
return reject(new Error('MetaMask Message Signature: User denied message signature.'))
|
||||||
|
default:
|
||||||
|
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PersonalMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add
|
||||||
|
* the new PersonalMessage to this.messages, and to save the unapproved PersonalMessages from that list to
|
||||||
|
* this.memStore.
|
||||||
|
*
|
||||||
|
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
||||||
|
* @param {Object} req (optional) The original request object possibly containing the origin
|
||||||
* @returns {number} The id of the newly created PersonalMessage.
|
* @returns {number} The id of the newly created PersonalMessage.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
addUnapprovedMessage (msgParams) {
|
addUnapprovedMessage (msgParams, req) {
|
||||||
log.debug(`PersonalMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`)
|
log.debug(`PersonalMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`)
|
||||||
|
// add origin from request
|
||||||
|
if (req) msgParams.origin = req.origin
|
||||||
msgParams.data = this.normalizeMsgData(msgParams.data)
|
msgParams.data = this.normalizeMsgData(msgParams.data)
|
||||||
// create txData obj with parameters and meta data
|
// create txData obj with parameters and meta data
|
||||||
var time = (new Date()).getTime()
|
var time = (new Date()).getTime()
|
||||||
|
@ -257,4 +289,3 @@ module.exports = class PersonalMessageManager extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
const Duplex = require('readable-stream').Duplex
|
|
||||||
const inherits = require('util').inherits
|
|
||||||
const noop = function () {}
|
|
||||||
|
|
||||||
module.exports = PortDuplexStream
|
|
||||||
|
|
||||||
inherits(PortDuplexStream, Duplex)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a stream that's both readable and writable.
|
|
||||||
* The stream supports arbitrary objects.
|
|
||||||
*
|
|
||||||
* @class
|
|
||||||
* @param {Object} port Remote Port object
|
|
||||||
*/
|
|
||||||
function PortDuplexStream (port) {
|
|
||||||
Duplex.call(this, {
|
|
||||||
objectMode: true,
|
|
||||||
})
|
|
||||||
this._port = port
|
|
||||||
port.onMessage.addListener(this._onMessage.bind(this))
|
|
||||||
port.onDisconnect.addListener(this._onDisconnect.bind(this))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback triggered when a message is received from
|
|
||||||
* the remote Port associated with this Stream.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Object} msg - Payload from the onMessage listener of Port
|
|
||||||
*/
|
|
||||||
PortDuplexStream.prototype._onMessage = function (msg) {
|
|
||||||
if (Buffer.isBuffer(msg)) {
|
|
||||||
delete msg._isBuffer
|
|
||||||
var data = new Buffer(msg)
|
|
||||||
this.push(data)
|
|
||||||
} else {
|
|
||||||
this.push(msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback triggered when the remote Port
|
|
||||||
* associated with this Stream disconnects.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
PortDuplexStream.prototype._onDisconnect = function () {
|
|
||||||
this.destroy()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Explicitly sets read operations to a no-op
|
|
||||||
*/
|
|
||||||
PortDuplexStream.prototype._read = noop
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called internally when data should be written to
|
|
||||||
* this writable stream.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} msg Arbitrary object to write
|
|
||||||
* @param {string} encoding Encoding to use when writing payload
|
|
||||||
* @param {Function} cb Called when writing is complete or an error occurs
|
|
||||||
*/
|
|
||||||
PortDuplexStream.prototype._write = function (msg, encoding, cb) {
|
|
||||||
try {
|
|
||||||
if (Buffer.isBuffer(msg)) {
|
|
||||||
var data = msg.toJSON()
|
|
||||||
data._isBuffer = true
|
|
||||||
this._port.postMessage(data)
|
|
||||||
} else {
|
|
||||||
this._port.postMessage(msg)
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
return cb(new Error('PortDuplexStream - disconnected'))
|
|
||||||
}
|
|
||||||
cb()
|
|
||||||
}
|
|
|
@ -70,11 +70,11 @@ function simplifyErrorMessages (report) {
|
||||||
|
|
||||||
function rewriteErrorMessages (report, rewriteFn) {
|
function rewriteErrorMessages (report, rewriteFn) {
|
||||||
// rewrite top level message
|
// rewrite top level message
|
||||||
if (report.message) report.message = rewriteFn(report.message)
|
if (typeof report.message === 'string') report.message = rewriteFn(report.message)
|
||||||
// rewrite each exception message
|
// rewrite each exception message
|
||||||
if (report.exception && report.exception.values) {
|
if (report.exception && report.exception.values) {
|
||||||
report.exception.values.forEach(item => {
|
report.exception.values.forEach(item => {
|
||||||
item.value = rewriteFn(item.value)
|
if (typeof item.value === 'string') item.value = rewriteFn(item.value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ const createId = require('./random-id')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const sigUtil = require('eth-sig-util')
|
const sigUtil = require('eth-sig-util')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
|
const jsonschema = require('jsonschema')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents, and contains data about, an 'eth_signTypedData' type signature request. These are created when a
|
* Represents, and contains data about, an 'eth_signTypedData' type signature request. These are created when a
|
||||||
|
@ -17,7 +18,7 @@ const log = require('loglevel')
|
||||||
* @property {Object} msgParams.from The address that is making the signature request.
|
* @property {Object} msgParams.from The address that is making the signature request.
|
||||||
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
|
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
|
||||||
* @property {number} time The epoch time at which the this message was created
|
* @property {number} time The epoch time at which the this message was created
|
||||||
* @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed' or 'rejected'
|
* @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed', 'rejected', or 'errored'
|
||||||
* @property {string} type The json-prc signing method for which a signature request has been made. A 'Message' will
|
* @property {string} type The json-prc signing method for which a signature request has been made. A 'Message' will
|
||||||
* always have a 'eth_signTypedData' type.
|
* always have a 'eth_signTypedData' type.
|
||||||
*
|
*
|
||||||
|
@ -26,17 +27,10 @@ const log = require('loglevel')
|
||||||
module.exports = class TypedMessageManager extends EventEmitter {
|
module.exports = class TypedMessageManager extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Controller in charge of managing - storing, adding, removing, updating - TypedMessage.
|
* Controller in charge of managing - storing, adding, removing, updating - TypedMessage.
|
||||||
*
|
|
||||||
* @typedef {Object} TypedMessage
|
|
||||||
* @param {Object} opts @deprecated
|
|
||||||
* @property {Object} memStore The observable store where TypedMessage are saved.
|
|
||||||
* @property {Object} memStore.unapprovedTypedMessages A collection of all TypedMessages in the 'unapproved' state
|
|
||||||
* @property {number} memStore.unapprovedTypedMessagesCount The count of all TypedMessages in this.memStore.unapprobedMsgs
|
|
||||||
* @property {array} messages Holds all messages that have been created by this TypedMessage
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
constructor (opts) {
|
constructor ({ networkController }) {
|
||||||
super()
|
super()
|
||||||
|
this.networkController = networkController
|
||||||
this.memStore = new ObservableStore({
|
this.memStore = new ObservableStore({
|
||||||
unapprovedTypedMessages: {},
|
unapprovedTypedMessages: {},
|
||||||
unapprovedTypedMessagesCount: 0,
|
unapprovedTypedMessagesCount: 0,
|
||||||
|
@ -72,11 +66,43 @@ module.exports = class TypedMessageManager extends EventEmitter {
|
||||||
* this.memStore. Before any of this is done, msgParams are validated
|
* this.memStore. Before any of this is done, msgParams are validated
|
||||||
*
|
*
|
||||||
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
||||||
|
* @param {Object} req (optional) The original request object possibly containing the origin
|
||||||
|
* @returns {promise} When the message has been signed or rejected
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
addUnapprovedMessageAsync (msgParams, req, version) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const msgId = this.addUnapprovedMessage(msgParams, req, version)
|
||||||
|
this.once(`${msgId}:finished`, (data) => {
|
||||||
|
switch (data.status) {
|
||||||
|
case 'signed':
|
||||||
|
return resolve(data.rawSig)
|
||||||
|
case 'rejected':
|
||||||
|
return reject(new Error('MetaMask Message Signature: User denied message signature.'))
|
||||||
|
case 'errored':
|
||||||
|
return reject(new Error(`MetaMask Message Signature: ${data.error}`))
|
||||||
|
default:
|
||||||
|
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new TypedMessage with an 'unapproved' status using the passed msgParams. this.addMsg is called to add
|
||||||
|
* the new TypedMessage to this.messages, and to save the unapproved TypedMessages from that list to
|
||||||
|
* this.memStore. Before any of this is done, msgParams are validated
|
||||||
|
*
|
||||||
|
* @param {Object} msgParams The params for the eth_sign call to be made after the message is approved.
|
||||||
|
* @param {Object} req (optional) The original request object possibly containing the origin
|
||||||
* @returns {number} The id of the newly created TypedMessage.
|
* @returns {number} The id of the newly created TypedMessage.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
addUnapprovedMessage (msgParams) {
|
addUnapprovedMessage (msgParams, req, version) {
|
||||||
|
msgParams.version = version
|
||||||
this.validateParams(msgParams)
|
this.validateParams(msgParams)
|
||||||
|
// add origin from request
|
||||||
|
if (req) msgParams.origin = req.origin
|
||||||
|
|
||||||
log.debug(`TypedMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`)
|
log.debug(`TypedMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`)
|
||||||
// create txData obj with parameters and meta data
|
// create txData obj with parameters and meta data
|
||||||
|
@ -103,6 +129,8 @@ module.exports = class TypedMessageManager extends EventEmitter {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
validateParams (params) {
|
validateParams (params) {
|
||||||
|
switch (params.version) {
|
||||||
|
case 'V1':
|
||||||
assert.equal(typeof params, 'object', 'Params should ben an object.')
|
assert.equal(typeof params, 'object', 'Params should ben an object.')
|
||||||
assert.ok('data' in params, 'Params must include a data field.')
|
assert.ok('data' in params, 'Params must include a data field.')
|
||||||
assert.ok('from' in params, 'Params must include a from field.')
|
assert.ok('from' in params, 'Params must include a from field.')
|
||||||
|
@ -111,6 +139,23 @@ module.exports = class TypedMessageManager extends EventEmitter {
|
||||||
assert.doesNotThrow(() => {
|
assert.doesNotThrow(() => {
|
||||||
sigUtil.typedSignatureHash(params.data)
|
sigUtil.typedSignatureHash(params.data)
|
||||||
}, 'Expected EIP712 typed data')
|
}, 'Expected EIP712 typed data')
|
||||||
|
break
|
||||||
|
case 'V3':
|
||||||
|
let data
|
||||||
|
assert.equal(typeof params, 'object', 'Params should be an object.')
|
||||||
|
assert.ok('data' in params, 'Params must include a data field.')
|
||||||
|
assert.ok('from' in params, 'Params must include a from field.')
|
||||||
|
assert.equal(typeof params.from, 'string', 'From field must be a string.')
|
||||||
|
assert.equal(typeof params.data, 'string', 'Data must be passed as a valid JSON string.')
|
||||||
|
assert.doesNotThrow(() => { data = JSON.parse(params.data) }, 'Data must be passed as a valid JSON string.')
|
||||||
|
const validation = jsonschema.validate(data, sigUtil.TYPED_MESSAGE_SCHEMA)
|
||||||
|
assert.ok(data.primaryType in data.types, `Primary type of "${data.primaryType}" has no type definition.`)
|
||||||
|
assert.equal(validation.errors.length, 0, 'Data must conform to EIP-712 schema. See https://git.io/fNtcx.')
|
||||||
|
const chainId = data.domain.chainId
|
||||||
|
const activeChainId = parseInt(this.networkController.getNetworkState())
|
||||||
|
chainId && assert.equal(chainId, activeChainId, `Provided chainId (${chainId}) must match the active chainId (${activeChainId})`)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,6 +230,7 @@ module.exports = class TypedMessageManager extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
prepMsgForSigning (msgParams) {
|
prepMsgForSigning (msgParams) {
|
||||||
delete msgParams.metamaskId
|
delete msgParams.metamaskId
|
||||||
|
delete msgParams.version
|
||||||
return Promise.resolve(msgParams)
|
return Promise.resolve(msgParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +244,19 @@ module.exports = class TypedMessageManager extends EventEmitter {
|
||||||
this._setMsgStatus(msgId, 'rejected')
|
this._setMsgStatus(msgId, 'rejected')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a TypedMessage status to 'errored' via a call to this._setMsgStatus.
|
||||||
|
*
|
||||||
|
* @param {number} msgId The id of the TypedMessage to error
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
errorMessage (msgId, error) {
|
||||||
|
const msg = this.getMsg(msgId)
|
||||||
|
msg.error = error
|
||||||
|
this._updateMsg(msg)
|
||||||
|
this._setMsgStatus(msgId, 'errored')
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// PRIVATE METHODS
|
// PRIVATE METHODS
|
||||||
//
|
//
|
||||||
|
@ -221,7 +280,7 @@ module.exports = class TypedMessageManager extends EventEmitter {
|
||||||
msg.status = status
|
msg.status = status
|
||||||
this._updateMsg(msg)
|
this._updateMsg(msg)
|
||||||
this.emit(`${msgId}:${status}`, msg)
|
this.emit(`${msgId}:${status}`, msg)
|
||||||
if (status === 'rejected' || status === 'signed') {
|
if (status === 'rejected' || status === 'signed' || status === 'errored') {
|
||||||
this.emit(`${msgId}:finished`, msg)
|
this.emit(`${msgId}:finished`, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,21 @@ function BnMultiplyByFraction (targetBN, numerator, denominator) {
|
||||||
return targetBN.mul(numBN).div(denomBN)
|
return targetBN.mul(numBN).div(denomBN)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyListeners (listeners, emitter) {
|
||||||
|
Object.keys(listeners).forEach((key) => {
|
||||||
|
emitter.on(key, listeners[key])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeListeners (listeners, emitter) {
|
||||||
|
Object.keys(listeners).forEach((key) => {
|
||||||
|
emitter.removeListener(key, listeners[key])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
removeListeners,
|
||||||
|
applyListeners,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getStack,
|
getStack,
|
||||||
getEnvironmentType,
|
getEnvironmentType,
|
||||||
|
|
|
@ -36,7 +36,6 @@ const TransactionController = require('./controllers/transactions')
|
||||||
const BalancesController = require('./controllers/computed-balances')
|
const BalancesController = require('./controllers/computed-balances')
|
||||||
const TokenRatesController = require('./controllers/token-rates')
|
const TokenRatesController = require('./controllers/token-rates')
|
||||||
const DetectTokensController = require('./controllers/detect-tokens')
|
const DetectTokensController = require('./controllers/detect-tokens')
|
||||||
const ConfigManager = require('./lib/config-manager')
|
|
||||||
const nodeify = require('./lib/nodeify')
|
const nodeify = require('./lib/nodeify')
|
||||||
const accountImporter = require('./account-import-strategies')
|
const accountImporter = require('./account-import-strategies')
|
||||||
const getBuyEthUrl = require('./lib/buy-eth-url')
|
const getBuyEthUrl = require('./lib/buy-eth-url')
|
||||||
|
@ -46,10 +45,12 @@ const BN = require('ethereumjs-util').BN
|
||||||
const GWEI_BN = new BN('1000000000')
|
const GWEI_BN = new BN('1000000000')
|
||||||
const percentile = require('percentile')
|
const percentile = require('percentile')
|
||||||
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
|
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
|
||||||
const cleanErrorStack = require('./lib/cleanErrorStack')
|
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const TrezorKeyring = require('eth-trezor-keyring')
|
const TrezorKeyring = require('eth-trezor-keyring')
|
||||||
const LedgerBridgeKeyring = require('eth-ledger-bridge-keyring')
|
const LedgerBridgeKeyring = require('eth-ledger-bridge-keyring')
|
||||||
|
const EthQuery = require('eth-query')
|
||||||
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
const sigUtil = require('eth-sig-util')
|
||||||
|
|
||||||
module.exports = class MetamaskController extends EventEmitter {
|
module.exports = class MetamaskController extends EventEmitter {
|
||||||
|
|
||||||
|
@ -67,6 +68,10 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
const initState = opts.initState || {}
|
const initState = opts.initState || {}
|
||||||
this.recordFirstTimeInfo(initState)
|
this.recordFirstTimeInfo(initState)
|
||||||
|
|
||||||
|
// this keeps track of how many "controllerStream" connections are open
|
||||||
|
// the only thing that uses controller connections are open metamask UI instances
|
||||||
|
this.activeControllerConnections = 0
|
||||||
|
|
||||||
// platform-specific api
|
// platform-specific api
|
||||||
this.platform = opts.platform
|
this.platform = opts.platform
|
||||||
|
|
||||||
|
@ -79,15 +84,11 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
// network store
|
// network store
|
||||||
this.networkController = new NetworkController(initState.NetworkController)
|
this.networkController = new NetworkController(initState.NetworkController)
|
||||||
|
|
||||||
// config manager
|
|
||||||
this.configManager = new ConfigManager({
|
|
||||||
store: this.store,
|
|
||||||
})
|
|
||||||
|
|
||||||
// preferences controller
|
// preferences controller
|
||||||
this.preferencesController = new PreferencesController({
|
this.preferencesController = new PreferencesController({
|
||||||
initState: initState.PreferencesController,
|
initState: initState.PreferencesController,
|
||||||
initLangCode: opts.initLangCode,
|
initLangCode: opts.initLangCode,
|
||||||
|
showWatchAssetUi: opts.showWatchAssetUi,
|
||||||
network: this.networkController,
|
network: this.networkController,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -108,8 +109,9 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
this.blacklistController.scheduleUpdates()
|
this.blacklistController.scheduleUpdates()
|
||||||
|
|
||||||
// rpc provider
|
// rpc provider
|
||||||
this.provider = this.initializeProvider()
|
this.initializeProvider()
|
||||||
this.blockTracker = this.provider._blockTracker
|
this.provider = this.networkController.getProviderAndBlockTracker().provider
|
||||||
|
this.blockTracker = this.networkController.getProviderAndBlockTracker().blockTracker
|
||||||
|
|
||||||
// token exchange rate tracker
|
// token exchange rate tracker
|
||||||
this.tokenRatesController = new TokenRatesController({
|
this.tokenRatesController = new TokenRatesController({
|
||||||
|
@ -126,6 +128,14 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
provider: this.provider,
|
provider: this.provider,
|
||||||
blockTracker: this.blockTracker,
|
blockTracker: this.blockTracker,
|
||||||
})
|
})
|
||||||
|
// start and stop polling for balances based on activeControllerConnections
|
||||||
|
this.on('controllerConnectionChanged', (activeControllerConnections) => {
|
||||||
|
if (activeControllerConnections > 0) {
|
||||||
|
this.accountTracker.start()
|
||||||
|
} else {
|
||||||
|
this.accountTracker.stop()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// key mgmt
|
// key mgmt
|
||||||
const additionalKeyrings = [TrezorKeyring, LedgerBridgeKeyring]
|
const additionalKeyrings = [TrezorKeyring, LedgerBridgeKeyring]
|
||||||
|
@ -136,19 +146,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
encryptor: opts.encryptor || undefined,
|
encryptor: opts.encryptor || undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
// If only one account exists, make sure it is selected.
|
this.keyringController.memStore.subscribe((s) => this._onKeyringControllerUpdate(s))
|
||||||
this.keyringController.memStore.subscribe((state) => {
|
|
||||||
const addresses = state.keyrings.reduce((res, keyring) => {
|
|
||||||
return res.concat(keyring.accounts)
|
|
||||||
}, [])
|
|
||||||
if (addresses.length === 1) {
|
|
||||||
const address = addresses[0]
|
|
||||||
this.preferencesController.setSelectedAddress(address)
|
|
||||||
}
|
|
||||||
// ensure preferences + identities controller know about all addresses
|
|
||||||
this.preferencesController.addAddresses(addresses)
|
|
||||||
this.accountTracker.syncWithAddresses(addresses)
|
|
||||||
})
|
|
||||||
|
|
||||||
// detect tokens controller
|
// detect tokens controller
|
||||||
this.detectTokensController = new DetectTokensController({
|
this.detectTokensController = new DetectTokensController({
|
||||||
|
@ -175,7 +173,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
blockTracker: this.blockTracker,
|
blockTracker: this.blockTracker,
|
||||||
getGasPrice: this.getGasPrice.bind(this),
|
getGasPrice: this.getGasPrice.bind(this),
|
||||||
})
|
})
|
||||||
this.txController.on('newUnapprovedTx', opts.showUnapprovedTx.bind(opts))
|
this.txController.on('newUnapprovedTx', () => opts.showUnapprovedTx())
|
||||||
|
|
||||||
this.txController.on(`tx:status-update`, (txId, status) => {
|
this.txController.on(`tx:status-update`, (txId, status) => {
|
||||||
if (status === 'confirmed' || status === 'failed') {
|
if (status === 'confirmed' || status === 'failed') {
|
||||||
|
@ -209,7 +207,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
this.networkController.lookupNetwork()
|
this.networkController.lookupNetwork()
|
||||||
this.messageManager = new MessageManager()
|
this.messageManager = new MessageManager()
|
||||||
this.personalMessageManager = new PersonalMessageManager()
|
this.personalMessageManager = new PersonalMessageManager()
|
||||||
this.typedMessageManager = new TypedMessageManager()
|
this.typedMessageManager = new TypedMessageManager({ networkController: this.networkController })
|
||||||
this.publicConfigStore = this.initPublicConfigStore()
|
this.publicConfigStore = this.initPublicConfigStore()
|
||||||
|
|
||||||
this.store.updateStructure({
|
this.store.updateStructure({
|
||||||
|
@ -253,30 +251,23 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
static: {
|
static: {
|
||||||
eth_syncing: false,
|
eth_syncing: false,
|
||||||
web3_clientVersion: `MetaMask/v${version}`,
|
web3_clientVersion: `MetaMask/v${version}`,
|
||||||
eth_sendTransaction: (payload, next, end) => {
|
|
||||||
const origin = payload.origin
|
|
||||||
const txParams = payload.params[0]
|
|
||||||
nodeify(this.txController.newUnapprovedTransaction, this.txController)(txParams, { origin }, end)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// account mgmt
|
// account mgmt
|
||||||
getAccounts: (cb) => {
|
getAccounts: async () => {
|
||||||
const isUnlocked = this.keyringController.memStore.getState().isUnlocked
|
const isUnlocked = this.keyringController.memStore.getState().isUnlocked
|
||||||
const result = []
|
|
||||||
const selectedAddress = this.preferencesController.getSelectedAddress()
|
const selectedAddress = this.preferencesController.getSelectedAddress()
|
||||||
|
|
||||||
// only show address if account is unlocked
|
// only show address if account is unlocked
|
||||||
if (isUnlocked && selectedAddress) {
|
if (isUnlocked && selectedAddress) {
|
||||||
result.push(selectedAddress)
|
return [selectedAddress]
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
}
|
}
|
||||||
cb(null, result)
|
|
||||||
},
|
},
|
||||||
// tx signing
|
// tx signing
|
||||||
// old style msg signing
|
processTransaction: this.newUnapprovedTransaction.bind(this),
|
||||||
processMessage: this.newUnsignedMessage.bind(this),
|
// msg signing
|
||||||
// personal_sign msg signing
|
processEthSignMessage: this.newUnsignedMessage.bind(this),
|
||||||
processPersonalMessage: this.newUnsignedPersonalMessage.bind(this),
|
processPersonalMessage: this.newUnsignedPersonalMessage.bind(this),
|
||||||
processTypedMessage: this.newUnsignedTypedMessage.bind(this),
|
|
||||||
}
|
}
|
||||||
const providerProxy = this.networkController.initializeProvider(providerOpts)
|
const providerProxy = this.networkController.initializeProvider(providerOpts)
|
||||||
return providerProxy
|
return providerProxy
|
||||||
|
@ -318,18 +309,15 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @returns {Object} status
|
* @returns {Object} status
|
||||||
*/
|
*/
|
||||||
getState () {
|
getState () {
|
||||||
const wallet = this.configManager.getWallet()
|
|
||||||
const vault = this.keyringController.store.getState().vault
|
const vault = this.keyringController.store.getState().vault
|
||||||
const isInitialized = (!!wallet || !!vault)
|
const isInitialized = !!vault
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...{ isInitialized },
|
...{ isInitialized },
|
||||||
...this.memStore.getFilteredFlatState(),
|
...this.memStore.getFilteredFlatState(),
|
||||||
...this.configManager.getConfig(),
|
|
||||||
...{
|
...{
|
||||||
lostAccounts: this.configManager.getLostAccounts(),
|
// TODO: Remove usages of lost accounts
|
||||||
seedWords: this.configManager.getSeedWords(),
|
lostAccounts: [],
|
||||||
forgottenPassword: this.configManager.getPasswordForgotten(),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,6 +382,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
addToken: nodeify(preferencesController.addToken, preferencesController),
|
addToken: nodeify(preferencesController.addToken, preferencesController),
|
||||||
removeToken: nodeify(preferencesController.removeToken, preferencesController),
|
removeToken: nodeify(preferencesController.removeToken, preferencesController),
|
||||||
removeRpcUrl: nodeify(preferencesController.removeRpcUrl, preferencesController),
|
removeRpcUrl: nodeify(preferencesController.removeRpcUrl, preferencesController),
|
||||||
|
removeSuggestedTokens: nodeify(preferencesController.removeSuggestedTokens, preferencesController),
|
||||||
setCurrentAccountTab: nodeify(preferencesController.setCurrentAccountTab, preferencesController),
|
setCurrentAccountTab: nodeify(preferencesController.setCurrentAccountTab, preferencesController),
|
||||||
setAccountLabel: nodeify(preferencesController.setAccountLabel, preferencesController),
|
setAccountLabel: nodeify(preferencesController.setAccountLabel, preferencesController),
|
||||||
setFeatureFlag: nodeify(preferencesController.setFeatureFlag, preferencesController),
|
setFeatureFlag: nodeify(preferencesController.setFeatureFlag, preferencesController),
|
||||||
|
@ -413,6 +402,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
updateTransaction: nodeify(txController.updateTransaction, txController),
|
updateTransaction: nodeify(txController.updateTransaction, txController),
|
||||||
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
|
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
|
||||||
retryTransaction: nodeify(this.retryTransaction, this),
|
retryTransaction: nodeify(this.retryTransaction, this),
|
||||||
|
createCancelTransaction: nodeify(this.createCancelTransaction, this),
|
||||||
getFilteredTxList: nodeify(txController.getFilteredTxList, txController),
|
getFilteredTxList: nodeify(txController.getFilteredTxList, txController),
|
||||||
isNonceTaken: nodeify(txController.isNonceTaken, txController),
|
isNonceTaken: nodeify(txController.isNonceTaken, txController),
|
||||||
estimateGas: nodeify(this.estimateGas, this),
|
estimateGas: nodeify(this.estimateGas, this),
|
||||||
|
@ -483,12 +473,32 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
async createNewVaultAndRestore (password, seed) {
|
async createNewVaultAndRestore (password, seed) {
|
||||||
const releaseLock = await this.createVaultMutex.acquire()
|
const releaseLock = await this.createVaultMutex.acquire()
|
||||||
try {
|
try {
|
||||||
|
let accounts, lastBalance
|
||||||
|
|
||||||
|
const keyringController = this.keyringController
|
||||||
|
|
||||||
// clear known identities
|
// clear known identities
|
||||||
this.preferencesController.setAddresses([])
|
this.preferencesController.setAddresses([])
|
||||||
// create new vault
|
// create new vault
|
||||||
const vault = await this.keyringController.createNewVaultAndRestore(password, seed)
|
const vault = await keyringController.createNewVaultAndRestore(password, seed)
|
||||||
|
|
||||||
|
const ethQuery = new EthQuery(this.provider)
|
||||||
|
accounts = await keyringController.getAccounts()
|
||||||
|
lastBalance = await this.getBalance(accounts[accounts.length - 1], ethQuery)
|
||||||
|
|
||||||
|
const primaryKeyring = keyringController.getKeyringsByType('HD Key Tree')[0]
|
||||||
|
if (!primaryKeyring) {
|
||||||
|
throw new Error('MetamaskController - No HD Key Tree found')
|
||||||
|
}
|
||||||
|
|
||||||
|
// seek out the first zero balance
|
||||||
|
while (lastBalance !== '0x0') {
|
||||||
|
await keyringController.addNewAccount(primaryKeyring)
|
||||||
|
accounts = await keyringController.getAccounts()
|
||||||
|
lastBalance = await this.getBalance(accounts[accounts.length - 1], ethQuery)
|
||||||
|
}
|
||||||
|
|
||||||
// set new identities
|
// set new identities
|
||||||
const accounts = await this.keyringController.getAccounts()
|
|
||||||
this.preferencesController.setAddresses(accounts)
|
this.preferencesController.setAddresses(accounts)
|
||||||
this.selectFirstIdentity()
|
this.selectFirstIdentity()
|
||||||
releaseLock()
|
releaseLock()
|
||||||
|
@ -499,6 +509,30 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an account balance from the AccountTracker or request it directly from the network.
|
||||||
|
* @param {string} address - The account address
|
||||||
|
* @param {EthQuery} ethQuery - The EthQuery instance to use when asking the network
|
||||||
|
*/
|
||||||
|
getBalance (address, ethQuery) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const cached = this.accountTracker.store.getState().accounts[address]
|
||||||
|
|
||||||
|
if (cached && cached.balance) {
|
||||||
|
resolve(cached.balance)
|
||||||
|
} else {
|
||||||
|
ethQuery.getBalance(address, (error, balance) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error)
|
||||||
|
log.error(error)
|
||||||
|
} else {
|
||||||
|
resolve(balance || '0x0')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Submits the user's password and attempts to unlock the vault.
|
* Submits the user's password and attempts to unlock the vault.
|
||||||
* Also synchronizes the preferencesController, to ensure its schema
|
* Also synchronizes the preferencesController, to ensure its schema
|
||||||
|
@ -632,7 +666,9 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
this.preferencesController.setAddresses(newAccounts)
|
this.preferencesController.setAddresses(newAccounts)
|
||||||
newAccounts.forEach(address => {
|
newAccounts.forEach(address => {
|
||||||
if (!oldAccounts.includes(address)) {
|
if (!oldAccounts.includes(address)) {
|
||||||
this.preferencesController.setAccountLabel(address, `${deviceName.toUpperCase()} ${parseInt(index, 10) + 1}`)
|
// Set the account label to Trezor 1 / Ledger 1, etc
|
||||||
|
this.preferencesController.setAccountLabel(address, `${deviceName[0].toUpperCase()}${deviceName.slice(1)} ${parseInt(index, 10) + 1}`)
|
||||||
|
// Select the account
|
||||||
this.preferencesController.setSelectedAddress(address)
|
this.preferencesController.setSelectedAddress(address)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -686,7 +722,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
|
|
||||||
this.verifySeedPhrase()
|
this.verifySeedPhrase()
|
||||||
.then((seedWords) => {
|
.then((seedWords) => {
|
||||||
this.configManager.setSeedWords(seedWords)
|
this.preferencesController.setSeedWords(seedWords)
|
||||||
return cb(null, seedWords)
|
return cb(null, seedWords)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -735,7 +771,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {function} cb Callback function called with the current address.
|
* @param {function} cb Callback function called with the current address.
|
||||||
*/
|
*/
|
||||||
clearSeedWordCache (cb) {
|
clearSeedWordCache (cb) {
|
||||||
this.configManager.setSeedWords(null)
|
this.preferencesController.setSeedWords(null)
|
||||||
cb(null, this.preferencesController.getSelectedAddress())
|
cb(null, this.preferencesController.getSelectedAddress())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,7 +804,8 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
// Remove account from the preferences controller
|
// Remove account from the preferences controller
|
||||||
this.preferencesController.removeAddress(address)
|
this.preferencesController.removeAddress(address)
|
||||||
// Remove account from the account tracker controller
|
// Remove account from the account tracker controller
|
||||||
this.accountTracker.removeAccount(address)
|
this.accountTracker.removeAccount([address])
|
||||||
|
|
||||||
// Remove account from the keyring
|
// Remove account from the keyring
|
||||||
await this.keyringController.removeAccount(address)
|
await this.keyringController.removeAccount(address)
|
||||||
return address
|
return address
|
||||||
|
@ -798,6 +835,18 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Identity Management (signature operations)
|
// Identity Management (signature operations)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a Dapp suggests a new tx to be signed.
|
||||||
|
* this wrapper needs to exist so we can provide a reference to
|
||||||
|
* "newUnapprovedTransaction" before "txController" is instantiated
|
||||||
|
*
|
||||||
|
* @param {Object} msgParams - The params passed to eth_sign.
|
||||||
|
* @param {Object} req - (optional) the original request, containing the origin
|
||||||
|
*/
|
||||||
|
async newUnapprovedTransaction (txParams, req) {
|
||||||
|
return await this.txController.newUnapprovedTransaction(txParams, req)
|
||||||
|
}
|
||||||
|
|
||||||
// eth_sign methods:
|
// eth_sign methods:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -809,20 +858,11 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {Object} msgParams - The params passed to eth_sign.
|
* @param {Object} msgParams - The params passed to eth_sign.
|
||||||
* @param {Function} cb = The callback function called with the signature.
|
* @param {Function} cb = The callback function called with the signature.
|
||||||
*/
|
*/
|
||||||
newUnsignedMessage (msgParams, cb) {
|
newUnsignedMessage (msgParams, req) {
|
||||||
const msgId = this.messageManager.addUnapprovedMessage(msgParams)
|
const promise = this.messageManager.addUnapprovedMessageAsync(msgParams, req)
|
||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
this.opts.showUnconfirmedMessage()
|
this.opts.showUnconfirmedMessage()
|
||||||
this.messageManager.once(`${msgId}:finished`, (data) => {
|
return promise
|
||||||
switch (data.status) {
|
|
||||||
case 'signed':
|
|
||||||
return cb(null, data.rawSig)
|
|
||||||
case 'rejected':
|
|
||||||
return cb(cleanErrorStack(new Error('Nifty Wallet Message Signature: User denied message signature.')))
|
|
||||||
default:
|
|
||||||
return cb(cleanErrorStack(new Error(`Nifty Wallet Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -876,24 +916,11 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {Function} cb - The callback function called with the signature.
|
* @param {Function} cb - The callback function called with the signature.
|
||||||
* Passed back to the requesting Dapp.
|
* Passed back to the requesting Dapp.
|
||||||
*/
|
*/
|
||||||
newUnsignedPersonalMessage (msgParams, cb) {
|
async newUnsignedPersonalMessage (msgParams, req) {
|
||||||
if (!msgParams.from) {
|
const promise = this.personalMessageManager.addUnapprovedMessageAsync(msgParams, req)
|
||||||
return cb(cleanErrorStack(new Error('Nifty Wallet Message Signature: from field is required.')))
|
|
||||||
}
|
|
||||||
|
|
||||||
const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
|
|
||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
this.opts.showUnconfirmedMessage()
|
this.opts.showUnconfirmedMessage()
|
||||||
this.personalMessageManager.once(`${msgId}:finished`, (data) => {
|
return promise
|
||||||
switch (data.status) {
|
|
||||||
case 'signed':
|
|
||||||
return cb(null, data.rawSig)
|
|
||||||
case 'rejected':
|
|
||||||
return cb(cleanErrorStack(new Error('Nifty Wallet Message Signature: User denied message signature.')))
|
|
||||||
default:
|
|
||||||
return cb(cleanErrorStack(new Error(`Nifty Wallet Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -942,26 +969,11 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {Object} msgParams - The params passed to eth_signTypedData.
|
* @param {Object} msgParams - The params passed to eth_signTypedData.
|
||||||
* @param {Function} cb - The callback function, called with the signature.
|
* @param {Function} cb - The callback function, called with the signature.
|
||||||
*/
|
*/
|
||||||
newUnsignedTypedMessage (msgParams, cb) {
|
newUnsignedTypedMessage (msgParams, req) {
|
||||||
let msgId
|
const promise = this.typedMessageManager.addUnapprovedMessageAsync(msgParams, req)
|
||||||
try {
|
|
||||||
msgId = this.typedMessageManager.addUnapprovedMessage(msgParams)
|
|
||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
this.opts.showUnconfirmedMessage()
|
this.opts.showUnconfirmedMessage()
|
||||||
} catch (e) {
|
return promise
|
||||||
return cb(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.typedMessageManager.once(`${msgId}:finished`, (data) => {
|
|
||||||
switch (data.status) {
|
|
||||||
case 'signed':
|
|
||||||
return cb(null, data.rawSig)
|
|
||||||
case 'rejected':
|
|
||||||
return cb(cleanErrorStack(new Error('Nifty Wallet Message Signature: User denied message signature.')))
|
|
||||||
default:
|
|
||||||
return cb(cleanErrorStack(new Error(`Nifty Wallet Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -971,22 +983,31 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {Object} msgParams - The params passed to eth_signTypedData.
|
* @param {Object} msgParams - The params passed to eth_signTypedData.
|
||||||
* @returns {Object} Full state update.
|
* @returns {Object} Full state update.
|
||||||
*/
|
*/
|
||||||
signTypedMessage (msgParams) {
|
async signTypedMessage (msgParams) {
|
||||||
log.info('MetaMaskController - signTypedMessage')
|
log.info('MetaMaskController - eth_signTypedData')
|
||||||
const msgId = msgParams.metamaskId
|
const msgId = msgParams.metamaskId
|
||||||
// sets the status op the message to 'approved'
|
const version = msgParams.version
|
||||||
// and removes the metamaskId for signing
|
try {
|
||||||
return this.typedMessageManager.approveMessage(msgParams)
|
const cleanMsgParams = await this.typedMessageManager.approveMessage(msgParams)
|
||||||
.then((cleanMsgParams) => {
|
const address = sigUtil.normalize(cleanMsgParams.from)
|
||||||
// signs the message
|
const keyring = await this.keyringController.getKeyringForAccount(address)
|
||||||
return this.keyringController.signTypedMessage(cleanMsgParams)
|
const wallet = keyring._getWalletForAccount(address)
|
||||||
})
|
const privKey = ethUtil.toBuffer(wallet.getPrivateKey())
|
||||||
.then((rawSig) => {
|
let signature
|
||||||
// tells the listener that the message has been signed
|
switch (version) {
|
||||||
// and can be returned to the dapp
|
case 'V1':
|
||||||
this.typedMessageManager.setMsgStatusSigned(msgId, rawSig)
|
signature = sigUtil.signTypedDataLegacy(privKey, { data: cleanMsgParams.data })
|
||||||
|
break
|
||||||
|
case 'V3':
|
||||||
|
signature = sigUtil.signTypedData(privKey, { data: JSON.parse(cleanMsgParams.data) })
|
||||||
|
break
|
||||||
|
}
|
||||||
|
this.typedMessageManager.setMsgStatusSigned(msgId, signature)
|
||||||
return this.getState()
|
return this.getState()
|
||||||
})
|
} catch (error) {
|
||||||
|
log.info('MetaMaskController - eth_signTypedData failed.', error)
|
||||||
|
this.typedMessageManager.errorMessage(msgId, error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1024,35 +1045,16 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* A legacy method used to record user confirmation that they understand
|
* A legacy method used to record user confirmation that they understand
|
||||||
* that some of their accounts have been recovered but should be backed up.
|
* that some of their accounts have been recovered but should be backed up.
|
||||||
|
* This function no longer does anything and will be removed.
|
||||||
*
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param {Function} cb - A callback function called with a full state update.
|
* @param {Function} cb - A callback function called with a full state update.
|
||||||
*/
|
*/
|
||||||
markAccountsFound (cb) {
|
markAccountsFound (cb) {
|
||||||
this.configManager.setLostAccounts([])
|
// TODO Remove me
|
||||||
this.sendUpdate()
|
|
||||||
cb(null, this.getState())
|
cb(null, this.getState())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A legacy method (probably dead code) that was used when we swapped out our
|
|
||||||
* key management library that we depended on.
|
|
||||||
*
|
|
||||||
* Described in:
|
|
||||||
* https://medium.com/metamask/metamask-3-migration-guide-914b79533cdd
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @param {} migratorOutput
|
|
||||||
*/
|
|
||||||
restoreOldLostAccounts (migratorOutput) {
|
|
||||||
const { lostAccounts } = migratorOutput
|
|
||||||
if (lostAccounts) {
|
|
||||||
this.configManager.setLostAccounts(lostAccounts.map(acct => acct.address))
|
|
||||||
return this.importLostAccounts(migratorOutput)
|
|
||||||
}
|
|
||||||
return Promise.resolve(migratorOutput)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An account object
|
* An account object
|
||||||
* @typedef Account
|
* @typedef Account
|
||||||
|
@ -1097,6 +1099,19 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows a user to attempt to cancel a previously submitted transaction by creating a new
|
||||||
|
* transaction.
|
||||||
|
* @param {number} originalTxId - the id of the txMeta that you want to attempt to cancel
|
||||||
|
* @param {string=} customGasPrice - the hex value to use for the cancel transaction
|
||||||
|
* @returns {object} MetaMask state
|
||||||
|
*/
|
||||||
|
async createCancelTransaction (originalTxId, customGasPrice, cb) {
|
||||||
|
await this.txController.createCancelTransaction(originalTxId, customGasPrice)
|
||||||
|
const state = await this.getState()
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
|
||||||
estimateGas (estimateGasParams) {
|
estimateGas (estimateGasParams) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
return this.txController.txGasUtil.query.estimateGas(estimateGasParams, (err, res) => {
|
return this.txController.txGasUtil.query.estimateGas(estimateGasParams, (err, res) => {
|
||||||
|
@ -1118,7 +1133,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {Function} cb - A callback function called when complete.
|
* @param {Function} cb - A callback function called when complete.
|
||||||
*/
|
*/
|
||||||
markPasswordForgotten (cb) {
|
markPasswordForgotten (cb) {
|
||||||
this.configManager.setPasswordForgotten(true)
|
this.preferencesController.setPasswordForgotten(true)
|
||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
@ -1128,7 +1143,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {Function} cb - A callback function called when complete.
|
* @param {Function} cb - A callback function called when complete.
|
||||||
*/
|
*/
|
||||||
unMarkPasswordForgotten (cb) {
|
unMarkPasswordForgotten (cb) {
|
||||||
this.configManager.setPasswordForgotten(false)
|
this.preferencesController.setPasswordForgotten(false)
|
||||||
this.sendUpdate()
|
this.sendUpdate()
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
@ -1199,18 +1214,28 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
setupControllerConnection (outStream) {
|
setupControllerConnection (outStream) {
|
||||||
const api = this.getApi()
|
const api = this.getApi()
|
||||||
const dnode = Dnode(api)
|
const dnode = Dnode(api)
|
||||||
|
// report new active controller connection
|
||||||
|
this.activeControllerConnections++
|
||||||
|
this.emit('controllerConnectionChanged', this.activeControllerConnections)
|
||||||
|
// connect dnode api to remote connection
|
||||||
pump(
|
pump(
|
||||||
outStream,
|
outStream,
|
||||||
dnode,
|
dnode,
|
||||||
outStream,
|
outStream,
|
||||||
(err) => {
|
(err) => {
|
||||||
|
// report new active controller connection
|
||||||
|
this.activeControllerConnections--
|
||||||
|
this.emit('controllerConnectionChanged', this.activeControllerConnections)
|
||||||
|
// report any error
|
||||||
if (err) log.error(err)
|
if (err) log.error(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
dnode.on('remote', (remote) => {
|
dnode.on('remote', (remote) => {
|
||||||
// push updates to popup
|
// push updates to popup
|
||||||
const sendUpdate = remote.sendUpdate.bind(remote)
|
const sendUpdate = (update) => remote.sendUpdate(update)
|
||||||
this.on('update', sendUpdate)
|
this.on('update', sendUpdate)
|
||||||
|
// remove update listener once the connection ends
|
||||||
|
dnode.on('end', () => this.removeListener('update', sendUpdate))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,12 +1251,16 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
// create filter polyfill middleware
|
// create filter polyfill middleware
|
||||||
const filterMiddleware = createFilterMiddleware({
|
const filterMiddleware = createFilterMiddleware({
|
||||||
provider: this.provider,
|
provider: this.provider,
|
||||||
blockTracker: this.provider._blockTracker,
|
blockTracker: this.blockTracker,
|
||||||
})
|
})
|
||||||
|
|
||||||
engine.push(createOriginMiddleware({ origin }))
|
engine.push(createOriginMiddleware({ origin }))
|
||||||
engine.push(createLoggerMiddleware({ origin }))
|
engine.push(createLoggerMiddleware({ origin }))
|
||||||
engine.push(filterMiddleware)
|
engine.push(filterMiddleware)
|
||||||
|
engine.push(this.preferencesController.requestWatchAsset.bind(this.preferencesController))
|
||||||
|
engine.push(this.createTypedDataMiddleware('eth_signTypedData', 'V1').bind(this))
|
||||||
|
engine.push(this.createTypedDataMiddleware('eth_signTypedData_v1', 'V1').bind(this))
|
||||||
|
engine.push(this.createTypedDataMiddleware('eth_signTypedData_v3', 'V3').bind(this))
|
||||||
engine.push(createProviderMiddleware({ provider: this.provider }))
|
engine.push(createProviderMiddleware({ provider: this.provider }))
|
||||||
|
|
||||||
// setup connection
|
// setup connection
|
||||||
|
@ -1259,15 +1288,45 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {*} outStream - The stream to provide public config over.
|
* @param {*} outStream - The stream to provide public config over.
|
||||||
*/
|
*/
|
||||||
setupPublicConfig (outStream) {
|
setupPublicConfig (outStream) {
|
||||||
|
const configStream = asStream(this.publicConfigStore)
|
||||||
pump(
|
pump(
|
||||||
asStream(this.publicConfigStore),
|
configStream,
|
||||||
outStream,
|
outStream,
|
||||||
(err) => {
|
(err) => {
|
||||||
|
configStream.destroy()
|
||||||
if (err) log.error(err)
|
if (err) log.error(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a KeyringController update
|
||||||
|
* @param {object} state the KC state
|
||||||
|
* @return {Promise<void>}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
async _onKeyringControllerUpdate (state) {
|
||||||
|
const {isUnlocked, keyrings} = state
|
||||||
|
const addresses = keyrings.reduce((acc, {accounts}) => acc.concat(accounts), [])
|
||||||
|
|
||||||
|
if (!addresses.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure preferences + identities controller know about all addresses
|
||||||
|
this.preferencesController.addAddresses(addresses)
|
||||||
|
this.accountTracker.syncWithAddresses(addresses)
|
||||||
|
|
||||||
|
const wasLocked = !isUnlocked
|
||||||
|
if (wasLocked) {
|
||||||
|
const oldSelectedAddress = this.preferencesController.getSelectedAddress()
|
||||||
|
if (!addresses.includes(oldSelectedAddress)) {
|
||||||
|
const address = addresses[0]
|
||||||
|
await this.preferencesController.setSelectedAddress(address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method for emitting the full MetaMask state to all registered listeners.
|
* A method for emitting the full MetaMask state to all registered listeners.
|
||||||
* @private
|
* @private
|
||||||
|
@ -1439,6 +1498,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Replace isClientOpen methods with `controllerConnectionChanged` events.
|
||||||
/**
|
/**
|
||||||
* A method for recording whether the MetaMask user interface is open or not.
|
* A method for recording whether the MetaMask user interface is open or not.
|
||||||
* @private
|
* @private
|
||||||
|
@ -1459,4 +1519,34 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
set isClientOpenAndUnlocked (active) {
|
set isClientOpenAndUnlocked (active) {
|
||||||
this.tokenRatesController.isActive = active
|
this.tokenRatesController.isActive = active
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates RPC engine middleware for processing eth_signTypedData requests
|
||||||
|
*
|
||||||
|
* @param {Object} req - request object
|
||||||
|
* @param {Object} res - response object
|
||||||
|
* @param {Function} - next
|
||||||
|
* @param {Function} - end
|
||||||
|
*/
|
||||||
|
createTypedDataMiddleware (methodName, version) {
|
||||||
|
return async (req, res, next, end) => {
|
||||||
|
const { method, params } = req
|
||||||
|
if (method === methodName) {
|
||||||
|
const promise = this.typedMessageManager.addUnapprovedMessageAsync({
|
||||||
|
data: params.length >= 1 && params[0],
|
||||||
|
from: params.length >= 2 && params[1],
|
||||||
|
}, req, version)
|
||||||
|
this.sendUpdate()
|
||||||
|
this.opts.showUnconfirmedMessage()
|
||||||
|
try {
|
||||||
|
res.result = await promise
|
||||||
|
end()
|
||||||
|
} catch (error) {
|
||||||
|
end(error)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
const version = 5
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
This is an incomplete migration bc it requires post-decrypted data
|
|
||||||
which we dont have access to at the time of this writing.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const ObservableStore = require('obs-store')
|
|
||||||
const ConfigManager = require('../../app/scripts/lib/config-manager')
|
|
||||||
const IdentityStoreMigrator = require('../../app/scripts/lib/idStore-migrator')
|
|
||||||
const KeyringController = require('eth-keychain-controller')
|
|
||||||
|
|
||||||
const password = 'obviously not correct'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
version,
|
|
||||||
|
|
||||||
migrate: function (versionedData) {
|
|
||||||
versionedData.meta.version = version
|
|
||||||
|
|
||||||
const store = new ObservableStore(versionedData.data)
|
|
||||||
const configManager = new ConfigManager({ store })
|
|
||||||
const idStoreMigrator = new IdentityStoreMigrator({ configManager })
|
|
||||||
const keyringController = new KeyringController({
|
|
||||||
configManager: configManager,
|
|
||||||
})
|
|
||||||
|
|
||||||
// attempt to migrate to multiVault
|
|
||||||
return idStoreMigrator.migratedVaultForPassword(password)
|
|
||||||
.then((result) => {
|
|
||||||
// skip if nothing to migrate
|
|
||||||
if (!result) return Promise.resolve(versionedData)
|
|
||||||
delete versionedData.data.wallet
|
|
||||||
// create new keyrings
|
|
||||||
const privKeys = result.lostAccounts.map(acct => acct.privateKey)
|
|
||||||
return Promise.all([
|
|
||||||
keyringController.restoreKeyring(result.serialized),
|
|
||||||
keyringController.restoreKeyring({ type: 'Simple Key Pair', data: privKeys }),
|
|
||||||
]).then(() => {
|
|
||||||
return keyringController.persistAllKeyrings(password)
|
|
||||||
}).then(() => {
|
|
||||||
// copy result on to state object
|
|
||||||
versionedData.data = store.get()
|
|
||||||
return Promise.resolve(versionedData)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ const uniqBy = require('lodash.uniqby')
|
||||||
|
|
||||||
module.exports = class NoticeController extends EventEmitter {
|
module.exports = class NoticeController extends EventEmitter {
|
||||||
|
|
||||||
constructor (opts) {
|
constructor (opts = {}) {
|
||||||
super()
|
super()
|
||||||
this.noticePoller = null
|
this.noticePoller = null
|
||||||
this.firstVersion = opts.firstVersion
|
this.firstVersion = opts.firstVersion
|
||||||
|
|
|
@ -2,7 +2,7 @@ const injectCss = require('inject-css')
|
||||||
const OldMetaMaskUiCss = require('../../old-ui/css')
|
const OldMetaMaskUiCss = require('../../old-ui/css')
|
||||||
const NewMetaMaskUiCss = require('../../ui/css')
|
const NewMetaMaskUiCss = require('../../ui/css')
|
||||||
const startPopup = require('./popup-core')
|
const startPopup = require('./popup-core')
|
||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('extension-port-stream')
|
||||||
const { getEnvironmentType } = require('./lib/util')
|
const { getEnvironmentType } = require('./lib/util')
|
||||||
const { ENVIRONMENT_TYPE_NOTIFICATION } = require('./lib/enums')
|
const { ENVIRONMENT_TYPE_NOTIFICATION } = require('./lib/enums')
|
||||||
const extension = require('extensionizer')
|
const extension = require('extensionizer')
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
"modalState": {},
|
"modalState": {},
|
||||||
"previousModalState": {}
|
"previousModalState": {}
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"transForward": true,
|
"transForward": true,
|
||||||
"isLoading": false,
|
"isLoading": false,
|
||||||
"warning": null,
|
"warning": null,
|
||||||
|
|
|
@ -141,6 +141,7 @@
|
||||||
"accountDetail": {
|
"accountDetail": {
|
||||||
"subview": "transactions"
|
"subview": "transactions"
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"modal": {
|
"modal": {
|
||||||
"modalState": {},
|
"modalState": {},
|
||||||
"previousModalState": {}
|
"previousModalState": {}
|
||||||
|
|
|
@ -162,6 +162,7 @@
|
||||||
"accountDetail": {
|
"accountDetail": {
|
||||||
"subview": "transactions"
|
"subview": "transactions"
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"modal": {
|
"modal": {
|
||||||
"modalState": {},
|
"modalState": {},
|
||||||
"previousModalState": {}
|
"previousModalState": {}
|
||||||
|
|
|
@ -120,6 +120,7 @@
|
||||||
"accountDetail": {
|
"accountDetail": {
|
||||||
"subview": "transactions"
|
"subview": "transactions"
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"modal": {
|
"modal": {
|
||||||
"modalState": {},
|
"modalState": {},
|
||||||
"previousModalState": {}
|
"previousModalState": {}
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
"accountDetail": {
|
"accountDetail": {
|
||||||
"subview": "transactions"
|
"subview": "transactions"
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"transForward": true,
|
"transForward": true,
|
||||||
"isLoading": false,
|
"isLoading": false,
|
||||||
"warning": null,
|
"warning": null,
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
"name": "Send Account 4"
|
"name": "Send Account 4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"assetImages": {},
|
||||||
"unapprovedTxs": {},
|
"unapprovedTxs": {},
|
||||||
"currentCurrency": "USD",
|
"currentCurrency": "USD",
|
||||||
"conversionRate": 1200.88200327,
|
"conversionRate": 1200.88200327,
|
||||||
|
@ -141,6 +142,7 @@
|
||||||
"accountDetail": {
|
"accountDetail": {
|
||||||
"subview": "transactions"
|
"subview": "transactions"
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"modal": {
|
"modal": {
|
||||||
"modalState": {},
|
"modalState": {},
|
||||||
"previousModalState": {}
|
"previousModalState": {}
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
"name": "Address Book Account 1"
|
"name": "Address Book Account 1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"assetImages": {},
|
||||||
"tokens": [],
|
"tokens": [],
|
||||||
"transactions": {},
|
"transactions": {},
|
||||||
"selectedAddressTxList": [],
|
"selectedAddressTxList": [],
|
||||||
|
@ -120,6 +121,7 @@
|
||||||
"accountDetail": {
|
"accountDetail": {
|
||||||
"subview": "transactions"
|
"subview": "transactions"
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"modal": {
|
"modal": {
|
||||||
"modalState": {},
|
"modalState": {},
|
||||||
"previousModalState": {}
|
"previousModalState": {}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
"name": "Account 4"
|
"name": "Account 4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"assetImages": {},
|
||||||
"unapprovedTxs": {},
|
"unapprovedTxs": {},
|
||||||
"currentCurrency": "USD",
|
"currentCurrency": "USD",
|
||||||
"conversionRate": 16.88200327,
|
"conversionRate": 16.88200327,
|
||||||
|
@ -99,6 +100,7 @@
|
||||||
"accountExport": "none",
|
"accountExport": "none",
|
||||||
"privateKey": ""
|
"privateKey": ""
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"transForward": true,
|
"transForward": true,
|
||||||
"isLoading": false,
|
"isLoading": false,
|
||||||
"warning": null,
|
"warning": null,
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
"modalState": {},
|
"modalState": {},
|
||||||
"previousModalState": {}
|
"previousModalState": {}
|
||||||
},
|
},
|
||||||
|
"sidebar": {},
|
||||||
"transForward": true,
|
"transForward": true,
|
||||||
"isLoading": false,
|
"isLoading": false,
|
||||||
"warning": null,
|
"warning": null,
|
||||||
|
|
|
@ -5,7 +5,6 @@ To add another network to our dropdown menu, make sure the following files are a
|
||||||
```
|
```
|
||||||
app/scripts/config.js
|
app/scripts/config.js
|
||||||
app/scripts/lib/buy-eth-url.js
|
app/scripts/lib/buy-eth-url.js
|
||||||
app/scripts/lib/config-manager.js
|
|
||||||
ui/app/app.js
|
ui/app/app.js
|
||||||
ui/app/components/buy-button-subview.js
|
ui/app/components/buy-button-subview.js
|
||||||
ui/app/components/drop-menu-item.js
|
ui/app/components/drop-menu-item.js
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
### Developing on Dependencies
|
### Developing on Dependencies
|
||||||
|
|
||||||
To enjoy the live-reloading that `gulp dev` offers while working on the `web3-provider-engine` or other dependencies:
|
To enjoy the live-reloading that `gulp dev` offers while working on the dependencies:
|
||||||
|
|
||||||
1. Clone the dependency locally.
|
1. Clone the dependency locally.
|
||||||
2. `npm install` in its folder.
|
2. `npm install` in its folder.
|
||||||
3. Run `npm link` in its folder.
|
3. Run `npm link` in its folder.
|
||||||
4. Run `npm link $DEP_NAME` in this project folder.
|
4. Run `npm link $DEP_NAME` in this project folder.
|
||||||
5. Next time you `npm start` it will watch the dependency for changes as well!
|
5. Next time you `npm start` it will watch the dependency for changes as well!
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,6 @@ MetaMask has two kinds of [duplex stream APIs](https://github.com/substack/strea
|
||||||
|
|
||||||
If you are making a MetaMask-powered browser for a new platform, one of the trickiest tasks will be injecting the Web3 API into websites that are visited. On WebExtensions, we actually have to pipe data through a total of three JS contexts just to let sites talk to our background process (site -> contentscript -> background).
|
If you are making a MetaMask-powered browser for a new platform, one of the trickiest tasks will be injecting the Web3 API into websites that are visited. On WebExtensions, we actually have to pipe data through a total of three JS contexts just to let sites talk to our background process (site -> contentscript -> background).
|
||||||
|
|
||||||
To make this as easy as possible, we use one of our favorite internal tools, [web3-provider-engine](https://www.npmjs.com/package/web3-provider-engine) to construct a custom web3 provider object whose source of truth is a stream that we connect to remotely.
|
|
||||||
|
|
||||||
To see how we do that, you can refer to the [inpage script](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/inpage.js) that we inject into every website. There you can see it creates a multiplex stream to the background, and uses it to initialize what we call the [inpage-provider](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/lib/inpage-provider.js), which you can see stubs a few methods out, but mostly just passes calls to `sendAsync` through the stream it's passed! That's really all the magic that's needed to create a web3-like API in a remote context, once you have a stream to MetaMask available.
|
To see how we do that, you can refer to the [inpage script](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/inpage.js) that we inject into every website. There you can see it creates a multiplex stream to the background, and uses it to initialize what we call the [inpage-provider](https://github.com/MetaMask/metamask-extension/blob/master/app/scripts/lib/inpage-provider.js), which you can see stubs a few methods out, but mostly just passes calls to `sendAsync` through the stream it's passed! That's really all the magic that's needed to create a web3-like API in a remote context, once you have a stream to MetaMask available.
|
||||||
|
|
||||||
In `inpage.js` you can see we create a `PortStream`, that's just a class we use to wrap WebExtension ports as streams, so we can reuse our favorite stream abstraction over the more irregular API surface of the WebExtension. In a new platform, you will probably need to construct this stream differently. The key is that you need to construct a stream that talks from the site context to the background. Once you have that set up, it works like magic!
|
In `inpage.js` you can see we create a `PortStream`, that's just a class we use to wrap WebExtension ports as streams, so we can reuse our favorite stream abstraction over the more irregular API surface of the WebExtension. In a new platform, you will probably need to construct this stream differently. The key is that you need to construct a stream that talks from the site context to the background. Once you have that set up, it works like magic!
|
||||||
|
|
|
@ -62,7 +62,9 @@ class CreatePasswordScreen extends Component {
|
||||||
return password === confirmPassword
|
return password === confirmPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
createAccount = () => {
|
createAccount = (event) => {
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
if (!this.isValid()) {
|
if (!this.isValid()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -121,7 +123,7 @@ class CreatePasswordScreen extends Component {
|
||||||
It allows you to hold ether & tokens, and interact with decentralized applications.
|
It allows you to hold ether & tokens, and interact with decentralized applications.
|
||||||
</div>
|
</div>
|
||||||
</div>}
|
</div>}
|
||||||
<div className="create-password">
|
<form className="create-password">
|
||||||
<div className="create-password__title">
|
<div className="create-password__title">
|
||||||
Create Password
|
Create Password
|
||||||
</div>
|
</div>
|
||||||
|
@ -182,7 +184,7 @@ class CreatePasswordScreen extends Component {
|
||||||
</a>
|
</a>
|
||||||
{ */ }
|
{ */ }
|
||||||
<Breadcrumbs total={3} currentIndex={0} />
|
<Breadcrumbs total={3} currentIndex={0} />
|
||||||
</div>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,6 +33,7 @@ function mapStateToProps (state) {
|
||||||
currentCurrency: state.metamask.currentCurrency,
|
currentCurrency: state.metamask.currentCurrency,
|
||||||
currentAccountTab: state.metamask.currentAccountTab,
|
currentAccountTab: state.metamask.currentAccountTab,
|
||||||
tokens: state.metamask.tokens,
|
tokens: state.metamask.tokens,
|
||||||
|
suggestedTokens: state.metamask.suggestedTokens,
|
||||||
computedBalances: state.metamask.computedBalances,
|
computedBalances: state.metamask.computedBalances,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +51,10 @@ AccountDetailScreen.prototype.render = function () {
|
||||||
var account = props.accounts[selected]
|
var account = props.accounts[selected]
|
||||||
const { network, conversionRate, currentCurrency } = props
|
const { network, conversionRate, currentCurrency } = props
|
||||||
|
|
||||||
|
if (Object.keys(props.suggestedTokens).length > 0) {
|
||||||
|
this.props.dispatch(actions.showAddSuggestedTokenPage())
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
h('.account-detail-section.full-flex-height', [
|
h('.account-detail-section.full-flex-height', [
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
const inherits = require('util').inherits
|
||||||
|
const Component = require('react').Component
|
||||||
|
const h = require('react-hyperscript')
|
||||||
|
const connect = require('react-redux').connect
|
||||||
|
const actions = require('../../ui/app/actions')
|
||||||
|
const Tooltip = require('./components/tooltip.js')
|
||||||
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
const Copyable = require('./components/copyable')
|
||||||
|
const addressSummary = require('./util').addressSummary
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = connect(mapStateToProps)(AddSuggestedTokenScreen)
|
||||||
|
|
||||||
|
function mapStateToProps (state) {
|
||||||
|
return {
|
||||||
|
identities: state.metamask.identities,
|
||||||
|
suggestedTokens: state.metamask.suggestedTokens,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inherits(AddSuggestedTokenScreen, Component)
|
||||||
|
function AddSuggestedTokenScreen () {
|
||||||
|
this.state = {
|
||||||
|
warning: null,
|
||||||
|
}
|
||||||
|
Component.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
AddSuggestedTokenScreen.prototype.render = function () {
|
||||||
|
const state = this.state
|
||||||
|
const props = this.props
|
||||||
|
const { warning } = state
|
||||||
|
const key = Object.keys(props.suggestedTokens)[0]
|
||||||
|
const { address, symbol, decimals } = props.suggestedTokens[key]
|
||||||
|
|
||||||
|
return (
|
||||||
|
h('.flex-column.flex-grow', [
|
||||||
|
|
||||||
|
// subtitle and nav
|
||||||
|
h('.section-title.flex-row.flex-center', [
|
||||||
|
h('h2.page-subtitle', 'Add Suggested Token'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('.error', {
|
||||||
|
style: {
|
||||||
|
display: warning ? 'block' : 'none',
|
||||||
|
padding: '0 20px',
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
}, warning),
|
||||||
|
|
||||||
|
// conf view
|
||||||
|
h('.flex-column.flex-justify-center.flex-grow.select-none', [
|
||||||
|
h('.flex-space-around', {
|
||||||
|
style: {
|
||||||
|
padding: '20px',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
|
||||||
|
h('div', [
|
||||||
|
h(Tooltip, {
|
||||||
|
position: 'top',
|
||||||
|
title: 'The contract of the actual token contract. Click for more info.',
|
||||||
|
}, [
|
||||||
|
h('a', {
|
||||||
|
style: { fontWeight: 'bold', paddingRight: '10px'},
|
||||||
|
href: 'https://support.metamask.io/kb/article/24-what-is-a-token-contract-address',
|
||||||
|
target: '_blank',
|
||||||
|
}, [
|
||||||
|
h('span', 'Token Contract Address '),
|
||||||
|
h('i.fa.fa-question-circle'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div', {
|
||||||
|
style: { display: 'flex' },
|
||||||
|
}, [
|
||||||
|
h(Copyable, {
|
||||||
|
value: ethUtil.toChecksumAddress(address),
|
||||||
|
}, [
|
||||||
|
h('span#token-address', {
|
||||||
|
style: {
|
||||||
|
width: 'inherit',
|
||||||
|
flex: '1 0 auto',
|
||||||
|
height: '30px',
|
||||||
|
margin: '8px',
|
||||||
|
display: 'flex',
|
||||||
|
},
|
||||||
|
}, addressSummary(address, 24, 4, false)),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div', [
|
||||||
|
h('span', {
|
||||||
|
style: { fontWeight: 'bold', paddingRight: '10px'},
|
||||||
|
}, 'Token Symbol'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div', { style: {display: 'flex'} }, [
|
||||||
|
h('p#token_symbol', {
|
||||||
|
style: {
|
||||||
|
width: 'inherit',
|
||||||
|
flex: '1 0 auto',
|
||||||
|
height: '30px',
|
||||||
|
margin: '8px',
|
||||||
|
},
|
||||||
|
}, symbol),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div', [
|
||||||
|
h('span', {
|
||||||
|
style: { fontWeight: 'bold', paddingRight: '10px'},
|
||||||
|
}, 'Decimals of Precision'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div', { style: {display: 'flex'} }, [
|
||||||
|
h('p#token_decimals', {
|
||||||
|
type: 'number',
|
||||||
|
style: {
|
||||||
|
width: 'inherit',
|
||||||
|
flex: '1 0 auto',
|
||||||
|
height: '30px',
|
||||||
|
margin: '8px',
|
||||||
|
},
|
||||||
|
}, decimals),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('button', {
|
||||||
|
style: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
margin: '8px',
|
||||||
|
},
|
||||||
|
onClick: (event) => {
|
||||||
|
this.props.dispatch(actions.removeSuggestedTokens())
|
||||||
|
},
|
||||||
|
}, 'Cancel'),
|
||||||
|
|
||||||
|
h('button', {
|
||||||
|
style: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
margin: '8px',
|
||||||
|
},
|
||||||
|
onClick: (event) => {
|
||||||
|
const valid = this.validateInputs({ address, symbol, decimals })
|
||||||
|
if (!valid) return
|
||||||
|
|
||||||
|
this.props.dispatch(actions.addToken(address.trim(), symbol.trim(), decimals))
|
||||||
|
.then(() => {
|
||||||
|
this.props.dispatch(actions.removeSuggestedTokens())
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}, 'Add'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
AddSuggestedTokenScreen.prototype.componentWillMount = function () {
|
||||||
|
if (typeof global.ethereumProvider === 'undefined') return
|
||||||
|
}
|
||||||
|
|
||||||
|
AddSuggestedTokenScreen.prototype.validateInputs = function (opts) {
|
||||||
|
let msg = ''
|
||||||
|
const identitiesList = Object.keys(this.props.identities)
|
||||||
|
const { address, symbol, decimals } = opts
|
||||||
|
const standardAddress = ethUtil.addHexPrefix(address).toLowerCase()
|
||||||
|
|
||||||
|
const validAddress = ethUtil.isValidAddress(address)
|
||||||
|
if (!validAddress) {
|
||||||
|
msg += 'Address is invalid.'
|
||||||
|
}
|
||||||
|
|
||||||
|
const validDecimals = decimals >= 0 && decimals <= 36
|
||||||
|
if (!validDecimals) {
|
||||||
|
msg += 'Decimals must be at least 0, and not over 36. '
|
||||||
|
}
|
||||||
|
|
||||||
|
const symbolLen = symbol.trim().length
|
||||||
|
const validSymbol = symbolLen > 0 && symbolLen < 10
|
||||||
|
if (!validSymbol) {
|
||||||
|
msg += 'Symbol must be between 0 and 10 characters.'
|
||||||
|
}
|
||||||
|
|
||||||
|
const ownAddress = identitiesList.includes(standardAddress)
|
||||||
|
if (ownAddress) {
|
||||||
|
msg = 'Personal address detected. Input the token contract address.'
|
||||||
|
}
|
||||||
|
|
||||||
|
const isValid = validAddress && validDecimals && !ownAddress
|
||||||
|
|
||||||
|
if (!isValid) {
|
||||||
|
this.setState({
|
||||||
|
warning: msg,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.setState({ warning: null })
|
||||||
|
}
|
||||||
|
|
||||||
|
return isValid
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ const ConfigScreen = require('./config')
|
||||||
const AddTokenScreen = require('./components/add-token')
|
const AddTokenScreen = require('./components/add-token')
|
||||||
const ConfirmAddTokenScreen = require('./components/confirm-add-token')
|
const ConfirmAddTokenScreen = require('./components/confirm-add-token')
|
||||||
const RemoveTokenScreen = require('./remove-token')
|
const RemoveTokenScreen = require('./remove-token')
|
||||||
|
const AddSuggestedTokenScreen = require('./add-suggested-token')
|
||||||
const Import = require('./accounts/import')
|
const Import = require('./accounts/import')
|
||||||
const InfoScreen = require('./info')
|
const InfoScreen = require('./info')
|
||||||
const AppBar = require('./components/app-bar')
|
const AppBar = require('./components/app-bar')
|
||||||
|
@ -80,6 +81,7 @@ function mapStateToProps (state) {
|
||||||
lostAccounts: state.metamask.lostAccounts,
|
lostAccounts: state.metamask.lostAccounts,
|
||||||
frequentRpcList: state.metamask.frequentRpcList || [],
|
frequentRpcList: state.metamask.frequentRpcList || [],
|
||||||
featureFlags,
|
featureFlags,
|
||||||
|
suggestedTokens: state.metamask.suggestedTokens,
|
||||||
|
|
||||||
// state needed to get account dropdown temporarily rendering from app bar
|
// state needed to get account dropdown temporarily rendering from app bar
|
||||||
identities,
|
identities,
|
||||||
|
@ -248,6 +250,10 @@ App.prototype.renderPrimary = function () {
|
||||||
log.debug('rendering remove-token screen from unlock screen.')
|
log.debug('rendering remove-token screen from unlock screen.')
|
||||||
return h(RemoveTokenScreen, {key: 'remove-token', ...props.currentView.context })
|
return h(RemoveTokenScreen, {key: 'remove-token', ...props.currentView.context })
|
||||||
|
|
||||||
|
case 'add-suggested-token':
|
||||||
|
log.debug('rendering add-suggested-token screen from unlock screen.')
|
||||||
|
return h(AddSuggestedTokenScreen, {key: 'add-suggested-token'})
|
||||||
|
|
||||||
case 'config':
|
case 'config':
|
||||||
log.debug('rendering config screen')
|
log.debug('rendering config screen')
|
||||||
return h(ConfigScreen, {key: 'config'})
|
return h(ConfigScreen, {key: 'config'})
|
||||||
|
|
|
@ -124,6 +124,12 @@ Notice.prototype.render = function () {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notice.prototype.setInitialDisclaimerState = function () {
|
||||||
|
if (document.getElementsByClassName('notice-box')[0].clientHeight < 310) {
|
||||||
|
this.setState({disclaimerDisabled: false})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Notice.prototype.componentDidMount = function () {
|
Notice.prototype.componentDidMount = function () {
|
||||||
// eslint-disable-next-line react/no-find-dom-node
|
// eslint-disable-next-line react/no-find-dom-node
|
||||||
var node = findDOMNode(this)
|
var node = findDOMNode(this)
|
||||||
|
@ -131,6 +137,16 @@ Notice.prototype.componentDidMount = function () {
|
||||||
if (document.getElementsByClassName('notice-box')[0].clientHeight < 300) {
|
if (document.getElementsByClassName('notice-box')[0].clientHeight < 300) {
|
||||||
this.setState({disclaimerDisabled: false})
|
this.setState({disclaimerDisabled: false})
|
||||||
}
|
}
|
||||||
|
this.setInitialDisclaimerState()
|
||||||
|
}
|
||||||
|
|
||||||
|
Notice.prototype.componentDidUpdate = function (prevProps) {
|
||||||
|
const { notice: { id } = {} } = this.props
|
||||||
|
const { notice: { id: prevNoticeId } = {} } = prevProps
|
||||||
|
|
||||||
|
if (id !== prevNoticeId) {
|
||||||
|
this.setInitialDisclaimerState()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Notice.prototype.componentWillUnmount = function () {
|
Notice.prototype.componentWillUnmount = function () {
|
||||||
|
|
|
@ -21,7 +21,7 @@ PendingMsgDetails.prototype.render = function () {
|
||||||
var identity = state.identities[address] || { address: address }
|
var identity = state.identities[address] || { address: address }
|
||||||
var account = state.accounts[address] || { address: address }
|
var account = state.accounts[address] || { address: address }
|
||||||
|
|
||||||
var { data } = msgParams
|
var { data, version } = msgParams
|
||||||
|
|
||||||
return (
|
return (
|
||||||
h('div', {
|
h('div', {
|
||||||
|
@ -48,6 +48,7 @@ PendingMsgDetails.prototype.render = function () {
|
||||||
h('label.font-small', { style: { display: 'block' } }, 'YOU ARE SIGNING'),
|
h('label.font-small', { style: { display: 'block' } }, 'YOU ARE SIGNING'),
|
||||||
h(TypedMessageRenderer, {
|
h(TypedMessageRenderer, {
|
||||||
value: data,
|
value: data,
|
||||||
|
version,
|
||||||
style: {
|
style: {
|
||||||
height: '215px',
|
height: '215px',
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,7 @@ const Component = require('react').Component
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
|
const { ObjectInspector } = require('react-inspector')
|
||||||
|
|
||||||
module.exports = TypedMessageRenderer
|
module.exports = TypedMessageRenderer
|
||||||
|
|
||||||
|
@ -12,8 +13,16 @@ function TypedMessageRenderer () {
|
||||||
|
|
||||||
TypedMessageRenderer.prototype.render = function () {
|
TypedMessageRenderer.prototype.render = function () {
|
||||||
const props = this.props
|
const props = this.props
|
||||||
const { value, style } = props
|
const { value, version, style } = props
|
||||||
const text = renderTypedData(value)
|
let text
|
||||||
|
switch (version) {
|
||||||
|
case 'V1':
|
||||||
|
text = renderTypedData(value)
|
||||||
|
break
|
||||||
|
case 'V3':
|
||||||
|
text = renderTypedDataV3(value)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
const defaultStyle = extend({
|
const defaultStyle = extend({
|
||||||
width: '315px',
|
width: '315px',
|
||||||
|
@ -44,3 +53,17 @@ function renderTypedData (values) {
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderTypedDataV3 (values) {
|
||||||
|
const { domain, message } = JSON.parse(values)
|
||||||
|
return [
|
||||||
|
domain ? h('div', [
|
||||||
|
h('h1', 'Domain'),
|
||||||
|
h(ObjectInspector, { data: domain, expandLevel: 1, name: 'domain' }),
|
||||||
|
]) : '',
|
||||||
|
message ? h('div', [
|
||||||
|
h('h1', 'Message'),
|
||||||
|
h(ObjectInspector, { data: message, expandLevel: 1, name: 'message' }),
|
||||||
|
]) : '',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -1672,9 +1672,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@zxing/library": {
|
"@zxing/library": {
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@zxing/library/-/library-0.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@zxing/library/-/library-0.8.0.tgz",
|
||||||
"integrity": "sha512-VJ1cJaCWVF8MspnuyaZKGKlrSQLqQ5usgSap8uuCAvWGQ6W6OwN1NeGvnjhT+9hmnwkHK8XjaflvzaDBC7nKnw==",
|
"integrity": "sha512-D7oopukr7cJ0Va01Er2zXiSPXvmvc6D1PpOq/THRvd/57yEsBs+setRsiDo7tSRnYHcw7FrRZSZ7rwyzNSLJeA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"text-encoding": "^0.6.4",
|
"text-encoding": "^0.6.4",
|
||||||
"ts-custom-error": "^2.2.1"
|
"ts-custom-error": "^2.2.1"
|
||||||
|
@ -3963,6 +3963,7 @@
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/backoff/-/backoff-2.5.0.tgz",
|
||||||
"integrity": "sha1-9hbtqdPktmuMp/ynn2lXIsX44m8=",
|
"integrity": "sha1-9hbtqdPktmuMp/ynn2lXIsX44m8=",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"precond": "0.2"
|
"precond": "0.2"
|
||||||
}
|
}
|
||||||
|
@ -5188,7 +5189,7 @@
|
||||||
},
|
},
|
||||||
"chromedriver": {
|
"chromedriver": {
|
||||||
"version": "2.36.0",
|
"version": "2.36.0",
|
||||||
"resolved": "http://registry.npmjs.org/chromedriver/-/chromedriver-2.36.0.tgz",
|
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-2.36.0.tgz",
|
||||||
"integrity": "sha512-Lq2HrigCJ4RVdIdCmchenv1rVrejNSJ7EUCQojycQo12ww3FedQx4nb+GgTdqMhjbOMTqq5+ziaiZlrEN2z1gQ==",
|
"integrity": "sha512-Lq2HrigCJ4RVdIdCmchenv1rVrejNSJ7EUCQojycQo12ww3FedQx4nb+GgTdqMhjbOMTqq5+ziaiZlrEN2z1gQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -6115,6 +6116,7 @@
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.1.0.tgz",
|
||||||
"integrity": "sha512-FTIt2WK44RiafWQ62xIvd+oBoVd392abh1lF872trLlA74JCR1s4oTHlixwoIKy44ehn8WbQ0Ds2P16sw7ZQxg==",
|
"integrity": "sha512-FTIt2WK44RiafWQ62xIvd+oBoVd392abh1lF872trLlA74JCR1s4oTHlixwoIKy44ehn8WbQ0Ds2P16sw7ZQxg==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"node-fetch": "2.1.1",
|
"node-fetch": "2.1.1",
|
||||||
"whatwg-fetch": "2.0.3"
|
"whatwg-fetch": "2.0.3"
|
||||||
|
@ -6123,7 +6125,8 @@
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.1.tgz",
|
||||||
"integrity": "sha1-NpynC4L1DIZJYQSmx3bSdPTkotQ="
|
"integrity": "sha1-NpynC4L1DIZJYQSmx3bSdPTkotQ=",
|
||||||
|
"dev": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -8297,88 +8300,62 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eth-block-tracker": {
|
"eth-block-tracker": {
|
||||||
"version": "2.3.0",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-4.0.1.tgz",
|
||||||
"integrity": "sha512-yrNyBIBKC7WfUjrXSG/CZVy0gW2aF8+MnjnrkOxkZOR+BAtL6JgYOnzVnrU8KE6mKJETlA/1dYMygvLXWyJGGw==",
|
"integrity": "sha512-ytJxddJ0TMcJHYxPlgGhMyr5EH6/Kyp3bg0WsjXgY9X0uYX3xVHTTeU5WVX6KX+9oJ37ZLUjh5PZ6VYnF1Fx/Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async-eventemitter": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
"eth-json-rpc-infura": "^3.1.0",
|
||||||
"eth-query": "^2.1.0",
|
"eth-query": "^2.1.0",
|
||||||
"ethereumjs-tx": "^1.3.3",
|
"pify": "^3.0.0"
|
||||||
"ethereumjs-util": "^5.1.3",
|
|
||||||
"ethjs-util": "^0.1.3",
|
|
||||||
"json-rpc-engine": "^3.6.0",
|
|
||||||
"pify": "^2.3.0",
|
|
||||||
"tape": "^4.6.3"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async-eventemitter": {
|
"cross-fetch": {
|
||||||
"version": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
"version": "2.2.2",
|
||||||
"from": "async-eventemitter@github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.2.2.tgz",
|
||||||
|
"integrity": "sha1-pH/09/xxLauo9qaVoRyUhEDUVyM=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "^2.4.0"
|
"node-fetch": "2.1.2",
|
||||||
|
"whatwg-fetch": "2.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"babel-preset-env": {
|
"eth-json-rpc-infura": {
|
||||||
"version": "1.6.1",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/eth-json-rpc-infura/-/eth-json-rpc-infura-3.1.2.tgz",
|
||||||
"integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==",
|
"integrity": "sha512-IuK5Iowfs6taluA/3Okmu6EfZcFMq6MQuyrUL1PrCoJstuuBr3TvVeSy3keDyxfbrjFB34nCo538I8G+qMtsbw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-plugin-check-es2015-constants": "^6.22.0",
|
"cross-fetch": "^2.1.1",
|
||||||
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
|
"eth-json-rpc-middleware": "^1.5.0",
|
||||||
"babel-plugin-transform-async-to-generator": "^6.22.0",
|
"json-rpc-engine": "^3.4.0",
|
||||||
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
|
"json-rpc-error": "^2.0.0",
|
||||||
"babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0",
|
"tape": "^4.8.0"
|
||||||
"babel-plugin-transform-es2015-block-scoping": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-classes": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-computed-properties": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-duplicate-keys": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-for-of": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-function-name": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-literals": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-modules-amd": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-modules-systemjs": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-modules-umd": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-object-super": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-parameters": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-shorthand-properties": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-spread": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-sticky-regex": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-template-literals": "^6.22.0",
|
|
||||||
"babel-plugin-transform-es2015-typeof-symbol": "^6.23.0",
|
|
||||||
"babel-plugin-transform-es2015-unicode-regex": "^6.22.0",
|
|
||||||
"babel-plugin-transform-exponentiation-operator": "^6.22.0",
|
|
||||||
"babel-plugin-transform-regenerator": "^6.22.0",
|
|
||||||
"browserslist": "^2.1.2",
|
|
||||||
"invariant": "^2.2.2",
|
|
||||||
"semver": "^5.3.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"babelify": {
|
"eth-json-rpc-middleware": {
|
||||||
"version": "7.3.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz",
|
"resolved": "http://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz",
|
||||||
"integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=",
|
"integrity": "sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-core": "^6.0.14",
|
"async": "^2.5.0",
|
||||||
"object-assign": "^4.0.0"
|
"eth-query": "^2.1.2",
|
||||||
}
|
"eth-tx-summary": "^3.1.2",
|
||||||
},
|
"ethereumjs-block": "^1.6.0",
|
||||||
"browserslist": {
|
"ethereumjs-tx": "^1.3.3",
|
||||||
"version": "2.11.3",
|
"ethereumjs-util": "^5.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.11.3.tgz",
|
"ethereumjs-vm": "^2.1.0",
|
||||||
"integrity": "sha512-yWu5cXT7Av6mVwzWc8lMsJMHWn4xyjSuGYi4IozbVTLUOEYPSagUB8kiMDUHA1fS3zjr8nkxkn9jdvug4BBRmA==",
|
"fetch-ponyfill": "^4.0.0",
|
||||||
"requires": {
|
"json-rpc-engine": "^3.6.0",
|
||||||
"caniuse-lite": "^1.0.30000792",
|
"json-rpc-error": "^2.0.0",
|
||||||
"electron-to-chromium": "^1.3.30"
|
"json-stable-stringify": "^1.0.1",
|
||||||
|
"promise-to-callback": "^1.0.0",
|
||||||
|
"tape": "^4.6.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereumjs-util": {
|
"ethereumjs-util": {
|
||||||
"version": "5.1.3",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||||
"integrity": "sha512-U/wmHagElZVxnpo3bFsvk5beFADegUcEzqtA/NfQbitAPOs6JoYq8M4SY9NfH4HD8236i63UOkkXafd7bqBL9A==",
|
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.8.0",
|
"bn.js": "^4.11.0",
|
||||||
"create-hash": "^1.1.2",
|
"create-hash": "^1.1.2",
|
||||||
"ethjs-util": "^0.1.3",
|
"ethjs-util": "^0.1.3",
|
||||||
"keccak": "^1.0.2",
|
"keccak": "^1.0.2",
|
||||||
|
@ -8387,22 +8364,15 @@
|
||||||
"secp256k1": "^3.0.1"
|
"secp256k1": "^3.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"json-rpc-engine": {
|
"node-fetch": {
|
||||||
"version": "3.6.0",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/json-rpc-engine/-/json-rpc-engine-3.6.0.tgz",
|
"resolved": "http://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz",
|
||||||
"integrity": "sha512-QGEIIPMaG4lQ8iKQgzKq7Ra6hscqSL+6S+xiUFbNAoVaZII8iyN1l6tJHmUWIdbnl2o0rbwCnOPFAhTn9AJObw==",
|
"integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U="
|
||||||
"requires": {
|
|
||||||
"async": "^2.0.1",
|
|
||||||
"babel-preset-env": "^1.3.2",
|
|
||||||
"babelify": "^7.3.0",
|
|
||||||
"json-rpc-error": "^2.0.0",
|
|
||||||
"promise-to-callback": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"pify": {
|
"whatwg-fetch": {
|
||||||
"version": "2.3.0",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
"resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
|
||||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -8529,6 +8499,24 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8598,11 +8586,11 @@
|
||||||
"json-rpc-engine": "^3.4.0",
|
"json-rpc-engine": "^3.4.0",
|
||||||
"json-rpc-error": "^2.0.0",
|
"json-rpc-error": "^2.0.0",
|
||||||
"tape": "^4.8.0"
|
"tape": "^4.8.0"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
"eth-json-rpc-middleware": {
|
"eth-json-rpc-middleware": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz",
|
"resolved": "http://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz",
|
||||||
"integrity": "sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q==",
|
"integrity": "sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "^2.5.0",
|
"async": "^2.5.0",
|
||||||
|
@ -8618,8 +8606,8 @@
|
||||||
"json-stable-stringify": "^1.0.1",
|
"json-stable-stringify": "^1.0.1",
|
||||||
"promise-to-callback": "^1.0.0",
|
"promise-to-callback": "^1.0.0",
|
||||||
"tape": "^4.6.3"
|
"tape": "^4.6.3"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"ethereumjs-util": {
|
"ethereumjs-util": {
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||||
|
@ -8636,6 +8624,66 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"eth-json-rpc-middleware": {
|
||||||
|
"version": "2.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-2.4.0.tgz",
|
||||||
|
"integrity": "sha512-KUxyz7pr6MZmFlsym8EObWwrFHVxRCLHGfl8H2V7D4ZjK0yhoPaA94jSXAumUbfx2AmyYEtG9j2xmU1P83m7OQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"async": "^2.5.0",
|
||||||
|
"clone": "^2.1.1",
|
||||||
|
"eth-query": "^2.1.2",
|
||||||
|
"eth-sig-util": "^1.4.2",
|
||||||
|
"eth-tx-summary": "^3.1.2",
|
||||||
|
"ethereumjs-block": "^1.6.0",
|
||||||
|
"ethereumjs-tx": "^1.3.3",
|
||||||
|
"ethereumjs-util": "^5.1.2",
|
||||||
|
"ethereumjs-vm": "^2.1.0",
|
||||||
|
"fetch-ponyfill": "^4.0.0",
|
||||||
|
"json-rpc-engine": "^3.6.3",
|
||||||
|
"json-rpc-error": "^2.0.0",
|
||||||
|
"json-stable-stringify": "^1.0.1",
|
||||||
|
"pify": "^3.0.0",
|
||||||
|
"promise-to-callback": "^1.0.0",
|
||||||
|
"tape": "^4.6.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"eth-sig-util": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
||||||
|
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"ethereumjs-util": "^5.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ethereumjs-util": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||||
|
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.11.0",
|
||||||
|
"create-hash": "^1.1.2",
|
||||||
|
"ethjs-util": "^0.1.3",
|
||||||
|
"keccak": "^1.0.2",
|
||||||
|
"rlp": "^2.0.0",
|
||||||
|
"safe-buffer": "^5.1.1",
|
||||||
|
"secp256k1": "^3.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"eth-keychain-controller": {
|
"eth-keychain-controller": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/eth-keychain-controller/-/eth-keychain-controller-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/eth-keychain-controller/-/eth-keychain-controller-5.0.0.tgz",
|
||||||
|
@ -8672,12 +8720,22 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereumjs-abi": {
|
"ethereumjs-abi": {
|
||||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.10.0",
|
"bn.js": "^4.10.0",
|
||||||
"ethereumjs-util": "^5.0.0"
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
@ -8687,7 +8745,6 @@
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||||
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.11.0",
|
"bn.js": "^4.11.0",
|
||||||
"create-hash": "^1.1.2",
|
"create-hash": "^1.1.2",
|
||||||
|
@ -8732,6 +8789,16 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereum-common": {
|
"ethereum-common": {
|
||||||
|
@ -8934,13 +9001,13 @@
|
||||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.2.tgz",
|
||||||
"integrity": "sha512-tB6E8jf/aZQ943bo3+iojl8xRe3Jzcl+9OT6v8K7kWis6PdIX19SB2vYvN849cB9G9m/XLjYFK381SgdbsnpTA==",
|
"integrity": "sha512-tB6E8jf/aZQ943bo3+iojl8xRe3Jzcl+9OT6v8K7kWis6PdIX19SB2vYvN849cB9G9m/XLjYFK381SgdbsnpTA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"ethereumjs-abi": "0.6.5",
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ethereumjs-abi": {
|
"ethereumjs-abi": {
|
||||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"version": "0.6.5",
|
||||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
"resolved": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.10.0",
|
"bn.js": "^4.10.0",
|
||||||
"ethereumjs-util": "^5.0.0"
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
@ -9205,6 +9272,16 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereum-common": {
|
"ethereum-common": {
|
||||||
|
@ -9336,6 +9413,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"pify": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||||
|
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
||||||
|
},
|
||||||
"web3-provider-engine": {
|
"web3-provider-engine": {
|
||||||
"version": "13.8.0",
|
"version": "13.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/web3-provider-engine/-/web3-provider-engine-13.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/web3-provider-engine/-/web3-provider-engine-13.8.0.tgz",
|
||||||
|
@ -9362,6 +9444,28 @@
|
||||||
"xtend": "^4.0.1"
|
"xtend": "^4.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"async-eventemitter": {
|
||||||
|
"version": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
||||||
|
"from": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
||||||
|
"requires": {
|
||||||
|
"async": "^2.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eth-block-tracker": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-NamWuMBIl8kmkJFVj8WzGatySTzQPQag4Xr677yFxdVtIxACFbL/dQowk0MzEqIKk93U1TwY3MjVU6mOcwZnKA==",
|
||||||
|
"requires": {
|
||||||
|
"async-eventemitter": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
||||||
|
"eth-query": "^2.1.0",
|
||||||
|
"ethereumjs-tx": "^1.3.3",
|
||||||
|
"ethereumjs-util": "^5.1.3",
|
||||||
|
"ethjs-util": "^0.1.3",
|
||||||
|
"json-rpc-engine": "^3.6.0",
|
||||||
|
"pify": "^2.3.0",
|
||||||
|
"tape": "^4.6.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"eth-sig-util": {
|
"eth-sig-util": {
|
||||||
"version": "1.4.2",
|
"version": "1.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
||||||
|
@ -9369,6 +9473,24 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereumjs-util": {
|
"ethereumjs-util": {
|
||||||
|
@ -10196,6 +10318,52 @@
|
||||||
"extensionizer": "^1.0.0"
|
"extensionizer": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"extension-port-stream": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/extension-port-stream/-/extension-port-stream-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-FsFr64yr6ituPdaGP6Io5recGFWVjJoDYt7asz2AvPkYqGN9c923nmEtyHH+413066bjGcQZaF8w5wn9HbNXiQ==",
|
||||||
|
"requires": {
|
||||||
|
"readable-stream": "^2.3.6",
|
||||||
|
"util": "^0.11.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"process-nextick-args": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
|
||||||
|
},
|
||||||
|
"readable-stream": {
|
||||||
|
"version": "2.3.6",
|
||||||
|
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||||
|
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||||
|
"requires": {
|
||||||
|
"core-util-is": "~1.0.0",
|
||||||
|
"inherits": "~2.0.3",
|
||||||
|
"isarray": "~1.0.0",
|
||||||
|
"process-nextick-args": "~2.0.0",
|
||||||
|
"safe-buffer": "~5.1.1",
|
||||||
|
"string_decoder": "~1.1.1",
|
||||||
|
"util-deprecate": "~1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"string_decoder": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||||
|
"requires": {
|
||||||
|
"safe-buffer": "~5.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"util": {
|
||||||
|
"version": "0.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/util/-/util-0.11.0.tgz",
|
||||||
|
"integrity": "sha512-5n12uMzKCjvB2HPFHnbQSjaqAa98L5iIXmHrZCLavuZVe0qe/SJGbDGWlpaHk5lnBkWRDO+dRu1/PgmUYKPPTw==",
|
||||||
|
"requires": {
|
||||||
|
"inherits": "2.0.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"extensionizer": {
|
"extensionizer": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/extensionizer/-/extensionizer-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/extensionizer/-/extensionizer-1.0.1.tgz",
|
||||||
|
@ -12181,8 +12349,7 @@
|
||||||
"bn.js": {
|
"bn.js": {
|
||||||
"version": "4.11.6",
|
"version": "4.11.6",
|
||||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz",
|
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz",
|
||||||
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=",
|
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"chai": {
|
"chai": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.0",
|
||||||
|
@ -12273,6 +12440,46 @@
|
||||||
"node-fetch": "2.1.2",
|
"node-fetch": "2.1.2",
|
||||||
"whatwg-fetch": "2.0.4"
|
"whatwg-fetch": "2.0.4"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"eth-json-rpc-middleware": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "http://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"async": "^2.5.0",
|
||||||
|
"eth-query": "^2.1.2",
|
||||||
|
"eth-tx-summary": "^3.1.2",
|
||||||
|
"ethereumjs-block": "^1.6.0",
|
||||||
|
"ethereumjs-tx": "^1.3.3",
|
||||||
|
"ethereumjs-util": "^5.1.2",
|
||||||
|
"ethereumjs-vm": "^2.1.0",
|
||||||
|
"fetch-ponyfill": "^4.0.0",
|
||||||
|
"json-rpc-engine": "^3.6.0",
|
||||||
|
"json-rpc-error": "^2.0.0",
|
||||||
|
"json-stable-stringify": "^1.0.1",
|
||||||
|
"promise-to-callback": "^1.0.0",
|
||||||
|
"tape": "^4.6.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ethereum-common": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ethereum-common/-/ethereum-common-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-XOnAR/3rntJgbCdGhqdaLIxDLWKLmsZOGhHdBKadEr6gEnJLH52k93Ou+TUdFaPN3hJc3isBZBal3U/XZ15abA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"ethereumjs-block": {
|
||||||
|
"version": "1.7.1",
|
||||||
|
"resolved": "http://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-1.7.1.tgz",
|
||||||
|
"integrity": "sha512-B+sSdtqm78fmKkBq78/QLKJbu/4Ts4P2KFISdgcuZUPDm9x+N7qgBPIIFUGbaakQh8bzuquiRVbdmvPKqbILRg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"async": "^2.0.1",
|
||||||
|
"ethereum-common": "0.2.0",
|
||||||
|
"ethereumjs-tx": "^1.2.2",
|
||||||
|
"ethereumjs-util": "^5.0.0",
|
||||||
|
"merkle-patricia-tree": "^2.1.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -12285,7 +12492,6 @@
|
||||||
"ethereumjs-abi": {
|
"ethereumjs-abi": {
|
||||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.10.0",
|
"bn.js": "^4.10.0",
|
||||||
"ethereumjs-util": "^5.0.0"
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
@ -12380,7 +12586,6 @@
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||||
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.11.0",
|
"bn.js": "^4.11.0",
|
||||||
"create-hash": "^1.1.2",
|
"create-hash": "^1.1.2",
|
||||||
|
@ -12559,6 +12764,17 @@
|
||||||
"requires": {
|
"requires": {
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
"ethereumjs-util": "^5.1.1"
|
"ethereumjs-util": "^5.1.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereum-common": {
|
"ethereum-common": {
|
||||||
|
@ -12567,6 +12783,14 @@
|
||||||
"integrity": "sha1-L9w1dvIykDNYl26znaeDIT/5Uj8=",
|
"integrity": "sha1-L9w1dvIykDNYl26znaeDIT/5Uj8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ethereumjs-abi": {
|
||||||
|
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.10.0",
|
||||||
|
"ethereumjs-util": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ethereumjs-tx": {
|
"ethereumjs-tx": {
|
||||||
"version": "1.3.3",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.3.tgz",
|
||||||
|
@ -16087,8 +16311,7 @@
|
||||||
"is-dom": {
|
"is-dom": {
|
||||||
"version": "1.0.9",
|
"version": "1.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/is-dom/-/is-dom-1.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/is-dom/-/is-dom-1.0.9.tgz",
|
||||||
"integrity": "sha1-SDgy1SlyBz3hK5/j9gMghw2oNw0=",
|
"integrity": "sha1-SDgy1SlyBz3hK5/j9gMghw2oNw0="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"is-dotfile": {
|
"is-dotfile": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
|
@ -17056,11 +17279,47 @@
|
||||||
"readable-stream": "^2.3.3"
|
"readable-stream": "^2.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"async-eventemitter": {
|
||||||
|
"version": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
||||||
|
"from": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
||||||
|
"requires": {
|
||||||
|
"async": "^2.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"bn.js": {
|
"bn.js": {
|
||||||
"version": "4.11.6",
|
"version": "4.11.6",
|
||||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz",
|
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz",
|
||||||
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU="
|
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU="
|
||||||
},
|
},
|
||||||
|
"eth-block-tracker": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-NamWuMBIl8kmkJFVj8WzGatySTzQPQag4Xr677yFxdVtIxACFbL/dQowk0MzEqIKk93U1TwY3MjVU6mOcwZnKA==",
|
||||||
|
"requires": {
|
||||||
|
"async-eventemitter": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
|
||||||
|
"eth-query": "^2.1.0",
|
||||||
|
"ethereumjs-tx": "^1.3.3",
|
||||||
|
"ethereumjs-util": "^5.1.3",
|
||||||
|
"ethjs-util": "^0.1.3",
|
||||||
|
"json-rpc-engine": "^3.6.0",
|
||||||
|
"pify": "^2.3.0",
|
||||||
|
"tape": "^4.6.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ethereumjs-util": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz",
|
||||||
|
"integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==",
|
||||||
|
"requires": {
|
||||||
|
"bn.js": "^4.11.0",
|
||||||
|
"create-hash": "^1.1.2",
|
||||||
|
"ethjs-util": "^0.1.3",
|
||||||
|
"keccak": "^1.0.2",
|
||||||
|
"rlp": "^2.0.0",
|
||||||
|
"safe-buffer": "^5.1.1",
|
||||||
|
"secp256k1": "^3.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ethjs-format": {
|
"ethjs-format": {
|
||||||
"version": "0.2.2",
|
"version": "0.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/ethjs-format/-/ethjs-format-0.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/ethjs-format/-/ethjs-format-0.2.2.tgz",
|
||||||
|
@ -17096,6 +17355,11 @@
|
||||||
"is-hex-prefixed": "1.0.0",
|
"is-hex-prefixed": "1.0.0",
|
||||||
"strip-hex-prefix": "1.0.0"
|
"strip-hex-prefix": "1.0.0"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"pify": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||||
|
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -17132,6 +17396,14 @@
|
||||||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
|
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
|
||||||
},
|
},
|
||||||
|
"json2mq": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/json2mq/-/json2mq-0.2.0.tgz",
|
||||||
|
"integrity": "sha1-tje9O6nqvhIsg+lyBIOusQ0skEo=",
|
||||||
|
"requires": {
|
||||||
|
"string-convert": "^0.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"json3": {
|
"json3": {
|
||||||
"version": "3.3.2",
|
"version": "3.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
|
||||||
|
@ -17242,6 +17514,11 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"jsonschema": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.4.tgz",
|
||||||
|
"integrity": "sha512-lz1nOH69GbsVHeVgEdvyavc/33oymY1AZwtePMiMj4HZPMbP5OIKK3zT9INMWjwua/V4Z4yq7wSlBbSG+g4AEw=="
|
||||||
|
},
|
||||||
"jsprim": {
|
"jsprim": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
|
||||||
|
@ -19931,6 +20208,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"metamask-inpage-provider": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/metamask-inpage-provider/-/metamask-inpage-provider-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-8ouTHzBuMb5DlsJstb3ikeA53zKk01ebcXEy3vHzg48MBO8sqHyFII37KYBkzkZ+ZkvouhmxMVCO+n8qo1oTmQ==",
|
||||||
|
"requires": {
|
||||||
|
"json-rpc-engine": "^3.7.3",
|
||||||
|
"json-rpc-middleware-stream": "^1.0.1",
|
||||||
|
"loglevel": "^1.6.1",
|
||||||
|
"obj-multiplex": "^1.0.0",
|
||||||
|
"obs-store": "^3.0.0",
|
||||||
|
"pump": "^3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"loglevel": {
|
||||||
|
"version": "1.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.1.tgz",
|
||||||
|
"integrity": "sha1-4PyVEztu8nbNyIh82vJKpvFW+Po="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"methods": {
|
"methods": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||||
|
@ -25221,7 +25518,8 @@
|
||||||
"precond": {
|
"precond": {
|
||||||
"version": "0.2.3",
|
"version": "0.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/precond/-/precond-0.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/precond/-/precond-0.2.3.tgz",
|
||||||
"integrity": "sha1-qpWRvKokkj8eD0hJ0kD0fvwQdaw="
|
"integrity": "sha1-qpWRvKokkj8eD0hJ0kD0fvwQdaw=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"prelude-ls": {
|
"prelude-ls": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
|
@ -26191,7 +26489,6 @@
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-inspector/-/react-inspector-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-inspector/-/react-inspector-2.3.0.tgz",
|
||||||
"integrity": "sha512-aIcbWb0fKFhEMB+RadoOYawlr1JoMMfrQ1oRgPUG/f/e4zERVJ6nYcIaQmrQmdHCZ63BOqe2cEkoeY0kyLBzNg==",
|
"integrity": "sha512-aIcbWb0fKFhEMB+RadoOYawlr1JoMMfrQ1oRgPUG/f/e4zERVJ6nYcIaQmrQmdHCZ63BOqe2cEkoeY0kyLBzNg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-runtime": "^6.26.0",
|
"babel-runtime": "^6.26.0",
|
||||||
"is-dom": "^1.0.9"
|
"is-dom": "^1.0.9"
|
||||||
|
@ -26232,6 +26529,16 @@
|
||||||
"xtend": "^4.0.1"
|
"xtend": "^4.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"react-media": {
|
||||||
|
"version": "1.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-media/-/react-media-1.8.0.tgz",
|
||||||
|
"integrity": "sha512-XcfqkDQj5/hmJod/kXUAZljJyMVkWrBWOkzwynAR8BXOGlbFLGBwezM0jQHtp2BrSymhf14/XrQrb3gGBnGK4g==",
|
||||||
|
"requires": {
|
||||||
|
"invariant": "^2.2.2",
|
||||||
|
"json2mq": "^0.2.0",
|
||||||
|
"prop-types": "^15.5.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"react-modal": {
|
"react-modal": {
|
||||||
"version": "3.4.4",
|
"version": "3.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.4.4.tgz",
|
||||||
|
@ -29121,6 +29428,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
|
||||||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM="
|
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM="
|
||||||
},
|
},
|
||||||
|
"string-convert": {
|
||||||
|
"version": "0.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz",
|
||||||
|
"integrity": "sha1-aYLMMEn7tM2F+LJFaLnZvznu/5c="
|
||||||
|
},
|
||||||
"string-length": {
|
"string-length": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz",
|
||||||
|
@ -29947,6 +30259,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"swappable-obj-proxy": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/swappable-obj-proxy/-/swappable-obj-proxy-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-bXbKO85b0YNbZi/61TjRAbNtY49ABKu7rQ4k2+RFXPL7TA2mphttfqAqCeJ+lrlKlkYc5pvm6erFk6vOWJSpdw=="
|
||||||
|
},
|
||||||
"swarm-js": {
|
"swarm-js": {
|
||||||
"version": "0.1.37",
|
"version": "0.1.37",
|
||||||
"resolved": "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.37.tgz",
|
"resolved": "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.37.tgz",
|
||||||
|
@ -32269,124 +32586,6 @@
|
||||||
"web3-utils": "1.0.0-beta.34"
|
"web3-utils": "1.0.0-beta.34"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"web3-provider-engine": {
|
|
||||||
"version": "14.0.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/web3-provider-engine/-/web3-provider-engine-14.0.5.tgz",
|
|
||||||
"integrity": "sha512-1W/ue7VOwOMnmKgMY3HCpbixi6qhfl4r1dK8W597AwJLbrQ+twJKwWlFAedDpJjCc9MwRCCB3pyexW4HJVSiBg==",
|
|
||||||
"requires": {
|
|
||||||
"async": "^2.5.0",
|
|
||||||
"backoff": "^2.5.0",
|
|
||||||
"clone": "^2.0.0",
|
|
||||||
"cross-fetch": "^2.1.0",
|
|
||||||
"eth-block-tracker": "^3.0.0",
|
|
||||||
"eth-json-rpc-infura": "^3.1.0",
|
|
||||||
"eth-sig-util": "^1.4.2",
|
|
||||||
"ethereumjs-block": "^1.2.2",
|
|
||||||
"ethereumjs-tx": "^1.2.0",
|
|
||||||
"ethereumjs-util": "^5.1.5",
|
|
||||||
"ethereumjs-vm": "^2.3.4",
|
|
||||||
"json-rpc-error": "^2.0.0",
|
|
||||||
"json-stable-stringify": "^1.0.1",
|
|
||||||
"promise-to-callback": "^1.0.0",
|
|
||||||
"readable-stream": "^2.2.9",
|
|
||||||
"request": "^2.67.0",
|
|
||||||
"semaphore": "^1.0.3",
|
|
||||||
"tape": "^4.4.0",
|
|
||||||
"ws": "^5.1.1",
|
|
||||||
"xhr": "^2.2.0",
|
|
||||||
"xtend": "^4.0.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"eth-block-tracker": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-3.0.0.tgz",
|
|
||||||
"integrity": "sha512-Lhhu/+1GOeekMRDRhUcM7VSJRmX279DByrwzEbmG0JL1tcT3xRo6GLNXnidyJ7ahHJm+0JFhw/RqtTeIxagQwA==",
|
|
||||||
"requires": {
|
|
||||||
"eth-query": "^2.1.0",
|
|
||||||
"ethereumjs-tx": "^1.3.3",
|
|
||||||
"ethereumjs-util": "^5.1.3",
|
|
||||||
"ethjs-util": "^0.1.3",
|
|
||||||
"json-rpc-engine": "^3.6.0",
|
|
||||||
"pify": "^2.3.0",
|
|
||||||
"tape": "^4.6.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"eth-json-rpc-infura": {
|
|
||||||
"version": "3.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/eth-json-rpc-infura/-/eth-json-rpc-infura-3.1.0.tgz",
|
|
||||||
"integrity": "sha512-uMYkEP6fga8CyNo8TMoA/7cxi6bL3V8pTvjKQikOi9iYl6/AO5xlfgniyAMElSiq2mmXz3lYa/9VYDMzt/J5aA==",
|
|
||||||
"requires": {
|
|
||||||
"cross-fetch": "^2.1.0",
|
|
||||||
"eth-json-rpc-middleware": "^1.5.0",
|
|
||||||
"json-rpc-engine": "^3.4.0",
|
|
||||||
"json-rpc-error": "^2.0.0",
|
|
||||||
"tape": "^4.8.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"eth-sig-util": {
|
|
||||||
"version": "1.4.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
|
||||||
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
|
|
||||||
"requires": {
|
|
||||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
|
||||||
"ethereumjs-util": "^5.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ethereumjs-abi": {
|
|
||||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
|
|
||||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
|
||||||
"requires": {
|
|
||||||
"bn.js": "^4.10.0",
|
|
||||||
"ethereumjs-util": "^5.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ethereumjs-util": {
|
|
||||||
"version": "5.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.1.5.tgz",
|
|
||||||
"integrity": "sha512-xPaSEATYJpMTCGowIt0oMZwFP4R1bxd6QsWgkcDvFL0JtXsr39p32WEcD14RscCjfP41YXZPCVWA4yAg0nrJmw==",
|
|
||||||
"requires": {
|
|
||||||
"bn.js": "^4.11.0",
|
|
||||||
"create-hash": "^1.1.2",
|
|
||||||
"ethjs-util": "^0.1.3",
|
|
||||||
"keccak": "^1.0.2",
|
|
||||||
"rlp": "^2.0.0",
|
|
||||||
"safe-buffer": "^5.1.1",
|
|
||||||
"secp256k1": "^3.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ethereumjs-vm": {
|
|
||||||
"version": "2.3.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-vm/-/ethereumjs-vm-2.3.5.tgz",
|
|
||||||
"integrity": "sha512-AJ7x44+xqyE5+UO3Nns19WkTdZfyqFZ+sEjIEpvme7Ipbe3iBU1uwCcHEdiu/yY9bdhr3IfSa/NfIKNeXPaRVQ==",
|
|
||||||
"requires": {
|
|
||||||
"async": "^2.1.2",
|
|
||||||
"async-eventemitter": "^0.2.2",
|
|
||||||
"ethereum-common": "0.2.0",
|
|
||||||
"ethereumjs-account": "^2.0.3",
|
|
||||||
"ethereumjs-block": "~1.7.0",
|
|
||||||
"ethereumjs-util": "^5.1.3",
|
|
||||||
"fake-merkle-patricia-tree": "^1.0.1",
|
|
||||||
"functional-red-black-tree": "^1.0.1",
|
|
||||||
"merkle-patricia-tree": "^2.1.2",
|
|
||||||
"rustbn.js": "~0.1.1",
|
|
||||||
"safe-buffer": "^5.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pify": {
|
|
||||||
"version": "2.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
|
||||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
|
||||||
},
|
|
||||||
"ws": {
|
|
||||||
"version": "5.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-5.1.1.tgz",
|
|
||||||
"integrity": "sha512-bOusvpCb09TOBLbpMKszd45WKC2KPtxiyiHanv+H2DE3Az+1db5a/L7sVJZVDPUC1Br8f0SKRr1KjLpD1U/IAw==",
|
|
||||||
"requires": {
|
|
||||||
"async-limiter": "~1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"web3-providers-http": {
|
"web3-providers-http": {
|
||||||
"version": "1.0.0-beta.34",
|
"version": "1.0.0-beta.34",
|
||||||
"resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.0.0-beta.34.tgz",
|
"resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.0.0-beta.34.tgz",
|
||||||
|
|
26
package.json
26
package.json
|
@ -8,6 +8,7 @@
|
||||||
"mascara": "gulp dev:mascara & node ./mascara/example/server",
|
"mascara": "gulp dev:mascara & node ./mascara/example/server",
|
||||||
"dist": "gulp dist",
|
"dist": "gulp dist",
|
||||||
"doc": "jsdoc -c development/tools/.jsdoc.json",
|
"doc": "jsdoc -c development/tools/.jsdoc.json",
|
||||||
|
"publish-docs": "gh-pages -d docs/jsdocs",
|
||||||
"test": "npm run test:unit && npm run test:integration && npm run lint",
|
"test": "npm run test:unit && npm run test:integration && npm run lint",
|
||||||
"watch:test:unit": "nodemon --exec \"npm run test:unit\" ./test ./app ./ui",
|
"watch:test:unit": "nodemon --exec \"npm run test:unit\" ./test ./app ./ui",
|
||||||
"test:unit": "cross-env METAMASK_ENV=test mocha --exit --require test/setup.js --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\" && dot-only-hunter",
|
"test:unit": "cross-env METAMASK_ENV=test mocha --exit --require test/setup.js --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\" && dot-only-hunter",
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
"test:e2e:run:firefox": "SELENIUM_BROWSER=firefox mocha test/e2e/metamask.spec --bail --recursive",
|
"test:e2e:run:firefox": "SELENIUM_BROWSER=firefox mocha test/e2e/metamask.spec --bail --recursive",
|
||||||
"test:screens": "shell-parallel -s 'npm run ganache:start' -x 'sleep 3 && npm run test:screens:run'",
|
"test:screens": "shell-parallel -s 'npm run ganache:start' -x 'sleep 3 && npm run test:screens:run'",
|
||||||
"test:screens:run": "node test/screens/new-ui.js",
|
"test:screens:run": "node test/screens/new-ui.js",
|
||||||
"test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload",
|
"test:coverage": "nyc --reporter=text --reporter=html npm run test:unit && npm run test:coveralls-upload",
|
||||||
"test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi",
|
"test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi",
|
||||||
"test:flat": "npm run test:flat:build && karma start test/flat.conf.js",
|
"test:flat": "npm run test:flat:build && karma start test/flat.conf.js",
|
||||||
"test:flat:build": "npm run test:flat:build:ui && npm run test:flat:build:tests && npm run test:flat:build:locales",
|
"test:flat:build": "npm run test:flat:build:ui && npm run test:flat:build:tests && npm run test:flat:build:locales",
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
"test:mascara:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales",
|
"test:mascara:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales",
|
||||||
"test:mascara:build:background": "browserify mascara/src/background.js -o dist/mascara/background.js",
|
"test:mascara:build:background": "browserify mascara/src/background.js -o dist/mascara/background.js",
|
||||||
"test:mascara:build:tests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js",
|
"test:mascara:build:tests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js",
|
||||||
"ganache:start": "ganache-cli -m 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'",
|
"ganache:start": "ganache-cli --noVMErrorsOnRPCResponse -m 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'",
|
||||||
"sentry:publish": "node ./development/sentry-publish.js",
|
"sentry:publish": "node ./development/sentry-publish.js",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
|
@ -57,7 +58,11 @@
|
||||||
[
|
[
|
||||||
"env",
|
"env",
|
||||||
{
|
{
|
||||||
"debug": true
|
"browsers": [
|
||||||
|
">0.25%",
|
||||||
|
"not ie 11",
|
||||||
|
"not op_mini all"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stage-0"
|
"stage-0"
|
||||||
|
@ -75,7 +80,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@material-ui/core": "1.0.0",
|
"@material-ui/core": "1.0.0",
|
||||||
"@zxing/library": "^0.7.0",
|
"@zxing/library": "^0.8.0",
|
||||||
"abi-decoder": "^1.0.9",
|
"abi-decoder": "^1.0.9",
|
||||||
"asmcrypto.js": "0.22.0",
|
"asmcrypto.js": "0.22.0",
|
||||||
"async": "^2.5.0",
|
"async": "^2.5.0",
|
||||||
|
@ -105,11 +110,13 @@
|
||||||
"ensnare": "^1.0.0",
|
"ensnare": "^1.0.0",
|
||||||
"eslint-plugin-react": "^7.4.0",
|
"eslint-plugin-react": "^7.4.0",
|
||||||
"eth-bin-to-ops": "^1.0.1",
|
"eth-bin-to-ops": "^1.0.1",
|
||||||
|
"eth-block-tracker": "^4.0.1",
|
||||||
"eth-contract-metadata": "github:MetaMask/eth-contract-metadata#master",
|
"eth-contract-metadata": "github:MetaMask/eth-contract-metadata#master",
|
||||||
"eth-ens-namehash": "^2.0.8",
|
"eth-ens-namehash": "^2.0.8",
|
||||||
"eth-hd-keyring": "^2.0.0",
|
"eth-hd-keyring": "^2.0.0",
|
||||||
"eth-json-rpc-filters": "^3.0.1",
|
"eth-json-rpc-filters": "^3.0.1",
|
||||||
"eth-json-rpc-infura": "^3.0.0",
|
"eth-json-rpc-infura": "^3.0.0",
|
||||||
|
"eth-keyring-controller": "^3.1.4",
|
||||||
"eth-ledger-bridge-keyring": "^0.1.0",
|
"eth-ledger-bridge-keyring": "^0.1.0",
|
||||||
"eth-method-registry": "^1.0.0",
|
"eth-method-registry": "^1.0.0",
|
||||||
"eth-net-props": "^1.0.7",
|
"eth-net-props": "^1.0.7",
|
||||||
|
@ -128,6 +135,7 @@
|
||||||
"ethjs-query": "^0.3.4",
|
"ethjs-query": "^0.3.4",
|
||||||
"express": "^4.15.5",
|
"express": "^4.15.5",
|
||||||
"extension-link-enabler": "^1.0.0",
|
"extension-link-enabler": "^1.0.0",
|
||||||
|
"extension-port-stream": "^1.0.0",
|
||||||
"extensionizer": "^1.0.1",
|
"extensionizer": "^1.0.1",
|
||||||
"fast-json-patch": "^2.0.4",
|
"fast-json-patch": "^2.0.4",
|
||||||
"fast-levenshtein": "^2.0.6",
|
"fast-levenshtein": "^2.0.6",
|
||||||
|
@ -149,12 +157,14 @@
|
||||||
"inject-css": "^0.1.1",
|
"inject-css": "^0.1.1",
|
||||||
"json-rpc-engine": "^3.8.0",
|
"json-rpc-engine": "^3.8.0",
|
||||||
"json-rpc-middleware-stream": "^1.0.1",
|
"json-rpc-middleware-stream": "^1.0.1",
|
||||||
|
"jsonschema": "^1.2.4",
|
||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
"lodash.memoize": "^4.1.2",
|
"lodash.memoize": "^4.1.2",
|
||||||
"lodash.shuffle": "^4.2.0",
|
"lodash.shuffle": "^4.2.0",
|
||||||
"lodash.uniqby": "^4.7.0",
|
"lodash.uniqby": "^4.7.0",
|
||||||
"loglevel": "^1.4.1",
|
"loglevel": "^1.4.1",
|
||||||
"metamascara": "^2.0.0",
|
"metamascara": "^2.0.0",
|
||||||
|
"metamask-inpage-provider": "^1.0.0",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"multihashes": "^0.4.12",
|
"multihashes": "^0.4.12",
|
||||||
"multiplex": "^6.7.0",
|
"multiplex": "^6.7.0",
|
||||||
|
@ -180,7 +190,9 @@
|
||||||
"react-addons-css-transition-group": "^15.6.0",
|
"react-addons-css-transition-group": "^15.6.0",
|
||||||
"react-dom": "^15.6.2",
|
"react-dom": "^15.6.2",
|
||||||
"react-hyperscript": "^3.0.0",
|
"react-hyperscript": "^3.0.0",
|
||||||
|
"react-inspector": "^2.3.0",
|
||||||
"react-markdown": "^3.0.0",
|
"react-markdown": "^3.0.0",
|
||||||
|
"react-media": "^1.8.0",
|
||||||
"react-redux": "^5.0.5",
|
"react-redux": "^5.0.5",
|
||||||
"react-router-dom": "^4.2.2",
|
"react-router-dom": "^4.2.2",
|
||||||
"react-select": "^1.0.0",
|
"react-select": "^1.0.0",
|
||||||
|
@ -205,10 +217,10 @@
|
||||||
"shallow-copy": "0.0.1",
|
"shallow-copy": "0.0.1",
|
||||||
"sw-controller": "^1.0.3",
|
"sw-controller": "^1.0.3",
|
||||||
"sw-stream": "^2.0.2",
|
"sw-stream": "^2.0.2",
|
||||||
|
"swappable-obj-proxy": "^1.1.0",
|
||||||
"valid-url": "^1.0.9",
|
"valid-url": "^1.0.9",
|
||||||
"vreme": "^3.0.2",
|
"vreme": "^3.0.2",
|
||||||
"web3": "^0.20.1",
|
"web3": "^0.20.1",
|
||||||
"web3-provider-engine": "^14.0.5",
|
|
||||||
"web3-stream-provider": "^3.0.1",
|
"web3-stream-provider": "^3.0.1",
|
||||||
"webrtc-adapter": "^6.3.0",
|
"webrtc-adapter": "^6.3.0",
|
||||||
"xtend": "^4.0.1"
|
"xtend": "^4.0.1"
|
||||||
|
@ -248,9 +260,10 @@
|
||||||
"eslint-plugin-json": "^1.2.0",
|
"eslint-plugin-json": "^1.2.0",
|
||||||
"eslint-plugin-mocha": "^5.0.0",
|
"eslint-plugin-mocha": "^5.0.0",
|
||||||
"eslint-plugin-react": "^7.4.0",
|
"eslint-plugin-react": "^7.4.0",
|
||||||
"eth-json-rpc-middleware": "^1.6.0",
|
"eth-json-rpc-middleware": "^2.4.0",
|
||||||
"eth-keychain-controller": "^5.0.0",
|
"eth-keychain-controller": "^5.0.0",
|
||||||
"file-loader": "^1.1.11",
|
"file-loader": "^1.1.11",
|
||||||
|
"fs-extra": "^6.0.1",
|
||||||
"fs-promise": "^2.0.3",
|
"fs-promise": "^2.0.3",
|
||||||
"ganache-cli": "^6.1.0",
|
"ganache-cli": "^6.1.0",
|
||||||
"ganache-core": "^2.1.5",
|
"ganache-core": "^2.1.5",
|
||||||
|
@ -295,6 +308,7 @@
|
||||||
"open": "0.0.5",
|
"open": "0.0.5",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"png-file-stream": "^1.0.0",
|
"png-file-stream": "^1.0.0",
|
||||||
|
"prepend-file": "^1.3.1",
|
||||||
"prompt": "^1.0.0",
|
"prompt": "^1.0.0",
|
||||||
"proxyquire": "2.0.1",
|
"proxyquire": "2.0.1",
|
||||||
"qs": "^6.2.0",
|
"qs": "^6.2.0",
|
||||||
|
|
|
@ -314,12 +314,12 @@ describe('Using MetaMask with an existing account', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the transaction in the transactions list', async function () {
|
it('finds the transaction in the transactions list', async function () {
|
||||||
const transactions = await findElements(driver, By.css('.tx-list-item'))
|
const transactions = await findElements(driver, By.css('.transaction-list-item'))
|
||||||
assert.equal(transactions.length, 1)
|
assert.equal(transactions.length, 1)
|
||||||
|
|
||||||
const txValues = await findElements(driver, By.css('.tx-list-value'))
|
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
assert.equal(txValues.length, 1)
|
assert.equal(txValues.length, 1)
|
||||||
assert.equal(await txValues[0].getText(), '1 ETH')
|
assert.equal(await txValues[0].getText(), '-1 ETH')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ const fs = require('fs')
|
||||||
const mkdirp = require('mkdirp')
|
const mkdirp = require('mkdirp')
|
||||||
const pify = require('pify')
|
const pify = require('pify')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const {until} = require('selenium-webdriver')
|
|
||||||
const { delay } = require('../func')
|
const { delay } = require('../func')
|
||||||
|
const { until } = require('selenium-webdriver')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
assertElementNotPresent,
|
assertElementNotPresent,
|
||||||
|
|
|
@ -225,19 +225,9 @@ describe('MetaMask', function () {
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
await clickWordAndWait(words[0])
|
for (let i = 0; i < 12; i++) {
|
||||||
await clickWordAndWait(words[1])
|
await clickWordAndWait(words[i])
|
||||||
await clickWordAndWait(words[2])
|
}
|
||||||
await clickWordAndWait(words[3])
|
|
||||||
await clickWordAndWait(words[4])
|
|
||||||
await clickWordAndWait(words[5])
|
|
||||||
await clickWordAndWait(words[6])
|
|
||||||
await clickWordAndWait(words[7])
|
|
||||||
await clickWordAndWait(words[8])
|
|
||||||
await clickWordAndWait(words[9])
|
|
||||||
await clickWordAndWait(words[10])
|
|
||||||
await clickWordAndWait(words[11])
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (count > 2) {
|
if (count > 2) {
|
||||||
throw e
|
throw e
|
||||||
|
@ -414,12 +404,12 @@ describe('MetaMask', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the transaction in the transactions list', async function () {
|
it('finds the transaction in the transactions list', async function () {
|
||||||
const transactions = await findElements(driver, By.css('.tx-list-item'))
|
const transactions = await findElements(driver, By.css('.transaction-list-item'))
|
||||||
assert.equal(transactions.length, 1)
|
assert.equal(transactions.length, 1)
|
||||||
|
|
||||||
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
||||||
const txValues = await findElement(driver, By.css('.tx-list-value'))
|
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
await driver.wait(until.elementTextMatches(txValues, /1\sETH/), 10000)
|
await driver.wait(until.elementTextMatches(txValues, /-1\sETH/), 10000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -457,16 +447,11 @@ describe('MetaMask', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the transaction in the transactions list', async function () {
|
it('finds the transaction in the transactions list', async function () {
|
||||||
const transactions = await findElements(driver, By.css('.tx-list-item'))
|
const transactions = await findElements(driver, By.css('.transaction-list-item'))
|
||||||
assert.equal(transactions.length, 2)
|
assert.equal(transactions.length, 2)
|
||||||
|
|
||||||
await findElement(driver, By.xpath(`//span[contains(text(), 'Submitted')]`))
|
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
|
await driver.wait(until.elementTextMatches(txValues, /-3\sETH/), 10000)
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
|
||||||
await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/))
|
|
||||||
|
|
||||||
const txValues = await findElement(driver, By.css('.tx-list-value'))
|
|
||||||
await driver.wait(until.elementTextMatches(txValues, /3\sETH/), 10000)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -489,9 +474,9 @@ describe('MetaMask', function () {
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const txListItem = await findElement(driver, By.xpath(`//span[contains(text(), 'Contract Deployment')]`))
|
const txListItem = await findElement(driver, By.xpath(`//div[contains(text(), 'Contract Deployment')]`))
|
||||||
await txListItem.click()
|
await txListItem.click()
|
||||||
await delay(regularDelayMs)
|
await delay(largeDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays the contract creation data', async () => {
|
it('displays the contract creation data', async () => {
|
||||||
|
@ -513,15 +498,15 @@ describe('MetaMask', function () {
|
||||||
it('confirms a deploy contract transaction', async () => {
|
it('confirms a deploy contract transaction', async () => {
|
||||||
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
|
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
|
||||||
await confirmButton.click()
|
await confirmButton.click()
|
||||||
await delay(regularDelayMs)
|
await delay(largeDelayMs)
|
||||||
|
|
||||||
await findElement(driver, By.xpath(`//span[contains(text(), 'Submitted')]`))
|
driver.wait(async () => {
|
||||||
|
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
||||||
|
return confirmedTxes.length === 3
|
||||||
|
}, 10000)
|
||||||
|
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
const txAction = await findElements(driver, By.css('.transaction-list-item__action'))
|
||||||
await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/))
|
await driver.wait(until.elementTextMatches(txAction[0], /Contract\sDeployment/), 10000)
|
||||||
|
|
||||||
const txAccounts = await findElements(driver, By.css('.tx-list-account'))
|
|
||||||
assert.equal(await txAccounts[0].getText(), 'Contract Deployment')
|
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -542,9 +527,9 @@ describe('MetaMask', function () {
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await delay(largeDelayMs)
|
await delay(largeDelayMs)
|
||||||
|
|
||||||
await findElements(driver, By.css('.tx-list-pending-item-container'))
|
await findElements(driver, By.css('.transaction-list-item'))
|
||||||
const [txListValue] = await findElements(driver, By.css('.tx-list-value'))
|
const [txListValue] = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
await driver.wait(until.elementTextMatches(txListValue, /4\sETH/), 10000)
|
await driver.wait(until.elementTextMatches(txListValue, /-4\sETH/), 10000)
|
||||||
await txListValue.click()
|
await txListValue.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -572,15 +557,17 @@ describe('MetaMask', function () {
|
||||||
await confirmButton.click()
|
await confirmButton.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
driver.wait(async () => {
|
||||||
await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/))
|
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
||||||
|
return confirmedTxes.length === 4
|
||||||
|
}, 10000)
|
||||||
|
|
||||||
const txValues = await findElement(driver, By.css('.tx-list-value'))
|
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
await driver.wait(until.elementTextMatches(txValues, /4\sETH/), 10000)
|
await driver.wait(until.elementTextMatches(txValues[0], /-4\sETH/), 10000)
|
||||||
|
|
||||||
const txAccounts = await findElements(driver, By.css('.tx-list-account'))
|
// const txAccounts = await findElements(driver, By.css('.tx-list-account'))
|
||||||
const firstTxAddress = await txAccounts[0].getText()
|
// const firstTxAddress = await txAccounts[0].getText()
|
||||||
assert(firstTxAddress.match(/^0x\w{8}\.{3}\w{4}$/))
|
// assert(firstTxAddress.match(/^0x\w{8}\.{3}\w{4}$/))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls and confirms a contract method where ETH is received', async () => {
|
it('calls and confirms a contract method where ETH is received', async () => {
|
||||||
|
@ -594,7 +581,7 @@ describe('MetaMask', function () {
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const txListItem = await findElement(driver, By.css('.tx-list-item'))
|
const txListItem = await findElement(driver, By.css('.transaction-list-item'))
|
||||||
await txListItem.click()
|
await txListItem.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -602,18 +589,20 @@ describe('MetaMask', function () {
|
||||||
await confirmButton.click()
|
await confirmButton.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
driver.wait(async () => {
|
||||||
await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/))
|
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
||||||
|
return confirmedTxes.length === 5
|
||||||
|
}, 10000)
|
||||||
|
|
||||||
const txValues = await findElement(driver, By.css('.tx-list-value'))
|
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
await driver.wait(until.elementTextMatches(txValues, /0\sETH/), 10000)
|
await driver.wait(until.elementTextMatches(txValues, /-0\sETH/), 10000)
|
||||||
|
|
||||||
await closeAllWindowHandlesExcept(driver, [extension, dapp])
|
await closeAllWindowHandlesExcept(driver, [extension, dapp])
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the correct ETH balance', async () => {
|
it('renders the correct ETH balance', async () => {
|
||||||
const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
|
const balance = await findElement(driver, By.css('.transaction-view-balance__primary-balance'))
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
||||||
await driver.wait(until.elementTextMatches(balance, /^92.*ETH.*$/), 10000)
|
await driver.wait(until.elementTextMatches(balance, /^92.*ETH.*$/), 10000)
|
||||||
|
@ -626,20 +615,21 @@ describe('MetaMask', function () {
|
||||||
|
|
||||||
describe('Add a custom token from a dapp', () => {
|
describe('Add a custom token from a dapp', () => {
|
||||||
it('creates a new token', async () => {
|
it('creates a new token', async () => {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
let windowHandles = await driver.getAllWindowHandles()
|
||||||
const extension = windowHandles[0]
|
const extension = windowHandles[0]
|
||||||
const dapp = windowHandles[1]
|
const dapp = windowHandles[1]
|
||||||
await delay(regularDelayMs * 2)
|
await delay(regularDelayMs * 2)
|
||||||
|
|
||||||
await driver.switchTo().window(dapp)
|
await driver.switchTo().window(dapp)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs * 2)
|
||||||
|
|
||||||
const createToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Create Token')]`))
|
const createToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Create Token')]`))
|
||||||
await createToken.click()
|
await createToken.click()
|
||||||
await delay(regularDelayMs)
|
await delay(largeDelayMs)
|
||||||
|
|
||||||
await driver.switchTo().window(extension)
|
windowHandles = await driver.getAllWindowHandles()
|
||||||
await loadExtension(driver, extensionId)
|
const popup = windowHandles[2]
|
||||||
|
await driver.switchTo().window(popup)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
|
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
|
||||||
|
@ -657,18 +647,17 @@ describe('MetaMask', function () {
|
||||||
await closeAllWindowHandlesExcept(driver, [extension, dapp])
|
await closeAllWindowHandlesExcept(driver, [extension, dapp])
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await delay(regularDelayMs)
|
await delay(largeDelayMs)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('clicks on the Add Token button', async () => {
|
it('clicks on the Add Token button', async () => {
|
||||||
const addToken = await findElement(driver, By.xpath(`//button[contains(text(), 'Add Token')]`))
|
const addToken = await driver.findElement(By.css('.wallet-view__add-token-button'))
|
||||||
await addToken.click()
|
await addToken.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('picks the newly created Test token', async () => {
|
it('picks the newly created Test token', async () => {
|
||||||
const addCustomToken = await findElement(driver, By.xpath("//div[contains(text(), 'Custom Token')]"))
|
const addCustomToken = await findElement(driver, By.xpath("//li[contains(text(), 'Custom Token')]"))
|
||||||
await addCustomToken.click()
|
await addCustomToken.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -686,7 +675,7 @@ describe('MetaMask', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the balance for the new token', async () => {
|
it('renders the balance for the new token', async () => {
|
||||||
const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
|
const balance = await findElement(driver, By.css('.transaction-view-balance .transaction-view-balance__token-balance'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /^100\s*TST\s*$/))
|
await driver.wait(until.elementTextMatches(balance, /^100\s*TST\s*$/))
|
||||||
const tokenAmount = await balance.getText()
|
const tokenAmount = await balance.getText()
|
||||||
assert.ok(/^100\s*TST\s*$/.test(tokenAmount))
|
assert.ok(/^100\s*TST\s*$/.test(tokenAmount))
|
||||||
|
@ -755,21 +744,25 @@ describe('MetaMask', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the transaction in the transactions list', async function () {
|
it('finds the transaction in the transactions list', async function () {
|
||||||
const transactions = await findElements(driver, By.css('.tx-list-item'))
|
const transactions = await findElements(driver, By.css('.transaction-list-item'))
|
||||||
assert.equal(transactions.length, 1)
|
assert.equal(transactions.length, 1)
|
||||||
|
|
||||||
const txValues = await findElements(driver, By.css('.tx-list-value'))
|
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
assert.equal(txValues.length, 1)
|
assert.equal(txValues.length, 1)
|
||||||
|
|
||||||
// test cancelled on firefox until https://github.com/mozilla/geckodriver/issues/906 is resolved,
|
// test cancelled on firefox until https://github.com/mozilla/geckodriver/issues/906 is resolved,
|
||||||
// or possibly until we use latest version of firefox in the tests
|
// or possibly until we use latest version of firefox in the tests
|
||||||
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
||||||
await driver.wait(until.elementTextMatches(txValues[0], /50\sTST/), 10000)
|
await driver.wait(until.elementTextMatches(txValues[0], /-50\sTST/), 10000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
driver.wait(async () => {
|
||||||
const tx = await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed|Failed/), 10000)
|
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
||||||
assert.equal(await tx.getText(), 'Confirmed')
|
return confirmedTxes.length === 1
|
||||||
|
}, 10000)
|
||||||
|
const txStatuses = await findElements(driver, By.css('.transaction-list-item__action'))
|
||||||
|
const tx = await driver.wait(until.elementTextMatches(txStatuses[0], /Sent\sToken|Failed/), 10000)
|
||||||
|
assert.equal(await tx.getText(), 'Sent Tokens')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -792,9 +785,9 @@ describe('MetaMask', function () {
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await delay(largeDelayMs)
|
await delay(largeDelayMs)
|
||||||
|
|
||||||
await findElements(driver, By.css('.tx-list-pending-item-container'))
|
await findElements(driver, By.css('.transaction-list__pending-transactions'))
|
||||||
const [txListValue] = await findElements(driver, By.css('.tx-list-value'))
|
const [txListValue] = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
await driver.wait(until.elementTextMatches(txListValue, /7\sTST/), 10000)
|
await driver.wait(until.elementTextMatches(txListValue, /-7\sTST/), 10000)
|
||||||
await txListValue.click()
|
await txListValue.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -841,25 +834,28 @@ describe('MetaMask', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the transaction in the transactions list', async function () {
|
it('finds the transaction in the transactions list', async function () {
|
||||||
const transactions = await findElements(driver, By.css('.tx-list-item'))
|
driver.wait(async () => {
|
||||||
assert.equal(transactions.length, 2)
|
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
||||||
|
return confirmedTxes.length === 2
|
||||||
|
}, 10000)
|
||||||
|
|
||||||
const txValues = await findElements(driver, By.css('.tx-list-value'))
|
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
await driver.wait(until.elementTextMatches(txValues[0], /7\sTST/))
|
await driver.wait(until.elementTextMatches(txValues[0], /-7\sTST/))
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
const txStatuses = await findElements(driver, By.css('.transaction-list-item__action'))
|
||||||
await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/))
|
await driver.wait(until.elementTextMatches(txStatuses[0], /Sent\sToken/))
|
||||||
|
|
||||||
const walletBalance = await findElement(driver, By.css('.wallet-balance'))
|
const walletBalance = await findElement(driver, By.css('.wallet-balance'))
|
||||||
await walletBalance.click()
|
await walletBalance.click()
|
||||||
|
|
||||||
const tokenListItems = await findElements(driver, By.css('.token-list-item'))
|
const tokenListItems = await findElements(driver, By.css('.token-list-item'))
|
||||||
await tokenListItems[0].click()
|
await tokenListItems[0].click()
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
// test cancelled on firefox until https://github.com/mozilla/geckodriver/issues/906 is resolved,
|
// test cancelled on firefox until https://github.com/mozilla/geckodriver/issues/906 is resolved,
|
||||||
// or possibly until we use latest version of firefox in the tests
|
// or possibly until we use latest version of firefox in the tests
|
||||||
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
if (process.env.SELENIUM_BROWSER !== 'firefox') {
|
||||||
const tokenBalanceAmount = await findElement(driver, By.css('.token-balance__amount'))
|
const tokenBalanceAmount = await findElement(driver, By.css('.transaction-view-balance__token-balance'))
|
||||||
assert.equal(await tokenBalanceAmount.getText(), '43')
|
assert.equal(await tokenBalanceAmount.getText(), '43 TST')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -883,9 +879,14 @@ describe('MetaMask', function () {
|
||||||
await driver.switchTo().window(extension)
|
await driver.switchTo().window(extension)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const [txListItem] = await findElements(driver, By.css('.tx-list-item'))
|
driver.wait(async () => {
|
||||||
const [txListValue] = await findElements(driver, By.css('.tx-list-value'))
|
const pendingTxes = await findElements(driver, By.css('.transaction-list__pending-transactions .transaction-list-item'))
|
||||||
await driver.wait(until.elementTextMatches(txListValue, /0\sETH/))
|
return pendingTxes.length === 1
|
||||||
|
}, 10000)
|
||||||
|
|
||||||
|
const [txListItem] = await findElements(driver, By.css('.transaction-list-item'))
|
||||||
|
const [txListValue] = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
|
await driver.wait(until.elementTextMatches(txListValue, /-7\sTST/))
|
||||||
await txListItem.click()
|
await txListItem.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
@ -956,10 +957,15 @@ describe('MetaMask', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('finds the transaction in the transactions list', async function () {
|
it('finds the transaction in the transactions list', async function () {
|
||||||
const txValues = await findElements(driver, By.css('.tx-list-value'))
|
driver.wait(async () => {
|
||||||
await driver.wait(until.elementTextMatches(txValues[0], /0\sETH/))
|
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
||||||
const txStatuses = await findElements(driver, By.css('.tx-list-status'))
|
return confirmedTxes.length === 3
|
||||||
await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/))
|
}, 10000)
|
||||||
|
|
||||||
|
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
|
||||||
|
await driver.wait(until.elementTextMatches(txValues[0], /-7\sTST/))
|
||||||
|
const txStatuses = await findElements(driver, By.css('.transaction-list-item__action'))
|
||||||
|
await driver.wait(until.elementTextMatches(txStatuses[0], /Approve/))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1009,9 +1015,69 @@ describe('MetaMask', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the balance for the chosen token', async () => {
|
it('renders the balance for the chosen token', async () => {
|
||||||
const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
|
const balance = await findElement(driver, By.css('.transaction-view-balance__token-balance'))
|
||||||
await driver.wait(until.elementTextMatches(balance, /0\sBAT/))
|
await driver.wait(until.elementTextMatches(balance, /0\sBAT/))
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Stores custom RPC history', () => {
|
||||||
|
const customRpcUrls = [
|
||||||
|
'https://mainnet.infura.io/1',
|
||||||
|
'https://mainnet.infura.io/2',
|
||||||
|
'https://mainnet.infura.io/3',
|
||||||
|
'https://mainnet.infura.io/4',
|
||||||
|
]
|
||||||
|
|
||||||
|
customRpcUrls.forEach(customRpcUrl => {
|
||||||
|
it('creates custom RPC: ' + customRpcUrl, async () => {
|
||||||
|
const networkDropdown = await findElement(driver, By.css('.network-name'))
|
||||||
|
await networkDropdown.click()
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
const customRpcButton = await findElement(driver, By.xpath(`//span[contains(text(), 'Custom RPC')]`))
|
||||||
|
await customRpcButton.click()
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
const customRpcInput = await findElement(driver, By.css('input[placeholder="New RPC URL"]'))
|
||||||
|
await customRpcInput.clear()
|
||||||
|
await customRpcInput.sendKeys(customRpcUrl)
|
||||||
|
|
||||||
|
const customRpcSave = await findElement(driver, By.css('.settings-tab__rpc-save-button'))
|
||||||
|
await customRpcSave.click()
|
||||||
|
await delay(largeDelayMs * 2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('selects another provider', async () => {
|
||||||
|
const networkDropdown = await findElement(driver, By.css('.network-name'))
|
||||||
|
await networkDropdown.click()
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
const customRpcButton = await findElement(driver, By.xpath(`//span[contains(text(), 'Main Ethereum Network')]`))
|
||||||
|
await customRpcButton.click()
|
||||||
|
await delay(largeDelayMs * 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('finds 3 recent RPCs in history', async () => {
|
||||||
|
const networkDropdown = await findElement(driver, By.css('.network-name'))
|
||||||
|
await networkDropdown.click()
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
// oldest selected RPC is not found
|
||||||
|
await assertElementNotPresent(webdriver, driver, By.xpath(`//span[contains(text(), '${customRpcUrls[0]}')]`))
|
||||||
|
|
||||||
|
// only recent 3 are found and in correct order (most recent at the top)
|
||||||
|
const customRpcs = await findElements(driver, By.xpath(`//span[contains(text(), 'https://mainnet.infura.io/')]`))
|
||||||
|
|
||||||
|
assert.equal(customRpcs.length, 3)
|
||||||
|
|
||||||
|
for (let i = 0; i < customRpcs.length; i++) {
|
||||||
|
const linkText = await customRpcs[i].getText()
|
||||||
|
const rpcUrl = customRpcUrls[customRpcUrls.length - i - 1]
|
||||||
|
|
||||||
|
assert.notEqual(linkText.indexOf(rpcUrl), -1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,5 +6,5 @@ set -o pipefail
|
||||||
|
|
||||||
export PATH="$PATH:./node_modules/.bin"
|
export PATH="$PATH:./node_modules/.bin"
|
||||||
|
|
||||||
shell-parallel -s 'npm run ganache:start' -x 'sleep 5 && static-server test/e2e/beta/contract-test/ --port 8080' -x 'sleep 5 && mocha test/e2e/beta/metamask-beta-ui.spec'
|
shell-parallel -s 'npm run ganache:start -- -b 2' -x 'sleep 5 && static-server test/e2e/beta/contract-test/ --port 8080' -x 'sleep 5 && mocha test/e2e/beta/metamask-beta-ui.spec'
|
||||||
shell-parallel -s 'npm run ganache:start -- -d' -x 'sleep 5 && static-server test/e2e/beta/contract-test/ --port 8080' -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec'
|
shell-parallel -s 'npm run ganache:start -- -d -b 2' -x 'sleep 5 && static-server test/e2e/beta/contract-test/ --port 8080' -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec'
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require('chromedriver')
|
require('chromedriver')
|
||||||
require('geckodriver')
|
require('geckodriver')
|
||||||
const fs = require('fs')
|
const fs = require('fs-extra')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const pify = require('pify')
|
||||||
|
const prependFile = pify(require('prepend-file'))
|
||||||
const webdriver = require('selenium-webdriver')
|
const webdriver = require('selenium-webdriver')
|
||||||
const Command = require('selenium-webdriver/lib/command').Command
|
const Command = require('selenium-webdriver/lib/command').Command
|
||||||
|
|
||||||
|
@ -10,6 +12,9 @@ const { By } = webdriver
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
delay,
|
delay,
|
||||||
|
createModifiedTestBuild,
|
||||||
|
setupBrowserAndExtension,
|
||||||
|
verboseReportOnFailure,
|
||||||
buildChromeWebDriver,
|
buildChromeWebDriver,
|
||||||
buildFirefoxWebdriver,
|
buildFirefoxWebdriver,
|
||||||
installWebExt,
|
installWebExt,
|
||||||
|
@ -21,6 +26,37 @@ function delay (time) {
|
||||||
return new Promise(resolve => setTimeout(resolve, time))
|
return new Promise(resolve => setTimeout(resolve, time))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function createModifiedTestBuild ({ browser, srcPath }) {
|
||||||
|
// copy build to test-builds directory
|
||||||
|
const extPath = path.resolve(`test-builds/${browser}`)
|
||||||
|
await fs.ensureDir(extPath)
|
||||||
|
await fs.copy(srcPath, extPath)
|
||||||
|
// inject METAMASK_TEST_CONFIG setting default test network
|
||||||
|
const config = { NetworkController: { provider: { type: 'localhost' } } }
|
||||||
|
await prependFile(`${extPath}/background.js`, `window.METAMASK_TEST_CONFIG=${JSON.stringify(config)};\n`)
|
||||||
|
return { extPath }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setupBrowserAndExtension ({ browser, extPath }) {
|
||||||
|
let driver, extensionId, extensionUri
|
||||||
|
|
||||||
|
if (browser === 'chrome') {
|
||||||
|
driver = buildChromeWebDriver(extPath)
|
||||||
|
extensionId = await getExtensionIdChrome(driver)
|
||||||
|
extensionUri = `chrome-extension://${extensionId}/home.html`
|
||||||
|
} else if (browser === 'firefox') {
|
||||||
|
driver = buildFirefoxWebdriver()
|
||||||
|
await installWebExt(driver, extPath)
|
||||||
|
await delay(700)
|
||||||
|
extensionId = await getExtensionIdFirefox(driver)
|
||||||
|
extensionUri = `moz-extension://${extensionId}/home.html`
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unknown Browser "${browser}"`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return { driver, extensionId, extensionUri }
|
||||||
|
}
|
||||||
|
|
||||||
function buildChromeWebDriver (extPath) {
|
function buildChromeWebDriver (extPath) {
|
||||||
const tmpProfile = fs.mkdtempSync(path.join(os.tmpdir(), 'mm-chrome-profile'))
|
const tmpProfile = fs.mkdtempSync(path.join(os.tmpdir(), 'mm-chrome-profile'))
|
||||||
return new webdriver.Builder()
|
return new webdriver.Builder()
|
||||||
|
@ -62,3 +98,13 @@ async function installWebExt (driver, extension) {
|
||||||
|
|
||||||
return await driver.execute(cmd, 'installWebExt(' + extension + ')')
|
return await driver.execute(cmd, 'installWebExt(' + extension + ')')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function verboseReportOnFailure ({ browser, driver, title }) {
|
||||||
|
const artifactDir = `./test-artifacts/${browser}/${title}`
|
||||||
|
const filepathBase = `${artifactDir}/test-failure`
|
||||||
|
await fs.ensureDir(artifactDir)
|
||||||
|
const screenshot = await driver.takeScreenshot()
|
||||||
|
await fs.writeFile(`${filepathBase}-screenshot.png`, screenshot, { encoding: 'base64' })
|
||||||
|
const htmlSource = await driver.getPageSource()
|
||||||
|
await fs.writeFile(`${filepathBase}-dom.html`, htmlSource)
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
|
const Ganache = require('ganache-core')
|
||||||
|
const nock = require('nock')
|
||||||
import Enzyme from 'enzyme'
|
import Enzyme from 'enzyme'
|
||||||
import Adapter from 'enzyme-adapter-react-15'
|
import Adapter from 'enzyme-adapter-react-15'
|
||||||
|
|
||||||
|
nock.disableNetConnect()
|
||||||
|
nock.enableNetConnect('localhost')
|
||||||
|
|
||||||
Enzyme.configure({ adapter: new Adapter() })
|
Enzyme.configure({ adapter: new Adapter() })
|
||||||
// disallow promises from swallowing errors
|
// disallow promises from swallowing errors
|
||||||
enableFailureOnUnhandledPromiseRejection()
|
enableFailureOnUnhandledPromiseRejection()
|
||||||
|
|
||||||
|
// ganache server
|
||||||
|
const server = Ganache.server()
|
||||||
|
server.listen(8545, () => {
|
||||||
|
console.log('Ganache Testrpc is running on "http://localhost:8545"')
|
||||||
|
})
|
||||||
|
|
||||||
// logging util
|
// logging util
|
||||||
var log = require('loglevel')
|
var log = require('loglevel')
|
||||||
log.setDefaultLevel(5)
|
log.setDefaultLevel(5)
|
||||||
|
@ -14,6 +25,9 @@ global.log = log
|
||||||
// polyfills
|
// polyfills
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// fetch
|
||||||
|
global.fetch = require('isomorphic-fetch')
|
||||||
|
|
||||||
// dom
|
// dom
|
||||||
require('jsdom-global')()
|
require('jsdom-global')()
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ async function runSendFlowTest (assert, done) {
|
||||||
selectState.val('send new ui')
|
selectState.val('send new ui')
|
||||||
reactTriggerChange(selectState[0])
|
reactTriggerChange(selectState[0])
|
||||||
|
|
||||||
const sendScreenButton = await queryAsync($, 'button.btn-primary.hero-balance-button')
|
const sendScreenButton = await queryAsync($, 'button.btn-primary.transaction-view-balance__button')
|
||||||
assert.ok(sendScreenButton[1], 'send screen button present')
|
assert.ok(sendScreenButton[1], 'send screen button present')
|
||||||
sendScreenButton[1].click()
|
sendScreenButton[1].click()
|
||||||
|
|
||||||
|
@ -124,10 +124,10 @@ async function runSendFlowTest (assert, done) {
|
||||||
selectState.val('send edit')
|
selectState.val('send edit')
|
||||||
reactTriggerChange(selectState[0])
|
reactTriggerChange(selectState[0])
|
||||||
|
|
||||||
const confirmFromName = (await queryAsync($, '.sender-to-recipient__sender-name')).first()
|
const confirmFromName = (await queryAsync($, '.sender-to-recipient__name')).first()
|
||||||
assert.equal(confirmFromName[0].textContent, 'Send Account 4', 'confirm screen should show correct from name')
|
assert.equal(confirmFromName[0].textContent, 'Send Account 4', 'confirm screen should show correct from name')
|
||||||
|
|
||||||
const confirmToName = (await queryAsync($, '.sender-to-recipient__recipient-name')).last()
|
const confirmToName = (await queryAsync($, '.sender-to-recipient__name')).last()
|
||||||
assert.equal(confirmToName[0].textContent, 'Send Account 3', 'confirm screen should show correct to name')
|
assert.equal(confirmToName[0].textContent, 'Send Account 3', 'confirm screen should show correct to name')
|
||||||
|
|
||||||
const confirmScreenRowFiats = await queryAsync($, '.confirm-detail-row__fiat')
|
const confirmScreenRowFiats = await queryAsync($, '.confirm-detail-row__fiat')
|
||||||
|
|
|
@ -29,26 +29,25 @@ async function runTxListItemsTest (assert, done) {
|
||||||
assert.ok(metamaskLogo[0], 'metamask logo present')
|
assert.ok(metamaskLogo[0], 'metamask logo present')
|
||||||
metamaskLogo[0].click()
|
metamaskLogo[0].click()
|
||||||
|
|
||||||
const txListItems = await queryAsync($, '.tx-list-item')
|
const txListItems = await queryAsync($, '.transaction-list-item')
|
||||||
assert.equal(txListItems.length, 8, 'all tx list items are rendered')
|
assert.equal(txListItems.length, 8, 'all tx list items are rendered')
|
||||||
|
|
||||||
const unapprovedTx = txListItems[0]
|
const retryTxGrid = await findAsync($(txListItems[1]), '.transaction-list-item__grid')
|
||||||
assert.equal($(unapprovedTx).hasClass('tx-list-pending-item-container'), true, 'unapprovedTx has the correct class')
|
retryTxGrid[0].click()
|
||||||
|
const retryTxDetails = await findAsync($(txListItems[1]), '.transaction-list-item-details')
|
||||||
const retryTx = txListItems[1]
|
const headerButtons = await findAsync($(retryTxDetails[0]), '.transaction-list-item-details__header-button')
|
||||||
const retryTxLink = await findAsync($(retryTx), '.tx-list-item-retry-container span')
|
assert.equal(headerButtons[0].textContent, 'speed up')
|
||||||
assert.equal(retryTxLink[0].textContent, 'Taking too long? Increase the gas price on your transaction', 'retryTx has expected link')
|
|
||||||
|
|
||||||
const approvedTx = txListItems[2]
|
const approvedTx = txListItems[2]
|
||||||
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.tx-list-status')
|
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.transaction-list-item__status')
|
||||||
assert.equal(approvedTxRenderedStatus[0].textContent, 'Approved', 'approvedTx has correct label')
|
assert.equal(approvedTxRenderedStatus[0].textContent, 'pending', 'approvedTx has correct label')
|
||||||
|
|
||||||
const unapprovedMsg = txListItems[3]
|
const unapprovedMsg = txListItems[3]
|
||||||
const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.tx-list-account')
|
const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.transaction-list-item__action')
|
||||||
assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description')
|
assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description')
|
||||||
|
|
||||||
const failedTx = txListItems[4]
|
const failedTx = txListItems[4]
|
||||||
const failedTxRenderedStatus = await findAsync($(failedTx), '.tx-list-status')
|
const failedTxRenderedStatus = await findAsync($(failedTx), '.transaction-list-item__status')
|
||||||
assert.equal(failedTxRenderedStatus[0].textContent, 'Failed', 'failedTx has correct label')
|
assert.equal(failedTxRenderedStatus[0].textContent, 'Failed', 'failedTx has correct label')
|
||||||
|
|
||||||
const shapeShiftTx = txListItems[5]
|
const shapeShiftTx = txListItems[5]
|
||||||
|
@ -56,10 +55,10 @@ async function runTxListItemsTest (assert, done) {
|
||||||
assert.equal(shapeShiftTxStatus[0].textContent, 'No deposits received', 'shapeShiftTx has correct status')
|
assert.equal(shapeShiftTxStatus[0].textContent, 'No deposits received', 'shapeShiftTx has correct status')
|
||||||
|
|
||||||
const confirmedTokenTx = txListItems[6]
|
const confirmedTokenTx = txListItems[6]
|
||||||
const confirmedTokenTxAddress = await findAsync($(confirmedTokenTx), '.tx-list-account')
|
const confirmedTokenTxAddress = await findAsync($(confirmedTokenTx), '.transaction-list-item__status')
|
||||||
assert.equal(confirmedTokenTxAddress[0].textContent, '0xE7884118...81a9', 'confirmedTokenTx has correct address')
|
assert.equal(confirmedTokenTxAddress[0].textContent, 'Confirmed', 'confirmedTokenTx has correct address')
|
||||||
|
|
||||||
const rejectedTx = txListItems[7]
|
const rejectedTx = txListItems[7]
|
||||||
const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.tx-list-status')
|
const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.transaction-list-item__status')
|
||||||
assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label')
|
assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label')
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
const txStateHistoryHelper = require('../../app/scripts/controllers/transactions/lib/tx-state-history-helper')
|
||||||
|
|
||||||
|
module.exports = createTxMeta
|
||||||
|
|
||||||
|
function createTxMeta (partialMeta) {
|
||||||
|
const txMeta = Object.assign({
|
||||||
|
status: 'unapproved',
|
||||||
|
txParams: {},
|
||||||
|
}, partialMeta)
|
||||||
|
// initialize history
|
||||||
|
txMeta.history = []
|
||||||
|
// capture initial snapshot of txMeta for history
|
||||||
|
const snapshot = txStateHistoryHelper.snapshotFromTxMeta(txMeta)
|
||||||
|
txMeta.history.push(snapshot)
|
||||||
|
return txMeta
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
const ObservableStore = require('obs-store')
|
|
||||||
const clone = require('clone')
|
|
||||||
const ConfigManager = require('../../app/scripts/lib/config-manager')
|
|
||||||
const firstTimeState = require('../../app/scripts/first-time-state')
|
|
||||||
|
|
||||||
module.exports = function () {
|
|
||||||
const store = new ObservableStore(clone(firstTimeState))
|
|
||||||
return new ConfigManager({ store })
|
|
||||||
}
|
|
|
@ -1,6 +1,3 @@
|
||||||
// polyfill fetch
|
|
||||||
global.fetch = global.fetch || require('isomorphic-fetch')
|
|
||||||
|
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const nock = require('nock')
|
const nock = require('nock')
|
||||||
const CurrencyController = require('../../../../app/scripts/controllers/currency')
|
const CurrencyController = require('../../../../app/scripts/controllers/currency')
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
const nock = require('nock')
|
||||||
const sinon = require('sinon')
|
const sinon = require('sinon')
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const DetectTokensController = require('../../../../app/scripts/controllers/detect-tokens')
|
const DetectTokensController = require('../../../../app/scripts/controllers/detect-tokens')
|
||||||
|
@ -7,14 +8,33 @@ const PreferencesController = require('../../../../app/scripts/controllers/prefe
|
||||||
|
|
||||||
describe('DetectTokensController', () => {
|
describe('DetectTokensController', () => {
|
||||||
const sandbox = sinon.createSandbox()
|
const sandbox = sinon.createSandbox()
|
||||||
let clock, keyringMemStore, network, preferences
|
let clock, keyringMemStore, network, preferences, controller
|
||||||
|
|
||||||
|
const noop = () => {}
|
||||||
|
|
||||||
|
const networkControllerProviderConfig = {
|
||||||
|
getAccounts: noop,
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
|
||||||
|
|
||||||
|
nock('https://api.infura.io')
|
||||||
|
.get(/.*/)
|
||||||
|
.reply(200)
|
||||||
|
|
||||||
keyringMemStore = new ObservableStore({ isUnlocked: false})
|
keyringMemStore = new ObservableStore({ isUnlocked: false})
|
||||||
network = new NetworkController({ provider: { type: 'mainnet' }})
|
network = new NetworkController()
|
||||||
preferences = new PreferencesController({ network })
|
preferences = new PreferencesController({ network })
|
||||||
|
controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||||
|
|
||||||
|
network.initializeProvider(networkControllerProviderConfig)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
sandbox.restore()
|
sandbox.restore()
|
||||||
|
nock.cleanAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should poll on correct interval', async () => {
|
it('should poll on correct interval', async () => {
|
||||||
|
@ -26,7 +46,10 @@ describe('DetectTokensController', () => {
|
||||||
|
|
||||||
it('should be called on every polling period', async () => {
|
it('should be called on every polling period', async () => {
|
||||||
clock = sandbox.useFakeTimers()
|
clock = sandbox.useFakeTimers()
|
||||||
|
const network = new NetworkController()
|
||||||
|
network.initializeProvider(networkControllerProviderConfig)
|
||||||
network.setProviderType('mainnet')
|
network.setProviderType('mainnet')
|
||||||
|
const preferences = new PreferencesController({ network })
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = true
|
controller.isUnlocked = true
|
||||||
|
@ -44,8 +67,6 @@ describe('DetectTokensController', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not check tokens while in test network', async () => {
|
it('should not check tokens while in test network', async () => {
|
||||||
network.setProviderType('rinkeby')
|
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = true
|
controller.isUnlocked = true
|
||||||
|
|
||||||
|
@ -58,7 +79,6 @@ describe('DetectTokensController', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should only check and add tokens while in main network', async () => {
|
it('should only check and add tokens while in main network', async () => {
|
||||||
network.setProviderType('mainnet')
|
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = true
|
controller.isUnlocked = true
|
||||||
|
@ -95,8 +115,6 @@ describe('DetectTokensController', () => {
|
||||||
// })
|
// })
|
||||||
|
|
||||||
it('should trigger detect new tokens when change address', async () => {
|
it('should trigger detect new tokens when change address', async () => {
|
||||||
network.setProviderType('mainnet')
|
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = true
|
controller.isUnlocked = true
|
||||||
var stub = sandbox.stub(controller, 'detectNewTokens')
|
var stub = sandbox.stub(controller, 'detectNewTokens')
|
||||||
|
@ -105,8 +123,6 @@ describe('DetectTokensController', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should trigger detect new tokens when submit password', async () => {
|
it('should trigger detect new tokens when submit password', async () => {
|
||||||
network.setProviderType('mainnet')
|
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.selectedAddress = '0x0'
|
controller.selectedAddress = '0x0'
|
||||||
var stub = sandbox.stub(controller, 'detectNewTokens')
|
var stub = sandbox.stub(controller, 'detectNewTokens')
|
||||||
|
@ -115,8 +131,6 @@ describe('DetectTokensController', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not trigger detect new tokens when not open or not unlocked', async () => {
|
it('should not trigger detect new tokens when not open or not unlocked', async () => {
|
||||||
network.setProviderType('mainnet')
|
|
||||||
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
|
|
||||||
controller.isOpen = true
|
controller.isOpen = true
|
||||||
controller.isUnlocked = false
|
controller.isUnlocked = false
|
||||||
var stub = sandbox.stub(controller, 'detectTokenBalance')
|
var stub = sandbox.stub(controller, 'detectTokenBalance')
|
||||||
|
|
|
@ -3,16 +3,22 @@ const sinon = require('sinon')
|
||||||
const clone = require('clone')
|
const clone = require('clone')
|
||||||
const nock = require('nock')
|
const nock = require('nock')
|
||||||
const createThoughStream = require('through2').obj
|
const createThoughStream = require('through2').obj
|
||||||
const MetaMaskController = require('../../../../app/scripts/metamask-controller')
|
|
||||||
const blacklistJSON = require('eth-phishing-detect/src/config')
|
const blacklistJSON = require('eth-phishing-detect/src/config')
|
||||||
const firstTimeState = require('../../../../app/scripts/first-time-state')
|
const MetaMaskController = require('../../../../app/scripts/metamask-controller')
|
||||||
|
const firstTimeState = require('../../../unit/localhostState')
|
||||||
|
const createTxMeta = require('../../../lib/createTxMeta')
|
||||||
|
const EthQuery = require('eth-query')
|
||||||
|
|
||||||
const currentNetworkId = 42
|
const currentNetworkId = 42
|
||||||
const DEFAULT_LABEL = 'Account 1'
|
const DEFAULT_LABEL = 'Account 1'
|
||||||
|
const DEFAULT_LABEL_2 = 'Account 2'
|
||||||
const TEST_SEED = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
const TEST_SEED = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
||||||
const TEST_ADDRESS = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'
|
const TEST_ADDRESS = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'
|
||||||
|
const TEST_ADDRESS_2 = '0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b'
|
||||||
|
const TEST_ADDRESS_3 = '0xeb9e64b93097bc15f01f13eae97015c57ab64823'
|
||||||
const TEST_SEED_ALT = 'setup olympic issue mobile velvet surge alcohol burger horse view reopen gentle'
|
const TEST_SEED_ALT = 'setup olympic issue mobile velvet surge alcohol burger horse view reopen gentle'
|
||||||
const TEST_ADDRESS_ALT = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
const TEST_ADDRESS_ALT = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
||||||
|
const CUSTOM_RPC_URL = 'http://localhost:8545'
|
||||||
|
|
||||||
describe('MetaMaskController', function () {
|
describe('MetaMaskController', function () {
|
||||||
let metamaskController
|
let metamaskController
|
||||||
|
@ -134,6 +140,9 @@ describe('MetaMaskController', function () {
|
||||||
describe('#createNewVaultAndRestore', function () {
|
describe('#createNewVaultAndRestore', function () {
|
||||||
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
|
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
|
||||||
const password = 'what-what-what'
|
const password = 'what-what-what'
|
||||||
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
|
metamaskController.getBalance.callsFake(() => { return Promise.resolve('0x0') })
|
||||||
|
|
||||||
await metamaskController.createNewVaultAndRestore(password, TEST_SEED.slice(0, -1)).catch((e) => null)
|
await metamaskController.createNewVaultAndRestore(password, TEST_SEED.slice(0, -1)).catch((e) => null)
|
||||||
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
|
await metamaskController.createNewVaultAndRestore(password, TEST_SEED)
|
||||||
|
|
||||||
|
@ -141,6 +150,9 @@ describe('MetaMaskController', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should clear previous identities after vault restoration', async () => {
|
it('should clear previous identities after vault restoration', async () => {
|
||||||
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
|
metamaskController.getBalance.callsFake(() => { return Promise.resolve('0x0') })
|
||||||
|
|
||||||
await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED)
|
await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED)
|
||||||
assert.deepEqual(metamaskController.getState().identities, {
|
assert.deepEqual(metamaskController.getState().identities, {
|
||||||
[TEST_ADDRESS]: { address: TEST_ADDRESS, name: DEFAULT_LABEL },
|
[TEST_ADDRESS]: { address: TEST_ADDRESS, name: DEFAULT_LABEL },
|
||||||
|
@ -156,6 +168,54 @@ describe('MetaMaskController', function () {
|
||||||
[TEST_ADDRESS_ALT]: { address: TEST_ADDRESS_ALT, name: DEFAULT_LABEL },
|
[TEST_ADDRESS_ALT]: { address: TEST_ADDRESS_ALT, name: DEFAULT_LABEL },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should restore any consecutive accounts with balances', async () => {
|
||||||
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
|
metamaskController.getBalance.withArgs(TEST_ADDRESS).callsFake(() => {
|
||||||
|
return Promise.resolve('0x14ced5122ce0a000')
|
||||||
|
})
|
||||||
|
metamaskController.getBalance.withArgs(TEST_ADDRESS_2).callsFake(() => {
|
||||||
|
return Promise.resolve('0x0')
|
||||||
|
})
|
||||||
|
metamaskController.getBalance.withArgs(TEST_ADDRESS_3).callsFake(() => {
|
||||||
|
return Promise.resolve('0x14ced5122ce0a000')
|
||||||
|
})
|
||||||
|
|
||||||
|
await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED)
|
||||||
|
assert.deepEqual(metamaskController.getState().identities, {
|
||||||
|
[TEST_ADDRESS]: { address: TEST_ADDRESS, name: DEFAULT_LABEL },
|
||||||
|
[TEST_ADDRESS_2]: { address: TEST_ADDRESS_2, name: DEFAULT_LABEL_2 },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('#getBalance', () => {
|
||||||
|
it('should return the balance known by accountTracker', async () => {
|
||||||
|
const accounts = {}
|
||||||
|
const balance = '0x14ced5122ce0a000'
|
||||||
|
accounts[TEST_ADDRESS] = { balance: balance }
|
||||||
|
|
||||||
|
metamaskController.accountTracker.store.putState({ accounts: accounts })
|
||||||
|
|
||||||
|
const gotten = await metamaskController.getBalance(TEST_ADDRESS)
|
||||||
|
|
||||||
|
assert.equal(balance, gotten)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should ask the network for a balance when not known by accountTracker', async () => {
|
||||||
|
const accounts = {}
|
||||||
|
const balance = '0x14ced5122ce0a000'
|
||||||
|
const ethQuery = new EthQuery()
|
||||||
|
sinon.stub(ethQuery, 'getBalance').callsFake((account, callback) => {
|
||||||
|
callback(undefined, balance)
|
||||||
|
})
|
||||||
|
|
||||||
|
metamaskController.accountTracker.store.putState({ accounts: accounts })
|
||||||
|
|
||||||
|
const gotten = await metamaskController.getBalance(TEST_ADDRESS, ethQuery)
|
||||||
|
|
||||||
|
assert.equal(balance, gotten)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#getApi', function () {
|
describe('#getApi', function () {
|
||||||
|
@ -360,29 +420,19 @@ describe('MetaMaskController', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#setCustomRpc', function () {
|
describe('#setCustomRpc', function () {
|
||||||
const customRPC = 'https://custom.rpc/'
|
|
||||||
let rpcTarget
|
let rpcTarget
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
rpcTarget = metamaskController.setCustomRpc(CUSTOM_RPC_URL)
|
||||||
nock('https://custom.rpc')
|
|
||||||
.post('/')
|
|
||||||
.reply(200)
|
|
||||||
|
|
||||||
rpcTarget = metamaskController.setCustomRpc(customRPC)
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
nock.cleanAll()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns custom RPC that when called', async function () {
|
it('returns custom RPC that when called', async function () {
|
||||||
assert.equal(await rpcTarget, customRPC)
|
assert.equal(await rpcTarget, CUSTOM_RPC_URL)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes the network controller rpc', function () {
|
it('changes the network controller rpc', function () {
|
||||||
const networkControllerState = metamaskController.networkController.store.getState()
|
const networkControllerState = metamaskController.networkController.store.getState()
|
||||||
assert.equal(networkControllerState.provider.rpcTarget, customRPC)
|
assert.equal(networkControllerState.provider.rpcTarget, CUSTOM_RPC_URL)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -487,9 +537,10 @@ describe('MetaMaskController', function () {
|
||||||
getNetworkstub.returns(42)
|
getNetworkstub.returns(42)
|
||||||
|
|
||||||
metamaskController.txController.txStateManager._saveTxList([
|
metamaskController.txController.txStateManager._saveTxList([
|
||||||
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'} },
|
createTxMeta({ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'} }),
|
||||||
{ id: 2, status: 'rejected', metamaskNetworkId: 32, txParams: {} },
|
createTxMeta({ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'} }),
|
||||||
{ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4'} },
|
createTxMeta({ id: 2, status: 'rejected', metamaskNetworkId: 32 }),
|
||||||
|
createTxMeta({ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4'} }),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -522,7 +573,7 @@ describe('MetaMaskController', function () {
|
||||||
assert(metamaskController.preferencesController.removeAddress.calledWith(addressToRemove))
|
assert(metamaskController.preferencesController.removeAddress.calledWith(addressToRemove))
|
||||||
})
|
})
|
||||||
it('should call accountTracker.removeAccount', async function () {
|
it('should call accountTracker.removeAccount', async function () {
|
||||||
assert(metamaskController.accountTracker.removeAccount.calledWith(addressToRemove))
|
assert(metamaskController.accountTracker.removeAccount.calledWith([addressToRemove]))
|
||||||
})
|
})
|
||||||
it('should call keyringController.removeAccount', async function () {
|
it('should call keyringController.removeAccount', async function () {
|
||||||
assert(metamaskController.keyringController.removeAccount.calledWith(addressToRemove))
|
assert(metamaskController.keyringController.removeAccount.calledWith(addressToRemove))
|
||||||
|
@ -533,22 +584,18 @@ describe('MetaMaskController', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#clearSeedWordCache', function () {
|
describe('#clearSeedWordCache', function () {
|
||||||
|
it('should set seed words to null', function (done) {
|
||||||
|
sandbox.stub(metamaskController.preferencesController, 'setSeedWords')
|
||||||
|
metamaskController.clearSeedWordCache((err) => {
|
||||||
|
if (err) {
|
||||||
|
done(err)
|
||||||
|
}
|
||||||
|
|
||||||
it('should have set seed words', function () {
|
assert.ok(metamaskController.preferencesController.setSeedWords.calledOnce)
|
||||||
metamaskController.configManager.setSeedWords('test words')
|
assert.deepEqual(metamaskController.preferencesController.setSeedWords.args, [[null]])
|
||||||
const getConfigSeed = metamaskController.configManager.getSeedWords()
|
done()
|
||||||
assert.equal(getConfigSeed, 'test words')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should clear config seed phrase', function () {
|
|
||||||
metamaskController.configManager.setSeedWords('test words')
|
|
||||||
metamaskController.clearSeedWordCache((err, result) => {
|
|
||||||
if (err) console.log(err)
|
|
||||||
})
|
})
|
||||||
const getConfigSeed = metamaskController.configManager.getSeedWords()
|
|
||||||
assert.equal(getConfigSeed, null)
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#setCurrentLocale', function () {
|
describe('#setCurrentLocale', function () {
|
||||||
|
@ -566,14 +613,16 @@ describe('MetaMaskController', function () {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#newUnsignedMessage', function () {
|
describe('#newUnsignedMessage', () => {
|
||||||
|
|
||||||
let msgParams, metamaskMsgs, messages, msgId
|
let msgParams, metamaskMsgs, messages, msgId
|
||||||
|
|
||||||
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
const address = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'
|
||||||
const data = '0x43727970746f6b697474696573'
|
const data = '0x43727970746f6b697474696573'
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async () => {
|
||||||
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
|
metamaskController.getBalance.callsFake(() => { return Promise.resolve('0x0') })
|
||||||
|
|
||||||
await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED_ALT)
|
await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED_ALT)
|
||||||
|
|
||||||
|
@ -582,7 +631,10 @@ describe('MetaMaskController', function () {
|
||||||
'data': data,
|
'data': data,
|
||||||
}
|
}
|
||||||
|
|
||||||
metamaskController.newUnsignedMessage(msgParams, noop)
|
const promise = metamaskController.newUnsignedMessage(msgParams)
|
||||||
|
// handle the promise so it doesn't throw an unhandledRejection
|
||||||
|
promise.then(noop).catch(noop)
|
||||||
|
|
||||||
metamaskMsgs = metamaskController.messageManager.getUnapprovedMsgs()
|
metamaskMsgs = metamaskController.messageManager.getUnapprovedMsgs()
|
||||||
messages = metamaskController.messageManager.messages
|
messages = metamaskController.messageManager.messages
|
||||||
msgId = Object.keys(metamaskMsgs)[0]
|
msgId = Object.keys(metamaskMsgs)[0]
|
||||||
|
@ -622,13 +674,17 @@ describe('MetaMaskController', function () {
|
||||||
|
|
||||||
describe('#newUnsignedPersonalMessage', function () {
|
describe('#newUnsignedPersonalMessage', function () {
|
||||||
|
|
||||||
it('errors with no from in msgParams', function () {
|
it('errors with no from in msgParams', async () => {
|
||||||
const msgParams = {
|
const msgParams = {
|
||||||
'data': data,
|
'data': data,
|
||||||
}
|
}
|
||||||
metamaskController.newUnsignedPersonalMessage(msgParams, function (error) {
|
|
||||||
|
try {
|
||||||
|
await metamaskController.newUnsignedPersonalMessage(msgParams)
|
||||||
|
assert.fail('should have thrown')
|
||||||
|
} catch (error) {
|
||||||
assert.equal(error.message, 'Nifty Wallet Message Signature: from field is required.')
|
assert.equal(error.message, 'Nifty Wallet Message Signature: from field is required.')
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let msgParams, metamaskPersonalMsgs, personalMessages, msgId
|
let msgParams, metamaskPersonalMsgs, personalMessages, msgId
|
||||||
|
@ -637,6 +693,8 @@ describe('MetaMaskController', function () {
|
||||||
const data = '0x43727970746f6b697474696573'
|
const data = '0x43727970746f6b697474696573'
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
|
sandbox.stub(metamaskController, 'getBalance')
|
||||||
|
metamaskController.getBalance.callsFake(() => { return Promise.resolve('0x0') })
|
||||||
|
|
||||||
await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED_ALT)
|
await metamaskController.createNewVaultAndRestore('foobar1337', TEST_SEED_ALT)
|
||||||
|
|
||||||
|
@ -645,7 +703,10 @@ describe('MetaMaskController', function () {
|
||||||
'data': data,
|
'data': data,
|
||||||
}
|
}
|
||||||
|
|
||||||
metamaskController.newUnsignedPersonalMessage(msgParams, noop)
|
const promise = metamaskController.newUnsignedPersonalMessage(msgParams)
|
||||||
|
// handle the promise so it doesn't throw an unhandledRejection
|
||||||
|
promise.then(noop).catch(noop)
|
||||||
|
|
||||||
metamaskPersonalMsgs = metamaskController.personalMessageManager.getUnapprovedMsgs()
|
metamaskPersonalMsgs = metamaskController.personalMessageManager.getUnapprovedMsgs()
|
||||||
personalMessages = metamaskController.personalMessageManager.messages
|
personalMessages = metamaskController.personalMessageManager.messages
|
||||||
msgId = Object.keys(metamaskPersonalMsgs)[0]
|
msgId = Object.keys(metamaskPersonalMsgs)[0]
|
||||||
|
@ -684,22 +745,27 @@ describe('MetaMaskController', function () {
|
||||||
describe('#setupUntrustedCommunication', function () {
|
describe('#setupUntrustedCommunication', function () {
|
||||||
let streamTest
|
let streamTest
|
||||||
|
|
||||||
const phishingUrl = 'decentral.market'
|
const phishingUrl = 'myethereumwalletntw.com'
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
streamTest.end()
|
streamTest.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets up phishing stream for untrusted communication ', async function () {
|
it('sets up phishing stream for untrusted communication ', async () => {
|
||||||
await metamaskController.blacklistController.updatePhishingList()
|
await metamaskController.blacklistController.updatePhishingList()
|
||||||
|
console.log(blacklistJSON.blacklist.includes(phishingUrl))
|
||||||
|
|
||||||
|
const { promise, resolve } = deferredPromise()
|
||||||
|
|
||||||
streamTest = createThoughStream((chunk, enc, cb) => {
|
streamTest = createThoughStream((chunk, enc, cb) => {
|
||||||
assert.equal(chunk.name, 'phishing')
|
if (chunk.name !== 'phishing') return cb()
|
||||||
assert.equal(chunk.data.hostname, phishingUrl)
|
assert.equal(chunk.data.hostname, phishingUrl)
|
||||||
|
resolve()
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
// console.log(streamTest)
|
|
||||||
metamaskController.setupUntrustedCommunication(streamTest, phishingUrl)
|
metamaskController.setupUntrustedCommunication(streamTest, phishingUrl)
|
||||||
|
|
||||||
|
await promise
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -724,25 +790,102 @@ describe('MetaMaskController', function () {
|
||||||
describe('#markAccountsFound', function () {
|
describe('#markAccountsFound', function () {
|
||||||
it('adds lost accounts to config manager data', function () {
|
it('adds lost accounts to config manager data', function () {
|
||||||
metamaskController.markAccountsFound(noop)
|
metamaskController.markAccountsFound(noop)
|
||||||
const configManagerData = metamaskController.configManager.getData()
|
const state = metamaskController.getState()
|
||||||
assert.deepEqual(configManagerData.lostAccounts, [])
|
assert.deepEqual(state.lostAccounts, [])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#markPasswordForgotten', function () {
|
describe('#markPasswordForgotten', function () {
|
||||||
it('adds and sets forgottenPassword to config data to true', function () {
|
it('adds and sets forgottenPassword to config data to true', function () {
|
||||||
metamaskController.markPasswordForgotten(noop)
|
metamaskController.markPasswordForgotten(noop)
|
||||||
const configManagerData = metamaskController.configManager.getData()
|
const state = metamaskController.getState()
|
||||||
assert.equal(configManagerData.forgottenPassword, true)
|
assert.equal(state.forgottenPassword, true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#unMarkPasswordForgotten', function () {
|
describe('#unMarkPasswordForgotten', function () {
|
||||||
it('adds and sets forgottenPassword to config data to false', function () {
|
it('adds and sets forgottenPassword to config data to false', function () {
|
||||||
metamaskController.unMarkPasswordForgotten(noop)
|
metamaskController.unMarkPasswordForgotten(noop)
|
||||||
const configManagerData = metamaskController.configManager.getData()
|
const state = metamaskController.getState()
|
||||||
assert.equal(configManagerData.forgottenPassword, false)
|
assert.equal(state.forgottenPassword, false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('#_onKeyringControllerUpdate', function () {
|
||||||
|
it('should do nothing if there are no keyrings in state', async function () {
|
||||||
|
const addAddresses = sinon.fake()
|
||||||
|
const syncWithAddresses = sinon.fake()
|
||||||
|
sandbox.replace(metamaskController, 'preferencesController', {
|
||||||
|
addAddresses,
|
||||||
|
})
|
||||||
|
sandbox.replace(metamaskController, 'accountTracker', {
|
||||||
|
syncWithAddresses,
|
||||||
|
})
|
||||||
|
|
||||||
|
const oldState = metamaskController.getState()
|
||||||
|
await metamaskController._onKeyringControllerUpdate({keyrings: []})
|
||||||
|
|
||||||
|
assert.ok(addAddresses.notCalled)
|
||||||
|
assert.ok(syncWithAddresses.notCalled)
|
||||||
|
assert.deepEqual(metamaskController.getState(), oldState)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should update selected address if keyrings was locked', async function () {
|
||||||
|
const addAddresses = sinon.fake()
|
||||||
|
const getSelectedAddress = sinon.fake.returns('0x42')
|
||||||
|
const setSelectedAddress = sinon.fake()
|
||||||
|
const syncWithAddresses = sinon.fake()
|
||||||
|
sandbox.replace(metamaskController, 'preferencesController', {
|
||||||
|
addAddresses,
|
||||||
|
getSelectedAddress,
|
||||||
|
setSelectedAddress,
|
||||||
|
})
|
||||||
|
sandbox.replace(metamaskController, 'accountTracker', {
|
||||||
|
syncWithAddresses,
|
||||||
|
})
|
||||||
|
|
||||||
|
const oldState = metamaskController.getState()
|
||||||
|
await metamaskController._onKeyringControllerUpdate({
|
||||||
|
isUnlocked: false,
|
||||||
|
keyrings: [{
|
||||||
|
accounts: ['0x1', '0x2'],
|
||||||
|
}],
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.deepEqual(addAddresses.args, [[['0x1', '0x2']]])
|
||||||
|
assert.deepEqual(syncWithAddresses.args, [[['0x1', '0x2']]])
|
||||||
|
assert.deepEqual(setSelectedAddress.args, [['0x1']])
|
||||||
|
assert.deepEqual(metamaskController.getState(), oldState)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should NOT update selected address if already unlocked', async function () {
|
||||||
|
const addAddresses = sinon.fake()
|
||||||
|
const syncWithAddresses = sinon.fake()
|
||||||
|
sandbox.replace(metamaskController, 'preferencesController', {
|
||||||
|
addAddresses,
|
||||||
|
})
|
||||||
|
sandbox.replace(metamaskController, 'accountTracker', {
|
||||||
|
syncWithAddresses,
|
||||||
|
})
|
||||||
|
|
||||||
|
const oldState = metamaskController.getState()
|
||||||
|
await metamaskController._onKeyringControllerUpdate({
|
||||||
|
isUnlocked: true,
|
||||||
|
keyrings: [{
|
||||||
|
accounts: ['0x1', '0x2'],
|
||||||
|
}],
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.deepEqual(addAddresses.args, [[['0x1', '0x2']]])
|
||||||
|
assert.deepEqual(syncWithAddresses.args, [[['0x1', '0x2']]])
|
||||||
|
assert.deepEqual(metamaskController.getState(), oldState)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function deferredPromise () {
|
||||||
|
let resolve
|
||||||
|
const promise = new Promise(_resolve => { resolve = _resolve })
|
||||||
|
return { promise, resolve }
|
||||||
|
}
|
||||||
|
|
|
@ -32,9 +32,10 @@ describe('# Network Controller', function () {
|
||||||
describe('#provider', function () {
|
describe('#provider', function () {
|
||||||
it('provider should be updatable without reassignment', function () {
|
it('provider should be updatable without reassignment', function () {
|
||||||
networkController.initializeProvider(networkControllerProviderConfig)
|
networkController.initializeProvider(networkControllerProviderConfig)
|
||||||
const proxy = networkController._proxy
|
const providerProxy = networkController.getProviderAndBlockTracker().provider
|
||||||
proxy.setTarget({ test: true, on: () => {} })
|
assert.equal(providerProxy.test, undefined)
|
||||||
assert.ok(proxy.test)
|
providerProxy.setTarget({ test: true })
|
||||||
|
assert.equal(providerProxy.test, true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('#getNetworkState', function () {
|
describe('#getNetworkState', function () {
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const configManagerGen = require('../../../lib/mock-config-manager')
|
|
||||||
const NoticeController = require('../../../../app/scripts/notice-controller')
|
const NoticeController = require('../../../../app/scripts/notice-controller')
|
||||||
|
|
||||||
describe('notice-controller', function () {
|
describe('notice-controller', function () {
|
||||||
var noticeController
|
var noticeController
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// simple localStorage polyfill
|
noticeController = new NoticeController()
|
||||||
const configManager = configManagerGen()
|
|
||||||
noticeController = new NoticeController({
|
|
||||||
configManager: configManager,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('notices', function () {
|
describe('notices', function () {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const PreferencesController = require('../../../../app/scripts/controllers/preferences')
|
const PreferencesController = require('../../../../app/scripts/controllers/preferences')
|
||||||
|
const sinon = require('sinon')
|
||||||
|
|
||||||
describe('preferences controller', function () {
|
describe('preferences controller', function () {
|
||||||
let preferencesController
|
let preferencesController
|
||||||
|
@ -368,5 +369,144 @@ describe('preferences controller', function () {
|
||||||
assert.deepEqual(tokensSecond, initialTokensSecond, 'tokens equal for same network')
|
assert.deepEqual(tokensSecond, initialTokensSecond, 'tokens equal for same network')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('on watchAsset', function () {
|
||||||
|
var stubNext, stubEnd, stubHandleWatchAssetERC20, asy, req, res
|
||||||
|
const sandbox = sinon.createSandbox()
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
req = {params: {}}
|
||||||
|
res = {}
|
||||||
|
asy = {next: () => {}, end: () => {}}
|
||||||
|
stubNext = sandbox.stub(asy, 'next')
|
||||||
|
stubEnd = sandbox.stub(asy, 'end').returns(0)
|
||||||
|
stubHandleWatchAssetERC20 = sandbox.stub(preferencesController, '_handleWatchAssetERC20')
|
||||||
|
})
|
||||||
|
after(() => {
|
||||||
|
sandbox.restore()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('shouldn not do anything if method not corresponds', async function () {
|
||||||
|
const asy = {next: () => {}, end: () => {}}
|
||||||
|
var stubNext = sandbox.stub(asy, 'next')
|
||||||
|
var stubEnd = sandbox.stub(asy, 'end').returns(0)
|
||||||
|
req.method = 'metamask'
|
||||||
|
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
|
||||||
|
sandbox.assert.notCalled(stubEnd)
|
||||||
|
sandbox.assert.called(stubNext)
|
||||||
|
})
|
||||||
|
it('should do something if method is supported', async function () {
|
||||||
|
const asy = {next: () => {}, end: () => {}}
|
||||||
|
var stubNext = sandbox.stub(asy, 'next')
|
||||||
|
var stubEnd = sandbox.stub(asy, 'end').returns(0)
|
||||||
|
req.method = 'metamask_watchAsset'
|
||||||
|
req.params.type = 'someasset'
|
||||||
|
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
|
||||||
|
sandbox.assert.called(stubEnd)
|
||||||
|
sandbox.assert.notCalled(stubNext)
|
||||||
|
})
|
||||||
|
it('should through error if method is supported but asset type is not', async function () {
|
||||||
|
req.method = 'metamask_watchAsset'
|
||||||
|
req.params.type = 'someasset'
|
||||||
|
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
|
||||||
|
sandbox.assert.called(stubEnd)
|
||||||
|
sandbox.assert.notCalled(stubHandleWatchAssetERC20)
|
||||||
|
sandbox.assert.notCalled(stubNext)
|
||||||
|
assert.deepEqual(res, {})
|
||||||
|
})
|
||||||
|
it('should trigger handle add asset if type supported', async function () {
|
||||||
|
const asy = {next: () => {}, end: () => {}}
|
||||||
|
req.method = 'metamask_watchAsset'
|
||||||
|
req.params.type = 'ERC20'
|
||||||
|
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
|
||||||
|
sandbox.assert.called(stubHandleWatchAssetERC20)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('on watchAsset of type ERC20', function () {
|
||||||
|
var req
|
||||||
|
|
||||||
|
const sandbox = sinon.createSandbox()
|
||||||
|
beforeEach(() => {
|
||||||
|
req = {params: {type: 'ERC20'}}
|
||||||
|
})
|
||||||
|
after(() => {
|
||||||
|
sandbox.restore()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should add suggested token', async function () {
|
||||||
|
const address = '0xabcdef1234567'
|
||||||
|
const symbol = 'ABBR'
|
||||||
|
const decimals = 5
|
||||||
|
const image = 'someimage'
|
||||||
|
req.params.options = { address, symbol, decimals, image }
|
||||||
|
|
||||||
|
sandbox.stub(preferencesController, '_validateERC20AssetParams').returns(true)
|
||||||
|
preferencesController.showWatchAssetUi = async () => {}
|
||||||
|
|
||||||
|
await preferencesController._handleWatchAssetERC20(req.params.options)
|
||||||
|
const suggested = preferencesController.getSuggestedTokens()
|
||||||
|
assert.equal(Object.keys(suggested).length, 1, `one token added ${Object.keys(suggested)}`)
|
||||||
|
|
||||||
|
assert.equal(suggested[address].address, address, 'set address correctly')
|
||||||
|
assert.equal(suggested[address].symbol, symbol, 'set symbol correctly')
|
||||||
|
assert.equal(suggested[address].decimals, decimals, 'set decimals correctly')
|
||||||
|
assert.equal(suggested[address].image, image, 'set image correctly')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should add token correctly if user confirms', async function () {
|
||||||
|
const address = '0xabcdef1234567'
|
||||||
|
const symbol = 'ABBR'
|
||||||
|
const decimals = 5
|
||||||
|
const image = 'someimage'
|
||||||
|
req.params.options = { address, symbol, decimals, image }
|
||||||
|
|
||||||
|
sandbox.stub(preferencesController, '_validateERC20AssetParams').returns(true)
|
||||||
|
preferencesController.showWatchAssetUi = async () => {
|
||||||
|
await preferencesController.addToken(address, symbol, decimals, image)
|
||||||
|
}
|
||||||
|
|
||||||
|
await preferencesController._handleWatchAssetERC20(req.params.options)
|
||||||
|
const tokens = preferencesController.getTokens()
|
||||||
|
assert.equal(tokens.length, 1, `one token added`)
|
||||||
|
const added = tokens[0]
|
||||||
|
assert.equal(added.address, address, 'set address correctly')
|
||||||
|
assert.equal(added.symbol, symbol, 'set symbol correctly')
|
||||||
|
assert.equal(added.decimals, decimals, 'set decimals correctly')
|
||||||
|
|
||||||
|
const assetImages = preferencesController.getAssetImages()
|
||||||
|
assert.ok(assetImages[address], `set image correctly`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('setPasswordForgotten', function () {
|
||||||
|
it('should default to false', function () {
|
||||||
|
const state = preferencesController.store.getState()
|
||||||
|
assert.equal(state.forgottenPassword, false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should set the forgottenPassword property in state', function () {
|
||||||
|
assert.equal(preferencesController.store.getState().forgottenPassword, false)
|
||||||
|
|
||||||
|
preferencesController.setPasswordForgotten(true)
|
||||||
|
|
||||||
|
assert.equal(preferencesController.store.getState().forgottenPassword, true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('setSeedWords', function () {
|
||||||
|
it('should default to null', function () {
|
||||||
|
const state = preferencesController.store.getState()
|
||||||
|
assert.equal(state.seedWords, null)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should set the seedWords property in state', function () {
|
||||||
|
assert.equal(preferencesController.store.getState().seedWords, null)
|
||||||
|
|
||||||
|
preferencesController.setSeedWords('foo bar baz')
|
||||||
|
|
||||||
|
assert.equal(preferencesController.store.getState().seedWords, 'foo bar baz')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -224,14 +224,15 @@ function generateNonceTrackerWith (pending, confirmed, providerStub = '0x0') {
|
||||||
providerResultStub.result = providerStub
|
providerResultStub.result = providerStub
|
||||||
const provider = {
|
const provider = {
|
||||||
sendAsync: (_, cb) => { cb(undefined, providerResultStub) },
|
sendAsync: (_, cb) => { cb(undefined, providerResultStub) },
|
||||||
_blockTracker: {
|
}
|
||||||
|
const blockTracker = {
|
||||||
getCurrentBlock: () => '0x11b568',
|
getCurrentBlock: () => '0x11b568',
|
||||||
},
|
getLatestBlock: async () => '0x11b568',
|
||||||
}
|
}
|
||||||
return new NonceTracker({
|
return new NonceTracker({
|
||||||
provider,
|
provider,
|
||||||
|
blockTracker,
|
||||||
getPendingTransactions,
|
getPendingTransactions,
|
||||||
getConfirmedTransactions,
|
getConfirmedTransactions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ describe('PendingTransactionTracker', function () {
|
||||||
let pendingTxTracker, txMeta, txMetaNoHash, providerResultStub,
|
let pendingTxTracker, txMeta, txMetaNoHash, providerResultStub,
|
||||||
provider, txMeta3, txList, knownErrors
|
provider, txMeta3, txList, knownErrors
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
txMeta = {
|
txMeta = {
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -40,7 +41,10 @@ describe('PendingTransactionTracker', function () {
|
||||||
getPendingTransactions: () => { return [] },
|
getPendingTransactions: () => { return [] },
|
||||||
getCompletedTransactions: () => { return [] },
|
getCompletedTransactions: () => { return [] },
|
||||||
publishTransaction: () => {},
|
publishTransaction: () => {},
|
||||||
|
confirmTransaction: () => {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
pendingTxTracker._getBlock = (blockNumber) => { return {number: blockNumber, transactions: []} }
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_checkPendingTx state management', function () {
|
describe('_checkPendingTx state management', function () {
|
||||||
|
@ -92,58 +96,6 @@ describe('PendingTransactionTracker', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#checkForTxInBlock', function () {
|
|
||||||
it('should return if no pending transactions', function () {
|
|
||||||
// throw a type error if it trys to do anything on the block
|
|
||||||
// thus failing the test
|
|
||||||
const block = Proxy.revocable({}, {}).revoke()
|
|
||||||
pendingTxTracker.checkForTxInBlock(block)
|
|
||||||
})
|
|
||||||
it('should emit \'tx:failed\' if the txMeta does not have a hash', function (done) {
|
|
||||||
const block = Proxy.revocable({}, {}).revoke()
|
|
||||||
pendingTxTracker.getPendingTransactions = () => [txMetaNoHash]
|
|
||||||
pendingTxTracker.once('tx:failed', (txId, err) => {
|
|
||||||
assert(txId, txMetaNoHash.id, 'should pass txId')
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
pendingTxTracker.checkForTxInBlock(block)
|
|
||||||
})
|
|
||||||
it('should emit \'txConfirmed\' if the tx is in the block', function (done) {
|
|
||||||
const block = { transactions: [txMeta]}
|
|
||||||
pendingTxTracker.getPendingTransactions = () => [txMeta]
|
|
||||||
pendingTxTracker.once('tx:confirmed', (txId) => {
|
|
||||||
assert(txId, txMeta.id, 'should pass txId')
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
pendingTxTracker.once('tx:failed', (_, err) => { done(err) })
|
|
||||||
pendingTxTracker.checkForTxInBlock(block)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('#queryPendingTxs', function () {
|
|
||||||
it('should call #_checkPendingTxs if their is no oldBlock', function (done) {
|
|
||||||
let oldBlock
|
|
||||||
const newBlock = { number: '0x01' }
|
|
||||||
pendingTxTracker._checkPendingTxs = done
|
|
||||||
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
|
|
||||||
})
|
|
||||||
it('should call #_checkPendingTxs if oldBlock and the newBlock have a diff of greater then 1', function (done) {
|
|
||||||
const oldBlock = { number: '0x01' }
|
|
||||||
const newBlock = { number: '0x03' }
|
|
||||||
pendingTxTracker._checkPendingTxs = done
|
|
||||||
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
|
|
||||||
})
|
|
||||||
it('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less', function (done) {
|
|
||||||
const oldBlock = { number: '0x1' }
|
|
||||||
const newBlock = { number: '0x2' }
|
|
||||||
pendingTxTracker._checkPendingTxs = () => {
|
|
||||||
const err = new Error('should not call #_checkPendingTxs if oldBlock and the newBlock have a diff of 1 or less')
|
|
||||||
done(err)
|
|
||||||
}
|
|
||||||
pendingTxTracker.queryPendingTxs({ oldBlock, newBlock })
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('#_checkPendingTx', function () {
|
describe('#_checkPendingTx', function () {
|
||||||
it('should emit \'tx:failed\' if the txMeta does not have a hash', function (done) {
|
it('should emit \'tx:failed\' if the txMeta does not have a hash', function (done) {
|
||||||
pendingTxTracker.once('tx:failed', (txId, err) => {
|
pendingTxTracker.once('tx:failed', (txId, err) => {
|
||||||
|
@ -157,16 +109,6 @@ describe('PendingTransactionTracker', function () {
|
||||||
providerResultStub.eth_getTransactionByHash = null
|
providerResultStub.eth_getTransactionByHash = null
|
||||||
pendingTxTracker._checkPendingTx(txMeta)
|
pendingTxTracker._checkPendingTx(txMeta)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit \'txConfirmed\'', function (done) {
|
|
||||||
providerResultStub.eth_getTransactionByHash = {blockNumber: '0x01'}
|
|
||||||
pendingTxTracker.once('tx:confirmed', (txId) => {
|
|
||||||
assert(txId, txMeta.id, 'should pass txId')
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
pendingTxTracker.once('tx:failed', (_, err) => { done(err) })
|
|
||||||
pendingTxTracker._checkPendingTx(txMeta)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#_checkPendingTxs', function () {
|
describe('#_checkPendingTxs', function () {
|
||||||
|
@ -180,19 +122,19 @@ describe('PendingTransactionTracker', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should warp all txMeta\'s in #_checkPendingTx', function (done) {
|
it('should warp all txMeta\'s in #updatePendingTxs', function (done) {
|
||||||
pendingTxTracker.getPendingTransactions = () => txList
|
pendingTxTracker.getPendingTransactions = () => txList
|
||||||
pendingTxTracker._checkPendingTx = (tx) => { tx.resolve(tx) }
|
pendingTxTracker._checkPendingTx = (tx) => { tx.resolve(tx) }
|
||||||
Promise.all(txList.map((tx) => tx.processed))
|
Promise.all(txList.map((tx) => tx.processed))
|
||||||
.then((txCompletedList) => done())
|
.then((txCompletedList) => done())
|
||||||
.catch(done)
|
.catch(done)
|
||||||
|
|
||||||
pendingTxTracker._checkPendingTxs()
|
pendingTxTracker.updatePendingTxs()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#resubmitPendingTxs', function () {
|
describe('#resubmitPendingTxs', function () {
|
||||||
const blockStub = { number: '0x0' }
|
const blockNumberStub = '0x0'
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const txMeta2 = txMeta3 = txMeta
|
const txMeta2 = txMeta3 = txMeta
|
||||||
txList = [txMeta, txMeta2, txMeta3].map((tx) => {
|
txList = [txMeta, txMeta2, txMeta3].map((tx) => {
|
||||||
|
@ -210,7 +152,7 @@ describe('PendingTransactionTracker', function () {
|
||||||
Promise.all(txList.map((tx) => tx.processed))
|
Promise.all(txList.map((tx) => tx.processed))
|
||||||
.then((txCompletedList) => done())
|
.then((txCompletedList) => done())
|
||||||
.catch(done)
|
.catch(done)
|
||||||
pendingTxTracker.resubmitPendingTxs(blockStub)
|
pendingTxTracker.resubmitPendingTxs(blockNumberStub)
|
||||||
})
|
})
|
||||||
it('should not emit \'tx:failed\' if the txMeta throws a known txError', function (done) {
|
it('should not emit \'tx:failed\' if the txMeta throws a known txError', function (done) {
|
||||||
knownErrors = [
|
knownErrors = [
|
||||||
|
@ -237,7 +179,7 @@ describe('PendingTransactionTracker', function () {
|
||||||
.then((txCompletedList) => done())
|
.then((txCompletedList) => done())
|
||||||
.catch(done)
|
.catch(done)
|
||||||
|
|
||||||
pendingTxTracker.resubmitPendingTxs(blockStub)
|
pendingTxTracker.resubmitPendingTxs(blockNumberStub)
|
||||||
})
|
})
|
||||||
it('should emit \'tx:warning\' if it encountered a real error', function (done) {
|
it('should emit \'tx:warning\' if it encountered a real error', function (done) {
|
||||||
pendingTxTracker.once('tx:warning', (txMeta, err) => {
|
pendingTxTracker.once('tx:warning', (txMeta, err) => {
|
||||||
|
@ -255,7 +197,7 @@ describe('PendingTransactionTracker', function () {
|
||||||
.then((txCompletedList) => done())
|
.then((txCompletedList) => done())
|
||||||
.catch(done)
|
.catch(done)
|
||||||
|
|
||||||
pendingTxTracker.resubmitPendingTxs(blockStub)
|
pendingTxTracker.resubmitPendingTxs(blockNumberStub)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('#_resubmitTx', function () {
|
describe('#_resubmitTx', function () {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
const EventEmitter = require('events')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const EthTx = require('ethereumjs-tx')
|
const EthTx = require('ethereumjs-tx')
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
|
@ -22,12 +23,14 @@ describe('Transaction Controller', function () {
|
||||||
}
|
}
|
||||||
provider = createTestProviderTools({ scaffold: providerResultStub }).provider
|
provider = createTestProviderTools({ scaffold: providerResultStub }).provider
|
||||||
fromAccount = getTestAccounts()[0]
|
fromAccount = getTestAccounts()[0]
|
||||||
|
const blockTrackerStub = new EventEmitter()
|
||||||
|
blockTrackerStub.getCurrentBlock = noop
|
||||||
|
blockTrackerStub.getLatestBlock = noop
|
||||||
txController = new TransactionController({
|
txController = new TransactionController({
|
||||||
provider,
|
provider,
|
||||||
networkStore: new ObservableStore(currentNetworkId),
|
networkStore: new ObservableStore(currentNetworkId),
|
||||||
txHistoryLimit: 10,
|
txHistoryLimit: 10,
|
||||||
blockTracker: { getCurrentBlock: noop, on: noop, once: noop },
|
blockTracker: blockTrackerStub,
|
||||||
signTransaction: (ethTx) => new Promise((resolve) => {
|
signTransaction: (ethTx) => new Promise((resolve) => {
|
||||||
ethTx.sign(fromAccount.key)
|
ethTx.sign(fromAccount.key)
|
||||||
resolve()
|
resolve()
|
||||||
|
@ -49,9 +52,9 @@ describe('Transaction Controller', function () {
|
||||||
describe('#getUnapprovedTxCount', function () {
|
describe('#getUnapprovedTxCount', function () {
|
||||||
it('should return the number of unapproved txs', function () {
|
it('should return the number of unapproved txs', function () {
|
||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||||
{ id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
{ id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||||
{ id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
{ id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||||
])
|
])
|
||||||
const unapprovedTxCount = txController.getUnapprovedTxCount()
|
const unapprovedTxCount = txController.getUnapprovedTxCount()
|
||||||
assert.equal(unapprovedTxCount, 3, 'should be 3')
|
assert.equal(unapprovedTxCount, 3, 'should be 3')
|
||||||
|
@ -61,9 +64,9 @@ describe('Transaction Controller', function () {
|
||||||
describe('#getPendingTxCount', function () {
|
describe('#getPendingTxCount', function () {
|
||||||
it('should return the number of pending txs', function () {
|
it('should return the number of pending txs', function () {
|
||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
|
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||||
{ id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
|
{ id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||||
{ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
|
{ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||||
])
|
])
|
||||||
const pendingTxCount = txController.getPendingTxCount()
|
const pendingTxCount = txController.getPendingTxCount()
|
||||||
assert.equal(pendingTxCount, 3, 'should be 3')
|
assert.equal(pendingTxCount, 3, 'should be 3')
|
||||||
|
@ -79,15 +82,15 @@ describe('Transaction Controller', function () {
|
||||||
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||||
}
|
}
|
||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
{id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams},
|
{id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -201,24 +204,22 @@ describe('Transaction Controller', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#addTxGasDefaults', function () {
|
describe('#addTxGasDefaults', function () {
|
||||||
it('should add the tx defaults if their are none', function (done) {
|
it('should add the tx defaults if their are none', async () => {
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
'txParams': {
|
txParams: {
|
||||||
'from': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||||
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||||
},
|
},
|
||||||
|
history: [],
|
||||||
}
|
}
|
||||||
providerResultStub.eth_gasPrice = '4a817c800'
|
providerResultStub.eth_gasPrice = '4a817c800'
|
||||||
providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' }
|
providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' }
|
||||||
providerResultStub.eth_estimateGas = '5209'
|
providerResultStub.eth_estimateGas = '5209'
|
||||||
txController.addTxGasDefaults(txMeta)
|
|
||||||
.then((txMetaWithDefaults) => {
|
const txMetaWithDefaults = await txController.addTxGasDefaults(txMeta)
|
||||||
assert(txMetaWithDefaults.txParams.value, '0x0', 'should have added 0x0 as the value')
|
assert(txMetaWithDefaults.txParams.value, '0x0', 'should have added 0x0 as the value')
|
||||||
assert(txMetaWithDefaults.txParams.gasPrice, 'should have added the gas price')
|
assert(txMetaWithDefaults.txParams.gasPrice, 'should have added the gas price')
|
||||||
assert(txMetaWithDefaults.txParams.gas, 'should have added the gas field')
|
assert(txMetaWithDefaults.txParams.gas, 'should have added the gas field')
|
||||||
done()
|
|
||||||
})
|
|
||||||
.catch(done)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -381,8 +382,9 @@ describe('Transaction Controller', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should publish a tx, updates the rawTx when provided a one', async function () {
|
it('should publish a tx, updates the rawTx when provided a one', async function () {
|
||||||
|
const rawTx = '0x477b2e6553c917af0db0388ae3da62965ff1a184558f61b749d1266b2e6d024c'
|
||||||
txController.txStateManager.addTx(txMeta)
|
txController.txStateManager.addTx(txMeta)
|
||||||
await txController.publishTransaction(txMeta.id)
|
await txController.publishTransaction(txMeta.id, rawTx)
|
||||||
const publishedTx = txController.txStateManager.getTx(1)
|
const publishedTx = txController.txStateManager.getTx(1)
|
||||||
assert.equal(publishedTx.hash, hash)
|
assert.equal(publishedTx.hash, hash)
|
||||||
assert.equal(publishedTx.status, 'submitted')
|
assert.equal(publishedTx.status, 'submitted')
|
||||||
|
@ -398,7 +400,7 @@ describe('Transaction Controller', function () {
|
||||||
data: '0x0',
|
data: '0x0',
|
||||||
}
|
}
|
||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams },
|
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||||
])
|
])
|
||||||
txController.retryTransaction(1)
|
txController.retryTransaction(1)
|
||||||
.then((txMeta) => {
|
.then((txMeta) => {
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
// polyfill fetch
|
|
||||||
global.fetch = global.fetch || require('isomorphic-fetch')
|
|
||||||
|
|
||||||
const assert = require('assert')
|
|
||||||
const configManagerGen = require('../lib/mock-config-manager')
|
|
||||||
|
|
||||||
describe('config-manager', function () {
|
|
||||||
var configManager
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
configManager = configManagerGen()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('#setConfig', function () {
|
|
||||||
it('should set the config key', function () {
|
|
||||||
var testConfig = {
|
|
||||||
provider: {
|
|
||||||
type: 'rpc',
|
|
||||||
rpcTarget: 'foobar',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
configManager.setConfig(testConfig)
|
|
||||||
var result = configManager.getData()
|
|
||||||
|
|
||||||
assert.equal(result.config.provider.type, testConfig.provider.type)
|
|
||||||
assert.equal(result.config.provider.rpcTarget, testConfig.provider.rpcTarget)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('setting wallet should not overwrite config', function () {
|
|
||||||
var testConfig = {
|
|
||||||
provider: {
|
|
||||||
type: 'rpc',
|
|
||||||
rpcTarget: 'foobar',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
configManager.setConfig(testConfig)
|
|
||||||
|
|
||||||
var testWallet = {
|
|
||||||
name: 'this is my fake wallet',
|
|
||||||
}
|
|
||||||
configManager.setWallet(testWallet)
|
|
||||||
|
|
||||||
var result = configManager.getData()
|
|
||||||
assert.equal(result.wallet.name, testWallet.name, 'wallet name is set')
|
|
||||||
assert.equal(result.config.provider.rpcTarget, testConfig.provider.rpcTarget)
|
|
||||||
|
|
||||||
testConfig.provider.type = 'something else!'
|
|
||||||
configManager.setConfig(testConfig)
|
|
||||||
|
|
||||||
result = configManager.getData()
|
|
||||||
assert.equal(result.wallet.name, testWallet.name, 'wallet name is set')
|
|
||||||
assert.equal(result.config.provider.rpcTarget, testConfig.provider.rpcTarget)
|
|
||||||
assert.equal(result.config.provider.type, testConfig.provider.type)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('wallet nicknames', function () {
|
|
||||||
it('should return null when no nicknames are saved', function () {
|
|
||||||
var nick = configManager.nicknameForWallet('0x0')
|
|
||||||
assert.equal(nick, null, 'no nickname returned')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should persist nicknames', function () {
|
|
||||||
var account = '0x0'
|
|
||||||
var nick1 = 'foo'
|
|
||||||
var nick2 = 'bar'
|
|
||||||
configManager.setNicknameForWallet(account, nick1)
|
|
||||||
|
|
||||||
var result1 = configManager.nicknameForWallet(account)
|
|
||||||
assert.equal(result1, nick1)
|
|
||||||
|
|
||||||
configManager.setNicknameForWallet(account, nick2)
|
|
||||||
var result2 = configManager.nicknameForWallet(account)
|
|
||||||
assert.equal(result2, nick2)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('transactions', function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
configManager.setTxList([])
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('#getTxList', function () {
|
|
||||||
it('when new should return empty array', function () {
|
|
||||||
var result = configManager.getTxList()
|
|
||||||
assert.ok(Array.isArray(result))
|
|
||||||
assert.equal(result.length, 0)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('#setTxList', function () {
|
|
||||||
it('saves the submitted data to the tx list', function () {
|
|
||||||
var target = [{ foo: 'bar' }]
|
|
||||||
configManager.setTxList(target)
|
|
||||||
var result = configManager.getTxList()
|
|
||||||
assert.equal(result[0].foo, 'bar')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} FirstTimeState
|
||||||
|
* @property {Object} config Initial configuration parameters
|
||||||
|
* @property {Object} NetworkController Network controller state
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {FirstTimeState}
|
||||||
|
*/
|
||||||
|
const initialState = {
|
||||||
|
config: {},
|
||||||
|
NetworkController: {
|
||||||
|
provider: {
|
||||||
|
type: 'rpc',
|
||||||
|
rpcTarget: 'http://localhost:8545',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = initialState
|
|
@ -1,33 +0,0 @@
|
||||||
const Component = require('react').Component
|
|
||||||
const h = require('react-hyperscript')
|
|
||||||
const inherits = require('util').inherits
|
|
||||||
// Main Views
|
|
||||||
const TxView = require('./components/tx-view')
|
|
||||||
const WalletView = require('./components/wallet-view')
|
|
||||||
|
|
||||||
module.exports = AccountAndTransactionDetails
|
|
||||||
|
|
||||||
inherits(AccountAndTransactionDetails, Component)
|
|
||||||
function AccountAndTransactionDetails () {
|
|
||||||
Component.call(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountAndTransactionDetails.prototype.render = function () {
|
|
||||||
return h('div.account-and-transaction-details', [
|
|
||||||
// wallet
|
|
||||||
h(WalletView, {
|
|
||||||
style: {
|
|
||||||
},
|
|
||||||
responsiveDisplayClassname: '.lap-visible',
|
|
||||||
}, [
|
|
||||||
]),
|
|
||||||
|
|
||||||
// transaction
|
|
||||||
h(TxView, {
|
|
||||||
style: {
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ const {
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const { fetchLocale } = require('../i18n-helper')
|
const { fetchLocale } = require('../i18n-helper')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
|
const { ENVIRONMENT_TYPE_NOTIFICATION } = require('../../app/scripts/lib/enums')
|
||||||
const { hasUnconfirmedTransactions } = require('./helpers/confirm-transaction/util')
|
const { hasUnconfirmedTransactions } = require('./helpers/confirm-transaction/util')
|
||||||
const WebcamUtils = require('../lib/webcam-utils')
|
const WebcamUtils = require('../lib/webcam-utils')
|
||||||
|
|
||||||
|
@ -232,10 +233,13 @@ var actions = {
|
||||||
showAddTokenPage,
|
showAddTokenPage,
|
||||||
showConfirmAddTokensPage,
|
showConfirmAddTokensPage,
|
||||||
showRemoveTokenPage,
|
showRemoveTokenPage,
|
||||||
|
SHOW_ADD_SUGGESTED_TOKEN_PAGE: 'SHOW_ADD_SUGGESTED_TOKEN_PAGE',
|
||||||
|
showAddSuggestedTokenPage,
|
||||||
addToken,
|
addToken,
|
||||||
addTokens,
|
addTokens,
|
||||||
removeToken,
|
removeToken,
|
||||||
updateTokens,
|
updateTokens,
|
||||||
|
removeSuggestedTokens,
|
||||||
UPDATE_TOKENS: 'UPDATE_TOKENS',
|
UPDATE_TOKENS: 'UPDATE_TOKENS',
|
||||||
setRpcTarget: setRpcTarget,
|
setRpcTarget: setRpcTarget,
|
||||||
setProviderType: setProviderType,
|
setProviderType: setProviderType,
|
||||||
|
@ -323,6 +327,8 @@ var actions = {
|
||||||
showDeleteImportedAccount,
|
showDeleteImportedAccount,
|
||||||
CONFIRM_CHANGE_PASSWORD: 'CONFIRM_CHANGE_PASSWORD',
|
CONFIRM_CHANGE_PASSWORD: 'CONFIRM_CHANGE_PASSWORD',
|
||||||
confirmChangePassword,
|
confirmChangePassword,
|
||||||
|
|
||||||
|
createCancelTransaction,
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = actions
|
module.exports = actions
|
||||||
|
@ -425,7 +431,12 @@ function createNewVaultAndRestore (password, seed) {
|
||||||
log.debug(`background.createNewVaultAndRestore`)
|
log.debug(`background.createNewVaultAndRestore`)
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
background.createNewVaultAndRestore(password, seed, err => {
|
background.clearSeedWordCache((err) => {
|
||||||
|
if (err) {
|
||||||
|
return reject(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
background.createNewVaultAndRestore(password, seed, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
|
@ -433,6 +444,7 @@ function createNewVaultAndRestore (password, seed) {
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
.then(() => dispatch(actions.unMarkPasswordForgotten()))
|
.then(() => dispatch(actions.unMarkPasswordForgotten()))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(actions.showAccountsPage())
|
dispatch(actions.showAccountsPage())
|
||||||
|
@ -1181,6 +1193,10 @@ function updateAndApproveTx (txData) {
|
||||||
|
|
||||||
return txData
|
return txData
|
||||||
})
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
return Promise.reject(err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1630,6 +1646,13 @@ function showConfirmAddTokensPage (transitionForward = true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showAddSuggestedTokenPage (transitionForward = true) {
|
||||||
|
return {
|
||||||
|
type: actions.SHOW_ADD_SUGGESTED_TOKEN_PAGE,
|
||||||
|
value: transitionForward,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function showRemoveTokenPage (token, transitionForward = true) {
|
function showRemoveTokenPage (token, transitionForward = true) {
|
||||||
return {
|
return {
|
||||||
type: actions.SHOW_REMOVE_TOKEN_PAGE,
|
type: actions.SHOW_REMOVE_TOKEN_PAGE,
|
||||||
|
@ -1638,11 +1661,11 @@ function showRemoveTokenPage (token, transitionForward = true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToken (address, symbol, decimals, network) {
|
function addToken (address, symbol, decimals, image, network) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
background.addToken(address, symbol, decimals, network, (err, tokens) => {
|
background.addToken(address, symbol, decimals, image, network, (err, tokens) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(actions.displayWarning(err.message))
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
@ -1692,6 +1715,27 @@ function addTokens (tokens) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeSuggestedTokens () {
|
||||||
|
return (dispatch) => {
|
||||||
|
dispatch(actions.showLoadingIndication())
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
background.removeSuggestedTokens((err, suggestedTokens) => {
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
if (err) {
|
||||||
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
}
|
||||||
|
dispatch(actions.clearPendingTokens())
|
||||||
|
if (global.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) {
|
||||||
|
return global.platform.closeCurrentWindow()
|
||||||
|
}
|
||||||
|
resolve(suggestedTokens)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(() => updateMetamaskStateFromBackground())
|
||||||
|
.then(suggestedTokens => dispatch(actions.updateMetamaskState({...suggestedTokens})))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateTokens (newTokens) {
|
function updateTokens (newTokens) {
|
||||||
return {
|
return {
|
||||||
type: actions.UPDATE_TOKENS,
|
type: actions.UPDATE_TOKENS,
|
||||||
|
@ -1699,6 +1743,12 @@ function updateTokens (newTokens) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearPendingTokens () {
|
||||||
|
return {
|
||||||
|
type: actions.CLEAR_PENDING_TOKENS,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function goBackToInitView () {
|
function goBackToInitView () {
|
||||||
return {
|
return {
|
||||||
type: actions.BACK_TO_INIT_MENU,
|
type: actions.BACK_TO_INIT_MENU,
|
||||||
|
@ -1774,6 +1824,29 @@ function retryTransaction (txId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createCancelTransaction (txId, customGasPrice) {
|
||||||
|
log.debug('background.cancelTransaction')
|
||||||
|
let newTxId
|
||||||
|
|
||||||
|
return dispatch => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
background.createCancelTransaction(txId, customGasPrice, (err, newState) => {
|
||||||
|
if (err) {
|
||||||
|
dispatch(actions.displayWarning(err.message))
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
const { selectedAddressTxList } = newState
|
||||||
|
const { id } = selectedAddressTxList[selectedAddressTxList.length - 1]
|
||||||
|
newTxId = id
|
||||||
|
resolve(newState)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(newState => dispatch(actions.updateMetamaskState(newState)))
|
||||||
|
.then(() => newTxId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// config
|
// config
|
||||||
//
|
//
|
||||||
|
@ -1878,9 +1951,13 @@ function hideModal (payload) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSidebar () {
|
function showSidebar ({ transitionName, type }) {
|
||||||
return {
|
return {
|
||||||
type: actions.SIDEBAR_OPEN,
|
type: actions.SIDEBAR_OPEN,
|
||||||
|
value: {
|
||||||
|
transitionName,
|
||||||
|
type,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2382,12 +2459,6 @@ function setPendingTokens (pendingTokens) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearPendingTokens () {
|
|
||||||
return {
|
|
||||||
type: actions.CLEAR_PENDING_TOKENS,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showDeleteRPC (RPC_URL, transitionForward = true) {
|
function showDeleteRPC (RPC_URL, transitionForward = true) {
|
||||||
return {
|
return {
|
||||||
type: actions.SHOW_DELETE_RPC,
|
type: actions.SHOW_DELETE_RPC,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue