#[doc(no_inline)]
pub use sui_sdk_types::{
ActiveJwk, Address, Argument, CheckpointCommitment, CheckpointContents, CheckpointData,
CheckpointSequenceNumber, CheckpointSummary, CheckpointTimestamp, CheckpointTransaction,
Command, Digest, EndOfEpochData, EpochId, Event, ExecutionError, ExecutionStatus,
GasCostSummary, IdOperation, Identifier, Jwk, JwkId, MoveCall, MovePackage, Object, ObjectIn,
ObjectOut, Owner, ProgrammableTransaction, ProtocolVersion, SignedTransaction, StructTag,
Transaction, TransactionEffects, TransactionEffectsV1, TransactionEffectsV2, TransactionEvents,
TransactionExpiration, TransactionKind, TypeOrigin, TypeParseError, TypeTag,
UnchangedConsensusKind, UpgradeInfo, UserSignature, Version,
};
pub mod encoding;
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::move_object_type::MoveObjectType;
#[doc(inline)]
pub use self::sui::transaction::{ImmOwnedOrReceivingError, ObjectArg};
pub type ObjectRef = (Address, Version, Digest);
pub const CLOCK_ID: Address = Address::from_static("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: Digest = Digest::new([OBJECT_DIGEST_DELETED_BYTE_VAL; 32]);
pub const OBJECT_DIGEST_WRAPPED: Digest = Digest::new([OBJECT_DIGEST_WRAPPED_BYTE_VAL; 32]);
pub const OBJECT_DIGEST_CANCELLED: Digest = Digest::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_2021);* $(;)?) => {
$(
pub const $addr: Address = builtin_address($init);
pub const $id: Address = Address::new($addr.into_inner());
)*
}
}
macro_rules! built_in_pkgs {
($($addr:ident / $id:ident = $init:expr_2021);* $(;)?) => {
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)
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct StructTagHelper {
pub address: Address,
pub module: Identifier,
pub name: Identifier,
pub type_params: Vec<TypeTag>,
}
impl From<StructTagHelper> for StructTag {
fn from(helper: StructTagHelper) -> Self {
Self::new(
helper.address,
helper.module,
helper.name,
helper.type_params,
)
}
}
impl From<&StructTag> for StructTagHelper {
fn from(struct_tag: &StructTag) -> Self {
Self {
address: *struct_tag.address(),
module: struct_tag.module().clone(),
name: struct_tag.name().clone(),
type_params: struct_tag.type_params().to_vec(),
}
}
}
#[doc(inline)]
pub use self::encoding::{decode_base64_default, encode_base64_default};