@provablehq/sdk 0.9.7 → 0.9.9

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.
Files changed (31) hide show
  1. package/dist/mainnet/browser.d.ts +8 -2
  2. package/dist/mainnet/browser.js +140 -73
  3. package/dist/mainnet/browser.js.map +1 -1
  4. package/dist/mainnet/models/record-provider/encryptedRecord.d.ts +58 -0
  5. package/dist/mainnet/models/record-provider/ownedRecord.d.ts +60 -0
  6. package/dist/mainnet/models/record-provider/recordSearchParams.d.ts +19 -0
  7. package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +24 -0
  8. package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
  9. package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +35 -0
  10. package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.ts +38 -0
  11. package/dist/mainnet/models/record-scanner/registrationRequest.d.ts +13 -0
  12. package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +15 -0
  13. package/dist/mainnet/network-client.d.ts +29 -4
  14. package/dist/mainnet/program-manager.d.ts +4 -2
  15. package/dist/mainnet/record-provider.d.ts +106 -68
  16. package/dist/testnet/browser.d.ts +8 -2
  17. package/dist/testnet/browser.js +140 -73
  18. package/dist/testnet/browser.js.map +1 -1
  19. package/dist/testnet/models/record-provider/encryptedRecord.d.ts +58 -0
  20. package/dist/testnet/models/record-provider/ownedRecord.d.ts +60 -0
  21. package/dist/testnet/models/record-provider/recordSearchParams.d.ts +19 -0
  22. package/dist/testnet/models/record-scanner/ownedFilter.d.ts +24 -0
  23. package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
  24. package/dist/testnet/models/record-scanner/recordsFilter.d.ts +35 -0
  25. package/dist/testnet/models/record-scanner/recordsResponseFilter.d.ts +38 -0
  26. package/dist/testnet/models/record-scanner/registrationRequest.d.ts +13 -0
  27. package/dist/testnet/models/record-scanner/registrationResponse.d.ts +15 -0
  28. package/dist/testnet/network-client.d.ts +29 -4
  29. package/dist/testnet/program-manager.d.ts +4 -2
  30. package/dist/testnet/record-provider.d.ts +106 -68
  31. package/package.json +2 -2
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Encrypted Record found on chain. This type provides the record ciphertext and metadata from the ledger such as the record's name, the program/function that produced it, etc.
3
+ *
4
+ * @property {string} commitment - The commitment of the record.
5
+ * @property {string | undefined} checksum - The checksum of the record.
6
+ * @property {number | undefined} block_height - The block height of the record.
7
+ * @property {number | undefined} block_timestamp - The block timestamp of the record.
8
+ * @property {string | undefined} program_name - The name of the program that produced the record.
9
+ * @property {string | undefined} function_name - The name of the function that produced the record.
10
+ * @property {number | undefined} output_index - The output index of the record.
11
+ * @property {string | undefined} owner - The owner of the record.
12
+ * @property {string | undefined} record_ciphertext - The ciphertext of the record.
13
+ * @property {string | undefined} record_name - The name of the record.
14
+ * @property {string | undefined} record_nonce - The nonce of the record.
15
+ * @property {string | undefined} sender_ciphertext - The ciphertext of the sender.
16
+ * @property {string | undefined} transaction_id - The ID of the transaction that produced the record.
17
+ * @property {string | undefined} transition_id - The ID of the transition that produced the record.
18
+ * @property {number | undefined} transaction_index - The index of the transaction that produced the record.
19
+ * @property {number | undefined} transition_index - The index of the transition that produced the record.
20
+ *
21
+ * @example
22
+ * const encryptedRecord: EncryptedRecord = {
23
+ * commitment: "1754131901135854615627743152473414463769543922079966020586765988138574911385field",
24
+ * checksum: "731623304764338277682996290553427512270277231686866672455141481050283829616field",
25
+ * block_height: 123456,
26
+ * block_timestamp: 1725845998,
27
+ * program_name: "credits.aleo",
28
+ * function_name: "transfer_private",
29
+ * output_index: 0,
30
+ * owner: "ciphertext1qgqdetlfzk98jkm4e7sgqml66e3x2gpg5d6udkpw0g67z0tplkpmzrm6q5dyfd7xhgmhedvptxzwfhrtxaqn7n0hs0esge3lwg9s2zukqgzxd0cr",
31
+ * record_ciphertext: "record1qyqsqt43u9kp97svljyyup3v4jmppd0vgght9edvvmtxx6mxycsej8cwqsrxzmt0w4h8ggcqqgqspf8zqut2ycnap7f0uzz5ktu0cxscca96urtkg2aweuzn70787dsrpp6x76m9de0kjezrqqpqyqp3mn3xeh53lukvcy406amjf5g0ksl3saauzjk0j4ljtjqq6kqlqhdz05sw92zye96qym7kp83ra0eesgtwhaw37c85r499456se8ts28m90p6x2unwv9k97ct4w35x7unf0fshg6t0de0hyet3w45hyetyyvqqyqgq4t2wr9tmcrfha5tfz5j585ptvvslqe0f6sf29vytshhdh7ym05rpqct4w35x7unf0fjkghm4de6xjmprqqpqzqru6p7fef29vuz6smyqwcn3z7jhxtdgjdw5xv23ppxhpgnvu72fp8hz6fjt6gsdn8yxhzq7gpsah0rscwqrzxwl5e8aemkj5gt09y7q5506yrf",
32
+ * record_name: "credits",
33
+ * record_nonce: "3077450429259593211617823051143573281856129402760267155982965992208217472983group",
34
+ * sender_ciphertext: "1754131901135854615627743152473414463769543922079966020586765988138574911385field",
35
+ * transaction_id: "at1f8ueqxu3x49sckpc6jlg676tmxumddzer3fwe2l0dxwj4dqxygyqua4u2q",
36
+ * transition_id: "au17mm5v7sfwus6y40xsyc99d5rtsr4vsajdec6twdjzv0m458q85zspqdnka",
37
+ * transaction_index: 0,
38
+ * transition_index: 0,
39
+ * }
40
+ */
41
+ export type EncryptedRecord = {
42
+ commitment: string;
43
+ checksum?: string;
44
+ block_height?: number;
45
+ block_timestamp?: number;
46
+ program_name?: string;
47
+ function_name?: string;
48
+ output_index?: number;
49
+ owner?: string;
50
+ record_ciphertext?: string;
51
+ record_name?: string;
52
+ record_nonce?: string;
53
+ sender_ciphertext?: string;
54
+ transaction_id?: string;
55
+ transition_id?: string;
56
+ transaction_index?: number;
57
+ transition_index?: number;
58
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Record owned by a registered view key. This type provides the record ciphertext, record plaintext and metadata from the ledger such as the record's name, the program/function that produced it, etc.
3
+ *
4
+ * @property {number | undefined} block_height - Block height where the record was created.
5
+ * @property {number | undefined} block_timestamp - The timestamp of the block that the record was created in.
6
+ * @property {string | undefined} commitment - Commitment of the record.
7
+ * @property {string | undefined} function_name - Name of the function that created the record.
8
+ * @property {number | undefined} output_index - Index of the output in the function call that created the record.
9
+ * @property {string | undefined} owner - Address of the record owner.
10
+ * @property {string | undefined} program_name - Name of the program that created the record.
11
+ * @property {string | undefined} record_ciphertext - Encrypted ciphertext of the record.
12
+ * @property {string | undefined} record_name - Name of the record.
13
+ * @property {string | undefined} sender - Address of the sender.
14
+ * @property {boolean | undefined} spent - Whether the record has been spent.
15
+ * @property {string | undefined} tag - Tag associated with the record.
16
+ * @property {string | undefined} transaction_id - ID of the transaction that created the record.
17
+ * @property {string | undefined} transition_id - ID of the transition that created the record.
18
+ * @property {string | undefined} transaction_index - Index of the transaction in the block.
19
+ * @property {string | undefined} transition_index - Index of the transition in the transaction.
20
+ *
21
+ * @example
22
+ * const ownedRecord: OwnedRecord = {
23
+ * block_height: 123456,
24
+ * block_timestamp: 1725845998,
25
+ * commitment: "1754131901135854615627743152473414463769543922079966020586765988138574911385field",
26
+ * function_name: "transfer_public_to_private",
27
+ * output_index: 0,
28
+ * owner: "ciphertext1qgqdetlfzk98jkm4e7sgqml66e3x2gpg5d6udkpw0g67z0tplkpmzrm6q5dyfd7xhgmhedvptxzwfhrtxaqn7n0hs0esge3lwg9s2zukqgzxd0cr",
29
+ * program_name: "credits.aleo",
30
+ * record_ciphertext: "record1qyqsqt43u9kp97svljyyup3v4jmppd0vgght9edvvmtxx6mxycsej8cwqsrxzmt0w4h8ggcqqgqspf8zqut2ycnap7f0uzz5ktu0cxscca96urtkg2aweuzn70787dsrpp6x76m9de0kjezrqqpqyqp3mn3xeh53lukvcy406amjf5g0ksl3saauzjk0j4ljtjqq6kqlqhdz05sw92zye96qym7kp83ra0eesgtwhaw37c85r499456se8ts28m90p6x2unwv9k97ct4w35x7unf0fshg6t0de0hyet3w45hyetyyvqqyqgq4t2wr9tmcrfha5tfz5j585ptvvslqe0f6sf29vytshhdh7ym05rpqct4w35x7unf0fjkghm4de6xjmprqqpqzqru6p7fef29vuz6smyqwcn3z7jhxtdgjdw5xv23ppxhpgnvu72fp8hz6fjt6gsdn8yxhzq7gpsah0rscwqrzxwl5e8aemkj5gt09y7q5506yrf",
31
+ * record_plaintext: "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public , _version: 1u8 }",
32
+ * record_name: "credits",
33
+ * spent: true,
34
+ * sender: "aleo1sf5kk4f8mcmgjasw9fannmm0h8z2nwqxu5e200cjneu28jxvtvpqulfxsa",
35
+ * tag: "6511661650536816422260305447175136877451468301541296257226129781611237851030field",
36
+ * transaction_id: "at1f8ueqxu3x49sckpc6jlg676tmxumddzer3fwe2l0dxwj4dqxygyqua4u2q",
37
+ * transition_id: "au17mm5v7sfwus6y40xsyc99d5rtsr4vsajdec6twdjzv0m458q85zspqdnka",
38
+ * transaction_index: 0,
39
+ * transition_index: 0,
40
+ * }
41
+ */
42
+ export type OwnedRecord = {
43
+ block_height?: number;
44
+ block_timestamp?: number;
45
+ commitment?: string;
46
+ function_name?: string;
47
+ output_index?: number;
48
+ owner?: string;
49
+ program_name?: string;
50
+ record_ciphertext?: string;
51
+ record_plaintext?: string;
52
+ record_name?: string;
53
+ sender?: string;
54
+ spent?: boolean;
55
+ tag?: string;
56
+ transaction_id?: string;
57
+ transition_id?: string;
58
+ transaction_index?: number;
59
+ transition_index?: number;
60
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider
3
+ * implementations.
4
+ *
5
+ * @example
6
+ * const recordSearchParams: RecordSearchParams = {
7
+ * // Declared fields
8
+ * unspent: true,
9
+ * nonces: ["3077450429259593211617823051143573281856129402760267155982965992208217472983group"],
10
+ * // Arbitrary fields
11
+ * startHeight: 123456,
12
+ * programName: "credits.aleo"
13
+ * }
14
+ */
15
+ export interface RecordSearchParams {
16
+ unspent?: boolean;
17
+ nonces?: string[];
18
+ [key: string]: any;
19
+ }
@@ -0,0 +1,24 @@
1
+ import { RecordSearchParams } from "../record-provider/recordSearchParams";
2
+ import { RecordsFilter } from "./recordsFilter";
3
+ import { OwnedRecordsResponseFilter } from "./ownedRecordsResponseFilter";
4
+ /**
5
+ * OwnedFilter is an extension of RecordSearchParams that represents a filter for scanning owned records.
6
+ *
7
+ * @example
8
+ * const ownedFilter: OwnedFilter = {
9
+ * unspent: true,
10
+ * nonces: ["3077450429259593211617823051143573281856129402760267155982965992208217472983group"],
11
+ * decrypt: true,
12
+ * filter: {
13
+ * program: "credits.aleo",
14
+ * record: "credits",
15
+ * },
16
+ * }
17
+ */
18
+ export interface OwnedFilter extends RecordSearchParams {
19
+ decrypt?: boolean;
20
+ filter?: RecordsFilter;
21
+ responseFilter?: OwnedRecordsResponseFilter;
22
+ unspent?: boolean;
23
+ uuid?: string;
24
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * OwnedRecordsResponseFilter is a type that represents a filter for the response from a record provider.
3
+ * A `true` value for a field in the filter will include that field in the response.
4
+ *
5
+ * @example
6
+ * const ownedRecordsResponseFilter: OwnedRecordsResponseFilter = {
7
+ * commitment: true,
8
+ * owner: true,
9
+ * tag: true,
10
+ * sender: true,
11
+ * spent: true,
12
+ * record_ciphertext: true,
13
+ * block_height: true,
14
+ * block_timestamp: true,
15
+ * output_index: true,
16
+ * record_name: true,
17
+ * function_name: true,
18
+ * program_name: true,
19
+ * transition_id: true,
20
+ * transaction_id: true,
21
+ * transaction_index: true,
22
+ * transition_index: true,
23
+ * }
24
+ */
25
+ export interface OwnedRecordsResponseFilter {
26
+ commitment?: boolean;
27
+ owner?: boolean;
28
+ tag?: boolean;
29
+ sender?: boolean;
30
+ spent?: boolean;
31
+ record_ciphertext?: boolean;
32
+ block_height?: boolean;
33
+ block_timestamp?: boolean;
34
+ output_index?: boolean;
35
+ record_name?: boolean;
36
+ function_name?: boolean;
37
+ program_name?: boolean;
38
+ transition_id?: boolean;
39
+ transaction_id?: boolean;
40
+ transaction_index?: boolean;
41
+ transition_index?: boolean;
42
+ }
@@ -0,0 +1,35 @@
1
+ import { RecordSearchParams } from "../record-provider/recordSearchParams";
2
+ import { RecordsResponseFilter } from "./recordsResponseFilter";
3
+ /**
4
+ * RecordsFilter is an extension of RecordSearchParams that represents a filter for scanning encrypted or owned records.
5
+ *
6
+ * @example
7
+ * const recordsFilter: RecordsFilter = {
8
+ * start: 0,
9
+ * end: 100,
10
+ * programs: ["credits.aleo"],
11
+ * records: ["credits"],
12
+ * functions: ["transfer_public_to_private"],
13
+ * response: {
14
+ * program: true,
15
+ * record: true,
16
+ * function: true,
17
+ * transition: true,
18
+ * block_height: true,
19
+ * transaction_id: true,
20
+ * }
21
+ * results_per_page: 100,
22
+ * page: 0,
23
+ * }
24
+ */
25
+ export interface RecordsFilter extends RecordSearchParams {
26
+ commitments?: string[];
27
+ response?: RecordsResponseFilter;
28
+ start?: number;
29
+ end?: number;
30
+ programs?: string[];
31
+ records?: string[];
32
+ functions?: string[];
33
+ results_per_page?: number;
34
+ page?: number;
35
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * RecordsResponseFilter is a type that represents a filter for the response from a record provider.
3
+ * A `true` value for a field in the filter will include that field in the response.
4
+ *
5
+ * @example
6
+ * const recordsResponseFilter: RecordsResponseFilter = {
7
+ * block_height: true,
8
+ * checksum: true,
9
+ * commitment: true,
10
+ * record_ciphertext: true,
11
+ * function_name: true,
12
+ * nonce: true,
13
+ * output_index: true,
14
+ * owner: true,
15
+ * program_name: true,
16
+ * record_name: true,
17
+ * transaction_id: true,
18
+ * transition_id: true,
19
+ * transaction_index: true,
20
+ * transition_index: true,
21
+ * }
22
+ */
23
+ export type RecordsResponseFilter = {
24
+ blockHeight?: boolean;
25
+ checksum?: boolean;
26
+ commitment?: boolean;
27
+ record_ciphertext?: boolean;
28
+ function_name?: boolean;
29
+ nonce?: boolean;
30
+ output_index?: boolean;
31
+ owner?: boolean;
32
+ program_name?: boolean;
33
+ record_name?: boolean;
34
+ transaction_id?: boolean;
35
+ transition_id?: boolean;
36
+ transaction_index?: boolean;
37
+ transition_index?: boolean;
38
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * RegistrationRequest is a type that represents a request to register an account's view key with a record scanning service.
3
+ *
4
+ * @example
5
+ * const registrationRequest: RegistrationRequest = {
6
+ * view_key: "AViewKey1ccEt8A2Ryva5rxnKcAbn7wgTaTsb79tzkKHFpeKsm9NX",
7
+ * start: 123456,
8
+ * }
9
+ */
10
+ export type RegistrationRequest = {
11
+ view_key: string;
12
+ start: number;
13
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * RegistrationResponse is a type that represents a response from a record scanning service.
3
+ *
4
+ * @example
5
+ * const registrationResponse: RegistrationResponse = {
6
+ * uuid: "5291249998620209321712738612705518874926462927543783711572375085855029172391field",
7
+ * job_id: "3019177021147406178755252788128212930359855601860174268911518336835545087409field",
8
+ * status: "pending",
9
+ * }
10
+ */
11
+ interface RegistrationResponse {
12
+ uuid: string;
13
+ job_id?: string;
14
+ status?: string;
15
+ }
@@ -12,6 +12,18 @@ interface AleoNetworkClientOptions {
12
12
  [key: string]: string;
13
13
  };
14
14
  }
15
+ /**
16
+ * Options for submitting a proving request.
17
+ *
18
+ * @property provingRequest {ProvingRequest | string} The proving request being submitted to the network.
19
+ * @property url {string} The URL of the delegated proving service.
20
+ * @property apiKey {string} The API key to use for authentication.
21
+ */
22
+ interface DelegatedProvingParams {
23
+ provingRequest: ProvingRequest | string;
24
+ url?: string;
25
+ apiKey?: string;
26
+ }
15
27
  /**
16
28
  * Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this
17
29
  * allow users to query public information from the Aleo blockchain and submit transactions to the network.
@@ -34,6 +46,7 @@ declare class AleoNetworkClient {
34
46
  ctx: {
35
47
  [key: string]: string;
36
48
  };
49
+ verboseErrors: boolean;
37
50
  readonly network: string;
38
51
  constructor(host: string, options?: AleoNetworkClientOptions);
39
52
  /**
@@ -59,7 +72,6 @@ declare class AleoNetworkClient {
59
72
  * Set a new host for the networkClient
60
73
  *
61
74
  * @param {string} host The address of a node hosting the Aleo API
62
- * @param host
63
75
  *
64
76
  * @example
65
77
  * import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
@@ -71,6 +83,20 @@ declare class AleoNetworkClient {
71
83
  * networkClient.setHost("http://api.explorer.provable.com/v1");
72
84
  */
73
85
  setHost(host: string): void;
86
+ /**
87
+ * Set verbose errors to true or false for the `AleoNetworkClient`. When set to true, if `submitTransaction` fails, the failure responses will report descriptive information as to why the transaction failed.
88
+ *
89
+ * @param {boolean} verboseErrors Set verbose error mode to true or false for the AleoNetworkClient.
90
+ * @example
91
+ * import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
92
+ *
93
+ * // Create a networkClient
94
+ * const networkClient = new AleoNetworkClient();
95
+ *
96
+ * // Set debug mode to true
97
+ * networkClient.setVerboseTransactionErrors(true);
98
+ **/
99
+ setVerboseErrors(verboseErrors: boolean): void;
74
100
  /**
75
101
  * Set a header in the `AleoNetworkClient`s header map
76
102
  *
@@ -711,11 +737,10 @@ declare class AleoNetworkClient {
711
737
  /**
712
738
  * Submit a `ProvingRequest` to a remote proving service for delegated proving. If the broadcast flag of the `ProvingRequest` is set to `true` the remote service will attempt to broadcast the result `Transaction` on behalf of the requestor.
713
739
  *
714
- * @param {ProvingRequest | string} provingRequest - The `ProvingRequest` (generated by the ProgramManager) to submit.
715
- * @param {string} url - (Optional) The url of the proving service.
740
+ * @param {DelegatedProvingParams} options - The optional parameters required to submit a proving request.
716
741
  * @returns {Promise<ProvingResponse>} The ProvingResponse containing the transaction result and the result of the broadcast if the `broadcast` flag was set to `true`.
717
742
  */
718
- submitProvingRequest(provingRequest: ProvingRequest | string, url?: string): Promise<ProvingResponse>;
743
+ submitProvingRequest(options: DelegatedProvingParams): Promise<ProvingResponse>;
719
744
  /**
720
745
  * Await a submitted transaction to be confirmed or rejected on the Aleo network.
721
746
  *
@@ -1,9 +1,11 @@
1
1
  import { Account } from "./account.js";
2
2
  import { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from "./network-client.js";
3
3
  import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports.js";
4
- import { RecordProvider, RecordSearchParams } from "./record-provider.js";
4
+ import { RecordProvider } from "./record-provider.js";
5
+ import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
5
6
  import { FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
6
7
  import { Authorization, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
8
+ import { OwnedRecord } from "./models/record-provider/ownedRecord.js";
7
9
  /**
8
10
  * Represents the options for executing a transaction in the Aleo network.
9
11
  * This interface is used to specify the parameters required for building and submitting an execution transaction.
@@ -1085,6 +1087,6 @@ declare class ProgramManager {
1085
1087
  * @param {string} program The program source code
1086
1088
  */
1087
1089
  verifyProgram(program: string): boolean;
1088
- getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext>;
1090
+ getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<OwnedRecord>;
1089
1091
  }
1090
1092
  export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions };