Skip to content

Commit

Permalink
clean up global list and add function to produce multiple links in on…
Browse files Browse the repository at this point in the history
…e go EDCON
  • Loading branch information
bitcoinwarrior1 committed Jan 22, 2020
1 parent 60f3c1a commit d339125
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@

public class EdconLinkGenerator {

private static List<BigInteger> tokens = new ArrayList<>();
private static final String contractAddress = "0xF6b8DD8Ba9996bEaE6Ad0eE3481F1E9cF080A9eB";
private static ParseMagicLink parseMagicLink = new ParseMagicLink(new CryptoFunctions(), null);
//TODO set private key & chain id
private static final BigInteger privateKey = BigInteger.TEN;
private static final BigInteger privateKey = new BigInteger("0", 16);
private static final int chainId = 100;

// Time todo put in right format & set each time
private static final String date = "20250706210000+0300";
private static final String date = "20200403090000+0300";
// Cities
private static final long VIENNA = 1;

Expand All @@ -38,12 +37,15 @@ public class EdconLinkGenerator {
private static final long E = 5;

// Ticket expiry
private static long expiry = (System.currentTimeMillis() + 1000000000) / 1000L;;
private static long expiry = (System.currentTimeMillis() + 5000000000L) / 1000L;;


public static void main(String[] args) throws SalesOrderMalformed {
//TODO set token ids here
new com.alphawallet.token.web.Service.EdconLinkGenerator(date, VIENNA, BLOCKCHAIN_HALL, 25);
int rounds = 50;
while(rounds > 0) {
new com.alphawallet.token.web.Service.EdconLinkGenerator(date, VIENNA, BLOCKCHAIN_HALL, 1);
rounds--;
}
}

private EdconLinkGenerator(
Expand All @@ -53,20 +55,22 @@ private EdconLinkGenerator(
int quantity
) throws SalesOrderMalformed {
// Set values here
setTokenIds(date, city, venue, A, quantity);
createSpawnableLink();
List<BigInteger> tokens = setTokenIds(date, city, venue, A, quantity);
createSpawnableLink(tokens);
}

private void createSpawnableLink() throws SalesOrderMalformed {
private void createSpawnableLink(List<BigInteger> tokens) throws SalesOrderMalformed {
byte[] message = parseMagicLink.getSpawnableBytes(tokens, contractAddress, BigInteger.ZERO, expiry);
byte[] signature = signMagicLink(message);
byte[] linkData = ParseMagicLink.generateSpawnableLeadingLinkBytes(tokens, contractAddress, BigInteger.ZERO, expiry);
String link = parseMagicLink.completeUniversalLink(chainId, linkData, signature);
System.out.println(link);
System.out.println();
}

private void setTokenIds(String date, long city, long venue, long category, int quantity)
private List<BigInteger> setTokenIds(String date, long city, long venue, long category, int quantity)
{
List<BigInteger> tokens = new ArrayList<>();
while(quantity > 0) {
String tokenId = "";
tokenId += Numeric.toHexStringNoPrefixZeroPadded(Numeric.toBigInt(date.getBytes()), 38);
Expand All @@ -83,6 +87,7 @@ private void setTokenIds(String date, long city, long venue, long category, int
tokens.add(token);
quantity--;
}
return tokens;
}

private byte[] signMagicLink(byte[] signData) {
Expand Down

0 comments on commit d339125

Please sign in to comment.