Skip to content

Commit

Permalink
deploy: 86e3cc7
Browse files Browse the repository at this point in the history
  • Loading branch information
hal3e committed Feb 20, 2024
1 parent d42ca99 commit 9b3dbbb
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 128 deletions.
8 changes: 4 additions & 4 deletions master/accounts.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ <h2 id="transferring-assets"><a class="header" href="#transferring-assets">Trans
let wallet = wallets.first().unwrap();

let amount = 1000;
let base_layer_address =
Address::from_str(&quot;0x4710162c2e3a95a6faff05139150017c9e38e5e280432d546fae345d6ce6d8fe&quot;)
.expect(&quot;Invalid address.&quot;);
let base_layer_address = Address::from_str(
&quot;0x4710162c2e3a95a6faff05139150017c9e38e5e280432d546fae345d6ce6d8fe&quot;,
)?;
let base_layer_address = Bech32Address::from(base_layer_address);
// Transfer an amount of 1000 to the specified base layer address
let (tx_id, msg_id, _receipts) = wallet
Expand All @@ -235,7 +235,7 @@ <h2 id="transferring-assets"><a class="header" href="#transferring-assets">Trans
.try_provider()?
.get_message_proof(&amp;tx_id, &amp;msg_id, None, Some(2))
.await?
.expect(&quot;Failed to retrieve message proof.&quot;);
.expect(&quot;failed to retrieve message proof&quot;);

// Verify the amount and recipient
assert_eq!(proof.amount, amount);
Expand Down
6 changes: 3 additions & 3 deletions master/calling-contracts/call-params.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ <h1 id="call-parameters"><a class="header" href="#call-parameters">Call paramete
<!-- payable:example:start -->
<p><code>call_params</code> returns a result to ensure you don't forward assets to a contract method that isn't payable.</p>
<!-- payable:example:end -->
<p>In the following example, we try to forward an amount of 100 of the base asset to <code>non_payable</code>. As its name suggests, <code>non_payable</code> isn't annotated with <code>#[payable]</code> in the contract code. Passing <code>CallParameters</code> with an amount other than 0 leads to an <code>InvalidCallParameters</code> error:</p>
<p>In the following example, we try to forward an amount of <code>100</code> of the base asset to <code>non_payable</code>. As its name suggests, <code>non_payable</code> isn't annotated with <code>#[payable]</code> in the contract code. Passing <code>CallParameters</code> with an amount other than <code>0</code> leads to an error:</p>
<pre><code class="language-rust ignore"> let err = contract_methods
.non_payable()
.call_params(CallParameters::default().with_amount(100))
.expect_err(&quot;Should return call params error.&quot;);
.expect_err(&quot;should return error&quot;);

assert!(matches!(err, Error::AssetsForwardedToNonPayableMethod));
assert!(matches!(err, Error::Other(s) if s.contains(&quot;assets forwarded to non-payable method&quot;)));
</code></pre>
<blockquote>
<p><strong>Note:</strong> forwarding gas to a contract call is always possible, regardless of the contract method being non-payable.</p>
Expand Down
2 changes: 1 addition & 1 deletion master/calling-contracts/logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ <h1 id="logs"><a class="header" href="#logs">Logs</a></h1>
</code></pre>
<p>Due to possible performance hits, it is not recommended to use <code>decode_logs()</code> outside of a debugging scenario.</p>
<blockquote>
<p><strong>Note:</strong> String slices can not be logged directly. Use the <code>__to_str_array()</code> function to convert it to a <code>str[N]</code> first.</p>
<p><strong>Note:</strong> String slices cannot be logged directly. Use the <code>__to_str_array()</code> function to convert it to a <code>str[N]</code> first.</p>
</blockquote>

</main>
Expand Down
2 changes: 1 addition & 1 deletion master/calling-contracts/tx-dependency-estimation.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h1 id="transaction-dependency-estimation"><a class="header" href="#transaction-

