File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @ckb-ccc/core " : minor
3
+ ---
4
+
5
+ feat(core): Transaction.getFee
Original file line number Diff line number Diff line change @@ -1643,13 +1643,13 @@ export class Transaction extends mol.Entity.Base<
1643
1643
return this . completeInputsAddOne ( from , filter ) ;
1644
1644
}
1645
1645
1646
- async fee ( client : Client ) : Promise < Num > {
1646
+ async getFee ( client : Client ) : Promise < Num > {
1647
1647
return ( await this . getInputsCapacity ( client ) ) - this . getOutputsCapacity ( ) ;
1648
1648
}
1649
1649
1650
- async feeRate ( client : Client ) : Promise < Num > {
1650
+ async getFeeRate ( client : Client ) : Promise < Num > {
1651
1651
return (
1652
- ( ( await this . fee ( client ) ) * numFrom ( 1000 ) ) /
1652
+ ( ( await this . getFee ( client ) ) * numFrom ( 1000 ) ) /
1653
1653
numFrom ( this . toBytes ( ) . length + 4 )
1654
1654
) ;
1655
1655
}
@@ -1700,7 +1700,7 @@ export class Transaction extends mol.Entity.Base<
1700
1700
// The initial fee is calculated based on prepared transaction
1701
1701
leastFee = tx . estimateFee ( feeRate ) ;
1702
1702
}
1703
- const fee = await tx . fee ( from . client ) ;
1703
+ const fee = await tx . getFee ( from . client ) ;
1704
1704
// The extra capacity paid the fee without a change
1705
1705
if ( fee === leastFee ) {
1706
1706
this . copy ( tx ) ;
@@ -1714,7 +1714,7 @@ export class Transaction extends mol.Entity.Base<
1714
1714
continue ;
1715
1715
}
1716
1716
1717
- if ( ( await tx . fee ( from . client ) ) !== leastFee ) {
1717
+ if ( ( await tx . getFee ( from . client ) ) !== leastFee ) {
1718
1718
throw new Error (
1719
1719
"The change function doesn't use all available capacity" ,
1720
1720
) ;
Original file line number Diff line number Diff line change @@ -596,9 +596,9 @@ export abstract class Client {
596
596
const tx = Transaction . from ( transaction ) ;
597
597
598
598
const maxFeeRate = numFrom ( options ?. maxFeeRate ?? DEFAULT_MAX_FEE_RATE ) ;
599
- const fee = await tx . feeRate ( this ) ;
600
- if ( maxFeeRate > Zero && fee > maxFeeRate ) {
601
- throw new ErrorClientMaxFeeRateExceeded ( maxFeeRate , fee ) ;
599
+ const feeRate = await tx . getFeeRate ( this ) ;
600
+ if ( maxFeeRate > Zero && feeRate > maxFeeRate ) {
601
+ throw new ErrorClientMaxFeeRateExceeded ( maxFeeRate , feeRate ) ;
602
602
}
603
603
604
604
const txHash = await this . sendTransactionNoCache ( tx , validator ) ;
You can’t perform that action at this time.
0 commit comments