Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justblender/candid-parser-wasm
JavaScript/TypeScript bindings for "candid_parser", compiled to WebAssembly
https://github.com/justblender/candid-parser-wasm
candid candid-parser icp internet-computer wasm webassembly
Last synced: 5 days ago
JSON representation
JavaScript/TypeScript bindings for "candid_parser", compiled to WebAssembly
- Host: GitHub
- URL: https://github.com/justblender/candid-parser-wasm
- Owner: justblender
- Created: 2024-02-11T14:40:50.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-13T17:25:31.000Z (9 months ago)
- Last Synced: 2024-08-02T06:16:48.194Z (3 months ago)
- Topics: candid, candid-parser, icp, internet-computer, wasm, webassembly
- Language: Rust
- Homepage: https://www.npmjs.com/package/candid-parser-wasm
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-internet-computer - candid-parser-wasm - JavaScript/TypeScript bindings for "candid_parser", compiled to WebAssembly. (Candid / Candid implementations)
README
# candid-parser-wasm
This package provides bindings to (and helper functions for) the `candid_parser` crate.
![version][version-image]
![downloads][dl-image]## Features
- Read all actor functions along with their signature (mode, argument and return types);
- Encode or decode the arguments of a (shared) actor function into `Uint8Array` or `string`;
- Serialize Candid into a JSON string.## Installation
`npm install candid-parser-wasm`
## Usage
> [!IMPORTANT]
> Before you can use this library in your Vite app, it is recommended that you first install `vite-plugin-wasm`.```js
import { parseCandid } from "candid-parser-wasm";// TIP: You can use `fetchCandid` from `@dfinity/agent`
// to fetch Candid source for a given canister ID on-demand.const parser = parseCandid(`
service : {
hello : (text) -> (text) query;
};
`);const encoded: Uint8Array = parser.encodeIdlArgs("hello", '("world")');
// ^ `Uint8Array` with encoded bytesconst decoded: string = parser.decodeIdlArgs("hello", encoded);
// ^ ("world")const functions: Record = parser.getFunctions();
// ^ { hello: {modes: [{ kind: "query" }], args: ["text"], rets: ["text"]} }const json: string = parser.toJSON();
// ^ fully serialized IDL in a JSON string
```## Contributing
Contributions are welcome. Please submit your pull requests or open issues to propose changes or report bugs.
[version-image]: https://img.shields.io/npm/v/candid-parser-wasm
[dl-image]: https://img.shields.io/npm/dw/candid-parser-wasm