Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions scripts/boilerplate.fe
Original file line number Diff line number Diff line change
Expand Up @@ -68,46 +68,11 @@ mod _boilerplate {
pub fn ecrecover(_ hash: u256, _ v: u8, _ r: u256, _ s: u256) -> Address { todo() }
pub fn block_hash(_ number: u256) -> u256 { todo() }

// Address type stub
pub struct Address { inner: u256 }
impl Address {
pub fn zero() -> Self { Address { inner: 0 } }
pub fn encode<E>(own self, _ e: mut E) { todo() }
pub fn decode<D>(_ d: mut D) -> Self { todo() }
pub fn as_topic(self) -> u256 { self.inner }
}
impl core::abi::Encode<std::abi::Sol> for Address {
fn encode<E: core::abi::AbiEncoder<std::abi::Sol>>(own self, _ e: mut E) { todo() }
}
impl core::abi::Decode<std::abi::Sol> for Address {
fn decode<D: core::abi::AbiDecoder<std::abi::Sol>>(_ d: mut D) -> Self { todo() }
}
impl std::abi::SolCompat for Address {
type S = String<7>
const SOL_TYPE: Self::S = "address"
}
impl Copy for Address {}
impl core::ops::Eq for Address {
fn eq(self, _ other: Self) -> bool { todo() }
}

// Assert function stub - uses fixed String<256> which can accept smaller string literals
pub fn assert(cond: bool, message: String<256>) { todo() }

// Note: revert is re-exported from core above

// Option enum for optional values
pub enum Option<T> {
Some(T),
None,
}

// Result enum for error handling
pub enum Result<T, E> {
Ok(T),
Err(E),
}

// Common trait stubs
pub trait Hashable {
fn hash(self) -> u256
Expand Down
2 changes: 0 additions & 2 deletions src/content/docs/appendix/from-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ Optional values use `Option<T>`:

```fe
//<hide>
use _boilerplate::Option

fn example() -> u256 {
//</hide>
let maybe: Option<u256> = Option::Some(42)
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/appendix/from-solidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function transfer(...) {
**Fe**:
```fe
//<hide>
use _boilerplate::{Address, Log}
use _boilerplate::Log
//</hide>
#[event]
struct Transfer {
Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/appendix/intrinsics.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ These intrinsics provide information about the execution context:

```fe
//<hide>
use _boilerplate::{Ctx, Address, assert}
use _boilerplate::{Ctx, assert}
//</hide>

fn only_owner(owner: Address) uses (ctx: Ctx) {
Expand Down Expand Up @@ -54,7 +54,7 @@ These intrinsics relate to contract state and identity:

```fe
//<hide>
use _boilerplate::{Address, self_balance, code_size}
use _boilerplate::{self_balance, code_size}
//</hide>

fn get_contract_balance() -> u256 {
Expand All @@ -81,7 +81,7 @@ Hash functions and cryptographic operations:

```fe
//<hide>
use _boilerplate::{Address, keccak256, ecrecover}
use _boilerplate::{keccak256, ecrecover}
//</hide>

fn hash_value(value: u256) -> u256 {
Expand Down Expand Up @@ -186,7 +186,7 @@ Event emission:

```fe
//<hide>
use _boilerplate::{Address, Log}
use _boilerplate::Log
//</hide>
#[event]
struct TransferEvent {
Expand Down
2 changes: 0 additions & 2 deletions src/content/docs/appendix/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ Represents an optional value:

```fe
//<hide>
use _boilerplate::Option

fn example() -> u256 {
//</hide>
let maybe_value: Option<u256> = Option::Some(42)
Expand Down
1 change: 0 additions & 1 deletion src/content/docs/effects/built-in.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ Structs can serve as effects, allowing you to inject behavior:

```fe
//<hide>
use _boilerplate::Option
//</hide>
// Define a validator effect
pub struct RangeValidator {
Expand Down
12 changes: 6 additions & 6 deletions src/content/docs/events/emitting.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Emit an event through a Log effect:

```fe
//<hide>
use _boilerplate::{Log}
use _boilerplate::Log
//</hide>


Expand Down Expand Up @@ -78,7 +78,7 @@ A critical pattern: emit events after state changes succeed, not before:

```fe
//<hide>
use _boilerplate::{Map, Log}
use _boilerplate::Map
pub struct TokenStorage { pub balances: Map<u256, u256> }
#[event]
struct Transfer {
Expand Down Expand Up @@ -161,7 +161,7 @@ Emit different event types from the same handler:

```fe
//<hide>
use _boilerplate::{Map, Log}
use _boilerplate::Map
pub struct TokenStorage {
pub balances: Map<u256, u256>,
pub allowances: Map<u256, Map<u256, u256>>,
Expand Down Expand Up @@ -221,7 +221,7 @@ Emit when persistent state changes:

```fe
//<hide>
use _boilerplate::{Map, Log}
use _boilerplate::Map
pub struct TokenStorage {
pub balances: Map<u256, u256>,
pub total_supply: u256,
Expand Down Expand Up @@ -303,7 +303,7 @@ Create helper functions for common events:

```fe
//<hide>
use _boilerplate::{Map, Log}
use _boilerplate::Map
pub struct TokenStorage { pub balances: Map<u256, u256> }
#[event]
struct Transfer {
Expand Down Expand Up @@ -350,7 +350,7 @@ Only emit when something meaningful happens:

```fe
//<hide>
use _boilerplate::{Map, Log}
use _boilerplate::Map
pub struct TokenStorage { pub allowances: Map<u256, Map<u256, u256>> }
#[event]
struct Approval {
Expand Down
1 change: 0 additions & 1 deletion src/content/docs/examples/erc20.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ struct ApprovalEvent {

//<hide>
// stubs for missing std lib stuff
use _boilerplate::Address

extern {
fn assert(_: bool, _: String<64>)
Expand Down
2 changes: 0 additions & 2 deletions src/content/docs/foundations/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ Use `_` to match any value you don't need:

```fe
//<hide>
use _boilerplate::Result

fn use_value(v: u256) { let _ = v }
fn handle_error() {}

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/traits/bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn find<T: Comparable>(items: Array<T>, target: T) -> bool {

```fe
//<hide>
use _boilerplate::{Option, Default}
use _boilerplate::Default
//</hide>
trait Default {
fn default() -> Self
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/traits/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ let _ = (x, y)

```fe
//<hide>
use _boilerplate::{Option, Default}
use _boilerplate::Default
//</hide>
fn or_default<T: Default>(value: own Option<T>) -> T {
match value {
Expand Down
1 change: 0 additions & 1 deletion src/examples/landing-page.fe
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub contract GuestBook uses (ctx: Ctx, log: mut Log) {
}

// Stubs for type checking (not shown on landing page)
use _boilerplate::Address

pub struct Ctx {}
impl Ctx {
Expand Down