Compare commits

..

22 Commits
v6 ... v6.0.2

Author SHA1 Message Date
Richard Moore
6c338c1c5b Fixed crossed assert in Fetch (#3733). 2023-02-04 08:25:15 -05:00
Richard Moore
8d5a13faea docs: updated post-build folder docs 2023-02-04 08:24:19 -05:00
Richard Moore
24e13fc0f2 admin: updated dist files 2023-02-04 03:26:34 -05:00
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
Richard Moore
90afd9bd81 Fixed typo in Provider changes. 2023-02-02 22:20:41 -05:00
Richard Moore
a646e4332e Provider objects cleanup. 2023-02-02 22:18:40 -05:00
Richard Moore
6cae18328d Fixed commonjs imports missing types (#3703). 2023-02-02 22:04:33 -05:00
Richard Moore
de2b1f66c6 admin: updated package description 2023-02-02 22:03:45 -05:00
Richard Moore
b3f615a1b2 admin: use default branch for CI checkouts 2023-02-02 21:34:17 -05:00
Richard Moore
0e8a34805f admin: update docs and CI for v6 release 2023-02-02 21:28:26 -05:00
254 changed files with 8846 additions and 900 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 @@ name: CI Tests
on:
push:
branches:
- v6
- main
jobs:
@@ -32,8 +32,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: "v6"
- name: Install dependencies
run: npm ci
@@ -65,8 +63,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: "v6"
- name: Install dependencies
run: npm ci
@@ -122,7 +118,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: "v6"
fetch-depth: "0"
- name: Install dependencies

7
CHANGELOG.md Normal file
View File

@@ -0,0 +1,7 @@
Changelog
=========
ethers/v6.0.0 (2023-02-02 21:19)
--------------------------------
- Initial v6 release.

View File

@@ -1,30 +1,11 @@
The Ethers Project
==================
```
This branch (i.e. v6-beta-exports) is still experimental and a
playground for new ideas for the upcoming v6 release. Please
don't use it in production yet.
To install:
npm install ethers@beta-exports
Please try it out and report any bugs you find using the v6-beta
template in the GitHub issues.
Documentation is coming, but will still take a bit of time.
In general, please be a patient as there is lots to do.
Thanks! :)
```
[![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=v6-beta-exports)](https://github.com/ethers-io/ethers.js/actions/workflows/test-ci.yml)
[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/ethers-io/ethers.js/badge)](https://www.gitpoap.io/gh/ethers-io/ethers.js)
![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/ethers/beta-exports)
[![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)
![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)
-----
@@ -43,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
@@ -57,10 +38,11 @@ For the latest news and advisories, please follow the
non-marketing, important information only) as well as watch this GitHub project.
For the latest changes, see the
[CHANGELOG](https://github.com/ethers-io/ethers.js/blob/master/CHANGELOG.md).
[CHANGELOG](https://github.com/ethers-io/ethers.js/blob/main/CHANGELOG.md).
**Summaries**
- [September 2022](https://blog.ricmoo.com/highlights-ethers-js-september-2022-d7bda0fc37ed)
- [June 2022](https://blog.ricmoo.com/highlights-ethers-js-june-2022-f5328932e35d)
- [March 2022](https://blog.ricmoo.com/highlights-ethers-js-march-2022-f511fe1e88a1)
- [December 2021](https://blog.ricmoo.com/highlights-ethers-js-december-2021-dc1adb779d1a)
@@ -77,7 +59,7 @@ Installing
**NodeJS**
```
/home/ricmoo/some_project> npm install ethers@beta-exports
/home/ricmoo/some_project> npm install ethers
```
**Browser (ESM)**
@@ -94,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/v5/getting-started/)
- [Full API Documentation](https://docs.ethers.io/v5/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/)
@@ -121,12 +101,13 @@ 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:
- [Ankr](https://www.ankr.com/)
- [QuickNode](https://www.quicknode.com/)
- [Etherscan](https://etherscan.io/)
- [INFURA](https://infura.io/)
- [Alchemy](https://dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d)

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.

691
dist/ethers.js vendored

File diff suppressed because it is too large Load Diff

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

View File

@@ -145,7 +145,7 @@ const u64 = {
add, add3L, add3H, add4L, add4H, add5H, add5L,
};
const version = "6.0.0";
const version = "6.0.1";
/**
* Property helper functions.

File diff suppressed because one or more lines are too long

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

@@ -1,20 +1,4 @@
_section: Documentation (BETA) @<about-home> @nav<Documentation>
**NOTE:** This documentation is for the **beta branch** (i.e. ``v6-beta-exports``), which
is still undergoing minor changes.
To try it out:
_code:
/home/ricmoo> npm install ethers@beta-exports
_null:
Please [report any v6 issues](link-issue) and I will get to them right away.
If you are looking v5 docs, please see the [v5 documentation here](link-docs-v5).
_subsection: What is Ethers?
_section: Documentation @<about-home> @nav<Documentation>
The ethers.js library aims to be a complete and compact library
for interacting with the Ethereum Blockchain and its ecosystem.
@@ -24,6 +8,7 @@ wallets (such as [[link-metamask]] and [[link-tally]]) and
other tools and simple scripts that require reading and writing
to the blockchain.
_subsection: About this documentation?
These docs are still under construction, and are being expanded
@@ -32,4 +17,12 @@ every day.
Developers new to Ethers shoud be sure to read through the
[[getting-started]] section.
And the [[about-api]] is available for drilling down into more details.
And the [[about-api]] is available for drilling down into more details
about the entire Application Programming Interface.
_subsection: Older Documentation
- [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).

6
lib.commonjs/README.md Normal file
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,84 @@
export type TestBlockchainNetwork = "mainnet" | "goerli";
export interface TestBlockchainAddress {
test: string;
address: string;
code?: string;
nonce?: number;
name?: string;
balance?: bigint;
storage?: Record<string, string>;
}
export interface TestBlockchainBlock {
test: string;
hash: string;
parentHash: string;
number: number;
timestamp: number;
nonce: string;
difficulty: bigint;
gasLimit: bigint;
gasUsed: bigint;
miner: string;
extraData: string;
transactions: Array<string>;
baseFeePerGas?: bigint;
}
export interface TestBlockchainTransaction {
test: string;
hash: string;
blockHash: string;
blockNumber: number;
type: number;
from: string;
gasPrice: bigint;
gasLimit: bigint;
to: string;
value: bigint;
nonce: number;
data: string;
signature: {
r: string;
s: string;
yParity: 0 | 1;
v: number;
networkV: null | bigint;
};
creates: null | string;
chainId: bigint;
accessList?: Array<Record<string, Array<string>>>;
maxPriorityFeePerGas?: bigint;
maxFeePerGas?: bigint;
}
export interface TestBlockchainReceipt {
test: string;
blockHash: string;
blockNumber: number;
type: number;
contractAddress: null | string;
cumulativeGasUsed: bigint;
from: string;
gasUsed: bigint;
gasPrice: bigint;
logs: Array<{
address: string;
blockHash: string;
blockNumber: number;
data: string;
index: number;
topics: Array<string>;
transactionHash: string;
transactionIndex: number;
}>;
logsBloom: string;
root: null | string;
status: null | number;
to: string;
hash: string;
index: number;
}
export declare const testAddress: Record<TestBlockchainNetwork, Array<TestBlockchainAddress>>;
export declare const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>>;
export declare const testTransaction: Record<TestBlockchainNetwork, Array<TestBlockchainTransaction>>;
export declare const testReceipt: Record<TestBlockchainNetwork, Array<TestBlockchainReceipt>>;
export declare const networkNames: Array<TestBlockchainNetwork>;
export declare function networkFeatureAtBlock(feature: string, block: number): boolean;

View File

@@ -0,0 +1,7 @@
import type { AbstractProvider } from "../index.js";
export declare function setupProviders(): void;
export declare const providerNames: readonly string[];
export declare function getProviderNetworks(provider: string): Array<string>;
export declare function getProvider(provider: string, network: string): null | AbstractProvider;
export declare function checkProvider(provider: string, network: string): boolean;
export declare function connect(network: string): AbstractProvider;

1
lib.commonjs/_tests/test-abi.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-address.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-crypto.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-hash.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-rlp.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,12 @@
export type TestCaseBadString = {
name: string;
bytes: Uint8Array;
ignore: string;
replace: string;
error: string;
};
export type TestCaseCodePoints = {
name: string;
text: string;
codepoints: Array<number>;
};

View File

@@ -0,0 +1,6 @@
declare global {
class TextDecoder {
decode(data: Uint8Array): string;
}
}
export {};

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

1
lib.commonjs/_tests/test-wallet.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export {};

216
lib.commonjs/_tests/types.d.ts vendored Normal file
View File

@@ -0,0 +1,216 @@
export type TestCaseAbiVerbose = {
type: "address" | "hexstring" | "number" | "string";
value: string;
} | {
type: "boolean";
value: boolean;
} | {
type: "array";
value: Array<TestCaseAbiVerbose>;
} | {
type: "object";
value: Array<TestCaseAbiVerbose>;
};
export interface TestCaseAbi {
name: string;
type: string;
value: any;
verbose: TestCaseAbiVerbose;
bytecode: string;
encoded: string;
}
export interface TestCaseAccount {
name: string;
privateKey: string;
address: string;
icap: string;
}
export type TestCaseCreate = {
sender: string;
creates: Array<{
name: string;
nonce: number;
address: string;
}>;
};
export type TestCaseCreate2 = {
sender: string;
creates: Array<{
name: string;
salt: string;
initCode: string;
initCodeHash: string;
address: string;
}>;
};
export interface TestCaseHash {
name: string;
data: string;
sha256: string;
sha512: string;
ripemd160: string;
keccak256: string;
}
export interface TestCasePbkdf {
name: string;
password: string;
salt: string;
dkLen: number;
pbkdf2: {
iterations: number;
algorithm: "sha256" | "sha512";
key: string;
};
scrypt: {
N: number;
r: number;
p: number;
key: string;
};
}
export interface TestCaseHmac {
name: string;
data: string;
key: string;
algorithm: "sha256" | "sha512";
hmac: string;
}
export interface TestCaseHash {
name: string;
data: string;
sha256: string;
sha512: string;
ripemd160: string;
keccak256: string;
}
export interface TestCaseNamehash {
name: string;
ensName: string;
error?: string;
namehash?: string;
}
export interface TestCaseTypedDataDomain {
name?: string;
version?: string;
chainId?: number;
verifyingContract?: string;
salt?: string;
}
export interface TestCaseTypedDataType {
name: string;
type: string;
}
export interface TestCaseTypedData {
name: string;
domain: TestCaseTypedDataDomain;
primaryType: string;
types: Record<string, Array<TestCaseTypedDataType>>;
data: any;
encoded: string;
digest: string;
privateKey?: string;
signature?: string;
}
export interface TestCaseSolidityHash {
name: string;
types: Array<string>;
keccak256: string;
ripemd160: string;
sha256: string;
values: Array<any>;
}
export interface TestCaseUnit {
name: string;
wei: string;
ethers: string;
ether_format: string;
kwei?: string;
mwei?: string;
gwei?: string;
szabo?: string;
finney?: string;
finney_format?: string;
szabo_format?: string;
gwei_format?: string;
mwei_format?: string;
kwei_format?: string;
}
export type NestedHexString = string | Array<string | NestedHexString>;
export interface TestCaseRlp {
name: string;
encoded: string;
decoded: NestedHexString;
}
export interface TestCaseTransactionTx {
to?: string;
nonce?: number;
gasLimit?: string;
gasPrice?: string;
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
data?: string;
value?: string;
accessList?: Array<{
address: string;
storageKeys: Array<string>;
}>;
chainId?: string;
}
export interface TestCaseTransactionSig {
r: string;
s: string;
v: string;
}
export interface TestCaseTransaction {
name: string;
transaction: TestCaseTransactionTx;
privateKey: string;
unsignedLegacy: string;
signedLegacy: string;
unsignedEip155: string;
signedEip155: string;
unsignedBerlin: string;
signedBerlin: string;
unsignedLondon: string;
signedLondon: string;
signatureLegacy: TestCaseTransactionSig;
signatureEip155: TestCaseTransactionSig;
signatureBerlin: TestCaseTransactionSig;
signatureLondon: TestCaseTransactionSig;
}
export interface TestCaseMnemonicNode {
path: string;
chainCode: string;
depth: number;
index: number;
parentFingerprint: string;
fingerprint: string;
publicKey: string;
privateKey: string;
xpriv: string;
xpub: string;
}
export interface TestCaseMnemonic {
name: string;
phrase: string;
phraseHash: string;
password: string;
locale: string;
entropy: string;
seed: string;
nodes: Array<TestCaseMnemonicNode>;
}
export interface TestCaseWallet {
name: string;
filename: string;
type: string;
address: string;
password: string;
content: string;
}
export interface TestCaseWordlist {
name: string;
filename: string;
locale: string;
content: string;
}

8
lib.commonjs/_tests/utils.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
export declare function loadTests<T>(tag: string): Array<T>;
export declare function log(context: any, text: string): void;
export declare function stall(duration: number): Promise<void>;
export interface MochaRunnable {
timeout: (value: number) => void;
skip: () => void;
}
export declare function retryIt(name: string, func: (this: MochaRunnable) => Promise<void>): Promise<void>;

1
lib.commonjs/_version.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export declare const version: string;

View File

@@ -1,5 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "6.0.0";
exports.version = "6.0.1";
//# sourceMappingURL=_version.js.map

58
lib.commonjs/abi/abi-coder.d.ts vendored Normal file
View File

@@ -0,0 +1,58 @@
/**
* When sending values to or receiving values from a [[Contract]], the
* data is generally encoded using the [ABI standard](solc-abi-standard).
*
* The AbiCoder provides a utility to encode values to ABI data and
* decode values from ABI data.
*
* Most of the time, developers should favour the [[Contract]] class,
* which further abstracts a lot of the finer details of ABI data.
*
* @_section api/abi/abi-coder:ABI Encoding
*/
import { Result } from "./coders/abstract-coder.js";
import { ParamType } from "./fragments.js";
import type { BytesLike, CallExceptionAction, CallExceptionError } from "../utils/index.js";
/**
* About AbiCoder
*/
export declare class AbiCoder {
#private;
/**
* Get the default values for the given %%types%%.
*
* For example, a ``uint`` is by default ``0`` and ``bool``
* is by default ``false``.
*/
getDefaultValue(types: ReadonlyArray<string | ParamType>): Result;
/**
* Encode the %%values%% as the %%types%% into ABI data.
*
* @returns DataHexstring
*/
encode(types: ReadonlyArray<string | ParamType>, values: ReadonlyArray<any>): string;
/**
* Decode the ABI %%data%% as the %%types%% into values.
*
* If %%loose%% decoding is enabled, then strict padding is
* not enforced. Some older versions of Solidity incorrectly
* padded event data emitted from ``external`` functions.
*/
decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
/**
* Returns the shared singleton instance of a default [[AbiCoder]].
*
* On the first call, the instance is created internally.
*/
static defaultAbiCoder(): AbiCoder;
/**
* Returns an ethers-compatible [[CALL_EXCEPTION]] Error for the given
* result %%data%% for the [[CallExceptionAction]] %%action%% against
* the Transaction %%tx%%.
*/
static getBuiltinCallException(action: CallExceptionAction, tx: {
to?: null | string;
from?: null | string;
data?: string;
}, data: null | BytesLike): CallExceptionError;
}

14
lib.commonjs/abi/bytes32.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
/**
* About bytes32 strings...
*
* @_docloc: api/utils:Bytes32 Strings
*/
import type { BytesLike } from "../utils/index.js";
/**
* Encodes %%text%% as a Bytes32 string.
*/
export declare function encodeBytes32String(text: string): string;
/**
* Encodes the Bytes32-encoded %%bytes%% into a string.
*/
export declare function decodeBytes32String(_bytes: BytesLike): string;

View File

@@ -0,0 +1,116 @@
import type { BigNumberish, BytesLike } from "../../utils/index.js";
/**
* @_ignore:
*/
export declare const WordSize: number;
/**
* A [[Result]] is a sub-class of Array, which allows accessing any
* of its values either positionally by its index or, if keys are
* provided by its name.
*
* @_docloc: api/abi
*/
export declare class Result extends Array<any> {
#private;
[K: string | number]: any;
/**
* @private
*/
constructor(...args: Array<any>);
/**
* Returns the Result as a normal Array.
*
* This will throw if there are any outstanding deferred
* errors.
*/
toArray(): Array<any>;
/**
* Returns the Result as an Object with each name-value pair.
*
* This will throw if any value is unnamed, or if there are
* any outstanding deferred errors.
*/
toObject(): Record<string, any>;
/**
* @_ignore
*/
slice(start?: number | undefined, end?: number | undefined): Result;
/**
* @_ignore
*/
filter(callback: (el: any, index: number, array: Result) => boolean, thisArg?: any): Result;
/**
* Returns the value for %%name%%.
*
* Since it is possible to have a key whose name conflicts with
* a method on a [[Result]] or its superclass Array, or any
* JavaScript keyword, this ensures all named values are still
* accessible by name.
*/
getValue(name: string): any;
/**
* Creates a new [[Result]] for %%items%% with each entry
* also accessible by its corresponding name in %%keys%%.
*/
static fromItems(items: Array<any>, keys?: Array<null | string>): Result;
}
/**
* Returns all errors found in a [[Result]].
*
* Since certain errors encountered when creating a [[Result]] do
* not impact the ability to continue parsing data, they are
* deferred until they are actually accessed. Hence a faulty string
* in an Event that is never used does not impact the program flow.
*
* However, sometimes it may be useful to access, identify or
* validate correctness of a [[Result]].
*
* @_docloc api/abi
*/
export declare function checkResultErrors(result: Result): Array<{
path: Array<string | number>;
error: Error;
}>;
/**
* @_ignore
*/
export declare abstract class Coder {
readonly name: string;
readonly type: string;
readonly localName: string;
readonly dynamic: boolean;
constructor(name: string, type: string, localName: string, dynamic: boolean);
_throwError(message: string, value: any): never;
abstract encode(writer: Writer, value: any): number;
abstract decode(reader: Reader): any;
abstract defaultValue(): any;
}
/**
* @_ignore
*/
export declare class Writer {
#private;
constructor();
get data(): string;
get length(): number;
appendWriter(writer: Writer): number;
writeBytes(value: BytesLike): number;
writeValue(value: BigNumberish): number;
writeUpdatableValue(): (value: BigNumberish) => void;
}
/**
* @_ignore
*/
export declare class Reader {
#private;
readonly allowLoose: boolean;
constructor(data: BytesLike, allowLoose?: boolean);
get data(): string;
get dataLength(): number;
get consumed(): number;
get bytes(): Uint8Array;
subReader(offset: number): Reader;
readBytes(length: number, loose?: boolean): Uint8Array;
readValue(): bigint;
readIndex(): number;
}

12
lib.commonjs/abi/coders/address.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class AddressCoder extends Coder {
constructor(localName: string);
defaultValue(): string;
encode(writer: Writer, _value: string | Typed): number;
decode(reader: Reader): any;
}

14
lib.commonjs/abi/coders/anonymous.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* Clones the functionality of an existing Coder, but without a localName
*
* @_ignore
*/
export declare class AnonymousCoder extends Coder {
private coder;
constructor(coder: Coder);
defaultValue(): any;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

24
lib.commonjs/abi/coders/array.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
import { Typed } from "../typed.js";
import { Coder, Result, Writer } from "./abstract-coder.js";
import type { Reader } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare function pack(writer: Writer, coders: ReadonlyArray<Coder>, values: Array<any> | {
[name: string]: any;
}): number;
/**
* @_ignore
*/
export declare function unpack(reader: Reader, coders: ReadonlyArray<Coder>): Result;
/**
* @_ignore
*/
export declare class ArrayCoder extends Coder {
readonly coder: Coder;
readonly length: number;
constructor(coder: Coder, length: number, localName: string);
defaultValue(): Array<any>;
encode(writer: Writer, _value: Array<any> | Typed): number;
decode(reader: Reader): any;
}

12
lib.commonjs/abi/coders/boolean.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class BooleanCoder extends Coder {
constructor(localName: string);
defaultValue(): boolean;
encode(writer: Writer, _value: boolean | Typed): number;
decode(reader: Reader): any;
}

18
lib.commonjs/abi/coders/bytes.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class DynamicBytesCoder extends Coder {
constructor(type: string, localName: string);
defaultValue(): string;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}
/**
* @_ignore
*/
export declare class BytesCoder extends DynamicBytesCoder {
constructor(localName: string);
decode(reader: Reader): any;
}

View File

@@ -0,0 +1,14 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { BytesLike } from "../../utils/index.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class FixedBytesCoder extends Coder {
readonly size: number;
constructor(size: number, localName: string);
defaultValue(): string;
encode(writer: Writer, _value: BytesLike | Typed): number;
decode(reader: Reader): any;
}

11
lib.commonjs/abi/coders/null.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class NullCoder extends Coder {
constructor(localName: string);
defaultValue(): null;
encode(writer: Writer, value: any): number;
decode(reader: Reader): any;
}

15
lib.commonjs/abi/coders/number.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { BigNumberish } from "../../utils/index.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class NumberCoder extends Coder {
readonly size: number;
readonly signed: boolean;
constructor(size: number, signed: boolean, localName: string);
defaultValue(): number;
encode(writer: Writer, _value: BigNumberish | Typed): number;
decode(reader: Reader): any;
}

12
lib.commonjs/abi/coders/string.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Typed } from "../typed.js";
import { DynamicBytesCoder } from "./bytes.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class StringCoder extends DynamicBytesCoder {
constructor(localName: string);
defaultValue(): string;
encode(writer: Writer, _value: string | Typed): number;
decode(reader: Reader): any;
}

15
lib.commonjs/abi/coders/tuple.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
import { Typed } from "../typed.js";
import { Coder } from "./abstract-coder.js";
import type { Reader, Writer } from "./abstract-coder.js";
/**
* @_ignore
*/
export declare class TupleCoder extends Coder {
readonly coders: ReadonlyArray<Coder>;
constructor(coders: Array<Coder>, localName: string);
defaultValue(): any;
encode(writer: Writer, _value: Array<any> | {
[name: string]: any;
} | Typed): number;
decode(reader: Reader): any;
}

372
lib.commonjs/abi/fragments.d.ts vendored Normal file
View File

@@ -0,0 +1,372 @@
/**
* About frgaments...
*
* @_subsection api/abi/abi-coder:Fragments
*/
/**
* A type description in a JSON API.
*/
export interface JsonFragmentType {
/**
* The parameter name.
*/
readonly name?: string;
/**
* If the parameter is indexed.
*/
readonly indexed?: boolean;
/**
* The type of the parameter.
*/
readonly type?: string;
/**
* The internal Solidity type.
*/
readonly internalType?: string;
/**
* The components for a tuple.
*/
readonly components?: ReadonlyArray<JsonFragmentType>;
}
/**
* A fragment for a method, event or error in a JSON API.
*/
export interface JsonFragment {
/**
* The name of the error, event, function, etc.
*/
readonly name?: string;
/**
* The type of the fragment (e.g. ``event``, ``"function"``, etc.)
*/
readonly type?: string;
/**
* If the event is anonymous.
*/
readonly anonymous?: boolean;
/**
* If the function is payable.
*/
readonly payable?: boolean;
/**
* If the function is constant.
*/
readonly constant?: boolean;
/**
* The mutability state of the function.
*/
readonly stateMutability?: string;
/**
* The input parameters.
*/
readonly inputs?: ReadonlyArray<JsonFragmentType>;
/**
* The output parameters.
*/
readonly outputs?: ReadonlyArray<JsonFragmentType>;
/**
* The gas limit to use when sending a transaction for this function.
*/
readonly gas?: string;
}
/**
* The format to serialize the output as.
*/
export type FormatType = "sighash" | "minimal" | "full" | "json";
/**
* When [walking](ParamType-walk) a [[ParamType]], this is called
* on each component.
*/
export type ParamTypeWalkFunc = (type: string, value: any) => any;
/**
* When [walking asynchronously](ParamType-walkAsync) a [[ParamType]],
* this is called on each component.
*/
export type ParamTypeWalkAsyncFunc = (type: string, value: any) => any | Promise<any>;
/**
* Each input and output of a [[Fragment]] is an Array of **PAramType**.
*/
export declare class ParamType {
#private;
/**
* The local name of the parameter (or ``""`` if unbound)
*/
readonly name: string;
/**
* The fully qualified type (e.g. ``"address"``, ``"tuple(address)"``,
* ``"uint256[3][]"``)
*/
readonly type: string;
/**
* The base type (e.g. ``"address"``, ``"tuple"``, ``"array"``)
*/
readonly baseType: string;
/**
* True if the parameters is indexed.
*
* For non-indexable types (see [[ParamType_isIndexable]]) this
* is ``null``.
*/
readonly indexed: null | boolean;
/**
* The components for the tuple.
*
* For non-tuple types (see [[ParamType_isTuple]]) this is ``null``.
*/
readonly components: null | ReadonlyArray<ParamType>;
/**
* The array length, or ``-1`` for dynamic-lengthed arrays.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
*/
readonly arrayLength: null | number;
/**
* The type of each child in the array.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
*/
readonly arrayChildren: null | ParamType;
/**
* @private
*/
constructor(guard: any, name: string, type: string, baseType: string, indexed: null | boolean, components: null | ReadonlyArray<ParamType>, arrayLength: null | number, arrayChildren: null | ParamType);
/**
* Return a string representation of this type.
*
* For example,
*
* ``sighash" => "(uint256,address)"``
*
* ``"minimal" => "tuple(uint256,address) indexed"``
*
* ``"full" => "tuple(uint256 foo, address bar) indexed baz"``
*/
format(format?: FormatType): string;
/**
* Returns true if %%this%% is an Array type.
*
* This provides a type gaurd ensuring that [[arrayChildren]]
* and [[arrayLength]] are non-null.
*/
isArray(): this is (ParamType & {
arrayChildren: ParamType;
arrayLength: number;
});
/**
* Returns true if %%this%% is a Tuple type.
*
* This provides a type gaurd ensuring that [[components]]
* is non-null.
*/
isTuple(): this is (ParamType & {
components: ReadonlyArray<ParamType>;
});
/**
* Returns true if %%this%% is an Indexable type.
*
* This provides a type gaurd ensuring that [[indexed]]
* is non-null.
*/
isIndexable(): this is (ParamType & {
indexed: boolean;
});
/**
* Walks the **ParamType** with %%value%%, calling %%process%%
* on each type, destructing the %%value%% recursively.
*/
walk(value: any, process: ParamTypeWalkFunc): any;
/**
* Walks the **ParamType** with %%value%%, asynchronously calling
* %%process%% on each type, destructing the %%value%% recursively.
*
* This can be used to resolve ENS naes by walking and resolving each
* ``"address"`` type.
*/
walkAsync(value: any, process: ParamTypeWalkAsyncFunc): Promise<any>;
/**
* Creates a new **ParamType** for %%obj%%.
*
* If %%allowIndexed%% then the ``indexed`` keyword is permitted,
* otherwise the ``indexed`` keyword will throw an error.
*/
static from(obj: any, allowIndexed?: boolean): ParamType;
/**
* Returns true if %%value%% is a **ParamType**.
*/
static isParamType(value: any): value is ParamType;
}
/**
* The type of a [[Fragment]].
*/
export type FragmentType = "constructor" | "error" | "event" | "fallback" | "function" | "struct";
/**
* An abstract class to represent An individual fragment from a parse ABI.
*/
export declare abstract class Fragment {
/**
* The type of the fragment.
*/
readonly type: FragmentType;
/**
* The inputs for the fragment.
*/
readonly inputs: ReadonlyArray<ParamType>;
/**
* @private
*/
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>);
/**
* Returns a string representation of this fragment.
*/
abstract format(format?: FormatType): string;
/**
* Creates a new **Fragment** for %%obj%%, wich can be any supported
* ABI frgament type.
*/
static from(obj: any): Fragment;
/**
* Returns true if %%value%% is a [[ConstructorFragment]].
*/
static isConstructor(value: any): value is ConstructorFragment;
/**
* Returns true if %%value%% is an [[ErrorFragment]].
*/
static isError(value: any): value is ErrorFragment;
/**
* Returns true if %%value%% is an [[EventFragment]].
*/
static isEvent(value: any): value is EventFragment;
/**
* Returns true if %%value%% is a [[FunctionFragment]].
*/
static isFunction(value: any): value is FunctionFragment;
/**
* Returns true if %%value%% is a [[StructFragment]].
*/
static isStruct(value: any): value is StructFragment;
}
/**
* An abstract class to represent An individual fragment
* which has a name from a parse ABI.
*/
export declare abstract class NamedFragment extends Fragment {
/**
* The name of the fragment.
*/
readonly name: string;
/**
* @private
*/
constructor(guard: any, type: FragmentType, name: string, inputs: ReadonlyArray<ParamType>);
}
/**
* A Fragment which represents a //Custom Error//.
*/
export declare class ErrorFragment extends NamedFragment {
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>);
/**
* The Custom Error selector.
*/
get selector(): string;
format(format?: FormatType): string;
static from(obj: any): ErrorFragment;
static isFragment(value: any): value is ErrorFragment;
}
/**
* A Fragment which represents an Event.
*/
export declare class EventFragment extends NamedFragment {
readonly anonymous: boolean;
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>, anonymous: boolean);
/**
* The Event topic hash.
*/
get topicHash(): string;
format(format?: FormatType): string;
static getTopicHash(name: string, params?: Array<any>): string;
static from(obj: any): EventFragment;
static isFragment(value: any): value is EventFragment;
}
/**
* A Fragment which represents a constructor.
*/
export declare class ConstructorFragment extends Fragment {
readonly payable: boolean;
readonly gas: null | bigint;
/**
* @private
*/
constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>, payable: boolean, gas: null | bigint);
format(format?: FormatType): string;
static from(obj: any): ConstructorFragment;
static isFragment(value: any): value is ConstructorFragment;
}
/**
* A Fragment which represents a method.
*/
export declare class FallbackFragment extends Fragment {
/**
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
constructor(guard: any, inputs: ReadonlyArray<ParamType>, payable: boolean);
format(format?: FormatType): string;
static from(obj: any): FallbackFragment;
static isFragment(value: any): value is FallbackFragment;
}
/**
* A Fragment which represents a method.
*/
export declare class FunctionFragment extends NamedFragment {
/**
* If the function is constant (e.g. ``pure`` or ``view`` functions).
*/
readonly constant: boolean;
/**
* The returned types for the result of calling this function.
*/
readonly outputs: ReadonlyArray<ParamType>;
/**
* The state mutability (e.g. ``payable``, ``nonpayable``, ``view``
* or ``pure``)
*/
readonly stateMutability: "payable" | "nonpayable" | "view" | "pure";
/**
* If the function can be sent value during invocation.
*/
readonly payable: boolean;
/**
* The amount of gas to send when calling this function
*/
readonly gas: null | bigint;
/**
* @private
*/
constructor(guard: any, name: string, stateMutability: "payable" | "nonpayable" | "view" | "pure", inputs: ReadonlyArray<ParamType>, outputs: ReadonlyArray<ParamType>, gas: null | bigint);
/**
* The Function selector.
*/
get selector(): string;
format(format?: FormatType): string;
static getSelector(name: string, params?: Array<any>): string;
static from(obj: any): FunctionFragment;
static isFragment(value: any): value is FunctionFragment;
}
/**
* A Fragment which represents a structure.
*/
export declare class StructFragment extends NamedFragment {
/**
* @private
*/
constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>);
format(): string;
static from(obj: any): StructFragment;
static isFragment(value: any): value is FunctionFragment;
}

View File

@@ -33,10 +33,12 @@ const SimpleTokens = {
",": "COMMA", "@": "AT"
};
// 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]*))$");
class TokenString {
#offset;
#tokens;
@@ -145,7 +147,7 @@ function lex(text) {
while (offset < text.length) {
// 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);
@@ -194,7 +196,7 @@ function lex(text) {
}
continue;
}
match = cur.match(regexIdentifier);
match = cur.match(regexIdPrefix);
if (match) {
token.text = match[1];
offset += token.text.length;
@@ -209,7 +211,7 @@ function lex(text) {
token.type = "ID";
continue;
}
match = cur.match(regexNumber);
match = cur.match(regexNumberPrefix);
if (match) {
token.text = match[1];
token.type = "NUMBER";
@@ -654,7 +656,7 @@ class ParamType {
return new ParamType(_guard, name, type, baseType, indexed, comps, arrayLength, arrayChildren);
}
const name = obj.name;
(0, index_js_1.assertArgument)(!name || (typeof (name) === "string" && name.match(regexIdentifier)), "invalid name", "obj.name", name);
(0, index_js_1.assertArgument)(!name || (typeof (name) === "string" && name.match(regexId)), "invalid name", "obj.name", name);
let indexed = obj.indexed;
if (indexed != null) {
(0, index_js_1.assertArgument)(allowIndexed, "parameter cannot be indexed", "obj.indexed", obj.indexed);
@@ -799,7 +801,7 @@ class NamedFragment extends Fragment {
*/
constructor(guard, type, name, inputs) {
super(guard, type, inputs);
(0, index_js_1.assertArgument)(typeof (name) === "string" && name.match(regexIdentifier), "invalid identifier", "name", name);
(0, index_js_1.assertArgument)(typeof (name) === "string" && name.match(regexId), "invalid identifier", "name", name);
inputs = Object.freeze(inputs.slice());
(0, index_js_1.defineProperties)(this, { name });
}

File diff suppressed because one or more lines are too long

13
lib.commonjs/abi/index.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
/**
* Explain about ABI here...
*
* @_section api/abi:Application Binary Interface [abi]
* @_navTitle: ABI
*/
export { AbiCoder } from "./abi-coder.js";
export { decodeBytes32String, encodeBytes32String } from "./bytes32.js";
export { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, NamedFragment, ParamType, StructFragment, } from "./fragments.js";
export { checkResultErrors, Indexed, Interface, ErrorDescription, LogDescription, TransactionDescription, Result } from "./interface.js";
export { Typed } from "./typed.js";
export type { JsonFragment, JsonFragmentType, FormatType, FragmentType, ParamTypeWalkAsyncFunc, ParamTypeWalkFunc } from "./fragments.js";
export type { InterfaceAbi, } from "./interface.js";

253
lib.commonjs/abi/interface.d.ts vendored Normal file
View File

@@ -0,0 +1,253 @@
/**
* About Interface
*
* @_subsection api/abi:Interfaces [interfaces]
*/
import { AbiCoder } from "./abi-coder.js";
import { checkResultErrors, Result } from "./coders/abstract-coder.js";
import { ConstructorFragment, ErrorFragment, EventFragment, FallbackFragment, Fragment, FunctionFragment, ParamType } from "./fragments.js";
import { Typed } from "./typed.js";
import type { BigNumberish, BytesLike, CallExceptionError, CallExceptionTransaction } from "../utils/index.js";
import type { JsonFragment } from "./fragments.js";
export { checkResultErrors, Result };
export declare class LogDescription {
readonly fragment: EventFragment;
readonly name: string;
readonly signature: string;
readonly topic: string;
readonly args: Result;
constructor(fragment: EventFragment, topic: string, args: Result);
}
export declare class TransactionDescription {
readonly fragment: FunctionFragment;
readonly name: string;
readonly args: Result;
readonly signature: string;
readonly selector: string;
readonly value: bigint;
constructor(fragment: FunctionFragment, selector: string, args: Result, value: bigint);
}
export declare class ErrorDescription {
readonly fragment: ErrorFragment;
readonly name: string;
readonly args: Result;
readonly signature: string;
readonly selector: string;
constructor(fragment: ErrorFragment, selector: string, args: Result);
}
export declare class Indexed {
readonly hash: null | string;
readonly _isIndexed: boolean;
static isIndexed(value: any): value is Indexed;
constructor(hash: null | string);
}
/**
* @TODO
*/
export type InterfaceAbi = string | ReadonlyArray<Fragment | JsonFragment | string>;
/**
* An Interface abstracts many of the low-level details for
* encoding and decoding the data on the blockchain.
*
* An ABI provides information on how to encode data to send to
* a Contract, how to decode the results and events and how to
* interpret revert errors.
*
* The ABI can be specified by [any supported format](InterfaceAbi).
*/
export declare class Interface {
#private;
/**
* All the Contract ABI members (i.e. methods, events, errors, etc).
*/
readonly fragments: ReadonlyArray<Fragment>;
/**
* The Contract constructor.
*/
readonly deploy: ConstructorFragment;
/**
* The Fallback method, if any.
*/
readonly fallback: null | FallbackFragment;
/**
* If receiving ether is supported.
*/
readonly receive: boolean;
/**
* Create a new Interface for the %%fragments%%.
*/
constructor(fragments: InterfaceAbi);
/**
* Returns the entire Human-Readable ABI, as an array of
* signatures, optionally as %%minimal%% strings, which
* removes parameter names and unneceesary spaces.
*/
format(minimal?: boolean): Array<string>;
/**
* Return the JSON-encoded ABI. This is the format Solidiy
* returns.
*/
formatJson(): string;
/**
* The ABI coder that will be used to encode and decode binary
* data.
*/
getAbiCoder(): AbiCoder;
/**
* Get the function name for %%key%%, which may be a function selector,
* function name or function signature that belongs to the ABI.
*/
getFunctionName(key: string): string;
/**
* Get the [[FunctionFragment]] for %%key%%, which may be a function
* selector, function name or function signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple functions match by name.
*
* If the %%key%% and %%values%% do not refine to a single function in
* the ABI, this will throw.
*/
getFunction(key: string, values?: Array<any | Typed>): null | FunctionFragment;
/**
* Iterate over all functions, calling %%callback%%, sorted by their name.
*/
forEachFunction(callback: (func: FunctionFragment, index: number) => void): void;
/**
* Get the event name for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*/
getEventName(key: string): string;
/**
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple events match by name.
*
* If the %%key%% and %%values%% do not refine to a single event in
* the ABI, this will throw.
*/
getEvent(key: string, values?: Array<any | Typed>): null | EventFragment;
/**
* Iterate over all events, calling %%callback%%, sorted by their name.
*/
forEachEvent(callback: (func: EventFragment, index: number) => void): void;
/**
* Get the [[ErrorFragment]] for %%key%%, which may be an error
* selector, error name or error signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple errors match by name.
*
* If the %%key%% and %%values%% do not refine to a single error in
* the ABI, this will throw.
*/
getError(key: string, values?: Array<any | Typed>): null | ErrorFragment;
/**
* Iterate over all errors, calling %%callback%%, sorted by their name.
*/
forEachError(callback: (func: ErrorFragment, index: number) => void): void;
_decodeParams(params: ReadonlyArray<ParamType>, data: BytesLike): Result;
_encodeParams(params: ReadonlyArray<ParamType>, values: ReadonlyArray<any>): string;
/**
* Encodes a ``tx.data`` object for deploying the Contract with
* the %%values%% as the constructor arguments.
*/
encodeDeploy(values?: ReadonlyArray<any>): string;
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified error (see [[getError]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeErrorResult(fragment: ErrorFragment | string, data: BytesLike): Result;
/**
* Encodes the transaction revert data for a call result that
* reverted from the the Contract with the sepcified %%error%%
* (see [[getError]] for valid values for %%fragment%%) with the %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeErrorResult(fragment: ErrorFragment | string, values?: ReadonlyArray<any>): string;
/**
* Decodes the %%data%% from a transaction ``tx.data`` for
* the function specified (see [[getFunction]] for valid values
* for %%fragment%%).
*
* Most developers should prefer the [[parseTransaction]] method
* instead, which will automatically detect the fragment.
*/
decodeFunctionData(fragment: FunctionFragment | string, data: BytesLike): Result;
/**
* Encodes the ``tx.data`` for a transaction that calls the function
* specified (see [[getFunction]] for valid values for %%fragment%%) with
* the %%values%%.
*/
encodeFunctionData(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeFunctionResult(fragment: FunctionFragment | string, data: BytesLike): Result;
makeError(_data: BytesLike, tx: CallExceptionTransaction): CallExceptionError;
/**
* Encodes the result data (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values
* for %%fragment%%) with %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeFunctionResult(fragment: FunctionFragment | string, values?: ReadonlyArray<any>): string;
encodeFilterTopics(fragment: EventFragment | string, values: ReadonlyArray<any>): Array<null | string | Array<string>>;
encodeEventLog(fragment: EventFragment | string, values: ReadonlyArray<any>): {
data: string;
topics: Array<string>;
};
decodeEventLog(fragment: EventFragment | string, data: BytesLike, topics?: ReadonlyArray<string>): Result;
/**
* Parses a transaction, finding the matching function and extracts
* the parameter values along with other useful function details.
*
* If the matching function cannot be found, return null.
*/
parseTransaction(tx: {
data: string;
value?: BigNumberish;
}): null | TransactionDescription;
parseCallResult(data: BytesLike): Result;
/**
* Parses a receipt log, finding the matching event and extracts
* the parameter values along with other useful event details.
*
* If the matching event cannot be found, returns null.
*/
parseLog(log: {
topics: Array<string>;
data: string;
}): null | LogDescription;
/**
* Parses a revert data, finding the matching error and extracts
* the parameter values along with other useful error details.
*
* If the matching event cannot be found, returns null.
*/
parseError(data: BytesLike): null | ErrorDescription;
/**
* Creates a new [[Interface]] from the ABI %%value%%.
*
* The %%value%% may be provided as an existing [[Interface]] object,
* a JSON-encoded ABI or any Human-Readable ABI format.
*/
static from(value: InterfaceAbi | Interface): Interface;
}

162
lib.commonjs/abi/typed.d.ts vendored Normal file
View File

@@ -0,0 +1,162 @@
/**
* About typed...
*
* @_subsection: api/abi:Typed Values
*/
import type { Addressable } from "../address/index.js";
import type { BigNumberish, BytesLike } from "../utils/index.js";
import type { Result } from "./coders/abstract-coder.js";
export interface TypedNumber extends Typed {
value: number;
defaultValue(): number;
minValue(): number;
maxValue(): number;
}
export interface TypedBigInt extends Typed {
value: bigint;
defaultValue(): bigint;
minValue(): bigint;
maxValue(): bigint;
}
export interface TypedData extends Typed {
value: string;
defaultValue(): string;
}
export interface TypedString extends Typed {
value: string;
defaultValue(): string;
}
export declare class Typed {
#private;
readonly type: string;
readonly value: any;
readonly _typedSymbol: Symbol;
constructor(gaurd: any, type: string, value: any, options?: any);
format(): string;
defaultValue(): string | number | bigint | Result;
minValue(): string | number | bigint;
maxValue(): string | number | bigint;
isBigInt(): this is TypedBigInt;
isData(): this is TypedData;
isString(): this is TypedString;
get tupleName(): null | string;
get arrayLength(): null | number;
static from(type: string, value: any): Typed;
static uint8(v: BigNumberish): Typed;
static uint16(v: BigNumberish): Typed;
static uint24(v: BigNumberish): Typed;
static uint32(v: BigNumberish): Typed;
static uint40(v: BigNumberish): Typed;
static uint48(v: BigNumberish): Typed;
static uint56(v: BigNumberish): Typed;
static uint64(v: BigNumberish): Typed;
static uint72(v: BigNumberish): Typed;
static uint80(v: BigNumberish): Typed;
static uint88(v: BigNumberish): Typed;
static uint96(v: BigNumberish): Typed;
static uint104(v: BigNumberish): Typed;
static uint112(v: BigNumberish): Typed;
static uint120(v: BigNumberish): Typed;
static uint128(v: BigNumberish): Typed;
static uint136(v: BigNumberish): Typed;
static uint144(v: BigNumberish): Typed;
static uint152(v: BigNumberish): Typed;
static uint160(v: BigNumberish): Typed;
static uint168(v: BigNumberish): Typed;
static uint176(v: BigNumberish): Typed;
static uint184(v: BigNumberish): Typed;
static uint192(v: BigNumberish): Typed;
static uint200(v: BigNumberish): Typed;
static uint208(v: BigNumberish): Typed;
static uint216(v: BigNumberish): Typed;
static uint224(v: BigNumberish): Typed;
static uint232(v: BigNumberish): Typed;
static uint240(v: BigNumberish): Typed;
static uint248(v: BigNumberish): Typed;
static uint256(v: BigNumberish): Typed;
static uint(v: BigNumberish): Typed;
static int8(v: BigNumberish): Typed;
static int16(v: BigNumberish): Typed;
static int24(v: BigNumberish): Typed;
static int32(v: BigNumberish): Typed;
static int40(v: BigNumberish): Typed;
static int48(v: BigNumberish): Typed;
static int56(v: BigNumberish): Typed;
static int64(v: BigNumberish): Typed;
static int72(v: BigNumberish): Typed;
static int80(v: BigNumberish): Typed;
static int88(v: BigNumberish): Typed;
static int96(v: BigNumberish): Typed;
static int104(v: BigNumberish): Typed;
static int112(v: BigNumberish): Typed;
static int120(v: BigNumberish): Typed;
static int128(v: BigNumberish): Typed;
static int136(v: BigNumberish): Typed;
static int144(v: BigNumberish): Typed;
static int152(v: BigNumberish): Typed;
static int160(v: BigNumberish): Typed;
static int168(v: BigNumberish): Typed;
static int176(v: BigNumberish): Typed;
static int184(v: BigNumberish): Typed;
static int192(v: BigNumberish): Typed;
static int200(v: BigNumberish): Typed;
static int208(v: BigNumberish): Typed;
static int216(v: BigNumberish): Typed;
static int224(v: BigNumberish): Typed;
static int232(v: BigNumberish): Typed;
static int240(v: BigNumberish): Typed;
static int248(v: BigNumberish): Typed;
static int256(v: BigNumberish): Typed;
static int(v: BigNumberish): Typed;
static bytes1(v: BytesLike): Typed;
static bytes2(v: BytesLike): Typed;
static bytes3(v: BytesLike): Typed;
static bytes4(v: BytesLike): Typed;
static bytes5(v: BytesLike): Typed;
static bytes6(v: BytesLike): Typed;
static bytes7(v: BytesLike): Typed;
static bytes8(v: BytesLike): Typed;
static bytes9(v: BytesLike): Typed;
static bytes10(v: BytesLike): Typed;
static bytes11(v: BytesLike): Typed;
static bytes12(v: BytesLike): Typed;
static bytes13(v: BytesLike): Typed;
static bytes14(v: BytesLike): Typed;
static bytes15(v: BytesLike): Typed;
static bytes16(v: BytesLike): Typed;
static bytes17(v: BytesLike): Typed;
static bytes18(v: BytesLike): Typed;
static bytes19(v: BytesLike): Typed;
static bytes20(v: BytesLike): Typed;
static bytes21(v: BytesLike): Typed;
static bytes22(v: BytesLike): Typed;
static bytes23(v: BytesLike): Typed;
static bytes24(v: BytesLike): Typed;
static bytes25(v: BytesLike): Typed;
static bytes26(v: BytesLike): Typed;
static bytes27(v: BytesLike): Typed;
static bytes28(v: BytesLike): Typed;
static bytes29(v: BytesLike): Typed;
static bytes30(v: BytesLike): Typed;
static bytes31(v: BytesLike): Typed;
static bytes32(v: BytesLike): Typed;
static address(v: string | Addressable): Typed;
static bool(v: any): Typed;
static bytes(v: BytesLike): Typed;
static string(v: string): Typed;
static array(v: Array<any | Typed>, dynamic?: null | boolean): Typed;
static tuple(v: Array<any | Typed> | Record<string, any | Typed>, name?: string): Typed;
static overrides(v: Record<string, any>): Typed;
/**
* Returns true only if %%value%% is a [[Typed]] instance.
*/
static isTyped(value: any): value is Typed;
/**
* If the value is a [[Typed]] instance, validates the underlying value
* and returns it, otherwise returns value directly.
*
* This is useful for functions that with to accept either a [[Typed]]
* object or values.
*/
static dereference<T>(value: Typed | T, type: string): T;
}

55
lib.commonjs/address/address.d.ts vendored Normal file
View File

@@ -0,0 +1,55 @@
/**
* Returns a normalized and checksumed address for %%address%%.
* This accepts non-checksum addresses, checksum addresses and
* [[getIcapAddress]] formats.
*
* The checksum in Ethereum uses the capitalization (upper-case
* vs lower-case) of the characters within an address to encode
* its checksum, which offers, on average, a checksum of 15-bits.
*
* If %%address%% contains both upper-case and lower-case, it is
* assumed to already be a checksum address and its checksum is
* validated, and if the address fails its expected checksum an
* error is thrown.
*
* If you wish the checksum of %%address%% to be ignore, it should
* be converted to lower-case (i.e. ``.toLowercase()``) before
* being passed in. This should be a very rare situation though,
* that you wish to bypass the safegaurds in place to protect
* against an address that has been incorrectly copied from another
* source.
*
* @example:
* // Adds the checksum (via upper-casing specific letters)
* getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
* //_result:
*
* // Converts ICAP address and adds checksum
* getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
* //_result:
*
* // Throws an error if an address contains mixed case,
* // but the checksum fails
* getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
* //_error:
*/
export declare function getAddress(address: string): string;
/**
* The [ICAP Address format](link-icap) format is an early checksum
* format which attempts to be compatible with the banking
* industry [IBAN format](link-wiki-iban] for bank accounts.
*
* It is no longer common or a recommended format.
*
* @example:
* getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
* //_result:
*
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
* //_result:
*
* // Throws an error if the ICAP checksum is wrong
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
* //_error:
*/
export declare function getIcapAddress(address: string): string;

80
lib.commonjs/address/checks.d.ts vendored Normal file
View File

@@ -0,0 +1,80 @@
import type { Addressable, AddressLike, NameResolver } from "./index.js";
/**
* Returns true if %%value%% is an object which implements the
* [[Addressable]] interface.
*
* @example:
* // Wallets and AbstractSigner sub-classes
* isAddressable(Wallet.createRandom())
* //_result:
*
* // Contracts
* contract = new Contract("dai.tokens.ethers.eth", [ ], provider)
* isAddressable(contract)
* //_result:
*/
export declare function isAddressable(value: any): value is Addressable;
/**
* Returns true if %%value%% is a valid address.
*
* @example:
* // Valid address
* isAddress("0x8ba1f109551bD432803012645Ac136ddd64DBA72")
* //_result:
*
* // Valid ICAP address
* isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36")
* //_result:
*
* // Invalid checksum
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBa72")
* //_result:
*
* // Invalid ICAP checksum
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
* //_result:
*
* // Not an address (an ENS name requires a provided and an
* // asynchronous API to access)
* isAddress("ricmoo.eth")
* //_result:
*/
export declare function isAddress(value: any): value is string;
/**
* Resolves to an address for the %%target%%, which may be any
* supported address type, an [[Addressable]] or a Promise which
* resolves to an address.
*
* If an ENS name is provided, but that name has not been correctly
* configured a [[UnconfiguredNameError]] is thrown.
*
* @example:
* addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
*
* // Addresses are return synchronously
* resolveAddress(addr, provider)
* //_result:
*
* // Address promises are resolved asynchronously
* resolveAddress(Promise.resolve(addr))
* //_result:
*
* // ENS names are resolved asynchronously
* resolveAddress("dai.tokens.ethers.eth", provider)
* //_result:
*
* // Addressable objects are resolved asynchronously
* contract = new Contract(addr, [ ])
* resolveAddress(contract, provider)
* //_result:
*
* // Unconfigured ENS names reject
* resolveAddress("nothing-here.ricmoo.eth", provider)
* //_error:
*
* // ENS names require a NameResolver object passed in
* // (notice the provider was omitted)
* resolveAddress("nothing-here.ricmoo.eth")
* //_error:
*/
export declare function resolveAddress(target: AddressLike, resolver?: null | NameResolver): string | Promise<string>;

View File

@@ -0,0 +1,47 @@
import type { BigNumberish, BytesLike } from "../utils/index.js";
/**
* Returns the address that would result from a ``CREATE`` for %%tx%%.
*
* This can be used to compute the address a contract will be
* deployed to by an EOA when sending a deployment transaction (i.e.
* when the ``to`` address is ``null``).
*
* This can also be used to compute the address a contract will be
* deployed to by a contract, by using the contract's address as the
* ``to`` and the contract's nonce.
*
* @example
* from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
* nonce = 5;
*
* getCreateAddress({ from, nonce });
* //_result:
*/
export declare function getCreateAddress(tx: {
from: string;
nonce: BigNumberish;
}): string;
/**
* Returns the address that would result from a ``CREATE2`` operation
* with the given %%from%%, %%salt%% and %%initCodeHash%%.
*
* To compute the %%initCodeHash%% from a contract's init code, use
* the [[keccak256]] function.
*
* For a quick overview and example of ``CREATE2``, see [[link-ricmoo-wisps]].
*
* @example
* // The address of the contract
* from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72"
*
* // The salt
* salt = id("HelloWorld")
*
* // The hash of the initCode
* initCode = "0x6394198df16000526103ff60206004601c335afa6040516060f3";
* initCodeHash = keccak256(initCode)
*
* getCreate2Address(from, salt, initCodeHash)
* //_result:
*/
export declare function getCreate2Address(_from: string, _salt: BytesLike, _initCodeHash: BytesLike): string;

48
lib.commonjs/address/index.d.ts vendored Normal file
View File

@@ -0,0 +1,48 @@
/**
* Addresses are a fundamental part of interacting with Ethereum. They
* represent the gloabal identity of Externally Owned Accounts (accounts
* backed by a private key) and contracts.
*
* The Ethereum Naming Service (ENS) provides an interconnected ecosystem
* of contracts, standards and libraries which enable looking up an
* address for an ENS name.
*
* These functions help convert between various formats, validate
* addresses and safely resolve ENS names.
*
* @_section: api/address:Addresses [addresses]
*/
/**
* An interface for objects which have an address, and can
* resolve it asyncronously.
*
* This allows objects such as [[Signer]] or [[Contract]] to
* be used most places an address can be, for example getting
* the [balance](Provider-getBalance).
*/
export interface Addressable {
/**
* Get the object address.
*/
getAddress(): Promise<string>;
}
/**
* Anything that can be used to return or resolve an address.
*/
export type AddressLike = string | Promise<string> | Addressable;
/**
* An interface for any object which can resolve an ENS name.
*/
export interface NameResolver {
/**
* Resolve to the address for the ENS %%name%%.
*
* Resolves to ``null`` if the name is unconfigued. Use
* [[resolveAddress]] (passing this object as %%resolver%%) to
* throw for names that are unconfigured.
*/
resolveName(name: string): Promise<null | string>;
}
export { getAddress, getIcapAddress } from "./address.js";
export { getCreateAddress, getCreate2Address } from "./contract-address.js";
export { isAddressable, isAddress, resolveAddress } from "./checks.js";

6
lib.commonjs/constants/addresses.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* A constant for the zero address.
*
* (**i.e.** ``"0x0000000000000000000000000000000000000000"``)
*/
export declare const ZeroAddress: string;

6
lib.commonjs/constants/hashes.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* A constant for the zero hash.
*
* (**i.e.** ``"0x0000000000000000000000000000000000000000000000000000000000000000"``)
*/
export declare const ZeroHash: string;

9
lib.commonjs/constants/index.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* Some common constants useful for Ethereum.
*
* @_section: api/constants: Constants [constants]
*/
export { ZeroAddress } from "./addresses.js";
export { ZeroHash } from "./hashes.js";
export { N, WeiPerEther, MaxUint256, MinInt256, MaxInt256 } from "./numbers.js";
export { EtherSymbol, MessagePrefix } from "./strings.js";

30
lib.commonjs/constants/numbers.d.ts vendored Normal file
View File

@@ -0,0 +1,30 @@
/**
* A constant for the order N for the secp256k1 curve.
*
* (**i.e.** ``0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n``)
*/
export declare const N: bigint;
/**
* A constant for the number of wei in a single ether.
*
* (**i.e.** ``1000000000000000000n``)
*/
export declare const WeiPerEther: bigint;
/**
* A constant for the maximum value for a ``uint256``.
*
* (**i.e.** ``0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``)
*/
export declare const MaxUint256: bigint;
/**
* A constant for the minimum value for an ``int256``.
*
* (**i.e.** ``-8000000000000000000000000000000000000000000000000000000000000000n``)
*/
export declare const MinInt256: bigint;
/**
* A constant for the maximum value for an ``int256``.
*
* (**i.e.** ``0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``)
*/
export declare const MaxInt256: bigint;

12
lib.commonjs/constants/strings.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* A constant for the ether symbol (normalized using NFKC).
*
* (**i.e.** ``"\\u039e"``)
*/
export declare const EtherSymbol: string;
/**
* A constant for the [[link-eip-191]] personal message prefix.
*
* (**i.e.** ``"\\x19Ethereum Signed Message:\\n"``)
*/
export declare const MessagePrefix: string;

58
lib.commonjs/contract/contract.d.ts vendored Normal file
View File

@@ -0,0 +1,58 @@
import { Interface } from "../abi/index.js";
import { Log, TransactionResponse } from "../providers/provider.js";
import { ContractTransactionResponse, EventLog } from "./wrappers.js";
import type { EventFragment, FunctionFragment, InterfaceAbi, ParamType } from "../abi/index.js";
import type { Addressable } from "../address/index.js";
import type { EventEmitterable, Listener } from "../utils/index.js";
import type { BlockTag, ContractRunner, TransactionRequest } from "../providers/index.js";
import type { ContractEventName, ContractInterface, ContractMethod, ContractEvent, ContractTransaction } from "./types.js";
/**
* @_ignore:
*/
export declare function copyOverrides<O extends string = "data" | "to">(arg: any, allowed?: Array<string>): Promise<Omit<ContractTransaction, O>>;
/**
* @_ignore:
*/
export declare function resolveArgs(_runner: null | ContractRunner, inputs: ReadonlyArray<ParamType>, args: Array<any>): Promise<Array<any>>;
declare class WrappedFallback {
readonly _contract: BaseContract;
constructor(contract: BaseContract);
populateTransaction(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransaction>;
staticCall(overrides?: Omit<TransactionRequest, "to">): Promise<string>;
send(overrides?: Omit<TransactionRequest, "to">): Promise<ContractTransactionResponse>;
estimateGas(overrides?: Omit<TransactionRequest, "to">): Promise<bigint>;
}
declare const internal: unique symbol;
export declare class BaseContract implements Addressable, EventEmitterable<ContractEventName> {
readonly target: string | Addressable;
readonly interface: Interface;
readonly runner: null | ContractRunner;
readonly filters: Record<string, ContractEvent>;
readonly [internal]: any;
readonly fallback: null | WrappedFallback;
constructor(target: string | Addressable, abi: Interface | InterfaceAbi, runner?: null | ContractRunner, _deployTx?: null | TransactionResponse);
connect(runner: null | ContractRunner): BaseContract;
getAddress(): Promise<string>;
getDeployedCode(): Promise<null | string>;
waitForDeployment(): Promise<this>;
deploymentTransaction(): null | ContractTransactionResponse;
getFunction<T extends ContractMethod = ContractMethod>(key: string | FunctionFragment): T;
getEvent(key: string | EventFragment): ContractEvent;
queryTransaction(hash: string): Promise<Array<EventLog>>;
queryFilter(event: ContractEventName, fromBlock?: BlockTag, toBlock?: BlockTag): Promise<Array<EventLog | Log>>;
on(event: ContractEventName, listener: Listener): Promise<this>;
once(event: ContractEventName, listener: Listener): Promise<this>;
emit(event: ContractEventName, ...args: Array<any>): Promise<boolean>;
listenerCount(event?: ContractEventName): Promise<number>;
listeners(event?: ContractEventName): Promise<Array<Listener>>;
off(event: ContractEventName, listener?: Listener): Promise<this>;
removeAllListeners(event?: ContractEventName): Promise<this>;
addListener(event: ContractEventName, listener: Listener): Promise<this>;
removeListener(event: ContractEventName, listener: Listener): Promise<this>;
static buildClass<T = ContractInterface>(abi: InterfaceAbi): new (target: string, runner?: null | ContractRunner) => BaseContract & Omit<T, keyof BaseContract>;
static from<T = ContractInterface>(target: string, abi: InterfaceAbi, runner?: null | ContractRunner): BaseContract & Omit<T, keyof BaseContract>;
}
declare const Contract_base: new (target: string, abi: InterfaceAbi, runner?: ContractRunner | null | undefined) => BaseContract & Omit<ContractInterface, keyof BaseContract>;
export declare class Contract extends Contract_base {
}
export {};

21
lib.commonjs/contract/factory.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
import { Interface } from "../abi/index.js";
import { BaseContract } from "./contract.js";
import type { InterfaceAbi } from "../abi/index.js";
import type { ContractRunner } from "../providers/index.js";
import type { BytesLike } from "../utils/index.js";
import type { ContractInterface, ContractMethodArgs, ContractDeployTransaction } from "./types.js";
import type { ContractTransactionResponse } from "./wrappers.js";
export declare class ContractFactory<A extends Array<any> = Array<any>, I = BaseContract> {
readonly interface: Interface;
readonly bytecode: string;
readonly runner: null | ContractRunner;
constructor(abi: Interface | InterfaceAbi, bytecode: BytesLike | {
object: string;
}, runner?: null | ContractRunner);
getDeployTransaction(...args: ContractMethodArgs<A>): Promise<ContractDeployTransaction>;
deploy(...args: ContractMethodArgs<A>): Promise<BaseContract & {
deploymentTransaction(): ContractTransactionResponse;
} & Omit<I, keyof BaseContract>>;
connect(runner: null | ContractRunner): ContractFactory<A, I>;
static fromSolidity<A extends Array<any> = Array<any>, I = ContractInterface>(output: any, runner?: ContractRunner): ContractFactory<A, I>;
}

9
lib.commonjs/contract/index.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* About contracts...
*
* @_section: api/contract:Contracts [contracts]
*/
export { BaseContract, Contract } from "./contract.js";
export { ContractFactory } from "./factory.js";
export { ContractEventPayload, ContractUnknownEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, } from "./wrappers.js";
export type { BaseContractMethod, ConstantContractMethod, PostfixOverrides, ContractEvent, ContractEventArgs, ContractEventName, ContractDeployTransaction, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides } from "./types.js";

48
lib.commonjs/contract/types.d.ts vendored Normal file
View File

@@ -0,0 +1,48 @@
import type { EventFragment, FunctionFragment, Result, Typed } from "../abi/index.js";
import type { TransactionRequest, PreparedTransactionRequest, TopicFilter } from "../providers/index.js";
import type { ContractTransactionResponse } from "./wrappers.js";
export type ContractEventName = string | ContractEvent | TopicFilter | DeferredTopicFilter;
export interface ContractInterface {
[name: string]: BaseContractMethod;
}
export interface DeferredTopicFilter {
getTopicFilter(): Promise<TopicFilter>;
fragment: EventFragment;
}
export interface ContractTransaction extends PreparedTransactionRequest {
to: string;
data: string;
from?: string;
}
export interface ContractDeployTransaction extends Omit<ContractTransaction, "to"> {
}
export interface Overrides extends Omit<TransactionRequest, "to" | "data"> {
}
export type PostfixOverrides<A extends Array<any>> = A | [...A, Overrides];
export type ContractMethodArgs<A extends Array<any>> = PostfixOverrides<{
[I in keyof A]-?: A[I] | Typed;
}>;
export interface BaseContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> {
(...args: ContractMethodArgs<A>): Promise<D>;
name: string;
fragment: FunctionFragment;
getFragment(...args: ContractMethodArgs<A>): FunctionFragment;
populateTransaction(...args: ContractMethodArgs<A>): Promise<ContractTransaction>;
staticCall(...args: ContractMethodArgs<A>): Promise<R>;
send(...args: ContractMethodArgs<A>): Promise<ContractTransactionResponse>;
estimateGas(...args: ContractMethodArgs<A>): Promise<bigint>;
staticCallResult(...args: ContractMethodArgs<A>): Promise<Result>;
}
export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> extends BaseContractMethod<A, R, D> {
}
export interface ConstantContractMethod<A extends Array<any>, R = any> extends ContractMethod<A, R, R> {
}
export type ContractEventArgs<A extends Array<any>> = {
[I in keyof A]?: A[I] | Typed | null;
};
export interface ContractEvent<A extends Array<any> = Array<any>> {
(...args: ContractEventArgs<A>): DeferredTopicFilter;
name: string;
fragment: EventFragment;
getFragment(...args: ContractEventArgs<A>): EventFragment;
}

40
lib.commonjs/contract/wrappers.d.ts vendored Normal file
View File

@@ -0,0 +1,40 @@
import { Block, Log, TransactionReceipt, TransactionResponse } from "../providers/provider.js";
import { EventPayload } from "../utils/index.js";
import type { EventFragment, Interface, Result } from "../abi/index.js";
import type { Listener } from "../utils/index.js";
import type { Provider } from "../providers/index.js";
import type { BaseContract } from "./contract.js";
import type { ContractEventName } from "./types.js";
export declare class EventLog extends Log {
readonly interface: Interface;
readonly fragment: EventFragment;
readonly args: Result;
constructor(log: Log, iface: Interface, fragment: EventFragment);
get eventName(): string;
get eventSignature(): string;
}
export declare class ContractTransactionReceipt extends TransactionReceipt {
#private;
constructor(iface: Interface, provider: Provider, tx: TransactionReceipt);
get logs(): Array<EventLog | Log>;
}
export declare class ContractTransactionResponse extends TransactionResponse {
#private;
constructor(iface: Interface, provider: Provider, tx: TransactionResponse);
wait(confirms?: number): Promise<null | ContractTransactionReceipt>;
}
export declare class ContractUnknownEventPayload extends EventPayload<ContractEventName> {
readonly log: Log;
constructor(contract: BaseContract, listener: null | Listener, filter: ContractEventName, log: Log);
getBlock(): Promise<Block>;
getTransaction(): Promise<TransactionResponse>;
getTransactionReceipt(): Promise<TransactionReceipt>;
}
export declare class ContractEventPayload extends ContractUnknownEventPayload {
readonly fragment: EventFragment;
readonly log: EventLog;
readonly args: Result;
constructor(contract: BaseContract, listener: null | Listener, filter: ContractEventName, fragment: EventFragment, _log: Log);
get eventName(): string;
get eventSignature(): string;
}

14
lib.commonjs/crypto/crypto-browser.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
declare global {
interface Window {
}
const window: Window;
const self: Window;
}
export interface CryptoHasher {
update(data: Uint8Array): CryptoHasher;
digest(): Uint8Array;
}
export declare function createHash(algo: string): CryptoHasher;
export declare function createHmac(_algo: string, key: Uint8Array): CryptoHasher;
export declare function pbkdf2Sync(password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, _algo: "sha256" | "sha512"): Uint8Array;
export declare function randomBytes(length: number): Uint8Array;

1
lib.commonjs/crypto/crypto.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export { createHash, createHmac, pbkdf2Sync, randomBytes } from "crypto";

24
lib.commonjs/crypto/hmac.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
import type { BytesLike } from "../utils/index.js";
/**
* Return the HMAC for %%data%% using the %%key%% key with the underlying
* %%algo%% used for compression.
*
* @example:
* key = id("some-secret")
*
* // Compute the HMAC
* computeHmac("sha256", key, "0x1337")
* //_result:
*
* // To compute the HMAC of UTF-8 data, the data must be
* // converted to UTF-8 bytes
* computeHmac("sha256", key, toUtf8Bytes("Hello World"))
* //_result:
*
*/
export declare function computeHmac(algorithm: "sha256" | "sha512", _key: BytesLike, _data: BytesLike): string;
export declare namespace computeHmac {
var _: (algorithm: "sha256" | "sha512", key: Uint8Array, data: Uint8Array) => BytesLike;
var lock: () => void;
var register: (func: (algorithm: "sha256" | "sha512", key: Uint8Array, data: Uint8Array) => BytesLike) => void;
}

20
lib.commonjs/crypto/index.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
/**
* A fundamental building block of Ethereum is the underlying
* cryptographic primitives.
*
* @_section: api/crypto:Cryptographic Functions [crypto]
*/
import { computeHmac } from "./hmac.js";
import { keccak256 } from "./keccak.js";
import { ripemd160 } from "./ripemd160.js";
import { pbkdf2 } from "./pbkdf2.js";
import { randomBytes } from "./random.js";
import { scrypt, scryptSync } from "./scrypt.js";
import { sha256, sha512 } from "./sha2.js";
export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync };
export { SigningKey } from "./signing-key.js";
export { Signature } from "./signature.js";
declare function lock(): void;
export { lock };
export type { ProgressCallback } from "./scrypt.js";
export type { SignatureLike } from "./signature.js";

34
lib.commonjs/crypto/keccak.d.ts vendored Normal file
View File

@@ -0,0 +1,34 @@
/**
* Cryptographic hashing functions
*
* @_subsection: api/crypto:Hash Functions [about-crypto-hashing]
*/
import type { BytesLike } from "../utils/index.js";
/**
* Compute the cryptographic KECCAK256 hash of %%data%%.
*
* The %%data%% **must** be a data representation, to compute the
* hash of UTF-8 data use the [[id]] function.
*
* @returns DataHexstring
* @example:
* keccak256("0x")
* //_result:
*
* keccak256("0x1337")
* //_result:
*
* keccak256(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*
* // Strings are assumed to be DataHexString, otherwise it will
* // throw. To hash UTF-8 data, see the note above.
* keccak256("Hello World")
* //_error:
*/
export declare function keccak256(_data: BytesLike): string;
export declare namespace keccak256 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}

34
lib.commonjs/crypto/pbkdf2.d.ts vendored Normal file
View File

@@ -0,0 +1,34 @@
/**
* A **Password-Based Key-Derivation Function** is designed to create
* a sequence of bytes suitible as a **key** from a human-rememberable
* password.
*
* @_subsection: api/crypto:Passwords [about-pbkdf]
*/
import type { BytesLike } from "../utils/index.js";
/**
* Return the [[link-pbkdf2]] for %%keylen%% bytes for %%password%% using
* the %%salt%% and using %%iterations%% of %%algo%%.
*
* This PBKDF is outdated and should not be used in new projects, but is
* required to decrypt older files.
*
* @example:
* // The password must be converted to bytes, and it is generally
* // best practices to ensure the string has been normalized. Many
* // formats explicitly indicate the normalization form to use.
* password = "hello"
* passwordBytes = toUtf8Bytes(password, "NFKC")
*
* salt = id("some-salt")
*
* // Compute the PBKDF2
* pbkdf2(passwordBytes, salt, 1024, 16, "sha256")
* //_result:
*/
export declare function pbkdf2(_password: BytesLike, _salt: BytesLike, iterations: number, keylen: number, algo: "sha256" | "sha512"): string;
export declare namespace pbkdf2 {
var _: (password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, algo: "sha256" | "sha512") => BytesLike;
var lock: () => void;
var register: (func: (password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, algo: "sha256" | "sha512") => BytesLike) => void;
}

13
lib.commonjs/crypto/random.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
/**
* Return %%length%% bytes of cryptographically secure random data.
*
* @example:
* randomBytes(8)
* //_result:
*/
export declare function randomBytes(length: number): Uint8Array;
export declare namespace randomBytes {
var _: (length: number) => Uint8Array;
var lock: () => void;
var register: (func: (length: number) => Uint8Array) => void;
}

24
lib.commonjs/crypto/ripemd160.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
import type { BytesLike } from "../utils/index.js";
/**
* Compute the cryptographic RIPEMD-160 hash of %%data%%.
*
* @_docloc: api/crypto:Hash Functions
* @returns DataHexstring
*
* @example:
* ripemd160("0x")
* //_result:
*
* ripemd160("0x1337")
* //_result:
*
* ripemd160(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*
*/
export declare function ripemd160(_data: BytesLike): string;
export declare namespace ripemd160 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}

79
lib.commonjs/crypto/scrypt.d.ts vendored Normal file
View File

@@ -0,0 +1,79 @@
import type { BytesLike } from "../utils/index.js";
/**
* A callback during long-running operations to update any
* UI or provide programatic access to the progress.
*
* The %%percent%% is a value between ``0`` and ``1``.
*/
export type ProgressCallback = (percent: number) => void;
/**
* The [[link-wiki-scrypt]] uses a memory and cpu hard method of
* derivation to increase the resource cost to brute-force a password
* for a given key.
*
* This means this algorithm is intentionally slow, and can be tuned to
* become slower. As computation and memory speed improve over time,
* increasing the difficulty maintains the cost of an attacker.
*
* For example, if a target time of 5 seconds is used, a legitimate user
* which knows their password requires only 5 seconds to unlock their
* account. A 6 character password has 68 billion possibilities, which
* would require an attacker to invest over 10,000 years of CPU time. This
* is of course a crude example (as password generally aren't random),
* but demonstrates to value of imposing large costs to decryption.
*
* For this reason, if building a UI which involved decrypting or
* encrypting datsa using scrypt, it is recommended to use a
* [[ProgressCallback]] (as event short periods can seem lik an eternity
* if the UI freezes). Including the phrase //"decrypting"// in the UI
* can also help, assuring the user their waiting is for a good reason.
*
* @_docloc: api/crypto:Passwords
*
* @example:
* // The password must be converted to bytes, and it is generally
* // best practices to ensure the string has been normalized. Many
* // formats explicitly indicate the normalization form to use.
* password = "hello"
* passwordBytes = toUtf8Bytes(password, "NFKC")
*
* salt = id("some-salt")
*
* // Compute the scrypt
* scrypt(passwordBytes, salt, 1024, 8, 1, 16)
* //_result:
*/
export declare function scrypt(_passwd: BytesLike, _salt: BytesLike, N: number, r: number, p: number, dkLen: number, progress?: ProgressCallback): Promise<string>;
export declare namespace scrypt {
var _: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number, onProgress?: ProgressCallback | undefined) => Promise<Uint8Array>;
var lock: () => void;
var register: (func: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number, progress?: ProgressCallback | undefined) => Promise<BytesLike>) => void;
}
/**
* Provides a synchronous variant of [[scrypt]].
*
* This will completely lock up and freeze the UI in a browser and will
* prevent any event loop from progressing. For this reason, it is
* preferred to use the [async variant](scrypt).
*
* @_docloc: api/crypto:Passwords
*
* @example:
* // The password must be converted to bytes, and it is generally
* // best practices to ensure the string has been normalized. Many
* // formats explicitly indicate the normalization form to use.
* password = "hello"
* passwordBytes = toUtf8Bytes(password, "NFKC")
*
* salt = id("some-salt")
*
* // Compute the scrypt
* scryptSync(passwordBytes, salt, 1024, 8, 1, 16)
* //_result:
*/
export declare function scryptSync(_passwd: BytesLike, _salt: BytesLike, N: number, r: number, p: number, dkLen: number): string;
export declare namespace scryptSync {
var _: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number) => Uint8Array;
var lock: () => void;
var register: (func: (passwd: Uint8Array, salt: Uint8Array, N: number, r: number, p: number, dkLen: number) => BytesLike) => void;
}

46
lib.commonjs/crypto/sha2.d.ts vendored Normal file
View File

@@ -0,0 +1,46 @@
import type { BytesLike } from "../utils/index.js";
/**
* Compute the cryptographic SHA2-256 hash of %%data%%.
*
* @_docloc: api/crypto:Hash Functions
* @returns DataHexstring
*
* @example:
* sha256("0x")
* //_result:
*
* sha256("0x1337")
* //_result:
*
* sha256(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*
*/
export declare function sha256(_data: BytesLike): string;
export declare namespace sha256 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}
/**
* Compute the cryptographic SHA2-512 hash of %%data%%.
*
* @_docloc: api/crypto:Hash Functions
* @returns DataHexstring
*
* @example:
* sha512("0x")
* //_result:
*
* sha512("0x1337")
* //_result:
*
* sha512(new Uint8Array([ 0x13, 0x37 ]))
* //_result:
*/
export declare function sha512(_data: BytesLike): string;
export declare namespace sha512 {
var _: (data: Uint8Array) => Uint8Array;
var lock: () => void;
var register: (func: (data: Uint8Array) => BytesLike) => void;
}

149
lib.commonjs/crypto/signature.d.ts vendored Normal file
View File

@@ -0,0 +1,149 @@
import type { BigNumberish, BytesLike } from "../utils/index.js";
export type SignatureLike = Signature | string | {
r: string;
s: string;
v: BigNumberish;
yParity?: 0 | 1;
yParityAndS?: string;
} | {
r: string;
yParityAndS: string;
yParity?: 0 | 1;
s?: string;
v?: number;
} | {
r: string;
s: string;
yParity: 0 | 1;
v?: BigNumberish;
yParityAndS?: string;
};
/**
* A Signature @TODO
*/
export declare class Signature {
#private;
/**
* The ``r`` value for a signautre.
*
* This represents the ``x`` coordinate of a "reference" or
* challenge point, from which the ``y`` can be computed.
*/
get r(): string;
set r(value: BytesLike);
/**
* The ``s`` value for a signature.
*/
get s(): string;
set s(_value: BytesLike);
/**
* The ``v`` value for a signature.
*
* Since a given ``x`` value for ``r`` has two possible values for
* its correspondin ``y``, the ``v`` indicates which of the two ``y``
* values to use.
*
* It is normalized to the values ``27`` or ``28`` for legacy
* purposes.
*/
get v(): 27 | 28;
set v(value: BigNumberish);
/**
* The EIP-155 ``v`` for legacy transactions. For non-legacy
* transactions, this value is ``null``.
*/
get networkV(): null | bigint;
/**
* The chain ID for EIP-155 legacy transactions. For non-legacy
* transactions, this value is ``null``.
*/
get legacyChainId(): null | bigint;
/**
* The ``yParity`` for the signature.
*
* See ``v`` for more details on how this value is used.
*/
get yParity(): 0 | 1;
/**
* The [[link-eip-2098]] compact representation of the ``yParity``
* and ``s`` compacted into a single ``bytes32``.
*/
get yParityAndS(): string;
/**
* The [[link-eip-2098]] compact representation.
*/
get compactSerialized(): string;
/**
* The serialized representation.
*/
get serialized(): string;
/**
* @private
*/
constructor(guard: any, r: string, s: string, v: 27 | 28);
/**
* Returns a new identical [[Signature]].
*/
clone(): Signature;
/**
* Returns a representation that is compatible with ``JSON.stringify``.
*/
toJSON(): any;
/**
* Compute the chain ID from the ``v`` in a legacy EIP-155 transactions.
*
* @example:
* Signature.getChainId(45)
* //_result:
*
* Signature.getChainId(46)
* //_result:
*/
static getChainId(v: BigNumberish): bigint;
/**
* Compute the ``v`` for a chain ID for a legacy EIP-155 transactions.
*
* Legacy transactions which use [[link-eip-155]] hijack the ``v``
* property to include the chain ID.
*
* @example:
* Signature.getChainIdV(5, 27)
* //_result:
*
* Signature.getChainIdV(5, 28)
* //_result:
*
*/
static getChainIdV(chainId: BigNumberish, v: 27 | 28): bigint;
/**
* Compute the normalized legacy transaction ``v`` from a ``yParirty``,
* a legacy transaction ``v`` or a legacy [[link-eip-155]] transaction.
*
* @example:
* // The values 0 and 1 imply v is actually yParity
* Signature.getNormalizedV(0)
* //_result:
*
* // Legacy non-EIP-1559 transaction (i.e. 27 or 28)
* Signature.getNormalizedV(27)
* //_result:
*
* // Legacy EIP-155 transaction (i.e. >= 35)
* Signature.getNormalizedV(46)
* //_result:
*
* // Invalid values throw
* Signature.getNormalizedV(5)
* //_error:
*/
static getNormalizedV(v: BigNumberish): 27 | 28;
/**
* Creates a new [[Signature]].
*
* If no %%sig%% is provided, a new [[Signature]] is created
* with default values.
*
* If %%sig%% is a string, it is parsed.
*/
static from(sig?: SignatureLike): Signature;
}

116
lib.commonjs/crypto/signing-key.d.ts vendored Normal file
View File

@@ -0,0 +1,116 @@
import { Signature } from "./signature.js";
import type { BytesLike } from "../utils/index.js";
import type { SignatureLike } from "./index.js";
/**
* A **SigningKey** provides high-level access to the elliptic curve
* cryptography (ECC) operations and key management.
*/
export declare class SigningKey {
#private;
/**
* Creates a new **SigningKey** for %%privateKey%%.
*/
constructor(privateKey: BytesLike);
/**
* The private key.
*/
get privateKey(): string;
/**
* The uncompressed public key.
*
* This will always begin with the prefix ``0x04`` and be 132
* characters long (the ``0x`` prefix and 130 hexadecimal nibbles).
*/
get publicKey(): string;
/**
* The compressed public key.
*
* This will always begin with either the prefix ``0x02`` or ``0x03``
* and be 68 characters long (the ``0x`` prefix and 33 hexadecimal
* nibbles)
*/
get compressedPublicKey(): string;
/**
* Return the signature of the signed %%digest%%.
*/
sign(digest: BytesLike): Signature;
/**
* Returns the [[link-wiki-ecdh]] shared secret between this
* private key and the %%other%% key.
*
* The %%other%% key may be any type of key, a raw public key,
* a compressed/uncompressed pubic key or aprivate key.
*
* Best practice is usually to use a cryptographic hash on the
* returned value before using it as a symetric secret.
*
* @example:
* sign1 = new SigningKey(id("some-secret-1"))
* sign2 = new SigningKey(id("some-secret-2"))
*
* // Notice that privA.computeSharedSecret(pubB)...
* sign1.computeSharedSecret(sign2.publicKey)
* //_result:
*
* // ...is equal to privB.computeSharedSecret(pubA).
* sign2.computeSharedSecret(sign1.publicKey)
* //_result:
*/
computeSharedSecret(other: BytesLike): string;
/**
* Compute the public key for %%key%%, optionally %%compressed%%.
*
* The %%key%% may be any type of key, a raw public key, a
* compressed/uncompressed public key or private key.
*
* @example:
* sign = new SigningKey(id("some-secret"));
*
* // Compute the uncompressed public key for a private key
* SigningKey.computePublicKey(sign.privateKey)
* //_result:
*
* // Compute the compressed public key for a private key
* SigningKey.computePublicKey(sign.privateKey, true)
* //_result:
*
* // Compute the uncompressed public key
* SigningKey.computePublicKey(sign.publicKey, false);
* //_result:
*
* // Compute the Compressed a public key
* SigningKey.computePublicKey(sign.publicKey, true);
* //_result:
*/
static computePublicKey(key: BytesLike, compressed?: boolean): string;
/**
* Returns the public key for the private key which produced the
* %%signature%% for the given %%digest%%.
*
* @example:
* key = new SigningKey(id("some-secret"))
* digest = id("hello world")
* sig = key.sign(digest)
*
* // Notice the signer public key...
* key.publicKey
* //_result:
*
* // ...is equal to the recovered public key
* SigningKey.recoverPublicKey(digest, sig)
* //_result:
*
*/
static recoverPublicKey(digest: BytesLike, signature: SignatureLike): string;
/**
* Returns the point resulting from adding the ellipic curve points
* %%p0%% and %%p1%%.
*
* This is not a common function most developers should require, but
* can be useful for certain privacy-specific techniques.
*
* For example, it is used by [[HDNodeWallet]] to compute child
* addresses from parent public keys and chain codes.
*/
static addPoints(p0: BytesLike, p1: BytesLike, compressed?: boolean): string;
}

21
lib.commonjs/ethers.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
export { version } from "./_version.js";
export { decodeBytes32String, encodeBytes32String, AbiCoder, ConstructorFragment, ErrorFragment, EventFragment, Fragment, FunctionFragment, ParamType, checkResultErrors, Indexed, Interface, LogDescription, Result, TransactionDescription, Typed, } from "./abi/index.js";
export { getAddress, getIcapAddress, getCreateAddress, getCreate2Address, isAddressable, isAddress, resolveAddress } from "./address/index.js";
export { ZeroAddress, WeiPerEther, MaxUint256, MinInt256, MaxInt256, N, ZeroHash, EtherSymbol, MessagePrefix } from "./constants/index.js";
export { BaseContract, Contract, ContractFactory, ContractEventPayload, ContractTransactionReceipt, ContractTransactionResponse, EventLog, } from "./contract/index.js";
export { computeHmac, randomBytes, keccak256, ripemd160, sha256, sha512, pbkdf2, scrypt, scryptSync, lock, Signature, SigningKey } from "./crypto/index.js";
export { id, ensNormalize, isValidName, namehash, dnsEncode, hashMessage, verifyMessage, solidityPacked, solidityPackedKeccak256, solidityPackedSha256, TypedDataEncoder } from "./hash/index.js";
export { getDefaultProvider, Block, FeeData, Log, TransactionReceipt, TransactionResponse, AbstractSigner, NonceManager, VoidSigner, AbstractProvider, FallbackProvider, JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner, BrowserProvider, AlchemyProvider, AnkrProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, PocketProvider, QuickNodeProvider, IpcSocketProvider, SocketProvider, WebSocketProvider, EnsResolver, Network } from "./providers/index.js";
export { accessListify, computeAddress, recoverAddress, Transaction } from "./transaction/index.js";
export { decodeBase58, encodeBase58, decodeBase64, encodeBase64, concat, dataLength, dataSlice, getBytes, getBytesCopy, hexlify, isHexString, isBytesLike, stripZerosLeft, zeroPadBytes, zeroPadValue, defineProperties, assert, assertArgument, assertArgumentCount, assertNormalize, assertPrivate, makeError, isCallException, isError, FetchRequest, FetchResponse, FetchCancelSignal, FixedNumber, getBigInt, getNumber, getUint, toBeArray, toBigInt, toBeHex, toNumber, toQuantity, fromTwos, toTwos, mask, formatEther, parseEther, formatUnits, parseUnits, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs, decodeRlp, encodeRlp } from "./utils/index.js";
export { Mnemonic, BaseWallet, HDNodeWallet, HDNodeVoidWallet, Wallet, defaultPath, getAccountPath, isCrowdsaleJson, isKeystoreJson, decryptCrowdsaleJson, decryptKeystoreJsonSync, decryptKeystoreJson, encryptKeystoreJson, encryptKeystoreJsonSync, } from "./wallet/index.js";
export { Wordlist, LangEn, WordlistOwl, WordlistOwlA } from "./wordlists/index.js";
export type { JsonFragment, JsonFragmentType, InterfaceAbi, ParamTypeWalkFunc, ParamTypeWalkAsyncFunc } from "./abi/index.js";
export type { Addressable } from "./address/index.js";
export type { ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName, ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction, DeferredTopicFilter, Overrides } from "./contract/index.js";
export type { ProgressCallback, SignatureLike } from "./crypto/index.js";
export type { TypedDataDomain, TypedDataField } from "./hash/index.js";
export type { Provider, Signer } from "./providers/index.js";
export type { AccessList, AccessListish, AccessListEntry, TransactionLike } from "./transaction/index.js";
export type { BytesLike, BigNumberish, Numeric, ErrorCode, FixedFormat, Utf8ErrorFunc, UnicodeNormalizationForm, Utf8ErrorReason, RlpStructuredData, GetUrlResponse, FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc, FetchGatewayFunc, FetchGetUrlFunc, EthersError, UnknownError, NotImplementedError, UnsupportedOperationError, NetworkError, ServerError, TimeoutError, BadDataError, CancelledError, BufferOverrunError, NumericFaultError, InvalidArgumentError, MissingArgumentError, UnexpectedArgumentError, CallExceptionError, InsufficientFundsError, NonceExpiredError, OffchainFaultError, ReplacementUnderpricedError, TransactionReplacedError, UnconfiguredNameError, ActionRejectedError, CodedEthersError, } from "./utils/index.js";
export type { KeystoreAccount, EncryptOptions } from "./wallet/index.js";

12
lib.commonjs/hash/id.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* A simple hashing function which operates on UTF-8 strings to
* compute an 32-byte irentifier.
*
* This simply computes the [UTF-8 bytes](toUtf8Bytes) and computes
* the [[keccak256]].
*
* @example:
* id("hello world")
* //_result:
*/
export declare function id(value: string): string;

11
lib.commonjs/hash/index.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
/**
* About hashing here...
*
* @_section: api/hashing:Hashing Utilities [hashing]
*/
export { id } from "./id.js";
export { ensNormalize, isValidName, namehash, dnsEncode } from "./namehash.js";
export { hashMessage, verifyMessage } from "./message.js";
export { solidityPacked, solidityPackedKeccak256, solidityPackedSha256 } from "./solidity.js";
export { TypedDataEncoder } from "./typed-data.js";
export type { TypedDataDomain, TypedDataField } from "./typed-data.js";

31
lib.commonjs/hash/message.d.ts vendored Normal file
View File

@@ -0,0 +1,31 @@
import type { SignatureLike } from "../crypto/index.js";
/**
* Computes the [[link-eip-191]] personal-sign message digest to sign.
*
* This prefixes the message with [[MessagePrefix]] and the decimal length
* of %%message%% and computes the [[keccak256]] digest.
*
* If %%message%% is a string, it is converted to its UTF-8 bytes
* first. To compute the digest of a [[DataHexString]], it must be converted
* to [bytes](getBytes).
*
* @example:
* hashMessage("Hello World")
* //_result:
*
* // Hashes the SIX (6) string characters, i.e.
* // [ "0", "x", "4", "2", "4", "3" ]
* hashMessage("0x4243")
* //_result:
*
* // Hashes the TWO (2) bytes [ 0x42, 0x43 ]...
* hashMessage(getBytes("0x4243"))
* //_result:
*
* // ...which is equal to using data
* hashMessage(new Uint8Array([ 0x42, 0x43 ]))
* //_result:
*
*/
export declare function hashMessage(message: Uint8Array | string): string;
export declare function verifyMessage(message: Uint8Array | string, sig: SignatureLike): string;

Some files were not shown because too many files have changed in this diff Show More