-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
docs/src/getting-started/basics.md
Outdated
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unmaintainable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion...?
There was a problem hiding this comment.
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.
## 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. | ||
|
There was a problem hiding this comment.
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:
Start by creating an instance of `MyContract`: | |
```Rust | |
let contract_instance = MyContract::new(contract_id.to_string(), provider, wallet); | |
``` |
There was a problem hiding this comment.
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!
docs/src/getting-started/basics.md
Outdated
// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency nitpick
let response = instance | |
let response = contract_instance |
docs/src/getting-started/basics.md
Outdated
let address = wallet.address(); | ||
|
||
// withdraw some tokens to wallet | ||
instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance | |
contract_instance |
docs/src/getting-started/basics.md
Outdated
|
||
### 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let response = my_contract | |
let response = contract_instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
Updates the mdbook to include and match all that's new to the SDK.