diff options
author | Esteban MiƱo <efmino@uc.cl> | 2019-01-23 02:22:56 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2019-01-23 02:22:56 +0800 |
commit | e21dfd18622dd7f70dac51855a0052a56fb74e57 (patch) | |
tree | 03fe6571c87474c15af266fa0e3bc9c1a755c450 /app | |
parent | fe780fb3d457dd22be84cf7ef386327ba9a2ec93 (diff) | |
download | tangerine-wallet-browser-e21dfd18622dd7f70dac51855a0052a56fb74e57.tar.gz tangerine-wallet-browser-e21dfd18622dd7f70dac51855a0052a56fb74e57.tar.zst tangerine-wallet-browser-e21dfd18622dd7f70dac51855a0052a56fb74e57.zip |
Use Parity on-chain registry only when is needed (#6052)
* add and use knownMethodData to avoid infura requests
* dataMethod to methodData and check empty response
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/controllers/preferences.js | 14 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 2faf8220b..fa162c21f 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -19,6 +19,7 @@ class PreferencesController { * @property {boolean} store.useBlockie The users preference for blockie identicons within the UI * @property {object} store.featureFlags A key-boolean map, where keys refer to features and booleans to whether the * user wishes to see that feature + * @property {object} store.knownMethodData Contains all data methods known by the user * @property {string} store.currentLocale The preferred language locale key * @property {string} store.selectedAddress A hex string that matches the currently selected address in the app * @@ -36,6 +37,7 @@ class PreferencesController { betaUI: true, skipAnnounceBetaUI: true, }, + knownMethodData: {}, currentLocale: opts.initLangCode, identities: {}, lostIdentities: {}, @@ -99,6 +101,18 @@ class PreferencesController { } /** + * Add new methodData to state, to avoid requesting this information again through Infura + * + * @param {string} fourBytePrefix Four-byte method signature + * @param {string} methodData Corresponding data method + */ + addKnownMethodData (fourBytePrefix, methodData) { + const knownMethodData = this.store.getState().knownMethodData + knownMethodData[fourBytePrefix] = methodData + this.store.updateState({ knownMethodData }) + } + + /** * RPC engine middleware for requesting new asset added * * @param req diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index c7e9cfcc7..ea57582a0 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -425,6 +425,7 @@ module.exports = class MetamaskController extends EventEmitter { setAccountLabel: nodeify(preferencesController.setAccountLabel, preferencesController), setFeatureFlag: nodeify(preferencesController.setFeatureFlag, preferencesController), setPreference: nodeify(preferencesController.setPreference, preferencesController), + addKnownMethodData: nodeify(preferencesController.addKnownMethodData, preferencesController), // BlacklistController whitelistPhishingDomain: this.whitelistPhishingDomain.bind(this), |