Skip to content

Commit

Permalink
catch estimates
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Dec 14, 2023
1 parent 854c49e commit 1ec6a60
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 84 deletions.
50 changes: 33 additions & 17 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,20 @@ const submitContractInteraction$3 = async ({ transaction, signer, provider })=>{
let contract = new ethers.Contract(transaction.to, transaction.api, provider);
let contractArguments = transaction.getContractArguments({ contract });
let method = contract.connect(signer)[transaction.getMethodNameWithSignature()];
let gas = await estimate(transaction);
gas = gas.add(gas.div(10));
let gas;
try {
gas = await estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e) {}
if(contractArguments) {
return method(...contractArguments, {
return await method(...contractArguments, {
value: Transaction.bigNumberify(transaction.value, transaction.blockchain),
gasLimit: gas ? gas.toHexString() : undefined
gasLimit: _optionalChain$j([gas, 'optionalAccess', _7 => _7.toHexString, 'call', _8 => _8()])
})
} else {
return method({
return await method({
value: Transaction.bigNumberify(transaction.value, transaction.blockchain),
gasLimit: gas ? gas.toHexString() : undefined
gasLimit: _optionalChain$j([gas, 'optionalAccess', _9 => _9.toHexString, 'call', _10 => _10()])
})
}
};
Expand Down Expand Up @@ -875,17 +878,20 @@ const submitContractInteraction$2 = async ({ transaction, wallet })=>{
} else {
gasPrice = gasPrice.toHexString();
}
let gas = await estimate(transaction);
let gas;
try {
gas = await estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e2) {}
const data = await transaction.getData();
const value = transaction.value ? ethers.utils.hexlify(ethers.BigNumber.from(transaction.value)) : undefined;
const nonce = ethers.utils.hexlify(transaction.nonce);
gas = gas.add(gas.div(10));
return wallet.connector.sendTransaction({
from: transaction.from,
to: transaction.to,
value,
data,
gas: gas.toHexString(),
gas: _optionalChain$5([gas, 'optionalAccess', _10 => _10.toHexString, 'call', _11 => _11()]),
gasPrice,
nonce,
})
Expand All @@ -894,20 +900,23 @@ const submitContractInteraction$2 = async ({ transaction, wallet })=>{
const submitSimpleTransfer$2 = async ({ transaction, wallet })=>{
const provider = await getProvider(transaction.blockchain);
let gasPrice = await provider.getGasPrice();
if(_optionalChain$5([wallet, 'access', _10 => _10.session, 'optionalAccess', _11 => _11.peerMeta, 'optionalAccess', _12 => _12.name]) === 'Uniswap Wallet') {
if(_optionalChain$5([wallet, 'access', _12 => _12.session, 'optionalAccess', _13 => _13.peerMeta, 'optionalAccess', _14 => _14.name]) === 'Uniswap Wallet') {
gasPrice = undefined;
} else {
gasPrice = gasPrice.toHexString();
}
const gas = await estimate(transaction);
try {
gas = await estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e3) {}
const value = ethers.utils.hexlify(ethers.BigNumber.from(transaction.value));
const nonce = ethers.utils.hexlify(transaction.nonce);
return wallet.connector.sendTransaction({
from: transaction.from,
to: transaction.to,
value,
data: '0x',
gas: gas.toHexString(),
gas: _optionalChain$5([gas, 'optionalAccess', _15 => _15.toHexString, 'call', _16 => _16()]),
gasPrice,
nonce,
})
Expand Down Expand Up @@ -1326,8 +1335,11 @@ const submit$1 = ({ transaction, wallet }) => {
const submitContractInteraction$1 = async ({ transaction, wallet })=>{
const provider = await getProvider(transaction.blockchain);
const blockchain = Blockchains[transaction.blockchain];
let gas = await estimate(transaction);
gas = gas.add(gas.div(10));
let gas;
try {
gas = await estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e2) {}
const gasPrice = await provider.getGasPrice();
return wallet.signClient.request({
topic: wallet.session.topic,
Expand All @@ -1339,7 +1351,7 @@ const submitContractInteraction$1 = async ({ transaction, wallet })=>{
to: transaction.to,
value: transaction.value ? ethers.BigNumber.from(transaction.value.toString()).toHexString() : undefined,
data: await transaction.getData(),
gas: gas.toHexString(),
gas: _optionalChain$3([gas, 'optionalAccess', _10 => _10.toHexString, 'call', _11 => _11()]),
gasPrice: gasPrice.toHexString(),
nonce: transaction.nonce,
}]
Expand All @@ -1350,7 +1362,11 @@ const submitContractInteraction$1 = async ({ transaction, wallet })=>{
const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
const provider = await getProvider(transaction.blockchain);
let blockchain = Blockchains[transaction.blockchain];
const gas = await estimate(transaction);
let gas;
try {
gas = await estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e3) {}
const gasPrice = await provider.getGasPrice();
return wallet.signClient.request({
topic: wallet.session.topic,
Expand All @@ -1361,7 +1377,7 @@ const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
from: transaction.from,
to: transaction.to,
value: transaction.value ? ethers.BigNumber.from(transaction.value.toString()).toHexString() : undefined,
gas: gas.toHexString(),
gas: _optionalChain$3([gas, 'optionalAccess', _12 => _12.toHexString, 'call', _13 => _13()]),
gasPrice: gasPrice.toHexString(),
nonce: transaction.nonce
}]
Expand Down
50 changes: 33 additions & 17 deletions dist/esm/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 33 additions & 17 deletions dist/umd/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,20 @@
let contract = new ethers.ethers.Contract(transaction.to, transaction.api, provider);
let contractArguments = transaction.getContractArguments({ contract });
let method = contract.connect(signer)[transaction.getMethodNameWithSignature()];
let gas = await web3ClientEvm.estimate(transaction);
gas = gas.add(gas.div(10));
let gas;
try {
gas = await web3ClientEvm.estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e) {}
if(contractArguments) {
return method(...contractArguments, {
return await method(...contractArguments, {
value: Transaction.bigNumberify(transaction.value, transaction.blockchain),
gasLimit: gas ? gas.toHexString() : undefined
gasLimit: _optionalChain$j([gas, 'optionalAccess', _7 => _7.toHexString, 'call', _8 => _8()])
})
} else {
return method({
return await method({
value: Transaction.bigNumberify(transaction.value, transaction.blockchain),
gasLimit: gas ? gas.toHexString() : undefined
gasLimit: _optionalChain$j([gas, 'optionalAccess', _9 => _9.toHexString, 'call', _10 => _10()])
})
}
};
Expand Down Expand Up @@ -878,17 +881,20 @@
} else {
gasPrice = gasPrice.toHexString();
}
let gas = await web3ClientEvm.estimate(transaction);
let gas;
try {
gas = await web3ClientEvm.estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e2) {}
const data = await transaction.getData();
const value = transaction.value ? ethers.ethers.utils.hexlify(ethers.ethers.BigNumber.from(transaction.value)) : undefined;
const nonce = ethers.ethers.utils.hexlify(transaction.nonce);
gas = gas.add(gas.div(10));
return wallet.connector.sendTransaction({
from: transaction.from,
to: transaction.to,
value,
data,
gas: gas.toHexString(),
gas: _optionalChain$5([gas, 'optionalAccess', _10 => _10.toHexString, 'call', _11 => _11()]),
gasPrice,
nonce,
})
Expand All @@ -897,20 +903,23 @@
const submitSimpleTransfer$2 = async ({ transaction, wallet })=>{
const provider = await web3ClientEvm.getProvider(transaction.blockchain);
let gasPrice = await provider.getGasPrice();
if(_optionalChain$5([wallet, 'access', _10 => _10.session, 'optionalAccess', _11 => _11.peerMeta, 'optionalAccess', _12 => _12.name]) === 'Uniswap Wallet') {
if(_optionalChain$5([wallet, 'access', _12 => _12.session, 'optionalAccess', _13 => _13.peerMeta, 'optionalAccess', _14 => _14.name]) === 'Uniswap Wallet') {
gasPrice = undefined;
} else {
gasPrice = gasPrice.toHexString();
}
const gas = await web3ClientEvm.estimate(transaction);
try {
gas = await web3ClientEvm.estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e3) {}
const value = ethers.ethers.utils.hexlify(ethers.ethers.BigNumber.from(transaction.value));
const nonce = ethers.ethers.utils.hexlify(transaction.nonce);
return wallet.connector.sendTransaction({
from: transaction.from,
to: transaction.to,
value,
data: '0x',
gas: gas.toHexString(),
gas: _optionalChain$5([gas, 'optionalAccess', _15 => _15.toHexString, 'call', _16 => _16()]),
gasPrice,
nonce,
})
Expand Down Expand Up @@ -1329,8 +1338,11 @@
const submitContractInteraction$1 = async ({ transaction, wallet })=>{
const provider = await web3ClientEvm.getProvider(transaction.blockchain);
const blockchain = Blockchains__default['default'][transaction.blockchain];
let gas = await web3ClientEvm.estimate(transaction);
gas = gas.add(gas.div(10));
let gas;
try {
gas = await web3ClientEvm.estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e2) {}
const gasPrice = await provider.getGasPrice();
return wallet.signClient.request({
topic: wallet.session.topic,
Expand All @@ -1342,7 +1354,7 @@
to: transaction.to,
value: transaction.value ? ethers.ethers.BigNumber.from(transaction.value.toString()).toHexString() : undefined,
data: await transaction.getData(),
gas: gas.toHexString(),
gas: _optionalChain$3([gas, 'optionalAccess', _10 => _10.toHexString, 'call', _11 => _11()]),
gasPrice: gasPrice.toHexString(),
nonce: transaction.nonce,
}]
Expand All @@ -1353,7 +1365,11 @@
const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
const provider = await web3ClientEvm.getProvider(transaction.blockchain);
let blockchain = Blockchains__default['default'][transaction.blockchain];
const gas = await web3ClientEvm.estimate(transaction);
let gas;
try {
gas = await web3ClientEvm.estimate(transaction);
gas = gas.add(gas.div(10));
} catch (e3) {}
const gasPrice = await provider.getGasPrice();
return wallet.signClient.request({
topic: wallet.session.topic,
Expand All @@ -1364,7 +1380,7 @@
from: transaction.from,
to: transaction.to,
value: transaction.value ? ethers.ethers.BigNumber.from(transaction.value.toString()).toHexString() : undefined,
gas: gas.toHexString(),
gas: _optionalChain$3([gas, 'optionalAccess', _12 => _12.toHexString, 'call', _13 => _13()]),
gasPrice: gasPrice.toHexString(),
nonce: transaction.nonce
}]
Expand Down
Loading

0 comments on commit 1ec6a60

Please sign in to comment.