@provablehq/sdk 0.8.1 → 0.8.2

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 (103) hide show
  1. package/dist/mainnet/account.d.ts +137 -0
  2. package/dist/mainnet/browser.d.ts +35 -0
  3. package/dist/mainnet/browser.js +934 -0
  4. package/dist/mainnet/browser.js.map +1 -0
  5. package/dist/mainnet/constants.d.ts +34 -0
  6. package/dist/mainnet/function-key-provider.d.ts +349 -0
  7. package/dist/mainnet/managed-worker.d.ts +3 -0
  8. package/dist/mainnet/models/blockJSON.d.ts +21 -0
  9. package/dist/mainnet/models/confirmed_transaction.d.ts +9 -0
  10. package/dist/mainnet/models/deployment/deploymentJSON.d.ts +6 -0
  11. package/dist/mainnet/models/deployment/deploymentObject.d.ts +6 -0
  12. package/dist/mainnet/models/execution/executionJSON.d.ts +11 -0
  13. package/dist/mainnet/models/execution/executionObject.d.ts +11 -0
  14. package/dist/mainnet/models/finalizeJSON.d.ts +6 -0
  15. package/dist/mainnet/models/functionObject.d.ts +8 -0
  16. package/dist/mainnet/models/input/inputJSON.d.ts +9 -0
  17. package/dist/mainnet/models/input/inputObject.d.ts +14 -0
  18. package/dist/mainnet/models/output/outputJSON.d.ts +6 -0
  19. package/dist/mainnet/models/output/outputObject.d.ts +17 -0
  20. package/dist/mainnet/models/owner/ownerJSON.d.ts +4 -0
  21. package/dist/mainnet/models/owner/ownerObject.d.ts +5 -0
  22. package/dist/mainnet/models/plaintext/array.d.ts +3 -0
  23. package/dist/mainnet/models/plaintext/literal.d.ts +1 -0
  24. package/dist/mainnet/models/plaintext/plaintext.d.ts +5 -0
  25. package/dist/mainnet/models/plaintext/struct.d.ts +5 -0
  26. package/dist/mainnet/models/transaction/transactionJSON.d.ts +11 -0
  27. package/dist/mainnet/models/transaction/transactionObject.d.ts +14 -0
  28. package/dist/mainnet/models/transition/transitionJSON.d.ts +13 -0
  29. package/dist/mainnet/models/transition/transitionObject.d.ts +15 -0
  30. package/dist/mainnet/network-client.d.ts +358 -0
  31. package/dist/mainnet/node-polyfill.d.ts +5 -0
  32. package/dist/mainnet/node-polyfill.js +261 -0
  33. package/dist/mainnet/node-polyfill.js.map +1 -0
  34. package/dist/mainnet/node.d.ts +2 -0
  35. package/dist/mainnet/node.js +14 -0
  36. package/dist/mainnet/node.js.map +1 -0
  37. package/dist/mainnet/offline-key-provider.d.ts +348 -0
  38. package/dist/mainnet/polyfill/crypto.d.ts +1 -0
  39. package/dist/mainnet/polyfill/fetch.d.ts +1 -0
  40. package/dist/mainnet/polyfill/shared.d.ts +1 -0
  41. package/dist/mainnet/polyfill/worker.d.ts +1 -0
  42. package/dist/mainnet/polyfill/xmlhttprequest.d.ts +1 -0
  43. package/dist/mainnet/program-manager-pTXN5gjF.js +2369 -0
  44. package/dist/mainnet/program-manager-pTXN5gjF.js.map +1 -0
  45. package/dist/mainnet/program-manager.d.ts +669 -0
  46. package/dist/mainnet/record-provider.d.ts +236 -0
  47. package/dist/mainnet/utils.d.ts +4 -0
  48. package/dist/mainnet/wasm.d.ts +1 -0
  49. package/dist/mainnet/worker.d.ts +9 -0
  50. package/dist/mainnet/worker.js +78 -0
  51. package/dist/mainnet/worker.js.map +1 -0
  52. package/dist/testnet/account.d.ts +137 -0
  53. package/dist/testnet/browser.d.ts +35 -0
  54. package/dist/testnet/browser.js +934 -0
  55. package/dist/testnet/browser.js.map +1 -0
  56. package/dist/testnet/constants.d.ts +34 -0
  57. package/dist/testnet/function-key-provider.d.ts +349 -0
  58. package/dist/testnet/managed-worker.d.ts +3 -0
  59. package/dist/testnet/models/blockJSON.d.ts +21 -0
  60. package/dist/testnet/models/confirmed_transaction.d.ts +9 -0
  61. package/dist/testnet/models/deployment/deploymentJSON.d.ts +6 -0
  62. package/dist/testnet/models/deployment/deploymentObject.d.ts +6 -0
  63. package/dist/testnet/models/execution/executionJSON.d.ts +11 -0
  64. package/dist/testnet/models/execution/executionObject.d.ts +11 -0
  65. package/dist/testnet/models/finalizeJSON.d.ts +6 -0
  66. package/dist/testnet/models/functionObject.d.ts +8 -0
  67. package/dist/testnet/models/input/inputJSON.d.ts +9 -0
  68. package/dist/testnet/models/input/inputObject.d.ts +14 -0
  69. package/dist/testnet/models/output/outputJSON.d.ts +6 -0
  70. package/dist/testnet/models/output/outputObject.d.ts +17 -0
  71. package/dist/testnet/models/owner/ownerJSON.d.ts +4 -0
  72. package/dist/testnet/models/owner/ownerObject.d.ts +5 -0
  73. package/dist/testnet/models/plaintext/array.d.ts +3 -0
  74. package/dist/testnet/models/plaintext/literal.d.ts +1 -0
  75. package/dist/testnet/models/plaintext/plaintext.d.ts +5 -0
  76. package/dist/testnet/models/plaintext/struct.d.ts +5 -0
  77. package/dist/testnet/models/transaction/transactionJSON.d.ts +11 -0
  78. package/dist/testnet/models/transaction/transactionObject.d.ts +14 -0
  79. package/dist/testnet/models/transition/transitionJSON.d.ts +13 -0
  80. package/dist/testnet/models/transition/transitionObject.d.ts +15 -0
  81. package/dist/testnet/network-client.d.ts +358 -0
  82. package/dist/testnet/node-polyfill.d.ts +5 -0
  83. package/dist/testnet/node-polyfill.js +261 -0
  84. package/dist/testnet/node-polyfill.js.map +1 -0
  85. package/dist/testnet/node.d.ts +2 -0
  86. package/dist/testnet/node.js +14 -0
  87. package/dist/testnet/node.js.map +1 -0
  88. package/dist/testnet/offline-key-provider.d.ts +348 -0
  89. package/dist/testnet/polyfill/crypto.d.ts +1 -0
  90. package/dist/testnet/polyfill/fetch.d.ts +1 -0
  91. package/dist/testnet/polyfill/shared.d.ts +1 -0
  92. package/dist/testnet/polyfill/worker.d.ts +1 -0
  93. package/dist/testnet/polyfill/xmlhttprequest.d.ts +1 -0
  94. package/dist/testnet/program-manager-DQZd0G79.js +2369 -0
  95. package/dist/testnet/program-manager-DQZd0G79.js.map +1 -0
  96. package/dist/testnet/program-manager.d.ts +669 -0
  97. package/dist/testnet/record-provider.d.ts +236 -0
  98. package/dist/testnet/utils.d.ts +4 -0
  99. package/dist/testnet/wasm.d.ts +1 -0
  100. package/dist/testnet/worker.d.ts +9 -0
  101. package/dist/testnet/worker.js +78 -0
  102. package/dist/testnet/worker.js.map +1 -0
  103. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Object representation of an Input as raw JSON returned from a SnarkOS node.
