@@ -66,14 +66,20 @@ public function balanceOf(string $address)
6666 * @param float $amount
6767 * @return Transaction\Transaction
6868 */
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 ' )
7070 {
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+ }
7783
7884 return (new TransactionBuilder ())
7985 ->setEth ($ this ->getEth ())
@@ -96,14 +102,20 @@ public function buildTransferData(string $to, $amount)
96102 ;
97103 }
98104
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 ' )
100106 {
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+ }
107119
108120 return (new TransactionBuilder ())
109121 ->setEth ($ this ->getEth ())
@@ -137,14 +149,20 @@ public function allowance(string $ownerAddress, string $spenderAddress)
137149 * @param float $amount
138150 * @return Transaction\Transaction
139151 */
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+ }
148166
149167 return (new TransactionBuilder ())
150168 ->setEth ($ this ->getEth ())
0 commit comments