Skip to content

Commit

Permalink
fix: allow sending test transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Mar 26, 2024
1 parent bb22403 commit f8f2709
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 4 additions & 2 deletions lib/src/network/explorer/explorer_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,11 @@ class ExplorerClient {
}
}

Future<dynamic> send({required Map<String, dynamic> transaction}) async {
Future<dynamic> send(
{required Map<String, dynamic> transaction, bool test = false}) async {
try {
var response = await client.post(api('transaction/send'), transaction);
var response = await client.post(
api('transaction/send'), {"test": test, "transaction": transaction});
if (response.containsKey('error')) {
throw ExplorerException(code: -3, message: response['error']);
}
Expand Down
13 changes: 5 additions & 8 deletions lib/src/schema/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,13 @@ class Transaction extends GeneratedMessage {

String toRawJson({bool asHex = false}) => json.encode(jsonMap(asHex: asHex));

Map<String, dynamic> jsonMap({bool asHex = false, bool test = false}) {
Map<String, dynamic> jsonMap({bool asHex = false}) {
final txType = hasDataRequest() ? 'DataRequest' : 'ValueTransfer';
return {
"test": test,
"transaction": {
txType: {
"body": transaction.body.jsonMap(asHex: asHex),
"signatures": List<dynamic>.from(
transaction.signatures.map((x) => x.jsonMap(asHex: asHex))),
}
txType: {
"body": transaction.body.jsonMap(asHex: asHex),
"signatures": List<dynamic>.from(
transaction.signatures.map((x) => x.jsonMap(asHex: asHex))),
}
};
}
Expand Down

0 comments on commit f8f2709

Please sign in to comment.