Skip to content

Commit 803c7f6

Browse files
author
Julien
committed
Add gasPrice and gasLimit to the approve() function
1 parent fa3aa2e commit 803c7f6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/infura/proxy.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default class Proxy {
8383
)
8484

8585
// Tx2: approve proxy contract transfers of DAI Token
86-
await this.daiToken.methods.approve(proxyAddr, '-1').send({ from: user })
86+
await this.daiToken.methods.approve(proxyAddr, '-1').send({ from: user, gas: gasLimit })
8787

8888
return proxy
8989
}
@@ -156,10 +156,17 @@ export default class Proxy {
156156
* Ask the user to approve his DAI for this proxy
157157
* @param {address} proxyAddr Address of the proxy
158158
* @param {address} user User of the system - a CFD party
159+
* @param {Number} gasLimit How much gas we are willing to spent
160+
* @param {Number} gasPrice Price of the gas
161+
(if undefined, will use the default value from config file)
159162
* @return {Number} Allowed amount by the user for this proxy
160163
*/
161-
approve(proxyAddr, user) {
162-
return this.daiToken.methods.approve(proxyAddr, '-1').send({ from: user })
164+
approve(proxyAddr, user, gasLimit = 100000, gasPrice = undefined) {
165+
return this.daiToken.methods.approve(proxyAddr, '-1').send({
166+
from: user,
167+
gas: gasLimit,
168+
gasPrice: gasPrice || this.config.gasPrice,
169+
})
163170
}
164171

165172
/**

0 commit comments

Comments
 (0)