@provablehq/sdk 0.6.11 → 0.6.13

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.
@@ -1,4 +1,4 @@
1
- import { ProvingKey, VerifyingKey } from "./index";
1
+ import { ProvingKey, VerifyingKey, Key } from "./index";
2
2
  type FunctionKeyPair = [ProvingKey, VerifyingKey];
3
3
  type CachedKeyPair = [Uint8Array, Uint8Array];
4
4
  type AleoKeyProviderInitParams = {
@@ -18,6 +18,7 @@ interface KeySearchParams {
18
18
  * verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.
19
19
  */
20
20
  declare class AleoKeyProviderParams implements KeySearchParams {
21
+ name: string | undefined;
21
22
  proverUri: string | undefined;
22
23
  verifierUri: string | undefined;
23
24
  cacheKey: string | undefined;
@@ -33,6 +34,7 @@ declare class AleoKeyProviderParams implements KeySearchParams {
33
34
  proverUri?: string;
34
35
  verifierUri?: string;
35
36
  cacheKey?: string;
37
+ name?: string;
36
38
  });
37
39
  }
38
40
  /**
@@ -278,7 +280,17 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
278
280
  * CREDITS_PROGRAM_KEYS.transfer_private.verifier,
279
281
  * );
280
282
  */
281
- fetchKeys(proverUrl: string, verifierUrl: string, cacheKey?: string): Promise<FunctionKeyPair | Error>;
283
+ fetchRemoteKeys(proverUrl: string, verifierUrl: string, cacheKey?: string): Promise<FunctionKeyPair | Error>;
284
+ /***
285
+ * Fetches the proving key from a remote source.
286
+ *
287
+ * @param proverUrl
288
+ * @param cacheKey
289
+ *
290
+ * @returns {Promise<ProvingKey | Error>} Proving key for the specified program
291
+ */
292
+ fetchProvingKey(proverUrl: string, cacheKey?: string): Promise<ProvingKey | Error>;
293
+ fetchCreditsKeys(key: Key): Promise<FunctionKeyPair | Error>;
282
294
  bondPublicKeys(): Promise<FunctionKeyPair | Error>;
283
295
  bondValidatorKeys(): Promise<FunctionKeyPair | Error>;
284
296
  claimUnbondPublicKeys(): Promise<FunctionKeyPair | Error>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { VerifyingKey } from "@provablehq/wasm";
2
2
  declare const KEY_STORE: string;
3
3
  interface Key {
4
+ name: string;
4
5
  locator: string;
5
6
  prover: string;
6
7
  verifier: string;
@@ -22,6 +23,7 @@ declare const CREDITS_PROGRAM_KEYS: {
22
23
  transfer_public_as_signer: Key;
23
24
  transfer_public_to_private: Key;
24
25
  unbond_public: Key;
26
+ getKey: (key: string) => Key | Error;
25
27
  };
26
28
  declare const PRIVATE_TRANSFER_TYPES: Set<string>;
27
29
  declare const VALID_TRANSFER_TYPES: Set<string>;
@@ -47,4 +49,4 @@ export { createAleoWorker } from "./managed-worker";
47
49
  export { ProgramManager } from "./program-manager";
48
50
  export { Address, Execution as FunctionExecution, ExecutionResponse, Field, OfflineQuery, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Transaction, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm";
49
51
  export { initializeWasm };
50
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, Block, BlockHeightSearch, CachedKeyPair, Execution, FunctionKeyPair, FunctionKeyProvider, Input, KeySearchParams, NetworkRecordProvider, ProgramImports, OfflineKeyProvider, OfflineSearchParams, Output, RecordProvider, RecordSearchParams, TransactionModel, Transition, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, logAndThrow, };
52
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, Block, BlockHeightSearch, CachedKeyPair, Execution, FunctionKeyPair, FunctionKeyProvider, Input, Key, KeySearchParams, NetworkRecordProvider, ProgramImports, OfflineKeyProvider, OfflineSearchParams, Output, RecordProvider, RecordSearchParams, TransactionModel, Transition, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, logAndThrow, };
package/dist/index.js CHANGED
@@ -232,7 +232,7 @@ class AleoNetworkClient {
232
232
  else {
233
233
  this.headers = {
234
234
  // This is replaced by the actual version by a Rollup plugin
235
- "X-Aleo-SDK-Version": "0.6.10",
235
+ "X-Aleo-SDK-Version": "0.6.12",
236
236
  };
237
237
  }
238
238
  }
@@ -839,6 +839,7 @@ class AleoNetworkClient {
839
839
  * verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.
840
840
  */
841
841
  class AleoKeyProviderParams {
842
+ name;
842
843
  proverUri;
843
844
  verifierUri;
844
845
  cacheKey;
@@ -854,6 +855,7 @@ class AleoKeyProviderParams {
854
855
  this.proverUri = params.proverUri;
855
856
  this.verifierUri = params.verifierUri;
856
857
  this.cacheKey = params.cacheKey;
858
+ this.name = params.name;
857
859
  }
858
860
  }
859
861
  /**
@@ -964,6 +966,12 @@ class AleoKeyProvider {
964
966
  let proverUrl;
965
967
  let verifierUrl;
966
968
  let cacheKey;
969
+ if ("name" in params && typeof params["name"] == "string") {
970
+ let key = CREDITS_PROGRAM_KEYS.getKey(params["name"]);
971
+ if (!(key instanceof Error)) {
972
+ return this.fetchCreditsKeys(key);
973
+ }
974
+ }
967
975
  if ("proverUri" in params && typeof params["proverUri"] == "string") {
968
976
  proverUrl = params["proverUri"];
969
977
  }
@@ -974,7 +982,7 @@ class AleoKeyProvider {
974
982
  cacheKey = params["cacheKey"];
975
983
  }
976
984
  if (proverUrl && verifierUrl) {
977
- return await this.fetchKeys(proverUrl, verifierUrl, cacheKey);
985
+ return await this.fetchRemoteKeys(proverUrl, verifierUrl, cacheKey);
978
986
  }
979
987
  if (cacheKey) {
980
988
  return this.getKeys(cacheKey);
@@ -1007,7 +1015,7 @@ class AleoKeyProvider {
1007
1015
  * CREDITS_PROGRAM_KEYS.transfer_private.verifier,
1008
1016
  * );
1009
1017
  */
1010
- async fetchKeys(proverUrl, verifierUrl, cacheKey) {
1018
+ async fetchRemoteKeys(proverUrl, verifierUrl, cacheKey) {
1011
1019
  try {
1012
1020
  // If cache is enabled, check if the keys have already been fetched and return them if they have
1013
1021
  if (this.cacheOption) {
@@ -1038,14 +1046,67 @@ class AleoKeyProvider {
1038
1046
  throw new Error(`Error: ${error} fetching fee proving and verifying keys from ${proverUrl} and ${verifierUrl}.`);
1039
1047
  }
1040
1048
  }
1041
- bondPublicKeys() {
1042
- return this.fetchKeys(CREDITS_PROGRAM_KEYS.bond_public.prover, CREDITS_PROGRAM_KEYS.bond_public.verifier, CREDITS_PROGRAM_KEYS.bond_public.locator);
1049
+ /***
1050
+ * Fetches the proving key from a remote source.
1051
+ *
1052
+ * @param proverUrl
1053
+ * @param cacheKey
1054
+ *
1055
+ * @returns {Promise<ProvingKey | Error>} Proving key for the specified program
1056
+ */
1057
+ async fetchProvingKey(proverUrl, cacheKey) {
1058
+ try {
1059
+ // If cache is enabled, check if the keys have already been fetched and return them if they have
1060
+ if (this.cacheOption) {
1061
+ if (!cacheKey) {
1062
+ cacheKey = proverUrl;
1063
+ }
1064
+ const value = this.cache.get(cacheKey);
1065
+ if (typeof value !== "undefined") {
1066
+ return ProvingKey.fromBytes(value[0]);
1067
+ }
1068
+ else {
1069
+ console.debug("Fetching proving keys from url " + proverUrl);
1070
+ const provingKey = ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
1071
+ return provingKey;
1072
+ }
1073
+ }
1074
+ else {
1075
+ const provingKey = ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
1076
+ return provingKey;
1077
+ }
1078
+ }
1079
+ catch (error) {
1080
+ throw new Error(`Error: ${error} fetching fee proving keys from ${proverUrl}`);
1081
+ }
1082
+ }
1083
+ async fetchCreditsKeys(key) {
1084
+ try {
1085
+ if (!this.cache.has(key.locator) || !this.cacheOption) {
1086
+ const verifying_key = key.verifyingKey();
1087
+ const proving_key = await this.fetchProvingKey(key.prover, key.locator);
1088
+ if (this.cacheOption) {
1089
+ this.cache.set(CREDITS_PROGRAM_KEYS.bond_public.locator, [proving_key.toBytes(), verifying_key.toBytes()]);
1090
+ }
1091
+ return [proving_key, verifying_key];
1092
+ }
1093
+ else {
1094
+ const keyPair = this.cache.get(key.locator);
1095
+ return [ProvingKey.fromBytes(keyPair[0]), VerifyingKey.fromBytes(keyPair[1])];
1096
+ }
1097
+ }
1098
+ catch (error) {
1099
+ throw new Error(`Error: fetching credits.aleo keys: ${error}`);
1100
+ }
1101
+ }
1102
+ async bondPublicKeys() {
1103
+ return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_public);
1043
1104
  }
1044
1105
  bondValidatorKeys() {
1045
- return this.fetchKeys(CREDITS_PROGRAM_KEYS.bond_validator.prover, CREDITS_PROGRAM_KEYS.bond_validator.verifier, CREDITS_PROGRAM_KEYS.bond_validator.locator);
1106
+ return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_validator);
1046
1107
  }
1047
1108
  claimUnbondPublicKeys() {
1048
- return this.fetchKeys(CREDITS_PROGRAM_KEYS.claim_unbond_public.prover, CREDITS_PROGRAM_KEYS.claim_unbond_public.verifier, CREDITS_PROGRAM_KEYS.claim_unbond_public.locator);
1109
+ return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.claim_unbond_public);
1049
1110
  }
1050
1111
  /**
1051
1112
  * Returns the proving and verifying keys for the transfer functions in the credits.aleo program
@@ -1067,19 +1128,19 @@ class AleoKeyProvider {
1067
1128
  */
1068
1129
  async transferKeys(visibility) {
1069
1130
  if (PRIVATE_TRANSFER.has(visibility)) {
1070
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.transfer_private.prover, CREDITS_PROGRAM_KEYS.transfer_private.verifier, CREDITS_PROGRAM_KEYS.transfer_private.locator);
1131
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private);
1071
1132
  }
1072
1133
  else if (PRIVATE_TO_PUBLIC_TRANSFER.has(visibility)) {
1073
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.transfer_private_to_public.prover, CREDITS_PROGRAM_KEYS.transfer_private_to_public.verifier, CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator);
1134
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private_to_public);
1074
1135
  }
