arb-ethers-web3-bridge
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -496,9 +496,4 @@ /* | ||
} | ||
if (txRequest.gas) { | ||
txRequest.gasLimit = txRequest.gas | ||
delete(txRequest.gas) | ||
} | ||
signer.sendTransaction(txRequest).then( | ||
signer.sendTransaction(makeTransaction(txRequest)).then( | ||
function (tx) { | ||
@@ -505,0 +500,0 @@ respond(tx.hash) |
53
index.js
@@ -19,2 +19,53 @@ /* | ||
module.exports = ProviderBridge | ||
// wrapProvider was inspired by https://github.com/ethereum-optimism/optimism-monorepo/blob/master/packages/ovm-truffle-provider-wrapper/index.ts | ||
function wrapProvider(provider) { | ||
if (typeof provider !== 'object' || !provider['sendAsync']) { | ||
throw Error( | ||
'Invalid provider. Expected provider to conform to Truffle provider interface!' | ||
) | ||
} | ||
let chainId = 'not set'; | ||
provider.sendAsync({ | ||
jsonrpc: "2.0", | ||
method: "net_version", | ||
params: [], | ||
id: 0 | ||
}, (err, network) => { | ||
if (chainId == 'not set') { | ||
if (err) { | ||
throw Error("couldn't get chain id", err) | ||
} | ||
if (typeof(network.result) === 'string') { | ||
network.result = parseInt(network.result) | ||
} | ||
chainId = network.result | ||
} | ||
}) | ||
const sendAsync = provider.sendAsync | ||
const send = provider.send | ||
provider.sendAsync = function(...args) { | ||
if (args[0].method === 'eth_sendTransaction') { | ||
// To properly set chainID for all transactions. | ||
args[0].params[0].chainId = chainId | ||
} | ||
sendAsync.apply(this, args) | ||
} | ||
provider.send = function(...args) { | ||
if (args[0].method === 'eth_sendTransaction') { | ||
// To properly set chainID for all transactions. | ||
args[0].params[0].chainId = chainId | ||
} | ||
send.apply(this, args) | ||
} | ||
return provider | ||
} | ||
module.exports = { | ||
ProviderBridge, | ||
wrapProvider | ||
} |
{ | ||
"name": "arb-ethers-web3-bridge", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "Arbitrum bridge for converting ethers provider into web3", | ||
@@ -5,0 +5,0 @@ "author": "Offchain Labs, Inc.", |
35282
802