package nft.transfer;

import common.Constant;
import config.Config;
import util.Tools;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

public class Test {
    public static void main(String[] args) throws Exception {

        String operateId = UUID.randomUUID().toString();
        TryTransfer transfer = new TryTransfer(Config.platformPubKey, "ZX9d3b2679666cd2b0d5d121c7e76858af9b5f1b05", "fe1d8b87a9e0c6174f554b89f8bbf5a645b3c5a71c8a667e5bbd47bd8dfc0d89_1", operateId);

        String taskId = transfer.tryTransfer(Config.platformPrivateKey);

        QueryTransferResult queryTransferResult = new QueryTransferResult(Config.platformPubKey, taskId);
        TransferResult result = new TransferResult();

        long startTime = System.currentTimeMillis();
        while (Tools.checkTimeout(startTime, Constant.DEFAULT_TIMEOUT) && result.getTaskStatus() < 7) {
            result = queryTransferResult.query();
            TimeUnit.SECONDS.sleep(1);
        }

        if (result.getTaskStatus() != 7) {
            System.out.println("transfer failed: "+ result.getTaskMsg());
        } else {
            System.out.println("transfer success: " + result.getTaskStatus());
        }
    }
}
