Skip to content

Commit

Permalink
fix tests; restore inpage _metamask.isApproved
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed Oct 25, 2019
1 parent a28d839 commit ea3d6be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/scripts/inpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const getPublicConfigWhenReady = async () => {

// add metamask-specific convenience methods
inpageProvider._metamask = new Proxy({

/**
* Determines if MetaMask is unlocked by the user
*
Expand All @@ -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<boolean>} - 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 ' +
Expand Down
5 changes: 4 additions & 1 deletion test/unit/app/controllers/transactions/tx-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Transaction Controller', function () {
ethTx.sign(fromAccount.key)
resolve()
}),
getPermittedAccounts: () => {},
})
txController.nonceTracker.getNonceLock = () => Promise.resolve({ nextNonce: 0, releaseLock: noop })
})
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ea3d6be

Please sign in to comment.