@@ -12,6 +12,7 @@ import {
12
12
} from "./function-key-provider" ;
13
13
14
14
import {
15
+ Address ,
15
16
ExecutionResponse ,
16
17
Execution as FunctionExecution ,
17
18
OfflineQuery ,
@@ -326,20 +327,20 @@ class ProgramManager {
326
327
let feeAddress ;
327
328
328
329
if ( typeof privateKey !== "undefined" ) {
329
- feeAddress = privateKey . address ( ) ;
330
+ feeAddress = Address . fromPrivateKey ( privateKey ) ;
330
331
} else {
331
332
feeAddress = this . account ?. address ( ) ;
332
333
}
333
334
334
- // Check to make sure the public balance is sufficient to cover the execution fee.
335
- if (
336
- tx . feeAmount ( ) >
337
- ( await this . networkClient ?. getProgramMappingValue (
335
+ const account_balance =
336
+ await this . networkClient ?. getProgramMappingValue (
338
337
"credits.aleo" ,
339
338
"account" ,
340
339
feeAddress ,
341
- ) )
342
- ) {
340
+ ) ;
341
+
342
+ // Check to make sure the public balance is sufficient to cover the execution fee.
343
+ if ( tx . feeAmount ( ) > account_balance ) {
343
344
throw "Public balance is insufficient to execute the transacation." ;
344
345
}
345
346
@@ -546,6 +547,19 @@ class ProgramManager {
546
547
async execute ( options : ExecuteOptions ) : Promise < string > {
547
548
const tx = < Transaction > await this . buildExecutionTransaction ( options ) ;
548
549
550
+ let feeAddress = this . account ?. address ( ) ;
551
+ const account_balance =
552
+ await this . networkClient ?. getProgramMappingValue (
553
+ "credits.aleo" ,
554
+ "account" ,
555
+ feeAddress ,
556
+ ) ;
557
+
558
+ // Check to make sure the public balance is sufficient to cover the execution fee.
559
+ if ( tx . feeAmount ( ) > account_balance ) {
560
+ throw "Public balance is insufficient to execute the transacation." ;
561
+ }
562
+
549
563
// Check to make sure the public balance is sufficient to cover the execution fee.
550
564
if (
551
565
tx . feeAmount ( ) >
@@ -775,20 +789,20 @@ class ProgramManager {
775
789
let feeAddress ;
776
790
777
791
if ( typeof privateKey !== "undefined" ) {
778
- feeAddress = privateKey . address ( ) ;
792
+ feeAddress = Address . fromPrivateKey ( privateKey ) ;
779
793
} else {
780
794
feeAddress = this . account ?. address ( ) ;
781
795
}
782
796
783
- // Check to make sure the public balance is sufficient to cover the execution fee.
784
- if (
785
- tx . feeAmount ( ) >
786
- ( await this . networkClient ?. getProgramMappingValue (
797
+ const account_balance =
798
+ await this . networkClient ?. getProgramMappingValue (
787
799
"credits.aleo" ,
788
800
"account" ,
789
801
feeAddress ,
790
- ) )
791
- ) {
802
+ ) ;
803
+
804
+ // Check to make sure the public balance is sufficient to cover the execution fee.
805
+ if ( tx . feeAmount ( ) > account_balance ) {
792
806
throw "Public balance is insufficient to execute the transacation." ;
793
807
}
794
808
@@ -880,20 +894,20 @@ class ProgramManager {
880
894
let feeAddress ;
881
895
882
896
if ( typeof privateKey !== "undefined" ) {
883
- feeAddress = privateKey . address ( ) ;
897
+ feeAddress = Address . fromPrivateKey ( privateKey ) ;
884
898
} else {
885
899
feeAddress = this . account ?. address ( ) ;
886
900
}
887
901
888
- // Check to make sure the public balance is sufficient to cover the execution fee.
889
- if (
890
- tx . feeAmount ( ) >
891
- ( await this . networkClient ?. getProgramMappingValue (
902
+ const account_balance =
903
+ await this . networkClient ?. getProgramMappingValue (
892
904
"credits.aleo" ,
893
905
"account" ,
894
906
feeAddress ,
895
- ) )
896
- ) {
907
+ ) ;
908
+
909
+ // Check to make sure the public balance is sufficient to cover the execution fee.
910
+ if ( tx . feeAmount ( ) > account_balance ) {
897
911
throw "Public balance is insufficient to execute the transacation." ;
898
912
}
899
913
@@ -1259,20 +1273,20 @@ class ProgramManager {
1259
1273
let feeAddress ;
1260
1274
1261
1275
if ( typeof privateKey !== "undefined" ) {
1262
- feeAddress = privateKey . address ( ) ;
1276
+ feeAddress = Address . fromPrivateKey ( privateKey ) ;
1263
1277
} else {
1264
1278
feeAddress = this . account ?. address ( ) ;
1265
1279
}
1266
1280
1267
- // Check to make sure the public balance is sufficient to cover the execution fee.
1268
- if (
1269
- tx . feeAmount ( ) >
1270
- ( await this . networkClient ?. getProgramMappingValue (
1281
+ const account_balance =
1282
+ await this . networkClient ?. getProgramMappingValue (
1271
1283
"credits.aleo" ,
1272
1284
"account" ,
1273
1285
feeAddress ,
1274
- ) )
1275
- ) {
1286
+ ) ;
1287
+
1288
+ // Check to make sure the public balance is sufficient to cover the execution fee.
1289
+ if ( tx . feeAmount ( ) > account_balance ) {
1276
1290
throw "Public balance is insufficient to execute the transacation." ;
1277
1291
}
1278
1292
@@ -1396,15 +1410,16 @@ class ProgramManager {
1396
1410
)
1397
1411
) ;
1398
1412
1399
- // Check to make sure the public balance is sufficient to cover the execution fee.
1400
- if (
1401
- tx . feeAmount ( ) >
1402
- this . networkClient ?. getProgramMappingValue (
1413
+ let feeAddress = this . account ?. address ( ) ;
1414
+ const account_balance =
1415
+ await this . networkClient ?. getProgramMappingValue (
1403
1416
"credits.aleo" ,
1404
1417
"account" ,
1405
- this . account ?. address ( ) ,
1406
- )
1407
- ) {
1418
+ feeAddress ,
1419
+ ) ;
1420
+
1421
+ // Check to make sure the public balance is sufficient to cover the execution fee.
1422
+ if ( tx . feeAmount ( ) > account_balance ) {
1408
1423
throw "Public balance is insufficient to execute the transacation." ;
1409
1424
}
1410
1425
@@ -1537,15 +1552,16 @@ class ProgramManager {
1537
1552
)
1538
1553
) ;
1539
1554
1540
- // Check to make sure the public balance is sufficient to cover the execution fee.
1541
- if (
1542
- tx . feeAmount ( ) >
1543
- this . networkClient ?. getProgramMappingValue (
1555
+ let feeAddress = this . account ?. address ( ) ;
1556
+ const account_balance =
1557
+ await this . networkClient ?. getProgramMappingValue (
1544
1558
"credits.aleo" ,
1545
1559
"account" ,
1546
- this . account ?. address ( ) ,
1547
- )
1548
- ) {
1560
+ feeAddress ,
1561
+ ) ;
1562
+
1563
+ // Check to make sure the public balance is sufficient to cover the execution fee.
1564
+ if ( tx . feeAmount ( ) > account_balance ) {
1549
1565
throw "Public balance is insufficient to execute the transacation." ;
1550
1566
}
1551
1567
@@ -1663,15 +1679,16 @@ class ProgramManager {
1663
1679
)
1664
1680
) ;
1665
1681
1666
- // Check to make sure the public balance is sufficient to cover the execution fee.
1667
- if (
1668
- tx . feeAmount ( ) >
1669
- this . networkClient ?. getProgramMappingValue (
1682
+ let feeAddress = this . account ?. address ( ) ;
1683
+ const account_balance =
1684
+ await this . networkClient ?. getProgramMappingValue (
1670
1685
"credits.aleo" ,
1671
1686
"account" ,
1672
- this . account ?. address ( ) ,
1673
- )
1674
- ) {
1687
+ feeAddress ,
1688
+ ) ;
1689
+
1690
+ // Check to make sure the public balance is sufficient to cover the execution fee.
1691
+ if ( tx . feeAmount ( ) > account_balance ) {
1675
1692
throw "Public balance is insufficient to execute the transacation." ;
1676
1693
}
1677
1694
@@ -1780,15 +1797,16 @@ class ProgramManager {
1780
1797
)
1781
1798
) ;
1782
1799
1783
- // Check to make sure the public balance is sufficient to cover the execution fee.
1784
- if (
1785
- tx . feeAmount ( ) >
1786
- this . networkClient ?. getProgramMappingValue (
1800
+ let feeAddress = this . account ?. address ( ) ;
1801
+ const account_balance =
1802
+ await this . networkClient ?. getProgramMappingValue (
1787
1803
"credits.aleo" ,
1788
1804
"account" ,
1789
- this . account ?. address ( ) ,
1790
- )
1791
- ) {
1805
+ feeAddress ,
1806
+ ) ;
1807
+
1808
+ // Check to make sure the public balance is sufficient to cover the execution fee.
1809
+ if ( tx . feeAmount ( ) > account_balance ) {
1792
1810
throw "Public balance is insufficient to execute the transacation." ;
1793
1811
}
1794
1812
@@ -1910,15 +1928,16 @@ class ProgramManager {
1910
1928
)
1911
1929
) ;
1912
1930
1913
- // Check to make sure the public balance is sufficient to cover the execution fee.
1914
- if (
1915
- tx . feeAmount ( ) >
1916
- ( await this . networkClient ?. getProgramMappingValue (
1931
+ let feeAddress = this . account ?. address ( ) ;
1932
+ const account_balance =
1933
+ await this . networkClient ?. getProgramMappingValue (
1917
1934
"credits.aleo" ,
1918
1935
"account" ,
1919
- this . account ?. address ( ) ,
1920
- ) )
1921
- ) {
1936
+ feeAddress ,
1937
+ ) ;
1938
+
1939
+ // Check to make sure the public balance is sufficient to cover the execution fee.
1940
+ if ( tx . feeAmount ( ) > account_balance ) {
1922
1941
throw "Public balance is insufficient to execute the transacation." ;
1923
1942
}
1924
1943
0 commit comments