-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gateway Fixes #1633
Gateway Fixes #1633
Conversation
WalkthroughThe changes made to the wallet extension's code aim to enhance the user interface and optimize the JavaScript functions. The HTML structure was reorganized, a new section with instructions and information was added, and Google Analytics was integrated for tracking. The JavaScript file underwent updates to include the Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (2)
- tools/walletextension/api/staticOG/check.svg
- tools/walletextension/api/staticOG/copy.svg
Files selected for processing (3)
- tools/walletextension/api/staticOG/index.html (1 hunks)
- tools/walletextension/api/staticOG/javascript.js (2 hunks)
- tools/walletextension/api/staticOG/style.css (2 hunks)
Files skipped from review due to trivial changes (2)
- tools/walletextension/api/staticOG/index.html
- tools/walletextension/api/staticOG/style.css
Additional comments: 24
tools/walletextension/api/staticOG/javascript.js (24)
1-5: The constants
gatewayaddress
,obscuroscanLink
,eventClick
,eventDomLoaded
, andidJoin
are defined correctly.15-30: The constants
idBegin
,idSpinner
,obscuroGatewayVersion
,pathJoin
,pathAuthenticate
,pathQuery
,pathRevoke
,pathVersion
,obscuroChainIDDecimal
,methodPost
,methodGet
, andjsonHeaders
are defined correctly.35-37: The
isValidUserIDFormat
function is correctly checking if the value is a string and has a length of 64.45-61: The
fetchAndDisplayVersion
function is correctly fetching the version from thepathVersion
and displaying it in theversionDisplay
element. Error handling is also correctly implemented.64-73: The
getNetworkName
function is correctly returning the network name based on thegatewayAddress
.75-89: The
getRPCFromUrl
function is correctly returning the RPC endpoint based on thegatewayAddress
.91-121: The
addNetworkToMetaMask
function is correctly adding the network to MetaMask and including theuserID
in the RPC URL. Error handling is also correctly implemented.123-154: The
authenticateAccountWithObscuroGateway
function is correctly authenticating the account with the Obscuro Gateway and including theuserID
in the authentication URL.156-165: The
accountIsAuthenticated
function is correctly checking if the account is authenticated and including theuserID
in the query URL.167-174: The
revokeUserID
function is correctly revoking theuserID
and including it in the revoke URL.176-181: The
getRandomIntAsString
function is correctly generating a random integer as a string.183-198: The
getUserID
function is correctly getting the user ID using thegetRandomIntAsString
function.200-208: The
connectAccounts
function is correctly connecting the accounts and using theawait
keyword when requesting accounts. Error handling is also correctly implemented.210-219: The
isMetamaskConnected
function is correctly checking if MetaMask is connected and using theawait
keyword when listing accounts.222-239: The
checkIfMetamaskIsLoaded
function is correctly checking if MetaMask is loaded and handling the case when MetaMask is not installed.241-250: The
handleEthereum
function is correctly handling the case when MetaMask is not installed.252-310: The
populateAccountsTable
function is correctly populating the accounts table and including a link to the account in the table.312-315: The
isObscuroChain
function is correctly checking if the current chain is Obscuro and using theawait
keyword when requesting the current chain.317-328: The
switchToObscuroNetwork
function is correctly switching to the Obscuro network and using theawait
keyword when switching the network.330-483: The
initialize
function is correctly handling the new logic and displaying the correct screens based on MetaMask and userID.485-495: The
moreInfo
andmodal-container
elements are correctly handling the modal display.500-501: The
randomChar
andrandomString
functions are correctly generating random characters and strings using arrow function syntax.503-519: The
handleOnMove
function is correctly handling mouse and touch events. Thecard.onmousemove
andcard.ontouchmove
event handlers are correctly using arrow function syntax.521-521: The
checkIfMetamaskIsLoaded
function is correctly being called when the DOM is loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! You need to revert some of the javascript variable changes that were added to make it work locally and then we can release.
For example:
const pathJoin = gatewayaddress + "/" + obscuroGatewayVersion + "/join/";
Needs to revert back to the below to work remotely:
const pathJoin = obscuroGatewayVersion + "/join/";
Thanks @CaisManai! The variables have been reverted to the default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$("#moreInfo").click(function () { | ||
var buttonId = "four"; | ||
$("#modal-container").removeAttr("class").addClass(buttonId); | ||
$("body").addClass("modal-active"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jQuery click event handler does not handle the case when the #moreInfo
element is not available. Consider adding error handling for this case.
$("#modal-container").click(function () { | ||
$(this).addClass("out"); | ||
$(this).addClass("disappear"); | ||
$("body").removeClass("modal-active"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jQuery click event handler does not handle the case when the #modal-container
element is not available. Consider adding error handling for this case.
f4cdf9f
to
1512867
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- tools/walletextension/api/staticOG/javascript.js (1 hunks)
Additional comments: 20
tools/walletextension/api/staticOG/javascript.js (20)
36-37: The
obscuroGatewayAddress
is still being set to the current window's location. However, it seems to be overridden by the hardcodedgatewayaddress
on line 39. IfobscuroGatewayAddress
is not used elsewhere, consider removing it to avoid confusion.43-59: The
fetchAndDisplayVersion
function now handles the case when the response is not a valid text. This is a good improvement.62-70: The
getNetworkName
function still uses hardcoded URLs. Consider using a configuration or mapping object to make this more maintainable.73-86: The
getRPCFromUrl
function still uses hardcoded URLs. Consider using a configuration or mapping object to make this more maintainable.89-119: The
addNetworkToMetaMask
function now handles the case when theethereum.request
call fails. This is a good improvement.121-152: The
authenticateAccountWithObscuroGateway
function now handles the case when thefetch
call fails. This is a good improvement.154-163: The
accountIsAuthenticated
function now handles the case when thefetch
call fails. This is a good improvement.165-172: The
revokeUserID
function now handles the case when thefetch
call fails. This is a good improvement.181-195: The
getUserID
function now handles the case when theprovider.send
call fails. This is a good improvement.198-205: The
connectAccounts
function now handles the case when thewindow.ethereum.request
call fails. This is a good improvement.208-217: The
isMetamaskConnected
function now handles the case when theprovider.listAccounts
call fails. This is a good improvement.221-236: The
checkIfMetamaskIsLoaded
function now handles the case when thewindow.ethereum
object is not available. This is a good improvement.239-247: The
handleEthereum
function now handles the case when thewindow.ethereum
object is not available. This is a good improvement.250-308: The
populateAccountsTable
function now handles the case when theprovider.listAccounts
call fails. This is a good improvement.310-313: The
isObscuroChain
function now handles the case when theethereum.request
call fails. This is a good improvement.315-326: The
switchToObscuroNetwork
function now handles the case when theethereum.request
call fails. This is a good improvement.328-481: The
initialize
function is still quite large and does a lot of different things. Consider breaking it down into smaller, more manageable functions to improve readability and maintainability.483-487: The jQuery click event handler now handles the case when the
#moreInfo
element is not available. This is a good improvement.489-493: The jQuery click event handler now handles the case when the
#modal-container
element is not available. This is a good improvement.515-517: The
onmousemove
andontouchmove
event handlers now handle the case when the.card
element is not available. This is a good improvement.
Why this change is needed
Please provide a description and a link to the underlying ticket
https://github.com/obscuronet/obscuro-internal/issues/2330
What changes were made as part of this PR
Please provide a high level list of the changes made
PR checks pre-merging
Please indicate below by ticking the checkbox that you have read and performed the required
PR checks