Skip to content

Commit 3e1f5eb

Browse files
committed
proper l2 handling
1 parent 70a697a commit 3e1f5eb

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

assets_js_bitrequest_ethl2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ $(document).ready(function() {
3939

4040
// Initializes Layer 2 socket connections for Ethereum and ERC20 token transactions
4141
function initialize_layer2_connections(payment, address, ct, socket_node) {
42-
const l2_options = get_layer2_config(payment);
42+
const idx_array = glob_const.eth_l2s,
43+
l2_options = get_layer2_config(payment);
4344
if (l2_options) {
4445
const ctracts = ct || contracts(request.currencysymbol),
4546
l2_arr = [],
4647
is_request = request.isrequest,
4748
req_l2_arr = request.eth_l2s;
48-
let index = 0;
4949
$.each(l2_options, function(l2, l2_dat) {
5050
const set_select = is_request ? false : (l2_dat.selected === false) ? false : !empty_obj(l2_dat),
51+
index = idx_array.indexOf(l2),
5152
inarr = ($.inArray(index, req_l2_arr) > -1),
5253
selected = set_select || inarr;
5354
if (selected) {
5455
l2_arr.push(index);
5556
const sn = socket_node || get_network_node_config(payment, l2, l2_dat, "websockets");
5657
setup_layer2_monitoring(l2, sn, address, ctracts);
5758
}
58-
index++;
5959
});
6060
if (l2_arr.length) { // layer 2
6161
if (!is_request) {
@@ -77,7 +77,7 @@ function setup_layer2_monitoring(l2, sn, address, ctracts, retry) {
7777
ping_id = sha_sub(socket_node.url + layer2, 15);
7878
socket_info(socket_node, true);
7979
glob_let.socket_attempt[ping_id] = true;
80-
if (node_name === "infura") {
80+
if (ctracts && node_name === "infura") {
8181
web3_erc20_websocket(socket_node, address, contract, ping_id);
8282
return
8383
}

assets_js_bitrequest_lang_nl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ function lang_nl(id, data) {
425425
"disableproxy": "Schakel proxy " + data.set_proxy_val + " uit?",
426426
"enableproxy": "Schakel proxy " + data.set_proxy_val + " in?",
427427
// dialog
428-
"unabletoconnectln": "Kan geen verbinding aken met de lightning node",
428+
"unabletoconnectln": "Kan geen verbinding maken met de lightning node",
429429

430430
// BIP39
431431
"disclaimer": "Disclaimer!",

assets_js_bitrequest_sockets.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ function init_eth_sockets(payment_type, socket_node, wallet_address, retry) {
10111011
if (str_incudes(socket_node.url, glob_const.main_alchemy_socket)) {
10121012
alchemy_eth_websocket(socket_node, wallet_address); // L1 Alchemy
10131013
} else {
1014-
web3_eth_websocket(socket_node, wallet_address, glob_const.main_eth_node); // L1 Infura
1014+
web3_eth_websocket(socket_node, wallet_address); // L1 Infura
10151015
}
10161016
} else {
10171017
web3_erc20_websocket(socket_node, wallet_address, token_contracts.main);
@@ -1074,7 +1074,7 @@ function alchemy_eth_websocket(socket_node, wallet_address) {
10741074
}
10751075

10761076
// Establishes WebSocket connection to Ethereum node for monitoring new blocks with RPC-based transaction filtering
1077-
function web3_eth_websocket(socket_node, wallet_address, rpc_url) {
1077+
function web3_eth_websocket(socket_node, wallet_address) {
10781078
const network_type = socket_node.network,
10791079
base_url = socket_node.url,
10801080
infura_key = get_infura_apikey(base_url),
@@ -1105,7 +1105,7 @@ function web3_eth_websocket(socket_node, wallet_address, rpc_url) {
11051105
if (block_data && block_data.hash) {
11061106
const api_data = helper ? q_obj(helper, "api_info.data") : null;
11071107
if (!api_data) return;
1108-
const node_url = api_data.default === false ? api_data.url : rpc_url;
1108+
const node_url = api_data.default === false ? api_data.url : glob_const.main_eth_node;
11091109
api_proxy(eth_params(node_url, 25, "eth_getBlockByHash", [block_data.hash, true])).done(function(response) {
11101110
const result_data = inf_result(response),
11111111
transactions = result_data.transactions;
@@ -1143,6 +1143,10 @@ function web3_erc20_websocket(socket_node, wallet_address, contract_address, soc
11431143
if (glob_let.sockets[socket_id]) {
11441144
return
11451145
}
1146+
if (!contract_address) {
1147+
web3_eth_websocket(socket_node, wallet_address);
1148+
return
1149+
}
11461150
const network_type = socket_node.network,
11471151
base_url = complete_url(socket_node.url),
11481152
infura_key = get_infura_apikey(base_url),

assets_js_lib_global_queries.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ const br_bipobj = br_get_local("bpdat", true),
158158
"litecoin": "https://litecoinspace.org",
159159
"dogecoin": null,
160160
"bitcoin-cash": null
161-
}
161+
},
162+
"eth_l2s": ["arbitrum", "polygon", "bnb"]
162163
},
163164
glob_let = {
164165
"socket_attempt": {},

0 commit comments

Comments
 (0)