Skip to content

Remove useless polygon gas station #4914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib.commonjs/providers/default-provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { WebSocketLike } from "./provider-websocket.js";
* - ``"chainstack"``
* - ``"etherscan"``
* - ``"infura"``
* - ``"publicPolygon"``
* - ``"quicknode"``
*
* @example:
Expand All @@ -46,4 +45,3 @@ import { WebSocketLike } from "./provider-websocket.js";
* });
*/
export declare function getDefaultProvider(network?: string | Networkish | WebSocketLike, options?: any): AbstractProvider;
//# sourceMappingURL=default-provider.d.ts.map
11 changes: 1 addition & 10 deletions lib.commonjs/providers/default-provider.js

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

4 changes: 1 addition & 3 deletions lib.commonjs/providers/provider-ankr.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* - Optimism (``optimism``)
* - Optimism Goerli Testnet (``optimism-goerli``)
* - Optimism Sepolia Testnet (``optimism-sepolia``)
* - Polygon (``matic``)
* - Polygon Mumbai Testnet (``matic-mumbai``)
*
* @_subsection: api/providers/thirdparty:Ankr [providers-ankr]
*/
Expand Down Expand Up @@ -58,4 +56,4 @@ export declare class AnkrProvider extends JsonRpcProvider implements CommunityRe
getRpcError(payload: JsonRpcPayload, error: JsonRpcError): Error;
isCommunityResource(): boolean;
}
//# sourceMappingURL=provider-ankr.d.ts.map
//# sourceMappingURL=provider-ankr.d.ts.map
3 changes: 1 addition & 2 deletions lib.commonjs/providers/provider-chainstack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* - Ethereum Mainnet (``mainnet``)
* - Arbitrum (``arbitrum``)
* - BNB Smart Chain Mainnet (``bnb``)
* - Polygon (``matic``)
*
* @_subsection: api/providers/thirdparty:Chainstack [providers-chainstack]
*/
Expand Down Expand Up @@ -43,4 +42,4 @@ export declare class ChainstackProvider extends JsonRpcProvider implements Commu
*/
static getRequest(network: Network, apiKey?: null | string): FetchRequest;
}
//# sourceMappingURL=provider-chainstack.d.ts.map
//# sourceMappingURL=provider-chainstack.d.ts.map
5 changes: 1 addition & 4 deletions lib.commonjs/providers/provider-etherscan.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
* - BNB Smart Chain Testnet (``bnbt``)
* - Optimism (``optimism``)
* - Optimism Goerli Testnet (``optimism-goerli``)
* - Polygon (``matic``)
* - Polygon Mumbai Testnet (``matic-mumbai``)
* - Polygon Amoy Testnet (``matic-amoy``)
*
* @_subsection api/providers/thirdparty:Etherscan [providers-etherscan]
*/
Expand Down Expand Up @@ -144,4 +141,4 @@ export declare class EtherscanProvider extends AbstractProvider {
getContract(_address: string): Promise<null | Contract>;
isCommunityResource(): boolean;
}
//# sourceMappingURL=provider-etherscan.d.ts.map
//# sourceMappingURL=provider-etherscan.d.ts.map
36 changes: 2 additions & 34 deletions src.ts/providers/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,32 +320,6 @@ function parseUnits(_value: number | string, decimals: number): bigint {
return BigInt(comps[0] + comps[1]);
}

// Used by Polygon to use a gas station for fee data
function getGasStationPlugin(url: string) {
return new FetchUrlFeeDataNetworkPlugin(url, async (fetchFeeData, provider, request) => {

// Prevent Cloudflare from blocking our request in node.js
request.setHeader("User-Agent", "ethers");

let response;
try {
const [ _response, _feeData ] = await Promise.all([
request.send(), fetchFeeData()
]);
response = _response;
const payload = response.bodyJson.standard;
const feeData = {
gasPrice: _feeData.gasPrice,
maxFeePerGas: parseUnits(payload.maxFee, 9),
maxPriorityFeePerGas: parseUnits(payload.maxPriorityFee, 9),
};
return feeData;
} catch (error: any) {
assert(false, `error encountered with polygon gas station (${ JSON.stringify(request.url) })`, "SERVER_ERROR", { request, response, error });
}
});
}

// See: https://chainlist.org
let injected = false;
function injectCommonNetworks(): void {
Expand Down Expand Up @@ -411,17 +385,11 @@ function injectCommonNetworks(): void {
registerEth("linea-sepolia", 59141, { });

registerEth("matic", 137, {
ensNetwork: 1,
plugins: [
getGasStationPlugin("https:/\/gasstation.polygon.technology/v2")
]
ensNetwork: 1
});
registerEth("matic-amoy", 80002, { });
registerEth("matic-mumbai", 80001, {
altNames: [ "maticMumbai", "maticmum" ], // @TODO: Future remove these alts
plugins: [
getGasStationPlugin("https:/\/gasstation-testnet.polygon.technology/v2")
]
altNames: [ "maticMumbai", "maticmum" ]
});

registerEth("optimism", 10, {
Expand Down
9 changes: 0 additions & 9 deletions src.ts/providers/provider-etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
* - BNB Smart Chain Testnet (``bnbt``)
* - Optimism (``optimism``)
* - Optimism Goerli Testnet (``optimism-goerli``)
* - Polygon (``matic``)
* - Polygon Mumbai Testnet (``matic-mumbai``)
* - Polygon Amoy Testnet (``matic-amoy``)
*
* @_subsection api/providers/thirdparty:Etherscan [providers-etherscan]
*/
Expand Down Expand Up @@ -181,12 +178,6 @@ export class EtherscanProvider extends AbstractProvider {
return "https:/\/api.bscscan.com";
case "bnbt":
return "https:/\/api-testnet.bscscan.com";
case "matic":
return "https:/\/api.polygonscan.com";
case "matic-amoy":
return "https:/\/api-amoy.polygonscan.com";
case "matic-mumbai":
return "https:/\/api-testnet.polygonscan.com";
case "optimism":
return "https:/\/api-optimistic.etherscan.io";
case "optimism-goerli":
Expand Down