|
|
@@ -20,6 +20,7 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.binary.Hex;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
import org.springframework.retry.annotation.Backoff;
|
|
|
import org.springframework.retry.annotation.Retryable;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
@@ -27,6 +28,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@@ -38,6 +40,7 @@ public class NFTService {
|
|
|
private final GeneralProperties generalProperties;
|
|
|
private final SnowflakeIdWorker snowflakeIdWorker;
|
|
|
private final ApplicationContext context;
|
|
|
+ private final Environment env;
|
|
|
|
|
|
@Async
|
|
|
public void createAccount(Long userId) {
|
|
|
@@ -85,6 +88,11 @@ public class NFTService {
|
|
|
@Retryable(maxAttempts = 10, backoff = @Backoff(delay = 5000), value = BusinessException.class)
|
|
|
public synchronized NFT createToken(String toAccount, String tokenId) throws Exception {
|
|
|
log.info("开始执行EVM合约mint, toAccount: {}, tokenId: {}", toAccount, tokenId);
|
|
|
+ if (Arrays.asList(env.getActiveProfiles()).contains("test")) {
|
|
|
+ NFT nft = new NFT("1", tokenId, new BigInteger("1"), new BigInteger("1"));
|
|
|
+ log.info("测试服生成假token {}", tokenId);
|
|
|
+ return nft;
|
|
|
+ }
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
jsonArray.add(Utils.getIdentityByName(toAccount));
|
|
|
jsonArray.add(new BigInteger(tokenId, 16));
|