@provablehq/sdk 0.11.2 → 0.11.4
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 +137 -63
- 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 +136 -64
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/node.cjs +2 -0
- package/dist/mainnet/node.cjs.map +1 -1
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/program-manager.d.cts +9 -3
- package/dist/mainnet/program-manager.d.ts +9 -3
- package/dist/mainnet/security.d.cts +43 -0
- package/dist/mainnet/security.d.ts +43 -0
- package/dist/testnet/browser.cjs +137 -63
- 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 +136 -64
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/node.cjs +2 -0
- package/dist/testnet/node.cjs.map +1 -1
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/program-manager.d.cts +9 -3
- package/dist/testnet/program-manager.d.ts +9 -3
- package/dist/testnet/security.d.cts +43 -0
- package/dist/testnet/security.d.ts +43 -0
- package/package.json +2 -2
|
@@ -70,6 +70,6 @@ export { initializeWasm };
|
|
|
70
70
|
export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
|
|
71
71
|
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
|
|
72
72
|
export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
|
|
73
|
-
export { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest, zeroizeBytes } from "./security.js";
|
|
73
|
+
export { encryptAuthorization, encryptProvingRequest, encryptSerializedProvingRequest, encryptViewKey, encryptRegistrationRequest, serializeProvingRequest, zeroizeBytes, } from "./security.js";
|
|
74
74
|
export { toField, toGroup, toViewKey, toSignature, toAddress, isViewKeyStrategy, isInputIdStrategy, isRecordViewKeyStrategy, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, } from "./external-signing.js";
|
|
75
75
|
export type { FieldLike, GroupLike, ViewKeyLike, SignatureLike, AddressLike, InputID, ExecutionRequestParams, RecordViewKeyStrategy, ViewKeyStrategy, InputIdStrategy, InputStrategy, ExternalSigningInput, ExternalSigningOptions, RequestSignInput, OutputFormat, FieldOutput, } from "./external-signing.js";
|
|
@@ -70,6 +70,6 @@ export { initializeWasm };
|
|
|
70
70
|
export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
|
|
71
71
|
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
|
|
72
72
|
export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
|
|
73
|
-
export { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest, zeroizeBytes } from "./security.js";
|
|
73
|
+
export { encryptAuthorization, encryptProvingRequest, encryptSerializedProvingRequest, encryptViewKey, encryptRegistrationRequest, serializeProvingRequest, zeroizeBytes, } from "./security.js";
|
|
74
74
|
export { toField, toGroup, toViewKey, toSignature, toAddress, isViewKeyStrategy, isInputIdStrategy, isRecordViewKeyStrategy, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, } from "./external-signing.js";
|
|
75
75
|
export type { FieldLike, GroupLike, ViewKeyLike, SignatureLike, AddressLike, InputID, ExecutionRequestParams, RecordViewKeyStrategy, ViewKeyStrategy, InputIdStrategy, InputStrategy, ExternalSigningInput, ExternalSigningOptions, RequestSignInput, OutputFormat, FieldOutput, } from "./external-signing.js";
|
package/dist/mainnet/browser.js
CHANGED
|
@@ -438,7 +438,15 @@ class IndexedDBKeyStore {
|
|
|
438
438
|
* @returns {string} the encrypted authorization in RFC 4648 standard Base64.
|
|
439
439
|
*/
|
|
440
440
|
function encryptAuthorization(publicKey, authorization) {
|
|
441
|
-
|
|
441
|
+
// Zeroize the intermediate plaintext bytes regardless of success or
|
|
442
|
+
// failure — same pattern as encryptRegistrationRequest.
|
|
443
|
+
const bytes = authorization.toBytesLe();
|
|
444
|
+
try {
|
|
445
|
+
return encryptMessage(publicKey, bytes);
|
|
446
|
+
}
|
|
447
|
+
finally {
|
|
448
|
+
zeroizeBytes(bytes);
|
|
449
|
+
}
|
|
442
450
|
}
|
|
443
451
|
/**
|
|
444
452
|
* Encrypt a ProvingRequest with a cryptobox X25519 public key (libsodium-compatible wire format).
|
|
@@ -449,7 +457,62 @@ function encryptAuthorization(publicKey, authorization) {
|
|
|
449
457
|
* @returns {string} the encrypted ProvingRequest in RFC 4648 standard Base64.
|
|
450
458
|
*/
|
|
451
459
|
function encryptProvingRequest(publicKey, provingRequest) {
|
|
452
|
-
|
|
460
|
+
// Zeroize the intermediate plaintext bytes regardless of success or
|
|
461
|
+
// failure — same pattern as encryptRegistrationRequest.
|
|
462
|
+
const bytes = provingRequest.toBytesLe();
|
|
463
|
+
try {
|
|
464
|
+
return encryptMessage(publicKey, bytes);
|
|
465
|
+
}
|
|
466
|
+
finally {
|
|
467
|
+
zeroizeBytes(bytes);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Serialize a ProvingRequest for later encryption with
|
|
472
|
+
* `encryptSerializedProvingRequest`.
|
|
473
|
+
*
|
|
474
|
+
* Useful when the request may have to be encrypted more than once: the
|
|
475
|
+
* delegated proving service's one-time keys are single-use, so a client that
|
|
476
|
+
* needs to resend a request (e.g. after the service rejected a spent or
|
|
477
|
+
* unknown `key_id`) can keep the serialized form and re-encrypt it for a
|
|
478
|
+
* fresh key instead of rebuilding and re-signing the request.
|
|
479
|
+
*
|
|
480
|
+
* The returned buffer contains the plaintext request (including the signed
|
|
481
|
+
* authorization and its inputs) and is owned by the caller: keep it only as
|
|
482
|
+
* long as a resend may still be needed, then overwrite it with
|
|
483
|
+
* `zeroizeBytes(serialized)`. Zeroization in JavaScript is best-effort (see
|
|
484
|
+
* `zeroizeBytes`), and transient copies made inside the wasm boundary by
|
|
485
|
+
* `toBytesLe` are outside its reach.
|
|
486
|
+
*
|
|
487
|
+
* @param {ProvingRequest} provingRequest the ProvingRequest to serialize.
|
|
488
|
+
*
|
|
489
|
+
* @returns {Uint8Array} the serialized ProvingRequest bytes.
|
|
490
|
+
*/
|
|
491
|
+
function serializeProvingRequest(provingRequest) {
|
|
492
|
+
return provingRequest.toBytesLe();
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Encrypt an already-serialized ProvingRequest (as produced by
|
|
496
|
+
* `serializeProvingRequest`) with a cryptobox X25519 public key
|
|
497
|
+
* (libsodium-compatible wire format).
|
|
498
|
+
*
|
|
499
|
+
* Produces exactly the same ciphertext format as `encryptProvingRequest` —
|
|
500
|
+
* `encryptSerializedProvingRequest(pk, serializeProvingRequest(req))` and
|
|
501
|
+
* `encryptProvingRequest(pk, req)` are interchangeable from the proving
|
|
502
|
+
* service's point of view.
|
|
503
|
+
*
|
|
504
|
+
* The input buffer is not mutated and deliberately not zeroized here: the
|
|
505
|
+
* caller keeps ownership so the same bytes can be re-encrypted for another
|
|
506
|
+
* one-time key (retry). Call `zeroizeBytes(serializedProvingRequest)` once
|
|
507
|
+
* no resend can be needed anymore.
|
|
508
|
+
*
|
|
509
|
+
* @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).
|
|
510
|
+
* @param {Uint8Array} serializedProvingRequest the serialized ProvingRequest bytes.
|
|
511
|
+
*
|
|
512
|
+
* @returns {string} the encrypted ProvingRequest in RFC 4648 standard Base64.
|
|
513
|
+
*/
|
|
514
|
+
function encryptSerializedProvingRequest(publicKey, serializedProvingRequest) {
|
|
515
|
+
return encryptMessage(publicKey, serializedProvingRequest);
|
|
453
516
|
}
|
|
454
517
|
/**
|
|
455
518
|
* Encrypt a view key with a cryptobox X25519 public key (libsodium-compatible wire format).
|
|
@@ -460,7 +523,15 @@ function encryptProvingRequest(publicKey, provingRequest) {
|
|
|
460
523
|
* @returns {string} the encrypted view key in RFC 4648 standard Base64.
|
|
461
524
|
*/
|
|
462
525
|
function encryptViewKey(publicKey, viewKey) {
|
|
463
|
-
|
|
526
|
+
// Zeroize the intermediate plaintext bytes regardless of success or
|
|
527
|
+
// failure — same pattern as encryptRegistrationRequest.
|
|
528
|
+
const bytes = viewKey.toBytesLe();
|
|
529
|
+
try {
|
|
530
|
+
return encryptMessage(publicKey, bytes);
|
|
531
|
+
}
|
|
532
|
+
finally {
|
|
533
|
+
zeroizeBytes(bytes);
|
|
534
|
+
}
|
|
464
535
|
}
|
|
465
536
|
/**
|
|
466
537
|
* Encrypt a record scanner registration request.
|
|
@@ -1531,7 +1602,7 @@ class AleoNetworkClient {
|
|
|
1531
1602
|
else {
|
|
1532
1603
|
this.headers = {
|
|
1533
1604
|
// This is replaced by the actual version by a Rollup plugin
|
|
1534
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1605
|
+
"X-Aleo-SDK-Version": "0.11.4",
|
|
1535
1606
|
"X-Aleo-environment": environment(),
|
|
1536
1607
|
};
|
|
1537
1608
|
}
|
|
@@ -1547,7 +1618,7 @@ class AleoNetworkClient {
|
|
|
1547
1618
|
else {
|
|
1548
1619
|
this.headers = {
|
|
1549
1620
|
// This is replaced by the actual version by a Rollup plugin
|
|
1550
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1621
|
+
"X-Aleo-SDK-Version": "0.11.4",
|
|
1551
1622
|
"X-Aleo-environment": environment(),
|
|
1552
1623
|
};
|
|
1553
1624
|
}
|
|
@@ -2408,7 +2479,7 @@ class AleoNetworkClient {
|
|
|
2408
2479
|
async getProgramAmendmentCount(programId) {
|
|
2409
2480
|
try {
|
|
2410
2481
|
this.ctx = { "X-ALEO-METHOD": "getProgramAmendmentCount" };
|
|
2411
|
-
const raw = await this.fetchRaw("/
|
|
2482
|
+
const raw = await this.fetchRaw("/program/" + programId + "/amendment_count");
|
|
2412
2483
|
return JSON.parse(raw);
|
|
2413
2484
|
}
|
|
2414
2485
|
catch (error) {
|
|
@@ -5836,83 +5907,84 @@ class ProgramManager {
|
|
|
5836
5907
|
this._keyStore = keyStore;
|
|
5837
5908
|
}
|
|
5838
5909
|
/**
|
|
5839
|
-
*
|
|
5840
|
-
*
|
|
5841
|
-
*
|
|
5842
|
-
*
|
|
5843
|
-
* @param loadKeys When true (default), loads cached proving/verifying keys
|
|
5844
|
-
* from the KeyStore into the builder. Set to false for authorization and
|
|
5845
|
-
* proving request paths where keys are not synthesized.
|
|
5910
|
+
* Collect static imports declared by the entry program together with any
|
|
5911
|
+
* caller-provided imports, then resolve missing transitive dependencies.
|
|
5912
|
+
* Caller-provided program sources take precedence over network sources.
|
|
5846
5913
|
*/
|
|
5847
|
-
async
|
|
5848
|
-
const builder = new ProgramImports();
|
|
5914
|
+
async collectProgramImports(program, imports, tolerateNetworkErrors) {
|
|
5849
5915
|
const programSource = typeof program === "string" ? program : program.toString();
|
|
5850
|
-
const
|
|
5851
|
-
|
|
5852
|
-
if (
|
|
5853
|
-
return { builder, importEditions: new Map() };
|
|
5854
|
-
}
|
|
5855
|
-
let resolvedImports = {};
|
|
5856
|
-
if (imports) {
|
|
5857
|
-
resolvedImports = { ...imports };
|
|
5858
|
-
}
|
|
5859
|
-
if (importNames.length > 0 && !imports) {
|
|
5916
|
+
const providedImports = { ...(imports ?? {}) };
|
|
5917
|
+
let resolvedImports = { ...providedImports };
|
|
5918
|
+
if (ProgramManager.getImportNames(programSource).length > 0) {
|
|
5860
5919
|
try {
|
|
5861
|
-
|
|
5920
|
+
const networkImports = await this.networkClient.getProgramImports(programSource, { ...resolvedImports });
|
|
5921
|
+
resolvedImports = { ...networkImports, ...providedImports };
|
|
5862
5922
|
}
|
|
5863
5923
|
catch (e) {
|
|
5924
|
+
if (!tolerateNetworkErrors)
|
|
5925
|
+
throw e;
|
|
5864
5926
|
logger.warn(`Failed to resolve program imports from network: ${e}.`);
|
|
5865
5927
|
}
|
|
5866
5928
|
}
|
|
5867
|
-
// Build a map of which functions each import actually calls,
|
|
5868
|
-
// so we only load keys for functions in the call chain.
|
|
5869
|
-
const calledFunctions = ProgramManager.callGraphToMap(programObj.getCallGraph(entryFunction));
|
|
5870
|
-
// Phase 1: Collect all programs via BFS, discovering transitive imports.
|
|
5871
|
-
// The initial getProgramImports call above already resolves the full
|
|
5872
|
-
// transitive closure via recursive DFS. The BFS loop here only needs
|
|
5873
|
-
// to handle user-provided imports whose transitive deps may not yet be
|
|
5874
|
-
// known. For each unknown import we issue a single getProgram() call
|
|
5875
|
-
// (not a full recursive getProgramImports) and fetch siblings in
|
|
5876
|
-
// parallel to minimize round-trips.
|
|
5877
5929
|
const collected = new Map();
|
|
5878
|
-
const collectQueue = Object.entries(resolvedImports).map(([name,
|
|
5930
|
+
const collectQueue = Object.entries(resolvedImports).map(([name, source]) => [name, typeof source === "string" ? source : source.toString()]);
|
|
5879
5931
|
while (collectQueue.length > 0) {
|
|
5880
5932
|
const [name, source] = collectQueue.shift();
|
|
5881
5933
|
if (collected.has(name))
|
|
5882
5934
|
continue;
|
|
5883
5935
|
collected.set(name, source);
|
|
5884
|
-
// Discover transitive imports for collection (call-graph tracing
|
|
5885
|
-
// happens in a separate pass after topological sorting).
|
|
5886
5936
|
try {
|
|
5887
5937
|
const subImports = ProgramManager.getImportNames(source);
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
if (entry && !collected.has(entry[0])) {
|
|
5905
|
-
collectQueue.push(entry);
|
|
5906
|
-
}
|
|
5938
|
+
const unknownImports = subImports.filter((id) => !collected.has(id) && !(id in resolvedImports));
|
|
5939
|
+
if (unknownImports.length > 0) {
|
|
5940
|
+
const fetched = await Promise.all(unknownImports.map(async (id) => {
|
|
5941
|
+
try {
|
|
5942
|
+
const importedSource = await this.networkClient.getProgram(id);
|
|
5943
|
+
return [id, importedSource];
|
|
5944
|
+
}
|
|
5945
|
+
catch (e) {
|
|
5946
|
+
if (!tolerateNetworkErrors)
|
|
5947
|
+
throw e;
|
|
5948
|
+
return null;
|
|
5949
|
+
}
|
|
5950
|
+
}));
|
|
5951
|
+
for (const entry of fetched) {
|
|
5952
|
+
if (entry && !collected.has(entry[0])) {
|
|
5953
|
+
collectQueue.push(entry);
|
|
5907
5954
|
}
|
|
5908
5955
|
}
|
|
5909
5956
|
}
|
|
5910
5957
|
}
|
|
5911
5958
|
catch (e) {
|
|
5959
|
+
if (!tolerateNetworkErrors)
|
|
5960
|
+
throw e;
|
|
5912
5961
|
logger.warn(`Failed to resolve transitive imports for ${name}: ${e}`);
|
|
5913
5962
|
}
|
|
5914
5963
|
}
|
|
5915
|
-
|
|
5964
|
+
return collected;
|
|
5965
|
+
}
|
|
5966
|
+
/**
|
|
5967
|
+
* Build a ProgramImportsBuilder from a program and its imports.
|
|
5968
|
+
* Fetches missing imports from the network, resolves transitive
|
|
5969
|
+
* dependencies, and optionally pre-loads cached keys from the KeyStore.
|
|
5970
|
+
*
|
|
5971
|
+
* @param loadKeys When true (default), loads cached proving/verifying keys
|
|
5972
|
+
* from the KeyStore into the builder. Set to false for authorization and
|
|
5973
|
+
* proving request paths where keys are not synthesized.
|
|
5974
|
+
*/
|
|
5975
|
+
async buildProgramImports(program, imports, loadKeys, entryFunction) {
|
|
5976
|
+
const builder = new ProgramImports();
|
|
5977
|
+
const programSource = typeof program === "string" ? program : program.toString();
|
|
5978
|
+
const programObj = Program.fromString(programSource);
|
|
5979
|
+
const importNames = programObj.getImports();
|
|
5980
|
+
if (importNames.length === 0 && (!imports || Object.keys(imports).length === 0)) {
|
|
5981
|
+
return { builder, importEditions: new Map() };
|
|
5982
|
+
}
|
|
5983
|
+
const collected = await this.collectProgramImports(programSource, imports, true);
|
|
5984
|
+
// Build a map of which functions each import actually calls,
|
|
5985
|
+
// so we only load keys for functions in the call chain.
|
|
5986
|
+
const calledFunctions = ProgramManager.callGraphToMap(programObj.getCallGraph(entryFunction));
|
|
5987
|
+
// Add programs in topological order (leaves first).
|
|
5916
5988
|
// A simple DFS post-order ensures dependencies are added before
|
|
5917
5989
|
// dependents, regardless of the order collected entries arrived.
|
|
5918
5990
|
const sorted = [];
|
|
@@ -8385,7 +8457,7 @@ class ProgramManager {
|
|
|
8385
8457
|
throw new Error("Authorization must be provided if estimating fee for Authorization.");
|
|
8386
8458
|
}
|
|
8387
8459
|
const programSource = program ? program.toString() : await this.networkClient.getProgram(programName, edition);
|
|
8388
|
-
const programImports =
|
|
8460
|
+
const programImports = Object.fromEntries(await this.collectProgramImports(programSource, imports, false));
|
|
8389
8461
|
return ProgramManager$1.estimateFeeForAuthorization(authorization, programSource, programImports, edition);
|
|
8390
8462
|
}
|
|
8391
8463
|
/**
|
|
@@ -8420,7 +8492,7 @@ class ProgramManager {
|
|
|
8420
8492
|
throw new Error("Function name must be specified when estimating fee.");
|
|
8421
8493
|
}
|
|
8422
8494
|
const programSource = program ? program.toString() : await this.networkClient.getProgram(programName, edition);
|
|
8423
|
-
const programImports =
|
|
8495
|
+
const programImports = Object.fromEntries(await this.collectProgramImports(programSource, imports, false));
|
|
8424
8496
|
return ProgramManager$1.estimateExecutionFee(programSource, functionName, programImports, edition);
|
|
8425
8497
|
}
|
|
8426
8498
|
// Internal utility function for getting a credits.aleo record
|
|
@@ -8464,7 +8536,7 @@ class ProgramManager {
|
|
|
8464
8536
|
* import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
8465
8537
|
*
|
|
8466
8538
|
* // Initialize the development consensus heights in order to work with devnode.
|
|
8467
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
|
|
8539
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
|
|
8468
8540
|
*
|
|
8469
8541
|
* // Create a new NetworkClient and RecordProvider.
|
|
8470
8542
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -8591,7 +8663,7 @@ class ProgramManager {
|
|
|
8591
8663
|
* import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
|
|
8592
8664
|
*
|
|
8593
8665
|
* // Initialize the development consensus heights in order to work with a local devnode.
|
|
8594
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
|
|
8666
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
|
|
8595
8667
|
*
|
|
8596
8668
|
* // Create a new NetworkClient, and RecordProvider
|
|
8597
8669
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -9137,5 +9209,5 @@ async function initializeWasm() {
|
|
|
9137
9209
|
logger.warn("initializeWasm is deprecated, you no longer need to use it");
|
|
9138
9210
|
}
|
|
9139
9211
|
|
|
9140
|
-
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, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, programChecksum, provingKeyLocator, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
|
|
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 };
|
|
9141
9213
|
//# sourceMappingURL=browser.js.map
|