1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
use sbor::Sbor;
use strum::FromRepr;
use strum::IntoStaticStr;
//=========================================================================
// Please update REP-60 after updating types/configs defined in this file!
// Please use and update REP-71 for choosing an entity type prefix
//=========================================================================
/// An enum which represents the different addressable entities.
#[repr(u8)]
#[derive(
Clone, Copy, Debug, PartialEq, Eq, Ord, Hash, PartialOrd, FromRepr, Sbor, IntoStaticStr,
)]
#[sbor(use_repr_discriminators)]
pub enum EntityType {
//=========================================================================
// Package (start with char p for package)
//=========================================================================
/// A global package entity (13 in decimal). Gives Bech32 prefix: `p` followed by one of `5`, `4`, `k` or `h`.
GlobalPackage = 0b00001101, //------------------- 00001 => p, 101xx => 54kh [pkg vanity prefix]
//=========================================================================
// System Components (start with char s for system)
//=========================================================================
/// The global consensus manager entity (134 in decimal). Gives Bech32 prefix: `s` followed by one of `c`, `e`, `6` or `m`.
GlobalConsensusManager = 0b10000110, //-------------- 10000 => s, 110xx => ce6m [se vanity prefix]
/// A global validator entity (131 in decimal). Gives Bech32 prefix: `s` followed by one of `v`, `d`, `w` or `0`.
GlobalValidator = 0b10000011, //--------------------- 10000 => s, 011xx => vdw0
/// A global transaction tracker (130 in decimal). Gives Bech32 prefix: `s` followed by one of `g`, `f`, `2` or `t`.
GlobalTransactionTracker = 0b10000010, //-------- 10000 => s, 010xx => gf2t [st vanity prefix]
//=========================================================================
// Standard Global Components (start with char c for component)
//=========================================================================
/// A global generic (eg scrypto) component entity (192 in decimal). Gives Bech32 prefix: `c` followed by one of `q`, `p`, `z` or `r`.
GlobalGenericComponent = 0b11000000, //---------- 11000 => c, 000xx => qpzr [cpt vanity prefix] (000 = generic component)
/// A global non-virtual native account component entity (193 in decimal). Gives Bech32 prefix: `c` followed by one of `y`, `9`, `x` or `8`.
GlobalAccount = 0b11000001, //------------------- 11000 => c, 001xx => y9x8 (001 = account)
/// A global non-virtual native identity component entity (194 in decimal). Gives Bech32 prefix: `c` followed by one of `g`, `f`, `2` or `t`.
GlobalIdentity = 0b11000010, //------------------ 11000 => c, 010xx => gf2t (010 = identity)
/// A global native access controller entity (195 in decimal). Gives Bech32 prefix: `c` followed by one of `v`, `d`, `w` or `0`.
GlobalAccessController = 0b11000011, //---------- 11000 => c, 011xx => vdw0 (011 = access controller)
/// A global native pool entity (196 in decimal). Gives Bech32 prefix: `c` followed by one of `s`, `3`, `j` or `n`.
GlobalOneResourcePool = 0b11000100, //----------- 11000 => c, 100xx => s3jn (100 = pool)
/// A global native pool entity (197 in decimal). Gives Bech32 prefix: `c` followed by one of `5`, `4`, `k` or `h`.
GlobalTwoResourcePool = 0b11000101, //----------- 11000 => c, 101xx => 54kh (101 = pool)
/// A global native pool entity (197 in decimal). Gives Bech32 prefix: `c` followed by one of `c`, `e`, `6` or `m`.
GlobalMultiResourcePool = 0b11000110, //--------- 11000 => c, 110xx => ce6m (101 = pool)
//=========================================================================
// Secp256k1 Virtual Global Components (start with char 6 for Secp256k1)
//=========================================================================
/// A global virtual Secp256k1 account component entity (209 in decimal). Gives Bech32 prefix: `6` followed by one of `y`, `9`, `x` or `8`.
GlobalVirtualSecp256k1Account = 0b11010001, //--- 11010 => 6, 001xx => y9x8 (001 = account)
/// A global virtual Secp256k1 identity component entity (210 in decimal). Gives Bech32 prefix: `6` followed by one of `g`, `f`, `2` or `t`.
GlobalVirtualSecp256k1Identity = 0b11010010, //-- 11010 => 6, 010xx => gf2t (010 = identity)
//=========================================================================
// Ed25519 Virtual Global Components (start with char 2 for Ed25519)
//=========================================================================
/// A global virtual Ed25519 account component entity (81 in decimal). Gives Bech32 prefix: `2` followed by one of `y`, `9`, `x` or `8`.
GlobalVirtualEd25519Account = 0b01010001, //----- 01010 => 2, 001xx => y9x8 (001 = account)
/// A global virtual Ed25519 identity component entity (82 in decimal). Gives Bech32 prefix: `2` followed by one of `g`, `f`, `2` or `t`.
GlobalVirtualEd25519Identity = 0b01010010, //---- 01010 => 2, 010xx => gf2t (010 = identity)
//=========================================================================
// Fungible-related (start with letter t for token)
//=========================================================================
/// A global fungible resource entity (93 in decimal). Gives Bech32 prefix: `t` followed by one of `5`, `4`, `k` or `h`.
GlobalFungibleResourceManager = 0b01011101, //---------- 01011 => t, 101xx => 54kh [tkn vanity prefix]
/// An internal fungible vault entity (88 in decimal). Gives Bech32 prefix: `t` followed by one of `q`, `p`, `z` or `r`.
InternalFungibleVault = 0b01011000, //------------------ 01011 => t, 000xx => qpzr (000 = vault under t/f prefix)
//=========================================================================
// Non-fungible-related (start with letter n for non-fungible)
//=========================================================================
/// A global non-fungible resource entity (154 in decimal). Gives Bech32 prefix: `n` followed by one of `g`, `f`, `2` or `t`.
GlobalNonFungibleResourceManager = 0b10011010, //------- 10011 => n, 010xx => gf2t [nf vanity prefix]
/// An internal non-fungible vault entity (152 in decimal). Gives Bech32 prefix: `n` followed by one of `q`, `p`, `z` or `r`.
InternalNonFungibleVault = 0b10011000, //-------- 10011 => n, 000xx => qpzr (000 = vault under t/f prefix)
//=========================================================================
// Internal misc components (start with letter l for ..? local)
//=========================================================================
/// An internal generic (eg scrypto) component entity (248 in decimal). Gives Bech32 prefix: `l` followed by one of `q`, `p`, `z` or `r`.
InternalGenericComponent = 0b11111000, //-------- 11111 => l, 000xx => qpzr (000 = generic component)
//=========================================================================
// Internal key-value-store-like entities (start with k for key-value)
//=========================================================================
/// An internal key-value store entity (176 in decimal). Gives Bech32 prefix: `k` followed by one of `q`, `p`, `z` or `r`.
///
/// A key value store allows access to substates, but not on-ledger iteration.
/// The substates are considered independent for contention/locking/versioning.
InternalKeyValueStore = 0b10110000, //----------- 10110 => k, 000xx => qpzr
}
impl EntityType {
pub const fn is_global(&self) -> bool {
match self {
EntityType::GlobalPackage
| EntityType::GlobalFungibleResourceManager
| EntityType::GlobalNonFungibleResourceManager
| EntityType::GlobalConsensusManager
| EntityType::GlobalValidator
| EntityType::GlobalAccessController
| EntityType::GlobalAccount
| EntityType::GlobalIdentity
| EntityType::GlobalGenericComponent
| EntityType::GlobalVirtualSecp256k1Account
| EntityType::GlobalVirtualEd25519Account
| EntityType::GlobalVirtualSecp256k1Identity
| EntityType::GlobalVirtualEd25519Identity
| EntityType::GlobalOneResourcePool
| EntityType::GlobalTwoResourcePool
| EntityType::GlobalMultiResourcePool
| EntityType::GlobalTransactionTracker => true,
EntityType::InternalFungibleVault
| EntityType::InternalNonFungibleVault
| EntityType::InternalGenericComponent
| EntityType::InternalKeyValueStore => false,
}
}
pub const fn is_internal(&self) -> bool {
!self.is_global()
}
pub const fn is_global_component(&self) -> bool {
match self {
EntityType::GlobalConsensusManager
| EntityType::GlobalValidator
| EntityType::GlobalAccessController
| EntityType::GlobalAccount
| EntityType::GlobalIdentity
| EntityType::GlobalGenericComponent
| EntityType::GlobalVirtualSecp256k1Account
| EntityType::GlobalVirtualEd25519Account
| EntityType::GlobalVirtualSecp256k1Identity
| EntityType::GlobalVirtualEd25519Identity
| EntityType::GlobalOneResourcePool
| EntityType::GlobalTwoResourcePool
| EntityType::GlobalMultiResourcePool
| EntityType::GlobalTransactionTracker => true,
EntityType::GlobalPackage
| EntityType::GlobalFungibleResourceManager
| EntityType::GlobalNonFungibleResourceManager
| EntityType::InternalFungibleVault
| EntityType::InternalNonFungibleVault
| EntityType::InternalGenericComponent
| EntityType::InternalKeyValueStore => false,
}
}
pub const fn is_global_package(&self) -> bool {
matches!(self, EntityType::GlobalPackage)
}
pub const fn is_global_consensus_manager(&self) -> bool {
matches!(self, EntityType::GlobalConsensusManager)
}
pub const fn is_global_validator(&self) -> bool {
matches!(self, EntityType::GlobalValidator)
}
pub const fn is_global_resource_manager(&self) -> bool {
matches!(
self,
EntityType::GlobalFungibleResourceManager
| EntityType::GlobalNonFungibleResourceManager
)
}
pub const fn is_global_fungible_resource_manager(&self) -> bool {
matches!(self, EntityType::GlobalFungibleResourceManager)
}
pub const fn is_global_non_fungible_resource_manager(&self) -> bool {
matches!(self, EntityType::GlobalNonFungibleResourceManager)
}
pub const fn is_global_virtual(&self) -> bool {
match self {
EntityType::GlobalVirtualSecp256k1Account
| EntityType::GlobalVirtualEd25519Account
| EntityType::GlobalVirtualSecp256k1Identity
| EntityType::GlobalVirtualEd25519Identity => true,
_ => false,
}
}
pub const fn is_internal_kv_store(&self) -> bool {
matches!(self, EntityType::InternalKeyValueStore)
}
pub const fn is_internal_fungible_vault(&self) -> bool {
matches!(self, EntityType::InternalFungibleVault)
}
pub const fn is_internal_non_fungible_vault(&self) -> bool {
matches!(self, EntityType::InternalNonFungibleVault)
}
pub const fn is_internal_vault(&self) -> bool {
matches!(
self,
EntityType::InternalFungibleVault | EntityType::InternalNonFungibleVault
)
}
}