1075
1136
  else if (PUBLIC_TRANSFER.has(visibility)) {
1076
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.transfer_public.prover, CREDITS_PROGRAM_KEYS.transfer_public.verifier, CREDITS_PROGRAM_KEYS.transfer_public.locator);
1137
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public);
1077
1138
  }
1078
1139
  else if (PUBLIC_TRANSFER_AS_SIGNER.has(visibility)) {
1079
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.transfer_public_as_signer.prover, CREDITS_PROGRAM_KEYS.transfer_public_as_signer.verifier, CREDITS_PROGRAM_KEYS.transfer_public_as_signer.locator);
1140
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_as_signer);
1080
1141
  }
1081
1142
  else if (PUBLIC_TO_PRIVATE_TRANSFER.has(visibility)) {
1082
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.transfer_public_to_private.prover, CREDITS_PROGRAM_KEYS.transfer_public_to_private.verifier, CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator);
1143
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_to_private);
1083
1144
  }
1084
1145
  else {
1085
1146
  throw new Error("Invalid visibility type");
@@ -1091,7 +1152,7 @@ class AleoKeyProvider {
1091
1152
  * @returns {Promise<FunctionKeyPair | Error>} Proving and verifying keys for the join function
1092
1153
  */
1093
1154
  async joinKeys() {
1094
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.join.prover, CREDITS_PROGRAM_KEYS.join.verifier, CREDITS_PROGRAM_KEYS.join.locator);
1155
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.join);
1095
1156
  }
