Skip to content

Commit

Permalink
Ligo refactored for Mavkit Mavryk
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanAllaire committed Apr 24, 2024
1 parent eb040a6 commit 970b52b
Show file tree
Hide file tree
Showing 192 changed files with 1,182 additions and 619 deletions.
6 changes: 3 additions & 3 deletions gitlab-pages/docs/advanced/package-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ by simply placing a manifest file, `ligo.json` over there.

## LIGO registry

The [LIGO registry](https://packages.mavryk.network/) is used to host LIGO packages. The LIGO registry contains the contracts/libraries along with their metadata. The packages which reside on the LIGO registry can be installed using the `ligo install` command.
The [LIGO registry](https://packages.ligolang.org/) is used to host LIGO packages. The LIGO registry contains the contracts/libraries along with their metadata. The packages which reside on the LIGO registry can be installed using the `ligo install` command.

## Consuming

To fetch (download) & maintain different versions of external libraries we need a package manager.
LIGO libraries can be published to the [LIGO registry](https://packages.mavryk.network/) as well as [npm](https://www.npmjs.com/).
LIGO libraries can be published to the [LIGO registry](https://packages.ligolang.org/) as well as [npm](https://www.npmjs.com/).
Using `ligo install` command we can fetch these ligo libraries.

Note:
Expand Down Expand Up @@ -455,7 +455,7 @@ This would create a `.ligorc` in the home directory.
### Publishing

LIGO packages can be published to a central repository at
[`packages.ligo.mavryk.org`](https://packages.mavryk.network/) with the `ligo publish` command.
[`packages.ligolang.org`](https://packages.ligolang.org/) with the `ligo publish` command.

```bash
$ ligo publish
Expand Down
4 changes: 2 additions & 2 deletions gitlab-pages/docs/contributors/big-picture/vendors.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There are three kinds of utilities, corresponding to their dependencies.
`simple-utils` contain most utilities. For instance, in `simple-utils` are `X_list` and `X_option`, that extend the `List` module and the `option` type found in `Pervasives`.

Of particular interest in `simple-utils` is `trace.ml`, a module used pervasively in LIGO’s code-base. It deals with exceptions (and soon enough debugging annotations) in a functional manner. It offers a lot of utilities to build, combine and propagate exceptions. Given it’s used everywhere, that it relies on some advanced features of OCaml (higher order functions, ppx preprocessing) and that it exposes **a lot** of functions, it’s a good idea to look at this file’s documentation.
## tezos-modded
`tezos-modded` is a modded version of Mavryk. There are modifications in it that are quite useful (exposing more functions from the protocol, giving more options to functions already defined), but not integrated yet.
## mavryk-modded
`mavryk-modded` is a modded version of Mavryk. There are modifications in it that are quite useful (exposing more functions from the protocol, giving more options to functions already defined), but not integrated yet.
It should in the end be integrated into the Mavryk protocol, but until then, we use this.

2 changes: 1 addition & 1 deletion gitlab-pages/docs/faq/tezos-now-advance-time.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
id: tezos-now-advance-time
id: mavryk-now-advance-time
title: Is there a way to advance time in LIGO tests ?
---

Expand Down
12 changes: 6 additions & 6 deletions gitlab-pages/docs/intro/ligo-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TabItem from '@theme/TabItem';

### Ligo, a SmartContract Language built for Mavryk

LIGO is a programming language for writing [smart contracts](https://opentezos.com/tezos-basics/smart-contracts), compiling in [Michelson](https://opentezos.com/michelson) and deployable on [Mavryk blockchain](https://tezos.com/).
LIGO is a programming language for writing [smart contracts](https://opentezos.com/mavryk-basics/smart-contracts), compiling in [Michelson](https://opentezos.com/michelson) and deployable on [Mavryk blockchain](https://tezos.com/).

Our hope is to have a simple, strongly typed language with
a low footprint. Most useful smart contracts can express their core functionality in under a
Expand Down Expand Up @@ -42,14 +42,14 @@ Even if LIGO currently offers **two syntaxes**, you'll need to **choose only one
let store_hello (delta : int) (store : storage) : operation list * storage = [], "Hello"
```

A significant advantage of the multi-syntax feature is to share knowledge, toolings, and [modules](https://ligo.mavryk.org/docs/language-basics/modules) (like [libraries](https://ligo.mavryk.org/docs/advanced/package-management) onto [registry](https://packages.mavryk.network/packages)) in a larger community.
A significant advantage of the multi-syntax feature is to share knowledge, toolings, and [modules](https://ligo.mavryk.org/docs/language-basics/modules) (like [libraries](https://ligo.mavryk.org/docs/advanced/package-management) onto [registry](https://packages.ligolang.org/packages)) in a larger community.

### LIGO, designed to be cost-effective

Unlike desktop, mobile, or web application development, smart
contracts cannot rely on cheap CPU time and memory. All resources
contracts use are expensive and tracked as
['gas costs'](https://ligo.mavryk.org/docs/tutorials/optimisation/#tezos-gas-model).
['gas costs'](https://ligo.mavryk.org/docs/tutorials/optimisation/#mavryk-gas-model).

The LIGO compiler generates optimised Michelson code, which will
be cost-effective on Mavryk.
Expand Down Expand Up @@ -79,7 +79,7 @@ For critical code, LIGO also keeps its compiled output unbloated making **possib
### A set of tools already available

- Quickly explore LIGO using [webide](https://ide.mavryk.network/local)
- Quickly bootstrap a project with [registry](https://packages.mavryk.network/packages)
- Quickly bootstrap a project with [registry](https://packages.ligolang.org/packages)
- Improve development experience with our LSP server available in the
[VS Code extension](https://marketplace.visualstudio.com/items?itemName=ligolang-publish.ligo-vscode)
- Understand and troubleshoot your code with the debugger available in [vscode extension](https://marketplace.visualstudio.com/items?itemName=ligolang-publish.ligo-vscode)
Expand All @@ -98,14 +98,14 @@ For a quick overview, [get-started]( https://ligo.mavryk.org/docs/tutorials/gett

Your choice to learn LIGO is already available:
- Read [basics](https://ligo.mavryk.org/docs/language-basics/types) to have a basic comprehension
- Write your first [smart contract](https://ligo.mavryk.org/docs/tutorials/taco-shop/tezos-taco-shop-smart-contract).
- Write your first [smart contract](https://ligo.mavryk.org/docs/tutorials/taco-shop/mavryk-taco-shop-smart-contract).
- Others resources are available on [marigold.dev](https://www.marigold.dev/learn)

### Do you want to build a production-ready project?

You will need a deeper comprehension:
- Teach yourself how to structure your code with [Combining code](https://ligo.mavryk.org/docs/next/language-basics/modules) section
- Learn how to [write tests](https://ligo.mavryk.org/docs/next/advanced/testing?lang=jsligo) we strongly encourage to use [breathalyzer library from the LIGO registry.](https://packages.mavryk.network/package/ligo-breathalyzer)
- Learn how to [write tests](https://ligo.mavryk.org/docs/next/advanced/testing?lang=jsligo) we strongly encourage to use [breathalyzer library from the LIGO registry.](https://packages.ligolang.org/package/ligo-breathalyzer)
- Understand how to [secure a contract](https://ligo.mavryk.org/docs/tutorials/security)

### Dig deeper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
id: tezos-specific
id: mavryk-specific
title: Mavryk Domain-Specific Operations
---

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const id_string = (p) => {
let packed = Bytes.pack(p);
return Bytes.unpack(packed);
};
3 changes: 3 additions & 0 deletions gitlab-pages/docs/language-basics/src/mavryk-specific/a.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let id_string (p : string) : string option =
let packed: bytes = Bytes.pack p in
Bytes.unpack packed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const check_hash_key = (kh1: key_hash, k2: key) => {
let kh2 = Crypto.hash_key(k2);
return [kh1 == kh2, kh2];
};
3 changes: 3 additions & 0 deletions gitlab-pages/docs/language-basics/src/mavryk-specific/b.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let check_hash_key (kh1, k2 : key_hash * key) : bool * key_hash =
let kh2 : key_hash = Crypto.hash_key k2 in
(kh1 = kh2), kh2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const check_signature =
(pk: key, signed: signature, msg: bytes) =>
Crypto.check(pk, signed, msg);
2 changes: 2 additions & 0 deletions gitlab-pages/docs/language-basics/src/mavryk-specific/c.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let check_signature (pk, signed, msg : key * signature * bytes) : bool =
Crypto.check pk signed msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const current_addr = Mavryk.get_self_address();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let current_addr : address = Mavryk.get_self_address ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const origination = Mavryk.create_contract(
(p: nat, s: string) => [list([]), s],
None(),
3mav,
"initial_storage"
);
5 changes: 5 additions & 0 deletions gitlab-pages/docs/language-basics/src/mavryk-specific/e.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let origination : operation * address = Mavryk.create_contract
(fun (p : nat) (s : string) -> ([], s))
None
3mv
"initial_storage"
2 changes: 1 addition & 1 deletion gitlab-pages/docs/numbers/declaring.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ numbers.

Contrary to integral numbers in other programming languages, numbers
in LIGO have arbitrary-precision, that is, they do not overflow or
underflow. (See [Mavryk-specific features](../language-basics/tezos-specific.md) for more).
underflow. (See [Mavryk-specific features](../language-basics/mavryk-specific.md) for more).

Digits of large numbers can be separated by an underscore, to increase
readability.
Expand Down
2 changes: 1 addition & 1 deletion gitlab-pages/docs/reference/Tezos.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
id: tezos-reference
id: mavryk-reference
title: Mavryk
hide_table_of_contents: true
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Two choices are offered, ideal if you want to work with Ligo :
- Install necessary stuff onto your machine
- [Ligo compiler](https://ligo.mavryk.org/docs/intro/installation) to compile your code.
- [IDE plugins](https://ligo.mavryk.org/docs/intro/editor-support)
- [mavkit-client](https://tezos.gitlab.io/introduction/howtoget.html) used to interact with tezos blockchain. Pre-built binaries are available [here](https://github.com/serokell/tezos-packaging)
- [mavkit-client](https://tezos.gitlab.io/introduction/howtoget.html) used to interact with tezos blockchain. Pre-built binaries are available [here](https://github.com/serokell/mavryk-packaging)
- Use [webide](https://ide.mavryk.network), ideal if you want a quick view of ligo. You'll be able to do, test, dry-run, and deploy the code !

## Building a smart-contract.
Expand Down Expand Up @@ -339,4 +339,4 @@ It can be annoying to deploy you contract onto a node to test it. We advise test

This conclude this part of our tutorial.
You should now be able to compile, test, publish and call a contract.
Now you can go to the [tacos shop tutorial](https://ligo.mavryk.org/docs/tutorials/taco-shop/tezos-taco-shop-smart-contract) to know more about programming with LIGO or you can start developing your own contract using the LIGO syntax you are more familiar with.
Now you can go to the [tacos shop tutorial](https://ligo.mavryk.org/docs/tutorials/taco-shop/mavryk-taco-shop-smart-contract) to know more about programming with LIGO or you can start developing your own contract using the LIGO syntax you are more familiar with.
2 changes: 1 addition & 1 deletion gitlab-pages/docs/tutorials/mv-vs-eth/mv-vs-eth.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ Fee model in Mavryk is more complicated than the Ethereum one. The most importan
2. When you call a contract, the transaction spends gas for reading, deserialising and type-checking the storage. Also, a certain amount of gas gets spent for serialising and writing the storage back to the context. In practice, it means that **the larger your code and storage are, the more expensive it is to call your contract,** regardless of the number of computations performed. If you have big or unbounded containers in storage, you should most probably use `big_map`.
3. Emitting internal operations is very expensive in terms of gas: there is a fixed cost of 10000 gas for `Mavryk.get_{contract, entrypoint}_opt` plus the cost of reading, deserialising, and type-checking the parameter of the callee.

Always test for gas consumption and strive to minimise the size of the data stored on chain and the number of internal operations emitted. You can read more on fees in our [Optimisation guide](../optimisation/optimisation.md) or in the [Serokell blog post](https://medium.com/tqtezos/how-to-minimize-transaction-costs-of-tezos-smart-contracts-9962347faf64).
Always test for gas consumption and strive to minimise the size of the data stored on chain and the number of internal operations emitted. You can read more on fees in our [Optimisation guide](../optimisation/optimisation.md) or in the [Serokell blog post](https://medium.com/tqtezos/how-to-minimize-transaction-costs-of-mavryk-smart-contracts-9962347faf64).

## Conclusion

Expand Down
8 changes: 4 additions & 4 deletions gitlab-pages/docs/tutorials/registry/what-is-the-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ id: what-is-the-registry
title: What is the registry?
---

The [LIGO Registry](https://packages.mavryk.network) is a website that gathers reusable resources for the LIGO ecosystem and provide a way to audit your packages. It's important to note that it's still a beta for now.
The [LIGO Registry](https://packages.ligolang.org) is a website that gathers reusable resources for the LIGO ecosystem and provide a way to audit your packages. It's important to note that it's still a beta for now.

## [Packages](https://packages.mavryk.network/packages)
## [Packages](https://packages.ligolang.org/packages)

Packages are similar to libraries. They're pieces of code made by the community or the LIGO team that you can reuse when you develop your own contracts. You can refer to the documentation on each packages to know how they work and to install them.

### How to publish my own package?

You can refer to [this documentation](https://ligo.mavryk.org/docs/advanced/package-management#packaging) to learn how to turn LIGO files into a library and publish them.

## [Contracts](https://packages.mavryk.network/contracts)
## [Contracts](https://packages.ligolang.org/contracts)

You'll be able to find a collection of contracts which are templates for your Dapps. Rather than developing from scratch common patterns such as NFT, randomness or multisig, you can use our contracts.

## [Dapps](https://packages.mavryk.network/dapps)
## [Dapps](https://packages.ligolang.org/dapps)

Dapps are similar to contracts, but rather than only having the LIGO contracts, you'll find a full template of Dapp including contracts and frontend.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
id: tezos-taco-shop-payout
id: mavryk-taco-shop-payout
title: Paying out profits from the Taco Shop
---

import Syntax from '@theme/Syntax';

In the
[previous tutorial](tezos-taco-shop-smart-contract.md)
[previous tutorial](mavryk-taco-shop-smart-contract.md)
we have learnt how to setup & interact with the LIGO CLI. Followed an
implementation of a simple Taco Shop smart contract for our
entrepreneur Pedro.
Expand All @@ -15,7 +15,7 @@ In this tutorial we will make sure Pedro has access to tokens that
people have spent at his shop when buying tacos.

<br/>
<img src="/img/tutorials/get-started/tezos-taco-shop-payout/get-money.svg" width="50%" />
<img src="/img/tutorials/get-started/mavryk-taco-shop-payout/get-money.svg" width="50%" />

<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '10px' }}>
<div>Icons made by <a href="https://www.flaticon.com/authors/smashicons" title="Smashicons">Smashicons</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
Expand Down Expand Up @@ -424,7 +424,7 @@ ligo run dry-run taco-shop.jsligo --syntax jsligo -m TacoShop --amount 1 --entry

</Syntax>

<img src="/img/tutorials/get-started/tezos-taco-shop-payout/dry-run-1.png" />
<img src="/img/tutorials/get-started/mavryk-taco-shop-payout/dry-run-1.png" />
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '12px', marginTop: '-24px' }}>
<b>Operation(...bytes)</b> included in the output
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
id: tezos-taco-shop-smart-contract
id: mavryk-taco-shop-smart-contract
title: The Taco Shop Smart Contract
---

Expand All @@ -18,7 +18,7 @@ contract that will manage supply, pricing & sales of his tacos to the
consumers.

<br/>
<img src="/img/tutorials/get-started/tezos-taco-shop-smart-contract/taco-stand.svg" width="50%" />
<img src="/img/tutorials/get-started/mavryk-taco-shop-smart-contract/taco-stand.svg" width="50%" />
<div style={{ opacity: 0.7, textAlign: 'center', fontSize: '10px' }}>Made by <a href="https://www.flaticon.com/authors/smashicons" title="Smashicons">Smashicons</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
</div>

Expand Down Expand Up @@ -206,7 +206,7 @@ When deploying contract, it is crucial to provide a correct
initial storage value. In our case the storage is type-checked as
`taco_shop_storage`, because the default storage is not directly used in the code,
we encourage to declare the type, if your storage mutate, your default_storage will be in error.
Reflecting [Pedro's daily offer](tezos-taco-shop-smart-contract.md#daily-offer),
Reflecting [Pedro's daily offer](mavryk-taco-shop-smart-contract.md#daily-offer),
our storage's value will be defined as follows:

<Syntax syntax="cameligo">
Expand Down Expand Up @@ -335,7 +335,7 @@ accessible within LIGO as `Mavryk.get_amount`.
To make sure we get paid, we will:

- calculate a `current_purchase_price` based on the
[equation specified earlier](tezos-taco-shop-smart-contract.md#calculating-the-current-purchase-price)
[equation specified earlier](mavryk-taco-shop-smart-contract.md#calculating-the-current-purchase-price)
- check if the sent amount matches the `current_purchase_price`:
- if not, then our contract will fail (`failwith`)
- otherwise, stock for the given `taco_kind` will be decreased and
Expand Down Expand Up @@ -412,7 +412,7 @@ For that, we will have another file in which will describe our test:
<Syntax syntax="cameligo">

```cameligo test-ligo group=test
#import "gitlab-pages/docs/tutorials/taco-shop/src/tezos-taco-shop-smart-contract/TacoShop.mligo" "TacoShop"
#import "gitlab-pages/docs/tutorials/taco-shop/src/mavryk-taco-shop-smart-contract/TacoShop.mligo" "TacoShop"
let assert_string_failure (res : test_exec_result) (expected : string) =
let expected = Test.eval expected in
Expand Down Expand Up @@ -464,7 +464,7 @@ let test =
<Syntax syntax="jsligo">

```jsligo test-ligo group=test
#import "gitlab-pages/docs/tutorials/taco-shop/src/tezos-taco-shop-smart-contract/TacoShop.jsligo" "TacoShop"
#import "gitlab-pages/docs/tutorials/taco-shop/src/mavryk-taco-shop-smart-contract/TacoShop.jsligo" "TacoShop"
function assert_string_failure (res: test_exec_result, expected: string) {
const expected_bis = Test.eval(expected);
Expand Down Expand Up @@ -591,7 +591,7 @@ with `"test"`:
<Syntax syntax="cameligo">

```zsh
ligo run test gitlab-pages/docs/tutorials/taco-shop/src/tezos-taco-shop-smart-contract/test.mligo
ligo run test gitlab-pages/docs/tutorials/taco-shop/src/mavryk-taco-shop-smart-contract/test.mligo
# Output:
#
# Everything at the top-level was executed.
Expand All @@ -603,7 +603,7 @@ ligo run test gitlab-pages/docs/tutorials/taco-shop/src/tezos-taco-shop-smart-co
<Syntax syntax="jsligo">

```zsh
ligo run test gitlab-pages/docs/tutorials/taco-shop/src/tezos-taco-shop-smart-contract/test.jsligo
ligo run test gitlab-pages/docs/tutorials/taco-shop/src/mavryk-taco-shop-smart-contract/test.jsligo
# Output:
#
# Everything at the top-level was executed.
Expand Down
Loading

0 comments on commit 970b52b

Please sign in to comment.