@provablehq/sdk 0.10.2-rc.1 → 0.10.3
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/dynamic/browser.cjs +12 -0
- package/dist/dynamic/browser.d.cts +8 -0
- package/dist/dynamic/browser.d.ts +2 -2
- package/dist/dynamic/node.cjs +12 -0
- package/dist/dynamic/node.d.cts +8 -0
- package/dist/dynamic/node.d.ts +2 -2
- package/dist/mainnet/account.d.cts +347 -0
- package/dist/mainnet/browser.cjs +8507 -0
- package/dist/mainnet/browser.cjs.map +1 -0
- package/dist/mainnet/browser.d.cts +72 -0
- package/dist/mainnet/browser.d.ts +4 -5
- package/dist/mainnet/browser.js +332 -855
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/constants.d.cts +40 -0
- package/dist/mainnet/external-signing.d.cts +76 -0
- package/dist/mainnet/integrations/sealance/merkle-tree.d.cts +192 -0
- package/dist/mainnet/keys/keystore/error.d.cts +24 -0
- package/dist/mainnet/keys/keystore/file.d.cts +177 -0
- package/dist/mainnet/keys/keystore/interface.d.cts +161 -0
- package/dist/mainnet/keys/provider/interface.d.cts +170 -0
- package/dist/mainnet/keys/provider/memory.d.cts +213 -0
- package/dist/mainnet/keys/provider/memory.d.ts +6 -2
- package/dist/mainnet/keys/provider/offline.d.cts +365 -0
- package/dist/mainnet/keys/verifier/interface.d.cts +70 -0
- package/dist/mainnet/keys/verifier/memory.d.cts +37 -0
- package/dist/mainnet/keys/verifier/memory.d.ts +1 -1
- package/dist/mainnet/models/authorization.d.cts +6 -0
- package/dist/mainnet/models/authorization.d.ts +2 -2
- package/dist/mainnet/models/blockJSON.d.cts +33 -0
- package/dist/mainnet/models/confirmed_transaction.d.cts +9 -0
- package/dist/mainnet/models/cryptoBoxPubkey.d.cts +4 -0
- package/dist/mainnet/models/deployment/deploymentJSON.d.cts +6 -0
- package/dist/mainnet/models/deployment/deploymentObject.d.cts +6 -0
- package/dist/mainnet/models/encryptedProvingRequest.d.cts +4 -0
- package/dist/mainnet/models/execution/executionJSON.d.cts +11 -0
- package/dist/mainnet/models/execution/executionObject.d.cts +11 -0
- package/dist/mainnet/models/external-signing.d.cts +123 -0
- package/dist/mainnet/models/finalizeJSON.d.cts +6 -0
- package/dist/mainnet/models/functionInput.d.cts +7 -0
- package/dist/mainnet/models/functionObject.d.cts +8 -0
- package/dist/mainnet/models/imports.d.cts +7 -0
- package/dist/mainnet/models/input/inputJSON.d.cts +10 -0
- package/dist/mainnet/models/input/inputObject.d.cts +15 -0
- package/dist/mainnet/models/inputID.d.cts +4 -0
- package/dist/mainnet/models/keyPair.d.cts +4 -0
- package/dist/mainnet/models/output/outputJSON.d.cts +7 -0
- package/dist/mainnet/models/output/outputObject.d.cts +18 -0
- package/dist/mainnet/models/owner/ownerJSON.d.cts +4 -0
- package/dist/mainnet/models/owner/ownerObject.d.cts +5 -0
- package/dist/mainnet/models/plaintext/array.d.cts +3 -0
- package/dist/mainnet/models/plaintext/literal.d.cts +1 -0
- package/dist/mainnet/models/plaintext/plaintext.d.cts +5 -0
- package/dist/mainnet/models/plaintext/struct.d.cts +5 -0
- package/dist/mainnet/models/provingRequest.d.cts +6 -0
- package/dist/mainnet/models/provingRequest.d.ts +1 -1
- package/dist/mainnet/models/provingResponse.d.cts +51 -0
- package/dist/mainnet/models/ratification.d.cts +4 -0
- package/dist/mainnet/models/record-provider/encryptedRecord.d.cts +58 -0
- package/dist/mainnet/models/record-provider/ownedRecord.d.cts +60 -0
- package/dist/mainnet/models/record-provider/recordSearchParams.d.cts +19 -0
- package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
- package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
- package/dist/mainnet/models/record-scanner/error.d.cts +47 -0
- package/dist/mainnet/models/record-scanner/error.d.ts +1 -1
- package/dist/mainnet/models/record-scanner/ownedFilter.d.cts +22 -0
- package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +3 -3
- package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.cts +35 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +2 -2
- package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
- package/dist/mainnet/models/record-scanner/registrationRequest.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResponse.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResult.d.cts +9 -0
- package/dist/mainnet/models/record-scanner/revokeResult.d.cts +17 -0
- package/dist/mainnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
- package/dist/mainnet/models/record-scanner/statusResponse.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/statusResult.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/tagsResult.d.cts +12 -0
- package/dist/mainnet/models/request.d.cts +14 -0
- package/dist/mainnet/models/request.d.ts +1 -1
- package/dist/mainnet/models/solution.d.cts +14 -0
- package/dist/mainnet/models/transaction/transactionJSON.d.cts +11 -0
- package/dist/mainnet/models/transaction/transactionObject.d.cts +14 -0
- package/dist/mainnet/models/transition/transitionJSON.d.cts +13 -0
- package/dist/mainnet/models/transition/transitionObject.d.cts +15 -0
- package/dist/mainnet/network-client.d.cts +850 -0
- package/dist/mainnet/network-client.d.ts +3 -16
- package/dist/mainnet/node-polyfill.cjs +238 -0
- package/dist/mainnet/node-polyfill.cjs.map +1 -0
- package/dist/mainnet/node-polyfill.d.cts +5 -0
- package/dist/mainnet/node-polyfill.js +1 -1
- package/dist/mainnet/node-polyfill.js.map +1 -1
- package/dist/mainnet/node.cjs +685 -0
- package/dist/mainnet/node.cjs.map +1 -0
- package/dist/mainnet/node.d.cts +3 -0
- package/dist/mainnet/node.js +3 -3
- package/dist/mainnet/polyfill/crypto.d.cts +1 -0
- package/dist/mainnet/polyfill/fetch.d.cts +1 -0
- package/dist/mainnet/polyfill/shared.d.cts +1 -0
- package/dist/mainnet/polyfill/worker.d.cts +1 -0
- package/dist/mainnet/polyfill/xmlhttprequest.d.cts +1 -0
- package/dist/mainnet/program-manager.d.cts +1588 -0
- package/dist/mainnet/program-manager.d.ts +1 -62
- package/dist/mainnet/record-provider.d.cts +274 -0
- package/dist/mainnet/record-scanner.d.cts +371 -0
- package/dist/mainnet/record-scanner.d.ts +9 -6
- package/dist/mainnet/security.d.cts +62 -0
- package/dist/mainnet/security.d.ts +5 -5
- package/dist/mainnet/utils.d.cts +23 -0
- package/dist/mainnet/utils.d.ts +10 -2
- package/dist/mainnet/wasm.d.cts +1 -0
- package/dist/mainnet/wasm.d.ts +1 -1
- package/dist/testnet/account.d.cts +347 -0
- package/dist/testnet/browser.cjs +8507 -0
- package/dist/testnet/browser.cjs.map +1 -0
- package/dist/testnet/browser.d.cts +72 -0
- package/dist/testnet/browser.d.ts +4 -5
- package/dist/testnet/browser.js +332 -855
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/constants.d.cts +40 -0
- package/dist/testnet/external-signing.d.cts +76 -0
- package/dist/testnet/integrations/sealance/merkle-tree.d.cts +192 -0
- package/dist/testnet/keys/keystore/error.d.cts +24 -0
- package/dist/testnet/keys/keystore/file.d.cts +177 -0
- package/dist/testnet/keys/keystore/interface.d.cts +161 -0
- package/dist/testnet/keys/provider/interface.d.cts +170 -0
- package/dist/testnet/keys/provider/memory.d.cts +213 -0
- package/dist/testnet/keys/provider/memory.d.ts +6 -2
- package/dist/testnet/keys/provider/offline.d.cts +365 -0
- package/dist/testnet/keys/verifier/interface.d.cts +70 -0
- package/dist/testnet/keys/verifier/memory.d.cts +37 -0
- package/dist/testnet/keys/verifier/memory.d.ts +1 -1
- package/dist/testnet/models/authorization.d.cts +6 -0
- package/dist/testnet/models/authorization.d.ts +2 -2
- package/dist/testnet/models/blockJSON.d.cts +33 -0
- package/dist/testnet/models/confirmed_transaction.d.cts +9 -0
- package/dist/testnet/models/cryptoBoxPubkey.d.cts +4 -0
- package/dist/testnet/models/deployment/deploymentJSON.d.cts +6 -0
- package/dist/testnet/models/deployment/deploymentObject.d.cts +6 -0
- package/dist/testnet/models/encryptedProvingRequest.d.cts +4 -0
- package/dist/testnet/models/execution/executionJSON.d.cts +11 -0
- package/dist/testnet/models/execution/executionObject.d.cts +11 -0
- package/dist/testnet/models/external-signing.d.cts +123 -0
- package/dist/testnet/models/finalizeJSON.d.cts +6 -0
- package/dist/testnet/models/functionInput.d.cts +7 -0
- package/dist/testnet/models/functionObject.d.cts +8 -0
- package/dist/testnet/models/imports.d.cts +7 -0
- package/dist/testnet/models/input/inputJSON.d.cts +10 -0
- package/dist/testnet/models/input/inputObject.d.cts +15 -0
- package/dist/testnet/models/inputID.d.cts +4 -0
- package/dist/testnet/models/keyPair.d.cts +4 -0
- package/dist/testnet/models/output/outputJSON.d.cts +7 -0
- package/dist/testnet/models/output/outputObject.d.cts +18 -0
- package/dist/testnet/models/owner/ownerJSON.d.cts +4 -0
- package/dist/testnet/models/owner/ownerObject.d.cts +5 -0
- package/dist/testnet/models/plaintext/array.d.cts +3 -0
- package/dist/testnet/models/plaintext/literal.d.cts +1 -0
- package/dist/testnet/models/plaintext/plaintext.d.cts +5 -0
- package/dist/testnet/models/plaintext/struct.d.cts +5 -0
- package/dist/testnet/models/provingRequest.d.cts +6 -0
- package/dist/testnet/models/provingRequest.d.ts +1 -1
- package/dist/testnet/models/provingResponse.d.cts +51 -0
- package/dist/testnet/models/ratification.d.cts +4 -0
- package/dist/testnet/models/record-provider/encryptedRecord.d.cts +58 -0
- package/dist/testnet/models/record-provider/ownedRecord.d.cts +60 -0
- package/dist/testnet/models/record-provider/recordSearchParams.d.cts +19 -0
- package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
- package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
- package/dist/testnet/models/record-scanner/error.d.cts +47 -0
- package/dist/testnet/models/record-scanner/error.d.ts +1 -1
- package/dist/testnet/models/record-scanner/ownedFilter.d.cts +22 -0
- package/dist/testnet/models/record-scanner/ownedFilter.d.ts +3 -3
- package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.cts +35 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.ts +2 -2
- package/dist/testnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
- package/dist/testnet/models/record-scanner/registrationRequest.d.cts +13 -0
- package/dist/testnet/models/record-scanner/registrationResponse.d.cts +13 -0
- package/dist/testnet/models/record-scanner/registrationResult.d.cts +9 -0
- package/dist/testnet/models/record-scanner/revokeResult.d.cts +17 -0
- package/dist/testnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
- package/dist/testnet/models/record-scanner/statusResponse.d.cts +13 -0
- package/dist/testnet/models/record-scanner/statusResult.d.cts +13 -0
- package/dist/testnet/models/record-scanner/tagsResult.d.cts +12 -0
- package/dist/testnet/models/request.d.cts +14 -0
- package/dist/testnet/models/request.d.ts +1 -1
- package/dist/testnet/models/solution.d.cts +14 -0
- package/dist/testnet/models/transaction/transactionJSON.d.cts +11 -0
- package/dist/testnet/models/transaction/transactionObject.d.cts +14 -0
- package/dist/testnet/models/transition/transitionJSON.d.cts +13 -0
- package/dist/testnet/models/transition/transitionObject.d.cts +15 -0
- package/dist/testnet/network-client.d.cts +850 -0
- package/dist/testnet/network-client.d.ts +3 -16
- package/dist/testnet/node-polyfill.cjs +238 -0
- package/dist/testnet/node-polyfill.cjs.map +1 -0
- package/dist/testnet/node-polyfill.d.cts +5 -0
- package/dist/testnet/node-polyfill.js +1 -1
- package/dist/testnet/node-polyfill.js.map +1 -1
- package/dist/testnet/node.cjs +685 -0
- package/dist/testnet/node.cjs.map +1 -0
- package/dist/testnet/node.d.cts +3 -0
- package/dist/testnet/node.js +3 -3
- package/dist/testnet/polyfill/crypto.d.cts +1 -0
- package/dist/testnet/polyfill/fetch.d.cts +1 -0
- package/dist/testnet/polyfill/shared.d.cts +1 -0
- package/dist/testnet/polyfill/worker.d.cts +1 -0
- package/dist/testnet/polyfill/xmlhttprequest.d.cts +1 -0
- package/dist/testnet/program-manager.d.cts +1588 -0
- package/dist/testnet/program-manager.d.ts +1 -62
- package/dist/testnet/record-provider.d.cts +274 -0
- package/dist/testnet/record-scanner.d.cts +371 -0
- package/dist/testnet/record-scanner.d.ts +9 -6
- package/dist/testnet/security.d.cts +62 -0
- package/dist/testnet/security.d.ts +5 -5
- package/dist/testnet/utils.d.cts +23 -0
- package/dist/testnet/utils.d.ts +10 -2
- package/dist/testnet/wasm.d.cts +1 -0
- package/dist/testnet/wasm.d.ts +1 -1
- package/package.json +51 -13
- package/dist/mainnet/keys/keystore/indexeddb.d.ts +0 -49
- package/dist/testnet/keys/keystore/indexeddb.d.ts +0 -49
|
@@ -4,7 +4,6 @@ import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports.js";
|
|
|
4
4
|
import { RecordProvider } from "./record-provider.js";
|
|
5
5
|
import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
|
|
6
6
|
import { FunctionKeyProvider, KeySearchParams } from "./keys/provider/interface.js";
|
|
7
|
-
import { KeyStore } from "./keys/keystore/interface.js";
|
|
8
7
|
import { FunctionKeyPair } from "./models/keyPair.js";
|
|
9
8
|
import { Authorization, ExecutionRequest, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
|
|
10
9
|
import { ExternalSigningOptions } from "./models/external-signing.js";
|
|
@@ -121,7 +120,6 @@ interface ExecuteAuthorizationOptions {
|
|
|
121
120
|
offlineQuery?: OfflineQuery;
|
|
122
121
|
program?: string | Program;
|
|
123
122
|
imports?: ProgramImports;
|
|
124
|
-
edition?: number;
|
|
125
123
|
}
|
|
126
124
|
/**
|
|
127
125
|
* Represents the options for executing a transaction in the Aleo network.
|
|
@@ -215,14 +213,13 @@ declare class ProgramManager {
|
|
|
215
213
|
networkClient: AleoNetworkClient;
|
|
216
214
|
recordProvider: RecordProvider | undefined;
|
|
217
215
|
inclusionKeysLoaded: boolean;
|
|
218
|
-
private _keyStore;
|
|
219
216
|
/** Create a new instance of the ProgramManager
|
|
220
217
|
*
|
|
221
218
|
* @param { string | undefined } host A host uri running the official Aleo API
|
|
222
219
|
* @param { FunctionKeyProvider | undefined } keyProvider A key provider that implements {@link FunctionKeyProvider} interface
|
|
223
220
|
* @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface
|
|
224
221
|
*/
|
|
225
|
-
constructor(host?: string | undefined, keyProvider?: FunctionKeyProvider | undefined, recordProvider?: RecordProvider | undefined, networkClientOptions?: AleoNetworkClientOptions | undefined
|
|
222
|
+
constructor(host?: string | undefined, keyProvider?: FunctionKeyProvider | undefined, recordProvider?: RecordProvider | undefined, networkClientOptions?: AleoNetworkClientOptions | undefined);
|
|
226
223
|
/**
|
|
227
224
|
* Check if the fee is sufficient to pay for the transaction
|
|
228
225
|
*/
|
|
@@ -251,64 +248,6 @@ declare class ProgramManager {
|
|
|
251
248
|
* @param {RecordProvider} recordProvider
|
|
252
249
|
*/
|
|
253
250
|
setRecordProvider(recordProvider: RecordProvider): void;
|
|
254
|
-
/**
|
|
255
|
-
* Set the key store for automatic key caching across executions.
|
|
256
|
-
*
|
|
257
|
-
* @param {KeyStore} keyStore
|
|
258
|
-
*/
|
|
259
|
-
setKeyStore(keyStore: KeyStore): void;
|
|
260
|
-
/**
|
|
261
|
-
* Build a ProgramImportsBuilder from a program and its imports.
|
|
262
|
-
* Fetches imports from the network if not provided, resolves transitive
|
|
263
|
-
* dependencies, and optionally pre-loads cached keys from the KeyStore.
|
|
264
|
-
*
|
|
265
|
-
* @param loadKeys When true (default), loads cached proving/verifying keys
|
|
266
|
-
* from the KeyStore into the builder. Set to false for authorization and
|
|
267
|
-
* proving request paths where keys are not synthesized.
|
|
268
|
-
*/
|
|
269
|
-
private buildProgramImports;
|
|
270
|
-
/**
|
|
271
|
-
* Extract `import program_name.aleo;` names from program source via regex.
|
|
272
|
-
* Avoids a WASM round-trip compared to Program.fromString + getImports.
|
|
273
|
-
*/
|
|
274
|
-
private static getImportNames;
|
|
275
|
-
/**
|
|
276
|
-
* Parse `call program.aleo/function` instructions from program source
|
|
277
|
-
* to determine which functions of each import are actually in the call chain.
|
|
278
|
-
* Returns a map of program name -> set of called function names.
|
|
279
|
-
*/
|
|
280
|
-
private static getCalledFunctions;
|
|
281
|
-
/**
|
|
282
|
-
* Resolve the active KeyStore, preferring the directly-set _keyStore
|
|
283
|
-
* over the KeyProvider's keyStore().
|
|
284
|
-
*/
|
|
285
|
-
private resolveKeyStore;
|
|
286
|
-
/**
|
|
287
|
-
* Resolve the edition and amendment count for a program from the network.
|
|
288
|
-
* Returns `{ edition, amendment }` or falls back to `{ edition: 1, amendment: 0 }`.
|
|
289
|
-
*/
|
|
290
|
-
private resolveEditionAndAmendment;
|
|
291
|
-
/**
|
|
292
|
-
* Load cached proving/verifying keys from the KeyStore into a ProgramImportsBuilder.
|
|
293
|
-
* Only loads keys for the specified functions — returns immediately if
|
|
294
|
-
* functionNames is empty or undefined.
|
|
295
|
-
* Resolves edition and amendment from the network for accurate key locator
|
|
296
|
-
* construction when not explicitly provided.
|
|
297
|
-
*/
|
|
298
|
-
private loadKeysFromStore;
|
|
299
|
-
/**
|
|
300
|
-
* Persist newly synthesized keys from the returned ProgramImportsBuilder
|
|
301
|
-
* into the KeyStore. Only writes keys that are not already in the store,
|
|
302
|
-
* avoiding unnecessary writes of large proving keys.
|
|
303
|
-
* Fetches each program's current edition and amendment count from the network
|
|
304
|
-
* for accurate key locator construction.
|
|
305
|
-
*/
|
|
306
|
-
private persistExtractedKeys;
|
|
307
|
-
/**
|
|
308
|
-
* Resolve top-level function keys, checking the KeyStore first and
|
|
309
|
-
* falling back to the KeyProvider.
|
|
310
|
-
*/
|
|
311
|
-
private resolveTopLevelKeys;
|
|
312
251
|
/**
|
|
313
252
|
* Set a header in the `AleoNetworkClient`s header map
|
|
314
253
|
*
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Account } from "./account.js";
|
|
2
|
+
import { AleoNetworkClient } from "./network-client.js";
|
|
3
|
+
import { EncryptedRecord } from "./models/record-provider/encryptedRecord.js";
|
|
4
|
+
import { OwnedRecord } from "./models/record-provider/ownedRecord.js";
|
|
5
|
+
import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
|
|
6
|
+
import { RecordsResponseFilter } from "./models/record-scanner/recordsResponseFilter.js";
|
|
7
|
+
/**
|
|
8
|
+
* Interface for a record provider. A record provider is used to find records for use in deployment and execution
|
|
9
|
+
* transactions on the Aleo Network. A default implementation is provided by the NetworkRecordProvider class. However,
|
|
10
|
+
* a custom implementation can be provided (say if records are synced locally to a database from the network) by
|
|
11
|
+
* implementing this interface.
|
|
12
|
+
*/
|
|
13
|
+
interface RecordProvider {
|
|
14
|
+
/**
|
|
15
|
+
* The account used to search for records.
|
|
16
|
+
*/
|
|
17
|
+
account?: Account;
|
|
18
|
+
/**
|
|
19
|
+
* Find encrypted records from the chosen provider.
|
|
20
|
+
*
|
|
21
|
+
* @param {RecordSearchParams} recordsFilter The filter used to find the records.
|
|
22
|
+
* @param {RecordsResponseFilter} responseFilter The filter used to filter the response.
|
|
23
|
+
* @returns {Promise<EncryptedRecord[]>} The encrypted records.
|
|
24
|
+
*/
|
|
25
|
+
encryptedRecords(recordsFilter: RecordSearchParams, responseFilter?: RecordsResponseFilter): Promise<EncryptedRecord[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a list of serial numbers exist in the chosen provider.
|
|
28
|
+
*
|
|
29
|
+
* @param {string[]} serialNumbers The serial numbers to check.
|
|
30
|
+
* @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.
|
|
31
|
+
*/
|
|
32
|
+
checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a list of tags exist in the chosen provider.
|
|
35
|
+
*
|
|
36
|
+
* @param {string[]} tags The tags to check.
|
|
37
|
+
* @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.
|
|
38
|
+
*/
|
|
39
|
+
checkTags(tags: string[]): Promise<Record<string, boolean>>;
|
|
40
|
+
/**
|
|
41
|
+
* Find a credits.aleo record with a given number of microcredits from the chosen provider.
|
|
42
|
+
*
|
|
43
|
+
* @param {number} microcredits The number of microcredits to search for.
|
|
44
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
45
|
+
* @returns {Promise<OwnedRecord>} The record if one is found.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // A class implementing record provider can be used to find a record with a given number of microcredits
|
|
49
|
+
* const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });
|
|
50
|
+
*
|
|
51
|
+
* // When a record is found but not yet used, its nonce should be added to the nonces array so that it is not
|
|
52
|
+
* // found again if a subsequent search is performed
|
|
53
|
+
* const record2 = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [record.nonce()] });
|
|
54
|
+
*
|
|
55
|
+
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
56
|
+
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
57
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
58
|
+
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
59
|
+
*/
|
|
60
|
+
findCreditsRecord(microcredits: number, searchParameters: RecordSearchParams): Promise<OwnedRecord>;
|
|
61
|
+
/**
|
|
62
|
+
* Find a list of credit.aleo records with a given number of microcredits from the chosen provider
|
|
63
|
+
*
|
|
64
|
+
* @param {number[]} microcreditAmounts A list of separate microcredit amounts to search for (e.g. [5000, 100000]).
|
|
65
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
66
|
+
* @returns {Promise<OwnedRecord[]>} A list of records with a value greater or equal to the amounts specified if such records exist, otherwise an error.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // A class implementing record provider can be used to find a record with a given number of microcredits
|
|
70
|
+
* const records = await recordProvider.findCreditsRecords([5000, 5000], { unspent: true, nonces: [] });
|
|
71
|
+
*
|
|
72
|
+
* // When a record is found but not yet used, it's nonce should be added to the nonces array so that it is not
|
|
73
|
+
* // found again if a subsequent search is performed
|
|
74
|
+
* const nonces = [];
|
|
75
|
+
* records.forEach(record => { nonces.push(record.nonce()) });
|
|
76
|
+
* const records2 = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces });
|
|
77
|
+
*
|
|
78
|
+
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
79
|
+
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
80
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
81
|
+
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
82
|
+
*/
|
|
83
|
+
findCreditsRecords(microcreditAmounts: number[], searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Find an arbitrary record
|
|
86
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
87
|
+
* @returns {Promise<OwnedRecord>} The record if found, otherwise an error.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // The RecordSearchParams interface can be used to create parameters for custom record searches which can then
|
|
91
|
+
* // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown
|
|
92
|
+
* // below.
|
|
93
|
+
*
|
|
94
|
+
* class CustomRecordSearch implements RecordSearchParams {
|
|
95
|
+
* startHeight: number;
|
|
96
|
+
* endHeight: number;
|
|
97
|
+
* amount: number;
|
|
98
|
+
* program: string;
|
|
99
|
+
* recordName: string;
|
|
100
|
+
* nonces: string[];
|
|
101
|
+
* unspent: boolean;
|
|
102
|
+
* constructor(
|
|
103
|
+
* startHeight: number,
|
|
104
|
+
* endHeight: number,
|
|
105
|
+
* credits: number,
|
|
106
|
+
* maxRecords: number,
|
|
107
|
+
* programName: string,
|
|
108
|
+
* recordName: string,
|
|
109
|
+
* nonces: string[],
|
|
110
|
+
* unspent: boolean
|
|
111
|
+
* ) {
|
|
112
|
+
* this.startHeight = startHeight;
|
|
113
|
+
* this.endHeight = endHeight;
|
|
114
|
+
* this.amount = amount;
|
|
115
|
+
* this.program = programName;
|
|
116
|
+
* this.recordName = recordName;
|
|
117
|
+
* this.nonces = nonces;
|
|
118
|
+
* this.unspent = unspent;
|
|
119
|
+
* }
|
|
120
|
+
* }
|
|
121
|
+
*
|
|
122
|
+
* const params = new CustomRecordSearch(0, 100, 5000, "credits.aleo", "credits", [], true);
|
|
123
|
+
*
|
|
124
|
+
* const record = await recordProvider.findRecord(params);
|
|
125
|
+
*/
|
|
126
|
+
findRecord(searchParameters: RecordSearchParams): Promise<OwnedRecord>;
|
|
127
|
+
/**
|
|
128
|
+
* Find multiple records from arbitrary programs
|
|
129
|
+
*
|
|
130
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
131
|
+
* @returns {Promise<OwnedRecord[]>} The records if found, otherwise an error.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // The RecordSearchParams interface can be used to create parameters for custom record searches which can then
|
|
135
|
+
* // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown
|
|
136
|
+
* // below.
|
|
137
|
+
*
|
|
138
|
+
* class CustomRecordSearch implements RecordSearchParams {
|
|
139
|
+
* startHeight: number;
|
|
140
|
+
* endHeight: number;
|
|
141
|
+
* credits: number;
|
|
142
|
+
* program: string;
|
|
143
|
+
* recordName: string;
|
|
144
|
+
* nonces: string[];
|
|
145
|
+
* unspent: boolean;
|
|
146
|
+
* constructor(
|
|
147
|
+
* startHeight: number,
|
|
148
|
+
* endHeight: number,
|
|
149
|
+
* credits: number,
|
|
150
|
+
* maxRecords: number,
|
|
151
|
+
* programName: string,
|
|
152
|
+
* recordName: string,
|
|
153
|
+
* nonces: string[],
|
|
154
|
+
* unspent: boolean
|
|
155
|
+
* ) {
|
|
156
|
+
* this.startHeight = startHeight;
|
|
157
|
+
* this.endHeight = endHeight;
|
|
158
|
+
* this.credits = credits;
|
|
159
|
+
* this.program = programName;
|
|
160
|
+
* this.recordName = recordName;
|
|
161
|
+
* this.nonces = nonces;
|
|
162
|
+
* this.unspent = unspent;
|
|
163
|
+
* }
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* const params = new CustomRecordSearch(0, 100, 5000, 2, "credits.aleo", "credits");
|
|
167
|
+
* const records = await recordProvider.findRecord(true, [], params);
|
|
168
|
+
*/
|
|
169
|
+
findRecords(searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A record provider implementation that uses the official Aleo API to find records for usage in program execution and
|
|
173
|
+
* deployment, wallet functionality, and other use cases.
|
|
174
|
+
*/
|
|
175
|
+
declare class NetworkRecordProvider implements RecordProvider {
|
|
176
|
+
account: Account;
|
|
177
|
+
networkClient: AleoNetworkClient;
|
|
178
|
+
constructor(account: Account, networkClient: AleoNetworkClient);
|
|
179
|
+
/**
|
|
180
|
+
* Set the account used to search for records
|
|
181
|
+
*
|
|
182
|
+
* @param {Account} account The account used to use for searching for records.
|
|
183
|
+
*/
|
|
184
|
+
setAccount(account: Account): void;
|
|
185
|
+
/**
|
|
186
|
+
* Find a list of credit records with a given number of microcredits by via the official Aleo API
|
|
187
|
+
*
|
|
188
|
+
* @param {number[]} microcredits The number of microcredits to search for.
|
|
189
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
190
|
+
* @returns {Promise<OwnedRecord[]>} The records if found, otherwise an error.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* // Create a new NetworkRecordProvider
|
|
194
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
195
|
+
* const keyProvider = new AleoKeyProvider();
|
|
196
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
197
|
+
*
|
|
198
|
+
* // The record provider can be used to find records with a given number of microcredits
|
|
199
|
+
* const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });
|
|
200
|
+
*
|
|
201
|
+
* // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
|
|
202
|
+
* // found again if a subsequent search is performed
|
|
203
|
+
* const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });
|
|
204
|
+
*
|
|
205
|
+
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
206
|
+
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
207
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
208
|
+
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
209
|
+
*
|
|
210
|
+
* */
|
|
211
|
+
findCreditsRecords(microcredits: number[], searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Find a credit record with a given number of microcredits by via the official Aleo API
|
|
214
|
+
*
|
|
215
|
+
* @param {number} microcredits The number of microcredits to search for.
|
|
216
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
217
|
+
* @returns {Promise<OwnedRecord>} The record if found, otherwise an error.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* // Create a new NetworkRecordProvider
|
|
221
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
222
|
+
* const keyProvider = new AleoKeyProvider();
|
|
223
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
224
|
+
*
|
|
225
|
+
* // The record provider can be used to find records with a given number of microcredits
|
|
226
|
+
* const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });
|
|
227
|
+
*
|
|
228
|
+
* // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
|
|
229
|
+
* // found again if a subsequent search is performed
|
|
230
|
+
* const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });
|
|
231
|
+
*
|
|
232
|
+
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
233
|
+
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
234
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
235
|
+
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
236
|
+
*/
|
|
237
|
+
findCreditsRecord(microcredits: number, searchParameters: RecordSearchParams): Promise<OwnedRecord>;
|
|
238
|
+
/**
|
|
239
|
+
* Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error.
|
|
240
|
+
*/
|
|
241
|
+
findRecord(searchParameters: RecordSearchParams): Promise<OwnedRecord>;
|
|
242
|
+
/**
|
|
243
|
+
* Find multiple records from a specified program.
|
|
244
|
+
*/
|
|
245
|
+
findRecords(searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;
|
|
246
|
+
encryptedRecords(recordsFilter: RecordSearchParams, responseFilter?: RecordsResponseFilter): Promise<EncryptedRecord[]>;
|
|
247
|
+
checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;
|
|
248
|
+
checkTags(tags: string[]): Promise<Record<string, boolean>>;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* BlockHeightSearch is a RecordSearchParams implementation that allows for searching for records within a given
|
|
252
|
+
* block height range.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* // Create a new BlockHeightSearch
|
|
256
|
+
* const params = new BlockHeightSearch(89995, 99995);
|
|
257
|
+
*
|
|
258
|
+
* // Create a new NetworkRecordProvider
|
|
259
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
260
|
+
* const keyProvider = new AleoKeyProvider();
|
|
261
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
262
|
+
*
|
|
263
|
+
* // The record provider can be used to find records with a given number of microcredits and the block height search
|
|
264
|
+
* // can be used to find records within a given block height range
|
|
265
|
+
* const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [], ...params });
|
|
266
|
+
*
|
|
267
|
+
*/
|
|
268
|
+
declare class BlockHeightSearch implements RecordSearchParams {
|
|
269
|
+
startHeight: number;
|
|
270
|
+
endHeight: number;
|
|
271
|
+
unspent: boolean;
|
|
272
|
+
constructor(startHeight: number, endHeight: number, unspent?: boolean);
|
|
273
|
+
}
|
|
274
|
+
export { BlockHeightSearch, NetworkRecordProvider, RecordProvider, };
|