|
|
@ -374,22 +374,6 @@ class PreferencesController { |
|
|
|
return Promise.resolve(label) |
|
|
|
return Promise.resolve(label) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Gets an updated rpc list from this.addToFrequentRpcList() and sets the `frequentRpcList` to this update list. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {string} _url The the new rpc url to add to the updated list |
|
|
|
|
|
|
|
* @param {bool} remove Remove selected url |
|
|
|
|
|
|
|
* @returns {Promise<void>} Promise resolves with undefined |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
updateFrequentRpcList (_url, remove = false) { |
|
|
|
|
|
|
|
return this.addToFrequentRpcList(_url, remove) |
|
|
|
|
|
|
|
.then((rpcList) => { |
|
|
|
|
|
|
|
this.store.updateState({ frequentRpcList: rpcList }) |
|
|
|
|
|
|
|
return Promise.resolve() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Setter for the `currentAccountTab` property |
|
|
|
* Setter for the `currentAccountTab` property |
|
|
|
* |
|
|
|
* |
|
|
@ -405,24 +389,39 @@ class PreferencesController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns an updated rpcList based on the passed url and the current list. |
|
|
|
* Adds custom RPC url to state. |
|
|
|
* The returned list will have a max length of 3. If the _url currently exists it the list, it will be moved to the |
|
|
|
|
|
|
|
* end of the list. The current list is modified and returned as a promise. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param {string} _url The rpc url to add to the frequentRpcList. |
|
|
|
* @param {string} url The RPC url to add to frequentRpcList. |
|
|
|
* @param {bool} remove Remove selected url |
|
|
|
* @returns {Promise<array>} Promise resolving to updated frequentRpcList. |
|
|
|
* @returns {Promise<array>} The updated frequentRpcList. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
addToFrequentRpcList (_url, remove = false) { |
|
|
|
addToFrequentRpcList (url) { |
|
|
|
const rpcList = this.getFrequentRpcList() |
|
|
|
const rpcList = this.getFrequentRpcList() |
|
|
|
const index = rpcList.findIndex((element) => { return element === _url }) |
|
|
|
const index = rpcList.findIndex((element) => { return element === url }) |
|
|
|
if (index !== -1) { |
|
|
|
if (index !== -1) { |
|
|
|
rpcList.splice(index, 1) |
|
|
|
rpcList.splice(index, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
if (!remove && _url !== 'http://localhost:8545') { |
|
|
|
if (url !== 'http://localhost:8545') { |
|
|
|
rpcList.push(_url) |
|
|
|
rpcList.push(url) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.store.updateState({ frequentRpcList: rpcList }) |
|
|
|
|
|
|
|
return Promise.resolve(rpcList) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Removes custom RPC url from state. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {string} url The RPC url to remove from frequentRpcList. |
|
|
|
|
|
|
|
* @returns {Promise<array>} Promise resolving to updated frequentRpcList. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
removeFromFrequentRpcList (url) { |
|
|
|
|
|
|
|
const rpcList = this.getFrequentRpcList() |
|
|
|
|
|
|
|
const index = rpcList.findIndex((element) => { return element === url }) |
|
|
|
|
|
|
|
if (index !== -1) { |
|
|
|
|
|
|
|
rpcList.splice(index, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.store.updateState({ frequentRpcList: rpcList }) |
|
|
|
return Promise.resolve(rpcList) |
|
|
|
return Promise.resolve(rpcList) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|