update
This commit is contained in:
parent
4675b2e3d7
commit
927bfa198c
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"nodesUrl": {
|
||||||
|
"ETH": {
|
||||||
|
"url":"https://api.etherscan.io/v2/api",
|
||||||
|
"key":"2KKTKZ8MSG6DNUPQ4K9JVWPQ4H33DSUQA3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"abiPath": {
|
||||||
|
"usdt_erc20_abi": "./src/abi/erc20usdt.json",
|
||||||
|
"usdc_erc20_abi": "./src/abi/erc20usdc.json",
|
||||||
|
"usdt_trc20_abi": "./src/abi/trc20usdt.json"
|
||||||
|
}
|
||||||
|
}
|
106
src/chain/eth.js
106
src/chain/eth.js
|
@ -1,6 +1,6 @@
|
||||||
const app = require("../app");
|
const app = require("../app");
|
||||||
const abiDecoder = require("abi-decoder");
|
const abiDecoder = require("abi-decoder");
|
||||||
const Web3 = require("web3");
|
// const Web3 = require("web3");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
|
||||||
class ETH {
|
class ETH {
|
||||||
|
@ -9,7 +9,7 @@ class ETH {
|
||||||
const apiUrl = app.ethNodeUrl
|
const apiUrl = app.ethNodeUrl
|
||||||
const usdt_abi = app.abis.usdterc20_abi;
|
const usdt_abi = app.abis.usdterc20_abi;
|
||||||
const usdc_abi = app.abis.usdcerc20_abi;
|
const usdc_abi = app.abis.usdcerc20_abi;
|
||||||
this.web3 = new Web3(new Web3.providers.HttpProvider(apiUrl));
|
// this.web3 = new Web3(new Web3.providers.HttpProvider(apiUrl));
|
||||||
abiDecoder.addABI(usdt_abi);
|
abiDecoder.addABI(usdt_abi);
|
||||||
abiDecoder.addABI(usdc_abi);
|
abiDecoder.addABI(usdc_abi);
|
||||||
this.decoder = abiDecoder;
|
this.decoder = abiDecoder;
|
||||||
|
@ -25,59 +25,59 @@ class ETH {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async decodeTxInput(txHash) {
|
// async decodeTxInput(txHash) {
|
||||||
try{
|
// try{
|
||||||
const tx = await this.web3.eth.getTransaction(txHash);
|
// const tx = await this.web3.eth.getTransaction(txHash);
|
||||||
if (!tx || !tx.input) {
|
// if (!tx || !tx.input) {
|
||||||
console.error("Transaction not found or has no input data.");
|
// console.error("Transaction not found or has no input data.");
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
return this.decodeInput(tx.input);
|
// return this.decodeInput(tx.input);
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error("Error decoding transaction input:", error);
|
// console.error("Error decoding transaction input:", error);
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
decodeUSDT(input){
|
// decodeUSDT(input){
|
||||||
const decoded = this.decodeInput(input)
|
// const decoded = this.decodeInput(input)
|
||||||
const result = []
|
// const result = []
|
||||||
if (decoded && decoded.name === "transfer") {
|
// if (decoded && decoded.name === "transfer") {
|
||||||
for (let item of decoded.params) {
|
// for (let item of decoded.params) {
|
||||||
const obj = {}
|
// const obj = {}
|
||||||
if (item.name === "_to") {
|
// if (item.name === "_to") {
|
||||||
obj.toAddress = item.value;
|
// obj.toAddress = item.value;
|
||||||
}
|
// }
|
||||||
if (item.name === "_value") {
|
// if (item.name === "_value") {
|
||||||
obj.amount = this.web3.utils.fromWei(item.value, "ether");
|
// obj.amount = this.web3.utils.fromWei(item.value, "ether");
|
||||||
}
|
// }
|
||||||
if (Object.keys(obj).length > 0) {
|
// if (Object.keys(obj).length > 0) {
|
||||||
result.push(obj);
|
// result.push(obj);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
decodeUSDC(input){
|
// decodeUSDC(input){
|
||||||
const decoded = this.decodeInput(input)
|
// const decoded = this.decodeInput(input)
|
||||||
const result = []
|
// const result = []
|
||||||
if (decoded && decoded.name === "transfer") {
|
// if (decoded && decoded.name === "transfer") {
|
||||||
for (let item of decoded.params) {
|
// for (let item of decoded.params) {
|
||||||
const obj = {}
|
// const obj = {}
|
||||||
if (item.name === "to") {
|
// if (item.name === "to") {
|
||||||
obj.toAddress = item.value;
|
// obj.toAddress = item.value;
|
||||||
}
|
// }
|
||||||
if (item.name === "value") {
|
// if (item.name === "value") {
|
||||||
obj.amount = this.web3.utils.fromWei(item.value, "mwei");
|
// obj.amount = this.web3.utils.fromWei(item.value, "mwei");
|
||||||
}
|
// }
|
||||||
if (Object.keys(obj).length > 0) {
|
// if (Object.keys(obj).length > 0) {
|
||||||
result.push(obj);
|
// result.push(obj);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
async checkUSDTPaymentStatus(address, amount, ts){
|
async checkUSDTPaymentStatus(address, amount, ts){
|
||||||
const url = `${app.ethNodeUrl}
|
const url = `${app.ethNodeUrl}
|
||||||
|
|
Loading…
Reference in New Issue