Skip to content

Commit d1928e2

Browse files
author
Mohammad Fawaz
committed
A few more fixes
1 parent 7d4e38c commit d1928e2

18 files changed

Lines changed: 101 additions & 101 deletions

File tree

documentation/cli/00_overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can print the list of commands by running `leo --help`
1717
- [`abi`](./02b_abi.md) - Generate an ABI JSON file from a compiled `.aleo` bytecode file.
1818
- [`account`](./01_account.md) - Create a new Aleo account, sign and verify messages.
1919
- [`new`](./01_account.md#leo-account-new) - Generates a new Aleo account.
20-
- [`import`](./01_account.md#leo-account-import) - Derive and Aleo account from a private key.
20+
- [`import`](./01_account.md#leo-account-import) - Derive an Aleo account from a private key.
2121
- [`sign`](./01_account.md#leo-account-sign) - Sign a message using your Aleo private key.
2222
- [`verify`](./01_account.md#leo-account-verify) - Verify a message and signature from an Aleo address.
2323
- [`add`](./02_add.md) - Add a new onchain or local dependency to the current project.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"program": "pair_user.aleo",
3+
"version": "0.1.0",
4+
"description": "",
5+
"license": "MIT",
6+
"dependencies": [
7+
{
8+
"name": "pair_lib",
9+
"location": "local",
10+
"path": "../const_generic_dep",
11+
"edition": null
12+
}
13+
]
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
program pair_user.aleo {
2+
// ANCHOR: file
3+
// Construct a const-generic struct defined in another package.
4+
fn build() -> pair_lib::Pair::[3u32] {
5+
return pair_lib::Pair::[3u32] { first: 1u32, second: 2u32 };
6+
}
7+
8+
// Call a const-generic helper defined in another package.
9+
fn triple(x: u32) -> u32 {
10+
return pair_lib::scale::[3u32](x);
11+
}
12+
// ANCHOR_END: file
13+
14+
@noupgrade
15+
constructor() {}
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"program": "pair_lib",
3+
"version": "0.1.0",
4+
"description": "Library exposing a const-generic struct and helper.",
5+
"license": "MIT"
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// A const-generic pair, parameterised by an integer tag `N`.
2+
struct Pair::[N: u32] {
3+
first: u32,
4+
second: u32,
5+
}
6+
7+
// A const-generic helper that scales `x` by the type-level constant `N`.
8+
fn scale::[N: u32](x: u32) -> u32 {
9+
return x * N;
10+
}

documentation/code_snippets/migration/test_target/tests/test_test_program.leo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ program test_test_program.aleo {
1313
@should_fail
1414
fn test_overflow() {
1515
let result: u8 = test_program.aleo::sum_u8(255u8, 1u8);
16-
assert_eq(result, 0u8);
1716
}
1817

1918
@noupgrade

documentation/code_snippets/testing/example_program/src/main.leo

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ program example_program.aleo {
2222
}
2323
// ANCHOR_END: mint_record
2424

25+
// ANCHOR: pause
26+
const ADMIN: address = aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke;
27+
28+
fn pause() {
29+
assert_eq(self.signer, ADMIN);
30+
}
31+
// ANCHOR_END: pause
32+
2533
@noupgrade
2634
constructor() {}
2735
}

documentation/code_snippets/testing/example_program/tests/test_example_program.leo

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ program test_example_program.aleo {
3737
}
3838
// ANCHOR_END: test_with_private_key
3939

40+
// ANCHOR: test_admin_pair
41+
@test(private_key = "APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK")
42+
fn test_admin_can_pause() {
43+
example_program.aleo::pause();
44+
}
45+
46+
@test
47+
@should_fail
48+
fn test_non_admin_cannot_pause() {
49+
example_program.aleo::pause();
50+
}
51+
// ANCHOR_END: test_admin_pair
52+
4053
@noupgrade
4154
constructor() {}
4255
}

documentation/guides/01_finalization.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ Leo enables developers to call entry functions from imported programs. A call to
3535

3636
### The `Final` Type
3737

38-
`Final` is an opaque value: once produced, you can either run it (with `.run()`) or pass it onward to another finalize-aware function, but you **cannot** inspect, copy, reassign, pattern-destructure, or otherwise manipulate it. The compiler enforces this — every `Final` produced in a function must be consumed exactly once on every execution path, and any attempt to use a `Final` "in another way" produces an `ESAZ0374005` error (`Finals should be created, assigned to a variable, and consumed without being moved or reassigned`).
39-
40-
In particular, expressions like `f.0`, `f.1`, … **do not** index the inputs of a `Final`. The `.N` syntax works only on tuples; if a function returns `(record, Final)`, then `result.0` is the record and `result.1` is the `Final` itself, but there is no syntax to peek at the inputs that the `Final` will pass to its finalize body.
38+
`Final` is an opaque value: once produced, you can either run it (with `.run()`) or pass it onward to another finalize-aware function, but you **cannot** inspect, copy, reassign, or otherwise manipulate it. The compiler enforces this — every `Final` produced in a function must be consumed exactly once on every execution path.
4139

4240
If a finalize body needs values that were available in the caller's proof context, pass them as additional arguments to the finalize call rather than trying to extract them from the `Final` afterwards.
4341

@@ -57,7 +55,7 @@ When binding a `Final` to a `let`, you have two options:
5755

5856
`Final<Fn()>` is the type of a finalize value with no inputs (typically produced by an inline `final { }` block whose body references no external state).
5957

60-
The two forms are interchangeable at the binding site; the compiler emits the same code for both. The parametric form is what `Final` expands to internally and what appears in error messages.
58+
The two forms are interchangeable at the binding site; the compiler emits the same code for both. The parametric form is what `Final` expands to internally and what appears in error messages. The type parameters of `Final` are used purely for type-checking the inputs supplied to `.run()`; there is no syntax to read the inputs from a `Final` value.
6159

6260
## Managing Both Public and Private State
6361

documentation/guides/05_signing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ leo account verify -a {$ADDRESS} -m 5field -s sign1signaturehere
5151
✅ The signature is valid
5252

5353
# Error Output:
54-
Error [ECLI0377002]: cli error: ❌ The signature is invalid
54+
Error: ❌ The signature is invalid
5555
```
5656

5757
To verify signatures of signed plaintext values, run:
@@ -64,5 +64,5 @@ leo account verify -a {$ADDRESS} --raw -m "Hello, Aleo" -s sign1signaturehere
6464
✅ The signature is valid
6565

6666
# Error Output:
67-
Error [ECLI0377002]: cli error: ❌ The signature is invalid
67+
Error: ❌ The signature is invalid
6868
```

0 commit comments

Comments
 (0)