Skip to content

Commit

Permalink
Update ligo example (#2750)
Browse files Browse the repository at this point in the history
* docs: ligo example update and small dapp cleanup

* docs: add comment for usability

* docs: update ligo broken link in maps_bigmaps.md

* docs: update teams building with taquito

re #2758

* docs: update smartcontracts.md changes in version 17.5

* docs: updated jsligov1.2.0 counter contract

* docs: updated comments of how to use deploy-test-dapp-contracts.ts
  • Loading branch information
hui-an-yang authored Dec 18, 2023
1 parent bcebcae commit fe57c7a
Show file tree
Hide file tree
Showing 26 changed files with 947 additions and 244 deletions.
67 changes: 0 additions & 67 deletions apps/taquito-test-dapp/src/assets/contract.mligo

This file was deleted.

8 changes: 0 additions & 8 deletions apps/taquito-test-dapp/src/assets/contract.storageList.mligo

This file was deleted.

20 changes: 9 additions & 11 deletions apps/taquito-test-dapp/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { NetworkType } from "@airgap/beacon-sdk";
export type SupportedNetworks = NetworkType.NAIROBINET | NetworkType.GHOSTNET | NetworkType.MAINNET | NetworkType.CUSTOM;

const rpcUrls: Record<SupportedNetworks, string> = {
[NetworkType.NAIROBINET]: "https://nairobinet.ecadinfra.com/",
[NetworkType.MAINNET]: "https://mainnet.ecadinfra.com",
[NetworkType.GHOSTNET]: "https://ghostnet.ecadinfra.com/",
[NetworkType.MAINNET]: "https://mainnet.ecadinfra.com", //"https://mainnet-tezos.giganode.io"
[NetworkType.CUSTOM]: "https://ghostnet.ecadinfra.com/",
[NetworkType.NAIROBINET]: "https://nairobinet.ecadinfra.com/",
// [NetworkType.CUSTOM]: "https://ghostnet.ecadinfra.com/",
};

export const getRpcUrl = (networkType: SupportedNetworks): string => {
Expand All @@ -15,12 +15,12 @@ export const getRpcUrl = (networkType: SupportedNetworks): string => {

export const getTzKtUrl = (networkType: SupportedNetworks): string | undefined => {
switch (networkType) {
case NetworkType.NAIROBINET:
return "https://nairobinet.tzkt.io";
case NetworkType.GHOSTNET:
return "https://ghostnet.tzkt.io";
case NetworkType.MAINNET:
return "https://tzkt.io";
case NetworkType.GHOSTNET:
return "https://ghostnet.tzkt.io";
case NetworkType.NAIROBINET:
return "https://nairobinet.tzkt.io";
case NetworkType.CUSTOM:
return undefined;
}
Expand All @@ -30,11 +30,9 @@ export const defaultMatrixNode = "beacon-node-1.sky.papers.tech";

export const defaultNetworkType = NetworkType.GHOSTNET;

// new protocol updated rpc url in example/data/test-dapp-contract.ts and npm -w example run example:deploy-dapp
export const contractAddress = {
mainnet: "KT1ShtH2zCrKMuWGRejEd6RAcnePwxBQeMAN",
ithacanet: "KT1QKmcNBcfzVTXG2kBcE6XqXtEuYYUzMcT5",
ghostnet: "KT1QKmcNBcfzVTXG2kBcE6XqXtEuYYUzMcT5",
custom: "KT1T2gL26SwYMxpkR5SZT1pHRBF84knfw8Cg",
mumbainet: "KT1Tkm7U3NS9JWgeCGywrRTSQdLZJvDSgD5Z",
nairobinet: "KT1Tkm7U3NS9JWgeCGywrRTSQdLZJvDSgD5Z" // TODO: originate the contract and update this.
nairobinet: "KT1WoyF3wpUGRm6fbmmm1qKmpfneq1iijMT8"
};
2 changes: 1 addition & 1 deletion docs/maps_bigmaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Michelson offers two variants of `Maps` that are semantically the same but have

This example builds on the Ligo Lang Taco Shop learning resources.

The storage of the contract used in the following example is a map where a key is a natural number (a `nat`), and a value is a pair composed of two values representing the quantity of stock and `tez` tokens, respectively. The contract's source code is available [here](https://ligolang.org/docs/tutorials/get-started/tezos-taco-shop-smart-contract#making-sure-we-get-paid-for-our-tacos). In the example, the contract is originated with initial values using the `MichelsonMap` class' `set` method.
The storage of the contract used in the following example is a map where a key is a natural number (a `nat`), and a value is a pair composed of two values representing the quantity of stock and `tez` tokens, respectively. The contract's source code is available [here](https://ligolang.org/docs/tutorials/taco-shop/tezos-taco-shop-smart-contract/?lang=jsligo). In the example, the contract is originated with initial values using the `MichelsonMap` class' `set` method.

<Tabs
defaultValue="contractAPI"
Expand Down
44 changes: 17 additions & 27 deletions docs/smartcontracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,35 @@ The counter contract has two entry points named `increment` and `decrement.` Taq

The counter contract's storage is a simple integer that gets increased or decreased based on the calls to the entrypoints.

### Counter Contract in JSLIGO
### Counter Contract in JSLIGO v1.2.0

```
type storage = int;
type parameter =
| ["Increment", int]
| ["Decrement", int]
| ["Reset"];
type return_ = [list <operation>, storage];
/* Two entrypoints */
const add = ([store, delta] : [storage, int]) : storage => store + delta;
const sub = ([store, delta] : [storage, int]) : storage => store - delta;
/* Main access point that dispatches to the entrypoints according to
the smart contract parameter. */
const main = ([action, store] : [parameter, storage]) : return_ => {
return [
(list([]) as list <operation>), // No operations
(match (action, {
Increment: (n: int) => add ([store, n]),
Decrement: (n: int) => sub ([store, n]),
Reset: () => 0}))
]
};
export namespace Counter {
export type storage = int;
type ret = [list<operation>, storage];
// Three entrypoints
@entry
const increment = (delta : int, store : storage) : ret => [list([]), store + delta];
@entry
const decrement = (delta : int, store : storage) : ret => [list([]), store - delta];
@entry
const reset = (_u : unit, _s : storage) : ret => [list([]), 0];
};
```

You can view this contract and deploy it to a testnet using the [Ligo WebIDE][2]

### Counter Contract Michelson source code

```
{ parameter (or (or (int %decrement) (int %increment)) (unit %reset)) ;
{ parameter (or (unit %reset) (or (int %decrement) (int %increment))) ;
storage int ;
code { UNPAIR ;
IF_LEFT { IF_LEFT { SWAP ; SUB } { ADD } } { DROP 2 ; PUSH int 0 } ;
IF_LEFT { DROP 2 ; PUSH int 0 } { IF_LEFT { SWAP ; SUB } { ADD } } ;
NIL operation ;
PAIR } }
```
Expand Down
Loading

0 comments on commit fe57c7a

Please sign in to comment.