1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
use self::error::AlgodError;
use crate::Error;
use algonaut_algod::apis::configuration::{ApiKey, Configuration};
use algonaut_core::{Address, AppId, AssetId, CompiledTeal, Round, ToMsgPack, TransactionId};
use algonaut_encoding::decode_base64;
use algonaut_model::algod::ext::block::BlockResponse;
use algonaut_model::algod::{
self as models, Account, AccountApplicationInformation, AccountApplicationsInformation,
AccountAssetsInformation, Application, ApplicationBoxes, Asset, BlockHash, BlockLogs,
BlockTimestampOffset, BlockTxids, DebugSettingsProf, DisassembledTeal, DryrunRequest,
DryrunResponse, LightBlockHeaderProof, NodeStatus, PendingTransactionResponse,
PendingTransactions, SimulateRequest, SimulateTransactionResponse, StateProof, SubmitResponse,
SuggestedParams, Supply, SyncRound, TransactionGroupStateDeltas, TransactionProof, Version,
};
use algonaut_transaction::SignedTransaction;
/// Whether `teal_compile` should ask algod to include a source-map alongside
/// the compiled bytes. Distinct from [`algonaut_abi::sourcemap::SourceMap`],
/// which is the *parsed* source-map type returned by
/// [`Algod::teal_compile_with_sourcemap`].
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SourceMap {
/// Request a source-map. The map travels back on the JSON response but
/// [`Algod::teal_compile`] still returns only the compiled bytes — call
/// [`Algod::teal_compile_with_sourcemap`] if you need the parsed map.
Emit,
/// Do not request a source-map.
Skip,
}
impl SourceMap {
fn as_option_bool(self) -> Option<bool> {
match self {
SourceMap::Emit => Some(true),
SourceMap::Skip => None,
}
}
}
/// Error class wrapping errors from algonaut_algod
pub(crate) mod error;
mod pending_submission;
pub use pending_submission::PendingSubmission;
#[derive(Debug, Clone)]
pub struct Algod {
pub(crate) configuration: Configuration,
}
impl Algod {
/// Build a v2 client for Algorand protocol daemon.
pub fn new(url: &str, token: &str) -> Result<Self, Error> {
let conf = Configuration {
base_path: url.to_owned(),
user_agent: Some("algonaut".to_owned()),
client: reqwest::Client::new(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: Some(ApiKey {
prefix: None,
key: token.to_owned(),
}),
};
Ok(Self {
configuration: conf,
})
}
/// Given a specific account public key and application ID, this call returns the account's application local state and global state (AppLocalState and AppParams, if either exists). Global state will only be returned if the provided address is the application's creator.
pub async fn account_app(
self,
address: &Address,
app_id: AppId,
) -> Result<AccountApplicationInformation, Error> {
Ok(
algonaut_algod::apis::public_api::account_application_information(
&self.configuration,
&address.to_string(),
app_id.0,
None,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Lookup an account's application holdings (local state and params if the
/// account is the creator), paginated by application ID.
///
/// `include` controls which sub-objects are returned (e.g. `["params"]`).
pub async fn account_apps(
&self,
address: &Address,
limit: Option<u64>,
next: Option<&str>,
include: Option<&[String]>,
) -> Result<AccountApplicationsInformation, Error> {
Ok(
algonaut_algod::apis::public_api::account_applications_information(
&self.configuration,
&address.to_string(),
limit,
next,
include.map(<[String]>::to_vec),
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Lookup an account's asset holdings, paginated by asset ID.
pub async fn account_assets(
&self,
address: &Address,
limit: Option<u64>,
next: Option<&str>,
) -> Result<AccountAssetsInformation, Error> {
Ok(
algonaut_algod::apis::public_api::account_assets_information(
&self.configuration,
&address.to_string(),
limit,
next,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Given a specific account public key, this call returns the accounts status, balance and spendable amounts
pub async fn account(&self, address: &Address) -> Result<Account, Error> {
Ok(algonaut_algod::apis::public_api::account_information(
&self.configuration,
&address.to_string(),
None,
None,
)
.await
.map_err(Into::<AlgodError>::into)?)
}
/// Returns wether the experimental API are enabled
pub async fn experimental(&self) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::experimental_check(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Given an application ID and box name, it returns the box name and value (each base64 encoded). Box names must be in the goal app call arg encoding form 'encoding:value'. For ints, use the form 'int:1234'. For raw bytes, use the form 'b64:A=='. For printable strings, use the form 'str:hello'. For addresses, use the form 'addr:XYZ...'.
pub async fn app_box(&self, app_id: AppId, name: &str) -> Result<models::Box, Error> {
Ok(
algonaut_algod::apis::public_api::get_application_box_by_name(
&self.configuration,
app_id.0,
name,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Given an application ID, return all Box names. No particular ordering is guaranteed. Request fails when client or server-side configured limits prevent returning all Box names.
pub async fn app_boxes(
&self,
app_id: AppId,
max: Option<u64>,
) -> Result<ApplicationBoxes, Error> {
Ok(algonaut_algod::apis::public_api::get_application_boxes(
&self.configuration,
app_id.0,
max,
)
.await
.map_err(Into::<AlgodError>::into)?)
}
/// Given a application ID, it returns application information including creator, approval and clear programs, global and local schemas, and global state.
pub async fn app(&self, app_id: AppId) -> Result<Application, Error> {
Ok(
algonaut_algod::apis::public_api::get_application_by_id(&self.configuration, app_id.0)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Given a asset ID, it returns asset information including creator, name, total supply and special addresses.
pub async fn asset(&self, asset_id: AssetId) -> Result<Asset, Error> {
Ok(
algonaut_algod::apis::public_api::get_asset_by_id(&self.configuration, asset_id.0)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get the block for the given round.
pub async fn block(&self, round: u64) -> Result<BlockResponse, Error> {
Ok(
algonaut_algod::apis::public_api::get_block(&self.configuration, round, None)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get the block hash for the block on the given round.
pub async fn block_hash(&self, round: u64) -> Result<BlockHash, Error> {
Ok(
algonaut_algod::apis::public_api::get_block_hash(&self.configuration, round)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get all of the logs from outer and inner app calls in the given round.
pub async fn block_logs(&self, round: u64) -> Result<BlockLogs, Error> {
Ok(
algonaut_algod::apis::public_api::get_block_logs(&self.configuration, round)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get the top level transaction IDs for the block on the given round.
pub async fn block_transaction_ids(&self, round: u64) -> Result<BlockTxids, Error> {
Ok(
algonaut_algod::apis::public_api::get_block_txids(&self.configuration, round)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get the current timestamp offset.
pub async fn block_timestamp_offset(&self) -> Result<BlockTimestampOffset, Error> {
Ok(
algonaut_algod::apis::public_api::get_block_time_stamp_offset(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Set the timestamp offset (seconds) for blocks in dev mode. Providing an
/// offset of 0 will unset this value and try to use the real clock for the
/// timestamp.
pub async fn set_block_timestamp_offset(&self, offset: u64) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::set_block_time_stamp_offset(
&self.configuration,
offset,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Returns the entire genesis file in json.
pub async fn genesis(&self) -> Result<String, Error> {
Ok(
algonaut_algod::apis::public_api::get_genesis(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get ledger deltas for a round.
pub async fn state_delta(&self, round: u64) -> Result<serde_json::Value, Error> {
Ok(algonaut_algod::apis::public_api::get_ledger_state_delta(
&self.configuration,
round,
None,
)
.await
.map_err(Into::<AlgodError>::into)?)
}
/// Get a ledger delta for a given transaction group, identified by the ID
/// of the first transaction in the group.
pub async fn transaction_group_state_delta(
&self,
transaction_id: &TransactionId,
) -> Result<serde_json::Value, Error> {
Ok(
algonaut_algod::apis::public_api::get_ledger_state_delta_for_transaction_group(
&self.configuration,
transaction_id.as_str(),
None,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get ledger deltas for every transaction group in a given round.
pub async fn transaction_group_state_deltas_for_round(
&self,
round: u64,
) -> Result<TransactionGroupStateDeltas, Error> {
Ok(
algonaut_algod::apis::public_api::get_transaction_group_ledger_state_deltas_for_round(
&self.configuration,
round,
None,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Gets a proof for a given light block header inside a state proof commitment.
pub async fn light_block_header_proof(
&self,
round: u64,
) -> Result<LightBlockHeaderProof, Error> {
Ok(
algonaut_algod::apis::public_api::get_light_block_header_proof(
&self.configuration,
round,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get the list of pending transactions, sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending transactions.
///
/// `format` selects the response encoding (`"json"` or `"msgpack"`).
pub async fn pending_transactions(
&self,
max: Option<u64>,
format: Option<&str>,
) -> Result<PendingTransactions, Error> {
Ok(algonaut_algod::apis::public_api::get_pending_transactions(
&self.configuration,
max,
format,
)
.await
.map_err(Into::<AlgodError>::into)?)
}
/// Get the list of pending transactions by address, sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending transactions.
///
/// `format` selects the response encoding (`"json"` or `"msgpack"`).
pub async fn address_pending_transactions(
&self,
address: &Address,
max: Option<u64>,
format: Option<&str>,
) -> Result<PendingTransactions, Error> {
Ok(
algonaut_algod::apis::public_api::get_pending_transactions_by_address(
&self.configuration,
&address.to_string(),
max,
format,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// TODO
pub async fn ready(&self) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::get_ready(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get a state proof that covers a given round.
pub async fn state_proof(&self, round: u64) -> Result<StateProof, Error> {
Ok(
algonaut_algod::apis::public_api::get_state_proof(&self.configuration, round)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Gets the current node status.
pub async fn status(&self) -> Result<NodeStatus, Error> {
Ok(
algonaut_algod::apis::public_api::get_status(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get the current supply reported by the ledger.
pub async fn supply(&self) -> Result<Supply, Error> {
Ok(
algonaut_algod::apis::public_api::get_supply(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Gets the minimum sync round for the ledger.
pub async fn sync_round(&self) -> Result<SyncRound, Error> {
Ok(
algonaut_algod::apis::public_api::get_sync_round(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get a proof for a transaction in a block.
pub async fn transaction_proof(
&self,
round: u64,
transaction_id: &TransactionId,
) -> Result<TransactionProof, Error> {
Ok(algonaut_algod::apis::public_api::get_transaction_proof(
&self.configuration,
round,
transaction_id.as_str(),
None,
None,
)
.await
.map_err(Into::<AlgodError>::into)?)
}
/// Retrieves the supported API versions, binary build versions, and genesis information.
pub async fn version(&self) -> Result<Version, Error> {
Ok(
algonaut_algod::apis::public_api::get_version(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Returns Ok if healthy
pub async fn health(&self) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::health_check(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Return metrics about algod functioning.
pub async fn metrics(&self) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::metrics(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Given a transaction ID of a recently submitted transaction, it returns information about it. There are several cases when this might succeed: - transaction committed (committed round > 0) - transaction still in the pool (committed round = 0, pool error = \"\") - transaction removed from pool due to error (committed round = 0, pool error != \"\") Or the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error.
pub async fn pending_transaction(
&self,
transaction_id: &TransactionId,
) -> Result<PendingTransactionResponse, Error> {
Ok(
algonaut_algod::apis::public_api::pending_transaction_information(
&self.configuration,
transaction_id.as_str(),
None,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Broadcasts a raw transaction or transaction group to the network.
pub async fn send_raw(&self, raw: &[u8]) -> Result<SubmitResponse, Error> {
Ok(
algonaut_algod::apis::public_api::raw_transaction(&self.configuration, raw)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Broadcasts a transaction to the network.
pub async fn send(&self, transaction: &SignedTransaction) -> Result<SubmitResponse, Error> {
self.send_raw(&transaction.to_msg_pack()?).await
}
/// Broadcasts a transaction group to the network.
///
/// Atomic if the transactions share a [group](algonaut_transaction::transaction::Transaction::group)
pub async fn send_transactions(
&self,
transactions: &[SignedTransaction],
) -> Result<SubmitResponse, Error> {
let mut bytes = vec![];
for t in transactions {
bytes.push(t.to_msg_pack()?);
}
self.send_raw(&bytes.concat()).await
}
/// Wrap an existing transaction id in a [`PendingSubmission`] so callers
/// that already have the id (e.g. they submitted earlier and stashed it)
/// can still poll for finality with the shared
/// [`PendingSubmission::confirm`] implementation.
pub fn pending_submission(&self, transaction_id: &TransactionId) -> PendingSubmission {
PendingSubmission::new(self.clone(), transaction_id.clone())
}
/// Broadcasts a single signed transaction and returns a
/// [`PendingSubmission`] handle that polls algod for finality.
pub async fn submit(
&self,
transaction: &SignedTransaction,
) -> Result<PendingSubmission, Error> {
let resp = self.send(transaction).await?;
Ok(PendingSubmission::new(
self.clone(),
TransactionId::from(resp.tx_id),
))
}
/// Broadcasts a transaction group and returns a [`PendingSubmission`]
/// handle for the group's representative transaction id.
///
/// Atomic if the transactions share a
/// [group](algonaut_transaction::transaction::Transaction::group).
pub async fn submit_transactions(
&self,
transactions: &[SignedTransaction],
) -> Result<PendingSubmission, Error> {
let resp = self.send_transactions(transactions).await?;
Ok(PendingSubmission::new(
self.clone(),
TransactionId::from(resp.tx_id),
))
}
/// Broadcasts already-encoded msgpack transaction bytes and returns a
/// [`PendingSubmission`] handle for the returned transaction id.
pub async fn submit_raw(&self, raw: &[u8]) -> Result<PendingSubmission, Error> {
let resp = self.send_raw(raw).await?;
Ok(PendingSubmission::new(
self.clone(),
TransactionId::from(resp.tx_id),
))
}
/// Broadcasts a raw transaction or transaction group to the network without
/// performing ahead-of-time checks. Returns as soon as the request is
/// accepted, without a transaction ID.
pub async fn send_raw_async(&self, raw: &[u8]) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::raw_transaction_async(&self.configuration, raw)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Broadcasts a transaction to the network without ahead-of-time checks.
pub async fn send_async(&self, transaction: &SignedTransaction) -> Result<(), Error> {
self.send_raw_async(&transaction.to_msg_pack()?).await
}
/// Broadcasts a transaction group to the network without ahead-of-time checks.
///
/// Atomic if the transactions share a [group](algonaut_transaction::transaction::Transaction::group)
pub async fn send_transactions_async(
&self,
transactions: &[SignedTransaction],
) -> Result<(), Error> {
let mut bytes = vec![];
for t in transactions {
bytes.push(t.to_msg_pack()?);
}
self.send_raw_async(&bytes.concat()).await
}
/// Sets the minimum sync round on the ledger.
pub async fn sync(&self, round: u64) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::set_sync_round(&self.configuration, round)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Simulates a raw transaction or transaction group as it would be evaluated on the network. WARNING: This endpoint is experimental and under active development. There are no guarantees in terms of functionality or future support.
pub async fn simulate(
&self,
request: SimulateRequest,
) -> Result<SimulateTransactionResponse, Error> {
Ok(algonaut_algod::apis::public_api::simulate_transaction(
&self.configuration,
request,
None,
)
.await
.map_err(Into::<AlgodError>::into)?)
}
/// Returns the entire swagger spec in json.
pub async fn swagger_json(&self) -> Result<String, Error> {
Ok(
algonaut_algod::apis::public_api::swagger_json(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Given TEAL source code in plain text, return base64 encoded program bytes and base32 SHA512_256 hash of program bytes (Address style). This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true.
pub async fn teal_compile(
&self,
source: &[u8],
sourcemap: SourceMap,
) -> Result<CompiledTeal, Error> {
let api_compiled_teal = algonaut_algod::apis::public_api::teal_compile(
&self.configuration,
source,
sourcemap.as_option_bool(),
)
.await
.map_err(Into::<AlgodError>::into)?;
// The api result (program + hash) is mapped to the domain program struct, which computes the hash on demand.
// The hash here is redundant and we want to allow to generate it with the SDK too (e.g. for when loading programs from a DB).
// At the moment it seems not warranted to add a cache (so it's initialized with the API hash or lazily), but this can be re-evaluated.
// Note that for contract accounts, there's [ContractAccount](algonaut_transaction::account::ContractAccount), which caches it (as address).
Ok(CompiledTeal(decode_base64(
api_compiled_teal.result.as_bytes(),
)?))
}
/// Compile TEAL with `sourcemap=true` and return the compiled bytes
/// plus the parsed [`SourceMap`].
pub async fn teal_compile_with_sourcemap(
&self,
source: &[u8],
) -> Result<(CompiledTeal, algonaut_abi::sourcemap::SourceMap), Error> {
let api_compiled_teal =
algonaut_algod::apis::public_api::teal_compile(&self.configuration, source, Some(true))
.await
.map_err(Into::<AlgodError>::into)?;
let bytes = decode_base64(api_compiled_teal.result.as_bytes())?;
let raw = api_compiled_teal.sourcemap.ok_or(Error::MissingSourcemap)?;
let json = serde_json::to_string(&raw).map_err(|e| Error::Msg(e.to_string()))?;
let map = algonaut_abi::sourcemap::SourceMap::from_json(&json)
.map_err(|e| Error::Msg(e.to_string()))?;
Ok((CompiledTeal(bytes), map))
}
/// Given the program bytes, return the TEAL source code in plain text. This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true.
pub async fn teal_disassemble(&self, source: &[u8]) -> Result<DisassembledTeal, Error> {
Ok(
algonaut_algod::apis::public_api::teal_disassemble(&self.configuration, source)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Executes TEAL program(s) in context and returns debugging information about the execution. This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true.
pub async fn teal_dryrun(
&self,
request: Option<DryrunRequest>,
) -> Result<DryrunResponse, Error> {
Ok(
algonaut_algod::apis::public_api::teal_dryrun(&self.configuration, request)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Get parameters for constructing a new transaction.
pub async fn suggested_params(&self) -> Result<SuggestedParams, Error> {
Ok(
algonaut_algod::apis::public_api::transaction_params(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Unset the ledger sync round.
pub async fn unsync(&self) -> Result<(), Error> {
Ok(
algonaut_algod::apis::public_api::unset_sync_round(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Waits for a block to appear after round {round} and returns the node's status at the time.
pub async fn status_after_block(&self, round: Round) -> Result<NodeStatus, Error> {
Ok(
algonaut_algod::apis::public_api::wait_for_block(&self.configuration, round.0)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Generate and install participation keys to the node, valid for rounds
/// `first` through `last`. Returns the participation ID of the new keys.
pub async fn generate_participation_keys(
&self,
address: &Address,
first: u64,
last: u64,
dilution: Option<u64>,
) -> Result<String, Error> {
Ok(
algonaut_algod::apis::private_api::generate_participation_keys(
&self.configuration,
&address.to_string(),
first,
last,
dilution,
)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Returns the merged (defaults + overrides) node config file as a JSON string.
pub async fn config(&self) -> Result<String, Error> {
Ok(
algonaut_algod::apis::private_api::get_config(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Retrieves the current settings for blocking and mutex profiles.
pub async fn debug_settings_prof(&self) -> Result<DebugSettingsProf, Error> {
Ok(
algonaut_algod::apis::private_api::get_debug_settings_prof(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
/// Enables blocking and mutex profiles, and returns the old settings.
pub async fn set_debug_settings_prof(&self) -> Result<DebugSettingsProf, Error> {
Ok(
algonaut_algod::apis::private_api::put_debug_settings_prof(&self.configuration)
.await
.map_err(Into::<AlgodError>::into)?,
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_valid_client_builder() {
let res = Algod::new(
"http://example.com",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
);
assert!(res.ok().is_some());
}
}