Skip to content

Commit 96de581

Browse files
committedMar 19, 2022

File tree

6 files changed

+191
-6
lines changed

6 files changed

+191
-6
lines changed
 
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Bug Report Test Form
2+
description: Bug Report Test Form
3+
title: "Bug Report"
4+
labels: ["investigate"]
5+
assignees:
6+
- ricmoo
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thank you for taking the time to report an issue. But please **read this first**.
12+
- type: markdown
13+
attributes:
14+
value: |
15+
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.
16+
- type: input
17+
id: version
18+
attributes:
19+
label: Ethers Version
20+
description: What version of ethers are you using? Before opening an issue, please make sure you are up to date.
21+
placeholder: x.y.z
22+
validations:
23+
required: true
24+
- type: checkboxes
25+
id: search-check
26+
attributes:
27+
label: Have you searched existing issues?
28+
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)?
29+
options:
30+
- label: I have searched the existing issues
31+
required: true
32+
- type: input
33+
id: search-terms
34+
attributes:
35+
label: Search Terms
36+
description: Please include the search terms you have tried. This helps us add more keywords where needed.
37+
placeholder: e.g. abi, network, utf8
38+
- type: textarea
39+
id: about-the-bug
40+
attributes:
41+
label: Describe the bug. What did you expect to happen vs what did happen?
42+
placeholder: What happened?
43+
validations:
44+
required: true
45+
- type: textarea
46+
id: code-snippet
47+
attributes:
48+
label: Code Snippet
49+
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).
50+
placeholder: provider.getBlockNumber()
51+
render: shell
52+
- type: textarea
53+
id: contract-abi
54+
attributes:
55+
label: Contract ABI
56+
description: If this involves a contract, please include any **concise and relevant** ABI fragments.
57+
placeholder: contract ABI
58+
render: shell
59+
- type: checkboxes
60+
id: environment
61+
attributes:
62+
label: Environment
63+
decsription: What environment or frameworks are you using?
64+
options:
65+
- label: node.js (v12 or newer)
66+
- label: node.js (older than v12)
67+
- label: Browser (Chrome, Safari, etc)
68+
- label: React Native/Expo/JavaScriptCore
69+
- label: Hardhat
70+
- label: Geth
71+
- label: Parity
72+
- label: Ganache
73+
- type: input
74+
id: other-envrionment
75+
attributes:
76+
label: Other Environment
77+
placeholder: anything else?

‎README.md

