From e21dfd18622dd7f70dac51855a0052a56fb74e57 Mon Sep 17 00:00:00 2001 From: Esteban MiƱo Date: Tue, 22 Jan 2019 15:22:56 -0300 Subject: 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 --- app/scripts/controllers/preferences.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/scripts/controllers/preferences.js') 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: {}, @@ -98,6 +100,18 @@ class PreferencesController { this.store.updateState({ suggestedTokens: suggested }) } + /** + * 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 * -- cgit