From f2dd0068e9f235fd364120cb32607169831b2c98 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Thu, 09 May 2024 16:59:32 +0800
Subject: [PATCH] 合约监听

---
 src/main/java/cc/mrbird/febs/dapp/chain/EthUsdtContract.java |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/chain/EthUsdtContract.java b/src/main/java/cc/mrbird/febs/dapp/chain/EthUsdtContract.java
index f81debf..3b4fd99 100644
--- a/src/main/java/cc/mrbird/febs/dapp/chain/EthUsdtContract.java
+++ b/src/main/java/cc/mrbird/febs/dapp/chain/EthUsdtContract.java
@@ -3,8 +3,6 @@
 import io.reactivex.Flowable;
 import io.reactivex.functions.Function;
 import org.web3j.abi.EventEncoder;
-import org.web3j.abi.EventValues;
-import org.web3j.abi.FunctionReturnDecoder;
 import org.web3j.abi.TypeReference;
 import org.web3j.abi.datatypes.*;
 import org.web3j.abi.datatypes.generated.Uint256;
@@ -174,25 +172,25 @@
      *            {
      * 				"indexed": false,
      * 				"internalType": "uint256",
-     * 				"name": "sameCoin",
+     * 				"name": "usdtTarget",
      * 				"type": "uint256"
      *            },
      *            {
      * 				"indexed": false,
      * 				"internalType": "uint256",
-     * 				"name": "finxMineCoin",
+     * 				"name": "coinTarget",
+     * 				"type": "uint256"
+     *            },
+     *            {
+     * 				"indexed": false,
+     * 				"internalType": "uint256",
+     * 				"name": "usdtCoin",
      * 				"type": "uint256"
      *            },
      *            {
      * 				"indexed": false,
      * 				"internalType": "uint256",
      * 				"name": "lastMineTime",
-     * 				"type": "uint256"
-     *            },
-     *            {
-     * 				"indexed": false,
-     * 				"internalType": "uint256",
-     * 				"name": "thisMineTime",
      * 				"type": "uint256"
      *            }
      * 		],
@@ -410,10 +408,11 @@
                     typedResponse.adr = (String) eventValues.getNonIndexedValues().get(0).getValue();
                     typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
                     typedResponse.price = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
-                    typedResponse.sameCoin = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
-                    typedResponse.finxMineCoin = (BigInteger) eventValues.getNonIndexedValues().get(4).getValue();
-                    typedResponse.lastMineTime = (BigInteger) eventValues.getNonIndexedValues().get(5).getValue();
-                    typedResponse.thisMineTime = (BigInteger) eventValues.getNonIndexedValues().get(6).getValue();
+                    typedResponse.usdtTarget = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue();
+                    typedResponse.coinTarget = (BigInteger) eventValues.getNonIndexedValues().get(4).getValue();
+                    typedResponse.usdtCoin = (BigInteger) eventValues.getNonIndexedValues().get(5).getValue();
+                    typedResponse.lastMineTime = (BigInteger) eventValues.getNonIndexedValues().get(6).getValue();
+                    typedResponse.blockHash = log.getTransactionHash();
                 }
 
                 return typedResponse;
@@ -427,7 +426,7 @@
 
     public Flowable<CoinRewardEventResponse> coinRewardEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
         EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
-        filter.addSingleTopic(EventEncoder.encode(TRANSFER_EVENT));
+        filter.addSingleTopic(EventEncoder.encode(COINREWARD_EVENT));
         return coinRewardEventFlowable(filter);
     }
 
@@ -831,13 +830,14 @@
     }
 
     public static class CoinRewardEventResponse extends BaseEventResponse {
-        public String adr;
+        public String adr;//地址
 
-        public BigInteger amount;
-        public BigInteger price;
-        public BigInteger sameCoin;
-        public BigInteger finxMineCoin;
-        public BigInteger lastMineTime;
-        public BigInteger thisMineTime;
+        public BigInteger amount;//总挖矿币量
+        public BigInteger price;//挖矿时价格
+        public BigInteger usdtTarget;//金本位多少USDT,单位USDT
+        public BigInteger coinTarget;//币本位多少币
+        public BigInteger usdtCoin;//金本位换算后多少币
+        public BigInteger lastMineTime;//上一次挖矿时间
+        public String blockHash;//上一次挖矿时间
     }
 }

--
Gitblit v1.9.1