Search in sources :

Example 6 with OperationTxBuilder

use of com.radixdlt.api.core.model.OperationTxBuilder in project radixdlt by radixdlt.

the class ConstructionParseMessageTest method buildUnsignedTxnWithMessage.

private byte[] buildUnsignedTxnWithMessage(String message) throws Exception {
    var accountAddress = REAddr.ofPubKeyAccount(self);
    var otherAddress = REAddr.ofPubKeyAccount(PrivateKeys.ofNumeric(2).getPublicKey());
    var entityOperationGroups = List.of(List.of(EntityOperation.from(new AccountVaultEntity(accountAddress), ResourceOperation.withdraw(new TokenResource("xrd", REAddr.ofNativeToken()), UInt256.ONE)), EntityOperation.from(new AccountVaultEntity(otherAddress), ResourceOperation.deposit(new TokenResource("xrd", REAddr.ofNativeToken()), UInt256.ONE))));
    var operationTxBuilder = new OperationTxBuilder(message, entityOperationGroups, currentForkView);
    var builder = radixEngine.constructWithFees(operationTxBuilder, false, accountAddress, NotEnoughNativeTokensForFeesException::new);
    var unsignedTransaction = builder.buildForExternalSign();
    return unsignedTransaction.blob();
}
Also used : OperationTxBuilder(com.radixdlt.api.core.model.OperationTxBuilder) TokenResource(com.radixdlt.api.core.model.TokenResource) NotEnoughNativeTokensForFeesException(com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException) AccountVaultEntity(com.radixdlt.api.core.model.entities.AccountVaultEntity)

Example 7 with OperationTxBuilder

use of com.radixdlt.api.core.model.OperationTxBuilder in project radixdlt by radixdlt.

the class ConstructionParseTransferTest method buildUnsignedTransferTxn.

private byte[] buildUnsignedTransferTxn(REAddr from, REAddr to) throws Exception {
    final UInt256 toTransfer = transferAmount();
    var entityOperationGroups = List.of(List.of(EntityOperation.from(new AccountVaultEntity(from), ResourceOperation.withdraw(new TokenResource("xrd", REAddr.ofNativeToken()), toTransfer)), EntityOperation.from(new AccountVaultEntity(to), ResourceOperation.deposit(new TokenResource("xrd", REAddr.ofNativeToken()), toTransfer))));
    var operationTxBuilder = new OperationTxBuilder(null, entityOperationGroups, currentForkView);
    var builder = radixEngine.constructWithFees(operationTxBuilder, false, from, NotEnoughNativeTokensForFeesException::new);
    var unsignedTransaction = builder.buildForExternalSign();
    return unsignedTransaction.blob();
}
Also used : OperationTxBuilder(com.radixdlt.api.core.model.OperationTxBuilder) TokenResource(com.radixdlt.api.core.model.TokenResource) NotEnoughNativeTokensForFeesException(com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException) AccountVaultEntity(com.radixdlt.api.core.model.entities.AccountVaultEntity) UInt256(com.radixdlt.utils.UInt256)

Example 8 with OperationTxBuilder

use of com.radixdlt.api.core.model.OperationTxBuilder in project radixdlt by radixdlt.

the class TxWithMessageTest method buildSignedTxn.

private Txn buildSignedTxn(REAddr from, REAddr to, String message) throws Exception {
    var toTransfer = UInt256.ONE;
    var entityOperationGroups = List.of(List.of(EntityOperation.from(new AccountVaultEntity(from), ResourceOperation.withdraw(new TokenResource("xrd", REAddr.ofNativeToken()), toTransfer)), EntityOperation.from(new AccountVaultEntity(to), ResourceOperation.deposit(new TokenResource("xrd", REAddr.ofNativeToken()), toTransfer))));
    var operationTxBuilder = new OperationTxBuilder(message, entityOperationGroups, currentForkView);
    var builder = radixEngine.constructWithFees(operationTxBuilder, false, from, NotEnoughNativeTokensForFeesException::new);
    return builder.signAndBuild(hashSigner::sign);
}
Also used : OperationTxBuilder(com.radixdlt.api.core.model.OperationTxBuilder) TokenResource(com.radixdlt.api.core.model.TokenResource) NotEnoughNativeTokensForFeesException(com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException) AccountVaultEntity(com.radixdlt.api.core.model.entities.AccountVaultEntity)

Aggregations

NotEnoughNativeTokensForFeesException (com.radixdlt.api.core.model.NotEnoughNativeTokensForFeesException)8 OperationTxBuilder (com.radixdlt.api.core.model.OperationTxBuilder)8 TokenResource (com.radixdlt.api.core.model.TokenResource)8 AccountVaultEntity (com.radixdlt.api.core.model.entities.AccountVaultEntity)8 UInt256 (com.radixdlt.utils.UInt256)4