Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wasm-forge/wasi2ic
WASI dependency replacer for the *.wasm files
https://github.com/wasm-forge/wasi2ic
infrastructure internet-computer polyfill tools wasi
Last synced: 5 days ago
JSON representation
WASI dependency replacer for the *.wasm files
- Host: GitHub
- URL: https://github.com/wasm-forge/wasi2ic
- Owner: wasm-forge
- License: mit
- Created: 2023-02-05T14:13:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T13:34:22.000Z (6 days ago)
- Last Synced: 2024-11-01T14:29:54.201Z (6 days ago)
- Topics: infrastructure, internet-computer, polyfill, tools, wasi
- Language: Rust
- Homepage:
- Size: 59.6 KB
- Stars: 25
- Watchers: 5
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-internet-computer - wasi2ic - Convert WASI binaries into binaries runnable on the IC. (Developer Tooling / AssemblyScript)
README
## wasi2ic: WASI Polyfill Tool
![Tests](https://github.com/wasm-forge/wasi2ic/actions/workflows/rust.yml/badge.svg?event=push)
[![Coverage](https://codecov.io/gh/wasm-forge/wasi2ic/graph/badge.svg?token=XE48Z6JSYS)](https://codecov.io/gh/wasm-forge/wasi2ic)`wasi2ic` is a command-line tool that replaces WebAssembly System Interface (WASI) specific function calls with their
corresponding polyfill implementations. This allows you to run Wasm binaries compiled for `wasm32-wasi` on the Internet
Computer.## Installation
Install `wasi2ic` using Cargo:
```bash
cargo install wasi2ic
```## Usage
Replace WASI dependencies in a Wasm file using:
```bash
wasi2ic
```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 in it:
```bash
cargo add ic-wasi-polyfill
```Also you will need to add the initialization call to the polyfill library, basic example featuring user memory manager:
```rust
use ic_stable_structures::{memory_manager::MemoryManager, DefaultMemoryImpl};
use std::cell::RefCell;thread_local! {
static MEMORY_MANAGER: RefCell> =
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 detailed information, see our [examples repository](https://github.com/wasm-forge/examples).
## Related repositories
| Repository | Description |
| --------------------------------------------- | ----------------------------- |
| [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 running WASI projects on the IC. |