From bef473b656fc1050c4265e38f97166ef33bc6aed Mon Sep 17 00:00:00 2001 From: collin <16715212+collinc97@users.noreply.github.com> Date: Mon, 1 Aug 2022 16:04:00 -0700 Subject: [PATCH] add import example, remove directory nesting, improve examples readme --- .../bubblesort_tuple => bubblesort}/.gitignore | 0 examples/bubblesort/README.md | 13 +++++++++++++ .../inputs/bubblesort.in} | 0 .../bubblesort_tuple => bubblesort}/program.json | 2 +- .../bubblesort_tuple => bubblesort}/src/main.leo | 0 examples/core/README.md | 13 ++++++++++--- examples/groups/README.md | 13 ++++++++++--- examples/helloworld/README.md | 13 ++++++++++--- examples/helloworld/imports/foo.leo | 8 ++++++++ examples/helloworld/src/main.leo | 7 +++---- examples/message/README.md | 14 +++++++++++--- examples/point/.gitignore | 2 ++ examples/point/README.md | 14 ++++++++++++++ examples/point/imports/point.leo | 16 ++++++++++++++++ examples/point/inputs/point.in | 7 +++++++ examples/point/program.json | 10 ++++++++++ examples/point/src/main.leo | 8 ++++++++ examples/sorting/bubblesort_tuple/README.md | 8 -------- examples/token/README.md | 13 ++++++++++--- 19 files changed, 133 insertions(+), 28 deletions(-) rename examples/{sorting/bubblesort_tuple => bubblesort}/.gitignore (100%) create mode 100644 examples/bubblesort/README.md rename examples/{sorting/bubblesort_tuple/inputs/bubblesort_tuple.in => bubblesort/inputs/bubblesort.in} (100%) rename examples/{sorting/bubblesort_tuple => bubblesort}/program.json (87%) rename examples/{sorting/bubblesort_tuple => bubblesort}/src/main.leo (100%) create mode 100644 examples/helloworld/imports/foo.leo create mode 100644 examples/point/.gitignore create mode 100644 examples/point/README.md create mode 100644 examples/point/imports/point.leo create mode 100644 examples/point/inputs/point.in create mode 100644 examples/point/program.json create mode 100644 examples/point/src/main.leo delete mode 100644 examples/sorting/bubblesort_tuple/README.md diff --git a/examples/sorting/bubblesort_tuple/.gitignore b/examples/bubblesort/.gitignore similarity index 100% rename from examples/sorting/bubblesort_tuple/.gitignore rename to examples/bubblesort/.gitignore diff --git a/examples/bubblesort/README.md b/examples/bubblesort/README.md new file mode 100644 index 0000000000..34d507afc8 --- /dev/null +++ b/examples/bubblesort/README.md @@ -0,0 +1,13 @@ +# bubblesort + +## Build Guide + +To compile this program, run: +```bash +leo build +``` + +To run this program, run: +```bash +leo run +``` \ No newline at end of file diff --git a/examples/sorting/bubblesort_tuple/inputs/bubblesort_tuple.in b/examples/bubblesort/inputs/bubblesort.in similarity index 100% rename from examples/sorting/bubblesort_tuple/inputs/bubblesort_tuple.in rename to examples/bubblesort/inputs/bubblesort.in diff --git a/examples/sorting/bubblesort_tuple/program.json b/examples/bubblesort/program.json similarity index 87% rename from examples/sorting/bubblesort_tuple/program.json rename to examples/bubblesort/program.json index 5bf01f4eb2..3ea5152561 100644 --- a/examples/sorting/bubblesort_tuple/program.json +++ b/examples/bubblesort/program.json @@ -1,5 +1,5 @@ { - "program": "bubblesort_tuple.aleo", + "program": "bubblesort.aleo", "version": "0.0.0", "description": "", "development": { diff --git a/examples/sorting/bubblesort_tuple/src/main.leo b/examples/bubblesort/src/main.leo similarity index 100% rename from examples/sorting/bubblesort_tuple/src/main.leo rename to examples/bubblesort/src/main.leo diff --git a/examples/core/README.md b/examples/core/README.md index 1c4de25dca..4660673568 100644 --- a/examples/core/README.md +++ b/examples/core/README.md @@ -1,6 +1,13 @@ -# core.aleo +# Leo core functions + ## Build Guide -To compile this Aleo program, run: + +To compile this program, run: ```bash -aleo build +leo build ``` + +To run this program, run: +```bash +leo run +``` \ No newline at end of file diff --git a/examples/groups/README.md b/examples/groups/README.md index aec682bda2..a1a8a58c67 100644 --- a/examples/groups/README.md +++ b/examples/groups/README.md @@ -1,6 +1,13 @@ -# groups.aleo +# Leo group operations. + ## Build Guide -To compile this Aleo program, run: + +To compile this program, run: ```bash -aleo build +leo build ``` + +To run this program, run: +```bash +leo run +``` \ No newline at end of file diff --git a/examples/helloworld/README.md b/examples/helloworld/README.md index 54497b88ba..e04a14969b 100644 --- a/examples/helloworld/README.md +++ b/examples/helloworld/README.md @@ -1,6 +1,13 @@ -# helloworld.aleo +# Leo helloworld + ## Build Guide -To compile this Aleo program, run: + +To compile this program, run: ```bash -aleo build +leo build ``` + +To run this program, run: +```bash +leo run +``` \ No newline at end of file diff --git a/examples/helloworld/imports/foo.leo b/examples/helloworld/imports/foo.leo new file mode 100644 index 0000000000..319eed328e --- /dev/null +++ b/examples/helloworld/imports/foo.leo @@ -0,0 +1,8 @@ +circuit Foo { + x: u64, + y: u64, +} + +function bar(x: u64, y: u64) -> Foo { + return Foo {x, y}; +} \ No newline at end of file diff --git a/examples/helloworld/src/main.leo b/examples/helloworld/src/main.leo index e4179820b4..a1f61ec20c 100644 --- a/examples/helloworld/src/main.leo +++ b/examples/helloworld/src/main.leo @@ -1,8 +1,7 @@ +import foo.leo; + // The 'helloworld' main function. + function main(public a: u32, b: u32) -> u32 { return a + b; } - -function foo(x: u64) -> u64 { - return x - x; -} \ No newline at end of file diff --git a/examples/message/README.md b/examples/message/README.md index 137165b8bd..2ba4c23f3f 100644 --- a/examples/message/README.md +++ b/examples/message/README.md @@ -1,6 +1,14 @@ -# message.aleo +# Leo message circuit +A basic example showing how to declare a circuit in the Leo language. + ## Build Guide -To compile this Aleo program, run: + +To compile this program, run: ```bash -aleo build +leo build ``` + +To run this program, run: +```bash +leo run +``` \ No newline at end of file diff --git a/examples/point/.gitignore b/examples/point/.gitignore new file mode 100644 index 0000000000..b28696155d --- /dev/null +++ b/examples/point/.gitignore @@ -0,0 +1,2 @@ +outputs/ +build/ diff --git a/examples/point/README.md b/examples/point/README.md new file mode 100644 index 0000000000..038ce192d3 --- /dev/null +++ b/examples/point/README.md @@ -0,0 +1,14 @@ +# Leo import example +An example showing how to import symbols from file `point.leo`. + +## Build Guide + +To compile this program, run: +```bash +leo build +``` + +To run this program, run: +```bash +leo run +``` \ No newline at end of file diff --git a/examples/point/imports/point.leo b/examples/point/imports/point.leo new file mode 100644 index 0000000000..b666d2ba52 --- /dev/null +++ b/examples/point/imports/point.leo @@ -0,0 +1,16 @@ +// A (x, y) coordinate point +circuit Point { + x: u32, + y: u32, +} + +function new(x: u32, y: u32) -> Point { + return Point {x, y}; +} + +function add(a: Point, b: Point) -> Point { + return Point { + x: a.x + b.x, + y: a.y + b.y, + } +} \ No newline at end of file diff --git a/examples/point/inputs/point.in b/examples/point/inputs/point.in new file mode 100644 index 0000000000..407979d09f --- /dev/null +++ b/examples/point/inputs/point.in @@ -0,0 +1,7 @@ +// The program input for point/src/main.leo +[main] +public a: u32 = 1u32; +b: u32 = 2u32; // Input variable `b` is private by default. + +[foo] +x: u64 = 5u64; \ No newline at end of file diff --git a/examples/point/program.json b/examples/point/program.json new file mode 100644 index 0000000000..5ab6425df6 --- /dev/null +++ b/examples/point/program.json @@ -0,0 +1,10 @@ +{ + "program": "helloworld.aleo", + "version": "0.0.0", + "description": "", + "development": { + "private_key": "APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx", + "address": "aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau" + }, + "license": "MIT" +} diff --git a/examples/point/src/main.leo b/examples/point/src/main.leo new file mode 100644 index 0000000000..ecae299db6 --- /dev/null +++ b/examples/point/src/main.leo @@ -0,0 +1,8 @@ +// Import the circuits and functions from `imports/point.leo`. +// In testnet3, Leo imports all symbols from a file by default. +import point.leo; + +// The 'point' main function. +function main(public a: u32, b: u32) -> u32 { + return a + b; +} diff --git a/examples/sorting/bubblesort_tuple/README.md b/examples/sorting/bubblesort_tuple/README.md deleted file mode 100644 index 87f6687360..0000000000 --- a/examples/sorting/bubblesort_tuple/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# bubblesort_tuple.aleo - -## Build Guide - -To compile this Aleo program, run: -```bash -aleo build -``` diff --git a/examples/token/README.md b/examples/token/README.md index 00e89b78a4..dc20c3d7db 100644 --- a/examples/token/README.md +++ b/examples/token/README.md @@ -1,6 +1,13 @@ -# token.aleo +# token + ## Build Guide -To compile this Aleo program, run: + +To compile this program, run: ```bash -aleo build +leo build ``` + +To run this program, run: +```bash +leo run +``` \ No newline at end of file