Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Commit 4f09e58

Browse files
committed
Stop treating mantle particularly
1 parent fe9e0f0 commit 4f09e58

File tree

2 files changed

+1
-47
lines changed

2 files changed

+1
-47
lines changed

src/wallets.test.ts

-25
Original file line numberDiff line numberDiff line change
@@ -272,31 +272,6 @@ describe('hasEnoughBalance', () => {
272272
);
273273
});
274274

275-
it('should throw an error when failed to get gas price (mantle)', async () => {
276-
const sponsorWallet = {
277-
provider: {
278-
getBlock: jest.fn().mockResolvedValue({
279-
timestamp: Math.floor(Date.now() / 1000),
280-
}),
281-
network: {
282-
chainId: 5000,
283-
name: 'mantle',
284-
},
285-
send: jest.fn().mockImplementation((method: string) => {
286-
if (method === 'rollup_gasPrices') {
287-
throw new Error('getGasPrice: Unexpected');
288-
}
289-
}),
290-
getGasPrice: jest.fn().mockResolvedValue(ethers.utils.parseUnits('10', 'gwei')),
291-
},
292-
getBalance: jest.fn().mockResolvedValue(ethers.utils.parseEther('1')),
293-
};
294-
295-
await expect(hasEnoughBalance(sponsorWallet as any, {} as any, {} as any, undefined, logOptions)).rejects.toThrow(
296-
'getGasPrice: Unexpected'
297-
);
298-
});
299-
300275
it('should throw an error when failed to estimate gas', async () => {
301276
const sponsorWallet = {
302277
provider: {

src/wallets.ts

+1-22
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { go, goSync } from '@api3/promise-utils';
55
import { ethers } from 'ethers';
66
import { uniq } from 'lodash';
77
import { LogOptionsOverride, logger } from './logging';
8-
import { RateLimitedProvider } from './providers';
98
import { Provider, SponsorWalletsPrivateKey, getState, updateState } from './state';
109
import { createDummyBeaconUpdateData, shortenAddress } from './utils';
1110
import { DataFeedUpdates } from './validation';
@@ -61,26 +60,6 @@ export const retrieveSponsorWallet = (sponsorAddress: string): ethers.Wallet =>
6160
return new ethers.Wallet(sponsorWalletsPrivateKey[sponsorAddress]);
6261
};
6362

64-
const getMantleGasPrice = async (provider: RateLimitedProvider) => {
65-
const goRes = await go(() => provider.send('rollup_gasPrices', []));
66-
if (!goRes.success) throw goRes.error;
67-
68-
const l1GasPrice = ethers.BigNumber.from(goRes.data.l1GasPrice);
69-
const l2GasPrice = ethers.BigNumber.from(goRes.data.l2GasPrice);
70-
71-
return l1GasPrice.add(l2GasPrice);
72-
};
73-
74-
const getGasPrice = async (provider: RateLimitedProvider) => {
75-
switch (provider.network.chainId) {
76-
case 5000:
77-
case 5001:
78-
return getMantleGasPrice(provider);
79-
default:
80-
return provider.getGasPrice();
81-
}
82-
};
83-
8463
export const hasEnoughBalance = async (
8564
sponsorWallet: ethers.Wallet,
8665
dummyAirnode: ethers.Wallet,
@@ -97,7 +76,7 @@ export const hasEnoughBalance = async (
9776
const balance = goGetBalance.data;
9877

9978
// Get the gas price from provider
100-
const goGasPrice = await go(() => getGasPrice(sponsorWallet.provider as RateLimitedProvider), { retries: 1 });
79+
const goGasPrice = await go(() => sponsorWallet.provider.getGasPrice(), { retries: 1 });
10180
if (!goGasPrice.success) {
10281
logger.error('Failed to get chain gas price', goGasPrice.error, logOptions);
10382
throw new Error(goGasPrice.error.message);

0 commit comments

Comments
 (0)