Merge pull request #143 from raid-guild/develop
removed custom gas price
This commit is contained in:
commit
abe561c115
|
@ -1,9 +1,7 @@
|
||||||
import { Contract, utils } from 'ethers';
|
import { Contract, utils } from 'ethers';
|
||||||
import { gql, request } from 'graphql-request';
|
import { gql, request } from 'graphql-request';
|
||||||
|
|
||||||
import { getGasPrice } from './gasPrice';
|
|
||||||
import { getAMBAddress, getGraphEndpoint, logError } from './helpers';
|
import { getAMBAddress, getGraphEndpoint, logError } from './helpers';
|
||||||
import { isEIP1193 } from './providers';
|
|
||||||
|
|
||||||
export const fetchConfirmations = async (chainId, ethersProvider) => {
|
export const fetchConfirmations = async (chainId, ethersProvider) => {
|
||||||
const abi = ['function requiredBlockConfirmations() view returns (uint256)'];
|
const abi = ['function requiredBlockConfirmations() view returns (uint256)'];
|
||||||
|
@ -50,12 +48,7 @@ export const executeSignatures = async (ethersProvider, chainId, message) => {
|
||||||
);
|
);
|
||||||
const address = getAMBAddress(chainId);
|
const address = getAMBAddress(chainId);
|
||||||
const ambContract = new Contract(address, abi, ethersProvider.getSigner());
|
const ambContract = new Contract(address, abi, ethersProvider.getSigner());
|
||||||
const options = isEIP1193(ethersProvider)
|
return ambContract.executeSignatures(message.msgData, signatures);
|
||||||
? undefined
|
|
||||||
: { gasPrice: getGasPrice(chainId) };
|
|
||||||
return options
|
|
||||||
? ambContract.executeSignatures(message.msgData, signatures, options)
|
|
||||||
: ambContract.executeSignatures(message.msgData, signatures);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const messagesTXQuery = gql`
|
const messagesTXQuery = gql`
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { BigNumber, Contract } from 'ethers';
|
import { BigNumber, Contract } from 'ethers';
|
||||||
|
|
||||||
import { REVERSE_BRIDGE_ENABLED } from './constants';
|
import { REVERSE_BRIDGE_ENABLED } from './constants';
|
||||||
import { getGasPrice } from './gasPrice';
|
|
||||||
import {
|
import {
|
||||||
getBridgeNetwork,
|
getBridgeNetwork,
|
||||||
getMediatorAddress,
|
getMediatorAddress,
|
||||||
|
@ -9,7 +8,7 @@ import {
|
||||||
logError,
|
logError,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
import { getOverriddenToToken, isOverridden } from './overrides';
|
import { getOverriddenToToken, isOverridden } from './overrides';
|
||||||
import { getEthersProvider, isEIP1193 } from './providers';
|
import { getEthersProvider } from './providers';
|
||||||
import { fetchTokenDetails } from './token';
|
import { fetchTokenDetails } from './token';
|
||||||
|
|
||||||
const getToName = (fromName, fromxDai) => {
|
const getToName = (fromName, fromxDai) => {
|
||||||
|
@ -241,32 +240,23 @@ export const fetchTokenLimits = async (
|
||||||
|
|
||||||
export const relayTokens = async (ethersProvider, token, receiver, amount) => {
|
export const relayTokens = async (ethersProvider, token, receiver, amount) => {
|
||||||
const signer = ethersProvider.getSigner();
|
const signer = ethersProvider.getSigner();
|
||||||
const { chainId, mode, mediator, address } = token;
|
const { mode, mediator, address } = token;
|
||||||
const options = isEIP1193(ethersProvider)
|
|
||||||
? undefined
|
|
||||||
: { gasPrice: getGasPrice(chainId) };
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 'erc677': {
|
case 'erc677': {
|
||||||
const abi = ['function transferAndCall(address, uint256, bytes)'];
|
const abi = ['function transferAndCall(address, uint256, bytes)'];
|
||||||
const tokenContract = new Contract(address, abi, signer);
|
const tokenContract = new Contract(address, abi, signer);
|
||||||
return options
|
return tokenContract.transferAndCall(mediator, amount, receiver);
|
||||||
? tokenContract.transferAndCall(mediator, amount, receiver, options)
|
|
||||||
: tokenContract.transferAndCall(mediator, amount, receiver);
|
|
||||||
}
|
}
|
||||||
case 'dedicated-erc20': {
|
case 'dedicated-erc20': {
|
||||||
const abi = ['function relayTokens(address, uint256)'];
|
const abi = ['function relayTokens(address, uint256)'];
|
||||||
const mediatorContract = new Contract(mediator, abi, signer);
|
const mediatorContract = new Contract(mediator, abi, signer);
|
||||||
return options
|
return mediatorContract.relayTokens(receiver, amount);
|
||||||
? mediatorContract.relayTokens(receiver, amount, options)
|
|
||||||
: mediatorContract.relayTokens(receiver, amount);
|
|
||||||
}
|
}
|
||||||
case 'erc20':
|
case 'erc20':
|
||||||
default: {
|
default: {
|
||||||
const abi = ['function relayTokens(address, address, uint256)'];
|
const abi = ['function relayTokens(address, address, uint256)'];
|
||||||
const mediatorContract = new Contract(mediator, abi, signer);
|
const mediatorContract = new Contract(mediator, abi, signer);
|
||||||
return options
|
return mediatorContract.relayTokens(token.address, receiver, amount);
|
||||||
? mediatorContract.relayTokens(token.address, receiver, amount, options)
|
|
||||||
: mediatorContract.relayTokens(token.address, receiver, amount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,9 +87,7 @@ export const uniqueTokens = list => {
|
||||||
export const formatValue = (num, dec) => {
|
export const formatValue = (num, dec) => {
|
||||||
const str = utils.formatUnits(num, dec);
|
const str = utils.formatUnits(num, dec);
|
||||||
if (str.length > 50) {
|
if (str.length > 50) {
|
||||||
const expStr = Number(str)
|
const expStr = Number(str).toExponential().replace(/e\+?/, ' x 10^');
|
||||||
.toExponential()
|
|
||||||
.replace(/e\+?/, ' x 10^');
|
|
||||||
const split = expStr.split(' x 10^');
|
const split = expStr.split(' x 10^');
|
||||||
const first = Number(split[0]).toLocaleString('en', {
|
const first = Number(split[0]).toLocaleString('en', {
|
||||||
maximumFractionDigits: 4,
|
maximumFractionDigits: 4,
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import { BigNumber, Contract } from 'ethers';
|
import { BigNumber, Contract } from 'ethers';
|
||||||
|
|
||||||
import { ADDRESS_ZERO, REVERSE_BRIDGE_ENABLED } from './constants';
|
import { ADDRESS_ZERO, REVERSE_BRIDGE_ENABLED } from './constants';
|
||||||
import { getGasPrice } from './gasPrice';
|
|
||||||
import { getMediatorAddress, isxDaiChain, logError } from './helpers';
|
import { getMediatorAddress, isxDaiChain, logError } from './helpers';
|
||||||
import {
|
import {
|
||||||
getOverriddenMediator,
|
getOverriddenMediator,
|
||||||
getOverriddenMode,
|
getOverriddenMode,
|
||||||
isOverridden,
|
isOverridden,
|
||||||
} from './overrides';
|
} from './overrides';
|
||||||
import { getEthersProvider, isEIP1193 } from './providers';
|
import { getEthersProvider } from './providers';
|
||||||
|
|
||||||
export const fetchAllowance = async (
|
export const fetchAllowance = async (
|
||||||
{ mediator, address },
|
{ mediator, address },
|
||||||
|
@ -100,17 +99,12 @@ export const fetchTokenDetails = async token => {
|
||||||
|
|
||||||
export const approveToken = async (
|
export const approveToken = async (
|
||||||
ethersProvider,
|
ethersProvider,
|
||||||
{ chainId, address, mediator },
|
{ address, mediator },
|
||||||
amount,
|
amount,
|
||||||
) => {
|
) => {
|
||||||
const abi = ['function approve(address, uint256)'];
|
const abi = ['function approve(address, uint256)'];
|
||||||
const options = isEIP1193(ethersProvider)
|
|
||||||
? undefined
|
|
||||||
: { gasPrice: getGasPrice(chainId) };
|
|
||||||
const tokenContract = new Contract(address, abi, ethersProvider.getSigner());
|
const tokenContract = new Contract(address, abi, ethersProvider.getSigner());
|
||||||
return options
|
return tokenContract.approve(mediator, amount);
|
||||||
? tokenContract.approve(mediator, amount.toString(), options)
|
|
||||||
: tokenContract.approve(mediator, amount.toString());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchTokenBalance = async (token, account) => {
|
export const fetchTokenBalance = async (token, account) => {
|
||||||
|
|
Loading…
Reference in New Issue