diff --git a/app/scripts/background.js b/app/scripts/background.js index af9fbed2f..bba1acc4e 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -16,8 +16,7 @@ import pump from 'pump' import debounce from 'debounce-stream' import log from 'loglevel' import extension from 'extensionizer' -import storeTransform from 'obs-store/lib/transform' -import asStream from 'obs-store/lib/asStream' +import { storeAsStream, storeTransformStream } from '@metamask/obs-store' import PortStream from 'extension-port-stream' import { captureException } from '@sentry/browser' import migrations from './migrations' @@ -250,9 +249,9 @@ function setupController(initState, initLangCode) { // setup state persistence pump( - asStream(controller.store), + storeAsStream(controller.store), debounce(1000), - storeTransform(versionifyData), + storeTransformStream(versionifyData), createStreamSink(persistData), (error) => { log.error('MetaMask - Persistence pipeline failed', error) diff --git a/app/scripts/controllers/alert.js b/app/scripts/controllers/alert.js index 4dc215f35..a58276d88 100644 --- a/app/scripts/controllers/alert.js +++ b/app/scripts/controllers/alert.js @@ -1,4 +1,4 @@ -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import { TOGGLEABLE_ALERT_TYPES, WEB3_SHIM_USAGE_ALERT_STATES, diff --git a/app/scripts/controllers/app-state.js b/app/scripts/controllers/app-state.js index 738a0ef85..207ce96e4 100644 --- a/app/scripts/controllers/app-state.js +++ b/app/scripts/controllers/app-state.js @@ -1,5 +1,5 @@ import EventEmitter from 'events' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' export default class AppStateController extends EventEmitter { /** diff --git a/app/scripts/controllers/cached-balances.js b/app/scripts/controllers/cached-balances.js index 6e7e4eace..16ef40e88 100644 --- a/app/scripts/controllers/cached-balances.js +++ b/app/scripts/controllers/cached-balances.js @@ -1,4 +1,4 @@ -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' /** * @typedef {Object} CachedBalancesOptions diff --git a/app/scripts/controllers/ens/index.js b/app/scripts/controllers/ens/index.js index 766aeeb88..08647b12f 100644 --- a/app/scripts/controllers/ens/index.js +++ b/app/scripts/controllers/ens/index.js @@ -1,6 +1,6 @@ import punycode from 'punycode/punycode' import ethUtil from 'ethereumjs-util' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import Ens from './ens' diff --git a/app/scripts/controllers/incoming-transactions.js b/app/scripts/controllers/incoming-transactions.js index 3cb942826..58a059dd2 100644 --- a/app/scripts/controllers/incoming-transactions.js +++ b/app/scripts/controllers/incoming-transactions.js @@ -1,4 +1,4 @@ -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import BN from 'bn.js' import createId from '../lib/random-id' diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index 23e6dfcf2..c995ea491 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -1,5 +1,5 @@ import { merge, omit } from 'lodash' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import { bufferToHex, sha3 } from 'ethereumjs-util' import { ENVIRONMENT_TYPE_BACKGROUND } from '../lib/enums' import { diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 9dc605cf2..dc7b4a648 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -1,7 +1,6 @@ import assert from 'assert' import EventEmitter from 'events' -import ObservableStore from 'obs-store' -import ComposedStore from 'obs-store/lib/composed' +import { ComposedStore, ObservableStore } from '@metamask/obs-store' import { JsonRpcEngine } from 'json-rpc-engine' import providerFromEngine from 'eth-json-rpc-middleware/providerFromEngine' import log from 'loglevel' diff --git a/app/scripts/controllers/onboarding.js b/app/scripts/controllers/onboarding.js index 71424a1e4..011edbfc3 100644 --- a/app/scripts/controllers/onboarding.js +++ b/app/scripts/controllers/onboarding.js @@ -1,4 +1,4 @@ -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' /** diff --git a/app/scripts/controllers/permissions/index.js b/app/scripts/controllers/permissions/index.js index b9d4ddd47..c4ffd14fb 100644 --- a/app/scripts/controllers/permissions/index.js +++ b/app/scripts/controllers/permissions/index.js @@ -1,6 +1,6 @@ import nanoid from 'nanoid' import { JsonRpcEngine } from 'json-rpc-engine' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import { CapabilitiesController as RpcCap } from 'rpc-cap' import { ethErrors } from 'eth-json-rpc-errors' diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 12da861f6..7445be65b 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -1,5 +1,5 @@ import { strict as assert } from 'assert' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import { ethErrors } from 'eth-json-rpc-errors' import { normalize as normalizeAddress } from 'eth-sig-util' import { isValidAddress } from 'ethereumjs-util' diff --git a/app/scripts/controllers/swaps.js b/app/scripts/controllers/swaps.js index e230b8d63..0f599bb07 100644 --- a/app/scripts/controllers/swaps.js +++ b/app/scripts/controllers/swaps.js @@ -1,7 +1,7 @@ import { ethers } from 'ethers' import log from 'loglevel' import BigNumber from 'bignumber.js' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import { mapValues, cloneDeep } from 'lodash' import abi from 'human-standard-token-abi' import { calcTokenAmount } from '../../../ui/app/helpers/utils/token-util' diff --git a/app/scripts/controllers/threebox.js b/app/scripts/controllers/threebox.js index ec73e2651..d7503b589 100644 --- a/app/scripts/controllers/threebox.js +++ b/app/scripts/controllers/threebox.js @@ -1,4 +1,4 @@ -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' /* eslint-disable import/first,import/order */ const Box = process.env.IN_TEST diff --git a/app/scripts/controllers/token-rates.js b/app/scripts/controllers/token-rates.js index b943c540f..9011b1d01 100644 --- a/app/scripts/controllers/token-rates.js +++ b/app/scripts/controllers/token-rates.js @@ -1,4 +1,4 @@ -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import { normalize as normalizeAddress } from 'eth-sig-util' import ethUtil from 'ethereumjs-util' diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 4a4488fc1..670fce56f 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -1,5 +1,5 @@ import EventEmitter from 'safe-event-emitter' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import Transaction from 'ethereumjs-tx' import EthQuery from 'ethjs-query' diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index 456a1db98..0c94bd270 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -1,5 +1,5 @@ import EventEmitter from 'safe-event-emitter' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import createId from '../../lib/random-id' import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction' diff --git a/app/scripts/lib/ComposableObservableStore.js b/app/scripts/lib/ComposableObservableStore.js index a943b31b1..3661259bd 100644 --- a/app/scripts/lib/ComposableObservableStore.js +++ b/app/scripts/lib/ComposableObservableStore.js @@ -1,4 +1,4 @@ -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' /** * An ObservableStore that can composes a flat diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js index a22d56760..850c39291 100644 --- a/app/scripts/lib/account-tracker.js +++ b/app/scripts/lib/account-tracker.js @@ -9,7 +9,7 @@ import EthQuery from 'eth-query' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import log from 'loglevel' import pify from 'pify' import Web3 from 'web3' diff --git a/app/scripts/lib/decrypt-message-manager.js b/app/scripts/lib/decrypt-message-manager.js index dc73b80f8..fc8ce03ce 100644 --- a/app/scripts/lib/decrypt-message-manager.js +++ b/app/scripts/lib/decrypt-message-manager.js @@ -1,5 +1,5 @@ import EventEmitter from 'events' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import log from 'loglevel' diff --git a/app/scripts/lib/encryption-public-key-manager.js b/app/scripts/lib/encryption-public-key-manager.js index 5079c8be1..d563cae0b 100644 --- a/app/scripts/lib/encryption-public-key-manager.js +++ b/app/scripts/lib/encryption-public-key-manager.js @@ -1,5 +1,5 @@ import EventEmitter from 'events' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import { ethErrors } from 'eth-json-rpc-errors' import log from 'loglevel' import createId from './random-id' diff --git a/app/scripts/lib/message-manager.js b/app/scripts/lib/message-manager.js index 6f6a208e2..872f97b0d 100644 --- a/app/scripts/lib/message-manager.js +++ b/app/scripts/lib/message-manager.js @@ -1,5 +1,5 @@ import EventEmitter from 'events' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import createId from './random-id' diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index 4e8b66de7..52d20588f 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -1,5 +1,5 @@ import EventEmitter from 'events' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import ethUtil from 'ethereumjs-util' import { ethErrors } from 'eth-json-rpc-errors' import log from 'loglevel' diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js index c4f5fd54a..6bcfe846b 100644 --- a/app/scripts/lib/typed-message-manager.js +++ b/app/scripts/lib/typed-message-manager.js @@ -1,6 +1,6 @@ import EventEmitter from 'events' import assert from 'assert' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import { ethErrors } from 'eth-json-rpc-errors' import { typedSignatureHash, TYPED_MESSAGE_SCHEMA } from 'eth-sig-util' import { isValidAddress } from 'ethereumjs-util' diff --git a/package.json b/package.json index 540e0d262..0642a8909 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "@metamask/inpage-provider": "^8.0.1", "@metamask/jazzicon": "^2.0.0", "@metamask/logo": "^2.5.0", + "@metamask/obs-store": "^5.0.0", "@popperjs/core": "^2.4.0", "@reduxjs/toolkit": "^1.3.2", "@sentry/browser": "^5.26.0", @@ -140,7 +141,6 @@ "nanoid": "^2.1.6", "nonce-tracker": "^1.0.0", "obj-multiplex": "^1.0.0", - "obs-store": "^4.0.3", "pify": "^5.0.0", "post-message-stream": "^3.0.0", "promise-to-callback": "^1.0.0", diff --git a/test/unit/app/ComposableObservableStore.js b/test/unit/app/ComposableObservableStore.js index 961be1dc0..205e0a59b 100644 --- a/test/unit/app/ComposableObservableStore.js +++ b/test/unit/app/ComposableObservableStore.js @@ -1,5 +1,5 @@ import assert from 'assert' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import ComposableObservableStore from '../../../app/scripts/lib/ComposableObservableStore' describe('ComposableObservableStore', function () { diff --git a/test/unit/app/controllers/detect-tokens-test.js b/test/unit/app/controllers/detect-tokens-test.js index d54c55154..b7ab22ed6 100644 --- a/test/unit/app/controllers/detect-tokens-test.js +++ b/test/unit/app/controllers/detect-tokens-test.js @@ -1,6 +1,6 @@ import assert from 'assert' import sinon from 'sinon' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import contracts from '@metamask/contract-metadata' import BigNumber from 'bignumber.js' diff --git a/test/unit/app/controllers/ens-controller-test.js b/test/unit/app/controllers/ens-controller-test.js index 0fbaf33ac..dd116e69f 100644 --- a/test/unit/app/controllers/ens-controller-test.js +++ b/test/unit/app/controllers/ens-controller-test.js @@ -1,6 +1,6 @@ import assert from 'assert' import sinon from 'sinon' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import EnsController from '../../../../app/scripts/controllers/ens' const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' diff --git a/test/unit/app/controllers/permissions/permissions-log-controller-test.js b/test/unit/app/controllers/permissions/permissions-log-controller-test.js index 101f898b9..d98db8453 100644 --- a/test/unit/app/controllers/permissions/permissions-log-controller-test.js +++ b/test/unit/app/controllers/permissions/permissions-log-controller-test.js @@ -1,5 +1,5 @@ import { strict as assert } from 'assert' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import nanoid from 'nanoid' import { useFakeTimers } from 'sinon' diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 6a831c3e7..065d35782 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -1,5 +1,5 @@ import assert from 'assert' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import sinon from 'sinon' import PreferencesController from '../../../../app/scripts/controllers/preferences' diff --git a/test/unit/app/controllers/swaps-test.js b/test/unit/app/controllers/swaps-test.js index 6aa3e0476..38f948088 100644 --- a/test/unit/app/controllers/swaps-test.js +++ b/test/unit/app/controllers/swaps-test.js @@ -4,7 +4,7 @@ import sinon from 'sinon' import { ethers } from 'ethers' import { mapValues } from 'lodash' import BigNumber from 'bignumber.js' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import { ROPSTEN_NETWORK_ID, MAINNET_NETWORK_ID, diff --git a/test/unit/app/controllers/token-rates-controller.js b/test/unit/app/controllers/token-rates-controller.js index 1f342abe5..58e0009a1 100644 --- a/test/unit/app/controllers/token-rates-controller.js +++ b/test/unit/app/controllers/token-rates-controller.js @@ -1,6 +1,6 @@ import assert from 'assert' import sinon from 'sinon' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import TokenRatesController from '../../../../app/scripts/controllers/token-rates' describe('TokenRatesController', function () { diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 0e39f791d..e37c44a47 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -2,7 +2,7 @@ import { strict as assert } from 'assert' import EventEmitter from 'events' import ethUtil from 'ethereumjs-util' import EthTx from 'ethereumjs-tx' -import ObservableStore from 'obs-store' +import { ObservableStore } from '@metamask/obs-store' import sinon from 'sinon' import TransactionController from '../../../../../app/scripts/controllers/transactions' diff --git a/yarn.lock b/yarn.lock index f469feb97..0cff65506 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2145,6 +2145,15 @@ gl-mat4 "1.1.4" gl-vec3 "1.0.3" +"@metamask/obs-store@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@metamask/obs-store/-/obs-store-5.0.0.tgz#cf2213874c62186a8a4c80f0c402af62a0a877a9" + integrity sha512-9Az33hULCDVUVpBzNAdjPPgNTfs6paC38LYZv4xazt03mJt4jwWFFTP79TtF4grXfiAtUs/UZOktW4Vp+r37rw== + dependencies: + "@metamask/safe-event-emitter" "^2.0.0" + readable-stream "^2.2.2" + through2 "^2.0.3" + "@metamask/safe-event-emitter@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@metamask/safe-event-emitter/-/safe-event-emitter-2.0.0.tgz#af577b477c683fad17c619a78208cede06f9605c"