@@ -66,14 +66,20 @@ public function balanceOf(string $address)
66
66
* @param float $amount
67
67
* @return Transaction\Transaction
68
68
*/
69
- public function transfer (string $ from , string $ to , float $ amount )
69
+ public function transfer (string $ from , string $ to , float $ amount, string $ gasLimit = ' default ' , string $ gasPrice = ' default ' )
70
70
{
71
- $ amount = Number::scaleUp ($ amount , $ this ->decimals ());
72
- $ data = $ this ->buildTransferData ($ to , $ amount );
73
- $ nonce = Number::toHex ($ this ->getEth ()
74
- ->getTransactionCount ($ from , 'pending ' ));
75
- $ gasLimit = $ this ->getGasLimit ('transfer ' );
76
- $ gasPrice = $ this ->getSafeGasPrice ();
71
+ $ amount = Number::scaleUp ($ amount , $ this ->decimals ());
72
+ $ data = $ this ->buildTransferData ($ to , $ amount );
73
+ $ nonce = Number::toHex ($ this ->getEth ()
74
+ ->getTransactionCount ($ from , 'pending ' ));
75
+ if (strtolower ($ gasLimit ) === 'default ' )
76
+ {
77
+ $ gasLimit = $ this ->getGasLimit ('transfer ' );
78
+ }
79
+ if (strtolower ($ gasPrice ) === 'default ' )
80
+ {
81
+ $ gasPrice = $ this ->getSafeGasPrice ();
82
+ }
77
83
78
84
return (new TransactionBuilder ())
79
85
->setEth ($ this ->getEth ())
@@ -96,14 +102,20 @@ public function buildTransferData(string $to, $amount)
96
102
;
97
103
}
98
104
99
- public function approve (string $ ownerAddress , string $ spenderAddress , string $ amount )
105
+ public function approve (string $ ownerAddress , string $ spenderAddress , string $ amount, string $ gasLimit = ' default ' , string $ gasPrice = ' default ' )
100
106
{
101
- $ amount = Number::scaleUp ($ amount , $ this ->decimals ());
102
- $ data = $ this ->buildApproveData ($ spenderAddress , $ amount );
103
- $ nonce = Number::toHex ($ this ->getEth ()
104
- ->getTransactionCount ($ ownerAddress , 'pending ' ));
105
- $ gasLimit = $ this ->getGasLimit ('approve ' );
106
- $ gasPrice = $ this ->getSafeGasPrice ();
107
+ $ amount = Number::scaleUp ($ amount , $ this ->decimals ());
108
+ $ data = $ this ->buildApproveData ($ spenderAddress , $ amount );
109
+ $ nonce = Number::toHex ($ this ->getEth ()
110
+ ->getTransactionCount ($ ownerAddress , 'pending ' ));
111
+ if (strtolower ($ gasLimit ) === 'default ' )
112
+ {
113
+ $ gasLimit = $ this ->getGasLimit ('approve ' );
114
+ }
115
+ if (strtolower ($ gasPrice ) === 'default ' )
116
+ {
117
+ $ gasPrice = $ this ->getSafeGasPrice ();
118
+ }
107
119
108
120
return (new TransactionBuilder ())
109
121
->setEth ($ this ->getEth ())
@@ -137,14 +149,20 @@ public function allowance(string $ownerAddress, string $spenderAddress)
137
149
* @param float $amount
138
150
* @return Transaction\Transaction
139
151
*/
140
- public function transferFrom (string $ spender , string $ from , string $ to , float $ amount )
141
- {
142
- $ amount = Number::scaleUp ($ amount , $ this ->decimals ());
143
- $ data = $ this ->buildTransferFromData ($ from , $ to , $ amount );
144
- $ nonce = Number::toHex ($ this ->getEth ()
145
- ->getTransactionCount ($ spender , 'pending ' ));
146
- $ gasLimit = $ this ->getGasLimit ('transferFrom ' );
147
- $ gasPrice = $ this ->getSafeGasPrice ();
152
+ public function transferFrom (string $ spender , string $ from , string $ to , float $ amount , string $ gasLimit = 'default ' , string $ gasPrice = 'default ' )
153
+ {
154
+ $ amount = Number::scaleUp ($ amount , $ this ->decimals ());
155
+ $ data = $ this ->buildTransferFromData ($ from , $ to , $ amount );
156
+ $ nonce = Number::toHex ($ this ->getEth ()
157
+ ->getTransactionCount ($ spender , 'pending ' ));
158
+ if (strtolower ($ gasLimit ) === 'default ' )
159
+ {
160
+ $ gasLimit = $ this ->getGasLimit ('transferFrom ' );
161
+ }
162
+ if (strtolower ($ gasPrice ) === 'default ' )
163
+ {
164
+ $ gasPrice = $ this ->getSafeGasPrice ();
165
+ }
148
166
149
167
return (new TransactionBuilder ())
150
168
->setEth ($ this ->getEth ())
0 commit comments