Skip to content

Commit

Permalink
feat: ✨ Add TransactionUtil.isSCCallExecuted method to check is a S…
Browse files Browse the repository at this point in the history
…C has been executed
  • Loading branch information
redDwarf03 committed Jul 26, 2024
1 parent be43865 commit 0dfaf06
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Changelog
=========
#### Version 1.2.9
* Add `TransactionUtil.isSCCallExecuted` method to check is a SC has been executed

#### Version 1.2.8
* Update dependencies

Expand Down
39 changes: 39 additions & 0 deletions lib/src/util/transaction_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,45 @@ mixin TransactionMixin {
return;
}

Future<bool> isSCCallExecuted(
String contractAddress,
String txAddress,
) async {
var executed = false;
final apiService = sl.get<ApiService>();

final transactionChainResult = await apiService.getTransactionChain(
{contractAddress: ''},
orderAsc: false,
request:
'validationStamp {ledgerOperations { consumedInputs { from, type } } }',
);

if (transactionChainResult[contractAddress] != null) {
final transactions = transactionChainResult[contractAddress];
for (final transaction in transactions!) {
if (transaction.validationStamp != null &&
transaction.validationStamp!.ledgerOperations != null &&
transaction
.validationStamp!.ledgerOperations!.consumedInputs.isNotEmpty) {
for (final consumedInput in transaction
.validationStamp!.ledgerOperations!.consumedInputs) {
if (consumedInput.type == 'call' &&
consumedInput.from != null &&
consumedInput.from!.toUpperCase() == txAddress.toUpperCase()) {
executed = true;
break;
}
}
}
if (executed) {
break;
}
}
}
return executed;
}

Future<double> getAmountFromTxInput(
String txAddress,
String? tokenAddress,
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e"
sha256: e84c8a53fe1510ef4582f118c7b4bdf15b03002b51d7c2b66983c65843d61193
url: "https://pub.dev"
source: hosted
version: "2.2.7"
version: "2.2.8"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -1009,10 +1009,10 @@ packages:
dependency: transitive
description:
name: url_launcher_android
sha256: "95d8027db36a0e52caf55680f91e33ea6aa12a3ce608c90b06f4e429a21067ac"
sha256: c24484594a8dea685610569ab0f2547de9c7a1907500a9bc5e37e4c9a3cbfb23
url: "https://pub.dev"
source: hosted
version: "6.3.5"
version: "6.3.6"
url_launcher_ios:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: archethic_dapp_framework_flutter
description: An internal framework for archethic flutter development
homepage: https://github.com/archethic-foundation/archethic-dapp-framework-flutter

version: 1.2.8
version: 1.2.9

environment:
sdk: ">=3.3.0 <4.0.0"
Expand Down

0 comments on commit 0dfaf06

Please sign in to comment.