Skip to content

Commit a9c8da1

Browse files
Build SDK docs
1 parent 1b26998 commit a9c8da1

File tree

3 files changed

+105
-9
lines changed

3 files changed

+105
-9
lines changed

docs/api_reference/sdk-src_account.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,21 +504,23 @@ const viewKey = account.viewKey();
504504

505505
---
506506

507-
### `computeKey() ► Field`
507+
### `computeKey() ► ComputeKey`
508508

509509
![modifier: public](images/badges/modifier-public.svg)
510510

511-
Returns the Transition View Key associated with the transition public key.
511+
Returns the ComputeKey associated with the account.
512512

513513
Parameters | Type | Description
514514
--- | --- | ---
515-
__*return*__ | [Field](sdk-src_wasm.md) | *The transition view key*
515+
__*return*__ | `ComputeKey` | *The compute key of the account*
516516

517517
#### Examples
518518

519519
```javascript
520520
import { Account } from "@provablehq/sdk/testnet.js";
521-
const account =
521+
522+
const account = new Account();
523+
const computeKey = account.computeKey();
522524
```
523525

524526
---

docs/api_reference/sdk-src_program-manager.md

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,44 @@ const authorization = await programManager.buildAuthorization({
311311

312312
---
313313

314+
### `buildAuthorizationUnchecked(options) ► Promise.<Authorization>`
315+
316+
![modifier: public](images/badges/modifier-public.svg)
317+
318+
Builds a SnarkVM &#x60;Authorization&#x60; for a specific function without building a circuit first. This should be used when fast authorization generation is needed and the invoker is confident inputs are coorect.
319+
320+
Parameters | Type | Description
321+
--- | --- | ---
322+
__options__ | `AuthorizationOptions` | *The options for building the &#x60;Authorization&#x60;*
323+
__*return*__ | `Promise.<Authorization>` | *- A promise that resolves to an &#x60;Authorization&#x60; or throws an Error.*
324+
325+
#### Examples
326+
327+
```javascript
328+
/// Import the mainnet version of the sdk.
329+
import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
330+
331+
// Create a new NetworkClient, KeyProvider, and RecordProvider.
332+
const keyProvider = new AleoKeyProvider();
333+
const recordProvider = new NetworkRecordProvider(account, networkClient);
334+
keyProvider.useCache = true;
335+
336+
// Initialize a ProgramManager with the key and record providers.
337+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
338+
339+
// Build the unchecked `Authorization`.
340+
const authorization = await programManager.buildAuthorizationUnchecked({
341+
programName: "credits.aleo",
342+
functionName: "transfer_public",
343+
inputs: [
344+
"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
345+
"10000000u64",
346+
],
347+
});
348+
```
349+
350+
---
351+
314352
### `buildFeeAuthorization(options) ► Promise.<Authorization>`
315353

316354
![modifier: public](images/badges/modifier-public.svg)
@@ -1129,7 +1167,7 @@ setTimeout(async () => {
11291167

11301168
---
11311169

1132-
### `verifyExecution(executionResponse, imports, importedVerifyingKeys) ► boolean`
1170+
### `verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys) ► boolean`
11331171

11341172
![modifier: public](images/badges/modifier-public.svg)
11351173

@@ -1138,6 +1176,7 @@ Verify a proof from an offline execution. This is useful when it is desired to d
11381176
Parameters | Type | Description
11391177
--- | --- | ---
11401178
__executionResponse__ | `executionResponse` | *The response from an offline function execution (via the &#x60;programManager.run&#x60; method)*
1179+
__blockHeight__ | `blockHeight` | *The ledger height when the execution was generated.*
11411180
__imports__ | `ImportedPrograms` | *The imported programs used in the execution. Specified as { &quot;programName&quot;: &quot;programSourceCode&quot;, ... }*
11421181
__importedVerifyingKeys__ | `ImportedVerifyingKeys` | *The verifying keys in the execution. Specified as { &quot;programName&quot;: [[&quot;functionName&quot;, &quot;verifyingKey&quot;], ...], ... }*
11431182
__*return*__ | `boolean` | *True if the proof is valid, false otherwise*
@@ -1165,7 +1204,7 @@ const imports = { "add_it_up.aleo": program_import };
11651204
const importedVerifyingKeys = { "add_it_up.aleo": [["add_it", "verifyingKey1..."]] };
11661205

11671206
/// Verify the execution.
1168-
let blockHeight = 9_000_000;
1207+
const blockHeight = 9000000;
11691208
const isValid = programManager.verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys);
11701209
assert(isValid);
11711210
```
@@ -1498,6 +1537,44 @@ const authorization = await programManager.buildAuthorization({
14981537

14991538
---
15001539

1540+
### `buildAuthorizationUnchecked(options) ► Promise.<Authorization>`
1541+
1542+
![modifier: public](images/badges/modifier-public.svg)
1543+
1544+
Builds a SnarkVM &#x60;Authorization&#x60; for a specific function without building a circuit first. This should be used when fast authorization generation is needed and the invoker is confident inputs are coorect.
1545+
1546+
Parameters | Type | Description
1547+
--- | --- | ---
1548+
__options__ | `AuthorizationOptions` | *The options for building the &#x60;Authorization&#x60;*
1549+
__*return*__ | `Promise.<Authorization>` | *- A promise that resolves to an &#x60;Authorization&#x60; or throws an Error.*
1550+
1551+
#### Examples
1552+
1553+
```javascript
1554+
/// Import the mainnet version of the sdk.
1555+
import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
1556+
1557+
// Create a new NetworkClient, KeyProvider, and RecordProvider.
1558+
const keyProvider = new AleoKeyProvider();
1559+
const recordProvider = new NetworkRecordProvider(account, networkClient);
1560+
keyProvider.useCache = true;
1561+
1562+
// Initialize a ProgramManager with the key and record providers.
1563+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
1564+
1565+
// Build the unchecked `Authorization`.
1566+
const authorization = await programManager.buildAuthorizationUnchecked({
1567+
programName: "credits.aleo",
1568+
functionName: "transfer_public",
1569+
inputs: [
1570+
"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
1571+
"10000000u64",
1572+
],
1573+
});
1574+
```
1575+
1576+
---
1577+
15011578
### `buildFeeAuthorization(options) ► Promise.<Authorization>`
15021579

15031580
![modifier: public](images/badges/modifier-public.svg)
@@ -2316,7 +2393,7 @@ setTimeout(async () => {
23162393

23172394
---
23182395

2319-
### `verifyExecution(executionResponse, imports, importedVerifyingKeys) ► boolean`
2396+
### `verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys) ► boolean`
23202397

23212398
![modifier: public](images/badges/modifier-public.svg)
23222399

@@ -2325,6 +2402,7 @@ Verify a proof from an offline execution. This is useful when it is desired to d
23252402
Parameters | Type | Description
23262403
--- | --- | ---
23272404
__executionResponse__ | `executionResponse` | *The response from an offline function execution (via the &#x60;programManager.run&#x60; method)*
2405+
__blockHeight__ | `blockHeight` | *The ledger height when the execution was generated.*
23282406
__imports__ | `ImportedPrograms` | *The imported programs used in the execution. Specified as { &quot;programName&quot;: &quot;programSourceCode&quot;, ... }*
23292407
__importedVerifyingKeys__ | `ImportedVerifyingKeys` | *The verifying keys in the execution. Specified as { &quot;programName&quot;: [[&quot;functionName&quot;, &quot;verifyingKey&quot;], ...], ... }*
23302408
__*return*__ | `boolean` | *True if the proof is valid, false otherwise*
@@ -2352,7 +2430,8 @@ const imports = { "add_it_up.aleo": program_import };
23522430
const importedVerifyingKeys = { "add_it_up.aleo": [["add_it", "verifyingKey1..."]] };
23532431

23542432
/// Verify the execution.
2355-
const isValid = programManager.verifyExecution(executionResponse, imports, importedVerifyingKeys);
2433+
const blockHeight = 9000000;
2434+
const isValid = programManager.verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys);
23562435
assert(isValid);
23572436
```
23582437

docs/api_reference/sdk-src_wasm.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2759,7 +2759,7 @@ __*return*__ | `string` | *Nonce of the record*
27592759
27602760
---
27612761
2762-
### `serialNumberString(private_key, program_id, record_name) ► string`
2762+
### `serialNumberString(private_key, program_id, record_name, record_view_key) ► string`
27632763
27642764
![modifier: public](images/badges/modifier-public.svg)
27652765
@@ -2770,6 +2770,7 @@ Parameters | Type | Description
27702770
__private_key__ | [PrivateKey](sdk-src_wasm.md) | *Private key of the account that owns the record*
27712771
__program_id__ | `string` | *Program ID of the program that the record is associated with*
27722772
__record_name__ | `string` | *Name of the record*
2773+
__record_view_key__ | `string` | *The string representation of the record view key.*
27732774
__*return*__ | `string` | *Serial number of the record*
27742775
27752776
---
@@ -2788,6 +2789,20 @@ __*return*__ | [Field](sdk-src_wasm.md) | **
27882789
27892790
---
27902791
2792+
### `recordViewKey(view_key) ► Group`
2793+
2794+
![modifier: public](images/badges/modifier-public.svg)
2795+
2796+
Generate the record view key. The record view key can only decrypt record if the
2797+
supplied view key belongs to the record owner.
2798+
2799+
Parameters | Type | Description
2800+
--- | --- | ---
2801+
__view_key__ | `ViewKey` | *View key used to generate the record view key*
2802+
__*return*__ | [Group](sdk-src_wasm.md) | *record view key*
2803+
2804+
---
2805+
27912806
# Class `Scalar`
27922807
27932808
Scalar field element.

0 commit comments

Comments
 (0)