Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @metamask/controllers #1598

Merged
merged 5 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/UI/AccountList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class AccountList extends PureComponent {

getAccounts() {
const { accounts, identities, selectedAddress, keyrings, getBalanceError } = this.props;
// This is a temporary fix until we can read the state from GABA
// This is a temporary fix until we can read the state from @metamask/controllers
const allKeyrings = keyrings && keyrings.length ? keyrings : Engine.context.KeyringController.state.keyrings;

const accountsOrdered = allKeyrings.reduce((list, keyring) => list.concat(keyring.accounts), []);
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/PersonalSign/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { colors, fontStyles } from '../../../styles/common';
import Engine from '../../../core/Engine';
import SignatureRequest from '../SignatureRequest';
import ExpandedMessage from '../SignatureRequest/ExpandedMessage';
import { util } from 'gaba';
import { util } from '@metamask/controllers';

const styles = StyleSheet.create({
messageText: {
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import TransactionElement from '../TransactionElement';
import Engine from '../../../core/Engine';
import { showAlert } from '../../../actions/alert';
import TransactionsNotificationManager from '../../../core/TransactionsNotificationManager';
import { CANCEL_RATE, SPEED_UP_RATE } from 'gaba';
import { CANCEL_RATE, SPEED_UP_RATE, util } from '@metamask/controllers';
import { renderFromWei } from '../../../util/number';
import { safeToChecksumAddress } from '../../../util/address';
import Device from '../../../util/Device';
import { hexToBN } from 'gaba/dist/util';
import { BN } from 'ethereumjs-util';
import TransactionActionModal from '../TransactionActionModal';

const { hexToBN } = util;
const styles = StyleSheet.create({
wrapper: {
backgroundColor: colors.white,
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/TxNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import Device from '../../../util/Device';
import Animated, { Easing } from 'react-native-reanimated';
import ElevatedView from 'react-native-elevated-view';
import { strings } from '../../../../locales/i18n';
import { CANCEL_RATE, SPEED_UP_RATE, BN } from 'gaba';
import { CANCEL_RATE, SPEED_UP_RATE, BN, util } from '@metamask/controllers';
import ActionContent from '../ActionModal/ActionContent';
import TransactionActionContent from '../TransactionActionModal/TransactionActionContent';
import { renderFromWei } from '../../../util/number';
import Engine from '../../../core/Engine';
import { safeToChecksumAddress } from '../../../util/address';
import { hexToBN } from 'gaba/dist/util';

const { hexToBN } = util;
const BROWSER_ROUTE = 'BrowserView';

const styles = StyleSheet.create({
Expand Down
3 changes: 2 additions & 1 deletion app/components/Views/ApproveView/Approve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import CustomGas from '../../SendFlow/CustomGas';
import ActionModal from '../../../UI/ActionModal';
import { strings } from '../../../../../locales/i18n';
import { setTransactionObject } from '../../../../actions/transaction';
import { BNToHex, hexToBN } from 'gaba/dist/util';
import { util } from '@metamask/controllers';
import { renderFromWei, weiToFiatNumber, isBN, renderFromTokenMinimalUnit, isDecimal } from '../../../../util/number';
import {
getTicker,
Expand All @@ -44,6 +44,7 @@ import Identicon from '../../../UI/Identicon';
import Analytics from '../../../../core/Analytics';
import { ANALYTICS_EVENT_OPTS } from '../../../../util/analytics';

const { BNToHex, hexToBN } = util;
const styles = StyleSheet.create({
wrapper: {
backgroundColor: colors.white,
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/ApproveView/Approve/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';
import Approve from './';
import configureMockStore from 'redux-mock-store';
import { BN } from 'gaba';
import { BN } from '@metamask/controllers';

const mockStore = configureMockStore();

Expand Down
4 changes: 3 additions & 1 deletion app/components/Views/SendFlow/Amount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
handleWeiNumber
} from '../../../../util/number';
import { getTicker, generateTransferData, getEther } from '../../../../util/transactions';
import { hexToBN, BNToHex } from 'gaba/dist/util';
import { util } from '@metamask/controllers';
import FadeIn from 'react-native-fade-in-image';
import ErrorMessage from '../ErrorMessage';
import { fetchBasicGasEstimates, apiEstimateModifiedToWEI } from '../../../../util/custom-gas';
Expand All @@ -53,6 +53,8 @@ import { BN } from 'ethereumjs-util';
import Analytics from '../../../../core/Analytics';
import { ANALYTICS_EVENT_OPTS } from '../../../../util/analytics';

const { hexToBN, BNToHex } = util;

const KEYBOARD_OFFSET = Device.isSmallDevice() ? 80 : 120;

const ethLogo = require('../../../../images/eth-logo.png'); // eslint-disable-line
Expand Down
3 changes: 2 additions & 1 deletion app/components/Views/SendFlow/Confirm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '../../../../util/number';
import { getTicker, decodeTransferData } from '../../../../util/transactions';
import StyledButton from '../../../UI/StyledButton';
import { hexToBN, BNToHex } from 'gaba/dist/util';
import { util } from '@metamask/controllers';
import { prepareTransaction, resetTransaction } from '../../../../actions/transaction';
import { fetchBasicGasEstimates, convertApiValueToGWEI } from '../../../../util/custom-gas';
import Engine from '../../../../core/Engine';
Expand All @@ -51,6 +51,7 @@ import TransactionSummary from '../../TransactionSummary';
import Analytics from '../../../../core/Analytics';
import { ANALYTICS_EVENT_OPTS } from '../../../../util/analytics';

const { hexToBN, BNToHex } = util;
const {
CUSTOM_GAS: { AVERAGE_GAS, FAST_GAS, LOW_GAS }
} = TransactionTypes;
Expand Down
3 changes: 2 additions & 1 deletion app/components/Views/SendFlow/SendTo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import { getTicker, getEther } from '../../../../util/transactions';
import ErrorMessage from '../ErrorMessage';
import { strings } from '../../../../../locales/i18n';
import WarningMessage from '../WarningMessage';
import { hexToBN } from 'gaba/dist/util';
import { util } from '@metamask/controllers';
import Analytics from '../../../../core/Analytics';
import { ANALYTICS_EVENT_OPTS } from '../../../../util/analytics';

const { hexToBN } = util;
const styles = StyleSheet.create({
wrapper: {
flex: 1,
Expand Down
4 changes: 2 additions & 2 deletions app/core/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
TokenRatesController,
TransactionController,
TypedMessageManager
} from 'gaba';
} from '@metamask/controllers';

import AsyncStorage from '@react-native-community/async-storage';

Expand All @@ -34,7 +34,7 @@ const OPENSEA_API_KEY = process.env['MM_OPENSEA_KEY']; // eslint-disable-line do
const encryptor = new Encryptor();
let refreshing = false;
/**
* Core controller responsible for composing other GABA controllers together
* Core controller responsible for composing other metamask controllers together
* and exposing convenience methods for common wallet operations.
*/
class Engine {
Expand Down
2 changes: 1 addition & 1 deletion app/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import rootReducer from '../reducers';
import AppConstants from '../core/AppConstants';

const migrations = {
// Needed after https://github.com/MetaMask/gaba/pull/152
// Needed after https://github.com/MetaMask/controllers/pull/152
0: state => {
const addressBook = state.engine.backgroundState.AddressBookController.addressBook;
const migratedAddressBook = {};
Expand Down
2 changes: 1 addition & 1 deletion app/util/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { BN } from 'ethereumjs-util';
import convert from 'ethjs-unit';
import { util } from 'gaba';
import { util } from '@metamask/controllers';
import numberToBN from 'number-to-bn';
import currencySymbols from '../util/currency-symbols.json';

Expand Down
2 changes: 1 addition & 1 deletion app/util/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Engine from '../core/Engine';
import { strings } from '../../locales/i18n';
import contractMap from 'eth-contract-metadata';
import { safeToChecksumAddress } from './address';
import { util } from 'gaba';
import { util } from '@metamask/controllers';

export const TOKEN_METHOD_TRANSFER = 'transfer';
export const TOKEN_METHOD_APPROVE = 'approve';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"react-native-level-fs/**/bl": "^0.9.5"
},
"dependencies": {
"@metamask/controllers": "^2.0.0",
"@react-native-community/async-storage": "1.9.0",
"@react-native-community/clipboard": "^1.2.2",
"@react-native-community/netinfo": "4.1.5",
Expand Down Expand Up @@ -96,7 +97,6 @@
"ethjs-unit": "0.1.6",
"events": "3.0.0",
"fuse.js": "3.4.4",
"gaba": "1.11.0",
"https-browserify": "0.0.1",
"json-rpc-engine": "5.1.5",
"json-rpc-middleware-stream": "2.1.1",
Expand Down
86 changes: 43 additions & 43 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,34 @@
"@types/yargs" "^15.0.0"
chalk "^3.0.0"

"@metamask/controllers@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-2.0.0.tgz#e57762c213d2722fd178d4c5c288ad98a2ee8bdf"
integrity sha512-J2DSoyyPRAilTdohl43O5tZdqOSMvB94Kx1ApRpkPZxQwtDUIzWHRpTXptyCEwkhaOdkNz9BvWMoaRQxjktfKw==
dependencies:
await-semaphore "^0.1.3"
eth-contract-metadata "^1.11.0"
eth-ens-namehash "^2.0.8"
eth-json-rpc-errors "^2.0.2"
eth-json-rpc-infura "^4.0.1"
eth-keyring-controller "^5.6.1"
eth-method-registry "1.1.0"
eth-phishing-detect "^1.1.13"
eth-query "^2.1.2"
eth-sig-util "^2.3.0"
ethereumjs-util "^6.1.0"
ethereumjs-wallet "0.6.0"
ethjs-query "^0.3.8"
human-standard-collectible-abi "^1.0.2"
human-standard-token-abi "^2.0.0"
isomorphic-fetch "^2.2.1"
jsonschema "^1.2.4"
percentile "^1.2.1"
single-call-balance-checker-abi "^1.0.0"
uuid "^3.3.2"
web3 "^0.20.7"
web3-provider-engine "^15.0.4"

"@metamask/mobile-provider@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@metamask/mobile-provider/-/mobile-provider-1.2.0.tgz#d28f58f213ca364c9a732b867eef74301542699a"
Expand Down Expand Up @@ -4714,14 +4742,14 @@ eth-ens-namehash@^1.0.2:
idna-uts46 "^1.0.1"
js-sha3 "^0.5.7"

eth-hd-keyring@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/eth-hd-keyring/-/eth-hd-keyring-3.4.0.tgz#288e73041f2b3f047b4151fb4b5ab5ad5710b9a6"
integrity sha512-MMKSSwDWuEfItEM/826LHrs2HVjy57qQQfcgSxIYOCJY0vykw++LH8d6QJOBrGFe+xu/gtbHBRMURrFGdqfevw==
eth-hd-keyring@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/eth-hd-keyring/-/eth-hd-keyring-3.5.0.tgz#3976d83a27b24305481c389178f290d9264e839d"
integrity sha512-Ix1LcWYxHMxCCSIMz+TLXLtt50zF6ZDd/TRVXthdw91IwOk1ajuf7QHg3bCDcfeUpdf9oEpwIPbL3xjDqEEjYw==
dependencies:
bip39 "^2.2.0"
eth-sig-util "^2.4.4"
eth-simple-keyring "^3.4.0"
eth-simple-keyring "^3.5.0"
ethereumjs-abi "^0.6.5"
ethereumjs-util "^5.1.1"
ethereumjs-wallet "^0.6.0"
Expand Down Expand Up @@ -4802,17 +4830,17 @@ eth-json-rpc-middleware@4.3.0, eth-json-rpc-middleware@^4.0.0, eth-json-rpc-midd
pify "^3.0.0"
safe-event-emitter "^1.0.1"

eth-keyring-controller@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-5.3.0.tgz#8d85a67b894360ab7d601222ca71df8ed5f456c6"
integrity sha512-aoqYjKUbdOSgS1s63IsTp69QAMtLPTCqR4VAbCULps71o3yuaA9JRx2W+GAxqVNBtIdyZllxoOJlvErkO4iWNw==
eth-keyring-controller@^5.6.1:
version "5.6.1"
resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-5.6.1.tgz#7b7268400704c8f5ce98a055910341177dd207ca"
integrity sha512-sxJ87bJg7PvvPzj1sY1jJYHQL1HVUhh84Q/a4QPrcnzAAng1yibvvUfww0pCez4XJfHuMkJvUxfF8eAusJM8fQ==
dependencies:
bip39 "^2.4.0"
bluebird "^3.5.0"
browser-passworder "^2.0.3"
eth-hd-keyring "^3.4.0"
eth-hd-keyring "^3.5.0"
eth-sig-util "^1.4.0"
eth-simple-keyring "^3.4.0"
eth-simple-keyring "^3.5.0"
ethereumjs-util "^5.1.2"
loglevel "^1.5.0"
obs-store "^4.0.3"
Expand Down Expand Up @@ -4859,10 +4887,10 @@ eth-sig-util@^2.3.0, eth-sig-util@^2.4.4, eth-sig-util@^2.5.0:
tweetnacl "^1.0.0"
tweetnacl-util "^0.15.0"

eth-simple-keyring@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/eth-simple-keyring/-/eth-simple-keyring-3.4.0.tgz#01464234b070af42a343a3c451dd58b00ae1a042"
integrity sha512-g/ObWqWaTHikrhhm7fNinpkkpEPqBRz02oBXcH81mc3VFkOLb3pjfvNg1Da6Jh+A4wA0kBE4vkiiG7BUwF1zNg==
eth-simple-keyring@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/eth-simple-keyring/-/eth-simple-keyring-3.5.0.tgz#c7fa285ca58d31ef44bc7db678b689f9ffd7b453"
integrity sha512-z9IPt9aoMWAw5Zc3Jk/HKbWPJNc7ivZ5ECNtl3ZoQUGRnwoWO71W5+liVPJtXFNacGOOGsBfqTqrXL9C4EnYYQ==
dependencies:
eth-sig-util "^2.5.0"
ethereumjs-abi "^0.6.5"
Expand Down Expand Up @@ -5877,34 +5905,6 @@ g-status@^2.0.2:
matcher "^1.0.0"
simple-git "^1.85.0"

gaba@1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/gaba/-/gaba-1.11.0.tgz#7ff49cad2f2b95941222121a1984bb63783fe076"
integrity sha512-rQcLgR/FHQ8W6oNza/vxFnkbav0vgauBxm6LKqK6BkbjJGB979qoBRVja9fU/H5dUMiYmHJO9CrHjL0ofG/ukA==
dependencies:
await-semaphore "^0.1.3"
eth-contract-metadata "^1.11.0"
eth-ens-namehash "^2.0.8"
eth-json-rpc-errors "^2.0.2"
eth-json-rpc-infura "^4.0.1"
eth-keyring-controller "^5.3.0"
eth-method-registry "1.1.0"
eth-phishing-detect "^1.1.13"
eth-query "^2.1.2"
eth-sig-util "^2.3.0"
ethereumjs-util "^6.1.0"
ethereumjs-wallet "0.6.0"
ethjs-query "^0.3.8"
human-standard-collectible-abi "^1.0.2"
human-standard-token-abi "^2.0.0"
isomorphic-fetch "^2.2.1"
jsonschema "^1.2.4"
percentile "^1.2.1"
single-call-balance-checker-abi "^1.0.0"
uuid "^3.3.2"
web3 "^0.20.7"
web3-provider-engine "^15.0.4"

gauge@~2.7.3:
version "2.7.4"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
Expand Down