1#[doc(no_inline)]
32pub use sui_sdk_types::{
33 ActiveJwk, Address, Argument, CheckpointCommitment, CheckpointContents, CheckpointData,
34 CheckpointSequenceNumber, CheckpointSummary, CheckpointTimestamp, CheckpointTransaction,
35 Command, Digest, EndOfEpochData, EpochId, Event, ExecutionError, ExecutionStatus,
36 GasCostSummary, IdOperation, Identifier, Jwk, JwkId, MoveCall, MovePackage, Object, ObjectIn,
37 ObjectOut, Owner, ProgrammableTransaction, ProtocolVersion, SignedTransaction, StructTag,
38 Transaction, TransactionEffects, TransactionEffectsV1, TransactionEffectsV2, TransactionEvents,
39 TransactionExpiration, TransactionKind, TypeOrigin, TypeParseError, TypeTag,
40 UnchangedConsensusKind, UpgradeInfo, UserSignature, Version,
41};
42
43pub mod encoding;
44pub(crate) mod move_core;
46pub mod sui;
48
49#[doc(inline)]
50pub use self::move_core::identifier::{IdentStr, InvalidIdentifierError};
51#[cfg(feature = "u256")]
52#[doc(inline)]
53pub use self::move_core::u256::{self, U256};
54#[doc(inline)]
55pub use self::sui::chain_identifier::ChainIdentifier;
56#[doc(inline)]
57pub use self::sui::effects::TransactionEffectsAPI;
58#[doc(inline)]
59pub use self::sui::move_object_type::MoveObjectType;
60#[doc(inline)]
61pub use self::sui::transaction::{ImmOwnedOrReceivingError, ObjectArg};
62
63pub type ObjectRef = (Address, Version, Digest);
75
76pub const CLOCK_ID: Address = Address::from_static("0x6");
82
83const OBJECT_DIGEST_DELETED_BYTE_VAL: u8 = 99;
84const OBJECT_DIGEST_WRAPPED_BYTE_VAL: u8 = 88;
85const OBJECT_DIGEST_CANCELLED_BYTE_VAL: u8 = 77;
86
87pub const OBJECT_DIGEST_DELETED: Digest = Digest::new([OBJECT_DIGEST_DELETED_BYTE_VAL; 32]);
89
90pub const OBJECT_DIGEST_WRAPPED: Digest = Digest::new([OBJECT_DIGEST_WRAPPED_BYTE_VAL; 32]);
92
93pub const OBJECT_DIGEST_CANCELLED: Digest = Digest::new([OBJECT_DIGEST_CANCELLED_BYTE_VAL; 32]);
94
95pub const COIN_MODULE_NAME: &IdentStr = IdentStr::cast("coin");
96pub const COIN_STRUCT_NAME: &IdentStr = IdentStr::cast("Coin");
97pub const COIN_METADATA_STRUCT_NAME: &IdentStr = IdentStr::cast("CoinMetadata");
98pub const COIN_TREASURE_CAP_NAME: &IdentStr = IdentStr::cast("TreasuryCap");
99
100pub const PAY_MODULE_NAME: &IdentStr = IdentStr::cast("pay");
101pub const PAY_JOIN_FUNC_NAME: &IdentStr = IdentStr::cast("join");
102pub const PAY_SPLIT_N_FUNC_NAME: &IdentStr = IdentStr::cast("divide_and_keep");
103pub const PAY_SPLIT_VEC_FUNC_NAME: &IdentStr = IdentStr::cast("split_vec");
104
105pub const DYNAMIC_FIELD_MODULE_NAME: &IdentStr = IdentStr::cast("dynamic_field");
106pub const DYNAMIC_FIELD_FIELD_STRUCT_NAME: &IdentStr = IdentStr::cast("Field");
107
108pub const DYNAMIC_OBJECT_FIELD_MODULE_NAME: &IdentStr = IdentStr::cast("dynamic_object_field");
109pub const DYNAMIC_OBJECT_FIELD_WRAPPER_STRUCT_NAME: &IdentStr = IdentStr::cast("Wrapper");
110
111pub const MIST_PER_SUI: u64 = 1_000_000_000;
112
113pub const TOTAL_SUPPLY_SUI: u64 = 10_000_000_000;
115
116pub const TOTAL_SUPPLY_MIST: u64 = TOTAL_SUPPLY_SUI * MIST_PER_SUI;
119
120pub const GAS_MODULE_NAME: &IdentStr = IdentStr::cast("sui");
121pub const GAS_STRUCT_NAME: &IdentStr = IdentStr::cast("SUI");
122
123pub const MAX_VALIDATOR_COUNT: u64 = 150;
126
127pub const MIN_VALIDATOR_JOINING_STAKE_MIST: u64 = 30_000_000 * MIST_PER_SUI;
131
132pub const VALIDATOR_LOW_STAKE_THRESHOLD_MIST: u64 = 20_000_000 * MIST_PER_SUI;
140
141pub const VALIDATOR_VERY_LOW_STAKE_THRESHOLD_MIST: u64 = 15_000_000 * MIST_PER_SUI;
146
147pub const VALIDATOR_LOW_STAKE_GRACE_PERIOD: u64 = 7;
150
151pub const STAKING_POOL_MODULE_NAME: &IdentStr = IdentStr::cast("staking_pool");
152pub const STAKED_SUI_STRUCT_NAME: &IdentStr = IdentStr::cast("StakedSui");
153
154pub const ADD_STAKE_MUL_COIN_FUN_NAME: &IdentStr = IdentStr::cast("request_add_stake_mul_coin");
155pub const ADD_STAKE_FUN_NAME: &IdentStr = IdentStr::cast("request_add_stake");
156pub const WITHDRAW_STAKE_FUN_NAME: &IdentStr = IdentStr::cast("request_withdraw_stake");
157
158macro_rules! built_in_ids {
159 ($($addr:ident / $id:ident = $init:expr_2021);* $(;)?) => {
160 $(
161 pub const $addr: Address = builtin_address($init);
162 pub const $id: Address = Address::new($addr.into_inner());
163 )*
164 }
165}
166
167macro_rules! built_in_pkgs {
168 ($($addr:ident / $id:ident = $init:expr_2021);* $(;)?) => {
169 built_in_ids! { $($addr / $id = $init;)* }
170 pub const SYSTEM_PACKAGE_ADDRESSES: &[Address] = &[$($addr),*];
171 pub fn is_system_package(addr: impl Into<Address>) -> bool {
172 matches!(addr.into(), $($addr)|*)
173 }
174 }
175}
176
177built_in_pkgs! {
178 MOVE_STDLIB_ADDRESS / MOVE_STDLIB_PACKAGE_ID = 0x1;
179 SUI_FRAMEWORK_ADDRESS / SUI_FRAMEWORK_PACKAGE_ID = 0x2;
180 SUI_SYSTEM_ADDRESS / SUI_SYSTEM_PACKAGE_ID = 0x3;
181 BRIDGE_ADDRESS / BRIDGE_PACKAGE_ID = 0xb;
182 DEEPBOOK_ADDRESS / DEEPBOOK_PACKAGE_ID = 0xdee9;
183}
184
185const fn builtin_address(suffix: u16) -> Address {
186 let mut addr = [0u8; Address::LENGTH];
187 let [hi, lo] = suffix.to_be_bytes();
188 addr[Address::LENGTH - 2] = hi;
189 addr[Address::LENGTH - 1] = lo;
190 Address::new(addr)
191}
192
193#[derive(Clone, Debug, Eq, PartialEq)]
198pub struct StructTagHelper {
199 pub address: Address,
200 pub module: Identifier,
201 pub name: Identifier,
202 pub type_params: Vec<TypeTag>,
203}
204
205impl From<StructTagHelper> for StructTag {
206 fn from(helper: StructTagHelper) -> Self {
207 Self::new(
208 helper.address,
209 helper.module,
210 helper.name,
211 helper.type_params,
212 )
213 }
214}
215
216impl From<&StructTag> for StructTagHelper {
217 fn from(struct_tag: &StructTag) -> Self {
218 Self {
219 address: *struct_tag.address(),
220 module: struct_tag.module().clone(),
221 name: struct_tag.name().clone(),
222 type_params: struct_tag.type_params().to_vec(),
223 }
224 }
225}
226
227#[doc(inline)]
232pub use self::encoding::{decode_base64_default, encode_base64_default};