Skip to content

Commit

Permalink
Merge pull request #242 from VerusCoin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Asherda authored Apr 20, 2024
2 parents 9356462 + 9bd0e8f commit 8e9ac04
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 300 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ stages:
variables:
DOCKER_DRIVER: overlay2
DEFAULT_VERUSCOIN_BRANCH: release
VERUS_VERSION: 1.2.2-3
VERUSCOIN_VERSION: 1.2.2-3
VERUS_VERSION: 1.2.2-4
VERUSCOIN_VERSION: 1.2.2-4
KOMODO_VERSION: 0.8.1
KOMODO_DOWNLOAD_URL: https://github.com/KomodoPlatform/komodo/releases/download
PIRATE_VERSION: 5.8.1
Expand Down
7 changes: 5 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,11 @@ if (!hasLock) {
createAppCloseWindow();
api.quitKomodod(appConfig.general.native.cliStopTimeout);

setInterval(() => {
if (!Object.keys(api.startedDaemonRegistry).length) {
setInterval(async () => {
if (
!Object.keys(api.startedDaemonRegistry).length &&
!(await api.isAnyDaemonRunning())
) {
closeApp();
}
}, 1000);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "verus-desktop",
"productName": "Verus-Desktop",
"version": "1.2.2-3",
"version": "1.2.2-4",
"description": "Verus Desktop Wallet App",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -81,6 +81,7 @@
"tx-builder": "^0.18.0",
"unzipper": "0.10.11",
"verus-typescript-primitives": "git+https://github.com/VerusCoin/verus-typescript-primitives.git",
"verusd-rpc-ts-client": "git+https://github.com/VerusCoin/verusd-rpc-ts-client",
"verus-wallet-endpoints": "git+https://github.com/VerusCoin/verus-wallet-endpoints.git",
"verus_bridgekeeper": "git+https://github.com/VerusCoin/verusbridgekeeper.git",
"wif": "2.0.6"
Expand Down
1 change: 1 addition & 0 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ api = require('./api/native/idUpdate.js')(api);
api = require('./api/native/idInformation.js')(api);
api = require('./api/native/getCurrencies.js')(api);
api = require('./api/native/getCurrency.js')(api);
api = require('./api/native/estimateSendcurrencyFee.js')(api);
api = require('./api/native/estimateConversion.js')(api);
api = require('./api/native/getConversionPaths.js')(api);
api = require('./api/native/currencyGraylist.js')(api);
Expand Down
12 changes: 12 additions & 0 deletions routes/api/binsUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const os = require('os');
const fsnode = require('fs');
const _fs = require('graceful-fs');
const { DAEMON_NAMES } = require('./utils/constants');
const exec = require('child_process').exec;

module.exports = (api) => {
Expand Down Expand Up @@ -63,5 +64,16 @@ module.exports = (api) => {
})
}

api.isAnyDaemonRunning = async () => {
for (const daemon of DAEMON_NAMES) {
if (await api.isDaemonRunning(daemon)) {
api.log(`${daemon} is currently running...`, 'native.process');
return true;
} else {
api.log(`${daemon} is not currently running...`, 'native.process');
}
}
}

return api;
};
35 changes: 35 additions & 0 deletions routes/api/native/callDaemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,43 @@ const {
RPC_PARSE_ERROR
} = require("../utils/rpc/rpcStatusCodes");
const RpcError = require('../utils/rpc/rpcError');
const { VerusdRpcInterface } = require('verusd-rpc-ts-client');

module.exports = (api) => {
api.native.getRpcInterface = (coin, systemid) => {
const interface = new VerusdRpcInterface(
systemid,
"",
undefined,
async (req) => {
const { params, method, id } = req;

try {
const res = await api.native.callDaemon(coin, method, params);

return {
id,
result: res,
error: null
}
} catch(e) {
const error = {
id,
result: null,
error: {
code: -32603,
message: e.message,
},
};

return error;
}
}
);

return interface;
}

api.native.callDaemon = (coin, cmd, params) => {
return new Promise(async (resolve, reject) => {
let _payload;
Expand Down
53 changes: 53 additions & 0 deletions routes/api/native/estimateSendcurrencyFee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = (api) => {
api.native.estimate_sendcurrency_fee = async (chain, _params, minconfs = 1, sendfee = 0.0001) => {
try {
let feecurrency;

const vETH = await api.native.get_currency(chain, 'vETH');

// These are throwaway addresses, without any funds, to ensure this
// tx would fail if it were to be broadcasted, or at least not spend
// any user funds in the absolute worst case scenario.
const raddr = "RGM3raQ1McqQYZpFyuBrqUpLnmgK7h8k4A"
const address = _params.exportto === vETH.currencyid ?
"0xd62971620094e8244F1ed3B12a8D31bC969081fA"
:
raddr;

const params = {..._params, amount: 0, address};

const res = await api.native.callDaemon(chain, 'sendcurrency', [raddr, [params], minconfs, sendfee, true]);

if (params.feecurrency == null) {
const chainCurrency = await api.native.get_currency(chain, chain);
feecurrency = chainCurrency.currencyid;
} else feecurrency = params.feecurrency;

return res.outputtotals[feecurrency];
} catch(e) {
throw e
}
};

api.setPost('/native/estimate_sendcurrency_fee', async (req, res, next) => {
const { chainTicker, params, minconfs, sendfee } = req.body;

try {
const retObj = {
msg: 'success',
result: await api.native.estimate_sendcurrency_fee(chainTicker, params, minconfs, sendfee),
};

res.send(JSON.stringify(retObj));
} catch(e) {
const retObj = {
msg: 'error',
result: e.message,
};

res.send(JSON.stringify(retObj));
}
});

return api;
};
Loading

0 comments on commit 8e9ac04

Please sign in to comment.