1096
1157
  /**
1097
1158
  * Returns the proving and verifying keys for the split function in the credits.aleo program
@@ -1099,7 +1160,7 @@ class AleoKeyProvider {
1099
1160
  * @returns {Promise<FunctionKeyPair | Error>} Proving and verifying keys for the split function
1100
1161
  * */
1101
1162
  async splitKeys() {
1102
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.split.prover, CREDITS_PROGRAM_KEYS.split.verifier, CREDITS_PROGRAM_KEYS.split.locator);
1163
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.split);
1103
1164
  }
1104
1165
  /**
1105
1166
  * Returns the proving and verifying keys for the fee_private function in the credits.aleo program
@@ -1107,7 +1168,7 @@ class AleoKeyProvider {
1107
1168
  * @returns {Promise<FunctionKeyPair | Error>} Proving and verifying keys for the fee function
1108
1169
  */
1109
1170
  async feePrivateKeys() {
1110
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.fee_private.prover, CREDITS_PROGRAM_KEYS.fee_private.verifier, CREDITS_PROGRAM_KEYS.fee_private.locator);
1171
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_private);
1111
1172
  }
1112
1173
  /**
1113
1174
  * Returns the proving and verifying keys for the fee_public function in the credits.aleo program
@@ -1115,7 +1176,7 @@ class AleoKeyProvider {
1115
1176
  * @returns {Promise<FunctionKeyPair | Error>} Proving and verifying keys for the fee function
1116
1177
  */
