Explorar o código

Merge branch 'master' of https://git.yishihui.com/contracts/denet-node-server

Rony %!s(int64=2) %!d(string=hai) anos
pai
achega
f41d714952
Modificáronse 3 ficheiros con 12 adicións e 8 borrados
  1. 3 4
      model/http_withdraw.js
  2. 5 2
      model/moralis_sdk.js
  3. 4 2
      model/utils.js

+ 3 - 4
model/http_withdraw.js

@@ -1,4 +1,3 @@
-
 const axios = require('axios');
 
 
@@ -8,11 +7,11 @@ const logger = require('./logger.js');
 var url = account_config.CZZ_BASEURL
 
 
-const withdraw = async (params) => {
+const withdraw = async(params) => {
     params.privateKey = ''
     params.toAddress = params.receiver
     logger.info('http-withdraw', process.env.NODE_ENV, url, ' params ', params)
-    var data = { ...params }
+    var data = {...params }
     return new Promise(resolve => {
         axios.post(url + '/withdraw', data, { timeout: 5 * 60 * 1000 })
             .then(res => {
@@ -26,7 +25,7 @@ const withdraw = async (params) => {
 }
 
 
-const check_withdraw_status = async (params) => {
+const check_withdraw_status = async(params) => {
     logger.info('txn_status_czz', process.env.NODE_ENV, url, ' params ', params)
     var pars = {
         txn_hash: params.hash,

+ 5 - 2
model/moralis_sdk.js

@@ -1083,14 +1083,16 @@ async function transfer_(opts) {
     if (opts.receiver) {
         opts.receiver = utils.trim(opts.receiver)
     }
-    if (opts.chainId == utils.CHAIN_ID.bsc_testnet || opts.chainId == utils.CHAIN_ID.bsc_mainnet) {
+    // if (opts.chainId == utils.CHAIN_ID.bsc_testnet || opts.chainId == utils.CHAIN_ID.bsc_mainnet) {
+    if (false) {
+
         var options;
         // sending 0.5 DAI tokens with 18 decimals on BSC testnet
         if (opts.contractAddress) { //如果存在就是代币
             options = Moralis.TransferOptions = {
                 type: opts.type,
                 // amount: (opts.amount - 1000).toString(), //金额不足而出现的问题
-                amount: (opts.amount - 1000).toLocaleString('fullwide', { useGrouping: false }),
+                amount: (opts.amount * .999999999).toLocaleString('fullwide', { useGrouping: false }),
                 receiver: opts.receiver, //接收钱包地址
                 contractAddress: opts.contractAddress //用户合约地址
             };
@@ -1132,6 +1134,7 @@ async function transfer_(opts) {
         if (opts.type != 'native') {
             opts.type = 'token'
         }
+        opts.amount = (opts.amount * .999999999).toLocaleString('fullwide', { useGrouping: false })
         opts.chain = utils.getChainIdToName(opts.chainId)
         var ret = await czz.withdraw(opts)
         if (ret && ret.data && ret.code == 0) {

+ 4 - 2
model/utils.js

@@ -115,7 +115,8 @@ const CHAIN_TOKEN_TYPE = {
 const CHAIN_ID = {
     eth: '0x1',
     bsc_testnet: '0x61',
-    bsc_mainnet: '0x38',
+    // bsc_mainnet: '0x38',
+    bsc_mainnet: '56',
     czz: '2019',
     kcc_testnet: '322',
     kcc_mainnet: '321',
@@ -125,12 +126,13 @@ const CHAIN_ID = {
 
 const CHAIN_ID_NAME = {
     97: 'bsc_testnet',
-    56: 'bsc_mainnet',
+    56: 'bsc',
     2019: 'czz',
     65: 'okc',
     66: 'okc',
     321: 'kcc',
     322: 'kcc',
+    '0x38': 'bsc',
 }
 
 const USE_SDK = {