+35-6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ A complete Ethereum wallet implementation and utilities in JavaScript (and TypeS
2626
Keep Updated
2727
------------
2828

29-
For the latest news and advisories, please follow the [@ethersproject](https://twitter.com/ethersproject)
30-
on Twitter (low-traffic, non-marketing, important information only) as well as watch this GitHub project.
29+
For the latest news and advisories, please follow the
30+
[@ethersproject](https://twitter.com/ethersproject) on Twitter (low-traffic,
31+
non-marketing, important information only) as well as watch this GitHub project.
3132

32-
For the latest changes, see the [CHANGELOG](https://github.com/ethers-io/ethers.js/blob/master/CHANGELOG.md).
33+
For the latest changes, see the
34+
[CHANGELOG](https://github.com/ethers-io/ethers.js/blob/master/CHANGELOG.md).
3335

3436

3537
Installing
@@ -44,15 +46,15 @@ Installing
4446
**browser (UMD)**
4547

4648
```
47-
<script src="https://cdn.ethers.io/lib/ethers-5.1.umd.min.js" type="text/javascript">
49+
<script src="https://cdn.ethers.io/lib/ethers-5.6.umd.min.js" type="text/javascript">
4850
</script>
4951
```
5052

5153
**browser (ESM)**
5254

5355
```
5456
<script type="module">
55-
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.1.esm.min.js";
57+
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.6.esm.min.js";
5658
</script>
5759
```
5860

@@ -66,7 +68,34 @@ Browse the [documentation](https://docs.ethers.io/v5/) online:
6668
- [Full API Documentation](https://docs.ethers.io/v5/api/)
6769
- [Various Ethereum Articles](https://blog.ricmoo.com/)
6870

69-
Or browse the entire documentation as a [single page](https://docs.ethers.io/v5/single-page/) to make searching easier.
71+
72+
Providers
73+
---------
74+
75+
Ethers works closely with an ever-growing list of third-party providers
76+
to ensure getting started is quick and easy, by providing default keys
77+
to each service.
78+
79+
These built-in keys mean you can use `ethers.getDefaultProvider()` and
80+
start developing right away.
81+
82+
However, the API keys provided to ethers are also shared and are
83+
intentionally throttled to encourage developers to eventually get
84+
their own keys, which unlock many other features, such as faster
85+
responses, more capacity, analytics and other features like archival
86+
data.
87+
88+
When you are ready to sign up and start using for your own keys, please
89+
check out the [Provider API Keys](https://docs.ethers.io/v5/api-keys/) in
90+
the documentation.
91+
92+
A special thanks to these services for providing community resources:
93+
94+
- [Etherscan](https://etherscan.io/)
95+
- [INFURA](https://infura.io/)
96+
- [Alchemy](https://dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d)
97+
- [Pocket](https://pokt.network/pocket-gateway-ethereum-mainnet/)
98+
- [Ankr](https://www.ankr.com/)
7099

71100

72101
Ancillary Packages

‎packages/networks/src.ts/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ function ethDefaultProvider(network: string | Network): Renetworkable {
6464
} catch(error) { }
6565
}
6666

67+
if (providers.AnkrProvider && options.ankr !== "-") {
68+
try {
69+
providerList.push(new providers.AnkrProvider(network, options.ankr));
70+
} catch(error) { }
71+
}
72+
6773
if (providerList.length === 0) { return null; }
6874

6975
if (providers.FallbackProvider) {
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
import { Network } from "@ethersproject/networks";
3+
4+
import { showThrottleMessage } from "./formatter";
5+
import { UrlJsonRpcProvider } from "./url-json-rpc-provider";
6+
7+
import type { ConnectionInfo } from "@ethersproject/web";
8+
9+
import { Logger } from "@ethersproject/logger";
10+
import { version } from "./_version";
11+
const logger = new Logger(version);
12+
13+
14+
const defaultApiKey = "9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";
15+
16+
function getHost(name: string): string {
17+
switch (name) {
18+
case "homestead":
19+
return "rpc.ankr.com/eth/";
20+
case "matic":
21+
return "rpc.ankr.com/polygon/";
22+
case "arbitrum":
23+
return "rpc.ankr.com/arbitrum/";
24+
}
25+
return logger.throwArgumentError("unsupported network", "name", name);
26+
}
27+
28+
export class AnkrProvider extends UrlJsonRpcProvider {
29+
readonly apiKey: string;
30+
31+
isCommunityResource(): boolean {
32+
return (this.apiKey === defaultApiKey);
33+
}
34+
35+
static getApiKey(apiKey: any): any {
36+
if (apiKey == null) { return defaultApiKey; }
37+
return apiKey;
38+
}
39+
40+
static getUrl(network: Network, apiKey: any): ConnectionInfo {
41+
if (apiKey == null) { apiKey = defaultApiKey; }
42+
const connection: ConnectionInfo = {
43+
allowGzip: true,
44+
url: ("https:/\/" + getHost(network.name) + apiKey),
45+
throttleCallback: (attempt: number, url: string) => {
46+
if (apiKey.apiKey === defaultApiKey) {
47+
showThrottleMessage();
48+
}
49+
return Promise.resolve(true);
50+
}
51+
};
52+
53+
if (apiKey.projectSecret != null) {
54+
connection.user = "";
55+
connection.password = apiKey.projectSecret
56+
}
57+
58+
return connection;
59+
}
60+
}

‎packages/providers/src.ts/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Network, Networkish } from "@ethersproject/networks";
2020
import { BaseProvider, EnsProvider, EnsResolver, Resolver } from "./base-provider";
2121

2222
import { AlchemyProvider, AlchemyWebSocketProvider } from "./alchemy-provider";
23+
import { AnkrProvider } from "./ankr-provider";
2324
import { CloudflareProvider } from "./cloudflare-provider";
2425
import { EtherscanProvider } from "./etherscan-provider";
2526
import { FallbackProvider, FallbackProviderConfig } from "./fallback-provider";
@@ -76,6 +77,7 @@ function getDefaultProvider(network?: Networkish, options?: any): BaseProvider {
7677
FallbackProvider,
7778

7879
AlchemyProvider,
80+
AnkrProvider,
7981
CloudflareProvider,
8082
EtherscanProvider,
8183
InfuraProvider,
@@ -108,6 +110,7 @@ export {
108110

109111
AlchemyProvider,
110112
AlchemyWebSocketProvider,
113+
AnkrProvider,
111114
CloudflareProvider,
112115
EtherscanProvider,
113116
InfuraProvider,

‎packages/tests/src.ts/test-providers.ts

+10
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,16 @@ const providerFunctions: Array<ProviderDescription> = [
583583
return new ethers.providers.AlchemyProvider(network, getApiKeys(network).alchemy);
584584
}
585585
},
586+
{
587+
name: "AnkrProvider",
588+
networks: [ "default", "homestead" ],
589+
create: (network: string) => {
590+
if (network == "default") {
591+
return new ethers.providers.AnkrProvider(null);
592+
}
593+
return new ethers.providers.AnkrProvider(network);
594+
}
595+
},
586596
/*
587597
{
588598
name: "CloudflareProvider",

0 commit comments

Comments
 (0)
Please sign in to comment.