Переглянути джерело

Merge remote-tracking branch 'origin/master'

Wren 1 рік тому
батько
коміт
28c9b4115f

+ 8 - 0
front/admin-front/src/api/user.js

@@ -104,3 +104,11 @@ export function updatePassword(params) {
     data: params
   })
 }
+
+//获取当前用户的菜单ID数组
+export function getUserRights() {
+  return request({
+    url:  'uc/menu/current/user/menu',
+    method: 'get',
+  })
+}

+ 76 - 3
front/admin-front/src/layout/components/Sidebar/index.vue

@@ -53,6 +53,7 @@ import Logo from "./Logo";
 import SidebarItem from "./SidebarItem";
 import variables from "@/styles/variables.scss";
 import Hamburger from "@/components/Hamburger";
+import {getUserRights} from "@/api/user";
 
 export default {
   components: {
@@ -60,13 +61,20 @@ export default {
     Logo,
     Hamburger,
   },
+  data(){
+    return {
+      routes:[]
+    }
+  },
   computed: {
     ...mapGetters(["sidebar"]),
-    routes() {
-      return this.$router.options.routes;
-    },
+    // routes() {
+    //   console.log(this.$router.options.routes);
+    //   return this.$router.options.routes;
+    // },
     activeMenu() {
       const route = this.$route;
+
       const { meta, path } = route;
       // if set path, the sidebar will highlight the path you set
       if (meta.activeMenu) {
@@ -84,10 +92,75 @@ export default {
       return !this.sidebar.opened;
     },
   },
+  beforeMount() {
+    this.getRightsInfo()
+  },
+
   methods: {
     toggleSideBar() {
       this.$store.dispatch("app/toggleSideBar");
     },
+    // 690f84fec2374880b922d62e614245ea	数据看板
+    // 2caf11b463de4eeeaaa1f42c7f443270	用户管理
+    // 5501cc476bc14e63ae6de0e8515d1f99	系统参数
+    // c05b49809dbe45f6a18695b7aef4558b	任务管理
+    // 0c78a0fff4bd47bd9fef257f03f6410a	项目管理
+    // 4bf360eec98e432992019426ed430800	地址管理
+
+    // a9b295e9bbcc4a8580b8932589612442	编辑任务
+    // c3b727c313e24e21b720ccbbc229395f	新增任务
+    getRightsInfo() {
+      let Arr = ['690f84fec2374880b922d62e614245ea','2caf11b463de4eeeaaa1f42c7f443270',
+      '5501cc476bc14e63ae6de0e8515d1f99','c05b49809dbe45f6a18695b7aef4558b','0c78a0fff4bd47bd9fef257f03f6410a',
+      '4bf360eec98e432992019426ed430800','a9b295e9bbcc4a8580b8932589612442','c3b727c313e24e21b720ccbbc229395f']
+      getUserRights().then(res=>{
+        let showRoutes = this.$router.options.routes
+        Arr.forEach((item,index)=>{
+          let result = res.includes(item)
+          if(!result){
+            if(index === 0) {
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 1){
+              let inx = showRoutes.findIndex(el=>{
+               return el.path === '/user'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 2){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/sys-param'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 3){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/autoplay'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 4){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/airdrop'
+              })
+              showRoutes.splice(inx,1)
+            }else if (index === 5){
+              let inx = showRoutes.findIndex(el=>{
+                return el.path === '/address'
+              })
+              showRoutes.splice(inx,1)
+            }
+          }else {
+            if (index === 6){
+              this.$store.commit('changeEditTask')
+            }else if (index === 7){
+              this.$store.commit('changeAddTask')
+            }
+          }
+        })
+        this.routes = showRoutes
+      })
+    },
+
   },
 };
 </script>

+ 13 - 1
front/admin-front/src/store/index.js

@@ -13,7 +13,19 @@ const store = new Vuex.Store({
     settings,
     user
   },
-  getters
+  getters,
+  state:{
+    editTask:false,
+    addTask:false
+  },
+  mutations: {
+    changeEditTask (state) {
+      state.editTask = true
+    },
+    changeAddTask (state) {
+      state.addTask = true
+    }
+  }
 })
 
 export default store

+ 21 - 8
front/admin-front/src/views/address/index.vue

@@ -53,9 +53,13 @@
         </div>
       </div>
       <div class="app-container-table-select">
-        <div @click="selectAddressGroup(index)" v-for="(item,index) in table.walletNameGroup" :class="index === table.walletNameGroupIndex ? 'app-container-table-select-item-active' : 'app-container-table-select-item'">
+        <el-scrollbar>
+        <div class="scrollbar-flex-content">
+          <div @click="selectAddressGroup(index)" v-for="(item,index) in table.walletNameGroup" :class="index === table.walletNameGroupIndex ? 'app-container-table-select-item-active' : 'app-container-table-select-item'">
           {{item}}
+          </div>
         </div>
+        </el-scrollbar>
       </div>
       <div class="app-container-table-screening">
         <div class="app-container-table-screening-item">
@@ -635,12 +639,12 @@ export default {
       // console.log('输入的密码:', dataToEncrypt);
       // 获取当前北京时间
       const beijingDate = this.getCurrentBeijingTime();
-      // 生成keyByte
+      // 生成keyByte;
       const keyByte = this.generateKeyByteArray(beijingDate);
       // console.log('生成的toHex:', keyByte);
       // 加密数据
       const encryptedData = this.encryptData(dataToEncrypt, keyByte);
-      console.log('加密后的数据:', encryptedData);
+      // console.log('加密后的数据:', encryptedData);
       let params = {
         chainId : this.batchAddressObj.chainId,
         groupName : this.batchAddressObj.groupName,
@@ -793,7 +797,7 @@ export default {
         title: '错误',
         message: message
       });
-    }
+    },
   }
 }
 </script>
