forked from ethers-io/ethers.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
191 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Bug Report Test Form | ||
description: Bug Report Test Form | ||
title: "Bug Report" | ||
labels: ["investigate"] | ||
assignees: | ||
- ricmoo | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thank you for taking the time to report an issue. But please **read this first**. | ||
- type: markdown | ||
attributes: | ||
value: | | ||
This issue template is for reporting **bugs within ethers**. If you are new to ethers or uncertain whether this is a bug in ethers, a bug in another framework or a bug in your own code, please start a [discussion first](https://github.com/ethers-io/ethers.js/discussions) first. | ||
- type: input | ||
id: version | ||
attributes: | ||
label: Ethers Version | ||
description: What version of ethers are you using? Before opening an issue, please make sure you are up to date. | ||
placeholder: x.y.z | ||
validations: | ||
required: true | ||
- type: checkboxes | ||
id: search-check | ||
attributes: | ||
label: Have you searched existing issues? | ||
description: Have you searched for answers [in the documentation](https://docs.ethers.io), [through the issues](https://github.com/ethers-io/ethers.js/issues) and [on the discusions](https://github.com/ethers-io/ethers.js/discussions)? | ||
options: | ||
- label: I have searched the existing issues | ||
required: true | ||
- type: input | ||
id: search-terms | ||
attributes: | ||
label: Search Terms | ||
description: Please include the search terms you have tried. This helps us add more keywords where needed. | ||
placeholder: e.g. abi, network, utf8 | ||
- type: textarea | ||
id: about-the-bug | ||
attributes: | ||
label: Describe the bug. What did you expect to happen vs what did happen? | ||
placeholder: What happened? | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: code-snippet | ||
attributes: | ||
label: Code Snippet | ||
description: Please include any **short and concise** code snippets that can reproduce this issue. Ideally code that can be pasted into the [Ethers Playground](https://playground.ethers.org). | ||
placeholder: provider.getBlockNumber() | ||
render: shell | ||
- type: textarea | ||
id: contract-abi | ||
attributes: | ||
label: Contract ABI | ||
description: If this involves a contract, please include any **concise and relevant** ABI fragments. | ||
placeholder: contract ABI | ||
render: shell | ||
- type: checkboxes | ||
id: environment | ||
attributes: | ||
label: Environment | ||
decsription: What environment or frameworks are you using? | ||
options: | ||
- label: node.js (v12 or newer) | ||
- label: node.js (older than v12) | ||
- label: Browser (Chrome, Safari, etc) | ||
- label: React Native/Expo/JavaScriptCore | ||
- label: Hardhat | ||
- label: Geth | ||
- label: Parity | ||
- label: Ganache | ||
- type: input | ||
id: other-envrionment | ||
attributes: | ||
label: Other Environment | ||
placeholder: anything else? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
import { Network } from "@ethersproject/networks"; | ||
|
||
import { showThrottleMessage } from "./formatter"; | ||
import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; | ||
|
||
import type { ConnectionInfo } from "@ethersproject/web"; | ||
|
||
import { Logger } from "@ethersproject/logger"; | ||
import { version } from "./_version"; | ||
const logger = new Logger(version); | ||
|
||
|
||
const defaultApiKey = "9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972"; | ||
|
||
function getHost(name: string): string { | ||
switch (name) { | ||
case "homestead": | ||
return "rpc.ankr.com/eth/"; | ||
case "matic": | ||
return "rpc.ankr.com/polygon/"; | ||
case "arbitrum": | ||
return "rpc.ankr.com/arbitrum/"; | ||
} | ||
return logger.throwArgumentError("unsupported network", "name", name); | ||
} | ||
|
||
export class AnkrProvider extends UrlJsonRpcProvider { | ||
readonly apiKey: string; | ||
|
||
isCommunityResource(): boolean { | ||
return (this.apiKey === defaultApiKey); | ||
} | ||
|
||
static getApiKey(apiKey: any): any { | ||
if (apiKey == null) { return defaultApiKey; } | ||
return apiKey; | ||
} | ||
|
||
static getUrl(network: Network, apiKey: any): ConnectionInfo { | ||
if (apiKey == null) { apiKey = defaultApiKey; } | ||
const connection: ConnectionInfo = { | ||
allowGzip: true, | ||
url: ("https:/\/" + getHost(network.name) + apiKey), | ||
throttleCallback: (attempt: number, url: string) => { | ||
if (apiKey.apiKey === defaultApiKey) { | ||
showThrottleMessage(); | ||
} | ||
return Promise.resolve(true); | ||
} | ||
}; | ||
|
||
if (apiKey.projectSecret != null) { | ||
connection.user = ""; | ||
connection.password = apiKey.projectSecret | ||
} | ||
|
||
return connection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters