package nft.series_claim;

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 {
        SeriesClaim seriesClaim = new SeriesClaim(
                Config.platformPubKey,
                "tesfsafas222",
                100,
                UUID.randomUUID().toString(),
                "https://baidu.com",
                "test",
                false
        );

        String taskId = seriesClaim.claim(Config.platformPrivateKey);
        QueryResult queryResult = new QueryResult(taskId);

        long startTime = System.currentTimeMillis();

        ClaimResult claimResult = new ClaimResult();
        while (Tools.checkTimeout(startTime, Constant.DEFAULT_TIMEOUT) && claimResult.getTaskStatus() < 7) {
            claimResult = queryResult.claimResult();
            TimeUnit.SECONDS.sleep(1);
        }

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