Merge branch 'docs/mligo-religo-transactions' into 'dev'
[LIGO-365] Add CameLIGO and ReasonLIGO transaction examples See merge request ligolang/ligo!318
This commit is contained in:
commit
65656741da
@ -79,31 +79,28 @@ In our case, we have a `counter.ligo` contract that accepts a parameter of type
|
|||||||
|
|
||||||
<!--DOCUSAURUS_CODE_TABS-->
|
<!--DOCUSAURUS_CODE_TABS-->
|
||||||
<!--Pascaligo-->
|
<!--Pascaligo-->
|
||||||
```pascaligo group=dup
|
```pascaligo
|
||||||
// counter.types.ligo
|
|
||||||
type action is
|
|
||||||
| Increment of int
|
|
||||||
| Decrement of int
|
|
||||||
| Reset of unit
|
|
||||||
```
|
|
||||||
|
|
||||||
```pascaligo group=d
|
|
||||||
// counter.ligo
|
// counter.ligo
|
||||||
type action is
|
type action is
|
||||||
| Increment of int
|
| Increment of int
|
||||||
| Decrement of int
|
| Decrement of int
|
||||||
| Reset of unit
|
| Reset of unit
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```pascaligo skip
|
```pascaligo skip
|
||||||
// proxy.ligo
|
// 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)
|
function proxy(const param: action; const store: unit): (list(operation) * unit)
|
||||||
is block {
|
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
|
// re-use the param passed to the proxy in the subsequent transaction
|
||||||
// e.g.:
|
// e.g.:
|
||||||
// const mockParam: action = Increment(5);
|
// 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;
|
const opList: list(operation) = list op; end;
|
||||||
} with (opList, store)
|
} with (opList, store)
|
||||||
```
|
```
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
<!--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