Skip to content

Conversation

@anegg0
Copy link
Contributor

@anegg0 anegg0 commented Dec 13, 2025

Alternative Stylus docs version

docs/stylus/
│
├── gentle-introduction.mdx
├── quickstart.mdx
├── using-cli.mdx (legacy)
│
├── fundamentals/
│   ├── _category_.yml
│   ├── choose-your-path.mdx [NEW - Phase 4]
│   ├── prerequisites.mdx [Phase 3]
│   ├── project-structure.mdx
│   ├── contracts.mdx [DIAGRAM: Lifecycle]
│   ├── global-variables-and-functions.mdx
│   ├── testing-contracts.mdx
│   └── data-types/
│       ├── primitives.mdx
│       ├── compound-types.mdx
│       ├── storage.mdx [DIAGRAMS: Hierarchy + Layout]
│       └── conversions-between-types.mdx
│
├── guides/
│   ├── _category_.yml
│   ├── using-constructors.mdx
│   ├── using-inheritance.mdx
│   ├── importing-interfaces.mdx [DIAGRAM: Cross-Contract Calls]
│   ├── exporting-abi.mdx
│   ├── optimizing-binaries.mdx
│   ├── caching-contracts.mdx
│   ├── deploying-non-rust-wasm-contracts.mdx
│   └── adding-support-for-new-languages.mdx
│
├── cli-tools/
│   ├── _category_.yml
│   ├── overview.mdx
│   ├── check-and-deploy.mdx
│   ├── verify-contracts.mdx
│   ├── debugging-tx.mdx
│   └── commands-reference.mdx
│
├── best-practices/ [NEW - Phase 4]
│   ├── _category_.yml
│   ├── security.mdx (501 lines)
│   └── gas-optimization.mdx [DIAGRAM: Performance Comparison] (548 lines)
│
├── troubleshooting/ [NEW - Phase 4]
│   ├── _category_.yml
│   ├── common-issues.mdx (591 lines)
│   └── troubleshooting-building-stylus.md (legacy)
│
├── concepts/
│   ├── _category_.yml
│   ├── webassembly.mdx [DIAGRAMS: Pipeline + Binary + Memory]
│   ├── activation.mdx [DIAGRAM: Deployment]
│   ├── gas-metering.mdx
│   ├── vm-differences.mdx (renamed in Phase 3)
│   └── public-preview-expectations.mdx
│
├── advanced/
│   ├── _category_.yml
│   ├── rust-to-solidity-differences.mdx (renamed in Phase 3)
│   ├── minimal-entrypoint-contracts.mdx
│   ├── hostio-exports.mdx
│   └── recommended-libraries.mdx
│
├── reference/
│   ├── _category_.yml
│   ├── overview.mdx
│   ├── opcode-hostio-pricing.mdx
│   └── rust-sdk-guide.md
│
├── partials/ (Reusable Content)
│   ├── _setup-rust-toolchain.mdx
│   ├── _setup-cargo-stylus.mdx
│   ├── _setup-docker-nitro.mdx
│   ├── _stylus-faucets.mdx
│   ├── _stylus-no-multi-inheritance-banner-partial.mdx
│   └── _stylus-public-preview-banner-partial.md

anegg0 and others added 30 commits November 12, 2025 14:31
Add lint:markdown:fix to the format script to automatically fix
markdown linting issues when running yarn format. This ensures
markdown files are both formatted (prettier) and linted (markdownlint)
in one command.

The new format workflow:
1. Format docs with prettier
2. Format app files with prettier
3. Auto-fix markdown linting issues
4. Verify all files pass prettier check
Add detailed documentation for all Stylus SDK primitive types including:
- Boolean (bool) with usage examples and Solidity mappings
- Unsigned integers (u8-u128, U256, Uint<BITS, LIMBS>)
- Signed integers (i8-i128, I256, Signed<BITS, LIMBS>)
- Address type with constants and validation examples
- String type with literal and formatting examples
- Bytes types (dynamic Bytes and fixed FixedBytes<N>)
- Hex literal usage examples
- Complete type mapping tables for all primitives
- Best practices for each primitive type
- Type conversion examples

Each section includes:
- Practical code examples
- Solidity type mappings
- Storage size information
- ABI signature details
- Common usage patterns
Add detailed documentation for all Stylus SDK compound types including:
- Tuples with destructuring and pattern matching examples
- Structs using sol! macro with AbiType derivation
- Nested structs for complex data structures
- Fixed-size arrays with iteration and operations
- Vectors (dynamic arrays) with filter, map, and fold operations
- Bytes types (dynamic Bytes and fixed FixedBytes<N>)
- Complete type mapping tables for all compound types
- Best practices for each compound type
- Type conversion helpers and iterator patterns
- Common patterns (batch operations, pagination)

