Enum ethers_solc::artifacts::bytecode::BytecodeObject
source · Expand description
Represents the bytecode of a contracts that might be not fully linked yet.
Variants§
Bytecode(Bytes)
Fully linked bytecode object
Unlinked(String)
Bytecode as hex string that’s not fully linked yet and contains library placeholders
Implementations§
source§impl BytecodeObject
impl BytecodeObject
sourcepub fn into_bytes(self) -> Option<Bytes>
pub fn into_bytes(self) -> Option<Bytes>
Returns the underlying Bytes
if the object is a valid bytecode, and not empty
sourcepub fn as_bytes(&self) -> Option<&Bytes>
pub fn as_bytes(&self) -> Option<&Bytes>
Returns a reference to the underlying Bytes
if the object is a valid bytecode, and not
empty
sourcepub fn bytes_len(&self) -> usize
pub fn bytes_len(&self) -> usize
Returns the number of bytes of the fully linked bytecode
Returns 0
if this object is unlinked.
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns a reference to the underlying String
if the object is unlinked
sourcepub fn into_unlinked(self) -> Option<String>
pub fn into_unlinked(self) -> Option<String>
Returns the unlinked String
if the object is unlinked or empty
sourcepub fn is_unlinked(&self) -> bool
pub fn is_unlinked(&self) -> bool
Whether this object is still unlinked
sourcepub fn is_bytecode(&self) -> bool
pub fn is_bytecode(&self) -> bool
Whether this object a valid bytecode
sourcepub fn is_non_empty_bytecode(&self) -> bool
pub fn is_non_empty_bytecode(&self) -> bool
Returns true
if the object is a valid bytecode and not empty.
Returns false the object is a valid but empty bytecode or unlinked.
sourcepub fn resolve(&mut self) -> Option<&Bytes>
pub fn resolve(&mut self) -> Option<&Bytes>
Tries to resolve the unlinked string object a valid bytecode object in place
Returns the string if it is a valid
sourcepub fn link_fully_qualified(
&mut self,
name: impl AsRef<str>,
addr: Address
) -> &mut Self
pub fn link_fully_qualified(
&mut self,
name: impl AsRef<str>,
addr: Address
) -> &mut Self
Link using the fully qualified name of a library
The fully qualified library name is the path of its source file and the library name
separated by :
like file.sol:Math
This will replace all occurrences of the library placeholder with the given address.
See also: https://docs.soliditylang.org/en/develop/using-the-compiler.html#library-linking
sourcepub fn link(
&mut self,
file: impl AsRef<str>,
library: impl AsRef<str>,
addr: Address
) -> &mut Self
pub fn link(
&mut self,
file: impl AsRef<str>,
library: impl AsRef<str>,
addr: Address
) -> &mut Self
Link using the file
and library
names as fully qualified name <file>:<library>
See BytecodeObject::link_fully_qualified
sourcepub fn link_all<I, S, T>(&mut self, libs: I) -> &mut Selfwhere
I: IntoIterator<Item = (S, T, Address)>,
S: AsRef<str>,
T: AsRef<str>,
pub fn link_all<I, S, T>(&mut self, libs: I) -> &mut Selfwhere
I: IntoIterator<Item = (S, T, Address)>,
S: AsRef<str>,
T: AsRef<str>,
Links the bytecode object with all provided (file, lib, addr)
sourcepub fn contains_fully_qualified_placeholder(&self, name: impl AsRef<str>) -> bool
pub fn contains_fully_qualified_placeholder(&self, name: impl AsRef<str>) -> bool
Whether the bytecode contains a matching placeholder using the qualified name
Trait Implementations§
source§impl AsRef<[u8]> for BytecodeObject
impl AsRef<[u8]> for BytecodeObject
source§impl Clone for BytecodeObject
impl Clone for BytecodeObject
source§fn clone(&self) -> BytecodeObject
fn clone(&self) -> BytecodeObject
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BytecodeObject
impl Debug for BytecodeObject
source§impl Default for BytecodeObject
impl Default for BytecodeObject
source§impl<'de> Deserialize<'de> for BytecodeObject
impl<'de> Deserialize<'de> for BytecodeObject
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<BytecodeObject> for Bytecode
impl From<BytecodeObject> for Bytecode
source§fn from(object: BytecodeObject) -> Bytecode
fn from(object: BytecodeObject) -> Bytecode
source§impl PartialEq<BytecodeObject> for BytecodeObject
impl PartialEq<BytecodeObject> for BytecodeObject
source§fn eq(&self, other: &BytecodeObject) -> bool
fn eq(&self, other: &BytecodeObject) -> bool
source§impl Serialize for BytecodeObject
impl Serialize for BytecodeObject
impl Eq for BytecodeObject
impl StructuralEq for BytecodeObject
impl StructuralPartialEq for BytecodeObject
Auto Trait Implementations§
impl RefUnwindSafe for BytecodeObject
impl Send for BytecodeObject
impl Sync for BytecodeObject
impl Unpin for BytecodeObject
impl UnwindSafe for BytecodeObject
Blanket Implementations§
§impl<T, U> AsByteSlice<T> for Uwhere
T: ToByteSlice,
U: AsRef<[T]> + ?Sized,
impl<T, U> AsByteSlice<T> for Uwhere
T: ToByteSlice,
U: AsRef<[T]> + ?Sized,
fn as_byte_slice(&self) -> &[u8] ⓘ
§impl<U> AsSliceOf for Uwhere
U: AsRef<[u8]> + ?Sized,
impl<U> AsSliceOf for Uwhere
U: AsRef<[u8]> + ?Sized,
fn as_slice_of<T>(&self) -> Result<&[T], Error>where
T: FromByteSlice,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
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>
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ToHex for Twhere
T: AsRef<[u8]>,
impl<T> ToHex for Twhere
T: AsRef<[u8]>,
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
) Read moresource§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
) Read more