123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- const router = require('koa-router')()
- const moralis = require("../model/moralis_sdk")
- router.prefix('/denettest');
- const BigNumber = require('bignumber.js')
- function calculate_total_usdprice(amount, decimals, usdprice) {
- return parseInt(amount) / (10 ** parseInt(decimals)) * parseFloat(usdprice);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- async function getTransfers(ctx) {
- const obj = ctx.request.body;
- console.log("obj", obj);
- if (!obj.chain)
- obj.chain = 'bsc'
- var token_total_usdprice = calculate_total_usdprice('99999999999999999998', '18', 0.1);
- var data =
- {
- nonce: 118,
- gasPrice: { type: 'BigNumber', hex: '0x02540be400' },
- gasLimit: { type: 'BigNumber', hex: '0x5208' },
- to: '0x7C7401fcc82D1e53C4090561c3e6fde80d74e317',
- value: { type: 'BigNumber', hex: '0x039696f3392000' },
- data: '0x',
- chainId: 97,
- v: 230,
- r: '0x075149b50e81da71aa72ee73d1b07e8df6fa2416b97133dc3e2dea19b4ed4c88',
- s: '0x7d8ac906b85275d63233e8f8ba6c0f5b860e9ebea1bc896346fe81824d9ec9c3',
- from: '0xAD48D13E77011cFE03fF19729B6A247847AfD28E',
- hash: '0xb9a75efb6a17325f2decaec9fba30fead7664c13a589fe0ccac02f791a7c84c8',
- type: null,
- confirmations: 0
- }
- var curGasPrice = BigNumber(data.gasPrice.hex)
- var curGasLimit = BigNumber(data.gasLimit.hex)
- if(curGasLimit > 0)
- {
- console.log('curGasLimit', curGasLimit.toNumber())
- }
- console.log('curGasPrice', curGasPrice.toNumber())
- var a = parseInt('10000000000000000')
- var b = parseInt('100000000000000000')
- console.log(token_total_usdprice, a / b);
-
-
- if (obj.address) {
- moralis.pushCollectConisObj(obj)
- }
- ctx.body = curGasPrice + '-' + curGasLimit;
-
-
-
- }
- router.post('/getTransfers', getTransfers)
- async function crypto_test(ctx) {
- if (ctx.request == null || ctx.request.body == null) {
- ctx.body = utils.toJson(-1, null, "request error. ");
- return;
- }
- const obj = ctx.request.body;
- var crypt_key = obj.key;
- var message = obj.privateKey;
-
- console.log("NDK_HOME", process.env.NDK_HOME);
- var de_message = utils.decryptPrivityKey(crypt_key, message);
- console.log("decrypt message:", message);
- ctx.body = {
- decrypt: de_message
- }
- }
- router.post('/crypto_test', crypto_test)
- module.exports = router
|