#![cfg_attr(all(doc, not(doctest)), feature(doc_auto_cfg))]
#[doc(no_inline)]
pub use sui_sdk_types::{
ActiveJwk,
Address,
Argument,
CheckpointCommitment,
CheckpointContents,
CheckpointContentsDigest,
CheckpointDigest,
CheckpointSequenceNumber,
CheckpointSummary,
CheckpointTimestamp,
Command,
ConsensusCommitDigest,
Digest,
EffectsAuxiliaryDataDigest,
EndOfEpochData,
EpochId,
Event,
ExecutionError,
ExecutionStatus,
GasCostSummary,
IdOperation,
Identifier,
Jwk,
JwkId,
MoveCall,
MovePackage,
ObjectDigest,
ObjectId,
ObjectIn,
ObjectOut,
ProgrammableTransaction,
ProtocolVersion,
SignedTransaction,
StructTag,
Transaction,
TransactionDigest,
TransactionEffects,
TransactionEffectsDigest,
TransactionEffectsV1,
TransactionEffectsV2,
TransactionEvents,
TransactionEventsDigest,
TransactionExpiration,
TransactionKind,
TypeOrigin,
TypeTag,
UnchangedSharedKind,
UpgradeInfo,
UserSignature,
Version,
};
mod const_address;
pub mod encoding;
#[cfg(feature = "hash")]
mod hash;
pub(crate) mod move_core;
pub mod sui;
#[doc(inline)]
pub use self::move_core::identifier::{IdentStr, InvalidIdentifierError};
#[cfg(feature = "u256")]
#[doc(inline)]
pub use self::move_core::u256::{self, U256};
#[doc(inline)]
pub use self::sui::chain_identifier::ChainIdentifier;
#[doc(inline)]
pub use self::sui::effects::TransactionEffectsAPI;
#[doc(inline)]
pub use self::sui::full_checkpoint_content::{CheckpointData, CheckpointTransaction};
#[doc(inline)]
pub use self::sui::move_object_type::MoveObjectType;
#[doc(inline)]
pub use self::sui::object::{MoveObject, Object, Owner};
#[doc(inline)]
pub use self::sui::transaction::{
GasData,
ObjectArg,
TransactionData,
TransactionDataAPI,
TransactionDataV1,
TransactionFromBase64Error,
};
pub type ObjectRef = (ObjectId, Version, ObjectDigest);
pub const CLOCK_ID: ObjectId = ObjectId::new(hex_address_bytes(b"0x6"));
const OBJECT_DIGEST_DELETED_BYTE_VAL: u8 = 99;
const OBJECT_DIGEST_WRAPPED_BYTE_VAL: u8 = 88;
const OBJECT_DIGEST_CANCELLED_BYTE_VAL: u8 = 77;
pub const OBJECT_DIGEST_DELETED: ObjectDigest =
ObjectDigest::new([OBJECT_DIGEST_DELETED_BYTE_VAL; 32]);
pub const OBJECT_DIGEST_WRAPPED: ObjectDigest =
ObjectDigest::new([OBJECT_DIGEST_WRAPPED_BYTE_VAL; 32]);
pub const OBJECT_DIGEST_CANCELLED: ObjectDigest =
ObjectDigest::new([OBJECT_DIGEST_CANCELLED_BYTE_VAL; 32]);
pub const COIN_MODULE_NAME: &IdentStr = IdentStr::cast("coin");
pub const COIN_STRUCT_NAME: &IdentStr = IdentStr::cast("Coin");
pub const COIN_METADATA_STRUCT_NAME: &IdentStr = IdentStr::cast("CoinMetadata");
pub const COIN_TREASURE_CAP_NAME: &IdentStr = IdentStr::cast("TreasuryCap");
pub const PAY_MODULE_NAME: &IdentStr = IdentStr::cast("pay");
pub const PAY_JOIN_FUNC_NAME: &IdentStr = IdentStr::cast("join");
pub const PAY_SPLIT_N_FUNC_NAME: &IdentStr = IdentStr::cast("divide_and_keep");
pub const PAY_SPLIT_VEC_FUNC_NAME: &IdentStr = IdentStr::cast("split_vec");
pub const DYNAMIC_FIELD_MODULE_NAME: &IdentStr = IdentStr::cast("dynamic_field");
pub const DYNAMIC_FIELD_FIELD_STRUCT_NAME: &IdentStr = IdentStr::cast("Field");
pub const DYNAMIC_OBJECT_FIELD_MODULE_NAME: &IdentStr = IdentStr::cast("dynamic_object_field");
pub const DYNAMIC_OBJECT_FIELD_WRAPPER_STRUCT_NAME: &IdentStr = IdentStr::cast("Wrapper");
pub const MIST_PER_SUI: u64 = 1_000_000_000;
pub const TOTAL_SUPPLY_SUI: u64 = 10_000_000_000;
pub const TOTAL_SUPPLY_MIST: u64 = TOTAL_SUPPLY_SUI * MIST_PER_SUI;
pub const GAS_MODULE_NAME: &IdentStr = IdentStr::cast("sui");
pub const GAS_STRUCT_NAME: &IdentStr = IdentStr::cast("SUI");
pub const MAX_VALIDATOR_COUNT: u64 = 150;
pub const MIN_VALIDATOR_JOINING_STAKE_MIST: u64 = 30_000_000 * MIST_PER_SUI;
pub const VALIDATOR_LOW_STAKE_THRESHOLD_MIST: u64 = 20_000_000 * MIST_PER_SUI;
pub const VALIDATOR_VERY_LOW_STAKE_THRESHOLD_MIST: u64 = 15_000_000 * MIST_PER_SUI;
pub const VALIDATOR_LOW_STAKE_GRACE_PERIOD: u64 = 7;
pub const STAKING_POOL_MODULE_NAME: &IdentStr = IdentStr::cast("staking_pool");
pub const STAKED_SUI_STRUCT_NAME: &IdentStr = IdentStr::cast("StakedSui");
pub const ADD_STAKE_MUL_COIN_FUN_NAME: &IdentStr = IdentStr::cast("request_add_stake_mul_coin");
pub const ADD_STAKE_FUN_NAME: &IdentStr = IdentStr::cast("request_add_stake");
pub const WITHDRAW_STAKE_FUN_NAME: &IdentStr = IdentStr::cast("request_withdraw_stake");
macro_rules! built_in_ids {
($($addr:ident / $id:ident = $init:expr);* $(;)?) => {
$(
pub const $addr: Address = builtin_address($init);
pub const $id: ObjectId = ObjectId::new($addr.into_inner());
)*
}
}
macro_rules! built_in_pkgs {
($($addr:ident / $id:ident = $init:expr);* $(;)?) => {
built_in_ids! { $($addr / $id = $init;)* }
pub const SYSTEM_PACKAGE_ADDRESSES: &[Address] = &[$($addr),*];
pub fn is_system_package(addr: impl Into<Address>) -> bool {
matches!(addr.into(), $($addr)|*)
}
}
}
built_in_pkgs! {
MOVE_STDLIB_ADDRESS / MOVE_STDLIB_PACKAGE_ID = 0x1;
SUI_FRAMEWORK_ADDRESS / SUI_FRAMEWORK_PACKAGE_ID = 0x2;
SUI_SYSTEM_ADDRESS / SUI_SYSTEM_PACKAGE_ID = 0x3;
BRIDGE_ADDRESS / BRIDGE_PACKAGE_ID = 0xb;
DEEPBOOK_ADDRESS / DEEPBOOK_PACKAGE_ID = 0xdee9;
}
const fn builtin_address(suffix: u16) -> Address {
let mut addr = [0u8; Address::LENGTH];
let [hi, lo] = suffix.to_be_bytes();
addr[Address::LENGTH - 2] = hi;
addr[Address::LENGTH - 1] = lo;
Address::new(addr)
}
#[doc(inline)]
pub use self::const_address::hex_address_bytes;
#[doc(inline)]
pub use self::encoding::{decode_base64_default, encode_base64_default};
pub const fn address(bytes: &[u8]) -> Address {
Address::new(hex_address_bytes(bytes))
}
pub const fn object_id(bytes: &[u8]) -> ObjectId {
ObjectId::new(hex_address_bytes(bytes))
}