Skip to content
Permalink
Browse files

Add Create AT API Call

  • Loading branch information...
harry1453 committed Apr 25, 2019
1 parent 1b6d885 commit 8c216d1c21976d95588bc0e94d14c2f864b1e606
@@ -288,6 +288,23 @@
*/
Single<GenerateTransactionResponse> generateMultiOutSameTransaction(byte[] senderPublicKey, BurstValue amount, BurstValue fee, int deadline, Set<BurstAddress> recipients) throws IllegalArgumentException;

/**
* TODO javadoc
* @param senderPublicKey
* @param fee
* @param deadline
* @param name
* @param description
* @param creationBytes
* @param code
* @param dpages
* @param cspages
* @param uspages
* @param minActivationAmount
* @return
*/
Single<GenerateTransactionResponse> generateCreateATTransaction(byte[] senderPublicKey, BurstValue fee, int deadline, String name, String description, byte[] creationBytes, byte[] code, byte[] data, int dpages, int cspages, int uspages, BurstValue minActivationAmount);

static BurstNodeService getInstance(String nodeAddress, String userAgent, SchedulerAssigner schedulerAssigner) {
return new BurstNodeServiceImpl(nodeAddress, userAgent, schedulerAssigner);
}
@@ -274,6 +274,11 @@ public void updateConnection(String newNodeAddress, String newUserAgent) {
return assign(blockchainService.sendMoneyMultiSame(null, new HexStringByteArray(senderPublicKey).toHexString(), fee.toPlanck(), String.valueOf(deadline), null, false, recipientsString.toString(), amount.toPlanck()));
}

@Override
public Single<GenerateTransactionResponse> generateCreateATTransaction(byte[] senderPublicKey, BurstValue fee, int deadline, String name, String description, byte[] creationBytes, byte[] code, byte[] data, int dpages, int cspages, int uspages, BurstValue minActivationAmount) {
return assign(blockchainService.createATProgram(new HexStringByteArray(senderPublicKey).toHexString(), fee.toPlanck(), deadline, false, name, description, new HexStringByteArray(creationBytes).toHexString(), new HexStringByteArray(code).toHexString(), new HexStringByteArray(data).toHexString(), dpages, cspages, uspages, minActivationAmount.toPlanck()));
}

private interface BlockchainService {
@GET("burst?requestType=getBlock")
Single<BlockResponse> getBlock(@Query("block") String blockId, @Query("height") String blockHeight, @Query("timestamp") String timestamp, @Query("includeTransactions") String[] transactions); // TODO Array of transactions
@@ -352,5 +357,8 @@ public void updateConnection(String newNodeAddress, String newUserAgent) {

@POST("burst?requestType=sendMoneyMultiSame")
Single<GenerateTransactionResponse> sendMoneyMultiSame(@Query("secretPhrase") String secretPhrase, @Query("publicKey") String publicKey, @Query("feeNQT") String feeNQT, @Query("deadline") String deadline, @Query("referencedTransactionFullHash") String referencedTransactionFullHash, @Query("broadcast") boolean broadcast, @Query("recipients") String recipients, @Query("amountNQT") String amountNQT);

@POST("burst?requestType=createATProgram")
Single<GenerateTransactionResponse> createATProgram(@Query("publicKey") String publicKey, @Query("feeNQT") String fee, @Query("deadline") int deadline, @Query("broadcast") boolean broadcast, @Query("name") String name, @Query("description") String description, @Query("creationBytes") String creationBytes, @Query("code") String code, @Query("data") String data, @Query("dpages") int dpages, @Query("cspages") int cspages, @Query("uspages") int uspages, @Query("minActivationAmountNQT") String minActivationAmountNQT);
}
}
@@ -9,6 +9,7 @@
import burst.kit.entity.response.attachment.MultiOutAttachment;
import burst.kit.entity.response.attachment.MultiOutSameAttachment;
import burst.kit.service.BurstNodeService;
import org.bouncycastle.util.encoders.Hex;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -184,4 +185,10 @@ public void testBurstServiceGenerateMultiOutSame() {
recipients.add(burstCrypto.getBurstAddressFromPassphrase("example2"));
GenerateTransactionResponse multiOutSameResponse = RxTestUtils.testSingle(burstNodeService.generateMultiOutSameTransaction(TestVariables.EXAMPLE_ACCOUNT_PUBKEY.getBytes(), BurstValue.fromBurst(1), BurstValue.fromPlanck(753000), 1440, recipients));
}

@Test
public void testBurstServiceGenerateCreateATTransaction() {
byte[] lotteryAt = Hex.decode("1e000000003901090000006400000000000000351400000000000201000000000000000104000000803a0900000000000601000000040000003615000200000000000000260200000036160003000000020000001f030000000100000072361b0008000000020000002308000000090000000f1af3000000361c0004000000020000001e0400000035361700040000000200000026040000007f2004000000050000001e02050000000400000036180006000000020000000200000000030000001a39000000352000070000001b07000000181b0500000012332100060000001a310100000200000000030000001a1a0000003618000a0000000200000020080000000900000023070800000009000000341f00080000000a0000001a78000000341f00080000000a0000001ab800000002000000000400000003050000001a1a000000");
GenerateTransactionResponse createATResponse = RxTestUtils.testSingle(burstNodeService.generateCreateATTransaction(TestVariables.EXAMPLE_ACCOUNT_PUBKEY.getBytes(), BurstValue.fromBurst(1), 1440, "Test AT", "An AT For Testing", lotteryAt, new byte[0], new byte[0], 0, 0, 0, BurstValue.fromBurst(1)));
}
}

0 comments on commit 8c216d1

Please sign in to comment.
You can’t perform that action at this time.