{"id":24066324,"url":"https://github.com/rainlanguage/dotrain","last_synced_at":"2025-09-02T18:38:32.012Z","repository":{"id":73306042,"uuid":"564660211","full_name":"rainlanguage/dotrain","owner":"rainlanguage","description":".rain to rainlang composer and rain language server protocol services","archived":false,"fork":false,"pushed_at":"2025-08-15T12:06:55.000Z","size":20543,"stargazers_count":3,"open_issues_count":6,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-18T15:55:50.081Z","etag":null,"topics":["blockchain","ethereum","evm","lsp","lsp-server","rainlang","wasm","wasm-bindgen"],"latest_commit_sha":null,"homepage":"https://rainlang.xyz","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rainlanguage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-11T07:41:39.000Z","updated_at":"2025-08-15T12:06:59.000Z","dependencies_parsed_at":"2023-12-25T00:22:33.631Z","dependency_job_id":"5f0a7b50-4595-4ff7-8be9-145e3c32b43d","html_url":"https://github.com/rainlanguage/dotrain","commit_stats":null,"previous_names":["rainlanguage/rainlang","rainprotocol/rainlang"],"tags_count":93,"template":false,"template_full_name":null,"purl":"pkg:github/rainlanguage/dotrain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainlanguage%2Fdotrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainlanguage%2Fdotrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainlanguage%2Fdotrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainlanguage%2Fdotrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rainlanguage","download_url":"https://codeload.github.com/rainlanguage/dotrain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rainlanguage%2Fdotrain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273332595,"owners_count":25086959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","ethereum","evm","lsp","lsp-server","rainlang","wasm","wasm-bindgen"],"created_at":"2025-01-09T11:40:17.854Z","updated_at":"2025-09-02T18:38:31.958Z","avatar_url":"https://github.com/rainlanguage.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://raw.githubusercontent.com/rainlanguage/rain.brand/main/Rainlang%20lockup%20light.svg)\n\n# **Rain Language Composer and LSP**\nThe Rain language server protocol ([LSP](https://microsoft.github.io/language-server-protocol/)) services implementation (language services) and .rain composer written in rust and made available for NodeJs and broswers through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/) in Typescript/Javascript which makes it well suited for editors and IDEs (as it is used in Rainlang vscode and codemirror language extension).\n- Dotrain specs can be found [here](https://github.com/rainlanguage/specs/blob/main/dotrain.md)\n- Rainlang specs can be found [here](https://github.com/rainlanguage/specs/blob/main/rainlang.md)\n- Dotrain has been implemented for vscode and codemirror, see [rainlang-vscode](https://github.com/rainlanguage/rainlang-vscode) and [rainlang-codemirror](https://github.com/rainlanguage/rainlang-codemirror) repositories for more details.\n- Dotrain vscode extension can be found [here](https://marketplace.visualstudio.com/items?itemName=rainprotocol.rainlang-vscode).\n\nThe primary goal of the Rain language is to make smart contract development accessible for as many people as possible. This is fundamentally grounded in our belief that accessibility is the difference between theoretical and practical decentralisation. There are many people who would like to participate in authoring and auditing crypto code but currently cannot. When someone wants/needs to do something but cannot, then they delegate to someone who can, this is by definition centralisation.\n\nFor more info and details, please read this [article](https://hackmd.io/@REJeq0MuTUiqnjx9w5SsUA/HJj9s-nfi#Rainlang-has-a-spectrum-of-representations-from-concise-gtexplicit)\n\nIf you find an issue or you want to propose an improvement, please feel free to post it on: [issues](https://github.com/rainlanguage/dotrain/issues)\n\n---\n# **Tutorial**\n## **Javascript/Typescript**\nTo get started, install the package:\n```bash\nnpm install @rainlanguage/dotrain\n```\nor\n```bash\nyarn add @rainlanguage/dotrain\n```\n\u003cbr\u003e\n\n```typescript\n// imports\nimport { RainLanguageServices, MetaStore, TextDocumentItem } from \"@rainlanguage/dotrain\";\n\n// instantiate a MetaStore which is a in-memory CAS for Rain metadata\nconst metaStore = new MetaStore();\n\n// some text document\nconst textDocument = TextDocumentItem.create(\n  \"file:///file-name.rain\",\n  \"rainlang\",\n  0,\n  \"some dotrain text\"\n);\n\n// initiating the services (metaStore is optional)\nconst langServices = new RainLanguageServices(metaStore);\n\n// getting validation results (lsp Diagnostics)\nconst diagnostics = await langServices.doValidate(textDocument);\n\n// instantiate a new RainDocument\nconst rainDocument = await langServices.newRainDocument(textDocument)\n\n// composing a RainDocument to get rainlang string\nconst rainlangText = await rainDocument.compose([\"entrypoint-1\" , \"entrypoint-2\"]);\n```\n\u003cbr\u003e\n\n## **Rust**\n## dotrain crate\nTo get started, install the package:\n```bash\ncargo add dotrain\n```\n\n### Features\n- `cli`: A [clap](https://docs.rs/clap/latest/clap/) based module (CLI app) for functionalities of this library, this features is required for building the **binary**\n- `js-api`: includes wrappers around main structs and functionalities to provide an API through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/)\n\n\u003cbr\u003e\n\n```rust\nuse std::sync::{Arc, RwLock};\nuse dotrain::{Store, RainDocument};\n\nlet text = \"some text\".to_string();\n\n// instantiate arc locked Store\nlet meta_store = Arc::new(RwLock::new(Store::default()));\n\n// instantiate\nlet rain_document = RainDocument::new(text, Some(meta_store));\n\n// compose this instance of RainDocument to get rainlang string\nlet rainlang_text = rain_document.compose(\u0026vec![\"entrypoint1\", \"entrypoint2\"], None)?;\n```\n\u003cbr\u003e\n\n## dotrain_lsp crate\nTo get started, install the package:\n```bash\ncargo add dotrain-lsp\n```\n\n### Features\n- `js-api`: includes wrappers around main structs and functionalities to provide an API through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/)\n\n```rust\nuse std::sync::{Arc, RwLock};\nuse dotrain::{Store, RainLanguageServices, TextDocumentItem, LanguageServiceParams, RainDocument};\n\n// instantiate arc locked Store\nlet meta_store = Arc::new(RwLock::new(Store::default()));\n\n// the following needs 'lsp' feature to be enabled\nlet lang_params = LanguageServiceParams {\n  meta_store: Some(meta_store)\n}\n\n// a LSP TextdocumentItem\nlet text_document = TextDocumentItem {\n  uri,\n  text,\n  version: 0,\n  language_id: \"rainlang\".to_string()\n}\n\n// instantiate RainLanguageServices\nlet lang_services = RainLanguageServices::new(lang_params);\n\n// get LSP diagnostics of the given text document\nlet diagnostics = lang_services.do_validate(\u0026text_document, true);\n```\n\n## CLI\nThe CLI app can be built using nix (requires nix package manager to be installed):\n```bash\nnix build github:rainlanguage/dotrain\n```\nor installed with the following command from cargo:\n```bash\ncargo install dotrain\n```\n\nthis will install the dotrain binary in your path which then can be used to compose .rain files and generate outputs.\n\n### Examples\ncomposes a .rain file with specified entrypoints\n```bash\ndotrain compose --input path/to/some.rain --entrypoints first --entrypoints second\n```\noptionally, path to `rainconfig.json` can be provided:\n```bash\ndotrain -c path/to/rainconfig.json --input path/to/some.rain --entrypoints first --entrypoints second\n```\n\u003cbr\u003e\n\nDotrain cli is also available in [Rain CLI app](https://github.com/rainlanguage/rain.cli) which can be easily run with nix:\n```bash\nnix run github:rainlanguage/rain.cli -- --help\n```\n\u003cbr\u003e\n\n## **rainconfig**\nConfiguration details for .rain composer (source files and subgraphs).\nFollowing command will print info about rainconfig and its fields:\n```bash\ndotrain rainconfig \u003cCOMMAND\u003e\n```\nHere is an example of a `rainconfig.json`:\n```json\n{\n  \"include\": [\"./folder1\", \"./folder2\"],\n  \"subgraphs\": [\n    \"https://subgraph1-url\",\n    \"https://subgraph2-url\",\n    \"https://subgraph3-url\"\n  ]\n}\n```\n\n## **Building JS/TS Bindings**\nFrom the root of this repo, simply run the following to build the js bindings:\n```bash\nnix develop -c build-js-bindings\n```\n\nThis will build the rust library with `wasm32-unknown-unknown` target in release mode with `js-api` feature enabled and then generates bindings using `wasm-bindgen-cli` into `./dist` directory by encoding the wasm binary into a json as importing json is native in js/ts and eliminates the need for using fetch/fs operations when loading the wasm module.\n\nTo generate js/ts documents:\n```bash\nnix develop -c js-bindings-docs\n```\n\nTo run tests:\n```bash\nnix develop -c test-js-bindings\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainlanguage%2Fdotrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frainlanguage%2Fdotrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainlanguage%2Fdotrain/lists"}