@provablehq/sdk 0.11.5 → 0.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mainnet/browser.cjs +215 -50
- package/dist/mainnet/browser.cjs.map +1 -1
- package/dist/mainnet/browser.d.cts +1 -1
- package/dist/mainnet/browser.d.ts +1 -1
- package/dist/mainnet/browser.js +215 -51
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/node.cjs +1 -0
- package/dist/mainnet/node.cjs.map +1 -1
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/program-manager.d.cts +82 -3
- package/dist/mainnet/program-manager.d.ts +82 -3
- package/dist/testnet/browser.cjs +215 -50
- package/dist/testnet/browser.cjs.map +1 -1
- package/dist/testnet/browser.d.cts +1 -1
- package/dist/testnet/browser.d.ts +1 -1
- package/dist/testnet/browser.js +215 -51
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/node.cjs +1 -0
- package/dist/testnet/node.cjs.map +1 -1
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/program-manager.d.cts +82 -3
- package/dist/testnet/program-manager.d.ts +82 -3
- package/package.json +2 -2
|
@@ -61,7 +61,7 @@ import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./rec
|
|
|
61
61
|
import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
|
|
62
62
|
import { generateHookData } from "./integrations/circle/hook-data.js";
|
|
63
63
|
declare function initializeWasm(): Promise<void>;
|
|
64
|
-
export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof, programChecksum } from "./program-manager.js";
|
|
64
|
+
export { ProgramManager, PreparedProgram, PrepareProgramOptions, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof, programChecksum } from "./program-manager.js";
|
|
65
65
|
export { logAndThrow, TransportFunction, defaultTransport, cookieAffinityTransport } from "./utils/utils.js";
|
|
66
66
|
export { setLogLevel, getLogLevel } from "./utils/logger.js";
|
|
67
67
|
export type { LogLevel } from "./utils/logger.js";
|
|
@@ -61,7 +61,7 @@ import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./rec
|
|
|
61
61
|
import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
|
|
62
62
|
import { generateHookData } from "./integrations/circle/hook-data.js";
|
|
63
63
|
declare function initializeWasm(): Promise<void>;
|
|
64
|
-
export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof, programChecksum } from "./program-manager.js";
|
|
64
|
+
export { ProgramManager, PreparedProgram, PrepareProgramOptions, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof, programChecksum } from "./program-manager.js";
|
|
65
65
|
export { logAndThrow, TransportFunction, defaultTransport, cookieAffinityTransport } from "./utils/utils.js";
|
|
66
66
|
export { setLogLevel, getLogLevel } from "./utils/logger.js";
|
|
67
67
|
export type { LogLevel } from "./utils/logger.js";
|
package/dist/testnet/browser.js
CHANGED
|
@@ -1602,7 +1602,7 @@ class AleoNetworkClient {
|
|
|
1602
1602
|
else {
|
|
1603
1603
|
this.headers = {
|
|
1604
1604
|
// This is replaced by the actual version by a Rollup plugin
|
|
1605
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1605
|
+
"X-Aleo-SDK-Version": "0.11.7",
|
|
1606
1606
|
"X-Aleo-environment": environment(),
|
|
1607
1607
|
};
|
|
1608
1608
|
}
|
|
@@ -1618,7 +1618,7 @@ class AleoNetworkClient {
|
|
|
1618
1618
|
else {
|
|
1619
1619
|
this.headers = {
|
|
1620
1620
|
// This is replaced by the actual version by a Rollup plugin
|
|
1621
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1621
|
+
"X-Aleo-SDK-Version": "0.11.7",
|
|
1622
1622
|
"X-Aleo-environment": environment(),
|
|
1623
1623
|
};
|
|
1624
1624
|
}
|
|
@@ -5798,6 +5798,56 @@ function generateHookData(recipientAddress, secretNonce) {
|
|
|
5798
5798
|
return hookData;
|
|
5799
5799
|
}
|
|
5800
5800
|
|
|
5801
|
+
const preparedProgramBuilders = new WeakMap();
|
|
5802
|
+
function clonePreparedProgramBuilder(preparedProgram) {
|
|
5803
|
+
const builder = preparedProgramBuilders.get(preparedProgram);
|
|
5804
|
+
if (!builder) {
|
|
5805
|
+
throw new Error("Prepared program has already been freed");
|
|
5806
|
+
}
|
|
5807
|
+
// The WASM clone is a cheap shared Rc handle, not a deep copy. Mutations
|
|
5808
|
+
// made while authorizing intentionally remain cached in the prepared context.
|
|
5809
|
+
return builder.clone();
|
|
5810
|
+
}
|
|
5811
|
+
function programImportsFromBuilder(builder, entryProgramName) {
|
|
5812
|
+
const imports = {};
|
|
5813
|
+
for (const name of Array.from(builder.programNames())) {
|
|
5814
|
+
if (name === entryProgramName)
|
|
5815
|
+
continue;
|
|
5816
|
+
const source = builder.getProgram(name);
|
|
5817
|
+
if (source)
|
|
5818
|
+
imports[name] = source;
|
|
5819
|
+
}
|
|
5820
|
+
return imports;
|
|
5821
|
+
}
|
|
5822
|
+
/**
|
|
5823
|
+
* A reusable program context created by {@link ProgramManager.prepareProgram}.
|
|
5824
|
+
*
|
|
5825
|
+
* The context is scoped to one program function. Calls using it must be
|
|
5826
|
+
* sequential. The caller owns the context and should call {@link free} when it
|
|
5827
|
+
* is no longer needed.
|
|
5828
|
+
*/
|
|
5829
|
+
class PreparedProgram {
|
|
5830
|
+
programName;
|
|
5831
|
+
functionName;
|
|
5832
|
+
programSource;
|
|
5833
|
+
edition;
|
|
5834
|
+
/**
|
|
5835
|
+
* Instances are normally created through {@link ProgramManager.prepareProgram}.
|
|
5836
|
+
*/
|
|
5837
|
+
constructor(programName, functionName, programSource, edition) {
|
|
5838
|
+
this.programName = programName;
|
|
5839
|
+
this.functionName = functionName;
|
|
5840
|
+
this.programSource = programSource;
|
|
5841
|
+
this.edition = edition;
|
|
5842
|
+
}
|
|
5843
|
+
/**
|
|
5844
|
+
* Release the prepared snarkVM process. This method is idempotent.
|
|
5845
|
+
*/
|
|
5846
|
+
free() {
|
|
5847
|
+
preparedProgramBuilders.get(this)?.free();
|
|
5848
|
+
preparedProgramBuilders.delete(this);
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5801
5851
|
/**
|
|
5802
5852
|
* The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
|
|
5803
5853
|
*/
|
|
@@ -5906,6 +5956,93 @@ class ProgramManager {
|
|
|
5906
5956
|
setKeyStore(keyStore) {
|
|
5907
5957
|
this._keyStore = keyStore;
|
|
5908
5958
|
}
|
|
5959
|
+
/**
|
|
5960
|
+
* Prepare a program for later authorization or proving-request generation.
|
|
5961
|
+
*
|
|
5962
|
+
* This resolves the source, edition, and transitive imports and initializes
|
|
5963
|
+
* the underlying snarkVM process without accessing a private key. Reuse the
|
|
5964
|
+
* returned context through the `preparedProgram` option, then call `free()`
|
|
5965
|
+
* when it is no longer needed.
|
|
5966
|
+
*
|
|
5967
|
+
* @param options Program and function to prepare.
|
|
5968
|
+
* @returns A reusable, caller-owned context.
|
|
5969
|
+
*
|
|
5970
|
+
* @example
|
|
5971
|
+
* const prepared = await programManager.prepareProgram({
|
|
5972
|
+
* programName: "hello_hello.aleo",
|
|
5973
|
+
* functionName: "hello",
|
|
5974
|
+
* });
|
|
5975
|
+
* try {
|
|
5976
|
+
* const authorization = await programManager.buildAuthorization({
|
|
5977
|
+
* programName: "hello_hello.aleo",
|
|
5978
|
+
* functionName: "hello",
|
|
5979
|
+
* inputs: ["5u32", "5u32"],
|
|
5980
|
+
* preparedProgram: prepared,
|
|
5981
|
+
* });
|
|
5982
|
+
* } finally {
|
|
5983
|
+
* prepared.free();
|
|
5984
|
+
* }
|
|
5985
|
+
*/
|
|
5986
|
+
async prepareProgram(options) {
|
|
5987
|
+
let program = options.programSource;
|
|
5988
|
+
if (program === undefined) {
|
|
5989
|
+
try {
|
|
5990
|
+
program = await this.networkClient.getProgram(options.programName);
|
|
5991
|
+
}
|
|
5992
|
+
catch (e) {
|
|
5993
|
+
logAndThrow(`Error finding ${options.programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`);
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
else if (program instanceof Program) {
|
|
5997
|
+
program = program.toString();
|
|
5998
|
+
}
|
|
5999
|
+
const parsedProgram = Program.fromString(program);
|
|
6000
|
+
if (parsedProgram.id() !== options.programName) {
|
|
6001
|
+
throw new Error(`Program source ID '${parsedProgram.id()}' does not match requested program '${options.programName}'`);
|
|
6002
|
+
}
|
|
6003
|
+
if (!parsedProgram.getFunctions().includes(options.functionName)) {
|
|
6004
|
+
throw new Error(`Function '${options.functionName}' does not exist in program '${options.programName}'`);
|
|
6005
|
+
}
|
|
6006
|
+
const edition = options.edition
|
|
6007
|
+
?? (await this.resolveEditionAndAmendment(options.programName)).edition;
|
|
6008
|
+
const { builder } = await this.buildProgramImports(program, options.programImports, false, options.functionName);
|
|
6009
|
+
// Add the entry program as well as its imports so the snarkVM process is
|
|
6010
|
+
// fully initialized before an authorization is requested.
|
|
6011
|
+
builder.addProgram(options.programName, program, edition);
|
|
6012
|
+
const preparedProgram = new PreparedProgram(options.programName, options.functionName, program, edition);
|
|
6013
|
+
preparedProgramBuilders.set(preparedProgram, builder);
|
|
6014
|
+
return preparedProgram;
|
|
6015
|
+
}
|
|
6016
|
+
validatePreparedProgram(preparedProgram, options) {
|
|
6017
|
+
if (preparedProgram.programName !== options.programName
|
|
6018
|
+
|| preparedProgram.functionName !== options.functionName) {
|
|
6019
|
+
throw new Error(`Prepared program is for ${preparedProgram.programName}/${preparedProgram.functionName}, not ${options.programName}/${options.functionName}`);
|
|
6020
|
+
}
|
|
6021
|
+
const providedSource = options.programSource instanceof Program
|
|
6022
|
+
? options.programSource.toString()
|
|
6023
|
+
: options.programSource;
|
|
6024
|
+
if (providedSource !== undefined
|
|
6025
|
+
&& providedSource !== preparedProgram.programSource) {
|
|
6026
|
+
throw new Error("Prepared program source does not match the supplied program source");
|
|
6027
|
+
}
|
|
6028
|
+
if (options.edition !== undefined
|
|
6029
|
+
&& options.edition !== preparedProgram.edition) {
|
|
6030
|
+
throw new Error("Prepared program edition does not match the supplied edition");
|
|
6031
|
+
}
|
|
6032
|
+
if (options.programImports) {
|
|
6033
|
+
const builder = clonePreparedProgramBuilder(preparedProgram);
|
|
6034
|
+
try {
|
|
6035
|
+
for (const [name, source] of Object.entries(options.programImports)) {
|
|
6036
|
+
if (builder.getProgram(name) !== source.toString()) {
|
|
6037
|
+
throw new Error(`Prepared program import '${name}' does not match the supplied import`);
|
|
6038
|
+
}
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
finally {
|
|
6042
|
+
builder.free();
|
|
6043
|
+
}
|
|
6044
|
+
}
|
|
6045
|
+
}
|
|
5909
6046
|
/**
|
|
5910
6047
|
* Collect static imports declared by the entry program together with any
|
|
5911
6048
|
* caller-provided imports, then resolve missing transitive dependencies.
|
|
@@ -6906,11 +7043,15 @@ class ProgramManager {
|
|
|
6906
7043
|
async buildAuthorization(options) {
|
|
6907
7044
|
// Destructure the options object to access the parameters.
|
|
6908
7045
|
const { functionName, inputs, } = options;
|
|
7046
|
+
const preparedProgram = options.preparedProgram;
|
|
7047
|
+
if (preparedProgram) {
|
|
7048
|
+
this.validatePreparedProgram(preparedProgram, options);
|
|
7049
|
+
}
|
|
6909
7050
|
const privateKey = options.privateKey;
|
|
6910
|
-
let program = options.programSource;
|
|
6911
|
-
let programName = options.programName;
|
|
6912
|
-
|
|
6913
|
-
let edition = options.edition;
|
|
7051
|
+
let program = preparedProgram?.programSource ?? options.programSource;
|
|
7052
|
+
let programName = preparedProgram?.programName ?? options.programName;
|
|
7053
|
+
const imports = options.programImports;
|
|
7054
|
+
let edition = preparedProgram?.edition ?? options.edition;
|
|
6914
7055
|
// Ensure the function exists on the network.
|
|
6915
7056
|
if (program === undefined) {
|
|
6916
7057
|
try {
|
|
@@ -6936,16 +7077,21 @@ class ProgramManager {
|
|
|
6936
7077
|
if (typeof executionPrivateKey === "undefined") {
|
|
6937
7078
|
throw "No private key provided and no private key set in the ProgramManager";
|
|
6938
7079
|
}
|
|
6939
|
-
|
|
6940
|
-
|
|
7080
|
+
if (!preparedProgram) {
|
|
7081
|
+
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7082
|
+
edition = edition ?? resolved.edition;
|
|
7083
|
+
}
|
|
6941
7084
|
// Auto-convert bare string inputs to field elements where the function expects field type.
|
|
6942
7085
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
6943
7086
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
6944
7087
|
// authorizations don't synthesize keys).
|
|
6945
|
-
const
|
|
7088
|
+
const builder = preparedProgram
|
|
7089
|
+
? clonePreparedProgramBuilder(preparedProgram)
|
|
7090
|
+
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7091
|
+
const hasPreparedProcess = preparedProgram !== undefined;
|
|
6946
7092
|
const hasImports = !builder.isEmpty();
|
|
6947
7093
|
// Build and return an `Authorization` for the desired function.
|
|
6948
|
-
const authorization = await ProgramManager$1.authorize(executionPrivateKey, program, functionName, preparedInputs, hasImports ? undefined : imports, edition, hasImports ? builder
|
|
7094
|
+
const authorization = await ProgramManager$1.authorize(executionPrivateKey, program, functionName, preparedInputs, hasPreparedProcess || hasImports ? undefined : imports, edition, hasPreparedProcess ? builder : hasImports ? builder.clone() : undefined);
|
|
6949
7095
|
return authorization;
|
|
6950
7096
|
}
|
|
6951
7097
|
/**
|
|
@@ -6979,11 +7125,15 @@ class ProgramManager {
|
|
|
6979
7125
|
async buildAuthorizationUnchecked(options) {
|
|
6980
7126
|
// Destructure the options object to access the parameters.
|
|
6981
7127
|
const { functionName, inputs, } = options;
|
|
7128
|
+
const preparedProgram = options.preparedProgram;
|
|
7129
|
+
if (preparedProgram) {
|
|
7130
|
+
this.validatePreparedProgram(preparedProgram, options);
|
|
7131
|
+
}
|
|
6982
7132
|
const privateKey = options.privateKey;
|
|
6983
|
-
let program = options.programSource;
|
|
6984
|
-
let programName = options.programName;
|
|
6985
|
-
|
|
6986
|
-
let edition = options.edition;
|
|
7133
|
+
let program = preparedProgram?.programSource ?? options.programSource;
|
|
7134
|
+
let programName = preparedProgram?.programName ?? options.programName;
|
|
7135
|
+
const imports = options.programImports;
|
|
7136
|
+
let edition = preparedProgram?.edition ?? options.edition;
|
|
6987
7137
|
// Ensure the function exists on the network.
|
|
6988
7138
|
if (program === undefined) {
|
|
6989
7139
|
try {
|
|
@@ -7009,16 +7159,21 @@ class ProgramManager {
|
|
|
7009
7159
|
if (typeof executionPrivateKey === "undefined") {
|
|
7010
7160
|
throw "No private key provided and no private key set in the ProgramManager";
|
|
7011
7161
|
}
|
|
7012
|
-
|
|
7013
|
-
|
|
7162
|
+
if (!preparedProgram) {
|
|
7163
|
+
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7164
|
+
edition = edition ?? resolved.edition;
|
|
7165
|
+
}
|
|
7014
7166
|
// Auto-convert bare string inputs to field elements where the function expects field type.
|
|
7015
7167
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7016
7168
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7017
7169
|
// authorizations don't synthesize keys).
|
|
7018
|
-
const
|
|
7170
|
+
const builder = preparedProgram
|
|
7171
|
+
? clonePreparedProgramBuilder(preparedProgram)
|
|
7172
|
+
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7173
|
+
const hasPreparedProcess = preparedProgram !== undefined;
|
|
7019
7174
|
const hasImports = !builder.isEmpty();
|
|
7020
7175
|
// Build and return an `Authorization` for the desired function.
|
|
7021
|
-
const authorization = await ProgramManager$1.buildAuthorizationUnchecked(executionPrivateKey, program, functionName, preparedInputs, hasImports ? undefined : imports, edition, hasImports ? builder
|
|
7176
|
+
const authorization = await ProgramManager$1.buildAuthorizationUnchecked(executionPrivateKey, program, functionName, preparedInputs, hasPreparedProcess || hasImports ? undefined : imports, edition, hasPreparedProcess ? builder : hasImports ? builder.clone() : undefined);
|
|
7022
7177
|
return authorization;
|
|
7023
7178
|
}
|
|
7024
7179
|
/**
|
|
@@ -7055,14 +7210,18 @@ class ProgramManager {
|
|
|
7055
7210
|
async provingRequest(options) {
|
|
7056
7211
|
// Destructure the options object to access the parameters.
|
|
7057
7212
|
const { functionName, priorityFee, privateFee, inputs, recordSearchParams, broadcast = false, unchecked = false, } = options;
|
|
7213
|
+
const preparedProgram = options.preparedProgram;
|
|
7214
|
+
if (preparedProgram) {
|
|
7215
|
+
this.validatePreparedProgram(preparedProgram, options);
|
|
7216
|
+
}
|
|
7058
7217
|
const baseFee = options.baseFee ? options.baseFee : 0;
|
|
7059
7218
|
const privateKey = options.privateKey;
|
|
7060
7219
|
const useFeeMaster = options.useFeeMaster ? options.useFeeMaster : false;
|
|
7061
|
-
let program = options.programSource;
|
|
7062
|
-
let programName = options.programName;
|
|
7220
|
+
let program = preparedProgram?.programSource ?? options.programSource;
|
|
7221
|
+
let programName = preparedProgram?.programName ?? options.programName;
|
|
7063
7222
|
let feeRecord = options.feeRecord;
|
|
7064
7223
|
let imports = options.programImports;
|
|
7065
|
-
let edition = options.edition;
|
|
7224
|
+
let edition = preparedProgram?.edition ?? options.edition;
|
|
7066
7225
|
if (!inputs && !options.executionRequest) {
|
|
7067
7226
|
throw new Error("Either function inputs or an execution request must be provided to form a proving request");
|
|
7068
7227
|
}
|
|
@@ -7082,8 +7241,10 @@ class ProgramManager {
|
|
|
7082
7241
|
if (programName === undefined) {
|
|
7083
7242
|
programName = Program.fromString(program).id();
|
|
7084
7243
|
}
|
|
7085
|
-
|
|
7086
|
-
|
|
7244
|
+
if (!preparedProgram) {
|
|
7245
|
+
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7246
|
+
edition = edition ?? resolved.edition;
|
|
7247
|
+
}
|
|
7087
7248
|
// Get the private key from the account if it is not provided in the parameters.
|
|
7088
7249
|
let executionPrivateKey = privateKey;
|
|
7089
7250
|
if (typeof privateKey === "undefined" &&
|
|
@@ -7093,7 +7254,7 @@ class ProgramManager {
|
|
|
7093
7254
|
}
|
|
7094
7255
|
// Resolve the program imports if they exist.
|
|
7095
7256
|
const numberOfImports = Program.fromString(program).getImports().length;
|
|
7096
|
-
if (numberOfImports > 0 && !imports) {
|
|
7257
|
+
if (!preparedProgram && numberOfImports > 0 && !imports) {
|
|
7097
7258
|
try {
|
|
7098
7259
|
imports = (await this.networkClient.getProgramImports(programName));
|
|
7099
7260
|
}
|
|
@@ -7101,6 +7262,28 @@ class ProgramManager {
|
|
|
7101
7262
|
logAndThrow(`Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`);
|
|
7102
7263
|
}
|
|
7103
7264
|
}
|
|
7265
|
+
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7266
|
+
// proving requests don't synthesize keys).
|
|
7267
|
+
const builder = preparedProgram
|
|
7268
|
+
? clonePreparedProgramBuilder(preparedProgram)
|
|
7269
|
+
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7270
|
+
const hasPreparedProcess = preparedProgram !== undefined;
|
|
7271
|
+
const hasImports = !builder.isEmpty();
|
|
7272
|
+
// Normalize imports once to the full merged set from the builder so
|
|
7273
|
+
// both the private-fee estimate below and the Rust-side fee estimator
|
|
7274
|
+
// (estimate_fee_for_authorization uses the legacy imports Object to
|
|
7275
|
+
// avoid a RefCell double-borrow — see proving_request.rs) see all
|
|
7276
|
+
// transitive imports, not just the caller's partial set. Use
|
|
7277
|
+
// programNames + getProgram to avoid serializing key bytes (toObject
|
|
7278
|
+
// would serialize all proving/verifying keys, which can be tens of
|
|
7279
|
+
// MB). The prepared executionRequest path skips the copy: it passes
|
|
7280
|
+
// the process builder directly and never estimates fees, so the
|
|
7281
|
+
// imports Object goes unused there.
|
|
7282
|
+
const importsObjectUnused = hasPreparedProcess
|
|
7283
|
+
&& options.executionRequest instanceof ExecutionRequest;
|
|
7284
|
+
if ((hasPreparedProcess || hasImports) && !importsObjectUnused) {
|
|
7285
|
+
imports = programImportsFromBuilder(builder, programName);
|
|
7286
|
+
}
|
|
7104
7287
|
// Get the fee record from the account if it is not provided in the parameters
|
|
7105
7288
|
try {
|
|
7106
7289
|
if (privateFee && !useFeeMaster && !options.executionRequest) {
|
|
@@ -7121,30 +7304,11 @@ class ProgramManager {
|
|
|
7121
7304
|
catch (e) {
|
|
7122
7305
|
logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
|
|
7123
7306
|
}
|
|
7124
|
-
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7125
|
-
// proving requests don't synthesize keys).
|
|
7126
|
-
// Note: imports is kept for the Rust-side fee estimation fallback
|
|
7127
|
-
// (estimate_fee_for_authorization uses the legacy imports Object to avoid
|
|
7128
|
-
// a RefCell double-borrow — see proving_request.rs).
|
|
7129
|
-
const { builder } = await this.buildProgramImports(program, imports, false, functionName);
|
|
7130
|
-
const hasImports = !builder.isEmpty();
|
|
7131
|
-
// Normalize imports to the full merged set from the builder so the
|
|
7132
|
-
// Rust fee estimator sees all transitive imports, not just the
|
|
7133
|
-
// caller's partial set. Use programNames + getProgram to avoid
|
|
7134
|
-
// serializing key bytes (toObject would serialize all proving/
|
|
7135
|
-
// verifying keys, which can be tens of MB).
|
|
7136
|
-
if (hasImports) {
|
|
7137
|
-
const merged = {};
|
|
7138
|
-
for (const name of Array.from(builder.programNames())) {
|
|
7139
|
-
const src = builder.getProgram(name);
|
|
7140
|
-
if (src)
|
|
7141
|
-
merged[name] = src;
|
|
7142
|
-
}
|
|
7143
|
-
imports = merged;
|
|
7144
|
-
}
|
|
7145
7307
|
if (options.executionRequest instanceof ExecutionRequest) {
|
|
7146
|
-
return await ProgramManager$1.buildProvingRequestFromExecutionRequest(options.executionRequest, program, unchecked, broadcast, edition,
|
|
7147
|
-
|
|
7308
|
+
return await ProgramManager$1.buildProvingRequestFromExecutionRequest(options.executionRequest, program, unchecked, broadcast, edition,
|
|
7309
|
+
// The prepared process supersedes the legacy imports Object;
|
|
7310
|
+
// without one, imports is kept for fee estimation in Rust.
|
|
7311
|
+
hasPreparedProcess ? undefined : imports, executionPrivateKey, hasPreparedProcess ? builder : hasImports ? builder.clone() : undefined);
|
|
7148
7312
|
}
|
|
7149
7313
|
else {
|
|
7150
7314
|
// Ensure the private key exists.
|
|
@@ -7159,7 +7323,7 @@ class ProgramManager {
|
|
|
7159
7323
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7160
7324
|
// Build and return the `ProvingRequest`.
|
|
7161
7325
|
return await ProgramManager$1.buildProvingRequest(executionPrivateKey, program, functionName, preparedInputs, baseFee, priorityFee, feeRecord, imports, // kept for fee estimation in Rust
|
|
7162
|
-
broadcast, unchecked, edition, useFeeMaster, hasImports ? builder
|
|
7326
|
+
broadcast, unchecked, edition, useFeeMaster, hasPreparedProcess ? builder : hasImports ? builder.clone() : undefined);
|
|
7163
7327
|
}
|
|
7164
7328
|
}
|
|
7165
7329
|
/**
|
|
@@ -8536,7 +8700,7 @@ class ProgramManager {
|
|
|
8536
8700
|
* import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
8537
8701
|
*
|
|
8538
8702
|
* // Initialize the development consensus heights in order to work with devnode.
|
|
8539
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
|
|
8703
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18");
|
|
8540
8704
|
*
|
|
8541
8705
|
* // Create a new NetworkClient and RecordProvider.
|
|
8542
8706
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -8663,7 +8827,7 @@ class ProgramManager {
|
|
|
8663
8827
|
* import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
|
|
8664
8828
|
*
|
|
8665
8829
|
* // Initialize the development consensus heights in order to work with a local devnode.
|
|
8666
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
|
|
8830
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18");
|
|
8667
8831
|
*
|
|
8668
8832
|
* // Create a new NetworkClient, and RecordProvider
|
|
8669
8833
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -9209,5 +9373,5 @@ async function initializeWasm() {
|
|
|
9209
9373
|
logger.warn("initializeWasm is deprecated, you no longer need to use it");
|
|
9210
9374
|
}
|
|
9211
9375
|
|
|
9212
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, cookieAffinityTransport, defaultTransport, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptSerializedProvingRequest, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, programChecksum, provingKeyLocator, serializeProvingRequest, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
|
|
9376
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PreparedProgram, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, cookieAffinityTransport, defaultTransport, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptSerializedProvingRequest, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, programChecksum, provingKeyLocator, serializeProvingRequest, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
|
|
9213
9377
|
//# sourceMappingURL=browser.js.map
|