assert!(matches!(
response,
Err(Error::RevertTransactionError { .. })
Err(Error::Transaction(Reason::Reverted { .. }))
));
</code></pre>
<p>As mentioned in previous chapters, you can specify the external contract with <code>.with_contracts()</code> and add an output variable with <code>append_variable_outputs()</code> to resolve this:</p>
Expand Down
10 changes: 4 additions & 6 deletions master/connecting/external-node.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ <h1 id="connecting-to-the-testnet-or-an-external-node"><a class="header" href="#
let provider = Provider::connect(&quot;beta-4.fuel.network&quot;).await.unwrap();

// Setup a private key
let secret =
SecretKey::from_str(&quot;a1447cd75accc6b71a976fd3401a1f6ce318d27ba660b0315ee6ac347bf39568&quot;)
.unwrap();
let secret = SecretKey::from_str(
&quot;a1447cd75accc6b71a976fd3401a1f6ce318d27ba660b0315ee6ac347bf39568&quot;,
)?;

// Create the wallet
let wallet = WalletUnlocked::new_from_private_key(secret, Some(provider));
Expand All @@ -172,9 +172,7 @@ <h1 id="connecting-to-the-testnet-or-an-external-node"><a class="header" href="#
<p><a href="https://fuellabs.github.io/block-explorer-v2">block-explorer</a></p>
</blockquote>
<p>If you want to connect to another node just change the URL or IP and port. For example, to connect to a local node that was created with <code>fuel-core</code> you can use:</p>
<pre><code class="language-rust ignore"> let _provider = Provider::connect(format!(&quot;127.0.0.1:{port}&quot;))
.await
.unwrap();
<pre><code class="language-rust ignore"> let _provider = Provider::connect(format!(&quot;127.0.0.1:{port}&quot;)).await?;
</code></pre>

</main>
Expand Down
4 changes: 1 addition & 3 deletions master/cookbook/deposit-and-withdraw.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ <h1 id="deposit-and-withdraw"><a class="header" href="#deposit-and-withdraw">Dep
</code></pre>
<p>Next, we set up a wallet with custom-defined assets. We give our wallet some of the contracts <code>BASE_TOKEN</code> and the default asset (required for contract deployment):</p>
<pre><code class="language-rust ignore"> let base_asset_id: AssetId =
&quot;0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c&quot;
.parse()
.unwrap();
&quot;0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c&quot;.parse()?;

