Skip to main content

quai_primitives/
lib.rs

1//! Validated, allocation-free representations of Quai addresses and shards.
2//!
3//! [`Address`] accepts any 20-byte address, matching `quais.js`'s `getAddress`.
4//! [`QuaiAddress`] and [`QiAddress`] additionally require a known zone and the
5//! appropriate ledger bit. A known zone does not imply that a chain has activated
6//! that zone; providers must check network capabilities separately.
7//!
8//! Address strings use the same mixed-case Keccak checksum as `quais.js`.
9//! Lowercase and uppercase inputs are accepted; mixed-case inputs are checked.
10
11mod fixed;
12pub mod numeric;
13/// The published reference's legacy display symbol (Greek capital Xi).
14/// Presentation metadata, not an amount unit or protocol discriminator.
15pub const QUAIS_SYMBOL: &str = "\u{039e}";
16pub use fixed::{FixedError, FixedFormat, FixedPoint, Rounding};
17mod encoding;
18mod error_class;
19pub use error_class::ErrorClass;
20mod text;
21pub use encoding::{
22    EncodingError, MAX_BASE58_BYTES, MAX_ENCODING_BYTES, concat_bytes, data_slice, decode_base58,
23    decode_base58_bytes, decode_base64, decode_bytes32, encode_base58, encode_base64,
24    encode_bytes32, from_twos, get_bytes, hexlify, mask, strip_zeros_left, to_twos, zero_pad_bytes,
25    zero_pad_value,
26};
27pub use text::{
28    UTF8_UNICODE_VERSION, Utf8Normalization, to_utf8_bytes, to_utf8_code_points, to_utf8_string,
29    uuid_v4,
30};
31mod address;
32mod amount;
33mod contract;
34mod hash;
35mod shard;
36
37pub use address::{Address, AddressError, Ledger, QiAddress, QuaiAddress};
38pub use amount::{
39    AmountError, SignedUnits, Unit, format_qi, format_quai, format_units, parse_qi, parse_quai,
40    parse_signed_units, parse_units,
41};
42pub use contract::{contract_address, create2_address};
43pub use hash::{Hash32, Hash32Error};
44pub use shard::{Region, Shard, ShardError, ShardMetadata, Zone};