From 2df8b85c5f9bdcf99217d67cf957951985043b49 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Fri, 6 Mar 2020 13:34:56 -0800 Subject: [PATCH] LoginPerSite: Support multiple accounts without automatic switching (#8079) * transaction editing: use txParams 'from' account * signature-request: use txParams 'from' account * signature-request-original: use txParams 'from' account * encryption/decryption: use txParams 'from' account * update tests * set 'send' state 'from' address in confirm containers --- app/scripts/background.js | 12 +- app/scripts/controllers/transactions/index.js | 6 +- .../lib/encryption-public-key-manager.js | 6 +- development/states/add-token.json | 2 +- development/states/conf-tx.json | 2 +- development/states/confirm-new-ui.json | 2 +- development/states/confirm-sig-requests.json | 8 +- development/states/currency-localization.json | 2 +- development/states/first-time.json | 2 +- development/states/navigate-txs.json | 2 +- .../states/pending-tx-insufficient.json | 2 +- development/states/pending-tx.json | 2 +- development/states/personal-sign.json | 2 +- .../states/private-key-export-success.json | 2 +- development/states/private-key-export.json | 2 +- development/states/send-edit.json | 2 +- development/states/send-new-ui.json | 2 +- development/states/send.json | 2 +- development/states/tx-list-items.json | 18 ++- test/data/2-state.json | 2 +- test/data/mock-state.json | 2 +- .../transactions/tx-controller-test.js | 4 +- test/unit/ui/app/reducers/metamask.spec.js | 4 +- .../gas-modal-page-container.container.js | 4 +- ...gas-modal-page-container-container.test.js | 2 +- .../cancel-transaction.container.js | 4 +- .../signature-request-original.component.js | 16 +- .../signature-request-original.container.js | 22 +-- .../signature-request.component.js | 17 ++- .../signature-request.container.js | 23 ++- .../tests/signature-request.test.js | 4 +- .../app/tests/signature-request.test.js | 4 +- ui/app/ducks/metamask/metamask.js | 7 +- ui/app/helpers/utils/util.js | 8 + .../confirm-approve.container.js | 13 +- .../confirm-decrypt-message.component.js | 27 ++-- .../confirm-decrypt-message.container.js | 23 +-- ...confirm-encryption-public-key.component.js | 23 +-- ...confirm-encryption-public-key.container.js | 22 ++- .../confirm-send-ether.container.js | 2 + .../confirm-send-token.container.js | 15 +- ...onfirm-token-transaction-base.container.js | 10 +- ui/app/pages/confirm-transaction/conf-tx.js | 12 +- ui/app/pages/routes/index.js | 2 - .../add-recipient/add-recipient.container.js | 2 +- .../tests/add-recipient-container.test.js | 2 +- .../send-content/send-content.container.js | 2 +- .../send/send-footer/send-footer.container.js | 17 ++- ui/app/pages/send/send.container.js | 17 ++- ui/app/pages/send/send.selectors.js | 47 ++---- .../send/tests/send-selectors-test-data.js | 6 +- .../pages/send/tests/send-selectors.test.js | 134 +--------------- ui/app/selectors/selectors.js | 8 +- ui/app/selectors/tests/selectors-test-data.js | 2 +- ui/app/selectors/tests/transactions.test.js | 143 +++++++++++++++--- ui/app/selectors/transactions.js | 62 ++++++-- ui/app/store/actions.js | 16 +- ui/index.js | 10 +- 58 files changed, 456 insertions(+), 362 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 997e1461b..dbac8854f 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -122,16 +122,16 @@ initialize().catch(log.error) * @property {string} network - A stringified number of the current network ID. * @property {Object} accounts - An object mapping lower-case hex addresses to objects with "balance" and "address" keys, both storing hex string values. * @property {hex} currentBlockGasLimit - The most recently seen block gas limit, in a lower case hex prefixed string. - * @property {TransactionMeta[]} selectedAddressTxList - An array of transactions associated with the currently selected account. - * @property {Object} unapprovedMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options. + * @property {TransactionMeta[]} currentNetworkTxList - An array of transactions associated with the currently selected network. + * @property {Object} unapprovedMsgs - An object of messages pending approval, mapping a unique ID to the options. * @property {number} unapprovedMsgCount - The number of messages in unapprovedMsgs. - * @property {Object} unapprovedPersonalMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options. + * @property {Object} unapprovedPersonalMsgs - An object of messages pending approval, mapping a unique ID to the options. * @property {number} unapprovedPersonalMsgCount - The number of messages in unapprovedPersonalMsgs. - * @property {Object} EncryptionPublicKeyMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options. + * @property {Object} unapprovedEncryptionPublicKeyMsgs - An object of messages pending approval, mapping a unique ID to the options. * @property {number} unapprovedEncryptionPublicKeyMsgCount - The number of messages in EncryptionPublicKeyMsgs. - * @property {Object} unapprovedDecryptMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options. + * @property {Object} unapprovedDecryptMsgs - An object of messages pending approval, mapping a unique ID to the options. * @property {number} unapprovedDecryptMsgCount - The number of messages in unapprovedDecryptMsgs. - * @property {Object} unapprovedTypedMsgs - An object of messages associated with the currently selected account, mapping a unique ID to the options. + * @property {Object} unapprovedTypedMsgs - An object of messages pending approval, mapping a unique ID to the options. * @property {number} unapprovedTypedMsgCount - The number of messages in unapprovedTypedMsgs. * @property {string[]} keyringTypes - An array of unique keyring identifying strings, representing available strategies for creating accounts. * @property {Keyring[]} keyrings - An array of keyring descriptions, summarizing the accounts that are available for use, and what keyrings they belong to. diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 394a59613..801aa8340 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -119,7 +119,6 @@ class TransactionController extends EventEmitter { this._onBootCleanUp() this._updateMemstore() }) - this.preferencesStore.subscribe(() => this._updateMemstore()) // request state update to finalize initialization this._updatePendingTxsAfterFirstBlock() @@ -748,11 +747,10 @@ class TransactionController extends EventEmitter { _updateMemstore () { this.pendingTxTracker.updatePendingTxs() const unapprovedTxs = this.txStateManager.getUnapprovedTxList() - const selectedAddressTxList = this.txStateManager.getFilteredTxList({ - from: this.getSelectedAddress(), + const currentNetworkTxList = this.txStateManager.getFilteredTxList({ metamaskNetworkId: this.getNetwork(), }) - this.memStore.updateState({ unapprovedTxs, selectedAddressTxList }) + this.memStore.updateState({ unapprovedTxs, currentNetworkTxList }) } } diff --git a/app/scripts/lib/encryption-public-key-manager.js b/app/scripts/lib/encryption-public-key-manager.js index 4667330ed..4055104c0 100644 --- a/app/scripts/lib/encryption-public-key-manager.js +++ b/app/scripts/lib/encryption-public-key-manager.js @@ -104,7 +104,7 @@ export default class EncryptionPublicKeyManager extends EventEmitter { * @returns {number} The id of the newly created EncryptionPublicKey. * */ - addUnapprovedMessage (address, _req) { + addUnapprovedMessage (address, req) { log.debug(`EncryptionPublicKeyManager addUnapprovedMessage: address`) // create txData obj with parameters and meta data const time = (new Date()).getTime() @@ -117,8 +117,8 @@ export default class EncryptionPublicKeyManager extends EventEmitter { type: 'eth_getEncryptionPublicKey', } - if (_req) { - msgData.origin = _req.origin + if (req) { + msgData.origin = req.origin } this.addMsg(msgData) diff --git a/development/states/add-token.json b/development/states/add-token.json index 7ac344d13..32e3dc381 100644 --- a/development/states/add-token.json +++ b/development/states/add-token.json @@ -62,7 +62,7 @@ ], "tokens": [], "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/development/states/conf-tx.json b/development/states/conf-tx.json index b47db9e80..4eae66b46 100644 --- a/development/states/conf-tx.json +++ b/development/states/conf-tx.json @@ -92,7 +92,7 @@ } }, "transactions": {}, - "selectedAddressTxList": [ + "currentNetworkTxList": [ { "id": 3870222542191014, "time": 1487271497135, diff --git a/development/states/confirm-new-ui.json b/development/states/confirm-new-ui.json index b7c1f3fcb..4a9a78440 100644 --- a/development/states/confirm-new-ui.json +++ b/development/states/confirm-new-ui.json @@ -61,7 +61,7 @@ ], "tokens": [], "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedTxs": { "4768706228115573": { "id": 4768706228115573, diff --git a/development/states/confirm-sig-requests.json b/development/states/confirm-sig-requests.json index a0f4cd470..d99b9e1ca 100644 --- a/development/states/confirm-sig-requests.json +++ b/development/states/confirm-sig-requests.json @@ -67,14 +67,14 @@ "tokens": [], "transactions": {}, "incomingTransactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedTxs": {}, "unapprovedMsgs": { "8927167822566864": { "id": 8927167822566864, "msgParams": { "data": "0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0", - "from": "0x0d0c7188d9c72b019a5da9bca0d127680c22e658" + "from": "0xd85a4b6a394794842887b8284293d69163007bbb" }, "status": "unapproved", "time": 1537889070000, @@ -87,7 +87,7 @@ "id": 8907167822566865, "msgParams": { "data": "0x23205465726d73206f662055736520230a0a2a2a544849532041475245454d454e54204953205355424a45435420544f2042494e44494e47204152424954524154494f4e20414e44204120574149564552204f4620434c41535320414354494f4e205249474854532041532044455441494c454420494e2053454354494f4e2031332e20504c454153452052454144205448452041475245454d454e54204341524546554c4c592e2a2a0a0a5f4f7572205465726d73206f66205573652068617665206265656e2075706461746564206173206f662053657074656d62657220352c20323031365f0a0a232320312e20416363657074616e6365206f66205465726d732023230a0a4d6574614d61736b2070726f7669646573206120706c6174666f726d20666f72206d616e6167696e6720457468657265756d20286f7220224554482229206163636f756e74732c20616e6420616c6c6f77696e67206f7264696e61727920776562736974657320746f20696e74657261637420776974682074686520457468657265756d20626c6f636b636861696e2c207768696c65206b656570696e6720746865207573657220696e20636f6e74726f6c206f7665722077686174207472616e73616374696f6e73207468657920617070726f76652c207468726f756768206f75722077656273697465206c6f63617465642061745b205d28687474703a2f2f6d6574616d61736b2e696f295b68747470733a2f2f6d6574616d61736b2e696f2f5d2868747470733a2f2f6d6574616d61736b2e696f2f2920616e642062726f7773657220706c7567696e2028746865202253697465222920e2809420776869636820696e636c7564657320746578742c20696d616765732c20617564696f2c20636f646520616e64206f74686572206d6174657269616c73202028636f6c6c6563746976656c792c2074686520e2809c436f6e74656e74e2809d2920616e6420616c6c206f66207468652066656174757265732c20616e642073657276696365732070726f76696465642e2054686520536974652c20616e6420616e79206f746865722066656174757265732c20746f6f6c732c206d6174657269616c732c206f72206f74686572207365727669636573206f6666657265642066726f6d2074696d6520746f2074696d65206279204d6574614d61736b2061726520726566657272656420746f20686572652061732074686520e2809c536572766963652ee2809d20506c656173652072656164207468657365205465726d73206f6620557365202874686520e2809c5465726d73e2809d206f7220e2809c5465726d73206f6620557365e2809d29206361726566756c6c79206265666f7265207573696e672074686520536572766963652e204279207573696e67206f72206f746865727769736520616363657373696e67207468652053657276696365732c206f7220636c69636b696e6720746f20616363657074206f7220616772656520746f207468657365205465726d732077686572652074686174206f7074696f6e206973206d61646520617661696c61626c652c20796f75202831292061636365707420616e6420616772656520746f207468657365205465726d732028322920636f6e73656e7420746f2074686520636f6c6c656374696f6e2c207573652c20646973636c6f7375726520616e64206f746865722068616e646c696e67206f6620696e666f726d6174696f6e2061732064657363726962656420696e206f7572205072697661637920506f6c6963792020616e642028332920616e79206164646974696f6e616c207465726d732c2072756c657320616e6420636f6e646974696f6e73206f662070617274696369706174696f6e20697373756564206279204d6574614d61736b2066726f6d2074696d6520746f2074696d652e20496620796f7520646f206e6f7420616772656520746f20746865205465726d732c207468656e20796f75206d6179206e6f7420616363657373206f72207573652074686520436f6e74656e74206f722053657276696365732e0a0a232320322e204d6f64696669636174696f6e206f66205465726d73206f66205573652023230a0a45786365707420666f722053656374696f6e2031332c2070726f766964696e6720666f722062696e64696e67206172626974726174696f6e20616e6420776169766572206f6620636c61737320616374696f6e207269676874732c204d6574614d61736b207265736572766573207468652072696768742c2061742069747320736f6c652064697363726574696f6e2c20746f206d6f64696679206f72207265706c61636520746865205465726d73206f662055736520617420616e792074696d652e20546865206d6f73742063757272656e742076657273696f6e206f66207468657365205465726d732077696c6c20626520706f73746564206f6e206f757220536974652e20596f75207368616c6c20626520726573706f6e7369626c6520666f7220726576696577696e6720616e64206265636f6d696e672066616d696c696172207769746820616e792073756368206d6f64696669636174696f6e732e20557365206f662074686520536572766963657320627920796f7520616674657220616e79206d6f64696669636174696f6e20746f20746865205465726d7320636f6e737469747574657320796f757220616363657074616e6365206f6620746865205465726d73206f6620557365206173206d6f6469666965642e0a0a0a0a232320332e20456c69676962696c6974792023230a0a596f752068657265627920726570726573656e7420616e642077617272616e74207468617420796f75206172652066756c6c792061626c6520616e6420636f6d706574656e7420746f20656e74657220696e746f20746865207465726d732c20636f6e646974696f6e732c206f626c69676174696f6e732c2061666669726d6174696f6e732c20726570726573656e746174696f6e7320616e642077617272616e746965732073657420666f72746820696e207468657365205465726d7320616e6420746f20616269646520627920616e6420636f6d706c792077697468207468657365205465726d732e0a0a4d6574614d61736b206973206120676c6f62616c20706c6174666f726d20616e6420627920616363657373696e672074686520436f6e74656e74206f722053657276696365732c20796f752061726520726570726573656e74696e6720616e642077617272616e74696e6720746861742c20796f7520617265206f6620746865206c6567616c20616765206f66206d616a6f7269747920696e20796f7572206a7572697364696374696f6e20617320697320726571756972656420746f20616363657373207375636820536572766963657320616e6420436f6e74656e…16e79206368616e67657320746f20746869732073656374696f6e2e204368616e6765732077696c6c206265636f6d6520656666656374697665206f6e207468652036307468206461792c20616e642077696c6c206170706c792070726f73706563746976656c79206f6e6c7920746f20616e7920636c61696d732061726973696e67206166746572207468652036307468206461792e0a0a466f7220616e792064697370757465206e6f74207375626a65637420746f206172626974726174696f6e20796f7520616e64204d6574614d61736b20616772656520746f207375626d697420746f2074686520706572736f6e616c20616e64206578636c7573697665206a7572697364696374696f6e206f6620616e642076656e756520696e20746865206665646572616c20616e6420737461746520636f75727473206c6f636174656420696e204e657720596f726b2c204e657720596f726b2e20596f75206675727468657220616772656520746f206163636570742073657276696365206f662070726f63657373206279206d61696c2c20616e642068657265627920776169766520616e7920616e6420616c6c206a7572697364696374696f6e616c20616e642076656e756520646566656e736573206f746865727769736520617661696c61626c652e0a0a546865205465726d7320616e64207468652072656c6174696f6e73686970206265747765656e20796f7520616e64204d6574614d61736b207368616c6c20626520676f7665726e656420627920746865206c617773206f6620746865205374617465206f66204e657720596f726b20776974686f75742072656761726420746f20636f6e666c696374206f66206c61772070726f766973696f6e732e0a0a23232031342e2047656e6572616c20496e666f726d6174696f6e2023230a0a2323232031342e3120456e746972652041677265656d656e74202323230a0a5468657365205465726d732028616e6420616e79206164646974696f6e616c207465726d732c2072756c657320616e6420636f6e646974696f6e73206f662070617274696369706174696f6e2074686174204d6574614d61736b206d617920706f7374206f6e2074686520536572766963652920636f6e737469747574652074686520656e746972652061677265656d656e74206265747765656e20796f7520616e64204d6574614d61736b2077697468207265737065637420746f20746865205365727669636520616e64207375706572736564657320616e79207072696f722061677265656d656e74732c206f72616c206f72207772697474656e2c206265747765656e20796f7520616e64204d6574614d61736b2e20496e20746865206576656e74206f66206120636f6e666c696374206265747765656e207468657365205465726d7320616e6420746865206164646974696f6e616c207465726d732c2072756c657320616e6420636f6e646974696f6e73206f662070617274696369706174696f6e2c20746865206c61747465722077696c6c207072657661696c206f76657220746865205465726d7320746f2074686520657874656e74206f662074686520636f6e666c6963742e0a0a2323232031342e322057616976657220616e642053657665726162696c697479206f66205465726d73202323230a0a546865206661696c757265206f66204d6574614d61736b20746f206578657263697365206f7220656e666f72636520616e79207269676874206f722070726f766973696f6e206f6620746865205465726d73207368616c6c206e6f7420636f6e73746974757465206120776169766572206f662073756368207269676874206f722070726f766973696f6e2e20496620616e792070726f766973696f6e206f6620746865205465726d7320697320666f756e6420627920616e2061726269747261746f72206f7220636f757274206f6620636f6d706574656e74206a7572697364696374696f6e20746f20626520696e76616c69642c207468652070617274696573206e657665727468656c6573732061677265652074686174207468652061726269747261746f72206f7220636f7572742073686f756c6420656e646561766f7220746f20676976652065666665637420746f2074686520706172746965732720696e74656e74696f6e73206173207265666c656374656420696e207468652070726f766973696f6e2c20616e6420746865206f746865722070726f766973696f6e73206f6620746865205465726d732072656d61696e20696e2066756c6c20666f72636520616e64206566666563742e0a0a2323232031342e332053746174757465206f66204c696d69746174696f6e73202323230a0a596f752061677265652074686174207265676172646c657373206f6620616e792073746174757465206f72206c617720746f2074686520636f6e74726172792c20616e7920636c61696d206f72206361757365206f6620616374696f6e2061726973696e67206f7574206f66206f722072656c6174656420746f2074686520757365206f66207468652053657276696365206f7220746865205465726d73206d7573742062652066696c65642077697468696e206f6e65202831292079656172206166746572207375636820636c61696d206f72206361757365206f6620616374696f6e2061726f7365206f7220626520666f7265766572206261727265642e0a0a2323232031342e342053656374696f6e205469746c6573202323230a0a5468652073656374696f6e207469746c657320696e20746865205465726d732061726520666f7220636f6e76656e69656e6365206f6e6c7920616e642068617665206e6f206c6567616c206f7220636f6e747261637475616c206566666563742e0a0a2323232031342e3520436f6d6d756e69636174696f6e73202323230a0a55736572732077697468207175657374696f6e732c20636f6d706c61696e7473206f7220636c61696d732077697468207265737065637420746f207468652053657276696365206d617920636f6e74616374207573207573696e67207468652072656c6576616e7420636f6e7461637420696e666f726d6174696f6e2073657420666f7274682061626f766520616e6420617420636f6d6d756e69636174696f6e73406d6574616d61736b2e696f2e0a0a23232031352052656c61746564204c696e6b732023230a0a2a2a5b5465726d73206f66205573655d2868747470733a2f2f6d6574616d61736b2e696f2f7465726d732e68746d6c292a2a0a0a2a2a5b507269766163795d2868747470733a2f2f6d6574616d61736b2e696f2f707269766163792e68746d6c292a2a0a0a2a2a5b4174747269627574696f6e735d2868747470733a2f2f6d6574616d61736b2e696f2f6174747269627574696f6e732e68746d6c292a2a0a", - "from": "0x0d0c7188d9c72b019a5da9bca0d127680c22e659" + "from": "0xd85a4b6a394794842887b8284293d69163007bbb" }, "status": "unapproved", "time": 1537889065000, @@ -103,7 +103,7 @@ {"type": "string", "name": "Message", "value": "Hi, Alice!"}, {"type": "uint32", "name": "A number", "value": "1337"} ], - "from": "0x0d0c7188d9c72b019a5da9bca0d127680c22e659" + "from": "0xd85a4b6a394794842887b8284293d69163007bbb" }, "status": "unapproved", "time": 1537889060000, diff --git a/development/states/currency-localization.json b/development/states/currency-localization.json index 263ef89c5..dbcc01f7c 100644 --- a/development/states/currency-localization.json +++ b/development/states/currency-localization.json @@ -68,7 +68,7 @@ "tokens": [], "transactions": {}, "incomingTransactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/development/states/first-time.json b/development/states/first-time.json index 4a77bfbe5..a9d76c545 100644 --- a/development/states/first-time.json +++ b/development/states/first-time.json @@ -20,7 +20,7 @@ "network": "3", "accounts": {}, "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "keyringTypes": [ diff --git a/development/states/navigate-txs.json b/development/states/navigate-txs.json index 88b44bbf8..829b07fad 100644 --- a/development/states/navigate-txs.json +++ b/development/states/navigate-txs.json @@ -169,7 +169,7 @@ } }, "currentBlockGasLimit": "0x731e25", - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/development/states/pending-tx-insufficient.json b/development/states/pending-tx-insufficient.json index feadbc9c0..0b30c9c3a 100644 --- a/development/states/pending-tx-insufficient.json +++ b/development/states/pending-tx-insufficient.json @@ -44,7 +44,7 @@ } }, "transactions": {}, - "selectedAddressTxList": [ + "currentNetworkTxList": [ { "id": 1188547363326880, "time": 1487662234127, diff --git a/development/states/pending-tx.json b/development/states/pending-tx.json index f97bf3d43..2e85187ba 100644 --- a/development/states/pending-tx.json +++ b/development/states/pending-tx.json @@ -31,7 +31,7 @@ } }, "currentBlockGasLimit": "0x66df83", - "selectedAddressTxList": [ + "currentNetworkTxList": [ { "id": 3516145537630216, "time": 1512615655535, diff --git a/development/states/personal-sign.json b/development/states/personal-sign.json index 1017514a0..f0862d8de 100644 --- a/development/states/personal-sign.json +++ b/development/states/personal-sign.json @@ -43,7 +43,7 @@ } }, "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": { diff --git a/development/states/private-key-export-success.json b/development/states/private-key-export-success.json index 8f38895dd..166615d24 100644 --- a/development/states/private-key-export-success.json +++ b/development/states/private-key-export-success.json @@ -23,7 +23,7 @@ } }, "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/development/states/private-key-export.json b/development/states/private-key-export.json index d41bfc2a2..ee043fe9f 100644 --- a/development/states/private-key-export.json +++ b/development/states/private-key-export.json @@ -23,7 +23,7 @@ } }, "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/development/states/send-edit.json b/development/states/send-edit.json index a527c9fde..eb18b2fcd 100644 --- a/development/states/send-edit.json +++ b/development/states/send-edit.json @@ -64,7 +64,7 @@ ], "tokens": [], "transactions": {}, - "selectedAddressTxList": [{ + "currentNetworkTxList": [{ "id": 4768706228115573, "time": 1487363153561, "status": "unapproved", diff --git a/development/states/send-new-ui.json b/development/states/send-new-ui.json index 350aaab8b..ac7e781e6 100644 --- a/development/states/send-new-ui.json +++ b/development/states/send-new-ui.json @@ -66,7 +66,7 @@ "assetImages": {}, "tokens": [], "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/development/states/send.json b/development/states/send.json index bc1fb9034..cdc373def 100644 --- a/development/states/send.json +++ b/development/states/send.json @@ -55,7 +55,7 @@ } }, "transactions": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/development/states/tx-list-items.json b/development/states/tx-list-items.json index f13aab769..816bb0a7f 100644 --- a/development/states/tx-list-items.json +++ b/development/states/tx-list-items.json @@ -3,7 +3,9 @@ "completedOnboarding": true, "isInitialized": true, "isUnlocked": true, - "featureFlags": {"betaUI": true}, + "featureFlags": { + "betaUI": true + }, "rpcTarget": "https://rawtestrpc.metamask.io/", "identities": { "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": { @@ -68,7 +70,7 @@ "tokens": [], "transactions": {}, "incomingTransactions": {}, - "selectedAddressTxList": [ + "currentNetworkTxList": [ { "err": { "message": "Error: intrinsic gas too low", @@ -226,7 +228,7 @@ "time": 1522378334455, "txParams": { "chainId": "0x3", - "from": "0x5b1cbd5636d484bf1cb6927a9425db9e7dc73ce4", + "from": "0xd85a4b6a394794842887b8284293d69163007bbb", "gas": "0x0", "gasPrice": "0x77359400", "nonce": "0x3", @@ -241,7 +243,7 @@ "metamaskNetworkId": "1", "loadingDefaults": false, "txParams": { - "from": "0x5b1cbd5636d484bf1cb6927a9425db9e7dc73ce4", + "from": "0xd85a4b6a394794842887b8284293d69163007bbb", "to": "0xf45d68f31b3c9ac84ff0d07b86c59b753a60b1e3", "value": "0x0", "gas": "0x0", @@ -506,7 +508,7 @@ "txParams": { "chainId": "0x3", "data": "0xa9059cbb000000000000000000000000e7884118ee52ec3f4eef715cb022279d7d4181a9000000000000000000000000000000000000000000000000000000000000000b", - "from": "0x5b1cbd5636d484bf1cb6927a9425db9e7dc73ce4", + "from": "0xd85a4b6a394794842887b8284293d69163007bbb", "gas": "0xd3e1", "gasPrice": "0x5f5e100", "nonce": "0x6", @@ -714,7 +716,7 @@ "txParams": { "chainId": "0x3", "data": "0xa9059cbb000000000000000000000000e7884118ee52ec3f4eef715cb022279d7d4181a9000000000000000000000000000000000000000000000000000000000000000b", - "from": "0x5b1cbd5636d484bf1cb6927a9425db9e7dc73ce4", + "from": "0xd85a4b6a394794842887b8284293d69163007bbb", "gas": "0xd3e1", "gasPrice": "0x5f5e100", "nonce": "0x2", @@ -729,7 +731,7 @@ "metamaskNetworkId": "1", "loadingDefaults": false, "txParams": { - "from": "0x5b1cbd5636d484bf1cb6927a9425db9e7dc73ce4", + "from": "0xd85a4b6a394794842887b8284293d69163007bbb", "to": "0xf45d68f31b3c9ac84ff0d07b86c59b753a60b1e3", "value": "0x0", "gas": "0xcf08", @@ -908,7 +910,7 @@ "metamaskNetworkId": "1", "loadingDefaults": false, "txParams": { - "from": "0x5b1cbd5636d484bf1cb6927a9425db9e7dc73ce4", + "from": "0xd85a4b6a394794842887b8284293d69163007bbb", "to": "0xf45d68f31b3c9ac84ff0d07b86c59b753a60b1e3", "value": "0x0", "gas": "0xcf08", diff --git a/test/data/2-state.json b/test/data/2-state.json index 8100b7e03..3173c902f 100644 --- a/test/data/2-state.json +++ b/test/data/2-state.json @@ -13,7 +13,7 @@ }, "currentBlockGasLimit": "", "unapprovedTxs": {}, - "selectedAddressTxList": [], + "currentNetworkTxList": [], "unapprovedMsgs": {}, "unapprovedMsgCount": 0, "unapprovedPersonalMsgs": {}, diff --git a/test/data/mock-state.json b/test/data/mock-state.json index 6b4b732d6..df6b7402b 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -157,7 +157,7 @@ "forceGasMin": null, "toNickname": "" }, - "selectedAddressTxList": [ + "currentNetworkTxList": [ { "id": 3387511061307736, "time": 1528133130531, diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index 0284fb376..01251e5ec 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -56,9 +56,9 @@ describe('Transaction Controller', function () { it('should return a state object with the right keys and datat types', function () { const exposedState = txController.getState() assert('unapprovedTxs' in exposedState, 'state should have the key unapprovedTxs') - assert('selectedAddressTxList' in exposedState, 'state should have the key selectedAddressTxList') + assert('currentNetworkTxList' in exposedState, 'state should have the key currentNetworkTxList') assert(exposedState && typeof exposedState.unapprovedTxs === 'object', 'should be an object') - assert(Array.isArray(exposedState.selectedAddressTxList), 'should be an array') + assert(Array.isArray(exposedState.currentNetworkTxList), 'should be an array') }) }) diff --git a/test/unit/ui/app/reducers/metamask.spec.js b/test/unit/ui/app/reducers/metamask.spec.js index 3df42c569..31d953617 100644 --- a/test/unit/ui/app/reducers/metamask.spec.js +++ b/test/unit/ui/app/reducers/metamask.spec.js @@ -274,7 +274,7 @@ describe('MetaMask Reducers', function () { it('updates value of tx by id', function () { const oldState = { - selectedAddressTxList: [ + currentNetworkTxList: [ { id: 1, txParams: 'foo', @@ -288,7 +288,7 @@ describe('MetaMask Reducers', function () { value: 'bar', }) - assert.equal(state.selectedAddressTxList[0].txParams, 'bar') + assert.equal(state.currentNetworkTxList[0].txParams, 'bar') }) it('sets blockies', function () { diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index 1b530fe85..b611ae98e 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -71,11 +71,11 @@ import { getMaxModeOn } from '../../../../pages/send/send-content/send-amount-ro import { calcMaxAmount } from '../../../../pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.utils' const mapStateToProps = (state, ownProps) => { - const { selectedAddressTxList } = state.metamask + const { currentNetworkTxList } = state.metamask const { modalState: { props: modalProps } = {} } = state.appState.modal || {} const { txData = {} } = modalProps || {} const { transaction = {} } = ownProps - const selectedTransaction = selectedAddressTxList.find(({ id }) => id === (transaction.id || txData.id)) + const selectedTransaction = currentNetworkTxList.find(({ id }) => id === (transaction.id || txData.id)) const buttonDataLoading = getBasicGasEstimateLoadingStatus(state) const gasEstimatesLoading = getGasEstimatesLoadingStatus(state) diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js index 73aeb4fdd..9c756e25f 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js @@ -85,7 +85,7 @@ describe('gas-modal-page-container container', function () { provider: { type: 'mainnet', }, - selectedAddressTxList: [{ + currentNetworkTxList: [{ id: 34, txParams: { gas: '0x1600000', diff --git a/ui/app/components/app/modals/cancel-transaction/cancel-transaction.container.js b/ui/app/components/app/modals/cancel-transaction/cancel-transaction.container.js index 341a6cfb5..99a09368e 100644 --- a/ui/app/components/app/modals/cancel-transaction/cancel-transaction.container.js +++ b/ui/app/components/app/modals/cancel-transaction/cancel-transaction.container.js @@ -10,8 +10,8 @@ import { getHexGasTotal } from '../../../../helpers/utils/confirm-tx.util' const mapStateToProps = (state, ownProps) => { const { metamask } = state const { transactionId, originalGasPrice } = ownProps - const { selectedAddressTxList } = metamask - const transaction = selectedAddressTxList.find(({ id }) => id === transactionId) + const { currentNetworkTxList } = metamask + const transaction = currentNetworkTxList.find(({ id }) => id === transactionId) const transactionStatus = transaction ? transaction.status : '' const defaultNewGasPrice = ethUtil.addHexPrefix( diff --git a/ui/app/components/app/signature-request-original/signature-request-original.component.js b/ui/app/components/app/signature-request-original/signature-request-original.component.js index 7a08e36a1..7bf6246f4 100644 --- a/ui/app/components/app/signature-request-original/signature-request-original.component.js +++ b/ui/app/components/app/signature-request-original/signature-request-original.component.js @@ -19,19 +19,22 @@ export default class SignatureRequestOriginal extends Component { } static propTypes = { - balance: PropTypes.string, + fromAccount: PropTypes.shape({ + address: PropTypes.string.isRequired, + balance: PropTypes.string, + name: PropTypes.string, + }).isRequired, cancel: PropTypes.func.isRequired, clearConfirmTransaction: PropTypes.func.isRequired, conversionRate: PropTypes.number, history: PropTypes.object.isRequired, requesterAddress: PropTypes.string, - selectedAccount: PropTypes.string, sign: PropTypes.func.isRequired, txData: PropTypes.object.isRequired, } state = { - selectedAccount: this.props.selectedAccount, + fromAccount: this.props.fromAccount, } componentDidMount = () => { @@ -81,7 +84,7 @@ export default class SignatureRequestOriginal extends Component { } renderAccount = () => { - const { selectedAccount } = this.state + const { fromAccount } = this.state return (
@@ -91,7 +94,7 @@ export default class SignatureRequestOriginal extends Component {
@@ -100,7 +103,8 @@ export default class SignatureRequestOriginal extends Component { } renderBalance = () => { - const { balance, conversionRate } = this.props + const { conversionRate } = this.props + const { fromAccount: { balance } } = this.state const balanceInEther = conversionUtil(balance, { fromNumericBase: 'hex', diff --git a/ui/app/components/app/signature-request-original/signature-request-original.container.js b/ui/app/components/app/signature-request-original/signature-request-original.container.js index 9a5e9057c..4dfe44fe0 100644 --- a/ui/app/components/app/signature-request-original/signature-request-original.container.js +++ b/ui/app/components/app/signature-request-original/signature-request-original.container.js @@ -2,30 +2,28 @@ import { connect } from 'react-redux' import { compose } from 'redux' import { withRouter } from 'react-router-dom' -import * as actions from '../../../store/actions' +import { goHome } from '../../../store/actions' import { - getSelectedAccount, - getCurrentAccountWithSendEtherInfo, - getSelectedAddress, + accountsWithSendEtherInfoSelector, conversionRateSelector, } from '../../../selectors/selectors.js' +import { getAccountByAddress } from '../../../helpers/utils/util' import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck' import SignatureRequestOriginal from './signature-request-original.component' function mapStateToProps (state) { return { - balance: getSelectedAccount(state).balance, - selectedAccount: getCurrentAccountWithSendEtherInfo(state), - selectedAddress: getSelectedAddress(state), requester: null, requesterAddress: null, conversionRate: conversionRateSelector(state), + // not passed to component + allAccounts: accountsWithSendEtherInfoSelector(state), } } function mapDispatchToProps (dispatch) { return { - goHome: () => dispatch(actions.goHome()), + goHome: () => dispatch(goHome()), clearConfirmTransaction: () => dispatch(clearConfirmTransaction()), } } @@ -41,7 +39,12 @@ function mergeProps (stateProps, dispatchProps, ownProps) { txData, } = ownProps - const { type } = txData + const { allAccounts } = stateProps + delete stateProps.allAccounts + + const { type, msgParams: { from } } = txData + + const fromAccount = getAccountByAddress(allAccounts, from) let cancel let sign @@ -60,6 +63,7 @@ function mergeProps (stateProps, dispatchProps, ownProps) { ...ownProps, ...stateProps, ...dispatchProps, + fromAccount, txData, cancel, sign, diff --git a/ui/app/components/app/signature-request/signature-request.component.js b/ui/app/components/app/signature-request/signature-request.component.js index 2a25dd895..a6cbbdbc8 100644 --- a/ui/app/components/app/signature-request/signature-request.component.js +++ b/ui/app/components/app/signature-request/signature-request.component.js @@ -10,11 +10,11 @@ import Identicon from '../../ui/identicon' export default class SignatureRequest extends PureComponent { static propTypes = { txData: PropTypes.object.isRequired, - selectedAccount: PropTypes.shape({ - address: PropTypes.string, + fromAccount: PropTypes.shape({ + address: PropTypes.string.isRequired, balance: PropTypes.string, name: PropTypes.string, - }), + }).isRequired, clearConfirmTransaction: PropTypes.func.isRequired, cancel: PropTypes.func.isRequired, @@ -50,29 +50,30 @@ export default class SignatureRequest extends PureComponent { render () { const { - selectedAccount, - txData: { msgParams: { data, origin, from: senderWallet } }, + fromAccount, + txData: { msgParams: { data, origin } }, cancel, sign, } = this.props + const { address: fromAddress } = fromAccount const { message, domain = {} } = JSON.parse(data) return (
-
+
{this.context.t('sigRequest')}
{ domain.name && domain.name[0] }
{domain.name}
{origin}
-
{this.formatWallet(senderWallet)}
+
{this.formatWallet(fromAddress)}