Compare commits

..

13 Commits

Author SHA1 Message Date
Richard Moore
faa556c1e5 docs: added basic security details 2023-02-04 03:24:24 -05:00
Richard Moore
1c5e1e8201 docs: added README to explain folder usage 2023-02-04 03:23:32 -05:00
Richard Moore
3f7dbe75ad docs: added more info for migration 2023-02-04 03:22:42 -05:00
Richard Moore
a0f272973d docs: added links for CDN 2023-02-04 03:22:19 -05:00
Richard Moore
b67ad79264 docs: added more docs on Errors 2023-02-04 03:21:16 -05:00
Richard Moore
ccb9a0643e admin: updated post-build file copying 2023-02-04 03:15:22 -05:00
Richard Moore
d0ed91840c Fix Subscriber model when removed within emit callback. 2023-02-04 03:12:04 -05:00
Richard Moore
32b1e7827a docs: replaces ethers.io URLs with ethers.org 2023-02-03 21:53:10 -05:00
Richard Moore
522fd16f68 Fixed human-readable parser when identifier begins with valid type prefix (#3728). 2023-02-03 21:50:30 -05:00
Richard Moore
803e8f9821 Update to latest secp256k1 library (#3719). 2023-02-03 03:28:22 -05:00
Richard Moore
2cba1c7781 admin: added funding details to pacakge.json 2023-02-02 23:05:38 -05:00
Richard Moore
0b92fed9ed admin: added Issue Templates from v5 2023-02-02 23:04:45 -05:00
Richard Moore
0a740c470d admin: updated dist files 2023-02-02 22:21:31 -05:00
34 changed files with 396 additions and 265 deletions

81
.github/ISSUE_TEMPLATE/bug-report.yml vendored Normal file
View File

@@ -0,0 +1,81 @@
name: Bug Report
description: Open an issue for a bug in Ethers
title: "Bug Report Title"
labels: ["investigate"]
assignees:
- ricmoo
body:
- type: markdown
attributes:
value: |
**READ THIS FIRST** and follow all instructions, please. `:)`
Thank you for taking the time to report an issue. This form 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](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: input
id: search-terms
attributes:
label: Search Terms
description: Have you searched for answers [in the documentation](https://docs.ethers.org), through [the issues](https://github.com/ethers-io/ethers.js/issues) and [on the discusions](https://github.com/ethers-io/ethers.js/discussions)? 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 Problem
description: Please describe what you expected to happen vs what did happen?
placeholder: What happened?
validations:
required: true
- type: textarea
id: code-snippet
attributes:
label: Code Snippet
description: If possible, please include a **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: e.g. 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: e.g. [ 'function balanceOf(address owner) view returns (uint)' ]
render: shell
- type: textarea
id: errors
attributes:
label: Errors
description: If there is an error, please include the **entire error** (redacting any sensitive information).
placeholder: "e.g. Error: invalid name (code='INVALID_ARGUMENT, ...)"
render: shell
- type: dropdown
id: environment
attributes:
label: Environment
description: What environment, platforms or frameworks are you using? Select all that apply.
multiple: true
options:
- Ethereum (mainnet/ropsten/rinkeby/goerli)
- Altcoin - Please specify (e.g. Polygon)
- node.js (v12 or newer)
- node.js (older than v12)
- Browser (Chrome, Safari, etc)
- React Native/Expo/JavaScriptCore
- Hardhat
- Geth
- Parity
- Ganache
- Other (please specify)
- type: input
id: other-envrionment
attributes:
label: Environment (Other)
placeholder: anything else?

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1 @@
blank_issues_enabled: false

View File

@@ -0,0 +1,23 @@
name: Documentation
description: Documentation update, change or suggestion
title: "Documentation Title"
labels: ["documentation"]
body:
- type: markdown
attributes:
value: |
Please include anything about the [documentation](https://docs.ethers.org) you would like to see improved.
- Missing information or details?
- Spelling or Grammar mistakes?
- Wrong Information?
- Dead or wrong links?
- Something needs code examples?
- General feedback or anything else?
- type: textarea
id: suggestion
attributes:
label: Suggestion
placeholder: e.g. please add an example for ropsten
validations:
required: true

View File

@@ -0,0 +1,26 @@
name: Feature Request
description: Suggest a new feature or addition to Ethers
title: "Feature Request Title"
labels: [ "enhancement" ]
body:
- type: markdown
attributes:
value: |
The best place to start a new feature request is by starting an [Idea discussion](https://github.com/ethers-io/ethers.js/discussions), to mull over the feature, discuss current options and think through the impact on the overall library.
Keep in mind that features increase the library size, and may require additional dependencies. Ethers strives to remain lean and the number of dependencies low, so many features may make more sense as ancillary packages.
- type: textarea
id: about-the-feature
attributes:
label: Describe the Feature
description: Please describe the feature, the problem it is solving, your solution and alternatives you've considered.
placeholder: e.g. I want Ethers to be more/less magical.
validations:
required: true
- type: textarea
id: code-example
attributes:
label: Code Example
description: Optionally, provide an example of how the feature would be used in code.
placeholder: e.g. provider.doMagic()
render: shell

View File

@@ -3,7 +3,7 @@ The Ethers Project
[![npm (tag)](https://img.shields.io/npm/v/ethers)](https://www.npmjs.com/package/ethers)
[![CI Tests](https://github.com/ethers-io/ethers.js/actions/workflows/test-ci.yml/badge.svg?branch=main)](https://github.com/ethers-io/ethers.js/actions/workflows/test-ci.yml)
![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/ethers/main)
![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/ethers)
![npm (downloads)](https://img.shields.io/npm/dm/ethers)
[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/ethers-io/ethers.js/badge)](https://www.gitpoap.io/gh/ethers-io/ethers.js)
[![Twitter Follow](https://img.shields.io/twitter/follow/ricmoo?style=social)](https://twitter.com/ricmoo)
@@ -24,7 +24,7 @@ in [TypeScript](https://www.typescriptlang.org).
- **Tiny** (~120kb compressed; 400kb uncompressed)
- **Tree-shaking** focused; include only what you need during bundling
- **Complete** functionality for all your Ethereum desires
- Extensive [documentation](https://docs.ethers.io/v5/)
- Extensive [documentation](https://docs.ethers.org/v6/)
- Large collection of **test cases** which are maintained and added to
- Fully written in **TypeScript**, with strict types for security
- **MIT License** (including ALL dependencies); completely open source to do with as you please
@@ -76,12 +76,10 @@ The bundled library is available in the `./dist/` folder in this repo.
Documentation
-------------
**Note: The v6 docs are not available yet**
Browse the [documentation](https://docs.ethers.org) online:
Browse the [documentation](https://docs.ethers.io) online:
- [Getting Started](https://docs.ethers.io/v6/getting-started/)
- [Full API Documentation](https://docs.ethers.io/v6/api/)
- [Getting Started](https://docs.ethers.org/v6/getting-started/)
- [Full API Documentation](https://docs.ethers.org/v6/api/)
- [Various Ethereum Articles](https://blog.ricmoo.com/)
@@ -103,7 +101,7 @@ responses, more capacity, analytics and other features like archival
data.
When you are ready to sign up and start using for your own keys, please
check out the [Provider API Keys](https://docs.ethers.io/v5/api-keys/) in
check out the [Provider API Keys](https://docs.ethers.org/v5/api-keys/) in
the documentation.
A special thanks to these services for providing community resources:

34
SECURITY.md Normal file
View File

@@ -0,0 +1,34 @@
# Security Policy
## Supported Versions
Maintaining multiple versions of the library is quite time consuming, so
the majority of the effort is focused on the latest major release.
If you do require a version outside of this chart updated with patch fix,
please [contact me](mailto:github@ricmoo.com).
| Version | Supported | Initial Release |
| ------- | ------------------------------------------ | ----------------- |
| 6.0.x | :white_check_mark: | 2023-02-02 |
| 5.0.x | :white_check_mark: (security updates) | 2020-06-12 |
| 4.0.x | :x: | 2018-10-01 |
| 3.0.x | :x: | 2018-03-05 |
| 2.2.x | :x: | 2018-01-11 |
| 2.1.x | :x: | 2017-05-22 |
| 2.0.x | :x: | 2017-04-05 |
| 1.0.x | :x: | 2016-08-23 |
| 0.0.x | :x: | 2016-07-14 |
## Reporting a Vulnerability
If you identify a security vulnerability with this library (or any dependency),
please do not hesitate to contact [github@ricmoo.com](mailto:github@ricmoo.com)
immediately.
I try to respond within the same day and will address any concern as quickly
as possible (including code fixes and publishing to NPM).
Any vulnerability will also be published to this file, along with credits,
pertinent information and links to fixes.

7
dist/README.md vendored Normal file
View File

@@ -0,0 +1,7 @@
Distribution Files
==================
This folder contains the library reduced to single-file variants.
They are generate with the `npm run build-dist` command, which uses
rollup (via the `/rollup.config.js` configuration).

57
dist/ethers.js vendored
View File

@@ -12305,7 +12305,7 @@ class Block {
* prefetched them, by passing ``true`` to %%prefetchTxs%%
* into [[provider_getBlock]].
*/
get transactionResponses() {
get prefetchedTransactions() {
const txs = this.#transactions.slice();
// Doesn't matter...
if (txs.length === 0) {
@@ -12398,8 +12398,8 @@ class Block {
return tx;
}
}
getTransactionResponse(indexOrHash) {
const txs = this.transactionResponses;
getPrefetchedTransaction(indexOrHash) {
const txs = this.prefetchedTransactions;
if (typeof (indexOrHash) === "number") {
return txs[indexOrHash];
}
@@ -12409,7 +12409,7 @@ class Block {
return tx;
}
}
throw new Error("no such tx");
assertArgument(false, "no matching transaction", "indexOrHash", indexOrHash);
}
/**
* Has this block been mined.
@@ -12433,23 +12433,6 @@ class Block {
}
//////////////////////
// Log
/*
export interface LogParams {
transactionHash: string;
blockHash: string;
blockNumber: number;
removed: boolean;
address: string;
data: string;
topics: ReadonlyArray<string>;
index: number;
transactionIndex: number;
}
*/
class Log {
provider;
transactionHash;
@@ -12476,9 +12459,6 @@ class Log {
transactionIndex: log.transactionIndex,
});
}
//connect(provider: Provider): Log {
// return new Log(this, provider);
//}
toJSON() {
const { address, blockHash, blockNumber, data, index, removed, topics, transactionHash, transactionIndex } = this;
return {
@@ -12509,32 +12489,6 @@ class Log {
//////////////////////
// Transaction Receipt
/*
export interface TransactionReceiptParams {
to: null | string;
from: string;
contractAddress: null | string;
hash: string;
index: number;
blockHash: string;
blockNumber: number;
logsBloom: string;
logs: ReadonlyArray<LogParams>;
gasUsed: bigint;
cumulativeGasUsed: bigint;
gasPrice?: null | bigint;
effectiveGasPrice?: null | bigint;
type: number;
//byzantium: boolean;
status: null | number;
root: null | string;
}
*/
/*
export interface LegacyTransactionReceipt {
byzantium: false;
status: null;
@@ -12589,9 +12543,6 @@ class TransactionReceipt {
});
}
get logs() { return this.#logs; }
//connect(provider: Provider): TransactionReceipt {
// return new TransactionReceipt(this, provider);
//}
toJSON() {
const { to, from, contractAddress, hash, index, blockHash, blockNumber, logsBloom, logs, //byzantium,
status, root } = this;

2
dist/ethers.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

5
docs.wrm/README.md Normal file
View File

@@ -0,0 +1,5 @@
Documentation Source
====================
This folder contains all the Flatworm source for the documentation.

View File

@@ -13,11 +13,26 @@ const subtitle = (function(version) {
return version.substring(dash + 1);
})(version);
const extraLinks = function() {
return [
`link-cdnjs [ethers.min.js](https:/\/cdnjs.cloudflare.com/ajax/libs/ethers/${ version }/ethers.min.js)`,
`link-cdnjs-wordlists [wordlists-extra.min.js](https:/\/cdnjs.cloudflare.com/ajax/libs/ethers/${ version }/wordlists-extra.min.js)`,
];
}
export default {
title, subtitle,
// Where all the basic documentation is
docRoot: ".",
// Where all the code is for the jsdocs API crawler
codeRoot: "../src.ts/index.ts",
// Place all files in the /v6/ folder
prefix: "v6",
// Prepare the context for running the examples
contextify: function(context) {
Object.assign(context, ethers);
context.provider = new ethers.InfuraProvider();
@@ -42,22 +57,28 @@ export default {
};
},
// The base URL to use for the <src> links
srcBaseUrl: "https:/\/github.com/ethers-io/ethers.js/blob/main/src.ts/{FILENAME}#L{LINENO}",
// Used at the bottom of each page to indicate the last-modified-time.
// This uses the most recent time in the repo that the file was
// updated.
getTimestamp: function(path) {
return getModifiedTime(path);
},
docRoot: ".",
codeRoot: "../src.ts/index.ts",
// All the links to pull in
links: [
"./links/javascript.txt",
"./links/npm.txt",
"./links/projects.txt",
"./links/ricmoo.txt",
"./links/specs.txt",
"./links/wiki.txt"
"./links/wiki.txt",
extraLinks
],
// Extra files to copy over to the /static folder
staticFiles: [
"logo.svg",
"social.jpg"

View File

@@ -23,6 +23,6 @@ about the entire Application Programming Interface.
_subsection: Older Documentation
- [v5 documentation here](link-docs-v5)
- [v4 documentation here](link-docs-v4)
- [v3 documentation here](link-docs-v3)
- [v5 documentation](link-docs-v5)
- [v4 documentation](link-docs-v4)
- [v3 documentation](link-docs-v3)

View File

@@ -6,9 +6,9 @@ link-ci [Ethers CI](https://github.com/ethers-io/ethers.js/actions/runs/15800690
link-discussion [Ethers Discussion](https://github.com/ethers-io/ethers.js/discussions)
link-issue [Open Ethers Issue](https://github.com/ethers-io/ethers.js/issues/new/choose)
link-issues [Ethers Issues](https://github.com/ethers-io/ethers.js/issues)
link-docs-v3 [V3 Documentation](https://docs.ethers.io/v3/)
link-docs-v4 [V4 Documentation](https://docs.ethers.io/v4/)
link-docs-v5 [V5 Documentation](https://docs.ethers.io/v5/)
link-docs-v3 [V3 Documentation](https://docs.ethers.org/v3/)
link-docs-v4 [V4 Documentation](https://docs.ethers.org/v4/)
link-docs-v5 [V5 Documentation](https://docs.ethers.org/v5/)
# Social profiles
link-repo [GitHub Repo](https://github.com/ethers-io/ethers.js)

View File

@@ -206,3 +206,23 @@ _code: default AbiCoder @lang<script>
// instance is returned.
coder = AbiCoder.defaultAbiCoder()
_code: getting a JSON-RPC quantity @lang<script>
// In v5:
hex = ethers.util.hexValue(value)
// In v6:
hex = ethers.toQuantity(value)
_code: using Bytes32 strings @lang<script>
// In v5:
bytes32 = formatBytes32String(text)
text = parseBytes32String(bytes32)
// In v6:
bytes32 = encodeBytes32String(text)
text = decodeBytes32String(bytes32)
_subsection: Removed Classes and functions
The **Logger** class has been replaced by
[several Error utility functions](about-errors).

View File

@@ -177,7 +177,7 @@ export declare class Block implements BlockParams, Iterable<string> {
* prefetched them, by passing ``true`` to %%prefetchTxs%%
* into [[provider_getBlock]].
*/
get transactionResponses(): Array<TransactionResponse>;
get prefetchedTransactions(): Array<TransactionResponse>;
/**
* Returns a JSON-friendly value.
*/
@@ -195,7 +195,7 @@ export declare class Block implements BlockParams, Iterable<string> {
* Get the transaction at %%indexe%% within this block.
*/
getTransaction(indexOrHash: number | string): Promise<TransactionResponse>;
getTransactionResponse(indexOrHash: number | string): TransactionResponse;
getPrefetchedTransaction(indexOrHash: number | string): TransactionResponse;
/**
* Has this block been mined.
*

View File

@@ -233,7 +233,7 @@ class Block {
* prefetched them, by passing ``true`` to %%prefetchTxs%%
* into [[provider_getBlock]].
*/
get transactionResponses() {
get prefetchedTransactions() {
const txs = this.#transactions.slice();
// Doesn't matter...
if (txs.length === 0) {
@@ -326,8 +326,8 @@ class Block {
return tx;
}
}
getTransactionResponse(indexOrHash) {
const txs = this.transactionResponses;
getPrefetchedTransaction(indexOrHash) {
const txs = this.prefetchedTransactions;
if (typeof (indexOrHash) === "number") {
return txs[indexOrHash];
}
@@ -337,7 +337,7 @@ class Block {
return tx;
}
}
throw new Error("no such tx");
(0, index_js_1.assertArgument)(false, "no matching transaction", "indexOrHash", indexOrHash);
}
/**
* Has this block been mined.
@@ -362,23 +362,6 @@ class Block {
exports.Block = Block;
//////////////////////
// Log
/*
export interface LogParams {
transactionHash: string;
blockHash: string;
blockNumber: number;
removed: boolean;
address: string;
data: string;
topics: ReadonlyArray<string>;
index: number;
transactionIndex: number;
}
*/
class Log {
provider;
transactionHash;
@@ -405,9 +388,6 @@ class Log {
transactionIndex: log.transactionIndex,
});
}
//connect(provider: Provider): Log {
// return new Log(this, provider);
//}
toJSON() {
const { address, blockHash, blockNumber, data, index, removed, topics, transactionHash, transactionIndex } = this;
return {
@@ -439,32 +419,6 @@ exports.Log = Log;
//////////////////////
// Transaction Receipt
/*
export interface TransactionReceiptParams {
to: null | string;
from: string;
contractAddress: null | string;
hash: string;
index: number;
blockHash: string;
blockNumber: number;
logsBloom: string;
logs: ReadonlyArray<LogParams>;
gasUsed: bigint;
cumulativeGasUsed: bigint;
gasPrice?: null | bigint;
effectiveGasPrice?: null | bigint;
type: number;
//byzantium: boolean;
status: null | number;
root: null | string;
}
*/
/*
export interface LegacyTransactionReceipt {
byzantium: false;
status: null;
@@ -519,9 +473,6 @@ class TransactionReceipt {
});
}
get logs() { return this.#logs; }
//connect(provider: Provider): TransactionReceipt {
// return new TransactionReceipt(this, provider);
//}
toJSON() {
const { to, from, contractAddress, hash, index, blockHash, blockNumber, logsBloom, logs, //byzantium,
status, root } = this;

File diff suppressed because one or more lines are too long

View File

@@ -228,7 +228,7 @@ export class Block {
* prefetched them, by passing ``true`` to %%prefetchTxs%%
* into [[provider_getBlock]].
*/
get transactionResponses() {
get prefetchedTransactions() {
const txs = this.#transactions.slice();
// Doesn't matter...
if (txs.length === 0) {
@@ -321,8 +321,8 @@ export class Block {
return tx;
}
}
getTransactionResponse(indexOrHash) {
const txs = this.transactionResponses;
getPrefetchedTransaction(indexOrHash) {
const txs = this.prefetchedTransactions;
if (typeof (indexOrHash) === "number") {
return txs[indexOrHash];
}
@@ -332,7 +332,7 @@ export class Block {
return tx;
}
}
throw new Error("no such tx");
assertArgument(false, "no matching transaction", "indexOrHash", indexOrHash);
}
/**
* Has this block been mined.
@@ -356,23 +356,6 @@ export class Block {
}
//////////////////////
// Log
/*
export interface LogParams {
transactionHash: string;
blockHash: string;
blockNumber: number;
removed: boolean;
address: string;
data: string;
topics: ReadonlyArray<string>;
index: number;
transactionIndex: number;
}
*/
export class Log {
provider;
transactionHash;
@@ -399,9 +382,6 @@ export class Log {
transactionIndex: log.transactionIndex,
});
}
//connect(provider: Provider): Log {
// return new Log(this, provider);
//}
toJSON() {
const { address, blockHash, blockNumber, data, index, removed, topics, transactionHash, transactionIndex } = this;
return {
@@ -432,32 +412,6 @@ export class Log {
//////////////////////
// Transaction Receipt
/*
export interface TransactionReceiptParams {
to: null | string;
from: string;
contractAddress: null | string;
hash: string;
index: number;
blockHash: string;
blockNumber: number;
logsBloom: string;
logs: ReadonlyArray<LogParams>;
gasUsed: bigint;
cumulativeGasUsed: bigint;
gasPrice?: null | bigint;
effectiveGasPrice?: null | bigint;
type: number;
//byzantium: boolean;
status: null | number;
root: null | string;
}
*/
/*
export interface LegacyTransactionReceipt {
byzantium: false;
status: null;
@@ -512,9 +466,6 @@ export class TransactionReceipt {
});
}
get logs() { return this.#logs; }
//connect(provider: Provider): TransactionReceipt {
// return new TransactionReceipt(this, provider);
//}
toJSON() {
const { to, from, contractAddress, hash, index, blockHash, blockNumber, logsBloom, logs, //byzantium,
status, root } = this;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
CommonJS Generated Files
========================
Do not modify the files in this folder. They are deleted on `build-clean`.
These files are generated from the `/tsconfig.commonjs.json`

View File

@@ -0,0 +1,6 @@
ESM Generated Files
===================
Do not modify the files in this folder. They are deleted on `build-clean`.
These files are generated from the `/tsconfig.esm.json`

View File

@@ -11,7 +11,7 @@
"dependencies": {
"@adraffy/ens-normalize": "1.8.9",
"@noble/hashes": "1.1.2",
"@noble/secp256k1": "1.6.3",
"@noble/secp256k1": "1.7.1",
"aes-js": "4.0.0-beta.3",
"tslib": "2.4.0",
"ws": "8.5.0"
@@ -28,6 +28,7 @@
"typescript": "4.9.5",
"uglify-js": "3.17.0"
},
"ethereum": "donations.ethers.eth",
"engines": {
"node": ">=14.0.0"
},
@@ -93,7 +94,18 @@
"types": "./types/wordlists/index.d.ts"
}
},
"gitHead": "415efbfb0474298458a7f73b5b4959ecf93c3f30",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/ethers-io/"
},
{
"type": "individual",
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"gitHead": "90afd9bd81ed1408421a0247fa0845a74c9eb319",
"homepage": "https://ethers.org",
"keywords": [
"ethereum",
"ethers",
@@ -117,9 +129,9 @@
"_dist-stats": "gzip -k9f -S '.gz' ./dist/ethers.min.js && gzip -k9f -S '.gz' ./dist/wordlists-extra.min.js && du -hs ./dist/*.gz && echo '' && du -hs ./dist/*.js",
"auto-build": "npm run build -- -w",
"build": "tsc --project tsconfig.esm.json",
"build-all": "npm run build && npm run build-commonjs && npm run build-types",
"build-all": "npm run build && cp ./output/post-build/lib.esm/* ./lib.esm/ && npm run build-commonjs && npm run build-types",
"build-clean": "npm run clean && npm run build && node lib.esm/_admin/update-version.js && npm run build-all && npm run _build-dist && npm run _dist-stats",
"build-commonjs": "tsc --project tsconfig.commonjs.json && cp ./package-commonjs.json ./lib.commonjs/package.json",
"build-commonjs": "tsc --project tsconfig.commonjs.json && cp ./output/post-build/lib.commonjs/* ./lib.commonjs/",
"build-dist": "npm run build && npm run _build-dist && npm run _dist-stats",
"build-docs": "echo 'foo'",
"build-types": "tsc --project tsconfig.types.json",

View File

@@ -137,10 +137,13 @@ const SimpleTokens: Record<string, string> = {
};
// Parser regexes to consume the next token
const regexWhitespace = new RegExp("^(\\s*)");
const regexNumber = new RegExp("^([0-9]+)");
const regexIdentifier = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)");
const regexType = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))");
const regexWhitespacePrefix = new RegExp("^(\\s*)");
const regexNumberPrefix = new RegExp("^([0-9]+)");
const regexIdPrefix = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)");
// Parser regexs to check validity
const regexId = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$");
const regexType = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");
/**
* @ignore:
@@ -293,7 +296,7 @@ function lex(text: string): TokenString {
// Strip off any leading whitespace
let cur = text.substring(offset);
let match = cur.match(regexWhitespace);
let match = cur.match(regexWhitespacePrefix);
if (match) {
offset += match[1].length;
cur = text.substring(offset);
@@ -347,7 +350,7 @@ function lex(text: string): TokenString {
continue;
}
match = cur.match(regexIdentifier);
match = cur.match(regexIdPrefix);
if (match) {
token.text = match[1];
offset += token.text.length;
@@ -366,7 +369,7 @@ function lex(text: string): TokenString {
continue;
}
match = cur.match(regexNumber);
match = cur.match(regexNumberPrefix);
if (match) {
token.text = match[1];
token.type = "NUMBER";
@@ -841,7 +844,7 @@ export class ParamType {
}
const name = obj.name;
assertArgument(!name || (typeof(name) === "string" && name.match(regexIdentifier)),
assertArgument(!name || (typeof(name) === "string" && name.match(regexId)),
"invalid name", "obj.name", name);
let indexed = obj.indexed;
@@ -1019,7 +1022,7 @@ export abstract class NamedFragment extends Fragment {
*/
constructor(guard: any, type: FragmentType, name: string, inputs: ReadonlyArray<ParamType>) {
super(guard, type, inputs);
assertArgument(typeof(name) === "string" && name.match(regexIdentifier),
assertArgument(typeof(name) === "string" && name.match(regexId),
"invalid identifier", "name", name);
inputs = Object.freeze(inputs.slice());
defineProperties<NamedFragment>(this, { name });

View File

@@ -161,6 +161,8 @@ type Sub = {
nameMap: Map<string, string>
addressableMap: WeakMap<Addressable, string>;
listeners: Array<{ listener: Listener, once: boolean }>;
// @TODO: get rid of this, as it is (and has to be)
// tracked in subscriber
started: boolean;
subscriber: Subscriber;
};

View File

@@ -44,6 +44,6 @@ export function showThrottleMessage(service: string): void {
console.log("signing up for your own API keys to improve performance, increase your");
console.log("request rate/limit and enable other perks, such as metrics and advanced APIs.");
console.log("");
console.log("For more details: https:/\/docs.ethers.io/api-keys/");
console.log("For more details: https:/\/docs.ethers.org/api-keys/");
console.log("==========================");
}

View File

@@ -27,15 +27,21 @@ export class BlockConnectionSubscriber implements Subscriber {
#provider: ConnectionRpcProvider;
#blockNumber: number;
#running: boolean;
#filterId: null | number;
constructor(provider: ConnectionRpcProvider) {
this.#provider = provider;
this.#blockNumber = -2;
this.#running = false;
this.#filterId = null;
}
start(): void {
if (this.#running) { return; }
this.#running = true;
this.#filterId = this.#provider._subscribe([ "newHeads" ], (result: any) => {
const blockNumber = getNumber(result.number);
const initial = (this.#blockNumber === -2) ? blockNumber: (this.#blockNumber + 1)
@@ -47,6 +53,9 @@ export class BlockConnectionSubscriber implements Subscriber {
}
stop(): void {
if (!this.#running) { return; }
this.#running = false;
if (this.#filterId != null) {
this.#provider._unsubscribe(this.#filterId);
this.#filterId = null;

View File

@@ -26,6 +26,8 @@ export class FilterIdSubscriber implements Subscriber {
#filterIdPromise: null | Promise<string>;
#poller: (b: number) => Promise<void>;
#running: boolean;
#network: null | Network;
#hault: boolean;
@@ -36,6 +38,8 @@ export class FilterIdSubscriber implements Subscriber {
this.#filterIdPromise = null;
this.#poller = this.#poll.bind(this);
this.#running = false;
this.#network = null;
this.#hault = false;
@@ -91,9 +95,17 @@ export class FilterIdSubscriber implements Subscriber {
}
}
start(): void { this.#poll(-2); }
start(): void {
if (this.#running) { return; }
this.#running = true;
this.#poll(-2);
}
stop(): void {
if (!this.#running) { return; }
this.#running = false;
this.#hault = true;
this.#teardown();
this.#provider.off("block", this.#poller);

View File

@@ -76,13 +76,13 @@ export class PollingBlockSubscriber implements Subscriber {
}
start(): void {
if (this.#poller) { throw new Error("subscriber already running"); }
if (this.#poller) { return; }
this.#poller = this.#provider._setTimeout(this.#poll.bind(this), this.#interval);
this.#poll();
}
stop(): void {
if (!this.#poller) { throw new Error("subscriber not running"); }
if (!this.#poller) { return; }
this.#provider._clearTimeout(this.#poller);
this.#poller = null;
}
@@ -105,9 +105,11 @@ export class PollingBlockSubscriber implements Subscriber {
export class OnBlockSubscriber implements Subscriber {
#provider: AbstractProvider;
#poll: (b: number) => void;
#running: boolean;
constructor(provider: AbstractProvider) {
this.#provider = provider;
this.#running = false;
this.#poll = (blockNumber: number) => {
this._poll(blockNumber, this.#provider);
}
@@ -118,11 +120,17 @@ export class OnBlockSubscriber implements Subscriber {
}
start(): void {
if (this.#running) { return; }
this.#running = true;
this.#poll(-2);
this.#provider.on("block", this.#poll);
}
stop(): void {
if (!this.#running) { return; }
this.#running = false;
this.#provider.off("block", this.#poll);
}
@@ -178,6 +186,8 @@ export class PollingEventSubscriber implements Subscriber {
#filter: EventFilter;
#poller: (b: number) => void;
#running: boolean;
// The most recent block we have scanned for events. The value -2
// indicates we still need to fetch an initial block number
#blockNumber: number;
@@ -186,6 +196,7 @@ export class PollingEventSubscriber implements Subscriber {
this.#provider = provider;
this.#filter = copy(filter);
this.#poller = this.#poll.bind(this);
this.#running = false;
this.#blockNumber = -2;
}
@@ -215,6 +226,9 @@ export class PollingEventSubscriber implements Subscriber {
}
start(): void {
if (this.#running) { return; }
this.#running = true;
if (this.#blockNumber === -2) {
this.#provider.getBlockNumber().then((blockNumber) => {
this.#blockNumber = blockNumber;
@@ -224,6 +238,9 @@ export class PollingEventSubscriber implements Subscriber {
}
stop(): void {
if (!this.#running) { return; }
this.#running = false;
this.#provider.off("block", this.#poller);
}

View File

@@ -1,56 +0,0 @@
/*
import { defineProperties } from "@ethersproject/properties";
export type EventCommon = "block" | "debug" | "blockObject";
export type Event = EventCommon | string | { address?: string, topics: Array<string | Array<string>> }
export type EventLike = Event | Array<string>;
export function getTag(eventName: Event): string {
if (typeof(eventName) === "string") { return eventName; }
if (typeof(eventName) === "object") {
return (eventName.address || "*") + (eventName.topics || []).map((topic) => {
if (typeof(topic) === "string") { return topic; }
return topic.join("|");
}).join("&");
}
throw new Error("FOO");
}
export function getEvent(tag: string): Event {
}
let nextId = 1;
export class Subscriber {
readonly id!: number;
readonly tag!: string;
#paused: boolean;
#blockNumber: number;
constructor(tag: string) {
this.#paused = false;
this.#blockNumber = -1;
defineProperties<Subscriber>(this, { id: nextId++, tag });
}
get blockNumber(): number {
return this.#blockNumber;
}
_setBlockNumber(blockNumber: number): void { this.#blockNumber = blockNumber; }
setup(): void { }
teardown(): void { }
isPaused(): boolean { return this.#paused; }
pause(): void { this.#paused = true; }
resume(): void { this.#paused = false; }
resubscribeInfo(): string { return this.tag; }
resubscribe(info: string): boolean { return true; }
}
*/

View File

@@ -61,11 +61,62 @@ function stringify(value: any): any {
* All errors emitted by ethers have an **ErrorCode** to help
* identify and coalesce errors to simplfy programatic analysis.
*
* _property: ``"UNKNOWN_ERROR"``
* This is a general puspose fallback when no other error makes sense
* or the error wasn't expected
* Each **ErrorCode** is the %%code%% proerty of a coresponding
* [[EthersError]].
*
* _property: ``"NOT_IMPLEMENTED"``
* **Generic Errors**
*
* **``"UNKNOWN_ERROR"``** - see [[UnknownError]]
*
* **``"NOT_IMPLEMENTED"``** - see [[NotImplementedError]]
*
* **``"UNSUPPORTED_OPERATION"``** - see [[UnsupportedOperationError]]
*
* **``"NETWORK_ERROR"``** - see [[NetworkError]]
*
* **``"SERVER_ERROR"``** - see [[ServerError]]
*
* **``"TIMEOUT"``** - see [[TimeoutError]]
*
* **``"BAD_DATA"``** - see [[BadDataError]]
*
* **``"CANCELLED"``** - see [[CancelledError]]
*
* **Operational Errors**
*
* **``"BUFFER_OVERRUN"``** - see [[BufferOverrunError]]
*
* **``"NUMERIC_FAULT"``** - see [[NumericFaultError]]
*
* **Argument Errors**
*
* **``"INVALID_ARGUMENT"``** - see [[InvalidArgumentError]]
*
* **``"MISSING_ARGUMENT"``** - see [[MissingArgumentError]]
*
* **``"UNEXPECTED_ARGUMENT"``** - see [[UnexpectedArgumentError]]
*
* **``"VALUE_MISMATCH"``** - //unused//
*
* **Blockchain Errors**
*
* **``"CALL_EXCEPTION"``** - see [[CallExceptionError]]
*
* **``"INSUFFICIENT_FUNDS"``** - see [[InsufficientFundsError]]
*
* **``"NONCE_EXPIRED"``** - see [[NonceExpiredError]]
*
* **``"REPLACEMENT_UNDERPRICED"``** - see [[ReplacementUnderpricedError]]
*
* **``"TRANSACTION_REPLACED"``** - see [[TransactionReplacedError]]
*
* **``"UNCONFIGURED_NAME"``** - see [[UnconfiguredNameError]]
*
* **``"OFFCHAIN_FAULT"``** - see [[OffchainFaultError]]
*
* **User Interaction Errors**
*
* **``"ACTION_REJECTED"``** - see [[ActionRejectedError]]
*/
export type ErrorCode =
@@ -462,7 +513,7 @@ export interface TransactionReplacedError extends EthersError<"TRANSACTION_REPLA
* been configured.
*
* This could indicate an ENS name is unowned or that the current
* address being pointed to is the [[Zero]].
* address being pointed to is the [[ZeroAddress]].
*/
export interface UnconfiguredNameError extends EthersError<"UNCONFIGURED_NAME"> {
/**
@@ -558,7 +609,7 @@ export function isError<K extends ErrorCode, T extends CodedEthersError<K>>(erro
}
/**
* Returns true if %%error%% is a [CALL_EXCEPTION](api:CallExceptionError).
* Returns true if %%error%% is a [[CallExceptionError].
*/
export function isCallException(error: any): error is CallExceptionError {
return isError(error, "CALL_EXCEPTION");

View File

@@ -177,7 +177,7 @@ export declare class Block implements BlockParams, Iterable<string> {
* prefetched them, by passing ``true`` to %%prefetchTxs%%
* into [[provider_getBlock]].
*/
get transactionResponses(): Array<TransactionResponse>;
get prefetchedTransactions(): Array<TransactionResponse>;
/**
* Returns a JSON-friendly value.
*/
@@ -195,7 +195,7 @@ export declare class Block implements BlockParams, Iterable<string> {
* Get the transaction at %%indexe%% within this block.
*/
getTransaction(indexOrHash: number | string): Promise<TransactionResponse>;
getTransactionResponse(indexOrHash: number | string): TransactionResponse;
getPrefetchedTransaction(indexOrHash: number | string): TransactionResponse;
/**
* Has this block been mined.
*

File diff suppressed because one or more lines are too long