Skip to content
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

hardcodes tokens to mainnet on tokens page #6599

Merged
merged 3 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/assets/v2/js/pages/tokens_settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
/* eslint-disable nonblock-statement-body-position */
load_tokens();
load_tokens_from_network('mainnet');

$(document).ready(function() {

Expand Down Expand Up @@ -34,6 +34,10 @@ $(document).ready(function() {
e.preventDefault();
return;
}
if (!web3 || typeof web3 == 'undefined') {
_alert('You are not connected to a web3 wallet. Please unlock metamask (or web3 wallet equivilent), set to mainnet, and connect to gitcoin on the mainnet (settings > connections).', 'error');
return;
}

e.preventDefault();
// actual approval
Expand Down
54 changes: 30 additions & 24 deletions app/assets/v2/js/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,41 @@ const tokenNameToDetails = (network, token_name) => {
return _tokens.filter(_token => _token.name == token_name)[0];
};

var load_tokens = function() {
window.addEventListener('load', function() {
waitforWeb3(function() {
// add tokens to the submission form
var tokenAddress = localStorage['tokenAddress'];
var load_tokens_from_network = function(network) {
// add tokens to the submission form
var tokenAddress = localStorage['tokenAddress'];

if (!tokenAddress) {
tokenAddress = '0x0000000000000000000000000000000000000000';
}
var _tokens = tokens(document.web3network);
if (!tokenAddress) {
tokenAddress = '0x0000000000000000000000000000000000000000';
}
var _tokens = tokens(network);

for (var i = 0; i < _tokens.length; i++) {
if (_tokens[i]['divider']) {
$('select[name=denomination]').append('<option disabled />');
continue;
}
for (var i = 0; i < _tokens.length; i++) {
if (_tokens[i]['divider']) {
$('select[name=denomination]').append('<option disabled />');
continue;
}

var token = _tokens[i];
var select = {
value: token['addr'],
text: token['name']
};
var token = _tokens[i];
var select = {
value: token['addr'],
text: token['name']
};

if (token['addr'] == tokenAddress) {
select['selected'] = 'selected';
}
if (token['addr'] == tokenAddress) {
select['selected'] = 'selected';
}

$('select[name=denomination]').append($('<option>', select));
}
};

var load_tokens = function() {
window.addEventListener('load', function() {
waitforWeb3(function() {

load_tokens_from_network(document.web3network);

$('select[name=denomination]').append($('<option>', select));
}
// if web3, set the values of some form variables
var url_string = window.location.href;
var url = new URL(url_string);
Expand Down