3
+ */
4
+ export interface InputJSON {
5
+ type: string;
6
+ id: string;
7
+ tag?: string;
8
+ value?: string;
9
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Aleo function Input represented as a typed typescript object.
3
+ */
4
+ import { Ciphertext, Field, Plaintext } from "../../wasm";
5
+ import { PlaintextObject } from "../plaintext/plaintext";
6
+ /**
7
+ * Object representation of an Input as raw JSON returned from a SnarkOS node.
8
+ */
9
+ export interface InputObject {
10
+ type: "string";
11
+ id: "string" | Field;
12
+ tag?: string | Field;
13
+ value?: Ciphertext | Plaintext | PlaintextObject;
14
+ }
@@ -0,0 +1,6 @@
1
+ export interface OutputJSON {
2
+ type: string;
3
+ id: string;
4
+ checksum?: string;
5
+ value: string;
6
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Aleo function Input represented as a typed typescript object.
3
+ */
4
+ import { Field, Ciphertext, Plaintext } from "../../wasm";
5
+ import { PlaintextObject } from "../plaintext/plaintext";
6
+ /**
7
+ * Object representation of an Input as raw JSON returned from a SnarkOS node.
8
+ */
9
+ export interface OutputObject {
10
+ type: string;
11
+ id: string | Field;
12
+ value?: Ciphertext | Plaintext | PlaintextObject;
13
+ checksum?: string | Field;
14
+ program?: string;
15
+ function?: string;
16
+ arguments?: Array<Plaintext> | Array<OutputObject>;
17
+ }
@@ -0,0 +1,4 @@
1
+ export interface OwnerJSON {
2
+ address: string;
3
+ signature: string;
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Address, Signature } from "../../wasm";
2
+ export interface OwnerObject {
3
+ address: string | Address;
4
+ signature: string | Signature;
5
+ }
@@ -0,0 +1,3 @@
1
+ import { PlaintextLiteral } from "./literal";
2
+ import { PlaintextStruct } from "./struct";
3
+ export type PlaintextArray = PlaintextLiteral[] | PlaintextStruct[] | PlaintextArray[];
@@ -0,0 +1 @@
1
+ export type PlaintextLiteral = boolean | bigint | number | string;
@@ -0,0 +1,5 @@
1
+ import { Plaintext } from "../../wasm";
2
+ import { PlaintextArray } from "./array";
3
+ import { PlaintextLiteral } from "./literal";
4
+ import { PlaintextStruct } from "./struct";
5
+ export type PlaintextObject = PlaintextArray | PlaintextLiteral | PlaintextStruct | Plaintext;
@@ -0,0 +1,5 @@
1
+ import { PlaintextArray } from "./array";
2
+ import { PlaintextLiteral } from "./literal";
3
+ export type PlaintextStruct = {
4
+ [key: string]: PlaintextArray | PlaintextLiteral | PlaintextStruct;
5
+ };
@@ -0,0 +1,11 @@
1
+ import { DeploymentJSON } from "../deployment/deploymentJSON";
2
+ import { ExecutionJSON, FeeExecutionJSON } from "../execution/executionJSON";
3
+ import { OwnerJSON } from "../owner/ownerJSON";
4
+ export interface TransactionJSON {
5
+ type: string;
6
+ id: string;
7
+ deployment?: DeploymentJSON;
8
+ execution?: ExecutionJSON;
9
+ fee: FeeExecutionJSON;
10
+ owner?: OwnerJSON;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { DeploymentObject } from "../deployment/deploymentObject";
2
+ import { ExecutionObject, FeeExecutionObject } from "../execution/executionObject";
3
+ import { OwnerObject } from "../owner/ownerObject";
4
+ export interface TransactionObject {
5
+ type: string;
6
+ id: string;
7
+ execution?: ExecutionObject;
8
+ deployment?: DeploymentObject;
9
+ fee: FeeExecutionObject;
10
+ owner?: OwnerObject;
11
+ feeAmount?: bigint;
12
+ baseFee?: bigint;
13
+ priorityFee?: bigint;
14
+ }
@@ -0,0 +1,13 @@
1
+ import { InputJSON } from "../input/inputJSON";
2
+ import { OutputJSON } from "../output/outputJSON";
3
+ export interface TransitionJSON {
4
+ id: string;
5
+ program: string;
6
+ function: string;
7
+ inputs?: (InputJSON)[];
8
+ outputs?: (OutputJSON)[];
9
+ proof: string;
10
+ tpk: string;
11
+ tcm: string;
12
+ fee: bigint;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { InputObject } from "../input/inputObject";
2
+ import { OutputObject } from "../output/outputObject";
3
+ import { Field, Group } from "../../wasm";
4
+ export interface TransitionObject {
5
+ id: string;
6
+ program: string;
7
+ function: string;
8
+ inputs?: (InputObject)[];
9
+ outputs?: (OutputObject)[];
10
+ proof: string;
11
+ tpk: string | Group;
12
+ tcm: string | Field;
13
+ scm: string | Field;
14
+ fee: bigint;
15
+ }
@@ -0,0 +1,358 @@
1
+ import { Account } from "./account";
2
+ import { BlockJSON } from "./models/blockJSON";
3
+ import { TransactionJSON } from "./models/transaction/transactionJSON";
4
+ import { Plaintext, Program, RecordPlaintext, PrivateKey, Transaction } from "./wasm";
5
+ import { ConfirmedTransactionJSON } from "./models/confirmed_transaction";
6
+ type ProgramImports = {
7
+ [key: string]: string | Program;
8
+ };
9
+ interface AleoNetworkClientOptions {
10
+ headers?: {
11
+ [key: string]: string;
12
+ };
13
+ }
14
+ /**
15
+ * Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this
16
+ * allow users to query public information from the Aleo blockchain and submit transactions to the network.
17
+ *
18
+ * @param {string} host
19
+ * @example
20
+ * // Connection to a local node
21
+ * const localNetworkClient = new AleoNetworkClient("http://localhost:3030");
22
+ *
23
+ * // Connection to a public beacon node
24
+ * const publicnetworkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
25
+ */
26
+ declare class AleoNetworkClient {
27
+ host: string;
28
+ headers: {
29
+ [key: string]: string;
30
+ };
31
+ account: Account | undefined;
32
+ constructor(host: string, options?: AleoNetworkClientOptions);
33
+ /**
34
+ * Set an account to use in networkClient calls
35
+ *
36
+ * @param {Account} account
37
+ * @example
38
+ * const account = new Account();
39
+ * networkClient.setAccount(account);
40
+ */
41
+ setAccount(account: Account): void;
42
+ /**
43
+ * Return the Aleo account used in the networkClient
44
+ *
45
+ * @example
46
+ * const account = networkClient.getAccount();
47
+ */
48
+ getAccount(): Account | undefined;
49
+ /**
50
+ * Set a new host for the networkClient
51
+ *
52
+ * @param {string} host The address of a node hosting the Aleo API
53
+ * @param host
54
+ */
55
+ setHost(host: string): void;
56
+ /**
57
+ * Fetches data from the Aleo network and returns it as a JSON object.
58
+ *
59
+ * @param url
60
+ */
61
+ fetchData<Type>(url?: string): Promise<Type>;
62
+ /**
63
+ * Fetches data from the Aleo network and returns it as an unparsed string.
64
+ *
65
+ * This method should be used when it is desired to reconstitute data returned
66
+ * from the network into a WASM object.
67
+ *
68
+ * @param url
69
+ */
70
+ fetchRaw(url?: string): Promise<string>;
71
+ /**
72
+ * Attempts to find unspent records in the Aleo blockchain for a specified private key.
73
+ * @param {number} startHeight - The height at which to start searching for unspent records
74
+ * @param {number} endHeight - The height at which to stop searching for unspent records
75
+ * @param {string | PrivateKey} privateKey - The private key to use to find unspent records
76
+ * @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
77
+ * @param {number} maxMicrocredits - The maximum number of microcredits to search for
78
+ * @param {string[]} nonces - The nonces of already found records to exclude from the search
79
+ *
80
+ * @example
81
+ * // Find all unspent records
82
+ * const privateKey = "[PRIVATE_KEY]";
83
+ * const records = networkClient.findUnspentRecords(0, undefined, privateKey);
84
+ *
85
+ * // Find specific amounts
86
+ * const startHeight = 500000;
87
+ * const amounts = [600000, 1000000];
88
+ * const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, amounts);
89
+ *
90
+ * // Find specific amounts with a maximum number of cumulative microcredits
91
+ * const maxMicrocredits = 100000;
92
+ * const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, undefined, maxMicrocredits);
93
+ */
94
+ findUnspentRecords(startHeight: number, endHeight: number | undefined, privateKey: string | PrivateKey | undefined, amounts: number[] | undefined, maxMicrocredits?: number | undefined, nonces?: string[] | undefined): Promise<Array<RecordPlaintext>>;
95
+ /**
96
+ * Returns the contents of the block at the specified block height.
97
+ *
98
+ * @param {number} height
99
+ * @example
100
+ * const block = networkClient.getBlock(1234);
101
+ */
102
+ getBlock(height: number): Promise<BlockJSON>;
103
+ /**
104
+ * Returns a range of blocks between the specified block heights.
105
+ *
106
+ * @param {number} start
107
+ * @param {number} end
108
+ * @example
109
+ * const blockRange = networkClient.getBlockRange(2050, 2100);
110
+ */
111
+ getBlockRange(start: number, end: number): Promise<Array<BlockJSON>>;
112
+ /**
113
+ * Returns the deployment transaction id associated with the specified program.
114
+ *
115
+ * @param {Program | string} program
116
+ * @returns {TransactionJSON}
117
+ */
118
+ getDeploymentTransactionIDForProgram(program: Program | string): Promise<string>;
119
+ /**
120
+ * Returns the deployment transaction associated with a specified program.
121
+ *
122
+ * @param {Program | string} program
123
+ * @returns {TransactionJSON}
124
+ */
125
+ getDeploymentTransactionForProgram(program: Program | string): Promise<TransactionJSON>;
126
+ /**
127
+ * Returns the deployment transaction associated with a specified program as a wasm object.
128
+ *
129
+ * @param {Program | string} program
130
+ * @returns {TransactionJSON}
131
+ */
132
+ getDeploymentTransactioObjectnForProgram(program: Program | string): Promise<Transaction>;
133
+ /**
134
+ * Returns the contents of the latest block.
135
+ *
136
+ * @example
137
+ * const latestHeight = networkClient.getLatestBlock();
138
+ */
139
+ getLatestBlock(): Promise<BlockJSON>;
140
+ /**
141
+ * Returns the latest committee.
142
+ *
143
+ * @returns {Promise<object>} A javascript object containing the latest committee
144
+ */
145
+ getLatestCommittee(): Promise<object>;
146
+ /**
147
+ * Returns the latest block height.
148
+ *
149
+ * @example
150
+ * const latestHeight = networkClient.getLatestHeight();
151
+ */
152
+ getLatestHeight(): Promise<number>;
153
+ /**
154
+ * Returns the source code of a program given a program ID.
155
+ *
156
+ * @param {string} programId The program ID of a program deployed to the Aleo Network
157
+ * @return {Promise<string>} Source code of the program
158
+ *
159
+ * @example
160
+ * const program = networkClient.getProgram("hello_hello.aleo");
161
+ * const expectedSource = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n"
162
+ * assert.equal(program, expectedSource);
163
+ */
164
+ getProgram(programId: string): Promise<string>;
165
+ /**
166
+ * Returns a program object from a program ID or program source code.
167
+ *
168
+ * @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network
169
+ * @return {Promise<Program>} Source code of the program
170
+ *
171
+ * @example
172
+ * const programID = "hello_hello.aleo";
173
+ * const programSource = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n"
174
+ *
175
+ * // Get program object from program ID or program source code
176
+ * const programObjectFromID = await networkClient.getProgramObject(programID);
177
+ * const programObjectFromSource = await networkClient.getProgramObject(programSource);
178
+ *
179
+ * // Both program objects should be equal
180
+ * assert.equal(programObjectFromID.to_string(), programObjectFromSource.to_string());
181
+ */
182
+ getProgramObject(inputProgram: string): Promise<Program>;
183
+ /**
184
+ * Returns an object containing the source code of a program and the source code of all programs it imports
185
+ *
186
+ * @param {Program | string} inputProgram The program ID or program source code of a program deployed to the Aleo Network
187
+ * @returns {Promise<ProgramImports>} Object of the form { "program_id": "program_source", .. } containing program id & source code for all program imports
188
+ *
189
+ * @example
190
+ * const double_test_source = "import multiply_test.aleo;\n\nprogram double_test.aleo;\n\nfunction double_it:\n input r0 as u32.private;\n call multiply_test.aleo/multiply 2u32 r0 into r1;\n output r1 as u32.private;\n"
191
+ * const double_test = Program.fromString(double_test_source);
192
+ * const expectedImports = {
193
+ * "multiply_test.aleo": "program multiply_test.aleo;\n\nfunction multiply:\n input r0 as u32.public;\n input r1 as u32.private;\n mul r0 r1 into r2;\n output r2 as u32.private;\n"
194
+ * }
195
+ *
196
+ * // Imports can be fetched using the program ID, source code, or program object
197
+ * let programImports = await networkClient.getProgramImports("double_test.aleo");
198
+ * assert.deepStrictEqual(programImports, expectedImports);
199
+ *
200
+ * // Using the program source code
201
+ * programImports = await networkClient.getProgramImports(double_test_source);
202
+ * assert.deepStrictEqual(programImports, expectedImports);
203
+ *
204
+ * // Using the program object
205
+ * programImports = await networkClient.getProgramImports(double_test);
206
+ * assert.deepStrictEqual(programImports, expectedImports);
207
+ */
208
+ getProgramImports(inputProgram: Program | string): Promise<ProgramImports>;
209
+ /**
210
+ * Get a list of the program names that a program imports.
211
+ *
212
+ * @param {Program | string} inputProgram - The program id or program source code to get the imports of
213
+ * @returns {string[]} - The list of program names that the program imports
214
+ *
215
+ * @example
216
+ * const programImportsNames = networkClient.getProgramImports("double_test.aleo");
217
+ * const expectedImportsNames = ["multiply_test.aleo"];
218
+ * assert.deepStrictEqual(programImportsNames, expectedImportsNames);
219
+ */
220
+ getProgramImportNames(inputProgram: Program | string): Promise<string[]>;
221
+ /**
222
+ * Returns the names of the mappings of a program.
223
+ *
224
+ * @param {string} programId - The program ID to get the mappings of (e.g. "credits.aleo")
225
+ * @example
226
+ * const mappings = networkClient.getProgramMappingNames("credits.aleo");
227
+ * const expectedMappings = ["account"];
228
+ * assert.deepStrictEqual(mappings, expectedMappings);
229
+ */
230
+ getProgramMappingNames(programId: string): Promise<Array<string>>;
231
+ /**
232
+ * Returns the value of a program's mapping for a specific key.
233
+ *
234
+ * @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
235
+ * @param {string} mappingName - The name of the mapping to get the value of (e.g. "account")
236
+ * @param {string | Plaintext} key - The key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
237
+ * @return {Promise<string>} String representation of the value of the mapping
238
+ *
239
+ * @example
240
+ * // Get public balance of an account
241
+ * const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
242
+ * const expectedValue = "0u64";
243
+ * assert.equal(mappingValue, expectedValue);
244
+ */
245
+ getProgramMappingValue(programId: string, mappingName: string, key: string | Plaintext): Promise<string>;
246
+ /**
247
+ * Returns the value of a mapping as a wasm Plaintext object. Returning an
248
+ * object in this format allows it to be converted to a Js type and for its
249
+ * internal members to be inspected if it's a struct or array.
250
+ *
251
+ * @example
252
+ * // Get the bond state as an account.
253
+ * const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
254
+ *
255
+ * // Get the two members of the object individually.
256
+ * const validator = unbondedState.getMember("validator");
257
+ * const microcredits = unbondedState.getMember("microcredits");
258
+ *
259
+ * // Ensure the expected values are correct.
260
+ * assert.equal(validator, "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd");
261
+ * assert.equal(microcredits, BigInt("9007199254740991"));
262
+ *
263
+ * // Get a JS object representation of the unbonded state.
264
+ * const unbondedStateObject = unbondedState.toObject();
265
+ *
266
+ * const expectedState = {
267
+ * validator: "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd",
268
+ * microcredits: BigInt("9007199254740991")
269
+ * };
270
+ * assert.equal(unbondedState, expectedState);
271
+ *
272
+ * @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
273
+ * @param {string} mappingName - The name of the mapping to get the value of (e.g. "account")
274
+ * @param {string | Plaintext} key - The key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
275
+ *
276
+ * @return {Promise<string>} String representation of the value of the mapping
277
+ */
278
+ getProgramMappingPlaintext(programId: string, mappingName: string, key: string | Plaintext): Promise<Plaintext>;
279
+ /**
280
+ * Returns the latest state/merkle root of the Aleo blockchain.
281
+ *
282
+ * @example
283
+ * const stateRoot = networkClient.getStateRoot();
284
+ */
285
+ getStateRoot(): Promise<string>;
286
+ /**
287
+ * Returns a transaction by its unique identifier.
288
+ *
289
+ * @param {string} id
290
+ * @example
291
+ * const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
292
+ */
293
+ getTransaction(transactionId: string): Promise<TransactionJSON>;
294
+ /**
295
+ * Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,
296
+ * outputs, and records to be searched for and displayed.
297
+ *
298
+ * @example
299
+ * const transactionObject = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
300
+ * // Get the transaction inputs as a JS array.
301
+ * const transactionOutputs = transactionObject.inputs(true);
302
+ *
303
+ * // Get the transaction outputs as a JS object.
304
+ * const transactionInputs = transactionObject.outputs(true);
305
+ *
306
+ * // Get any records generated in transitions in the transaction as a JS object.
307
+ * const records = transactionObject.records();
308
+ *
309
+ * // Get the transaction type.
310
+ * const transactionType = transactionObject.transactionType();
311
+ * assert.equal(transactionType, "Execute");
312
+ *
313
+ * // Get a JS representation of all inputs, outputs, and transaction metadata.
314
+ * const transactionSummary = transactionObject.summary();
315
+ *
316
+ * @param {string} transactionId
317
+ * @example
318
+ * const transaction = networkClient.getTransactionObject("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
319
+ */
320
+ getTransactionObject(transactionId: string): Promise<Transaction>;
321
+ /**
322
+ * Returns the transactions present at the specified block height.
323
+ *
324
+ * @param {number} height
325
+ * @example
326
+ * const transactions = networkClient.getTransactions(654);
327
+ */
328
+ getTransactions(height: number): Promise<Array<ConfirmedTransactionJSON>>;
329
+ /**
330
+ * Returns the transactions in the memory pool. This method requires access to a validator's REST API.
331
+ *
332
+ * @example
333
+ * const transactions = networkClient.getTransactionsInMempool();
334
+ */
335
+ getTransactionsInMempool(): Promise<Array<TransactionJSON>>;
336
+ /**
337
+ * Returns the transition ID of the transition corresponding to the ID of the input or output.
338
+ * @param {string} inputOrOutputID - ID of the input or output.
339
+ *
340
+ * @example
341
+ * const transitionId = networkClient.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");
342
+ */
343
+ getTransitionId(inputOrOutputID: string): Promise<string>;
344
+ /**
345
+ * Submit an execute or deployment transaction to the Aleo network.
346
+ *
347
+ * @param {Transaction | string} transaction - The transaction to submit to the network
348
+ * @returns {string} - The transaction id of the submitted transaction or the resulting error
349
+ */
350
+ submitTransaction(transaction: Transaction | string): Promise<string>;
351
+ /**
352
+ * Submit a solution to the Aleo network.
353
+ *
354
+ * @param {string} solution The string representation of the solution desired to be submitted to the network.
355
+ */
356
+ submitSolution(solution: string): Promise<string>;
357
+ }
358
+ export { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports };
@@ -0,0 +1,5 @@
1
+ import "./polyfill/shared";
2
+ import "./polyfill/crypto";
3
+ import "./polyfill/fetch";
4
+ import "./polyfill/xmlhttprequest";
5
+ import "./polyfill/worker";