@taqueria/plugin-ligo 0.40.10 → 0.40.14

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 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.26.0 or later
10
- - Node.js v16.16 or later. (v17.x.x or later is not supported)
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 2 code snippets:
85
- ```ligo title="counter.mligo"
86
- type storage = int
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="testCounter.mligo"
112
- #include "counter.mligo"
113
-
114
- let initial_storage = 42
115
-
116
- let test_initial_storage =
117
- let (taddr, _, _) = Test.originate main initial_storage 0tez in
118
- assert (Test.get_storage taddr = initial_storage)
119
-
120
- let test_increment =
121
- let (taddr, _, _) = Test.originate main initial_storage 0tez in
122
- let contr = Test.to_contract taddr in
123
- let _ = Test.transfer_to_contract_exn contr (Increment 1) 1mutez in
124
- assert (Test.get_storage taddr = initial_storage + 1)
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
- testCounter.mligo │ Everything at the top-level was executed. │
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