The sails-js-parser
is designed to parse Sails IDL files, producing an output that can be used to generate client libraries or facilitate interaction with Gear blockchain programs.
To install the sails-js-parser
library:
npm install sails-js-parser
import { SailsIdlParser } from 'sails-js-parser';
const parser = await SailsIdlParser.new();
Often used with sails-js
:
import { Sails } from 'sails-js';
import { SailsIdlParser } from 'sails-js-parser';
const parser = await SailsIdlParser.new();
const sails = new Sails(parser);
const idl = `
constructor {
New : ();
};
service SailsApp {
DoSomething : () -> str;
};
`
const program = parser.parse(idl);
The parse
method returns a Program instance representing the parsed IDL.