https://github.com/lukateras/ts-concordium-schema
Concordium contract schema parser for Node.js in TypeScript
https://github.com/lukateras/ts-concordium-schema
concordium nodejs npm-package smart-contracts typescript
Last synced: 8 months ago
JSON representation
Concordium contract schema parser for Node.js in TypeScript
- Host: GitHub
- URL: https://github.com/lukateras/ts-concordium-schema
- Owner: lukateras
- License: mpl-2.0
- Created: 2022-01-10T23:23:33.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-05T02:33:24.000Z (almost 3 years ago)
- Last Synced: 2025-02-22T01:35:11.541Z (8 months ago)
- Topics: concordium, nodejs, npm-package, smart-contracts, typescript
- Language: TypeScript
- Homepage:
- Size: 84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Concordium Schema
Node.js TypeScript library for deserializing [Concordium](https://github.com/Concordium) contract schemas.
Fully compatible with [`concordium-std::schema` v2.0.0](https://docs.rs/concordium-std/2.0.0/concordium_std/schema/index.html).
This project has been commissioned by [Blocktech.dk](https://www.blocktech.dk).
## Documentation
You can read the latest documentation at .
## Installation
This NPM package is privately published using [GitHub Packages](https://github.com/features/packages).
To install it for use with your NPM project, first associate `@transumption`
package scope with GitHub Packages NPM registry:
```sh
$ npm config --userconfig .npmrc set @transumption:registry https://npm.pkg.github.com
```
Next, authenticate with the NPM registry. You will have to enter your GitHub
username, personal access token with `repo` and `read:packages` access scopes
([get one here](https://github.com/settings/tokens)), and public email address.
```sh
$ npm login --scope=@transumption --registry=https://npm.pkg.github.com
Username:
Password:
Email:
```
And finally, add the NPM package to `package.json`:
```sh
$ npm install --save @transumption/concordium-schema
```
## Usage
Here's how you can deserialize a Concordium contract schema module file:
```ts
import * as fs from 'fs';
import { deserialModule } from '@transumption/concordium-schema';
const stream = fs.createReadStream('schema.bin');
stream.on('readable', () => {
const schema = deserialModule(stream);
// ...
stream.destroy();
});
```
This package's type definitions closely follow the Rust implementation.
If you are familiar with `concordium_std` crate, you will feel right at home :)
Functions starting with `deserial` accept a Node.js [Readable][] stream as the
only parameter, and return a value of the type that comes after `deserial`
(for example, `deserialModule` returns a `Module`).
I recommend looking at the [documentation](#documentation) if you get stuck!
[Readable]: https://nodejs.org/api/stream.html#class-streamreadable