From ea3d6bee896422fb376548a3cbf172a4d86e6306 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Fri, 25 Oct 2019 15:31:17 -0700 Subject: [PATCH] fix tests; restore inpage _metamask.isApproved --- app/scripts/inpage.js | 11 +++++++++++ .../controllers/transactions/tx-controller-test.js | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 8b55a1772c59..5925e193ed2b 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -77,6 +77,7 @@ const getPublicConfigWhenReady = async () => { // add metamask-specific convenience methods inpageProvider._metamask = new Proxy({ + /** * Determines if MetaMask is unlocked by the user * @@ -86,6 +87,16 @@ inpageProvider._metamask = new Proxy({ const { isUnlocked } = await getPublicConfigWhenReady() return Boolean(isUnlocked) }, + + /** + * WILL BE DEPRECATED. + * Asynchronously determines if this domain is currently enabled. + * + * @returns {Promise} - Promise resolving to true if this domain is currently enabled + */ + isApproved: async function () { + return Boolean(inpageProvider.selectedAddress) + }, }, { get: function (obj, prop) { !warned && console.warn('Heads up! ethereum._metamask exposes methods that have ' + diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 9072dc684caf..d1926657c621 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -46,6 +46,7 @@ describe('Transaction Controller', function () { ethTx.sign(fromAccount.key) resolve() }), + getPermittedAccounts: () => {}, }) txController.nonceTracker.getNonceLock = () => Promise.resolve({ nextNonce: 0, releaseLock: noop }) }) @@ -171,13 +172,15 @@ describe('Transaction Controller', function () { describe('#addUnapprovedTransaction', function () { const selectedAddress = '0x1678a085c290ebd122dc42cba69373b5953b831d' - let getSelectedAddress + let getSelectedAddress, getPermittedAccounts beforeEach(function () { getSelectedAddress = sinon.stub(txController, 'getSelectedAddress').returns(selectedAddress) + getPermittedAccounts = sinon.stub(txController, 'getPermittedAccounts').returns([selectedAddress]) }) afterEach(function () { getSelectedAddress.restore() + getPermittedAccounts.restore() }) it('should add an unapproved transaction and return a valid txMeta', function (done) {