Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Fuel Rust SDK book to match latest development #258

Merged
merged 4 commits into from
May 6, 2022

Conversation

digorithm
Copy link
Member

Updates the mdbook to include and match all that's new to the SDK.

@digorithm digorithm added the documentation Improvements or additions to documentation label May 5, 2022
@digorithm digorithm self-assigned this May 5, 2022
docs/src/getting-started/basics.md Outdated Show resolved Hide resolved
Comment on lines 95 to 98
pub const DEFAULT_GAS_LIMIT: u64 = 1_000_000;
pub const DEFAULT_GAS_PRICE: u64 = 0;
pub const DEFAULT_BYTE_PRICE: u64 = 0;
pub const DEFAULT_MATURITY: u32 = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unmaintainable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just permalink to the source file? And add extensive docstrings to the constants.

docs/src/getting-started/setup.md Outdated Show resolved Hide resolved
## Calling and configuring contract calls

Once you've deployed your contract, as seen in the previous section, you'll likely want to call contract methods and configure some parameters such as gas price, byte price, gas limit, and forward coins in your contract call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contract_instance seems to appear out of nowhere, maybe include something like:

Suggested change
Start by creating an instance of `MyContract`:
```Rust
let contract_instance = MyContract::new(contract_id.to_string(), provider, wallet);
```

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a great point, thanks!

// this is a big number for checking that amount can be a u64
let call_params = CallParameters::new(Some(1_000_000), None);

let response = instance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency nitpick

Suggested change
let response = instance
let response = contract_instance

let address = wallet.address();

// withdraw some tokens to wallet
instance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instance
contract_instance

MujkicA
MujkicA previously approved these changes May 6, 2022

### Contract calls calling other contracts

Sometimes, you might need to call your contract, which calls other contracts. To do so, you must feed the external contract IDs that your contract depends on to the method you're calling. You do it by chaining `.set_contracts(&[external_contract_id, ...])` to the method you want to call. For instance:

```Rust
let response = my_contract
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let response = my_contract
let response = contract_instance

iqdecay
iqdecay previously approved these changes May 6, 2022
Copy link
Contributor

@iqdecay iqdecay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@digorithm digorithm dismissed stale reviews from iqdecay and MujkicA via d7ea495 May 6, 2022 17:04
let (provider, wallet) = setup_test_provider_and_wallet().await;

// Load the compiled Sway contract (this is the output from `forc build`)
let compiled = Contract::load_sway_contract(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should include in the documentation for the new function load_sway_contract_with_salt() and how and when to use it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point! As we discussed earlier, I'll add this (and some other wallet-related stuff) on the next batch of doc updates -- I'm trying to keep this one bite-sized.

@adlerjohn
Copy link
Contributor

:shipit:

@digorithm digorithm merged commit c52a48d into master May 6, 2022
@digorithm digorithm deleted the rodrigo/mdbook-update branch May 6, 2022 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants