20 files modified
1 files added
| | |
| | | /** |
| | | * 链类型 |
| | | * -- todo |
| | | * 0xD88F63aCbcF82cC6D2255b8082D7bdE43b559d00 测试链 |
| | | * 0x81cEAD4B1FaD71c97F77e286F864b95400Ff427B 已审计 |
| | | */ |
| | | @Getter |
| | | public enum ChainEnum { |
| | | |
| | | |
| | | BSC_USDT_W_POOL_CONTRACT("BSC", "0xB3cF9669F398f444DfCAebbAd2A49bF32ba41fE3", |
| | | "3ff7147104fcc4b3e47eef1c6a826107ad13f8ceaf46d6747b7cd4e56f8b01c6", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x99A08A65DB5542f35b96FD69F01896Bd3cDB9DC4", |
| | | ""), |
| | | |
| | | /** |
| | | * 提现USDT |
| | |
| | | * 正式 0xb27e44f98543e480dbd071b6605005e3d99b3dd4 https://bsc-dataseed1.ninicoin.io |
| | | * |
| | | */ |
| | | BSC_TFC("BSC", "0x0F22E63D2FB18963C57A5Cb3C43403d156D140c2+1", |
| | | "0x5bd9f75f53693076e19a8f20d66a147bf0a438275463d2b8d85be8ab11780836+1", |
| | | BSC_TFC("BSC", "0xa60aac0da34c76f3f60207ee09e9f75043319ab4", |
| | | "221be67f85375a5af6dd0f4b77fbe877ad2e57e05db201de1b1383fb76494d18", |
| | | "https://bsc-dataseed1.ninicoin.io", |
| | | "0x9b4406bC2fa21d2058FD4939BAF29B3763cFeDe2+1", |
| | | "0x55d398326f99059fF775485246999027B3197955", |
| | | ""), |
| | | |
| | | /** |
| | |
| | | String transferBaseToken(String address, BigDecimal amount); |
| | | |
| | | BigDecimal balanceOfBaseToken(String address); |
| | | |
| | | |
| | | String transferUSDT(String address, BigDecimal amount); |
| | | } |
| | |
| | | package cc.mrbird.febs.dapp.chain; |
| | | |
| | | import cc.mrbird.febs.dapp.contract.andao.Abi; |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String transferUSDT(String address, BigDecimal amount) { |
| | | try { |
| | | return tokenUSDTTransfer(privateKey, ownerAddress, address, amount.toPlainString()); |
| | | } catch (ExecutionException | InterruptedException e) { |
| | | e.printStackTrace(); |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | public String tokenUSDTTransfer(String privateKey, String fromAddress, String toAddress, String amount) throws ExecutionException, InterruptedException { |
| | | // String gas = getGas(); |
| | | String gas = "5"; |
| | | BigInteger amountOut = new BigInteger(Convert.toWei(amount, Convert.Unit.ETHER).setScale(0).toString()); |
| | | // BigDecimal amountPow = new BigDecimal(amount).multiply(BigDecimal.TEN.pow(decimals())); |
| | | // amount = amountPow.toPlainString(); |
| | | // if (amount.contains(".")) { |
| | | // amount = amount.substring(0, amount.lastIndexOf(".")); |
| | | // } |
| | | |
| | | Credentials credentials = Credentials.create(privateKey); |
| | | |
| | | EthGetTransactionCount ethGetTransactionCount = web3j |
| | | .ethGetTransactionCount(fromAddress, DefaultBlockParameterName.LATEST).sendAsync().get(); |
| | | |
| | | BigInteger nonce = ethGetTransactionCount.getTransactionCount(); |
| | | |
| | | Function function = new Function("withdrawANDAO", |
| | | Arrays.asList(new Address(toAddress), new Uint256(amountOut)), |
| | | Arrays.asList(new TypeReference<Type>() { |
| | | })); |
| | | |
| | | String encodedFunction = FunctionEncoder.encode(function); |
| | | |
| | | RawTransaction rawTransaction = RawTransaction.createTransaction(nonce, |
| | | Convert.toWei(gas, Convert.Unit.GWEI).toBigInteger(),// 给矿工开的转账单价 单价越高越快 |
| | | Convert.toWei("100000", Convert.Unit.WEI).toBigInteger(), contractAddress, encodedFunction);//里程上限 |
| | | |
| | | byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials); |
| | | String hexValue = Numeric.toHexString(signedMessage); |
| | | |
| | | CompletableFuture<EthSendTransaction> ethSendTransactionCompletableFuture = web3j.ethSendRawTransaction(hexValue).sendAsync(); |
| | | EthSendTransaction ethSendTransaction = ethSendTransactionCompletableFuture.get(); |
| | | |
| | | |
| | | if (ethSendTransaction.hasError()) { |
| | | return ""; |
| | | } else { |
| | | return ethSendTransaction.getTransactionHash(); |
| | | } |
| | | } |
| | | } |
| | |
| | | public BigDecimal balanceOfBaseToken(String address) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String transferUSDT(String address, BigDecimal amount) { |
| | | return null; |
| | | } |
| | | } |
| | |
| | | package cc.mrbird.febs.dapp.contract.andao; |
| | | |
| | | import io.reactivex.Flowable; |
| | | import io.reactivex.functions.Function; |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | import org.web3j.abi.TypeReference; |
| | | import org.web3j.abi.datatypes.Address; |
| | | import org.web3j.abi.datatypes.Event; |
| | | import org.web3j.abi.datatypes.Function; |
| | | import org.web3j.abi.datatypes.Type; |
| | | import org.web3j.abi.datatypes.Utf8String; |
| | | import org.web3j.abi.datatypes.generated.Uint256; |
| | | import org.web3j.abi.datatypes.generated.Uint8; |
| | | import org.web3j.crypto.Credentials; |
| | | import org.web3j.protocol.Web3j; |
| | | import org.web3j.protocol.core.DefaultBlockParameter; |
| | |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | public class Abi extends Contract { |
| | | private static final String BINARY = "608060405273ca143ce32fe78f1f7019d7d551a6402fc5350c73600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555030600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507355d398326f99059ff775485246999027b3197955600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555073adc5331ac7f46c63e877aec2dfbb5523c7680812600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550737a9bfe048d110ef90a467803653f9b8666f9096c600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550737a9bfe048d110ef90a467803653f9b8666f9096c600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550737a9bfe048d110ef90a467803653f9b8666f9096c600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503480156200025057600080fd5b506000620002636200081560201b60201c565b9050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3506040518060400160405280600d81526020017f444d44746573743220436f696e00000000000000000000000000000000000000815250600690805190602001906200034e929190620009c5565b506040518060400160405280600881526020017f444d447465737432000000000000000000000000000000000000000000000000815250600590805190602001906200039c929190620009c5565b506008600460006101000a81548160ff021916908360ff16021790555066049e57d6354000600381905550600354600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555033600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c9c65396600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b1580156200056857600080fd5b505af11580156200057d573d6000803e3d6000fd5b505050506040513d60208110156200059457600080fd5b8101908080519060200190929190505050600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006200061e60646200060a60556003546200081d60201b62001c191790919060201c565b620008a860201b62001c9f1790919060201c565b90503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a36000620006bf6064620006ab600a6003546200081d60201b62001c191790919060201c565b620008a860201b62001c9f1790919060201c565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a360006200078260646200076e60056003546200081d60201b62001c191790919060201c565b620008a860201b62001c9f1790919060201c565b9050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505062000a74565b600033905090565b600080831415620008325760009050620008a2565b60008284029050828482816200084457fe5b04146200089d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180620029fa6021913960400191505060405180910390fd5b809150505b92915050565b6000620008f283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250620008fa60201b60201c565b905092915050565b60008083118290620009aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156200096e57808201518184015260208101905062000951565b50505050905090810190601f1680156200099c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581620009b757fe5b049050809150509392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1062000a0857805160ff191683800117855562000a39565b8280016001018555821562000a39579182015b8281111562000a3857825182559160200191906001019062000a1b565b5b50905062000a48919062000a4c565b5090565b62000a7191905b8082111562000a6d57600081600090555060010162000a53565b5090565b90565b611f768062000a846000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c80638da5cb5b116100a2578063a457c2d711610071578063a457c2d71461053b578063a9059cbb146105a1578063c45a015514610607578063dd62ed3e14610651578063f2fde38b146106c957610116565b80638da5cb5b146103de5780638f99d7371461042857806395d89b4114610472578063a0712d68146104f557610116565b8063313ce567116100e9578063313ce567146102a857806339509351146102cc57806370a0823114610332578063715018a61461038a578063893d20e81461039457610116565b806306fdde031461011b578063095ea7b31461019e57806318160ddd1461020457806323b872dd14610222575b600080fd5b61012361070d565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610163578082015181840152602081019050610148565b50505050905090810190601f1680156101905780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ea600480360360408110156101b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107af565b604051808215151515815260200191505060405180910390f35b61020c6107cd565b6040518082815260200191505060405180910390f35b61028e6004803603606081101561023857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107d7565b604051808215151515815260200191505060405180910390f35b6102b06108b0565b604051808260ff1660ff16815260200191505060405180910390f35b610318600480360360408110156102e257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108c7565b604051808215151515815260200191505060405180910390f35b6103746004803603602081101561034857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061097a565b6040518082815260200191505060405180910390f35b6103926109c3565b005b61039c610b4b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103e6610b5a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610430610b83565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61047a610ba9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104ba57808201518184015260208101905061049f565b50505050905090810190601f1680156104e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105216004803603602081101561050b57600080fd5b8101908080359060200190929190505050610c4b565b604051808215151515815260200191505060405180910390f35b6105876004803603604081101561055157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d30565b604051808215151515815260200191505060405180910390f35b6105ed600480360360408110156105b757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dfd565b604051808215151515815260200191505060405180910390f35b61060f610e1b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106b36004803603604081101561066757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e41565b6040518082815260200191505060405180910390f35b61070b600480360360208110156106df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ec8565b005b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107a55780601f1061077a576101008083540402835291602001916107a5565b820191906000526020600020905b81548152906001019060200180831161078857829003601f168201915b5050505050905090565b60006107c36107bc610f9d565b8484610fa5565b6001905092915050565b6000600354905090565b60006107e484848461119c565b6108a5846107f0610f9d565b6108a085604051806060016040528060288152602001611e6960289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610856610f9d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116229092919063ffffffff16565b610fa5565b600190509392505050565b6000600460009054906101000a900460ff16905090565b60006109706108d4610f9d565b8461096b85600260006108e5610f9d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116e290919063ffffffff16565b610fa5565b6001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6109cb610f9d565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a8c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000610b55610b5a565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c415780601f10610c1657610100808354040283529160200191610c41565b820191906000526020600020905b815481529060010190602001808311610c2457829003601f168201915b5050505050905090565b6000610c55610f9d565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d16576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610d27610d21610f9d565b8361176a565b60019050919050565b6000610df3610d3d610f9d565b84610dee85604051806060016040528060258152602001611efb6025913960026000610d67610f9d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116229092919063ffffffff16565b610fa5565b6001905092915050565b6000610e11610e0a610f9d565b848461119c565b6001905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610ed0610f9d565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f91576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610f9a81611927565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561102b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611e1f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110b1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611f206022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611222576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611dfa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112a8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ed86023913960400191505060405180910390fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806113515750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b1561136657611361838383611a6b565b61161d565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561143d5760006113e560646113d7600385611c1990919063ffffffff16565b611c9f90919063ffffffff16565b905060006113fc8284611ce990919063ffffffff16565b905061142b85600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611a6b565b611436858583611a6b565b505061161c565b8173ffffffffffffffffffffffffffffffffffffffff16600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561160f5760006114bc60646114ae600385611c1990919063ffffffff16565b611c9f90919063ffffffff16565b905060006114e760646114d9603285611c1990919063ffffffff16565b611c9f90919063ffffffff16565b90506114f585600083611a6b565b600061151e6064611510601e86611c1990919063ffffffff16565b611c9f90919063ffffffff16565b90506000611549606461153b600a87611c1990919063ffffffff16565b611c9f90919063ffffffff16565b905061157887600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683611a6b565b60006115a16064611593600a88611c1990919063ffffffff16565b611c9f90919063ffffffff16565b90506115d088600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683611a6b565b60006115f7846115e9888a611ce990919063ffffffff16565b6116e290919063ffffffff16565b9050611604898983611a6b565b50505050505061161b565b61161a838383611a6b565b5b5b5b505050565b60008383111582906116cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611694578082015181840152602081019050611679565b50505050905090810190601f1680156116c15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611760576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561180d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f42455032303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b611822816003546116e290919063ffffffff16565b60038190555061187a81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116e290919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119ad576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611e436026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611ad781604051806060016040528060268152602001611eb260269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116229092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611b6c81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116e290919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600080831415611c2c5760009050611c99565b6000828402905082848281611c3d57fe5b0414611c94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611e916021913960400191505060405180910390fd5b809150505b92915050565b6000611ce183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611d33565b905092915050565b6000611d2b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611622565b905092915050565b60008083118290611ddf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611da4578082015181840152602081019050611d89565b50505050905090810190601f168015611dd15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611deb57fe5b04905080915050939250505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737342455032303a20617070726f76652066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737342455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7742455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a20617070726f766520746f20746865207a65726f2061646472657373a265627a7a72315820d7e632842a9b52d9aa2d71219268c5f18d77202f58c8ba1ec00969183192167364736f6c63430005100032536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77"; |
| | | private static final String BINARY = "6080604052600180546001600160a01b03199081167355d398326f99059ff775485246999027b319795517909155600380548216731562e481cef00b14693e43465444b726739e0cba17905560048054909116733614b30913f284e8868d7f6814bbcb62e3f8412717905534801561007657600080fd5b50600154600280546001600160a01b03199081166001600160a01b0390931692909217905560008054909116331790556108eb806100b56000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806310786a021461003b57806347be04b914610050575b600080fd5b61004e610049366004610736565b610063565b005b61004e61005e3660046106c3565b6103a7565b600254604051636eb1769f60e11b81523360048201523060248201526000916001600160a01b03169063dd62ed3e9060440160206040518083038186803b1580156100ad57600080fd5b505afa1580156100c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e5919061071d565b9050838110156101355760405162461bcd60e51b8152602060048201526016602482015275496e73756666696369656e7420616c6c6f77616e636560501b60448201526064015b60405180910390fd5b6002546040516323b872dd60e01b8152336004820152306024820152604481018690526000916001600160a01b0316906323b872dd90606401602060405180830381600087803b15801561018857600080fd5b505af115801561019c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c091906106fb565b9050806101df5760405162461bcd60e51b815260040161012c90610807565b60006101f760646101f188600a6105c7565b9061064f565b60025460035460405163a9059cbb60e01b81526001600160a01b03918216600482015260248101849052929350169063a9059cbb90604401602060405180830381600087803b15801561024957600080fd5b505af115801561025d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028191906106fb565b61029d5760405162461bcd60e51b815260040161012c90610807565b60006102af60646101f18960466105c7565b6002546004805460405163a9059cbb60e01b81526001600160a01b03918216928101929092526024820184905292935091169063a9059cbb90604401602060405180830381600087803b15801561030557600080fd5b505af1158015610319573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033d91906106fb565b6103595760405162461bcd60e51b815260040161012c90610807565b336001600160a01b03167f4ea43b897a5f947a4940ce8fc2485d2854dcf256c52754394f1804723a091a2188888860405161039693929190610830565b60405180910390a250505050505050565b6000546001600160a01b031633146104185760405162461bcd60e51b815260206004820152602e60248201527f4f6e6c792074686520636f6e74726163742063726561746f722063616e20636160448201526d1b1b081d1a1a5cc81b595d1a1bd960921b606482015260840161012c565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561045c57600080fd5b505afa158015610470573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610494919061071d565b9050818110156104dd5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640161012c565b60025460405163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b15801561052b57600080fd5b505af115801561053f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056391906106fb565b61057f5760405162461bcd60e51b815260040161012c90610807565b826001600160a01b03167f6fb24f3ad0678f9d138e80b17293be051d87911eb34e9e60f0d1b9c3805e885a836040516105ba91815260200190565b60405180910390a2505050565b6000826105d657506000610649565b60006105e28385610888565b9050826105ef8583610866565b146106465760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161012c565b90505b92915050565b600061064683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250600081836106ad5760405162461bcd60e51b815260040161012c91906107b2565b5060006106ba8486610866565b95945050505050565b600080604083850312156106d657600080fd5b82356001600160a01b03811681146106ed57600080fd5b946020939093013593505050565b60006020828403121561070d57600080fd5b8151801515811461064657600080fd5b60006020828403121561072f57600080fd5b5051919050565b60008060006040848603121561074b57600080fd5b83359250602084013567ffffffffffffffff8082111561076a57600080fd5b818601915086601f83011261077e57600080fd5b81358181111561078d57600080fd5b87602082850101111561079f57600080fd5b6020830194508093505050509250925092565b600060208083528351808285015260005b818110156107df578581018301518582016040015282016107c3565b818111156107f1576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b60008261088357634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156108b057634e487b7160e01b600052601160045260246000fd5b50029056fea2646970667358221220694ed63a5283d88a2b5d348c1fcde9747ff91126df19a57ff8395fcdff4d712164736f6c63430008070033"; |
| | | |
| | | public static final String FUNC_ALLOWANCE = "allowance"; |
| | | public static final String FUNC_RECEIVEANDAO = "receiveANDAO"; |
| | | |
| | | public static final String FUNC_APPROVE = "approve"; |
| | | public static final String FUNC_WITHDRAWANDAO = "withdrawANDAO"; |
| | | |
| | | public static final String FUNC_BALANCEOF = "balanceOf"; |
| | | |
| | | public static final String FUNC_DECIMALS = "decimals"; |
| | | |
| | | public static final String FUNC_DECREASEALLOWANCE = "decreaseAllowance"; |
| | | |
| | | public static final String FUNC_FACTORY = "factory"; |
| | | |
| | | public static final String FUNC_GETOWNER = "getOwner"; |
| | | |
| | | public static final String FUNC_INCREASEALLOWANCE = "increaseAllowance"; |
| | | |
| | | public static final String FUNC_LPACC = "lpacc"; |
| | | |
| | | public static final String FUNC_MINT = "mint"; |
| | | |
| | | public static final String FUNC_NAME = "name"; |
| | | |
| | | public static final String FUNC_OWNER = "owner"; |
| | | |
| | | public static final String FUNC_RENOUNCEOWNERSHIP = "renounceOwnership"; |
| | | |
| | | public static final String FUNC_SYMBOL = "symbol"; |
| | | |
| | | public static final String FUNC_TOTALSUPPLY = "totalSupply"; |
| | | |
| | | public static final String FUNC_TRANSFER = "transfer"; |
| | | |
| | | public static final String FUNC_TRANSFERFROM = "transferFrom"; |
| | | |
| | | public static final String FUNC_TRANSFEROWNERSHIP = "transferOwnership"; |
| | | |
| | | public static final Event APPROVAL_EVENT = new Event("Approval", |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Uint256>() {})); |
| | | public static final Event RECEIVED_EVENT = new Event("received", |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {})); |
| | | ; |
| | | |
| | | public static final Event OWNERSHIPTRANSFERRED_EVENT = new Event("OwnershipTransferred", |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {})); |
| | | ; |
| | | |
| | | public static final Event TRANSFER_EVENT = new Event("Transfer", |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Address>(true) {}, new TypeReference<Uint256>() {})); |
| | | public static final Event WITHDRAWN_EVENT = new Event("withdrawn", |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}, new TypeReference<Uint256>() {})); |
| | | ; |
| | | |
| | | @Deprecated |
| | |
| | | super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); |
| | | } |
| | | |
| | | public List<ApprovalEventResponse> getApprovalEvents(TransactionReceipt transactionReceipt) { |
| | | List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(APPROVAL_EVENT, transactionReceipt); |
| | | ArrayList<ApprovalEventResponse> responses = new ArrayList<ApprovalEventResponse>(valueList.size()); |
| | | public RemoteFunctionCall<TransactionReceipt> receiveANDAO(BigInteger amount, String regFlow) { |
| | | final Function function = new Function( |
| | | FUNC_RECEIVEANDAO, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(amount), |
| | | new org.web3j.abi.datatypes.Utf8String(regFlow)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | } |
| | | |
| | | public List<ReceivedEventResponse> getReceivedEvents(TransactionReceipt transactionReceipt) { |
| | | List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(RECEIVED_EVENT, transactionReceipt); |
| | | ArrayList<ReceivedEventResponse> responses = new ArrayList<ReceivedEventResponse>(valueList.size()); |
| | | for (Contract.EventValuesWithLog eventValues : valueList) { |
| | | ApprovalEventResponse typedResponse = new ApprovalEventResponse(); |
| | | typedResponse.log = eventValues.getLog(); |
| | | typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.spender = (String) eventValues.getIndexedValues().get(1).getValue(); |
| | | typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | responses.add(typedResponse); |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | public Flowable<ApprovalEventResponse> approvalEventFlowable(EthFilter filter) { |
| | | return web3j.ethLogFlowable(filter).map(new Function<Log, ApprovalEventResponse>() { |
| | | @Override |
| | | public ApprovalEventResponse apply(Log log) { |
| | | Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(APPROVAL_EVENT, log); |
| | | ApprovalEventResponse typedResponse = new ApprovalEventResponse(); |
| | | typedResponse.log = log; |
| | | typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.spender = (String) eventValues.getIndexedValues().get(1).getValue(); |
| | | typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | return typedResponse; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public Flowable<ApprovalEventResponse> approvalEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { |
| | | EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); |
| | | filter.addSingleTopic(EventEncoder.encode(APPROVAL_EVENT)); |
| | | return approvalEventFlowable(filter); |
| | | } |
| | | |
| | | public List<OwnershipTransferredEventResponse> getOwnershipTransferredEvents(TransactionReceipt transactionReceipt) { |
| | | List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, transactionReceipt); |
| | | ArrayList<OwnershipTransferredEventResponse> responses = new ArrayList<OwnershipTransferredEventResponse>(valueList.size()); |
| | | for (Contract.EventValuesWithLog eventValues : valueList) { |
| | | OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse(); |
| | | typedResponse.log = eventValues.getLog(); |
| | | typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue(); |
| | | responses.add(typedResponse); |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | public Flowable<OwnershipTransferredEventResponse> ownershipTransferredEventFlowable(EthFilter filter) { |
| | | return web3j.ethLogFlowable(filter).map(new Function<Log, OwnershipTransferredEventResponse>() { |
| | | @Override |
| | | public OwnershipTransferredEventResponse apply(Log log) { |
| | | Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, log); |
| | | OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse(); |
| | | typedResponse.log = log; |
| | | typedResponse.previousOwner = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.newOwner = (String) eventValues.getIndexedValues().get(1).getValue(); |
| | | return typedResponse; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public Flowable<OwnershipTransferredEventResponse> ownershipTransferredEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { |
| | | EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); |
| | | filter.addSingleTopic(EventEncoder.encode(OWNERSHIPTRANSFERRED_EVENT)); |
| | | return ownershipTransferredEventFlowable(filter); |
| | | } |
| | | |
| | | public List<TransferEventResponse> getTransferEvents(TransactionReceipt transactionReceipt) { |
| | | List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt); |
| | | ArrayList<TransferEventResponse> responses = new ArrayList<TransferEventResponse>(valueList.size()); |
| | | for (Contract.EventValuesWithLog eventValues : valueList) { |
| | | TransferEventResponse typedResponse = new TransferEventResponse(); |
| | | ReceivedEventResponse typedResponse = new ReceivedEventResponse(); |
| | | typedResponse.log = eventValues.getLog(); |
| | | typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); |
| | | typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | typedResponse.regFlow = (String) eventValues.getNonIndexedValues().get(1).getValue(); |
| | | responses.add(typedResponse); |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | public Flowable<TransferEventResponse> transferEventFlowable(EthFilter filter) { |
| | | return web3j.ethLogFlowable(filter).map(new Function<Log, TransferEventResponse>() { |
| | | public Flowable<ReceivedEventResponse> receivedEventFlowable(EthFilter filter) { |
| | | return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, ReceivedEventResponse>() { |
| | | @Override |
| | | public TransferEventResponse apply(Log log) { |
| | | Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(TRANSFER_EVENT, log); |
| | | TransferEventResponse typedResponse = new TransferEventResponse(); |
| | | typedResponse.log = log; |
| | | |
| | | public ReceivedEventResponse apply(Log log) { |
| | | Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(RECEIVED_EVENT, log); |
| | | ReceivedEventResponse typedResponse = new ReceivedEventResponse(); |
| | | if(eventValues==null){ |
| | | // 为空则直接返回空对象 |
| | | return typedResponse; |
| | | } |
| | | typedResponse.log = log; |
| | | typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.to = (String) eventValues.getIndexedValues().get(1).getValue(); |
| | | typedResponse.value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | typedResponse.regFlow = (String) eventValues.getNonIndexedValues().get(1).getValue(); |
| | | return typedResponse; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public Flowable<TransferEventResponse> transferEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { |
| | | public Flowable<ReceivedEventResponse> receivedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { |
| | | EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); |
| | | filter.addSingleTopic(EventEncoder.encode(TRANSFER_EVENT)); |
| | | return transferEventFlowable(filter); |
| | | filter.addSingleTopic(EventEncoder.encode(RECEIVED_EVENT)); |
| | | return receivedEventFlowable(filter); |
| | | } |
| | | |
| | | public RemoteFunctionCall<BigInteger> allowance(String owner, String spender) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_ALLOWANCE, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, owner), |
| | | new org.web3j.abi.datatypes.Address(160, spender)), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, BigInteger.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> approve(String spender, BigInteger amount) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_APPROVE, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, spender), |
| | | new org.web3j.abi.datatypes.generated.Uint256(amount)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | } |
| | | |
| | | public RemoteFunctionCall<BigInteger> balanceOf(String account) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_BALANCEOF, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, account)), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, BigInteger.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<BigInteger> decimals() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_DECIMALS, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Uint8>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, BigInteger.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> decreaseAllowance(String spender, BigInteger subtractedValue) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_DECREASEALLOWANCE, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, spender), |
| | | new org.web3j.abi.datatypes.generated.Uint256(subtractedValue)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | } |
| | | |
| | | public RemoteFunctionCall<String> factory() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FACTORY, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, String.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<String> getOwner() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_GETOWNER, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, String.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> increaseAllowance(String spender, BigInteger addedValue) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_INCREASEALLOWANCE, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, spender), |
| | | new org.web3j.abi.datatypes.generated.Uint256(addedValue)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | } |
| | | |
| | | public RemoteFunctionCall<String> lpacc() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_LPACC, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, String.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> mint(BigInteger amount) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_MINT, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(amount)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | } |
| | | |
| | | public RemoteFunctionCall<String> name() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_NAME, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, String.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<String> owner() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_OWNER, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, String.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> renounceOwnership() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_RENOUNCEOWNERSHIP, |
| | | Arrays.<Type>asList(), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | } |
| | | |
| | | public RemoteFunctionCall<String> symbol() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_SYMBOL, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, String.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<BigInteger> totalSupply() { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_TOTALSUPPLY, |
| | | Arrays.<Type>asList(), |
| | | Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {})); |
| | | return executeRemoteCallSingleValueReturn(function, BigInteger.class); |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> transfer(String recipient, BigInteger amount) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_TRANSFER, |
| | | public RemoteFunctionCall<TransactionReceipt> withdrawANDAO(String recipient, BigInteger amount) { |
| | | final Function function = new Function( |
| | | FUNC_WITHDRAWANDAO, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, recipient), |
| | | new org.web3j.abi.datatypes.generated.Uint256(amount)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> transferFrom(String sender, String recipient, BigInteger amount) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_TRANSFERFROM, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, sender), |
| | | new org.web3j.abi.datatypes.Address(160, recipient), |
| | | new org.web3j.abi.datatypes.generated.Uint256(amount)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | public List<WithdrawnEventResponse> getWithdrawnEvents(TransactionReceipt transactionReceipt) { |
| | | List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(WITHDRAWN_EVENT, transactionReceipt); |
| | | ArrayList<WithdrawnEventResponse> responses = new ArrayList<WithdrawnEventResponse>(valueList.size()); |
| | | for (Contract.EventValuesWithLog eventValues : valueList) { |
| | | WithdrawnEventResponse typedResponse = new WithdrawnEventResponse(); |
| | | typedResponse.log = eventValues.getLog(); |
| | | typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | responses.add(typedResponse); |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | public RemoteFunctionCall<TransactionReceipt> transferOwnership(String newOwner) { |
| | | final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function( |
| | | FUNC_TRANSFEROWNERSHIP, |
| | | Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, newOwner)), |
| | | Collections.<TypeReference<?>>emptyList()); |
| | | return executeRemoteCallTransaction(function); |
| | | public Flowable<WithdrawnEventResponse> withdrawnEventFlowable(EthFilter filter) { |
| | | return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, WithdrawnEventResponse>() { |
| | | @Override |
| | | public WithdrawnEventResponse apply(Log log) { |
| | | Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(WITHDRAWN_EVENT, log); |
| | | WithdrawnEventResponse typedResponse = new WithdrawnEventResponse(); |
| | | if(eventValues==null){ |
| | | // 为空则直接返回空对象 |
| | | return typedResponse; |
| | | } |
| | | typedResponse.log = log; |
| | | typedResponse.to = (String) eventValues.getIndexedValues().get(0).getValue(); |
| | | typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); |
| | | return typedResponse; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public Flowable<WithdrawnEventResponse> withdrawnEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { |
| | | EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); |
| | | filter.addSingleTopic(EventEncoder.encode(WITHDRAWN_EVENT)); |
| | | return withdrawnEventFlowable(filter); |
| | | } |
| | | |
| | | @Deprecated |
| | |
| | | return deployRemoteCall(Abi.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); |
| | | } |
| | | |
| | | public static class ApprovalEventResponse extends BaseEventResponse { |
| | | public String owner; |
| | | |
| | | public String spender; |
| | | |
| | | public BigInteger value; |
| | | } |
| | | |
| | | public static class OwnershipTransferredEventResponse extends BaseEventResponse { |
| | | public String previousOwner; |
| | | |
| | | public String newOwner; |
| | | } |
| | | |
| | | public static class TransferEventResponse extends BaseEventResponse { |
| | | public static class ReceivedEventResponse extends BaseEventResponse { |
| | | public String from; |
| | | |
| | | public BigInteger amount; |
| | | |
| | | public String regFlow; |
| | | } |
| | | |
| | | public static class WithdrawnEventResponse extends BaseEventResponse { |
| | | public String to; |
| | | |
| | | public BigInteger value; |
| | | public BigInteger amount; |
| | | } |
| | | } |
| | |
| | | import cc.mrbird.febs.common.service.RedisService; |
| | | import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | |
| | | |
| | | |
| | | @Component |
| | | @ConditionalOnProperty(prefix = "system", name = "quartz-job", havingValue = "true") |
| | | public class AndaoContractInit { |
| | | |
| | | @Autowired |
| | |
| | | private RedisService redisService; |
| | | |
| | | |
| | | // @PostConstruct |
| | | // public void init(){ |
| | | // // 设置起始区块编号 TODO |
| | | // BigInteger start = new BigInteger("29636613"); |
| | | // // 需要打开 获取最新区块编号 |
| | | // Object bnb_block_number = redisService.get("BNB_BLOCK_NUMBER"); |
| | | // if(bnb_block_number !=null){ |
| | | // start = BigInteger.valueOf(Long.valueOf(bnb_block_number.toString())); |
| | | // } |
| | | // System.out.println("启动区块事件监听,监听起始:"+start); |
| | | // andaoContractMain.listenBetting(start); |
| | | // } |
| | | @PostConstruct |
| | | public void init(){ |
| | | // 设置起始区块编号 TODO |
| | | BigInteger start = new BigInteger("29837079"); |
| | | // 需要打开 获取最新区块编号 |
| | | Object bnb_block_number = redisService.get("BNB_BLOCK_NUMBER"); |
| | | if(bnb_block_number !=null){ |
| | | start = BigInteger.valueOf(Long.valueOf(bnb_block_number.toString())); |
| | | } |
| | | System.out.println("启动区块事件监听,监听起始:"+start); |
| | | andaoContractMain.listenBetting(start); |
| | | } |
| | | } |
| | |
| | | |
| | | import cc.mrbird.febs.common.contants.SystemConstants; |
| | | import cc.mrbird.febs.common.service.RedisService; |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.stereotype.Component; |
| | | import org.web3j.crypto.Credentials; |
| | | import org.web3j.protocol.Web3j; |
| | |
| | | |
| | | |
| | | @Component |
| | | @ConditionalOnProperty(prefix = "system", name = "quartz-job", havingValue = "true") |
| | | public class AndaoContractMain { |
| | | |
| | | @Autowired |
| | | private ChainProducer chainProducer; |
| | | |
| | | @Autowired |
| | | private DappMemberDao dappMemberDao; |
| | | |
| | | @Autowired |
| | | private DappFundFlowDao dappFundFlowDao; |
| | | |
| | | @Autowired |
| | | private SystemConstants systemConstants; |
| | |
| | | |
| | | // 合约地址 TODO |
| | | // private static String contractAddr = "0xb5a1aC0fA05BFb8ad16B231e84b0bAC1d46eAfD0";//测试 |
| | | private static String contractAddr = "0x06Bd96a05B0B7B06449F1da58E8918cc6AfBB394"; |
| | | private static String contractAddr = "0x99A08A65DB5542f35b96FD69F01896Bd3cDB9DC4"; |
| | | |
| | | // 操作账号 手续费钱包地址的私钥(合约里会把手续费转到你这个私钥地址上) 用于操作合约内方法 TODO |
| | | private static String privateKey = "221be67f85375a5af6dd0f4b77fbe877ad2e57e05db201de1b1383fb76494d18";//测试 |
| | | private static String privateKey = "3ff7147104fcc4b3e47eef1c6a826107ad13f8ceaf46d6747b7cd4e56f8b01c6";//测试 |
| | | |
| | | // private static String privateKey = AppContants.FEE_ADDRESS_KEY.get("feeAddressKey").toString() ; |
| | | |
| | |
| | | Credentials credentials = Credentials.create(privateKey); |
| | | Abi contract = Abi.load(contractAddr, getInstanceScope(), credentials, new DefaultGasProvider()); |
| | | EthFilter filter = getFilter(startBlock); |
| | | contract.transferEventFlowable(filter).subscribe(e->{ |
| | | contract.receivedEventFlowable(filter).subscribe(e->{ |
| | | try { |
| | | // 投注人的地址 |
| | | String from = e.from; |
| | | String to = e.to; |
| | | BigInteger amount = e.value; |
| | | if(from==null){ |
| | | // 为空则不进入后续逻辑 |
| | | return; |
| | | } |
| | | |
| | | // TODO 业务操作逻辑代码 |
| | | System.out.println("from:"+from+",to:"+to+",amount:"+amount); |
| | | // 更新区块编号 TODO |
| | | redisService.set("BNB_BLOCK_NUMBER",e.log.getBlockNumber().intValue()); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectByAddress(from, "BSC"); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return; |
| | | } |
| | | BigInteger amount = e.amount; |
| | | String regFlow = e.regFlow; |
| | | if(regFlow==null){ |
| | | // 为空则不进入后续逻辑 |
| | | return; |
| | | } |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(Long.parseLong(regFlow)); |
| | | if(ObjectUtil.isEmpty(dappFundFlowEntity)){ |
| | | return; |
| | | } |
| | | |
| | | // TODO 业务操作逻辑代码 |
| | | System.out.println("from:"+from+",amount:"+amount+",regFlow:"+regFlow); |
| | | chainProducer.sendContractAnDao(Long.parseLong(regFlow)); |
| | | //投注人 |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectByAddress(from, "BSC"); |
| | | // if(ObjectUtil.isNotEmpty(dappMemberEntity)){ |
| | |
| | | Abi contract = Abi.load(contractAddr, getInstance(), credentials, getStaticGasProvider()); |
| | | try { |
| | | //BigInteger bigInteger = Convert.toWei(amount.toString(), Convert.Unit.ETHER).toBigInteger(); |
| | | TransactionReceipt send = contract.transfer(to1, amount).send(); |
| | | if(ObjectUtil.isNotEmpty(send)){ |
| | | transactionHash = send.getTransactionHash(); |
| | | } |
| | | } catch (Exception exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | | return transactionHash; |
| | | } |
| | | |
| | | /** |
| | | * 从合约内转币到制定地址 |
| | | */ |
| | | public String burnToken(BigInteger amount, String to1){ |
| | | String transactionHash = null; |
| | | Credentials credentials = Credentials.create(privateKey); |
| | | Abi contract = Abi.load(contractAddr, getInstance(), credentials, getStaticGasProvider()); |
| | | try { |
| | | //BigInteger bigInteger = Convert.toWei(amount.toString(), Convert.Unit.ETHER).toBigInteger(); |
| | | TransactionReceipt send = contract.transfer(to1, amount).send(); |
| | | TransactionReceipt send = contract.withdrawANDAO(to1, amount).send(); |
| | | if(ObjectUtil.isNotEmpty(send)){ |
| | | transactionHash = send.getTransactionHash(); |
| | | } |
| | |
| | | AndaoContractMain andaoContractMain = new AndaoContractMain(); |
| | | |
| | | String address = "0x7a9bfE048d110EF90a467803653f9B8666f9096C"; |
| | | // String address = "0x785D5Aa2951Ac4C6f28Dc593AF0b0536Dd3E82Fe"; |
| | | BigInteger bigInteger = new BigInteger(Convert.toWei("1", Convert.Unit.ETHER).setScale(0).toString()); |
| | | String hash = andaoContractMain.trans(bigInteger,address); |
| | | System.out.println(hash); |
| | |
| | | void antKLineABMsg(Long id); |
| | | |
| | | void allMemberPerkAvaMsg(Long id); |
| | | |
| | | void contractAnDaoMsg(Long flowId); |
| | | |
| | | void contractAnDaoInMsg(Long flowId); |
| | | } |
| | |
| | | package cc.mrbird.febs.dapp.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.SpringContextUtil; |
| | |
| | | import java.math.BigInteger; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.Lock; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // String address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | // String address = "0x7a9bfE048d110EF90a467803653f9B8666f9096C"; |
| | | // /** |
| | | // * 发起USDT转账 |
| | | // */ |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(address, new BigDecimal("0.01")); |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, new BigDecimal("0.99")); |
| | | // System.out.println(hash); |
| | | // } |
| | | |
| | | @Override |
| | |
| | | * 发起USDT转账 |
| | | */ |
| | | log.info("amount:{},address:{}",amount,address); |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transfer(address, amount); |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL.name()).transfer(address, amount); |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount); |
| | | if(StrUtil.isEmpty(hash)){ |
| | | return; |
| | | } |
| | |
| | | * 紧急提现方法 |
| | | */ |
| | | public static void main(String[] args) { |
| | | BigDecimal amount = new BigDecimal("1000"); |
| | | String address = "0x844309788dD5B6050B3D6Ab6AF4B4Cc00d120840"; |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).transfer(address, amount); |
| | | BigDecimal amount = new BigDecimal("1"); |
| | | String address = "0xB3cF9669F398f444DfCAebbAd2A49bF32ba41fE3"; |
| | | |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount); |
| | | |
| | | System.out.println(hash); |
| | | |
| | | |
| | | // int i = ChainService.getInstance(ChainEnum.BSC_TFC.name()).allowanceCnt("0x80098f854950f9327C4F4E747d285Fd2d41fbf3e"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | AppContants.YL_MEMBER_ID,1); |
| | | |
| | | } |
| | | @Override |
| | | public void contractAnDaoMsg(Long flowId) { |
| | | DappFundFlowEntity flow = dappFundFlowDao.selectById(flowId); |
| | | if(ObjectUtil.isEmpty(flow)){ |
| | | return; |
| | | } |
| | | Long memberId = flow.getMemberId(); |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == flow.getStatus()){ |
| | | return; |
| | | } |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return; |
| | | } |
| | | /** |
| | | * 生成会员入金买A币的记录 |
| | | */ |
| | | DappChargeUsdtEntity dappChargeUsdtEntity = new DappChargeUsdtEntity( |
| | | memberId, |
| | | dappMemberEntity.getAddress(), |
| | | null, |
| | | 2, |
| | | flow.getAmount(), |
| | | BigDecimal.ZERO, |
| | | BigDecimal.ZERO); |
| | | dappChargeUsdtMapper.insert(dappChargeUsdtEntity); |
| | | /** |
| | | * 减少用户的AUSD数量 |
| | | */ |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId); |
| | | BigDecimal ausdAmount = dappUsdtPerkEntity.getAusdAmount(); |
| | | ausdAmount = ausdAmount.subtract(flow.getFee()).setScale(4,BigDecimal.ROUND_DOWN); |
| | | dappUsdtPerkEntity.setAusdAmount(ausdAmount); |
| | | dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity); |
| | | /** |
| | | * 流水关联用户购买记录 |
| | | */ |
| | | flow.setSystemProfitId(dappChargeUsdtEntity.getId()); |
| | | /** |
| | | * 链上转账的hash值 |
| | | */ |
| | | // flow.setFromHash(null); |
| | | flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(flow); |
| | | |
| | | /** |
| | | * 发送消息处理返利逻辑 |
| | | */ |
| | | chainProducer.sendAntACoinInContractMsg(flow.getId()); |
| | | /** |
| | | * 发送消息处理代理升级 |
| | | */ |
| | | chainProducer.sendAntMemberLevelMsg(memberId); |
| | | } |
| | | |
| | | @Override |
| | | public void contractAnDaoInMsg(Long flowId) { |
| | | /** |
| | | * 获取对应的流水记录 |
| | | */ |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectInfoById(flowId); |
| | | if(ObjectUtil.isEmpty(dappFundFlowEntity)){ |
| | | return; |
| | | } |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE != dappFundFlowEntity.getStatus()){ |
| | | return; |
| | | } |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return; |
| | | } |
| | | /** |
| | | * 会员充值金额 |
| | | */ |
| | | BigDecimal amount = dappFundFlowEntity.getAmount(); |
| | | /** |
| | | * A币的当前价格 |
| | | */ |
| | | DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_PRICE.getType(), |
| | | PoolEnum.COIN_A_PRICE.getCode() |
| | | ); |
| | | BigDecimal coinAPrice = new BigDecimal(StrUtil.isEmpty(coinAPriceDic.getValue()) ? "0" : coinAPriceDic.getValue()).setScale(12,BigDecimal.ROUND_DOWN); |
| | | /** |
| | | * 会员充值USDT买入A币记录的ID |
| | | */ |
| | | Long chergeRecordId = dappFundFlowEntity.getSystemProfitId() == null ? 0L : dappFundFlowEntity.getSystemProfitId(); |
| | | DappChargeUsdtEntity dappChargeUsdtEntity = dappChargeUsdtMapper.selectById(chergeRecordId); |
| | | if(ObjectUtil.isEmpty(dappChargeUsdtEntity)){ |
| | | return; |
| | | } |
| | | if(2 != dappChargeUsdtEntity.getStatus()){ |
| | | return; |
| | | } |
| | | // if(StrUtil.isEmpty(dappChargeUsdtEntity.getMemberHash())){ |
| | | // return; |
| | | // } |
| | | /** |
| | | * 金本位的三倍额度,增加业绩,增加对应的NFT的值 |
| | | */ |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId); |
| | | if(ObjectUtil.isEmpty(dappUsdtPerkEntity)){ |
| | | dappUsdtPerkEntity = new DappUsdtPerkEntity(); |
| | | dappUsdtPerkEntity.setAmount(amount.multiply(new BigDecimal(3))); |
| | | dappUsdtPerkEntity.setNftDevote(amount); |
| | | dappUsdtPerkEntity.setMemberId(memberId); |
| | | dappUsdtPerkEntityMapper.insert(dappUsdtPerkEntity); |
| | | } |
| | | //金本位的三倍额度 |
| | | BigDecimal amountPerk = dappUsdtPerkEntity.getAmount(); |
| | | amountPerk = amountPerk.add(amount.multiply(new BigDecimal(3))); |
| | | dappUsdtPerkEntity.setAmount(amountPerk); |
| | | //生成一条金本位的三倍额度的资金流水记录 |
| | | DappFundFlowEntity amountPerkFundFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | amount.multiply(new BigDecimal(3)), |
| | | FundFlowEnum.MEMBER_AMOUNT_PERK_TOTAL.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(amountPerkFundFlow); |
| | | |
| | | //增加业绩 |
| | | BigDecimal achieveAmount = dappUsdtPerkEntity.getAchieveAmount(); |
| | | achieveAmount = achieveAmount.add(amount); |
| | | dappUsdtPerkEntity.setAchieveAmount(achieveAmount); |
| | | //增加对应的NFT的值 |
| | | BigDecimal nftDevote = dappUsdtPerkEntity.getNftDevote(); |
| | | nftDevote = nftDevote.add(amount); |
| | | dappUsdtPerkEntity.setNftDevote(nftDevote); |
| | | dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity); |
| | | /** |
| | | * 1.90%底池的USDT做成100%溢价,铸造出70%金本位价值的A币。 |
| | | */ |
| | | DataDictionaryCustom produceAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.PRODUCE_A_PERCENT.getType(), |
| | | PoolEnum.PRODUCE_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal produceAPercent = new BigDecimal(StrUtil.isEmpty(produceAPercentDic.getValue()) ? "0.7" : produceAPercentDic.getValue()); |
| | | //购买数量 |
| | | BigDecimal totalCnt = amount.divide(coinAPrice, 4, BigDecimal.ROUND_DOWN); |
| | | /** |
| | | * 铸造出70%金本位价值的A币。实际产生数量 |
| | | */ |
| | | BigDecimal realCnt = totalCnt.multiply(produceAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | dappChargeUsdtEntity.setTotalCnt(totalCnt); |
| | | dappChargeUsdtEntity.setRealCnt(realCnt); |
| | | dappChargeUsdtMapper.updateById(dappChargeUsdtEntity); |
| | | /** |
| | | * 重新计算A币的价格 |
| | | */ |
| | | DataDictionaryCustom coinACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_CNT.getType(), |
| | | PoolEnum.COIN_A_CNT.getCode() |
| | | ); |
| | | //A币币本位底池-A币的数量 |
| | | BigDecimal coinACntDicCnt = new BigDecimal(coinACntDic.getValue()); |
| | | coinACntDicCnt = coinACntDicCnt.add(realCnt); |
| | | coinACntDic.setValue(coinACntDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinACntDic); |
| | | |
| | | DataDictionaryCustom coinAUsdtPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_USDT_PRICE.getType(), |
| | | PoolEnum.COIN_A_USDT_PRICE.getCode() |
| | | ); |
| | | //A币金本位底池-usdt数量 |
| | | BigDecimal coinAUsdtPriceDicCnt = new BigDecimal(coinAUsdtPriceDic.getValue()); |
| | | coinAUsdtPriceDicCnt = coinAUsdtPriceDicCnt.add(amount); |
| | | coinAUsdtPriceDic.setValue(coinAUsdtPriceDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAUsdtPriceDic); |
| | | |
| | | BigDecimal divide = coinAUsdtPriceDicCnt.divide(coinACntDicCnt, 12, BigDecimal.ROUND_DOWN); |
| | | coinAPriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAPriceDic); |
| | | |
| | | chainProducer.sendAntKLineMsg(0); |
| | | /** |
| | | * A币的分配 walletMine |
| | | * 【70%换算100%分配】 |
| | | * 50%客户秒到 |
| | | * 20%全网加权分红(按20%释放递减) |
| | | * 10%直推 |
| | | * 5%节点 |
| | | * 5%基金会 |
| | | * 10%级差奖 |
| | | */ |
| | | /** |
| | | * 50%客户秒到 |
| | | */ |
| | | DataDictionaryCustom memberGetAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.MEMBER_GET_A_PERCENT.getType(), |
| | | PoolEnum.MEMBER_GET_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal memberGetAPercent = new BigDecimal(StrUtil.isEmpty(memberGetAPercentDic.getValue()) ? "0.5" : memberGetAPercentDic.getValue()); |
| | | BigDecimal memberGetACnt = realCnt.multiply(memberGetAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | BigDecimal fundFlowToMemberFlag = this.getAndUpdateMemberPerk(dappFundFlowEntity.getMemberId(), memberGetACnt); |
| | | if(fundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){ |
| | | //生成一条50%客户秒到的资金流水记录 |
| | | DappFundFlowEntity fundFlowToMember = new DappFundFlowEntity( |
| | | dappFundFlowEntity.getMemberId(), |
| | | fundFlowToMemberFlag, |
| | | FundFlowEnum.MEMBER_GET_A_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(fundFlowToMember); |
| | | //用户的A币账户增加memberGetACnt数量 |
| | | dappWalletService.updateWalletMineWithLock(fundFlowToMemberFlag,dappFundFlowEntity.getMemberId(),1); |
| | | } |
| | | /** |
| | | * 20%全网加权分红(按20%释放递减)进入加权分红底池 |
| | | */ |
| | | DataDictionaryCustom poolAllMemberAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getType(), |
| | | PoolEnum.POOL_ALL_MEMBER_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal poolAllMemberAPercent = new BigDecimal(StrUtil.isEmpty(poolAllMemberAPercentDic.getValue()) ? "0.2" : poolAllMemberAPercentDic.getValue()); |
| | | BigDecimal poolAllMemberAPercentCnt = realCnt.multiply(poolAllMemberAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | DataDictionaryCustom poolAllMemberACntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.POOL_ALL_MEMBER_A_CNT.getType(), |
| | | PoolEnum.POOL_ALL_MEMBER_A_CNT.getCode() |
| | | ); |
| | | BigDecimal poolAllMemberACnt = new BigDecimal(StrUtil.isEmpty(poolAllMemberACntDic.getValue()) ? "0" : poolAllMemberACntDic.getValue()); |
| | | poolAllMemberACnt = poolAllMemberACnt.add(poolAllMemberAPercentCnt); |
| | | poolAllMemberACntDic.setValue(poolAllMemberACnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(poolAllMemberACntDic); |
| | | //生成一条20%全网加权分红(按20%释放递减)进入加权分红底池的资金流水记录 |
| | | DappFundFlowEntity poolAllMemberAFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | poolAllMemberAPercentCnt, |
| | | FundFlowEnum.POOL_ALL_MEMBER_A_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(poolAllMemberAFundFlow); |
| | | |
| | | /** |
| | | * 20%全网加权平分,按照个人投资占比全网的比例去平分 |
| | | */ |
| | | chainProducer.sendAllMemberPerkAvaMsg(poolAllMemberAFundFlow.getId()); |
| | | /** |
| | | * 10%直推 |
| | | */ |
| | | DataDictionaryCustom directAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.DIRECT_A_PERCENT.getType(), |
| | | PoolEnum.DIRECT_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal directAPercent = new BigDecimal(StrUtil.isEmpty(directAPercentDic.getValue()) ? "0.1" : directAPercentDic.getValue()); |
| | | BigDecimal directAPercentCnt = realCnt.multiply(directAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | String refererId = dappMemberEntity.getRefererId(); |
| | | DappMemberEntity directMemberEntity = dappMemberDao.selectMemberInfoByInviteId(refererId); |
| | | if(ObjectUtil.isNotEmpty(directMemberEntity)){ |
| | | /** |
| | | *推荐用户入单可享有贡献值.例.推荐100获得100贡献值 |
| | | */ |
| | | DappUsdtPerkEntity directDappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(directMemberEntity.getId()); |
| | | if(ObjectUtil.isEmpty(directDappUsdtPerkEntity)){ |
| | | directDappUsdtPerkEntity = new DappUsdtPerkEntity(); |
| | | directDappUsdtPerkEntity.setNftDevote(amount); |
| | | directDappUsdtPerkEntity.setMemberId(directMemberEntity.getId()); |
| | | dappUsdtPerkEntityMapper.insert(directDappUsdtPerkEntity); |
| | | } |
| | | |
| | | BigDecimal directNftDevote = directDappUsdtPerkEntity.getNftDevote(); |
| | | directNftDevote = directNftDevote.add(amount); |
| | | directDappUsdtPerkEntity.setNftDevote(directNftDevote); |
| | | dappUsdtPerkEntityMapper.updateById(directDappUsdtPerkEntity); |
| | | |
| | | BigDecimal directAPercentFundFlowToMemberFlag = this.getAndUpdateMemberPerk(directMemberEntity.getId(), directAPercentCnt); |
| | | if(directAPercentFundFlowToMemberFlag.compareTo(BigDecimal.ZERO) > 0){ |
| | | //生成一条10%直推的资金流水记录 |
| | | DappFundFlowEntity directAPercentFundFlowToMember = new DappFundFlowEntity( |
| | | directMemberEntity.getId(), |
| | | directAPercentFundFlowToMemberFlag, |
| | | FundFlowEnum.DIRECT_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(directAPercentFundFlowToMember); |
| | | //用户的A币账户增加directAPercentCnt数量 |
| | | dappWalletService.updateWalletMineWithLock(directAPercentFundFlowToMemberFlag,directMemberEntity.getId(),1); |
| | | } |
| | | if(directAPercentCnt.compareTo(directAPercentFundFlowToMemberFlag) > 0){ |
| | | DappFundFlowEntity directAPercentFundFlowToMemberAva = new DappFundFlowEntity( |
| | | 1L, |
| | | directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | FundFlowEnum.DIRECT_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(directAPercentFundFlowToMemberAva); |
| | | dappWalletService.updateWalletMineWithLock(directAPercentCnt.subtract(directAPercentFundFlowToMemberFlag), |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | } |
| | | /** |
| | | * 5%节点 |
| | | */ |
| | | DataDictionaryCustom nodeAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.NODE_A_PERCENT.getType(), |
| | | PoolEnum.NODE_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal nodeAPercent = new BigDecimal(StrUtil.isEmpty(nodeAPercentDic.getValue()) ? "0.05" : nodeAPercentDic.getValue()); |
| | | BigDecimal nodeAPercentCnt = realCnt.multiply(nodeAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | //生成一条5%节点的资金流水记录 |
| | | DappFundFlowEntity nodeAPercentFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | nodeAPercentCnt, |
| | | FundFlowEnum.NODE_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlow); |
| | | // chainProducer.sendAntACoinInNodeMsg(nodeAPercentFundFlow.getId()); |
| | | DataDictionaryCustom nodeAPercentPoolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.NODE_A_PERCENT_POOL.getType(), |
| | | PoolEnum.NODE_A_PERCENT_POOL.getCode() |
| | | ); |
| | | BigDecimal nodeAPercentPoolDicCnt = new BigDecimal(StrUtil.isEmpty(nodeAPercentPoolDic.getValue()) ? "0" : nodeAPercentPoolDic.getValue()); |
| | | nodeAPercentPoolDicCnt = nodeAPercentPoolDicCnt.add(nodeAPercentCnt); |
| | | nodeAPercentPoolDic.setValue(nodeAPercentPoolDicCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(nodeAPercentPoolDic); |
| | | |
| | | BigDecimal nodeAPercentCntAva = superNodePoolPerk(nodeAPercentCnt, NodeCodeEnum.SUPER_NODE.getCode(), FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode()); |
| | | |
| | | if(nodeAPercentCnt.compareTo(nodeAPercentCntAva) > 0){ |
| | | DappFundFlowEntity nodeAPercentFundFlowAva = new DappFundFlowEntity( |
| | | 1L, |
| | | nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | FundFlowEnum.NODE_A_PERCENT_TO_MEMBER.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(nodeAPercentFundFlowAva); |
| | | dappWalletService.updateWalletMineWithLock(nodeAPercentCnt.subtract(nodeAPercentCntAva), |
| | | AppContants.YL_MEMBER_ID,1); |
| | | } |
| | | /** |
| | | * 5%基金会 |
| | | */ |
| | | DataDictionaryCustom foundationAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.FOUNDATION_A_PERCENT.getType(), |
| | | PoolEnum.FOUNDATION_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal foundationAPercent = new BigDecimal(StrUtil.isEmpty(foundationAPercentDic.getValue()) ? "0.05" : foundationAPercentDic.getValue()); |
| | | BigDecimal foundationAPercentCnt = realCnt.multiply(foundationAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | //生成一条5%基金会的资金流水记录 |
| | | DappFundFlowEntity foundationAPercentFundFlow = new DappFundFlowEntity( |
| | | 295L, |
| | | foundationAPercentCnt, |
| | | FundFlowEnum.FOUNDATION_A_PERCENT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(foundationAPercentFundFlow); |
| | | //用户的A币账户增加memberGetACnt数量 |
| | | dappWalletService.updateWalletMineWithLock(foundationAPercentCnt,295L,1); |
| | | /** |
| | | * 10%级差奖 |
| | | */ |
| | | DataDictionaryCustom levelAPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.LEVEL_A_PERCENT.getType(), |
| | | PoolEnum.LEVEL_A_PERCENT.getCode() |
| | | ); |
| | | BigDecimal levelAPercent = new BigDecimal(StrUtil.isEmpty(levelAPercentDic.getValue()) ? "0.1" : levelAPercentDic.getValue()); |
| | | BigDecimal levelAPercentCnt = realCnt.multiply(levelAPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | |
| | | //生成一条10%级差奖进入10%级差奖底池的资金流水记录 |
| | | DappFundFlowEntity levelAPercentCntFundFlow = new DappFundFlowEntity( |
| | | 1L, |
| | | levelAPercentCnt, |
| | | FundFlowEnum.LEVEL_A_PERCENT_CNT.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | chergeRecordId); |
| | | dappFundFlowDao.insert(levelAPercentCntFundFlow); |
| | | chainProducer.sendAntACoinInLevelMsg(levelAPercentCntFundFlow.getId()); |
| | | |
| | | /** |
| | | * 更新用户为有效用户 |
| | | */ |
| | | dappMemberDao.updateMemberActiveStatus(1,memberId); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 测试转账 |
| | |
| | | 1, |
| | | ausdAmountNeed, |
| | | transferADto.getTxHash()); |
| | | |
| | | |
| | | // DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | // member.getId(), |
| | | // transferADto.getAmount(), |
| | | // type, |
| | | // 1, |
| | | // new BigDecimal("1"), |
| | | // transferADto.getTxHash()); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | return fundFlow.getId(); |
| | | } |
| | |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE == flow.getStatus()){ |
| | | throw new FebsException("请勿重复提交"); |
| | | } |
| | | /** |
| | | * 生成会员入金买A币的记录 |
| | | */ |
| | | DappChargeUsdtEntity dappChargeUsdtEntity = new DappChargeUsdtEntity( |
| | | member.getId(), |
| | | dappMemberEntity.getAddress(), |
| | | transferADto.getTxHash(), |
| | | 2, |
| | | transferADto.getAmount(), |
| | | BigDecimal.ZERO, |
| | | BigDecimal.ZERO); |
| | | dappChargeUsdtMapper.insert(dappChargeUsdtEntity); |
| | | /** |
| | | * 减少用户的AUSD数量 |
| | | */ |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(member.getId()); |
| | | BigDecimal ausdAmount = dappUsdtPerkEntity.getAusdAmount(); |
| | | ausdAmount = ausdAmount.subtract(flow.getFee()).setScale(4,BigDecimal.ROUND_DOWN); |
| | | dappUsdtPerkEntity.setAusdAmount(ausdAmount); |
| | | dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity); |
| | | /** |
| | | * 流水关联用户购买记录 |
| | | */ |
| | | flow.setSystemProfitId(dappChargeUsdtEntity.getId()); |
| | | |
| | | /** |
| | | * 链上转账的hash值 |
| | | */ |
| | | flow.setFromHash(transferADto.getTxHash()); |
| | | flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(flow); |
| | | /** |
| | | * 发送消息处理返利逻辑 |
| | | */ |
| | | chainProducer.sendAntACoinInMsg(flow.getId()); |
| | | /** |
| | | * 发送消息处理代理升级 |
| | | */ |
| | | chainProducer.sendAntMemberLevelMsg(member.getId()); |
| | | // /** |
| | | // * 生成会员入金买A币的记录 |
| | | // */ |
| | | // DappChargeUsdtEntity dappChargeUsdtEntity = new DappChargeUsdtEntity( |
| | | // member.getId(), |
| | | // dappMemberEntity.getAddress(), |
| | | // transferADto.getTxHash(), |
| | | // 2, |
| | | // transferADto.getAmount(), |
| | | // BigDecimal.ZERO, |
| | | // BigDecimal.ZERO); |
| | | // dappChargeUsdtMapper.insert(dappChargeUsdtEntity); |
| | | // /** |
| | | // * 减少用户的AUSD数量 |
| | | // */ |
| | | // DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(member.getId()); |
| | | // BigDecimal ausdAmount = dappUsdtPerkEntity.getAusdAmount(); |
| | | // ausdAmount = ausdAmount.subtract(flow.getFee()).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // dappUsdtPerkEntity.setAusdAmount(ausdAmount); |
| | | // dappUsdtPerkEntityMapper.updateById(dappUsdtPerkEntity); |
| | | // /** |
| | | // * 流水关联用户购买记录 |
| | | // */ |
| | | // flow.setSystemProfitId(dappChargeUsdtEntity.getId()); |
| | | // /** |
| | | // * 链上转账的hash值 |
| | | // */ |
| | | // flow.setFromHash(transferADto.getTxHash()); |
| | | // flow.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | // dappFundFlowDao.updateById(flow); |
| | | // /** |
| | | // * 发送消息处理返利逻辑 |
| | | // */ |
| | | // chainProducer.sendAntACoinInMsg(flow.getId()); |
| | | // /** |
| | | // * 发送消息处理代理升级 |
| | | // */ |
| | | // chainProducer.sendAntMemberLevelMsg(member.getId()); |
| | | } else { |
| | | DappFundFlowEntity flow = dappFundFlowDao.selectById(transferADto.getId()); |
| | | if (flow.getStatus() == 1) { |
| | |
| | | * A k线数据 |
| | | */ |
| | | public static final String QUEUE_ALL_MEMBER_PERK_AVA = "queue_all_member_perk_ava"; |
| | | /** |
| | | * A 合约铸造ANDAO |
| | | */ |
| | | public static final String QUEUE_CONTRACT_AN_DAO = "queue_contract_an_dao"; |
| | | /** |
| | | * A 入金的消息 队列 |
| | | */ |
| | | public static final String QUEUE_ANT_A_CION_IN_CONTRACT = "queue_ant_a_coin_in_contract"; |
| | | } |
| | |
| | | |
| | | @Getter |
| | | public enum QueueEnum { |
| | | //A 合约铸造ANDAO |
| | | ANT_A_CION_IN_CONTRACT("exchange_ant_a_coin_in_contract", "route_key_ant_a_coin_in_contract", QueueConstants.QUEUE_ANT_A_CION_IN_CONTRACT), |
| | | //A 合约铸造ANDAO |
| | | CONTRACT_AN_DAO("exchange_contract_an_dao", "route_key_contract_an_dao", QueueConstants.QUEUE_CONTRACT_AN_DAO), |
| | | //A 每人平分 |
| | | ALL_MEMBER_PERK_AVA("exchange_all_member_perk_ava", "route_key_all_member_perk_ava", QueueConstants.QUEUE_ALL_MEMBER_PERK_AVA), |
| | | //A k线数据 |
| | |
| | | return BindingBuilder.bind(allMemberPerkAvaQueue()).to(allMemberPerkAvaExchange()).with(QueueEnum.ALL_MEMBER_PERK_AVA.getRoute()); |
| | | } |
| | | // === A k线数据 end === |
| | | |
| | | |
| | | // === A 合约铸造ANDAO start === |
| | | @Bean |
| | | public DirectExchange contractAnDaoExchange() { |
| | | return new DirectExchange(QueueEnum.CONTRACT_AN_DAO.getExchange()); |
| | | } |
| | | |
| | | @Bean |
| | | public Queue contractAnDaoQueue() { |
| | | return new Queue(QueueEnum.CONTRACT_AN_DAO.getQueue()); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding contractAnDaoBind() { |
| | | return BindingBuilder.bind(contractAnDaoQueue()).to(contractAnDaoExchange()).with(QueueEnum.CONTRACT_AN_DAO.getRoute()); |
| | | } |
| | | // === A 合约铸造ANDAO end === |
| | | |
| | | |
| | | // === A 合约铸造ANDAO start === |
| | | @Bean |
| | | public DirectExchange contractAnDaoInExchange() { |
| | | return new DirectExchange(QueueEnum.ANT_A_CION_IN_CONTRACT.getExchange()); |
| | | } |
| | | |
| | | @Bean |
| | | public Queue contractAnDaoInQueue() { |
| | | return new Queue(QueueEnum.ANT_A_CION_IN_CONTRACT.getQueue()); |
| | | } |
| | | |
| | | @Bean |
| | | public Binding contractAnDaoInBind() { |
| | | return BindingBuilder.bind(contractAnDaoInQueue()).to(contractAnDaoInExchange()).with(QueueEnum.ANT_A_CION_IN_CONTRACT.getRoute()); |
| | | } |
| | | // === A 合约铸造ANDAO end === |
| | | } |
| | |
| | | log.info("全体平分:{}", id); |
| | | dappSystemService.allMemberPerkAvaMsg(id); |
| | | } |
| | | |
| | | /**合约铸造ANDAO |
| | | * @param flowId |
| | | */ |
| | | @RabbitListener(queues = QueueConstants.QUEUE_CONTRACT_AN_DAO) |
| | | public void contractAnDaoMsg(Long flowId) { |
| | | log.info("1-消费合约铸造ANDAO:{}", flowId); |
| | | dappSystemService.contractAnDaoMsg(flowId); |
| | | } |
| | | |
| | | /**合约铸造ANDAO |
| | | * @param flowId |
| | | */ |
| | | @RabbitListener(queues = QueueConstants.QUEUE_ANT_A_CION_IN_CONTRACT) |
| | | public void contractAnDaoInMsg(Long flowId) { |
| | | log.info("2-消费合约铸造ANDAO:{}", flowId); |
| | | dappSystemService.contractAnDaoInMsg(flowId); |
| | | } |
| | | } |
| | |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.ALL_MEMBER_PERK_AVA.getExchange(), QueueEnum.ALL_MEMBER_PERK_AVA.getRoute(), id, correlationData); |
| | | } |
| | | |
| | | /** |
| | | * 合约铸造ANDAO |
| | | */ |
| | | public void sendContractAnDao(Long flowId) { |
| | | log.info("合约铸造ANDAO:{}", flowId); |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.CONTRACT_AN_DAO.getExchange(), QueueEnum.CONTRACT_AN_DAO.getRoute(), flowId, correlationData); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * A 入金的消息 |
| | | * @param id |
| | | */ |
| | | public void sendAntACoinInContractMsg(Long id) { |
| | | log.info("开始---合约铸造ANDAO:{}", id); |
| | | CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); |
| | | rabbitTemplate.convertAndSend(QueueEnum.ANT_A_CION_IN_CONTRACT.getExchange(), QueueEnum.ANT_A_CION_IN_CONTRACT.getRoute(), id, correlationData); |
| | | } |
| | | } |
| New file |
| | |
| | | pragma solidity ^0.8.0; |
| | | |
| | | interface IERC20 { |
| | | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); |
| | | function approve(address spender, uint256 amount) external returns (bool); |
| | | function transfer(address to, uint256 amount) external returns (bool); |
| | | function balanceOf(address account) external view returns (uint256); |
| | | function allowance(address _owner, address spender) external view returns (uint256); |
| | | } |
| | | |
| | | contract ANDAOContract { |
| | | using SafeMath for uint256; |
| | | address owner; |
| | | address private usdtAddress = 0x55d398326f99059fF775485246999027B3197955; |
| | | IERC20 private usdtToken; |
| | | |
| | | constructor() { |
| | | usdtToken = IERC20(usdtAddress); |
| | | owner = msg.sender; |
| | | } |
| | | |
| | | address blpSwap = 0x1562e481cEF00B14693e43465444B726739e0CBA; |
| | | address alpSwap = 0x3614B30913f284e8868d7f6814Bbcb62e3f84127; |
| | | |
| | | event received(address indexed from, uint256 amount,string regFlow); |
| | | event withdrawn(address indexed to, uint256 amount); |
| | | |
| | | function receiveANDAO(uint256 amount,string calldata regFlow) external { |
| | | uint256 allowance = usdtToken.allowance(msg.sender, address(this)); |
| | | require(allowance >= amount, "Insufficient allowance"); |
| | | |
| | | bool transferSuccessful = usdtToken.transferFrom(msg.sender, address(this), amount); |
| | | require(transferSuccessful, "Transfer failed"); |
| | | uint256 blpSwapAmount = amount.mul(10).div(100); |
| | | require(usdtToken.transfer(blpSwap, blpSwapAmount), "Transfer failed"); |
| | | uint256 alpSwapAmount = amount.mul(70).div(100); |
| | | require(usdtToken.transfer(alpSwap, alpSwapAmount), "Transfer failed"); |
| | | |
| | | emit received(msg.sender, amount,regFlow); |
| | | } |
| | | |
| | | function withdrawANDAO(address recipient,uint256 amount) external { |
| | | require(msg.sender == owner, "Only the contract creator can call this method"); |
| | | uint256 contractBalance = usdtToken.balanceOf(address(this)); |
| | | require(contractBalance >= amount, "Insufficient balance"); |
| | | |
| | | require(usdtToken.transfer(recipient, amount), "Transfer failed"); |
| | | emit withdrawn(recipient, amount); |
| | | } |
| | | |
| | | } |
| | | |
| | | library SafeMath { |
| | | /** |
| | | * @dev Returns the addition of two unsigned integers, reverting on |
| | | * overflow. |
| | | * |
| | | * Counterpart to Solidity's `+` operator. |
| | | * |
| | | * Requirements: |
| | | * - Addition cannot overflow. |
| | | */ |
| | | function add(uint256 a, uint256 b) internal pure returns (uint256) { |
| | | uint256 c = a + b; |
| | | require(c >= a, "SafeMath: addition overflow"); |
| | | |
| | | return c; |
| | | } |
| | | |
| | | /** |
| | | * @dev Returns the subtraction of two unsigned integers, reverting on |
| | | * overflow (when the result is negative). |
| | | * |
| | | * Counterpart to Solidity's `-` operator. |
| | | * |
| | | * Requirements: |
| | | * - Subtraction cannot overflow. |
| | | */ |
| | | function sub(uint256 a, uint256 b) internal pure returns (uint256) { |
| | | return sub(a, b, "SafeMath: subtraction overflow"); |
| | | } |
| | | |
| | | /** |
| | | * @dev Returns the subtraction of two unsigned integers, reverting with custom message on |
| | | * overflow (when the result is negative). |
| | | * |
| | | * Counterpart to Solidity's `-` operator. |
| | | * |
| | | * Requirements: |
| | | * - Subtraction cannot overflow. |
| | | */ |
| | | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { |
| | | require(b <= a, errorMessage); |
| | | uint256 c = a - b; |
| | | |
| | | return c; |
| | | } |
| | | |
| | | /** |
| | | * @dev Returns the multiplication of two unsigned integers, reverting on |
| | | * overflow. |
| | | * |
| | | * Counterpart to Solidity's `*` operator. |
| | | * |
| | | * Requirements: |
| | | * - Multiplication cannot overflow. |
| | | */ |
| | | function mul(uint256 a, uint256 b) internal pure returns (uint256) { |
| | | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the |
| | | // benefit is lost if 'b' is also tested. |
| | | // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 |
| | | if (a == 0) { |
| | | return 0; |
| | | } |
| | | |
| | | uint256 c = a * b; |
| | | require(c / a == b, "SafeMath: multiplication overflow"); |
| | | |
| | | return c; |
| | | } |
| | | |
| | | /** |
| | | * @dev Returns the integer division of two unsigned integers. Reverts on |
| | | * division by zero. The result is rounded towards zero. |
| | | * |
| | | * Counterpart to Solidity's `/` operator. Note: this function uses a |
| | | * `revert` opcode (which leaves remaining gas untouched) while Solidity |
| | | * uses an invalid opcode to revert (consuming all remaining gas). |
| | | * |
| | | * Requirements: |
| | | * - The divisor cannot be zero. |
| | | */ |
| | | function div(uint256 a, uint256 b) internal pure returns (uint256) { |
| | | return div(a, b, "SafeMath: division by zero"); |
| | | } |
| | | |
| | | /** |
| | | * @dev Returns the integer division of two unsigned integers. Reverts with custom message on |
| | | * division by zero. The result is rounded towards zero. |
| | | * |
| | | * Counterpart to Solidity's `/` operator. Note: this function uses a |
| | | * `revert` opcode (which leaves remaining gas untouched) while Solidity |
| | | * uses an invalid opcode to revert (consuming all remaining gas). |
| | | * |
| | | * Requirements: |
| | | * - The divisor cannot be zero. |
| | | */ |
| | | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { |
| | | // Solidity only automatically asserts when dividing by 0 |
| | | require(b > 0, errorMessage); |
| | | uint256 c = a / b; |
| | | // assert(a == b * c + a % b); // There is no case in which this doesn't hold |
| | | |
| | | return c; |
| | | } |
| | | |
| | | /** |
| | | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), |
| | | * Reverts when dividing by zero. |
| | | * |
| | | * Counterpart to Solidity's `%` operator. This function uses a `revert` |
| | | * opcode (which leaves remaining gas untouched) while Solidity uses an |
| | | * invalid opcode to revert (consuming all remaining gas). |
| | | * |
| | | * Requirements: |
| | | * - The divisor cannot be zero. |
| | | */ |
| | | function mod(uint256 a, uint256 b) internal pure returns (uint256) { |
| | | return mod(a, b, "SafeMath: modulo by zero"); |
| | | } |
| | | |
| | | /** |
| | | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), |
| | | * Reverts with custom message when dividing by zero. |
| | | * |
| | | * Counterpart to Solidity's `%` operator. This function uses a `revert` |
| | | * opcode (which leaves remaining gas untouched) while Solidity uses an |
| | | * invalid opcode to revert (consuming all remaining gas). |
| | | * |
| | | * Requirements: |
| | | * - The divisor cannot be zero. |
| | | */ |
| | | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { |
| | | require(b != 0, errorMessage); |
| | | return a % b; |
| | | } |
| | | } |
| | |
| | | online-transfer: true |
| | | chain-listener: false |
| | | reset-job: false |
| | | quartz-job: false |
| | | quartz-job: true |
| | | debug: false |
| | |
| | | online-transfer: true |
| | | chain-listener: false |
| | | reset-job: false |
| | | quartz-job: false |
| | | quartz-job: true |
| | | debug: false |
| | |
| | | **/ |
| | | @SpringBootTest |
| | | public class JunitTest { |
| | | @Autowired |
| | | private DappMemberDao dappMemberDao; |
| | | |
| | | public static void main(String[] args) { |
| | | DateTime tomorrow = DateUtil.beginOfDay(DateUtil.tomorrow()); |
| | | System.out.println(DateUtil.between(new Date(), tomorrow, DateUnit.SECOND, true)); |
| | | } |
| | | |
| | | public String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1cHrcMpXoKNC8rjAa/jAbgU2bhIBmJmn6iYDfqt0Him/p2s5F0L9nfzZOLYlPq3z12zvXl9IgThhtLIBLi86RPW0ljuwpTvIZz9O36Zae9eMk5bMNsFEFsxg1IOLIM2Oc4ffNvGL58Uupp9RL5NCN1MRQyY61ISy7H2VRTznoJQIDAQAB"; |
| | | public String PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALVwetwylego0LyuMBr+MBuBTZuEgGYmafqJgN+q3QeKb+nazkXQv2d/Nk4tiU+rfPXbO9eX0iBOGG0sgEuLzpE9bSWO7ClO8hnP07fplp714yTlsw2wUQWzGDUg4sgzY5zh9828YvnxS6mn1Evk0I3UxFDJjrUhLLsfZVFPOeglAgMBAAECgYAPKWWS5gVB37tFsRajAs+5VK5MCyABqT8c6QWkay5KNYbRl2+6RM3h068RjFuXlUB9eQMAqpasDWqcIOZdqcKqmxm0ILF2zfPzJr4RaQNSNwDCVrKEeaDtrZQcq/0ygaNDF9y203UMHT0dfEQSGp/xkjTgXNsOuC9iLM56XScOVwJBAPOZLbrCi0h4PL7g3rWsCw8/aN6ehkJ3iTDgjYpdBwJOJSyxV0qi0xmDthGqPd99Kvc14u1jy3ghpm1SAEunrj8CQQC+rS6qajIkK7NiRmX43chDhgMPGo0UFHbmHyYBb1Eyrxu1MNWQEh221p54GsB2HqAGRhxxQ98Ds2S26Au7QpibAkA2nQAAn/8kFzjfPoEPz+uG1puHVZkaK7yJRb7V53dbz/NLqtK8O/cCAGKAYV+PzHsmg2FGAZqrazfpyHmifIx3AkBnFau/+A/JnFKr09F3XTfSwZXPyZPyAipRuQ9MAUmNtDuvloovDIxB9//OgPACLAZpvefMmFvuXUMa25LUF2n3AkBGb+vO+69NSyQM2SHKZ9fUrxx9ZPhupNt/TXNL9OMEQiLaHCYgg0tfcojGe3QjBCA6wVG+dCyZUcv5OwiW23pI"; |
| | | |
| | | @Test |
| | | public void encodeTest() { |
| | | RSA rsa = new RSA(AppContants.REQ_PRIVATE_KEY, AppContants.REQ_PUBLIC_KEY); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("test", 123); |
| | | String s = JSONObject.toJSONString(map); |
| | | String s1 = rsa.encryptBase64(s, KeyType.PublicKey); |
| | | System.out.println(s1); |
| | | } |
| | | |
| | | @Test |
| | | public void decodeTest() { |
| | | String ss = "pAEYpX4a+gm9lqy2/bQNx/EjJS0D7I/ezcCB+G/pgI5GDLWUj7+S7jhGWlV2PTGHcNj8vJQRXp5qpV7GOmaQX30HVao3srsOEL2CWU5F/5A4T9ncs3NuoYEv5LUCTolEEq8r5VdBRzU9BoZCISLFQxjFIp5inuydjz2JE9lnOBYQIP8kZSXHy2N1gkythypbj81q9cC83wNND7pvSjw140EDtXWqlCIhpoZlwB/n8+D5khBHwxWhuf0wacYLj9aKZ8tSKMyw0/WdQvpBZ6ymxuoHrLlcL36PTEN59rce9tnnRs5+AjAXppx4GIODdvbHLQJurBslw2GVHJeDbugRvA=="; |
| | | RSA rsa = new RSA(AppContants.RESP_PRIVATE_KEY, AppContants.RESP_PUBLIC_KEY); |
| | | String s = rsa.decryptStr(ss, KeyType.PrivateKey); |
| | | System.out.println(s); |
| | | } |
| | | // @Autowired |
| | | // private DappMemberDao dappMemberDao; |
| | | // |
| | | // public static void main(String[] args) { |
| | | // DateTime tomorrow = DateUtil.beginOfDay(DateUtil.tomorrow()); |
| | | // System.out.println(DateUtil.between(new Date(), tomorrow, DateUnit.SECOND, true)); |
| | | // } |
| | | // |
| | | // public String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1cHrcMpXoKNC8rjAa/jAbgU2bhIBmJmn6iYDfqt0Him/p2s5F0L9nfzZOLYlPq3z12zvXl9IgThhtLIBLi86RPW0ljuwpTvIZz9O36Zae9eMk5bMNsFEFsxg1IOLIM2Oc4ffNvGL58Uupp9RL5NCN1MRQyY61ISy7H2VRTznoJQIDAQAB"; |
| | | // public String PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALVwetwylego0LyuMBr+MBuBTZuEgGYmafqJgN+q3QeKb+nazkXQv2d/Nk4tiU+rfPXbO9eX0iBOGG0sgEuLzpE9bSWO7ClO8hnP07fplp714yTlsw2wUQWzGDUg4sgzY5zh9828YvnxS6mn1Evk0I3UxFDJjrUhLLsfZVFPOeglAgMBAAECgYAPKWWS5gVB37tFsRajAs+5VK5MCyABqT8c6QWkay5KNYbRl2+6RM3h068RjFuXlUB9eQMAqpasDWqcIOZdqcKqmxm0ILF2zfPzJr4RaQNSNwDCVrKEeaDtrZQcq/0ygaNDF9y203UMHT0dfEQSGp/xkjTgXNsOuC9iLM56XScOVwJBAPOZLbrCi0h4PL7g3rWsCw8/aN6ehkJ3iTDgjYpdBwJOJSyxV0qi0xmDthGqPd99Kvc14u1jy3ghpm1SAEunrj8CQQC+rS6qajIkK7NiRmX43chDhgMPGo0UFHbmHyYBb1Eyrxu1MNWQEh221p54GsB2HqAGRhxxQ98Ds2S26Au7QpibAkA2nQAAn/8kFzjfPoEPz+uG1puHVZkaK7yJRb7V53dbz/NLqtK8O/cCAGKAYV+PzHsmg2FGAZqrazfpyHmifIx3AkBnFau/+A/JnFKr09F3XTfSwZXPyZPyAipRuQ9MAUmNtDuvloovDIxB9//OgPACLAZpvefMmFvuXUMa25LUF2n3AkBGb+vO+69NSyQM2SHKZ9fUrxx9ZPhupNt/TXNL9OMEQiLaHCYgg0tfcojGe3QjBCA6wVG+dCyZUcv5OwiW23pI"; |
| | | // |
| | | // @Test |
| | | // public void encodeTest() { |
| | | // RSA rsa = new RSA(AppContants.REQ_PRIVATE_KEY, AppContants.REQ_PUBLIC_KEY); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("test", 123); |
| | | // String s = JSONObject.toJSONString(map); |
| | | // String s1 = rsa.encryptBase64(s, KeyType.PublicKey); |
| | | // System.out.println(s1); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void decodeTest() { |
| | | // String ss = "pAEYpX4a+gm9lqy2/bQNx/EjJS0D7I/ezcCB+G/pgI5GDLWUj7+S7jhGWlV2PTGHcNj8vJQRXp5qpV7GOmaQX30HVao3srsOEL2CWU5F/5A4T9ncs3NuoYEv5LUCTolEEq8r5VdBRzU9BoZCISLFQxjFIp5inuydjz2JE9lnOBYQIP8kZSXHy2N1gkythypbj81q9cC83wNND7pvSjw140EDtXWqlCIhpoZlwB/n8+D5khBHwxWhuf0wacYLj9aKZ8tSKMyw0/WdQvpBZ6ymxuoHrLlcL36PTEN59rce9tnnRs5+AjAXppx4GIODdvbHLQJurBslw2GVHJeDbugRvA=="; |
| | | // RSA rsa = new RSA(AppContants.RESP_PRIVATE_KEY, AppContants.RESP_PUBLIC_KEY); |
| | | // String s = rsa.decryptStr(ss, KeyType.PrivateKey); |
| | | // System.out.println(s); |
| | | // } |
| | | |
| | | } |
| | |
| | | @SpringBootTest |
| | | public class MemberTest { |
| | | |
| | | @Autowired |
| | | private DappMemberDao dappMemberDao; |
| | | |
| | | @Autowired |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Autowired |
| | | private DappFundFlowDao dappFundFlowDao; |
| | | |
| | | @Autowired |
| | | private ContractMain contractMain; |
| | | |
| | | @Autowired |
| | | private ChainProducer chainProducer; |
| | | |
| | | @Autowired |
| | | private DappAKlineMapper dappAKlineMapper; |
| | | |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | // String address = dappMemberEntity.getAddress(); |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount); |
| | | // if(StrUtil.isEmpty(hash)){ |
| | | // return; |
| | | // } |
| | | |
| | | public static void main(String[] args) { |
| | | } |
| | | @Test |
| | | public void tranfer(){ |
| | | dappSystemService.antKLineMsg(1); |
| | | // boolean allowance = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).isAllowance("0x458ff43d5ddddb4fd44dd60170ae4831e0d97c9c"); |
| | | // System.out.println(allowance); |
| | | |
| | | // dappSystemService.AntACoinInMsg(780L); |
| | | // dappSystemService.aKlineJobHour(); |
| | | // dappSystemService.aKlineJobDay(); |
| | | // dappSystemService.AntACoinInMsg(164L); |
| | | |
| | | // List<JSONObject> objects = new ArrayList<>(); |
| | | // AKLineVo akLineVo = new AKLineVo(); |
| | | // akLineVo.setCreateTime(DateUtil.date()); |
| | | // akLineVo.setClosePrice(BigDecimal.ZERO); |
| | | // akLineVo.setOpenPrice(BigDecimal.ZERO); |
| | | // akLineVo.setLowestPrice(BigDecimal.ZERO); |
| | | // akLineVo.setHighestPrice(BigDecimal.ZERO); |
| | | // JSONObject parseObj = JSONUtil.parseObj(akLineVo); |
| | | // objects.add(parseObj); |
| | | // objects.add(parseObj); |
| | | // objects.add(parseObj); |
| | | // objects.add(parseObj); |
| | | // System.out.println(objects); |
| | | // System.out.println(objects.toString()); |
| | | // redisUtils.set("test",objects.toString()); |
| | | // Object test = redisUtils.get("test"); |
| | | // System.out.println(test.toString()); |
| | | // JSONArray jsonArray = JSONUtil.parseArray(test); |
| | | // System.out.println(jsonArray); |
| | | |
| | | // String hash = ChainService.getInstance(ChainEnum.BNB.name()).transferBaseToken(address, amount); |
| | | // @Autowired |
| | | // private DappMemberDao dappMemberDao; |
| | | // |
| | | // @Autowired |
| | | // private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | // |
| | | // @Autowired |
| | | // private DappFundFlowDao dappFundFlowDao; |
| | | // |
| | | // @Autowired |
| | | // private ContractMain contractMain; |
| | | // |
| | | // @Autowired |
| | | // private ChainProducer chainProducer; |
| | | // |
| | | // @Autowired |
| | | // private DappAKlineMapper dappAKlineMapper; |
| | | // |
| | | // @Autowired |
| | | // private RedisUtils redisUtils; |
| | | // // String address = dappMemberEntity.getAddress(); |
| | | //// String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, amount); |
| | | //// if(StrUtil.isEmpty(hash)){ |
| | | //// return; |
| | | //// } |
| | | // BigDecimal balance = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT.getAddress()); |
| | | //// Integer count = dappFundFlowDao.updateStatusById(DappFundFlowEntity.WITHDRAW_STATUS_AGREE,464L); |
| | | //// String address = dappMemberEntity.getAddress(); |
| | | //// log.info("{}",address); |
| | | // System.out.println(balance); |
| | | |
| | | |
| | | // dappSystemService.bnbTransferTest(44L); |
| | | |
| | | |
| | | //发送转币消息 |
| | | // chainProducer.sendBnbTransferMsg(93L); |
| | | // chainProducer.sendBnbTransferMsg(94L); |
| | | // chainProducer.sendBnbTransferMsg(95L); |
| | | // chainProducer.sendBnbTransferMsg(96L); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private SystemConstants systemConstants; |
| | | @Autowired |
| | | private DappSystemService dappSystemService; |
| | | @Test |
| | | public void balance() { |
| | | |
| | | dappSystemService.selectAndInsertDics(); |
| | | // /** |
| | | // * 从contractAddress合约地址中转移对应发行的代币到address中 |
| | | // */ |
| | | // dappSystemService.bnbTransfer(6L); |
| | | |
| | | |
| | | // String address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | // /** |
| | | // * 发起USDT转账 |
| | | // */ |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, new BigDecimal("0.01")); |
| | | // System.out.println(hash); |
| | | } |
| | | |
| | | @Test |
| | | public void refererIdsTest() { |
| | | DappMemberEntity member = dappMemberDao.selectById(24); |
| | | |
| | | boolean flag = false; |
| | | String parentId = "35087336"; |
| | | String ids = ""; |
| | | String feeProfitIds = ""; |
| | | |
| | | int i = 1; |
| | | List<DataDictionaryCustom> feeProfitDic = dataDictionaryCustomMapper.selectDicByType(AppContants.DIC_TYPE_DISTRIBUTE_PROP); |
| | | while (!flag && StringUtils.isNotBlank(parentId)) { |
| | | if (StrUtil.isBlank(ids)) { |
| | | ids += parentId; |
| | | } else { |
| | | ids += ("," + parentId); |
| | | } |
| | | |
| | | if (i <= 4) { |
| | | if (StrUtil.isBlank(feeProfitIds)) { |
| | | feeProfitIds += parentId; |
| | | } else { |
| | | feeProfitIds += ("," + parentId); |
| | | } |
| | | } |
| | | |
| | | i++; |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(parentId); |
| | | if (parentMember == null) { |
| | | break; |
| | | } |
| | | parentId = parentMember.getRefererId(); |
| | | if(StringUtils.isBlank(parentId) || "0".equals(parentId)){ |
| | | break; |
| | | } |
| | | if (parentMember.getRefererId().equals(parentMember.getInviteId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | member.setRefererIds(ids); |
| | | member.setFeeProfitIds(feeProfitIds); |
| | | } |
| | | // |
| | | // public static void main(String[] args) { |
| | | // } |
| | | // @Test |
| | | // public void tranfer(){ |
| | | // dappSystemService.antKLineMsg(1); |
| | | //// boolean allowance = ChainService.getInstance(ChainEnum.BSC_USDT_A_POOL.name()).isAllowance("0x458ff43d5ddddb4fd44dd60170ae4831e0d97c9c"); |
| | | //// System.out.println(allowance); |
| | | // |
| | | //// dappSystemService.AntACoinInMsg(780L); |
| | | //// dappSystemService.aKlineJobHour(); |
| | | //// dappSystemService.aKlineJobDay(); |
| | | //// dappSystemService.AntACoinInMsg(164L); |
| | | // |
| | | //// List<JSONObject> objects = new ArrayList<>(); |
| | | //// AKLineVo akLineVo = new AKLineVo(); |
| | | //// akLineVo.setCreateTime(DateUtil.date()); |
| | | //// akLineVo.setClosePrice(BigDecimal.ZERO); |
| | | //// akLineVo.setOpenPrice(BigDecimal.ZERO); |
| | | //// akLineVo.setLowestPrice(BigDecimal.ZERO); |
| | | //// akLineVo.setHighestPrice(BigDecimal.ZERO); |
| | | //// JSONObject parseObj = JSONUtil.parseObj(akLineVo); |
| | | //// objects.add(parseObj); |
| | | //// objects.add(parseObj); |
| | | //// objects.add(parseObj); |
| | | //// objects.add(parseObj); |
| | | //// System.out.println(objects); |
| | | //// System.out.println(objects.toString()); |
| | | //// redisUtils.set("test",objects.toString()); |
| | | //// Object test = redisUtils.get("test"); |
| | | //// System.out.println(test.toString()); |
| | | //// JSONArray jsonArray = JSONUtil.parseArray(test); |
| | | //// System.out.println(jsonArray); |
| | | // |
| | | //// String hash = ChainService.getInstance(ChainEnum.BNB.name()).transferBaseToken(address, amount); |
| | | ////// if(StrUtil.isEmpty(hash)){ |
| | | ////// return; |
| | | ////// } |
| | | //// BigDecimal balance = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT.getAddress()); |
| | | ////// Integer count = dappFundFlowDao.updateStatusById(DappFundFlowEntity.WITHDRAW_STATUS_AGREE,464L); |
| | | ////// String address = dappMemberEntity.getAddress(); |
| | | ////// log.info("{}",address); |
| | | //// System.out.println(balance); |
| | | // |
| | | // |
| | | //// dappSystemService.bnbTransferTest(44L); |
| | | // |
| | | // |
| | | // //发送转币消息 |
| | | //// chainProducer.sendBnbTransferMsg(93L); |
| | | //// chainProducer.sendBnbTransferMsg(94L); |
| | | //// chainProducer.sendBnbTransferMsg(95L); |
| | | //// chainProducer.sendBnbTransferMsg(96L); |
| | | // } |
| | | // |
| | | // |
| | | // @Autowired |
| | | // private SystemConstants systemConstants; |
| | | // @Autowired |
| | | // private DappSystemService dappSystemService; |
| | | // @Test |
| | | // public void balance() { |
| | | // |
| | | // dappSystemService.selectAndInsertDics(); |
| | | //// /** |
| | | //// * 从contractAddress合约地址中转移对应发行的代币到address中 |
| | | //// */ |
| | | //// dappSystemService.bnbTransfer(6L); |
| | | // |
| | | // |
| | | //// String address = AppContants.ADDRESS_A_POOL_PEOJECT; |
| | | //// /** |
| | | //// * 发起USDT转账 |
| | | //// */ |
| | | //// String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(address, new BigDecimal("0.01")); |
| | | //// System.out.println(hash); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void refererIdsTest() { |
| | | // DappMemberEntity member = dappMemberDao.selectById(24); |
| | | // |
| | | // boolean flag = false; |
| | | // String parentId = "35087336"; |
| | | // String ids = ""; |
| | | // String feeProfitIds = ""; |
| | | // |
| | | // int i = 1; |
| | | // List<DataDictionaryCustom> feeProfitDic = dataDictionaryCustomMapper.selectDicByType(AppContants.DIC_TYPE_DISTRIBUTE_PROP); |
| | | // while (!flag && StringUtils.isNotBlank(parentId)) { |
| | | // if (StrUtil.isBlank(ids)) { |
| | | // ids += parentId; |
| | | // } else { |
| | | // ids += ("," + parentId); |
| | | // } |
| | | // |
| | | // if (i <= 4) { |
| | | // if (StrUtil.isBlank(feeProfitIds)) { |
| | | // feeProfitIds += parentId; |
| | | // } else { |
| | | // feeProfitIds += ("," + parentId); |
| | | // } |
| | | // } |
| | | // |
| | | // i++; |
| | | // DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(parentId); |
| | | // if (parentMember == null) { |
| | | // break; |
| | | // } |
| | | // parentId = parentMember.getRefererId(); |
| | | // if(StringUtils.isBlank(parentId) || "0".equals(parentId)){ |
| | | // break; |
| | | // } |
| | | // if (parentMember.getRefererId().equals(parentMember.getInviteId())) { |
| | | // flag = true; |
| | | // } |
| | | // } |
| | | // member.setRefererIds(ids); |
| | | // member.setFeeProfitIds(feeProfitIds); |
| | | // } |
| | | } |
| | |
| | | @SpringBootTest |
| | | public class TreeTest { |
| | | |
| | | @Test |
| | | public void matrixTest() { |
| | | MatrixTree matrixTree = MatrixTree.getInstance(); |
| | | |
| | | |
| | | String refererId = null; |
| | | for (int i = 0; i < 11; i++) { |
| | | String inviteId = RandomUtil.randomString(6); |
| | | if (i == 2) { |
| | | refererId = inviteId; |
| | | } |
| | | MemberNode memberNode = new MemberNode(); |
| | | memberNode.setMemberId(Long.parseLong(i + 1 + "")); |
| | | memberNode.setInviteId(inviteId); |
| | | memberNode.setAddress(RandomUtil.randomString(14)); |
| | | memberNode.setRefererId(refererId); |
| | | matrixTree.addNode(memberNode); |
| | | } |
| | | System.out.println(System.currentTimeMillis()); |
| | | } |
| | | |
| | | @Autowired |
| | | private DappSystemService dappSystemService; |
| | | |
| | | @Autowired |
| | | private DappWalletService dappWalletService; |
| | | |
| | | @Autowired |
| | | private DappAchieveMemberTreeDao dappAchieveMemberTreeDao; |
| | | |
| | | /** |
| | | * |
| | | * // 第一次{amount: val, fee: 0, txHash: '', type: 1, buyType: 2} |
| | | * // 成功{type: 1, txHash: result.transactionHash, id: res.data, flag: 'success', buyType: 2} |
| | | * // 失败{type: 1, id: res.data, flag: 'fail', buyType: 2} |
| | | */ |
| | | @Test |
| | | public void testTransfer(){ |
| | | //第一次 |
| | | TransferDto transferDto = new TransferDto(); |
| | | transferDto.setAmount(new BigDecimal(0.00105)); |
| | | transferDto.setFee(BigDecimal.ZERO); |
| | | transferDto.setType(1); |
| | | transferDto.setBuyType(2); |
| | | transferDto.setMemberId(140L); |
| | | Long transfer = dappWalletService.transfer(transferDto); |
| | | transferDto.setTxHash("0x4c26f944d469219030512907bc3fd3d825d40d1ace7108dd3923a67d95b81094"); |
| | | transferDto.setId(transfer); |
| | | transferDto.setFlag("success"); |
| | | dappWalletService.transfer(transferDto); |
| | | } |
| | | @Test |
| | | public void testTransfer2(){ |
| | | //成功 |
| | | TransferDto transferDto = new TransferDto(); |
| | | transferDto.setType(1); |
| | | transferDto.setTxHash("ceshi"+ DateUtil.now()); |
| | | transferDto.setId(422L); |
| | | transferDto.setFlag("success"); |
| | | transferDto.setBuyType(2); |
| | | transferDto.setAmount(new BigDecimal(1.05)); |
| | | transferDto.setFee(BigDecimal.ZERO); |
| | | transferDto.setMemberId(111L); |
| | | dappWalletService.transfer(transferDto); |
| | | } |
| | | |
| | | @Test |
| | | public void resetMatrix() { |
| | | dappSystemService.levelProfit(9L); |
| | | dappSystemService.memberOut(9L); |
| | | } |
| | | |
| | | @Test |
| | | public void limitResetProfitTest() { |
| | | dappSystemService.putIntoProfit(59L, 1); |
| | | } |
| | | // @Test |
| | | // public void matrixTest() { |
| | | // MatrixTree matrixTree = MatrixTree.getInstance(); |
| | | // |
| | | // |
| | | // String refererId = null; |
| | | // for (int i = 0; i < 11; i++) { |
| | | // String inviteId = RandomUtil.randomString(6); |
| | | // if (i == 2) { |
| | | // refererId = inviteId; |
| | | // } |
| | | // MemberNode memberNode = new MemberNode(); |
| | | // memberNode.setMemberId(Long.parseLong(i + 1 + "")); |
| | | // memberNode.setInviteId(inviteId); |
| | | // memberNode.setAddress(RandomUtil.randomString(14)); |
| | | // memberNode.setRefererId(refererId); |
| | | // matrixTree.addNode(memberNode); |
| | | // } |
| | | // System.out.println(System.currentTimeMillis()); |
| | | // } |
| | | // |
| | | // @Autowired |
| | | // private DappSystemService dappSystemService; |
| | | // |
| | | // @Autowired |
| | | // private DappWalletService dappWalletService; |
| | | // |
| | | // @Autowired |
| | | // private DappAchieveMemberTreeDao dappAchieveMemberTreeDao; |
| | | // |
| | | // /** |
| | | // * |
| | | // * // 第一次{amount: val, fee: 0, txHash: '', type: 1, buyType: 2} |
| | | // * // 成功{type: 1, txHash: result.transactionHash, id: res.data, flag: 'success', buyType: 2} |
| | | // * // 失败{type: 1, id: res.data, flag: 'fail', buyType: 2} |
| | | // */ |
| | | // @Test |
| | | // public void testTransfer(){ |
| | | // //第一次 |
| | | // TransferDto transferDto = new TransferDto(); |
| | | // transferDto.setAmount(new BigDecimal(0.00105)); |
| | | // transferDto.setFee(BigDecimal.ZERO); |
| | | // transferDto.setType(1); |
| | | // transferDto.setBuyType(2); |
| | | // transferDto.setMemberId(140L); |
| | | // Long transfer = dappWalletService.transfer(transferDto); |
| | | // transferDto.setTxHash("0x4c26f944d469219030512907bc3fd3d825d40d1ace7108dd3923a67d95b81094"); |
| | | // transferDto.setId(transfer); |
| | | // transferDto.setFlag("success"); |
| | | // dappWalletService.transfer(transferDto); |
| | | // } |
| | | // @Test |
| | | // public void testTransfer2(){ |
| | | // //成功 |
| | | // TransferDto transferDto = new TransferDto(); |
| | | // transferDto.setType(1); |
| | | // transferDto.setTxHash("ceshi"+ DateUtil.now()); |
| | | // transferDto.setId(422L); |
| | | // transferDto.setFlag("success"); |
| | | // transferDto.setBuyType(2); |
| | | // transferDto.setAmount(new BigDecimal(1.05)); |
| | | // transferDto.setFee(BigDecimal.ZERO); |
| | | // transferDto.setMemberId(111L); |
| | | // dappWalletService.transfer(transferDto); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void resetMatrix() { |
| | | // dappSystemService.levelProfit(9L); |
| | | // dappSystemService.memberOut(9L); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void limitResetProfitTest() { |
| | | // dappSystemService.putIntoProfit(59L, 1); |
| | | // } |
| | | } |