You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Destructure the options object to access the parameters.
864
+
const{
865
+
programName,
866
+
functionName,
867
+
baseFee,
868
+
priorityFee,
869
+
privateFee,
870
+
inputs,
871
+
recordSearchParams,
872
+
broadcast =false,
873
+
unchecked =false,
874
+
}=options;
875
+
876
+
constprivateKey=options.privateKey;
877
+
letprogram=options.programSource;
878
+
letfeeRecord=options.feeRecord;
879
+
letimports=options.programImports;
880
+
881
+
// Ensure the function exists on the network.
882
+
if(program===undefined){
883
+
try{
884
+
program=<string>(
885
+
awaitthis.networkClient.getProgram(programName)
886
+
);
887
+
}catch(e: any){
888
+
logAndThrow(
889
+
`Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,
890
+
);
891
+
}
892
+
}elseif(programinstanceofProgram){
893
+
program=program.toString();
894
+
}
895
+
896
+
// Get the private key from the account if it is not provided in the parameters.
897
+
letexecutionPrivateKey=privateKey;
898
+
if(
899
+
typeofprivateKey==="undefined"&&
900
+
typeofthis.account!=="undefined"
901
+
){
902
+
executionPrivateKey=this.account.privateKey();
903
+
}
904
+
905
+
if(typeofexecutionPrivateKey==="undefined"){
906
+
throw"No private key provided and no private key set in the ProgramManager";
907
+
}
908
+
909
+
// Get the fee record from the account if it is not provided in the parameters.
910
+
try{
911
+
feeRecord=privateFee
912
+
? <RecordPlaintext>(
913
+
awaitthis.getCreditsRecord(
914
+
priorityFee,
915
+
[],
916
+
feeRecord,
917
+
recordSearchParams,
918
+
)
919
+
)
920
+
: undefined;
921
+
}catch(e: any){
922
+
logAndThrow(
923
+
`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.`,
`Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,
* Builds a SnarkVM fee `Authorization` for `credits.aleo/fee_private` or `credits.aleo/fee_public`. If a record is provided `fee_private` will be executed, otherwise `fee_public` will be executed.
795
958
*
@@ -1082,13 +1245,13 @@ class ProgramManager {
1082
1245
try{
1083
1246
feeRecord=privateFee
1084
1247
? <RecordPlaintext>(
1085
-
awaitthis.getCreditsRecord(
1086
-
priorityFee,
1087
-
[],
1088
-
feeRecord,
1089
-
recordSearchParams,
1090
-
)
1091
-
)
1248
+
awaitthis.getCreditsRecord(
1249
+
priorityFee,
1250
+
[],
1251
+
feeRecord,
1252
+
recordSearchParams,
1253
+
)
1254
+
)
1092
1255
: undefined;
1093
1256
}catch(e: any){
1094
1257
logAndThrow(
@@ -1168,14 +1331,14 @@ class ProgramManager {
1168
1331
privateKey?: PrivateKey,
1169
1332
offlineQuery?: OfflineQuery,
1170
1333
): Promise<string>{
1171
-
// Get the private key from the account if it is not provided in the parameters
1172
-
letexecutionPrivateKey=privateKey;
1173
-
if(
1174
-
typeofprivateKey==="undefined"&&
1175
-
typeofthis.account!=="undefined"
1176
-
){
1177
-
executionPrivateKey=this.account.privateKey();
1178
-
}
1334
+
// Get the private key from the account if it is not provided in the parameters
1335
+
letexecutionPrivateKey=privateKey;
1336
+
if(
1337
+
typeofprivateKey==="undefined"&&
1338
+
typeofthis.account!=="undefined"
1339
+
){
1340
+
executionPrivateKey=this.account.privateKey();
1341
+
}
1179
1342
1180
1343
if(typeofexecutionPrivateKey==="undefined"){
1181
1344
throw"No private key provided and no private key set in the ProgramManager";
@@ -1368,13 +1531,13 @@ class ProgramManager {
1368
1531
}
1369
1532
feeRecord=privateFee
1370
1533
? <RecordPlaintext>(
1371
-
awaitthis.getCreditsRecord(
1372
-
priorityFee,
1373
-
nonces,
1374
-
feeRecord,
1375
-
recordSearchParams,
1376
-
)
1377
-
)
1534
+
awaitthis.getCreditsRecord(
1535
+
priorityFee,
1536
+
nonces,
1537
+
feeRecord,
1538
+
recordSearchParams,
1539
+
)
1540
+
)
1378
1541
: undefined;
1379
1542
}catch(e: any){
1380
1543
logAndThrow(
@@ -2376,8 +2539,8 @@ function validateTransferType(transferType: string): string {
2376
2539
returnVALID_TRANSFER_TYPES.has(transferType)
2377
2540
? transferType
2378
2541
: logAndThrow(
2379
-
`Invalid transfer type '${transferType}'. Valid transfer types are 'private', 'privateToPublic', 'public', and 'publicToPrivate'.`,
2380
-
);
2542
+
`Invalid transfer type '${transferType}'. Valid transfer types are 'private', 'privateToPublic', 'public', and 'publicToPrivate'.`,
0 commit comments