Skip to content

refactor: reduce wrapper boilerplate with macros #25

@darioAnongba

Description

@darioAnongba

Summary

Each BDK type wrapper requires ~50-100 lines of repetitive boilerplate (struct definition, From/Into impls, wasm_bindgen getters/setters). Investigate if procedural or declarative macros can reduce this.

Current Pattern

#[wasm_bindgen]
pub struct WasmType(BdkType);

impl From<BdkType> for WasmType { ... }
impl From<WasmType> for BdkType { ... }

#[wasm_bindgen]
impl WasmType {
    #[wasm_bindgen(getter)]
    pub fn field(&self) -> ... { self.0.field.into() }
    // ... repeat for every field
}

Tasks

  • Analyze which parts of the pattern are truly repetitive
  • Prototype a declarative macro for simple field-forwarding wrappers
  • Evaluate if a proc macro is worth the complexity
  • Ensure generated code still produces clean TypeScript bindings
  • Refactor existing types to use the macro where beneficial

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions