Skip to content

Commit

Permalink
v3.6.0
Browse files Browse the repository at this point in the history
add signAndBuildTransactionAsync method to support building cardano transactions asynchronously.
  • Loading branch information
mrtnetwork committed Jul 5, 2024
1 parent d107814 commit 32dfbd1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.6.0

- add signAndBuildTransactionAsync method to support building cardano transactions asynchronously.

## 3.5.0

- Update dependencies.
Expand Down
31 changes: 29 additions & 2 deletions lib/ada/src/builder/builder/transaction_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import 'mint_builder.dart';
typedef ONSignADA = ADABaseTransactionWitness Function(
{required List<int> digest, required ADAAddress address});

typedef ONSignADAAsync = Future<ADABaseTransactionWitness> Function(
{required List<int> digest, required ADAAddress address});

class ADATransactionBuilder {
BigInt? _fee;
BigInt? get fee => _fee;
Expand Down Expand Up @@ -176,8 +179,32 @@ class ADATransactionBuilder {
final transactionSigners = signers;

for (final i in transactionSigners) {
final wit = onSignADA(address: i, digest: bodyHash);
witnesses.add(wit);
final witness = onSignADA(address: i, digest: bodyHash);
witnesses.add(witness);
}
final vkeys = witnesses.whereType<Vkeywitness>().toList();
final bootstraps = witnesses.whereType<BootstrapWitness>().toList();
return ADATransaction(
body: trBody,
data: aux,
witnessSet: TransactionWitnessSet(
vKeys: vkeys,
nativeScripts: transactionNativeScripts,
bootstraps: bootstraps));
}

Future<ADATransaction> signAndBuildTransactionAsync(
ONSignADAAsync onSignADA) async {
_validateAmounts();
final aux = auxiliaryData;
final trBody = buildTxBody(auxHash: aux?.toHash());
final bodyHash = List<int>.unmodifiable(trBody.toHash().data);
final List<ADABaseTransactionWitness> witnesses = [];
final transactionSigners = signers;

for (final i in transactionSigners) {
final witness = await onSignADA(address: i, digest: bodyHash);
witnesses.add(witness);
}
final vkeys = witnesses.whereType<Vkeywitness>().toList();
final bootstraps = witnesses.whereType<BootstrapWitness>().toList();
Expand Down
2 changes: 1 addition & 1 deletion lib/tron/src/provider/models/account_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TronAccountModel {
final List<AssetV2Model> assetV2;
final String? assetIssuedID;
final List<FreeAssetNetUsageV2Model> freeAssetNetUsageV2;
final bool assetOptimized;
final bool? assetOptimized;

const TronAccountModel._({
this.accountName,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: on_chain
description: Streamline Ethereum, Tron, Solana and Cardano operations. Effortlessly create transactions, interact with smart contracts, sign, and send transactions.
version: 3.5.0
version: 3.6.0
homepage: "https://github.com/mrtnetwork/on_chain"
repository: "https://github.com/mrtnetwork/on_chain"
Author: [email protected]
Expand Down

0 comments on commit 32dfbd1

Please sign in to comment.