Skip to main content

fvm_sdk/sys/
network.rs

1// Copyright 2021-2023 Protocol Labs
2// SPDX-License-Identifier: Apache-2.0, MIT
3//! Syscalls for network metadata.
4
5// for documentation links
6#[doc(inline)]
7pub use fvm_shared::sys::out::network::NetworkContext;
8
9#[cfg(doc)]
10use crate::sys::ErrorNumber::*;
11
12super::fvm_syscalls! {
13    module = "network";
14
15    /// Gets the circulating supply.
16    ///
17    /// # Errors
18    ///
19    /// None
20    pub fn total_fil_circ_supply() -> Result<super::TokenAmount>;
21
22    /// Retrieves a tipset's CID within the last finality, if available
23    ///
24    /// # Arguments
25    ///
26    /// - `epoch` the epoch being queried.
27    /// - `ret_off` and `ret_len` specify the location and length of the buffer into which the
28    ///   tipset CID will be written.
29    ///
30    /// # Returns
31    ///
32    /// Returns the length of the CID written to the output buffer.
33    ///
34    /// # Errors
35    ///
36    /// | Error               | Reason                                       |
37    /// |---------------------|----------------------------------------------|
38    /// | [`IllegalArgument`] | specified epoch is negative or in the future |
39    /// | [`LimitExceeded`]   | specified epoch exceeds finality             |
40    pub fn tipset_cid(
41        epoch: i64,
42        ret_off: *mut u8,
43        ret_len: u32,
44    ) -> Result<u32>;
45
46    /// Returns the details about the network.
47    ///
48    /// # Errors
49    ///
50    /// None
51    pub fn context() -> Result<NetworkContext>;
52}