Skip to content

Commit

Permalink
Merge branch 'master' into feature/trig-never
Browse files Browse the repository at this point in the history
  • Loading branch information
MujkicA authored Mar 14, 2024
2 parents e7088af + 250250c commit ef13152
Show file tree
Hide file tree
Showing 109 changed files with 4,455 additions and 3,463 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ env:
CARGO_TERM_COLOR: always
DASEL_VERSION: https://github.com/TomWright/dasel/releases/download/v2.3.6/dasel_linux_amd64
RUSTFLAGS: "-D warnings"
FUEL_CORE_VERSION: 0.22.1
FUEL_CORE_VERSION: 0.23.0
FUEL_CORE_PATCH_BRANCH:
RUST_VERSION: 1.74.0
FORC_VERSION: 0.50.0
FORC_VERSION: 0.51.1
FORC_PATCH_BRANCH: ""
FORC_PATCH_REVISION: ""

Expand Down
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@ tokio = { version = "1.34.0", default-features = false }
tracing = "0.1.40"
trybuild = "1.0.85"
uint = { version = "0.9.5", default-features = false }
which = { version = "5.0.0", default-features = false }
which = { version = "6.0.0", default-features = false }
zeroize = "1.7.0"

# Dependencies from the `fuel-core` repository:
fuel-core = { version = "0.22.1", default-features = false }
fuel-core-chain-config = { version = "0.22.1", default-features = false }
fuel-core-client = { version = "0.22.1", default-features = false }
fuel-core-poa = { version = "0.22.1", default-features = false }
fuel-core-services = { version = "0.22.1", default-features = false }
fuel-core-types = { version = "0.22.1", default-features = false }
fuel-core = { version = "0.23.0", default-features = false }
fuel-core-chain-config = { version = "0.23.0", default-features = false }
fuel-core-client = { version = "0.23.0", default-features = false }
fuel-core-poa = { version = "0.23.0", default-features = false }
fuel-core-services = { version = "0.23.0", default-features = false }
fuel-core-types = { version = "0.23.0", default-features = false }

# Dependencies from the `fuel-vm` repository:
fuel-asm = { version = "0.43.2" }
fuel-crypto = { version = "0.43.2" }
fuel-merkle = { version = "0.43.2" }
fuel-storage = { version = "0.43.2" }
fuel-tx = { version = "0.43.2" }
fuel-types = { version = "0.43.2" }
fuel-vm = { version = "0.43.2" }
fuel-asm = { version = "0.47.1" }
fuel-crypto = { version = "0.47.1" }
fuel-merkle = { version = "0.47.1" }
fuel-storage = { version = "0.47.1" }
fuel-tx = { version = "0.47.1" }
fuel-types = { version = "0.47.1" }
fuel-vm = { version = "0.47.1" }

