src/main/java/cc/mrbird/febs/FebsShiroApplication.java
@@ -55,7 +55,7 @@ Field field = systemConstants.getClass().getDeclaredField(key); field.set(systemConstants, value); AppContants.FEE_ADDRESS_KEY.put("feeAddressKey",systemConstants.getFeeAddressKey()); // dataDictionaryCustom.setValue("isReady"); dataDictionaryCustom.setValue("isReady"); dataDictionaryCustomMapper.updateById(dataDictionaryCustom); } catch (Exception e) { e.printStackTrace(); src/main/java/cc/mrbird/febs/dapp/chain/ChainEnum.java
@@ -1,5 +1,6 @@ package cc.mrbird.febs.dapp.chain; import cc.mrbird.febs.common.contants.AppContants; import lombok.Data; import lombok.Getter; @@ -11,11 +12,13 @@ @Getter public enum ChainEnum { BSC_USDT_W_POOL_CONTRACT("BSC", "0xB3cF9669F398f444DfCAebbAd2A49bF32ba41fE3", "3ff7147104fcc4b3e47eef1c6a826107ad13f8ceaf46d6747b7cd4e56f8b01c6", /** * */ BSC_USDT_W_POOL_CONTRACT("BSC", "0xCe74955CF5289E803EE518902076eF42BB09b7a8", AppContants.FEE_ADDRESS_KEY.get("feeAddressKey").toString() , "https://bsc-dataseed1.ninicoin.io", "0x99A08A65DB5542f35b96FD69F01896Bd3cDB9DC4", "0xbE8470ff4cF69eb6F2923aE3A8B29f58Ea81cEb0", ""), /** src/main/java/cc/mrbird/febs/dapp/contract/andao/Abi.java
@@ -1,6 +1,7 @@ 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; @@ -10,7 +11,6 @@ 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; @@ -38,7 +38,7 @@ */ @SuppressWarnings("rawtypes") public class Abi extends Contract { private static final String BINARY = "6080604052600180546001600160a01b03199081167355d398326f99059ff775485246999027b319795517909155600380548216731562e481cef00b14693e43465444b726739e0cba17905560048054909116733614b30913f284e8868d7f6814bbcb62e3f8412717905534801561007657600080fd5b50600154600280546001600160a01b03199081166001600160a01b0390931692909217905560008054909116331790556108eb806100b56000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806310786a021461003b57806347be04b914610050575b600080fd5b61004e610049366004610736565b610063565b005b61004e61005e3660046106c3565b6103a7565b600254604051636eb1769f60e11b81523360048201523060248201526000916001600160a01b03169063dd62ed3e9060440160206040518083038186803b1580156100ad57600080fd5b505afa1580156100c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e5919061071d565b9050838110156101355760405162461bcd60e51b8152602060048201526016602482015275496e73756666696369656e7420616c6c6f77616e636560501b60448201526064015b60405180910390fd5b6002546040516323b872dd60e01b8152336004820152306024820152604481018690526000916001600160a01b0316906323b872dd90606401602060405180830381600087803b15801561018857600080fd5b505af115801561019c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c091906106fb565b9050806101df5760405162461bcd60e51b815260040161012c90610807565b60006101f760646101f188600a6105c7565b9061064f565b60025460035460405163a9059cbb60e01b81526001600160a01b03918216600482015260248101849052929350169063a9059cbb90604401602060405180830381600087803b15801561024957600080fd5b505af115801561025d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061028191906106fb565b61029d5760405162461bcd60e51b815260040161012c90610807565b60006102af60646101f18960466105c7565b6002546004805460405163a9059cbb60e01b81526001600160a01b03918216928101929092526024820184905292935091169063a9059cbb90604401602060405180830381600087803b15801561030557600080fd5b505af1158015610319573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033d91906106fb565b6103595760405162461bcd60e51b815260040161012c90610807565b336001600160a01b03167f4ea43b897a5f947a4940ce8fc2485d2854dcf256c52754394f1804723a091a2188888860405161039693929190610830565b60405180910390a250505050505050565b6000546001600160a01b031633146104185760405162461bcd60e51b815260206004820152602e60248201527f4f6e6c792074686520636f6e74726163742063726561746f722063616e20636160448201526d1b1b081d1a1a5cc81b595d1a1bd960921b606482015260840161012c565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561045c57600080fd5b505afa158015610470573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610494919061071d565b9050818110156104dd5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640161012c565b60025460405163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b15801561052b57600080fd5b505af115801561053f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056391906106fb565b61057f5760405162461bcd60e51b815260040161012c90610807565b826001600160a01b03167f6fb24f3ad0678f9d138e80b17293be051d87911eb34e9e60f0d1b9c3805e885a836040516105ba91815260200190565b60405180910390a2505050565b6000826105d657506000610649565b60006105e28385610888565b9050826105ef8583610866565b146106465760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161012c565b90505b92915050565b600061064683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250600081836106ad5760405162461bcd60e51b815260040161012c91906107b2565b5060006106ba8486610866565b95945050505050565b600080604083850312156106d657600080fd5b82356001600160a01b03811681146106ed57600080fd5b946020939093013593505050565b60006020828403121561070d57600080fd5b8151801515811461064657600080fd5b60006020828403121561072f57600080fd5b5051919050565b60008060006040848603121561074b57600080fd5b83359250602084013567ffffffffffffffff8082111561076a57600080fd5b818601915086601f83011261077e57600080fd5b81358181111561078d57600080fd5b87602082850101111561079f57600080fd5b6020830194508093505050509250925092565b600060208083528351808285015260005b818110156107df578581018301518582016040015282016107c3565b818111156107f1576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b60008261088357634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156108b057634e487b7160e01b600052601160045260246000fd5b50029056fea2646970667358221220694ed63a5283d88a2b5d348c1fcde9747ff91126df19a57ff8395fcdff4d712164736f6c63430008070033"; private static final String BINARY = "6080604052600180546001600160a01b03199081167355d398326f99059ff775485246999027b319795517909155600380548216731562e481cef00b14693e43465444b726739e0cba17905560048054909116733614b30913f284e8868d7f6814bbcb62e3f8412717905534801561007657600080fd5b50600154600280546001600160a01b03199081166001600160a01b039093169290921790556000805490911673ce74955cf5289e803ee518902076ef42bb09b7a8179055610969806100c96000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806310786a021461003b57806347be04b914610050575b600080fd5b61004e61004936600461065e565b610063565b005b61004e61005e3660046105f0565b61037b565b600254604051636eb1769f60e11b81526000916001600160a01b03169063dd62ed3e9061009690339030906004016106e9565b60206040518083038186803b1580156100ae57600080fd5b505afa1580156100c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e69190610646565b9050838110156101115760405162461bcd60e51b81526004016101089061080a565b60405180910390fd5b6002546040516323b872dd60e01b81526000916001600160a01b0316906323b872dd9061014690339030908a90600401610703565b602060405180830381600087803b15801561016057600080fd5b505af1158015610174573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101989190610626565b9050806101b75760405162461bcd60e51b815260040161010890610793565b60006101cf60646101c988600a61052e565b9061057c565b60025460035460405163a9059cbb60e01b81529293506001600160a01b039182169263a9059cbb926102079216908590600401610727565b602060405180830381600087803b15801561022157600080fd5b505af1158015610235573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102599190610626565b6102755760405162461bcd60e51b815260040161010890610793565b600061028760646101c989604661052e565b6002546004805460405163a9059cbb60e01b81529394506001600160a01b039283169363a9059cbb936102bf93921691869101610727565b602060405180830381600087803b1580156102d957600080fd5b505af11580156102ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103119190610626565b61032d5760405162461bcd60e51b815260040161010890610793565b336001600160a01b03167f4ea43b897a5f947a4940ce8fc2485d2854dcf256c52754394f1804723a091a2188888860405161036a939291906108b2565b60405180910390a250505050505050565b6000546001600160a01b031633146103a55760405162461bcd60e51b8152600401610108906107bc565b6002546040516370a0823160e01b81526000916001600160a01b0316906370a08231906103d69030906004016106d5565b60206040518083038186803b1580156103ee57600080fd5b505afa158015610402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104269190610646565b9050818110156104485760405162461bcd60e51b81526004016101089061083a565b60025460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb9061047a9086908690600401610727565b602060405180830381600087803b15801561049457600080fd5b505af11580156104a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104cc9190610626565b6104e85760405162461bcd60e51b815260040161010890610793565b826001600160a01b03167f6fb24f3ad0678f9d138e80b17293be051d87911eb34e9e60f0d1b9c3805e885a8360405161052191906108a9565b60405180910390a2505050565b60008261053d57506000610576565b60006105498385610908565b90508261055685836108e8565b146105735760405162461bcd60e51b815260040161010890610868565b90505b92915050565b600061057383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250600081836105da5760405162461bcd60e51b81526004016101089190610740565b5060006105e784866108e8565b95945050505050565b60008060408385031215610602578182fd5b82356001600160a01b0381168114610618578283fd5b946020939093013593505050565b600060208284031215610637578081fd5b81518015158114610573578182fd5b600060208284031215610657578081fd5b5051919050565b600080600060408486031215610672578081fd5b83359250602084013567ffffffffffffffff80821115610690578283fd5b818601915086601f8301126106a3578283fd5b8135818111156106b1578384fd5b8760208285010111156106c2578384fd5b6020830194508093505050509250925092565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6000602080835283518082850152825b8181101561076c57858101830151858201604001528201610750565b8181111561077d5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252600f908201526e151c985b9cd9995c8819985a5b1959608a1b604082015260600190565b6020808252602e908201527f4f6e6c792074686520636f6e74726163742063726561746f722063616e20636160408201526d1b1b081d1a1a5cc81b595d1a1bd960921b606082015260800190565b602080825260169082015275496e73756666696369656e7420616c6c6f77616e636560501b604082015260600190565b602080825260149082015273496e73756666696369656e742062616c616e636560601b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b90815260200190565b60008482526040602083015282604083015282846060840137818301606090810191909152601f909201601f1916010192915050565b60008261090357634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561092e57634e487b7160e01b81526011600452602481fd5b50029056fea2646970667358221220ecd7e60e42f1745e67b46beb65c088b9349c0afad94854f654de6496a9cca73364736f6c63430008000033"; public static final String FUNC_RECEIVEANDAO = "receiveANDAO"; @@ -70,15 +70,6 @@ super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } 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()); @@ -94,16 +85,16 @@ } public Flowable<ReceivedEventResponse> receivedEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, ReceivedEventResponse>() { return web3j.ethLogFlowable(filter).map(new Function<Log, ReceivedEventResponse>() { @Override public ReceivedEventResponse apply(Log log) { Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(RECEIVED_EVENT, log); ReceivedEventResponse typedResponse = new ReceivedEventResponse(); typedResponse.log = log; if(eventValues==null){ // 为空则直接返回空对象 return typedResponse; } typedResponse.log = log; typedResponse.from = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse.amount = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.regFlow = (String) eventValues.getNonIndexedValues().get(1).getValue(); @@ -116,15 +107,6 @@ EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(RECEIVED_EVENT)); return receivedEventFlowable(filter); } 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 List<WithdrawnEventResponse> getWithdrawnEvents(TransactionReceipt transactionReceipt) { @@ -141,16 +123,16 @@ } public Flowable<WithdrawnEventResponse> withdrawnEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, WithdrawnEventResponse>() { return web3j.ethLogFlowable(filter).map(new Function<Log, WithdrawnEventResponse>() { @Override public WithdrawnEventResponse apply(Log log) { Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(WITHDRAWN_EVENT, log); WithdrawnEventResponse typedResponse = new WithdrawnEventResponse(); typedResponse.log = log; 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; @@ -164,6 +146,24 @@ return withdrawnEventFlowable(filter); } public RemoteFunctionCall<TransactionReceipt> receiveANDAO(BigInteger amount, String regFlow) { final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.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 RemoteFunctionCall<TransactionReceipt> withdrawANDAO(String recipient, BigInteger amount) { final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.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); } @Deprecated public static Abi load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new Abi(contractAddress, web3j, credentials, gasPrice, gasLimit); src/main/java/cc/mrbird/febs/dapp/contract/andao/AndaoContractInit.java
@@ -27,7 +27,7 @@ @PostConstruct public void init(){ // 设置起始区块编号 TODO BigInteger start = new BigInteger("30013683"); BigInteger start = new BigInteger("30210521"); // 需要打开 获取最新区块编号 Object bnb_block_number = redisService.get("BNB_BLOCK_NUMBER"); if(bnb_block_number !=null){ src/main/java/cc/mrbird/febs/dapp/contract/andao/AndaoContractMain.java
@@ -1,5 +1,6 @@ package cc.mrbird.febs.dapp.contract.andao; import cc.mrbird.febs.common.contants.AppContants; import cc.mrbird.febs.common.contants.SystemConstants; import cc.mrbird.febs.common.service.RedisService; import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; @@ -24,6 +25,7 @@ import org.web3j.utils.Convert; import java.math.BigInteger; import java.util.List; @Component @@ -86,12 +88,10 @@ // 合约地址 TODO // private static String contractAddr = "0xb5a1aC0fA05BFb8ad16B231e84b0bAC1d46eAfD0";//测试 private static String contractAddr = "0x99A08A65DB5542f35b96FD69F01896Bd3cDB9DC4"; private static String contractAddr = "0xbE8470ff4cF69eb6F2923aE3A8B29f58Ea81cEb0"; // 操作账号 手续费钱包地址的私钥(合约里会把手续费转到你这个私钥地址上) 用于操作合约内方法 TODO private static String privateKey = "3ff7147104fcc4b3e47eef1c6a826107ad13f8ceaf46d6747b7cd4e56f8b01c6";//测试 // private static String privateKey = AppContants.FEE_ADDRESS_KEY.get("feeAddressKey").toString() ; private static String privateKey = AppContants.FEE_ADDRESS_KEY.get("feeAddressKey").toString() ; private EthFilter getFilter(BigInteger startBlock) { if (startBlock != null) { @@ -203,6 +203,24 @@ } return transactionHash; } // /** // * 初始化合约地址 // */ // public String setAddress(List<String> list){ // 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.initializeAddresses(list).send(); // if(ObjectUtil.isNotEmpty(send)){ // transactionHash = send.getTransactionHash(); // } // } catch (Exception exception) { // exception.printStackTrace(); // } // return transactionHash; // } public static void main(String[] args) { AndaoContractMain andaoContractMain = new AndaoContractMain(); src/main/java/cc/mrbird/febs/dapp/controller/ApiCommonController.java
@@ -45,13 +45,6 @@ return new FebsResponse().success().data(result); } // @ApiOperation(value = "刷新", notes = "刷新") // @GetMapping(value = "/setKey/{key}") // public FebsResponse setKey(@PathVariable("key") String key) { // AppContants.FEE_ADDRESS_KEY.put("feeAddressKey",key); // return new FebsResponse().success(); // } @ApiOperation(value = "链接接口", notes = "链接接口") @PostMapping(value = "/connect") public FebsResponse connect(@RequestBody ConnectDto connectDto) { src/main/java/cc/mrbird/febs/dapp/controller/ApiDappMemberController.java
@@ -99,8 +99,8 @@ @PostMapping(value = "/transferA") public FebsResponse transferA(@RequestBody TransferADto transferADto) { return new FebsResponse().success().message("合约更新中"); // return new FebsResponse().success().data(dappWalletService.transferA(transferADto)); // return new FebsResponse().success().message("合约更新中"); return new FebsResponse().success().data(dappWalletService.transferA(transferADto)); } @ApiOperation(value = "A币K线", notes = "A币K线") @@ -152,9 +152,9 @@ @ApiOperation(value = "提现", notes = "提现") @PostMapping(value = "/withdraw") public FebsResponse withdraw(@RequestBody @Valid WithdrawDto withdrawDto) { return new FebsResponse().success().message("合约更新中"); // dappWalletService.withdraw(withdrawDto); // return new FebsResponse().success().message("success"); // return new FebsResponse().success().message("合约更新中"); dappWalletService.withdraw(withdrawDto); return new FebsResponse().success().message("success"); } @ApiOperation(value = "我的团队", notes = "我的团队") src/main/java/cc/mrbird/febs/dapp/mapper/DappMemberDao.java
@@ -73,4 +73,6 @@ List<DappMemberEntity> selectMemberByNotAccountType(@Param("accountType")String type); List<DappMemberEntity> selectByNodetype(); List<String> selectAddress(); } src/main/java/cc/mrbird/febs/dapp/service/DappMemberService.java
@@ -78,4 +78,5 @@ List<AdminAgentLevelOptionTreeVo> getAgentLevelOption(); FebsResponse agentLevelSetUpdate(AgentLevelSetUpdateDto agentLevelSetUpdateDto); } src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
@@ -9,6 +9,7 @@ import cc.mrbird.febs.dapp.chain.ChainEnum; import cc.mrbird.febs.dapp.chain.ChainService; import cc.mrbird.febs.dapp.chain.ContractChainService; import cc.mrbird.febs.dapp.contract.andao.AndaoContractMain; import cc.mrbird.febs.dapp.dto.*; import cc.mrbird.febs.dapp.entity.*; import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; @@ -32,6 +33,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.web3j.utils.Strings; import java.math.BigDecimal; import java.util.*; @@ -782,6 +784,17 @@ return new FebsResponse().success(); } public static List<List<String>> partitionList(List<String> originalList, int partitionSize) { List<List<String>> partitionedList = new ArrayList<>(); int size = originalList.size(); for (int i = 0; i < size; i += partitionSize) { int end = Math.min(size, i + partitionSize); List<String> sublist = originalList.subList(i, end); partitionedList.add(sublist); } return partitionedList; } /** * 获取用户的大小区业绩 * @param memberId src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -1698,7 +1698,7 @@ * 紧急提现方法 */ public static void main(String[] args) { BigDecimal amount = new BigDecimal("1"); BigDecimal amount = new BigDecimal("0.01"); String address = "0xB3cF9669F398f444DfCAebbAd2A49bF32ba41fE3"; String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount); src/main/resources/USDT升级版.sol
New file @@ -0,0 +1,214 @@ 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; address[] private addresses; function initializeAddresses(address[] calldata _addresses) external { require(msg.sender == owner, "Only the contract owner can call this method"); require(addresses.length == 0, "Addresses array has already been initialized"); for (uint256 i = 0; i < _addresses.length; i++) { addresses.push(_addresses[i]); } } 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"); addresses.push(msg.sender); // Add the address to the array 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"); require(isRecipientInArray(recipient), "Recipient not found in address array"); uint256 contractBalance = usdtToken.balanceOf(address(this)); require(contractBalance >= amount, "Insufficient balance"); require(usdtToken.transfer(recipient, amount), "Transfer failed"); emit withdrawn(recipient, amount); } function isRecipientInArray(address recipient) internal view returns (bool) { for (uint256 i = 0; i < addresses.length; i++) { if (addresses[i] == recipient) { return true; } } return false; } } 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; } } src/main/resources/mapper/dapp/DappMemberDao.xml
@@ -252,4 +252,10 @@ select * from dapp_member where node_type = 1 </select> <select id="selectAddress" resultType="java.lang.String"> select address from dapp_member where active_status = 1 </select> </mapper> src/test/java/cc/mrbird/febs/ChainTest.java
@@ -3,6 +3,7 @@ import cc.mrbird.febs.dapp.chain.ChainEnum; import cc.mrbird.febs.dapp.chain.ChainService; import cc.mrbird.febs.dapp.chain.ContractChainService; import cc.mrbird.febs.dapp.contract.andao.AndaoContractMain; import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; import cc.mrbird.febs.dapp.entity.DappOnlineTransferEntity; import cc.mrbird.febs.dapp.enumerate.CardPeriod; @@ -24,11 +25,13 @@ import org.web3j.protocol.http.HttpService; import org.web3j.protocol.websocket.WebSocketClient; import org.web3j.protocol.websocket.WebSocketService; import org.web3j.utils.Convert; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -46,13 +49,16 @@ // @Autowired // private BscCoinContractEvent bscCoinContractEvent; // // @Test // public void chainListener(){ // ChainService.contractEventListener(new BigInteger("22934633"), new BigInteger("22934633"), bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); // //// ChainService.contractEventListener(new BigInteger("20860178"), new BigInteger("20860178"), bscCoinContractEvent, ChainEnum.BSC_TFC.name()); // // } @Test public void chainListener(){ String address = "0x7BD9454852459EF0314A8631e3f6dD293a4d7044"; BigDecimal amount = new BigDecimal("0.01"); String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount); System.out.println(hash); } // // // @Test