Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding in support for mainnet #897

Merged
merged 25 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version: 2.1


orbs:
node: circleci/node@5.1.0
node: circleci/node@5.2.0


executors:
rust-node:
docker:
- image: cimg/rust:1.73-node
- image: cimg/rust:1.80-node


commands:
Expand Down Expand Up @@ -73,6 +73,25 @@ jobs:
yarn test


e2e-testnet:
executor: rust-node
steps:
- setup-sdk
- run:
working_directory: sdk/e2e/testnet
command: |
yarn start

e2e-mainnet:
executor: rust-node
steps:
- setup-sdk
- run:
working_directory: sdk/e2e/mainnet
command: |
yarn start


template-node:
executor: rust-node
steps:
Expand Down Expand Up @@ -119,7 +138,8 @@ jobs:
- run:
working_directory: wasm
command: |
cargo clippy
cargo clippy --features testnet
cargo clippy --features mainnet

check-fmt:
executor: rust-node
Expand All @@ -144,6 +164,12 @@ workflows:
- sdk-test:
requires:
- sdk
- e2e-testnet:
requires:
- sdk
- e2e-mainnet:
requires:
- sdk
- template-node:
requires:
- sdk
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ labels: bug
<!--
What's the bug in the Aleo SDK that you found?
How serious is this bug and what is affected?

Pauan marked this conversation as resolved.
Show resolved Hide resolved
To report a security issue in the Aleo SDK, please email [email protected].
-->

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**/node_modules
**/target
**/dist
**/tmp
storage*/
**/.next

Expand All @@ -18,4 +19,4 @@ rust/src/program/.DS_Store
# Local Netlify folder
.netlify