# Workspace projects
fuels = { version = "0.55.0", path = "./packages/fuels" }
Expand Down
2 changes: 1 addition & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
- [`Address`](./types/address.md)
- [`ContractId`](./types/contract-id.md)
- [`AssetId`](./types/asset-id.md)
- [Converting native types](./types/conversion.md)
- [`Bech32`](./types/bech32.md)
- [Structs and enums](./types/custom_types.md)
- [`String`](./types/string.md)
Expand All @@ -60,6 +59,7 @@
- [`B512`](./types/B512.md)
- [`EvmAddress`](./types/evm_address.md)
- [Vectors](./types/vectors.md)
- [Converting types](./types/conversion.md)
- [Codec](./codec/index.md)
- [Encoding](./codec/encoding.md)
- [Decoding](./codec/decoding.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/calling-contracts/call-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Then, in Rust, after setting up and deploying the above contract, you can config
<!-- payable:example:start -->
`call_params` returns a result to ensure you don't forward assets to a contract method that isn't payable.
<!-- payable:example:end -->
In the following example, we try to forward an amount of 100 of the base asset to `non_payable`. As its name suggests, `non_payable` isn't annotated with `#[payable]` in the contract code. Passing `CallParameters` with an amount other than 0 leads to an `InvalidCallParameters` error:
In the following example, we try to forward an amount of `100` of the base asset to `non_payable`. As its name suggests, `non_payable` isn't annotated with `#[payable]` in the contract code. Passing `CallParameters` with an amount other than `0` leads to an error:

```rust,ignore
{{#include ../../../packages/fuels/tests/contracts.rs:non_payable_params}}
Expand Down
13 changes: 4 additions & 9 deletions docs/src/calling-contracts/cost-estimation.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# Estimating contract call cost

With the function `estimate_transaction_cost(tolerance: Option<f64>)` provided by `ContractCallHandler` and `ContractMultiCallHandler`, you can get a cost estimation for a specific call. The return type, `TransactionCost`, is a struct that contains relevant information for the estimation:
With the function `estimate_transaction_cost(tolerance: Option<f64>, block_horizon: Option<u32>)` provided by `ContractCallHandler` and `ContractMultiCallHandler`, you can get a cost estimation for a specific call. The return type, `TransactionCost`, is a struct that contains relevant information for the estimation:

```rust,ignore
TransactionCost {
min_gas_price: u64,
min_byte_price: u64,
gas_price: u64,
gas_used: u64,
metered_bytes_size: u64,
total_fee: f64, // where total_fee is the sum of the gas and byte fees
}
{{#include ../../../packages/fuels-accounts/src/provider.rs:transaction_cost}}
```

Below are examples that show how to get the estimated transaction cost from single and multi call transactions.
Expand All @@ -24,3 +17,5 @@ Below are examples that show how to get the estimated transaction cost from sing
```

The transaction cost estimation can be used to set the gas limit for an actual call, or to show the user the estimated cost.

> **Note** The same estimation interface is available for scripts.
2 changes: 1 addition & 1 deletion docs/src/calling-contracts/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ You can use the `decode_logs()` function to retrieve a `LogResult` struct contai

Due to possible performance hits, it is not recommended to use `decode_logs()` outside of a debugging scenario.

> **Note:** String slices can not be logged directly. Use the `__to_str_array()` function to convert it to a `str[N]` first.
> **Note:** String slices cannot be logged directly. Use the `__to_str_array()` function to convert it to a `str[N]` first.
4 changes: 2 additions & 2 deletions docs/src/calling-contracts/tx-policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Transaction policies are defined as follows:

Where:

1. **Gas Price** - Maximum gas price for transaction.
1. **Tip** - amount to pay the block producer to prioritize the transaction.
2. **Witness Limit** - The maximum amount of witness data allowed for the transaction.
3. **Maturity** - Block until which the transaction cannot be included.
4. **Max Fee** - The maximum fee payable by this transaction.
5. **Script Gas Limit** - The maximum amount of gas the transaction may consume for executing its script code.

When the **Script Gas Limit** is not set, the Rust SDK will estimate the consumed gas in the background and set it as the limit. Similarly, if no **Gas Price** is defined, the Rust SDK defaults to the network's minimum gas price.
When the **Script Gas Limit** is not set, the Rust SDK will estimate the consumed gas in the background and set it as the limit.

If the **Witness Limit** is not set, the SDK will set it to the size of all witnesses and signatures defined in the transaction builder.

Expand Down
209 changes: 208 additions & 1 deletion docs/src/types/conversion.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,214 @@
# Converting native types
# Converting Types

Below you can find examples for common type conversions:

- [Convert Between Native Types](#convert-between-native-types)
- [Convert to `Bytes32`](#convert-to-bytes32)
- [Convert to `Address`](#convert-to-address)
- [Convert to `ContractId`](#convert-to-contractid)
- [Convert to `Identity`](#convert-to-identity)
- [Convert to `AssetId`](#convert-to-assetid)
- [Convert to `Bech32`](#convert-to-bech32)
- [Convert to `str`](#convert-to-str)
- [Convert to `Bits256`](#convert-to-bits256)
- [Convert to `Bytes`](#convert-to-bytes)
- [Convert to `B512`](#convert-to-b512)
- [Convert to `EvmAddress`](#convert-to-evmaddress)

## Convert Between Native Types

You might want to convert between the native types (`Bytes32`, `Address`, `ContractId`, and `AssetId`). Because these types are wrappers on `[u8; 32]`, converting is a matter of dereferencing one and instantiating the other using the dereferenced value. Here's an example:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:type_conversion}}
```

## Convert to `Bytes32`

Convert a `[u8; 32]` array to `Bytes32`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:array_to_bytes32}}
```

Convert a hex string to `Bytes32`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:hex_string_to_bytes32}}
```

## Convert to `Address`

Convert a `[u8; 32]` array to an `Address`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:array_to_address}}
```

Convert a `Bech32` address to an `Address`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:bech32_to_address}}
```

Convert a wallet to an `Address`:

```rust,ignore
{{#include ../../../examples/wallets/src/lib.rs:wallet_to_address}}
```

Convert a hex string to an `Address`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:hex_string_to_address}}
```

## Convert to `ContractId`

Convert a `[u8; 32]` array to to `ContractId`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:array_to_contract_id}}
```

Convert a hex string to a `ContractId`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:string_to_contract_id}}
```

Convert a contract instance to a `ContractId`:

```rust,ignore
{{#include ../../../packages/fuels/tests/logs.rs:instance_to_contract_id}}
```

## Convert to `Identity`

Convert an `Address` to an `Identity`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:address_to_identity}}
```

Convert a `ContractId` to an `Identity`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:contract_id_to_identity}}
```

## Convert to `AssetId`

Convert a `[u8; 32]` array to an `AssetId`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:array_to_asset_id}}
```

Convert a hex string to an `AssetId`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:string_to_asset_id}}
```

## Convert to `Bech32`

Convert a `[u8; 32]` array to a `Bech32` address:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:array_to_bech32}}
```

Convert `Bytes32` to a `Bech32` address:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:bytes32_to_bech32}}
```

Convert a string to a `Bech32` address:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:str_to_bech32}}
```

Convert an `Address` to a `Bech32` address:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:address_to_bech32}}
```

## Convert to `str`

Convert a `ContractId` to a `str`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:contract_id_to_str}}
```

Convert an `Address` to a `str`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:address_to_str}}
```

Convert an `AssetId` to a `str`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:asset_id_to_str}}
```

Convert `Bytes32` to a `str`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:bytes32_to_str}}
```

## Convert to `Bits256`

Convert a hex string to `Bits256`:

```rust,ignore
{{#include ../../../packages/fuels-core/src/types/core/bits.rs:hex_str_to_bits256}}
```

Convert a `ContractId` to `Bits256`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:contract_id_to_bits256}}
```

Convert an `Address` to `Bits256`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:address_to_bits256}}
```

Convert an `AssetId` to `Bits256`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:asset_id_to_bits256}}
```

## Convert to `Bytes`

Convert a string to `Bytes`:

```rust,ignore
{{#include ../../../packages/fuels-core/src/types/core/bytes.rs:hex_string_to_bytes32}}
```

## Convert to `B512`

Convert two hex strings to `B512`:

```rust,ignore
{{#include ../../../packages/fuels/tests/types_contracts.rs:b512_example}}
```

## Convert to `EvmAddress`

Convert a `Bits256` address to an `EvmAddress`:

```rust,ignore
{{#include ../../../examples/types/src/lib.rs:b256_to_evm_address}}
```
Loading

0 comments on commit ef13152

Please sign in to comment.