Browse Source

添加交易记录日志,新增个人转赠到公共账户方法

dev
long 3 years ago
parent
commit
166dcbf5e3
  1. 4
      conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/CheckArgs.java
  2. 27
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java
  3. 14
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftAccountServiceImpl.java
  4. 8
      conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java

4
conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/CheckArgs.java

@ -2,9 +2,6 @@ package com.conflux.web.controller.nft.domain;
import lombok.Data;
import java.math.BigInteger;
import java.util.List;
/**
* @Author _007long
* @Date 2022 05 31
@ -19,6 +16,7 @@ public class CheckArgs {
private String appId;
private String privateKey;
private String toUser;
private String userId;
private String nftId;
//非批量使用

27
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java

@ -428,7 +428,17 @@ public class ConfluxServiceImpl implements ConfluxService {
String contract = contractConfig.getContract();
long start = 0L;
Cfx cfx = Cfx.create(collectConfig.getNode(), 3, 1000);
Account account = Account.create(cfx, AESUtil.decrypt(contractConfig.getPrivateKey()));
Account account = null;
NftAccount nftAccount=null;
if (StringUtils.isNotEmpty(checkArgs.getUserId())){
nftAccount = nftAccountMapper.selectNftAccountByUserId(checkArgs.getUserId());
String nftPrivatekey = nftAccount.getPrivateKey();
String decrypt = AESUtil.Decrypt(nftPrivatekey, ConfluxArt.AESKEY);
account= Account.create(cfx, decrypt);
}else {
account=Account.create(cfx, AESUtil.decrypt(contractConfig.getPrivateKey()));
}
Account.Option opt = new Account.Option();
opt.withValue(BigInteger.ZERO);
opt.withChainId(collectConfig.getChainId());
@ -444,10 +454,12 @@ public class ConfluxServiceImpl implements ConfluxService {
//剩余燃气值
BigInteger sponsoredBalanceForGas = sponsorWhitelistControl.getSponsoredBalanceForGas(address.getABIAddress()).divide(new BigInteger("1000000000"));
log.info("[--------------------->mintNft][balance]{}[sponsoredBalanceForCollateral:]{}[sponsoredBalanceForGas:]{}", balance, sponsoredBalanceForCollateral, sponsoredBalanceForGas);
if (balance.compareTo(new BigInteger("40000000000000000000")) < 0) {
log.info("[--------------------->mintNft][balance not enough 50]{}", balance);
//sms notice
return AjaxResult.error("账户余额不足!");
if (StringUtils.isEmpty(checkArgs.getUserId())) {
if (balance.compareTo(new BigInteger("40000000000000000000")) < 0) {
log.info("[--------------------->mintNft][balance not enough 50]{}", balance);
//sms notice
return AjaxResult.error("账户余额不足!");
}
}
String owner = contractConfig.getOwner();
ConfluxExecutor confluxExecutor = new ConfluxExecutor(account, contract);
@ -658,9 +670,8 @@ public class ConfluxServiceImpl implements ConfluxService {
case ConfluxExecutor.SAFETRANSFERFROM://单个转赠
return subgift(est, hash, checkArgs, confluxExecutor, cfx, owner, contract, sponsoredBalanceForGas, opt, nftLog, start);
case ConfluxExecutor.PRIVATETOPUBLIC://私人转公共账户
String toUser=owner;
String toOwner=checkArgs.getToUser();
checkArgs.setToUser(toUser);
String toOwner=AESUtil.Decrypt(nftAccount.getNftAddress(),ConfluxArt.AESKEY);
checkArgs.setToUser(owner);
return subgift(est, hash, checkArgs, confluxExecutor, cfx, toOwner, contract, sponsoredBalanceForGas, opt, nftLog, start);
case ConfluxExecutor.AIRDROPCASTING://铸造方式空投
tokenURIs = checkArgs.getStrUri();

14
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftAccountServiceImpl.java

@ -2,9 +2,11 @@ package com.conflux.web.controller.nft.service.impl;
import com.conflux.common.utils.DateUtils;
import com.conflux.web.controller.nft.domain.ConfluxArt;
import com.conflux.web.controller.nft.domain.NftAccount;
import com.conflux.web.controller.nft.mapper.NftAccountMapper;
import com.conflux.web.controller.nft.service.INftAccountService;
import com.conflux.web.controller.util.AESUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -43,7 +45,17 @@ public class NftAccountServiceImpl implements INftAccountService
@Override
public List<NftAccount> selectNftAccountList(NftAccount nftAccount)
{
return nftAccountMapper.selectNftAccountList(nftAccount);
List<NftAccount> nftAccounts = nftAccountMapper.selectNftAccountList(nftAccount);
for (NftAccount nft:nftAccounts) {
try {
nft.setNftAddress(AESUtil.Decrypt(nft.getNftAddress(), ConfluxArt.AESKEY));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return nftAccounts;
}
/**

8
conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java

@ -1,8 +1,6 @@
package com.conflux.web.controller.util;
import com.alibaba.fastjson.JSONObject;
import com.conflux.common.utils.sign.Md5Utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
@ -11,10 +9,6 @@ import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
/**
* AES加密解密工具类提供对称加密
@ -225,7 +219,7 @@ public final class AESUtil {
try {
//System.err.println(Integer.valueOf("00000000000000000000000000000017"));
//AES
String encrypt = Encrypt("b829e58242004525995cb17323829d1e","CONFLUX@12345678");
String encrypt = Encrypt("f4152ff440c342e983003d4359c4eb8b","CONFLUX@12345678");
System.err.println(encrypt);
//md5
// String hash = Md5Utils.md5Salt("0efc989dea214ed8bff99b0d14714481d660a7e7137c3ef0fc093efad244ee171f4308d9ccda9359add79e029bd169c9");

Loading…
Cancel
Save