Skip to content

Commit 6f9b376

Browse files
Bump the SDK to version 0.8.2 and add buildDeploymentTransaction method for building deployment transactions offline
1 parent 9b01578 commit 6f9b376

File tree

5 files changed

+9855
-14235
lines changed

5 files changed

+9855
-14235
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/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

wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@provablehq/wasm",
3-
"version": "0.8.0",
3+
"version": "0.8.2",
44
"description": "SnarkVM WASM binaries with javascript bindings",
55
"collaborators": [
66
"The Provable Team"

0 commit comments

Comments
 (0)