Browse Source

now checks balances on bridge before allowing burn...

tags/v3.7.0
jojapoppa 10 months ago
parent
commit
cdcc67bcac
3 changed files with 1510 additions and 562 deletions
  1. +1444
    -556
      package-lock.json
  2. +3
    -2
      package.json
  3. +63
    -4
      src/js/wsui_main.js

+ 1444
- 556
package-lock.json
File diff suppressed because it is too large
View File


+ 3
- 2
package.json View File

@@ -2,7 +2,7 @@
"name": "FedoraGoldWallet",
"productName": "FedoraGoldWallet",
"description": "FedoraGold (FED) GUI Wallet",
"version": "v3.6.8",
"version": "v3.6.9",
"homepage": "https://github.com/jojapoppa/fedoragold-wallet-electron",
"repository": "https://github.com/jojapoppa/fedoragold-wallet-electron",
"main": "main.js",
@@ -64,6 +64,7 @@
"ip2int": "^1.0.1",
"is-running": "^2.1.0",
"keypair": "^1.0.3",
"moralis": "^1.5.9",
"navigator": "^1.0.1",
"node-forge": "^0.10.0",
"node-sessionstorage": "^1.0.0",
@@ -87,7 +88,7 @@
"ts-socks": "^0.9.3",
"typescript": "^4.3.2",
"util": "^0.12.3",
"web3": "^1.6.0",
"web3": "^1.7.1",
"web3-provider-engine": "^16.0.3"
},
"build": {


+ 63
- 4
src/js/wsui_main.js View File

@@ -14,6 +14,7 @@ const log = require('electron-log');
const randomBytes = require('randombytes');
const writeCSV = require('@danieldsf/csv-utils').writeCSV;
const get = require('simple-get');
const https = require('https');

const { setIntervalAsync } = require('set-interval-async/dynamic');
const { clearIntervalAsync } = require('set-interval-async')
@@ -2232,6 +2233,42 @@ function handleSendTransfer(){
return tpl;
}

function testBalance(addr, token, bERC20) {

const options = {
json: true,
headers: {'X-API-Key': '7l1H2MmLem33aWPqN6Vl3odVAPfRtTnnmGBPLrdjIe7nijCWF9Vboe3sTrioOl2l'}
}

return new Promise((resolve, reject) => {

let path = "/balance";
if (bERC20) path = "/erc20"

let url = 'https://deep-index.moralis.io/api/v2/'+addr+path+'?chain=polygon';
if (token.length > 0) url = url+'&token_addresses='+token;

const req = https.get(url, options, res => {
log.warn("testERC20Balance page statusCode: "+res.statusCode);

res.on('data', (datum) => {
log.warn("datum: "+datum);
let dat = JSON.parse(datum);
let theBalance = '';
if (token.length > 0) theBalance = dat[0].balance;
else theBalance = dat.balance;
let bal = parseFloat(theBalance) / 1000000000000000000;
log.warn("balance data: "+bal);
resolve(bal);
});

}).on('error', error => {
alert("chainLink bridge is down, please try again later: "+error);
reject(0);
});
});
}

function testRebalanceBridge() {
let url = "https://fedgoldwebservice.herokuapp.com/getapprovedfedamount?signature=NKtesZMBK4SEajCw566 vPC9ccvjkNbuS3i6DBS4MHWPtSHKLjUYtaAci4SaUXEjCGSdfLSSixvMmy3G316XmJytB2niSsWuXCqw2vE1Be2UcqTGJ3vhukQD3GFYVCR dmmyv72LfqYSK&transaction_id=b548de48476102c4a26138af78bccc4f89a1a4f8ae4ee85b4ef11ec98a4ad120";
return new Promise((resolve, reject) => {
@@ -2366,14 +2403,36 @@ function handleSendTransfer(){
let waladdr = wsession.get('loadedWalletAddress');

if (bTokenIssuance) {
log.warn("test Rebalance Bridge..");
//log.warn("test Rebalance Bridge app..");
testRebalanceBridge().then((httpresult) => {
//alert("httpresult: "+httpresult);
if (httpresult.indexOf("200000000") > -1) {
sendTx(useMixin, tx, waladdr, recipientAddress, paymentId);

//log.warn("test LINK balance now...");
let linkBridgeAddress = '0x0a31078cD57d23bf9e8e8F1BA78356ca2090569E';
let linkToken = '0xb0897686c545045afc77cf20ec7a532e3120e0f1';
testBalance(linkBridgeAddress, linkToken, true).then((balanceresult) => {
//log.warn("LINK balance: "+balanceresult);
if (balanceresult >= .5) {
//log.warn("test MATIC balance now...");
let maticBridgeAddress = '0x9693acf64c53fC597450107A93821C2F24496D65';
testBalance(maticBridgeAddress, '', false).then((balresult) => {
//log.warn("MATIC balance: "+balresult);
if (balresult >= 10) {
//log.warn("There is sufficient gas ready... sendTx now... go for it");
sendTx(useMixin, tx, waladdr, recipientAddress, paymentId);
}
}).catch((err) => {
let bMsg = "Bridge gas balance is too low. Please try again later: "+err;
alert(bMsg);
});
}
}).catch((err) => {
let bMsg = "Bridge gas balance is too low. Please try again later: "+err;
alert(bMsg);
});
}
}).catch((err) => {
let sEMsg = "Rebalance Bridge is down. Please try again later.";
let sEMsg = "Rebalance Bridge is down. Please try again later: "+err;
alert(sEMsg);
});
} else {


Loading…
Cancel
Save