@@ -710,13 +710,18 @@ class ProgramManager {
710
710
privateKey ?: PrivateKey ,
711
711
offlineQuery ?: OfflineQuery ,
712
712
) : Promise < string > {
713
- // Get the private key from the account if it is not provided in the parameters
713
+ // Get the private key from the account if it is not provided in the parameters and assign the fee address
714
714
let executionPrivateKey = privateKey ;
715
+ let feeAddress ;
715
716
if (
716
717
typeof privateKey === "undefined" &&
717
718
typeof this . account !== "undefined"
718
719
) {
719
720
executionPrivateKey = this . account . privateKey ( ) ;
721
+ feeAddress = this . account ?. address ( ) ;
722
+ }
723
+ else {
724
+ feeAddress = Address . from_private_key ( privateKey ) ;
720
725
}
721
726
722
727
if ( typeof executionPrivateKey === "undefined" ) {
@@ -788,18 +793,6 @@ class ProgramManager {
788
793
offlineQuery ,
789
794
) ;
790
795
791
- let feeAddress ;
792
-
793
- if ( typeof privateKey !== "undefined" ) {
794
- feeAddress = Address . from_private_key ( privateKey ) ;
795
- } else if ( this . account !== undefined ) {
796
- feeAddress = this . account ?. address ( ) ;
797
- } else {
798
- throw Error (
799
- "No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key." ,
800
- ) ;
801
- }
802
-
803
796
// Check if the account has sufficient credits to pay for the transaction
804
797
this . checkFee ( feeAddress . to_string ( ) , tx . feeAmount ( ) ) ;
805
798
@@ -841,14 +834,14 @@ class ProgramManager {
841
834
privateKey ?: PrivateKey ,
842
835
offlineQuery ?: OfflineQuery ,
843
836
) : Promise < string > {
844
- // Get the private key from the account if it is not provided in the parameters
845
- let executionPrivateKey = privateKey ;
846
- if (
847
- typeof executionPrivateKey === "undefined" &&
848
- typeof this . account !== "undefined"
849
- ) {
850
- executionPrivateKey = this . account . privateKey ( ) ;
851
- }
837
+ // Get the private key from the account if it is not provided in the parameters
838
+ let executionPrivateKey = privateKey ;
839
+ if (
840
+ typeof privateKey === "undefined" &&
841
+ typeof this . account !== "undefined"
842
+ ) {
843
+ executionPrivateKey = this . account . privateKey ( ) ;
844
+ }
852
845
853
846
if ( typeof executionPrivateKey === "undefined" ) {
854
847
throw "No private key provided and no private key set in the ProgramManager" ;
@@ -888,21 +881,6 @@ class ProgramManager {
888
881
offlineQuery ,
889
882
) ;
890
883
891
- let feeAddress ;
892
-
893
- if ( typeof privateKey !== "undefined" ) {
894
- feeAddress = Address . from_private_key ( privateKey ) ;
895
- } else if ( this . account !== undefined ) {
896
- feeAddress = this . account ?. address ( ) ;
897
- } else {
898
- throw Error (
899
- "No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key." ,
900
- ) ;
901
- }
902
-
903
- // Check if the account has sufficient credits to pay for the transaction
904
- this . checkFee ( feeAddress . to_string ( ) , tx . feeAmount ( ) ) ;
905
-
906
884
return await this . networkClient . submitTransaction ( tx ) ;
907
885
}
908
886
0 commit comments