Update Stylus how-to guides for SDK 0.10.7#3410
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
EmreDincoglu
left a comment
There was a problem hiding this comment.
I will continue the review on monday, but as of right now either stylus is just super hard to use or there is just a lot of changes that make previous things work no longer work
|
the updated code all seems to work, given the things I mentioned in the parts that were not updated (I went through the doc to learn and test thats how I caught it) |
Co-authored-by: Emre Dincoglu <85258206+EmreDincoglu@users.noreply.github.com>
Yes, same assessment here. There are quite a few things that have changed lately. |
Co-authored-by: Emre Dincoglu <85258206+EmreDincoglu@users.noreply.github.com>
| use stylus_sdk::prelude::*; | ||
|
|
||
| sol! { | ||
| error InsufficientBalance(address account, uint256 requested, uint256 available); | ||
| error Unauthorized(address caller); | ||
| error InvalidAmount(); | ||
| } | ||
|
|
||
| #[public] | ||
| impl Token { | ||
| pub fn transfer(&mut self, to: Address, amount: U256) -> Result<(), InsufficientBalance> { | ||
| let sender = self.vm().msg_sender(); | ||
| let balance = self.balances.get(sender); | ||
| if balance < amount { | ||
| return Err(InsufficientBalance { | ||
| account: sender, | ||
| requested: amount, | ||
| available: balance, | ||
| }); | ||
| } | ||
| // Transfer logic | ||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
This gotta be deleted, I cant add a suggestion due to the GH bug I was talking abt, I tried doing the suggestion removing all the lines in this chunk makes GH think im trying to delete other lines
There was a problem hiding this comment.
I made a few more changes; this should compile.
Please let me know if that's acceptable.
Stylus docs update — part of a small set of PRs (tagged
stylus) bringingdocs/stylus/in line with the current stack (stylus-sdk / cargo-stylus 0.10.7, Nitro v3.11.0).how-tos/exporting-abi.mdx— remove phantom CLI (export-abi constructor,--license,--pragma); documentcargo stylus constructor.how-tos/using-constructors.mdx— fix the event-emission API; add--constructor-valuefor payable constructors.how-tos/trait-based-composition.mdx— add required#[public]on interface traits; modernize the selector example.Examples verified against the live toolchain (compiled/deployed on a local Nitro dev node where relevant) and conceptual claims against the Nitro source. Builds clean (
yarn build, strictonBrokenLinks). Version strings are literals here; they are centralized intoglobalVars.jsin a follow-up PR.