[LIGO-365] Add CameLIGO and ReasonLIGO transaction examples
This commit is contained in:
parent
e67e2098c2
commit
7b1d7755d1
@ -79,31 +79,28 @@ In our case, we have a `counter.ligo` contract that accepts a parameter of type
|
||||
|
||||
<!--DOCUSAURUS_CODE_TABS-->
|
||||
<!--Pascaligo-->
|
||||
```pascaligo group=dup
|
||||
// counter.types.ligo
|
||||
type action is
|
||||
| Increment of int
|
||||
| Decrement of int
|
||||
| Reset of unit
|
||||
```
|
||||
|
||||
```pascaligo group=d
|
||||
```pascaligo
|
||||
// counter.ligo
|
||||
type action is
|
||||
| Increment of int
|
||||
| Decrement of int
|
||||
| Reset of unit
|
||||
|
||||
```
|
||||
|
||||
```pascaligo skip
|
||||
// proxy.ligo
|
||||
#include "counter.types.ligo"
|
||||
|
||||
const address: address = ("KT19wgxcuXG9VH4Af5Tpm1vqEKdaMFpznXT3": address);
|
||||
type action is
|
||||
| Increment of int
|
||||
| Decrement of int
|
||||
| Reset of unit
|
||||
|
||||
const dest: address = ("KT19wgxcuXG9VH4Af5Tpm1vqEKdaMFpznXT3": address);
|
||||
|
||||
function proxy(const param: action; const store: unit): (list(operation) * unit)
|
||||
is block {
|
||||
const counter: contract(action) = get_contract(address);
|
||||
const counter: contract(action) = get_contract(dest);
|
||||
// re-use the param passed to the proxy in the subsequent transaction
|
||||
// e.g.:
|
||||
// const mockParam: action = Increment(5);
|
||||
@ -111,4 +108,59 @@ function proxy(const param: action; const store: unit): (list(operation) * unit)
|
||||
const opList: list(operation) = list op; end;
|
||||
} with (opList, store)
|
||||
```
|
||||
<!--CameLIGO-->
|
||||
```cameligo
|
||||
// counter.mligo
|
||||
type action =
|
||||
| Increment of int
|
||||
| Decrement of int
|
||||
| Reset of unit
|
||||
|
||||
// ...
|
||||
```
|
||||
|
||||
```cameligo
|
||||
// proxy.mligo
|
||||
|
||||
type action =
|
||||
| Increment of int
|
||||
| Decrement of int
|
||||
| Reset of unit
|
||||
|
||||
let dest: address = ("KT19wgxcuXG9VH4Af5Tpm1vqEKdaMFpznXT3": address)
|
||||
|
||||
let proxy (param, storage: action * unit): operation list * unit =
|
||||
let counter: action contract = Operation.get_contract dest in
|
||||
let op: operation = Operation.transaction param 0mutez counter in
|
||||
[op], storage
|
||||
```
|
||||
|
||||
<!--ReasonLIGO-->
|
||||
```reasonligo
|
||||
// counter.religo
|
||||
|
||||
type action =
|
||||
| Increment(int)
|
||||
| Decrement(int)
|
||||
| Reset(unit);
|
||||
|
||||
// ...
|
||||
```
|
||||
|
||||
```reasonligo
|
||||
// proxy.religo
|
||||
|
||||
type action =
|
||||
| Increment(int)
|
||||
| Decrement(int)
|
||||
| Reset(unit);
|
||||
|
||||
let dest: address = ("KT19wgxcuXG9VH4Af5Tpm1vqEKdaMFpznXT3": address);
|
||||
|
||||
let proxy = (param_s: (action, unit)): (list(operation), unit) =>
|
||||
let counter: contract(action) = Operation.get_contract(dest);
|
||||
let op: operation = Operation.transaction(param_s[0], 0mutez, counter);
|
||||
([op], param_s[1]);
|
||||
```
|
||||
|
||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
Loading…
Reference in New Issue
Block a user