pub struct ProgramCore<N: Network> { /* private fields */ }Implementations§
Source§impl<N: Network> ProgramCore<N>
impl<N: Network> ProgramCore<N>
Sourcepub fn to_checksum(&self) -> [U8<N>; 32]
pub fn to_checksum(&self) -> [U8<N>; 32]
Returns the checksum of the program.
The checksum is a 32-byte hash of the program’s source code in string format. This ensures a strict definition of program equivalence, useful for program upgradability.
Source§impl<N: Network> ProgramCore<N>
impl<N: Network> ProgramCore<N>
Sourcepub const KEYWORDS: &'static [&'static str]
pub const KEYWORDS: &'static [&'static str]
A list of reserved keywords for Aleo programs, enforced at the parser level.
Sourcepub const RESTRICTED_KEYWORDS: &'static [(ConsensusVersion, &'static [&'static str])]
pub const RESTRICTED_KEYWORDS: &'static [(ConsensusVersion, &'static [&'static str])]
A list of restricted keywords for Aleo programs, enforced at the VM-level for program hygiene. Each entry is a tuple of the consensus version and a list of keywords. If the current consensus version is greater than or equal to the specified version, the keywords in the list should be restricted.
Sourcepub const fn imports(&self) -> &IndexMap<ProgramID<N>, Import<N>>
pub const fn imports(&self) -> &IndexMap<ProgramID<N>, Import<N>>
Returns the imports in the program.
Sourcepub const fn constructor(&self) -> Option<&ConstructorCore<N>>
pub const fn constructor(&self) -> Option<&ConstructorCore<N>>
Returns the constructor for the program.
Sourcepub const fn mappings(&self) -> &IndexMap<Identifier<N>, Mapping<N>>
pub const fn mappings(&self) -> &IndexMap<Identifier<N>, Mapping<N>>
Returns the mappings in the program.
Sourcepub const fn structs(&self) -> &IndexMap<Identifier<N>, StructType<N>>
pub const fn structs(&self) -> &IndexMap<Identifier<N>, StructType<N>>
Returns the structs in the program.
Sourcepub const fn records(&self) -> &IndexMap<Identifier<N>, RecordType<N>>
pub const fn records(&self) -> &IndexMap<Identifier<N>, RecordType<N>>
Returns the records in the program.
Sourcepub const fn closures(&self) -> &IndexMap<Identifier<N>, ClosureCore<N>>
pub const fn closures(&self) -> &IndexMap<Identifier<N>, ClosureCore<N>>
Returns the closures in the program.
Sourcepub const fn functions(&self) -> &IndexMap<Identifier<N>, FunctionCore<N>>
pub const fn functions(&self) -> &IndexMap<Identifier<N>, FunctionCore<N>>
Returns the functions in the program.
Sourcepub fn contains_import(&self, id: &ProgramID<N>) -> bool
pub fn contains_import(&self, id: &ProgramID<N>) -> bool
Returns true if the program contains an import with the given program ID.
Sourcepub const fn contains_constructor(&self) -> bool
pub const fn contains_constructor(&self) -> bool
Returns true if the program contains a constructor.
Sourcepub fn contains_mapping(&self, name: &Identifier<N>) -> bool
pub fn contains_mapping(&self, name: &Identifier<N>) -> bool
Returns true if the program contains a mapping with the given name.
Sourcepub fn contains_struct(&self, name: &Identifier<N>) -> bool
pub fn contains_struct(&self, name: &Identifier<N>) -> bool
Returns true if the program contains a struct with the given name.
Sourcepub fn contains_record(&self, name: &Identifier<N>) -> bool
pub fn contains_record(&self, name: &Identifier<N>) -> bool
Returns true if the program contains a record with the given name.
Sourcepub fn contains_closure(&self, name: &Identifier<N>) -> bool
pub fn contains_closure(&self, name: &Identifier<N>) -> bool
Returns true if the program contains a closure with the given name.
Sourcepub fn contains_function(&self, name: &Identifier<N>) -> bool
pub fn contains_function(&self, name: &Identifier<N>) -> bool
Returns true if the program contains a function with the given name.
Sourcepub fn get_mapping(&self, name: &Identifier<N>) -> Result<Mapping<N>>
pub fn get_mapping(&self, name: &Identifier<N>) -> Result<Mapping<N>>
Returns the mapping with the given name.
Sourcepub fn get_struct(&self, name: &Identifier<N>) -> Result<&StructType<N>>
pub fn get_struct(&self, name: &Identifier<N>) -> Result<&StructType<N>>
Returns the struct with the given name.
Sourcepub fn get_record(&self, name: &Identifier<N>) -> Result<&RecordType<N>>
pub fn get_record(&self, name: &Identifier<N>) -> Result<&RecordType<N>>
Returns the record with the given name.
Sourcepub fn get_closure(&self, name: &Identifier<N>) -> Result<ClosureCore<N>>
pub fn get_closure(&self, name: &Identifier<N>) -> Result<ClosureCore<N>>
Returns the closure with the given name.
Sourcepub fn get_function(&self, name: &Identifier<N>) -> Result<FunctionCore<N>>
pub fn get_function(&self, name: &Identifier<N>) -> Result<FunctionCore<N>>
Returns the function with the given name.
Sourcepub fn get_function_ref(&self, name: &Identifier<N>) -> Result<&FunctionCore<N>>
pub fn get_function_ref(&self, name: &Identifier<N>) -> Result<&FunctionCore<N>>
Returns a reference to the function with the given name.
Sourcepub fn is_reserved_opcode(name: &str) -> bool
pub fn is_reserved_opcode(name: &str) -> bool
Returns true if the given name is a reserved opcode.
Sourcepub fn is_reserved_keyword(name: &Identifier<N>) -> bool
pub fn is_reserved_keyword(name: &Identifier<N>) -> bool
Returns true if the given name uses a reserved keyword.
Sourcepub fn restricted_keywords_for_consensus_version(
consensus_version: ConsensusVersion,
) -> impl Iterator<Item = &'static str>
pub fn restricted_keywords_for_consensus_version( consensus_version: ConsensusVersion, ) -> impl Iterator<Item = &'static str>
Returns an iterator over the restricted keywords for the given consensus version.
Sourcepub fn check_restricted_keywords_for_consensus_version(
&self,
consensus_version: ConsensusVersion,
) -> Result<()>
pub fn check_restricted_keywords_for_consensus_version( &self, consensus_version: ConsensusVersion, ) -> Result<()>
Checks a program for restricted keywords for the given consensus version. Returns an error if any restricted keywords are found. Note: Restrictions are not enforced on the import names in case they were deployed before the restrictions were added.
Sourcepub fn check_program_naming_structure(&self) -> Result<()>
pub fn check_program_naming_structure(&self) -> Result<()>
Checks that the program structure is well-formed under the following rules:
- The program ID must not contain the keyword “aleo” in the program name.
- The record name must not contain the keyword “aleo”.
- Record names must not be prefixes of other record names.
- Record entry names must not contain the keyword “aleo”.
Sourcepub fn check_external_calls_to_credits_upgrade(&self) -> Result<()>
pub fn check_external_calls_to_credits_upgrade(&self) -> Result<()>
Checks that the program does not make external calls to credits.aleo/upgrade.
Sourcepub fn contains_v9_syntax(&self) -> bool
pub fn contains_v9_syntax(&self) -> bool
Returns true if a program contains any V9 syntax.
This includes constructor, Operand::Edition, Operand::Checksum, and Operand::ProgramOwner.
This is enforced to be false for programs before ConsensusVersion::V9.
Sourcepub fn exceeds_max_array_size(&self, max_array_size: u32) -> bool
pub fn exceeds_max_array_size(&self, max_array_size: u32) -> bool
Returns true if the program contains an array type with a size that exceeds the given maximum.
Sourcepub fn contains_v11_syntax(&self) -> bool
pub fn contains_v11_syntax(&self) -> bool
Returns true if a program contains any V11 syntax.
This includes:
.rawhash or signature verification variantsecdsa.verify.*opcodes- arrays that exceed the previous maximum length of 32.
Trait Implementations§
Source§impl<N: Clone + Network> Clone for ProgramCore<N>
impl<N: Clone + Network> Clone for ProgramCore<N>
Source§fn clone(&self) -> ProgramCore<N>
fn clone(&self) -> ProgramCore<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<N: Network> Debug for ProgramCore<N>
impl<N: Network> Debug for ProgramCore<N>
Source§impl<'de, N: Network> Deserialize<'de> for ProgramCore<N>
impl<'de, N: Network> Deserialize<'de> for ProgramCore<N>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserializes the program from a string or bytes.
Source§impl<N: Network> Display for ProgramCore<N>
impl<N: Network> Display for ProgramCore<N>
Source§impl<N: Network> FromBytes for ProgramCore<N>
impl<N: Network> FromBytes for ProgramCore<N>
Source§fn read_le<R: Read>(reader: R) -> IoResult<Self>
fn read_le<R: Read>(reader: R) -> IoResult<Self>
Self from reader as little-endian bytes.Source§fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
Self from a byte array in little-endian order.Source§fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
Self::from_bytes_le but avoids costly checks.
This shall only be called when deserializing from a trusted source, such as local storage. Read moreSource§fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
Self::read_le but avoids costly checks.
This shall only be called when deserializing from a trusted source, such as local storage. Read moreSource§impl<N: Network> FromStr for ProgramCore<N>
impl<N: Network> FromStr for ProgramCore<N>
Source§impl<N: Network> Parser for ProgramCore<N>
impl<N: Network> Parser for ProgramCore<N>
Source§fn parse(string: &str) -> ParserResult<'_, Self>
fn parse(string: &str) -> ParserResult<'_, Self>
Parses a string into a program.
Source§impl<N: Network> PartialEq for ProgramCore<N>
impl<N: Network> PartialEq for ProgramCore<N>
Source§impl<N: Network> Serialize for ProgramCore<N>
impl<N: Network> Serialize for ProgramCore<N>
Source§impl<N: Network> ToBytes for ProgramCore<N>
impl<N: Network> ToBytes for ProgramCore<N>
Source§impl<N: Network> TypeName for ProgramCore<N>
impl<N: Network> TypeName for ProgramCore<N>
impl<N: Network> Eq for ProgramCore<N>
Auto Trait Implementations§
impl<N> Freeze for ProgramCore<N>
impl<N> RefUnwindSafe for ProgramCore<N>where
<N as Environment>::Field: RefUnwindSafe,
N: RefUnwindSafe,
<N as Environment>::Projective: RefUnwindSafe,
<N as Environment>::Scalar: RefUnwindSafe,
impl<N> Send for ProgramCore<N>
impl<N> Sync for ProgramCore<N>
impl<N> Unpin for ProgramCore<N>where
<N as Environment>::Field: Unpin,
N: Unpin,
<N as Environment>::Projective: Unpin,
<N as Environment>::Scalar: Unpin,
impl<N> UnwindSafe for ProgramCore<N>where
<N as Environment>::Field: UnwindSafe,
N: UnwindSafe,
<N as Environment>::Projective: UnwindSafe,
<N as Environment>::Scalar: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
fn take_from_value<D>(
value: &mut Value,
field: &str,
) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more