Each section includes:
- Practical code examples from SDK examples
- Solidity type mappings
- ABI signature details
- Memory and gas efficiency considerations
- Complete working examples with nested structures
- Iterator and functional programming patterns
Add detailed documentation for all Stylus SDK storage types including:
- Storage overview and EVM State Trie interoperability
- Storage primitives (StorageBool, StorageUint, StorageAddress, FixedBytes)
- Integer update operations (wrapping and checked)
- Storage collections (StorageVec, StorageArray, StorageMap)
- StorageString and StorageBytes for dynamic data
- Storage structs with nested structures
- Complete type mapping tables
- Storage patterns (initialization, counter, access control, registry)
- Best practices for storage operations
- Storage slots and layout explanation
- Complete working token example

Each section includes:
- Practical code examples from SDK examples
- Method signatures and usage patterns
- Solidity equivalents and mappings
- Gas optimization guidance
- Common design patterns
- Best practices for efficient storage use
Add comprehensive documentation for Stylus contracts covering:

- Contract basics and minimal contract structure
- Storage definition with sol_storage! and #[storage]
- #[entrypoint] macro and TopLevelStorage trait
- #[public] macro for exposing methods
- State mutability inference (view, write, pure)
- Constructor with #[constructor] attribute
- Method attributes: #[payable], #[receive], #[fallback], #[selector]
- Trait-based contract composition with #[implements]
- Accessing VM context via self.vm()
- Events definition and emission with sol! macro
- External contract calls with sol_interface!
- Call configurations (view, mutating, payable, gas)
- Low-level calls (call, static_call, RawCall)
- Error handling with SolidityError
- Complete ERC-20 example demonstrating all features
- Best practices for state mutability, validation, errors, events, access control, gas optimization, CEI pattern, and type-safe interfaces

All code examples are based on actual SDK implementation from stylus-sdk-rs repository.
Add comprehensive documentation for global variables and functions accessible via self.vm() in Stylus contracts:

- Message context: msg_sender(), msg_value(), msg_reentrant()
- Transaction context: tx_origin(), tx_gas_price(), tx_ink_price()
- Block context: block_number(), block_timestamp(), block_basefee(), block_coinbase(), block_gas_limit()
- Chain context: chain_id()
- Account information: contract_address(), balance(), code(), code_size(), code_hash()
- Gas and metering: evm_gas_left(), evm_ink_left(), ink_to_gas(), gas_to_ink()
- Cryptographic functions: crypto::keccak(), native_keccak256()
- Event logging: log(), raw_log()
- Storage operations: storage_load_bytes32(), flush_cache()
- Memory management: pay_for_memory_grow()

Each section includes:
- Method signatures
- Solidity equivalents
- Practical code examples
- Important notes and caveats
- Arbitrum-specific behavior details

Complete example contract demonstrating usage of all major VM methods, plus a summary table of all available methods.

All code examples based on actual SDK implementation from stylus-sdk-rs repository.
The FloatingHoverModal component was wrapping pre-compiled MDX components in an MDXProvider, which caused React hook violations. The MDXProvider tried to establish new context outside the Docusaurus DocsVersionProvider hierarchy, resulting in "Hook useDocsVersion is called outside the <DocsVersionProvider>" error.

Fixed by:
- Removing the unnecessary MDXProvider wrapper
- Removing the mdxComponents object mapping (not needed for pre-compiled MDX)
- Rendering ContentComponent directly, which preserves Docusaurus context

Root cause: Pre-compiled MDX components don't need MDXProvider re-wrapping, and doing so breaks context inheritance from Docusaurus theme providers.
…ontext chain

HeaderBadges was wrapped in BrowserOnly which created a context boundary during hydration, breaking the DocsVersionProvider context for all doc pages. This caused 'Hook useDocsVersion is called outside provider' errors.

Fixed by using useEffect to set href client-side while always rendering the same DOM structure, preventing hydration mismatches and preserving context.
…ortWidget

The BrowserOnly callback had no return statement, causing hydration mismatches. Replaced with useEffect hook for proper side-effect handling.
The BrowserOnly callback had no return statement, causing hydration mismatches. Replaced with useEffect hook for proper side-effect handling.
Pre-compiled MDX components don't need MDXProvider re-wrapping. Removed unnecessary wrapper and components object to prevent context chain interruption.
Removed reference to deleted sync-stylus-content.js script from package.json build command
Upgraded from 3.6.3 to address potential context provider bugs
@anegg0 anegg0 marked this pull request as ready for review December 18, 2025 03:29
@anegg0 anegg0 requested a review from Copilot December 18, 2025 03:29
@anegg0 anegg0 marked this pull request as draft December 18, 2025 03:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 123 out of 148 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

slop starter Generated draft to start from

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants