@@ -12,6 +12,10 @@ class Client {
12
12
String get secretSeed => _keyPair.secretSeed;
13
13
Uint8List ? get privateKey => _keyPair.privateKey;
14
14
15
+ var logger = Logger (
16
+ printer: PrettyPrinter (),
17
+ );
18
+
15
19
Client (this ._network, String secretSeed) {
16
20
_keyPair = KeyPair .fromSecretSeed (secretSeed);
17
21
_initialize ();
@@ -70,8 +74,8 @@ class Client {
70
74
if (transaction != null ) {
71
75
transaction.sign (_keyPair, _stellarNetwork);
72
76
await _sdk.submitTransaction (transaction);
73
- print ("Account Activated Successfully." );
74
- print ("TFT Asset was added Successfully " );
77
+ logger. i ("Account Activated Successfully." );
78
+ logger. i ("TFT Asset was added Successfully " );
75
79
return true ;
76
80
} else {
77
81
throw Exception ("Failed to retrieve activation transaction." );
@@ -109,13 +113,13 @@ class Client {
109
113
try {
110
114
bool funded = await FriendBot .fundTestAccount (accountId);
111
115
if (funded) {
112
- print ("Account funded successfully" );
116
+ logger. i ("Account funded successfully" );
113
117
} else {
114
- print ("Failed to fund account" );
118
+ logger. e ("Failed to fund account" );
115
119
}
116
120
return funded;
117
121
} catch (error) {
118
- print ("Error while funding account: $error " );
122
+ logger. e ("Error while funding account: $error " );
119
123
return false ;
120
124
}
121
125
}
@@ -143,15 +147,15 @@ class Client {
143
147
await _sdk.submitTransaction (transaction);
144
148
145
149
if (! response.success) {
146
- print ("Failed to add trustline for $currencyCode " );
150
+ logger. e ("Failed to add trustline for $currencyCode " );
147
151
return false ;
148
152
} else {
149
- print ("trustline for $currencyCode was added successfully" );
153
+ logger. i ("trustline for $currencyCode was added successfully" );
150
154
return true ;
151
155
}
152
156
}
153
157
154
- print ("No trustlines were processed" );
158
+ logger. i ("No trustlines were processed" );
155
159
return false ;
156
160
}
157
161
@@ -169,10 +173,10 @@ class Client {
169
173
170
174
transaction! .sign (_keyPair, _stellarNetwork);
171
175
await _sdk.submitTransaction (transaction);
172
- print ("Transaction successful." );
176
+ logger. i ("Transaction successful." );
173
177
return true ;
174
178
} catch (error) {
175
- print ("Failed to send transaction: $error " );
179
+ logger. e ("Failed to send transaction: $error " );
176
180
return false ;
177
181
}
178
182
}
@@ -194,7 +198,7 @@ class Client {
194
198
await _sdk.submitTransaction (transaction);
195
199
return true ;
196
200
} catch (error) {
197
- print ("Failed to create account $error " );
201
+ logger. e ("Failed to create account $error " );
198
202
return false ;
199
203
}
200
204
}
@@ -232,10 +236,10 @@ class Client {
232
236
await _sdk.submitTransaction (transaction);
233
237
234
238
if (response2.success) {
235
- print ("Trustline for $asset_code added successfully." );
239
+ logger. i ("Trustline for $asset_code added successfully." );
236
240
return true ;
237
241
} else {
238
- print ("Failed to add trustline for $asset_code ." );
242
+ logger. e ("Failed to add trustline for $asset_code ." );
239
243
return false ;
240
244
}
241
245
} catch (error) {
@@ -263,10 +267,10 @@ class Client {
263
267
264
268
if (details != null ) {
265
269
TransactionData transactionData = TransactionData .fromJson (details);
266
- print (transactionData);
270
+ logger. i (transactionData);
267
271
return transactionData;
268
272
} else {
269
- print ('Failed to details for asset: ' );
273
+ logger. e ('Failed to details for asset: ' );
270
274
}
271
275
272
276
return null ;
@@ -358,8 +362,8 @@ class Client {
358
362
359
363
fundedTransaction! .sign (_keyPair, _stellarNetwork);
360
364
361
- print ('Sending to' );
362
- print (
365
+ logger. i ('Sending to' );
366
+ logger. i (
363
367
'${_serviceUrls [_network .toString ()]}/transactionfunding_service/fund_transaction' );
364
368
365
369
try {
@@ -371,7 +375,7 @@ class Client {
371
375
{'transaction' : fundedTransaction.toEnvelopeXdrBase64 ()}),
372
376
);
373
377
374
- print (response.body);
378
+ logger. i (response.body);
375
379
} catch (error) {
376
380
throw Exception ('Something went wrong! $error ' );
377
381
}
@@ -407,11 +411,11 @@ class Client {
407
411
transactionDetails.add (details);
408
412
}
409
413
} else {
410
- print ("Unhandled operation type: ${response .runtimeType }" );
414
+ logger. i ("Unhandled operation type: ${response .runtimeType }" );
411
415
}
412
416
}
413
417
} else {
414
- print ("No payment records found." );
418
+ logger. i ("No payment records found." );
415
419
}
416
420
return transactionDetails;
417
421
}
@@ -438,7 +442,7 @@ class Client {
438
442
final body = jsonDecode (response.body);
439
443
if (body['vesting_accounts' ] is List &&
440
444
body['vesting_accounts' ].isEmpty) {
441
- print ("no vesting account found" );
445
+ logger. i ("no vesting account found" );
442
446
return [];
443
447
} else {
444
448
List <VestingAccount > accountsList = [];
0 commit comments