@taqueria/plugin-ligo 0.40.8 → 0.40.13
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.eta +43 -42
- package/index.js +43 -664
- package/index.js.map +1 -1
- package/index.mjs +46 -651
- package/index.mjs.map +1 -1
- package/index.ts +9 -102
- package/ligo_templates.ts +27 -23
- package/package.json +3 -2
- package/common.ts +0 -66
- package/compile-all.ts +0 -38
- package/compile.ts +0 -458
- package/createContract.ts +0 -38
- package/ligo.ts +0 -72
- package/main.ts +0 -26
- package/postinstall.js +0 -19
- package/test.ts +0 -44
package/_readme.eta
CHANGED
|
@@ -6,8 +6,8 @@ The LIGO plugin provides tasks to work with LIGO smart contracts such as compili
|
|
|
6
6
|
|
|
7
7
|
## Requirements
|
|
8
8
|
|
|
9
|
-
- Taqueria v0.
|
|
10
|
-
- Node.js
|
|
9
|
+
- Taqueria v0.40.0 or later
|
|
10
|
+
- Node.js v18 or later
|
|
11
11
|
- Docker v20.10.12 or later
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
@@ -81,47 +81,48 @@ taq test <fileName>
|
|
|
81
81
|
### Basic description
|
|
82
82
|
This task tests the LIGO source code and reports either a failure or success. Normally you'd have a contract file and a separate test file that includes the contract's code, both within the `contracts` directory
|
|
83
83
|
|
|
84
|
-
For example, refer to the following
|
|
85
|
-
```ligo title="
|
|
86
|
-
|
|
84
|
+
For example, refer to the following snippets:
|
|
85
|
+
```ligo title="IncDec.jsligo"
|
|
86
|
+
export namespace IncDec {
|
|
87
|
+
export type storage = int;
|
|
88
|
+
type ret = [list<operation>, storage];
|
|
89
|
+
// Three entrypoints
|
|
90
|
+
|
|
91
|
+
@entry
|
|
92
|
+
const increment = (delta: int, store: storage): ret =>
|
|
93
|
+
[list([]), store + delta];
|
|
94
|
+
@entry
|
|
95
|
+
const decrement = (delta: int, store: storage): ret =>
|
|
96
|
+
[list([]), store - delta];
|
|
97
|
+
@entry
|
|
98
|
+
const reset = (_p: unit, _s: storage): ret => [list([]), 0]
|
|
99
|
+
};
|
|
87
100
|
|
|
88
|
-
type parameter =
|
|
89
|
-
Increment of int
|
|
90
|
-
| Decrement of int
|
|
91
|
-
| Reset
|
|
92
|
-
|
|
93
|
-
type return = operation list * storage
|
|
94
|
-
|
|
95
|
-
// Two entrypoints
|
|
96
|
-
|
|
97
|
-
let add (store, delta : storage * int) : storage = store + delta
|
|
98
|
-
let sub (store, delta : storage * int) : storage = store - delta
|
|
99
|
-
|
|
100
|
-
(* Main access point that dispatches to the entrypoints according to
|
|
101
|
-
the smart contract parameter. *)
|
|
102
|
-
|
|
103
|
-
let main (action, store : parameter * storage) : return =
|
|
104
|
-
([] : operation list), // No operations
|
|
105
|
-
(match action with
|
|
106
|
-
Increment (n) -> add (store, n)
|
|
107
|
-
| Decrement (n) -> sub (store, n)
|
|
108
|
-
| Reset -> 0)
|
|
109
101
|
```
|
|
110
102
|
|
|
111
|
-
```ligo title="
|
|
112
|
-
#
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
let
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
```ligo title="testIncDec.jsligo"
|
|
104
|
+
#import "IncDec.jsligo" "Contract"
|
|
105
|
+
|
|
106
|
+
/* Tests for main access point */
|
|
107
|
+
|
|
108
|
+
const test_initial_storage =
|
|
109
|
+
(
|
|
110
|
+
() => {
|
|
111
|
+
let initial_storage = 42;
|
|
112
|
+
let contract = Test.originate(contract_of (Contract.IncDec), initial_storage, 0 as tez);
|
|
113
|
+
return assert(Test.get_storage(contract.addr) == initial_storage)
|
|
114
|
+
}
|
|
115
|
+
)();
|
|
116
|
+
|
|
117
|
+
const test_increment =
|
|
118
|
+
(
|
|
119
|
+
() => {
|
|
120
|
+
let initial_storage = 42;
|
|
121
|
+
let contract = Test.originate(contract_of (Contract.IncDec), initial_storage, 0 as tez);
|
|
122
|
+
let _ = Test.transfer_exn(contract.addr, (Increment (1)), 1mutez);
|
|
123
|
+
return assert(Test.get_storage(contract.addr) == initial_storage + 1)
|
|
124
|
+
}
|
|
125
|
+
)();
|
|
125
126
|
```
|
|
126
127
|
|
|
127
128
|
By running `taq test testCounter.mligo`, you should get the following:
|
|
@@ -129,11 +130,11 @@ By running `taq test testCounter.mligo`, you should get the following:
|
|
|
129
130
|
┌───────────────────┬──────────────────────────────────────────────┐
|
|
130
131
|
│ Contract │ Test Results │
|
|
131
132
|
├───────────────────┼──────────────────────────────────────────────┤
|
|
132
|
-
│
|
|
133
|
+
│ testIncDec.jsligo │ Everything at the top-level was executed. │
|
|
133
134
|
│ │ - test_initial_storage exited with value (). │
|
|
134
135
|
│ │ - test_increment exited with value (). │
|
|
135
136
|
│ │ │
|
|
136
|
-
│ │ 🎉 All tests passed 🎉
|
|
137
|
+
│ │ 🎉 All tests passed 🎉 │
|
|
137
138
|
└───────────────────┴──────────────────────────────────────────────┘
|
|
138
139
|
```
|
|
139
140
|
|