-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ft-custom_rpc_node: Added logic to check the perform_address_lookups setting to add the event_0xaddress on hover behaviour Added logic to handle toggling address lookups (via rpc) Added logic to handle setting address lookups and a browser call endpoint Added line break Added logic to disable the RPC node address lookups Increased version number Added a small indicator to the popup box to show green/red box if any of the RPC commands fail Removed br's and used css properties instead for that house style Fixes style issues being inherited by the webpage. Now the popup has a house style. Yay Issue #247 - Made RPC calls async to prevent lag when waiting for RPC responses Added padding and margins Added twitter link Added Quiknode link to copy Added logic so the RPC node can be changed Added elements to give the user the ability to change the RPC node Added logic to modify the RPC node
- Loading branch information
Showing
8 changed files
with
294 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
let objBrowser = chrome ? chrome : browser; | ||
|
||
class RpcNodeSelector | ||
{ | ||
|
||
constructor() | ||
{ | ||
//No need to do anything here. | ||
} | ||
|
||
/** | ||
* Populates the RPC node input box with the current RPC node endpoint. | ||
*/ | ||
populateRpcNodeInput() | ||
{ | ||
objBrowser.runtime.sendMessage({func: "rpc_provider"}, function(objResponse) { | ||
document.getElementById("ext-etheraddresslookup-rpcnode_modify_url").value = objResponse.resp; | ||
}); | ||
} | ||
|
||
resetFormValues(objEvent) | ||
{ | ||
objBrowser.runtime.sendMessage({func: "rpc_default_provider"}, function(objResponse) { | ||
document.getElementById("ext-etheraddresslookup-rpcnode_modify_url").value = objResponse.resp; | ||
}); | ||
|
||
objEvent.preventDefault(); | ||
} | ||
|
||
saveFormValues(objEvent) | ||
{ | ||
var objRpcValue = document.getElementById("ext-etheraddresslookup-rpcnode_modify_url"); | ||
|
||
document.getElementById("ext-etheraddresslookup-rpcnode_connected_status").classList.add("hide-me"); | ||
document.getElementById("ext-etheraddresslookup-rpcnode_eth_version").classList.add("hide-me"); | ||
document.getElementById("ext-etheraddresslookup-rpcnode_api_version").classList.add("hide-me"); | ||
document.getElementById("ext-etheraddresslookup-rpcnode_network_version").classList.add("hide-me"); | ||
|
||
var objRpcSuccessNode = document.getElementById("ext-etheraddresslookup-rpcnode_success"); | ||
objRpcSuccessNode.classList.add("hide-me"); | ||
|
||
if( RpcNodeSelector.rpcEndpointIsAvailable(objRpcValue.value) ) { | ||
localStorage.setItem("ext-etheraddresslookup-rpc_node", objRpcValue.value) | ||
} | ||
|
||
objEvent.preventDefault(); | ||
|
||
RpcNodeSelector.updateNodeDetails(); | ||
|
||
return false; | ||
} | ||
|
||
static rpcEndpointIsAvailable(strHttpProvider) | ||
{ | ||
var objWeb3 = new Web3(new Web3.providers.HttpProvider(strHttpProvider)); | ||
var objRpcErrorNode = document.getElementById("ext-etheraddresslookup-rpcnode_errors"); | ||
objRpcErrorNode.innerText = ""; | ||
objRpcErrorNode.classList.add("hide-me"); | ||
|
||
try { | ||
var strVersion = objWeb3.version.ethereum; | ||
} catch (objException) { | ||
objRpcErrorNode.innerText = objException.message; | ||
objRpcErrorNode.classList.remove("hide-me"); | ||
return false; | ||
} | ||
|
||
var objRpcSuccessNode = document.getElementById("ext-etheraddresslookup-rpcnode_success"); | ||
objRpcSuccessNode.classList.remove("hide-me"); | ||
|
||
console.log("RPC Node Version: "+ strVersion); | ||
return true; | ||
} | ||
|
||
static updateNodeDetails() | ||
{ | ||
var strWeb3Provider = localStorage.getItem("ext-etheraddresslookup-rpc_node"); | ||
var objWeb3 = new Web3(new Web3.providers.HttpProvider(strWeb3Provider)); | ||
|
||
document.getElementById("ext-etheraddresslookup-rpcnode_connected_status").classList.remove("hide-me"); | ||
document.getElementById("ext-etheraddresslookup-rpcnode_eth_version").classList.remove("hide-me"); | ||
document.getElementById("ext-etheraddresslookup-rpcnode_api_version").classList.remove("hide-me"); | ||
document.getElementById("ext-etheraddresslookup-rpcnode_network_version").classList.remove("hide-me"); | ||
|
||
var blConnected = objWeb3.isConnected(); | ||
document.getElementById("ext-etheraddresslookup-rpcnode_connected_status").innerHTML = (blConnected ? "CONNECTED" : "DISCONNECTED") + "<br />"; | ||
if(blConnected) { | ||
document.getElementById("ext-etheraddresslookup-rpcnode_eth_version").innerHTML = "ETH Version: " + objWeb3.version.ethereum +"<br />"; | ||
document.getElementById("ext-etheraddresslookup-rpcnode_api_version").innerHTML = "API Version: " + objWeb3.version.api +"<br />"; | ||
document.getElementById("ext-etheraddresslookup-rpcnode_network_version").innerHTML = "API Version: " + objWeb3.version.network +"<br />"; | ||
} | ||
} | ||
|
||
} | ||
|
||
//On page load do everything. | ||
(function() { | ||
let objRpcNodeSelector = new RpcNodeSelector(); | ||
objRpcNodeSelector.populateRpcNodeInput(); | ||
|
||
var objForm = document.getElementById("ext-etheraddresslookup-rpcnode_modify_form"); | ||
objForm.addEventListener("reset", objRpcNodeSelector.resetFormValues, true); | ||
objForm.addEventListener("submit", objRpcNodeSelector.saveFormValues, true); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//On page load it checks/unchecks the checkbox | ||
(function() { | ||
refreshPerformAddressLookups(); | ||
})(); | ||
|
||
//Sets the local storage to remember their RPC address lookup setting | ||
function togglePerformAddressLookups() | ||
{ | ||
var objAddressLookups = document.getElementById("ext-etheraddresslookup-perform_address_lookups"); | ||
var intAddressLookups = objAddressLookups.checked ? 1 : 0; | ||
localStorage.setItem("ext-etheraddresslookup-perform_address_lookups", intAddressLookups); | ||
|
||
refreshPerformAddressLookups(); | ||
} | ||
|
||
function refreshPerformAddressLookups() { | ||
var intAddressLookups = localStorage.getItem("ext-etheraddresslookup-perform_address_lookups"); | ||
if(intAddressLookups === null) { | ||
intAddressLookups = 1; | ||
} | ||
document.getElementById("ext-etheraddresslookup-perform_address_lookups").checked = (intAddressLookups == 1 ? true : false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.