motoko 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/lib/generated/.prettierignore +1 -0
- package/lib/generated/moc.js +288386 -0
- package/lib/index.js +84 -0
- package/lib/index.test.js +17 -0
- package/lib/package.js +156 -0
- package/package.json +42 -0
package/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Motoko
|
2
|
+
|
3
|
+
### Compile [Motoko](https://smartcontracts.org/) smart contracts in Node.js and the browser.
|
4
|
+
|
5
|
+
## Installation:
|
6
|
+
|
7
|
+
`npm install --save motoko`
|
8
|
+
|
9
|
+
## Basic Example:
|
10
|
+
|
11
|
+
```js
|
12
|
+
import mo from 'motoko';
|
13
|
+
// -- OR --
|
14
|
+
const mo = require('motoko');
|
15
|
+
|
16
|
+
// Create a Motoko script in a virtual file system
|
17
|
+
mo.addFile('Main.mo', `
|
18
|
+
actor {
|
19
|
+
public func hello() : async Text {
|
20
|
+
"Hello, JavaScript!"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
`);
|
24
|
+
|
25
|
+
// Generate the corresponding Candid interface
|
26
|
+
console.log(mo.candid('Main.mo'))
|
27
|
+
```
|
28
|
+
|
29
|
+
## Advanced Usage:
|
30
|
+
|
31
|
+
```js
|
32
|
+
|
33
|
+
// Load dependencies
|
34
|
+
await mo.loadPackages({
|
35
|
+
base: 'dfinity/motoko-base/master/src',
|
36
|
+
});
|
37
|
+
|
38
|
+
// Generate a Motoko AST
|
39
|
+
console.log(mo.parse('actor Main { public func test() : async Nat { 123 } }'));
|
40
|
+
|
41
|
+
// Generate a Candid AST
|
42
|
+
console.log(mo.parseCandid('service : { test : () -> (nat) }'));
|
43
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
*
|