Browse Source

编写czz提币api

DevYK 2 years ago
parent
commit
4fbcd9efa9
6 changed files with 48 additions and 5 deletions
  1. 2 1
      config/dev_config.js
  2. 33 0
      model/czz.js
  3. 4 3
      model/moralis_sdk.js
  4. 1 0
      model/utils.js
  5. 1 1
      routes/sdk.js
  6. 7 0
      test/withdraw_czz.js

+ 2 - 1
config/dev_config.js

@@ -17,7 +17,8 @@ const account_config = {
     BNB_GAS_PRICE: '10000000000',
     TOKEN_GAS_PRICE: '10000000000',
     TRANSFER_GAS: true,
-    FEISHU_URL:'https://open.feishu.cn/open-apis/bot/v2/hook/18dfe21f-b1bd-46ca-a8c7-c85e1c84f02d'
+    FEISHU_URL:'https://open.feishu.cn/open-apis/bot/v2/hook/18dfe21f-b1bd-46ca-a8c7-c85e1c84f02d',
+    CZZ_BASEURL:"",
 }
 
 const reids_token_config = {

+ 33 - 0
model/czz.js

@@ -0,0 +1,33 @@
+
+const axios = require('axios');
+
+
+var { account_config } = require('../config/config.js')
+
+var url = account_config.CZZ_BASEURL
+
+const withdraw = async (params) => {
+    var log = '环境:' + process.env.NODE_ENV + ' params ' + params;
+    var data = { ...params }
+    return new Promise(resolve => {
+        axios.post(url, data)
+            .then(res => {
+                console.log('res=>', res.status, res.data);
+                resolve({
+                    code: 0,
+                    data: res
+                })
+            }).catch(err => {
+                console.error('http_request_post error ', err);
+                resolve({
+                    code: -1,
+                    err: err
+                })
+            });
+    })
+
+}
+
+module.exports = {
+    withdraw
+}

+ 4 - 3
model/moralis_sdk.js

@@ -12,6 +12,7 @@ const logger = require('./logger')
 const report = require("./report")  //导入 db.js
 const BigNumber = require('bignumber.js')
 const collect_coins_db = require('./db/collect_coins_db')
+const czz = require('./czz')
 
 /* Moralis init code */
 var serverUrl = moralis_config.SERVER_URL;
@@ -395,7 +396,7 @@ async function computeTransferGasFree(obj, my_account_all_coins, tokenPrices) {
                 ret_a_gas = lastBnbPrice;
             } else {
                 nativeGasPrice = parseInt(nativeCount) * parseInt(account_config.BNB_GAS_LIMIT) * parseInt(account_config.BNB_GAS_PRICE);
-                ret_a_gas =  parseInt(account_config.BNB_GAS_PRICE);
+                ret_a_gas = parseInt(account_config.BNB_GAS_PRICE);
             }
 
             // var real_native_amount = BigInt(nativeAllBalance) - BigInt(nativeGasPrice) - BigInt(tokenGasPrice);
@@ -954,8 +955,8 @@ async function transfer_(opts) {
     } else {
         switch (opts.chainId) {
             case utils.CHAIN_ID.czz:
-                //todo...
-                break
+                var ret = await czz.withdraw(opts)
+                return ret
         }
     }
 }

+ 1 - 0
model/utils.js

@@ -49,6 +49,7 @@ function decryptPrivityKey(message) {
     return de_pk
 }
 
+// console.log('decryptPrivityKey',decryptPrivityKey('4Uz4Jm7Xd1gH+1nFbR0B7hk1ITmsT8O3iAgS/hC0L9TkrqAZoklsQhXl4fA1X+uqpckF4HtnXnMpwng94GvvzsRfXYirfDfboneuzfc0o7s='))
 
 // 密钥
 const SECRET_KEY = CryptoJS.enc.Utf8.parse(cryppt_config.WITHDRAW_KEY);

+ 1 - 1
routes/sdk.js

@@ -491,7 +491,7 @@ async function timer_transfer_task() {
         var obj_ = {
             "type": "erc20",
             "contractAddress": "0xFF94950Ee8A79c52cC4B0Aa5178C8cEa48A3F3A6",
-            "amount": "111000000000000000000",
+            "amount": "123000000000000000000",
             "chain": "bsc_testnet",
             "receiver": "0x3B525c35DdC323B08241493f148340D89e3A73a7",
             "withdrawId": index.toString()

+ 7 - 0
test/withdraw_czz.js

@@ -0,0 +1,7 @@
+const withdraw_test = require('../model/czz')
+
+
+
+async function test(){
+    console.log('withdraw_test',await withdraw_test.withdraw())
+}