@@ -889,18 +893,25 @@ export default {
       display: flex;
       align-items: center;
       gap:56px;
-      border-bottom: 4px solid #f2f4f7;
+      //border-bottom: 4px solid #f2f4f7;
       width: 100%;
       margin-top: 28px;
+      .scrollbar-flex-content {
+        display: flex;
+        gap:56px;
+      }
+
       .app-container-table-select-item{
         font-weight: 400;
         font-size: 17px;
         line-height: 22px;
         color: #ABABAB;
         padding-bottom: 16px;
-        margin-bottom: -4px;
-        border-bottom: 4px solid #f2f4f7;
+        //margin-bottom: -4px;
+        border-bottom: 4px solid #f9fbff;
         cursor: pointer;
+        white-space:nowrap;
+        margin-bottom: 20px;
       }
       .app-container-table-select-item-active{
         font-weight: 700;
@@ -908,9 +919,11 @@ export default {
         line-height: 22px;
         color: #2980FF;
         padding-bottom: 16px;
-        margin-bottom: -4px;
+        //margin-bottom: -4px;
         border-bottom: 4px solid #2980FF;
         cursor: pointer;
+        white-space:nowrap;
+        margin-bottom: 20px;
       }
     }
     .app-container-table-screening{

+ 3 - 2
front/admin-front/src/views/autoplay/index.vue

@@ -4,7 +4,7 @@
       <div class="title">
         任务列表
       </div>
-      <div class="add">
+      <div class="add" v-if="$store.state.addTask">
         <div class="button" @click="addTaskDetails">
           <img src="../../assets/airdrop/add.svg" alt="add">
           添加任务
@@ -110,7 +110,7 @@
               </div>
             </div>
           </div>
-          <div class="drawerAddress-container-head-right">
+          <div class="drawerAddress-container-head-right" v-if="$store.state.editTask">
             <div class="complete" @click="modifyTask">
               <img src="../../assets/address/done_all.svg" alt="done_all">
               完成
@@ -1056,6 +1056,7 @@ export default {
       this.currentRecordData.intervalMin = item.intervalMin
       this.currentRecordData.maxGas = item.maxGas
       this.currentRecordData.executeId = item.executeId
+      this.currentRecordData.airdropParams = []
       let params = {
         page: 1,
         pageSize: 10,

+ 64 - 32
front/admin-front/src/views/dashboard/index.vue

@@ -148,10 +148,10 @@
       </div>
       <div class="right">
         <div class="title">
-          燃气报价(单位:)
+          燃气报价(单位:gwei)
         </div>
         <div class="base">
-          当前基数:38基于以太坊交易内存池预测
+<!--          当前基数:38基于以太坊交易内存池预测-->
         </div>
         <div class="gasBox">
           <div class="top">
@@ -159,10 +159,10 @@
               <img src="../../assets/dashboard/Vector.svg" alt="Vector">
               <div class="info">
                 <div class="speed">
-                  Top 40
+                  High
                 </div>
                 <div class="price">
-                  $1.57 | for 15 seconds
+                  {{gas.FastGasPrice}} gwei
                 </div>
               </div>
             </div>
@@ -172,43 +172,49 @@
               <img src="../../assets/dashboard/Vector-1.svg" alt="Vector">
               <div class="info">
                 <div class="speed">
-                  High speed 40
+                  Average
                 </div>
                 <div class="price">
-                  $1.53 | 1 minute
-                </div>
-              </div>
-            </div>
-          </div>
-          <div class="general">
-            <div class="item">
-              <img src="../../assets/dashboard/Vector-2.svg" alt="Vector">
-              <div class="info">
-                <div class="speed">
-                  General 40
-                </div>
-                <div class="price">
-                  $1.49 | 3 minutes
+                  {{gas.ProposeGasPrice}} gwei
                 </div>
               </div>
             </div>
           </div>
+<!--          <div class="general">-->
+<!--            <div class="item">-->
+<!--              <img src="../../assets/dashboard/Vector-2.svg" alt="Vector">-->
+<!--              <div class="info">-->
+<!--                <div class="speed">-->
+<!--                  Low-->
+<!--                </div>-->
+<!--                <div class="price">-->
+<!--                  {{gas.SafeGasPrice}}-->
+<!--                </div>-->
+<!--              </div>-->
+<!--            </div>-->
+<!--          </div>-->
           <div class="slow">
             <div class="item">
               <img src="../../assets/dashboard/Vector-3.svg" alt="Vector">
               <div class="info">
                 <div class="speed">
-                  Slow 40
+                  Low
                 </div>
                 <div class="price">
-                  $1.49 | > 10 minutes
+                  {{gas.SafeGasPrice}} gwei
                 </div>
               </div>
             </div>
           </div>
         </div>
-        <div class="logo">
-          <img src="../../assets/dashboard/image.svg" alt="image">
+        <div class="logo"  @click="getGas">
+<!--          <img src="../../assets/dashboard/image.svg" alt="image">-->
+          <div v-if="!loading">
+            刷新数据
+          </div>
+          <div v-if="loading" style="width: 20px;height: 20px">
+            <Loading />
+          </div>
         </div>
       </div>
     </div>
@@ -293,9 +299,12 @@
 <script>
 import * as echarts from 'echarts';
 import {addressGroup, countFee, dailyCost, expectedInput, taskProgress} from "@/api/statistics";
+import Loading from "@/components/Loading";
+
 
 export default {
   name: "Dashboard",
+  components: {Loading},
   data() {
     return {
       progressData: [],
@@ -358,7 +367,9 @@ export default {
         xAxisData:[],
         seriesData:[]
       },
-      timer:null
+      timer:null,
+      gas:{},
+      loading:false
     };
   },
   mounted() {
@@ -368,6 +379,7 @@ export default {
     this.getTaskProgress()
     this.getAddressGroup()
     this.roll(60)
+    this.getGas()
   },
   beforeDestroy() {
     if(this.timer) clearInterval(this.timer)
@@ -610,7 +622,6 @@ export default {
       this.rollStart(t)
     },
     rollStart(t) {
-      console.log('2')
       let ul1 = document.getElementById('progressBoxOne')
       let ul2 = document.getElementById('progressBoxTwo')
       let ulbox = document.getElementById('progressViewBox')
@@ -625,8 +636,20 @@ export default {
     },
     rollStop(){
       clearInterval(this.timer)
-      console.log('1')
-    }
+    },
+    getGas() {
+      this.loading = true
+      fetch('https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=DHB4H92CFC1EZTT8FINM3ETSF36T9TRXBZ')
+        .then( response =>{
+          let res = response.json()
+          res.then(result =>{
+            this.gas = result.result
+            this.loading = false
+          })
+        })
+
+    },
+
   },
 };
 </script>
@@ -918,7 +941,7 @@ export default {
       .gasBox {
         display: flex;
         flex-direction: column;
-        gap: 28px;
+        gap: 88px;
 
         .item {
           display: flex;
@@ -954,7 +977,9 @@ export default {
           border-radius: 10px;
           display: flex;
           align-items: center;
-          justify-content: center;
+          //justify-content: center;
+          padding-left: 80px;
+
         }
 
         .high {
@@ -965,7 +990,9 @@ export default {
           border-radius: 10px;
           display: flex;
           align-items: center;
-          justify-content: center;
+          //justify-content: center;
+          padding-left: 80px;
+
         }
 
         .general {
@@ -976,7 +1003,9 @@ export default {
           border-radius: 10px;
           display: flex;
           align-items: center;
-          justify-content: center;
+          //justify-content: center;
+          padding-left: 80px;
+
         }
 
         .slow {
@@ -987,7 +1016,8 @@ export default {
           border-radius: 10px;
           display: flex;
           align-items: center;
-          justify-content: center;
+          //justify-content: center;
+          padding-left: 80px;
         }
       }
 
@@ -995,6 +1025,8 @@ export default {
         margin-top: 72px;
         display: flex;
         justify-content: center;
+        color: #2980ff;
+        cursor: pointer;
       }
     }
   }

+ 15 - 15
js-runtime/src/script/zksync2/mute/swapUsdcForEth.js

@@ -8,7 +8,7 @@ import swapAbi from "../abi/swapAbi.js";
 const router = express.Router();
 
 async function sendSwapTx(amountNumber, router, signer, provider, wallet, approveGas) {
-    const amountIn = amountNumber * 1000000;
+    const amountIn = amountNumber;
     const path = ["0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4", "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91"];
     const stable = [false, false]
     let timestamp = new Date().getTime();
@@ -41,7 +41,7 @@ router.post("/", async (req, res) => {
     const amountMin = params.amountMin;
     const amountMax = params.amountMax;
     const accuracy = params.accuracy;
-    const amountNumber = mathUtil.getRandomNumber(amountMin, amountMax, accuracy);
+    const amountNumber = mathUtil.getRandomNumber(amountMin, amountMax, accuracy) * 1000000;
     const signer = req.body.wallet;
     const provider = new Provider('https://mainnet.era.zksync.io');
 
@@ -49,23 +49,23 @@ router.post("/", async (req, res) => {
     const router = "0x8b791913eb07c32779a16750e3868aa8495f5964";
     const usdc = new Contract("0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4", erc20, wallet);
     const routerContract = new Contract(router, swapAbi, wallet);
-    const allowance = await usdc.allowance(signer.address, router);
+    // const allowance = await usdc.allowance(signer.address, router);
 
     let result = {};
-    if (allowance <= 0) {
-        const approveTx = await usdc.approve(router, 0xFFFFFFFF);
-        await approveTx.wait();
-        const txReceipt = await provider.getTransactionReceipt(approveTx.hash);
-        const approveGas = utils.formatEther((txReceipt.gasUsed * approveTx.gasPrice).toFixed(0));
-        if (txReceipt.status === 1) {
-            result = await sendSwapTx(amountNumber, routerContract, signer, provider, wallet, approveGas);
-        } else {
-            throw new Error("approve error");
-        }
-
+    // if (allowance <= 0) {
+    const approveTx = await usdc.approve(router, amountNumber);
+    await approveTx.wait();
+    const txReceipt = await provider.getTransactionReceipt(approveTx.hash);
+    const approveGas = utils.formatEther((txReceipt.gasUsed * approveTx.gasPrice).toFixed(0));
+    if (txReceipt.status === 1) {
+        result = await sendSwapTx(amountNumber, routerContract, signer, provider, wallet, approveGas);
     } else {
-        result = await sendSwapTx(amountNumber, routerContract, signer, provider, wallet, 0);
+        throw new Error("approve error");
     }
+
+    // } else {
+    //     result = await sendSwapTx(amountNumber, routerContract, signer, provider, wallet, 0);
+    // }
     res.send(result);
 })
 

+ 12 - 12
js-runtime/src/script/zksync2/sync/swapUsdcForEth.js

@@ -1,7 +1,7 @@
 import express from "express";
 import mathUtil from "../../utils/mathUtil.js";
 import {Contract, Provider, Wallet} from "zksync-web3";
-import {tokenSwap, getPoolAddress, wETHAddress, usdcAddress,routerAddress} from "./swap.js";
+import {tokenSwap, getPoolAddress, wETHAddress, usdcAddress, routerAddress} from "./swap.js";
 import {utils} from "ethers";
 import erc20 from "../abi/erc20.js";
 
@@ -11,24 +11,24 @@ router.post("/", async (req, res) => {
     const amountMin = params.amountMin;
     const amountMax = params.amountMax;
     const accuracy = params.accuracy;
-    const amountNumber = mathUtil.getRandomNumber(amountMin, amountMax, accuracy);
+    const amountNumber = mathUtil.getRandomNumber(amountMin, amountMax, accuracy) * 1000000;
     const signer = req.body.wallet;
     const provider = new Provider('https://mainnet.era.zksync.io');
     const wallet = new Wallet(signer.privateKey, provider);
     const usdc = new Contract(usdcAddress, erc20, wallet);
-    const allowance = await usdc.allowance(signer.address, routerAddress);
+    // const allowance = await usdc.allowance(signer.address, routerAddress);
     let approveGas = 0;
-    if (allowance <= 0) {
-        const approveTx = await usdc.approve(routerAddress, 0xFFFFFFFF);
-        await approveTx.wait();
-        const txReceipt = await provider.getTransactionReceipt(approveTx.hash);
-        approveGas = utils.formatEther((txReceipt.gasUsed * approveTx.gasPrice).toFixed(0));
-        if (txReceipt.status !== 1) {
-            throw new Error("approve error");
-        }
+    // if (allowance <= 0) {
+    const approveTx = await usdc.approve(routerAddress, amountNumber);
+    await approveTx.wait();
+    const txReceipt = await provider.getTransactionReceipt(approveTx.hash);
+    approveGas = utils.formatEther((txReceipt.gasUsed * approveTx.gasPrice).toFixed(0));
+    if (txReceipt.status !== 1) {
+        throw new Error("approve error");
     }
+    // }
     const pool = await getPoolAddress(usdcAddress, wETHAddress);
-    const txR = await tokenSwap(pool, usdcAddress, parseFloat(amountNumber) * 1000000, wallet);
+    const txR = await tokenSwap(pool, usdcAddress, amountNumber, wallet);
     const tx = await provider.getTransaction(txR.transactionHash);
     // const swapReceipt = await provider.getTransactionReceipt(tx.hash);
     const gas = utils.formatEther((txR.gasUsed * tx.gasPrice).toFixed(0));

+ 8 - 2
src/main/java/com/ichaoj/ams/common/util/WalletUtil.java

@@ -86,9 +86,15 @@ public class WalletUtil {
     @SneakyThrows
     public static AirdropWallet getWalletByKeystore(String keystore, String userId, String groupName, String password) {
         Credentials credentials = WalletUtils.loadCredentials(password, WALLET_FILE_PATH + userId + File.separator + getEncryptPwd(groupName) + File.separator + keystore);
-        String privateKey = credentials.getEcKeyPair().getPrivateKey().toString(16);
+        StringBuilder privateKey = new StringBuilder(credentials.getEcKeyPair().getPrivateKey().toString(16));
         AirdropWallet wallet = new AirdropWallet();
-        wallet.setPrivateKey(privateKey);
+        if (privateKey.length() < 64) {
+            int priLenth = 64 - privateKey.length();
+            for (int i = 0; i < priLenth; i++) {
+                privateKey.insert(0, "0");
+            }
+        }
+        wallet.setPrivateKey(privateKey.toString());
         wallet.setAddress(credentials.getAddress());
         return wallet;
     }