package-lock.json
package-lock.json
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ several TypeScript & JavaScript libraries which provide the following functional
4. [Management of program state and data](https://provable.tools/record)
5. [Communication with the Aleo network](https://provable.tools/rest)

All of this functionality is demonstrated on [Provable.tools](https://provable.tools).
All of this functionality is demonstrated on [Provable.tools](https://provable.tools).


The Aleo SDK is divided into three TypeScript/JavaScript packages:
Expand All @@ -29,7 +29,7 @@ The official Aleo SDK providing JavaScript/TypeScript tools for creating zero-kn

### ⚡ Build your own app

Start here with the [Aleo SDK Readme](https://github.com/ProvableHQ/sdk#readme) to get started building your
Start here with the [Aleo SDK Readme](https://github.com/ProvableHQ/sdk#readme) to get started building your
first zero-knowledge web app.

#### Source: [`Aleo SDK`](https://www.npmjs.com/package/@provablehq/sdk)
Expand All @@ -47,7 +47,7 @@ start with working examples should start here.
<a href="https://www.npmjs.com/package/@provablehq/nodejs"> <img alt="Create Leo App" src="https://img.shields.io/npm/l/%40provablehq%2Fnodejs?label=NPM%20-%20Aleo%20Nodejs&labelColor=green&color=blue"></a>
<a href="https://crates.io/crates/aleo-wasm"> <img alt="Aleo-Wasm" src="https://img.shields.io/crates/v/aleo-wasm.svg?color=neon"></a>

Aleo Wasm is a Rust crate which compiles the Aleo source code responsible for creating and executing zero-knowledge programs into
Aleo Wasm is a Rust crate which compiles the Aleo source code responsible for creating and executing zero-knowledge programs into
WebAssembly.

When compiled with `wasm-pack`, JavaScript bindings are generated for the WebAssembly allowing Aleo zero-knowledge programs to be used in the browser and Node.js. This package is available on NPM (linked above). The Aleo Wasm
Expand Down
4 changes: 2 additions & 2 deletions create-leo-app/template-react-leo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Your app should be running on http://localhost:5173/

## Deploy program from web app

> [!WARNING]
> [!WARNING]
> This is for demonstration purposes or local testing only, in production applications you
> should avoid building a public facing web app with private key information

Expand All @@ -62,7 +62,7 @@ Aleo programs deployed require unique names, make sure to edit the program's nam
2. (Optional) Provide a fee record manually (located in commented code within `worker.js`)

If you do not provide a manual fee record, the SDK will attempt to scan for a record starting at the latest block. A simple way to speed this up would be to make a public transaction to this account right before deploying.

3. Run the web app and hit the deploy button

## Production deployment
Expand Down
2 changes: 1 addition & 1 deletion create-leo-app/template-react-leo/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function App() {
return (
<>
<div>
<a href="https://aleo.org" target="_blank">
<a href="https://provable.com" target="_blank">
<img src={aleoLogo} className="logo" alt="Aleo logo" />
</a>
<a href="https://react.dev" target="_blank">
Expand Down
4 changes: 2 additions & 2 deletions create-leo-app/template-react-leo/src/workers/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function deployProgram(program) {
keyProvider.useCache(true);

// Create a record provider that will be used to find records and transaction data for Aleo programs
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Use existing account with funds
const account = new Account({
Expand All @@ -48,7 +48,7 @@ async function deployProgram(program) {

// Initialize a program manager to talk to the Aleo network with the configured key and record providers
const programManager = new ProgramManager(
"https://api.explorer.aleo.org/v1",
"https://api.explorer.provable.com/v1",
keyProvider,
recordProvider,
);
Expand Down
2 changes: 1 addition & 1 deletion create-leo-app/template-react-managed-worker/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function App() {
return (
<>
<div>
<a href="https://aleo.org" target="_blank">
<a href="https://provable.com" target="_blank">
<img src={aleoLogo} className="logo" alt="Aleo logo" />
</a>
<a href="https://react.dev" target="_blank">
Expand Down
4 changes: 2 additions & 2 deletions create-leo-app/template-react-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Your app should be running on http://localhost:5173/

## Deploy program from web app

> [!WARNING]
> [!WARNING]
> This is for demonstration purposes or local testing only, in production applications you
> should avoid building a public facing web app with private key information

Expand All @@ -62,7 +62,7 @@ Aleo programs deployed require unique names, make sure to edit the program's nam
2. (Optional) Provide a fee record manually (located in commented code within `worker.js`)

If you do not provide a manual fee record, the SDK will attempt to scan for a record starting at the latest block. A simple way to speed this up would be to make a public transaction to this account right before deploying.

3. Run the web app and hit the deploy button

## Production deployment
Expand Down
2 changes: 1 addition & 1 deletion create-leo-app/template-react-ts/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function App() {
return (
<>
<div>
<a href="https://aleo.org" target="_blank">
<a href="https://provable.com" target="_blank">
<img src={aleoLogo} className="logo" alt="Aleo logo" />
</a>
<a href="https://react.dev" target="_blank">
Expand Down
4 changes: 2 additions & 2 deletions create-leo-app/template-react-ts/src/workers/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function deployProgram(program) {
keyProvider.useCache(true);

// Create a record provider that will be used to find records and transaction data for Aleo programs
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Use existing account with funds
const account = new Account({
Expand All @@ -49,7 +49,7 @@ async function deployProgram(program) {

// Initialize a program manager to talk to the Aleo network with the configured key and record providers
const programManager = new ProgramManager(
"https://api.explorer.aleo.org/v1",
"https://api.explorer.provable.com/v1",
keyProvider,
recordProvider,
);
Expand Down
2 changes: 1 addition & 1 deletion create-leo-app/template-vanilla/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ document.querySelector("#app").innerHTML = `
<a href="https://vitejs.dev" target="_blank">
<img src="${viteLogo}" class="logo" alt="Vite logo" />
</a>
<a href="https://aleo.org/" target="_blank">
<a href="https://provable.com/" target="_blank">
<img src="${aleoLogo}" class="logo" alt="Aleo logo" />
</a>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" target="_blank">
Expand Down
6 changes: 3 additions & 3 deletions create-leo-app/template-vanilla/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function deployProgram(program) {
keyProvider.useCache(true);

// Create a record provider that will be used to find records and transaction data for Aleo programs
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Use existing account with funds
const account = new Account({
Expand All @@ -56,7 +56,7 @@ async function deployProgram(program) {

// Initialize a program manager to talk to the Aleo network with the configured key and record providers
const programManager = new ProgramManager(
"https://api.explorer.aleo.org/v1",
"https://api.explorer.provable.com/v1",
keyProvider,
recordProvider,
);
Expand Down Expand Up @@ -91,5 +91,5 @@ onmessage = async function (e) {
postMessage({ error: error.message });
}
}

};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"wasm",
"website",
"create-leo-app",
"create-leo-app/*"
"create-leo-app/*",
"e2e",
"e2e/*"
],
"type": "module",
"scripts": {
Expand Down
32 changes: 16 additions & 16 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ import { Account, AleoNetworkClient, NetworkRecordProvider, ProgramManager, Aleo
const account = new Account();

// Create a network client to connect to the Aleo network
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Create a key provider that will be used to find public proving & verifying keys for Aleo programs
const keyProvider = new AleoKeyProvider();
Expand All @@ -285,7 +285,7 @@ keyProvider.useCache = true;
const recordProvider = new NetworkRecordProvider(account, networkClient);

// Initialize a program manager to talk to the Aleo network with the configured key and record providers
const programManager = new ProgramManager("https://api.explorer.aleo.org/v1", keyProvider, recordProvider);
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);

// Set the account for the program manager
programManager.setAccount(account);
Expand Down Expand Up @@ -367,7 +367,7 @@ const keyProvider = new AleoKeyProvider();
keyProvider.useCache(true);

// Create a record provider that will be used to find records and transaction data for Aleo programs
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

// Use existing account with funds
const account = new Account({
Expand All @@ -377,7 +377,7 @@ const account = new Account({
const recordProvider = new NetworkRecordProvider(account, networkClient);

// Initialize a program manager to talk to the Aleo network with the configured key and record providers
const programManager = new ProgramManager("https://api.explorer.aleo.org/v1", keyProvider, recordProvider);
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
programManager.setAccount(account)

// Define an Aleo program to deploy
Expand Down Expand Up @@ -429,7 +429,7 @@ A full example of this implementation can be found [here](https://github.com/Pro

Aleo Credits are used to access blockspace and computational resources on the network, with users paying Credits to submit transactions and have them processed.

Aleo credits are defined in the [credits.aleo](https://explorer.aleo.org/program/credits.aleo) program. This program is
Aleo credits are defined in the [credits.aleo](https://explorer.provable.com/program/credits.aleo) program. This program is
deployed to the Aleo network and defines data structures representing Aleo credits and the functions used to manage them.

There are two ways to hold Aleo credits:
Expand Down Expand Up @@ -544,13 +544,13 @@ import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNe

// Create a new NetworkClient, KeyProvider, and RecordProvider
const account = Account.from_string({privateKey: "user1PrivateKey"});
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const keyProvider = new AleoKeyProvider();
const recordProvider = new NetworkRecordProvider(account, networkClient);

// Initialize a program manager with the key provider to automatically fetch keys for executions
const USER_1_ADDRESS = "user1Address";
const programManager = new ProgramManager("https://api.explorer.aleo.org/v1", keyProvider, recordProvider);
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
programManager.setAccount(account);

// Send a private transfer to yourself
Expand Down Expand Up @@ -585,7 +585,7 @@ assert(public_balance === 0);
As shown above, a public balance of any address can be checked with `getMappingValue` function of the `NetworkClient`.

```typescript
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const USER_1_ADDRESS = "user1Address";
const public_balance = networkClient.getMappingValue("credits.aleo", USER_1_ADDRESS);
```
Expand Down Expand Up @@ -674,13 +674,13 @@ import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNe

// Create a new NetworkClient, KeyProvider, and RecordProvider
const account = Account.from_string({privateKey: "user1PrivateKey"});
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const keyProvider = new AleoKeyProvider();
const recordProvider = new NetworkRecordProvider(account, networkClient);

// Initialize a program manager with the key provider to automatically fetch keys for executions
const USER_2_ADDRESS = "user2Address";
const programManager = new ProgramManager("https://api.explorer.aleo.org/v1", keyProvider, recordProvider);
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
programManager.setAccount(account);

/// Send private transfer to User 2
Expand All @@ -695,12 +695,12 @@ import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNe

// Create a new NetworkClient, KeyProvider, and RecordProvider
const account = Account.from_string({privateKey: "user2PrivateKey"});
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const keyProvider = new AleoKeyProvider();
const recordProvider_User2 = new NetworkRecordProvider(account, networkClient);

// Initialize a program manager with the key provider to automatically fetch keys for executions
const programManager = new ProgramManager("https://api.explorer.aleo.org/v1", keyProvider, recordProvider);
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
programManager.setAccount(account);

// Fetch the transaction from the network that user 1 sent
Expand Down Expand Up @@ -863,7 +863,7 @@ read the value of a specific key within a mapping.
```typescript
import { AleoNetworkClient } from '@provablehq/sdk';

const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const creditsMappings = networkClient.getMappings("credits.aleo");
assert(creditsMappings === ["account"]);

Expand Down Expand Up @@ -903,20 +903,20 @@ by the Aleo network. All that the user of the SDK must do is ensure that the inp
If function inputs are invalid, the network will return an error, but the fee paid for the transaction will still be
consumed. Therefore, it is important to ensure that the inputs to a function are valid before executing it.

A simple example of a mapping update can be shown by simply executing 'transfer_public` as shown below.
A simple example of a mapping update can be shown by simply executing `transfer_public` as shown below.

```typescript
import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNetworkClient } from '@provablehq/sdk';

// Create a new NetworkClient, KeyProvider, and RecordProvider
const account = Account.from_string({privateKey: "user1PrivateKey"});
const networkClient = new AleoNetworkClient("https://api.explorer.aleo.org/v1");
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
const keyProvider = new AleoKeyProvider();
const recordProvider = new NetworkRecordProvider(account, networkClient);

// Initialize a program manager with the key provider to automatically fetch keys for executions
const RECIPIENT_ADDRESS = "user1Address";
const programManager = new ProgramManager("https://api.explorer.aleo.org/v1", keyProvider, recordProvider);
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
programManager.setAccount(account);

// Update or initialize a public balance
Expand Down
Loading
Loading