Skip to content

Commit

Permalink
improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
wasm-forge committed Nov 1, 2024
1 parent 56942a1 commit 408b54d
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,34 @@ wasi2ic <input-wasm-file> <output_wasm_file>
This command reads the input Wasm file, removes WASI dependencies, and reroutes WASI calls to their IC-specific
implementations. Note that the polyfill implementation must be present in your Wasm binary.

To include the polyfill implementation in your Canister project, add the ic-wasi-polyfill dependency to your project.
To include the polyfill implementation in your Canister project, add the ic-wasi-polyfill dependency in it:
```bash
cargo add ic-wasi-polyfill
```

Also you will need to add the initialization call to the polyfill library, basic example using memory manager:

```rust
use ic_stable_structures::{memory_manager::MemoryManager, DefaultMemoryImpl};
use std::cell::RefCell;

thread_local! {
// The memory manager enables multiple virtual memories in one.
static MEMORY_MANAGER: RefCell<MemoryManager<DefaultMemoryImpl>> =
RefCell::new(MemoryManager::init(DefaultMemoryImpl::default()));
}

#[ic_cdk::init]
fn init() {
MEMORY_MANAGER.with(|m| {
let m = m.borrow();
ic_wasi_polyfill::init_with_memory_manager(&[0u8; 32], &[], &m, 200..210);
});
}
```


For more information, check out our [examples repository](https://github.com/wasm-forge/examples).
For more detailed information, see our [examples repository](https://github.com/wasm-forge/examples).


## Related repositories
Expand All @@ -41,4 +66,4 @@ For more information, check out our [examples repository](https://github.com/was
| --------------------------------------------- | ----------------------------- |
| [ic-wasi-polyfill](https://github.com/wasm-forge/ic-wasi-polyfill) | Polyfill library implementing the low-level WASI calls. |
| [stable-fs](https://github.com/wasm-forge/stable-fs) | Simple file system implementation based on the stable structures. The file system implements backend for the ic-wasi-polyfill |
| [examples](https://github.com/wasm-forge/examples) | Repository containing various examplpes of runnig WASI projects on the IC. |
| [examples](https://github.com/wasm-forge/examples) | Repository containing various examplpes of running WASI projects on the IC. |

0 comments on commit 408b54d

Please sign in to comment.