1117
1178
  async feePublicKeys() {
1118
- return await this.fetchKeys(CREDITS_PROGRAM_KEYS.fee_public.prover, CREDITS_PROGRAM_KEYS.fee_public.verifier, CREDITS_PROGRAM_KEYS.fee_public.locator);
1179
+ return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public);
1119
1180
  }
1120
1181
  /**
1121
1182
  * Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise
@@ -1174,7 +1235,7 @@ class AleoKeyProvider {
1174
1235
  }
1175
1236
  }
1176
1237
  unBondPublicKeys() {
1177
- return this.fetchKeys(CREDITS_PROGRAM_KEYS.unbond_public.prover, CREDITS_PROGRAM_KEYS.unbond_public.verifier, CREDITS_PROGRAM_KEYS.unbond_public.locator);
1238
+ return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.unbond_public);
1178
1239
  }
1179
1240
  }
1180
1241
 
@@ -2373,7 +2434,6 @@ class ProgramManager {
2373
2434
  * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
2374
2435
  * @param {number} fee The fee to pay for the transfer
2375
2436
  * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
2376
- * @param {string | undefined} caller The caller of the function (if calling transfer_public)
2377
2437
  * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
2378
2438
  * records for the transfer transaction
2379
2439
  * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
@@ -2395,7 +2455,7 @@ class ProgramManager {
2395
2455
  * const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
2396
2456
  * const transaction = await programManager.networkClient.getTransaction(tx_id);
2397
2457
  */
