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
// Copyright 2020 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or distributed except according to those terms. Please review the Licences for the
// specific language governing permissions and limitations relating to use of the SAFE Network
// Software.

mod auth;
mod authd_client_api;
mod authenticator;
mod constants;
pub mod errors;
#[cfg(feature = "scl-mock")]
mod fake_scl;
pub mod fetch;
pub mod files;
mod helpers;
pub mod keys;
pub mod nrs;
pub mod nrs_map;
mod quic_endpoint;
#[cfg(not(feature = "scl-mock"))]
mod safe_client_libs;
mod safe_net;
pub mod wallet;
pub mod xorurl;
mod xorurl_media_types;

pub use authd_client_api::{
    AuthAllowPrompt, AuthReq, AuthdStatus, PendingAuthReqs, SafeAuthdClient,
};
pub use authenticator::{AuthedApp, AuthedAppsList, SafeAuthReq, SafeAuthReqId, SafeAuthenticator};
use constants::DEFAULT_XORURL_BASE;
pub use errors::{Error, Result};
pub use fetch::{
    NrsMapContainerInfo, SafeContentType, SafeData, SafeDataType, WalletSpendableBalances,
};
pub use files::ProcessedFiles;
pub use keys::BlsKeyPair;
pub use nrs::ProcessedEntries;
pub use nrs_map::{NrsMap, SubNamesMap};
pub use safe_nd::XorName;
pub use safe_net::SafeApp;
pub use xorurl::{XorUrl, XorUrlBase, XorUrlEncoder};

#[cfg(feature = "scl-mock")]
use fake_scl::SafeAppFake as SafeAppImpl;
#[cfg(not(feature = "scl-mock"))]
use safe_client_libs::SafeAppScl as SafeAppImpl;

pub struct Safe {
    safe_app: SafeAppImpl,
    pub xorurl_base: XorUrlBase,
}

impl Default for Safe {
    fn default() -> Self {
        Self::new(Some(DEFAULT_XORURL_BASE))
    }
}

#[allow(dead_code)]
impl Safe {
    pub fn new(xorurl_base: Option<XorUrlBase>) -> Self {
        Self {
            safe_app: SafeApp::new(),
            xorurl_base: xorurl_base.unwrap_or_else(|| DEFAULT_XORURL_BASE),
        }
    }
}