Skip to content

Commit

Permalink
Merge pull request #2 from edridudi/bloxbean-master
Browse files Browse the repository at this point in the history
Bloxbean master
  • Loading branch information
edridudi authored Jan 11, 2022
2 parents 3327f87 + e1b7d2a commit d70d594
Show file tree
Hide file tree
Showing 12 changed files with 477 additions and 52 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ For another platform, please create a request [here](https://github.com/bloxbean

[Cardano-client-lib examples repository](https://github.com/bloxbean/cardano-client-examples/)

[JavaDoc](https://javadoc.io/doc/com.bloxbean.cardano/cardano-client-lib/)

**Features**

#### Address Generation
Expand Down
71 changes: 37 additions & 34 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,79 @@ void mintTokenBackward() throws CborSerializationException, AddressExcepion, Api
assertThat(result.isSuccessful(), is(true));
}

@Test
void transferAndCollateMultiAssetMultiPayments_whenSingleSender_multipleToken() throws CborSerializationException, AddressExcepion, ApiException {
//Sender address : addr_test1qzx9hu8j4ah3auytk0mwcupd69hpc52t0cw39a65ndrah86djs784u92a3m5w475w3w35tyd6v3qumkze80j8a6h5tuqq5xe8y
String senderMnemonic = "damp wish scrub sentence vibrant gauge tumble raven game extend winner acid side amused vote edge affair buzz hospital slogan patient drum day vital";
Account sender = new Account(Networks.testnet(), senderMnemonic);

String receiver1 = "addr_test1qqwpl7h3g84mhr36wpetk904p7fchx2vst0z696lxk8ujsjyruqwmlsm344gfux3nsj6njyzj3ppvrqtt36cp9xyydzqzumz82";
String receiver2 = "addr_test1qz7r5eu2jg0hx470mmf79vpgueaggh22pmayry8xrre5grtpyy9s8u2heru58a4r68wysmdw9v40zznttmwrg0a6v9tq36pjak";
String receiver3 = "addr_test1qrp6x6aq2m28xhvxhqzufl0ff7x8gmzjejssrk29mx0q829dsty3hzmrl2k8jhwzghgxuzfjatgxlhg9wtl6ecv0v3cqf92rnh";
String receiver4 = "addr_test1qzj02w9f2lv3ayekxwr3hdxvn2umf3hyw6azze4rtczxzuwljt3yugepv88k3htyr60llrcj4a52hlytaka7jj3kf85szkyp6l";

PaymentTransaction paymentTransaction1 =
PaymentTransaction.builder()
.sender(sender)
.receiver(receiver1)
.unit(LOVELACE)
.amount(BigInteger.valueOf(1000000))
.fee(BigInteger.valueOf(4000)) //some low fee (invalid). Just for testing
.build();

PaymentTransaction paymentTransaction2a =
PaymentTransaction.builder()
.sender(sender)
.receiver(receiver2)
.unit(LOVELACE)
.amount(BigInteger.valueOf(1500000L))
.build();

PaymentTransaction paymentTransaction2b =
PaymentTransaction.builder()
.sender(sender)
.receiver(receiver2)
.unit("6b248bf1bbfac692610ca7e9873f988dc5e358b9229be8d6363aedd34d59546f6b656e")
.amount(BigInteger.valueOf(15))
.build();

PaymentTransaction paymentTransaction3 =
PaymentTransaction.builder()
.sender(sender)
.receiver(receiver3)
.amount(BigInteger.valueOf(4))
.unit("329728f73683fe04364631c27a7912538c116d802416ca1eaf2d7a96736174636f696e")
.build();

PaymentTransaction paymentTransaction4 =
PaymentTransaction.builder()
.sender(sender)
.receiver(receiver4)
.amount(BigInteger.valueOf(2))
.unit("b9bd3fb4511908402fbef848eece773bb44c867c25ac8c08d9ec3313696e746a")
.build();

//Calculate total fee for all 4 payment transactions and set in one of the payment transaction
BigInteger fee = feeCalculationService.calculateFee(Arrays.asList(paymentTransaction1, paymentTransaction2a, paymentTransaction2b, paymentTransaction3, paymentTransaction4),
TransactionDetailsParams
.builder()
.ttl(getTtl())
.build(), null);
paymentTransaction1.setFee(fee);

Result<TransactionResult> result = transactionHelperService.transfer(Arrays.asList(paymentTransaction1, paymentTransaction2a, paymentTransaction2b, paymentTransaction3, paymentTransaction4),
TransactionDetailsParams.builder().ttl(getTtl()).build());

if(result.isSuccessful())
System.out.println("Transaction Id: " + result.getValue());
else
System.out.println("Transaction failed: " + result);

System.out.println(result);
waitForTransaction(result);
assertThat(result.isSuccessful(), is(true));
}

@Test
void mintToken() throws CborSerializationException, AddressExcepion, ApiException {

Expand Down Expand Up @@ -1051,6 +1124,7 @@ void mintTokenWithNormalAccountKeyHash() throws CborSerializationException, ApiE
MintTransaction mintTransaction = MintTransaction.builder()
.sender(sender)
.mintAssets(Arrays.asList(multiAsset))
.policy(policy)
.build();

TransactionDetailsParams detailsParams =
Expand Down
Loading

0 comments on commit d70d594

Please sign in to comment.