@@ -12,31 +12,11 @@ export type BaseControllerInput = {
1212} ;
1313
1414export class BaseController {
15- private gasLimitEstimator ?: IGasLimitEstimator ;
15+ readonly gasLimitEstimator ?: IGasLimitEstimator ;
1616 constructor ( options ?: { gasLimitEstimator ?: IGasLimitEstimator } ) {
1717 this . gasLimitEstimator = options ?. gasLimitEstimator ;
1818 }
1919
20- protected async setTransactionGasOptions (
21- transaction : Transaction ,
22- options : { gasLimit ?: bigint ; gasPrice ?: bigint } ,
23- ) {
24- if ( options . gasPrice ) {
25- transaction . gasPrice = options . gasPrice ;
26- }
27-
28- if ( options . gasLimit ) {
29- transaction . gasLimit = options . gasLimit ;
30- return ;
31- } else {
32- this . addExtraGasLimitIfRequired ( transaction ) ;
33- }
34-
35- if ( this . gasLimitEstimator ) {
36- transaction . gasLimit = await this . gasLimitEstimator . estimateGasLimit ( { transaction } ) ;
37- }
38- }
39-
4020 protected addExtraGasLimitIfRequired ( transaction : Transaction ) : void {
4121 if ( transaction . guardian && ! transaction . guardian . isEmpty ( ) ) {
4222 transaction . gasLimit += BigInt ( EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS ) ;
@@ -47,13 +27,6 @@ export class BaseController {
4727 }
4828 }
4929
50- protected setVersionAndOptionsForGuardian ( transaction : Transaction ) : void {
51- if ( transaction . guardian && ! transaction . guardian . isEmpty ( ) ) {
52- const txComputer = new TransactionComputer ( ) ;
53- txComputer . applyGuardian ( transaction , transaction . guardian ) ;
54- }
55- }
56-
5730 protected async setupAndSignTransaction (
5831 transaction : Transaction ,
5932 options : BaseControllerInput ,
@@ -67,4 +40,31 @@ export class BaseController {
6740 await this . setTransactionGasOptions ( transaction , options ) ;
6841 transaction . signature = await sender . signTransaction ( transaction ) ;
6942 }
43+
44+ protected setVersionAndOptionsForGuardian ( transaction : Transaction ) : void {
45+ if ( transaction . guardian && ! transaction . guardian . isEmpty ( ) ) {
46+ const txComputer = new TransactionComputer ( ) ;
47+ txComputer . applyGuardian ( transaction , transaction . guardian ) ;
48+ }
49+ }
50+
51+ protected async setTransactionGasOptions (
52+ transaction : Transaction ,
53+ options : { gasLimit ?: bigint ; gasPrice ?: bigint } ,
54+ ) {
55+ if ( options . gasPrice ) {
56+ transaction . gasPrice = options . gasPrice ;
57+ }
58+
59+ if ( options . gasLimit ) {
60+ transaction . gasLimit = options . gasLimit ;
61+ return ;
62+ }
63+
64+ this . addExtraGasLimitIfRequired ( transaction ) ;
65+
66+ if ( this . gasLimitEstimator ) {
67+ transaction . gasLimit = await this . gasLimitEstimator . estimateGasLimit ( { transaction } ) ;
68+ }
69+ }
7070}
0 commit comments