@provablehq/sdk 0.9.8 → 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.
- package/dist/mainnet/browser.d.ts +8 -2
- package/dist/mainnet/browser.js +74 -48
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/models/record-provider/encryptedRecord.d.ts +58 -0
- package/dist/mainnet/models/record-provider/ownedRecord.d.ts +60 -0
- package/dist/mainnet/models/record-provider/recordSearchParams.d.ts +19 -0
- package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +24 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +35 -0
- package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.ts +38 -0
- package/dist/mainnet/models/record-scanner/registrationRequest.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +15 -0
- package/dist/mainnet/program-manager.d.ts +4 -2
- package/dist/mainnet/record-provider.d.ts +106 -68
- package/dist/testnet/browser.d.ts +8 -2
- package/dist/testnet/browser.js +74 -48
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/models/record-provider/encryptedRecord.d.ts +58 -0
- package/dist/testnet/models/record-provider/ownedRecord.d.ts +60 -0
- package/dist/testnet/models/record-provider/recordSearchParams.d.ts +19 -0
- package/dist/testnet/models/record-scanner/ownedFilter.d.ts +24 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.ts +35 -0
- package/dist/testnet/models/record-scanner/recordsResponseFilter.d.ts +38 -0
- package/dist/testnet/models/record-scanner/registrationRequest.d.ts +13 -0
- package/dist/testnet/models/record-scanner/registrationResponse.d.ts +15 -0
- package/dist/testnet/program-manager.d.ts +4 -2
- package/dist/testnet/record-provider.d.ts +106 -68
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@ import { BlockJSON, Header, Metadata } from "./models/blockJSON.js";
|
|
|
5
5
|
import { ConfirmedTransactionJSON } from "./models/confirmed_transaction.js";
|
|
6
6
|
import { DeploymentJSON, VerifyingKeys } from "./models/deployment/deploymentJSON.js";
|
|
7
7
|
import { DeploymentObject } from "./models/deployment/deploymentObject.js";
|
|
8
|
+
import { EncryptedRecord } from "./models/record-provider/encryptedRecord.js";
|
|
8
9
|
import { ExecutionJSON, FeeExecutionJSON } from "./models/execution/executionJSON.js";
|
|
9
10
|
import { ExecutionObject, FeeExecutionObject } from "./models/execution/executionObject.js";
|
|
10
11
|
import { FinalizeJSON } from "./models/finalizeJSON.js";
|
|
@@ -14,6 +15,8 @@ import { InputJSON } from "./models/input/inputJSON.js";
|
|
|
14
15
|
import { InputObject } from "./models/input/inputObject.js";
|
|
15
16
|
import { OutputJSON } from "./models/output/outputJSON.js";
|
|
16
17
|
import { OutputObject } from "./models/output/outputObject.js";
|
|
18
|
+
import { OwnedFilter } from "./models/record-scanner/ownedFilter.js";
|
|
19
|
+
import { OwnedRecord } from "./models/record-provider/ownedRecord.js";
|
|
17
20
|
import { OwnerJSON } from "./models/owner/ownerJSON.js";
|
|
18
21
|
import { PlaintextArray } from "./models/plaintext/array.js";
|
|
19
22
|
import { PlaintextLiteral } from "./models/plaintext/literal.js";
|
|
@@ -22,6 +25,9 @@ import { PlaintextStruct } from "./models/plaintext/struct.js";
|
|
|
22
25
|
import { ProvingRequestJSON } from "./models/provingRequest.js";
|
|
23
26
|
import { ProvingResponse } from "./models/provingResponse.js";
|
|
24
27
|
import { RatificationJSON } from "./models/ratification.js";
|
|
28
|
+
import { RecordsFilter } from "./models/record-scanner/recordsFilter.js";
|
|
29
|
+
import { RecordsResponseFilter } from "./models/record-scanner/recordsResponseFilter.js";
|
|
30
|
+
import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
|
|
25
31
|
import { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from "./models/solution.js";
|
|
26
32
|
import { TransactionJSON } from "./models/transaction/transactionJSON.js";
|
|
27
33
|
import { TransactionObject } from "./models/transaction/transactionObject.js";
|
|
@@ -29,11 +35,11 @@ import { TransitionJSON } from "./models/transition/transitionJSON.js";
|
|
|
29
35
|
import { TransitionObject } from "./models/transition/transitionObject.js";
|
|
30
36
|
import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
|
|
31
37
|
import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider.js";
|
|
32
|
-
import { BlockHeightSearch, NetworkRecordProvider, RecordProvider
|
|
38
|
+
import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
|
|
33
39
|
declare function initializeWasm(): Promise<void>;
|
|
34
40
|
export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from "./program-manager.js";
|
|
35
41
|
export { logAndThrow } from "./utils.js";
|
|
36
42
|
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm.js";
|
|
37
43
|
export { initializeWasm };
|
|
38
44
|
export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, } from "./constants.js";
|
|
39
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
|
|
45
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, EncryptedRecord, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
|
package/dist/mainnet/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'core-js/proposals/json-parse-with-source.js';
|
|
2
|
-
import { ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, EncryptionToolkit, Group, Program, Plaintext, Transaction, ProvingRequest, Metadata, VerifyingKey, ProvingKey, ProgramManager as ProgramManager$1,
|
|
2
|
+
import { ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, EncryptionToolkit, Group, Program, Plaintext, Transaction, ProvingRequest, Metadata, VerifyingKey, ProvingKey, RecordPlaintext, ProgramManager as ProgramManager$1, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
|
|
3
3
|
export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, GraphKey, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -491,7 +491,7 @@ class AleoNetworkClient {
|
|
|
491
491
|
else {
|
|
492
492
|
this.headers = {
|
|
493
493
|
// This is replaced by the actual version by a Rollup plugin
|
|
494
|
-
"X-Aleo-SDK-Version": "0.9.
|
|
494
|
+
"X-Aleo-SDK-Version": "0.9.9",
|
|
495
495
|
"X-Aleo-environment": environment(),
|
|
496
496
|
};
|
|
497
497
|
}
|
|
@@ -3032,7 +3032,7 @@ class NetworkRecordProvider {
|
|
|
3032
3032
|
/**
|
|
3033
3033
|
* Set the account used to search for records
|
|
3034
3034
|
*
|
|
3035
|
-
* @param {Account} account The account to use for searching for records
|
|
3035
|
+
* @param {Account} account The account used to use for searching for records.
|
|
3036
3036
|
*/
|
|
3037
3037
|
setAccount(account) {
|
|
3038
3038
|
this.account = account;
|
|
@@ -3040,11 +3040,9 @@ class NetworkRecordProvider {
|
|
|
3040
3040
|
/**
|
|
3041
3041
|
* Find a list of credit records with a given number of microcredits by via the official Aleo API
|
|
3042
3042
|
*
|
|
3043
|
-
* @param {number[]} microcredits The number of microcredits to search for
|
|
3044
|
-
* @param {
|
|
3045
|
-
* @
|
|
3046
|
-
* @param {RecordSearchParams} searchParameters Additional parameters to search for
|
|
3047
|
-
* @returns {Promise<RecordPlaintext>} The record if found, otherwise an error
|
|
3043
|
+
* @param {number[]} microcredits The number of microcredits to search for.
|
|
3044
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
3045
|
+
* @returns {Promise<OwnedRecord[]>} The records if found, otherwise an error.
|
|
3048
3046
|
*
|
|
3049
3047
|
* @example
|
|
3050
3048
|
* // Create a new NetworkRecordProvider
|
|
@@ -3053,11 +3051,11 @@ class NetworkRecordProvider {
|
|
|
3053
3051
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3054
3052
|
*
|
|
3055
3053
|
* // The record provider can be used to find records with a given number of microcredits
|
|
3056
|
-
* const record = await recordProvider.findCreditsRecord(5000, true, []);
|
|
3054
|
+
* const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });
|
|
3057
3055
|
*
|
|
3058
3056
|
* // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
|
|
3059
3057
|
* // found again if a subsequent search is performed
|
|
3060
|
-
* const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
|
|
3058
|
+
* const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });
|
|
3061
3059
|
*
|
|
3062
3060
|
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
3063
3061
|
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
@@ -3065,7 +3063,7 @@ class NetworkRecordProvider {
|
|
|
3065
3063
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3066
3064
|
*
|
|
3067
3065
|
* */
|
|
3068
|
-
async findCreditsRecords(microcredits,
|
|
3066
|
+
async findCreditsRecords(microcredits, searchParameters) {
|
|
3069
3067
|
let startHeight = 0;
|
|
3070
3068
|
let endHeight = 0;
|
|
3071
3069
|
let maxAmount = undefined;
|
|
@@ -3082,9 +3080,6 @@ class NetworkRecordProvider {
|
|
|
3082
3080
|
if ("maxAmount" in searchParameters && typeof searchParameters["maxAmount"] == "number") {
|
|
3083
3081
|
maxAmount = searchParameters["maxAmount"];
|
|
3084
3082
|
}
|
|
3085
|
-
if ("unspent" in searchParameters && typeof searchParameters["unspent"] == "boolean") {
|
|
3086
|
-
unspent = searchParameters["unspent"];
|
|
3087
|
-
}
|
|
3088
3083
|
}
|
|
3089
3084
|
// If the end height is not specified, use the current block height
|
|
3090
3085
|
if (endHeight == 0) {
|
|
@@ -3095,16 +3090,20 @@ class NetworkRecordProvider {
|
|
|
3095
3090
|
if (startHeight >= endHeight) {
|
|
3096
3091
|
logAndThrow("Start height must be less than end height");
|
|
3097
3092
|
}
|
|
3098
|
-
|
|
3093
|
+
const recordsPts = await this.networkClient.findRecords(startHeight, endHeight, searchParameters.unspent, ["credits.aleo"], microcredits, maxAmount, searchParameters.nonces, this.account.privateKey());
|
|
3094
|
+
return recordsPts.map((record) => ({
|
|
3095
|
+
owner: record.owner().toString(),
|
|
3096
|
+
programName: 'credits.aleo',
|
|
3097
|
+
recordName: 'credits',
|
|
3098
|
+
recordPlaintext: record.toString(),
|
|
3099
|
+
}));
|
|
3099
3100
|
}
|
|
3100
3101
|
/**
|
|
3101
3102
|
* Find a credit record with a given number of microcredits by via the official Aleo API
|
|
3102
3103
|
*
|
|
3103
|
-
* @param {number} microcredits The number of microcredits to search for
|
|
3104
|
-
* @param {
|
|
3105
|
-
* @
|
|
3106
|
-
* @param {RecordSearchParams} searchParameters Additional parameters to search for
|
|
3107
|
-
* @returns {Promise<RecordPlaintext>} The record if found, otherwise an error
|
|
3104
|
+
* @param {number} microcredits The number of microcredits to search for.
|
|
3105
|
+
* @param {RecordSearchParams} searchParameters Additional parameters to search for.
|
|
3106
|
+
* @returns {Promise<OwnedRecord>} The record if found, otherwise an error.
|
|
3108
3107
|
*
|
|
3109
3108
|
* @example
|
|
3110
3109
|
* // Create a new NetworkRecordProvider
|
|
@@ -3113,21 +3112,21 @@ class NetworkRecordProvider {
|
|
|
3113
3112
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3114
3113
|
*
|
|
3115
3114
|
* // The record provider can be used to find records with a given number of microcredits
|
|
3116
|
-
* const record = await recordProvider.findCreditsRecord(5000, true, []);
|
|
3115
|
+
* const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });
|
|
3117
3116
|
*
|
|
3118
3117
|
* // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
|
|
3119
3118
|
* // found again if a subsequent search is performed
|
|
3120
|
-
* const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
|
|
3119
|
+
* const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });
|
|
3121
3120
|
*
|
|
3122
3121
|
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
3123
3122
|
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
3124
3123
|
* const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
3125
3124
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3126
3125
|
*/
|
|
3127
|
-
async findCreditsRecord(microcredits,
|
|
3126
|
+
async findCreditsRecord(microcredits, searchParameters) {
|
|
3128
3127
|
let records = null;
|
|
3129
3128
|
try {
|
|
3130
|
-
records = await this.findCreditsRecords([microcredits],
|
|
3129
|
+
records = await this.findCreditsRecords([microcredits], searchParameters);
|
|
3131
3130
|
}
|
|
3132
3131
|
catch (e) {
|
|
3133
3132
|
console.log("No records found with error:", e);
|
|
@@ -3141,13 +3140,24 @@ class NetworkRecordProvider {
|
|
|
3141
3140
|
/**
|
|
3142
3141
|
* Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error.
|
|
3143
3142
|
*/
|
|
3144
|
-
async findRecord(
|
|
3145
|
-
|
|
3143
|
+
async findRecord(searchParameters) {
|
|
3144
|
+
let records;
|
|
3145
|
+
try {
|
|
3146
|
+
records = await this.findRecords(searchParameters);
|
|
3147
|
+
}
|
|
3148
|
+
catch (e) {
|
|
3149
|
+
console.log("No records found with error:", e);
|
|
3150
|
+
}
|
|
3151
|
+
if (records && records.length > 0) {
|
|
3152
|
+
return records[0];
|
|
3153
|
+
}
|
|
3154
|
+
console.error("Record not found with error:", records);
|
|
3155
|
+
throw new Error("Record not found");
|
|
3146
3156
|
}
|
|
3147
3157
|
/**
|
|
3148
3158
|
* Find multiple records from a specified program.
|
|
3149
3159
|
*/
|
|
3150
|
-
async findRecords(
|
|
3160
|
+
async findRecords(searchParameters) {
|
|
3151
3161
|
let startHeight = 0;
|
|
3152
3162
|
let endHeight = 0;
|
|
3153
3163
|
let amounts = undefined;
|
|
@@ -3166,29 +3176,35 @@ class NetworkRecordProvider {
|
|
|
3166
3176
|
if ("maxAmount" in searchParameters && typeof searchParameters["maxAmount"] == "number") {
|
|
3167
3177
|
maxAmount = searchParameters["maxAmount"];
|
|
3168
3178
|
}
|
|
3169
|
-
if ("nonces" in searchParameters && Array.isArray(searchParameters["nonces"]) && searchParameters["nonces"].every((item) => typeof item === "string")) {
|
|
3170
|
-
nonces = searchParameters["nonces"];
|
|
3171
|
-
}
|
|
3172
3179
|
if ("program" in searchParameters && typeof searchParameters["program"] == "string") {
|
|
3173
3180
|
programs = [searchParameters["program"]];
|
|
3174
3181
|
}
|
|
3175
3182
|
if ("programs" in searchParameters && Array.isArray(searchParameters["programs"]) && searchParameters["programs"].every((item) => typeof item === "string")) {
|
|
3176
3183
|
programs = searchParameters["programs"];
|
|
3177
3184
|
}
|
|
3178
|
-
if ("unspent" in searchParameters && typeof searchParameters["unspent"] == "boolean") {
|
|
3179
|
-
unspent = searchParameters["unspent"];
|
|
3180
|
-
}
|
|
3181
3185
|
}
|
|
3182
|
-
// If the end height is not specified, use the current block height
|
|
3186
|
+
// If the end height is not specified, use the current block height.
|
|
3183
3187
|
if (endHeight == 0) {
|
|
3184
3188
|
const end = await this.networkClient.getLatestHeight();
|
|
3185
3189
|
endHeight = end;
|
|
3186
3190
|
}
|
|
3187
|
-
// If the start height is greater than the end height, throw an error
|
|
3191
|
+
// If the start height is greater than the end height, throw an error.
|
|
3188
3192
|
if (startHeight >= endHeight) {
|
|
3189
3193
|
logAndThrow("Start height must be less than end height");
|
|
3190
3194
|
}
|
|
3191
|
-
|
|
3195
|
+
const recordPts = await this.networkClient.findRecords(startHeight, endHeight, searchParameters.unspent, programs, amounts, maxAmount, searchParameters.nonces, this.account.privateKey());
|
|
3196
|
+
return recordPts.map((record) => ({
|
|
3197
|
+
record_plaintext: record.toString(),
|
|
3198
|
+
}));
|
|
3199
|
+
}
|
|
3200
|
+
async encryptedRecords(recordsFilter, responseFilter) {
|
|
3201
|
+
throw new Error("Not implemented");
|
|
3202
|
+
}
|
|
3203
|
+
async checkSerialNumbers(serialNumbers) {
|
|
3204
|
+
throw new Error("Not implemented");
|
|
3205
|
+
}
|
|
3206
|
+
async checkTags(tags) {
|
|
3207
|
+
throw new Error("Not implemented");
|
|
3192
3208
|
}
|
|
3193
3209
|
}
|
|
3194
3210
|
/**
|
|
@@ -3206,15 +3222,17 @@ class NetworkRecordProvider {
|
|
|
3206
3222
|
*
|
|
3207
3223
|
* // The record provider can be used to find records with a given number of microcredits and the block height search
|
|
3208
3224
|
* // can be used to find records within a given block height range
|
|
3209
|
-
* const record = await recordProvider.findCreditsRecord(5000, true, [], params);
|
|
3225
|
+
* const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [], ...params });
|
|
3210
3226
|
*
|
|
3211
3227
|
*/
|
|
3212
3228
|
class BlockHeightSearch {
|
|
3213
3229
|
startHeight;
|
|
3214
3230
|
endHeight;
|
|
3215
|
-
|
|
3231
|
+
unspent;
|
|
3232
|
+
constructor(startHeight, endHeight, unspent) {
|
|
3216
3233
|
this.startHeight = startHeight;
|
|
3217
3234
|
this.endHeight = endHeight;
|
|
3235
|
+
this.unspent = !!unspent;
|
|
3218
3236
|
}
|
|
3219
3237
|
}
|
|
3220
3238
|
|
|
@@ -3392,7 +3410,7 @@ class ProgramManager {
|
|
|
3392
3410
|
// Get the fee record from the account if it is not provided in the parameters
|
|
3393
3411
|
try {
|
|
3394
3412
|
feeRecord = privateFee
|
|
3395
|
-
? (await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams))
|
|
3413
|
+
? RecordPlaintext.fromString((await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams)).record_plaintext ?? '')
|
|
3396
3414
|
: undefined;
|
|
3397
3415
|
}
|
|
3398
3416
|
catch (e) {
|
|
@@ -3556,7 +3574,7 @@ class ProgramManager {
|
|
|
3556
3574
|
// Get the fee record from the account if it is not provided in the parameters
|
|
3557
3575
|
try {
|
|
3558
3576
|
feeRecord = privateFee
|
|
3559
|
-
? (await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams))
|
|
3577
|
+
? RecordPlaintext.fromString((await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams)).record_plaintext ?? '')
|
|
3560
3578
|
: undefined;
|
|
3561
3579
|
}
|
|
3562
3580
|
catch (e) {
|
|
@@ -3839,7 +3857,7 @@ class ProgramManager {
|
|
|
3839
3857
|
// Get the fee record from the account if it is not provided in the parameters.
|
|
3840
3858
|
try {
|
|
3841
3859
|
feeRecord = privateFee
|
|
3842
|
-
? (await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams))
|
|
3860
|
+
? RecordPlaintext.fromString((await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams)).record_plaintext ?? '')
|
|
3843
3861
|
: undefined;
|
|
3844
3862
|
}
|
|
3845
3863
|
catch (e) {
|
|
@@ -4078,7 +4096,7 @@ class ProgramManager {
|
|
|
4078
4096
|
// Get the fee record from the account if it is not provided in the parameters
|
|
4079
4097
|
try {
|
|
4080
4098
|
feeRecord = privateFee
|
|
4081
|
-
? (await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams))
|
|
4099
|
+
? RecordPlaintext.fromString((await this.getCreditsRecord(priorityFee, [], feeRecord, recordSearchParams)).record_plaintext ?? '')
|
|
4082
4100
|
: undefined;
|
|
4083
4101
|
}
|
|
4084
4102
|
catch (e) {
|
|
@@ -4268,14 +4286,14 @@ class ProgramManager {
|
|
|
4268
4286
|
const nonces = [];
|
|
4269
4287
|
if (requiresAmountRecord(transferType)) {
|
|
4270
4288
|
// If the transfer type is private and requires an amount record, get it from the record provider
|
|
4271
|
-
amountRecord = (await this.getCreditsRecord(priorityFee, [], amountRecord, recordSearchParams));
|
|
4289
|
+
amountRecord = RecordPlaintext.fromString((await this.getCreditsRecord(priorityFee, [], amountRecord, recordSearchParams)).record_plaintext ?? '');
|
|
4272
4290
|
nonces.push(amountRecord.nonce());
|
|
4273
4291
|
}
|
|
4274
4292
|
else {
|
|
4275
4293
|
amountRecord = undefined;
|
|
4276
4294
|
}
|
|
4277
4295
|
feeRecord = privateFee
|
|
4278
|
-
? (await this.getCreditsRecord(priorityFee, nonces, feeRecord, recordSearchParams))
|
|
4296
|
+
? RecordPlaintext.fromString((await this.getCreditsRecord(priorityFee, nonces, feeRecord, recordSearchParams)).record_plaintext ?? '')
|
|
4279
4297
|
: undefined;
|
|
4280
4298
|
}
|
|
4281
4299
|
catch (e) {
|
|
@@ -4982,14 +5000,22 @@ class ProgramManager {
|
|
|
4982
5000
|
// Internal utility function for getting a credits.aleo record
|
|
4983
5001
|
async getCreditsRecord(amount, nonces, record, params) {
|
|
4984
5002
|
try {
|
|
4985
|
-
return record instanceof RecordPlaintext
|
|
4986
|
-
|
|
4987
|
-
|
|
5003
|
+
// return record instanceof RecordPlaintext
|
|
5004
|
+
// ? record
|
|
5005
|
+
// : RecordPlaintext.fromString(<string>record);
|
|
5006
|
+
if (record && record instanceof RecordPlaintext) {
|
|
5007
|
+
record = record.toString();
|
|
5008
|
+
}
|
|
5009
|
+
return ({
|
|
5010
|
+
recordPlaintext: record,
|
|
5011
|
+
programName: 'credits.aleo',
|
|
5012
|
+
recordName: 'credits',
|
|
5013
|
+
});
|
|
4988
5014
|
}
|
|
4989
5015
|
catch (e) {
|
|
4990
5016
|
try {
|
|
4991
5017
|
const recordProvider = this.recordProvider;
|
|
4992
|
-
return
|
|
5018
|
+
return await recordProvider.findCreditsRecord(amount, { ...params, unspent: true, nonces });
|
|
4993
5019
|
}
|
|
4994
5020
|
catch (e) {
|
|
4995
5021
|
logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
|