diff --git a/v0.21.0/core/all.html b/v0.21.0/core/all.html new file mode 100644 index 00000000..8ca4bf48 --- /dev/null +++ b/v0.21.0/core/all.html @@ -0,0 +1,15 @@ +List of all items in this project

List of all items

Structs

Describes a location in storage.

+

Traits

Trait for the addition of two values.

+

Trait to bitwise AND two values of the same type.

+

Trait to bitwise OR two values of the same type.

+

Trait to bitwise XOR two values of the same type.

+

Trait for the division of two values.

+

Trait to evaluate if two types are equal.

+

Trait for the modulo of two values.

+

Trait for the multiplication of two values.

+

Trait to invert a type.

+

Trait to evaluate if one value is greater or less than another of the same type.

+

Trait to bit shift a value.

+

Trait for the subtraction of two values.

+

Trait to return a type as a raw_slice.

+

Functions

\ No newline at end of file diff --git a/v0.21.0/core/codec/fn.abi_decode.html b/v0.21.0/core/codec/fn.abi_decode.html new file mode 100644 index 00000000..fa667601 --- /dev/null +++ b/v0.21.0/core/codec/fn.abi_decode.html @@ -0,0 +1,4 @@ +abi_decode in codec - Sway

Function core::codec::abi_decode

pub fn abi_decode<T>(data: raw_slice) -> T
+where
+    T: AbiDecode,
+
\ No newline at end of file diff --git a/v0.21.0/core/codec/fn.contract_call.html b/v0.21.0/core/codec/fn.contract_call.html new file mode 100644 index 00000000..7cdf155c --- /dev/null +++ b/v0.21.0/core/codec/fn.contract_call.html @@ -0,0 +1,12 @@ +contract_call in codec - Sway
pub fn contract_call<T, TArgs>(
+    contract_id: b256,
+    method_name: str,
+    args: TArgs,
+    coins: u64,
+    asset_id: b256,
+    gas: u64,
+) -> T
+where
+    T: AbiDecode,
+    TArgs: AbiEncode,
+
\ No newline at end of file diff --git a/v0.21.0/core/codec/fn.decode_first_param.html b/v0.21.0/core/codec/fn.decode_first_param.html new file mode 100644 index 00000000..563df182 --- /dev/null +++ b/v0.21.0/core/codec/fn.decode_first_param.html @@ -0,0 +1,4 @@ +decode_first_param in codec - Sway
pub fn decode_first_param<T>() -> T
+where
+    T: AbiDecode,
+
\ No newline at end of file diff --git a/v0.21.0/core/codec/fn.decode_predicate_data.html b/v0.21.0/core/codec/fn.decode_predicate_data.html new file mode 100644 index 00000000..b5d0aa9c --- /dev/null +++ b/v0.21.0/core/codec/fn.decode_predicate_data.html @@ -0,0 +1,4 @@ +decode_predicate_data in codec - Sway
pub fn decode_predicate_data<T>() -> T
+where
+    T: AbiDecode,
+
\ No newline at end of file diff --git a/v0.21.0/core/codec/fn.decode_script_data.html b/v0.21.0/core/codec/fn.decode_script_data.html new file mode 100644 index 00000000..d369fabd --- /dev/null +++ b/v0.21.0/core/codec/fn.decode_script_data.html @@ -0,0 +1,4 @@ +decode_script_data in codec - Sway
pub fn decode_script_data<T>() -> T
+where
+    T: AbiDecode,
+
\ No newline at end of file diff --git a/v0.21.0/core/codec/fn.decode_second_param.html b/v0.21.0/core/codec/fn.decode_second_param.html new file mode 100644 index 00000000..5b7f691d --- /dev/null +++ b/v0.21.0/core/codec/fn.decode_second_param.html @@ -0,0 +1,4 @@ +decode_second_param in codec - Sway
pub fn decode_second_param<T>() -> T
+where
+    T: AbiDecode,
+
\ No newline at end of file diff --git a/v0.21.0/core/codec/fn.encode.html b/v0.21.0/core/codec/fn.encode.html new file mode 100644 index 00000000..0eb24d1a --- /dev/null +++ b/v0.21.0/core/codec/fn.encode.html @@ -0,0 +1,4 @@ +encode in codec - Sway

Function core::codec::encode

pub fn encode<T>(item: T) -> raw_slice
+where
+    T: AbiEncode,
+
\ No newline at end of file diff --git a/v0.21.0/core/codec/index.html b/v0.21.0/core/codec/index.html new file mode 100644 index 00000000..c2368a3f --- /dev/null +++ b/v0.21.0/core/codec/index.html @@ -0,0 +1 @@ +codec in core - Sway

Module core::codec

Structs

Traits

Functions

\ No newline at end of file diff --git a/v0.21.0/core/codec/struct.Buffer.html b/v0.21.0/core/codec/struct.Buffer.html new file mode 100644 index 00000000..10143a5d --- /dev/null +++ b/v0.21.0/core/codec/struct.Buffer.html @@ -0,0 +1,5 @@ +Buffer in codec - Sway

Struct core::codec::Buffer

pub struct Buffer {
+    buffer: raw_ptr,
+    cap: u64,
+    size: u64,
+}

Fields

buffer: raw_ptrcap: u64size: u64

Trait Implementations

fn as_raw_slice(self) -> raw_slice

\ No newline at end of file diff --git a/v0.21.0/core/codec/struct.BufferReader.html b/v0.21.0/core/codec/struct.BufferReader.html new file mode 100644 index 00000000..7f7f24ae --- /dev/null +++ b/v0.21.0/core/codec/struct.BufferReader.html @@ -0,0 +1,4 @@ +BufferReader in codec - Sway
pub struct BufferReader {
+    ptr: raw_ptr,
+    pos: u64,
+}

Fields

ptr: raw_ptrpos: u64
\ No newline at end of file diff --git a/v0.21.0/core/codec/trait.AbiDecode.html b/v0.21.0/core/codec/trait.AbiDecode.html new file mode 100644 index 00000000..1f6838a9 --- /dev/null +++ b/v0.21.0/core/codec/trait.AbiDecode.html @@ -0,0 +1,3 @@ +AbiDecode in codec - Sway
pub trait AbiDecode {
+    fn abi_decode(ref mut buffer: BufferReader) -> Self;
+}

Required Methods

\ No newline at end of file diff --git a/v0.21.0/core/codec/trait.AbiEncode.html b/v0.21.0/core/codec/trait.AbiEncode.html new file mode 100644 index 00000000..de9b1e11 --- /dev/null +++ b/v0.21.0/core/codec/trait.AbiEncode.html @@ -0,0 +1,3 @@ +AbiEncode in codec - Sway
pub trait AbiEncode {
+    fn abi_encode(self, ref mut buffer: Buffer);
+}

Required Methods

\ No newline at end of file diff --git a/v0.21.0/core/index.html b/v0.21.0/core/index.html new file mode 100644 index 00000000..5b1daa35 --- /dev/null +++ b/v0.21.0/core/index.html @@ -0,0 +1 @@ +core in core - Sway

Library core

Modules

\ No newline at end of file diff --git a/v0.21.0/core/ops/fn.ok_str_eq.html b/v0.21.0/core/ops/fn.ok_str_eq.html new file mode 100644 index 00000000..a78bcf82 --- /dev/null +++ b/v0.21.0/core/ops/fn.ok_str_eq.html @@ -0,0 +1 @@ +ok_str_eq in ops - Sway

Function core::ops::ok_str_eq

pub fn ok_str_eq() 
Expand description
\ No newline at end of file diff --git a/v0.21.0/core/ops/index.html b/v0.21.0/core/ops/index.html new file mode 100644 index 00000000..0314a965 --- /dev/null +++ b/v0.21.0/core/ops/index.html @@ -0,0 +1,13 @@ +ops in core - Sway

Module core::ops

Traits

Trait for the addition of two values.

+

Trait to bitwise AND two values of the same type.

+

Trait to bitwise OR two values of the same type.

+

Trait to bitwise XOR two values of the same type.

+

Trait for the division of two values.

+

Trait to evaluate if two types are equal.

+

Trait for the modulo of two values.

+

Trait for the multiplication of two values.

+

Trait to invert a type.

+

Trait to evaluate if one value is greater or less than another of the same type.

+

Trait to bit shift a value.

+

Trait for the subtraction of two values.

+

Functions

\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Add.html b/v0.21.0/core/ops/trait.Add.html new file mode 100644 index 00000000..799a5c97 --- /dev/null +++ b/v0.21.0/core/ops/trait.Add.html @@ -0,0 +1,67 @@ +Add in ops - Sway

Trait core::ops::Add

pub trait Add {
+    /// Add two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value to add to self.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the two values added.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Add for MyStruct {
+    ///     fn add(self, other: Self) -> Self {
+    ///         let val = self.val + other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 1 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result_struct = struct1 + struct2;
+    ///     assert(result_struct.val == 3);
+    /// }
+    /// ```
+    fn add(self, other: Self) -> Self;
+}
Expand description

Trait for the addition of two values.

+

Required Methods

Add two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value to add to self.
  • +
+

Returns

+
    +
  • [Self] - The result of the two values added.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Add for MyStruct {
+    fn add(self, other: Self) -> Self {
+        let val = self.val + other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 1 };
+    let struct2 = MyStruct { val: 2 };
+    let result_struct = struct1 + struct2;
+    assert(result_struct.val == 3);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.BitwiseAnd.html b/v0.21.0/core/ops/trait.BitwiseAnd.html new file mode 100644 index 00000000..1399f6a7 --- /dev/null +++ b/v0.21.0/core/ops/trait.BitwiseAnd.html @@ -0,0 +1,67 @@ +BitwiseAnd in ops - Sway
pub trait BitwiseAnd {
+    /// Bitwise AND two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value of the same type.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the bitwise AND of the two values.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl BitwiseAnd for MyStruct {
+    ///     fn binary_and(self, other: Self) -> Self {
+    ///         let val = self.val & other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 11 };
+    ///     let result_struct = struct1 & struct2;
+    ///     assert(result_struct.val == 10);
+    /// }
+    /// ```
+    fn binary_and(self, other: Self) -> Self;
+}
Expand description

Trait to bitwise AND two values of the same type.

+

Required Methods

Bitwise AND two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [Self] - The result of the bitwise AND of the two values.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl BitwiseAnd for MyStruct {
+    fn binary_and(self, other: Self) -> Self {
+        let val = self.val & other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 11 };
+    let result_struct = struct1 & struct2;
+    assert(result_struct.val == 10);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.BitwiseOr.html b/v0.21.0/core/ops/trait.BitwiseOr.html new file mode 100644 index 00000000..2f5d5f68 --- /dev/null +++ b/v0.21.0/core/ops/trait.BitwiseOr.html @@ -0,0 +1,67 @@ +BitwiseOr in ops - Sway
pub trait BitwiseOr {
+    /// Bitwise OR two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value of the same type.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the bitwise OR of the two values.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl BitwiseOr for MyStruct {
+    ///     fn binary_or(self, other: Self) -> Self {
+    ///         let val = self.val | other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 11 };
+    ///     let result_struct = struct1 | struct2;
+    ///     assert(result_struct.val == 11);
+    /// }
+    /// ```
+    fn binary_or(self, other: Self) -> Self;
+}
Expand description

Trait to bitwise OR two values of the same type.

+

Required Methods

Bitwise OR two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [Self] - The result of the bitwise OR of the two values.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl BitwiseOr for MyStruct {
+    fn binary_or(self, other: Self) -> Self {
+        let val = self.val | other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 11 };
+    let result_struct = struct1 | struct2;
+    assert(result_struct.val == 11);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.BitwiseXor.html b/v0.21.0/core/ops/trait.BitwiseXor.html new file mode 100644 index 00000000..8da04fb1 --- /dev/null +++ b/v0.21.0/core/ops/trait.BitwiseXor.html @@ -0,0 +1,67 @@ +BitwiseXor in ops - Sway
pub trait BitwiseXor {
+    /// Bitwise XOR two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value of the same type.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the bitwise XOR of the two values.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl BitwiseXOr for MyStruct {
+    ///     fn binary_xor(self, other: Self) -> Self {
+    ///         let val = self.val ^ other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 11 };
+    ///     let result_struct = struct1 ^ struct2;
+    ///     assert(result_struct.val == 1);
+    /// }
+    /// ```
+    fn binary_xor(self, other: Self) -> Self;
+}
Expand description

Trait to bitwise XOR two values of the same type.

+

Required Methods

Bitwise XOR two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [Self] - The result of the bitwise XOR of the two values.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl BitwiseXOr for MyStruct {
+    fn binary_xor(self, other: Self) -> Self {
+        let val = self.val ^ other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 11 };
+    let result_struct = struct1 ^ struct2;
+    assert(result_struct.val == 1);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Divide.html b/v0.21.0/core/ops/trait.Divide.html new file mode 100644 index 00000000..621aebee --- /dev/null +++ b/v0.21.0/core/ops/trait.Divide.html @@ -0,0 +1,67 @@ +Divide in ops - Sway

Trait core::ops::Divide

pub trait Divide {
+    /// Divide two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value to divide with self.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the two values divided.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Divide for MyStruct {
+    ///     fn divide(self, other: Self) -> Self {
+    ///         let val = self.val / other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result_struct = struct1 / struct2;
+    ///     assert(result_struct.val == 5);
+    /// }
+    /// ```
+    fn divide(self, other: Self) -> Self;
+}
Expand description

Trait for the division of two values.

+

Required Methods

Divide two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value to divide with self.
  • +
+

Returns

+
    +
  • [Self] - The result of the two values divided.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Divide for MyStruct {
+    fn divide(self, other: Self) -> Self {
+        let val = self.val / other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result_struct = struct1 / struct2;
+    assert(result_struct.val == 5);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Eq.html b/v0.21.0/core/ops/trait.Eq.html new file mode 100644 index 00000000..9ec717ba --- /dev/null +++ b/v0.21.0/core/ops/trait.Eq.html @@ -0,0 +1,99 @@ +Eq in ops - Sway

Trait core::ops::Eq

pub trait Eq {
+    /// Evaluates if two values of the same type are equal.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value of the same type.
+    ///
+    /// # Returns
+    ///
+    /// * [bool] - `true` if the values are equal, otherwise `false`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Eq for MyStruct {
+    ///     fn eq(self, other: Self) -> bool {
+    ///         self.val == other.val
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 2 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result = struct1 == struct2;
+    ///     assert(result);
+    /// }
+    /// ```
+    fn eq(self, other: Self) -> bool;
+} {
+    /// Evaluates if two values of the same type are not equal.
+    ///
+    /// # Additional Information
+    ///
+    /// This function is inherited when `eq()` is implemented.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value of the same type.
+    ///
+    /// # Returns
+    ///
+    /// * [bool] - `true` if the two values are not equal, otherwise `false`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Eq for MyStruct {
+    ///     fn eq(self, other: Self) -> bool {
+    ///          self.val == other.val
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result = struct1 != struct2;
+    ///     assert(result);
+    /// }
+    /// ```
+    fn neq(self, other: Self) -> bool {
+        (self.eq(other)).not()
+    }
+}
Expand description

Trait to evaluate if two types are equal.

+

Required Methods

Evaluates if two values of the same type are equal.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the values are equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+        self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 2 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 == struct2;
+    assert(result);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Mod.html b/v0.21.0/core/ops/trait.Mod.html new file mode 100644 index 00000000..edfbf4b1 --- /dev/null +++ b/v0.21.0/core/ops/trait.Mod.html @@ -0,0 +1,67 @@ +Mod in ops - Sway

Trait core::ops::Mod

pub trait Mod {
+    /// Modulo two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value to mod with self.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The modulo of the two values.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Mod for MyStruct {
+    ///     fn modulo(self, other: Self) -> Self {
+    ///         let val = self.val % other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result_struct = struct1 % struct2;
+    ///     assert(result_struct.val == 0);
+    /// }
+    /// ```
+    fn modulo(self, other: Self) -> Self;
+}
Expand description

Trait for the modulo of two values.

+

Required Methods

Modulo two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value to mod with self.
  • +
+

Returns

+
    +
  • [Self] - The modulo of the two values.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Mod for MyStruct {
+    fn modulo(self, other: Self) -> Self {
+        let val = self.val % other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result_struct = struct1 % struct2;
+    assert(result_struct.val == 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Multiply.html b/v0.21.0/core/ops/trait.Multiply.html new file mode 100644 index 00000000..cfa4e830 --- /dev/null +++ b/v0.21.0/core/ops/trait.Multiply.html @@ -0,0 +1,67 @@ +Multiply in ops - Sway

Trait core::ops::Multiply

pub trait Multiply {
+    /// Multiply two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value to multiply with self.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the two values multiplied.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Multiply for MyStruct {
+    ///     fn multiply(self, other: Self) -> Self {
+    ///         let val = self.val * other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 3 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result_struct = struct1 * struct2;
+    ///     assert(result_struct.val == 6);
+    /// }
+    /// ```
+    fn multiply(self, other: Self) -> Self;
+}
Expand description

Trait for the multiplication of two values.

+

Required Methods

Multiply two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value to multiply with self.
  • +
+

Returns

+
    +
  • [Self] - The result of the two values multiplied.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Multiply for MyStruct {
+    fn multiply(self, other: Self) -> Self {
+        let val = self.val * other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 3 };
+    let struct2 = MyStruct { val: 2 };
+    let result_struct = struct1 * struct2;
+    assert(result_struct.val == 6);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Not.html b/v0.21.0/core/ops/trait.Not.html new file mode 100644 index 00000000..49270d13 --- /dev/null +++ b/v0.21.0/core/ops/trait.Not.html @@ -0,0 +1,55 @@ +Not in ops - Sway

Trait core::ops::Not

pub trait Not {
+    /// Inverts the value of the type.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the inverse.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: bool,
+    /// }
+    ///
+    /// impl Not for MyStruct {
+    ///     fn not(self) -> Self {
+    ///         Self {
+    ///             val: !self.val,
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct = MyStruct { val: true };
+    ///     let result_struct = !struct;
+    ///     assert(!result_struct.val);
+    /// }
+    /// ```
+    fn not(self) -> Self;
+}
Expand description

Trait to invert a type.

+

Required Methods

Inverts the value of the type.

+

Returns

+
    +
  • [Self] - The result of the inverse.
  • +
+

Examples

+
struct MyStruct {
+    val: bool,
+}
+
+impl Not for MyStruct {
+    fn not(self) -> Self {
+        Self {
+            val: !self.val,
+        }
+    }
+}
+
+fn foo() {
+    let struct = MyStruct { val: true };
+    let result_struct = !struct;
+    assert(!result_struct.val);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Ord.html b/v0.21.0/core/ops/trait.Ord.html new file mode 100644 index 00000000..1fa4eb64 --- /dev/null +++ b/v0.21.0/core/ops/trait.Ord.html @@ -0,0 +1,119 @@ +Ord in ops - Sway

Trait core::ops::Ord

pub trait Ord {
+    /// Evaluates if one value of the same type is greater than another.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value of the same type.
+    ///
+    /// # Returns
+    ///
+    /// * [bool] - `true` if `self` is greater than `other`, otherwise `false`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Ord for MyStruct {
+    ///     fn gt(self, other: Self) -> bool {
+    ///         self.val > other.val
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result = struct1 > struct2;
+    ///     assert(result);
+    /// }
+    /// ```
+    fn gt(self, other: Self) -> bool;
+    /// Evaluates if one value of the same type is less than another.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value of the same type.
+    ///
+    /// # Returns
+    ///
+    /// * [bool] - `true` if `self` is less than `other`, otherwise `false`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Ord for MyStruct {
+    ///     fn lt(self, other: Self) -> bool {
+    ///         self.val < other.val
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let struct2 = MyStruct { val: 2 };
+    ///     let result = struct1 < struct2;
+    ///     assert(!result);
+    /// }
+    /// ```
+    fn lt(self, other: Self) -> bool;
+}
Expand description

Trait to evaluate if one value is greater or less than another of the same type.

+

Required Methods

Evaluates if one value of the same type is greater than another.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if self is greater than other, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Ord for MyStruct {
+    fn gt(self, other: Self) -> bool {
+        self.val > other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 > struct2;
+    assert(result);
+}
+
+

Evaluates if one value of the same type is less than another.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if self is less than other, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Ord for MyStruct {
+    fn lt(self, other: Self) -> bool {
+        self.val < other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 < struct2;
+    assert(!result);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Shift.html b/v0.21.0/core/ops/trait.Shift.html new file mode 100644 index 00000000..0d3c2cc7 --- /dev/null +++ b/v0.21.0/core/ops/trait.Shift.html @@ -0,0 +1,127 @@ +Shift in ops - Sway

Trait core::ops::Shift

pub trait Shift {
+    /// Bit shift left by an amount.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [u64] - The amount to bit shift by.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the value bit shifted to the left.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Shift for MyStruct {
+    ///     fn lsh(self, other: u64) -> Self {
+    ///         let val = self.val << other;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let result_struct = struct1 << 3;
+    ///     assert(result_struct.val == 80);
+    /// }
+    /// ```
+    fn lsh(self, other: u64) -> Self;
+    /// Bit shift right by an amount.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [u64] - The amount to bit shift by.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the value bit shifted to the right.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Shift for MyStruct {
+    ///     fn rsh(self, other: u64) -> Self {
+    ///         let val = self.val >> other;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 10 };
+    ///     let result_struct = struct1 >> 1;
+    ///     assert(result_struct.val == 5);
+    /// }
+    /// ```
+    fn rsh(self, other: u64) -> Self;
+}
Expand description

Trait to bit shift a value.

+

Required Methods

Bit shift left by an amount.

+

Arguments

+
    +
  • other: [u64] - The amount to bit shift by.
  • +
+

Returns

+
    +
  • [Self] - The result of the value bit shifted to the left.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Shift for MyStruct {
+    fn lsh(self, other: u64) -> Self {
+        let val = self.val << other;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let result_struct = struct1 << 3;
+    assert(result_struct.val == 80);
+}
+
+

Bit shift right by an amount.

+

Arguments

+
    +
  • other: [u64] - The amount to bit shift by.
  • +
+

Returns

+
    +
  • [Self] - The result of the value bit shifted to the right.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Shift for MyStruct {
+    fn rsh(self, other: u64) -> Self {
+        let val = self.val >> other;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let result_struct = struct1 >> 1;
+    assert(result_struct.val == 5);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/ops/trait.Subtract.html b/v0.21.0/core/ops/trait.Subtract.html new file mode 100644 index 00000000..78b64818 --- /dev/null +++ b/v0.21.0/core/ops/trait.Subtract.html @@ -0,0 +1,67 @@ +Subtract in ops - Sway

Trait core::ops::Subtract

pub trait Subtract {
+    /// Subtract two values of the same type.
+    ///
+    /// # Arguments
+    ///
+    /// * `other`: [Self] - The value to subtract from self.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The result of the two values subtracted.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// struct MyStruct {
+    ///     val: u64,
+    /// }
+    ///
+    /// impl Subtract for MyStruct {
+    ///     fn subtract(self, other: Self) -> Self {
+    ///         let val = self.val - other.val;
+    ///         Self {
+    ///             val
+    ///         }
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let struct1 = MyStruct { val: 3 };
+    ///     let struct2 = MyStruct { val: 1 };
+    ///     let result_struct = struct1 - struct2;
+    ///     assert(result_struct.val == 2);
+    /// }
+    /// ```
+    fn subtract(self, other: Self) -> Self;
+}
Expand description

Trait for the subtraction of two values.

+

Required Methods

Subtract two values of the same type.

+

Arguments

+
    +
  • other: [Self] - The value to subtract from self.
  • +
+

Returns

+
    +
  • [Self] - The result of the two values subtracted.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Subtract for MyStruct {
+    fn subtract(self, other: Self) -> Self {
+        let val = self.val - other.val;
+        Self {
+            val
+        }
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 3 };
+    let struct2 = MyStruct { val: 1 };
+    let result_struct = struct1 - struct2;
+    assert(result_struct.val == 2);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/raw_slice/index.html b/v0.21.0/core/raw_slice/index.html new file mode 100644 index 00000000..51beb148 --- /dev/null +++ b/v0.21.0/core/raw_slice/index.html @@ -0,0 +1,2 @@ +raw_slice in core - Sway

Module core::raw_slice

Traits

Trait to return a type as a raw_slice.

+
\ No newline at end of file diff --git a/v0.21.0/core/raw_slice/trait.AsRawSlice.html b/v0.21.0/core/raw_slice/trait.AsRawSlice.html new file mode 100644 index 00000000..7e289ef1 --- /dev/null +++ b/v0.21.0/core/raw_slice/trait.AsRawSlice.html @@ -0,0 +1,65 @@ +AsRawSlice in raw_slice - Sway
pub trait AsRawSlice {
+    /// Converts self into a `raw_slice`.
+    ///
+    /// # Returns
+    ///
+    /// * [raw_slice] - The newly created `raw_slice` from self.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use std::alloc::alloc_bytes;
+    ///
+    /// struct MyType {
+    ///    ptr: raw_ptr,
+    ///    len: u64
+    /// }
+    ///
+    /// impl AsRawSlice for MyType {
+    ///     fn as_raw_slice(self) -> raw_slice {
+    ///         from_parts(self.ptr, self.len)
+    ///     }
+    /// }
+    ///
+    /// fn foo() {
+    ///     let my_type = MyType {
+    ///         ptr: alloc_bytes(0),
+    ///         len: 0
+    ///     }
+    ///     let slice = my_type.as_raw_slice();
+    ///     assert(slice.ptr() == my_type.ptr);
+    ///     assert(slice.number_of_bytes() == my_type.len);
+    /// }
+    /// ```
+    fn as_raw_slice(self) -> raw_slice;
+}
Expand description

Trait to return a type as a raw_slice.

+

Required Methods

Converts self into a raw_slice.

+

Returns

+
    +
  • [raw_slice] - The newly created raw_slice from self.
  • +
+

Examples

+
use std::alloc::alloc_bytes;
+
+struct MyType {
+   ptr: raw_ptr,
+   len: u64
+}
+
+impl AsRawSlice for MyType {
+    fn as_raw_slice(self) -> raw_slice {
+        from_parts(self.ptr, self.len)
+    }
+}
+
+fn foo() {
+    let my_type = MyType {
+        ptr: alloc_bytes(0),
+        len: 0
+    }
+    let slice = my_type.as_raw_slice();
+    assert(slice.ptr() == my_type.ptr);
+    assert(slice.number_of_bytes() == my_type.len);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/core/storage/index.html b/v0.21.0/core/storage/index.html new file mode 100644 index 00000000..4e6cf857 --- /dev/null +++ b/v0.21.0/core/storage/index.html @@ -0,0 +1,2 @@ +storage in core - Sway

Module core::storage

Structs

Describes a location in storage.

+
\ No newline at end of file diff --git a/v0.21.0/core/storage/struct.StorageKey.html b/v0.21.0/core/storage/struct.StorageKey.html new file mode 100644 index 00000000..93cf5428 --- /dev/null +++ b/v0.21.0/core/storage/struct.StorageKey.html @@ -0,0 +1,19 @@ +StorageKey in storage - Sway
pub struct StorageKey<T> {
+    /// The assigned location in storage.
+    slot: b256,
+    /// The assigned offset based on the data structure `T`.
+    offset: u64,
+    /// A unique identifier.
+    field_id: b256,
+}
Expand description

Describes a location in storage.

+

Additional Information

+

The location in storage is specified by the b256 key of a particular storage slot and an
+offset, in words, from the start of the storage slot at key. The parameter T is the type of
+the data to be read from or written to at offset.
+field_id is a unique identifier for the storage field being referred to, it is different even
+for multiple zero sized fields that might live at the same location but
+represent different storage constructs.

+

Fields

slot: b256

The assigned location in storage.

+
offset: u64

The assigned offset based on the data structure T.

+
field_id: b256

A unique identifier.

+
\ No newline at end of file diff --git a/v0.21.0/core/str/fn.from_str_array.html b/v0.21.0/core/str/fn.from_str_array.html new file mode 100644 index 00000000..5697cf26 --- /dev/null +++ b/v0.21.0/core/str/fn.from_str_array.html @@ -0,0 +1 @@ +from_str_array in str - Sway
pub fn from_str_array<S>(s: S) -> str 
\ No newline at end of file diff --git a/v0.21.0/core/str/index.html b/v0.21.0/core/str/index.html new file mode 100644 index 00000000..40a2cf63 --- /dev/null +++ b/v0.21.0/core/str/index.html @@ -0,0 +1 @@ +str in core - Sway

Module core::str

Functions

\ No newline at end of file diff --git a/v0.21.0/search.js b/v0.21.0/search.js new file mode 100644 index 00000000..5cb6505a --- /dev/null +++ b/v0.21.0/search.js @@ -0,0 +1,2 @@ +var SEARCH_INDEX={"core":[{"html_filename":"trait.AsRawSlice.html","module_info":["core","raw_slice"],"name":"AsRawSlice","preview":"Trait to return a type as a raw_slice.\n","type_name":"trait"},{"html_filename":"fn.from_str_array.html","module_info":["core","str"],"name":"from_str_array","preview":"","type_name":"function"},{"html_filename":"trait.Add.html","module_info":["core","ops"],"name":"Add","preview":"Trait for the addition of two values.\n","type_name":"trait"},{"html_filename":"trait.Subtract.html","module_info":["core","ops"],"name":"Subtract","preview":"Trait for the subtraction of two values.\n","type_name":"trait"},{"html_filename":"trait.Multiply.html","module_info":["core","ops"],"name":"Multiply","preview":"Trait for the multiplication of two values.\n","type_name":"trait"},{"html_filename":"trait.Divide.html","module_info":["core","ops"],"name":"Divide","preview":"Trait for the division of two values.\n","type_name":"trait"},{"html_filename":"trait.Mod.html","module_info":["core","ops"],"name":"Mod","preview":"Trait for the modulo of two values.\n","type_name":"trait"},{"html_filename":"trait.Not.html","module_info":["core","ops"],"name":"Not","preview":"Trait to invert a type.\n","type_name":"trait"},{"html_filename":"trait.Eq.html","module_info":["core","ops"],"name":"Eq","preview":"Trait to evaluate if two types are equal.\n","type_name":"trait"},{"html_filename":"trait.Ord.html","module_info":["core","ops"],"name":"Ord","preview":"Trait to evaluate if one value is greater or less than another of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseAnd.html","module_info":["core","ops"],"name":"BitwiseAnd","preview":"Trait to bitwise AND two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseOr.html","module_info":["core","ops"],"name":"BitwiseOr","preview":"Trait to bitwise OR two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.BitwiseXor.html","module_info":["core","ops"],"name":"BitwiseXor","preview":"Trait to bitwise XOR two values of the same type.\n","type_name":"trait"},{"html_filename":"trait.Shift.html","module_info":["core","ops"],"name":"Shift","preview":"Trait to bit shift a value.\n","type_name":"trait"},{"html_filename":"fn.ok_str_eq.html","module_info":["core","ops"],"name":"ok_str_eq","preview":"","type_name":"function"},{"html_filename":"struct.StorageKey.html","module_info":["core","storage"],"name":"StorageKey","preview":"Describes a location in storage.\n","type_name":"struct"},{"html_filename":"struct.Buffer.html","module_info":["core","codec"],"name":"Buffer","preview":"","type_name":"struct"},{"html_filename":"struct.BufferReader.html","module_info":["core","codec"],"name":"BufferReader","preview":"","type_name":"struct"},{"html_filename":"trait.AbiDecode.html","module_info":["core","codec"],"name":"AbiDecode","preview":"","type_name":"trait"},{"html_filename":"trait.AbiEncode.html","module_info":["core","codec"],"name":"AbiEncode","preview":"","type_name":"trait"},{"html_filename":"fn.encode.html","module_info":["core","codec"],"name":"encode","preview":"","type_name":"function"},{"html_filename":"fn.abi_decode.html","module_info":["core","codec"],"name":"abi_decode","preview":"","type_name":"function"},{"html_filename":"fn.contract_call.html","module_info":["core","codec"],"name":"contract_call","preview":"","type_name":"function"},{"html_filename":"fn.decode_script_data.html","module_info":["core","codec"],"name":"decode_script_data","preview":"","type_name":"function"},{"html_filename":"fn.decode_predicate_data.html","module_info":["core","codec"],"name":"decode_predicate_data","preview":"","type_name":"function"},{"html_filename":"fn.decode_first_param.html","module_info":["core","codec"],"name":"decode_first_param","preview":"","type_name":"function"},{"html_filename":"fn.decode_second_param.html","module_info":["core","codec"],"name":"decode_second_param","preview":"","type_name":"function"}],"standards":[{"html_filename":"abi.SRC3.html","module_info":["standards","src3"],"name":"SRC3","preview":"","type_name":"abi"},{"html_filename":"enum.State.html","module_info":["standards","src5"],"name":"State","preview":"Determines the state of ownership.\n","type_name":"enum"},{"html_filename":"enum.AccessError.html","module_info":["standards","src5"],"name":"AccessError","preview":"Error log for when access is denied.\n","type_name":"enum"},{"html_filename":"abi.SRC5.html","module_info":["standards","src5"],"name":"SRC5","preview":"","type_name":"abi"},{"html_filename":"struct.Deposit.html","module_info":["standards","src6"],"name":"Deposit","preview":"Event logged when a deposit is made.\n","type_name":"struct"},{"html_filename":"struct.Withdraw.html","module_info":["standards","src6"],"name":"Withdraw","preview":"Event logged when a withdrawal is made.\n","type_name":"struct"},{"html_filename":"abi.SRC6.html","module_info":["standards","src6"],"name":"SRC6","preview":"","type_name":"abi"},{"html_filename":"enum.Metadata.html","module_info":["standards","src7"],"name":"Metadata","preview":"Universal return type for metadata.\n","type_name":"enum"},{"html_filename":"abi.SRC7.html","module_info":["standards","src7"],"name":"SRC7","preview":"","type_name":"abi"},{"html_filename":"abi.SRC10.html","module_info":["standards","src10"],"name":"SRC10","preview":"","type_name":"abi"},{"html_filename":"struct.SecurityInformation.html","module_info":["standards","src11"],"name":"SecurityInformation","preview":"Contact Information to report bugs to.\n","type_name":"struct"},{"html_filename":"abi.SRC11.html","module_info":["standards","src11"],"name":"SRC11","preview":"","type_name":"abi"},{"html_filename":"abi.SRC12.html","module_info":["standards","src12"],"name":"SRC12","preview":"","type_name":"abi"},{"html_filename":"abi.SRC12_Extension.html","module_info":["standards","src12"],"name":"SRC12_Extension","preview":"","type_name":"abi"},{"html_filename":"abi.SRC20.html","module_info":["standards","src20"],"name":"SRC20","preview":"","type_name":"abi"}],"std":[{"html_filename":"constant.FAILED_REQUIRE_SIGNAL.html","module_info":["std","error_signals"],"name":"FAILED_REQUIRE_SIGNAL","preview":"A revert with this value signals that it was caused by a failing call to std::revert::require.","type_name":"constant"},{"html_filename":"constant.FAILED_TRANSFER_TO_ADDRESS_SIGNAL.html","module_info":["std","error_signals"],"name":"FAILED_TRANSFER_TO_ADDRESS_SIGNAL","preview":"A revert with this value signals that it was caused by a failing call to std::asset::transfer_to_address.","type_name":"constant"},{"html_filename":"constant.FAILED_ASSERT_EQ_SIGNAL.html","module_info":["std","error_signals"],"name":"FAILED_ASSERT_EQ_SIGNAL","preview":"A revert with this value signals that it was caused by a failing call to std::assert::assert_eq.","type_name":"constant"},{"html_filename":"constant.FAILED_ASSERT_SIGNAL.html","module_info":["std","error_signals"],"name":"FAILED_ASSERT_SIGNAL","preview":"A revert with this value signals that it was caused by a failing call to std::assert::assert.","type_name":"constant"},{"html_filename":"constant.FAILED_ASSERT_NE_SIGNAL.html","module_info":["std","error_signals"],"name":"FAILED_ASSERT_NE_SIGNAL","preview":"A revert with this value signals that it was caused by a failing call to std::assert::assert_ne.","type_name":"constant"},{"html_filename":"fn.log.html","module_info":["std","logging"],"name":"log","preview":"Log any stack type.\n","type_name":"function"},{"html_filename":"fn.revert.html","module_info":["std","revert"],"name":"revert","preview":"Will either panic or revert with a given number depending on the context.\n","type_name":"function"},{"html_filename":"fn.require.html","module_info":["std","revert"],"name":"require","preview":"Checks if the given condition is true and if not, logs value and reverts.","type_name":"function"},{"html_filename":"enum.Result.html","module_info":["std","result"],"name":"Result","preview":"Result is a type that represents either success (Ok) or failure (Err).","type_name":"enum"},{"html_filename":"enum.Option.html","module_info":["std","option"],"name":"Option","preview":"A type that represents an optional value, either Some(val) or None.","type_name":"enum"},{"html_filename":"fn.assert.html","module_info":["std","assert"],"name":"assert","preview":"Asserts that the given condition will always be true during runtime.","type_name":"function"},{"html_filename":"fn.assert_eq.html","module_info":["std","assert"],"name":"assert_eq","preview":"Asserts that the given values v1 & v2 will always be equal during runtime.","type_name":"function"},{"html_filename":"fn.assert_ne.html","module_info":["std","assert"],"name":"assert_ne","preview":"Asserts that the given values v1 & v2 will never be equal during runtime.","type_name":"function"},{"html_filename":"trait.From.html","module_info":["std","convert"],"name":"From","preview":"Used to do value-to-value conversions.\n","type_name":"trait"},{"html_filename":"trait.Into.html","module_info":["std","convert"],"name":"Into","preview":"Used to do value-to-value conversions.\n","type_name":"trait"},{"html_filename":"trait.TryFrom.html","module_info":["std","convert"],"name":"TryFrom","preview":"Used to attempt to do value-to-value conversions.
","type_name":"trait"},{"html_filename":"trait.TryInto.html","module_info":["std","convert"],"name":"TryInto","preview":"","type_name":"trait"},{"html_filename":"fn.is_reference_type.html","module_info":["std","intrinsics"],"name":"is_reference_type","preview":"Returns whether a generic type T is a reference type or not.\n","type_name":"function"},{"html_filename":"fn.size_of.html","module_info":["std","intrinsics"],"name":"size_of","preview":"Returns the size of a generic type T in bytes.\n","type_name":"function"},{"html_filename":"fn.size_of_val.html","module_info":["std","intrinsics"],"name":"size_of_val","preview":"Returns the size of the type of a value in bytes.\n","type_name":"function"},{"html_filename":"fn.alloc.html","module_info":["std","alloc"],"name":"alloc","preview":"Allocates zeroed memory on the heap.\n","type_name":"function"},{"html_filename":"fn.realloc.html","module_info":["std","alloc"],"name":"realloc","preview":"Reallocates the given area of memory.\n","type_name":"function"},{"html_filename":"fn.alloc_bytes.html","module_info":["std","alloc"],"name":"alloc_bytes","preview":"Allocates zeroed memory on the heap in individual bytes.\n","type_name":"function"},{"html_filename":"fn.realloc_bytes.html","module_info":["std","alloc"],"name":"realloc_bytes","preview":"Reallocates the given area of memory in individual bytes.\n","type_name":"function"},{"html_filename":"fn.overflow.html","module_info":["std","registers"],"name":"overflow","preview":"Contains overflow & underflow of addition, subtraction, and multiplication.\n","type_name":"function"},{"html_filename":"fn.program_counter.html","module_info":["std","registers"],"name":"program_counter","preview":"The program counter. Memory address of the current instruction.\n","type_name":"function"},{"html_filename":"fn.stack_start_ptr.html","module_info":["std","registers"],"name":"stack_start_ptr","preview":"Memory address of bottom of current writable stack area.\n","type_name":"function"},{"html_filename":"fn.stack_ptr.html","module_info":["std","registers"],"name":"stack_ptr","preview":"Memory address on top of current writable stack area (points to free memory).\n","type_name":"function"},{"html_filename":"fn.frame_ptr.html","module_info":["std","registers"],"name":"frame_ptr","preview":"Memory address of beginning of current call frame.\n","type_name":"function"},{"html_filename":"fn.heap_ptr.html","module_info":["std","registers"],"name":"heap_ptr","preview":"Memory address below the current bottom of the heap (points to free memory).\n","type_name":"function"},{"html_filename":"fn.error.html","module_info":["std","registers"],"name":"error","preview":"Error codes for particular operations.\n","type_name":"function"},{"html_filename":"fn.global_gas.html","module_info":["std","registers"],"name":"global_gas","preview":"Remaining gas globally.\n","type_name":"function"},{"html_filename":"fn.context_gas.html","module_info":["std","registers"],"name":"context_gas","preview":"Remaining gas in the context.\n","type_name":"function"},{"html_filename":"fn.balance.html","module_info":["std","registers"],"name":"balance","preview":"Get the amount of units of call_frames::msg_asset_id() being sent.\n","type_name":"function"},{"html_filename":"fn.instrs_start.html","module_info":["std","registers"],"name":"instrs_start","preview":"Pointer to the start of the currently-executing code.\n","type_name":"function"},{"html_filename":"fn.return_value.html","module_info":["std","registers"],"name":"return_value","preview":"Return value or pointer.\n","type_name":"function"},{"html_filename":"fn.return_length.html","module_info":["std","registers"],"name":"return_length","preview":"Return value length in bytes.\n","type_name":"function"},{"html_filename":"fn.flags.html","module_info":["std","registers"],"name":"flags","preview":"Flags register.\n","type_name":"function"},{"html_filename":"trait.Iterator.html","module_info":["std","iterator"],"name":"Iterator","preview":"","type_name":"trait"},{"html_filename":"struct.Vec.html","module_info":["std","vec"],"name":"Vec","preview":"A contiguous growable array type, written as Vec<T>, short for ‘vector’.\n","type_name":"struct"},{"html_filename":"struct.VecIter.html","module_info":["std","vec"],"name":"VecIter","preview":"","type_name":"struct"},{"html_filename":"struct.Bytes.html","module_info":["std","bytes"],"name":"Bytes","preview":"A type used to represent raw bytes.\n","type_name":"struct"},{"html_filename":"fn.test_encode_decode.html","module_info":["std","bytes"],"name":"test_encode_decode","preview":"","type_name":"function"},{"html_filename":"trait.Root.html","module_info":["std","math"],"name":"Root","preview":"Calculates the square root.\n","type_name":"trait"},{"html_filename":"trait.Power.html","module_info":["std","math"],"name":"Power","preview":"Calculates a number to a given power.\n","type_name":"trait"},{"html_filename":"trait.Exponent.html","module_info":["std","math"],"name":"Exponent","preview":"Trait for exponential functions.
","type_name":"trait"},{"html_filename":"trait.Logarithm.html","module_info":["std","math"],"name":"Logarithm","preview":"Calculates the log with a given base.\n","type_name":"trait"},{"html_filename":"trait.BinaryLogarithm.html","module_info":["std","math"],"name":"BinaryLogarithm","preview":"Calculates the binary log.\n","type_name":"trait"},{"html_filename":"fn.set_flags.html","module_info":["std","flags"],"name":"set_flags","preview":"Sets the flag register to the given value.\n","type_name":"function"},{"html_filename":"fn.disable_panic_on_overflow.html","module_info":["std","flags"],"name":"disable_panic_on_overflow","preview":"Allows overflowing operations to occur without a FuelVM panic.\n","type_name":"function"},{"html_filename":"fn.enable_panic_on_overflow.html","module_info":["std","flags"],"name":"enable_panic_on_overflow","preview":"Enables the default panic-on-overflow behavior in the FuelVM.\n","type_name":"function"},{"html_filename":"fn.disable_panic_on_unsafe_math.html","module_info":["std","flags"],"name":"disable_panic_on_unsafe_math","preview":"Allows unsafe math operations to occur without a FuelVM panic.
","type_name":"function"},{"html_filename":"fn.enable_panic_on_unsafe_math.html","module_info":["std","flags"],"name":"enable_panic_on_unsafe_math","preview":"Enables the default panic-on-unsafe-math behavior in the FuelVM.\n","type_name":"function"},{"html_filename":"struct.U128.html","module_info":["std","u128"],"name":"U128","preview":"The 128-bit unsigned integer type.\n","type_name":"struct"},{"html_filename":"enum.U128Error.html","module_info":["std","u128"],"name":"U128Error","preview":"The error type used for U128 type errors.\n","type_name":"enum"},{"html_filename":"struct.Hasher.html","module_info":["std","hash"],"name":"Hasher","preview":"","type_name":"struct"},{"html_filename":"trait.Hash.html","module_info":["std","hash"],"name":"Hash","preview":"","type_name":"trait"},{"html_filename":"fn.sha256.html","module_info":["std","hash"],"name":"sha256","preview":"Returns the SHA-2-256 hash of param.\n","type_name":"function"},{"html_filename":"fn.sha256_str_array.html","module_info":["std","hash"],"name":"sha256_str_array","preview":"Returns the SHA-2-256 hash of param.
","type_name":"function"},{"html_filename":"fn.keccak256.html","module_info":["std","hash"],"name":"keccak256","preview":"Returns the KECCAK-256 hash of param.\n","type_name":"function"},{"html_filename":"struct.ContractId.html","module_info":["std","contract_id"],"name":"ContractId","preview":"The ContractId type, a struct wrapper around the inner b256 value.\n","type_name":"struct"},{"html_filename":"struct.AssetId.html","module_info":["std","asset_id"],"name":"AssetId","preview":"An AssetId is used for interacting with an asset on the network.\n","type_name":"struct"},{"html_filename":"fn.run_external.html","module_info":["std","execution"],"name":"run_external","preview":"Load and run the contract with the provided ContractId.\n","type_name":"function"},{"html_filename":"constant.ZERO_B256.html","module_info":["std","constants"],"name":"ZERO_B256","preview":"A b256 of zero value.\n","type_name":"constant"},{"html_filename":"constant.BASE_ASSET_ID.html","module_info":["std","constants"],"name":"BASE_ASSET_ID","preview":"The BASE_ASSET_ID represents the base asset of a chain.\n","type_name":"constant"},{"html_filename":"constant.ZERO_U256.html","module_info":["std","constants"],"name":"ZERO_U256","preview":"A u256 of zero value.\n","type_name":"constant"},{"html_filename":"constant.DEFAULT_SUB_ID.html","module_info":["std","constants"],"name":"DEFAULT_SUB_ID","preview":"The default Sub Id for assets.\n","type_name":"constant"},{"html_filename":"fn.contract_id.html","module_info":["std","call_frames"],"name":"contract_id","preview":"Get the current contract’s id when called in an internal context.\n","type_name":"function"},{"html_filename":"fn.msg_asset_id.html","module_info":["std","call_frames"],"name":"msg_asset_id","preview":"Get the asset_id of coins being sent from the current call frame.\n","type_name":"function"},{"html_filename":"fn.code_size.html","module_info":["std","call_frames"],"name":"code_size","preview":"Get the code size in bytes (padded to word alignment) from the current call frame.\n","type_name":"function"},{"html_filename":"fn.first_param.html","module_info":["std","call_frames"],"name":"first_param","preview":"Get the first parameter from the current call frame.\n","type_name":"function"},{"html_filename":"fn.second_param.html","module_info":["std","call_frames"],"name":"second_param","preview":"Get the second parameter from the current call frame.\n","type_name":"function"},{"html_filename":"fn.get_previous_frame_pointer.html","module_info":["std","call_frames"],"name":"get_previous_frame_pointer","preview":"Get a pointer to the previous (relative to the frame_pointer parameter) call frame using offsets from a pointer.","type_name":"function"},{"html_filename":"fn.get_contract_id_from_call_frame.html","module_info":["std","call_frames"],"name":"get_contract_id_from_call_frame","preview":"Get the value of ContractId from any call frame on the stack.\n","type_name":"function"},{"html_filename":"fn.balance_of.html","module_info":["std","context"],"name":"balance_of","preview":"Get the balance of coin asset_id for the contract at ‘target’.\n","type_name":"function"},{"html_filename":"fn.this_balance.html","module_info":["std","context"],"name":"this_balance","preview":"Get the balance of coin asset_id for the current contract.\n","type_name":"function"},{"html_filename":"fn.msg_amount.html","module_info":["std","context"],"name":"msg_amount","preview":"Get the amount of units of call_frames::msg_asset_id() being sent.\n","type_name":"function"},{"html_filename":"fn.bytecode_root.html","module_info":["std","external"],"name":"bytecode_root","preview":"Get the root of the bytecode of the contract at ‘contract_id’.\n","type_name":"function"},{"html_filename":"struct.B512.html","module_info":["std","b512"],"name":"B512","preview":"Stores two b256s in contiguous memory.
","type_name":"struct"},{"html_filename":"constant.GTF_TYPE.html","module_info":["std","tx"],"name":"GTF_TYPE","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_GAS_LIMIT.html","module_info":["std","tx"],"name":"GTF_SCRIPT_GAS_LIMIT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_SCRIPT_LENGTH.html","module_info":["std","tx"],"name":"GTF_SCRIPT_SCRIPT_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_SCRIPT_DATA_LENGTH.html","module_info":["std","tx"],"name":"GTF_SCRIPT_SCRIPT_DATA_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_INPUTS_COUNT.html","module_info":["std","tx"],"name":"GTF_SCRIPT_INPUTS_COUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_OUTPUTS_COUNT.html","module_info":["std","tx"],"name":"GTF_SCRIPT_OUTPUTS_COUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_WITNESSES_COUNT.html","module_info":["std","tx"],"name":"GTF_SCRIPT_WITNESSES_COUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_RECEIPTS_ROOT.html","module_info":["std","tx"],"name":"GTF_SCRIPT_RECEIPTS_ROOT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_SCRIPT.html","module_info":["std","tx"],"name":"GTF_SCRIPT_SCRIPT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_SCRIPT_DATA.html","module_info":["std","tx"],"name":"GTF_SCRIPT_SCRIPT_DATA","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_INPUT_AT_INDEX.html","module_info":["std","tx"],"name":"GTF_SCRIPT_INPUT_AT_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_OUTPUT_AT_INDEX.html","module_info":["std","tx"],"name":"GTF_SCRIPT_OUTPUT_AT_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_SCRIPT_WITNESS_AT_INDEX.html","module_info":["std","tx"],"name":"GTF_SCRIPT_WITNESS_AT_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_CREATE_INPUTS_COUNT.html","module_info":["std","tx"],"name":"GTF_CREATE_INPUTS_COUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_CREATE_OUTPUTS_COUNT.html","module_info":["std","tx"],"name":"GTF_CREATE_OUTPUTS_COUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_CREATE_WITNESSES_COUNT.html","module_info":["std","tx"],"name":"GTF_CREATE_WITNESSES_COUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_CREATE_INPUT_AT_INDEX.html","module_info":["std","tx"],"name":"GTF_CREATE_INPUT_AT_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_CREATE_OUTPUT_AT_INDEX.html","module_info":["std","tx"],"name":"GTF_CREATE_OUTPUT_AT_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_CREATE_WITNESS_AT_INDEX.html","module_info":["std","tx"],"name":"GTF_CREATE_WITNESS_AT_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_WITNESS_DATA_LENGTH.html","module_info":["std","tx"],"name":"GTF_WITNESS_DATA_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_WITNESS_DATA.html","module_info":["std","tx"],"name":"GTF_WITNESS_DATA","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_POLICY_TYPES.html","module_info":["std","tx"],"name":"GTF_POLICY_TYPES","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_POLICY_GAS_PRICE.html","module_info":["std","tx"],"name":"GTF_POLICY_GAS_PRICE","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_POLICY_WITNESS_LIMIT.html","module_info":["std","tx"],"name":"GTF_POLICY_WITNESS_LIMIT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_POLICY_MATURITY.html","module_info":["std","tx"],"name":"GTF_POLICY_MATURITY","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_POLICY_MAX_FEE.html","module_info":["std","tx"],"name":"GTF_POLICY_MAX_FEE","preview":"","type_name":"constant"},{"html_filename":"enum.Transaction.html","module_info":["std","tx"],"name":"Transaction","preview":"A transaction type.\n","type_name":"enum"},{"html_filename":"fn.tx_type.html","module_info":["std","tx"],"name":"tx_type","preview":"Get the type of the current transaction.
","type_name":"function"},{"html_filename":"fn.tx_gas_price.html","module_info":["std","tx"],"name":"tx_gas_price","preview":"Get the gas price for the transaction, if it is set.\n","type_name":"function"},{"html_filename":"fn.script_gas_limit.html","module_info":["std","tx"],"name":"script_gas_limit","preview":"Get the script gas limit for the transaction.\n","type_name":"function"},{"html_filename":"fn.tx_maturity.html","module_info":["std","tx"],"name":"tx_maturity","preview":"Get the maturity for the transaction, if it is set.\n","type_name":"function"},{"html_filename":"fn.tx_witness_limit.html","module_info":["std","tx"],"name":"tx_witness_limit","preview":"Get the witness limit for the transaction, if it is set.\n","type_name":"function"},{"html_filename":"fn.tx_max_fee.html","module_info":["std","tx"],"name":"tx_max_fee","preview":"Get the max fee for the transaction, if it is set.\n","type_name":"function"},{"html_filename":"fn.tx_script_length.html","module_info":["std","tx"],"name":"tx_script_length","preview":"Get the length of the script for the transaction.\n","type_name":"function"},{"html_filename":"fn.tx_script_data_length.html","module_info":["std","tx"],"name":"tx_script_data_length","preview":"Get the script data length for the transaction.\n","type_name":"function"},{"html_filename":"fn.tx_witnesses_count.html","module_info":["std","tx"],"name":"tx_witnesses_count","preview":"Get the transaction witnesses count for the transaction.\n","type_name":"function"},{"html_filename":"fn.tx_witness_pointer.html","module_info":["std","tx"],"name":"tx_witness_pointer","preview":"Get a pointer to the witness at index index for the transaction.\n","type_name":"function"},{"html_filename":"fn.tx_witness_data_length.html","module_info":["std","tx"],"name":"tx_witness_data_length","preview":"Get the length of the witness data at index.\n","type_name":"function"},{"html_filename":"fn.tx_witness_data.html","module_info":["std","tx"],"name":"tx_witness_data","preview":"Get the witness data at index.\n","type_name":"function"},{"html_filename":"fn.tx_receipts_root.html","module_info":["std","tx"],"name":"tx_receipts_root","preview":"Get the transaction receipts root.\n","type_name":"function"},{"html_filename":"fn.tx_script_start_pointer.html","module_info":["std","tx"],"name":"tx_script_start_pointer","preview":"Get the transaction script start pointer.\n","type_name":"function"},{"html_filename":"fn.tx_script_data_start_pointer.html","module_info":["std","tx"],"name":"tx_script_data_start_pointer","preview":"Get the transaction script data start pointer.\n","type_name":"function"},{"html_filename":"fn.tx_script_data.html","module_info":["std","tx"],"name":"tx_script_data","preview":"Get the script data, typed.\n","type_name":"function"},{"html_filename":"fn.tx_script_bytecode.html","module_info":["std","tx"],"name":"tx_script_bytecode","preview":"Get the script bytecode.\n","type_name":"function"},{"html_filename":"fn.tx_script_bytecode_hash.html","module_info":["std","tx"],"name":"tx_script_bytecode_hash","preview":"Get the hash of the script bytecode.
\nReverts if not a transaction-script.\n","type_name":"function"},{"html_filename":"fn.tx_id.html","module_info":["std","tx"],"name":"tx_id","preview":"Get the Transaction ID of the current transaction.\n","type_name":"function"},{"html_filename":"constant.GTF_OUTPUT_TYPE.html","module_info":["std","outputs"],"name":"GTF_OUTPUT_TYPE","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_OUTPUT_COIN_TO.html","module_info":["std","outputs"],"name":"GTF_OUTPUT_COIN_TO","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_OUTPUT_COIN_AMOUNT.html","module_info":["std","outputs"],"name":"GTF_OUTPUT_COIN_AMOUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_OUTPUT_COIN_ASSET_ID.html","module_info":["std","outputs"],"name":"GTF_OUTPUT_COIN_ASSET_ID","preview":"","type_name":"constant"},{"html_filename":"enum.Output.html","module_info":["std","outputs"],"name":"Output","preview":"The output type for a transaction.\n","type_name":"enum"},{"html_filename":"fn.output_type.html","module_info":["std","outputs"],"name":"output_type","preview":"Get the type of an output at index.\n","type_name":"function"},{"html_filename":"fn.output_pointer.html","module_info":["std","outputs"],"name":"output_pointer","preview":"Get a pointer to the output at index
","type_name":"function"},{"html_filename":"fn.output_count.html","module_info":["std","outputs"],"name":"output_count","preview":"Get the transaction outputs count for either tx_type
","type_name":"function"},{"html_filename":"fn.output_amount.html","module_info":["std","outputs"],"name":"output_amount","preview":"The amount of coins to send to the output at index.\n","type_name":"function"},{"html_filename":"fn.output_asset_id.html","module_info":["std","outputs"],"name":"output_asset_id","preview":"Gets the AssetId of the output if it is a Output::Coin.\n","type_name":"function"},{"html_filename":"fn.output_asset_to.html","module_info":["std","outputs"],"name":"output_asset_to","preview":"Returns the receiver of the output if it is a Output::Coin. Represents the receiver as a b256.","type_name":"function"},{"html_filename":"struct.Address.html","module_info":["std","address"],"name":"Address","preview":"The Address type, a struct wrapper around the inner b256 value.\n","type_name":"struct"},{"html_filename":"enum.Identity.html","module_info":["std","identity"],"name":"Identity","preview":"The Identity type: either an Address or a ContractId.\n","type_name":"enum"},{"html_filename":"enum.EcRecoverError.html","module_info":["std","ecr"],"name":"EcRecoverError","preview":"The error type used when the ec_recover function fails.\n","type_name":"enum"},{"html_filename":"fn.ec_recover.html","module_info":["std","ecr"],"name":"ec_recover","preview":"Recover the public key derived from the private key used to sign a message.
","type_name":"function"},{"html_filename":"fn.ec_recover_r1.html","module_info":["std","ecr"],"name":"ec_recover_r1","preview":"Recover the public key derived from the private key used to sign a message.
","type_name":"function"},{"html_filename":"fn.ed_verify.html","module_info":["std","ecr"],"name":"ed_verify","preview":"Verifies that a public key derived from the private key was used to sign a message.
","type_name":"function"},{"html_filename":"fn.ec_recover_address.html","module_info":["std","ecr"],"name":"ec_recover_address","preview":"Recover the address derived from the private key used to sign a message.
","type_name":"function"},{"html_filename":"fn.ec_recover_address_r1.html","module_info":["std","ecr"],"name":"ec_recover_address_r1","preview":"Recover the address derived from the private key used to sign a message.
","type_name":"function"},{"html_filename":"struct.EvmAddress.html","module_info":["std","vm","evm","evm_address"],"name":"EvmAddress","preview":"The EvmAddress type, a struct wrapper around the inner b256 value.\n","type_name":"struct"},{"html_filename":"fn.ec_recover_evm_address.html","module_info":["std","vm","evm","ecr"],"name":"ec_recover_evm_address","preview":"Recover the EVM address derived from the private key used to sign a message.
","type_name":"function"},{"html_filename":"struct.String.html","module_info":["std","string"],"name":"String","preview":"A UTF-8 encoded growable string.\n","type_name":"struct"},{"html_filename":"fn.write.html","module_info":["std","storage","storage_api"],"name":"write","preview":"Stores a stack value in storage. Will not work for heap values.\n","type_name":"function"},{"html_filename":"fn.read.html","module_info":["std","storage","storage_api"],"name":"read","preview":"Reads a value of type T starting at the location specified by slot and offset. If the
","type_name":"function"},{"html_filename":"fn.clear.html","module_info":["std","storage","storage_api"],"name":"clear","preview":"Clear a value starting at some slot with an offset.\n","type_name":"function"},{"html_filename":"fn.write_slice.html","module_info":["std","storage","storable_slice"],"name":"write_slice","preview":"Store a raw_slice from the heap into storage.\n","type_name":"function"},{"html_filename":"fn.read_slice.html","module_info":["std","storage","storable_slice"],"name":"read_slice","preview":"Load a raw_slice from storage.\n","type_name":"function"},{"html_filename":"fn.clear_slice.html","module_info":["std","storage","storable_slice"],"name":"clear_slice","preview":"Clear a sequence of storage slots starting at a some key.\n","type_name":"function"},{"html_filename":"trait.StorableSlice.html","module_info":["std","storage","storable_slice"],"name":"StorableSlice","preview":"A general way to persistently store heap types.\n","type_name":"trait"},{"html_filename":"enum.StorageMapError.html","module_info":["std","storage","storage_map"],"name":"StorageMapError","preview":"Errors pertaining to the StorageMap struct.\n","type_name":"enum"},{"html_filename":"struct.StorageMap.html","module_info":["std","storage","storage_map"],"name":"StorageMap","preview":"A persistent key-value pair mapping struct.\n","type_name":"struct"},{"html_filename":"struct.StorageVec.html","module_info":["std","storage","storage_vec"],"name":"StorageVec","preview":"A persistent vector struct.\n","type_name":"struct"},{"html_filename":"struct.StorageBytes.html","module_info":["std","storage","storage_bytes"],"name":"StorageBytes","preview":"A persistent storage type to store a collection of tightly packed bytes.\n","type_name":"struct"},{"html_filename":"struct.StorageString.html","module_info":["std","storage","storage_string"],"name":"StorageString","preview":"","type_name":"struct"},{"html_filename":"fn.height.html","module_info":["std","block"],"name":"height","preview":"Get the current block height.\n","type_name":"function"},{"html_filename":"fn.timestamp_of_block.html","module_info":["std","block"],"name":"timestamp_of_block","preview":"Get the TAI64 timestamp of a block at a given block_height.\n","type_name":"function"},{"html_filename":"fn.timestamp.html","module_info":["std","block"],"name":"timestamp","preview":"Get the TAI64 timestamp of the current block.\n","type_name":"function"},{"html_filename":"fn.block_header_hash.html","module_info":["std","block"],"name":"block_header_hash","preview":"Get the header hash of the block at height block_height\n","type_name":"function"},{"html_filename":"constant.GTF_INPUT_COIN_OWNER.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_OWNER","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_AMOUNT.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_AMOUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_ASSET_ID.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_ASSET_ID","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_WITNESS_INDEX.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_WITNESS_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_MATURITY.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_MATURITY","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_PREDICATE_LENGTH.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_PREDICATE_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_PREDICATE_DATA_LENGTH.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_PREDICATE_DATA_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_PREDICATE.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_PREDICATE","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_COIN_PREDICATE_DATA.html","module_info":["std","inputs"],"name":"GTF_INPUT_COIN_PREDICATE_DATA","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_SENDER.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_SENDER","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_RECIPIENT.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_RECIPIENT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_AMOUNT.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_AMOUNT","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_NONCE.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_NONCE","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_WITNESS_INDEX.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_WITNESS_INDEX","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_DATA_LENGTH.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_DATA_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_PREDICATE_LENGTH.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_PREDICATE_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_DATA.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_DATA","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_PREDICATE.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_PREDICATE","preview":"","type_name":"constant"},{"html_filename":"constant.GTF_INPUT_MESSAGE_PREDICATE_DATA.html","module_info":["std","inputs"],"name":"GTF_INPUT_MESSAGE_PREDICATE_DATA","preview":"","type_name":"constant"},{"html_filename":"enum.Input.html","module_info":["std","inputs"],"name":"Input","preview":"The input type for a transaction.\n","type_name":"enum"},{"html_filename":"fn.input_type.html","module_info":["std","inputs"],"name":"input_type","preview":"Gets the type of the input at index.\n","type_name":"function"},{"html_filename":"fn.input_count.html","module_info":["std","inputs"],"name":"input_count","preview":"Gets the transaction inputs count.\n","type_name":"function"},{"html_filename":"fn.input_pointer.html","module_info":["std","inputs"],"name":"input_pointer","preview":"Gets the pointer of the input at index.\n","type_name":"function"},{"html_filename":"fn.input_amount.html","module_info":["std","inputs"],"name":"input_amount","preview":"Gets amount field from input at index.\n","type_name":"function"},{"html_filename":"fn.input_coin_owner.html","module_info":["std","inputs"],"name":"input_coin_owner","preview":"Gets owner field from input at index if it’s a coin.\n","type_name":"function"},{"html_filename":"fn.input_predicate_data_pointer.html","module_info":["std","inputs"],"name":"input_predicate_data_pointer","preview":"Gets the predicate data pointer from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_predicate_data.html","module_info":["std","inputs"],"name":"input_predicate_data","preview":"Gets the predicate data from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_asset_id.html","module_info":["std","inputs"],"name":"input_asset_id","preview":"Gets the AssetId of the input at index.\n","type_name":"function"},{"html_filename":"fn.input_witness_index.html","module_info":["std","inputs"],"name":"input_witness_index","preview":"Gets the witness index from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_predicate_length.html","module_info":["std","inputs"],"name":"input_predicate_length","preview":"Gets the predicate length from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_predicate_pointer.html","module_info":["std","inputs"],"name":"input_predicate_pointer","preview":"Gets the predicate pointer from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_predicate.html","module_info":["std","inputs"],"name":"input_predicate","preview":"Gets the predicate from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_predicate_data_length.html","module_info":["std","inputs"],"name":"input_predicate_data_length","preview":"Gets the predicate data length from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_maturity.html","module_info":["std","inputs"],"name":"input_maturity","preview":"Gets the maturity from the input at index.\n","type_name":"function"},{"html_filename":"fn.input_message_sender.html","module_info":["std","inputs"],"name":"input_message_sender","preview":"Gets the sender of the input message at index.\n","type_name":"function"},{"html_filename":"fn.input_message_recipient.html","module_info":["std","inputs"],"name":"input_message_recipient","preview":"Gets the recipient of the input message at index.\n","type_name":"function"},{"html_filename":"fn.input_message_nonce.html","module_info":["std","inputs"],"name":"input_message_nonce","preview":"Gets the nonce of input message at index.\n","type_name":"function"},{"html_filename":"fn.input_message_data_length.html","module_info":["std","inputs"],"name":"input_message_data_length","preview":"Gets the length of the input message at index.\n","type_name":"function"},{"html_filename":"fn.input_message_data.html","module_info":["std","inputs"],"name":"input_message_data","preview":"Gets the data of the input message at index.\n","type_name":"function"},{"html_filename":"enum.AuthError.html","module_info":["std","auth"],"name":"AuthError","preview":"The error type used when an Identity cannot be determined.\n","type_name":"enum"},{"html_filename":"fn.caller_is_external.html","module_info":["std","auth"],"name":"caller_is_external","preview":"Returns true if the caller is external (i.e. a script).
","type_name":"function"},{"html_filename":"fn.caller_contract_id.html","module_info":["std","auth"],"name":"caller_contract_id","preview":"If the caller is internal, returns the contract ID of the caller.\n","type_name":"function"},{"html_filename":"fn.caller_address.html","module_info":["std","auth"],"name":"caller_address","preview":"Get the owner of the inputs (of type Input::Coin or Input::Message) to a
","type_name":"function"},{"html_filename":"fn.msg_sender.html","module_info":["std","auth"],"name":"msg_sender","preview":"Get the Identity (i.e. Address or ContractId) from which a call was made.
","type_name":"function"},{"html_filename":"fn.predicate_address.html","module_info":["std","auth"],"name":"predicate_address","preview":"Get the current predicate’s address when called in an internal context.\n","type_name":"function"},{"html_filename":"fn.mint.html","module_info":["std","asset"],"name":"mint","preview":"Mint amount coins of the current contract’s sub_id. The newly minted assets are owned by the current contract.","type_name":"function"},{"html_filename":"fn.force_transfer_to_contract.html","module_info":["std","asset"],"name":"force_transfer_to_contract","preview":"UNCONDITIONAL transfer of amount coins of type asset_id to
","type_name":"function"},{"html_filename":"fn.transfer_to_address.html","module_info":["std","asset"],"name":"transfer_to_address","preview":"Transfer amount coins of type asset_id and send them to
","type_name":"function"},{"html_filename":"fn.transfer.html","module_info":["std","asset"],"name":"transfer","preview":"Transfer amount coins of the type asset_id and send them
","type_name":"function"},{"html_filename":"fn.mint_to.html","module_info":["std","asset"],"name":"mint_to","preview":"Mint amount coins of the current contract’s asset_id and transfer them
","type_name":"function"},{"html_filename":"fn.mint_to_contract.html","module_info":["std","asset"],"name":"mint_to_contract","preview":"Mint amount coins of the current contract’s asset_id and send them
","type_name":"function"},{"html_filename":"fn.mint_to_address.html","module_info":["std","asset"],"name":"mint_to_address","preview":"Mint amount coins of the current contract’s asset_id and send them to
","type_name":"function"},{"html_filename":"fn.burn.html","module_info":["std","asset"],"name":"burn","preview":"Burn amount coins of the current contract’s sub_id. Burns them from the balance of the current contract.","type_name":"function"},{"html_filename":"fn.send_message.html","module_info":["std","message"],"name":"send_message","preview":"Sends a message msg_data to recipient with a coins amount of the base asset.","type_name":"function"},{"html_filename":"fn.send_typed_message.html","module_info":["std","message"],"name":"send_typed_message","preview":"Sends a message msg_data of type T to recipient with a coins amount of the base asset.","type_name":"function"},{"html_filename":"struct.CallParams.html","module_info":["std","low_level_call"],"name":"CallParams","preview":"A struct representing the call parameters of a function call.\n","type_name":"struct"},{"html_filename":"fn.call_with_function_selector.html","module_info":["std","low_level_call"],"name":"call_with_function_selector","preview":"Call a target contract with a function selector and calldata, provided as Bytes.","type_name":"function"},{"html_filename":"fn.call_with_function_selector_vec.html","module_info":["std","low_level_call"],"name":"call_with_function_selector_vec","preview":"Call a target contract with a function selector and calldata, provided as Vec<u8>.","type_name":"function"}],"sway_libs":[{"html_filename":"enum.BurnError.html","module_info":["sway_libs","asset","errors"],"name":"BurnError","preview":"Error log for when something goes wrong when burning assets.\n","type_name":"enum"},{"html_filename":"fn._total_assets.html","module_info":["sway_libs","asset","base"],"name":"_total_assets","preview":"Returns the total number of individual assets for a contract.\n","type_name":"function"},{"html_filename":"fn._total_supply.html","module_info":["sway_libs","asset","base"],"name":"_total_supply","preview":"Returns the total supply of coins for an asset.\n","type_name":"function"},{"html_filename":"fn._name.html","module_info":["sway_libs","asset","base"],"name":"_name","preview":"Returns the name of the asset, such as “Ether”.\n","type_name":"function"},{"html_filename":"fn._symbol.html","module_info":["sway_libs","asset","base"],"name":"_symbol","preview":"Returns the symbol of the asset, such as “ETH”.\n","type_name":"function"},{"html_filename":"fn._decimals.html","module_info":["sway_libs","asset","base"],"name":"_decimals","preview":"Returns the number of decimals the asset uses.\n","type_name":"function"},{"html_filename":"fn._set_name.html","module_info":["sway_libs","asset","base"],"name":"_set_name","preview":"Unconditionally sets the name of an asset.\n","type_name":"function"},{"html_filename":"fn._set_symbol.html","module_info":["sway_libs","asset","base"],"name":"_set_symbol","preview":"Unconditionally sets the symbol of an asset.\n","type_name":"function"},{"html_filename":"fn._set_decimals.html","module_info":["sway_libs","asset","base"],"name":"_set_decimals","preview":"Unconditionally sets the decimals of an asset.\n","type_name":"function"},{"html_filename":"abi.SetAssetAttributes.html","module_info":["sway_libs","asset","base"],"name":"SetAssetAttributes","preview":"","type_name":"abi"},{"html_filename":"struct.StorageMetadata.html","module_info":["sway_libs","asset","metadata"],"name":"StorageMetadata","preview":"A persistent storage type to store the SRC-7; Metadata Standard type.\n","type_name":"struct"},{"html_filename":"fn._set_metadata.html","module_info":["sway_libs","asset","metadata"],"name":"_set_metadata","preview":"Unconditionally stores metadata for a specific asset and key pair.\n","type_name":"function"},{"html_filename":"abi.SetAssetMetadata.html","module_info":["sway_libs","asset","metadata"],"name":"SetAssetMetadata","preview":"","type_name":"abi"},{"html_filename":"fn._mint.html","module_info":["sway_libs","asset","supply"],"name":"_mint","preview":"Unconditionally mints new assets using the sub_id sub-identifier.\n","type_name":"function"},{"html_filename":"fn._burn.html","module_info":["sway_libs","asset","supply"],"name":"_burn","preview":"Burns assets with the given sub_id.\n","type_name":"function"},{"html_filename":"fn.compute_bytecode_root.html","module_info":["sway_libs","bytecode"],"name":"compute_bytecode_root","preview":"Takes the bytecode of a contract or predicate and computes the bytecode root.\n","type_name":"function"},{"html_filename":"fn.compute_bytecode_root_with_configurables.html","module_info":["sway_libs","bytecode"],"name":"compute_bytecode_root_with_configurables","preview":"Takes the bytecode of a contract or predicate and configurables and computes the bytecode root.","type_name":"function"},{"html_filename":"fn.compute_predicate_address.html","module_info":["sway_libs","bytecode"],"name":"compute_predicate_address","preview":"Takes the bytecode of a predicate and computes the address of a predicate.\n","type_name":"function"},{"html_filename":"fn.compute_predicate_address_with_configurables.html","module_info":["sway_libs","bytecode"],"name":"compute_predicate_address_with_configurables","preview":"Takes the bytecode of a predicate and configurables and computes the address of a predicate.\n","type_name":"function"},{"html_filename":"fn.predicate_address_from_root.html","module_info":["sway_libs","bytecode"],"name":"predicate_address_from_root","preview":"Takes the bytecode root of a predicate and generates the address of the predicate.\n","type_name":"function"},{"html_filename":"fn.swap_configurables.html","module_info":["sway_libs","bytecode"],"name":"swap_configurables","preview":"Swaps out configurable values in a contract or predicate’s bytecode.\n","type_name":"function"},{"html_filename":"fn.verify_contract_bytecode.html","module_info":["sway_libs","bytecode"],"name":"verify_contract_bytecode","preview":"Asserts that a contract’s bytecode and the given bytecode match.\n","type_name":"function"},{"html_filename":"fn.verify_contract_bytecode_with_configurables.html","module_info":["sway_libs","bytecode"],"name":"verify_contract_bytecode_with_configurables","preview":"Asserts that a contract’s bytecode and the given bytecode and configurable values match.\n","type_name":"function"},{"html_filename":"fn.verify_predicate_address.html","module_info":["sway_libs","bytecode"],"name":"verify_predicate_address","preview":"Asserts that a predicates’s address from some bytecode and the given address match.\n","type_name":"function"},{"html_filename":"fn.verify_predicate_address_with_configurables.html","module_info":["sway_libs","bytecode"],"name":"verify_predicate_address_with_configurables","preview":"Asserts that a predicates’s address from some bytecode and configurables and the given address match.","type_name":"function"},{"html_filename":"fn._predicate_address_from_root.html","module_info":["sway_libs","bytecode","utils"],"name":"_predicate_address_from_root","preview":"Takes the bytecode root of predicate generates the address of a predicate.\n","type_name":"function"},{"html_filename":"fn._compute_bytecode_root.html","module_info":["sway_libs","bytecode","utils"],"name":"_compute_bytecode_root","preview":"Takes some bytecode and computes the bytecode root.\n","type_name":"function"},{"html_filename":"fn._swap_configurables.html","module_info":["sway_libs","bytecode","utils"],"name":"_swap_configurables","preview":"Swaps out configurable values in a contract’s or predicate’s bytecode.\n","type_name":"function"},{"html_filename":"struct.UFP32.html","module_info":["sway_libs","fixed_point","ufp32"],"name":"UFP32","preview":"The 32-bit unsigned fixed point number type.\n","type_name":"struct"},{"html_filename":"struct.UFP64.html","module_info":["sway_libs","fixed_point","ufp64"],"name":"UFP64","preview":"The 64-bit unsigned fixed point number type.\n","type_name":"struct"},{"html_filename":"struct.UFP128.html","module_info":["sway_libs","fixed_point","ufp128"],"name":"UFP128","preview":"The 128-bit unsigned fixed point number type.\n","type_name":"struct"},{"html_filename":"struct.IFP64.html","module_info":["sway_libs","fixed_point","ifp64"],"name":"IFP64","preview":"The 64-bit signed fixed point number type.\n","type_name":"struct"},{"html_filename":"struct.IFP128.html","module_info":["sway_libs","fixed_point","ifp128"],"name":"IFP128","preview":"The 128-bit signed fixed point number type.\n","type_name":"struct"},{"html_filename":"struct.IFP256.html","module_info":["sway_libs","fixed_point","ifp256"],"name":"IFP256","preview":"The 256-bit signed fixed point number type.\n","type_name":"struct"},{"html_filename":"fn.starting_bit.html","module_info":["sway_libs","merkle","utils"],"name":"starting_bit","preview":"Calculates the starting bit of the path to a leaf\n","type_name":"function"},{"html_filename":"fn.path_length_from_key.html","module_info":["sway_libs","merkle","utils"],"name":"path_length_from_key","preview":"Calculates the length of the path to a leaf\n","type_name":"function"},{"html_filename":"enum.ProofError.html","module_info":["sway_libs","merkle","binary_proof"],"name":"ProofError","preview":"","type_name":"enum"},{"html_filename":"constant.LEAF.html","module_info":["sway_libs","merkle","binary_proof"],"name":"LEAF","preview":"Concatenated to leaf hash input as described by
\n“MTH({d(0)}) = SHA-256(0x00 || d(0))”\n","type_name":"constant"},{"html_filename":"constant.NODE.html","module_info":["sway_libs","merkle","binary_proof"],"name":"NODE","preview":"Concatenated to node hash input as described by
","type_name":"constant"},{"html_filename":"fn.leaf_digest.html","module_info":["sway_libs","merkle","binary_proof"],"name":"leaf_digest","preview":"Returns the computed leaf hash of “MTH({d(0)}) = SHA-256(0x00 || d(0))”.\n","type_name":"function"},{"html_filename":"fn.node_digest.html","module_info":["sway_libs","merkle","binary_proof"],"name":"node_digest","preview":"Returns the computed node hash of “MTH(D[n]) = SHA-256(0x01 || MTH(D[0:k]) || MTH(D[k:n]))”.\n","type_name":"function"},{"html_filename":"fn.process_proof.html","module_info":["sway_libs","merkle","binary_proof"],"name":"process_proof","preview":"This function will compute and return a Merkle root given a leaf and corresponding proof.\n","type_name":"function"},{"html_filename":"fn.verify_proof.html","module_info":["sway_libs","merkle","binary_proof"],"name":"verify_proof","preview":"This function will take a Merkle leaf and proof and return whether the corresponding root
","type_name":"function"},{"html_filename":"fn._owner.html","module_info":["sway_libs","ownership"],"name":"_owner","preview":"Returns the owner.\n","type_name":"function"},{"html_filename":"fn.only_owner.html","module_info":["sway_libs","ownership"],"name":"only_owner","preview":"Ensures that the sender is the owner.\n","type_name":"function"},{"html_filename":"fn.renounce_ownership.html","module_info":["sway_libs","ownership"],"name":"renounce_ownership","preview":"Revokes ownership of the current owner and disallows any new owners.\n","type_name":"function"},{"html_filename":"fn.initialize_ownership.html","module_info":["sway_libs","ownership"],"name":"initialize_ownership","preview":"Sets the passed identity as the initial owner.\n","type_name":"function"},{"html_filename":"fn.transfer_ownership.html","module_info":["sway_libs","ownership"],"name":"transfer_ownership","preview":"Transfers ownership to the passed identity.\n","type_name":"function"},{"html_filename":"enum.InitializationError.html","module_info":["sway_libs","ownership","errors"],"name":"InitializationError","preview":"Error log for when access is denied.\n","type_name":"enum"},{"html_filename":"struct.OwnershipRenounced.html","module_info":["sway_libs","ownership","events"],"name":"OwnershipRenounced","preview":"Logged when ownership is renounced.\n","type_name":"struct"},{"html_filename":"struct.OwnershipSet.html","module_info":["sway_libs","ownership","events"],"name":"OwnershipSet","preview":"Logged when ownership is given to a user.\n","type_name":"struct"},{"html_filename":"struct.OwnershipTransferred.html","module_info":["sway_libs","ownership","events"],"name":"OwnershipTransferred","preview":"Logged when ownership is given from one user to another.\n","type_name":"struct"},{"html_filename":"fn.add_admin.html","module_info":["sway_libs","admin"],"name":"add_admin","preview":"","type_name":"function"},{"html_filename":"fn.revoke_admin.html","module_info":["sway_libs","admin"],"name":"revoke_admin","preview":"Removes an administrator.\n","type_name":"function"},{"html_filename":"fn.is_admin.html","module_info":["sway_libs","admin"],"name":"is_admin","preview":"Returns whether admin is an administrator.\n","type_name":"function"},{"html_filename":"fn.only_admin.html","module_info":["sway_libs","admin"],"name":"only_admin","preview":"Ensures that the sender is an administrator.\n","type_name":"function"},{"html_filename":"fn.only_owner_or_admin.html","module_info":["sway_libs","admin"],"name":"only_owner_or_admin","preview":"Ensures that the sender is an owner or administrator.\n","type_name":"function"},{"html_filename":"enum.AdminError.html","module_info":["sway_libs","admin","errors"],"name":"AdminError","preview":"Error log for when access is denied.\n","type_name":"enum"},{"html_filename":"abi.Pausable.html","module_info":["sway_libs","pausable"],"name":"Pausable","preview":"","type_name":"abi"},{"html_filename":"fn._pause.html","module_info":["sway_libs","pausable"],"name":"_pause","preview":"Unconditionally sets the contract to the paused state.\n","type_name":"function"},{"html_filename":"fn._unpause.html","module_info":["sway_libs","pausable"],"name":"_unpause","preview":"Unconditionally sets the contract to the unpaused state.\n","type_name":"function"},{"html_filename":"fn._is_paused.html","module_info":["sway_libs","pausable"],"name":"_is_paused","preview":"Returns whether the contract is in the paused state.\n","type_name":"function"},{"html_filename":"fn.require_paused.html","module_info":["sway_libs","pausable"],"name":"require_paused","preview":"Requires that the contract is in the paused state.\n","type_name":"function"},{"html_filename":"fn.require_not_paused.html","module_info":["sway_libs","pausable"],"name":"require_not_paused","preview":"Requires that the contract is in the unpaused state.\n","type_name":"function"},{"html_filename":"enum.PauseError.html","module_info":["sway_libs","pausable","errors"],"name":"PauseError","preview":"Error emitted upon the opposite of the desired pause state.\n","type_name":"enum"},{"html_filename":"struct.Queue.html","module_info":["sway_libs","queue"],"name":"Queue","preview":"The Queue type corresponds to the same called data structure.\n","type_name":"struct"},{"html_filename":"fn.is_reentrant.html","module_info":["sway_libs","reentrancy"],"name":"is_reentrant","preview":"Returns true if the reentrancy pattern is detected, and false otherwise.","type_name":"function"},{"html_filename":"fn.reentrancy_guard.html","module_info":["sway_libs","reentrancy"],"name":"reentrancy_guard","preview":"Reverts if the reentrancy pattern is detected in the contract in which this is called.\n","type_name":"function"},{"html_filename":"enum.ReentrancyError.html","module_info":["sway_libs","reentrancy","errors"],"name":"ReentrancyError","preview":"Error log for when reentrancy has been detected\n","type_name":"enum"},{"html_filename":"trait.TwosComplement.html","module_info":["sway_libs","signed_integers","common"],"name":"TwosComplement","preview":"Trait for the Two’s Complement of a value.\n","type_name":"trait"},{"html_filename":"enum.Error.html","module_info":["sway_libs","signed_integers","errors"],"name":"Error","preview":"Error log for when unexpected behavior has occurred.\n","type_name":"enum"},{"html_filename":"struct.I8.html","module_info":["sway_libs","signed_integers","i8"],"name":"I8","preview":"The 8-bit signed integer type.\n","type_name":"struct"},{"html_filename":"struct.I16.html","module_info":["sway_libs","signed_integers","i16"],"name":"I16","preview":"The 16-bit signed integer type.\n","type_name":"struct"},{"html_filename":"struct.I32.html","module_info":["sway_libs","signed_integers","i32"],"name":"I32","preview":"The 32-bit signed integer type.\n","type_name":"struct"},{"html_filename":"struct.I64.html","module_info":["sway_libs","signed_integers","i64"],"name":"I64","preview":"The 64-bit signed integer type.\n","type_name":"struct"},{"html_filename":"struct.I128.html","module_info":["sway_libs","signed_integers","i128"],"name":"I128","preview":"The 128-bit signed integer type.\n","type_name":"struct"},{"html_filename":"struct.I256.html","module_info":["sway_libs","signed_integers","i256"],"name":"I256","preview":"The 256-bit signed integer type.\n","type_name":"struct"}]}; +"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=SEARCH_INDEX); \ No newline at end of file diff --git a/v0.21.0/standards/all.html b/v0.21.0/standards/all.html new file mode 100644 index 00000000..1ef0d847 --- /dev/null +++ b/v0.21.0/standards/all.html @@ -0,0 +1,7 @@ +List of all items in this project

List of all items

Structs

Contact Information to report bugs to.

+

Event logged when a deposit is made.

+

Event logged when a withdrawal is made.

+

Enums

Error log for when access is denied.

+

Determines the state of ownership.

+

Universal return type for metadata.

+

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/index.html b/v0.21.0/standards/index.html new file mode 100644 index 00000000..7fe0a88a --- /dev/null +++ b/v0.21.0/standards/index.html @@ -0,0 +1 @@ +standards in standards - Sway

Library standards

Modules

\ No newline at end of file diff --git a/v0.21.0/standards/src10/abi.SRC10.html b/v0.21.0/standards/src10/abi.SRC10.html new file mode 100644 index 00000000..1d33c2bd --- /dev/null +++ b/v0.21.0/standards/src10/abi.SRC10.html @@ -0,0 +1,159 @@ +SRC10 in src10 - Sway
abi SRC10 {
+    /// Compiles a message to be sent back to the canonical chain.
+    ///
+    /// # Additional Information
+    ///
+    /// * The `gateway` contract on the canonical chain receives the `token_address` ID in the message such that when assets are deposited they are reported to prevent loss of funds.
+    ///
+    /// # Arguments
+    ///
+    /// * `token_address`: [b256] - The token's address on the canonical chain.
+    /// * `gateway_contract`: [b256] - The contract that accepts deposits on the canonical chain.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src10::SRC10;
+    ///
+    /// fn foo(gateway_contract: b256, token_address: b256, bridge: ContractId) {
+    ///     let bridge_abi = abi(SRC10, bridge.value);
+    ///     bridge_abi.register_token(token_address, gateway_contract);
+    /// }
+    /// ```
+    #[storage(read, write)]
+    fn register_token(token_address: b256, gateway_contract: b256);
+    /// Accepts incoming deposit messages from the canonical chain and issues the corresponding bridged asset.
+    ///
+    /// # Arguments
+    ///
+    /// * `message_index`: [u64] - The index of the message to parse.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src10::SRC10;
+    ///
+    /// fn foo(message_index: u64, bridge: ContractId) {
+    ///     let bridge_abi = abi(SRC10, bridge.value);
+    ///     bridge_abi.process_message(message_index);
+    /// }
+    /// ```
+    #[storage(read, write)]
+    fn process_message(message_index: u64);
+    /// Accepts and burns a bridged asset and sends a messages to the canonical chain to release the original deposited token.
+    ///
+    /// # Arguments
+    ///
+    /// * `to_address`: [b256] - The address on the canonical chain to send the released tokens to.
+    /// * `sub_id`: [SubId] - The SubId of the asset sent in the transaction.
+    /// * `gateway_contract`: [b256] - The contract that holds the deposited tokens on the canonical chain.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src10::SRC10;
+    ///
+    /// fn foo(to_address: b256, asset_sub_id: SubId, gateway_contract: b256, bridge: ContractId, bridged_asset: AssetId) {
+    ///     let bridge_abi = abi(SRC10, bridge.value);
+    ///     bridge_abi {
+    ///         gas: 10000,
+    ///         coins: 100,
+    ///         asset_id: bridged_asset,
+    ///     }.withdraw(to_address, asset_sub_id, gateway_contract);
+    /// }
+    /// ```
+    #[storage(read, write)]
+    fn withdraw(to_address: b256, sub_id: SubId, gateway_contract: b256);
+    /// Returns a refund on the canonical chain if an error occurs while bridging.
+    ///
+    /// # Arguments
+    ///
+    /// * `to_address`: [b256] - The address on the canonical chain to send the refunded tokens to.
+    /// * `token_address`: [b256] - The token on the canonical chain to be refunded.
+    /// * `token_id`: [b256] - The token id of the token on the canonical chain to be refunded.
+    /// * `gateway_contract`: [b256] - The contract that holds the deposited tokens on the canonical chain.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src10::SRC10;
+    ///
+    /// fn foo(to_address: b256, token_address: b256, token_id: b256, gateway_contract: b256, bridge: ContractId) {
+    ///     let bridge_abi = abi(SRC10, bridge.value);
+    ///     bridge_abi.claim_refund(to_address, token_address, token_id, gateway_contract);
+    /// }
+    /// ```
+    #[storage(read, write)]
+    fn claim_refund(
+        to_address: b256,
+        token_address: b256,
+        token_id: b256,
+        gateway_contract: b256,
+    );
+}

Required Methods

Compiles a message to be sent back to the canonical chain.

+

Additional Information

+
    +
  • The gateway contract on the canonical chain receives the token_address ID in the message such that when assets are deposited they are reported to prevent loss of funds.
  • +
+

Arguments

+
    +
  • token_address: [b256] - The token’s address on the canonical chain.
  • +
  • gateway_contract: [b256] - The contract that accepts deposits on the canonical chain.
  • +
+

Examples

+
use src10::SRC10;
+
+fn foo(gateway_contract: b256, token_address: b256, bridge: ContractId) {
+    let bridge_abi = abi(SRC10, bridge.value);
+    bridge_abi.register_token(token_address, gateway_contract);
+}
+
+

Accepts incoming deposit messages from the canonical chain and issues the corresponding bridged asset.

+

Arguments

+
    +
  • message_index: [u64] - The index of the message to parse.
  • +
+

Examples

+
use src10::SRC10;
+
+fn foo(message_index: u64, bridge: ContractId) {
+    let bridge_abi = abi(SRC10, bridge.value);
+    bridge_abi.process_message(message_index);
+}
+
+

Accepts and burns a bridged asset and sends a messages to the canonical chain to release the original deposited token.

+

Arguments

+
    +
  • to_address: [b256] - The address on the canonical chain to send the released tokens to.
  • +
  • sub_id: [SubId] - The SubId of the asset sent in the transaction.
  • +
  • gateway_contract: [b256] - The contract that holds the deposited tokens on the canonical chain.
  • +
+

Examples

+
use src10::SRC10;
+
+fn foo(to_address: b256, asset_sub_id: SubId, gateway_contract: b256, bridge: ContractId, bridged_asset: AssetId) {
+    let bridge_abi = abi(SRC10, bridge.value);
+    bridge_abi {
+        gas: 10000,
+        coins: 100,
+        asset_id: bridged_asset,
+    }.withdraw(to_address, asset_sub_id, gateway_contract);
+}
+
+

Returns a refund on the canonical chain if an error occurs while bridging.

+

Arguments

+
    +
  • to_address: [b256] - The address on the canonical chain to send the refunded tokens to.
  • +
  • token_address: [b256] - The token on the canonical chain to be refunded.
  • +
  • token_id: [b256] - The token id of the token on the canonical chain to be refunded.
  • +
  • gateway_contract: [b256] - The contract that holds the deposited tokens on the canonical chain.
  • +
+

Examples

+
use src10::SRC10;
+
+fn foo(to_address: b256, token_address: b256, token_id: b256, gateway_contract: b256, bridge: ContractId) {
+    let bridge_abi = abi(SRC10, bridge.value);
+    bridge_abi.claim_refund(to_address, token_address, token_id, gateway_contract);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/standards/src10/index.html b/v0.21.0/standards/src10/index.html new file mode 100644 index 00000000..8003e5bd --- /dev/null +++ b/v0.21.0/standards/src10/index.html @@ -0,0 +1 @@ +src10 in standards - Sway

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/src11/abi.SRC11.html b/v0.21.0/standards/src11/abi.SRC11.html new file mode 100644 index 00000000..9b706ee1 --- /dev/null +++ b/v0.21.0/standards/src11/abi.SRC11.html @@ -0,0 +1,16 @@ +SRC11 in src11 - Sway
abi SRC11 {
+    /// Returns security, contact, and audit information about the contract.
+    /// White hat hackers may use this information to report bugs to the project.
+    ///
+    /// # Returns
+    ///
+    /// * [SecurityInformation] - Security information about the contract.
+    #[storage(read)]
+    fn security_information() -> SecurityInformation;
+}

Required Methods

Returns security, contact, and audit information about the contract.
+White hat hackers may use this information to report bugs to the project.

+

Returns

+
    +
  • [SecurityInformation] - Security information about the contract.
  • +
+
\ No newline at end of file diff --git a/v0.21.0/standards/src11/index.html b/v0.21.0/standards/src11/index.html new file mode 100644 index 00000000..dd6231c7 --- /dev/null +++ b/v0.21.0/standards/src11/index.html @@ -0,0 +1,2 @@ +src11 in standards - Sway

Structs

Contact Information to report bugs to.

+

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/src11/struct.SecurityInformation.html b/v0.21.0/standards/src11/struct.SecurityInformation.html new file mode 100644 index 00000000..041e4359 --- /dev/null +++ b/v0.21.0/standards/src11/struct.SecurityInformation.html @@ -0,0 +1,51 @@ +SecurityInformation in src11 - Sway
pub struct SecurityInformation {
+    /// Name of the project.
+    pub name: String,
+    /// Website URL of the project.
+    pub project_url: Option<String>,
+    /// List of contact information to contact developers of the project.
+    /// Should be in the format <contact_type>:<contact_information>.
+    /// You should include contact types that will not change over time.
+    pub contact_information: Vec<String>,
+    /// Text describing the project's security policy, or a link to it.
+    /// This should describe what kind of bounties your project offers and the terms under which you offer them.
+    pub policy: String,
+    /// A list of preferred languages (ISO 639-1).
+    pub preferred_languages: Option<Vec<String>>,
+    /// A PGP public key block (or similar) or a link to one.
+    pub encryption: Option<String>,
+    /// A URL to the project's source code.
+    pub source_code: Option<String>,
+    /// The release identifier of this build, ideally corresponding to a tag on git that can be rebuilt to reproduce the same binary.
+    /// 3rd party build verification tools will use this tag to identify a matching github release.
+    pub source_release: Option<String>,
+    /// The revision identifier of this build, usually a git commit hash that can be rebuilt to reproduce the same binary.
+    /// 3rd party build verification tools will use this tag to identify a matching github release.
+    pub source_revision: Option<String>,
+    /// A list of people or entities that audited this smart contract, or links to pages where audit reports are hosted.
+    /// Note that this field is self-reported by the author of the program and might not be accurate.
+    pub auditors: Option<Vec<String>>,
+    /// Text containing acknowledgments to security researchers who have previously found vulnerabilities in the project, or a link to it.
+    pub acknowledgments: Option<String>,
+    /// Text containing any additional information you want to provide, or a link to it.
+    pub additional_information: Option<String>,
+}
Expand description

Contact Information to report bugs to.

+

Fields

name: String

Name of the project.

+
project_url: Option

Website URL of the project.

+
contact_information: Vec

List of contact information to contact developers of the project.
+Should be in the format <contact_type>:<contact_information>.
+You should include contact types that will not change over time.

+
policy: String

Text describing the project’s security policy, or a link to it.
+This should describe what kind of bounties your project offers and the terms under which you offer them.

+
preferred_languages: Option

A list of preferred languages (ISO 639-1).

+
encryption: Option

A PGP public key block (or similar) or a link to one.

+
source_code: Option

A URL to the project’s source code.

+
source_release: Option

The release identifier of this build, ideally corresponding to a tag on git that can be rebuilt to reproduce the same binary.
+3rd party build verification tools will use this tag to identify a matching github release.

+
source_revision: Option

The revision identifier of this build, usually a git commit hash that can be rebuilt to reproduce the same binary.
+3rd party build verification tools will use this tag to identify a matching github release.

+
auditors: Option

A list of people or entities that audited this smart contract, or links to pages where audit reports are hosted.
+Note that this field is self-reported by the author of the program and might not be accurate.

+
acknowledgments: Option

Text containing acknowledgments to security researchers who have previously found vulnerabilities in the project, or a link to it.

+
additional_information: Option

Text containing any additional information you want to provide, or a link to it.

+
\ No newline at end of file diff --git a/v0.21.0/standards/src12/abi.SRC12.html b/v0.21.0/standards/src12/abi.SRC12.html new file mode 100644 index 00000000..c69b7a83 --- /dev/null +++ b/v0.21.0/standards/src12/abi.SRC12.html @@ -0,0 +1,124 @@ +SRC12 in src12 - Sway
abi SRC12 {
+    /// Verifies that a newly deployed contract is the child of a contract factory and registers it.
+    ///
+    /// # Arguments
+    ///
+    /// * `child_contract`: [ContractId] - The deployed factory child contract of which to verify the bytecode root.
+    /// * `configurables`: [Option<ContractConfigurables>] - The configurables value set for the `child_contract`.
+    ///
+    /// # Returns
+    ///
+    /// * [Result<BytecodeRoot, str>] - Either the bytecode root of the newly registered contract or a `str` error message.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src12::SRC12;
+    ///
+    /// fn foo(my_src_12_contract: ContractId, my_deployed_contract: ContractId, my_configurables: Option<ContractConfigurables>) {
+    ///     let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    ///     src_12_contract_abi.register_contract(my_deployed_contract, my_configurables);
+    ///     assert(src_12_contract_abi.is_valid(my_deployed_contract));
+    /// }
+    /// ```
+    #[storage(read, write)]
+    fn register_contract(
+        child_contract: ContractId,
+        configurables: Option<ContractConfigurables>,
+    ) -> Result<BytecodeRoot, str>;
+    /// Returns a boolean representing the state of whether a contract is a valid child of the contract factory.
+    ///
+    /// # Arguments
+    ///
+    /// * `child_contract`: [ContractId] - The deployed factory child contract of which to check the registry status.
+    ///
+    /// # Returns
+    ///
+    /// * [bool] - `true` if the contract has registered and is valid, otherwise `false`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src12::SRC12;
+    ///
+    /// fn foo(my_src_12_contract: ContractId, my_deployed_contract: ContractId, my_configurables: Option<ContractConfigurables>) {
+    ///     let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    ///     src_12_contract_abi.register_contract(my_deployed_contract, my_configurables);
+    ///     assert(src_12_contract_abi.is_valid(my_deployed_contract));
+    /// }
+    /// ```
+    #[storage(read)]
+    fn is_valid(child_contract: ContractId) -> bool;
+    /// Returns the bytecode root of the default template contract.
+    ///
+    /// # Returns
+    ///
+    /// * [Option<BytecodeRoot>] - The bytecode root of the default template contract.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src12::SRC12;
+    /// use std::constants::ZERO_B256;
+    ///
+    /// fn foo(my_src_12_contract: ContractId) {
+    ///     let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    ///     let root = src_12_contract_abi.factory_bytecode_root();
+    ///     assert(root.unwrap() != ZERO_B256);
+    /// }
+    /// ```
+    #[storage(read)]
+    fn factory_bytecode_root() -> Option<BytecodeRoot>;
+}

Required Methods

Verifies that a newly deployed contract is the child of a contract factory and registers it.

+

Arguments

+
    +
  • child_contract: [ContractId] - The deployed factory child contract of which to verify the bytecode root.
  • +
  • configurables: [Option] - The configurables value set for the child_contract.
  • +
+

Returns

+
    +
  • [Result<BytecodeRoot, str>] - Either the bytecode root of the newly registered contract or a str error message.
  • +
+

Examples

+
use src12::SRC12;
+
+fn foo(my_src_12_contract: ContractId, my_deployed_contract: ContractId, my_configurables: Option<ContractConfigurables>) {
+    let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    src_12_contract_abi.register_contract(my_deployed_contract, my_configurables);
+    assert(src_12_contract_abi.is_valid(my_deployed_contract));
+}
+
+

Returns a boolean representing the state of whether a contract is a valid child of the contract factory.

+

Arguments

+
    +
  • child_contract: [ContractId] - The deployed factory child contract of which to check the registry status.
  • +
+

Returns

+
    +
  • [bool] - true if the contract has registered and is valid, otherwise false.
  • +
+

Examples

+
use src12::SRC12;
+
+fn foo(my_src_12_contract: ContractId, my_deployed_contract: ContractId, my_configurables: Option<ContractConfigurables>) {
+    let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    src_12_contract_abi.register_contract(my_deployed_contract, my_configurables);
+    assert(src_12_contract_abi.is_valid(my_deployed_contract));
+}
+
+

Returns the bytecode root of the default template contract.

+

Returns

+
    +
  • [Option] - The bytecode root of the default template contract.
  • +
+

Examples

+
use src12::SRC12;
+use std::constants::ZERO_B256;
+
+fn foo(my_src_12_contract: ContractId) {
+    let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    let root = src_12_contract_abi.factory_bytecode_root();
+    assert(root.unwrap() != ZERO_B256);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/standards/src12/abi.SRC12_Extension.html b/v0.21.0/standards/src12/abi.SRC12_Extension.html new file mode 100644 index 00000000..8f05e3d7 --- /dev/null +++ b/v0.21.0/standards/src12/abi.SRC12_Extension.html @@ -0,0 +1,45 @@ +SRC12_Extension in src12 - Sway
abi SRC12_Extension {
+    /// Return a registered contract factory child contract with specific implementation details specified by it's configurables.
+    ///
+    /// # Arguments
+    ///
+    /// * `configurables`: [Option<ContractConfigurables>] - The configurables value set for the `child_contract`.
+    ///
+    /// # Returns
+    ///
+    /// * [Option<ContractId>] - The id of the contract which has registered with the specified configurables.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src12::SRC12;
+    ///
+    /// fn foo(my_src_12_contract: ContractId, my_deployed_contract: ContractId, my_configurables: Option<ContractConfigurables>) {
+    ///     let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    ///     src_12_contract_abi.register_contract(my_deployed_contract, my_configurables);
+    ///     let result_contract_id = src_12_contract_abi.get_contract_id(my_configurables);
+    ///     assert(result_contract_id.unwrap() == my_deployed_contract);
+    /// }
+    /// ```
+    #[storage(read)]
+    fn get_contract_id(configurables: Option<ContractConfigurables>) -> Option<ContractId>;
+}

Required Methods

Return a registered contract factory child contract with specific implementation details specified by it’s configurables.

+

Arguments

+
    +
  • configurables: [Option] - The configurables value set for the child_contract.
  • +
+

Returns

+
    +
  • [Option] - The id of the contract which has registered with the specified configurables.
  • +
+

Examples

+
use src12::SRC12;
+
+fn foo(my_src_12_contract: ContractId, my_deployed_contract: ContractId, my_configurables: Option<ContractConfigurables>) {
+    let src_12_contract_abi = abi(SRC12, my_src_12_contract.bits());
+    src_12_contract_abi.register_contract(my_deployed_contract, my_configurables);
+    let result_contract_id = src_12_contract_abi.get_contract_id(my_configurables);
+    assert(result_contract_id.unwrap() == my_deployed_contract);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/standards/src12/index.html b/v0.21.0/standards/src12/index.html new file mode 100644 index 00000000..ee5f5c15 --- /dev/null +++ b/v0.21.0/standards/src12/index.html @@ -0,0 +1 @@ +src12 in standards - Sway

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/src20/abi.SRC20.html b/v0.21.0/standards/src20/abi.SRC20.html new file mode 100644 index 00000000..a2183ade --- /dev/null +++ b/v0.21.0/standards/src20/abi.SRC20.html @@ -0,0 +1,209 @@ +SRC20 in src20 - Sway
abi SRC20 {
+    /// Returns the total number of individual assets for a contract.
+    ///
+    /// # Returns
+    ///
+    /// * [u64] - The number of assets that this contract has minted.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src20::SRC20;
+    ///
+    /// fn foo(contract: ContractId) {
+    ///     let contract_abi = abi(SRC20, contract);
+    ///     let total_assets = contract_abi.total_assets();
+    ///     assert(total_assets != 0);
+    /// }
+    /// ```
+    #[storage(read)]
+    fn total_assets() -> u64;
+    /// Returns the total supply of coins for an asset.
+    ///
+    /// # Arguments
+    ///
+    /// * `asset`: [AssetId] - The asset of which to query the total supply.
+    ///
+    /// # Returns
+    ///
+    /// * [Option<u64>] - The total supply of coins for `asset`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src20::SRC20;
+    ///
+    /// fn foo(contract: ContractId, asset: AssetId) {
+    ///     let contract_abi = abi(SRC20, contract);
+    ///     let total_supply = contract_abi.total_supply(asset);
+    ///     assert(total_supply.unwrap() != 0);
+    /// }
+    /// ```
+    #[storage(read)]
+    fn total_supply(asset: AssetId) -> Option<u64>;
+    /// Returns the name of the asset, such as “Ether”.
+    ///
+    /// # Arguments
+    ///
+    /// * `asset`: [AssetId] - The asset of which to query the name.
+    ///
+    /// # Returns
+    ///
+    /// * [Option<String>] - The name of `asset`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src20::SRC20;
+    /// use std::string::String;
+    ///
+    /// fn foo(contract: ContractId, asset: AssetId) {
+    ///     let contract_abi = abi(SRC20, contract);
+    ///     let name = contract_abi.name(asset);
+    ///     assert(name.is_some());
+    /// }
+    /// ```
+    #[storage(read)]
+    fn name(asset: AssetId) -> Option<String>;
+    /// Returns the symbol of the asset, such as “ETH”.
+    ///
+    /// # Arguments
+    ///
+    /// * `asset`: [AssetId] - The asset of which to query the symbol.
+    ///
+    /// # Returns
+    ///
+    /// * [Option<String>] - The symbol of `asset`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src20::SRC20;
+    /// use std::string::String;
+    ///
+    /// fn foo(contract: ContractId, asset: AssetId) {
+    ///     let contract_abi = abi(SRC20, contract);
+    ///     let symbol = contract_abi.symbol(asset);
+    ///     assert(symbol.is_some());
+    /// }
+    /// ```
+    #[storage(read)]
+    fn symbol(asset: AssetId) -> Option<String>;
+    /// Returns the number of decimals the asset uses.
+    ///
+    /// # Additional Information
+    ///
+    /// e.g. 8, means to divide the coin amount by 100000000 to get its user representation.
+    ///
+    /// # Arguments
+    ///
+    /// * `asset`: [AssetId] - The asset of which to query the decimals.
+    ///
+    /// # Returns
+    ///
+    /// * [Option<u8>] - The decimal precision used by `asset`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src20::SRC20;
+    ///
+    /// fn foo(contract: ContractId, asset: AssedId) {
+    ///     let contract_abi = abi(SRC20, contract);
+    ///     let decimals = contract_abi.decimals(asset);
+    ///     assert(decimals.unwrap() == 8u8);
+    /// }
+    /// ```
+    #[storage(read)]
+    fn decimals(asset: AssetId) -> Option<u8>;
+}

Required Methods

Returns the total number of individual assets for a contract.

+

Returns

+
    +
  • [u64] - The number of assets that this contract has minted.
  • +
+

Examples

+
use src20::SRC20;
+
+fn foo(contract: ContractId) {
+    let contract_abi = abi(SRC20, contract);
+    let total_assets = contract_abi.total_assets();
+    assert(total_assets != 0);
+}
+
+

Returns the total supply of coins for an asset.

+

Arguments

+
    +
  • asset: [AssetId] - The asset of which to query the total supply.
  • +
+

Returns

+
    +
  • [Option] - The total supply of coins for asset.
  • +
+

Examples

+
use src20::SRC20;
+
+fn foo(contract: ContractId, asset: AssetId) {
+    let contract_abi = abi(SRC20, contract);
+    let total_supply = contract_abi.total_supply(asset);
+    assert(total_supply.unwrap() != 0);
+}
+
+

Returns the name of the asset, such as “Ether”.

+

Arguments

+
    +
  • asset: [AssetId] - The asset of which to query the name.
  • +
+

Returns

+
    +
  • [Option] - The name of asset.
  • +
+

Examples

+
use src20::SRC20;
+use std::string::String;
+
+fn foo(contract: ContractId, asset: AssetId) {
+    let contract_abi = abi(SRC20, contract);
+    let name = contract_abi.name(asset);
+    assert(name.is_some());
+}
+
+

Returns the symbol of the asset, such as “ETH”.

+

Arguments

+
    +
  • asset: [AssetId] - The asset of which to query the symbol.
  • +
+

Returns

+
    +
  • [Option] - The symbol of asset.
  • +
+

Examples

+
use src20::SRC20;
+use std::string::String;
+
+fn foo(contract: ContractId, asset: AssetId) {
+    let contract_abi = abi(SRC20, contract);
+    let symbol = contract_abi.symbol(asset);
+    assert(symbol.is_some());
+}
+
+

Returns the number of decimals the asset uses.

+

Additional Information

+

e.g. 8, means to divide the coin amount by 100000000 to get its user representation.

+

Arguments

+
    +
  • asset: [AssetId] - The asset of which to query the decimals.
  • +
+

Returns

+
    +
  • [Option] - The decimal precision used by asset.
  • +
+

Examples

+
use src20::SRC20;
+
+fn foo(contract: ContractId, asset: AssedId) {
+    let contract_abi = abi(SRC20, contract);
+    let decimals = contract_abi.decimals(asset);
+    assert(decimals.unwrap() == 8u8);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/standards/src20/index.html b/v0.21.0/standards/src20/index.html new file mode 100644 index 00000000..9690116b --- /dev/null +++ b/v0.21.0/standards/src20/index.html @@ -0,0 +1 @@ +src20 in standards - Sway

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/src3/abi.SRC3.html b/v0.21.0/standards/src3/abi.SRC3.html new file mode 100644 index 00000000..3322c56c --- /dev/null +++ b/v0.21.0/standards/src3/abi.SRC3.html @@ -0,0 +1,87 @@ +SRC3 in src3 - Sway
abi SRC3 {
+    /// Mints new assets using the `vault_sub_id` sub-identifier.
+    ///
+    /// # Arguments
+    ///
+    /// * `recipient`: [Identity] - The user to which the newly minted asset is transferred to.
+    /// * `vault_sub_id`: [SubId] - The sub-identifier of the newly minted asset.
+    /// * `amount`: [u64] - The quantity of coins to mint.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src3::SRC3;
+    ///
+    /// fn foo(contract_id: ContractId) {
+    ///     let contract_abi = abi(SR3, contract);
+    ///     contract_abi.mint(Identity::ContractId(contract_id), ZERO_B256, 100);
+    /// }
+    /// ```
+    #[storage(read, write)]
+    fn mint(recipient: Identity, vault_sub_id: SubId, amount: u64);
+    /// Burns assets sent with the given `vault_sub_id`.
+    ///
+    /// # Additional Information
+    ///
+    /// NOTE: The sha-256 hash of `(ContractId, SubId)` must match the `AssetId` where `ContractId` is the id of
+    /// the implementing contract and `SubId` is the given `vault_sub_id` argument.
+    ///
+    /// # Arguments
+    ///
+    /// * `vault_sub_id`: [SubId] - The sub-identifier of the asset to burn.
+    /// * `amount`: [u64] - The quantity of coins to burn.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src3::SRC3;
+    ///
+    /// fn foo(contract_id: ContractId, asset_id: AssetId) {
+    ///     let contract_abi = abi(SR3, contract_id);
+    ///     contract_abi {
+    ///         gas: 10000,
+    ///         coins: 100,
+    ///         asset_id: asset_id,
+    ///     }.burn(ZERO_B256, 100);
+    /// }
+    /// ```
+    #[payable]
+    #[storage(read, write)]
+    fn burn(vault_sub_id: SubId, amount: u64);
+}

Required Methods

Mints new assets using the vault_sub_id sub-identifier.

+

Arguments

+
    +
  • recipient: [Identity] - The user to which the newly minted asset is transferred to.
  • +
  • vault_sub_id: [SubId] - The sub-identifier of the newly minted asset.
  • +
  • amount: [u64] - The quantity of coins to mint.
  • +
+

Examples

+
use src3::SRC3;
+
+fn foo(contract_id: ContractId) {
+    let contract_abi = abi(SR3, contract);
+    contract_abi.mint(Identity::ContractId(contract_id), ZERO_B256, 100);
+}
+
+

Burns assets sent with the given vault_sub_id.

+

Additional Information

+

NOTE: The sha-256 hash of (ContractId, SubId) must match the AssetId where ContractId is the id of
+the implementing contract and SubId is the given vault_sub_id argument.

+

Arguments

+
    +
  • vault_sub_id: [SubId] - The sub-identifier of the asset to burn.
  • +
  • amount: [u64] - The quantity of coins to burn.
  • +
+

Examples

+
use src3::SRC3;
+
+fn foo(contract_id: ContractId, asset_id: AssetId) {
+    let contract_abi = abi(SR3, contract_id);
+    contract_abi {
+        gas: 10000,
+        coins: 100,
+        asset_id: asset_id,
+    }.burn(ZERO_B256, 100);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/standards/src3/index.html b/v0.21.0/standards/src3/index.html new file mode 100644 index 00000000..558645ce --- /dev/null +++ b/v0.21.0/standards/src3/index.html @@ -0,0 +1 @@ +src3 in standards - Sway

Module standards::src3

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/src5/abi.SRC5.html b/v0.21.0/standards/src5/abi.SRC5.html new file mode 100644 index 00000000..61f225af --- /dev/null +++ b/v0.21.0/standards/src5/abi.SRC5.html @@ -0,0 +1,35 @@ +SRC5 in src5 - Sway
abi SRC5 {
+    /// Returns the owner.
+    ///
+    /// # Return Values
+    ///
+    /// * [State] - Represents the state of ownership for this contract.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// fn foo() {
+    ///     match owner() {
+    ///         State::Uninitalized => log("The ownership is uninitalized"),
+    ///         State::Initialized(owner) => log("The ownership is initalized"),
+    ///         State::Revoked => log("The ownership is revoked"),
+    ///     }
+    /// }
+    /// ```
+    #[storage(read)]
+    fn owner() -> State;
+}

Required Methods

Returns the owner.

+

Return Values

+
    +
  • [State] - Represents the state of ownership for this contract.
  • +
+

Examples

+
fn foo() {
+    match owner() {
+        State::Uninitalized => log("The ownership is uninitalized"),
+        State::Initialized(owner) => log("The ownership is initalized"),
+        State::Revoked => log("The ownership is revoked"),
+    }
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/standards/src5/enum.AccessError.html b/v0.21.0/standards/src5/enum.AccessError.html new file mode 100644 index 00000000..c90e99e5 --- /dev/null +++ b/v0.21.0/standards/src5/enum.AccessError.html @@ -0,0 +1,6 @@ +AccessError in src5 - Sway
pub enum AccessError {
+    /// Emitted when the caller is not the owner of the contract.
+    NotOwner: (),
+}
Expand description

Error log for when access is denied.

+

Variants

NotOwner: ()

Emitted when the caller is not the owner of the contract.

+
\ No newline at end of file diff --git a/v0.21.0/standards/src5/enum.State.html b/v0.21.0/standards/src5/enum.State.html new file mode 100644 index 00000000..a4ea25e9 --- /dev/null +++ b/v0.21.0/standards/src5/enum.State.html @@ -0,0 +1,12 @@ +State in src5 - Sway
pub enum State {
+    /// The ownership has not been set.
+    Uninitialized: (),
+    /// The user which has been given ownership.
+    Initialized: Identity,
+    /// The ownership has been given up and can never be set again.
+    Revoked: (),
+}
Expand description

Determines the state of ownership.

+

Variants

Uninitialized: ()

The ownership has not been set.

+

Initialized: Identity

The user which has been given ownership.

+

Revoked: ()

The ownership has been given up and can never be set again.

+
\ No newline at end of file diff --git a/v0.21.0/standards/src5/index.html b/v0.21.0/standards/src5/index.html new file mode 100644 index 00000000..8c847fad --- /dev/null +++ b/v0.21.0/standards/src5/index.html @@ -0,0 +1,3 @@ +src5 in standards - Sway

Module standards::src5

Enums

Error log for when access is denied.

+

Determines the state of ownership.

+

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/src6/abi.SRC6.html b/v0.21.0/standards/src6/abi.SRC6.html new file mode 100644 index 00000000..fbf37653 --- /dev/null +++ b/v0.21.0/standards/src6/abi.SRC6.html @@ -0,0 +1,184 @@ +SRC6 in src6 - Sway
abi SRC6 {
+    /// Deposits assets into the contract and mints shares to the receiver.
+    ///
+    /// # Additional Information
+    ///
+    /// * Assets must be forwarded to the contract in the contract call.
+    ///
+    /// # Arguments
+    ///
+    /// * `receiver`: [Identity] - The receiver of the shares.
+    /// * `vault_sub_id`: [SubId] - The SubId of the vault.
+    ///
+    /// # Returns
+    ///
+    /// * [u64] - The amount of shares minted.
+    ///
+    /// # Reverts
+    ///
+    /// * If the asset is not supported by the contract.
+    /// * If the amount of assets forwarded to the contract is zero.
+    /// * The user crosses any global or user specific deposit limits.
+    #[payable]
+    #[storage(read, write)]
+    fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64;
+    /// Burns shares from the sender and transfers assets to the receiver.
+    ///
+    /// # Additional Information
+    ///
+    /// * Shares must be forwarded to the contract in the contract call.
+    ///
+    /// # Arguments
+    ///
+    /// * `receiver`: [Identity] - The receiver of the assets.
+    /// * `underlying_asset`: [AssetId] - The asset for which the shares should be burned.
+    /// * `vault_sub_id`: [SubId] - The SubId of the vault.
+    ///
+    /// # Returns
+    ///
+    /// * [u64] - The amount of assets transferred.
+    ///
+    /// # Reverts
+    ///
+    /// * If the asset is not supported by the contract.
+    /// * If the amount of shares is zero.
+    /// * If the transferred shares do not corresspond to the given asset.
+    /// * The user crosses any global or user specific withdrawal limits.
+    #[payable]
+    #[storage(read, write)]
+    fn withdraw(
+        receiver: Identity,
+        underlying_asset: AssetId,
+        vault_sub_id: SubId,
+    ) -> u64;
+    /// Returns the amount of managed assets of the given asset.
+    ///
+    /// # Arguments
+    ///
+    /// * `underlying_asset`: [AssetId] - The asset for which the amount of managed assets should be returned.
+    /// * `vault_sub_id`: [SubId] - The SubId of the vault.
+    ///
+    /// # Returns
+    ///
+    /// * [u64] - The amount of managed assets of the given asset.
+    #[storage(read)]
+    fn managed_assets(underlying_asset: AssetId, vault_sub_id: SubId) -> u64;
+    /// Returns the maximum amount of assets that can be deposited into the contract, for the given asset.
+    ///
+    /// # Additional Information
+    ///
+    /// Must account for any user or global limits.
+    ///
+    /// # Arguments
+    ///
+    /// * `receiver`: [Identity] - The hypothetical receiver of the shares.
+    /// * `underlying_asset`: [AssetId] - The asset for which the maximum amount of depositable assets should be returned.
+    /// * `vault_sub_id`: [SubId] - The SubId of the vault.
+    ///
+    /// # Returns
+    ///
+    /// * [Some(u64)] - The maximum amount of assets that can be deposited into the contract, for the given asset.
+    /// * [None] - If the asset is not supported by the contract.
+    #[storage(read)]
+    fn max_depositable(
+        receiver: Identity,
+        underlying_asset: AssetId,
+        vault_sub_id: SubId,
+    ) -> Option<u64>;
+    /// Returns the maximum amount of assets that can be withdrawn from the contract, for the given asset.
+    ///
+    /// # Additional Information
+    ///
+    /// Must account for any global limits.
+    ///
+    /// # Arguments
+    ///
+    /// * `underlying_asset`: [AssetId] - The asset for which the maximum amount of withdrawable assets should be returned.
+    /// * `vault_sub_id`: [SubId] - The SubId of the vault.
+    ///
+    /// # Returns
+    ///
+    /// * [Some(u64)] - The maximum amount of assets that can be withdrawn from the contract, for the given asset.
+    /// * [None] - If the asset is not supported by the contract.
+    #[storage(read)]
+    fn max_withdrawable(underlying_asset: AssetId, vault_sub_id: SubId) -> Option<u64>;
+}

Required Methods

Deposits assets into the contract and mints shares to the receiver.

+

Additional Information

+
    +
  • Assets must be forwarded to the contract in the contract call.
  • +
+

Arguments

+
    +
  • receiver: [Identity] - The receiver of the shares.
  • +
  • vault_sub_id: [SubId] - The SubId of the vault.
  • +
+

Returns

+
    +
  • [u64] - The amount of shares minted.
  • +
+

Reverts

+
    +
  • If the asset is not supported by the contract.
  • +
  • If the amount of assets forwarded to the contract is zero.
  • +
  • The user crosses any global or user specific deposit limits.
  • +
+

Burns shares from the sender and transfers assets to the receiver.

+

Additional Information

+
    +
  • Shares must be forwarded to the contract in the contract call.
  • +
+

Arguments

+
    +
  • receiver: [Identity] - The receiver of the assets.
  • +
  • underlying_asset: [AssetId] - The asset for which the shares should be burned.
  • +
  • vault_sub_id: [SubId] - The SubId of the vault.
  • +
+

Returns

+
    +
  • [u64] - The amount of assets transferred.
  • +
+

Reverts

+
    +
  • If the asset is not supported by the contract.
  • +
  • If the amount of shares is zero.
  • +
  • If the transferred shares do not corresspond to the given asset.
  • +
  • The user crosses any global or user specific withdrawal limits.
  • +
+

Returns the amount of managed assets of the given asset.

+

Arguments

+
    +
  • underlying_asset: [AssetId] - The asset for which the amount of managed assets should be returned.
  • +
  • vault_sub_id: [SubId] - The SubId of the vault.
  • +
+

Returns

+
    +
  • [u64] - The amount of managed assets of the given asset.
  • +
+

Returns the maximum amount of assets that can be deposited into the contract, for the given asset.

+

Additional Information

+

Must account for any user or global limits.

+

Arguments

+
    +
  • receiver: [Identity] - The hypothetical receiver of the shares.
  • +
  • underlying_asset: [AssetId] - The asset for which the maximum amount of depositable assets should be returned.
  • +
  • vault_sub_id: [SubId] - The SubId of the vault.
  • +
+

Returns

+
    +
  • [Some(u64)] - The maximum amount of assets that can be deposited into the contract, for the given asset.
  • +
  • [None] - If the asset is not supported by the contract.
  • +
+

Returns the maximum amount of assets that can be withdrawn from the contract, for the given asset.

+

Additional Information

+

Must account for any global limits.

+

Arguments

+
    +
  • underlying_asset: [AssetId] - The asset for which the maximum amount of withdrawable assets should be returned.
  • +
  • vault_sub_id: [SubId] - The SubId of the vault.
  • +
+

Returns

+
    +
  • [Some(u64)] - The maximum amount of assets that can be withdrawn from the contract, for the given asset.
  • +
  • [None] - If the asset is not supported by the contract.
  • +
+
\ No newline at end of file diff --git a/v0.21.0/standards/src6/index.html b/v0.21.0/standards/src6/index.html new file mode 100644 index 00000000..2af50c40 --- /dev/null +++ b/v0.21.0/standards/src6/index.html @@ -0,0 +1,3 @@ +src6 in standards - Sway

Module standards::src6

Structs

Event logged when a deposit is made.

+

Event logged when a withdrawal is made.

+

Abi

\ No newline at end of file diff --git a/v0.21.0/standards/src6/struct.Deposit.html b/v0.21.0/standards/src6/struct.Deposit.html new file mode 100644 index 00000000..287cb03e --- /dev/null +++ b/v0.21.0/standards/src6/struct.Deposit.html @@ -0,0 +1,21 @@ +Deposit in src6 - Sway
pub struct Deposit {
+    /// The caller of the deposit function.
+    pub caller: Identity,
+    /// The receiver of the deposit.
+    pub receiver: Identity,
+    /// The asset being deposited.
+    pub underlying_asset: AssetId,
+    /// The SubId of the vault.
+    pub vault_sub_id: SubId,
+    /// The amount of assets being deposited.
+    pub deposited_amount: u64,
+    /// The amount of shares being minted.
+    pub minted_shares: u64,
+}
Expand description

Event logged when a deposit is made.

+

Fields

caller: Identity

The caller of the deposit function.

+
receiver: Identity

The receiver of the deposit.

+
underlying_asset: AssetId

The asset being deposited.

+
vault_sub_id: SubId

The SubId of the vault.

+
deposited_amount: u64

The amount of assets being deposited.

+
minted_shares: u64

The amount of shares being minted.

+
\ No newline at end of file diff --git a/v0.21.0/standards/src6/struct.Withdraw.html b/v0.21.0/standards/src6/struct.Withdraw.html new file mode 100644 index 00000000..b5800c2c --- /dev/null +++ b/v0.21.0/standards/src6/struct.Withdraw.html @@ -0,0 +1,21 @@ +Withdraw in src6 - Sway
pub struct Withdraw {
+    /// The caller of the withdrawal function.
+    pub caller: Identity,
+    /// The receiver of the withdrawal.
+    pub receiver: Identity,
+    /// The asset being withdrawn.
+    pub underlying_asset: AssetId,
+    /// The SubId of the vault.
+    pub vault_sub_id: SubId,
+    /// The amount of assets being withdrawn.
+    pub withdrawn_amount: u64,
+    /// The amount of shares being burned.
+    pub burned_shares: u64,
+}
Expand description

Event logged when a withdrawal is made.

+

Fields

caller: Identity

The caller of the withdrawal function.

+
receiver: Identity

The receiver of the withdrawal.

+
underlying_asset: AssetId

The asset being withdrawn.

+
vault_sub_id: SubId

The SubId of the vault.

+
withdrawn_amount: u64

The amount of assets being withdrawn.

+
burned_shares: u64

The amount of shares being burned.

+
\ No newline at end of file diff --git a/v0.21.0/standards/src7/abi.SRC7.html b/v0.21.0/standards/src7/abi.SRC7.html new file mode 100644 index 00000000..cf31e111 --- /dev/null +++ b/v0.21.0/standards/src7/abi.SRC7.html @@ -0,0 +1,49 @@ +SRC7 in src7 - Sway
abi SRC7 {
+    /// Returns metadata for the corresponding `asset` and `key`.
+    ///
+    /// # Arguments
+    ///
+    /// * `asset`: [AssetId] - The asset of which to query the metadata.
+    /// * `key`: [String] - The key to the specific metadata.
+    ///
+    /// # Returns
+    ///
+    /// * [Option<Metadata>] - `Some` metadata that corresponds to the `key` or `None`.
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use src7::{SRC7, Metadata};
+    /// use std::string::String;
+    ///
+    /// fn foo(contract_id: ContractId, asset: AssetId) {
+    ///     let contract_abi = abi(SRC7, contract_id);
+    ///     let key = String::from_ascii_str("image");
+    ///     let data = contract_abi.metadata(asset, key);
+    ///     assert(data.is_some());
+    /// }
+    /// ```
+    #[storage(read)]
+    fn metadata(asset: AssetId, key: String) -> Option<Metadata>;
+}

Required Methods

Returns metadata for the corresponding asset and key.

+

Arguments

+
    +
  • asset: [AssetId] - The asset of which to query the metadata.
  • +
  • key: [String] - The key to the specific metadata.
  • +
+

Returns

+
    +
  • [Option] - Some metadata that corresponds to the key or None.
  • +
+

Examples

+
use src7::{SRC7, Metadata};
+use std::string::String;
+
+fn foo(contract_id: ContractId, asset: AssetId) {
+    let contract_abi = abi(SRC7, contract_id);
+    let key = String::from_ascii_str("image");
+    let data = contract_abi.metadata(asset, key);
+    assert(data.is_some());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/standards/src7/enum.Metadata.html b/v0.21.0/standards/src7/enum.Metadata.html new file mode 100644 index 00000000..519e21f6 --- /dev/null +++ b/v0.21.0/standards/src7/enum.Metadata.html @@ -0,0 +1,14 @@ +Metadata in src7 - Sway
pub enum Metadata {
+    // Used when the stored metadata is a `b256`.
+    B256: b256,
+    /// Used when the stored metadata is `Bytes`.
+    Bytes: Bytes,
+    /// Used when the stored metadata is a `u64`.
+    Int: u64,
+    /// Used when the stored metadata is a `String`.
+    String: String,
+}
Expand description

Universal return type for metadata.

+

Variants

B256: b256

Bytes: Bytes

Used when the stored metadata is Bytes.

+

Int: u64

Used when the stored metadata is a u64.

+

String: String

Used when the stored metadata is a String.

+
\ No newline at end of file diff --git a/v0.21.0/standards/src7/index.html b/v0.21.0/standards/src7/index.html new file mode 100644 index 00000000..f5d9c8eb --- /dev/null +++ b/v0.21.0/standards/src7/index.html @@ -0,0 +1,2 @@ +src7 in standards - Sway

Module standards::src7

Enums

Universal return type for metadata.

+

Abi

\ No newline at end of file diff --git a/v0.21.0/static.files/FiraSans-Medium.woff2 b/v0.21.0/static.files/FiraSans-Medium.woff2 new file mode 100644 index 00000000..7a1e5fc5 Binary files /dev/null and b/v0.21.0/static.files/FiraSans-Medium.woff2 differ diff --git a/v0.21.0/static.files/FiraSans-Regular.woff2 b/v0.21.0/static.files/FiraSans-Regular.woff2 new file mode 100644 index 00000000..e766e06c Binary files /dev/null and b/v0.21.0/static.files/FiraSans-Regular.woff2 differ diff --git a/v0.21.0/static.files/NanumBarunGothic.ttf.woff2 b/v0.21.0/static.files/NanumBarunGothic.ttf.woff2 new file mode 100644 index 00000000..1866ad4b Binary files /dev/null and b/v0.21.0/static.files/NanumBarunGothic.ttf.woff2 differ diff --git a/v0.21.0/static.files/SourceCodePro-It.ttf.woff2 b/v0.21.0/static.files/SourceCodePro-It.ttf.woff2 new file mode 100644 index 00000000..462c34ef Binary files /dev/null and b/v0.21.0/static.files/SourceCodePro-It.ttf.woff2 differ diff --git a/v0.21.0/static.files/SourceCodePro-Regular.ttf.woff2 b/v0.21.0/static.files/SourceCodePro-Regular.ttf.woff2 new file mode 100644 index 00000000..10b558e0 Binary files /dev/null and b/v0.21.0/static.files/SourceCodePro-Regular.ttf.woff2 differ diff --git a/v0.21.0/static.files/SourceCodePro-Semibold.ttf.woff2 b/v0.21.0/static.files/SourceCodePro-Semibold.ttf.woff2 new file mode 100644 index 00000000..5ec64eef Binary files /dev/null and b/v0.21.0/static.files/SourceCodePro-Semibold.ttf.woff2 differ diff --git a/v0.21.0/static.files/SourceSerif4-Bold.ttf.woff2 b/v0.21.0/static.files/SourceSerif4-Bold.ttf.woff2 new file mode 100644 index 00000000..db57d214 Binary files /dev/null and b/v0.21.0/static.files/SourceSerif4-Bold.ttf.woff2 differ diff --git a/v0.21.0/static.files/SourceSerif4-It.ttf.woff2 b/v0.21.0/static.files/SourceSerif4-It.ttf.woff2 new file mode 100644 index 00000000..1cbc021a Binary files /dev/null and b/v0.21.0/static.files/SourceSerif4-It.ttf.woff2 differ diff --git a/v0.21.0/static.files/SourceSerif4-Regular.ttf.woff2 b/v0.21.0/static.files/SourceSerif4-Regular.ttf.woff2 new file mode 100644 index 00000000..2db73fe2 Binary files /dev/null and b/v0.21.0/static.files/SourceSerif4-Regular.ttf.woff2 differ diff --git a/v0.21.0/static.files/ayu.css b/v0.21.0/static.files/ayu.css new file mode 100644 index 00000000..47703d1a --- /dev/null +++ b/v0.21.0/static.files/ayu.css @@ -0,0 +1,472 @@ +:root { + --main-background-color: #0f1419; + --main-color: #c5c5c5; + --settings-input-color: #ffb454; + --sidebar-background-color: #14191f; + --sidebar-background-color-hover: rgba(70, 70, 70, 0.33); + --code-block-background-color: #191f26; + --scrollbar-track-background-color: transparent; + --scrollbar-thumb-background-color: #5c6773; + --scrollbar-color: #5c6773 #24292f; + --headings-border-bottom-color: #5c6773; +} +.slider { + background-color: #ccc; +} +.slider:before { + background-color: white; +} +input:focus + .slider { + box-shadow: 0 0 0 2px #0a84ff, 0 0 0 6px rgba(10, 132, 255, 0.3); +} +h1, +h2, +h3, +h4 { + color: white; +} +h1.fqn a { + color: #fff; +} +h4 { + border: none; +} +.docblock code { + color: #ffb454; +} +.code-header { + color: #e6e1cf; + margin-left: 1em; +} +.docblock pre > code, +pre > code { + color: #e6e1cf; +} +span code { + color: #e6e1cf; +} +.docblock a > code { + color: #39afd7 !important; +} +pre, +.swaydoc.source .example-wrap { + color: #e6e1cf; +} +.sway-logo { + filter: drop-shadow(1px 0 0px #fff) drop-shadow(0 1px 0 #fff) + drop-shadow(-1px 0 0 #fff) drop-shadow(0 -1px 0 #fff); +} +.sidebar .current, +.sidebar a:hover { + background-color: transparent; + color: #ffb44c; +} +.sidebar-elems .location { + color: #ff7733; +} +.line-numbers span { + color: #5c6773; +} +.line-numbers .line-highlighted { + color: #708090; + background-color: rgba(255, 236, 164, 0.06); + padding-right: 4px; + border-right: 1px solid #ffb44c; +} +.docblock table td, +.docblock table th { + border-color: #5c6773; +} +.content .item-info::before { + color: #ccc; +} +.content span.foreigntype, +.content a.foreigntype { + color: #ffa0a5; +} +.content span.union, +.content a.union { + color: #ffa0a5; +} +.content span.constant, +.content a.constant, +.content span.static, +.content a.static { + color: #39afd7; +} +.content span.primitive, +.content a.primitive { + color: #ffa0a5; +} +.content span.traitalias, +.content a.traitalias { + color: #39afd7; +} +.content span.keyword, +.content a.keyword { + color: #39afd7; +} +.content span.externcrate, +.content span.mod, +.content a.mod { + color: #39afd7; +} +.content span.struct, +.content a.struct { + color: #ffa0a5; +} +.content span.enum, +.content a.enum { + color: #ffa0a5; +} +.content span.trait, +.content a.trait { + color: #39afd7; +} +.content span.type, +.content a.type { + color: #39afd7; +} +.content span.type, +.content a.type, +.block a.current.type { + color: #39afd7; +} +.content span.associatedtype, +.content a.associatedtype, +.block a.current.associatedtype { + color: #39afd7; +} +.content span.fn, +.content a.fn, +.content span.method, +.content a.method, +.content span.tymethod, +.content a.tymethod, +.content .fnname { + color: #fdd687; +} +.content span.attr, +.content a.attr, +.content span.derive, +.content a.derive, +.content span.macro, +.content a.macro { + color: #a37acc; +} +.sidebar a.current.type { + color: #53b1db; +} +.sidebar a.current.associatedtype { + color: #53b1db; +} +pre.sway .comment { + color: #788797; +} +pre.sway .doccomment { + color: #a1ac88; +} +nav.main .current { + border-top-color: #5c6773; + border-bottom-color: #5c6773; +} +nav.main .separator { + border: 1px solid #5c6773; +} +a { + color: #c5c5c5; +} +.sidebar h2 a, +.sidebar h3 a { + color: white; +} + + +body.source .example-wrap pre.sway a { + background: #333; +} +details.swaydoc-toggle > summary.hideme > span, +details.swaydoc-toggle > summary::before { + color: #999; +} +details.swaydoc-toggle > summary::before { + filter: invert(100%); +} +#crate-search, +.search-input { + background-color: #141920; + border-color: #424c57; +} +#crate-search { + border-color: #424c57 !important; +} +.search-input { + color: #ffffff; +} +.module-item .stab, +.import-item .stab { + color: #000; +} + +.stab.unstable, +.stab.deprecated, +.stab.portability, +.stab.empty-impl, +.stab.must_implement { + color: #c5c5c5; + background: #314559 !important; + border-style: none !important; + border-radius: 4px; + padding: 3px 6px 3px 6px; +} +.stab.portability > code { + color: #e6e1cf; + background: none; +} +.rightside, +.out-of-band { + color: grey; +} +.result-name .primitive > i, +.result-name .keyword > i { + color: #788797; +} +.line-numbers :target { + background-color: transparent; +} +pre.sway .number, +pre.sway .string { + color: #b8cc52; +} +pre.sway .kw, +pre.sway .kw-2, +pre.sway .prelude-ty, +pre.sway .bool-val, +pre.sway .prelude-val, +pre.sway .op, +pre.sway .lifetime { + color: #ff7733; +} +pre.sway .macro, +pre.sway .macro-nonterminal { + color: #a37acc; +} +pre.sway .question-mark { + color: #ff9011; +} +pre.sway .self { + color: #36a3d9; + font-style: italic; +} +pre.sway .attribute { + color: #e6e1cf; +} +pre.sway .attribute .ident, +pre.sway .attribute .op { + color: #e6e1cf; +} +.example-wrap > pre.line-number { + color: #5c67736e; + border: none; +} +a.test-arrow { + font-size: 100%; + color: #788797; + border-radius: 4px; + background-color: rgba(57, 175, 215, 0.09); +} +a.test-arrow:hover { + background-color: rgba(57, 175, 215, 0.368); + color: #c5c5c5; +} +.toggle-label, +.code-attribute { + color: #999; +} +:target { + background: rgba(255, 236, 164, 0.06); + border-right: 3px solid rgba(255, 180, 76, 0.85); +} +pre.compile_fail { + border-left: 2px solid rgba(255, 0, 0, 0.4); +} +pre.compile_fail:hover, +.information:hover + pre.compile_fail { + border-left: 2px solid #f00; +} +pre.should_panic { + border-left: 2px solid rgba(255, 0, 0, 0.4); +} +pre.should_panic:hover, +.information:hover + pre.should_panic { + border-left: 2px solid #f00; +} +pre.ignore { + border-left: 2px solid rgba(255, 142, 0, 0.6); +} +pre.ignore:hover, +.information:hover + pre.ignore { + border-left: 2px solid #ff9200; +} +.tooltip.compile_fail { + color: rgba(255, 0, 0, 0.5); +} +.information > .compile_fail:hover { + color: #f00; +} +.tooltip.should_panic { + color: rgba(255, 0, 0, 0.5); +} +.information > .should_panic:hover { + color: #f00; +} +.tooltip.ignore { + color: rgba(255, 142, 0, 0.6); +} +.information > .ignore:hover { + color: #ff9200; +} +.search-failed a { + color: #39afd7; +} +.tooltip::after { + background-color: #314559; + color: #c5c5c5; + border: 1px solid #5c6773; +} +.tooltip::before { + border-color: transparent #314559 transparent transparent; +} +.notable-traits-tooltiptext { + background-color: #314559; + border-color: #5c6773; +} +.notable-traits-tooltiptext .notable { + border-bottom-color: #5c6773; +} +#titles > button.selected { + background-color: #141920 !important; + border-bottom: 1px solid #ffb44c !important; + border-top: none; +} +#titles > button:not(.selected) { + background-color: transparent !important; + border: none; +} +#titles > button:hover { + border-bottom: 1px solid rgba(242, 151, 24, 0.3); +} +#titles > button > div.count { + color: #888; +} + +@media (max-width: 700px) { + .sidebar-elems { + border-right-color: #5c6773; + } +} +kbd { + color: #c5c5c5; + background-color: #314559; + border-color: #5c6773; + border-bottom-color: #5c6773; + box-shadow: inset 0 -1px 0 #5c6773; +} +#settings-menu > a, +#help-button > a { + border-color: #5c6773; + background-color: #0f1419; + color: #fff; +} +#settings-menu > a img { + filter: invert(100); +} +.popover, +.popover::before, +#help-button span.top, +#help-button span.bottom { + border-color: #5c6773; +} +#copy-path { + color: #fff; +} +#copy-path > img { + filter: invert(70%); +} +#copy-path:hover > img { + filter: invert(100%); +} +#settings-menu > a:hover, +#settings-menu > a:focus, +#help-button > a:hover, +#help-button > a:focus { + border-color: #e0e0e0; +} +#theme-choices { + border-color: #5c6773; + background-color: #0f1419; +} +#theme-choices > button:not(:first-child) { + border-top-color: #5c6773; +} +#theme-choices > button:hover, +#theme-choices > button:focus { + background-color: rgba(110, 110, 110, 0.33); +} +#source-sidebar > .title { + color: #fff; + border-bottom-color: #5c6773; +} +#source-sidebar div.files > a:hover, +details.dir-entry summary:hover, +#source-sidebar div.files > a:focus, +details.dir-entry summary:focus { + background-color: #14191f; + color: #ffb44c; +} +#source-sidebar div.files > a.selected { + background-color: #14191f; + color: #ffb44c; +} +.scraped-example-list .scrape-help { + border-color: #aaa; + color: #eee; +} +.scraped-example-list .scrape-help:hover { + border-color: white; + color: white; +} +.more-examples-toggle summary, +.more-examples-toggle .hide-more { + color: #999; +} +.scraped-example .example-wrap .sway span.highlight { + background: rgb(91, 59, 1); +} +.scraped-example .example-wrap .sway span.highlight.focus { + background: rgb(124, 75, 15); +} +.scraped-example:not(.expanded) .code-wrapper:before { + background: linear-gradient( + to bottom, + rgba(15, 20, 25, 1), + rgba(15, 20, 25, 0) + ); +} +.scraped-example:not(.expanded) .code-wrapper:after { + background: linear-gradient(to top, rgba(15, 20, 25, 1), rgba(15, 20, 25, 0)); +} +.toggle-line-inner { + background: #999; +} +.toggle-line:hover .toggle-line-inner { + background: #c5c5c5; +} +.sidebar .location { + border-color: #000; + background-color: #0f1419; + color: #fff; +} +#all-types { + background-color: #14191f; +} diff --git a/v0.21.0/static.files/ayu.min.css b/v0.21.0/static.files/ayu.min.css new file mode 100644 index 00000000..e0450d7e --- /dev/null +++ b/v0.21.0/static.files/ayu.min.css @@ -0,0 +1,78 @@ +/* +Based off of the Ayu theme +Original by Dempfi (https://github.com/dempfi/ayu) +*/ + +.hljs { + display: block; + overflow-x: auto; + background: #191f26; + color: #e6e1cf; +} + +.hljs-comment, +.hljs-quote { + color: #5c6773; + font-style: italic; +} + +.hljs-variable, +.hljs-template-variable, +.hljs-attribute, +.hljs-attr, +.hljs-regexp, +.hljs-link, +.hljs-selector-id, +.hljs-selector-class { + color: #ff7733; +} + +.hljs-number, +.hljs-meta, +.hljs-builtin-name, +.hljs-literal, +.hljs-type, +.hljs-params { + color: #ffee99; +} + +.hljs-string, +.hljs-bullet { + color: #b8cc52; +} + +.hljs-title, +.hljs-built_in, +.hljs-section { + color: #ffb454; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-symbol { + color: #ff7733; +} + +.hljs-name { + color: #36a3d9; +} + +.hljs-tag { + color: #00568d; +} + +.hljs-emphasis { + font-style: italic; +} + +.hljs-strong { + font-weight: bold; +} + +.hljs-addition { + color: #91b362; +} + +.hljs-deletion { + color: #d96c75; +} \ No newline at end of file diff --git a/v0.21.0/static.files/clipboard.svg b/v0.21.0/static.files/clipboard.svg new file mode 100644 index 00000000..8adbd996 --- /dev/null +++ b/v0.21.0/static.files/clipboard.svg @@ -0,0 +1 @@ + diff --git a/v0.21.0/static.files/down-arrow.svg b/v0.21.0/static.files/down-arrow.svg new file mode 100644 index 00000000..5d76a64e --- /dev/null +++ b/v0.21.0/static.files/down-arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/v0.21.0/static.files/highlight.js b/v0.21.0/static.files/highlight.js new file mode 100644 index 00000000..04e33aac --- /dev/null +++ b/v0.21.0/static.files/highlight.js @@ -0,0 +1,392 @@ +/*! + Highlight.js v11.3.1 (git: 2a972d8658) + (c) 2006-2023 Ivan Sagalaev and other contributors + License: BSD-3-Clause + */ +var hljs=function(){"use strict";var e={exports:{}};function t(e){ +return e instanceof Map?e.clear=e.delete=e.set=()=>{ +throw Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=()=>{ +throw Error("set is read-only") +}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((n=>{var s=e[n] +;"object"!=typeof s||Object.isFrozen(s)||t(s)})),e} +e.exports=t,e.exports.default=t;var n=e.exports;class s{constructor(e){ +void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1} +ignoreMatch(){this.isMatchIgnored=!0}}function i(e){ +return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'") +}function a(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t] +;return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const r=e=>!!e.kind +;class o{constructor(e,t){ +this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){ +this.buffer+=i(e)}openNode(e){if(!r(e))return;let t=e.kind +;t=e.sublanguage?"language-"+t:((e,{prefix:t})=>{if(e.includes(".")){ +const n=e.split(".") +;return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ") +}return`${t}${e}`})(t,{prefix:this.classPrefix}),this.span(t)}closeNode(e){ +r(e)&&(this.buffer+="")}value(){return this.buffer}span(e){ +this.buffer+=``}}class l{constructor(){this.rootNode={ +children:[]},this.stack=[this.rootNode]}get top(){ +return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){ +this.top.children.push(e)}openNode(e){const t={kind:e,children:[]} +;this.add(t),this.stack.push(t)}closeNode(){ +if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){ +for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)} +walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){ +return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t), +t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){ +"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{ +l._collapse(e)})))}}class c extends l{constructor(e){super(),this.options=e} +addKeyword(e,t){""!==e&&(this.openNode(t),this.addText(e),this.closeNode())} +addText(e){""!==e&&this.add(e)}addSublanguage(e,t){const n=e.root +;n.kind=t,n.sublanguage=!0,this.add(n)}toHTML(){ +return new o(this,this.options).value()}finalize(){return!0}}function d(e){ +return e?"string"==typeof e?e:e.source:null}function u(e){return b("(?=",e,")")} +function g(e){return b("(?:",e,")*")}function h(e){return b("(?:",e,")?")} +function b(...e){return e.map((e=>d(e))).join("")}function p(...e){const t=(e=>{ +const t=e[e.length-1] +;return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{} +})(e);return"("+(t.capture?"":"?:")+e.map((e=>d(e))).join("|")+")"} +function f(e){return RegExp(e.toString()+"|").exec("").length-1} +const m=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./ +;function E(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n +;let s=d(e),i="";for(;s.length>0;){const e=m.exec(s);if(!e){i+=s;break} +i+=s.substring(0,e.index), +s=s.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+(Number(e[1])+t):(i+=e[0], +"("===e[0]&&n++)}return i})).map((e=>`(${e})`)).join(t)} +const _="[a-zA-Z]\\w*",w="[a-zA-Z_]\\w*",y="\\b\\d+(\\.\\d+)?",N="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",x="\\b(0b[01]+)",k={ +begin:"\\\\[\\s\\S]",relevance:0},v={scope:"string",begin:"'",end:"'", +illegal:"\\n",contains:[k]},O={scope:"string",begin:'"',end:'"',illegal:"\\n", +contains:[k]},S=(e,t,n={})=>{const s=a({scope:"comment",begin:e,end:t, +contains:[]},n);s.contains.push({scope:"doctag", +begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)", +end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0}) +;const i=p("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/) +;return s.contains.push({begin:b(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),s +},R=S("//","$"),M=S("/\\*","\\*/"),I=S("#","$");var A=Object.freeze({ +__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:_,UNDERSCORE_IDENT_RE:w, +NUMBER_RE:y,C_NUMBER_RE:N,BINARY_NUMBER_RE:x, +RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", +SHEBANG:(e={})=>{const t=/^#![ ]*\// +;return e.binary&&(e.begin=b(t,/.*\b/,e.binary,/\b.*/)),a({scope:"meta",begin:t, +end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)}, +BACKSLASH_ESCAPE:k,APOS_STRING_MODE:v,QUOTE_STRING_MODE:O,PHRASAL_WORDS_MODE:{ +begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ +},COMMENT:S,C_LINE_COMMENT_MODE:R,C_BLOCK_COMMENT_MODE:M,HASH_COMMENT_MODE:I, +NUMBER_MODE:{scope:"number",begin:y,relevance:0},C_NUMBER_MODE:{scope:"number", +begin:N,relevance:0},BINARY_NUMBER_MODE:{scope:"number",begin:x,relevance:0}, +REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{scope:"regexp",begin:/\//, +end:/\/[gimuy]*/,illegal:/\n/,contains:[k,{begin:/\[/,end:/\]/,relevance:0, +contains:[k]}]}]},TITLE_MODE:{scope:"title",begin:_,relevance:0}, +UNDERSCORE_TITLE_MODE:{scope:"title",begin:w,relevance:0},METHOD_GUARD:{ +begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0},END_SAME_AS_BEGIN:e=>Object.assign(e,{ +"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{ +t.data._beginMatch!==e[1]&&t.ignoreMatch()}})});function T(e,t){ +"."===e.input[e.index-1]&&t.ignoreMatch()}function D(e,t){ +void 0!==e.className&&(e.scope=e.className,delete e.className)}function j(e,t){ +t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)", +e.__beforeBegin=T,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords, +void 0===e.relevance&&(e.relevance=0))}function C(e,t){ +Array.isArray(e.illegal)&&(e.illegal=p(...e.illegal))}function B(e,t){ +if(e.match){ +if(e.begin||e.end)throw Error("begin & end are not supported with match") +;e.begin=e.match,delete e.match}}function L(e,t){ +void 0===e.relevance&&(e.relevance=1)}const z=(e,t)=>{if(!e.beforeMatch)return +;if(e.starts)throw Error("beforeMatch cannot be used with starts") +;const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t] +})),e.keywords=n.keywords,e.begin=b(n.beforeMatch,u(n.begin)),e.starts={ +relevance:0,contains:[Object.assign(n,{endsParent:!0})] +},e.relevance=0,delete n.beforeMatch +},$=["of","and","for","in","not","or","if","then","parent","list","value"] +;function U(e,t,n="keyword"){const s=Object.create(null) +;return"string"==typeof e?i(n,e.split(" ")):Array.isArray(e)?i(n,e):Object.keys(e).forEach((n=>{ +Object.assign(s,U(e[n],t,n))})),s;function i(e,n){ +t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((t=>{const n=t.split("|") +;s[n[0]]=[e,H(n[0],n[1])]}))}}function H(e,t){ +return t?Number(t):(e=>$.includes(e.toLowerCase()))(e)?0:1}const P={},K=e=>{ +console.error(e)},G=(e,...t)=>{console.log("WARN: "+e,...t)},F=(e,t)=>{ +P[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),P[`${e}/${t}`]=!0) +},Z=Error();function W(e,t,{key:n}){let s=0;const i=e[n],a={},r={} +;for(let e=1;e<=t.length;e++)r[e+s]=i[e],a[e+s]=!0,s+=f(t[e-1]) +;e[n]=r,e[n]._emit=a,e[n]._multi=!0}function X(e){(e=>{ +e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope, +delete e.scope)})(e),"string"==typeof e.beginScope&&(e.beginScope={ +_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope +}),(e=>{if(Array.isArray(e.begin)){ +if(e.skip||e.excludeBegin||e.returnBegin)throw K("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), +Z +;if("object"!=typeof e.beginScope||null===e.beginScope)throw K("beginScope must be object"), +Z;W(e,e.begin,{key:"beginScope"}),e.begin=E(e.begin,{joinWith:""})}})(e),(e=>{ +if(Array.isArray(e.end)){ +if(e.skip||e.excludeEnd||e.returnEnd)throw K("skip, excludeEnd, returnEnd not compatible with endScope: {}"), +Z +;if("object"!=typeof e.endScope||null===e.endScope)throw K("endScope must be object"), +Z;W(e,e.end,{key:"endScope"}),e.end=E(e.end,{joinWith:""})}})(e)}function q(e){ +function t(t,n){ +return RegExp(d(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":"")) +}class n{constructor(){ +this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0} +addRule(e,t){ +t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]), +this.matchAt+=f(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null) +;const e=this.regexes.map((e=>e[1]));this.matcherRe=t(E(e,{joinWith:"|" +}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex +;const t=this.matcherRe.exec(e);if(!t)return null +;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),s=this.matchIndexes[n] +;return t.splice(0,n),Object.assign(t,s)}}class s{constructor(){ +this.rules=[],this.multiRegexes=[], +this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){ +if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n +;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))), +t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){ +return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){ +this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){ +const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex +;let n=t.exec(e) +;if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{ +const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)} +return n&&(this.regexIndex+=n.position+1, +this.regexIndex===this.count&&this.considerAll()),n}} +if(e.compilerExtensions||(e.compilerExtensions=[]), +e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.") +;return e.classNameAliases=a(e.classNameAliases||{}),function n(i,r){const o=i +;if(i.isCompiled)return o +;[D,B,X,z].forEach((e=>e(i,r))),e.compilerExtensions.forEach((e=>e(i,r))), +i.__beforeBegin=null,[j,C,L].forEach((e=>e(i,r))),i.isCompiled=!0;let l=null +;return"object"==typeof i.keywords&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords), +l=i.keywords.$pattern, +delete i.keywords.$pattern),l=l||/\w+/,i.keywords&&(i.keywords=U(i.keywords,e.case_insensitive)), +o.keywordPatternRe=t(l,!0), +r&&(i.begin||(i.begin=/\B|\b/),o.beginRe=t(o.begin),i.end||i.endsWithParent||(i.end=/\B|\b/), +i.end&&(o.endRe=t(o.end)), +o.terminatorEnd=d(o.end)||"",i.endsWithParent&&r.terminatorEnd&&(o.terminatorEnd+=(i.end?"|":"")+r.terminatorEnd)), +i.illegal&&(o.illegalRe=t(i.illegal)), +i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>a(e,{ +variants:null},t)))),e.cachedVariants?e.cachedVariants:V(e)?a(e,{ +starts:e.starts?a(e.starts):null +}):Object.isFrozen(e)?a(e):e))("self"===e?i:e)))),i.contains.forEach((e=>{n(e,o) +})),i.starts&&n(i.starts,r),o.matcher=(e=>{const t=new s +;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin" +}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end" +}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(o),o}(e)}function V(e){ +return!!e&&(e.endsWithParent||V(e.starts))}class Q extends Error{ +constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}} +const J=i,Y=a,ee=Symbol("nomatch");var te=(e=>{ +const t=Object.create(null),i=Object.create(null),a=[];let r=!0 +;const o="Could not find the language '{}', did you forget to load/include a language module?",l={ +disableAutodetect:!0,name:"Plain text",contains:[]};let d={ +ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i, +languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-", +cssSelector:"pre code",languages:null,__emitter:c};function f(e){ +return d.noHighlightRe.test(e)}function m(e,t,n){let s="",i="" +;"object"==typeof t?(s=e, +n=t.ignoreIllegals,i=t.language):(F("10.7.0","highlight(lang, code, ...args) has been deprecated."), +F("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"), +i=e,s=t),void 0===n&&(n=!0);const a={code:s,language:i};O("before:highlight",a) +;const r=a.result?a.result:E(a.language,a.code,n) +;return r.code=a.code,O("after:highlight",r),r}function E(e,n,i,a){ +const l=Object.create(null);function c(){if(!v.keywords)return void S.addText(R) +;let e=0;v.keywordPatternRe.lastIndex=0;let t=v.keywordPatternRe.exec(R),n="" +;for(;t;){n+=R.substring(e,t.index) +;const i=y.case_insensitive?t[0].toLowerCase():t[0],a=(s=i,v.keywords[s]);if(a){ +const[e,s]=a +;if(S.addText(n),n="",l[i]=(l[i]||0)+1,l[i]<=7&&(M+=s),e.startsWith("_"))n+=t[0];else{ +const n=y.classNameAliases[e]||e;S.addKeyword(t[0],n)}}else n+=t[0] +;e=v.keywordPatternRe.lastIndex,t=v.keywordPatternRe.exec(R)}var s +;n+=R.substr(e),S.addText(n)}function u(){null!=v.subLanguage?(()=>{ +if(""===R)return;let e=null;if("string"==typeof v.subLanguage){ +if(!t[v.subLanguage])return void S.addText(R) +;e=E(v.subLanguage,R,!0,O[v.subLanguage]),O[v.subLanguage]=e._top +}else e=_(R,v.subLanguage.length?v.subLanguage:null) +;v.relevance>0&&(M+=e.relevance),S.addSublanguage(e._emitter,e.language) +})():c(),R=""}function g(e,t){let n=1;for(;void 0!==t[n];){if(!e._emit[n]){n++ +;continue}const s=y.classNameAliases[e[n]]||e[n],i=t[n] +;s?S.addKeyword(i,s):(R=i,c(),R=""),n++}}function h(e,t){ +return e.scope&&"string"==typeof e.scope&&S.openNode(y.classNameAliases[e.scope]||e.scope), +e.beginScope&&(e.beginScope._wrap?(S.addKeyword(R,y.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap), +R=""):e.beginScope._multi&&(g(e.beginScope,t),R="")),v=Object.create(e,{parent:{ +value:v}}),v}function b(e,t,n){let i=((e,t)=>{const n=e&&e.exec(t) +;return n&&0===n.index})(e.endRe,n);if(i){if(e["on:end"]){const n=new s(e) +;e["on:end"](t,n),n.isMatchIgnored&&(i=!1)}if(i){ +for(;e.endsParent&&e.parent;)e=e.parent;return e}} +if(e.endsWithParent)return b(e.parent,t,n)}function p(e){ +return 0===v.matcher.regexIndex?(R+=e[0],1):(T=!0,0)}function f(e){ +const t=e[0],s=n.substr(e.index),i=b(v,e,s);if(!i)return ee;const a=v +;v.endScope&&v.endScope._wrap?(u(), +S.addKeyword(t,v.endScope._wrap)):v.endScope&&v.endScope._multi?(u(), +g(v.endScope,e)):a.skip?R+=t:(a.returnEnd||a.excludeEnd||(R+=t), +u(),a.excludeEnd&&(R=t));do{ +v.scope&&S.closeNode(),v.skip||v.subLanguage||(M+=v.relevance),v=v.parent +}while(v!==i.parent);return i.starts&&h(i.starts,e),a.returnEnd?0:t.length} +let m={};function w(t,a){const o=a&&a[0];if(R+=t,null==o)return u(),0 +;if("begin"===m.type&&"end"===a.type&&m.index===a.index&&""===o){ +if(R+=n.slice(a.index,a.index+1),!r){const t=Error(`0 width match regex (${e})`) +;throw t.languageName=e,t.badRule=m.rule,t}return 1} +if(m=a,"begin"===a.type)return(e=>{ +const t=e[0],n=e.rule,i=new s(n),a=[n.__beforeBegin,n["on:begin"]] +;for(const n of a)if(n&&(n(e,i),i.isMatchIgnored))return p(t) +;return n.skip?R+=t:(n.excludeBegin&&(R+=t), +u(),n.returnBegin||n.excludeBegin||(R=t)),h(n,e),n.returnBegin?0:t.length})(a) +;if("illegal"===a.type&&!i){ +const e=Error('Illegal lexeme "'+o+'" for mode "'+(v.scope||"")+'"') +;throw e.mode=v,e}if("end"===a.type){const e=f(a);if(e!==ee)return e} +if("illegal"===a.type&&""===o)return 1 +;if(A>1e5&&A>3*a.index)throw Error("potential infinite loop, way more iterations than matches") +;return R+=o,o.length}const y=x(e) +;if(!y)throw K(o.replace("{}",e)),Error('Unknown language: "'+e+'"') +;const N=q(y);let k="",v=a||N;const O={},S=new d.__emitter(d);(()=>{const e=[] +;for(let t=v;t!==y;t=t.parent)t.scope&&e.unshift(t.scope) +;e.forEach((e=>S.openNode(e)))})();let R="",M=0,I=0,A=0,T=!1;try{ +for(v.matcher.considerAll();;){ +A++,T?T=!1:v.matcher.considerAll(),v.matcher.lastIndex=I +;const e=v.matcher.exec(n);if(!e)break;const t=w(n.substring(I,e.index),e) +;I=e.index+t}return w(n.substr(I)),S.closeAllNodes(),S.finalize(),k=S.toHTML(),{ +language:e,value:k,relevance:M,illegal:!1,_emitter:S,_top:v}}catch(t){ +if(t.message&&t.message.includes("Illegal"))return{language:e,value:J(n), +illegal:!0,relevance:0,_illegalBy:{message:t.message,index:I, +context:n.slice(I-100,I+100),mode:t.mode,resultSoFar:k},_emitter:S};if(r)return{ +language:e,value:J(n),illegal:!1,relevance:0,errorRaised:t,_emitter:S,_top:v} +;throw t}}function _(e,n){n=n||d.languages||Object.keys(t);const s=(e=>{ +const t={value:J(e),illegal:!1,relevance:0,_top:l,_emitter:new d.__emitter(d)} +;return t._emitter.addText(e),t})(e),i=n.filter(x).filter(v).map((t=>E(t,e,!1))) +;i.unshift(s);const a=i.sort(((e,t)=>{ +if(e.relevance!==t.relevance)return t.relevance-e.relevance +;if(e.language&&t.language){if(x(e.language).supersetOf===t.language)return 1 +;if(x(t.language).supersetOf===e.language)return-1}return 0})),[r,o]=a,c=r +;return c.secondBest=o,c}function w(e){let t=null;const n=(e=>{ +let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"" +;const n=d.languageDetectRe.exec(t);if(n){const t=x(n[1]) +;return t||(G(o.replace("{}",n[1])), +G("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"} +return t.split(/\s+/).find((e=>f(e)||x(e)))})(e);if(f(n))return +;if(O("before:highlightElement",{el:e,language:n +}),e.children.length>0&&(d.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), +console.warn("https://github.com/highlightjs/highlight.js/issues/2886"), +console.warn(e)), +d.throwUnescapedHTML))throw new Q("One of your code blocks includes unescaped HTML.",e.innerHTML) +;t=e;const s=t.textContent,a=n?m(s,{language:n,ignoreIllegals:!0}):_(s) +;e.innerHTML=a.value,((e,t,n)=>{const s=t&&i[t]||n +;e.classList.add("hljs"),e.classList.add("language-"+s) +})(e,n,a.language),e.result={language:a.language,re:a.relevance, +relevance:a.relevance},a.secondBest&&(e.secondBest={ +language:a.secondBest.language,relevance:a.secondBest.relevance +}),O("after:highlightElement",{el:e,result:a,text:s})}let y=!1;function N(){ +"loading"!==document.readyState?document.querySelectorAll(d.cssSelector).forEach(w):y=!0 +}function x(e){return e=(e||"").toLowerCase(),t[e]||t[i[e]]} +function k(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{ +i[e.toLowerCase()]=t}))}function v(e){const t=x(e) +;return t&&!t.disableAutodetect}function O(e,t){const n=e;a.forEach((e=>{ +e[n]&&e[n](t)}))} +"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(()=>{ +y&&N()}),!1),Object.assign(e,{highlight:m,highlightAuto:_,highlightAll:N, +highlightElement:w, +highlightBlock:e=>(F("10.7.0","highlightBlock will be removed entirely in v12.0"), +F("10.7.0","Please use highlightElement now."),w(e)),configure:e=>{d=Y(d,e)}, +initHighlighting:()=>{ +N(),F("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")}, +initHighlightingOnLoad:()=>{ +N(),F("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.") +},registerLanguage:(n,s)=>{let i=null;try{i=s(e)}catch(e){ +if(K("Language definition for '{}' could not be registered.".replace("{}",n)), +!r)throw e;K(e),i=l} +i.name||(i.name=n),t[n]=i,i.rawDefinition=s.bind(null,e),i.aliases&&k(i.aliases,{ +languageName:n})},unregisterLanguage:e=>{delete t[e] +;for(const t of Object.keys(i))i[t]===e&&delete i[t]}, +listLanguages:()=>Object.keys(t),getLanguage:x,registerAliases:k, +autoDetection:v,inherit:Y,addPlugin:e=>{(e=>{ +e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{ +e["before:highlightBlock"](Object.assign({block:t.el},t)) +}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{ +e["after:highlightBlock"](Object.assign({block:t.el},t))})})(e),a.push(e)} +}),e.debugMode=()=>{r=!1},e.safeMode=()=>{r=!0 +},e.versionString="11.3.1",e.regex={concat:b,lookahead:u,either:p,optional:h, +anyNumberOfTimes:g};for(const e in A)"object"==typeof A[e]&&n(A[e]) +;return Object.assign(e,A),e})({}),ne=Object.freeze({__proto__:null, +grmr_sway:e=>{const t={className:"title.function.invoke",relevance:0, +begin:b(/\b/,/(?!let\b)/,e.IDENT_RE,u(/\s*\(/))},n="([u](8|16|32|64))?";return{ +name:"Sway",aliases:["sw"],keywords:{$pattern:e.IDENT_RE+"!?", +keyword:["abi","as","asm","break","const","continue","contract","deref","else","enum","fn","for","if","impl","let","library","mod","match","mut","predicate","pub","ref","return","script","Self","self","storage","str","struct","type","trait","use","where","while"], +literal:["true","false","Some","None","Ok","Err"], +built_in:["bool","char","u8","u16","u32","u64","b256","str","Self"]}, +illegal:""},t]}}, +grmr_rust:e=>{const t=e.regex,n={className:"title.function.invoke",relevance:0, +begin:t.concat(/\b/,/(?!let\b)/,e.IDENT_RE,t.lookahead(/\s*\(/)) +},s="([ui](8|16|32|64|128|size)|f(32|64))?",i=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","panic!","file!","format!","format_args!","include_bin!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"] +;return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?", +type:["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"], +keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","unsafe","unsized","use","virtual","where","while","yield"], +literal:["true","false","Some","None","Ok","Err"],built_in:i},illegal:""},n]}}, +grmr_ini:e=>{const t=e.regex,n={className:"number",relevance:0,variants:[{ +begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},s=e.COMMENT();s.variants=[{ +begin:/;/,end:/$/},{begin:/#/,end:/$/}];const i={className:"variable", +variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},a={ +className:"literal",begin:/\bon|off|true|false|yes|no\b/},r={className:"string", +contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{ +begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}] +},o={begin:/\[/,end:/\]/,contains:[s,a,i,r,n,"self"],relevance:0 +},l=t.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{ +name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/, +contains:[s,{className:"section",begin:/\[+/,end:/\]+/},{ +begin:t.concat(l,"(\\s*\\.\\s*",l,")*",t.lookahead(/\s*=\s*[^#\s]/)), +className:"attr",starts:{end:/$/,contains:[s,o,a,i,r,n]}}]}},grmr_bash:e=>{ +const t=e.regex,n={},s={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/, +contains:[n]}]};Object.assign(n,{className:"variable",variants:[{ +begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},s]});const i={ +className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a={ +begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/, +end:/(\w+)/,className:"string"})]}},r={className:"string",begin:/"/,end:/"/, +contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(r);const o={begin:/\$\(\(/, +end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n] +},l=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10 +}),c={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0, +contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{ +name:"Bash",aliases:["sh"],keywords:{$pattern:/\b[a-z._-]+\b/, +keyword:["if","then","else","elif","fi","for","while","in","do","done","case","esac","function"], +literal:["true","false"], +built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"] +},contains:[l,e.SHEBANG(),c,o,e.HASH_COMMENT_MODE,a,{match:/(\/[a-z._-]+)+/},r,{ +className:"",begin:/\\"/},{className:"string",begin:/'/,end:/'/},n]}}, +grmr_shell:e=>({name:"Shell Session",aliases:["console","shellsession"], +contains:[{className:"meta",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{ +end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}),grmr_json:e=>({name:"JSON", +contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01 +},{match:/[{}[\],:]/,className:"punctuation",relevance:0},e.QUOTE_STRING_MODE,{ +beginKeywords:"true false null" +},e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}) +});const se=te;for(const e of Object.keys(ne)){ +const t=e.replace("grmr_","").replace("_","-");se.registerLanguage(t,ne[e])} +return se}() +;"object"==typeof exports&&"undefined"!=typeof module&&(module.exports=hljs); \ No newline at end of file diff --git a/v0.21.0/static.files/normalize.css b/v0.21.0/static.files/normalize.css new file mode 100644 index 00000000..552862c5 --- /dev/null +++ b/v0.21.0/static.files/normalize.css @@ -0,0 +1,147 @@ +/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ +html { + line-height: 1.15; + -webkit-text-size-adjust: 100%; +} +body { + margin: 0; +} +main { + display: block; +} +h1 { + font-size: 2em; + margin: 0.67em 0; +} +hr { + box-sizing: content-box; + height: 0; + overflow: visible; +} +pre { + font-family: monospace, monospace; + font-size: 1em; +} +a { + background-color: transparent; +} +abbr[title] { + border-bottom: none; + text-decoration: underline; + text-decoration: underline dotted; +} +b, +strong { + font-weight: bolder; +} +code, +kbd, +samp { + font-family: monospace, monospace; + font-size: 1em; +} +small { + font-size: 80%; +} +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} +sub { + bottom: -0.25em; +} +sup { + top: -0.5em; +} +img { + border-style: none; +} +button, +input, +optgroup, +select, +textarea { + font-family: inherit; + font-size: 100%; + line-height: 1.15; + margin: 0; +} +button, +input { + overflow: visible; +} +button, +select { + text-transform: none; +} +[type="button"], +[type="reset"], +[type="submit"], +button { + -webkit-appearance: button; +} +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner, +button::-moz-focus-inner { + border-style: none; + padding: 0; +} +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring, +button:-moz-focusring { + outline: 1px dotted ButtonText; +} +fieldset { + padding: 0.35em 0.75em 0.625em; +} +legend { + box-sizing: border-box; + color: inherit; + display: table; + max-width: 100%; + padding: 0; + white-space: normal; +} +progress { + vertical-align: baseline; +} +textarea { + overflow: auto; +} +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; + padding: 0; +} +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} +[type="search"] { + -webkit-appearance: textfield; + outline-offset: -2px; +} +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} +::-webkit-file-upload-button { + -webkit-appearance: button; + font: inherit; +} +details { + display: block; +} +summary { + display: list-item; +} +template { + display: none; +} +[hidden] { + display: none; +} diff --git a/v0.21.0/static.files/sway-logo.svg b/v0.21.0/static.files/sway-logo.svg new file mode 100644 index 00000000..cc536147 --- /dev/null +++ b/v0.21.0/static.files/sway-logo.svg @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v0.21.0/static.files/swaydoc.css b/v0.21.0/static.files/swaydoc.css new file mode 100644 index 00000000..dc3abdbb --- /dev/null +++ b/v0.21.0/static.files/swaydoc.css @@ -0,0 +1,2014 @@ +@font-face { + font-family: "Fira Sans"; + font-style: normal; + font-weight: 400; + src: local("Fira Sans"), url("FiraSans-Regular.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "Fira Sans"; + font-style: normal; + font-weight: 500; + src: local("Fira Sans Medium"), url("FiraSans-Medium.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "Source Serif 4"; + font-style: normal; + font-weight: 400; + src: local("Source Serif 4"), + url("SourceSerif4-Regular.ttf.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "Source Serif 4"; + font-style: italic; + font-weight: 400; + src: local("Source Serif 4 Italic"), + url("SourceSerif4-It.ttf.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "Source Serif 4"; + font-style: normal; + font-weight: 700; + src: local("Source Serif 4 Bold"), + url("SourceSerif4-Bold.ttf.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "Source Code Pro"; + font-style: normal; + font-weight: 400; + src: url("SourceCodePro-Regular.ttf.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "Source Code Pro"; + font-style: italic; + font-weight: 400; + src: url("SourceCodePro-It.ttf.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "Source Code Pro"; + font-style: normal; + font-weight: 600; + src: url("SourceCodePro-Semibold.ttf.woff2") format("woff2"); + font-display: swap; +} +@font-face { + font-family: "NanumBarunGothic"; + src: url("NanumBarunGothic.ttf.woff2") format("woff2"); + font-display: swap; + unicode-range: U+AC00-D7AF, U+1100-11FF, U+3130-318F, U+A960-A97F, U+D7B0-D7FF; +} +* { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +html { + content: ""; +} +@media (prefers-color-scheme: light) { + html { + content: "light"; + } +} +@media (prefers-color-scheme: dark) { + html { + content: "dark"; + } +} +body { + font: 16px/1.4 "Source Serif 4", NanumBarunGothic, serif; + margin: 0; + position: relative; + overflow-wrap: break-word; + overflow-wrap: anywhere; + -webkit-font-feature-settings: "kern", "liga"; + -moz-font-feature-settings: "kern", "liga"; + font-feature-settings: "kern", "liga"; + background-color: var(--main-background-color); + color: var(--main-color); +} +h1 { + font-size: 1.5rem; +} +h2 { + font-size: 1.375rem; +} +h3 { + font-size: 1.25rem; +} +h1, +h2, +h3, +h4, +h5, +h6 { + font-weight: 500; +} +h1, +h2, +h3, +h4 { + margin: 20px 0 15px 0; + padding-bottom: 6px; +} +.docblock h3, +.docblock h4, +h5, +h6 { + margin: 15px 0 5px 0; +} +h1.fqn { + margin: 0; + padding: 0; + border-bottom-color: var(--headings-border-bottom-color); +} +h2, +h3, +h4 { + border-bottom-color: var(--headings-border-bottom-color); +} +.main-heading { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + padding-bottom: 6px; + margin-bottom: 15px; +} +.main-heading a:hover { + text-decoration: underline; +} +#toggle-all-docs { + text-decoration: none; +} +h2, +.top-doc .docblock > h3, +.top-doc .docblock > h4 { + border-bottom: 1px solid var(--headings-border-bottom-color); +} +h3.code-header { + font-size: 1em; + font-weight: 600; +} +h4.code-header { + font-size: 1rem; +} +.code-header { + font-weight: 600; + border-bottom-style: none; + padding: 0; + margin-top: 0.6em; + margin-bottom: 0.4em; +} +.impl, +.impl-items .method, +.methods .method, +.impl-items .type, +.methods .type, +.impl-items .associatedconstant, +.methods .associatedconstant, +.impl-items .associatedtype, +.methods .associatedtype { + flex-basis: 100%; + font-weight: 600; + position: relative; +} +div.impl-items > div { + padding-left: 0; +} +h1, +h2, +h3, +h4, +h5, +h6, +.sidebar, +.mobile-topbar, +a.source, +.search-input, +.search-results .result-name, +.content table td:first-child > a, +.item-left > a, +.out-of-band, +span.since, +#source-sidebar, +#sidebar-toggle, +details.swaydoc-toggle > summary::before, +div.impl-items > div:not(.docblock):not(.item-info), +.content ul.crate a.crate, +a.srclink, +#main-content > .since, +#help-button > a, +details.swaydoc-toggle.top-doc > summary, +details.swaydoc-toggle.top-doc > summary::before, +details.swaydoc-toggle.non-exhaustive > summary, +details.swaydoc-toggle.non-exhaustive > summary::before, +.scraped-example-title, +.more-examples-toggle summary, +.more-examples-toggle .hide-more, +.example-links a, +#main-content > ul.docblock > li > a { + font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif; +} +h1, +h2, +h3, +h4, +a#toggle-all-docs, +a.anchor, +.small-section-header a, +#source-sidebar a, +pre.sway a, +.sidebar h2 a, +.sidebar h3 a, +.mobile-topbar h2 a, +.in-band a, +.search-results a, +.module-item .stab, +.import-item .stab, +.result-name .primitive > i, +.result-name .keyword > i, +.content .method .where, +.content .fn .where, +.content .where.fmt-newline { + color: var(--main-color); +} +ol, +ul { + padding-left: 24px; +} +ul ul, +ol ul, +ul ol, +ol ol { + margin-bottom: 0.625em; +} +p { + margin: 0 0 0.6em 0; +} +summary { + outline: none; +} +td, +th { + padding: 0; +} +table { + border-collapse: collapse; +} +button, +input, +optgroup, +select, +textarea { + color: inherit; + font: inherit; + margin: 0; +} +button { + padding: 1px 6px; +} +.swaydoc { + display: flex; + flex-direction: row; + flex-wrap: nowrap; +} +main { + position: relative; + flex-grow: 1; + padding: 10px 15px 40px 45px; + min-width: 0; +} +.source main { + padding: 15px; +} +.width-limiter { + max-width: 960px; + margin-right: auto; +} +.source .width-limiter { + max-width: unset; +} +details:not(.swaydoc-toggle) summary { + margin-bottom: 0.6em; +} +code, +pre, +a.test-arrow, +.code-header { + font-family: "Source Code Pro", monospace; +} +.docblock code, +.docblock-short code { + border-radius: 3px; + padding: 0 0.125em; +} +.docblock pre code, +.docblock-short pre code { + padding: 0; +} +pre { + padding: 14px; +} +.docblock.item-decl { + margin-left: 0; +} +.item-decl pre { + overflow-x: auto; +} +.source .content pre { + padding: 20px; +} +img { + max-width: 100%; +} +li { + position: relative; +} +.source .content { + max-width: none; + overflow: visible; + margin-left: 0px; +} +nav.sub { + position: relative; + font-size: 1rem; +} +.sub-container { + display: flex; + flex-direction: row; + flex-wrap: nowrap; +} +.sub-logo-container { + display: none; + margin-right: 20px; +} +.source .sub-logo-container { + display: block; +} +.source .sub-logo-container > img { + height: 60px; + width: 60px; + object-fit: contain; +} +.sidebar, +.mobile-topbar, +.sidebar-menu-toggle { + background-color: var(--sidebar-background-color); +} +.sidebar { + font-size: 0.875rem; + width: 200px; + min-width: 200px; + overflow-y: scroll; + position: sticky; + height: 100vh; + top: 0; + left: 0; +} +.sidebar > .location { + padding-left: 24px; +} +.sidebar .location { + border: 1px solid; + font-size: 17px; + margin: 30px 10px 20px 10px; + text-align: center; + word-wrap: break-word; + font-weight: inherit; + padding: 0; +} +.swaydoc.source .sidebar { + width: 50px; + min-width: 0px; + max-width: 300px; + flex-grow: 0; + flex-shrink: 0; + flex-basis: auto; + border-right: 1px solid; + overflow-x: hidden; + overflow-y: hidden; +} +.swaydoc.source .sidebar .sidebar-logo { + display: none; +} +.source .sidebar, +#sidebar-toggle, +#source-sidebar { + background-color: var(--sidebar-background-color); +} +#sidebar-toggle > button:hover, +#sidebar-toggle > button:focus { + background-color: var(--sidebar-background-color-hover); +} +.source .sidebar > *:not(#sidebar-toggle) { + opacity: 0; + visibility: hidden; +} +.source-sidebar-expanded .source .sidebar { + overflow-y: auto; +} +.source-sidebar-expanded .source .sidebar > *:not(#sidebar-toggle) { + opacity: 1; + visibility: visible; +} +#all-types { + text-align: center; + border: 1px solid; + margin: 0 10px; + margin-bottom: 10px; + display: block; + border-radius: 7px; +} +a#all-types:hover, +a#all-types:active { + background-color: var(--sidebar-background-color-hover); + color: #c5c5c5; +} +* { + scrollbar-width: initial; + scrollbar-color: var(--scrollbar-color); +} +.sidebar { + scrollbar-width: thin; + scrollbar-color: var(--scrollbar-color); +} +::-webkit-scrollbar { + width: 12px; +} +.sidebar::-webkit-scrollbar { + width: 8px; +} +::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0; + background-color: var(--scrollbar-track-background-color); +} +.sidebar::-webkit-scrollbar-track { + background-color: var(--scrollbar-track-background-color); +} +::-webkit-scrollbar-thumb, +.sidebar::-webkit-scrollbar-thumb { + background-color: var(--scrollbar-thumb-background-color); +} +.hidden { + display: none !important; +} +.sidebar .logo-container { + display: flex; + margin-top: 10px; + margin-bottom: 10px; + justify-content: center; +} +.version { + overflow-wrap: break-word; +} +.logo-container > img { + height: 100px; + width: 100px; +} +.location:empty { + border: none; +} +.location a:first-of-type { + font-weight: 500; +} +.block { + padding: 0; +} +.block ul, +.block li { + padding: 0; + margin: 0; + list-style: none; +} +.block a, +h2.location a { + display: block; + padding: 0.25rem; + margin-left: 2em; + text-overflow: ellipsis; + overflow: hidden; +} +.sidebar h2 { + border-bottom: none; + font-weight: 500; + padding: 0; + margin: 0; + margin-top: 0.7rem; + margin-bottom: 0.7rem; +} +.sidebar h3 { + font-size: 1.125rem; + font-weight: 500; + padding: 0; + margin: 0; +} +.sidebar-elems .block { + margin-bottom: 2em; +} +.sidebar-elems .block li a { + white-space: nowrap; +} +.mobile-topbar { + display: none; +} +.source .content pre.sway { + white-space: pre; + overflow: auto; + padding-left: 0; +} +.swaydoc .example-wrap { + display: inline-flex; + margin-bottom: 10px; +} +.example-wrap { + position: relative; + width: 100%; +} +.example-wrap > pre.line-number { + overflow: initial; + border: 1px solid; + padding: 13px 8px; + text-align: right; + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; +} +.example-wrap > pre.sway a:hover { + text-decoration: underline; +} +.line-numbers { + text-align: right; +} +.swaydoc:not(.source) .example-wrap > pre:not(.line-number) { + width: 100%; + overflow-x: auto; +} +.swaydoc:not(.source) .example-wrap > pre.line-numbers { + width: auto; + overflow-x: visible; +} +.swaydoc .example-wrap > pre { + margin: 0; +} +#search { + position: relative; +} +.search-loading { + text-align: center; +} +#results > table { + width: 100%; + table-layout: fixed; +} +.content > .example-wrap pre.line-numbers { + position: relative; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.line-numbers span { + cursor: pointer; +} +.docblock-short { + overflow-wrap: break-word; + overflow-wrap: anywhere; +} +.docblock-short p { + display: inline; +} +.docblock-short p { + overflow: hidden; + text-overflow: ellipsis; + margin: 0; +} +.docblock > :not(pre) > code, +.docblock-short > :not(pre) > code { + white-space: pre-wrap; +} +.top-doc .docblock h2 { + font-size: 1.375rem; +} +.top-doc .docblock h3 { + font-size: 1.25rem; +} +.top-doc .docblock h4, +.top-doc .docblock h5 { + font-size: 1.125rem; +} +.top-doc .docblock h6 { + font-size: 1rem; +} +.docblock h5 { + font-size: 1rem; +} +.docblock h6 { + font-size: 0.875rem; +} +.docblock h1, +.docblock h2, +.docblock h3, +.docblock h4, +.docblock h5, +.docblock h6 { + border-bottom-color: var(--headings-border-bottom-color); +} +.docblock { + margin-left: 24px; + position: relative; +} +.docblock > :not(.information):not(.more-examples-toggle) { + max-width: 100%; + overflow-x: auto; +} +.content .out-of-band { + flex-grow: 0; + font-size: 1.125rem; + font-weight: normal; + float: right; +} +.method > .code-header, +.trait-impl > .code-header { + max-width: calc(100% - 41px); + display: block; +} +.content .in-band { + flex-grow: 1; + margin-top: 0px; + padding: 0px; + overflow-wrap: break-word; + overflow-wrap: anywhere; +} +.in-band > code, +.in-band > .code-header { + display: inline-block; +} +.docblock code, +.docblock-short code, +pre, +.swaydoc.source .example-wrap { + background-color: var(--code-block-background-color); +} +#main-content { + position: relative; +} +#main-content > .since { + top: inherit; +} +.content table:not(.table-display) { + border-spacing: 0 5px; +} +.content td { + vertical-align: top; +} +.content td:first-child { + padding-right: 20px; +} +.content td p:first-child { + margin-top: 0; +} +.content td h1, +.content td h2 { + margin-left: 0; + font-size: 1.125rem; +} +.content tr:first-child td { + border-top: 0; +} +.docblock table { + margin: 0.5em 0; + width: calc(100% - 2px); + overflow-x: auto; + display: block; +} +.docblock table td { + padding: 0.5em; + border: 1px dashed; +} +.docblock table th { + padding: 0.5em; + text-align: left; + border: 1px solid; +} +.fields + table { + margin-bottom: 1em; +} +.content .item-list { + list-style-type: none; + padding: 0; +} +.content .multi-column { + -moz-column-count: 5; + -moz-column-gap: 2.5em; + -webkit-column-count: 5; + -webkit-column-gap: 2.5em; + column-count: 5; + column-gap: 2.5em; +} +.content .multi-column li { + width: 100%; + display: inline-block; +} +.content > .methods > .method { + font-size: 1rem; + position: relative; +} +.content .method .where, +.content .fn .where, +.content .where.fmt-newline { + display: block; + font-size: 0.875rem; +} +.content .methods > div:not(.notable-traits):not(.method) { + margin-left: 40px; + margin-bottom: 15px; +} +.content .docblock > .impl-items { + margin-left: 20px; + margin-top: -34px; +} +.content .docblock > .impl-items .table-display { + margin: 0; +} +.content .docblock > .impl-items table td { + padding: 0; +} +.content .docblock > .impl-items .table-display, +.impl-items table td { + border: none; +} +.item-info { + display: block; +} +.content .item-info code { + font-size: 0.875rem; +} +.content .item-info { + position: relative; + margin-left: 24px; +} +.sub-variant > div > .item-info { + margin-top: initial; +} +.content .impl-items .docblock, +.content .impl-items .item-info { + margin-bottom: 0.6em; +} +.content .impl-items > .item-info { + margin-left: 40px; +} +.methods > .item-info, +.content .impl-items > .item-info { + margin-top: -8px; +} +.impl-items { + flex-basis: 100%; +} +#main-content > .item-info { + margin-top: 0; + margin-left: 0; +} +nav.sub { + flex-grow: 1; + margin-bottom: 25px; +} +.source nav.sub { + margin-left: 32px; +} +nav.main { + padding: 20px 0; + text-align: center; +} +nav.main .current { + border-top: 1px solid; + border-bottom: 1px solid; +} +nav.main .separator { + border: 1px solid; + display: inline-block; + height: 23px; + margin: 0 20px; +} +nav.sum { + text-align: right; +} +nav.sub form { + display: inline; +} +a { + text-decoration: none; + background: transparent; +} +.small-section-header { + display: flex; + justify-content: space-between; + position: relative; +} +.small-section-header:hover > .anchor { + display: initial; +} +.in-band:hover > .anchor, +.impl:hover > .anchor, +.method.trait-impl:hover > .anchor, +.method.has-srclink:hover > .anchor, +.type.trait-impl:hover > .anchor, +.associatedconstant.trait-impl:hover > .anchor, +.associatedtype.trait-impl:hover > .anchor { + display: inline-block; + position: absolute; +} +.anchor { + display: none; + position: absolute; + background: none !important; +} +.anchor.field { + left: -5px; +} +.small-section-header > .anchor { + left: -15px; + padding-right: 8px; +} +h2.small-section-header > .anchor { + padding-right: 6px; +} +.anchor::before { + content: "§"; +} +.docblock a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, +.docblock-short a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, +.item-info a { + text-decoration: underline; +} +.block a.current.crate { + font-weight: 500; +} +table, +.item-table { + overflow-wrap: break-word; +} +.item-row { + padding: 10px 0; +} +.item-right { + padding-top: 4px; +} +.search-container { + position: relative; + display: flex; + height: 34px; +} +.search-container > * { + height: 100%; +} +.search-results-title { + display: inline; +} +#search-settings { + font-size: 1.5rem; + font-weight: 500; + margin-bottom: 20px; +} +#crate-search { + min-width: 115px; + margin-top: 5px; + padding-left: 0.15em; + padding-right: 23px; + border: 1px solid; + border-radius: 4px; + outline: none; + cursor: pointer; + -moz-appearance: none; + -webkit-appearance: none; + background-repeat: no-repeat; + background-color: transparent; + background-size: 20px; + background-position: calc(100% - 1px) 56%; + background-image: url("down-arrow.svg"); + max-width: 100%; + text-overflow: ellipsis; +} +.search-container { + margin-top: 4px; +} +.search-input { + -webkit-appearance: none; + -moz-box-sizing: border-box !important; + box-sizing: border-box !important; + outline: none; + border: 1px solid; + border-radius: 2px; + padding: 8px; + font-size: 1rem; + width: 100%; +} +.search-results { + display: block; +} +.search-results .desc > span { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + display: block; +} +.search-results table { + width: 100%; + white-space: nowrap; + table-layout: fixed; +} +.search-results tr { + cursor: pointer; + height:28px; + border-bottom:1px solid #28323E; +} +.search-results tr:hover { + background-color: #28323E; +} +.search-results p { + overflow: hidden; + text-overflow: ellipsis; + margin: 0; +} +.search-results td:first-child { + padding-right: 15px; + white-space: initial; +} +.search-results td:first-child span { + font-family: monospace; + font-size: 14px; +} +.search-results .type.struct, +.search-results .type.enum { + color: #2DBFB8; +} +.search-results .type.function { + color: #2BAB63; +} +.search-results .type.trait { + color: #B78CF2; +} +.search-results .type.constant { + color: #D2991D; +} +.popover { + font-size: 1rem; + position: absolute; + right: 0; + z-index: 2; + display: block; + margin-top: 7px; + border-radius: 3px; + border: 1px solid; + font-size: 1rem; +} +.popover::before { + content: ""; + position: absolute; + right: 11px; + border: solid; + border-width: 1px 1px 0 0; + display: inline-block; + padding: 4px; + transform: rotate(-45deg); + top: -5px; +} +.popover, +.popover::before { + background-color: var(--main-background-color); + color: var(--main-color); +} +#help-button .popover { + max-width: 600px; +} +#help-button .popover::before { + right: 48px; +} +#help-button dt { + float: left; + clear: left; + display: block; + margin-right: 0.5rem; +} +#help-button span.top, +#help-button span.bottom { + text-align: center; + display: block; + font-size: 1.125rem; +} +#help-button span.top { + text-align: center; + display: block; + margin: 10px 0; + border-bottom: 1px solid; + padding-bottom: 4px; + margin-bottom: 6px; +} +#help-button span.bottom { + clear: both; + border-top: 1px solid; +} +.side-by-side { + text-align: initial; +} +.side-by-side > div { + width: 50%; + float: left; + padding: 0 20px 20px 17px; +} +.item-info .stab { + width: fit-content; + min-height: 36px; + display: flex; + align-items: center; + white-space: pre-wrap; +} +.stab { + padding: 3px; + margin-bottom: 5px; + font-size: 0.875rem; + font-weight: normal; +} +.stab p { + display: inline; + margin: 0; +} +.stab .emoji { + font-size: 1.25rem; +} +.emoji { + text-shadow: 1px 0 0 black, -1px 0 0 black, 0 1px 0 black, 0 -1px 0 black; +} +.module-item .stab, +.import-item .stab { + border-radius: 3px; + display: inline-block; + font-size: 0.875rem; + line-height: 1.2; + margin-bottom: 0; + margin-left: 0.3125em; + padding: 2px; + vertical-align: text-bottom; +} +.module-item.unstable, +.import-item.unstable { + opacity: 0.65; +} +.since { + font-weight: normal; + font-size: initial; +} +.rightside { + padding-left: 12px; + padding-right: 2px; + position: initial; +} +.impl-items .srclink, +.impl .srclink, +.methods .srclink { + font-weight: normal; + font-size: 1rem; +} +.rightside { + float: right; +} +.variants_table { + width: 100%; +} +.variants_table tbody tr td:first-child { + width: 1%; +} +td.summary-column { + width: 100%; +} +.summary { + padding-right: 0px; +} +pre.sway .question-mark { + font-weight: bold; +} +a.test-arrow { + display: inline-block; + visibility: hidden; + position: absolute; + padding: 5px 10px 5px 10px; + border-radius: 5px; + font-size: 1.375rem; + top: 5px; + right: 5px; + z-index: 1; +} +.example-wrap:hover .test-arrow { + visibility: visible; +} +a.test-arrow:hover { + text-decoration: none; +} +.code-attribute { + font-weight: 300; +} +.item-spacer { + width: 100%; + height: 12px; +} +.out-of-band > span.since { + position: initial; + font-size: 1.25rem; +} +h3.variant { + font-weight: 600; + font-size: 1.125rem; + margin-bottom: 10px; + border-bottom: none; +} +.sub-variant h4 { + font-size: 1rem; + font-weight: 400; + border-bottom: none; + margin-top: 0; + margin-bottom: 0; +} +.sub-variant { + margin-left: 24px; + margin-bottom: 40px; +} +.sub-variant > .sub-variant-field { + margin-left: 24px; +} +.toggle-label { + display: inline-block; + margin-left: 4px; + margin-top: 3px; +} +:target > code, +:target > .code-header { + opacity: 1; +} +:target { + padding-right: 3px; +} +.information { + position: absolute; + left: -25px; + margin-top: 7px; + z-index: 1; +} +.tooltip { + position: relative; + display: inline-block; + cursor: pointer; +} +.tooltip::after { + display: none; + text-align: center; + padding: 5px 3px 3px 3px; + border-radius: 6px; + margin-left: 5px; + font-size: 1rem; +} +.tooltip.ignore::after { + content: "This example is not tested"; +} +.tooltip.compile_fail::after { + content: "This example deliberately fails to compile"; +} +.tooltip.should_panic::after { + content: "This example panics"; +} +.tooltip.edition::after { + content: "This code runs with edition " attr(data-edition); +} +.tooltip::before { + content: " "; + position: absolute; + top: 50%; + left: 16px; + margin-top: -5px; + border-width: 5px; + border-style: solid; + display: none; +} +.tooltip:hover::before, +.tooltip:hover::after { + display: inline; +} +.tooltip.compile_fail, +.tooltip.should_panic, +.tooltip.ignore { + font-weight: bold; + font-size: 1.25rem; +} +.notable-traits-tooltip { + display: inline-block; + cursor: pointer; +} +.notable-traits:hover .notable-traits-tooltiptext, +.notable-traits .notable-traits-tooltiptext.force-tooltip { + display: inline-block; +} +.notable-traits .notable-traits-tooltiptext { + display: none; + padding: 5px 3px 3px 3px; + border-radius: 6px; + margin-left: 5px; + z-index: 10; + font-size: 1rem; + cursor: default; + position: absolute; + border: 1px solid; +} +.notable-traits-tooltip::after { + content: "\00a0\00a0\00a0"; +} +.notable-traits .notable, +.notable-traits .docblock { + margin: 0; +} +.notable-traits .notable { + margin: 0; + margin-bottom: 13px; + font-size: 1.1875rem; + font-weight: 600; + display: block; +} +.notable-traits .docblock code.content { + margin: 0; + padding: 0; + font-size: 1.25rem; +} +pre.sway.sway-example-rendered { + position: relative; +} +pre.sway { + tab-size: 4; + -moz-tab-size: 4; +} +.search-failed { + text-align: center; + margin-top: 20px; + display: none; +} +.search-failed.active { + display: block; +} +.search-failed > ul { + text-align: left; + max-width: 570px; + margin-left: auto; + margin-right: auto; +} +#titles { + height: 35px; +} +#titles > button { + float: left; + width: 33.3%; + text-align: center; + font-size: 1.125rem; + cursor: pointer; + border: 0; + border-top: 2px solid; +} +#titles > button:first-child:last-child { + margin-right: 1px; + width: calc(100% - 1px); +} +#titles > button:not(:last-child) { + margin-right: 1px; + width: calc(33.3% - 1px); +} +#titles > button > div.count { + display: inline-block; + font-size: 1rem; +} +.notable-traits { + cursor: pointer; + z-index: 2; + margin-left: 5px; +} +#sidebar-toggle { + position: sticky; + top: 0; + left: 0; + font-weight: bold; + font-size: 1.25rem; + border-bottom: 1px solid; + display: flex; + height: 40px; + justify-content: center; + align-items: center; + z-index: 10; +} +#source-sidebar { + width: 100%; + z-index: 1; + overflow: auto; +} +#source-sidebar > .title { + font-size: 1.5rem; + text-align: center; + border-bottom: 1px solid; + margin-bottom: 6px; +} +#sidebar-toggle > button { + background: none; + color: inherit; + cursor: pointer; + text-align: center; + border: none; + outline: none; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: 100%; + -webkit-appearance: none; + opacity: 1; +} +#settings-menu, +#help-button { + margin-left: 4px; + outline: none; +} +#copy-path { + height: 34px; +} +#settings-menu > a, +#help-button > a, +#copy-path { + padding: 5px; + width: 33px; + border: 1px solid; + border-radius: 2px; + cursor: pointer; +} +#settings-menu { + padding: 0; +} +#settings-menu > a, +#help-button > a { + padding: 5px; + height: 100%; + display: block; +} +@keyframes rotating { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} +#settings-menu.rotate > a img { + animation: rotating 2s linear infinite; +} +.setting-line .radio-line input:checked { + box-shadow: inset 0 0 0 3px var(--main-background-color); + background-color: var(--settings-input-color); +} +.setting-line .radio-line input:focus { + box-shadow: 0 0 1px 1px var(--settings-input-color); +} +.setting-line .radio-line input:checked:focus { + box-shadow: inset 0 0 0 3px var(--main-background-color), + 0 0 2px 2px var(--settings-input-color); +} +.setting-line .radio-line input:hover { + border-color: var(--settings-input-color) !important; +} +input:checked + .slider { + background-color: var(--settings-input-color); +} +#help-button > a { + text-align: center; + font-size: 20px; + padding-top: 2px; +} +#copy-path { + background: initial; + margin-left: 10px; + padding: 0; + padding-left: 2px; + border: 0; +} +#theme-choices { + display: none; + position: absolute; + left: 0; + top: 28px; + border: 1px solid; + border-radius: 3px; + z-index: 1; + cursor: pointer; +} +#theme-choices > button { + border: none; + width: 100%; + padding: 4px 8px; + text-align: center; + background: rgba(0, 0, 0, 0); + overflow-wrap: normal; +} +#theme-choices > button:not(:first-child) { + border-top: 1px solid; +} +kbd { + display: inline-block; + padding: 3px 5px; + font: 15px monospace; + line-height: 10px; + vertical-align: middle; + border: solid 1px; + border-radius: 3px; + cursor: default; +} +.hidden-by-impl-hider, +.hidden-by-usual-hider { + display: none !important; +} +#implementations-list > h3 > span.in-band { + width: 100%; +} +.table-display { + width: 100%; + border: 0; + border-collapse: collapse; + border-spacing: 0; + font-size: 1rem; +} +.table-display tr td:first-child { + padding-right: 0; +} +.table-display tr td:last-child { + float: right; +} +.table-display .out-of-band { + position: relative; + font-size: 1.125rem; + display: block; +} +.table-display td:hover .anchor { + display: block; + top: 2px; + left: -5px; +} +#main-content > ul { + padding-left: 10px; +} +#main-content > ul > li { + list-style: none; +} +.non-exhaustive { + margin-bottom: 1em; +} +details.dir-entry { + padding-left: 4px; +} +details.dir-entry > summary { + margin: 0 0 0 13px; + list-style-position: outside; + cursor: pointer; +} +details.dir-entry div.folders, +details.dir-entry div.files { + padding-left: 23px; +} +details.dir-entry a { + display: block; +} +details.swaydoc-toggle > summary.hideme { + cursor: pointer; +} +details.swaydoc-toggle > summary { + list-style: none; +} +details.swaydoc-toggle > summary::-webkit-details-marker, +details.swaydoc-toggle > summary::marker { + display: none; +} +details.swaydoc-toggle > summary.hideme > span { + margin-left: 9px; +} +details.swaydoc-toggle > summary::before { + content: ""; + cursor: pointer; + width: 16px; + height: 16px; + background-repeat: no-repeat; + background-position: top left; + display: inline-block; + vertical-align: middle; + opacity: 0.5; +} +details.swaydoc-toggle > summary::after { + content: "Expand"; + overflow: hidden; + width: 0; + height: 0; + position: absolute; +} +details.swaydoc-toggle > summary.hideme::after { + content: ""; +} +details.swaydoc-toggle > summary:focus::before, +details.swaydoc-toggle > summary:hover::before { + opacity: 1; +} +details.swaydoc-toggle.top-doc > summary, +details.swaydoc-toggle.top-doc > summary::before, +details.swaydoc-toggle.non-exhaustive > summary, +details.swaydoc-toggle.non-exhaustive > summary::before { + font-size: 1rem; +} +details.non-exhaustive { + margin-bottom: 8px; +} +details.swaydoc-toggle > summary.hideme::before { + position: relative; +} +details.swaydoc-toggle > summary:not(.hideme)::before { + position: absolute; + left: -24px; + top: 4px; +} +.impl-items > details.swaydoc-toggle > summary:not(.hideme)::before { + position: absolute; + left: -24px; +} +details.swaydoc-toggle[open] > summary.hideme { + position: absolute; +} +details.swaydoc-toggle { + position: relative; +} +details.swaydoc-toggle[open] > summary.hideme > span { + display: none; +} +details.swaydoc-toggle[open] > summary::before, +details.swaydoc-toggle[open] > summary.hideme::before { + background-image: url("toggle-minus.svg"); +} +details.swaydoc-toggle > summary::before { + background-image: url("toggle-plus.svg"); +} +details.swaydoc-toggle[open] > summary::before, +details.swaydoc-toggle[open] > summary.hideme::before { + width: 16px; + height: 16px; + background-repeat: no-repeat; + background-position: top left; + display: inline-block; + content: ""; +} +details.swaydoc-toggle[open] > summary::after, +details.swaydoc-toggle[open] > summary.hideme::after { + content: "Collapse"; +} +.docblock summary > * { + display: inline-block; +} +@media (min-width: 701px) { + .docblock > .information:first-child > .tooltip { + margin-top: 16px; + } + .source-sidebar-expanded + .source + .sidebar + + main + .width-limiter + .sub-logo-container.rust-logo { + display: none; + } + .source-sidebar-expanded .source .sidebar { + width: 300px; + } +} +@media (max-width: 700px) { + *[id] { + scroll-margin-top: 45px; + } + .swaydoc { + padding-top: 0px; + display: block; + } + main { + padding-left: 15px; + padding-top: 0px; + } + .swaydoc, + .main-heading { + flex-direction: column; + } + .content .out-of-band { + text-align: left; + margin-left: initial; + padding: initial; + } + .content .out-of-band .since::before { + content: "Since "; + } + #copy-path { + display: none; + } + .sidebar .sidebar-logo, + .sidebar .location { + display: none; + } + .sidebar-elems { + margin-top: 1em; + } + .sidebar { + position: fixed; + top: 45px; + left: -1000px; + margin-left: 0; + margin: 0; + padding: 0; + z-index: 11; + height: calc(100vh - 45px); + } + .source main, + .swaydoc.source .sidebar { + top: 0; + padding: 0; + height: 100vh; + border: 0; + } + .sidebar.shown, + .source-sidebar-expanded .source .sidebar, + .sidebar:focus-within { + left: 0; + } + .swaydoc.source > .sidebar { + position: fixed; + margin: 0; + z-index: 11; + width: 0; + } + .mobile-topbar .location a { + padding: 0; + margin: 0; + } + .mobile-topbar .location { + border: none; + padding: 0; + margin: auto 0.5em auto auto; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + font-size: 24px; + } + .mobile-topbar .logo-container { + max-height: 45px; + } + .mobile-topbar .logo-container > img { + max-width: 35px; + max-height: 35px; + margin-left: 20px; + margin-top: 5px; + margin-bottom: 5px; + } + .mobile-topbar { + display: flex; + flex-direction: row; + position: sticky; + z-index: 10; + font-size: 2rem; + height: 45px; + width: 100%; + left: 0; + top: 0; + } + .source .mobile-topbar { + display: none; + } + .sidebar-menu-toggle { + width: 45px; + font-size: 32px; + border: none; + } + .sidebar-elems { + background-color: var(--sidebar-background-color); + } + .source nav:not(.sidebar).sub { + margin-left: 32px; + } + .content { + margin-left: 0px; + } + .source .content { + margin-top: 10px; + } + #search { + margin-left: 0; + padding: 0; + } + .anchor { + display: none !important; + } + .notable-traits { + position: absolute; + left: -22px; + top: 24px; + } + #titles > button > div.count { + float: left; + width: 100%; + } + #titles { + height: 50px; + } + #sidebar-filler { + position: fixed; + left: 45px; + width: calc(100% - 45px); + top: 0; + height: 45px; + z-index: -1; + border-bottom: 1px solid; + } + #main-content > details.swaydoc-toggle > summary::before, + #main-content > div > details.swaydoc-toggle > summary::before { + left: -11px; + } + #sidebar-toggle { + position: fixed; + left: 1px; + top: 100px; + width: 30px; + font-size: 1.5rem; + text-align: center; + padding: 0; + z-index: 10; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + cursor: pointer; + font-weight: bold; + border: 1px solid; + border-left: 0; + } + .source-sidebar-expanded #sidebar-toggle { + left: unset; + top: unset; + width: unset; + border-top-right-radius: unset; + border-bottom-right-radius: unset; + position: sticky; + border: 0; + border-bottom: 1px solid; + } + #source-sidebar { + z-index: 11; + } + #main-content > .line-numbers { + margin-top: 0; + } + .notable-traits .notable-traits-tooltiptext { + left: 0; + top: 100%; + } + #help-button { + display: none; + } + .item-table { + display: block; + } + .item-row { + display: flex; + flex-flow: column wrap; + } + .item-left, + .item-right { + width: 100%; + } + .search-results > a { + border-bottom: 1px solid #aaa9; + padding: 5px 0px; + } + .search-results .result-name, + .search-results div.desc, + .search-results .result-description { + width: 100%; + } + .search-results div.desc, + .search-results .result-description, + .item-right { + padding-left: 2em; + } + .source-sidebar-expanded .source .sidebar { + max-width: 100vw; + width: 100vw; + } + details.swaydoc-toggle:not(.top-doc) > summary { + margin-left: 10px; + } + .impl-items > details.swaydoc-toggle > summary:not(.hideme)::before, + #main-content > details.swaydoc-toggle:not(.top-doc) > summary::before, + #main-content > div > details.swaydoc-toggle > summary::before { + left: -11px; + } +} +@media print { + nav.sidebar, + nav.sub, + .content .out-of-band, + a.srclink, + #copy-path, + details.swaydoc-toggle[open] > summary::before, + details.swaydoc-toggle > summary::before, + details.swaydoc-toggle.top-doc > summary { + display: none; + } + .docblock { + margin-left: 0; + } + main { + padding: 10px; + } +} +@media (max-width: 464px) { + #titles, + #titles > button { + height: 73px; + } + #main-content > table:not(.table-display) td { + word-break: break-word; + width: 50%; + } + #crate-search { + border-radius: 4px; + } + .docblock { + margin-left: 12px; + } + .docblock code { + overflow-wrap: break-word; + overflow-wrap: anywhere; + } + .sub-container { + flex-direction: column; + } + .sub-logo-container { + align-self: center; + } + .source .sub-logo-container > img { + height: 35px; + width: 35px; + } + #sidebar-toggle { + top: 10px; + } + .source-sidebar-expanded #sidebar-toggle { + top: unset; + } +} +.method-toggle summary, +.implementors-toggle summary, +.impl { + margin-bottom: 0.75em; +} +.method-toggle[open] { + margin-bottom: 2em; +} +#trait-implementations-list .method-toggle, +#synthetic-implementations-list .method-toggle, +#blanket-implementations-list .method-toggle { + margin-bottom: 1em; +} +.scraped-example-list .scrape-help { + margin-left: 10px; + padding: 0 4px; + font-weight: normal; + font-size: 12px; + position: relative; + bottom: 1px; + background: transparent; + border-width: 1px; + border-style: solid; + border-radius: 50px; +} +.scraped-example .code-wrapper { + position: relative; + display: flex; + flex-direction: row; + flex-wrap: wrap; + width: 100%; +} +.scraped-example:not(.expanded) .code-wrapper { + max-height: 240px; +} +.scraped-example:not(.expanded) .code-wrapper pre { + overflow-y: hidden; + max-height: 240px; + padding-bottom: 0; +} +.scraped-example:not(.expanded) .code-wrapper pre.line-numbers { + overflow-x: hidden; +} +.scraped-example .code-wrapper .prev { + position: absolute; + top: 0.25em; + right: 2.25em; + z-index: 100; + cursor: pointer; +} +.scraped-example .code-wrapper .next { + position: absolute; + top: 0.25em; + right: 1.25em; + z-index: 100; + cursor: pointer; +} +.scraped-example .code-wrapper .expand { + position: absolute; + top: 0.25em; + right: 0.25em; + z-index: 100; + cursor: pointer; +} +.scraped-example:not(.expanded) .code-wrapper:before { + content: " "; + width: 100%; + height: 5px; + position: absolute; + z-index: 100; + top: 0; +} +.scraped-example:not(.expanded) .code-wrapper:after { + content: " "; + width: 100%; + height: 5px; + position: absolute; + z-index: 100; + bottom: 0; +} +.scraped-example .code-wrapper .line-numbers { + margin: 0; + padding: 14px 0; +} +.scraped-example .code-wrapper .line-numbers span { + padding: 0 14px; +} +.scraped-example .code-wrapper .example-wrap { + flex: 1; + overflow-x: auto; + overflow-y: hidden; + margin-bottom: 0; +} +.scraped-example:not(.expanded) .code-wrapper .example-wrap { + overflow-x: hidden; +} +.scraped-example .code-wrapper .example-wrap pre.sway { + overflow-x: inherit; + width: inherit; + overflow-y: hidden; +} +.more-examples-toggle { + max-width: calc(100% + 25px); + margin-top: 10px; + margin-left: -25px; +} +.more-examples-toggle .hide-more { + margin-left: 25px; + margin-bottom: 5px; + cursor: pointer; +} +.more-scraped-examples { + margin-left: 5px; + display: flex; + flex-direction: row; +} +.more-scraped-examples-inner { + width: calc(100% - 20px); +} +.toggle-line { + align-self: stretch; + margin-right: 10px; + margin-top: 5px; + padding: 0 4px; + cursor: pointer; +} +.toggle-line-inner { + min-width: 2px; + height: 100%; +} +.more-scraped-examples .scraped-example { + margin-bottom: 20px; +} +.more-scraped-examples .scraped-example:last-child { + margin-bottom: 0; +} +.example-links a { + margin-top: 20px; +} +.example-links ul { + margin-bottom: 0; +} +#all-types > p { + margin: 5px 0; +} diff --git a/v0.21.0/static.files/toggle-minus.svg b/v0.21.0/static.files/toggle-minus.svg new file mode 100644 index 00000000..73154788 --- /dev/null +++ b/v0.21.0/static.files/toggle-minus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/v0.21.0/static.files/toggle-plus.svg b/v0.21.0/static.files/toggle-plus.svg new file mode 100644 index 00000000..08b17033 --- /dev/null +++ b/v0.21.0/static.files/toggle-plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/v0.21.0/static.files/wheel.svg b/v0.21.0/static.files/wheel.svg new file mode 100644 index 00000000..01da3b24 --- /dev/null +++ b/v0.21.0/static.files/wheel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/v0.21.0/std/address/index.html b/v0.21.0/std/address/index.html new file mode 100644 index 00000000..b6b3b157 --- /dev/null +++ b/v0.21.0/std/address/index.html @@ -0,0 +1,3 @@ +address in std - Sway

Module std::address

Expand description

A wrapper around the b256 type to help enhance type-safety.

+

Structs

The Address type, a struct wrapper around the inner b256 value.

+
\ No newline at end of file diff --git a/v0.21.0/std/address/struct.Address.html b/v0.21.0/std/address/struct.Address.html new file mode 100644 index 00000000..a0d3ede1 --- /dev/null +++ b/v0.21.0/std/address/struct.Address.html @@ -0,0 +1,51 @@ +Address in address - Sway
pub struct Address {
+    /// The underlying raw `b256` data of the address.
+    bits: b256,
+}
Expand description

The Address type, a struct wrapper around the inner b256 value.

+

Fields

bits: b256

The underlying raw b256 data of the address.

+

Trait Implementations

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn from(bits: b256) -> Self

Casts raw b256 data to an Address.

+

Arguments

+
    +
  • bits: [b256] - The raw b256 data to be casted.
  • +
+

Returns

+
    +
  • [Address] - The newly created Address from the raw b256.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+
+fn foo() {
+   let address = Address::from(ZERO_B256);
+}
+
+

fn hash(
self,
refmut state: Hasher,
)

\ No newline at end of file diff --git a/v0.21.0/std/all.html b/v0.21.0/std/all.html new file mode 100644 index 00000000..862e1a0d --- /dev/null +++ b/v0.21.0/std/all.html @@ -0,0 +1,124 @@ +List of all items in this project

List of all items

Structs

The Address type, a struct wrapper around the inner b256 value.

+

An AssetId is used for interacting with an asset on the network.

+

Stores two b256s in contiguous memory.

A type used to represent raw bytes.

+

The ContractId type, a struct wrapper around the inner b256 value.

+

A struct representing the call parameters of a function call.

+

A persistent storage type to store a collection of tightly packed bytes.

+

A persistent key-value pair mapping struct.

+

A persistent vector struct.

+

A UTF-8 encoded growable string.

+

The 128-bit unsigned integer type.

+

A contiguous growable array type, written as Vec<T>, short for ‘vector’.

+

The EvmAddress type, a struct wrapper around the inner b256 value.

+

Enums

The error type used when an Identity cannot be determined.

+

The error type used when the ec_recover function fails.

+

The Identity type: either an Address or a ContractId.

+

The input type for a transaction.

+

A type that represents an optional value, either Some(val) or None.

The output type for a transaction.

+

Result is a type that represents either success (Ok) or failure (Err).

Errors pertaining to the StorageMap struct.

+

A transaction type.

+

The error type used for U128 type errors.

+

Traits

Used to do value-to-value conversions.

+

Used to do value-to-value conversions.

+

Used to attempt to do value-to-value conversions.

Calculates the binary log.

+

Trait for exponential functions.

Calculates the log with a given base.

+

Calculates a number to a given power.

+

Calculates the square root.

+

A general way to persistently store heap types.

+

Constants

The BASE_ASSET_ID represents the base asset of a chain.

+

The default Sub Id for assets.

+

A b256 of zero value.

+

A u256 of zero value.

+

A revert with this value signals that it was caused by a failing call to std::assert::assert_eq.

A revert with this value signals that it was caused by a failing call to std::assert::assert_ne.

A revert with this value signals that it was caused by a failing call to std::assert::assert.

A revert with this value signals that it was caused by a failing call to std::revert::require.

A revert with this value signals that it was caused by a failing call to std::asset::transfer_to_address.

Functions

Allocates zeroed memory on the heap.

+

Allocates zeroed memory on the heap in individual bytes.

+

Reallocates the given area of memory.

+

Reallocates the given area of memory in individual bytes.

+

Asserts that the given condition will always be true during runtime.

Asserts that the given values v1 & v2 will always be equal during runtime.

Asserts that the given values v1 & v2 will never be equal during runtime.

Burn amount coins of the current contract’s sub_id. Burns them from the balance of the current contract.

UNCONDITIONAL transfer of amount coins of type asset_id to

Mint amount coins of the current contract’s sub_id. The newly minted assets are owned by the current contract.

Mint amount coins of the current contract’s asset_id and transfer them

Mint amount coins of the current contract’s asset_id and send them to

Mint amount coins of the current contract’s asset_id and send them

Transfer amount coins of the type asset_id and send them

Transfer amount coins of type asset_id and send them to

Get the owner of the inputs (of type Input::Coin or Input::Message) to a

If the caller is internal, returns the contract ID of the caller.

+

Returns true if the caller is external (i.e. a script).

Get the Identity (i.e. Address or ContractId) from which a call was made.

Get the current predicate’s address when called in an internal context.

+

Get the header hash of the block at height block_height

+

Get the current block height.

+

Get the TAI64 timestamp of the current block.

+

Get the TAI64 timestamp of a block at a given block_height.

+

Get the code size in bytes (padded to word alignment) from the current call frame.

+

Get the current contract’s id when called in an internal context.

+

Get the first parameter from the current call frame.

+

Get the value of ContractId from any call frame on the stack.

+

Get a pointer to the previous (relative to the frame_pointer parameter) call frame using offsets from a pointer.

Get the asset_id of coins being sent from the current call frame.

+

Get the second parameter from the current call frame.

+

Get the balance of coin asset_id for the contract at ‘target’.

+

Get the amount of units of call_frames::msg_asset_id() being sent.

+

Get the balance of coin asset_id for the current contract.

+

Recover the public key derived from the private key used to sign a message.

Recover the address derived from the private key used to sign a message.

Recover the address derived from the private key used to sign a message.

Recover the public key derived from the private key used to sign a message.

Verifies that a public key derived from the private key was used to sign a message.

Load and run the contract with the provided ContractId.

+

Get the root of the bytecode of the contract at ‘contract_id’.

+

Allows overflowing operations to occur without a FuelVM panic.

+

Allows unsafe math operations to occur without a FuelVM panic.

Enables the default panic-on-overflow behavior in the FuelVM.

+

Enables the default panic-on-unsafe-math behavior in the FuelVM.

+

Sets the flag register to the given value.

+

Returns the KECCAK-256 hash of param.

+

Returns the SHA-2-256 hash of param.

+

Returns the SHA-2-256 hash of param.

Gets amount field from input at index.

+

Gets the AssetId of the input at index.

+

Gets owner field from input at index if it’s a coin.

+

Gets the transaction inputs count.

+

Gets the maturity from the input at index.

+

Gets the data of the input message at index.

+

Gets the length of the input message at index.

+

Gets the nonce of input message at index.

+

Gets the recipient of the input message at index.

+

Gets the sender of the input message at index.

+

Gets the pointer of the input at index.

+

Gets the predicate from the input at index.

+

Gets the predicate data from the input at index.

+

Gets the predicate data length from the input at index.

+

Gets the predicate data pointer from the input at index.

+

Gets the predicate length from the input at index.

+

Gets the predicate pointer from the input at index.

+

Gets the type of the input at index.

+

Gets the witness index from the input at index.

+

Returns whether a generic type T is a reference type or not.

+

Returns the size of a generic type T in bytes.

+

Returns the size of the type of a value in bytes.

+

Log any stack type.

+

Call a target contract with a function selector and calldata, provided as Bytes.

Call a target contract with a function selector and calldata, provided as Vec<u8>.

Sends a message msg_data to recipient with a coins amount of the base asset.

Sends a message msg_data of type T to recipient with a coins amount of the base asset.

The amount of coins to send to the output at index.

+

Gets the AssetId of the output if it is a Output::Coin.

+

Returns the receiver of the output if it is a Output::Coin. Represents the receiver as a b256.

Get the transaction outputs count for either tx_type

Get a pointer to the output at index

Get the type of an output at index.

+

Get the amount of units of call_frames::msg_asset_id() being sent.

+

Remaining gas in the context.

+

Error codes for particular operations.

+

Flags register.

+

Memory address of beginning of current call frame.

+

Remaining gas globally.

+

Memory address below the current bottom of the heap (points to free memory).

+

Pointer to the start of the currently-executing code.

+

Contains overflow & underflow of addition, subtraction, and multiplication.

+

The program counter. Memory address of the current instruction.

+

Return value length in bytes.

+

Return value or pointer.

+

Memory address on top of current writable stack area (points to free memory).

+

Memory address of bottom of current writable stack area.

+

Checks if the given condition is true and if not, logs value and reverts.

Will either panic or revert with a given number depending on the context.

+

Clear a sequence of storage slots starting at a some key.

+

Load a raw_slice from storage.

+

Store a raw_slice from the heap into storage.

+

Clear a value starting at some slot with an offset.

+

Reads a value of type T starting at the location specified by slot and offset. If the

Stores a stack value in storage. Will not work for heap values.

+

Get the script gas limit for the transaction.

+

Get the gas price for the transaction, if it is set.

+

Get the Transaction ID of the current transaction.

+

Get the maturity for the transaction, if it is set.

+

Get the max fee for the transaction, if it is set.

+

Get the transaction receipts root.

+

Get the script bytecode.

+

Get the hash of the script bytecode.
+Reverts if not a transaction-script.

+

Get the script data, typed.

+

Get the script data length for the transaction.

+

Get the transaction script data start pointer.

+

Get the length of the script for the transaction.

+

Get the transaction script start pointer.

+

Get the type of the current transaction.

Get the witness data at index.

+

Get the length of the witness data at index.

+

Get the witness limit for the transaction, if it is set.

+

Get a pointer to the witness at index index for the transaction.

+

Get the transaction witnesses count for the transaction.

+

Recover the EVM address derived from the private key used to sign a message.

\ No newline at end of file diff --git a/v0.21.0/std/alloc/fn.alloc.html b/v0.21.0/std/alloc/fn.alloc.html new file mode 100644 index 00000000..8e11d86b --- /dev/null +++ b/v0.21.0/std/alloc/fn.alloc.html @@ -0,0 +1,38 @@ +alloc in alloc - Sway

Function std::alloc::alloc

pub fn alloc<T>(count: u64) -> raw_ptr 
Expand description

Allocates zeroed memory on the heap.

+

Additional Information

+

In the FuelVM, the heap begins at VM_MAX_RAM and grows downward.
+The heap pointer($hp) always points to the first allocated byte.

+

Initially the heap will look like this:

+
                                                    ▾$hp
+... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
+                                                    ▴VM_MAX_RAM
+
+

After allocating with let ptr = alloc::<u64>(1):

+
                            ▾$hp
+... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
+                            ▴ptr                    ▴VM_MAX_RAM
+
+

After writing with sw(ptr, u64::max()):

+
                            ▾$hp
+... 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF |
+                            ▴ptr                    ▴VM_MAX_RAM
+
+

For more information, see the Fuel Spec for VM Initialization
+and the VM Instruction Set for Memory Allocation.

+

Arguments

+
    +
  • count: [u64] - The number of size_of<T> bytes to allocate onto the heap.
  • +
+

Returns

+
    +
  • [raw_ptr] - The pointer to the newly allocated memory.
  • +
+

Examples

+
use std::alloc::alloc;
+
+fn foo() {
+    let ptr = alloc::<u64>(2);
+    assert(!ptr.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/alloc/fn.alloc_bytes.html b/v0.21.0/std/alloc/fn.alloc_bytes.html new file mode 100644 index 00000000..f8c2ca61 --- /dev/null +++ b/v0.21.0/std/alloc/fn.alloc_bytes.html @@ -0,0 +1,18 @@ +alloc_bytes in alloc - Sway

Function std::alloc::alloc_bytes

pub fn alloc_bytes(count: u64) -> raw_ptr 
Expand description

Allocates zeroed memory on the heap in individual bytes.

+

Arguments

+
    +
  • count: [u64] - The number of bytes to allocate onto the heap.
  • +
+

Returns

+
    +
  • [raw_ptr] - The pointer to the newly allocated memory.
  • +
+

Examples

+
use std::alloc::alloc_bytes;
+
+fn foo() {
+    let ptr = alloc_bytes(2);
+    assert(!ptr.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/alloc/fn.realloc.html b/v0.21.0/std/alloc/fn.realloc.html new file mode 100644 index 00000000..7434d83d --- /dev/null +++ b/v0.21.0/std/alloc/fn.realloc.html @@ -0,0 +1,22 @@ +realloc in alloc - Sway

Function std::alloc::realloc

pub fn realloc<T>(ptr: raw_ptr, count: u64, new_count: u64) -> raw_ptr 
Expand description

Reallocates the given area of memory.

+

Arguments

+
    +
  • ptr: [raw_ptr] - The pointer to the area of memory to reallocate.
  • +
  • count: [u64] - The number of size_of<T> bytes kept when reallocating. These are not set to 0.
  • +
  • new_count: [u64] - The number of new size_of<T> bytes to allocate. These are set to 0.
  • +
+

Returns

+
    +
  • [raw_ptr] - The pointer to the newly reallocated memory.
  • +
+

Examples

+
use std::alloc::{alloc, realloc};
+
+fn foo() {
+    let ptr = alloc::<u64>(1);
+    ptr.write(5);
+    let reallocated_ptr = realloc::<u64>(ptr, 1, 2);
+    assert(reallocated_ptr.read::<u64>() == 5);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/alloc/fn.realloc_bytes.html b/v0.21.0/std/alloc/fn.realloc_bytes.html new file mode 100644 index 00000000..380d35ac --- /dev/null +++ b/v0.21.0/std/alloc/fn.realloc_bytes.html @@ -0,0 +1,22 @@ +realloc_bytes in alloc - Sway
pub fn realloc_bytes(ptr: raw_ptr, count: u64, new_count: u64) -> raw_ptr 
Expand description

Reallocates the given area of memory in individual bytes.

+

Arguments

+
    +
  • ptr: [raw_ptr] - The pointer to the area of memory to reallocate.
  • +
  • count: [u64] - The number of bytes kept when reallocating. These are not set to 0.
  • +
  • new_count: [u64] - The number of new bytes to allocate. These are set to 0.
  • +
+

Returns

+
    +
  • [raw_ptr] - The pointer to the newly reallocated memory.
  • +
+

Examples

+
use std::alloc::{alloc_bytes, realloc_bytes};
+
+fn foo() {
+    let ptr = alloc_bytes(8);
+    ptr.write(5);
+    let reallocated_ptr = realloc_bytes(ptr, 8, 16);
+    assert(reallocated_ptr.read::<u64>() == 5);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/alloc/index.html b/v0.21.0/std/alloc/index.html new file mode 100644 index 00000000..d0759af7 --- /dev/null +++ b/v0.21.0/std/alloc/index.html @@ -0,0 +1,6 @@ +alloc in std - Sway

Module std::alloc

Expand description

A library for allocating memory inspired by Rust’s std::alloc.

+

Functions

Allocates zeroed memory on the heap.

+

Allocates zeroed memory on the heap in individual bytes.

+

Reallocates the given area of memory.

+

Reallocates the given area of memory in individual bytes.

+
\ No newline at end of file diff --git a/v0.21.0/std/assert/fn.assert.html b/v0.21.0/std/assert/fn.assert.html new file mode 100644 index 00000000..0611f804 --- /dev/null +++ b/v0.21.0/std/assert/fn.assert.html @@ -0,0 +1,20 @@ +assert in assert - Sway

Function std::assert::assert

pub fn assert(condition: bool) 
Expand description

Asserts that the given condition will always be true during runtime.

+

Additional Information

+

To check for conditions that may not be true, use std::revert::require instead.
+For more information, see the Wiki article on Assertion.

+

Arguments

+
    +
  • condition: [bool] - The condition which will be asserted to be true.
  • +
+

Reverts

+
    +
  • Reverts when condition is false.
  • +
+

Examples

+
fn foo(a: u64, b: u64) {
+    assert(a == b);
+    // if code execution continues, that means a was equal to b
+    log("a is equal to b");
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/assert/fn.assert_eq.html b/v0.21.0/std/assert/fn.assert_eq.html new file mode 100644 index 00000000..d7d8df1e --- /dev/null +++ b/v0.21.0/std/assert/fn.assert_eq.html @@ -0,0 +1,21 @@ +assert_eq in assert - Sway

Function std::assert::assert_eq

pub fn assert_eq<T>(v1: T, v2: T)
+where
+    T: Eq,
+
Expand description

Asserts that the given values v1 & v2 will always be equal during runtime.

+

Arguments

+
    +
  • v1: [T] - The first value to compare.
  • +
  • v2: [T] - The second value to compare.
  • +
+

Reverts

+
    +
  • Reverts when v1 != v2.
  • +
+

Examples

+
fn foo(a: u64, b: u64) {
+    assert_eq(a, b);
+    // if code execution continues, that means `a` is equal to `b`
+    log("a is equal to b");
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/assert/fn.assert_ne.html b/v0.21.0/std/assert/fn.assert_ne.html new file mode 100644 index 00000000..e56468e7 --- /dev/null +++ b/v0.21.0/std/assert/fn.assert_ne.html @@ -0,0 +1,21 @@ +assert_ne in assert - Sway

Function std::assert::assert_ne

pub fn assert_ne<T>(v1: T, v2: T)
+where
+    T: Eq,
+
Expand description

Asserts that the given values v1 & v2 will never be equal during runtime.

+

Arguments

+
    +
  • v1: [T] - The first value to compare.
  • +
  • v2: [T] - The second value to compare.
  • +
+

Reverts

+
    +
  • Reverts when v1 == v2.
  • +
+

Examples

+
fn foo(a: u64, b: u64) {
+    assert_ne(a, b);
+    // if code execution continues, that means `a` is not equal to `b`
+    log("a is not equal to b");
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/assert/index.html b/v0.21.0/std/assert/index.html new file mode 100644 index 00000000..eb90886a --- /dev/null +++ b/v0.21.0/std/assert/index.html @@ -0,0 +1,2 @@ +assert in std - Sway

Module std::assert

Expand description

Functions to assert a given condition.

+

Functions

Asserts that the given condition will always be true during runtime.

Asserts that the given values v1 & v2 will always be equal during runtime.

Asserts that the given values v1 & v2 will never be equal during runtime.

\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.burn.html b/v0.21.0/std/asset/fn.burn.html new file mode 100644 index 00000000..ccd3a749 --- /dev/null +++ b/v0.21.0/std/asset/fn.burn.html @@ -0,0 +1,18 @@ +burn in asset - Sway

Function std::asset::burn

pub fn burn(sub_id: SubId, amount: u64) 
Expand description

Burn amount coins of the current contract’s sub_id. Burns them from the balance of the current contract.

+

Arguments

+
    +
  • sub_id: [SubId] - The sub identifier of the asset which to burn.
  • +
  • amount: [u64] - The amount of coins to burn.
  • +
+

Reverts

+
    +
  • When the contract balance is less than amount.
  • +
+

Examples

+
use std::{constants::ZERO_B256, asset::burn};
+
+fn foo() {
+    burn(ZERO_B256, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.force_transfer_to_contract.html b/v0.21.0/std/asset/fn.force_transfer_to_contract.html new file mode 100644 index 00000000..a75dbfa0 --- /dev/null +++ b/v0.21.0/std/asset/fn.force_transfer_to_contract.html @@ -0,0 +1,26 @@ +force_transfer_to_contract in asset - Sway
pub fn force_transfer_to_contract(to: ContractId, asset_id: AssetId, amount: u64) 
Expand description

UNCONDITIONAL transfer of amount coins of type asset_id to
+the contract at to.

+

Additional Information

+

This will transfer coins to a contract even with no way to retrieve them
+(i.e. no withdrawal functionality on receiving contract), possibly leading
+to the PERMANENT LOSS OF COINS if not used with care.

+

Arguments

+
    +
  • to: [ContractId] - The recipient contract.
  • +
  • asset_id: [AssetId] - The asset to transfer.
  • +
  • amount: [u64] - The amount of coins to transfer.
  • +
+

Reverts

+
    +
  • When amount is greater than the contract balance for asset_id.
  • +
  • When amount is equal to zero.
  • +
+

Examples

+
use std::{constants::{BASE_ASSET_ID, ZERO_B256}, asset::force_transfer_to_contract};
+
+fn foo() {
+    let to_contract_id = ContractId::from(ZERO_B256);
+    force_transfer_to_contract(to_contract_id, BASE_ASSET_ID, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.mint.html b/v0.21.0/std/asset/fn.mint.html new file mode 100644 index 00000000..c3f8c3bb --- /dev/null +++ b/v0.21.0/std/asset/fn.mint.html @@ -0,0 +1,14 @@ +mint in asset - Sway

Function std::asset::mint

pub fn mint(sub_id: SubId, amount: u64) 
Expand description

Mint amount coins of the current contract’s sub_id. The newly minted assets are owned by the current contract.

+

Arguments

+
    +
  • sub_id: [SubId] - The sub identifier of the asset which to mint.
  • +
  • amount: [u64] - The amount of coins to mint.
  • +
+

Examples

+
use std::{constants::ZERO_B256, asset::mint};
+
+fn foo() {
+    mint(ZERO_B256, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.mint_to.html b/v0.21.0/std/asset/fn.mint_to.html new file mode 100644 index 00000000..49c8a77f --- /dev/null +++ b/v0.21.0/std/asset/fn.mint_to.html @@ -0,0 +1,24 @@ +mint_to in asset - Sway

Function std::asset::mint_to

pub fn mint_to(to: Identity, sub_id: SubId, amount: u64) 
Expand description

Mint amount coins of the current contract’s asset_id and transfer them
+to to by calling either force_transfer_to_contract or
+transfer_to_address, depending on the type of Identity.

+

Additional Information

+

If the to Identity is a contract, this will transfer coins to the contract even with no way to retrieve them
+(i.e: no withdrawal functionality on the receiving contract), possibly leading to
+the PERMANENT LOSS OF COINS if not used with care.

+

Arguments

+
    +
  • to: [Identity] - The recipient identity.
  • +
  • sub_id: [SubId] - The sub identifier of the asset which to mint.
  • +
  • amount: [u64] - The amount of coins to mint.
  • +
+

Examples

+
use std::{constants::ZERO_B256, asset::mint_to};
+
+fn foo() {
+    let to_address = Identity::Address(Address::from(ZERO_B256));
+    let to_contract_id = Identity::ContractId(ContractId::from(ZERO_B256));
+    mint_to(to_address, ZERO_B256, 500);
+    mint_to(to_contract_id, ZERO_B256, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.mint_to_address.html b/v0.21.0/std/asset/fn.mint_to_address.html new file mode 100644 index 00000000..5f80d87d --- /dev/null +++ b/v0.21.0/std/asset/fn.mint_to_address.html @@ -0,0 +1,17 @@ +mint_to_address in asset - Sway
pub fn mint_to_address(to: Address, sub_id: SubId, amount: u64) 
Expand description

Mint amount coins of the current contract’s asset_id and send them to
+the Address to.

+

Arguments

+
    +
  • to: [Address] - The recipient address.
  • +
  • sub_id: [SubId] - The sub identifier of the asset which to mint.
  • +
  • amount: [u64] - The amount of coins to mint.
  • +
+

Examples

+
use std::{constants::ZERO_B256, asset::mint_to_address};
+
+fn foo() {
+    let to = Address::from(ZERO_B256);
+    mint_to_address(to, ZERO_B256, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.mint_to_contract.html b/v0.21.0/std/asset/fn.mint_to_contract.html new file mode 100644 index 00000000..91056213 --- /dev/null +++ b/v0.21.0/std/asset/fn.mint_to_contract.html @@ -0,0 +1,21 @@ +mint_to_contract in asset - Sway
pub fn mint_to_contract(to: ContractId, sub_id: SubId, amount: u64) 
Expand description

Mint amount coins of the current contract’s asset_id and send them
+UNCONDITIONALLY to the contract at to.

+

Additional Information

+

This will transfer coins to a contract even with no way to retrieve them
+(i.e: no withdrawal functionality on the receiving contract), possibly leading to
+the PERMANENT LOSS OF COINS if not used with care.

+

Arguments

+
    +
  • to: [ContractId] - The recipient contract.
  • +
  • sub_id: [SubId] - The sub identifier of the asset which to mint.
  • +
  • amount: [u64] - The amount of coins to mint.
  • +
+

Examples

+
use std::{constants::ZERO_B256, asset::mint_to_contract};
+
+fn foo() {
+    let to = ContractId::from(ZERO_B256);
+    mint_to_contract(to, ZERO_B256, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.transfer.html b/v0.21.0/std/asset/fn.transfer.html new file mode 100644 index 00000000..dcbf61e1 --- /dev/null +++ b/v0.21.0/std/asset/fn.transfer.html @@ -0,0 +1,30 @@ +transfer in asset - Sway

Function std::asset::transfer

pub fn transfer(to: Identity, asset_id: AssetId, amount: u64) 
Expand description

Transfer amount coins of the type asset_id and send them
+to to by calling either force_transfer_to_contract or
+transfer_to_address, depending on the type of Identity.

+

Additional Information

+

If the to Identity is a contract this may transfer coins to the contract even with no way to retrieve them
+(i.e. no withdrawal functionality on receiving contract), possibly leading
+to the PERMANENT LOSS OF COINS if not used with care.

+

Arguments

+
    +
  • to: [Identity] - The recipient identity.
  • +
  • asset_id: [AssetId] - The asset to transfer.
  • +
  • amount: [u64] - The amount of coins to transfer.
  • +
+

Reverts

+
    +
  • When amount is greater than the contract balance for asset_id.
  • +
  • When amount is equal to zero.
  • +
  • When there are no free variable outputs when transferring to an Address.
  • +
+

Examples

+
use std::{constants::{BASE_ASSET_ID, ZERO_B256}, asset::transfer};
+
+fn foo() {
+    let to_address = Identity::Address(Address::from(ZERO_B256));
+    let to_contract_id = Identity::ContractId(ContractId::from(ZERO_B256));
+    transfer(to_address, BASE_ASSET_ID, 500);
+    transfer(to_contract_id, BASE_ASSET_ID, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/fn.transfer_to_address.html b/v0.21.0/std/asset/fn.transfer_to_address.html new file mode 100644 index 00000000..50447fb8 --- /dev/null +++ b/v0.21.0/std/asset/fn.transfer_to_address.html @@ -0,0 +1,23 @@ +transfer_to_address in asset - Sway
pub fn transfer_to_address(to: Address, asset_id: AssetId, amount: u64) 
Expand description

Transfer amount coins of type asset_id and send them to
+the address to.

+

Arguments

+
    +
  • to: [Address] - The recipient address.
  • +
  • asset_id: [AssetId] - The asset to transfer.
  • +
  • amount: [u64] - The amount of coins to transfer.
  • +
+

Reverts

+
    +
  • When amount is greater than the contract balance for asset_id.
  • +
  • When amount is equal to zero.
  • +
  • When there are no free variable outputs.
  • +
+

Examples

+
use std::{constants::{BASE_ASSET_ID, ZERO_B256}, asset::transfer_to_address};
+
+fn foo() {
+    let to_address = Address::from(ZERO_B256);
+    transfer_to_address(to_address, BASE_ASSET_ID, 500);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/asset/index.html b/v0.21.0/std/asset/index.html new file mode 100644 index 00000000..73942093 --- /dev/null +++ b/v0.21.0/std/asset/index.html @@ -0,0 +1,2 @@ +asset in std - Sway

Module std::asset

Expand description

Functionality for performing common operations with assets.

+

Functions

Burn amount coins of the current contract’s sub_id. Burns them from the balance of the current contract.

UNCONDITIONAL transfer of amount coins of type asset_id to

Mint amount coins of the current contract’s sub_id. The newly minted assets are owned by the current contract.

Mint amount coins of the current contract’s asset_id and transfer them

Mint amount coins of the current contract’s asset_id and send them to

Mint amount coins of the current contract’s asset_id and send them

Transfer amount coins of the type asset_id and send them

Transfer amount coins of type asset_id and send them to

\ No newline at end of file diff --git a/v0.21.0/std/asset_id/index.html b/v0.21.0/std/asset_id/index.html new file mode 100644 index 00000000..ac3b1de8 --- /dev/null +++ b/v0.21.0/std/asset_id/index.html @@ -0,0 +1,2 @@ +asset_id in std - Sway

Module std::asset_id

Structs

An AssetId is used for interacting with an asset on the network.

+
\ No newline at end of file diff --git a/v0.21.0/std/asset_id/struct.AssetId.html b/v0.21.0/std/asset_id/struct.AssetId.html new file mode 100644 index 00000000..d80984a8 --- /dev/null +++ b/v0.21.0/std/asset_id/struct.AssetId.html @@ -0,0 +1,54 @@ +AssetId in asset_id - Sway
pub struct AssetId {
+    bits: b256,
+}
Expand description

An AssetId is used for interacting with an asset on the network.

+

Additional Information

+

It is calculated by taking the sha256 hash of the originating ContractId and a SubId.
+i.e. sha256((contract_id, sub_id)).

+

An exception is the Base Asset, which is just the ZERO_B256 AssetId.

+

The SubId is used to differentiate between different assets that are created by the same contract.

+

Fields

bits: b256

Trait Implementations

fn hash(
self,
refmut state: Hasher,
)

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn from(bits: b256) -> Self

Casts raw b256 data to an AssetId.

+

Arguments

+
    +
  • bits: [b256] - The raw b256 data to be casted.
  • +
+

Returns

+
    +
  • [AssetId] - The newly created AssetId from the raw b256.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+
+fn foo() {
+   let asset_id = AssetId::from(ZERO_B256);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/auth/enum.AuthError.html b/v0.21.0/std/auth/enum.AuthError.html new file mode 100644 index 00000000..b47f4165 --- /dev/null +++ b/v0.21.0/std/auth/enum.AuthError.html @@ -0,0 +1,9 @@ +AuthError in auth - Sway
pub enum AuthError {
+    /// The caller is external, but the inputs to the transaction are not all owned by the same address.
+    InputsNotAllOwnedBySameAddress: (),
+    /// The caller is internal, but the `caller_address` function was called.
+    CallerIsInternal: (),
+}
Expand description

The error type used when an Identity cannot be determined.

+

Variants

InputsNotAllOwnedBySameAddress: ()

The caller is external, but the inputs to the transaction are not all owned by the same address.

+

CallerIsInternal: ()

The caller is internal, but the caller_address function was called.

+
\ No newline at end of file diff --git a/v0.21.0/std/auth/fn.caller_address.html b/v0.21.0/std/auth/fn.caller_address.html new file mode 100644 index 00000000..420df8ba --- /dev/null +++ b/v0.21.0/std/auth/fn.caller_address.html @@ -0,0 +1,17 @@ +caller_address in auth - Sway
pub fn caller_address() -> Result<Address, AuthError> 
Expand description

Get the owner of the inputs (of type Input::Coin or Input::Message) to a
+TransactionScript if they all share the same owner.

+

Returns

+
    +
  • [Result<Address, AuthError>] - Ok(Address) if the owner can be determined, Err(AuthError) otherwise.
  • +
+

Examples

+
use std::auth::inputs_owner;
+
+fn foo() {
+    match inputs_owner() {
+        Ok(address) => log(address),
+        Err(AuthError::InputsNotAllOwnedBySameAddress) => log("Inputs not all owned by same address."),
+    }
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/auth/fn.caller_contract_id.html b/v0.21.0/std/auth/fn.caller_contract_id.html new file mode 100644 index 00000000..72ab4096 --- /dev/null +++ b/v0.21.0/std/auth/fn.caller_contract_id.html @@ -0,0 +1,18 @@ +caller_contract_id in auth - Sway
pub fn caller_contract_id() -> ContractId 
Expand description

If the caller is internal, returns the contract ID of the caller.

+

Additional Information

+

External calls result in undefined behaviour.

+

Returns

+
    +
  • [ContractId] - The contract ID of the caller.
  • +
+

Examples

+
use std::auth::{caller_is_external, caller_contract_id};
+
+fn foo() {
+    if !caller_is_external() {
+        let caller_contract_id = caller_contract_id();
+        log(caller_contract_id);
+    }
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/auth/fn.caller_is_external.html b/v0.21.0/std/auth/fn.caller_is_external.html new file mode 100644 index 00000000..e328a17e --- /dev/null +++ b/v0.21.0/std/auth/fn.caller_is_external.html @@ -0,0 +1,20 @@ +caller_is_external in auth - Sway
pub fn caller_is_external() -> bool 
Expand description

Returns true if the caller is external (i.e. a script).
+Otherwise, if the caller is a contract, returns false.

+

Additional Information

+

For more information refer to the VM Instruction Set.

+

Returns

+
    +
  • [bool] - true if the caller is external, false otherwise.
  • +
+

Examples

+
use std::auth::caller_is_external;
+
+fn foo() {
+    if caller_is_external() {
+        log("Caller is external.")
+    } else {
+        log("Caller is a contract.")
+    }
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/auth/fn.msg_sender.html b/v0.21.0/std/auth/fn.msg_sender.html new file mode 100644 index 00000000..123c8f3e --- /dev/null +++ b/v0.21.0/std/auth/fn.msg_sender.html @@ -0,0 +1,20 @@ +msg_sender in auth - Sway

Function std::auth::msg_sender

pub fn msg_sender() -> Result<Identity, AuthError> 
Expand description

Get the Identity (i.e. Address or ContractId) from which a call was made.
+Returns a Ok(Identity), or Err(AuthError) if an identity cannot be determined.

+

Additional Information

+

Returns an AuthError::InputsNotAllOwnedBySameAddress if the caller is external and the inputs to the transaction are not all owned by the same address.
+Should not return an AuthError::CallerIsInternal under any circumstances.

+

Returns

+
    +
  • [Result<Identity, AuthError>] - Ok(Identity) if the identity can be determined, Err(AuthError) otherwise.
  • +
+

Examples

+
fn foo() {
+    match msg_sender() {
+        Ok(Identity::Address(address)) => log(address),
+        Ok(Identity::ContractId(contract_id)) => log(contract_id),
+        Err(AuthError::InputsNotAllOwnedBySameAddress) => log("Inputs not all owned by same address."),
+        Err(AuthError::CallerIsInternal) => log("Hell froze over."),
+    }
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/auth/fn.predicate_address.html b/v0.21.0/std/auth/fn.predicate_address.html new file mode 100644 index 00000000..aa57c047 --- /dev/null +++ b/v0.21.0/std/auth/fn.predicate_address.html @@ -0,0 +1,18 @@ +predicate_address in auth - Sway
pub fn predicate_address() -> Address 
Expand description

Get the current predicate’s address when called in an internal context.

+

Returns

+
    +
  • [Address] - The address of this predicate.
  • +
+

Reverts

+
    +
  • When called outside of a predicate program.
  • +
+

Examples

+
use std::auth::predicate_address;
+
+fn main() {
+    let this_predicate = predicate_address();
+    log(this_predicate);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/auth/index.html b/v0.21.0/std/auth/index.html new file mode 100644 index 00000000..3fb7e5e4 --- /dev/null +++ b/v0.21.0/std/auth/index.html @@ -0,0 +1,5 @@ +auth in std - Sway

Module std::auth

Expand description

Functionality for determining who is calling a contract.

+

Enums

The error type used when an Identity cannot be determined.

+

Functions

Get the owner of the inputs (of type Input::Coin or Input::Message) to a

If the caller is internal, returns the contract ID of the caller.

+

Returns true if the caller is external (i.e. a script).

Get the Identity (i.e. Address or ContractId) from which a call was made.

Get the current predicate’s address when called in an internal context.

+
\ No newline at end of file diff --git a/v0.21.0/std/b512/index.html b/v0.21.0/std/b512/index.html new file mode 100644 index 00000000..4479022f --- /dev/null +++ b/v0.21.0/std/b512/index.html @@ -0,0 +1,3 @@ +b512 in std - Sway

Module std::b512

Expand description

A wrapper around two b256 types to support the usage of 64-byte values in Sway,
+which are needed when working with public keys and signatures.

+

Structs

Stores two b256s in contiguous memory.

\ No newline at end of file diff --git a/v0.21.0/std/b512/struct.B512.html b/v0.21.0/std/b512/struct.B512.html new file mode 100644 index 00000000..a905c215 --- /dev/null +++ b/v0.21.0/std/b512/struct.B512.html @@ -0,0 +1,36 @@ +B512 in b512 - Sway

Struct std::b512::B512

pub struct B512 {
+    /// The two `b256`s that make up the `B512`.
+    bits: [b256; 2],
+}
Expand description

Stores two b256s in contiguous memory.
+Guaranteed to be contiguous for use with ec-recover: std::ecr::ec_recover.

+

Fields

bits: [b256; 2]

The two b256s that make up the B512.

+

Trait Implementations

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn from(components: (b256, b256)) -> Self

\ No newline at end of file diff --git a/v0.21.0/std/block/fn.block_header_hash.html b/v0.21.0/std/block/fn.block_header_hash.html new file mode 100644 index 00000000..6566a0f6 --- /dev/null +++ b/v0.21.0/std/block/fn.block_header_hash.html @@ -0,0 +1,14 @@ +block_header_hash in block - Sway
pub fn block_header_hash(block_height: u32) -> Result<b256, BlockHashError> 
Expand description

Get the header hash of the block at height block_height

+

Returns

+
    +
  • [Result<b256, BlockHashError>] - The header hash of the block at block_height, or a [BlockHashError] if the block is not found.
  • +
+

Examples

+
use std::block::block_header_hash;
+
+fn foo() {
+    let header_hash_of_block_100 = block_header_hash(100u32);
+    log(header_hash_of_block_100);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/block/fn.height.html b/v0.21.0/std/block/fn.height.html new file mode 100644 index 00000000..cfe2533b --- /dev/null +++ b/v0.21.0/std/block/fn.height.html @@ -0,0 +1,14 @@ +height in block - Sway

Function std::block::height

pub fn height() -> u32 
Expand description

Get the current block height.

+

Returns

+
    +
  • [u32] - The current block height.
  • +
+

Examples

+
use std::block::height;
+
+fn foo() {
+    let current_height = height();
+    log(current_height);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/block/fn.timestamp.html b/v0.21.0/std/block/fn.timestamp.html new file mode 100644 index 00000000..551f07cd --- /dev/null +++ b/v0.21.0/std/block/fn.timestamp.html @@ -0,0 +1,18 @@ +timestamp in block - Sway

Function std::block::timestamp

pub fn timestamp() -> u64 
Expand description

Get the TAI64 timestamp of the current block.

+

Additional Information

+

The TAI64 timestamp begins at 262 seconds before 1970, and ends at 262 seconds after 1970,
+with a TAI second defined as the duration of 9192631770 periods of the radiation corresponding
+to the transition between the two hyperfine levels of the ground state of the cesium atom.

+

Returns

+
    +
  • [u64] - The TAI64 timestamp of the current block.
  • +
+

Examples

+
use std::block::timestamp;
+
+fn foo() {
+    let current_timestamp = timestamp();
+    log(current_timestamp);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/block/fn.timestamp_of_block.html b/v0.21.0/std/block/fn.timestamp_of_block.html new file mode 100644 index 00000000..b5b6e1c0 --- /dev/null +++ b/v0.21.0/std/block/fn.timestamp_of_block.html @@ -0,0 +1,22 @@ +timestamp_of_block in block - Sway
pub fn timestamp_of_block(block_height: u32) -> u64 
Expand description

Get the TAI64 timestamp of a block at a given block_height.

+

Additional Information

+

The TAI64 timestamp begins at 262 seconds before 1970, and ends at 262 seconds after 1970,
+with a TAI second defined as the duration of 9192631770 periods of the radiation corresponding
+to the transition between the two hyperfine levels of the ground state of the cesium atom.

+

Arguments

+
    +
  • block_height: [u32] - The height of the block to get the timestamp of.
  • +
+

Returns

+
    +
  • [u64] - The TAI64 timestamp of the block at block_height.
  • +
+

Examples

+
use std::block::timestamp_of_block;
+
+fn foo() {
+    let timestamp_of_block_100 = timestamp_of_block(100u32);
+    log(timestamp_of_block_100);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/block/index.html b/v0.21.0/std/block/index.html new file mode 100644 index 00000000..083f8eea --- /dev/null +++ b/v0.21.0/std/block/index.html @@ -0,0 +1,6 @@ +block in std - Sway

Module std::block

Expand description

Functionality for accessing block-related data.

+

Functions

Get the header hash of the block at height block_height

+

Get the current block height.

+

Get the TAI64 timestamp of the current block.

+

Get the TAI64 timestamp of a block at a given block_height.

+
\ No newline at end of file diff --git a/v0.21.0/std/bytes/fn.test_encode_decode.html b/v0.21.0/std/bytes/fn.test_encode_decode.html new file mode 100644 index 00000000..5b8909b8 --- /dev/null +++ b/v0.21.0/std/bytes/fn.test_encode_decode.html @@ -0,0 +1 @@ +test_encode_decode in bytes - Sway
pub fn test_encode_decode() 
Expand description
\ No newline at end of file diff --git a/v0.21.0/std/bytes/index.html b/v0.21.0/std/bytes/index.html new file mode 100644 index 00000000..b928754f --- /dev/null +++ b/v0.21.0/std/bytes/index.html @@ -0,0 +1,3 @@ +bytes in std - Sway

Module std::bytes

Expand description

The Bytes type is used when a collection of tightly-packed arbitrary bytes is needed.

+

Structs

A type used to represent raw bytes.

+

Functions

\ No newline at end of file diff --git a/v0.21.0/std/bytes/struct.Bytes.html b/v0.21.0/std/bytes/struct.Bytes.html new file mode 100644 index 00000000..4379fbe8 --- /dev/null +++ b/v0.21.0/std/bytes/struct.Bytes.html @@ -0,0 +1,80 @@ +Bytes in bytes - Sway

Struct std::bytes::Bytes

pub struct Bytes {
+    /// A barebones struct for the bytes.
+    buf: RawBytes,
+    /// The number of bytes being stored.
+    len: u64,
+}
Expand description

A type used to represent raw bytes.

+

Fields

buf: RawBytes

A barebones struct for the bytes.

+
len: u64

The number of bytes being stored.

+

Trait Implementations

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn as_raw_slice(self) -> raw_slice

Returns a raw slice of all of the elements in the type.

+

fn from(b: b256) -> Self

fn from(slice: raw_slice) -> Self

Creates a Bytes from a raw_slice.

+

Examples

+
use std:bytes::Bytes;
+
+let mut vec = Vec::new();
+let a = 5u8;
+let b = 7u8;
+let c = 9u8
+
+vec.push(a);
+vec.push(b);
+vec.push(c);
+
+let vec_as_raw_slice = vec.as_raw_slice();
+let bytes = Bytes::from(vec_as_raw_slice);
+
+assert(bytes.len == 3);
+assert(bytes.get(0).unwrap() == a);
+assert(bytes.get(1).unwrap() == b);
+assert(bytes.get(2).unwrap() == c);
+
+

fn from(vec: Vec<u8>) -> Self

Creates a Bytes from a Vec<u8>.

+

Examples

+
use std:bytes::Bytes;
+
+let mut vec = Vec::new();
+let a = 5u8;
+let b = 7u8;
+let c = 9u8
+
+vec.push(a);
+vec.push(b);
+vec.push(c);
+
+let bytes = Bytes::from(vec);
+
+assert(bytes.len == 3);
+assert(bytes.get(0).unwrap() == a);
+assert(bytes.get(1).unwrap() == b);
+assert(bytes.get(2).unwrap() == c);
+
+

fn abi_encode(
self,
refmut buffer: Buffer,
)

fn abi_decode(refmut buffer: BufferReader) -> Bytes

fn hash(
self,
refmut state: Hasher,
)

fn from(s: String) -> Bytes

\ No newline at end of file diff --git a/v0.21.0/std/call_frames/fn.code_size.html b/v0.21.0/std/call_frames/fn.code_size.html new file mode 100644 index 00000000..2ae08572 --- /dev/null +++ b/v0.21.0/std/call_frames/fn.code_size.html @@ -0,0 +1,17 @@ +code_size in call_frames - Sway
pub fn code_size() -> u64 
Expand description

Get the code size in bytes (padded to word alignment) from the current call frame.

+

Additional Information

+

More information on data from call frames can be found in the Fuel Specs.
+https://specs.fuel.network/master/fuel-vm/index.html?search=#call-frames

+

Returns

+
    +
  • [u64] - The code size of the current call frame.
  • +
+

Examples

+
use std::call_frames::code_size;
+
+fn foo() {
+    let size = code_size();
+    assert(size != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/call_frames/fn.contract_id.html b/v0.21.0/std/call_frames/fn.contract_id.html new file mode 100644 index 00000000..d36d7f33 --- /dev/null +++ b/v0.21.0/std/call_frames/fn.contract_id.html @@ -0,0 +1,18 @@ +contract_id in call_frames - Sway
pub fn contract_id() -> ContractId 
Expand description

Get the current contract’s id when called in an internal context.

+

Additional Information

+

Note: If called in an external context, this will not return a contract ID.
+If called externally, will actually return a pointer to the transaction ID.

+

Returns

+
    +
  • [ContractId] - The contract id of this contract.
  • +
+

Examples

+
use std::{call_frames::contract_id, constants::ZERO_B256, asset::mint};
+
+fn foo() {
+    let this_contract = contract_id();
+    mint(ZERO_B256, 50);
+    Address::from(ZERO_B256).transfer(AssetId::default(this_contract), 50);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/call_frames/fn.first_param.html b/v0.21.0/std/call_frames/fn.first_param.html new file mode 100644 index 00000000..b66195fc --- /dev/null +++ b/v0.21.0/std/call_frames/fn.first_param.html @@ -0,0 +1,17 @@ +first_param in call_frames - Sway
pub fn first_param() -> u64 
Expand description

Get the first parameter from the current call frame.

+

Additional Information

+

More information on data from call frames can be found in the Fuel Specs.
+https://specs.fuel.network/master/fuel-vm/index.html?search=#call-frames

+

Returns

+
    +
  • [u64] - The first parameter of the current call frame.
  • +
+

Examples

+
use std::call_frames::first_param;
+
+fn foo() {
+    let param = first_param();
+    assert(param != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/call_frames/fn.get_contract_id_from_call_frame.html b/v0.21.0/std/call_frames/fn.get_contract_id_from_call_frame.html new file mode 100644 index 00000000..315a672c --- /dev/null +++ b/v0.21.0/std/call_frames/fn.get_contract_id_from_call_frame.html @@ -0,0 +1,18 @@ +get_contract_id_from_call_frame in call_frames - Sway
pub fn get_contract_id_from_call_frame(frame_pointer: raw_ptr) -> ContractId 
Expand description

Get the value of ContractId from any call frame on the stack.

+

Arguments

+
    +
  • frame_pointer: [raw_ptr] - The call frame for which the Contract Id is to be returned.
  • +
+

Returns

+
    +
  • [ContractId] - The Contract Id of for the call frame.
  • +
+

Examples

+
use std::{call_frames::get_contract_id_from_call_frame, registers::frame_ptr};
+
+fn foo() {
+    let current_call_frame = frame_ptr();
+    let contract_id = get_contract_id_from_call_frame(current_call_frame);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/call_frames/fn.get_previous_frame_pointer.html b/v0.21.0/std/call_frames/fn.get_previous_frame_pointer.html new file mode 100644 index 00000000..e87ea7d2 --- /dev/null +++ b/v0.21.0/std/call_frames/fn.get_previous_frame_pointer.html @@ -0,0 +1,22 @@ +get_previous_frame_pointer in call_frames - Sway
pub fn get_previous_frame_pointer(frame_pointer: raw_ptr) -> raw_ptr 
Expand description

Get a pointer to the previous (relative to the frame_pointer parameter) call frame using offsets from a pointer.

+

Additional Information

+

More information on data from call frames can be found in the Fuel Specs.
+https://specs.fuel.network/master/fuel-vm/index.html?search=#call-frames

+

Arguments

+
    +
  • frame_pointer: [raw_ptr] - The call frame reference directly before the returned call frame pointer.
  • +
+

Returns

+
    +
  • [raw_ptr] - The memory location of the previous call frame data.
  • +
+

Examples

+
use std::{call_frames::get_previous_frame_pointer, registers::frame_ptr};
+
+fn foo() {
+    let current_call_frame = frame_ptr();
+    let previous_call_frame = get_previous_frame_pointer(current_call_frame);
+    assert(!previous_call_frame.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/call_frames/fn.msg_asset_id.html b/v0.21.0/std/call_frames/fn.msg_asset_id.html new file mode 100644 index 00000000..b1b7f782 --- /dev/null +++ b/v0.21.0/std/call_frames/fn.msg_asset_id.html @@ -0,0 +1,14 @@ +msg_asset_id in call_frames - Sway
pub fn msg_asset_id() -> AssetId 
Expand description

Get the asset_id of coins being sent from the current call frame.

+

Returns

+
    +
  • [AssetId] - The asset included in the current call frame.
  • +
+

Examples

+
use std::{call_frames::msg_asset_id, constants::BASE_ASSET_ID};
+
+fn foo() {
+    let asset = msg_asset_id();
+    assert(asset == BASE_ASSET_ID);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/call_frames/fn.second_param.html b/v0.21.0/std/call_frames/fn.second_param.html new file mode 100644 index 00000000..af75c10e --- /dev/null +++ b/v0.21.0/std/call_frames/fn.second_param.html @@ -0,0 +1,17 @@ +second_param in call_frames - Sway
pub fn second_param<T>() -> T 
Expand description

Get the second parameter from the current call frame.

+

Additional Information

+

More information on data from call frames can be found in the Fuel Specs.
+https://specs.fuel.network/master/fuel-vm/index.html?search=#call-frames

+

Returns

+
    +
  • [u64] - The second parameter of the current call frame.
  • +
+

Examples

+
use std::call_frames::second_param;
+
+fn foo() {
+    let param: u64 = second_param();
+    assert(param != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/call_frames/index.html b/v0.21.0/std/call_frames/index.html new file mode 100644 index 00000000..884a22c3 --- /dev/null +++ b/v0.21.0/std/call_frames/index.html @@ -0,0 +1,9 @@ +call_frames in std - Sway
Expand description

Helper functions for accessing data from call frames.
+Call frames store metadata across untrusted inter-contract calls.

+

Functions

Get the code size in bytes (padded to word alignment) from the current call frame.

+

Get the current contract’s id when called in an internal context.

+

Get the first parameter from the current call frame.

+

Get the value of ContractId from any call frame on the stack.

+

Get a pointer to the previous (relative to the frame_pointer parameter) call frame using offsets from a pointer.

Get the asset_id of coins being sent from the current call frame.

+

Get the second parameter from the current call frame.

+
\ No newline at end of file diff --git a/v0.21.0/std/constants/constant.BASE_ASSET_ID.html b/v0.21.0/std/constants/constant.BASE_ASSET_ID.html new file mode 100644 index 00000000..beb37fd9 --- /dev/null +++ b/v0.21.0/std/constants/constant.BASE_ASSET_ID.html @@ -0,0 +1,11 @@ +BASE_ASSET_ID in constants - Sway
pub const BASE_ASSET_ID: AssetId = AssetId::from(ZERO_B256)
Expand description

The BASE_ASSET_ID represents the base asset of a chain.

+

Additional Information

+

On the Fuel network, the base asset is Ether. It is hardcoded as the 0x00..00 ContractId.

+

Examples

+
use std::{call_frames::msg_asset_id, constants::BASE_ASSET_ID};
+
+fn foo() {
+    assert(BASE_ASSET_ID == msg_asset_id());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/constants/constant.DEFAULT_SUB_ID.html b/v0.21.0/std/constants/constant.DEFAULT_SUB_ID.html new file mode 100644 index 00000000..d697aaaf --- /dev/null +++ b/v0.21.0/std/constants/constant.DEFAULT_SUB_ID.html @@ -0,0 +1,10 @@ +DEFAULT_SUB_ID in constants - Sway
pub const DEFAULT_SUB_ID = ZERO_B256
Expand description

The default Sub Id for assets.

+

Examples

+
use std::{call_frames::contract_id, constants::DEFAULT_SUB_ID};
+
+fn foo() {
+    let asset = AssetId::default();
+    assert(AssetId::new(contract_id(), DEFAULT_SUB_ID) == msg_asset_id());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/constants/constant.ZERO_B256.html b/v0.21.0/std/constants/constant.ZERO_B256.html new file mode 100644 index 00000000..8a2050e0 --- /dev/null +++ b/v0.21.0/std/constants/constant.ZERO_B256.html @@ -0,0 +1,9 @@ +ZERO_B256 in constants - Sway
pub const ZERO_B256 = 0x0000000000000000000000000000000000000000000000000000000000000000
Expand description

A b256 of zero value.

+

Examples

+
use std::{call_frames::msg_asset_id, constants::ZERO_B256};
+
+fn foo() {
+    assert(ZERO_B256 == msg_asset_id().bits());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/constants/constant.ZERO_U256.html b/v0.21.0/std/constants/constant.ZERO_U256.html new file mode 100644 index 00000000..e98c6f1c --- /dev/null +++ b/v0.21.0/std/constants/constant.ZERO_U256.html @@ -0,0 +1,9 @@ +ZERO_U256 in constants - Sway
pub const ZERO_U256 = 0x00u256
Expand description

A u256 of zero value.

+

Examples

+
use std::constants::ZERO_U256;
+
+fn foo() {
+    assert(ZERO_U256 == u256::from(0_u64));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/constants/index.html b/v0.21.0/std/constants/index.html new file mode 100644 index 00000000..9f7b68e3 --- /dev/null +++ b/v0.21.0/std/constants/index.html @@ -0,0 +1,6 @@ +constants in std - Sway

Module std::constants

Expand description

Base asset and zero address constants.

+

Constants

The BASE_ASSET_ID represents the base asset of a chain.

+

The default Sub Id for assets.

+

A b256 of zero value.

+

A u256 of zero value.

+
\ No newline at end of file diff --git a/v0.21.0/std/context/fn.balance_of.html b/v0.21.0/std/context/fn.balance_of.html new file mode 100644 index 00000000..b0925bd5 --- /dev/null +++ b/v0.21.0/std/context/fn.balance_of.html @@ -0,0 +1,20 @@ +balance_of in context - Sway
pub fn balance_of(target: ContractId, asset_id: AssetId) -> u64 
Expand description

Get the balance of coin asset_id for the contract at ‘target’.

+

Arguments

+
    +
  • target: [ContractId] - The contract that contains the asset_id.
  • +
  • asset_id: [AssetId] - The asset of which the balance should be returned.
  • +
+

Returns

+
    +
  • [u64] - The amount of the asset which the target holds.
  • +
+

Examples

+
use std::{asset::mint, call_frames::contract_id, constants::DEFAULT_SUB_ID, context::balance_of};
+
+fn foo() {
+    mint(DEFAULT_SUB_ID, 50);
+    let asset_id = AssetId::default();
+    assert(balance_of(contract_id(), asset_id) == 50);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/context/fn.msg_amount.html b/v0.21.0/std/context/fn.msg_amount.html new file mode 100644 index 00000000..6ebb27bb --- /dev/null +++ b/v0.21.0/std/context/fn.msg_amount.html @@ -0,0 +1,13 @@ +msg_amount in context - Sway
pub fn msg_amount() -> u64 
Expand description

Get the amount of units of call_frames::msg_asset_id() being sent.

+

Returns

+
    +
  • [u64] - The amount of coins being sent.
  • +
+

Examples

+
use std::context::msg_amount;
+
+fn foo() {
+    assert(msg_amount() == 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/context/fn.this_balance.html b/v0.21.0/std/context/fn.this_balance.html new file mode 100644 index 00000000..be2d35ff --- /dev/null +++ b/v0.21.0/std/context/fn.this_balance.html @@ -0,0 +1,19 @@ +this_balance in context - Sway
pub fn this_balance(asset_id: AssetId) -> u64 
Expand description

Get the balance of coin asset_id for the current contract.

+

Arguments

+
    +
  • asset_id: [AssetId] - The asset of which the balance should be returned.
  • +
+

Returns

+
    +
  • [u64] - The amount of the asset which the contract holds.
  • +
+

Examples

+
use std::{context::this_balance, constants::DEFAULT_SUB_ID, asset::mint};
+
+fn foo() {
+    mint(DEFAULT_SUB_ID, 50);
+    let asset_id = AssetId::default();
+    assert(this_balance(asset_id)) == 50);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/context/index.html b/v0.21.0/std/context/index.html new file mode 100644 index 00000000..76f2899c --- /dev/null +++ b/v0.21.0/std/context/index.html @@ -0,0 +1,5 @@ +context in std - Sway

Module std::context

Expand description

Functionality for accessing context-specific information about the current contract or message.

+

Functions

Get the balance of coin asset_id for the contract at ‘target’.

+

Get the amount of units of call_frames::msg_asset_id() being sent.

+

Get the balance of coin asset_id for the current contract.

+
\ No newline at end of file diff --git a/v0.21.0/std/contract_id/index.html b/v0.21.0/std/contract_id/index.html new file mode 100644 index 00000000..abb2edfb --- /dev/null +++ b/v0.21.0/std/contract_id/index.html @@ -0,0 +1,3 @@ +contract_id in std - Sway
Expand description

A wrapper around the b256 type to help enhance type-safety.

+

Structs

The ContractId type, a struct wrapper around the inner b256 value.

+
\ No newline at end of file diff --git a/v0.21.0/std/contract_id/struct.ContractId.html b/v0.21.0/std/contract_id/struct.ContractId.html new file mode 100644 index 00000000..a0ef5483 --- /dev/null +++ b/v0.21.0/std/contract_id/struct.ContractId.html @@ -0,0 +1,51 @@ +ContractId in contract_id - Sway
pub struct ContractId {
+    /// The underlying raw `b256` data of the contract id.
+    bits: b256,
+}
Expand description

The ContractId type, a struct wrapper around the inner b256 value.

+

Fields

bits: b256

The underlying raw b256 data of the contract id.

+

Trait Implementations

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn from(bits: b256) -> Self

Casts raw b256 data to a ContractId.

+

Arguments

+
    +
  • bits: [b256] - The raw b256 data to be casted.
  • +
+

Returns

+
    +
  • [ContractId] - The newly created ContractId from the raw b256.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+
+fn foo() {
+   let contract_id = ContractId::from(ZERO_B256);
+}
+
+

fn hash(
self,
refmut state: Hasher,
)

\ No newline at end of file diff --git a/v0.21.0/std/convert/index.html b/v0.21.0/std/convert/index.html new file mode 100644 index 00000000..8d8e23a1 --- /dev/null +++ b/v0.21.0/std/convert/index.html @@ -0,0 +1,4 @@ +convert in std - Sway

Module std::convert

Expand description

Traits for conversions between types.

+

Traits

Used to do value-to-value conversions.

+

Used to do value-to-value conversions.

+

Used to attempt to do value-to-value conversions.

\ No newline at end of file diff --git a/v0.21.0/std/convert/trait.From.html b/v0.21.0/std/convert/trait.From.html new file mode 100644 index 00000000..33967e0b --- /dev/null +++ b/v0.21.0/std/convert/trait.From.html @@ -0,0 +1,6 @@ +From in convert - Sway

Trait std::convert::From

pub trait From<T> {
+    /// Converts to this type from the input type.
+    fn from(b: T) -> Self;
+}
Expand description

Used to do value-to-value conversions.

+

Required Methods

Converts to this type from the input type.

+
\ No newline at end of file diff --git a/v0.21.0/std/convert/trait.Into.html b/v0.21.0/std/convert/trait.Into.html new file mode 100644 index 00000000..67b3858c --- /dev/null +++ b/v0.21.0/std/convert/trait.Into.html @@ -0,0 +1,6 @@ +Into in convert - Sway

Trait std::convert::Into

pub trait Into<T> {
+    /// Converts this type into the (usually inferred) input type.
+    fn into(self) -> T;
+}
Expand description

Used to do value-to-value conversions.

+

Required Methods

Converts this type into the (usually inferred) input type.

+
\ No newline at end of file diff --git a/v0.21.0/std/convert/trait.TryFrom.html b/v0.21.0/std/convert/trait.TryFrom.html new file mode 100644 index 00000000..e4c623e3 --- /dev/null +++ b/v0.21.0/std/convert/trait.TryFrom.html @@ -0,0 +1,7 @@ +TryFrom in convert - Sway
pub trait TryFrom<T> {
+    /// Performs the conversion. Returns None if the conversion can't be performed in a lossless manner.
+    fn try_from(b: T) -> Option<Self>;
+}
Expand description

Used to attempt to do value-to-value conversions.
+Returns None if the conversion can’t be performed in a lossless manner.

+

Required Methods

Performs the conversion. Returns None if the conversion can’t be performed in a lossless manner.

+
\ No newline at end of file diff --git a/v0.21.0/std/convert/trait.TryInto.html b/v0.21.0/std/convert/trait.TryInto.html new file mode 100644 index 00000000..cab073f2 --- /dev/null +++ b/v0.21.0/std/convert/trait.TryInto.html @@ -0,0 +1,3 @@ +TryInto in convert - Sway
pub trait TryInto<T> {
+    fn try_into(self) -> Option<T>;
+}

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/ecr/enum.EcRecoverError.html b/v0.21.0/std/ecr/enum.EcRecoverError.html new file mode 100644 index 00000000..c33e91dd --- /dev/null +++ b/v0.21.0/std/ecr/enum.EcRecoverError.html @@ -0,0 +1,6 @@ +EcRecoverError in ecr - Sway
pub enum EcRecoverError {
+    /// The error variant used when the recover fails.
+    UnrecoverablePublicKey: (),
+}
Expand description

The error type used when the ec_recover function fails.

+

Variants

UnrecoverablePublicKey: ()

The error variant used when the recover fails.

+
\ No newline at end of file diff --git a/v0.21.0/std/ecr/fn.ec_recover.html b/v0.21.0/std/ecr/fn.ec_recover.html new file mode 100644 index 00000000..8d5a950a --- /dev/null +++ b/v0.21.0/std/ecr/fn.ec_recover.html @@ -0,0 +1,31 @@ +ec_recover in ecr - Sway

Function std::ecr::ec_recover

pub fn ec_recover(signature: B512, msg_hash: b256) -> Result<B512, EcRecoverError> 
Expand description

Recover the public key derived from the private key used to sign a message.
+Returns a Result to let the caller choose an error handling strategy.

+

Additional Information

+

Follows the Secp256k1 elliptical curve.

+

Arguments

+
    +
  • signature: [B512] - The signature generated by signing a message hash.
  • +
  • msg_hash: [b256] - The signed data.
  • +
+

Returns

+
    +
  • [Result<B512, EcRecoverError>] - The recovered public key or an error.
  • +
+

Examples

+
use std::{ecr::ec_recover, b512::B512};
+
+fn foo() {
+    let hi = 0xbd0c9b8792876713afa8bff383eebf31c43437823ed761cc3600d0016de5110c;
+    let lo = 0x44ac566bd156b4fc71a4a4cb2655d3dd360c695edb17dc3b64d611e122fea23d;
+    let msg_hash = 0xee45573606c96c98ba970ff7cf9511f1b8b25e6bcd52ced30b89df1e4a9c4323;
+    let pub_hi = 0xD73A188181464CC84AE267E45041AEF6AB938F278E636AA1D02D3014C1BEF74E;
+    let pub_lo = 0xC44415635160ACFC87A84300EED97928C949A2D958FC0947C535F7539C59AE75;
+    let signature: B512 = B512::from((hi, lo));
+    // A recovered public key pair.
+    let public_key = ec_recover(signature, msg_hash).unwrap();
+
+    assert(public_key.bits()[0] == pub_hi);
+    assert(public_key.bits()[1] == pub_lo);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/ecr/fn.ec_recover_address.html b/v0.21.0/std/ecr/fn.ec_recover_address.html new file mode 100644 index 00000000..b5ec115e --- /dev/null +++ b/v0.21.0/std/ecr/fn.ec_recover_address.html @@ -0,0 +1,28 @@ +ec_recover_address in ecr - Sway
pub fn ec_recover_address(signature: B512, msg_hash: b256) -> Result<Address, EcRecoverError> 
Expand description

Recover the address derived from the private key used to sign a message.
+Returns a Result to let the caller choose an error handling strategy.

+

Additional Information

+

Follows the Secp256k1 elliptical curve.

+

Arguments

+
    +
  • signature: [B512] - The signature generated by signing a message hash.
  • +
  • msg_hash: [b256] - The signed data.
  • +
+

Returns

+
    +
  • [Result<Address, EcRecoverError>] - The recovered Fuel address or an error.
  • +
+

Examples

+
use std::{ecr::ec_recover_address, b512::B512};
+
+fn foo() {
+    let hi = 0xbd0c9b8792876713afa8bff383eebf31c43437823ed761cc3600d0016de5110c;
+    let lo = 0x44ac566bd156b4fc71a4a4cb2655d3dd360c695edb17dc3b64d611e122fea23d;
+    let msg_hash = 0xee45573606c96c98ba970ff7cf9511f1b8b25e6bcd52ced30b89df1e4a9c4323;
+    let address = Address::from(0x7AAE2D980BE4C3275C72CE5B527FA23FFB97B766966559DD062E2B78FD9D3766);
+    let signature: B512 = B512::from((hi, lo));
+    // A recovered Fuel address.
+    let result_address = ec_recover_address(signature, msg_hash).unwrap();
+    assert(result_address == address);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/ecr/fn.ec_recover_address_r1.html b/v0.21.0/std/ecr/fn.ec_recover_address_r1.html new file mode 100644 index 00000000..a3ae7760 --- /dev/null +++ b/v0.21.0/std/ecr/fn.ec_recover_address_r1.html @@ -0,0 +1,28 @@ +ec_recover_address_r1 in ecr - Sway
pub fn ec_recover_address_r1(signature: B512, msg_hash: b256) -> Result<Address, EcRecoverError> 
Expand description

Recover the address derived from the private key used to sign a message.
+Returns a Result to let the caller choose an error handling strategy.

+

Additional Information

+

Follows the Secp256r1 elliptical curve.

+

Arguments

+
    +
  • signature: [B512] - The signature generated by signing a message hash.
  • +
  • msg_hash: [b256] - The signed data.
  • +
+

Returns

+
    +
  • [Result<Address, EcRecoverError>] - The recovered Fuel address or an error.
  • +
+

Examples

+
use std::{ecr::ec_recover_address_r1, b512::B512};
+
+fn foo() {
+    let hi = 0xbd0c9b8792876713afa8bf3383eebf31c43437823ed761cc3600d0016de5110c;
+    let lo = 0x44ac566bd156b4fc71a4a4cb2655d3dd360c695edb17dc3b64d611e122fea23d;
+    let msg_hash = 0xee45573606c96c98ba970ff7cf9511f1b8b25e6bcd52ced30b89df1e4a9c4323;
+    let address = Address::from(0xb4a5fabee8cc852084b71f17107e9c18d682033a58967027af0ab01edf2f9a6a);
+    let signature: B512 = B512::from((hi, lo));
+    // A recovered Fuel address.
+    let result_address = ec_recover_address_r1(signature, msg_hash).unwrap();
+    assert(result_address == address);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/ecr/fn.ec_recover_r1.html b/v0.21.0/std/ecr/fn.ec_recover_r1.html new file mode 100644 index 00000000..f2c43e69 --- /dev/null +++ b/v0.21.0/std/ecr/fn.ec_recover_r1.html @@ -0,0 +1,31 @@ +ec_recover_r1 in ecr - Sway

Function std::ecr::ec_recover_r1

pub fn ec_recover_r1(signature: B512, msg_hash: b256) -> Result<B512, EcRecoverError> 
Expand description

Recover the public key derived from the private key used to sign a message.
+Returns a Result to let the caller choose an error handling strategy.

+

Additional Information

+

Follows the Secp256r1 elliptical curve.

+

Arguments

+
    +
  • signature: [B512] - The signature generated by signing a message hash.
  • +
  • msg_hash: [b256] - The signed data.
  • +
+

Returns

+
    +
  • [Result<B512, EcRecoverError>] - The recovered public key or an error.
  • +
+

Examples

+
use std::{ecr::ec_recover_r1, b512::B512};
+
+fn foo() {
+    let hi = 0xbd0c9b8792876712afadbff382e1bf31c44437823ed761cc3600d0016de511ac;
+    let lo = 0x44ac566bd156b4fc71a4a4cb2655d3da360c695edb27dc3b64d621e122fea23d;
+    let msg_hash = 0x1e45523606c96c98ba970ff7cf9511fab8b25e1bcd52ced30b81df1e4a9c4323;
+    let pub_hi = 0xD73A188181464CC84AE267E45041AEF6AB938F278E636AA1D02D3014C1BEF74E;
+    let pub_lo = 0x62660ecce5979493fe5684526e8e00875b948e507a89a47096bc84064a175452;
+    let signature: B512 = B512::from((hi, lo));
+    // A recovered public key pair.
+    let public_key = ec_recover_r1(signature, msg_hash).unwrap();
+
+    assert(public_key.bits()[0] == pub_hi);
+    assert(public_key.bits()[1] == pub_lo);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/ecr/fn.ed_verify.html b/v0.21.0/std/ecr/fn.ed_verify.html new file mode 100644 index 00000000..ca6c1a01 --- /dev/null +++ b/v0.21.0/std/ecr/fn.ed_verify.html @@ -0,0 +1,34 @@ +ed_verify in ecr - Sway

Function std::ecr::ed_verify

pub fn ed_verify(
+    public_key: b256,
+    signature: B512,
+    msg_hash: b256,
+) -> Result<bool, EcRecoverError> 
Expand description

Verifies that a public key derived from the private key was used to sign a message.
+Returns a Result to let the caller choose an error handling strategy.

+

Additional Information

+

Follows the edDSA curve25519 verification.

+

Arguments

+
    +
  • public_key: [b256] - The public key that signed the message.
  • +
  • signature: [B512] - The signature generated by signing a message hash.
  • +
  • msg_hash: [b256] - The hashed signed data.
  • +
+

Returns

+
    +
  • [Result<bool, EcRecoverError>] - A verified result or an error.
  • +
+

Examples

+
use std::{ecr::ed_verify, b512::B512, constants::ZERO_B256};
+
+fn foo() {
+    let pub_key = 0x314fa58689bbe1da2430517de2d772b384a1c1d2e9cb87e73c6afcf246045b10;
+    let msg = ZERO_B256;
+    let msg_hash = sha256(msg);
+    let hi = 0xf38cef9361894be6c6e0eddec28a663d099d7ddff17c8077a1447d7ecb4e6545;
+    let lo = 0xf5084560039486d3462dd65a40c80a74709b2f06d450ffc5dc00345c6b2cdd00;
+    let signature: B512 = B512::from((hi, lo));
+    // A verified public key with signature
+    let verified = ed_verify(pub_key, signature, msg_hash).unwrap();
+    assert(verified);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/ecr/index.html b/v0.21.0/std/ecr/index.html new file mode 100644 index 00000000..122cacea --- /dev/null +++ b/v0.21.0/std/ecr/index.html @@ -0,0 +1,3 @@ +ecr in std - Sway

Module std::ecr

Expand description

Helper functions to verify signatures.

+

Enums

The error type used when the ec_recover function fails.

+

Functions

Recover the public key derived from the private key used to sign a message.

Recover the address derived from the private key used to sign a message.

Recover the address derived from the private key used to sign a message.

Recover the public key derived from the private key used to sign a message.

Verifies that a public key derived from the private key was used to sign a message.

\ No newline at end of file diff --git a/v0.21.0/std/error_signals/constant.FAILED_ASSERT_EQ_SIGNAL.html b/v0.21.0/std/error_signals/constant.FAILED_ASSERT_EQ_SIGNAL.html new file mode 100644 index 00000000..47563c8e --- /dev/null +++ b/v0.21.0/std/error_signals/constant.FAILED_ASSERT_EQ_SIGNAL.html @@ -0,0 +1,4 @@ +FAILED_ASSERT_EQ_SIGNAL in error_signals - Sway
pub const FAILED_ASSERT_EQ_SIGNAL = 0xffff_ffff_ffff_0003
Expand description

A revert with this value signals that it was caused by a failing call to std::assert::assert_eq.

+

Additional Information

+

The value is: 18446744073709486083

+
\ No newline at end of file diff --git a/v0.21.0/std/error_signals/constant.FAILED_ASSERT_NE_SIGNAL.html b/v0.21.0/std/error_signals/constant.FAILED_ASSERT_NE_SIGNAL.html new file mode 100644 index 00000000..956740bf --- /dev/null +++ b/v0.21.0/std/error_signals/constant.FAILED_ASSERT_NE_SIGNAL.html @@ -0,0 +1,4 @@ +FAILED_ASSERT_NE_SIGNAL in error_signals - Sway
pub const FAILED_ASSERT_NE_SIGNAL = 0xffff_ffff_ffff_0005
Expand description

A revert with this value signals that it was caused by a failing call to std::assert::assert_ne.

+

Additional Information

+

The value is: 18446744073709486085

+
\ No newline at end of file diff --git a/v0.21.0/std/error_signals/constant.FAILED_ASSERT_SIGNAL.html b/v0.21.0/std/error_signals/constant.FAILED_ASSERT_SIGNAL.html new file mode 100644 index 00000000..c81482a3 --- /dev/null +++ b/v0.21.0/std/error_signals/constant.FAILED_ASSERT_SIGNAL.html @@ -0,0 +1,4 @@ +FAILED_ASSERT_SIGNAL in error_signals - Sway
pub const FAILED_ASSERT_SIGNAL = 0xffff_ffff_ffff_0004
Expand description

A revert with this value signals that it was caused by a failing call to std::assert::assert.

+

Additional Information

+

The value is: 18446744073709486084

+
\ No newline at end of file diff --git a/v0.21.0/std/error_signals/constant.FAILED_REQUIRE_SIGNAL.html b/v0.21.0/std/error_signals/constant.FAILED_REQUIRE_SIGNAL.html new file mode 100644 index 00000000..1f8cea94 --- /dev/null +++ b/v0.21.0/std/error_signals/constant.FAILED_REQUIRE_SIGNAL.html @@ -0,0 +1,4 @@ +FAILED_REQUIRE_SIGNAL in error_signals - Sway
pub const FAILED_REQUIRE_SIGNAL = 0xffff_ffff_ffff_0000
Expand description

A revert with this value signals that it was caused by a failing call to std::revert::require.

+

Additional Information

+

The value is: 18446744073709486080

+
\ No newline at end of file diff --git a/v0.21.0/std/error_signals/constant.FAILED_TRANSFER_TO_ADDRESS_SIGNAL.html b/v0.21.0/std/error_signals/constant.FAILED_TRANSFER_TO_ADDRESS_SIGNAL.html new file mode 100644 index 00000000..27143997 --- /dev/null +++ b/v0.21.0/std/error_signals/constant.FAILED_TRANSFER_TO_ADDRESS_SIGNAL.html @@ -0,0 +1,4 @@ +FAILED_TRANSFER_TO_ADDRESS_SIGNAL in error_signals - Sway
pub const FAILED_TRANSFER_TO_ADDRESS_SIGNAL = 0xffff_ffff_ffff_0001
Expand description

A revert with this value signals that it was caused by a failing call to std::asset::transfer_to_address.

+

Additional Information

+

The value is: 18446744073709486081

+
\ No newline at end of file diff --git a/v0.21.0/std/error_signals/index.html b/v0.21.0/std/error_signals/index.html new file mode 100644 index 00000000..fd40dfd8 --- /dev/null +++ b/v0.21.0/std/error_signals/index.html @@ -0,0 +1,2 @@ +error_signals in std - Sway
Expand description

Values which signify special types of errors when passed to std::revert::revert.

+

Constants

A revert with this value signals that it was caused by a failing call to std::assert::assert_eq.

A revert with this value signals that it was caused by a failing call to std::assert::assert_ne.

A revert with this value signals that it was caused by a failing call to std::assert::assert.

A revert with this value signals that it was caused by a failing call to std::revert::require.

A revert with this value signals that it was caused by a failing call to std::asset::transfer_to_address.

\ No newline at end of file diff --git a/v0.21.0/std/execution/fn.run_external.html b/v0.21.0/std/execution/fn.run_external.html new file mode 100644 index 00000000..c2590213 --- /dev/null +++ b/v0.21.0/std/execution/fn.run_external.html @@ -0,0 +1,6 @@ +run_external in execution - Sway
pub fn run_external(load_target: ContractId) -> ! 
Expand description

Load and run the contract with the provided ContractId.

+

Contract code will be loaded using LDC and jumped into.
+Unlike a normal contract call, the context of the contract running
+run_external is retained for the loaded code.

+

As this function never returns to the original code that calls it, it returns !.

+
\ No newline at end of file diff --git a/v0.21.0/std/execution/index.html b/v0.21.0/std/execution/index.html new file mode 100644 index 00000000..1721f481 --- /dev/null +++ b/v0.21.0/std/execution/index.html @@ -0,0 +1,2 @@ +execution in std - Sway

Module std::execution

Functions

Load and run the contract with the provided ContractId.

+
\ No newline at end of file diff --git a/v0.21.0/std/external/fn.bytecode_root.html b/v0.21.0/std/external/fn.bytecode_root.html new file mode 100644 index 00000000..bca59121 --- /dev/null +++ b/v0.21.0/std/external/fn.bytecode_root.html @@ -0,0 +1,18 @@ +bytecode_root in external - Sway
pub fn bytecode_root(contract_id: ContractId) -> b256 
Expand description

Get the root of the bytecode of the contract at ‘contract_id’.

+

Arguments

+
    +
  • contract_id: [ContractId] - The contract of which the bytecode should be returned.
  • +
+

Returns

+
    +
  • [b256] - The bytecode root of the contract.
  • +
+

Examples

+
use std::{external::bytecode_root, call_frames::contract_id, constants::ZERO_B256};
+
+fn foo() {
+    let root_of_this_contract = bytecode_root(contract_id());
+    assert(root_of_this_contract != ZERO_B256);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/external/index.html b/v0.21.0/std/external/index.html new file mode 100644 index 00000000..a58cc788 --- /dev/null +++ b/v0.21.0/std/external/index.html @@ -0,0 +1,3 @@ +external in std - Sway

Module std::external

Expand description

Functions to work with external contracts.

+

Functions

Get the root of the bytecode of the contract at ‘contract_id’.

+
\ No newline at end of file diff --git a/v0.21.0/std/flags/fn.disable_panic_on_overflow.html b/v0.21.0/std/flags/fn.disable_panic_on_overflow.html new file mode 100644 index 00000000..611f86b1 --- /dev/null +++ b/v0.21.0/std/flags/fn.disable_panic_on_overflow.html @@ -0,0 +1,34 @@ +disable_panic_on_overflow in flags - Sway
pub fn disable_panic_on_overflow() -> u64 
Expand description

Allows overflowing operations to occur without a FuelVM panic.

+

Additional Information

+
+

WARNING:

+

Don’t forget to call enable_panic_on_overflow or set_flags after performing the operations for which you disabled the default panic-on-overflow behavior in the first place!

+
+

Returns

+
    +
  • [u64] - The flag prior to disabling panic on overflow.
  • +
+

Examples

+
use std::flags::{disable_panic_on_overflow, enable_panic_on_overflow};
+
+fn main() {
+    disable_panic_on_overflow();
+
+    // Adding 1 to the max value of a u64 is considered an overflow.
+    let bar = u64::max() + 1;
+
+    enable_panic_on_overflow();
+}
+
+
use std::flags::{disable_panic_on_overflow, set_flags};
+
+fn foo() {
+    let prior_flags = disable_panic_on_overflow();
+
+    // Adding 1 to the max value of a u64 is considered an overflow.
+    let bar = u64::max() + 1;
+
+    set_flags(prior_flags);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/flags/fn.disable_panic_on_unsafe_math.html b/v0.21.0/std/flags/fn.disable_panic_on_unsafe_math.html new file mode 100644 index 00000000..c7fd2df3 --- /dev/null +++ b/v0.21.0/std/flags/fn.disable_panic_on_unsafe_math.html @@ -0,0 +1,39 @@ +disable_panic_on_unsafe_math in flags - Sway
pub fn disable_panic_on_unsafe_math() -> u64 
Expand description

Allows unsafe math operations to occur without a FuelVM panic.
+Sets the $err register to true whenever unsafe math occurs.

+

Additional Information

+
+

WARNING:

+

Don’t forget to call enable_panic_on_unsafe_math or set_flags after performing the operations for which you disabled the default panic-on-unsafe-math behavior in the first place!

+
+

Returns

+
    +
  • [u64] - The flag prior to disabling panic on overflow.
  • +
+

Examples

+
use std::{assert::assert, flags::{disable_panic_on_unsafe_math, enable_panic_on_unsafe_math}, registers::error};
+
+fn main() {
+    disable_panic_on_unsafe_math();
+
+    // Division by zero is considered unsafe math.
+    let bar = 1 / 0;
+    // Error flag is set to true whenever unsafe math occurs. Here represented as 1.
+    assert(error() == 1);
+
+    enable_panic_on_unsafe_math();
+}
+
+
use std::{assert::assert, flags::{disable_panic_on_unsafe_math, set_flags}, registers::error};
+
+fn foo() {
+    let prior_flags = disable_panic_on_unsafe_math();
+
+    // Division by zero is considered unsafe math.
+    let bar = 1 / 0;
+    // Error flag is set to true whenever unsafe math occurs. Here represented as 1.
+    assert(error() == 1);
+
+    set_flags(prior_flags);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/flags/fn.enable_panic_on_overflow.html b/v0.21.0/std/flags/fn.enable_panic_on_overflow.html new file mode 100644 index 00000000..82d2ebeb --- /dev/null +++ b/v0.21.0/std/flags/fn.enable_panic_on_overflow.html @@ -0,0 +1,19 @@ +enable_panic_on_overflow in flags - Sway
pub fn enable_panic_on_overflow() 
Expand description

Enables the default panic-on-overflow behavior in the FuelVM.

+

Additional Information

+
+

Note:

+

panic-on-overflow is the default, so there is no need to use this function unless you have previously called disable_panic_on_overflow.

+
+

Examples

+
use std::flags::{disable_panic_on_overflow, enable_panic_on_overflow};
+
+fn main() {
+    disable_panic_on_overflow();
+
+    // Adding 1 to the max value of a u64 is considered an overflow.
+    let bar = u64::max() + 1;
+
+    enable_panic_on_overflow();
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/flags/fn.enable_panic_on_unsafe_math.html b/v0.21.0/std/flags/fn.enable_panic_on_unsafe_math.html new file mode 100644 index 00000000..c241420e --- /dev/null +++ b/v0.21.0/std/flags/fn.enable_panic_on_unsafe_math.html @@ -0,0 +1,21 @@ +enable_panic_on_unsafe_math in flags - Sway
pub fn enable_panic_on_unsafe_math() 
Expand description

Enables the default panic-on-unsafe-math behavior in the FuelVM.

+

Additional Information

+
+

Note:

+

panic-on-unsafe-math is the default, so there is no need to use this function unless you have previously called disable_panic_on_unsafe_math.

+
+

Examples

+
use std::{assert::assert, flags::{disable_panic_on_unsafe_math, enable_panic_on_unsafe_math}, registers::error};
+
+fn main() {
+    disable_panic_on_unsafe_math();
+
+    // Division by zero is considered unsafe math.
+    let bar = 1 / 0;
+    // Error flag is set to true whenever unsafe math occurs. Here represented as 1.
+    assert(error() == 1);
+
+    enable_panic_on_unsafe_math();
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/flags/fn.set_flags.html b/v0.21.0/std/flags/fn.set_flags.html new file mode 100644 index 00000000..d0e5015f --- /dev/null +++ b/v0.21.0/std/flags/fn.set_flags.html @@ -0,0 +1,18 @@ +set_flags in flags - Sway

Function std::flags::set_flags

pub fn set_flags(new_flags: u64) 
Expand description

Sets the flag register to the given value.

+

Arguments

+
    +
  • new_flags: [u64] - Binary encoded 64 bit value representing the flags to set.
  • +
+

Examples

+
use std::flags::{disable_panic_on_overflow_preserving, set_flags};
+
+fn foo() {
+    let prior_flags = disable_panic_on_overflow_preserving();
+
+    // Adding 1 to the max value of a u64 is considered an overflow.
+    let bar = u64::max() + 1;
+
+    set_flags(prior_flags);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/flags/index.html b/v0.21.0/std/flags/index.html new file mode 100644 index 00000000..af905380 --- /dev/null +++ b/v0.21.0/std/flags/index.html @@ -0,0 +1,6 @@ +flags in std - Sway

Module std::flags

Expand description

Functionality for setting and unsetting FuelVM flags to modify behavior related to the $err and $of registers.

+

Functions

Allows overflowing operations to occur without a FuelVM panic.

+

Allows unsafe math operations to occur without a FuelVM panic.

Enables the default panic-on-overflow behavior in the FuelVM.

+

Enables the default panic-on-unsafe-math behavior in the FuelVM.

+

Sets the flag register to the given value.

+
\ No newline at end of file diff --git a/v0.21.0/std/hash/fn.keccak256.html b/v0.21.0/std/hash/fn.keccak256.html new file mode 100644 index 00000000..23e6e49d --- /dev/null +++ b/v0.21.0/std/hash/fn.keccak256.html @@ -0,0 +1,21 @@ +keccak256 in hash - Sway

Function std::hash::keccak256

pub fn keccak256<T>(s: T) -> b256
+where
+    T: Hash,
+
Expand description

Returns the KECCAK-256 hash of param.

+

Arguments

+
    +
  • s: [T] - The value to be hashed.
  • +
+

Returns

+
    +
  • [b256] - The keccak-256 hash of the value.
  • +
+

Examples

+
use std::hash::keccak256;
+
+fn foo() {
+    let result = keccak256("Fuel");
+    assert(result == 0x4375c8bcdc904e5f51752581202ae9ae2bb6eddf8de05d5567d9a6b0ae4789ad);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/hash/fn.sha256.html b/v0.21.0/std/hash/fn.sha256.html new file mode 100644 index 00000000..9ce17725 --- /dev/null +++ b/v0.21.0/std/hash/fn.sha256.html @@ -0,0 +1,21 @@ +sha256 in hash - Sway

Function std::hash::sha256

pub fn sha256<T>(s: T) -> b256
+where
+    T: Hash,
+
Expand description

Returns the SHA-2-256 hash of param.

+

Arguments

+
    +
  • s: [T] - The value to be hashed.
  • +
+

Returns

+
    +
  • [b256] - The sha-256 hash of the value.
  • +
+

Examples

+
use std::hash::*;
+
+fn foo() {
+    let result = sha256("Fuel");
+    assert(result == 0xa80f942f4112036dfc2da86daf6d2ef6ede3164dd56d1000eb82fa87c992450f);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/hash/fn.sha256_str_array.html b/v0.21.0/std/hash/fn.sha256_str_array.html new file mode 100644 index 00000000..fd78951e --- /dev/null +++ b/v0.21.0/std/hash/fn.sha256_str_array.html @@ -0,0 +1,11 @@ +sha256_str_array in hash - Sway
pub fn sha256_str_array<S>(param: S) -> b256 
Expand description

Returns the SHA-2-256 hash of param.
+This function is specific for string arrays

+

Examples

+
use std::hash::*;
+
+fn foo() {
+    let result = sha256_str_array(__to_str_array("Fuel"));
+    assert(result == 0xa80f942f4112036dfc2da86daf6d2ef6ede3164dd56d1000eb82fa87c992450f);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/hash/index.html b/v0.21.0/std/hash/index.html new file mode 100644 index 00000000..8bf4a3b6 --- /dev/null +++ b/v0.21.0/std/hash/index.html @@ -0,0 +1,4 @@ +hash in std - Sway

Module std::hash

Expand description

Utility functions for cryptographic hashing.

+

Structs

Traits

Functions

Returns the KECCAK-256 hash of param.

+

Returns the SHA-2-256 hash of param.

+

Returns the SHA-2-256 hash of param.

\ No newline at end of file diff --git a/v0.21.0/std/hash/struct.Hasher.html b/v0.21.0/std/hash/struct.Hasher.html new file mode 100644 index 00000000..33fbacfa --- /dev/null +++ b/v0.21.0/std/hash/struct.Hasher.html @@ -0,0 +1,3 @@ +Hasher in hash - Sway

Struct std::hash::Hasher

pub struct Hasher {
+    bytes: Bytes,
+}

Fields

bytes: Bytes
\ No newline at end of file diff --git a/v0.21.0/std/hash/trait.Hash.html b/v0.21.0/std/hash/trait.Hash.html new file mode 100644 index 00000000..96340ec4 --- /dev/null +++ b/v0.21.0/std/hash/trait.Hash.html @@ -0,0 +1,3 @@ +Hash in hash - Sway

Trait std::hash::Hash

pub trait Hash {
+    fn hash(self, ref mut state: Hasher);
+}

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/identity/enum.Identity.html b/v0.21.0/std/identity/enum.Identity.html new file mode 100644 index 00000000..bbbce05b --- /dev/null +++ b/v0.21.0/std/identity/enum.Identity.html @@ -0,0 +1,5 @@ +Identity in identity - Sway
pub enum Identity {
+    Address: Address,
+    ContractId: ContractId,
+}
Expand description

The Identity type: either an Address or a ContractId.

+

Variants

Address: Address

ContractId: ContractId

\ No newline at end of file diff --git a/v0.21.0/std/identity/index.html b/v0.21.0/std/identity/index.html new file mode 100644 index 00000000..9816e345 --- /dev/null +++ b/v0.21.0/std/identity/index.html @@ -0,0 +1,4 @@ +identity in std - Sway

Module std::identity

Expand description

A wrapper type with two variants, Address and ContractId.
+The use of this type allows for handling interactions with contracts and addresses in a unified manner.

+

Enums

The Identity type: either an Address or a ContractId.

+
\ No newline at end of file diff --git a/v0.21.0/std/index.html b/v0.21.0/std/index.html new file mode 100644 index 00000000..4aea59e2 --- /dev/null +++ b/v0.21.0/std/index.html @@ -0,0 +1,24 @@ +std in std - Sway

Library std

Modules

A wrapper around the b256 type to help enhance type-safety.

+

A library for allocating memory inspired by Rust’s std::alloc.

Functions to assert a given condition.

+

Functionality for performing common operations with assets.

+

Functionality for determining who is calling a contract.

+

A wrapper around two b256 types to support the usage of 64-byte values in Sway,

Functionality for accessing block-related data.

+

The Bytes type is used when a collection of tightly-packed arbitrary bytes is needed.

Helper functions for accessing data from call frames.

Base asset and zero address constants.

+

Functionality for accessing context-specific information about the current contract or message.

A wrapper around the b256 type to help enhance type-safety.

+

Traits for conversions between types.

+

Helper functions to verify signatures.

+

Values which signify special types of errors when passed to std::revert::revert.

Functions to work with external contracts.

+

Functionality for setting and unsetting FuelVM flags to modify behavior related to the $err and $of registers.

Utility functions for cryptographic hashing.

+

A wrapper type with two variants, Address and ContractId.

Getters for fields on transaction inputs.

Exposes compiler intrinsics as stdlib wrapper functions.

+

Allows logging of arbitrary stack types, emitted as either Log or Logd receipts.

Utilities to help with low level calls.

+

Utilities for common math operations.

+

Helper functions to sign and send messages.

+

A type for optional values.

+

Getters for fields on transaction outputs.

Functions to expose 14 of the reserved FuelVM registers for ease of use.

Error handling with the Result type.

+

Functions to panic or revert with a given error code.

+

Contract storage utilities.

+

Transaction field getters.

+

A 128-bit unsigned integer type.

+

A vector type for dynamically sized arrays outside of storage.

+

VM-specific utilities.

+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_AMOUNT.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_AMOUNT.html new file mode 100644 index 00000000..1b16157d --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_AMOUNT.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_AMOUNT in inputs - Sway
pub const GTF_INPUT_COIN_AMOUNT = 0x204
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_ASSET_ID.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_ASSET_ID.html new file mode 100644 index 00000000..aa294be5 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_ASSET_ID.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_ASSET_ID in inputs - Sway
pub const GTF_INPUT_COIN_ASSET_ID = 0x205
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_MATURITY.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_MATURITY.html new file mode 100644 index 00000000..839d543c --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_MATURITY.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_MATURITY in inputs - Sway
pub const GTF_INPUT_COIN_MATURITY = 0x208
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_OWNER.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_OWNER.html new file mode 100644 index 00000000..3728eed2 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_OWNER.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_OWNER in inputs - Sway
pub const GTF_INPUT_COIN_OWNER = 0x203
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE.html new file mode 100644 index 00000000..ecb49983 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_PREDICATE in inputs - Sway
pub const GTF_INPUT_COIN_PREDICATE = 0x20B
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_DATA.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_DATA.html new file mode 100644 index 00000000..b096626c --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_DATA.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_PREDICATE_DATA in inputs - Sway
pub const GTF_INPUT_COIN_PREDICATE_DATA = 0x20C
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_DATA_LENGTH.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_DATA_LENGTH.html new file mode 100644 index 00000000..8ec0ad5f --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_DATA_LENGTH.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_PREDICATE_DATA_LENGTH in inputs - Sway
pub const GTF_INPUT_COIN_PREDICATE_DATA_LENGTH = 0x20A
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_LENGTH.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_LENGTH.html new file mode 100644 index 00000000..7715311a --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_PREDICATE_LENGTH.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_PREDICATE_LENGTH in inputs - Sway
pub const GTF_INPUT_COIN_PREDICATE_LENGTH = 0x209
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_WITNESS_INDEX.html b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_WITNESS_INDEX.html new file mode 100644 index 00000000..cb09ec8e --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_COIN_WITNESS_INDEX.html @@ -0,0 +1 @@ +GTF_INPUT_COIN_WITNESS_INDEX in inputs - Sway
pub const GTF_INPUT_COIN_WITNESS_INDEX = 0x207
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_AMOUNT.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_AMOUNT.html new file mode 100644 index 00000000..190107ff --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_AMOUNT.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_AMOUNT in inputs - Sway
pub const GTF_INPUT_MESSAGE_AMOUNT = 0x242
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_DATA.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_DATA.html new file mode 100644 index 00000000..00f5dca6 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_DATA.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_DATA in inputs - Sway
pub const GTF_INPUT_MESSAGE_DATA = 0x248
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_DATA_LENGTH.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_DATA_LENGTH.html new file mode 100644 index 00000000..545285f0 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_DATA_LENGTH.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_DATA_LENGTH in inputs - Sway
pub const GTF_INPUT_MESSAGE_DATA_LENGTH = 0x245
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_NONCE.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_NONCE.html new file mode 100644 index 00000000..7328fa66 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_NONCE.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_NONCE in inputs - Sway
pub const GTF_INPUT_MESSAGE_NONCE = 0x243
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE.html new file mode 100644 index 00000000..c66372fd --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_PREDICATE in inputs - Sway
pub const GTF_INPUT_MESSAGE_PREDICATE = 0x249
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_DATA.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_DATA.html new file mode 100644 index 00000000..addbe08e --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_DATA.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_PREDICATE_DATA in inputs - Sway
pub const GTF_INPUT_MESSAGE_PREDICATE_DATA = 0x24A
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH.html new file mode 100644 index 00000000..e2bfb862 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH in inputs - Sway
pub const GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH = 0x247
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_LENGTH.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_LENGTH.html new file mode 100644 index 00000000..685b4e4a --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_PREDICATE_LENGTH.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_PREDICATE_LENGTH in inputs - Sway
pub const GTF_INPUT_MESSAGE_PREDICATE_LENGTH = 0x246
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_RECIPIENT.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_RECIPIENT.html new file mode 100644 index 00000000..0c338b43 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_RECIPIENT.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_RECIPIENT in inputs - Sway
pub const GTF_INPUT_MESSAGE_RECIPIENT = 0x241
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_SENDER.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_SENDER.html new file mode 100644 index 00000000..52340d2b --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_SENDER.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_SENDER in inputs - Sway
pub const GTF_INPUT_MESSAGE_SENDER = 0x240
\ No newline at end of file diff --git a/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_WITNESS_INDEX.html b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_WITNESS_INDEX.html new file mode 100644 index 00000000..ae1371a1 --- /dev/null +++ b/v0.21.0/std/inputs/constant.GTF_INPUT_MESSAGE_WITNESS_INDEX.html @@ -0,0 +1 @@ +GTF_INPUT_MESSAGE_WITNESS_INDEX in inputs - Sway
pub const GTF_INPUT_MESSAGE_WITNESS_INDEX = 0x244
\ No newline at end of file diff --git a/v0.21.0/std/inputs/enum.Input.html b/v0.21.0/std/inputs/enum.Input.html new file mode 100644 index 00000000..0a2c2be3 --- /dev/null +++ b/v0.21.0/std/inputs/enum.Input.html @@ -0,0 +1,12 @@ +Input in inputs - Sway
pub enum Input {
+    /// A coin input.
+    Coin: (),
+    /// A contract input.
+    Contract: (),
+    /// A message input.
+    Message: (),
+}
Expand description

The input type for a transaction.

+

Variants

Coin: ()

A coin input.

+

Contract: ()

A contract input.

+

Message: ()

A message input.

+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_amount.html b/v0.21.0/std/inputs/fn.input_amount.html new file mode 100644 index 00000000..a73a1917 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_amount.html @@ -0,0 +1,18 @@ +input_amount in inputs - Sway
pub fn input_amount(index: u64) -> Option<u64> 
Expand description

Gets amount field from input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option] - The amount of the input at index, if the input’s type is Input::Coin or Input::Message, else None.
  • +
+

Examples

+
use std::inputs::input_amount;
+
+fn foo() {
+    let input_amount = input_amount(0);
+    assert(input_amount.unwrap() == 100);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_asset_id.html b/v0.21.0/std/inputs/fn.input_asset_id.html new file mode 100644 index 00000000..18a5b470 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_asset_id.html @@ -0,0 +1,18 @@ +input_asset_id in inputs - Sway
pub fn input_asset_id(index: u64) -> Option<AssetId> 
Expand description

Gets the AssetId of the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option] - The asset_id of the input at index, if the input’s type is Input::Coin or Input::Message, else None.
  • +
+

Examples

+
use std::{constants::BASE_ASSET_ID, inputs::input_asset_id};
+
+fn foo() {
+    let input_asset_id = input_asset_id(0);
+    assert(input_asset_id.unwrap() == BASE_ASSET_ID);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_coin_owner.html b/v0.21.0/std/inputs/fn.input_coin_owner.html new file mode 100644 index 00000000..5ff20dad --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_coin_owner.html @@ -0,0 +1,18 @@ +input_coin_owner in inputs - Sway
pub fn input_coin_owner(index: u64) -> Option<Address> 
Expand description

Gets owner field from input at index if it’s a coin.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option] - The owner of the input at index, if the input’s type is Input::Coin, else None.
  • +
+

Examples

+
use std::inputs::input_coin_owner;
+
+fn foo() {
+    let input_coin_owner = input_coin_owner(0);
+    assert(input_coin_owner.is_some()); // Ensure the input is a coin input.
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_count.html b/v0.21.0/std/inputs/fn.input_count.html new file mode 100644 index 00000000..45875113 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_count.html @@ -0,0 +1,14 @@ +input_count in inputs - Sway
pub fn input_count() -> u8 
Expand description

Gets the transaction inputs count.

+

Returns

+
    +
  • [u8] - The number of inputs in the transaction.
  • +
+

Examples

+
use std::inputs::input_count;
+
+fn foo() {
+    let input_count = input_count();
+    assert(input_count == 1);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_maturity.html b/v0.21.0/std/inputs/fn.input_maturity.html new file mode 100644 index 00000000..a7b361a4 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_maturity.html @@ -0,0 +1,20 @@ +input_maturity in inputs - Sway
pub fn input_maturity(index: u64) -> Option<u32> 
Expand description

Gets the maturity from the input at index.

+

Additional Information

+

The maturity of an input refers to the number of blocks that must pass before the input can be spent.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option] - The maturity of the input at index, if the input’s type is Input::Coin, else None.
  • +
+

Examples

+
use std::inputs::input_maturity;
+
+fn foo() {
+    let input_maturity = input_maturity(0);
+    assert(input_maturity.unwrap() == 0_u32);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_message_data.html b/v0.21.0/std/inputs/fn.input_message_data.html new file mode 100644 index 00000000..aad09df8 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_message_data.html @@ -0,0 +1,23 @@ +input_message_data in inputs - Sway
pub fn input_message_data(index: u64, offset: u64) -> Bytes 
Expand description

Gets the data of the input message at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
  • offset: [u64] - The offset to start reading the data from.
  • +
+

Returns

+
    +
  • [Bytes] - The data of the input message at index, if the input’s type is Input::Message.
  • +
+

Reverts

+
    +
  • When the input’s type is not Input::Message.
  • +
+

Examples

+
use std::inputs::input_message_data;
+
+fn foo() {
+    let input_message_data = input_message_data(0, 0);
+    assert(input_message_data.len() != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_message_data_length.html b/v0.21.0/std/inputs/fn.input_message_data_length.html new file mode 100644 index 00000000..053b7e6a --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_message_data_length.html @@ -0,0 +1,18 @@ +input_message_data_length in inputs - Sway
pub fn input_message_data_length(index: u64) -> u16 
Expand description

Gets the length of the input message at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [u16] - The length of the input message at index, if the input’s type is Input::Message.
  • +
+

Examples

+
use std::inputs::input_message_length;
+
+fn foo() {
+    let input_message_length = input_message_length(0);
+    assert(input_message_length != 0_u16);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_message_nonce.html b/v0.21.0/std/inputs/fn.input_message_nonce.html new file mode 100644 index 00000000..cc51d952 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_message_nonce.html @@ -0,0 +1,18 @@ +input_message_nonce in inputs - Sway
pub fn input_message_nonce(index: u64) -> b256 
Expand description

Gets the nonce of input message at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [b256] - The nonce of the input message at index, if the input’s type is Input::Message.
  • +
+

Examples

+
use std::{constants::ZERO_B256, inputs::input_message_nonce};
+
+fn foo() {
+    let input_message_nonce = input_message_nonce(0);
+    assert(input_message_nonce != b256::from(ZERO_B256));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_message_recipient.html b/v0.21.0/std/inputs/fn.input_message_recipient.html new file mode 100644 index 00000000..f94049ec --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_message_recipient.html @@ -0,0 +1,18 @@ +input_message_recipient in inputs - Sway
pub fn input_message_recipient(index: u64) -> Address 
Expand description

Gets the recipient of the input message at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Address] - The recipient of the input message at index, if the input’s type is Input::Message.
  • +
+

Examples

+
use std::{constants::ZERO_B256, inputs::input_message_recipient};
+
+fn foo() {
+    let input_message_recipient = input_message_recipient(0);
+    assert(input_message_recipient != Address::from(ZERO_B256));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_message_sender.html b/v0.21.0/std/inputs/fn.input_message_sender.html new file mode 100644 index 00000000..75e521a4 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_message_sender.html @@ -0,0 +1,18 @@ +input_message_sender in inputs - Sway
pub fn input_message_sender(index: u64) -> Address 
Expand description

Gets the sender of the input message at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Address] - The sender of the input message at index, if the input’s type is Input::Message.
  • +
+

Examples

+
use std::{constants::ZERO_B256, inputs::input_message_sender};
+
+fn foo() {
+    let input_message_sender = input_message_sender(0);
+    assert(input_message_sender != Address::from(ZERO_B256));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_pointer.html b/v0.21.0/std/inputs/fn.input_pointer.html new file mode 100644 index 00000000..1e8656d6 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_pointer.html @@ -0,0 +1,17 @@ +input_pointer in inputs - Sway
pub fn input_pointer(index: u64) -> u64 
Expand description

Gets the pointer of the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [u64] - The pointer of the input at index.
  • +
+

Examples

+
use std::inputs::input_pointer;
+
+fn foo() {
+    let input_pointer = input_pointer(0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_predicate.html b/v0.21.0/std/inputs/fn.input_predicate.html new file mode 100644 index 00000000..7e1a8836 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_predicate.html @@ -0,0 +1,22 @@ +input_predicate in inputs - Sway
pub fn input_predicate(index: u64) -> Bytes 
Expand description

Gets the predicate from the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Bytes] - The predicate bytecode of the input at index, if the input’s type is Input::Coin or Input::Message.
  • +
+

Reverts

+
    +
  • When the input’s type is not Input::Coin or Input::Message.
  • +
+

Examples

+
use std::inputs::input_predicate;
+
+fn foo() {
+    let input_predicate = input_predicate(0);
+    assert(input_predicate.len() != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_predicate_data.html b/v0.21.0/std/inputs/fn.input_predicate_data.html new file mode 100644 index 00000000..a4dc228c --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_predicate_data.html @@ -0,0 +1,18 @@ +input_predicate_data in inputs - Sway
pub fn input_predicate_data<T>(index: u64) -> T 
Expand description

Gets the predicate data from the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [T] - The predicate data of the input at index.
  • +
+

Examples

+
use std::inputs::input_predicate_data;
+
+fn foo() {
+    let input_predicate_data: u64 = input_predicate_data(0);
+    assert(input_predicate_data == 100);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_predicate_data_length.html b/v0.21.0/std/inputs/fn.input_predicate_data_length.html new file mode 100644 index 00000000..41f65e08 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_predicate_data_length.html @@ -0,0 +1,18 @@ +input_predicate_data_length in inputs - Sway
pub fn input_predicate_data_length(index: u64) -> Option<u16> 
Expand description

Gets the predicate data length from the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option] - The predicate data length of the input at index, if the input’s type is Input::Coin or Input::Message, else None.
  • +
+

Examples

+
use std::inputs::input_predicate_data_length;
+
+fn foo() {
+    let input_predicate_data_length = input_predicate_data_length(0);
+    assert(input_predicate_data_length.unwrap() != 0_u16);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_predicate_data_pointer.html b/v0.21.0/std/inputs/fn.input_predicate_data_pointer.html new file mode 100644 index 00000000..452c341c --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_predicate_data_pointer.html @@ -0,0 +1,18 @@ +input_predicate_data_pointer in inputs - Sway
pub fn input_predicate_data_pointer(index: u64) -> Option<raw_ptr> 
Expand description

Gets the predicate data pointer from the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option<raw_ptr>] - The predicate data pointer of the input at index, if the input’s type is Input::Coin or Input::Message, else None.
  • +
+

Examples

+
use std::inputs::input_predicate_data_pointer;
+
+fn foo() {
+    let input_predicate_data_pointer = input_predicate_data_pointer(0);
+    assert(input_predicate_data_pointer.is_some()); // Ensure the input is a coin or message input.
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_predicate_length.html b/v0.21.0/std/inputs/fn.input_predicate_length.html new file mode 100644 index 00000000..91758a3f --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_predicate_length.html @@ -0,0 +1,18 @@ +input_predicate_length in inputs - Sway
pub fn input_predicate_length(index: u64) -> Option<u16> 
Expand description

Gets the predicate length from the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option] - The predicate length of the input at index, if the input’s type is Input::Coin or Input::Message, else None.
  • +
+

Examples

+
use std::inputs::input_predicate_length;
+
+fn foo() {
+    let input_predicate_length = input_predicate_length(0);
+    assert(input_predicate_length.unwrap() != 0u16);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_predicate_pointer.html b/v0.21.0/std/inputs/fn.input_predicate_pointer.html new file mode 100644 index 00000000..06d688f0 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_predicate_pointer.html @@ -0,0 +1,18 @@ +input_predicate_pointer in inputs - Sway
pub fn input_predicate_pointer(index: u64) -> Option<raw_ptr> 
Expand description

Gets the predicate pointer from the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option<raw_ptr>] - The predicate pointer of the input at index, if the input’s type is Input::Coin or Input::Message, else None.
  • +
+

Examples

+
use std::inputs::input_predicate_pointer;
+
+fn foo() {
+    let input_predicate_pointer = input_predicate_pointer(0);
+    assert(input_predicate_pointer.is_some());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_type.html b/v0.21.0/std/inputs/fn.input_type.html new file mode 100644 index 00000000..40dd979c --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_type.html @@ -0,0 +1,20 @@ +input_type in inputs - Sway

Function std::inputs::input_type

pub fn input_type(index: u64) -> Input 
Expand description

Gets the type of the input at index.

+

Additional Information

+

The Input can be of 3 variants, Input::Coin, Input::Contract or Input::Message.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Input] - The type of the input at index.
  • +
+

Examples

+
use std::inputs::input_type;
+
+fn foo() {
+    let input_type = input_type(0);
+    assert(input_type == Input::Coin);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/fn.input_witness_index.html b/v0.21.0/std/inputs/fn.input_witness_index.html new file mode 100644 index 00000000..33ebf9a6 --- /dev/null +++ b/v0.21.0/std/inputs/fn.input_witness_index.html @@ -0,0 +1,18 @@ +input_witness_index in inputs - Sway
pub fn input_witness_index(index: u64) -> Option<u8> 
Expand description

Gets the witness index from the input at index.

+

Arguments

+
    +
  • index: [u64] - The index of the input to check.
  • +
+

Returns

+
    +
  • [Option] - The witness index of the input at index, if the input’s type is Input::Coin or Input::Message, else None.
  • +
+

Examples

+
use std::inputs::input_witness_index;
+
+fn foo() {
+    let input_witness_index = input_witness_index(0);
+    assert(input_witness_index.is_some()); // Ensure the input has a witness index.
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/inputs/index.html b/v0.21.0/std/inputs/index.html new file mode 100644 index 00000000..4603896b --- /dev/null +++ b/v0.21.0/std/inputs/index.html @@ -0,0 +1,23 @@ +inputs in std - Sway

Module std::inputs

Expand description

Getters for fields on transaction inputs.
+This includes Input::Coins, Input::Messages and Input::Contracts.

+

Enums

The input type for a transaction.

+

Constants

Functions

Gets amount field from input at index.

+

Gets the AssetId of the input at index.

+

Gets owner field from input at index if it’s a coin.

+

Gets the transaction inputs count.

+

Gets the maturity from the input at index.

+

Gets the data of the input message at index.

+

Gets the length of the input message at index.

+

Gets the nonce of input message at index.

+

Gets the recipient of the input message at index.

+

Gets the sender of the input message at index.

+

Gets the pointer of the input at index.

+

Gets the predicate from the input at index.

+

Gets the predicate data from the input at index.

+

Gets the predicate data length from the input at index.

+

Gets the predicate data pointer from the input at index.

+

Gets the predicate length from the input at index.

+

Gets the predicate pointer from the input at index.

+

Gets the type of the input at index.

+

Gets the witness index from the input at index.

+
\ No newline at end of file diff --git a/v0.21.0/std/intrinsics/fn.is_reference_type.html b/v0.21.0/std/intrinsics/fn.is_reference_type.html new file mode 100644 index 00000000..24a7aedc --- /dev/null +++ b/v0.21.0/std/intrinsics/fn.is_reference_type.html @@ -0,0 +1,14 @@ +is_reference_type in intrinsics - Sway
pub fn is_reference_type<T>() -> bool 
Expand description

Returns whether a generic type T is a reference type or not.

+

Returns

+
    +
  • [bool] - true if T is a reference type, false otherwise.
  • +
+

Examples

+
use std::intrinsics::is_reference_type;
+
+fn foo() {
+    let a = 1;
+    assert(is_reference_type(a))
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/intrinsics/fn.size_of.html b/v0.21.0/std/intrinsics/fn.size_of.html new file mode 100644 index 00000000..2c9b9ea6 --- /dev/null +++ b/v0.21.0/std/intrinsics/fn.size_of.html @@ -0,0 +1,24 @@ +size_of in intrinsics - Sway
pub fn size_of<T>() -> u64 
Expand description

Returns the size of a generic type T in bytes.

+

Returns

+
    +
  • [u64] - The size of T in bytes.
  • +
+

Examples

+
use std::intrinsics::size_of;
+
+fn foo() {
+    assert(size_of::<u64>() == 8);
+}
+
+
use std::intrinsics::size_of;
+
+pub struct Foo {
+    a: u64,
+    b: u64,
+}
+
+fn foo() {
+    assert(size_of::<Foo>() == 16);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/intrinsics/fn.size_of_val.html b/v0.21.0/std/intrinsics/fn.size_of_val.html new file mode 100644 index 00000000..02e8eec7 --- /dev/null +++ b/v0.21.0/std/intrinsics/fn.size_of_val.html @@ -0,0 +1,30 @@ +size_of_val in intrinsics - Sway
pub fn size_of_val<T>(val: T) -> u64 
Expand description

Returns the size of the type of a value in bytes.

+

Arguments

+
    +
  • val - The value to get the size of.
  • +
+

Returns

+
    +
  • [u64] - The size of the type of val in bytes.
  • +
+

Examples

+
use std::intrinsics::size_of_val;
+
+fn foo() {
+    let a = 1;
+    assert(size_of_val(a) == 8);
+}
+
+
use std::intrinsics::size_of_val;
+
+pub struct Foo {
+    a: u64,
+    b: u64,
+}
+
+fn foo() {
+    let a = Foo { a: 1, b: 2 };
+    assert(size_of_val(a) == 16);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/intrinsics/index.html b/v0.21.0/std/intrinsics/index.html new file mode 100644 index 00000000..f53b3d74 --- /dev/null +++ b/v0.21.0/std/intrinsics/index.html @@ -0,0 +1,5 @@ +intrinsics in std - Sway

Module std::intrinsics

Expand description

Exposes compiler intrinsics as stdlib wrapper functions.

+

Functions

Returns whether a generic type T is a reference type or not.

+

Returns the size of a generic type T in bytes.

+

Returns the size of the type of a value in bytes.

+
\ No newline at end of file diff --git a/v0.21.0/std/iterator/index.html b/v0.21.0/std/iterator/index.html new file mode 100644 index 00000000..6d39386d --- /dev/null +++ b/v0.21.0/std/iterator/index.html @@ -0,0 +1 @@ +iterator in std - Sway

Module std::iterator

Traits

\ No newline at end of file diff --git a/v0.21.0/std/iterator/trait.Iterator.html b/v0.21.0/std/iterator/trait.Iterator.html new file mode 100644 index 00000000..847471ac --- /dev/null +++ b/v0.21.0/std/iterator/trait.Iterator.html @@ -0,0 +1,64 @@ +Iterator in iterator - Sway
pub trait Iterator {
+    /// The type of the elements being iterated over.
+    type Item;
+    /// Advances the iterator and returns the next value.
+    ///
+    /// Returns [`None`] when iteration is finished. Individual iterator
+    /// implementations may choose to resume iteration, and so calling `next()`
+    /// again may or may not eventually start returning [`Some(Item)`] again at some
+    /// point.
+    ///
+    /// # Examples
+    ///
+    /// Basic usage:
+    ///
+    /// ```
+    /// let mut a = Vec::new();
+    ///
+    /// a.push(1);
+    /// a.push(2);
+    /// a.push(3);
+    ///
+    /// let mut iter = a.iter();
+    ///
+    /// // A call to next() returns the next value...
+    /// assert_eq!(Some(1), iter.next());
+    /// assert_eq!(Some(2), iter.next());
+    /// assert_eq!(Some(3), iter.next());
+    ///
+    /// // ... and then None once it's over.
+    /// assert_eq!(None, iter.next());
+    ///
+    /// // More calls may or may not return `None`. Here, they always will.
+    /// assert_eq!(None, iter.next());
+    /// assert_eq!(None, iter.next());
+    /// ```
+    fn next(ref mut self) -> Option<Self::Item>;
+}

Required Methods

Advances the iterator and returns the next value.

+

Returns [None] when iteration is finished. Individual iterator
+implementations may choose to resume iteration, and so calling next()
+again may or may not eventually start returning [Some(Item)] again at some
+point.

+

Examples

+

Basic usage:

+
let mut a = Vec::new();
+
+a.push(1);
+a.push(2);
+a.push(3);
+
+let mut iter = a.iter();
+
+// A call to next() returns the next value...
+assert_eq!(Some(1), iter.next());
+assert_eq!(Some(2), iter.next());
+assert_eq!(Some(3), iter.next());
+
+// ... and then None once it's over.
+assert_eq!(None, iter.next());
+
+// More calls may or may not return `None`. Here, they always will.
+assert_eq!(None, iter.next());
+assert_eq!(None, iter.next());
+
+
\ No newline at end of file diff --git a/v0.21.0/std/logging/fn.log.html b/v0.21.0/std/logging/fn.log.html new file mode 100644 index 00000000..a5144c9f --- /dev/null +++ b/v0.21.0/std/logging/fn.log.html @@ -0,0 +1,14 @@ +log in logging - Sway

Function std::logging::log

pub fn log<T>(value: T) 
Expand description

Log any stack type.

+

Additional Information

+

If the type is a reference type, log is used.
+Otherwise logd is used.’

+

Arguments

+
    +
  • value: [T] - The value to log.
  • +
+

Examples

+
fn foo() {
+    log("Fuel is blazingly fast");
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/logging/index.html b/v0.21.0/std/logging/index.html new file mode 100644 index 00000000..39984939 --- /dev/null +++ b/v0.21.0/std/logging/index.html @@ -0,0 +1,3 @@ +logging in std - Sway

Module std::logging

Expand description

Allows logging of arbitrary stack types, emitted as either Log or Logd receipts.

+

Functions

Log any stack type.

+
\ No newline at end of file diff --git a/v0.21.0/std/low_level_call/fn.call_with_function_selector.html b/v0.21.0/std/low_level_call/fn.call_with_function_selector.html new file mode 100644 index 00000000..06579166 --- /dev/null +++ b/v0.21.0/std/low_level_call/fn.call_with_function_selector.html @@ -0,0 +1,23 @@ +call_with_function_selector in low_level_call - Sway
pub fn call_with_function_selector(
+    target: ContractId,
+    function_selector: Bytes,
+    calldata: Bytes,
+    single_value_type_arg: bool,
+    call_params: CallParams,
+) 
Expand description

Call a target contract with a function selector and calldata, provided as Bytes.

+

Arguments

+
    +
  • target : [ContractId] - The ContractId of the contract to be called.
  • +
  • function_selector : [Bytes] - The function selector of the function to be called, i.e. the first 8 bytes of sha256("my_func(u64)").
  • +
  • calldata : [Bytes] - The encoded arguments with which to call the function.
  • +
  • single_value_type_arg : [bool] - Whether the function being called takes a single value-type argument.
  • +
  • call_params : [CallParams] - The amount and color of coins to forward, and the gas to forward.
  • +
+

Examples

+
use std::low_level_call::{bytes::Bytes, call_with_function_selector, CallParams};
+
+fn call_contract(target: ContractId, function_selector: Bytes, calldata: Bytes, call_params: CallParams, single_value_type_arg: bool) {
+    call_with_function_selector(target, function_selector, calldata, single_value_type_arg, call_params);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/low_level_call/fn.call_with_function_selector_vec.html b/v0.21.0/std/low_level_call/fn.call_with_function_selector_vec.html new file mode 100644 index 00000000..240daddf --- /dev/null +++ b/v0.21.0/std/low_level_call/fn.call_with_function_selector_vec.html @@ -0,0 +1,25 @@ +call_with_function_selector_vec in low_level_call - Sway
pub fn call_with_function_selector_vec(
+    target: ContractId,
+    function_selector: Vec<u8>,
+    calldata: Vec<u8>,
+    single_value_type_arg: bool,
+    call_params: CallParams,
+) 
Expand description

Call a target contract with a function selector and calldata, provided as Vec<u8>.

+

Additional Information

+

It is recommended to use the call_with_function_selector function as this function will be deprecated in the future.

+

Arguments

+
    +
  • target : [ContractId] - The ContractId of the contract to be called.
  • +
  • function_selector : [Vec] - The function selector of the function to be called, i.e. the first 8 bytes of sha256("my_func(u64)").
  • +
  • calldata : [Vec] - The encoded arguments with which to call the function.
  • +
  • single_value_type_arg : [bool] - Whether the function being called takes a single value-type argument.
  • +
  • call_params : [CallParams] - The amount and color of coins to forward, and the gas to forward.
  • +
+

Examples

+
use std::low_level_call::{call_with_function_selector_vec, CallParams};
+
+fn call_contract(target: ContractId, function_selector: Vec<u8>, calldata: Vec<u8>, call_params: CallParams, single_value_type_arg: bool) {
+    call_with_function_selector_vec(target, function_selector, calldata, single_value_type_arg, call_params);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/low_level_call/index.html b/v0.21.0/std/low_level_call/index.html new file mode 100644 index 00000000..2741beb4 --- /dev/null +++ b/v0.21.0/std/low_level_call/index.html @@ -0,0 +1,3 @@ +low_level_call in std - Sway
Expand description

Utilities to help with low level calls.

+

Structs

A struct representing the call parameters of a function call.

+

Functions

Call a target contract with a function selector and calldata, provided as Bytes.

Call a target contract with a function selector and calldata, provided as Vec<u8>.

\ No newline at end of file diff --git a/v0.21.0/std/low_level_call/struct.CallParams.html b/v0.21.0/std/low_level_call/struct.CallParams.html new file mode 100644 index 00000000..f501262d --- /dev/null +++ b/v0.21.0/std/low_level_call/struct.CallParams.html @@ -0,0 +1,12 @@ +CallParams in low_level_call - Sway
pub struct CallParams {
+    /// Amount of the asset to transfer.
+    pub coins: u64,
+    /// AssetId of the asset to transfer.
+    pub asset_id: AssetId,
+    /// Gas to forward.
+    pub gas: u64,
+}
Expand description

A struct representing the call parameters of a function call.

+

Fields

coins: u64

Amount of the asset to transfer.

+
asset_id: AssetId

AssetId of the asset to transfer.

+
gas: u64

Gas to forward.

+
\ No newline at end of file diff --git a/v0.21.0/std/math/index.html b/v0.21.0/std/math/index.html new file mode 100644 index 00000000..96f65ead --- /dev/null +++ b/v0.21.0/std/math/index.html @@ -0,0 +1,6 @@ +math in std - Sway

Module std::math

Expand description

Utilities for common math operations.

+

Traits

Calculates the binary log.

+

Trait for exponential functions.

Calculates the log with a given base.

+

Calculates a number to a given power.

+

Calculates the square root.

+
\ No newline at end of file diff --git a/v0.21.0/std/math/trait.BinaryLogarithm.html b/v0.21.0/std/math/trait.BinaryLogarithm.html new file mode 100644 index 00000000..084b1861 --- /dev/null +++ b/v0.21.0/std/math/trait.BinaryLogarithm.html @@ -0,0 +1,4 @@ +BinaryLogarithm in math - Sway
pub trait BinaryLogarithm {
+    fn log2(self) -> Self;
+}
Expand description

Calculates the binary log.

+

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/math/trait.Exponent.html b/v0.21.0/std/math/trait.Exponent.html new file mode 100644 index 00000000..1b531c63 --- /dev/null +++ b/v0.21.0/std/math/trait.Exponent.html @@ -0,0 +1,6 @@ +Exponent in math - Sway

Trait std::math::Exponent

pub trait Exponent {
+    // exponential function: e ^ exponent
+    fn exp(exponent: Self) -> Self;
+}
Expand description

Trait for exponential functions.
+This should exist for UFP64, UFP128 and their signed versions.

+

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/math/trait.Logarithm.html b/v0.21.0/std/math/trait.Logarithm.html new file mode 100644 index 00000000..a2269ea9 --- /dev/null +++ b/v0.21.0/std/math/trait.Logarithm.html @@ -0,0 +1,4 @@ +Logarithm in math - Sway
pub trait Logarithm {
+    fn log(self, base: Self) -> Self;
+}
Expand description

Calculates the log with a given base.

+

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/math/trait.Power.html b/v0.21.0/std/math/trait.Power.html new file mode 100644 index 00000000..a1e824ec --- /dev/null +++ b/v0.21.0/std/math/trait.Power.html @@ -0,0 +1,4 @@ +Power in math - Sway

Trait std::math::Power

pub trait Power {
+    fn pow(self, exponent: u32) -> Self;
+}
Expand description

Calculates a number to a given power.

+

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/math/trait.Root.html b/v0.21.0/std/math/trait.Root.html new file mode 100644 index 00000000..8152c257 --- /dev/null +++ b/v0.21.0/std/math/trait.Root.html @@ -0,0 +1,4 @@ +Root in math - Sway

Trait std::math::Root

pub trait Root {
+    fn sqrt(self) -> Self;
+}
Expand description

Calculates the square root.

+

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/message/fn.send_message.html b/v0.21.0/std/message/fn.send_message.html new file mode 100644 index 00000000..a52730f3 --- /dev/null +++ b/v0.21.0/std/message/fn.send_message.html @@ -0,0 +1,20 @@ +send_message in message - Sway
pub fn send_message(recipient: b256, msg_data: Bytes, coins: u64) 
Expand description

Sends a message msg_data to recipient with a coins amount of the base asset.

+

Additional Information

+

Use send_typed_message instead of send_message if the message needs to be indexed.

+

Arguments

+
    +
  • recipient: [b256] - The address of the message recipient.
  • +
  • msg_data: [Bytes] - Arbitrary length message data.
  • +
  • coins: [u64] - Amount of base asset to send.
  • +
+

Examples

+
use std::{message::send_message, bytes::Bytes};
+
+fn foo() {
+    let recipient = 0xee45573606c96c98ba970ff7cf9511f1b8b25e6bcd52ced30b89df1e4a9c4323;
+    let mut bytes = Bytes::new();
+    bytes.push(5u8);
+    send_message(recipient, bytes, 50);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/message/fn.send_typed_message.html b/v0.21.0/std/message/fn.send_typed_message.html new file mode 100644 index 00000000..68ca1755 --- /dev/null +++ b/v0.21.0/std/message/fn.send_typed_message.html @@ -0,0 +1,18 @@ +send_typed_message in message - Sway
pub fn send_typed_message<T>(recipient: b256, msg_data: T, coins: u64) 
Expand description

Sends a message msg_data of type T to recipient with a coins amount of the base asset.

+

Additional Information

+

Use send_typed_message instead of send_message if the message needs to be indexed.

+

Arguments

+
    +
  • recipient: [b256] - The address of the message recipient.
  • +
  • msg_data: [T] - Message data of arbitrary type T.
  • +
  • coins: [u64] - Amount of base asset to send.
  • +
+

Examples

+
use std::message::send_typed_message;
+
+fn foo() {
+    let recipient = 0xee45573606c96c98ba970ff7cf9511f1b8b25e6bcd52ced30b89df1e4a9c4323;
+    send_message(recipient, "Fuel is blazingly fast", 50);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/message/index.html b/v0.21.0/std/message/index.html new file mode 100644 index 00000000..a698086a --- /dev/null +++ b/v0.21.0/std/message/index.html @@ -0,0 +1,2 @@ +message in std - Sway

Module std::message

Expand description

Helper functions to sign and send messages.

+

Functions

Sends a message msg_data to recipient with a coins amount of the base asset.

Sends a message msg_data of type T to recipient with a coins amount of the base asset.

\ No newline at end of file diff --git a/v0.21.0/std/option/enum.Option.html b/v0.21.0/std/option/enum.Option.html new file mode 100644 index 00000000..5fa0e541 --- /dev/null +++ b/v0.21.0/std/option/enum.Option.html @@ -0,0 +1,9 @@ +Option in option - Sway
pub enum Option<T> {
+    /// No value.
+    None: (),
+    /// Some value of type `T`.
+    Some: T,
+}
Expand description

A type that represents an optional value, either Some(val) or None.

+

Variants

None: ()

No value.

+

Some: T

Some value of type T.

+
\ No newline at end of file diff --git a/v0.21.0/std/option/index.html b/v0.21.0/std/option/index.html new file mode 100644 index 00000000..eef11083 --- /dev/null +++ b/v0.21.0/std/option/index.html @@ -0,0 +1,63 @@ +option in std - Sway

Module std::option

Expand description

A type for optional values.

+

Type Option represents an optional value: every Option
+is either Some and contains a value, or None, and
+does not. Option types are very common in Sway code, as
+they have a number of uses:

+
    +
  • Initial values where None can be used as an initializer.
  • +
  • Return value for otherwise reporting simple errors, where None is
    +returned on error.
  • +
  • Optional struct fields.
  • +
  • Optional function arguments.
  • +
+

Options are commonly paired with pattern matching to query the presence
+of a value and take action, always accounting for the None case.

+
fn divide(numerator: u64, denominator: u64) -> Option<u64> {
+    if denominator == 0 {
+        None
+    } else {
+        Some(numerator / denominator)
+    }
+}
+
+fn call_divide() {
+    // The return value of the function is an option
+    let result = divide(6, 2);
+
+    // Pattern match to retrieve the value
+    match result {
+        // The division was valid
+        Some(x) => std::logging::log(x),
+        // The division was invalid
+        None    => std::logging::log("Cannot divide by 0"),
+    }
+}
+
+

Method overview

+

In addition to working with pattern matching, Option provides a wide
+variety of different methods.

+

Querying the variant

+

The is_some and is_none methods return true if the Option
+is Some or None, respectively.

+

is_none: Option::is_none
+is_some: Option::is_some

+

Extracting the contained value

+

These methods extract the contained value in an Option<T> when it
+is the Some variant. If the Option is None:

+
    +
  • unwrap reverts.
  • +
  • unwrap_or returns the provided default value.
  • +
+

unwrap : Option::unwrap
+unwrap_or: Option::unwrap_or

+

Transforming contained values

+

These methods transform Option to Result:

+
    +
  • ok_or transforms Some(v) to Ok(v), and None to
    +Err(e) using the provided default error value.
  • +
+

Err(e) : Result::Err
+Ok(v) : Result::Ok
+Some(v): Option::Some
+ok_or : Option::ok_or

+

Enums

A type that represents an optional value, either Some(val) or None.

\ No newline at end of file diff --git a/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_AMOUNT.html b/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_AMOUNT.html new file mode 100644 index 00000000..7dcad8b2 --- /dev/null +++ b/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_AMOUNT.html @@ -0,0 +1 @@ +GTF_OUTPUT_COIN_AMOUNT in outputs - Sway
pub const GTF_OUTPUT_COIN_AMOUNT = 0x302
\ No newline at end of file diff --git a/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_ASSET_ID.html b/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_ASSET_ID.html new file mode 100644 index 00000000..8bc9b0c4 --- /dev/null +++ b/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_ASSET_ID.html @@ -0,0 +1 @@ +GTF_OUTPUT_COIN_ASSET_ID in outputs - Sway
pub const GTF_OUTPUT_COIN_ASSET_ID = 0x303
\ No newline at end of file diff --git a/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_TO.html b/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_TO.html new file mode 100644 index 00000000..75f416c2 --- /dev/null +++ b/v0.21.0/std/outputs/constant.GTF_OUTPUT_COIN_TO.html @@ -0,0 +1 @@ +GTF_OUTPUT_COIN_TO in outputs - Sway
pub const GTF_OUTPUT_COIN_TO = 0x301
\ No newline at end of file diff --git a/v0.21.0/std/outputs/constant.GTF_OUTPUT_TYPE.html b/v0.21.0/std/outputs/constant.GTF_OUTPUT_TYPE.html new file mode 100644 index 00000000..6c14c39c --- /dev/null +++ b/v0.21.0/std/outputs/constant.GTF_OUTPUT_TYPE.html @@ -0,0 +1 @@ +GTF_OUTPUT_TYPE in outputs - Sway
pub const GTF_OUTPUT_TYPE = 0x300
\ No newline at end of file diff --git a/v0.21.0/std/outputs/enum.Output.html b/v0.21.0/std/outputs/enum.Output.html new file mode 100644 index 00000000..6d4d01fd --- /dev/null +++ b/v0.21.0/std/outputs/enum.Output.html @@ -0,0 +1,15 @@ +Output in outputs - Sway
pub enum Output {
+    /// A coin output.
+    Coin: (),
+    /// A contract output.
+    Contract: (),
+    /// Remaining "change" from spending of a coin.
+    Change: (),
+    /// A variable output.
+    Variable: (),
+}
Expand description

The output type for a transaction.

+

Variants

Coin: ()

A coin output.

+

Contract: ()

A contract output.

+

Change: ()

Remaining “change” from spending of a coin.

+

Variable: ()

A variable output.

+
\ No newline at end of file diff --git a/v0.21.0/std/outputs/fn.output_amount.html b/v0.21.0/std/outputs/fn.output_amount.html new file mode 100644 index 00000000..bdfffbd2 --- /dev/null +++ b/v0.21.0/std/outputs/fn.output_amount.html @@ -0,0 +1,28 @@ +output_amount in outputs - Sway
pub fn output_amount(index: u64) -> u64 
Expand description

The amount of coins to send to the output at index.

+

Additional Information

+

This method is only meaningful if the Output type has the amount field,
+specifically: Output::Coin, Output::Change & Output::Variable.

+

For now, output changes are always guaranteed to have an amount of
+zero since they’re only set after execution terminates.

+

Arguments

+
    +
  • index: [u64] - The index of the output to get the amount of.
  • +
+

Returns

+
    +
  • [u64] - The amount of coins to send to the output at index.
  • +
+

Reverts

+
    +
  • When the output type is Output::Contract.
  • +
  • When the output type is unrecognized. This should never happen.
  • +
+

Examples

+
use std::outputs::output_amount;
+
+fn foo() {
+    let output_amount = output_amount(0);
+    log(output_amount);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/outputs/fn.output_asset_id.html b/v0.21.0/std/outputs/fn.output_asset_id.html new file mode 100644 index 00000000..0005be2f --- /dev/null +++ b/v0.21.0/std/outputs/fn.output_asset_id.html @@ -0,0 +1,22 @@ +output_asset_id in outputs - Sway
pub fn output_asset_id(index: u64) -> Option<AssetId> 
Expand description

Gets the AssetId of the output if it is a Output::Coin.

+

Arguments

+
    +
  • index: [u64] - The index of the output to get the AssetId of.
  • +
+

Returns

+
    +
  • [Option] - The AssetId of the output if it is a Output::Coin. None otherwise.
  • +
+

Reverts

+
    +
  • When the output type is unrecognized. This should never happen.
  • +
+

Examples

+
use std::outputs::output_asset_id;
+
+fn foo() {
+    let output_asset_id = output_asset_id(0);
+    log(output_asset_id);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/outputs/fn.output_asset_to.html b/v0.21.0/std/outputs/fn.output_asset_to.html new file mode 100644 index 00000000..c3abead5 --- /dev/null +++ b/v0.21.0/std/outputs/fn.output_asset_to.html @@ -0,0 +1,22 @@ +output_asset_to in outputs - Sway
pub fn output_asset_to(index: u64) -> Option<b256> 
Expand description

Returns the receiver of the output if it is a Output::Coin. Represents the receiver as a b256.

+

Arguments

+
    +
  • index: [u64] - The index of the output to get the receiver of.
  • +
+

Returns

+
    +
  • [Option] - The receiver of the output if it is a Output::Coin. None otherwise.
  • +
+

Reverts

+
    +
  • When the output type is unrecognized. This should never happen.
  • +
+

Examples

+
use std::outputs::output_asset_to;
+
+fn foo() {
+    let output_receiver = output_asset_to(0);
+    log(output_receiver);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/outputs/fn.output_count.html b/v0.21.0/std/outputs/fn.output_count.html new file mode 100644 index 00000000..74083771 --- /dev/null +++ b/v0.21.0/std/outputs/fn.output_count.html @@ -0,0 +1,19 @@ +output_count in outputs - Sway
pub fn output_count() -> u64 
Expand description

Get the transaction outputs count for either tx_type
+(transaction-script or transaction-create).

+

Returns

+
    +
  • [u64] - The transaction outputs count.
  • +
+

Reverts

+
    +
  • When the output type is unrecognized. This should never happen.
  • +
+

Examples

+
use std::outputs::output_count;
+
+fn foo() {
+    let output_count = output_count();
+    log(output_count);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/outputs/fn.output_pointer.html b/v0.21.0/std/outputs/fn.output_pointer.html new file mode 100644 index 00000000..e1829629 --- /dev/null +++ b/v0.21.0/std/outputs/fn.output_pointer.html @@ -0,0 +1,23 @@ +output_pointer in outputs - Sway
pub fn output_pointer(index: u64) -> u64 
Expand description

Get a pointer to the output at index
+for either tx_type (transaction-script or transaction-create).

+

Arguments

+
    +
  • index: [u64] - The index of the output to get the pointer to.
  • +
+

Returns

+
    +
  • [u64] - A pointer to the output at index.
  • +
+

Reverts

+
    +
  • When the output type is unrecognized. This should never happen.
  • +
+

Examples

+
use std::outputs::output_pointer;
+
+fn foo() {
+    let output_pointer = output_pointer(0);
+    log(output_pointer);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/outputs/fn.output_type.html b/v0.21.0/std/outputs/fn.output_type.html new file mode 100644 index 00000000..761fa813 --- /dev/null +++ b/v0.21.0/std/outputs/fn.output_type.html @@ -0,0 +1,27 @@ +output_type in outputs - Sway
pub fn output_type(index: u64) -> Output 
Expand description

Get the type of an output at index.

+

Arguments

+
    +
  • index: [u64] - The index of the output to get the type of.
  • +
+

Returns

+
    +
  • [Output] - The type of the output at index.
  • +
+

Reverts

+
    +
  • When the output type is unrecognized. This should never happen.
  • +
+

Examples

+
use std::outputs::output_type;
+
+fn foo() {
+    let output_type = output_type(0);
+    match output_type {
+        Output::Coin => { log("The output is a coin") },
+        Output::Contract => { log("The output is a contract") },
+        Output::Change => { log("The output is change") },
+        Output::Variable => { log("The output is a variable") },
+    };
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/outputs/index.html b/v0.21.0/std/outputs/index.html new file mode 100644 index 00000000..6e79e0a0 --- /dev/null +++ b/v0.21.0/std/outputs/index.html @@ -0,0 +1,7 @@ +outputs in std - Sway

Module std::outputs

Expand description

Getters for fields on transaction outputs.
+This includes Output::Coins, Input::Messages and Input::Contracts.

+

Enums

The output type for a transaction.

+

Constants

Functions

The amount of coins to send to the output at index.

+

Gets the AssetId of the output if it is a Output::Coin.

+

Returns the receiver of the output if it is a Output::Coin. Represents the receiver as a b256.

Get the transaction outputs count for either tx_type

Get a pointer to the output at index

Get the type of an output at index.

+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.balance.html b/v0.21.0/std/registers/fn.balance.html new file mode 100644 index 00000000..1b80b8bd --- /dev/null +++ b/v0.21.0/std/registers/fn.balance.html @@ -0,0 +1,14 @@ +balance in registers - Sway

Function std::registers::balance

pub fn balance() -> u64 
Expand description

Get the amount of units of call_frames::msg_asset_id() being sent.

+

Returns

+
    +
  • [u64] - The forwarded coins in the context.
  • +
+

Examples

+
use std::register::balance;
+
+fn foo() {
+    let bal = balance();
+    assert(bal == 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.context_gas.html b/v0.21.0/std/registers/fn.context_gas.html new file mode 100644 index 00000000..52e66e72 --- /dev/null +++ b/v0.21.0/std/registers/fn.context_gas.html @@ -0,0 +1,19 @@ +context_gas in registers - Sway
pub fn context_gas() -> u64 
Expand description

Remaining gas in the context.

+

Returns

+
    +
  • [u64] - The remaining gas for the curren context.
  • +
+

Examples

+
use std::registers::context_gas;
+
+fn foo() {
+    let gas = context_gas();
+    let gas_2 = bar();
+    assert(gas_2 < gas);
+}
+
+fn bar() -> u64 {
+    context_gas();
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.error.html b/v0.21.0/std/registers/fn.error.html new file mode 100644 index 00000000..91f926b8 --- /dev/null +++ b/v0.21.0/std/registers/fn.error.html @@ -0,0 +1,19 @@ +error in registers - Sway

Function std::registers::error

pub fn error() -> u64 
Expand description

Error codes for particular operations.

+

Additional Information

+

Normally, if the result of an ALU operation is mathematically undefined (e.g. dividing by zero), the VM Reverts.
+However, if the F_UNSAFEMATH flag is set, $err is set to true and execution continues.

+

Returns

+
    +
  • [u64] - A VM error code.
  • +
+

Examples

+
use std::{registers::error, flags::{disable_panic_on_unsafe_math, enable_panic_on_unsafe_math}};
+
+fn foo() {
+    disable_panic_on_unsafe_math();
+    let bar = 1 / 0;
+    assert(error() == 1);
+    enable_panic_on_unsafe_math();
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.flags.html b/v0.21.0/std/registers/fn.flags.html new file mode 100644 index 00000000..dead05ba --- /dev/null +++ b/v0.21.0/std/registers/fn.flags.html @@ -0,0 +1,19 @@ +flags in registers - Sway

Function std::registers::flags

pub fn flags() -> u64 
Expand description

Flags register.

+

Returns

+
    +
  • [u64] - The current flags set within the VM.
  • +
+

Examples

+
use std::{registers::flags, flags::disable_panic_on_overflow};
+
+const F_WRAPPING_DISABLE_MASK: u64 = 0b00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000010;
+
+fn foo() {
+    let flag = flags();
+    assert(flag == 0);
+    disable_panic_on_overflow();
+    let flag_2 = flags();
+    assert(flag_2 == F_WRAPPING_DISABLE_MASK);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.frame_ptr.html b/v0.21.0/std/registers/fn.frame_ptr.html new file mode 100644 index 00000000..7838bc9c --- /dev/null +++ b/v0.21.0/std/registers/fn.frame_ptr.html @@ -0,0 +1,14 @@ +frame_ptr in registers - Sway
pub fn frame_ptr() -> raw_ptr 
Expand description

Memory address of beginning of current call frame.

+

Returns

+
    +
  • [raw_ptr] - The location in memory of the start of the call frame.
  • +
+

Examples

+
use std::registers::frame_ptr;
+
+fn foo() {
+    let fp = frame_ptr();
+    assert(!fp.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.global_gas.html b/v0.21.0/std/registers/fn.global_gas.html new file mode 100644 index 00000000..6e9c5909 --- /dev/null +++ b/v0.21.0/std/registers/fn.global_gas.html @@ -0,0 +1,22 @@ +global_gas in registers - Sway
pub fn global_gas() -> u64 
Expand description

Remaining gas globally.

+

Returns

+
    +
  • [u64] - The remaining gas.
  • +
+

Examples

+
use std::registers::global_gas;
+
+fn foo() {
+    let gas = global_gas();
+    assert(gas != 0);
+    bar();
+
+    let gas_2 = global_gas();
+    assert(gas_2 < gas);
+}
+
+fn bar() {
+    let val = 0;
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.heap_ptr.html b/v0.21.0/std/registers/fn.heap_ptr.html new file mode 100644 index 00000000..e920b5f9 --- /dev/null +++ b/v0.21.0/std/registers/fn.heap_ptr.html @@ -0,0 +1,14 @@ +heap_ptr in registers - Sway
pub fn heap_ptr() -> raw_ptr 
Expand description

Memory address below the current bottom of the heap (points to free memory).

+

Returns

+
    +
  • [raw_ptr] - The location in memory of the bottom of the heap.
  • +
+

Examples

+
use std::registers::heap_ptr;
+
+fn foo() {
+    let hp = heap_ptr();
+    assert(!hp.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.instrs_start.html b/v0.21.0/std/registers/fn.instrs_start.html new file mode 100644 index 00000000..12956296 --- /dev/null +++ b/v0.21.0/std/registers/fn.instrs_start.html @@ -0,0 +1,14 @@ +instrs_start in registers - Sway
pub fn instrs_start() -> raw_ptr 
Expand description

Pointer to the start of the currently-executing code.

+

Returns

+
    +
  • [raw_ptr] - The memory location of the start of the currently-executing code.
  • +
+

Examples

+
use std::registers::instrs_start;
+
+fn foo() {
+    let is = instrs_start();
+    assert(!is.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.overflow.html b/v0.21.0/std/registers/fn.overflow.html new file mode 100644 index 00000000..ac270348 --- /dev/null +++ b/v0.21.0/std/registers/fn.overflow.html @@ -0,0 +1,22 @@ +overflow in registers - Sway
pub fn overflow() -> u64 
Expand description

Contains overflow & underflow of addition, subtraction, and multiplication.

+

Additional Information

+

In order to use this function, panic on overflow must be disabled.

+

Returns

+
    +
  • [u64] - The overflow or underflow remaining value.
  • +
+

Examples

+
use std::{registers::overflow, flags::{disable_panic_on_overflow, enable_panic_on_overflow}};
+
+fn foo() {
+   disable_panic_on_overflow();
+   let max = u64::max();
+   let result = max + 1;
+   let overflow_val = overflow();
+
+   assert(result == 0);
+   assert(overflow_val == 1);
+   enable_panic_on_overflow();
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.program_counter.html b/v0.21.0/std/registers/fn.program_counter.html new file mode 100644 index 00000000..f5cfbec5 --- /dev/null +++ b/v0.21.0/std/registers/fn.program_counter.html @@ -0,0 +1,14 @@ +program_counter in registers - Sway
pub fn program_counter() -> raw_ptr 
Expand description

The program counter. Memory address of the current instruction.

+

Returns

+
    +
  • [raw_ptr] - The location in memory of the current instruction.
  • +
+

Examples

+
use std::registers::program_counter;
+
+fn foo() {
+    let pc = program_counter();
+    assert(!pc.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.return_length.html b/v0.21.0/std/registers/fn.return_length.html new file mode 100644 index 00000000..de8e4cf7 --- /dev/null +++ b/v0.21.0/std/registers/fn.return_length.html @@ -0,0 +1,14 @@ +return_length in registers - Sway
pub fn return_length() -> u64 
Expand description

Return value length in bytes.

+

Returns

+
    +
  • [u64] - The length in bytes of the value stored in the return register of the VM for the current context.
  • +
+

Examples

+
use std::registers::return_length;
+
+fn foo() {
+    let ret = return_length();
+    assert(ret == 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.return_value.html b/v0.21.0/std/registers/fn.return_value.html new file mode 100644 index 00000000..ecfb1dae --- /dev/null +++ b/v0.21.0/std/registers/fn.return_value.html @@ -0,0 +1,14 @@ +return_value in registers - Sway
pub fn return_value() -> u64 
Expand description

Return value or pointer.

+

Returns

+
    +
  • [u64] - The value or pointer stored in the return register of the VM for the current context.
  • +
+

Examples

+
use std::registers::return_value;
+
+fn foo() {
+    let ret = return_value();
+    assert(ret == 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.stack_ptr.html b/v0.21.0/std/registers/fn.stack_ptr.html new file mode 100644 index 00000000..568a3fb0 --- /dev/null +++ b/v0.21.0/std/registers/fn.stack_ptr.html @@ -0,0 +1,14 @@ +stack_ptr in registers - Sway
pub fn stack_ptr() -> raw_ptr 
Expand description

Memory address on top of current writable stack area (points to free memory).

+

Returns

+
    +
  • [raw_ptr] - The location in memory of the top of the stack.
  • +
+

Examples

+
use std::registers::stack_ptr;
+
+fn foo() {
+    let sp = stack_ptr();
+    assert(!sp.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/fn.stack_start_ptr.html b/v0.21.0/std/registers/fn.stack_start_ptr.html new file mode 100644 index 00000000..74bb2614 --- /dev/null +++ b/v0.21.0/std/registers/fn.stack_start_ptr.html @@ -0,0 +1,14 @@ +stack_start_ptr in registers - Sway
pub fn stack_start_ptr() -> raw_ptr 
Expand description

Memory address of bottom of current writable stack area.

+

Returns

+
    +
  • [raw_ptr] - The location in memory of the bottom of the stack.
  • +
+

Examples

+
use std::registers::stack_start_ptr;
+
+fn foo() {
+    let ssp = stack_start_ptr();
+    assert(!ssp.is_null());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/registers/index.html b/v0.21.0/std/registers/index.html new file mode 100644 index 00000000..9f52a539 --- /dev/null +++ b/v0.21.0/std/registers/index.html @@ -0,0 +1,17 @@ +registers in std - Sway

Module std::registers

Expand description

Functions to expose 14 of the reserved FuelVM registers for ease of use.
+Ref: https://fuellabs.github.io/fuel-specs/master/vm#semantics

+

Functions

Get the amount of units of call_frames::msg_asset_id() being sent.

+

Remaining gas in the context.

+

Error codes for particular operations.

+

Flags register.

+

Memory address of beginning of current call frame.

+

Remaining gas globally.

+

Memory address below the current bottom of the heap (points to free memory).

+

Pointer to the start of the currently-executing code.

+

Contains overflow & underflow of addition, subtraction, and multiplication.

+

The program counter. Memory address of the current instruction.

+

Return value length in bytes.

+

Return value or pointer.

+

Memory address on top of current writable stack area (points to free memory).

+

Memory address of bottom of current writable stack area.

+
\ No newline at end of file diff --git a/v0.21.0/std/result/enum.Result.html b/v0.21.0/std/result/enum.Result.html new file mode 100644 index 00000000..7407d48f --- /dev/null +++ b/v0.21.0/std/result/enum.Result.html @@ -0,0 +1,9 @@ +Result in result - Sway
pub enum Result<T, E> {
+    /// Contains the success value.
+    Ok: T,
+    /// Contains the error value.
+    Err: E,
+}
Expand description

Result is a type that represents either success (Ok) or failure (Err).

+

Variants

Ok: T

Contains the success value.

+

Err: E

Contains the error value.

+
\ No newline at end of file diff --git a/v0.21.0/std/result/index.html b/v0.21.0/std/result/index.html new file mode 100644 index 00000000..bfe46b43 --- /dev/null +++ b/v0.21.0/std/result/index.html @@ -0,0 +1,44 @@ +result in std - Sway

Module std::result

Expand description

Error handling with the Result type.

+

Result<T, E> Result is the type used for returning and propagating
+errors. It is an enum with the variants, Ok(T), representing
+success and containing a value, and Err(E), representing error
+and containing an error value.

+

Functions return Result whenever errors are expected and recoverable. In
+the std crate, Result is most prominently used for Identity
+interactions and cryptographic operations.

+

A simple function returning Result might be defined and used like so:

+
enum Version {
+    Version1,
+    Version2,
+}
+
+enum VersionError {
+    InvalidNumber,
+}
+
+fn parse_version(version_number: u8) -> Result<Version, VersionError> {
+    match version_number {
+        1 => Ok(Version::Version1),
+        2 => Ok(Version::Version2),
+        _ => Err(VersionError::InvalidNumber),
+    }
+}
+
+

Method overview

+

In addition to working with pattern matching, Result provides a variety
+of methods.

+

Querying the variant

+

The is_ok and is_err methods return true if the Result is
+Ok or Err, respectively.

+

is_ok : Result::is_ok
+is_err: Result::is_err

+

Extracting the contained value

+

These methods extract the contained value in a Result<T,E> when it is
+the Ok variant. If the Result is Err:

+
    +
  • unwrap reverts.
  • +
  • unwrap_or returns the default provided value.
  • +
+

unwrap : Result::unwrap
+unwrap_or: Result::unwrap_or

+

Enums

Result is a type that represents either success (Ok) or failure (Err).

\ No newline at end of file diff --git a/v0.21.0/std/revert/fn.require.html b/v0.21.0/std/revert/fn.require.html new file mode 100644 index 00000000..c1fbb572 --- /dev/null +++ b/v0.21.0/std/revert/fn.require.html @@ -0,0 +1,18 @@ +require in revert - Sway

Function std::revert::require

pub fn require<T>(condition: bool, value: T) 
Expand description

Checks if the given condition is true and if not, logs value and reverts.

+

Arguments

+
    +
  • condition: [bool] - The condition upon which to decide whether to revert or not.
  • +
  • value: [T] - The value which will be logged in case condition is false.
  • +
+

Reverts

+
    +
  • Reverts when condition is false.
  • +
+

Examples

+
fn foo(a: u64, b: u64) {
+    require(a == b, "a was not equal to b");
+    // If the condition was true, code execution will continue
+    log("The require function did not revert");
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/revert/fn.revert.html b/v0.21.0/std/revert/fn.revert.html new file mode 100644 index 00000000..5d952f3d --- /dev/null +++ b/v0.21.0/std/revert/fn.revert.html @@ -0,0 +1,21 @@ +revert in revert - Sway

Function std::revert::revert

pub fn revert(code: u64) -> ! 
Expand description

Will either panic or revert with a given number depending on the context.

+

Additional Information

+

If used in a predicate, it will panic.
+If used in a contract, it will revert.

+

Arguments

+
    +
  • code: [u64] - The code with which to revert the program.
  • +
+

Reverts

+
    +
  • Reverts unconditionally.
  • +
+

Examples

+
fn foo(should_revert: bool) {
+    match should_revert {
+        true => revert(0),
+        false => {},
+    }
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/revert/index.html b/v0.21.0/std/revert/index.html new file mode 100644 index 00000000..9a2f54c9 --- /dev/null +++ b/v0.21.0/std/revert/index.html @@ -0,0 +1,3 @@ +revert in std - Sway

Module std::revert

Expand description

Functions to panic or revert with a given error code.

+

Functions

Checks if the given condition is true and if not, logs value and reverts.

Will either panic or revert with a given number depending on the context.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/index.html b/v0.21.0/std/storage/index.html new file mode 100644 index 00000000..b6de621f --- /dev/null +++ b/v0.21.0/std/storage/index.html @@ -0,0 +1,7 @@ +storage in std - Sway

Module std::storage

Modules

Contract storage utilities.

+

Contract storage utilities.

+

Contract storage utilities.

+

Contract storage utilities.

+

Contract storage utilities.

+

Contract storage utilities.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storable_slice/fn.clear_slice.html b/v0.21.0/std/storage/storable_slice/fn.clear_slice.html new file mode 100644 index 00000000..4ddca0d4 --- /dev/null +++ b/v0.21.0/std/storage/storable_slice/fn.clear_slice.html @@ -0,0 +1,27 @@ +clear_slice in storable_slice - Sway
pub fn clear_slice(key: b256) -> bool 
Expand description

Clear a sequence of storage slots starting at a some key.

+

Arguments

+
    +
  • key: [b256] - The key of the first storage slot that will be cleared
  • +
+

Returns

+
    +
  • [bool] - Indicates whether all of the storage slots cleared were previously set.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
  • Clears: 2
  • +
+

Examples

+
use std::{alloc::alloc_bytes, storage::{clear_slice, write_slice, read_slice}, constants::ZERO_B256};
+
+fn foo() {
+    let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
+    write_slice(ZERO_B256, slice);
+    assert(read_slice(ZERO_B256).is_some());
+    let cleared = clear_slice(ZERO_B256);
+    assert(cleared);
+    assert(read_slice(ZERO_B256).is_none());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storable_slice/fn.read_slice.html b/v0.21.0/std/storage/storable_slice/fn.read_slice.html new file mode 100644 index 00000000..9e8fad6a --- /dev/null +++ b/v0.21.0/std/storage/storable_slice/fn.read_slice.html @@ -0,0 +1,26 @@ +read_slice in storable_slice - Sway
pub fn read_slice(key: b256) -> Option<raw_slice> 
Expand description

Load a raw_slice from storage.

+

Arguments

+
    +
  • key: [b256] - The storage slot to load the value from.
  • +
+

Returns

+
    +
  • [Option<raw_slice>] - If no value was previously stored at key, None is returned. Otherwise,
    +Some(value) is returned, where value is the value stored at key.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 2
  • +
+

Examples

+
use std::{alloc::alloc_bytes, storage::{write_slice, read_slice}, constants::ZERO_B256};
+
+fn foo {
+    let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
+    assert(read_slice(ZERO_B256).is_none());
+    write_slice(ZERO_B256, slice);
+    let stored_slice = read_slice(ZERO_B256).unwrap();
+    assert(slice == stored_slice);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storable_slice/fn.write_slice.html b/v0.21.0/std/storage/storable_slice/fn.write_slice.html new file mode 100644 index 00000000..9d952b4f --- /dev/null +++ b/v0.21.0/std/storage/storable_slice/fn.write_slice.html @@ -0,0 +1,22 @@ +write_slice in storable_slice - Sway
pub fn write_slice(key: b256, slice: raw_slice) 
Expand description

Store a raw_slice from the heap into storage.

+

Arguments

+
    +
  • key: [b256] - The storage slot at which the variable will be stored.
  • +
  • slice: [raw_slice] - The raw_slice to be stored.
  • +
+

Number of Storage Accesses

+
    +
  • Writes: 2
  • +
+

Examples

+
use std::{alloc::alloc_bytes, storage::{write_slice, read_slice}, constants::ZERO_B256};
+
+fn foo() {
+    let slice = asm(ptr: (alloc_bytes(1), 1)) { ptr: raw_slice };
+    assert(read_slice(ZERO_B256).is_none());
+    write_slice(ZERO_B256, slice);
+    let stored_slice = read_slice(ZERO_B256).unwrap();
+    assert(slice == stored_slice);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storable_slice/index.html b/v0.21.0/std/storage/storable_slice/index.html new file mode 100644 index 00000000..3a3b3091 --- /dev/null +++ b/v0.21.0/std/storage/storable_slice/index.html @@ -0,0 +1,6 @@ +storable_slice in std - Sway
Expand description

Contract storage utilities.

+

Traits

A general way to persistently store heap types.

+

Functions

Clear a sequence of storage slots starting at a some key.

+

Load a raw_slice from storage.

+

Store a raw_slice from the heap into storage.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storable_slice/trait.StorableSlice.html b/v0.21.0/std/storage/storable_slice/trait.StorableSlice.html new file mode 100644 index 00000000..d975e2b4 --- /dev/null +++ b/v0.21.0/std/storage/storable_slice/trait.StorableSlice.html @@ -0,0 +1,11 @@ +StorableSlice in storable_slice - Sway
pub trait StorableSlice<T> {
+    #[storage(read, write)]
+    fn write_slice(self, argument: T);
+    #[storage(read)]
+    fn read_slice(self) -> Option<T>;
+    #[storage(read, write)]
+    fn clear(self) -> bool;
+    #[storage(read)]
+    fn len(self) -> u64;
+}
Expand description

A general way to persistently store heap types.

+

Required Methods

\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_api/fn.clear.html b/v0.21.0/std/storage/storage_api/fn.clear.html new file mode 100644 index 00000000..9636387d --- /dev/null +++ b/v0.21.0/std/storage/storage_api/fn.clear.html @@ -0,0 +1,22 @@ +clear in storage_api - Sway
pub fn clear<T>(slot: b256, offset: u64) -> bool 
Expand description

Clear a value starting at some slot with an offset.

+

Arguments

+
    +
  • slot - The key of the stored value that will be cleared
  • +
  • offset - An offset, in words, from the start of slot, from which the value should be cleared.
  • +
+

Number of Storage Accesses

+
    +
  • Clears: 1
  • +
+

Examples

+
use std::{storage::storage_api::{read, write, clear}, constants::ZERO_B256};
+
+fn foo() {
+    let five = 5_u64;
+    write(ZERO_B256, 0, five);
+    let cleared = clear::<u64>(ZERO_B256);
+    assert(cleared);
+    assert(read::<u64>(ZERO_B256, 0).is_none());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_api/fn.read.html b/v0.21.0/std/storage/storage_api/fn.read.html new file mode 100644 index 00000000..97e2836e --- /dev/null +++ b/v0.21.0/std/storage/storage_api/fn.read.html @@ -0,0 +1,27 @@ +read in storage_api - Sway
pub fn read<T>(slot: b256, offset: u64) -> Option<T> 
Expand description

Reads a value of type T starting at the location specified by slot and offset. If the
+value crosses the boundary of a storage slot, reading continues at the following slot.

+

Arguments

+
    +
  • slot: [b256] - The storage slot to load the value from.
  • +
  • offset: [u64] - An offset, in words, from the start of slot, from which the value should be read.
  • +
+

Returns

+
    +
  • [Option] - Option(value) if the storage slots read were valid and contain value. Otherwise,
    +returns None.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use std::{storage::storage_api::{read, write}, constants::ZERO_B256};
+
+fn foo() {
+    let five = 5_u64;
+    write(ZERO_B256, 2, five);
+    let stored_five = read::<u64>(ZERO_B256, 2);
+    assert(five == stored_five.unwrap());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_api/fn.write.html b/v0.21.0/std/storage/storage_api/fn.write.html new file mode 100644 index 00000000..48d07f72 --- /dev/null +++ b/v0.21.0/std/storage/storage_api/fn.write.html @@ -0,0 +1,25 @@ +write in storage_api - Sway
pub fn write<T>(slot: b256, offset: u64, value: T) 
Expand description

Stores a stack value in storage. Will not work for heap values.

+

Additional Information

+

If the value crosses the boundary of a storage slot, writing continues at the following slot.

+

Arguments

+
    +
  • slot: [b256] - The storage slot at which the variable will be stored.
  • +
  • offset: [u64] - An offset starting at the beginning of slot at which value should be stored.
  • +
  • value: [T] - The value to be stored.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
  • Writes: 1
  • +
+

Examples

+
use std::{storage::storage_api::{read, write}, constants::ZERO_B256};
+
+fn foo() {
+    let five = 5_u64;
+    write(ZERO_B256, 2, five);
+    let stored_five = read::<u64>(ZERO_B256, 2).unwrap();
+    assert(five == stored_five);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_api/index.html b/v0.21.0/std/storage/storage_api/index.html new file mode 100644 index 00000000..bf812ff3 --- /dev/null +++ b/v0.21.0/std/storage/storage_api/index.html @@ -0,0 +1,4 @@ +storage_api in std - Sway
Expand description

Contract storage utilities.

+

Functions

Clear a value starting at some slot with an offset.

+

Reads a value of type T starting at the location specified by slot and offset. If the

Stores a stack value in storage. Will not work for heap values.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_bytes/index.html b/v0.21.0/std/storage/storage_bytes/index.html new file mode 100644 index 00000000..2b549156 --- /dev/null +++ b/v0.21.0/std/storage/storage_bytes/index.html @@ -0,0 +1,3 @@ +storage_bytes in std - Sway
Expand description

Contract storage utilities.

+

Structs

A persistent storage type to store a collection of tightly packed bytes.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_bytes/struct.StorageBytes.html b/v0.21.0/std/storage/storage_bytes/struct.StorageBytes.html new file mode 100644 index 00000000..576ce594 --- /dev/null +++ b/v0.21.0/std/storage/storage_bytes/struct.StorageBytes.html @@ -0,0 +1,2 @@ +StorageBytes in storage_bytes - Sway
pub struct StorageBytes {}
Expand description

A persistent storage type to store a collection of tightly packed bytes.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_map/enum.StorageMapError.html b/v0.21.0/std/storage/storage_map/enum.StorageMapError.html new file mode 100644 index 00000000..ad0905fe --- /dev/null +++ b/v0.21.0/std/storage/storage_map/enum.StorageMapError.html @@ -0,0 +1,6 @@ +StorageMapError in storage_map - Sway
pub enum StorageMapError<V> {
+    /// Indicates that a value already exists for the key.
+    OccupiedError: V,
+}
Expand description

Errors pertaining to the StorageMap struct.

+

Variants

OccupiedError: V

Indicates that a value already exists for the key.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_map/index.html b/v0.21.0/std/storage/storage_map/index.html new file mode 100644 index 00000000..9796ef24 --- /dev/null +++ b/v0.21.0/std/storage/storage_map/index.html @@ -0,0 +1,4 @@ +storage_map in std - Sway
Expand description

Contract storage utilities.

+

Structs

A persistent key-value pair mapping struct.

+

Enums

Errors pertaining to the StorageMap struct.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_map/struct.StorageMap.html b/v0.21.0/std/storage/storage_map/struct.StorageMap.html new file mode 100644 index 00000000..86664865 --- /dev/null +++ b/v0.21.0/std/storage/storage_map/struct.StorageMap.html @@ -0,0 +1,5 @@ +StorageMap in storage_map - Sway
pub struct StorageMap<K, V>
+where
+    K: Hash,
+{}
Expand description

A persistent key-value pair mapping struct.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_string/index.html b/v0.21.0/std/storage/storage_string/index.html new file mode 100644 index 00000000..03538dac --- /dev/null +++ b/v0.21.0/std/storage/storage_string/index.html @@ -0,0 +1,2 @@ +storage_string in std - Sway
Expand description

Contract storage utilities.

+

Structs

\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_string/struct.StorageString.html b/v0.21.0/std/storage/storage_string/struct.StorageString.html new file mode 100644 index 00000000..672bbfc0 --- /dev/null +++ b/v0.21.0/std/storage/storage_string/struct.StorageString.html @@ -0,0 +1 @@ +StorageString in storage_string - Sway
pub struct StorageString {}
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_vec/index.html b/v0.21.0/std/storage/storage_vec/index.html new file mode 100644 index 00000000..45ccbe39 --- /dev/null +++ b/v0.21.0/std/storage/storage_vec/index.html @@ -0,0 +1,3 @@ +storage_vec in std - Sway
Expand description

Contract storage utilities.

+

Structs

A persistent vector struct.

+
\ No newline at end of file diff --git a/v0.21.0/std/storage/storage_vec/struct.StorageVec.html b/v0.21.0/std/storage/storage_vec/struct.StorageVec.html new file mode 100644 index 00000000..ca874bf8 --- /dev/null +++ b/v0.21.0/std/storage/storage_vec/struct.StorageVec.html @@ -0,0 +1,2 @@ +StorageVec in storage_vec - Sway
pub struct StorageVec<V> {}
Expand description

A persistent vector struct.

+
\ No newline at end of file diff --git a/v0.21.0/std/string/index.html b/v0.21.0/std/string/index.html new file mode 100644 index 00000000..93a9f33a --- /dev/null +++ b/v0.21.0/std/string/index.html @@ -0,0 +1,2 @@ +string in std - Sway

Module std::string

Structs

A UTF-8 encoded growable string.

+
\ No newline at end of file diff --git a/v0.21.0/std/string/struct.String.html b/v0.21.0/std/string/struct.String.html new file mode 100644 index 00000000..8fd6f7bf --- /dev/null +++ b/v0.21.0/std/string/struct.String.html @@ -0,0 +1,40 @@ +String in string - Sway

Struct std::string::String

pub struct String {
+    /// The bytes representing the characters of the string.
+    bytes: Bytes,
+}
Expand description

A UTF-8 encoded growable string.

+

Additional Information

+

WARNING: As this type is meant to be forward compatible with UTF-8, do not
+add any mutation functionality or unicode input of any kind until char is
+implemented, codepoints are not guaranteed to fall on byte boundaries

+

Fields

bytes: Bytes

The bytes representing the characters of the string.

+

Trait Implementations

fn from(b: Bytes) -> Self

fn as_raw_slice(self) -> raw_slice

Returns a raw slice to all of the elements in the string.

+

fn from(slice: raw_slice) -> Self

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn hash(
self,
refmut state: Hasher,
)

\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_CREATE_INPUTS_COUNT.html b/v0.21.0/std/tx/constant.GTF_CREATE_INPUTS_COUNT.html new file mode 100644 index 00000000..5d675c92 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_CREATE_INPUTS_COUNT.html @@ -0,0 +1 @@ +GTF_CREATE_INPUTS_COUNT in tx - Sway
pub const GTF_CREATE_INPUTS_COUNT = 0x103
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_CREATE_INPUT_AT_INDEX.html b/v0.21.0/std/tx/constant.GTF_CREATE_INPUT_AT_INDEX.html new file mode 100644 index 00000000..b9f2cbc8 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_CREATE_INPUT_AT_INDEX.html @@ -0,0 +1 @@ +GTF_CREATE_INPUT_AT_INDEX in tx - Sway
pub const GTF_CREATE_INPUT_AT_INDEX = 0x108
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_CREATE_OUTPUTS_COUNT.html b/v0.21.0/std/tx/constant.GTF_CREATE_OUTPUTS_COUNT.html new file mode 100644 index 00000000..f943f6be --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_CREATE_OUTPUTS_COUNT.html @@ -0,0 +1 @@ +GTF_CREATE_OUTPUTS_COUNT in tx - Sway
pub const GTF_CREATE_OUTPUTS_COUNT = 0x104
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_CREATE_OUTPUT_AT_INDEX.html b/v0.21.0/std/tx/constant.GTF_CREATE_OUTPUT_AT_INDEX.html new file mode 100644 index 00000000..9ef3c65c --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_CREATE_OUTPUT_AT_INDEX.html @@ -0,0 +1 @@ +GTF_CREATE_OUTPUT_AT_INDEX in tx - Sway
pub const GTF_CREATE_OUTPUT_AT_INDEX = 0x109
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_CREATE_WITNESSES_COUNT.html b/v0.21.0/std/tx/constant.GTF_CREATE_WITNESSES_COUNT.html new file mode 100644 index 00000000..d6df650a --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_CREATE_WITNESSES_COUNT.html @@ -0,0 +1 @@ +GTF_CREATE_WITNESSES_COUNT in tx - Sway
pub const GTF_CREATE_WITNESSES_COUNT = 0x105
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_CREATE_WITNESS_AT_INDEX.html b/v0.21.0/std/tx/constant.GTF_CREATE_WITNESS_AT_INDEX.html new file mode 100644 index 00000000..40627dfb --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_CREATE_WITNESS_AT_INDEX.html @@ -0,0 +1 @@ +GTF_CREATE_WITNESS_AT_INDEX in tx - Sway
pub const GTF_CREATE_WITNESS_AT_INDEX = 0x10A
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_POLICY_GAS_PRICE.html b/v0.21.0/std/tx/constant.GTF_POLICY_GAS_PRICE.html new file mode 100644 index 00000000..c19fed06 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_POLICY_GAS_PRICE.html @@ -0,0 +1 @@ +GTF_POLICY_GAS_PRICE in tx - Sway
pub const GTF_POLICY_GAS_PRICE = 0x501
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_POLICY_MATURITY.html b/v0.21.0/std/tx/constant.GTF_POLICY_MATURITY.html new file mode 100644 index 00000000..dc06dcc9 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_POLICY_MATURITY.html @@ -0,0 +1 @@ +GTF_POLICY_MATURITY in tx - Sway
pub const GTF_POLICY_MATURITY = 0x503
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_POLICY_MAX_FEE.html b/v0.21.0/std/tx/constant.GTF_POLICY_MAX_FEE.html new file mode 100644 index 00000000..b16b72fc --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_POLICY_MAX_FEE.html @@ -0,0 +1 @@ +GTF_POLICY_MAX_FEE in tx - Sway
pub const GTF_POLICY_MAX_FEE = 0x504
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_POLICY_TYPES.html b/v0.21.0/std/tx/constant.GTF_POLICY_TYPES.html new file mode 100644 index 00000000..807c71e4 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_POLICY_TYPES.html @@ -0,0 +1 @@ +GTF_POLICY_TYPES in tx - Sway
pub const GTF_POLICY_TYPES = 0x500
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_POLICY_WITNESS_LIMIT.html b/v0.21.0/std/tx/constant.GTF_POLICY_WITNESS_LIMIT.html new file mode 100644 index 00000000..d8638287 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_POLICY_WITNESS_LIMIT.html @@ -0,0 +1 @@ +GTF_POLICY_WITNESS_LIMIT in tx - Sway
pub const GTF_POLICY_WITNESS_LIMIT = 0x502
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_GAS_LIMIT.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_GAS_LIMIT.html new file mode 100644 index 00000000..d2f9b8ac --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_GAS_LIMIT.html @@ -0,0 +1 @@ +GTF_SCRIPT_GAS_LIMIT in tx - Sway
pub const GTF_SCRIPT_GAS_LIMIT = 0x002
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_INPUTS_COUNT.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_INPUTS_COUNT.html new file mode 100644 index 00000000..c4f5847c --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_INPUTS_COUNT.html @@ -0,0 +1 @@ +GTF_SCRIPT_INPUTS_COUNT in tx - Sway
pub const GTF_SCRIPT_INPUTS_COUNT = 0x005
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_INPUT_AT_INDEX.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_INPUT_AT_INDEX.html new file mode 100644 index 00000000..0d886e42 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_INPUT_AT_INDEX.html @@ -0,0 +1 @@ +GTF_SCRIPT_INPUT_AT_INDEX in tx - Sway
pub const GTF_SCRIPT_INPUT_AT_INDEX = 0x00B
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_OUTPUTS_COUNT.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_OUTPUTS_COUNT.html new file mode 100644 index 00000000..475fa526 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_OUTPUTS_COUNT.html @@ -0,0 +1 @@ +GTF_SCRIPT_OUTPUTS_COUNT in tx - Sway
pub const GTF_SCRIPT_OUTPUTS_COUNT = 0x006
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_OUTPUT_AT_INDEX.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_OUTPUT_AT_INDEX.html new file mode 100644 index 00000000..753d55c6 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_OUTPUT_AT_INDEX.html @@ -0,0 +1 @@ +GTF_SCRIPT_OUTPUT_AT_INDEX in tx - Sway
pub const GTF_SCRIPT_OUTPUT_AT_INDEX = 0x00C
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_RECEIPTS_ROOT.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_RECEIPTS_ROOT.html new file mode 100644 index 00000000..7ad2c0ac --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_RECEIPTS_ROOT.html @@ -0,0 +1 @@ +GTF_SCRIPT_RECEIPTS_ROOT in tx - Sway
pub const GTF_SCRIPT_RECEIPTS_ROOT = 0x008
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT.html new file mode 100644 index 00000000..4fd377b9 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT.html @@ -0,0 +1 @@ +GTF_SCRIPT_SCRIPT in tx - Sway
pub const GTF_SCRIPT_SCRIPT = 0x009
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_DATA.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_DATA.html new file mode 100644 index 00000000..f67bdebc --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_DATA.html @@ -0,0 +1 @@ +GTF_SCRIPT_SCRIPT_DATA in tx - Sway
pub const GTF_SCRIPT_SCRIPT_DATA = 0x00A
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_DATA_LENGTH.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_DATA_LENGTH.html new file mode 100644 index 00000000..f99da339 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_DATA_LENGTH.html @@ -0,0 +1 @@ +GTF_SCRIPT_SCRIPT_DATA_LENGTH in tx - Sway
pub const GTF_SCRIPT_SCRIPT_DATA_LENGTH = 0x004
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_LENGTH.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_LENGTH.html new file mode 100644 index 00000000..e527fe58 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_SCRIPT_LENGTH.html @@ -0,0 +1 @@ +GTF_SCRIPT_SCRIPT_LENGTH in tx - Sway
pub const GTF_SCRIPT_SCRIPT_LENGTH = 0x003
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_WITNESSES_COUNT.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_WITNESSES_COUNT.html new file mode 100644 index 00000000..75434dcf --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_WITNESSES_COUNT.html @@ -0,0 +1 @@ +GTF_SCRIPT_WITNESSES_COUNT in tx - Sway
pub const GTF_SCRIPT_WITNESSES_COUNT = 0x007
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_SCRIPT_WITNESS_AT_INDEX.html b/v0.21.0/std/tx/constant.GTF_SCRIPT_WITNESS_AT_INDEX.html new file mode 100644 index 00000000..9971de6f --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_SCRIPT_WITNESS_AT_INDEX.html @@ -0,0 +1 @@ +GTF_SCRIPT_WITNESS_AT_INDEX in tx - Sway
pub const GTF_SCRIPT_WITNESS_AT_INDEX = 0x00D
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_TYPE.html b/v0.21.0/std/tx/constant.GTF_TYPE.html new file mode 100644 index 00000000..a0e5d909 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_TYPE.html @@ -0,0 +1 @@ +GTF_TYPE in tx - Sway

Constant std::tx::GTF_TYPE

pub const GTF_TYPE = 0x001
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_WITNESS_DATA.html b/v0.21.0/std/tx/constant.GTF_WITNESS_DATA.html new file mode 100644 index 00000000..93070d67 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_WITNESS_DATA.html @@ -0,0 +1 @@ +GTF_WITNESS_DATA in tx - Sway
pub const GTF_WITNESS_DATA = 0x401
\ No newline at end of file diff --git a/v0.21.0/std/tx/constant.GTF_WITNESS_DATA_LENGTH.html b/v0.21.0/std/tx/constant.GTF_WITNESS_DATA_LENGTH.html new file mode 100644 index 00000000..9984f160 --- /dev/null +++ b/v0.21.0/std/tx/constant.GTF_WITNESS_DATA_LENGTH.html @@ -0,0 +1 @@ +GTF_WITNESS_DATA_LENGTH in tx - Sway
pub const GTF_WITNESS_DATA_LENGTH = 0x400
\ No newline at end of file diff --git a/v0.21.0/std/tx/enum.Transaction.html b/v0.21.0/std/tx/enum.Transaction.html new file mode 100644 index 00000000..5ef41c52 --- /dev/null +++ b/v0.21.0/std/tx/enum.Transaction.html @@ -0,0 +1,9 @@ +Transaction in tx - Sway
pub enum Transaction {
+    /// A standard transaction, where execution is defined by a script.
+    Script: (),
+    /// A contract deployment transaction.
+    Create: (),
+}
Expand description

A transaction type.

+

Variants

Script: ()

A standard transaction, where execution is defined by a script.

+

Create: ()

A contract deployment transaction.

+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.script_gas_limit.html b/v0.21.0/std/tx/fn.script_gas_limit.html new file mode 100644 index 00000000..40bccdf4 --- /dev/null +++ b/v0.21.0/std/tx/fn.script_gas_limit.html @@ -0,0 +1,14 @@ +script_gas_limit in tx - Sway
pub fn script_gas_limit() -> u64 
Expand description

Get the script gas limit for the transaction.

+

Returns

+
    +
  • [u64] - The script gas limit for the transaction.
  • +
+

Examples

+
use std::tx::script_gas_limit;
+
+fn foo() {
+    let gas_limit = script_gas_limit();
+    log(gas_limit);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_gas_price.html b/v0.21.0/std/tx/fn.tx_gas_price.html new file mode 100644 index 00000000..d88da671 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_gas_price.html @@ -0,0 +1,14 @@ +tx_gas_price in tx - Sway

Function std::tx::tx_gas_price

pub fn tx_gas_price() -> Option<u64> 
Expand description

Get the gas price for the transaction, if it is set.

+

Returns

+
    +
  • [Option] - The gas price for the transaction.
  • +
+

Examples

+
use std::tx::tx_gas_price;
+
+fn foo() {
+    let gas_price = tx_gas_price();
+    log(gas_price);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_id.html b/v0.21.0/std/tx/fn.tx_id.html new file mode 100644 index 00000000..a1735c32 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_id.html @@ -0,0 +1,14 @@ +tx_id in tx - Sway

Function std::tx::tx_id

pub fn tx_id() -> b256 
Expand description

Get the Transaction ID of the current transaction.

+

Returns

+
    +
  • [b256] - The Transaction ID of the current transaction.
  • +
+

Examples

+
use std::tx::tx_id;
+
+fn foo() {
+    let tx_id: b256 = tx_id();
+    log(tx_id);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_maturity.html b/v0.21.0/std/tx/fn.tx_maturity.html new file mode 100644 index 00000000..e697e66c --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_maturity.html @@ -0,0 +1,14 @@ +tx_maturity in tx - Sway

Function std::tx::tx_maturity

pub fn tx_maturity() -> Option<u32> 
Expand description

Get the maturity for the transaction, if it is set.

+

Returns

+
    +
  • [Option] - The maturity for the transaction.
  • +
+

Examples

+
use std::tx::tx_maturity;
+
+fn foo() {
+    let maturity = tx_maturity();
+    log(maturity);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_max_fee.html b/v0.21.0/std/tx/fn.tx_max_fee.html new file mode 100644 index 00000000..e062fc8d --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_max_fee.html @@ -0,0 +1,14 @@ +tx_max_fee in tx - Sway

Function std::tx::tx_max_fee

pub fn tx_max_fee() -> Option<u64> 
Expand description

Get the max fee for the transaction, if it is set.

+

Returns

+
    +
  • [Option] - The max fee for the transaction.
  • +
+

Examples

+
use std::tx::tx_max_fee;
+
+fn foo() {
+    let max_fee = tx_max_fee();
+    log(max_fee);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_receipts_root.html b/v0.21.0/std/tx/fn.tx_receipts_root.html new file mode 100644 index 00000000..6a2dfbcc --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_receipts_root.html @@ -0,0 +1,18 @@ +tx_receipts_root in tx - Sway
pub fn tx_receipts_root() -> b256 
Expand description

Get the transaction receipts root.

+

Returns

+
    +
  • [b256] - The transaction receipts root.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_receipts_root;
+
+fn foo() {
+    let receipts_root = tx_receipts_root();
+    log(receipts_root);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_script_bytecode.html b/v0.21.0/std/tx/fn.tx_script_bytecode.html new file mode 100644 index 00000000..5835bc83 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_script_bytecode.html @@ -0,0 +1,21 @@ +tx_script_bytecode in tx - Sway
pub fn tx_script_bytecode<T>() -> T 
Expand description

Get the script bytecode.

+

Additional Information

+

Must be cast to a u64 array, with sufficient length to contain the bytecode.
+Bytecode will be padded to next whole word.

+

Returns

+
    +
  • [T] - The script bytecode.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_script_bytecode;
+
+fn foo() {
+    let script_bytecode: [u64; 64] = tx_script_bytecode();
+    log(script_bytecode);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_script_bytecode_hash.html b/v0.21.0/std/tx/fn.tx_script_bytecode_hash.html new file mode 100644 index 00000000..12248dd6 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_script_bytecode_hash.html @@ -0,0 +1,19 @@ +tx_script_bytecode_hash in tx - Sway
pub fn tx_script_bytecode_hash() -> b256 
Expand description

Get the hash of the script bytecode.
+Reverts if not a transaction-script.

+

Returns

+
    +
  • [b256] - The hash of the script bytecode.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_script_bytecode_hash;
+
+fn foo() {
+    let script_bytecode_hash: b256 = tx_script_bytecode_hash();
+    assert(script_bytecode_hash == 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_script_data.html b/v0.21.0/std/tx/fn.tx_script_data.html new file mode 100644 index 00000000..c0d5629e --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_script_data.html @@ -0,0 +1,21 @@ +tx_script_data in tx - Sway

Function std::tx::tx_script_data

pub fn tx_script_data<T>() -> T 
Expand description

Get the script data, typed.

+

Additional Information

+

Unsafe.
+Assumes the type is correct.

+

Returns

+
    +
  • [T] - The script data, typed.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_script_data;
+
+fn foo() {
+    let script_data: u64 = tx_script_data();
+    log(script_data);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_script_data_length.html b/v0.21.0/std/tx/fn.tx_script_data_length.html new file mode 100644 index 00000000..399e0350 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_script_data_length.html @@ -0,0 +1,18 @@ +tx_script_data_length in tx - Sway
pub fn tx_script_data_length() -> u64 
Expand description

Get the script data length for the transaction.

+

Returns

+
    +
  • [u64] - The script data length for the transaction.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_script_data_length;
+
+fn foo() {
+    let script_data_length = tx_script_data_length();
+    assert(script_data_length > 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_script_data_start_pointer.html b/v0.21.0/std/tx/fn.tx_script_data_start_pointer.html new file mode 100644 index 00000000..b641ac0d --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_script_data_start_pointer.html @@ -0,0 +1,18 @@ +tx_script_data_start_pointer in tx - Sway
pub fn tx_script_data_start_pointer() -> raw_ptr 
Expand description

Get the transaction script data start pointer.

+

Returns

+
    +
  • [raw_ptr] - The transaction script data start pointer.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_script_data_start_pointer;
+
+fn foo() {
+    let script_data_start_pointer = tx_script_data_start_pointer();
+    log(script_data_start_pointer);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_script_length.html b/v0.21.0/std/tx/fn.tx_script_length.html new file mode 100644 index 00000000..e16dfa2f --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_script_length.html @@ -0,0 +1,18 @@ +tx_script_length in tx - Sway
pub fn tx_script_length() -> u64 
Expand description

Get the length of the script for the transaction.

+

Returns

+
    +
  • [u64] - The script length for the transaction.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_script_length;
+
+fn foo() {
+    let script_length = tx_script_length();
+    assert(script_length > 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_script_start_pointer.html b/v0.21.0/std/tx/fn.tx_script_start_pointer.html new file mode 100644 index 00000000..c5f22fba --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_script_start_pointer.html @@ -0,0 +1,18 @@ +tx_script_start_pointer in tx - Sway
pub fn tx_script_start_pointer() -> raw_ptr 
Expand description

Get the transaction script start pointer.

+

Returns

+
    +
  • [raw_ptr] - The transaction script start pointer.
  • +
+

Reverts

+
    +
  • When the transaction type is of type Transaction::Create.
  • +
+

Examples

+
use std::tx::tx_script_start_pointer;
+
+fn foo() {
+    let script_start_pointer = tx_script_start_pointer();
+    log(script_start_pointer);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_type.html b/v0.21.0/std/tx/fn.tx_type.html new file mode 100644 index 00000000..044e889d --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_type.html @@ -0,0 +1,26 @@ +tx_type in tx - Sway

Function std::tx::tx_type

pub fn tx_type() -> Transaction 
Expand description

Get the type of the current transaction.
+Either Transaction::Script or Transaction::Create.

+

Returns

+
    +
  • [Transaction] - The type of the current transaction.
  • +
+

Reverts

+
    +
  • When the transaction type is unrecognized. This should never happen.
  • +
+

Example

+
use std::tx::tx_type;
+
+fn foo() {
+    let tx_type = tx_type();
+    match tx_type {
+        Transaction::Script => {
+            log("Regular script transaction");
+        },
+        Transaction::Create => {
+            log("Contract deployment transaction");
+        },
+    }
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_witness_data.html b/v0.21.0/std/tx/fn.tx_witness_data.html new file mode 100644 index 00000000..d1d6092c --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_witness_data.html @@ -0,0 +1,18 @@ +tx_witness_data in tx - Sway
pub fn tx_witness_data<T>(index: u64) -> T 
Expand description

Get the witness data at index.

+

Arguments

+
    +
  • index - The index of the witness to get the data for.
  • +
+

Returns

+
    +
  • [T] - The witness data at index.
  • +
+

Examples

+
use std::tx::tx_witness_data;
+
+fn foo() {
+    let witness_data: u64 = tx_witness_data(0);
+    log(witness_data);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_witness_data_length.html b/v0.21.0/std/tx/fn.tx_witness_data_length.html new file mode 100644 index 00000000..929e34c9 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_witness_data_length.html @@ -0,0 +1,18 @@ +tx_witness_data_length in tx - Sway
pub fn tx_witness_data_length(index: u64) -> u64 
Expand description

Get the length of the witness data at index.

+

Arguments

+
    +
  • index - The index of the witness to get the data length for.
  • +
+

Returns

+
    +
  • [u64] - The length of the witness data at index.
  • +
+

Examples

+
use std::tx::tx_witness_data_length;
+
+fn foo() {
+    let witness_data_length = tx_witness_data_length(0);
+    log(witness_data_length);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_witness_limit.html b/v0.21.0/std/tx/fn.tx_witness_limit.html new file mode 100644 index 00000000..ad585905 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_witness_limit.html @@ -0,0 +1,14 @@ +tx_witness_limit in tx - Sway
pub fn tx_witness_limit() -> Option<u64> 
Expand description

Get the witness limit for the transaction, if it is set.

+

Returns

+
    +
  • [Option] - The witness limit for the transaction.
  • +
+

Examples

+
use std::tx::tx_witness_limit;
+
+fn foo() {
+    let witness_limit = tx_witness_limit();
+    log(witness_limit);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_witness_pointer.html b/v0.21.0/std/tx/fn.tx_witness_pointer.html new file mode 100644 index 00000000..072e6297 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_witness_pointer.html @@ -0,0 +1,18 @@ +tx_witness_pointer in tx - Sway
pub fn tx_witness_pointer(index: u64) -> u64 
Expand description

Get a pointer to the witness at index index for the transaction.

+

Arguments

+
    +
  • index - The index of the witness to get the pointer for.
  • +
+

Returns

+
    +
  • [u64] - The pointer to the witness at index index.
  • +
+

Examples

+
use std::tx::tx_witness_pointer;
+
+fn foo() {
+    let witness_pointer = tx_witness_pointer(0);
+    log(witness_pointer);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/fn.tx_witnesses_count.html b/v0.21.0/std/tx/fn.tx_witnesses_count.html new file mode 100644 index 00000000..f0e39b79 --- /dev/null +++ b/v0.21.0/std/tx/fn.tx_witnesses_count.html @@ -0,0 +1,14 @@ +tx_witnesses_count in tx - Sway
pub fn tx_witnesses_count() -> u64 
Expand description

Get the transaction witnesses count for the transaction.

+

Returns

+
    +
  • [u64] - The witnesses count for the transaction.
  • +
+

Examples

+
use std::tx::tx_witnesses_count;
+
+fn foo() {
+    let witnesses_count = tx_witnesses_count();
+    log(witnesses_count);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/tx/index.html b/v0.21.0/std/tx/index.html new file mode 100644 index 00000000..df1f2a18 --- /dev/null +++ b/v0.21.0/std/tx/index.html @@ -0,0 +1,22 @@ +tx in std - Sway

Module std::tx

Expand description

Transaction field getters.

+

Enums

A transaction type.

+

Constants

Functions

Get the script gas limit for the transaction.

+

Get the gas price for the transaction, if it is set.

+

Get the Transaction ID of the current transaction.

+

Get the maturity for the transaction, if it is set.

+

Get the max fee for the transaction, if it is set.

+

Get the transaction receipts root.

+

Get the script bytecode.

+

Get the hash of the script bytecode.
+Reverts if not a transaction-script.

+

Get the script data, typed.

+

Get the script data length for the transaction.

+

Get the transaction script data start pointer.

+

Get the length of the script for the transaction.

+

Get the transaction script start pointer.

+

Get the type of the current transaction.

Get the witness data at index.

+

Get the length of the witness data at index.

+

Get the witness limit for the transaction, if it is set.

+

Get a pointer to the witness at index index for the transaction.

+

Get the transaction witnesses count for the transaction.

+
\ No newline at end of file diff --git a/v0.21.0/std/u128/enum.U128Error.html b/v0.21.0/std/u128/enum.U128Error.html new file mode 100644 index 00000000..6f8cb4b4 --- /dev/null +++ b/v0.21.0/std/u128/enum.U128Error.html @@ -0,0 +1,6 @@ +U128Error in u128 - Sway
pub enum U128Error {
+    /// This error occurs when a `U128` is attempted to be downcast to a `u64` and the conversion would result in a loss of precision.
+    LossOfPrecision: (),
+}
Expand description

The error type used for U128 type errors.

+

Variants

LossOfPrecision: ()

This error occurs when a U128 is attempted to be downcast to a u64 and the conversion would result in a loss of precision.

+
\ No newline at end of file diff --git a/v0.21.0/std/u128/index.html b/v0.21.0/std/u128/index.html new file mode 100644 index 00000000..1c7cee89 --- /dev/null +++ b/v0.21.0/std/u128/index.html @@ -0,0 +1,4 @@ +u128 in std - Sway

Module std::u128

Expand description

A 128-bit unsigned integer type.

+

Structs

The 128-bit unsigned integer type.

+

Enums

The error type used for U128 type errors.

+
\ No newline at end of file diff --git a/v0.21.0/std/u128/struct.U128.html b/v0.21.0/std/u128/struct.U128.html new file mode 100644 index 00000000..e9493b77 --- /dev/null +++ b/v0.21.0/std/u128/struct.U128.html @@ -0,0 +1,52 @@ +U128 in u128 - Sway

Struct std::u128::U128

pub struct U128 {
+    /// The most significant 64 bits of the `U128`.
+    upper: u64,
+    /// The least significant 64 bits of the `U128`.
+    lower: u64,
+}
Expand description

The 128-bit unsigned integer type.

+

Additional Information

+

Represented as two 64-bit components: (upper, lower), where value = (upper << 64) + lower.

+

Fields

upper: u64

The most significant 64 bits of the U128.

+
lower: u64

The least significant 64 bits of the U128.

+

Trait Implementations

fn from(components: (u64, u64)) -> Self

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn binary_and(self, other: Self) -> Self

fn binary_or(self, other: Self) -> Self

fn lsh(self, rhs: u64) -> Self

fn rsh(self, rhs: u64) -> Self

fn not(self) -> Self

fn add(self, other: Self) -> Self

Add a U128 to a U128. Reverts on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a U128 from a U128. Reverts of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a U128 with a U128. Reverts of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a U128 by a U128. Reverts if divisor is zero.

+

fn pow(self, exponent: u32) -> Self

fn sqrt(self) -> Self

Integer square root using Newton’s Method.

+

fn log2(self) -> Self

log2 of x is the largest n such that 2^n <= x < 2^(n+1).

+
    +
  • If x is smaller than 2^64, we could just rely on the log method by setting
    +the base to 2.
  • +
  • Otherwise, we can find the highest non-zero bit by taking the regular log of the upper
    +part of the U128, and then add 64.
  • +
+

fn log(self, base: Self) -> Self

\ No newline at end of file diff --git a/v0.21.0/std/vec/index.html b/v0.21.0/std/vec/index.html new file mode 100644 index 00000000..708e7b62 --- /dev/null +++ b/v0.21.0/std/vec/index.html @@ -0,0 +1,3 @@ +vec in std - Sway

Module std::vec

Expand description

A vector type for dynamically sized arrays outside of storage.

+

Structs

A contiguous growable array type, written as Vec<T>, short for ‘vector’.

+
\ No newline at end of file diff --git a/v0.21.0/std/vec/struct.Vec.html b/v0.21.0/std/vec/struct.Vec.html new file mode 100644 index 00000000..5ec7279c --- /dev/null +++ b/v0.21.0/std/vec/struct.Vec.html @@ -0,0 +1,5 @@ +Vec in vec - Sway

Struct std::vec::Vec

pub struct Vec<T> {
+    buf: RawVec<T>,
+    len: u64,
+}
Expand description

A contiguous growable array type, written as Vec<T>, short for ‘vector’.

+

Fields

buf: RawVeclen: u64
\ No newline at end of file diff --git a/v0.21.0/std/vec/struct.VecIter.html b/v0.21.0/std/vec/struct.VecIter.html new file mode 100644 index 00000000..ff7dff20 --- /dev/null +++ b/v0.21.0/std/vec/struct.VecIter.html @@ -0,0 +1,4 @@ +VecIter in vec - Sway

Struct std::vec::VecIter

pub struct VecIter<T> {
+    values: Vec<T>,
+    index: u64,
+}

Fields

values: Vecindex: u64
\ No newline at end of file diff --git a/v0.21.0/std/vm/evm/ecr/fn.ec_recover_evm_address.html b/v0.21.0/std/vm/evm/ecr/fn.ec_recover_evm_address.html new file mode 100644 index 00000000..99e73a78 --- /dev/null +++ b/v0.21.0/std/vm/evm/ecr/fn.ec_recover_evm_address.html @@ -0,0 +1,29 @@ +ec_recover_evm_address in ecr - Sway
pub fn ec_recover_evm_address(
+    signature: B512,
+    msg_hash: b256,
+) -> Result<EvmAddress, EcRecoverError> 
Expand description

Recover the EVM address derived from the private key used to sign a message.
+Returns a Result to let the caller choose an error handling strategy.

+

Arguments

+
    +
  • signature: [B512] - The signature generated by signing a message hash.
  • +
  • msg_hash: [b256] - The signed data.
  • +
+

Returns

+
    +
  • [Result<EvmAddress, EcRecoverError>] - The recovered evm address or an error.
  • +
+

Examples

+
use std::{vm::evm::{evm_address::EvmAddress, ecr::ec_recover_evm_address}, b512::B512};
+
+fn foo() {
+    let hi = 0xbd0c9b8792876713afa8bff383eebf31c43437823ed761cc3600d0016de5110c;
+    let lo = 0x44ac566bd156b4fc71a4a4cb2655d3dd360c695edb17dc3b64d611e122fea23d;
+    let msg_hash = 0xee45573606c96c98ba970ff7cf9511f1b8b25e6bcd52ced30b89df1e4a9c4323;
+    let evm_address = EvmAddress::from(0x7AAE2D980BE4C3275C72CE5B527FA23FFB97B766966559DD062E2B78FD9D3766);
+    let signature: B512 = B512::from((hi, lo));
+    // A recovered evm address.
+    let result_address = ec_recover_evm_address(signature, msg_hash).unwrap();
+    assert(result_address == evm_address);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/std/vm/evm/ecr/index.html b/v0.21.0/std/vm/evm/ecr/index.html new file mode 100644 index 00000000..1f754b6b --- /dev/null +++ b/v0.21.0/std/vm/evm/ecr/index.html @@ -0,0 +1,2 @@ +ecr in std - Sway

Module std::vm::evm::ecr

Expand description

VM-specific utilities.

+

Functions

Recover the EVM address derived from the private key used to sign a message.

\ No newline at end of file diff --git a/v0.21.0/std/vm/evm/evm_address/index.html b/v0.21.0/std/vm/evm/evm_address/index.html new file mode 100644 index 00000000..26463f47 --- /dev/null +++ b/v0.21.0/std/vm/evm/evm_address/index.html @@ -0,0 +1,3 @@ +evm_address in std - Sway

Module std::vm::evm::evm_address

Expand description

VM-specific utilities.

+

Structs

The EvmAddress type, a struct wrapper around the inner b256 value.

+
\ No newline at end of file diff --git a/v0.21.0/std/vm/evm/evm_address/struct.EvmAddress.html b/v0.21.0/std/vm/evm/evm_address/struct.EvmAddress.html new file mode 100644 index 00000000..26714580 --- /dev/null +++ b/v0.21.0/std/vm/evm/evm_address/struct.EvmAddress.html @@ -0,0 +1,35 @@ +EvmAddress in evm_address - Sway
pub struct EvmAddress {
+    /// The underlying evm address data.
+    bits: b256,
+}
Expand description

The EvmAddress type, a struct wrapper around the inner b256 value.

+

Fields

bits: b256

The underlying evm address data.

+

Trait Implementations

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn from(bits: b256) -> Self

fn hash(
self,
refmut state: Hasher,
)

\ No newline at end of file diff --git a/v0.21.0/std/vm/evm/index.html b/v0.21.0/std/vm/evm/index.html new file mode 100644 index 00000000..9e6b4581 --- /dev/null +++ b/v0.21.0/std/vm/evm/index.html @@ -0,0 +1,3 @@ +evm in std - Sway

Module std::vm::evm

Modules

VM-specific utilities.

+

VM-specific utilities.

+
\ No newline at end of file diff --git a/v0.21.0/std/vm/index.html b/v0.21.0/std/vm/index.html new file mode 100644 index 00000000..8929e2f1 --- /dev/null +++ b/v0.21.0/std/vm/index.html @@ -0,0 +1,2 @@ +vm in std - Sway

Module std::vm

Modules

VM-specific utilities.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/errors/enum.AdminError.html b/v0.21.0/sway_libs/admin/errors/enum.AdminError.html new file mode 100644 index 00000000..6bbb7760 --- /dev/null +++ b/v0.21.0/sway_libs/admin/errors/enum.AdminError.html @@ -0,0 +1,6 @@ +AdminError in errors - Sway
pub enum AdminError {
+    /// Emitted when the caller is not an admin.
+    NotAdmin: (),
+}
Expand description

Error log for when access is denied.

+

Variants

NotAdmin: ()

Emitted when the caller is not an admin.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/errors/index.html b/v0.21.0/sway_libs/admin/errors/index.html new file mode 100644 index 00000000..a819194f --- /dev/null +++ b/v0.21.0/sway_libs/admin/errors/index.html @@ -0,0 +1,2 @@ +errors in sway_libs - Sway

Enums

Error log for when access is denied.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/fn.add_admin.html b/v0.21.0/sway_libs/admin/fn.add_admin.html new file mode 100644 index 00000000..0d636539 --- /dev/null +++ b/v0.21.0/sway_libs/admin/fn.add_admin.html @@ -0,0 +1,22 @@ +add_admin in admin - Sway
pub fn add_admin(new_admin: Identity) 
Expand description

Arguments

+
    +
  • new_admin: [Identity] - The Identity which is to receive administrator status.
  • +
+

Reverts

+
    +
  • When the caller is not the contract owner.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::admin::{add_admin, is_admin};
+
+fn foo(new_admin: Identity) {
+    add_admin(new_admin);
+    assert(is_admin(new_admin));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/fn.is_admin.html b/v0.21.0/sway_libs/admin/fn.is_admin.html new file mode 100644 index 00000000..ca16b325 --- /dev/null +++ b/v0.21.0/sway_libs/admin/fn.is_admin.html @@ -0,0 +1,21 @@ +is_admin in admin - Sway
pub fn is_admin(admin: Identity) -> bool 
Expand description

Returns whether admin is an administrator.

+

Arguments

+
    +
  • admin: [Identity] - The Identity of which to check the administrator status.
  • +
+

Returns

+
    +
  • [bool] - true if the admin is an administrator, otherwise false.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::admin::{is_admin};
+
+fn foo(admin: Identity) {
+    assert(is_admin(admin));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/fn.only_admin.html b/v0.21.0/sway_libs/admin/fn.only_admin.html new file mode 100644 index 00000000..6eeb50a0 --- /dev/null +++ b/v0.21.0/sway_libs/admin/fn.only_admin.html @@ -0,0 +1,20 @@ +only_admin in admin - Sway
pub fn only_admin() 
Expand description

Ensures that the sender is an administrator.

+

Additional Information

+

NOTE: Owner and administrator are independent of one another. If an Owner calls this function, it will revert.

+

Reverts

+
    +
  • When the caller is not an administrator.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::admin::{only_admin};
+
+fn foo() {
+    only_admin();
+    // Only reachable by an administrator
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/fn.only_owner_or_admin.html b/v0.21.0/sway_libs/admin/fn.only_owner_or_admin.html new file mode 100644 index 00000000..8caa2640 --- /dev/null +++ b/v0.21.0/sway_libs/admin/fn.only_owner_or_admin.html @@ -0,0 +1,18 @@ +only_owner_or_admin in admin - Sway
pub fn only_owner_or_admin() 
Expand description

Ensures that the sender is an owner or administrator.

+

Reverts

+
    +
  • When the caller is not an owner or administrator.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 2
  • +
+

Examples

+
use sway_libs::admin::{only_owner_or_admin};
+
+fn foo() {
+    only_owner_or_admin();
+    // Only reachable by an owner or administrator
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/fn.revoke_admin.html b/v0.21.0/sway_libs/admin/fn.revoke_admin.html new file mode 100644 index 00000000..18de3fdf --- /dev/null +++ b/v0.21.0/sway_libs/admin/fn.revoke_admin.html @@ -0,0 +1,23 @@ +revoke_admin in admin - Sway
pub fn revoke_admin(old_admin: Identity) 
Expand description

Removes an administrator.

+

Arguments

+
    +
  • old_admin: [Identity] - The Identity which the administrator status is to be removed.
  • +
+

Reverts

+
    +
  • When the caller is not the contract owner.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::admin::{revoke_admin, is_admin};
+
+fn foo(old_admin: Identity) {
+    revoke_admin(old_admin);
+    assert(!is_admin(old_admin));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/admin/index.html b/v0.21.0/sway_libs/admin/index.html new file mode 100644 index 00000000..493805db --- /dev/null +++ b/v0.21.0/sway_libs/admin/index.html @@ -0,0 +1,5 @@ +admin in sway_libs - Sway

Modules

Functions

Returns whether admin is an administrator.

+

Ensures that the sender is an administrator.

+

Ensures that the sender is an owner or administrator.

+

Removes an administrator.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/all.html b/v0.21.0/sway_libs/all.html new file mode 100644 index 00000000..86ff0f0e --- /dev/null +++ b/v0.21.0/sway_libs/all.html @@ -0,0 +1,69 @@ +List of all items in this project

List of all items

Structs

A persistent storage type to store the SRC-7; Metadata Standard type.

+

The 128-bit signed fixed point number type.

+

The 256-bit signed fixed point number type.

+

The 64-bit signed fixed point number type.

+

The 128-bit unsigned fixed point number type.

+

The 32-bit unsigned fixed point number type.

+

The 64-bit unsigned fixed point number type.

+

Logged when ownership is renounced.

+

Logged when ownership is given to a user.

+

Logged when ownership is given from one user to another.

+

The Queue type corresponds to the same called data structure.

+

The 128-bit signed integer type.

+

The 16-bit signed integer type.

+

The 256-bit signed integer type.

+

The 32-bit signed integer type.

+

The 64-bit signed integer type.

+

The 8-bit signed integer type.

+

Enums

Error log for when access is denied.

+

Error log for when something goes wrong when burning assets.

+

Error log for when access is denied.

+

Error emitted upon the opposite of the desired pause state.

+

Error log for when reentrancy has been detected

+

Error log for when unexpected behavior has occurred.

+

Traits

Trait for the Two’s Complement of a value.

+

Abi

Constants

Concatenated to leaf hash input as described by
+“MTH({d(0)}) = SHA-256(0x00 || d(0))”

+

Concatenated to node hash input as described by

Functions

Returns whether admin is an administrator.

+

Ensures that the sender is an administrator.

+

Ensures that the sender is an owner or administrator.

+

Removes an administrator.

+

Returns the number of decimals the asset uses.

+

Returns the name of the asset, such as “Ether”.

+

Unconditionally sets the decimals of an asset.

+

Unconditionally sets the name of an asset.

+

Unconditionally sets the symbol of an asset.

+

Returns the symbol of the asset, such as “ETH”.

+

Returns the total number of individual assets for a contract.

+

Returns the total supply of coins for an asset.

+

Unconditionally stores metadata for a specific asset and key pair.

+

Burns assets with the given sub_id.

+

Unconditionally mints new assets using the sub_id sub-identifier.

+

Takes the bytecode of a contract or predicate and computes the bytecode root.

+

Takes the bytecode of a contract or predicate and configurables and computes the bytecode root.

Takes the bytecode of a predicate and computes the address of a predicate.

+

Takes the bytecode of a predicate and configurables and computes the address of a predicate.

+

Takes the bytecode root of a predicate and generates the address of the predicate.

+

Swaps out configurable values in a contract or predicate’s bytecode.

+

Takes some bytecode and computes the bytecode root.

+

Takes the bytecode root of predicate generates the address of a predicate.

+

Swaps out configurable values in a contract’s or predicate’s bytecode.

+

Asserts that a contract’s bytecode and the given bytecode match.

+

Asserts that a contract’s bytecode and the given bytecode and configurable values match.

+

Asserts that a predicates’s address from some bytecode and the given address match.

+

Asserts that a predicates’s address from some bytecode and configurables and the given address match.

Returns the computed leaf hash of “MTH({d(0)}) = SHA-256(0x00 || d(0))”.

+

Returns the computed node hash of “MTH(D[n]) = SHA-256(0x01 || MTH(D[0:k]) || MTH(D[k:n]))”.

+

This function will compute and return a Merkle root given a leaf and corresponding proof.

+

This function will take a Merkle leaf and proof and return whether the corresponding root

Calculates the length of the path to a leaf

+

Calculates the starting bit of the path to a leaf

+

Returns the owner.

+

Sets the passed identity as the initial owner.

+

Ensures that the sender is the owner.

+

Revokes ownership of the current owner and disallows any new owners.

+

Transfers ownership to the passed identity.

+

Returns whether the contract is in the paused state.

+

Unconditionally sets the contract to the paused state.

+

Unconditionally sets the contract to the unpaused state.

+

Requires that the contract is in the unpaused state.

+

Requires that the contract is in the paused state.

+

Returns true if the reentrancy pattern is detected, and false otherwise.

Reverts if the reentrancy pattern is detected in the contract in which this is called.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/abi.SetAssetAttributes.html b/v0.21.0/sway_libs/asset/base/abi.SetAssetAttributes.html new file mode 100644 index 00000000..5984789e --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/abi.SetAssetAttributes.html @@ -0,0 +1,8 @@ +SetAssetAttributes in base - Sway
abi SetAssetAttributes {
+    #[storage(write)]
+    fn set_name(asset: AssetId, name: String);
+    #[storage(write)]
+    fn set_symbol(asset: AssetId, symbol: String);
+    #[storage(write)]
+    fn set_decimals(asset: AssetId, decimals: u8);
+}

Required Methods

\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._decimals.html b/v0.21.0/sway_libs/asset/base/fn._decimals.html new file mode 100644 index 00000000..82595642 --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._decimals.html @@ -0,0 +1,32 @@ +_decimals in base - Sway
pub fn _decimals(
+    decimals_key: StorageKey<StorageMap<AssetId, u8>>,
+    asset: AssetId,
+) -> Option<u8> 
Expand description

Returns the number of decimals the asset uses.

+

Additional Information

+

e.g. 8, means to divide the coins amount by 100000000 to get its user representation.

+

Arguments

+
    +
  • decimals_key: [StorageKey<StorageMap<AssetId, u8>>] - The location in storage which the StorageMap that stores the decimals of assets is stored.
  • +
  • asset: [AssetId] - The asset of which to query the decimals.
  • +
+

Returns

+
    +
  • [Option] - The decimal precision used by asset.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::asset::base::_decimals;
+
+storage {
+    decimals: StorageMap<AssetId, u8> = StorageMap {},
+}
+
+fn foo(asset: AssedId) {
+    let decimals = _decimals(storage.decimals, asset);
+    assert(decimals.unwrap_or(0u8) == 8);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._name.html b/v0.21.0/sway_libs/asset/base/fn._name.html new file mode 100644 index 00000000..555bd78a --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._name.html @@ -0,0 +1,31 @@ +_name in base - Sway
pub fn _name(
+    name_key: StorageKey<StorageMap<AssetId, StorageString>>,
+    asset: AssetId,
+) -> Option<String> 
Expand description

Returns the name of the asset, such as “Ether”.

+

Arguments

+
    +
  • name_key: [StorageKey<StorageMap<AssetId, StorageKey>>] - The location in storage which the StorageMap that stores the names of assets is stored.
  • +
  • asset: [AssetId] - The asset of which to query the name.
  • +
+

Returns

+
    +
  • [Option] - The name of asset.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::asset::base::_name;
+use std::string::String;
+
+storage {
+    name: StorageMap<AssetId, StorageString> = StorageMap {},
+}
+
+fn foo(asset: AssetId) {
+    let name = _name(storage.name, asset);
+    assert(name.unwrap_or(String::new()).len() != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._set_decimals.html b/v0.21.0/sway_libs/asset/base/fn._set_decimals.html new file mode 100644 index 00000000..62f7f8df --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._set_decimals.html @@ -0,0 +1,32 @@ +_set_decimals in base - Sway
pub fn _set_decimals(
+    decimals_key: StorageKey<StorageMap<AssetId, u8>>,
+    asset: AssetId,
+    decimals: u8,
+) 
Expand description

Unconditionally sets the decimals of an asset.

+

Additional Information

+

NOTE: This does not check whether the asset id provided is valid or already exists.

+

Arguments

+
    +
  • decimals_key: [StorageKey<StorageMap<AssetId, u8>>] - The location in storage which the StorageMap that stores the decimals of assets is stored.
  • +
  • asset: [AssetId] - The asset of which to set the decimals.
  • +
  • decimal: [u8] - The decimals of the asset.
  • +
+

Number of Storage Accesses

+
    +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::asset::base::{_set_decimals, _decimals};
+use std::string::String;
+
+storage {
+    decimals: StorageMap<AssetId, u8> = StorageMap {},
+}
+
+fn foo(asset: AssetId) {
+    let decimals = 8u8;
+    _set_decimals(storage.decimals, asset, decimals);
+    assert(_decimals(storage.decimals, asset) == decimals);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._set_name.html b/v0.21.0/sway_libs/asset/base/fn._set_name.html new file mode 100644 index 00000000..31a28d98 --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._set_name.html @@ -0,0 +1,32 @@ +_set_name in base - Sway
pub fn _set_name(
+    name_key: StorageKey<StorageMap<AssetId, StorageString>>,
+    asset: AssetId,
+    name: String,
+) 
Expand description

Unconditionally sets the name of an asset.

+

Additional Information

+

NOTE: This does not check whether the asset id provided is valid or already exists.

+

Arguments

+
    +
  • name_key: [StorageKey<StorageMap<AssetId, StorageKey>>] - The location in storage which the StorageMap that stores the names of assets is stored.
  • +
  • asset: [AssetId] - The asset of which to set the name.
  • +
  • name: [String] - The name of the asset.
  • +
+

Number of Storage Accesses

+
    +
  • Writes: 2
  • +
+

Examples

+
use sway_libs::asset::base::{_set_name, _name};
+use std::string::String;
+
+storage {
+    name: StorageMap<AssetId, StorageString> = StorageMap {},
+}
+
+fn foo(asset: AssetId) {
+    let name = String::from_ascii_str("Ether");
+    _set_name(storage.name, asset, name);
+    assert(_name(storage.name, asset) == name);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._set_symbol.html b/v0.21.0/sway_libs/asset/base/fn._set_symbol.html new file mode 100644 index 00000000..762e245a --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._set_symbol.html @@ -0,0 +1,32 @@ +_set_symbol in base - Sway
pub fn _set_symbol(
+    symbol_key: StorageKey<StorageMap<AssetId, StorageString>>,
+    asset: AssetId,
+    symbol: String,
+) 
Expand description

Unconditionally sets the symbol of an asset.

+

Additional Information

+

NOTE: This does not check whether the asset id provided is valid or already exists.

+

Arguments

+
    +
  • symbol_key: [StorageKey<StorageMap<AssetId, StorageKey>>] - The location in storage which the StorageMap that stores the symbols of assets is stored.
  • +
  • asset: [AssetId] - The asset of which to set the symbol.
  • +
  • symbol: [String] - The symbol of the asset.
  • +
+

Number of Storage Accesses

+
    +
  • Writes: 2
  • +
+

Examples

+
use sway_libs::asset::base::{_set_symbol, _symbol};
+use std::string::String;
+
+storage {
+    symbol: StorageMap<AssetId, StorageString> = StorageMap {},
+}
+
+fn foo(asset: AssetId) {
+    let symbol = String::from_ascii_str("ETH");
+    _set_symbol(storage.symbol, asset, symbol);
+    assert(_symbol(storage.symbol, asset) == symbol);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._symbol.html b/v0.21.0/sway_libs/asset/base/fn._symbol.html new file mode 100644 index 00000000..081f19dd --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._symbol.html @@ -0,0 +1,31 @@ +_symbol in base - Sway
pub fn _symbol(
+    symbol_key: StorageKey<StorageMap<AssetId, StorageString>>,
+    asset: AssetId,
+) -> Option<String> 
Expand description

Returns the symbol of the asset, such as “ETH”.

+

Arguments

+
    +
  • symbol_key: [StorageKey<StorageMap<AssetId, StorageKey>>] - The location in storage which the StorageMap that stores the symbols of assets is stored.
  • +
  • asset: [AssetId] - The asset of which to query the symbol.
  • +
+

Returns

+
    +
  • [Option] - The symbol of asset.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::asset::base::_symbol;
+use std::string::String;
+
+storage {
+    symbol: StorageMap<AssetId, StorageString> = StorageMap {},
+}
+
+fn foo(asset: AssetId) {
+    let symbol = _symbol(storage.symbol, asset);
+    assert(symbol.unwrap_or(String::new()).len() != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._total_assets.html b/v0.21.0/sway_libs/asset/base/fn._total_assets.html new file mode 100644 index 00000000..b0c9303a --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._total_assets.html @@ -0,0 +1,26 @@ +_total_assets in base - Sway
pub fn _total_assets(total_assets_key: StorageKey<u64>) -> u64 
Expand description

Returns the total number of individual assets for a contract.

+

Arguments

+
    +
  • total_assets_key: [StorageKey] - The location in storage that the u64 which represents the total assets is stored.
  • +
+

Returns

+
    +
  • [u64] - The number of assets that this contract has minted.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::asset::base::_total_assets;
+
+storage {
+    total_assets: u64 = 0,
+}
+
+fn foo() {
+    let assets = _total_assets(storage.total_assets);
+    assert(assets == 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/fn._total_supply.html b/v0.21.0/sway_libs/asset/base/fn._total_supply.html new file mode 100644 index 00000000..ea515a07 --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/fn._total_supply.html @@ -0,0 +1,30 @@ +_total_supply in base - Sway
pub fn _total_supply(
+    total_supply_key: StorageKey<StorageMap<AssetId, u64>>,
+    asset: AssetId,
+) -> Option<u64> 
Expand description

Returns the total supply of coins for an asset.

+

Arguments

+
    +
  • total_supply_key: [StorageKey<StorageMap<AssetId, u64>>] - The location in storage which the StorageMap that stores the total supply of assets is stored.
  • +
  • asset: [AssetId] - The asset of which to query the total supply.
  • +
+

Returns

+
    +
  • [Option] - The total supply of an asset.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::asset::base::_total_supply;
+
+storage {
+    total_supply: StorageMap<AssetId, u64> = StorageMap {},
+}
+
+fn foo(asset_id: AssetId) {
+    let supply = _total_supply(storage.total_supply, asset_id);
+    assert(supply.unwrap_or(0) != 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/base/index.html b/v0.21.0/sway_libs/asset/base/index.html new file mode 100644 index 00000000..a59410bf --- /dev/null +++ b/v0.21.0/sway_libs/asset/base/index.html @@ -0,0 +1,9 @@ +base in sway_libs - Sway

Abi

Functions

Returns the number of decimals the asset uses.

+

Returns the name of the asset, such as “Ether”.

+

Unconditionally sets the decimals of an asset.

+

Unconditionally sets the name of an asset.

+

Unconditionally sets the symbol of an asset.

+

Returns the symbol of the asset, such as “ETH”.

+

Returns the total number of individual assets for a contract.

+

Returns the total supply of coins for an asset.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/errors/enum.BurnError.html b/v0.21.0/sway_libs/asset/errors/enum.BurnError.html new file mode 100644 index 00000000..176dda0f --- /dev/null +++ b/v0.21.0/sway_libs/asset/errors/enum.BurnError.html @@ -0,0 +1,6 @@ +BurnError in errors - Sway
pub enum BurnError {
+    /// Emitted when there are not enough coins owned by the contract to burn.
+    NotEnoughCoins: (),
+}
Expand description

Error log for when something goes wrong when burning assets.

+

Variants

NotEnoughCoins: ()

Emitted when there are not enough coins owned by the contract to burn.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/errors/index.html b/v0.21.0/sway_libs/asset/errors/index.html new file mode 100644 index 00000000..84167d96 --- /dev/null +++ b/v0.21.0/sway_libs/asset/errors/index.html @@ -0,0 +1,2 @@ +errors in sway_libs - Sway

Enums

Error log for when something goes wrong when burning assets.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/index.html b/v0.21.0/sway_libs/asset/index.html new file mode 100644 index 00000000..73e00f39 --- /dev/null +++ b/v0.21.0/sway_libs/asset/index.html @@ -0,0 +1 @@ +asset in sway_libs - Sway

Modules

\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/metadata/abi.SetAssetMetadata.html b/v0.21.0/sway_libs/asset/metadata/abi.SetAssetMetadata.html new file mode 100644 index 00000000..db474180 --- /dev/null +++ b/v0.21.0/sway_libs/asset/metadata/abi.SetAssetMetadata.html @@ -0,0 +1,4 @@ +SetAssetMetadata in metadata - Sway
abi SetAssetMetadata {
+    #[storage(read, write)]
+    fn set_metadata(asset: AssetId, key: String, metadata: Metadata);
+}

Required Methods

\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/metadata/fn._set_metadata.html b/v0.21.0/sway_libs/asset/metadata/fn._set_metadata.html new file mode 100644 index 00000000..0b5a40a1 --- /dev/null +++ b/v0.21.0/sway_libs/asset/metadata/fn._set_metadata.html @@ -0,0 +1,30 @@ +_set_metadata in metadata - Sway
pub fn _set_metadata(
+    metadata_key: StorageKey<StorageMetadata>,
+    asset: AssetId,
+    key: String,
+    metadata: Metadata,
+) 
Expand description

Unconditionally stores metadata for a specific asset and key pair.

+

Arguments

+
    +
  • metadata_key: [StorageKey] - The storage location for metadata.
  • +
  • asset: [AssetId] - The asset for the metadata to be stored.
  • +
  • key: [String] - The key for the metadata to be stored.
  • +
  • metadata: [Metadata] - The metadata which to be stored.
  • +
+

Number of Storage Accesses

+
    +
  • Writes: 2
  • +
+

Example

+
use standards::src7::Metadata;
+use sway_libs::asset::metadata::*;
+
+storage {
+    metadata: StorageMetadata = StorageMetadata {}
+}
+
+fn foo(asset: AssetId, key: String, metadata: Metadata) {
+    _set_metadata(storage.metadata, asset, key, metadata);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/metadata/index.html b/v0.21.0/sway_libs/asset/metadata/index.html new file mode 100644 index 00000000..eefccef5 --- /dev/null +++ b/v0.21.0/sway_libs/asset/metadata/index.html @@ -0,0 +1,3 @@ +metadata in sway_libs - Sway

Structs

A persistent storage type to store the SRC-7; Metadata Standard type.

+

Abi

Functions

Unconditionally stores metadata for a specific asset and key pair.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/metadata/struct.StorageMetadata.html b/v0.21.0/sway_libs/asset/metadata/struct.StorageMetadata.html new file mode 100644 index 00000000..8b833cb6 --- /dev/null +++ b/v0.21.0/sway_libs/asset/metadata/struct.StorageMetadata.html @@ -0,0 +1,4 @@ +StorageMetadata in metadata - Sway
pub struct StorageMetadata {}
Expand description

A persistent storage type to store the SRC-7; Metadata Standard type.

+

Additional Information

+

This type should only be used if metadata changes or cannot be set at contract deployment time.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/supply/fn._burn.html b/v0.21.0/sway_libs/asset/supply/fn._burn.html new file mode 100644 index 00000000..be251d62 --- /dev/null +++ b/v0.21.0/sway_libs/asset/supply/fn._burn.html @@ -0,0 +1,38 @@ +_burn in supply - Sway
pub fn _burn(
+    total_supply_key: StorageKey<StorageMap<AssetId, u64>>,
+    sub_id: SubId,
+    amount: u64,
+) 
Expand description

Burns assets with the given sub_id.

+

Additional Information

+

Warning This function burns assets unequivocally. It does not check that assets are sent to the calling contract.
+Warning This function reduces the total supply by the number of coins burned. Using this value when minting may cause unintended consequences.

+

Arguments

+
    +
  • total_assets_key: [StorageKey] - The location in storage that the u64 which represents the total assets is stored.
  • +
  • sub_id: [SubId] - The sub-identifier of the asset to burn.
  • +
  • amount: [u64] - The quantity of coins to burn.
  • +
+

Reverts

+
    +
  • When the calling contract does not have enough assets.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::asset::supply::_burn;
+use std::{call_frames::contract_id, constants::ZERO_B256, context::balance_of};
+
+storage {
+    total_supply: StorageMap<AssetId, u64> = StorageMap {},
+}
+
+fn foo(asset_id: AssetId) {
+    assert(balance_of(contract_id(), asset_id) == 100);
+    _burn(storage.total_supply, ZERO_B256, 100);
+    assert(balance_of(contract_id(), asset_id) == 0);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/supply/fn._mint.html b/v0.21.0/sway_libs/asset/supply/fn._mint.html new file mode 100644 index 00000000..f7de60c4 --- /dev/null +++ b/v0.21.0/sway_libs/asset/supply/fn._mint.html @@ -0,0 +1,42 @@ +_mint in supply - Sway
pub fn _mint(
+    total_assets_key: StorageKey<u64>,
+    total_supply_key: StorageKey<StorageMap<AssetId, u64>>,
+    recipient: Identity,
+    sub_id: SubId,
+    amount: u64,
+) -> AssetId 
Expand description

Unconditionally mints new assets using the sub_id sub-identifier.

+

Additional Information

+

Warning This function increases the total supply by the number of coins minted.

+

Arguments

+
    +
  • total_assets_key: [StorageKey] - The location in storage that the u64 which represents the total assets is stored.
  • +
  • total_supply_key: [StorageKey<StorageMap<AssetId, u64>>] - The location in storage which the StorageMap that stores the total supply of assets is stored.
  • +
  • recipient: [Identity] - The user to which the newly minted asset is transferred to.
  • +
  • sub_id: [SubId] - The sub-identifier of the newly minted asset.
  • +
  • amount: [u64] - The quantity of coins to mint.
  • +
+

Returns

+
    +
  • [AssetId] - The AssetId of the newly minted asset.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 2
  • +
  • Writes: 2
  • +
+

Examples

+
use sway_libs::asset::supply::_mint;
+use std::{constants::ZERO_B256, context::balance_of};
+
+storage {
+    total_assets: u64 = 0,
+    total_supply: StorageMap<AssetId, u64> = StorageMap {},
+}
+
+fn foo(recipient: Identity) {
+    let recipient = Identity::ContractId(ContractId::from(ZERO_B256));
+    let asset_id = _mint(storage.total_assets, storage.total_supply, recipient, ZERO_B256, 100);
+    assert(balance_of(recipient.as_contract_id(), asset_id), 100);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/asset/supply/index.html b/v0.21.0/sway_libs/asset/supply/index.html new file mode 100644 index 00000000..d4d360fc --- /dev/null +++ b/v0.21.0/sway_libs/asset/supply/index.html @@ -0,0 +1,3 @@ +supply in sway_libs - Sway

Functions

Burns assets with the given sub_id.

+

Unconditionally mints new assets using the sub_id sub-identifier.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.compute_bytecode_root.html b/v0.21.0/sway_libs/bytecode/fn.compute_bytecode_root.html new file mode 100644 index 00000000..6cd7fa4d --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.compute_bytecode_root.html @@ -0,0 +1,19 @@ +compute_bytecode_root in bytecode - Sway
pub fn compute_bytecode_root(bytecode: Vec<u8>) -> b256 
Expand description

Takes the bytecode of a contract or predicate and computes the bytecode root.

+

Arguments

+
    +
  • bytecode: [Vec] - The bytecode of a contract or predicate.
  • +
+

Returns

+
    +
  • [b256] - The bytecode root of the contract or predicate.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+use sway_libs::bytecode::compute_bytecode_root;
+
+fn foo(my_bytecode: Vec<u8>) {
+    let bytecode_root = compute_bytecode_root(my_bytecode);
+    assert(bytecode_root != ZERO_B256);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.compute_bytecode_root_with_configurables.html b/v0.21.0/sway_libs/bytecode/fn.compute_bytecode_root_with_configurables.html new file mode 100644 index 00000000..c20fd1fb --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.compute_bytecode_root_with_configurables.html @@ -0,0 +1,24 @@ +compute_bytecode_root_with_configurables in bytecode - Sway
pub fn compute_bytecode_root_with_configurables(
+    ref mut bytecode: Vec<u8>,
+    configurables: Vec<(u64, Vec<u8>)>,
+) -> b256 
Expand description

Takes the bytecode of a contract or predicate and configurables and computes the bytecode root.

+

Arguments

+
    +
  • bytecode: [Vec] - The bytecode of a contract or predicate.
  • +
  • configurables: [Vec<(u64, Vec)] - The configurable values to swap.
  • +
+

Returns

+
    +
  • [b256] - The bytecode root of the contract or predicate.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+use sway_libs::bytecode::compute_bytecode_root_with_configurables;
+
+fn foo(my_bytecode: Vec<u8>, my_configurables: Vec<(u64, Vec<u8>)>) {
+    let mut my_bytecode = my_bytecode;
+    let bytecode_root = compute_bytecode_root_with_configurables(my_bytecode, my_configurables);
+    assert(bytecode_root != ZERO_B256);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.compute_predicate_address.html b/v0.21.0/sway_libs/bytecode/fn.compute_predicate_address.html new file mode 100644 index 00000000..ab925334 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.compute_predicate_address.html @@ -0,0 +1,19 @@ +compute_predicate_address in bytecode - Sway
pub fn compute_predicate_address(bytecode: Vec<u8>) -> Address 
Expand description

Takes the bytecode of a predicate and computes the address of a predicate.

+

Arguments

+
    +
  • bytecode: [Vec] - The bytecode of a predicate.
  • +
+

Returns

+
    +
  • [Address] - The address of the predicate.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+use sway_libs::bytecode::compute_predicate_address;
+
+fn foo(my_bytecode: Vec<u8>) {
+    let predicate_address = compute_predicate_address(my_bytecode);
+    assert(predicate_address != Address::from(ZERO_B256));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.compute_predicate_address_with_configurables.html b/v0.21.0/sway_libs/bytecode/fn.compute_predicate_address_with_configurables.html new file mode 100644 index 00000000..9e09e4c8 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.compute_predicate_address_with_configurables.html @@ -0,0 +1,24 @@ +compute_predicate_address_with_configurables in bytecode - Sway
pub fn compute_predicate_address_with_configurables(
+    ref mut bytecode: Vec<u8>,
+    configurables: Vec<(u64, Vec<u8>)>,
+) -> Address 
Expand description

Takes the bytecode of a predicate and configurables and computes the address of a predicate.

+

Arguments

+
    +
  • bytecode: [Vec] - The bytecode of a predicate.
  • +
  • configurables: [Vec<(u64, Vec)] - The configurable values to swap.
  • +
+

Returns

+
    +
  • [Address] - The address of the predicate.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+use sway_libs::bytecode::compute_predicate_address;
+
+fn foo(my_bytecode: Vec<u8>, my_configurables: Vec<(u64, Vec<u8>)>) {
+    let mut my_bytecode = my_bytecode;
+    let predicate_address = compute_predicate_address(my_bytecode, my_configurables);
+    assert(predicate_address != Address::from(ZERO_B256));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.predicate_address_from_root.html b/v0.21.0/sway_libs/bytecode/fn.predicate_address_from_root.html new file mode 100644 index 00000000..556ee76b --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.predicate_address_from_root.html @@ -0,0 +1,19 @@ +predicate_address_from_root in bytecode - Sway
pub fn predicate_address_from_root(bytecode_root: b256) -> Address 
Expand description

Takes the bytecode root of a predicate and generates the address of the predicate.

+

Arguments

+
    +
  • bytecode_root: [b256] - The bytecode root of a predicate.
  • +
+

Returns

+
    +
  • [Address] - The address of the predicate.
  • +
+

Examples

+
use std::constants::ZERO_B256;
+use sway_libs::bytecode::predicate_address_from_root;
+
+fn foo(predicate_bytecode_root: b256) {
+    let predicate_address = predicate_address_from_root(predicate_bytecode_root);
+    assert(predicate_address != Address::from(ZERO_B256));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.swap_configurables.html b/v0.21.0/sway_libs/bytecode/fn.swap_configurables.html new file mode 100644 index 00000000..34a34149 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.swap_configurables.html @@ -0,0 +1,23 @@ +swap_configurables in bytecode - Sway
pub fn swap_configurables(
+    ref mut bytecode: Vec<u8>,
+    configurables: Vec<(u64, Vec<u8>)>,
+) -> Vec<u8> 
Expand description

Swaps out configurable values in a contract or predicate’s bytecode.

+

Arguments

+
    +
  • bytecode: [Vec] - The bytecode of a contract or predicate.
  • +
  • configurables: [Vec<(u64, Vec)] - The configurable values to swap.
  • +
+

Returns

+
    +
  • [Vec] - The resulting bytecode containing the new configurable values.
  • +
+

Examples

+
use sway_libs::bytecode::sway_configurables;
+
+fn foo(my_bytecode: Vec<u8>, my_configurables: Vec<(u64, Vec<u8>)>) {
+    let mut my_bytecode = my_bytecode;
+    let resulting_bytecode = swap_configurables(my_bytecode, my_configurables);
+    assert(resulting_bytecode != my_bytecode);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.verify_contract_bytecode.html b/v0.21.0/sway_libs/bytecode/fn.verify_contract_bytecode.html new file mode 100644 index 00000000..b6a90758 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.verify_contract_bytecode.html @@ -0,0 +1,19 @@ +verify_contract_bytecode in bytecode - Sway
pub fn verify_contract_bytecode(contract_id: ContractId, bytecode: Vec<u8>) 
Expand description

Asserts that a contract’s bytecode and the given bytecode match.

+

Arguments

+
    +
  • contract_id: [ContractId] - The contract that the bytecode should match.
  • +
  • bytecode: [Vec] - The bytecode of the contract.
  • +
+

Reverts

+
    +
  • When the contract’s bytecode root does not match the passed bytecode.
  • +
+

Examples

+
use sway_libs::bytecode::verify_contract_bytecode;
+
+fn foo(my_contract_id: ContractId, my_bytecode: Vec<u8>) {
+    verify_contract_bytecode(my_contract_id, my_bytecode);
+    // This line will only be reached if the contract's bytecode root and the computed bytecode root match.
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.verify_contract_bytecode_with_configurables.html b/v0.21.0/sway_libs/bytecode/fn.verify_contract_bytecode_with_configurables.html new file mode 100644 index 00000000..99f4d551 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.verify_contract_bytecode_with_configurables.html @@ -0,0 +1,25 @@ +verify_contract_bytecode_with_configurables in bytecode - Sway
pub fn verify_contract_bytecode_with_configurables(
+    contract_id: ContractId,
+    ref mut bytecode: Vec<u8>,
+    configurables: Vec<(u64, Vec<u8>)>,
+) 
Expand description

Asserts that a contract’s bytecode and the given bytecode and configurable values match.

+

Arguments

+
    +
  • contract_id: [ContractId] - The contract that the bytecode should match.
  • +
  • bytecode: [Vec] - The bytecode of the contract.
  • +
  • configurables: [Vec<(u6, Vec)>] - The configurable values to swap.
  • +
+

Reverts

+
    +
  • When the contract’s bytecode root does not match the passed bytecode.
  • +
+

Examples

+
use sway_libs::bytecode::verify_contract_bytecode_with_configurables;
+
+fn foo(my_contract_id: ContractId, my_bytecode: Vec<u8>, my_configurables: Vec<(u64, Vec<u8>)>) {
+    let mut my_bytecode = my_bytecode;
+    verify_contract_bytecode_with_configurables(my_contract_id, my_bytecode, my_configurables);
+    // This line will only be reached if the contract's bytecode root and the computed bytecode root match.
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.verify_predicate_address.html b/v0.21.0/sway_libs/bytecode/fn.verify_predicate_address.html new file mode 100644 index 00000000..39c496b9 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.verify_predicate_address.html @@ -0,0 +1,19 @@ +verify_predicate_address in bytecode - Sway
pub fn verify_predicate_address(predicate_id: Address, bytecode: Vec<u8>) 
Expand description

Asserts that a predicates’s address from some bytecode and the given address match.

+

Arguments

+
    +
  • predicate_id: [Address] - The predicate address that the bytecode should match.
  • +
  • bytecode: [Vec] - The bytecode of the predicate.
  • +
+

Reverts

+
    +
  • When the predicate’s address does not match the passed address.
  • +
+

Examples

+
use sway_libs::bytecode::verify_predicate_address;
+
+fn foo(my_predicate_id: Address, my_bytecode: Vec<u8>) {
+    verify_predicate_address(my_predicate_id, my_bytecode);
+    // This line will only be reached if the predicates's address and the computed address match.
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/fn.verify_predicate_address_with_configurables.html b/v0.21.0/sway_libs/bytecode/fn.verify_predicate_address_with_configurables.html new file mode 100644 index 00000000..5338285c --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/fn.verify_predicate_address_with_configurables.html @@ -0,0 +1,25 @@ +verify_predicate_address_with_configurables in bytecode - Sway
pub fn verify_predicate_address_with_configurables(
+    predicate_id: Address,
+    ref mut bytecode: Vec<u8>,
+    configurables: Vec<(u64, Vec<u8>)>,
+) 
Expand description

Asserts that a predicates’s address from some bytecode and configurables and the given address match.

+

Arguments

+
    +
  • predicate_id: [Address] - The predicate address that the bytecode should match.
  • +
  • bytecode: [Vec] - The bytecode of the predicate.
  • +
  • configurables: [Vec<(u64, Vec)>] - The configurable values to swap.
  • +
+

Reverts

+
    +
  • When the predicate’s address does not match the passed address.
  • +
+

Examples

+
use sway_libs::bytecode::verify_predicate_address_with_configurables;
+
+fn foo(my_predicate_id: Address, my_bytecode: Vec<u8>, my_configurables: Vec<(u64, Vec<u8>)>) {
+    let mut my_bytecode = my_bytecode;
+    verify_predicate_address_with_configurables(my_predicate_id, my_bytecode, my_configurables);
+    // This line will only be reached if the predicates's address and the computed address match.
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/index.html b/v0.21.0/sway_libs/bytecode/index.html new file mode 100644 index 00000000..3b0c4f14 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/index.html @@ -0,0 +1,9 @@ +bytecode in sway_libs - Sway

Modules

Functions

Takes the bytecode of a contract or predicate and computes the bytecode root.

+

Takes the bytecode of a contract or predicate and configurables and computes the bytecode root.

Takes the bytecode of a predicate and computes the address of a predicate.

+

Takes the bytecode of a predicate and configurables and computes the address of a predicate.

+

Takes the bytecode root of a predicate and generates the address of the predicate.

+

Swaps out configurable values in a contract or predicate’s bytecode.

+

Asserts that a contract’s bytecode and the given bytecode match.

+

Asserts that a contract’s bytecode and the given bytecode and configurable values match.

+

Asserts that a predicates’s address from some bytecode and the given address match.

+

Asserts that a predicates’s address from some bytecode and configurables and the given address match.

\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/utils/fn._compute_bytecode_root.html b/v0.21.0/sway_libs/bytecode/utils/fn._compute_bytecode_root.html new file mode 100644 index 00000000..dcf7b27c --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/utils/fn._compute_bytecode_root.html @@ -0,0 +1,2 @@ +_compute_bytecode_root in utils - Sway
pub fn _compute_bytecode_root(bytecode: raw_slice) -> b256 
Expand description

Takes some bytecode and computes the bytecode root.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/utils/fn._predicate_address_from_root.html b/v0.21.0/sway_libs/bytecode/utils/fn._predicate_address_from_root.html new file mode 100644 index 00000000..0e2ae9a9 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/utils/fn._predicate_address_from_root.html @@ -0,0 +1,2 @@ +_predicate_address_from_root in utils - Sway
pub fn _predicate_address_from_root(bytecode_root: b256) -> Address 
Expand description

Takes the bytecode root of predicate generates the address of a predicate.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/utils/fn._swap_configurables.html b/v0.21.0/sway_libs/bytecode/utils/fn._swap_configurables.html new file mode 100644 index 00000000..951bca98 --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/utils/fn._swap_configurables.html @@ -0,0 +1,5 @@ +_swap_configurables in utils - Sway
pub fn _swap_configurables(
+    ref mut bytecode: raw_slice,
+    configurables: Vec<(u64, Vec<u8>)>,
+) 
Expand description

Swaps out configurable values in a contract’s or predicate’s bytecode.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/bytecode/utils/index.html b/v0.21.0/sway_libs/bytecode/utils/index.html new file mode 100644 index 00000000..40cffe6d --- /dev/null +++ b/v0.21.0/sway_libs/bytecode/utils/index.html @@ -0,0 +1,4 @@ +utils in sway_libs - Sway

Functions

Takes some bytecode and computes the bytecode root.

+

Takes the bytecode root of predicate generates the address of a predicate.

+

Swaps out configurable values in a contract’s or predicate’s bytecode.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ifp128/index.html b/v0.21.0/sway_libs/fixed_point/ifp128/index.html new file mode 100644 index 00000000..814eba0f --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ifp128/index.html @@ -0,0 +1,2 @@ +ifp128 in sway_libs - Sway

Structs

The 128-bit signed fixed point number type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ifp128/struct.IFP128.html b/v0.21.0/sway_libs/fixed_point/ifp128/struct.IFP128.html new file mode 100644 index 00000000..fbeb88c8 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ifp128/struct.IFP128.html @@ -0,0 +1,47 @@ +IFP128 in ifp128 - Sway
pub struct IFP128 {
+    /// The underlying value representing the `IFP128` type.
+    pub underlying: UFP64,
+    /// The underlying boolean representing a negative value for the `IFP128` type.
+    pub non_negative: bool,
+}
Expand description

The 128-bit signed fixed point number type.

+

Additional Information

+

Represented by an underlying UFP64 number and a boolean.

+

Fields

underlying: UFP64

The underlying value representing the IFP128 type.

+
non_negative: bool

The underlying boolean representing a negative value for the IFP128 type.

+

Trait Implementations

fn from(value: UFP64) -> Self

Creates IFP128 from UFP64. Note that IFP128::from(1) is 1 / 2^32 and not 1.

+

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a IFP128 to a IFP128. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a IFP128 from a IFP128. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a IFP128 with a IFP128. Panics of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a IFP128 by a IFP128. Panics if divisor is zero.

+

fn exp(exponent: Self) -> Self

Exponent function. e ^ x

+

fn pow(self, exponent: u32) -> Self

Power function. x ^ exponent

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ifp256/index.html b/v0.21.0/sway_libs/fixed_point/ifp256/index.html new file mode 100644 index 00000000..55405988 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ifp256/index.html @@ -0,0 +1,2 @@ +ifp256 in sway_libs - Sway

Structs

The 256-bit signed fixed point number type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ifp256/struct.IFP256.html b/v0.21.0/sway_libs/fixed_point/ifp256/struct.IFP256.html new file mode 100644 index 00000000..66e8ef7a --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ifp256/struct.IFP256.html @@ -0,0 +1,47 @@ +IFP256 in ifp256 - Sway
pub struct IFP256 {
+    /// The underlying value representing the `IFP256` type.
+    pub underlying: UFP128,
+    /// The underlying boolean representing a negative value for the `IFP256` type.
+    pub non_negative: bool,
+}
Expand description

The 256-bit signed fixed point number type.

+

Additional Information

+

Represented by an underlying UFP128 number and a boolean.

+

Fields

underlying: UFP128

The underlying value representing the IFP256 type.

+
non_negative: bool

The underlying boolean representing a negative value for the IFP256 type.

+

Trait Implementations

fn from(value: UFP128) -> Self

Creates IFP256 from UFP128. Note that IFP256::from(1) is 1 / 2^128 and not 1.

+

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a IFP256 to a IFP256. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a IFP256 from a IFP256. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a IFP256 with a IFP256. Panics of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a IFP256 by a IFP256. Panics if divisor is zero.

+

fn exp(exponent: Self) -> Self

Exponent function. e ^ x

+

fn pow(self, exponent: u32) -> Self

Power function. x ^ exponent

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ifp64/index.html b/v0.21.0/sway_libs/fixed_point/ifp64/index.html new file mode 100644 index 00000000..56665290 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ifp64/index.html @@ -0,0 +1,2 @@ +ifp64 in sway_libs - Sway

Structs

The 64-bit signed fixed point number type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ifp64/struct.IFP64.html b/v0.21.0/sway_libs/fixed_point/ifp64/struct.IFP64.html new file mode 100644 index 00000000..84291546 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ifp64/struct.IFP64.html @@ -0,0 +1,47 @@ +IFP64 in ifp64 - Sway
pub struct IFP64 {
+    /// The underlying value representing the `IFP64` type.
+    pub underlying: UFP32,
+    /// The underlying boolean representing a negative value for the `IFP64` type.
+    pub non_negative: bool,
+}
Expand description

The 64-bit signed fixed point number type.

+

Additional Information

+

Represented by an underlying UFP32 number and a boolean.

+

Fields

underlying: UFP32

The underlying value representing the IFP64 type.

+
non_negative: bool

The underlying boolean representing a negative value for the IFP64 type.

+

Trait Implementations

fn from(value: UFP32) -> Self

Creates IFP64 from UFP32. Note that IFP64::from(1) is 1 / 2^32 and not 1.

+

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a IFP64 to a IFP64. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a IFP64 from a IFP64. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a IFP64 with a IFP64. Panics of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a IFP64 by a IFP64. Panics if divisor is zero.

+

fn exp(exponent: Self) -> Self

Exponent function. e ^ x

+

fn pow(self, exponent: u32) -> Self

Power function. x ^ exponent

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/index.html b/v0.21.0/sway_libs/fixed_point/index.html new file mode 100644 index 00000000..1ccecf31 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/index.html @@ -0,0 +1 @@ +fixed_point in sway_libs - Sway

Modules

\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ufp128/index.html b/v0.21.0/sway_libs/fixed_point/ufp128/index.html new file mode 100644 index 00000000..eb1f2b98 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ufp128/index.html @@ -0,0 +1,2 @@ +ufp128 in sway_libs - Sway

Structs

The 128-bit unsigned fixed point number type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ufp128/struct.UFP128.html b/v0.21.0/sway_libs/fixed_point/ufp128/struct.UFP128.html new file mode 100644 index 00000000..79dce2ed --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ufp128/struct.UFP128.html @@ -0,0 +1,41 @@ +UFP128 in ufp128 - Sway
pub struct UFP128 {
+    /// The underlying value representing the `UFP128` type.
+    pub value: U128,
+}
Expand description

The 128-bit unsigned fixed point number type.

+

Additional Information

+

Represented by an underlying U128 number.

+

Fields

value: U128

The underlying value representing the UFP128 type.

+

Trait Implementations

fn from(int_fract_tuple: (u64, u64)) -> Self

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a UFP128 to a UFP128. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a UFP128 from a UFP128. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a UFP128 with a UFP128. Panics on overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a UFP128 by a UFP128. Panics if divisor is zero.

+

fn sqrt(self) -> Self

fn pow(self, exponent: u32) -> Self

fn exp(exponent: Self) -> Self

\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ufp32/index.html b/v0.21.0/sway_libs/fixed_point/ufp32/index.html new file mode 100644 index 00000000..7d5ef654 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ufp32/index.html @@ -0,0 +1,2 @@ +ufp32 in sway_libs - Sway

Structs

The 32-bit unsigned fixed point number type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ufp32/struct.UFP32.html b/v0.21.0/sway_libs/fixed_point/ufp32/struct.UFP32.html new file mode 100644 index 00000000..7655da3e --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ufp32/struct.UFP32.html @@ -0,0 +1,45 @@ +UFP32 in ufp32 - Sway
pub struct UFP32 {
+    /// The underlying value representing the `UFP32` type.
+    pub value: u32,
+}
Expand description

The 32-bit unsigned fixed point number type.

+

Additional Information

+

Represented by an underlying u32 number.

+

Fields

value: u32

The underlying value representing the UFP32 type.

+

Trait Implementations

fn from(value: u32) -> Self

Creates UFP32 from u32. Note that UFP32::from(1) is 1 / 2^32 and not 1.

+

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a UFP32 to a UFP32. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a UFP32 from a UFP32. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a UFP32 with a UFP32. Panics of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a UFP32 by a UFP32. Panics if divisor is zero.

+

fn sqrt(self) -> Self

Sqaure root for UFP32

+

fn exp(exponent: Self) -> Self

Exponent function. e ^ x

+

fn pow(self, exponent: u32) -> Self

Power function. x ^ exponent

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ufp64/index.html b/v0.21.0/sway_libs/fixed_point/ufp64/index.html new file mode 100644 index 00000000..995acae3 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ufp64/index.html @@ -0,0 +1,2 @@ +ufp64 in sway_libs - Sway

Structs

The 64-bit unsigned fixed point number type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/fixed_point/ufp64/struct.UFP64.html b/v0.21.0/sway_libs/fixed_point/ufp64/struct.UFP64.html new file mode 100644 index 00000000..6c450125 --- /dev/null +++ b/v0.21.0/sway_libs/fixed_point/ufp64/struct.UFP64.html @@ -0,0 +1,45 @@ +UFP64 in ufp64 - Sway
pub struct UFP64 {
+    /// The underlying value representing the `UFP64` type.
+    pub value: u64,
+}
Expand description

The 64-bit unsigned fixed point number type.

+

Additional Information

+

Represented by an underlying u64 number.

+

Fields

value: u64

The underlying value representing the UFP64 type.

+

Trait Implementations

fn from(value: u64) -> Self

Creates UFP64 from u64. Note that UFP64::from(1) is 1 / 2^32 and not 1.

+

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a UFP64 to a UFP64. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a UFP64 from a UFP64. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a UFP64 with a UFP64. Panics of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a UFP64 by a UFP64. Panics if divisor is zero.

+

fn sqrt(self) -> Self

Sqaure root for UFP64

+

fn exp(exponent: Self) -> Self

Exponent function. e ^ x

+

fn pow(self, exponent: u32) -> Self

Power function. x ^ exponent

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/index.html b/v0.21.0/sway_libs/index.html new file mode 100644 index 00000000..01abb86d --- /dev/null +++ b/v0.21.0/sway_libs/index.html @@ -0,0 +1 @@ +sway_libs in sway_libs - Sway

Library sway_libs

Modules

\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/constant.LEAF.html b/v0.21.0/sway_libs/merkle/binary_proof/constant.LEAF.html new file mode 100644 index 00000000..55455a7a --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/constant.LEAF.html @@ -0,0 +1,3 @@ +LEAF in binary_proof - Sway
pub const LEAF = 0u8
Expand description

Concatenated to leaf hash input as described by
+“MTH({d(0)}) = SHA-256(0x00 || d(0))”

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/constant.NODE.html b/v0.21.0/sway_libs/merkle/binary_proof/constant.NODE.html new file mode 100644 index 00000000..c0c6974c --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/constant.NODE.html @@ -0,0 +1,3 @@ +NODE in binary_proof - Sway
pub const NODE = 1u8
Expand description

Concatenated to node hash input as described by
+“MTH(D[n]) = SHA-256(0x01 || MTH(D[0:k]) || MTH(D[k:n]))”

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/enum.ProofError.html b/v0.21.0/sway_libs/merkle/binary_proof/enum.ProofError.html new file mode 100644 index 00000000..140d9384 --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/enum.ProofError.html @@ -0,0 +1,4 @@ +ProofError in binary_proof - Sway
pub enum ProofError {
+    InvalidKey: (),
+    InvalidProofLength: (),
+}

Variants

InvalidKey: ()

InvalidProofLength: ()

\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/fn.leaf_digest.html b/v0.21.0/sway_libs/merkle/binary_proof/fn.leaf_digest.html new file mode 100644 index 00000000..ded7222a --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/fn.leaf_digest.html @@ -0,0 +1,20 @@ +leaf_digest in binary_proof - Sway
pub fn leaf_digest(data: b256) -> b256 
Expand description

Returns the computed leaf hash of “MTH({d(0)}) = SHA-256(0x00 || d(0))”.

+

Arguments

+
    +
  • ‘data’: [b256] - The hash of the leaf data.
  • +
+

Returns

+
    +
  • [b256] - The computed hash.
  • +
+

Examples

+
use sway_libs::merkle::binary_proof::leaf_digest;
+use std::contants::ZERO_B256;
+
+fn foo() {
+    let data = ZERO_B256;
+    let digest = leaf_digest(data);
+    assert(digest == 0x54f05a87f5b881780cdc40e3fddfebf72e3ba7e5f65405ab121c7f22d9849ab4);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/fn.node_digest.html b/v0.21.0/sway_libs/merkle/binary_proof/fn.node_digest.html new file mode 100644 index 00000000..35db3553 --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/fn.node_digest.html @@ -0,0 +1,22 @@ +node_digest in binary_proof - Sway
pub fn node_digest(left: b256, right: b256) -> b256 
Expand description

Returns the computed node hash of “MTH(D[n]) = SHA-256(0x01 || MTH(D[0:k]) || MTH(D[k:n]))”.

+

Arguments

+
    +
  • ‘left’: [b256] - The hash of the left node.
  • +
  • ‘right’: [b256] - The hash of the right node.
  • +
+

Returns

+
    +
  • [b256] - The hash of the node data.
  • +
+

Examples

+
use sway_libs::merkle::binary_proof::node_digest;
+use std::contants::ZERO_B256;
+
+fn foo() {
+    let leaf_1 = ZERO_B256;
+    let leaf_2 = ZERO_B256;
+    let digest = node_digest(leaf_1, leaf_2);
+    assert(digest == 0xee510d4daf24756c7b56b56b838212b193d9265c85c4a3b2c74f5a3189477c80);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/fn.process_proof.html b/v0.21.0/sway_libs/merkle/binary_proof/fn.process_proof.html new file mode 100644 index 00000000..fbf3cea2 --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/fn.process_proof.html @@ -0,0 +1,39 @@ +process_proof in binary_proof - Sway
pub fn process_proof(
+    key: u64,
+    merkle_leaf: b256,
+    num_leaves: u64,
+    proof: Vec<b256>,
+) -> b256 
Expand description

This function will compute and return a Merkle root given a leaf and corresponding proof.

+

Arguments

+
    +
  • ‘key’: [u64] - The key or index of the leaf to prove.
  • +
  • merkle_leaf: [b256] - The hash of a leaf on the Merkle Tree.
  • +
  • ‘num_leaves’: [u64] - The number of leaves in the Merkle Tree.
  • +
  • proof: [Vec] - The Merkle proof that will be used to traverse the Merkle Tree and compute a root.
  • +
+

Returns

+
    +
  • [b256] - The calculated root.
  • +
+

Reverts

+
    +
  • When an incorrect proof length is provided.
  • +
  • When there is one or no leaves and a proof is provided.
  • +
  • When the key is greater than or equal to the number of leaves.
  • +
  • When the computed height gets larger than the proof.
  • +
+

Examples

+
use sway_libs::merkle::binary_proof::process_proof;
+use std::contants::ZERO_B256;
+
+fn foo() {
+    let key = 0;
+    let leaf = ZERO_B256;
+    let num_leaves = 3;
+    let mut proof = Vec::new();
+    proof.push(0xb51fc5c7f5b6393a5b13bb6068de2247ac09df1d3b1bec17627502cb1d1a6ac6);
+    let root = process_proof(key, leaf, num_leaves, proof);
+    assert(root == 0xed84ee783dcb8999206160218e4fe8a1dc5ccb056e3b98f0a6fa633ca5896a47);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/fn.verify_proof.html b/v0.21.0/sway_libs/merkle/binary_proof/fn.verify_proof.html new file mode 100644 index 00000000..20904430 --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/fn.verify_proof.html @@ -0,0 +1,43 @@ +verify_proof in binary_proof - Sway
pub fn verify_proof(
+    key: u64,
+    merkle_leaf: b256,
+    merkle_root: b256,
+    num_leaves: u64,
+    proof: Vec<b256>,
+) -> bool 
Expand description

This function will take a Merkle leaf and proof and return whether the corresponding root
+matches the root given.

+

Arguments

+
    +
  • ‘key’: [u64] - The key or index of the leaf to verify.
  • +
  • merkle_leaf: [b256] - The hash of a leaf on the Merkle Tree.
  • +
  • merkle_root: [b256] - The pre-computed Merkle root that will be used to verify the leaf and proof.
  • +
  • ‘num_leaves’: [u64] - The number of leaves in the Merkle Tree.
  • +
  • proof: [Vec] - The Merkle proof that will be used to traverse the Merkle Tree and compute a root.
  • +
+

Returns

+
    +
  • [bool] - true if the computed root matches the provided root, otherwise ‘false’.
  • +
+

Reverts

+
    +
  • When an incorrect proof length is provided.
  • +
  • When there is one or no leaves and a proof is provided.
  • +
  • When the key is greater than or equal to the number of leaves.
  • +
  • When the computed height gets larger than the proof.
  • +
+

Examples

+
use sway_libs::merkle::binary_proof::process_proof;
+use std::contants::ZERO_B256;
+
+fn foo() {
+    let key = 0;
+    let leaf = ZERO_B256;
+    let num_leaves = 3;
+    let mut proof = Vec::new();
+    proof.push(0xb51fc5c7f5b6393a5b13bb6068de2247ac09df1d3b1bec17627502cb1d1a6ac6);
+    let root = 0xed84ee783dcb8999206160218e4fe8a1dc5ccb056e3b98f0a6fa633ca5896a47;
+
+    assert(verify_proof(key, leaf, root, num_leaves, proof) == true);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/binary_proof/index.html b/v0.21.0/sway_libs/merkle/binary_proof/index.html new file mode 100644 index 00000000..d462a62c --- /dev/null +++ b/v0.21.0/sway_libs/merkle/binary_proof/index.html @@ -0,0 +1,6 @@ +binary_proof in sway_libs - Sway

Enums

Constants

Concatenated to leaf hash input as described by
+“MTH({d(0)}) = SHA-256(0x00 || d(0))”

+

Concatenated to node hash input as described by

Functions

Returns the computed leaf hash of “MTH({d(0)}) = SHA-256(0x00 || d(0))”.

+

Returns the computed node hash of “MTH(D[n]) = SHA-256(0x01 || MTH(D[0:k]) || MTH(D[k:n]))”.

+

This function will compute and return a Merkle root given a leaf and corresponding proof.

+

This function will take a Merkle leaf and proof and return whether the corresponding root

\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/index.html b/v0.21.0/sway_libs/merkle/index.html new file mode 100644 index 00000000..20066882 --- /dev/null +++ b/v0.21.0/sway_libs/merkle/index.html @@ -0,0 +1 @@ +merkle in sway_libs - Sway

Modules

\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/utils/fn.path_length_from_key.html b/v0.21.0/sway_libs/merkle/utils/fn.path_length_from_key.html new file mode 100644 index 00000000..3134a3bb --- /dev/null +++ b/v0.21.0/sway_libs/merkle/utils/fn.path_length_from_key.html @@ -0,0 +1,13 @@ +path_length_from_key in utils - Sway
pub fn path_length_from_key(key: u64, num_leaves: u64) -> u64 
Expand description

Calculates the length of the path to a leaf

+

Additional Information

+

WARNING: This function will be private when https://github.com/FuelLabs/sway/issues/5765 is resolved.

+

Arguments

+
    +
  • key: [u64] - The key or index of the leaf.
  • +
  • num_leaves: [u64] - The total number of leaves in the Merkle Tree.
  • +
+

Returns

+
    +
  • [u64] - The length from the leaf to a root.
  • +
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/utils/fn.starting_bit.html b/v0.21.0/sway_libs/merkle/utils/fn.starting_bit.html new file mode 100644 index 00000000..c690f571 --- /dev/null +++ b/v0.21.0/sway_libs/merkle/utils/fn.starting_bit.html @@ -0,0 +1,12 @@ +starting_bit in utils - Sway
pub fn starting_bit(num_leaves: u64) -> u64 
Expand description

Calculates the starting bit of the path to a leaf

+

Additional Information

+

WARNING: This function will be private when https://github.com/FuelLabs/sway/issues/5765 is resolved.

+

Arguments

+
    +
  • num_leaves: [u64] - The number of leaves in the Merkle Tree.
  • +
+

Returns

+
    +
  • [u64] - The starting bit.
  • +
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/merkle/utils/index.html b/v0.21.0/sway_libs/merkle/utils/index.html new file mode 100644 index 00000000..9aa6dd5b --- /dev/null +++ b/v0.21.0/sway_libs/merkle/utils/index.html @@ -0,0 +1,3 @@ +utils in sway_libs - Sway

Functions

Calculates the length of the path to a leaf

+

Calculates the starting bit of the path to a leaf

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/errors/enum.InitializationError.html b/v0.21.0/sway_libs/ownership/errors/enum.InitializationError.html new file mode 100644 index 00000000..41902135 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/errors/enum.InitializationError.html @@ -0,0 +1,6 @@ +InitializationError in errors - Sway
pub enum InitializationError {
+    /// Emitted when an owner has already been set.
+    CannotReinitialized: (),
+}
Expand description

Error log for when access is denied.

+

Variants

CannotReinitialized: ()

Emitted when an owner has already been set.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/errors/index.html b/v0.21.0/sway_libs/ownership/errors/index.html new file mode 100644 index 00000000..e110e37e --- /dev/null +++ b/v0.21.0/sway_libs/ownership/errors/index.html @@ -0,0 +1,2 @@ +errors in sway_libs - Sway

Enums

Error log for when access is denied.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/events/index.html b/v0.21.0/sway_libs/ownership/events/index.html new file mode 100644 index 00000000..25fe8394 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/events/index.html @@ -0,0 +1,4 @@ +events in sway_libs - Sway

Structs

Logged when ownership is renounced.

+

Logged when ownership is given to a user.

+

Logged when ownership is given from one user to another.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/events/struct.OwnershipRenounced.html b/v0.21.0/sway_libs/ownership/events/struct.OwnershipRenounced.html new file mode 100644 index 00000000..73be5ae3 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/events/struct.OwnershipRenounced.html @@ -0,0 +1,6 @@ +OwnershipRenounced in events - Sway
pub struct OwnershipRenounced {
+    /// The user which revoked the ownership.
+    pub previous_owner: Identity,
+}
Expand description

Logged when ownership is renounced.

+

Fields

previous_owner: Identity

The user which revoked the ownership.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/events/struct.OwnershipSet.html b/v0.21.0/sway_libs/ownership/events/struct.OwnershipSet.html new file mode 100644 index 00000000..50320c98 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/events/struct.OwnershipSet.html @@ -0,0 +1,6 @@ +OwnershipSet in events - Sway
pub struct OwnershipSet {
+    /// The user which is now the owner.
+    pub new_owner: Identity,
+}
Expand description

Logged when ownership is given to a user.

+

Fields

new_owner: Identity

The user which is now the owner.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/events/struct.OwnershipTransferred.html b/v0.21.0/sway_libs/ownership/events/struct.OwnershipTransferred.html new file mode 100644 index 00000000..4be56c47 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/events/struct.OwnershipTransferred.html @@ -0,0 +1,9 @@ +OwnershipTransferred in events - Sway
pub struct OwnershipTransferred {
+    /// The user which is now the owner.
+    pub new_owner: Identity,
+    /// The user which has given up their ownership.
+    pub previous_owner: Identity,
+}
Expand description

Logged when ownership is given from one user to another.

+

Fields

new_owner: Identity

The user which is now the owner.

+
previous_owner: Identity

The user which has given up their ownership.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/fn._owner.html b/v0.21.0/sway_libs/ownership/fn._owner.html new file mode 100644 index 00000000..84157557 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/fn._owner.html @@ -0,0 +1,17 @@ +_owner in ownership - Sway
pub fn _owner() -> State 
Expand description

Returns the owner.

+

Returns

+
    +
  • [State] - The state of the ownership.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::ownership::_owner;
+
+fn foo() {
+    let stored_owner = _owner();
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/fn.initialize_ownership.html b/v0.21.0/sway_libs/ownership/fn.initialize_ownership.html new file mode 100644 index 00000000..cddc4ff9 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/fn.initialize_ownership.html @@ -0,0 +1,24 @@ +initialize_ownership in ownership - Sway
pub fn initialize_ownership(new_owner: Identity) 
Expand description

Sets the passed identity as the initial owner.

+

Arguments

+
    +
  • new_owner: [Identity] - The Identity that will be the first owner.
  • +
+

Reverts

+
    +
  • When ownership has been set before.
  • +
+

Number of Storage Acesses

+
    +
  • Reads: 1
  • +
  • Write: 1
  • +
+

Examples

+
use sway_libs::ownership::{_owner, initialize_ownership};
+
+fn foo(owner: Identity) {
+    assert(_owner() == State::Uninitialized);
+    initialize_ownership(owner);
+    assert(_owner() == State::Initialized(owner));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/fn.only_owner.html b/v0.21.0/sway_libs/ownership/fn.only_owner.html new file mode 100644 index 00000000..e1bd8e22 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/fn.only_owner.html @@ -0,0 +1,18 @@ +only_owner in ownership - Sway
pub fn only_owner() 
Expand description

Ensures that the sender is the owner.

+

Reverts

+
    +
  • When the sender is not the owner.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::ownership::only_owner;
+
+fn foo() {
+    only_owner();
+    // Do stuff here
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/fn.renounce_ownership.html b/v0.21.0/sway_libs/ownership/fn.renounce_ownership.html new file mode 100644 index 00000000..b25580ed --- /dev/null +++ b/v0.21.0/sway_libs/ownership/fn.renounce_ownership.html @@ -0,0 +1,20 @@ +renounce_ownership in ownership - Sway
pub fn renounce_ownership() 
Expand description

Revokes ownership of the current owner and disallows any new owners.

+

Reverts

+
    +
  • When the sender is not the owner.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::ownership::{_owner, renounce_ownership};
+
+fn foo() {
+    assert(_owner() == State::Initialized(Identity::Address(Address::from(ZERO_B256)));
+    renounce_ownership();
+    assert(_owner() == State::Revoked);
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/fn.transfer_ownership.html b/v0.21.0/sway_libs/ownership/fn.transfer_ownership.html new file mode 100644 index 00000000..703f25c5 --- /dev/null +++ b/v0.21.0/sway_libs/ownership/fn.transfer_ownership.html @@ -0,0 +1,24 @@ +transfer_ownership in ownership - Sway
pub fn transfer_ownership(new_owner: Identity) 
Expand description

Transfers ownership to the passed identity.

+

Arguments

+
    +
  • new_owner: [Identity] - The Identity that will be the next owner.
  • +
+

Reverts

+
    +
  • When the sender is not the owner.
  • +
+

Number of Storage Acesses

+
    +
  • Reads: 1
  • +
  • Write: 1
  • +
+

Examples

+
use sway_libs::ownership::{_owner, transfer_ownership};
+
+fn foo(new_owner: Identity) {
+    assert(_owner() == State::Initialized(Identity::Address(Address::from(ZERO_B256)));
+    transfer_ownership(new_owner);
+    assert(_owner() == State::Initialized(new_owner));
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/ownership/index.html b/v0.21.0/sway_libs/ownership/index.html new file mode 100644 index 00000000..f3db87de --- /dev/null +++ b/v0.21.0/sway_libs/ownership/index.html @@ -0,0 +1,6 @@ +ownership in sway_libs - Sway

Modules

Functions

Returns the owner.

+

Sets the passed identity as the initial owner.

+

Ensures that the sender is the owner.

+

Revokes ownership of the current owner and disallows any new owners.

+

Transfers ownership to the passed identity.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/abi.Pausable.html b/v0.21.0/sway_libs/pausable/abi.Pausable.html new file mode 100644 index 00000000..f4883b8f --- /dev/null +++ b/v0.21.0/sway_libs/pausable/abi.Pausable.html @@ -0,0 +1,123 @@ +Pausable in pausable - Sway
abi Pausable {
+    /// Pauses the contract.
+    ///
+    /// # Additional Information
+    ///
+    /// It is highly encouraged to use the Ownership Library in order to lock this
+    /// function to a single administrative user.
+    ///
+    /// # Number of Storage Accesses
+    ///
+    /// * Writes: `1`
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use sway_libs::pausable::Pausable;
+    ///
+    /// fn foo(contract_id: ContractId) {
+    ///     let pausable_abi = abi(Pausable, contract_id);
+    ///     pausable_abi.pause();
+    ///     assert(pausable_abi.is_paused());
+    /// }
+    /// ```
+    #[storage(write)]
+    fn pause();
+    /// Returns whether the contract is paused.
+    ///
+    /// # Returns
+    ///
+    /// * [bool] - The pause state for the contract.
+    ///
+    /// # Number of Storage Accesses
+    ///
+    /// * Reads: `1`
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use sway_libs::pausable::Pausable;
+    ///
+    /// fn foo(contract_id: ContractId) {
+    ///     let pausable_abi = abi(Pausable, contract_id);
+    ///     assert(!pausable_abi.is_paused());
+    /// }
+    /// ```
+    #[storage(read)]
+    fn is_paused() -> bool;
+    /// Unpauses the contract.
+    ///
+    /// # Additional Information
+    ///
+    /// It is highly encouraged to use the Ownership Library in order to lock this
+    /// function to a single administrative user.
+    ///
+    /// # Number of Storage Accesses
+    ///
+    /// * Writes: `1`
+    ///
+    /// # Examples
+    ///
+    /// ```sway
+    /// use sway_libs::pausable::Pausable;
+    ///
+    /// fn foo(contract_id: ContractId) {
+    ///     let pausable_abi = abi(Pausable, contract_id);
+    ///     pausable_abi.unpause();
+    ///     assert(!pausable_abi.is_paused());
+    /// }
+    /// ```
+    #[storage(write)]
+    fn unpause();
+}

Required Methods

Pauses the contract.

+

Additional Information

+

It is highly encouraged to use the Ownership Library in order to lock this
+function to a single administrative user.

+

Number of Storage Accesses

+
    +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::pausable::Pausable;
+
+fn foo(contract_id: ContractId) {
+    let pausable_abi = abi(Pausable, contract_id);
+    pausable_abi.pause();
+    assert(pausable_abi.is_paused());
+}
+
+

Returns whether the contract is paused.

+

Returns

+
    +
  • [bool] - The pause state for the contract.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::pausable::Pausable;
+
+fn foo(contract_id: ContractId) {
+    let pausable_abi = abi(Pausable, contract_id);
+    assert(!pausable_abi.is_paused());
+}
+
+

Unpauses the contract.

+

Additional Information

+

It is highly encouraged to use the Ownership Library in order to lock this
+function to a single administrative user.

+

Number of Storage Accesses

+
    +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::pausable::Pausable;
+
+fn foo(contract_id: ContractId) {
+    let pausable_abi = abi(Pausable, contract_id);
+    pausable_abi.unpause();
+    assert(!pausable_abi.is_paused());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/errors/enum.PauseError.html b/v0.21.0/sway_libs/pausable/errors/enum.PauseError.html new file mode 100644 index 00000000..a4842348 --- /dev/null +++ b/v0.21.0/sway_libs/pausable/errors/enum.PauseError.html @@ -0,0 +1,9 @@ +PauseError in errors - Sway
pub enum PauseError {
+    /// Emitted when the contract is paused.
+    Paused: (),
+    /// Emitted when the contract is not paused.
+    NotPaused: (),
+}
Expand description

Error emitted upon the opposite of the desired pause state.

+

Variants

Paused: ()

Emitted when the contract is paused.

+

NotPaused: ()

Emitted when the contract is not paused.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/errors/index.html b/v0.21.0/sway_libs/pausable/errors/index.html new file mode 100644 index 00000000..2eeb0226 --- /dev/null +++ b/v0.21.0/sway_libs/pausable/errors/index.html @@ -0,0 +1,2 @@ +errors in sway_libs - Sway

Enums

Error emitted upon the opposite of the desired pause state.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/fn._is_paused.html b/v0.21.0/sway_libs/pausable/fn._is_paused.html new file mode 100644 index 00000000..5e09abc9 --- /dev/null +++ b/v0.21.0/sway_libs/pausable/fn._is_paused.html @@ -0,0 +1,17 @@ +_is_paused in pausable - Sway
pub fn _is_paused() -> bool 
Expand description

Returns whether the contract is in the paused state.

+

Returns

+
    +
  • [bool] - The pause state of the contract.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::pausable::_is_paused;
+
+fn foo() {
+    assert(!_is_paused());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/fn._pause.html b/v0.21.0/sway_libs/pausable/fn._pause.html new file mode 100644 index 00000000..f6045d60 --- /dev/null +++ b/v0.21.0/sway_libs/pausable/fn._pause.html @@ -0,0 +1,14 @@ +_pause in pausable - Sway
pub fn _pause() 
Expand description

Unconditionally sets the contract to the paused state.

+

Number of Storage Accesses

+
    +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::pausable::{_pause, _is_paused};
+
+fn foo() {
+    _pause();
+    assert(_is_paused());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/fn._unpause.html b/v0.21.0/sway_libs/pausable/fn._unpause.html new file mode 100644 index 00000000..4690f03d --- /dev/null +++ b/v0.21.0/sway_libs/pausable/fn._unpause.html @@ -0,0 +1,14 @@ +_unpause in pausable - Sway
pub fn _unpause() 
Expand description

Unconditionally sets the contract to the unpaused state.

+

Number of Storage Accesses

+
    +
  • Writes: 1
  • +
+

Examples

+
use sway_libs::pausable::{_unpause, _is_paused};
+
+fn foo() {
+    _unpause();
+    assert(!_is_paused());
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/fn.require_not_paused.html b/v0.21.0/sway_libs/pausable/fn.require_not_paused.html new file mode 100644 index 00000000..1f874ce6 --- /dev/null +++ b/v0.21.0/sway_libs/pausable/fn.require_not_paused.html @@ -0,0 +1,19 @@ +require_not_paused in pausable - Sway
pub fn require_not_paused() 
Expand description

Requires that the contract is in the unpaused state.

+

Reverts

+
    +
  • When the contract is paused.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::pausable::{_unpause, require_not_paused};
+
+fn foo() {
+    _unpause();
+    require_not_paused();
+    // Only reachable when unpaused
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/fn.require_paused.html b/v0.21.0/sway_libs/pausable/fn.require_paused.html new file mode 100644 index 00000000..224fc71c --- /dev/null +++ b/v0.21.0/sway_libs/pausable/fn.require_paused.html @@ -0,0 +1,19 @@ +require_paused in pausable - Sway
pub fn require_paused() 
Expand description

Requires that the contract is in the paused state.

+

Reverts

+
    +
  • When the contract is not paused.
  • +
+

Number of Storage Accesses

+
    +
  • Reads: 1
  • +
+

Examples

+
use sway_libs::pausable::{_pause, require_paused};
+
+fn foo() {
+    _pause();
+    require_paused();
+    // Only reachable when paused
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/pausable/index.html b/v0.21.0/sway_libs/pausable/index.html new file mode 100644 index 00000000..e8922f6b --- /dev/null +++ b/v0.21.0/sway_libs/pausable/index.html @@ -0,0 +1,6 @@ +pausable in sway_libs - Sway

Modules

Abi

Functions

Returns whether the contract is in the paused state.

+

Unconditionally sets the contract to the paused state.

+

Unconditionally sets the contract to the unpaused state.

+

Requires that the contract is in the unpaused state.

+

Requires that the contract is in the paused state.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/queue/index.html b/v0.21.0/sway_libs/queue/index.html new file mode 100644 index 00000000..f4e5f73b --- /dev/null +++ b/v0.21.0/sway_libs/queue/index.html @@ -0,0 +1,2 @@ +queue in sway_libs - Sway

Structs

The Queue type corresponds to the same called data structure.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/queue/struct.Queue.html b/v0.21.0/sway_libs/queue/struct.Queue.html new file mode 100644 index 00000000..29e5374f --- /dev/null +++ b/v0.21.0/sway_libs/queue/struct.Queue.html @@ -0,0 +1,9 @@ +Queue in queue - Sway
pub struct Queue<T> {
+    /// The underlying vector that stored the elements of the `Queue`.
+    vec: Vec<T>,
+}
Expand description

The Queue type corresponds to the same called data structure.

+

Additional Information

+

A Queue is defined as a linear data structure that is open at both ends and the operations are performed in First In First Out order.
+Meaning additions to the list are made at one end, and all deletions from the list are made at the other end.

+

Fields

vec: Vec

The underlying vector that stored the elements of the Queue.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/reentrancy/errors/enum.ReentrancyError.html b/v0.21.0/sway_libs/reentrancy/errors/enum.ReentrancyError.html new file mode 100644 index 00000000..b54071b2 --- /dev/null +++ b/v0.21.0/sway_libs/reentrancy/errors/enum.ReentrancyError.html @@ -0,0 +1,6 @@ +ReentrancyError in errors - Sway
pub enum ReentrancyError {
+    /// Emitted when the caller is a reentrant.
+    NonReentrant: (),
+}
Expand description

Error log for when reentrancy has been detected

+

Variants

NonReentrant: ()

Emitted when the caller is a reentrant.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/reentrancy/errors/index.html b/v0.21.0/sway_libs/reentrancy/errors/index.html new file mode 100644 index 00000000..ed545992 --- /dev/null +++ b/v0.21.0/sway_libs/reentrancy/errors/index.html @@ -0,0 +1,2 @@ +errors in sway_libs - Sway

Enums

Error log for when reentrancy has been detected

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/reentrancy/fn.is_reentrant.html b/v0.21.0/sway_libs/reentrancy/fn.is_reentrant.html new file mode 100644 index 00000000..8269977a --- /dev/null +++ b/v0.21.0/sway_libs/reentrancy/fn.is_reentrant.html @@ -0,0 +1,17 @@ +is_reentrant in reentrancy - Sway
pub fn is_reentrant() -> bool 
Expand description

Returns true if the reentrancy pattern is detected, and false otherwise.

+

Additional Information

+

Detects reentrancy by iteratively checking previous calls in the current call stack for a
+contract ID equal to the current contract ID. If a match is found, it returns true, else false.

+

Returns

+
    +
  • [bool] - true if reentrancy pattern has occured.
  • +
+

Examples

+
use sway_libs::reentrancy::is_reentrant;
+
+fn foo() {
+    assert(is_reentrant() == false);
+    // Do critical stuff here
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/reentrancy/fn.reentrancy_guard.html b/v0.21.0/sway_libs/reentrancy/fn.reentrancy_guard.html new file mode 100644 index 00000000..27f12eb2 --- /dev/null +++ b/v0.21.0/sway_libs/reentrancy/fn.reentrancy_guard.html @@ -0,0 +1,17 @@ +reentrancy_guard in reentrancy - Sway
pub fn reentrancy_guard() 
Expand description

Reverts if the reentrancy pattern is detected in the contract in which this is called.

+

Additional Information

+

Not needed if the Checks-Effects-Interactions (CEI) pattern is followed (as prompted by the
+compiler).

+
+

Caution: While this can protect against both single-function reentrancy and cross-function
+reentrancy attacks, it WILL NOT PREVENT a cross-contract reentrancy attack.

+
+

Examples

+
use sway_libs::reentrancy::reentrancy_guard;
+
+fn foo() {
+    reentrancy_guard();
+    // Do critical stuff here
+}
+
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/reentrancy/index.html b/v0.21.0/sway_libs/reentrancy/index.html new file mode 100644 index 00000000..948b9dba --- /dev/null +++ b/v0.21.0/sway_libs/reentrancy/index.html @@ -0,0 +1,2 @@ +reentrancy in sway_libs - Sway

Modules

Functions

Returns true if the reentrancy pattern is detected, and false otherwise.

Reverts if the reentrancy pattern is detected in the contract in which this is called.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/common/index.html b/v0.21.0/sway_libs/signed_integers/common/index.html new file mode 100644 index 00000000..a659d470 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/common/index.html @@ -0,0 +1,2 @@ +common in sway_libs - Sway

Traits

Trait for the Two’s Complement of a value.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/common/trait.TwosComplement.html b/v0.21.0/sway_libs/signed_integers/common/trait.TwosComplement.html new file mode 100644 index 00000000..9b189917 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/common/trait.TwosComplement.html @@ -0,0 +1,14 @@ +TwosComplement in common - Sway
pub trait TwosComplement {
+    /// Returns the two's complement of a value.
+    ///
+    /// # Returns
+    ///
+    /// * [Self] - The value as two's complement.
+    fn twos_complement(self) -> Self;
+}
Expand description

Trait for the Two’s Complement of a value.

+

Required Methods

Returns the two’s complement of a value.

+

Returns

+
    +
  • [Self] - The value as two’s complement.
  • +
+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/errors/enum.Error.html b/v0.21.0/sway_libs/signed_integers/errors/enum.Error.html new file mode 100644 index 00000000..8461866b --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/errors/enum.Error.html @@ -0,0 +1,6 @@ +Error in errors - Sway
pub enum Error {
+    /// Emitted when division by zero has occured.
+    ZeroDivisor: (),
+}
Expand description

Error log for when unexpected behavior has occurred.

+

Variants

ZeroDivisor: ()

Emitted when division by zero has occured.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/errors/index.html b/v0.21.0/sway_libs/signed_integers/errors/index.html new file mode 100644 index 00000000..307bdbd7 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/errors/index.html @@ -0,0 +1,2 @@ +errors in sway_libs - Sway

Enums

Error log for when unexpected behavior has occurred.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i128/index.html b/v0.21.0/sway_libs/signed_integers/i128/index.html new file mode 100644 index 00000000..e7320d54 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i128/index.html @@ -0,0 +1,2 @@ +i128 in sway_libs - Sway

Structs

The 128-bit signed integer type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i128/struct.I128.html b/v0.21.0/sway_libs/signed_integers/i128/struct.I128.html new file mode 100644 index 00000000..fabb2659 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i128/struct.I128.html @@ -0,0 +1,44 @@ +I128 in i128 - Sway
pub struct I128 {
+    /// The underlying unsigned number representing the `I128` type.
+    pub underlying: U128,
+}
Expand description

The 128-bit signed integer type.

+

Additional Information

+

Represented as an underlying U128 value.
+Actual value is underlying value minus 2 ^ 127
+Max value is 2 ^ 127 - 1, min value is - 2 ^ 127

+

Fields

underlying: U128

The underlying unsigned number representing the I128 type.

+

Trait Implementations

fn from(value: U128) -> Self

Helper function to get a signed number from with an underlying

+

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a I128 to a I128. Panics on overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a I128 by a I128. Panics if divisor is zero.

+

fn multiply(self, other: Self) -> Self

Multiply a I128 with a I128. Panics of overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a I128 from a I128. Panics of overflow.

+

fn twos_complement(self) -> Self

\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i16/index.html b/v0.21.0/sway_libs/signed_integers/i16/index.html new file mode 100644 index 00000000..2852bdec --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i16/index.html @@ -0,0 +1,2 @@ +i16 in sway_libs - Sway

Structs

The 16-bit signed integer type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i16/struct.I16.html b/v0.21.0/sway_libs/signed_integers/i16/struct.I16.html new file mode 100644 index 00000000..b117b266 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i16/struct.I16.html @@ -0,0 +1,44 @@ +I16 in i16 - Sway
pub struct I16 {
+    /// The underlying value representing the signed integer.
+    pub underlying: u16,
+}
Expand description

The 16-bit signed integer type.

+

Additional Information

+

Represented as an underlying u16 value.
+Actual value is underlying value minus 2 ^ 15
+Max value is 2 ^ 15 - 1, min value is - 2 ^ 15

+

Fields

underlying: u16

The underlying value representing the signed integer.

+

Trait Implementations

fn from(value: u16) -> Self

Helper function to get a signed number from with an underlying

+

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a I16 to a I16. Panics on overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a I16 by a I16. Panics if divisor is zero.

+

fn multiply(self, other: Self) -> Self

Multiply a I16 with a I16. Panics of overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a I16 from a I16. Panics of overflow.

+

fn twos_complement(self) -> Self

\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i256/index.html b/v0.21.0/sway_libs/signed_integers/i256/index.html new file mode 100644 index 00000000..7d562c0c --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i256/index.html @@ -0,0 +1,2 @@ +i256 in sway_libs - Sway

Structs

The 256-bit signed integer type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i256/struct.I256.html b/v0.21.0/sway_libs/signed_integers/i256/struct.I256.html new file mode 100644 index 00000000..65ff215a --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i256/struct.I256.html @@ -0,0 +1,41 @@ +I256 in i256 - Sway
pub struct I256 {
+    pub underlying: u256,
+}
Expand description

The 256-bit signed integer type.

+

Additional Information

+

Represented as an underlying u256 value.
+Actual value is underlying value minus 2 ^ 255
+Max value is 2 ^ 255 - 1, min value is - 2 ^ 255

+

Fields

underlying: u256

Trait Implementations

fn from(value: u256) -> Self

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a I256 to a I256. Panics on overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a I256 by a I256. Panics if divisor is zero.

+

fn multiply(self, other: Self) -> Self

Multiply a I256 with a I256. Panics of overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a I256 from a I256. Panics of overflow.

+

fn twos_complement(self) -> Self

\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i32/index.html b/v0.21.0/sway_libs/signed_integers/i32/index.html new file mode 100644 index 00000000..7cf58547 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i32/index.html @@ -0,0 +1,2 @@ +i32 in sway_libs - Sway

Structs

The 32-bit signed integer type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i32/struct.I32.html b/v0.21.0/sway_libs/signed_integers/i32/struct.I32.html new file mode 100644 index 00000000..d3f696e3 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i32/struct.I32.html @@ -0,0 +1,43 @@ +I32 in i32 - Sway
pub struct I32 {
+    /// The underlying u32 type that represent a I32.
+    pub underlying: u32,
+}
Expand description

The 32-bit signed integer type.

+

Additional Information

+

Represented as an underlying u32 value.
+Actual value is underlying value minus 2 ^ 31
+Max value is 2 ^ 31 - 1, min value is - 2 ^ 31

+

Fields

underlying: u32

The underlying u32 type that represent a I32.

+

Trait Implementations

fn from(value: u32) -> Self

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a I32 to a I32. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a I32 from a I32. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a I32 with a I32. Panics of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a I32 by a I32. Panics if divisor is zero.

+

fn twos_complement(self) -> Self

\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i64/index.html b/v0.21.0/sway_libs/signed_integers/i64/index.html new file mode 100644 index 00000000..529cdaaf --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i64/index.html @@ -0,0 +1,2 @@ +i64 in sway_libs - Sway

Structs

The 64-bit signed integer type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i64/struct.I64.html b/v0.21.0/sway_libs/signed_integers/i64/struct.I64.html new file mode 100644 index 00000000..0d6a83b8 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i64/struct.I64.html @@ -0,0 +1,43 @@ +I64 in i64 - Sway
pub struct I64 {
+    /// The underlying unsigned number representing the `I64` type.
+    pub underlying: u64,
+}
Expand description

The 64-bit signed integer type.

+

Additional Information

+

Represented as an underlying u64 value.
+Actual value is underlying value minus 2 ^ 63
+Max value is 2 ^ 63 - 1, min value is - 2 ^ 63

+

Fields

underlying: u64

The underlying unsigned number representing the I64 type.

+

Trait Implementations

fn from(value: u64) -> Self

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a I64 to a I64. Panics on overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a I64 from a I64. Panics of overflow.

+

fn multiply(self, other: Self) -> Self

Multiply a I64 with a I64. Panics of overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a I64 by a I64. Panics if divisor is zero.

+

fn twos_complement(self) -> Self

\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i8/index.html b/v0.21.0/sway_libs/signed_integers/i8/index.html new file mode 100644 index 00000000..cf8de373 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i8/index.html @@ -0,0 +1,2 @@ +i8 in sway_libs - Sway

Structs

The 8-bit signed integer type.

+
\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/i8/struct.I8.html b/v0.21.0/sway_libs/signed_integers/i8/struct.I8.html new file mode 100644 index 00000000..8ff8b4b6 --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/i8/struct.I8.html @@ -0,0 +1,43 @@ +I8 in i8 - Sway
pub struct I8 {
+    /// The underlying unsigned `u8` type that makes up the signed `I8` type.
+    pub underlying: u8,
+}
Expand description

The 8-bit signed integer type.

+

Additional Information

+

Represented as an underlying u8 value.
+Actual value is underlying value minus 2 ^ 7
+Max value is 2 ^ 7 - 1, min value is - 2 ^ 7

+

Fields

underlying: u8

The underlying unsigned u8 type that makes up the signed I8 type.

+

Trait Implementations

fn from(value: u8) -> Self

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

+

Additional Information

+

This function is inherited when eq() is implemented.

+

Arguments

+
    +
  • other: [Self] - The value of the same type.
  • +
+

Returns

+
    +
  • [bool] - true if the two values are not equal, otherwise false.
  • +
+

Examples

+
struct MyStruct {
+    val: u64,
+}
+
+impl Eq for MyStruct {
+    fn eq(self, other: Self) -> bool {
+         self.val == other.val
+    }
+}
+
+fn foo() {
+    let struct1 = MyStruct { val: 10 };
+    let struct2 = MyStruct { val: 2 };
+    let result = struct1 != struct2;
+    assert(result);
+}
+
+

fn gt(self, other: Self) -> bool

fn lt(self, other: Self) -> bool

fn add(self, other: Self) -> Self

Add a I8 to a I8. Panics on overflow.

+

fn divide(self, divisor: Self) -> Self

Divide a I8 by a I8. Panics if divisor is zero.

+

fn multiply(self, other: Self) -> Self

Multiply a I8 with a I8. Panics of overflow.

+

fn subtract(self, other: Self) -> Self

Subtract a I8 from a I8. Panics of overflow.

+

fn twos_complement(self) -> Self

\ No newline at end of file diff --git a/v0.21.0/sway_libs/signed_integers/index.html b/v0.21.0/sway_libs/signed_integers/index.html new file mode 100644 index 00000000..692fa78a --- /dev/null +++ b/v0.21.0/sway_libs/signed_integers/index.html @@ -0,0 +1 @@ +signed_integers in sway_libs - Sway

Modules

\ No newline at end of file