Skip to content

Commit 1f4841a

Browse files
committed
scan for corresponding l2 on insufficient funds
1 parent 38fb25f commit 1f4841a

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

assets_js_bitrequest_core.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,12 @@ function payrequest() {
12921292
}
12931293
const thisrequestlist = thisnode.closest("li.rqli"),
12941294
rldata = thisrequestlist.data(),
1295-
rl_payment = rldata.payment,
1295+
dl2 = rldata.eth_layer2; // detected l2
1296+
let get_l2_index = false;
1297+
if (dl2) {
1298+
get_l2_index = get_network_index(dl2);
1299+
}
1300+
const rl_payment = rldata.payment,
12961301
rl_uoa = rldata.uoa,
12971302
rl_status = rldata.status,
12981303
rl_requesttype = rldata.requesttype,
@@ -1311,6 +1316,8 @@ function payrequest() {
13111316
"proxy": lightning.proxy_host,
13121317
"nid": lightning.nid,
13131318
"lid": lightning.pid
1319+
})) : (get_l2_index !== false) ? "&d=" + btoa(JSON.stringify({
1320+
"l2": [get_l2_index]
13141321
})) : "",
13151322
paymenturl = "?p=requests&payment=" + rl_payment + "&uoa=" + rl_uoa + "&amount=" + paymenturl_amount + midstring + endstring + d;
13161323
openpage(paymenturl, "", "payment");

assets_js_bitrequest_ethl2.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ $(document).ready(function() {
3434
//set_l2_status_init
3535
//set_l2_status
3636
//fertch_l2s
37+
//get_network_index
3738
//get_l2_node
3839
//omni_rdo
3940

@@ -586,6 +587,13 @@ function fertch_l2s(currency) {
586587
return q_obj(l2_setting, "options");
587588
}
588589

590+
// Returns the index of an L2 network in settings, or false if not found
591+
function get_network_index(l2_network) {
592+
const l2s = q_obj(get_erc20_settings(), "layer2.options"),
593+
networks = Object.keys(l2s);
594+
return networks.indexOf(l2_network) === -1 ? false : networks.indexOf(l2_network);
595+
}
596+
589597
// get node data based on api name
590598
function get_l2_node(payment, network, l2_dat, type) {
591599
const selected = q_obj(l2_dat, type);

assets_js_lib_global_queries.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,8 @@ function fetch_aws(filename, bckt) {
924924

925925
// Get object from array by keypair
926926
function object_from_array(array, key, val) {
927-
return $.grep(array, obj => obj[key] === val)[0];
927+
const result = array.find(obj => obj[key] === val);
928+
return result || false;
928929
}
929930

930931
// Retrieves and processes key data

0 commit comments

Comments
 (0)