Fix: remove callbacks from web3 options
MODIFY
src/common/SDKClient.ts
src/common/SDKClient.ts
-import BN from 'bn.js'
import Network from '@maticnetwork/meta/network'
-
+import BN from 'bn.js'
+import ContractsBase from '../common/ContractsBase'
import Web3Client from '../common/Web3Client'
import { address, SendOptions } from '../types/Common'
-import ContractsBase from '../common/ContractsBase'
export default class SDKClient extends ContractsBase {
static initializeNetwork(network = 'testnet', version = 'mumbai') {
@@ -65,11 +64,11 @@ export default class SDKClient extends ContractsBase {
}
const txObject = this.getERC20TokenContract(token, options.parent).methods.transfer(to, this.encode(amount))
const onRootChain = options.parent ? true : false
- const _options = await this.web3Client.fillOptions(txObject, onRootChain, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, onRootChain, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async transferERC721Tokens(token: address, to: address, tokenId: string, options?: SendOptions) {
@@ -79,11 +78,11 @@ export default class SDKClient extends ContractsBase {
const txObject = this.getERC721TokenContract(token, options.parent).methods.transferFrom(options.from, to, tokenId)
const onRootChain = options.parent ? true : false
- const _options = await this.web3Client.fillOptions(txObject, onRootChain, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, onRootChain, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async transferMaticEth(to: address, amount: BN | string, options?: SendOptions) {
@@ -93,10 +92,10 @@ export default class SDKClient extends ContractsBase {
const token = ContractsBase.MATIC_CHILD_TOKEN
const txObject = this.getChildMaticContract().methods.transfer(to, this.encode(amount))
options.value = this.encode(amount)
- const _options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
}

MODIFY
src/common/Web3Client.ts
src/common/Web3Client.ts
@@ -61,36 +61,35 @@ export default class Web3Client {
to: _options.to || null,
data: _options.data,
encodeAbi: _options.encodeAbi || false,
- onTransactionHash: _options.onTransactionHash || null,
- onReceipt: _options.onReceipt || null,
- onError: _options.onError || null,
}
}
- wrapWeb3Promise(promise, options) {
+ wrapWeb3Promise(promise, callbacks) {
const _emptyFunc = () => {}
return promise
- .on('transactionHash', options.onTransactionHash || _emptyFunc)
- .on('receipt', options.onReceipt || _emptyFunc)
- .on('error', options.onError || _emptyFunc)
+ .on('transactionHash', callbacks.onTransactionHash || _emptyFunc)
+ .on('receipt', callbacks.onReceipt || _emptyFunc)
+ .on('confirmation', callbacks.onConfirmation || _emptyFunc)
+ .on('error', callbacks.onError || _emptyFunc)
}
- async send(txObject, options?) {
- const _options = options || {}
+ send(txObject, web3Options?, callbacks?) {
+ const _web3Options = web3Options || {}
// since we use the delegated proxy patterns, the following should be a good way to provide enough gas
// apparently even when provided with a buffer of 20k, the call reverts. This shouldn't be happening because the actual gas used is less than what the estimation returns
// providing higher buffer for now
// @todo handle hex values of gas
- if (options.parent) {
- _options.gas = (_options.gas || this.parentDefaultOptions.gas) + 1000000
- _options.gasPrice = _options.gasPrice || this.parentDefaultOptions.gasPrice
+
+ if (web3Options.parent) {
+ _web3Options.gas = (_web3Options.gas || this.parentDefaultOptions.gas) + 1000000
+ _web3Options.gasPrice = _web3Options.gasPrice || this.parentDefaultOptions.gasPrice
} else {
- _options.gas = _options.gas || this.maticDefaultOptions.gas
- _options.gasPrice = _options.gasPrice || this.maticDefaultOptions.gasPrice
+ _web3Options.gas = _web3Options.gas || this.maticDefaultOptions.gas
+ _web3Options.gasPrice = _web3Options.gasPrice || this.maticDefaultOptions.gasPrice
}
- logger.debug('sending tx with', { _options })
- return this.wrapWeb3Promise(txObject.send(_options), _options)
+ logger.debug('sending tx with', { _web3Options })
+ return this.wrapWeb3Promise(txObject.send(_web3Options), callbacks)
}
getParentWeb3() {

MODIFY
src/index.ts
src/index.ts
@@ -382,8 +382,8 @@ export default class Matic extends SDKClient {
sellOrder.expiry,
to
)
- const _options = await this.web3Client.fillOptions(txObj, false /* onRootChain */, options)
- return this.web3Client.send(txObj, _options)
+ const web3Options = await this.web3Client.fillOptions(txObj, false /* onRootChain */, options)
+ return this.web3Client.send(txObj, web3Options, options)
}
depositERC20ForUser(token: address, user: address, amount: BN | string, options?: SendOptions) {
@@ -402,11 +402,11 @@ export default class Matic extends SDKClient {
this.depositManager.getAddress(),
tokenId
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
startWithdraw(token: address, amount: BN | string, options?: SendOptions) {

MODIFY
src/root/DepositManager.ts
src/root/DepositManager.ts
-import BN from 'bn.js'
import bluebird from 'bluebird'
+import BN from 'bn.js'
import Contract from 'web3/eth/contract'
-
import ContractsBase from '../common/ContractsBase'
-import { address, MaticClientInitializationOptions, SendOptions } from '../types/Common'
import Web3Client from '../common/Web3Client'
+import { address, MaticClientInitializationOptions, SendOptions } from '../types/Common'
import Registry from './Registry'
export default class DepositManager extends ContractsBase {
@@ -60,11 +59,11 @@ export default class DepositManager extends ContractsBase {
this.depositManagerContract.options.address,
this.encode(amount)
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async approveMaxERC20(token: address, options?: SendOptions) {
@@ -72,11 +71,11 @@ export default class DepositManager extends ContractsBase {
this.depositManagerContract.options.address,
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async allowanceOfERC20(userAddress: address, token: address, options?: SendOptions) {
@@ -92,11 +91,11 @@ export default class DepositManager extends ContractsBase {
async depositERC20(token: address, amount: BN | string, options?: SendOptions) {
const txObject = this.depositManagerContract.methods.depositERC20(token, this.encode(amount))
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.depositManagerContract.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.depositManagerContract.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
depositERC721(token: address, tokenId: string, options?: SendOptions) {
@@ -112,11 +111,11 @@ export default class DepositManager extends ContractsBase {
async depositERC20ForUser(token: address, amount: BN | string, user: address, options?: SendOptions) {
const txObject = this.depositManagerContract.methods.depositERC20ForUser(token, user, this.encode(amount))
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.depositManagerContract.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.depositManagerContract.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
depositERC721ForUser(token: address, tokenId: string, user: address, options?: SendOptions) {
@@ -125,15 +124,15 @@ export default class DepositManager extends ContractsBase {
async depositEther(amount: BN | string, options: SendOptions = {}) {
const txObject = this.depositManagerContract.methods.depositEther()
- const _options = await this.web3Client.fillOptions(
+ const web3Options = await this.web3Client.fillOptions(
txObject,
true /* onRootChain */,
Object.assign(options, { value: this.encode(amount) })
)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.depositManagerContract.options.address })
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.depositManagerContract.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
getAddress() {

MODIFY
src/root/POSRootChainManager.ts
src/root/POSRootChainManager.ts
import BN from 'bn.js'
-import Contract from 'web3/eth/contract'
import Web3 from 'web3'
-
+import Contract from 'web3/eth/contract'
import ContractsBase from '../common/ContractsBase'
-import { address, SendOptions, MaticClientInitializationOptions } from '../types/Common'
+import ExitManager from '../common/ExitManager'
import Web3Client from '../common/Web3Client'
+import { address, MaticClientInitializationOptions, SendOptions } from '../types/Common'
import RootChain from './RootChain'
-import ExitManager from '../common/ExitManager'
const ERC20_TRANSFER_EVENT_SIG = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
const ERC721_TRANSFER_EVENT_SIG = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
@@ -39,15 +38,15 @@ export default class POSRootChainManager extends ContractsBase {
async depositEtherForUser(amount: BN | string, user: address, options: SendOptions = {}) {
const txObject = this.posRootChainManager.methods.depositEtherFor(user)
- const _options = await this.web3Client.fillOptions(
+ const web3Options = await this.web3Client.fillOptions(
txObject,
true /* onRootChain */,
Object.assign(options, { value: this.formatUint256(amount) })
)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async depositFor(user: address, rootToken: address, depositData: string, options?: SendOptions) {
@@ -55,11 +54,11 @@ export default class POSRootChainManager extends ContractsBase {
throw new Error('posRootChainManager address not found. Set it while constructing MaticPOSClient.')
}
const txObject = this.posRootChainManager.methods.depositFor(user, rootToken, depositData)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async exit(burnTxHash: string, logSignature: string, options?: SendOptions) {
@@ -68,11 +67,11 @@ export default class POSRootChainManager extends ContractsBase {
}
const payload = await this.exitManager.buildPayloadForExit(burnTxHash, logSignature)
const txObject = this.posRootChainManager.methods.exit(payload)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async exitHermoine(burnTxHash: string, logSignature: string, options?: SendOptions) {
@@ -81,11 +80,11 @@ export default class POSRootChainManager extends ContractsBase {
}
const payload = await this.exitManager.buildPayloadForExitHermoine(burnTxHash, logSignature)
const txObject = this.posRootChainManager.methods.exit(payload)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.posRootChainManager.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async approveERC20(rootToken: address, amount: BN | string, options?: SendOptions) {
@@ -96,11 +95,11 @@ export default class POSRootChainManager extends ContractsBase {
this.erc20Predicate,
this.formatUint256(amount)
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: rootToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: rootToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async approveMaxERC20(rootToken: address, options?: SendOptions) {
@@ -111,11 +110,11 @@ export default class POSRootChainManager extends ContractsBase {
this.erc20Predicate,
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: rootToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: rootToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async allowanceOfERC20(userAddress: address, token: address, options?: SendOptions) {
@@ -137,11 +136,11 @@ export default class POSRootChainManager extends ContractsBase {
async burnERC20(childToken: address, amount: BN | string, options?: SendOptions) {
const childTokenContract = this.getPOSERC20TokenContract(childToken)
const txObject = childTokenContract.methods.withdraw(this.formatUint256(amount))
- const _options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: childToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: childToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async exitERC20(burnTxHash: string, options?: SendOptions) {
@@ -160,11 +159,11 @@ export default class POSRootChainManager extends ContractsBase {
this.erc721Predicate,
this.formatUint256(tokenId)
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: rootToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: rootToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async isApprovedERC721(token: address, tokenId: BN | string, options?: SendOptions) {
@@ -186,11 +185,11 @@ export default class POSRootChainManager extends ContractsBase {
this.erc721Predicate,
true
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: rootToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: rootToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async isApprovedForAllERC721(token: address, userAddress: address, options?: SendOptions) {
@@ -212,11 +211,11 @@ export default class POSRootChainManager extends ContractsBase {
async burnERC721(childToken: address, tokenId: BN | string, options?: SendOptions) {
const childTokenContract = this.getPOSERC721TokenContract(childToken)
const txObject = childTokenContract.methods.withdraw(this.formatUint256(tokenId))
- const _options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: childToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: childToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async exitERC721(burnTxHash: string, options?: SendOptions) {
@@ -235,11 +234,11 @@ export default class POSRootChainManager extends ContractsBase {
this.erc1155Predicate,
true
)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: rootToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: rootToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async depositSingleERC1155ForUser(
@@ -275,11 +274,11 @@ export default class POSRootChainManager extends ContractsBase {
async burnSingleERC1155(childToken: address, tokenId: BN | string, amount: BN | string, options?: SendOptions) {
const childTokenContract = this.getPOSERC1155TokenContract(childToken)
const txObject = childTokenContract.methods.withdrawSingle(this.formatUint256(tokenId), this.formatUint256(amount))
- const _options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: childToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: childToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async burnBatchERC1155(
@@ -293,11 +292,11 @@ export default class POSRootChainManager extends ContractsBase {
tokenIds.map(t => this.formatUint256(t)),
amounts.map(a => this.formatUint256(a))
)
- const _options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: childToken })
+ const web3Options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: childToken })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async exitSingleERC1155(burnTxHash: string, options?: SendOptions) {

MODIFY
src/root/WithdrawManager.ts
src/root/WithdrawManager.ts
+import BN from 'bn.js'
import ethUtils from 'ethereumjs-util'
import Contract from 'web3/eth/contract'
-
-import BN from 'bn.js'
+import ContractsBase from '../common/ContractsBase'
+import ExitManager from '../common/ExitManager'
+import Web3Client from '../common/Web3Client'
import Proofs from '../libs/ProofsUtil'
-
import { address, MaticClientInitializationOptions, SendOptions } from '../types/Common'
-import Web3Client from '../common/Web3Client'
-import ContractsBase from '../common/ContractsBase'
-import RootChain from './RootChain'
import Registry from './Registry'
-import ExitManager from '../common/ExitManager'
+import RootChain from './RootChain'
const logger = {
info: require('debug')('maticjs:WithdrawManager'),
@@ -64,20 +62,20 @@ export default class WithdrawManager extends ContractsBase {
} else {
txObject = this.getERC20TokenContract(token).methods.withdraw(this.encode(amount))
}
- const _options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async burnERC721Token(token: address, tokenId: BN | string, options?: SendOptions) {
const txObject = this.getERC721TokenContract(token).methods.withdraw(this.encode(tokenId))
- const _options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: token })
+ const web3Options = await this.web3Client.fillOptions(txObject, false /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: token })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async processExits(tokens: address | address[], options?: SendOptions) {
@@ -92,21 +90,21 @@ export default class WithdrawManager extends ContractsBase {
logger.info('processExits can be gas expensive, sending in 2000000 gas but even this might not be enough') // eslint-disable-line
options.gas = 2000000
}
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.withdrawManager.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.withdrawManager.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async startExitWithBurntERC20Tokens(burnTxHash, options?) {
const payload = await this.exitManager.buildPayloadForExit(burnTxHash, WithdrawManager.ERC20_WITHDRAW_EVENT_SIG)
const txObject = this.erc20Predicate.methods.startExitWithBurntTokens(payload)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.erc20Predicate.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.erc20Predicate.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async startExitWithBurntERC20TokensHermoine(burnTxHash, options?) {
@@ -115,21 +113,21 @@ export default class WithdrawManager extends ContractsBase {
WithdrawManager.ERC20_WITHDRAW_EVENT_SIG
)
const txObject = this.erc20Predicate.methods.startExitWithBurntTokens(payload)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.erc20Predicate.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.erc20Predicate.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async startExitWithBurntERC721Tokens(burnTxHash, options?) {
const payload = await this.exitManager.buildPayloadForExit(burnTxHash, WithdrawManager.ERC721_WITHDRAW_EVENT_SIG)
const txObject = this.erc721Predicate.methods.startExitWithBurntTokens(payload)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.erc721Predicate.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.erc721Predicate.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async startExitWithBurntERC721TokensHermoine(burnTxHash, options?) {
@@ -138,11 +136,11 @@ export default class WithdrawManager extends ContractsBase {
WithdrawManager.ERC721_WITHDRAW_EVENT_SIG
)
const txObject = this.erc721Predicate.methods.startExitWithBurntTokens(payload)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- if (_options.encodeAbi) {
- return Object.assign(_options, { data: txObject.encodeABI(), to: this.erc721Predicate.options.address })
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: this.erc721Predicate.options.address })
}
- return this.web3Client.send(txObject, _options)
+ return this.web3Client.send(txObject, web3Options, options)
}
async getExitTime(burnTxHash, confirmTxHash) {
@@ -170,8 +168,8 @@ export default class WithdrawManager extends ContractsBase {
predicate
)
const txObject = _predicate.methods.startExitForMintableBurntToken(payload, mint)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- return this.web3Client.send(txObject, _options)
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ return this.web3Client.send(txObject, web3Options, options)
}
/**
@@ -187,8 +185,8 @@ export default class WithdrawManager extends ContractsBase {
predicate
)
const txObject = _predicate.methods.startExitForMetadataMintableBurntToken(payload, mint)
- const _options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
- return this.web3Client.send(txObject, _options)
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ return this.web3Client.send(txObject, web3Options, options)
}
private async _buildPayloadAndFindMintTransaction(burnTxHash) {

Fix: remove callbacks from web3 options