let asset_ids = [AssetId::default(), base_asset_id];
let asset_configs = asset_ids
Expand Down
2 changes: 1 addition & 1 deletion master/cookbook/transfer-all-assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h1 id="transfer-all-assets"><a class="header" href="#transfer-all-assets">Trans
let mut inputs = vec![];
let mut outputs = vec![];
for (id_string, amount) in balances {
let id = AssetId::from_str(&amp;id_string).unwrap();
let id = AssetId::from_str(&amp;id_string)?;

// leave the base asset to cover transaction fees
if id == BASE_ASSET_ID {
Expand Down
40 changes: 18 additions & 22 deletions master/deploying/interacting-with-contracts.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,26 @@ <h1 class="menu-title">The Fuel Rust SDK</h1>
<main>
<h1 id="interacting-with-contracts"><a class="header" href="#interacting-with-contracts">Interacting with contracts</a></h1>
<p>If you already have a deployed contract and want to call its methods using the SDK, but without deploying it again, all you need is the contract ID of your deployed contract. You can skip the whole deployment setup and call <code>::new(contract_id, wallet)</code> directly. For example:</p>
<pre><code class="language-rust ignore"> abigen!(Contract(
name = &quot;MyContract&quot;,
// Replace with your contract ABI.json path
abi =
&quot;packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json&quot;
));
let wallet_original = launch_provider_and_get_wallet().await?;

let wallet = wallet_original.clone();
// Your bech32m encoded contract ID.
let contract_id: Bech32ContractId =
&quot;fuel1vkm285ypjesypw7vhdlhnty3kjxxx4efckdycqh3ttna4xvmxtfs6murwy&quot;
.parse()
.expect(&quot;Invalid ID&quot;);

let connected_contract_instance = MyContract::new(contract_id, wallet);
// You can now use the `connected_contract_instance` just as you did above!
<pre><code class="language-rust ignore"> abigen!(Contract(
name = &quot;MyContract&quot;,
// Replace with your contract ABI.json path
abi = &quot;packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json&quot;
));
let wallet_original = launch_provider_and_get_wallet().await?;

let wallet = wallet_original.clone();
// Your bech32m encoded contract ID.
let contract_id: Bech32ContractId =
&quot;fuel1vkm285ypjesypw7vhdlhnty3kjxxx4efckdycqh3ttna4xvmxtfs6murwy&quot;.parse()?;

let connected_contract_instance = MyContract::new(contract_id, wallet);
// You can now use the `connected_contract_instance` just as you did above!
</code></pre>
<p>The above example assumes that your contract ID string is encoded in the <code>bech32</code> format. You can recognize it by the human-readable-part &quot;fuel&quot; followed by the separator &quot;1&quot;. However, when using other Fuel tools, you might end up with a hex-encoded contract ID string. In that case, you can create your contract instance as follows:</p>
<pre><code class="language-rust ignore"> let contract_id: ContractId =
&quot;0x65b6a3d081966040bbccbb7f79ac91b48c635729c59a4c02f15ae7da999b32d3&quot;
.parse()
.expect(&quot;Invalid ID&quot;);
let connected_contract_instance = MyContract::new(contract_id, wallet);
<pre><code class="language-rust ignore"> let contract_id: ContractId =
&quot;0x65b6a3d081966040bbccbb7f79ac91b48c635729c59a4c02f15ae7da999b32d3&quot;.parse()?;

let connected_contract_instance = MyContract::new(contract_id, wallet);
</code></pre>
<p>You can learn more about the Fuel SDK <code>bech32</code> types <a href="../types/bech32.html">here</a>.</p>

Expand Down
12 changes: 3 additions & 9 deletions master/predicates/send-spend-predicate.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,13 @@ <h1 id="signatures-in-predicates-example"><a class="header" href="#signatures-in
</code></pre>
<p>Let's use the SDK to interact with the predicate. First, let's create three wallets with specific keys. Their hashed public keys are already hard-coded in the predicate. Then we create the receiver wallet, which we will use to spend the predicate funds.</p>
<pre><code class="language-rust ignore"> let secret_key1: SecretKey =
&quot;0x862512a2363db2b3a375c0d4bbbd27172180d89f23f2e259bac850ab02619301&quot;
.parse()
.unwrap();
&quot;0x862512a2363db2b3a375c0d4bbbd27172180d89f23f2e259bac850ab02619301&quot;.parse()?;

let secret_key2: SecretKey =
&quot;0x37fa81c84ccd547c30c176b118d5cb892bdb113e8e80141f266519422ef9eefd&quot;
.parse()
.unwrap();
&quot;0x37fa81c84ccd547c30c176b118d5cb892bdb113e8e80141f266519422ef9eefd&quot;.parse()?;

let secret_key3: SecretKey =
&quot;0x976e5c3fa620092c718d852ca703b6da9e3075b9f2ecb8ed42d9f746bf26aafb&quot;
.parse()
.unwrap();
&quot;0x976e5c3fa620092c718d852ca703b6da9e3075b9f2ecb8ed42d9f746bf26aafb&quot;.parse()?;

let mut wallet = WalletUnlocked::new_from_private_key(secret_key1, None);
let mut wallet2 = WalletUnlocked::new_from_private_key(secret_key2, None);
Expand Down
Loading

0 comments on commit 9b3dbbb

Please sign in to comment.