1#![cfg_attr(all(doc, not(doctest)), feature(doc_auto_cfg))]
2#[doc(no_inline)]
33pub use sui_sdk_types::{
34 ActiveJwk,
35 Address,
36 Argument,
37 CheckpointCommitment,
38 CheckpointContents,
39 CheckpointContentsDigest,
40 CheckpointDigest,
41 CheckpointSequenceNumber,
42 CheckpointSummary,
43 CheckpointTimestamp,
44 Command,
45 ConsensusCommitDigest,
46 Digest,
47 EffectsAuxiliaryDataDigest,
48 EndOfEpochData,
49 EpochId,
50 Event,
51 ExecutionError,
52 ExecutionStatus,
53 GasCostSummary,
54 IdOperation,
55 Identifier,
56 Jwk,
57 JwkId,
58 MoveCall,
59 MovePackage,
60 ObjectDigest,
61 ObjectId,
62 ObjectIn,
63 ObjectOut,
64 ProgrammableTransaction,
65 ProtocolVersion,
66 SignedTransaction,
67 StructTag,
68 Transaction,
69 TransactionDigest,
70 TransactionEffects,
71 TransactionEffectsDigest,
72 TransactionEffectsV1,
73 TransactionEffectsV2,
74 TransactionEvents,
75 TransactionEventsDigest,
76 TransactionExpiration,
77 TransactionKind,
78 TypeOrigin,
79 TypeParseError,
80 TypeTag,
81 UnchangedSharedKind,
82 UpgradeInfo,
83 UserSignature,
84 Version,
85};
86
87mod const_address;
88pub mod encoding;
89#[cfg(feature = "hash")]
90mod hash;
91pub(crate) mod move_core;
93pub mod sui;
95
96#[doc(inline)]
97pub use self::move_core::identifier::{IdentStr, InvalidIdentifierError};
98#[cfg(feature = "u256")]
99#[doc(inline)]
100pub use self::move_core::u256::{self, U256};
101#[doc(inline)]
102pub use self::sui::chain_identifier::ChainIdentifier;
103#[doc(inline)]
104pub use self::sui::effects::TransactionEffectsAPI;
105#[doc(inline)]
106pub use self::sui::full_checkpoint_content::{CheckpointData, CheckpointTransaction};
107#[doc(inline)]
108pub use self::sui::move_object_type::MoveObjectType;
109#[doc(inline)]
110pub use self::sui::object::{MoveObject, Object, Owner};
111#[doc(inline)]
112pub use self::sui::transaction::{
113 GasData,
114 ObjectArg,
115 TransactionData,
116 TransactionDataAPI,
117 TransactionDataV1,
118 TransactionFromBase64Error,
119};
120
121pub type ObjectRef = (ObjectId, Version, ObjectDigest);
133
134pub const CLOCK_ID: ObjectId = ObjectId::new(hex_address_bytes(b"0x6"));
140
141const OBJECT_DIGEST_DELETED_BYTE_VAL: u8 = 99;
142const OBJECT_DIGEST_WRAPPED_BYTE_VAL: u8 = 88;
143const OBJECT_DIGEST_CANCELLED_BYTE_VAL: u8 = 77;
144
145pub const OBJECT_DIGEST_DELETED: ObjectDigest =
147 ObjectDigest::new([OBJECT_DIGEST_DELETED_BYTE_VAL; 32]);
148
149pub const OBJECT_DIGEST_WRAPPED: ObjectDigest =
151 ObjectDigest::new([OBJECT_DIGEST_WRAPPED_BYTE_VAL; 32]);
152
153pub const OBJECT_DIGEST_CANCELLED: ObjectDigest =
154 ObjectDigest::new([OBJECT_DIGEST_CANCELLED_BYTE_VAL; 32]);
155
156pub const COIN_MODULE_NAME: &IdentStr = IdentStr::cast("coin");
157pub const COIN_STRUCT_NAME: &IdentStr = IdentStr::cast("Coin");
158pub const COIN_METADATA_STRUCT_NAME: &IdentStr = IdentStr::cast("CoinMetadata");
159pub const COIN_TREASURE_CAP_NAME: &IdentStr = IdentStr::cast("TreasuryCap");
160
161pub const PAY_MODULE_NAME: &IdentStr = IdentStr::cast("pay");
162pub const PAY_JOIN_FUNC_NAME: &IdentStr = IdentStr::cast("join");
163pub const PAY_SPLIT_N_FUNC_NAME: &IdentStr = IdentStr::cast("divide_and_keep");
164pub const PAY_SPLIT_VEC_FUNC_NAME: &IdentStr = IdentStr::cast("split_vec");
165
166pub const DYNAMIC_FIELD_MODULE_NAME: &IdentStr = IdentStr::cast("dynamic_field");
167pub const DYNAMIC_FIELD_FIELD_STRUCT_NAME: &IdentStr = IdentStr::cast("Field");
168
169pub const DYNAMIC_OBJECT_FIELD_MODULE_NAME: &IdentStr = IdentStr::cast("dynamic_object_field");
170pub const DYNAMIC_OBJECT_FIELD_WRAPPER_STRUCT_NAME: &IdentStr = IdentStr::cast("Wrapper");
171
172pub const MIST_PER_SUI: u64 = 1_000_000_000;
173
174pub const TOTAL_SUPPLY_SUI: u64 = 10_000_000_000;
176
177pub const TOTAL_SUPPLY_MIST: u64 = TOTAL_SUPPLY_SUI * MIST_PER_SUI;
180
181pub const GAS_MODULE_NAME: &IdentStr = IdentStr::cast("sui");
182pub const GAS_STRUCT_NAME: &IdentStr = IdentStr::cast("SUI");
183
184pub const MAX_VALIDATOR_COUNT: u64 = 150;
187
188pub const MIN_VALIDATOR_JOINING_STAKE_MIST: u64 = 30_000_000 * MIST_PER_SUI;
192
193pub const VALIDATOR_LOW_STAKE_THRESHOLD_MIST: u64 = 20_000_000 * MIST_PER_SUI;
201
202pub const VALIDATOR_VERY_LOW_STAKE_THRESHOLD_MIST: u64 = 15_000_000 * MIST_PER_SUI;
207
208pub const VALIDATOR_LOW_STAKE_GRACE_PERIOD: u64 = 7;
211
212pub const STAKING_POOL_MODULE_NAME: &IdentStr = IdentStr::cast("staking_pool");
213pub const STAKED_SUI_STRUCT_NAME: &IdentStr = IdentStr::cast("StakedSui");
214
215pub const ADD_STAKE_MUL_COIN_FUN_NAME: &IdentStr = IdentStr::cast("request_add_stake_mul_coin");
216pub const ADD_STAKE_FUN_NAME: &IdentStr = IdentStr::cast("request_add_stake");
217pub const WITHDRAW_STAKE_FUN_NAME: &IdentStr = IdentStr::cast("request_withdraw_stake");
218
219macro_rules! built_in_ids {
220 ($($addr:ident / $id:ident = $init:expr);* $(;)?) => {
221 $(
222 pub const $addr: Address = builtin_address($init);
223 pub const $id: ObjectId = ObjectId::new($addr.into_inner());
224 )*
225 }
226}
227
228macro_rules! built_in_pkgs {
229 ($($addr:ident / $id:ident = $init:expr);* $(;)?) => {
230 built_in_ids! { $($addr / $id = $init;)* }
231 pub const SYSTEM_PACKAGE_ADDRESSES: &[Address] = &[$($addr),*];
232 pub fn is_system_package(addr: impl Into<Address>) -> bool {
233 matches!(addr.into(), $($addr)|*)
234 }
235 }
236}
237
238built_in_pkgs! {
239 MOVE_STDLIB_ADDRESS / MOVE_STDLIB_PACKAGE_ID = 0x1;
240 SUI_FRAMEWORK_ADDRESS / SUI_FRAMEWORK_PACKAGE_ID = 0x2;
241 SUI_SYSTEM_ADDRESS / SUI_SYSTEM_PACKAGE_ID = 0x3;
242 BRIDGE_ADDRESS / BRIDGE_PACKAGE_ID = 0xb;
243 DEEPBOOK_ADDRESS / DEEPBOOK_PACKAGE_ID = 0xdee9;
244}
245
246const fn builtin_address(suffix: u16) -> Address {
247 let mut addr = [0u8; Address::LENGTH];
248 let [hi, lo] = suffix.to_be_bytes();
249 addr[Address::LENGTH - 2] = hi;
250 addr[Address::LENGTH - 1] = lo;
251 Address::new(addr)
252}
253
254#[doc(inline)]
259pub use self::const_address::hex_address_bytes;
260#[doc(inline)]
261pub use self::encoding::{decode_base64_default, encode_base64_default};
262
263pub const fn address(bytes: &[u8]) -> Address {
265 Address::new(hex_address_bytes(bytes))
266}
267
268pub const fn object_id(bytes: &[u8]) -> ObjectId {
270 ObjectId::new(hex_address_bytes(bytes))
271}