Skip to content

Commit 4a290f7

Browse files
Merge branch 'mainnet' into fix/documentation-cleanup
2 parents 19cf438 + 1d3a5cb commit 4a290f7

16 files changed

+9878
-14248
lines changed

create-leo-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-leo-app",
3-
"version": "0.7.3",
3+
"version": "0.8.2",
44
"type": "module",
55
"license": "GPL-3.0",
66
"collaborators": [

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@provablehq/sdk",
3-
"version": "0.8.0",
3+
"version": "0.8.2",
44
"description": "A Software Development Kit (SDK) for Zero-Knowledge Transactions",
55
"collaborators": [
66
"The Provable Team"

sdk/rollup.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default networks.map((network) => {
3939

4040
// Used by the SDK
4141
"comlink",
42+
`@provablehq/sdk/${network}.js`,
4243
`@provablehq/wasm/${network}.js`,
4344
"core-js/proposals/json-parse-with-source.js",
4445

sdk/src/program-manager.ts

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class ProgramManager {
134134
}
135135

136136
/**
137-
* Deploy an Aleo program to the Aleo network
137+
* Builds a deployment transaction for submission to the Aleo network.
138138
*
139139
* @param {string} program Program source code
140140
* @param {number} fee Fee to pay for the transaction
@@ -158,20 +158,17 @@ class ProgramManager {
158158
* // Define a fee in credits
159159
* const fee = 1.2;
160160
*
161-
* // Deploy the program
162-
* const tx_id = await programManager.deploy(program, fee);
163-
*
164-
* // Verify the transaction was successful
165-
* const transaction = await programManager.networkClient.getTransaction(tx_id);
161+
* // Create the deployment transaction.
162+
* const tx = await programManager.buildDeploymentTransaction(program, fee, false);
166163
*/
167-
async deploy(
164+
async buildDeploymentTransaction(
168165
program: string,
169166
fee: number,
170167
privateFee: boolean,
171168
recordSearchParams?: RecordSearchParams,
172169
feeRecord?: string | RecordPlaintext,
173170
privateKey?: PrivateKey,
174-
): Promise<string> {
171+
): Promise<Transaction> {
175172
// Ensure the program is valid and does not exist on the network
176173
try {
177174
const programObject = Program.fromString(program);
@@ -224,7 +221,49 @@ class ProgramManager {
224221
}
225222

226223
// Build a deployment transaction and submit it to the network
227-
const tx = await WasmProgramManager.buildDeploymentTransaction(deploymentPrivateKey, program, fee, feeRecord, this.host, imports, feeProvingKey, feeVerifyingKey);
224+
return await WasmProgramManager.buildDeploymentTransaction(deploymentPrivateKey, program, fee, feeRecord, this.host, imports, feeProvingKey, feeVerifyingKey);
225+
}
226+
227+
/**
228+
* Deploy an Aleo program to the Aleo network
229+
*
230+
* @param {string} program Program source code
231+
* @param {number} fee Fee to pay for the transaction
232+
* @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
233+
* @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for searching for a record to use
234+
* pay the deployment fee
235+
* @param {string | RecordPlaintext | undefined} feeRecord Optional Fee record to use for the transaction
236+
* @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction
237+
* @returns {string} The transaction id of the deployed program or a failure message from the network
238+
*
239+
* @example
240+
* // Create a new NetworkClient, KeyProvider, and RecordProvider
241+
* const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
242+
* const keyProvider = new AleoKeyProvider();
243+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
244+
*
245+
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
246+
* const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
247+
* const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
248+
*
249+
* // Define a fee in credits
250+
* const fee = 1.2;
251+
*
252+
* // Deploy the program
253+
* const tx_id = await programManager.deploy(program, fee, false);
254+
*
255+
* // Verify the transaction was successful
256+
* const transaction = await programManager.networkClient.getTransaction(tx_id);
257+
*/
258+
async deploy(
259+
program: string,
260+
fee: number,
261+
privateFee: boolean,
262+
recordSearchParams?: RecordSearchParams,
263+
feeRecord?: string | RecordPlaintext,
264+
privateKey?: PrivateKey,
265+
): Promise<string> {
266+
const tx = <Transaction>await this.buildDeploymentTransaction(program, fee, privateFee, recordSearchParams, feeRecord, privateKey);
228267
return await this.networkClient.submitTransaction(tx);
229268
}
230269

sdk/tests/account.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sinon from "sinon";
22
import { expect } from "chai";
3-
import { Account, Address, PrivateKey, RecordCiphertext, ViewKey } from "../src/node";
3+
import { Account, Address, PrivateKey, RecordCiphertext, ViewKey } from "@provablehq/sdk/%%NETWORK%%.js";
44
import { seed, message, beaconPrivateKeyString, beaconViewKeyString, beaconAddressString, recordCiphertextString, foreignCiphertextString, recordPlaintextString } from "./data/account-data";
55

66
describe('Account', () => {

sdk/tests/arithmetic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sinon from "sinon";
22
import { expect } from "chai";
3-
import { Field, Scalar, Group} from "../src/node";
3+
import { Field, Scalar, Group} from "@provablehq/sdk/%%NETWORK%%.js";
44

55
describe('Field and Group Arithmetic Tests', () => {
66
afterEach(() => {

sdk/tests/key-provider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import {AleoKeyProvider, CachedKeyPair, CREDITS_PROGRAM_KEYS, FunctionKeyPair, OfflineKeyProvider, ProvingKey, VerifyingKey} from "../src/node";
2+
import {AleoKeyProvider, CachedKeyPair, CREDITS_PROGRAM_KEYS, FunctionKeyPair, OfflineKeyProvider, ProvingKey, VerifyingKey} from "@provablehq/sdk/%%NETWORK%%.js";
33

44
describe('KeyProvider', () => {
55
let keyProvider: AleoKeyProvider;

sdk/tests/network-client.integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from "chai";
22
import {beaconAddressString, beaconPrivateKeyString} from "./data/account-data";
3-
import {Account, AleoNetworkClient} from "../src/browser";
3+
import {Account, AleoNetworkClient} from "@provablehq/sdk/%%NETWORK%%.js";
44

55
describe('NodeConnection', () => {
66
let localApiClient: AleoNetworkClient;

sdk/tests/network-client.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ import {
77
TransactionObject,
88
InputObject,
99
OutputObject,
10-
ExecutionObject
11-
} from "../src/node";
10+
ExecutionObject,
11+
DeploymentObject,
12+
ExecutionJSON,
13+
InputJSON,
14+
OutputJSON,
15+
Plaintext,
16+
PlaintextObject,
17+
Transition,
18+
TransitionObject,
19+
} from "@provablehq/sdk/%%NETWORK%%.js";
1220
import { beaconPrivateKeyString } from "./data/account-data";
13-
import { DeploymentObject, ExecutionJSON, InputJSON, OutputJSON, Plaintext, PlaintextObject, Transition, TransitionObject } from "../src/node";
1421

1522
async function catchError(f: () => Promise<any>): Promise<Error | null> {
1623
try {

sdk/tests/program-manager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
statePathRecordOwnerPrivateKey,
88
stateRoot
99
} from "./data/account-data";
10-
import { Account, ExecutionResponse, OfflineQuery, ProgramManager, RecordPlaintext } from "../src/node";
10+
import { Account, ExecutionResponse, OfflineQuery, ProgramManager, RecordPlaintext } from "@provablehq/sdk/%%NETWORK%%.js";
1111

1212
describe('Program Manager', () => {
1313
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", undefined, undefined);

0 commit comments

Comments
 (0)