2398
- async buildTransferTransaction(amount, recipient, transferType, fee, privateFee, caller, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) {
2458
+ async buildTransferTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) {
2399
2459
  // Validate the transfer type
2400
2460
  transferType = validateTransferType(transferType);
2401
2461
  // Get the private key from the account if it is not provided in the parameters
@@ -2436,13 +2496,12 @@ class ProgramManager {
2436
2496
  throw logAndThrow(`Error finding fee record. Record finder response: '${e}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
2437
2497
  }
2438
2498
  // Build an execution transaction and submit it to the network
2439
- return await ProgramManager$1.buildTransferTransaction(executionPrivateKey, amount, recipient, transferType, caller, amountRecord, fee, feeRecord, this.host, transferProvingKey, transferVerifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
2499
+ return await ProgramManager$1.buildTransferTransaction(executionPrivateKey, amount, recipient, transferType, amountRecord, fee, feeRecord, this.host, transferProvingKey, transferVerifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
2440
2500
  }
2441
2501
  /**
2442
2502
  * Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network
2443
2503
  *
2444
2504
  * @param {number} amount The amount of credits to transfer
2445
- * @param {string} caller The caller of the transfer (may be different from the signer)
2446
2505
  * @param {string} recipient The recipient of the transfer
2447
2506
  * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
2448
2507
  * @param {number} fee The fee to pay for the transfer
@@ -2455,8 +2514,8 @@ class ProgramManager {
2455
2514
  * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
2456
2515
  * @returns {Promise<string | Error>} The transaction id of the transfer transaction
2457
2516
  */
2458
- async buildTransferPublicTransaction(amount, caller, recipient, fee, privateKey, offlineQuery) {
2459
- return this.buildTransferTransaction(amount, recipient, "public", fee, false, caller, undefined, undefined, undefined, privateKey, offlineQuery);
2517
+ async buildTransferPublicTransaction(amount, recipient, fee, privateKey, offlineQuery) {
2518
+ return this.buildTransferTransaction(amount, recipient, "public", fee, false, undefined, undefined, undefined, privateKey, offlineQuery);
2460
2519
  }
2461
2520
  /**
2462
2521
  * Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network
@@ -2475,7 +2534,7 @@ class ProgramManager {
2475
2534
  * @returns {Promise<string | Error>} The transaction id of the transfer transaction
2476
2535
  */
2477
2536
  async buildTransferPublicAsSignerTransaction(amount, recipient, fee, privateKey, offlineQuery) {
2478
- return this.buildTransferTransaction(amount, recipient, "public", fee, false, undefined, undefined, undefined, undefined, privateKey, offlineQuery);
2537
+ return this.buildTransferTransaction(amount, recipient, "public", fee, false, undefined, undefined, undefined, privateKey, offlineQuery);
2479
2538
  }
2480
2539
  /**
2481
2540
  * Transfer credits to another account
@@ -2485,7 +2544,6 @@ class ProgramManager {
2485
2544
  * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
2486
2545
  * @param {number} fee The fee to pay for the transfer
2487
2546
  * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
2488
- * @param {string | undefined} caller The caller of the function (if calling transfer_public)
2489
2547
  * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
2490
2548
  * records for the transfer transaction
2491
2549
  * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
@@ -2506,8 +2564,8 @@ class ProgramManager {
2506
2564
  * const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
2507
2565
  * const transaction = await programManager.networkClient.getTransaction(tx_id);
2508
2566
  */
2509
- async transfer(amount, recipient, transferType, fee, privateFee, caller, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) {
2510
- const tx = await this.buildTransferTransaction(amount, recipient, transferType, fee, privateFee, caller, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery);
2567
+ async transfer(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) {
2568
+ const tx = await this.buildTransferTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery);
2511
2569
  return await this.networkClient.submitTransaction(tx);
2512
2570
  }
2513
2571
  /**
@@ -2960,6 +3018,7 @@ function convert(metadata) {
2960
3018
  throw new Error("Invalid method name: " + metadata.verifyingKey);
2961
3019
  }
2962
3020
  return {
3021
+ name: metadata.name,
2963
3022
  locator: metadata.locator,
2964
3023
  prover: metadata.prover,
2965
3024
  verifier: metadata.verifier,
@@ -2982,6 +3041,14 @@ const CREDITS_PROGRAM_KEYS = {
2982
3041
  transfer_public_as_signer: convert(Metadata.transfer_public_as_signer()),
2983
3042
  transfer_public_to_private: convert(Metadata.transfer_public_to_private()),
2984
3043
  unbond_public: convert(Metadata.unbond_public()),
3044
+ getKey: function (key) {
3045
+ if (this.hasOwnProperty(key)) {
3046
+ return this[key];
3047
+ }
3048
+ else {
3049
+ return new Error(`Key "${key}" not found.`);
3050
+ }
3051
+ }
2985
3052
  };
2986
3053
  const PRIVATE_TRANSFER_TYPES = new Set([
2987
3054
  "transfer_private",