Compare commits
No commits in common. "v4-legacy" and "main" have entirely different histories.
31
.eslintrc.js
31
.eslintrc.js
@ -1,31 +0,0 @@
|
||||
module.exports = {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
// "eslint:recommended",
|
||||
// "plugin:promise/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 5
|
||||
},
|
||||
"plugins": [
|
||||
"promise"
|
||||
],
|
||||
"rules": {
|
||||
"promise/always-return": "error",
|
||||
"promise/no-return-wrap": "error",
|
||||
"promise/param-names": "error",
|
||||
"promise/catch-or-return": "error",
|
||||
"promise/no-native": "off",
|
||||
// "promise/no-nesting": "warn",
|
||||
"promise/no-promise-in-callback": "warn",
|
||||
"promise/no-callback-in-promise": "warn",
|
||||
// "promise/avoid-new": "warn",
|
||||
"promise/no-new-statics": "error",
|
||||
"promise/no-return-in-finally": "warn",
|
||||
"promise/valid-params": "warn"
|
||||
}
|
||||
};
|
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
github: ethers-io
|
||||
custom: [ 'https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2', 'https://www.buymeacoffee.com/ricmoo' ]
|
81
.github/ISSUE_TEMPLATE/bug-report-legacy.yml
vendored
Normal file
81
.github/ISSUE_TEMPLATE/bug-report-legacy.yml
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
name: "Bug Report v5 (legacy)"
|
||||
description: "Open an issue for a bug in Ethers v5 (legacy)"
|
||||
title: "Add Bug Title Here"
|
||||
labels: [ "investigate", "v5" ]
|
||||
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**, specifically for the legacy v5 branch.
|
||||
|
||||
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: 5.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?
|
81
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
81
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
name: "Bug Report v6 (latest)"
|
||||
description: "Open an issue for a bug in Ethers v6 (latest)"
|
||||
title: "Add Bug Title Here"
|
||||
labels: [ "investigate", "v6" ]
|
||||
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: 6.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
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
23
.github/ISSUE_TEMPLATE/documentation.yml
vendored
Normal file
23
.github/ISSUE_TEMPLATE/documentation.yml
vendored
Normal 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
|
26
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
26
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal 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
|
48
.github/workflows/generate-docs.yml
vendored
Normal file
48
.github/workflows/generate-docs.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
name: Generate Documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "src.ts/**"
|
||||
- "docs.wrm/**"
|
||||
|
||||
jobs:
|
||||
docs:
|
||||
name: Generate Documentation
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
environment: ethers-tests
|
||||
env:
|
||||
FAUCET_PRIVATEKEY: ${{ secrets.FAUCET_PRIVATEKEY }}
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20.x
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: "0"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Install Flatworm
|
||||
run: npm install --no-save 'https://github.com/ricmoo/flatworm.git#tsdocs'
|
||||
|
||||
- name: Build Documentation
|
||||
run: node node_modules/flatworm/lib/cli-test ./docs.wrm/config.mjs
|
||||
|
||||
- name: Upload documentation to to docs.ethers.org
|
||||
uses: ethers-io/sync-s3-action@main
|
||||
with:
|
||||
aws_access_key_id: ${{ secrets.DOCS_AWS_ACCESS_KEY_ID }}
|
||||
aws_secret_access_key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY}}
|
||||
aws_s3_bucket: ethers.org
|
||||
source_folder: 'output/docs/'
|
||||
destination_prefix: 'docs/'
|
||||
aws_cloudfront_id: ${{ secrets.DOCS_AWS_CLOUDFRONT_ID }}
|
46
.github/workflows/test-browser.yml
vendored
Normal file
46
.github/workflows/test-browser.yml
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
name: Browser Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "src.ts/**"
|
||||
- "lib.esm/**"
|
||||
- "lib.commonjs/**"
|
||||
- "misc/test-browser/**"
|
||||
|
||||
jobs:
|
||||
test-browser:
|
||||
name: Run Browser Tests
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
environment: ethers-tests
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20.x
|
||||
|
||||
- name: Install and run Geth
|
||||
uses: ethers-io/run-geth-action@main
|
||||
|
||||
- name: Insall Chrome
|
||||
run: wget -q 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb' && sudo dpkg --install google-chrome-stable_current_amd64.deb
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build browser bundles (from TypeScript)
|
||||
run: npm run build-dist
|
||||
|
||||
- name: Run tests
|
||||
run: npm run test-browser
|
109
.github/workflows/test-ci.yml
vendored
Normal file
109
.github/workflows/test-ci.yml
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
name: CI Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "src.ts/**"
|
||||
- "lib.esm/**"
|
||||
- "lib.commonjs/**"
|
||||
|
||||
jobs:
|
||||
|
||||
test-node:
|
||||
#if: ${{ false }} # disable for now
|
||||
|
||||
name: Run Node.js Tests
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
environment: ethers-tests
|
||||
env:
|
||||
FAUCET_PRIVATEKEY: ${{ secrets.FAUCET_PRIVATEKEY }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [ 18.x, 20.x ]
|
||||
test-type: [ esm, commonjs ]
|
||||
|
||||
steps:
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install and run Geth
|
||||
uses: ethers-io/run-geth-action@main
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build ESM and CommonJS (from TypeScript)
|
||||
run: npm run build-all
|
||||
|
||||
- name: Run tests (${{ matrix.test-type }})
|
||||
run: npm run test-${{ matrix.test-type }}
|
||||
|
||||
|
||||
coverage:
|
||||
#if: ${{ false }} # disable for now
|
||||
|
||||
name: Generate Coverage Report
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
environment: ethers-tests
|
||||
env:
|
||||
FAUCET_PRIVATEKEY: ${{ secrets.FAUCET_PRIVATEKEY }}
|
||||
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20.x
|
||||
|
||||
- name: Install and run Geth
|
||||
uses: ethers-io/run-geth-action@main
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build ESM (from TypeScript)
|
||||
run: npm run build
|
||||
|
||||
- name: Run coverage tests
|
||||
run: npm run test-coverage
|
||||
|
||||
- name: Store coverage summary artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: coverage-summary
|
||||
path: ./output/summary.txt
|
||||
|
||||
- name: Tar coverage files
|
||||
run: tar -cvf ./output/coverage.tar ./output/lcov-report/
|
||||
|
||||
- name: Store full coverage artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: coverage-complete
|
||||
path: ./output/coverage.tar
|
||||
|
||||
- name: Upload coverage to build.ethers.org
|
||||
uses: ethers-io/sync-s3-action@main
|
||||
with:
|
||||
aws_access_key_id: ${{ secrets.BUILD_AWS_ACCESS_KEY_ID }}
|
||||
aws_secret_access_key: ${{ secrets.BUILD_AWS_SECRET_ACCESS_KEY}}
|
||||
aws_s3_bucket: ethers.org
|
||||
source_folder: 'output/'
|
||||
destination_prefix: 'build/output/'
|
||||
aws_cloudfront_id: ${{ secrets.BUILD_AWS_CLOUDFRONT_ID }}
|
86
.github/workflows/test-env.yml
vendored
Normal file
86
.github/workflows/test-env.yml
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
name: Environment Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
|
||||
test-tsc-env:
|
||||
name: Test TypeScript Environments
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
npm_config_registry: http://localhost:8043
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
tsModuleResolution: [ "node", "node16", "nodenext" ]
|
||||
tsModule: [ "commonjs", "es2020" ]
|
||||
|
||||
steps:
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20.x
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: "faux_modules/ethers"
|
||||
|
||||
- name: Copy tests to working directory
|
||||
run: cp -r faux_modules/ethers/testcases/test-env/test-tsc/* .
|
||||
|
||||
- name: Prepare setup moduleResolution=${{ matrix.tsModuleResolution }} module=${{ matrix.tsModule }}
|
||||
run: node prepare.cjs ${{ matrix.tsModuleResolution }} ${{ matrix.tsModule }}
|
||||
|
||||
- name: Dump Config
|
||||
run: cat package.json tsconfig.json
|
||||
|
||||
- name: Install and run Faux Registry
|
||||
uses: ethers-io/hijack-npm-action@main
|
||||
|
||||
- name: Install packages
|
||||
run: npm install
|
||||
|
||||
- name: Dump Faux Logs
|
||||
run: cat .fauxNpm.log
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
test-angular:
|
||||
name: Test Angular Environment
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
npm_config_registry: http://localhost:8043
|
||||
|
||||
steps:
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20.x
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: "faux_modules/ethers"
|
||||
|
||||
- name: Copy tests to working directory
|
||||
run: cp -r faux_modules/ethers/testcases/test-env/angular/* .
|
||||
|
||||
- name: Install and run Faux Registry
|
||||
uses: ethers-io/hijack-npm-action@main
|
||||
|
||||
- name: Install packages
|
||||
run: npm install
|
||||
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
|
17
.gitignore
vendored
17
.gitignore
vendored
@ -1,10 +1,7 @@
|
||||
node_modules/
|
||||
obsolete/
|
||||
.test-account.key
|
||||
.account.key
|
||||
.DS_Store
|
||||
.tmp/
|
||||
docs/build/doctrees/
|
||||
docs/build/html/_sources/
|
||||
dist/types/shims/
|
||||
shims/*.d.ts
|
||||
node_modules/**
|
||||
output/**
|
||||
|
||||
**/*.save
|
||||
**/*.swp
|
||||
**/*.tgz
|
||||
dist/*.gz
|
||||
|
38
.npmignore
38
.npmignore
@ -1,13 +1,31 @@
|
||||
# Config files for testing and linting
|
||||
.eslintrc.js
|
||||
.travis.yml
|
||||
|
||||
# This is only needed for building dist and library files
|
||||
gulpfile.js
|
||||
# Ignore TypeScript config and caches
|
||||
tsconfig.*.json
|
||||
tsconfig.tsbuildinfo
|
||||
rollup.config.js
|
||||
output/**
|
||||
docs.wrm/**
|
||||
.github/**
|
||||
|
||||
# We do not need the TypeScipt source in deployments
|
||||
tsconfig.json
|
||||
src.ts/
|
||||
# Ignore admin scripts and files
|
||||
src.ts/_admin/**
|
||||
lib.commonjs/_admin/**
|
||||
lib.esm/_admin/**
|
||||
types/_admin/**
|
||||
reporter.cjs
|
||||
package-commonjs.json
|
||||
.github/workflows/test-ci.yml
|
||||
|
||||
# To run tests, checkout GitHub
|
||||
tests/
|
||||
# Ignore test cases
|
||||
src.ts/_tests/**
|
||||
lib.commonjs/_tests/**
|
||||
lib.esm/_tests/**
|
||||
types/_tests/**
|
||||
testcases/**
|
||||
|
||||
# Ignore random junk
|
||||
.DS_Store
|
||||
node_modules/**
|
||||
misc/**
|
||||
**/*.tgz
|
||||
dist/*.gz
|
||||
|
1
.npmrc
Normal file
1
.npmrc
Normal file
@ -0,0 +1 @@
|
||||
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/
|
17
.travis.yml
17
.travis.yml
@ -1,17 +0,0 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "6"
|
||||
- "8"
|
||||
- "10"
|
||||
|
||||
env:
|
||||
- RUN_PHANTOMJS=0
|
||||
- RUN_PHANTOMJS=1
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- node_js: "6"
|
||||
env: RUN_PHANTOMJS=1
|
||||
- node_js: "8"
|
||||
env: RUN_PHANTOMJS=1
|
576
CHANGELOG.md
576
CHANGELOG.md
@ -1,321 +1,339 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
Change Log
|
||||
==========
|
||||
|
||||
ethers/v4.0.49 (2021-07-19 23:23)
|
||||
This change log is maintained by `src.ts/_admin/update-changelog.ts` but may also be manually updated.
|
||||
|
||||
ethers/v6.12.0 (2024-04-17 01:09)
|
||||
---------------------------------
|
||||
|
||||
- Updated elliptic library. ([#1439](https://github.com/ethers-io/ethers.js/issues/1439), [#1782](https://github.com/ethers-io/ethers.js/issues/1782); [9e94c03](https://github.com/ethers-io/ethers.js/commit/9e94c03d01ba51ef9b7b0cec060cb5077dd1b2e7))
|
||||
|
||||
ethers/v4.0.48 (2020-08-24 15:44)
|
||||
- Added Linea Sepolia network and Infura endpoint ([#4655](https://github.com/ethers-io/ethers.js/issues/4655); [b4aaab8](https://github.com/ethers-io/ethers.js/commit/b4aaab8d39fe47f8a1a296fa442f0856f84faf03)).
|
||||
- Do not send unsubscribe messages to destroyed Providers ([#4678](https://github.com/ethers-io/ethers.js/issues/4678); [c45935e](https://github.com/ethers-io/ethers.js/commit/c45935e29ca0dd1ecdf1277fa1107246041be580)).
|
||||
- Get definitive network from InfuraProvider when using InfuraWebSocketProvider ([38e32d8](https://github.com/ethers-io/ethers.js/commit/38e32d82145eb289e5179f9b6b11f4a9225a7022)).
|
||||
- Better error messages for transaction field mismatch ([#4659](https://github.com/ethers-io/ethers.js/issues/4659); [9230aa0](https://github.com/ethers-io/ethers.js/commit/9230aa0b9a88b5241915a8d6afa8a522d35abd5d)).
|
||||
- Added prevRandao to block ([#3372](https://github.com/ethers-io/ethers.js/issues/3372); [ec6a754](https://github.com/ethers-io/ethers.js/commit/ec6a754f0c8647dae59c73b2589225cb200d83dd)).
|
||||
- Added Polygon Amoy testnet ([#4645](https://github.com/ethers-io/ethers.js/issues/4645); [1717abb](https://github.com/ethers-io/ethers.js/commit/1717abbf29a14a6f6b106e479fe9a5b1f8768dc4)).
|
||||
- Added Chainstack provider ([#2741](https://github.com/ethers-io/ethers.js/issues/2741); [014004d](https://github.com/ethers-io/ethers.js/commit/014004d9402d7fd8c15553792cfb7a8a84ed327a)).
|
||||
- Added deep convertion to Result for toObject and toArray ([#4681](https://github.com/ethers-io/ethers.js/issues/4681); [03bfe2a](https://github.com/ethers-io/ethers.js/commit/03bfe2a4f7b29b15cd90127974b7fc1d8b03edf9)).
|
||||
- Added EIP-4844 broadcast support ([92bad88](https://github.com/ethers-io/ethers.js/commit/92bad88261a5d8a538535a7d5528162fe5010527)).
|
||||
- Fix ignored throttle parameters ([#4663](https://github.com/ethers-io/ethers.js/issues/4663); [12772e9](https://github.com/ethers-io/ethers.js/commit/12772e9498b70f8538838f30e16f3792ea90e173)).
|
||||
|
||||
ethers/v6.11.1 (2024-02-14 13:13)
|
||||
---------------------------------
|
||||
|
||||
- Bumped elliptic version for security updates. ([f79c965](https://github.com/ethers-io/ethers.js/commit/f79c9655bdd13ada834a6af9f66f93851740a9ab))
|
||||
- Throw an error when attempting to derive from a master path from a non-master node ([#4551](https://github.com/ethers-io/ethers.js/issues/4551); [556fdd9](https://github.com/ethers-io/ethers.js/commit/556fdd91d9b6bf7db4041bb099e66b2080e1a985)).
|
||||
- Allow ENS wildcards with labels up to 255 bytes wide; discussed with ENS and deemed safe ([#4543](https://github.com/ethers-io/ethers.js/issues/4543); [7f14bde](https://github.com/ethers-io/ethers.js/commit/7f14bdebf1aef6760462a1c2437c31f002b984fe)).
|
||||
- Enforce string is passed to toUtf8Bytes ([#4583](https://github.com/ethers-io/ethers.js/issues/4583); [f45bb87](https://github.com/ethers-io/ethers.js/commit/f45bb87aefaf2c6c3a4991f6e30a81c227ae83c0)).
|
||||
- Fix transaction.index not being populated on some backends ([#4591](https://github.com/ethers-io/ethers.js/issues/4591); [7f0e140](https://github.com/ethers-io/ethers.js/commit/7f0e140d5e3925a42e8bb2ac9eb1ba3fbd939864)).
|
||||
|
||||
ethers/v4.0.47 (2020-04-21 23:15)
|
||||
ethers/v6.11.0 (2024-02-08 20:26)
|
||||
---------------------------------
|
||||
|
||||
- Fixed typo in error message. ([#778](https://github.com/ethers-io/ethers.js/issues/778); [fab14f8](https://github.com/ethers-io/ethers.js/commit/fab14f8f5a16091810bbe4d35f38e0b976adab7c)).
|
||||
- Allow receive type in ABI without warning. ([#746](https://github.com/ethers-io/ethers.js/issues/746); [e8c89d7](https://github.com/ethers-io/ethers.js/commit/e8c89d7ca9cea6e20281f614c4fb22f180114622)).
|
||||
- Allow transaction encoding for inferred type transactions ([f02211d](https://github.com/ethers-io/ethers.js/commit/f02211d055567b51373b5faa2c3dc6efe0523618)).
|
||||
- Added EIP-4788, receipts root and state root fields to Block ([#4570](https://github.com/ethers-io/ethers.js/issues/4570); [c5f126f](https://github.com/ethers-io/ethers.js/commit/c5f126faf7d826b6a99df0ee578ff3d0ef409381)).
|
||||
- Added EIP-4844 fields to Provider classes and formatter ([#4570](https://github.com/ethers-io/ethers.js/issues/4570); [7b4f2c1](https://github.com/ethers-io/ethers.js/commit/7b4f2c1a74db411829b5e8ef758bfa2ee21e5890)).
|
||||
- Assert BrowserProvider receives an EIP-1193 provider to fail early when passing undefined ethereum object ([b69f43b](https://github.com/ethers-io/ethers.js/commit/b69f43bc6f35da881ca7a0c8ccc5fda92edd076d)).
|
||||
- Add timeout to ContractTransactionResponse wait ([#4497](https://github.com/ethers-io/ethers.js/issues/4497); [095de51](https://github.com/ethers-io/ethers.js/commit/095de51e605a9b88576e5e34fd55a6e32befa4eb)).
|
||||
- Allow override keyword in human-readable ABI and improve error messages ([#4514](https://github.com/ethers-io/ethers.js/issues/4514), [#4548](https://github.com/ethers-io/ethers.js/issues/4548); [be5ec2d](https://github.com/ethers-io/ethers.js/commit/be5ec2d327a503b2e5fc0f37c47eee9e828f8e23)).
|
||||
- Expand Contract sub-class to accept BaseContract super-class constructor arguments ([#4538](https://github.com/ethers-io/ethers.js/issues/4538); [98496bc](https://github.com/ethers-io/ethers.js/commit/98496bc48ec23ce0d9c21d3c6c87e5b1b796a610)).
|
||||
- Allow network for default provider to be null to select mainnet ([#4501](https://github.com/ethers-io/ethers.js/issues/4501); [b6bf7ab](https://github.com/ethers-io/ethers.js/commit/b6bf7aba62fb38839cd01858432b801cc5c28a11)).
|
||||
- Allow long dnsEncode names with optional length parameter ([#4543](https://github.com/ethers-io/ethers.js/issues/4543); [a136348](https://github.com/ethers-io/ethers.js/commit/a1363483a56b0dee342595c8f44ed8fcce7ecca9)).
|
||||
- Fix parseLog signature when receiving read-only array for topics ([#4029](https://github.com/ethers-io/ethers.js/issues/4029), [#4459](https://github.com/ethers-io/ethers.js/issues/4459); [20cd8a2](https://github.com/ethers-io/ethers.js/commit/20cd8a23eaf8e8a14e2b51f7f64da4cb3e32fccb)).
|
||||
- Use Secure endpoints for BNB on Etherscan ([#4525](https://github.com/ethers-io/ethers.js/issues/4525); [1f6e188](https://github.com/ethers-io/ethers.js/commit/1f6e1882515195bd67f0bce9fe347ec05107324b)).
|
||||
- Added holesky network and related end-points for supporting providers ([c6e6c43](https://github.com/ethers-io/ethers.js/commit/c6e6c432574a0b7e55c300ab3e470aafdace28b3)).
|
||||
- Added EIP-4844 BLOb transactions ([#4554](https://github.com/ethers-io/ethers.js/issues/4554); [9c1e82e](https://github.com/ethers-io/ethers.js/commit/9c1e82e1230526ebcd62902890c4f24b1f7f7d79)).
|
||||
- Normalize EIP-712 types before computing the payload ([#4541](https://github.com/ethers-io/ethers.js/issues/4541); [56c1361](https://github.com/ethers-io/ethers.js/commit/56c1361ee83db8b68859caf0850c95ff70e7e306)).
|
||||
- Updated thrid-part provider URLs for QuickNode ([2b4891d](https://github.com/ethers-io/ethers.js/commit/2b4891d86e72e849079cb1dc98b18e158b0c0620)).
|
||||
- Fixed normalization and abstracted EIP-712 Array parsing ([#4541](https://github.com/ethers-io/ethers.js/issues/4541); [8f99601](https://github.com/ethers-io/ethers.js/commit/8f99601df1f26a8ba4d6d9dea5e033e7f688107e)).
|
||||
- Updated third-party provider network URLs ([#4542](https://github.com/ethers-io/ethers.js/issues/4542); [84ca14f](https://github.com/ethers-io/ethers.js/commit/84ca14f1ffc5afbdd7f4c26a9b734ec5951eee3c)).
|
||||
- Added additional sepolia testnets ([4efef76](https://github.com/ethers-io/ethers.js/commit/4efef76e8cab0acaf1b2ba231a0148f9381bb1ee)).
|
||||
- Fix EIP-712 type aliases for uint and int ([#4541](https://github.com/ethers-io/ethers.js/issues/4541); [43fb9c2](https://github.com/ethers-io/ethers.js/commit/43fb9c233696aeaa80b1c2b0e5fafce90e0ad508)).
|
||||
- Fixed typo in Error string ([#4539](https://github.com/ethers-io/ethers.js/issues/4539); [7882905](https://github.com/ethers-io/ethers.js/commit/78829050853093bc5291ae78fc5a904044759aa0)).
|
||||
- Better debugging output on fetch errors ([bee07a0](https://github.com/ethers-io/ethers.js/commit/bee07a0750b448a9d13c2d57014bcf27f43e2ed7)).
|
||||
|
||||
ethers/v4.0.46 (2020-03-14 16:56)
|
||||
ethers/v6.10.0 (2024-01-12 19:46)
|
||||
---------------------------------
|
||||
|
||||
- Fixed typo in error. ([#722](https://github.com/ethers-io/ethers.js/issues/722); [3b7176f](https://github.com/ethers-io/ethers.js/commit/3b7176f322376f8f42c333082388ef56d1720bae)).
|
||||
- Fix EtherscanProvider from throwing outside async context. ([#729](https://github.com/ethers-io/ethers.js/issues/729); [5f7ddcd](https://github.com/ethers-io/ethers.js/commit/5f7ddcd5d71d8a1c9efbeef1232c34ef93f92e5a)).
|
||||
- Limit decoded result imflation ratio from ABI-encoded data ([#4537](https://github.com/ethers-io/ethers.js/issues/4537); [1b4debd](https://github.com/ethers-io/ethers.js/commit/1b4debd4a9e61d171bfc60590116facb8bdbd2da)).
|
||||
|
||||
ethers/v4.0.45 (2020-02-16 16:16)
|
||||
---------------------------------
|
||||
|
||||
- Added default API key for EtherscanProvider. ([a930047](https://github.com/ethers-io/ethers.js/commit/a930047a102d3369c4e847d7ef43bd850704cf00)).
|
||||
- Fixed typo in arguments name for waitForTransaction. ([#477](https://github.com/ethers-io/ethers.js/issues/477); [4e41871](https://github.com/ethers-io/ethers.js/commit/4e41871fa4cf701d714ad73527a367e9ca1d3431)).
|
||||
- Partial support for non-English mnemonics for encrypted JSON wallets. ([#685](https://github.com/ethers-io/ethers.js/issues/685); [9947acc](https://github.com/ethers-io/ethers.js/commit/9947acc349691734bce8b33d870ab48944a7962f)).
|
||||
- Updated expected balance in test cases. ([748f896](https://github.com/ethers-io/ethers.js/commit/748f89660ac4bf60175f936da755cf1a0d370f46)).
|
||||
|
||||
ethers/v4.0.44 (2020-01-29 22:01)
|
||||
---------------------------------
|
||||
|
||||
- Fix backwards compatibility with certain parsed JSON objects passed into Interface and Contracts ([#721](https://github.com/ethers-io/ethers.js/issues/721); [0589b31](https://github.com/ethers-io/ethers.js/commit/0589b3102e2da702f4ac19a32c8b083faa6bbeea)).
|
||||
- Updated ENS registry address for all networks ([df51b26](https://github.com/ethers-io/ethers.js/commit/df51b26fe71c33fb8aa610d95c4955647345ce0a)).
|
||||
|
||||
ethers/v4.0.43 (2020-01-10 21:14)
|
||||
---------------------------------
|
||||
|
||||
- Fixed Contract and Interface constructor abi paramter type; should be a Fragment not a ParamType ([#602](https://github.com/ethers-io/ethers.js/issues/602); [6da5c53](https://github.com/ethers-io/ethers.js/commit/6da5c531206777ceef98d111a12b050a04bdf49c)).
|
||||
- Add missing chainId to transaction responses ([#700](https://github.com/ethers-io/ethers.js/issues/700); [26d3271](https://github.com/ethers-io/ethers.js/commit/26d32716436cd8925a5278173ba72ad54e00eef8)).
|
||||
- Fix resolveName when name is an address with an invalid checksum ([#694](https://github.com/ethers-io/ethers.js/issues/694); [bd066b8](https://github.com/ethers-io/ethers.js/commit/bd066b85421b1d0e575180e0626fcfb70135caf0)).
|
||||
- Fixed testcases for PhantomJS syntax. ([447889](https://github.com/ethers-io/ethers.js/commit/4478896ca5e77be0e20d6d491a092da981ed5343))
|
||||
|
||||
|
||||
ethers/v4.0.42 (2020-01-03 18:35)
|
||||
---------------------------------
|
||||
|
||||
- Properly handle errors in the IpcProvider ([#695](https://github.com/ethers-io/ethers.js/issues/695); [c76e01e](https://github.com/ethers-io/ethers.js/commit/c76e01e61fd52692f58c516842f7ed3b252b0f83))
|
||||
- Added utility function to compute CREATE2 addresses ([#697](https://github.com/ethers-io/ethers.js/issues/697); [f8087ae](https://github.com/ethers-io/ethers.js/commit/f8087ae39ce7631425b6b4763347a4f9618f9730))
|
||||
|
||||
ethers/v4.0.41 (2019-12-21 01:05)
|
||||
---------------------------------
|
||||
|
||||
- Added proper support for v0.6 Solidity JSON type ([#688](https://github.com/ethers-io/ethers.js/issues/688); [20f34f1](https://github.com/ethers-io/ethers.js/commit/20f34f1ba9c698d1731cb12c5de1822ad462fd7f)).
|
||||
|
||||
ethers/v4.0.40 (2019-11-24 19:58)
|
||||
---------------------------------
|
||||
|
||||
- Update elliptic package to protect from Minerva timing attack ([#666](https://github.com/ethers-io/ethers.js/issues/666); [20409c0](https://github.com/ethers-io/ethers.js/commit/20409c083cd428c46cba09488ee609cc14ff1d2b)).
|
||||
- Do not poll if disabled during the previous event loop. ([7a90f18](https://github.com/ethers-io/ethers.js/commit/7a90f18145931e7ff790cd9e1fd549929fbb9023)).
|
||||
- Moved node types to devDependencies ([#663](https://github.com/ethers-io/ethers.js/issues/663); [df1ae61](https://github.com/ethers-io/ethers.js/commit/df1ae611bab0955005b0da6604191b60b34f198f)).
|
||||
- Added provider property to Web3Provider ([#641](https://github.com/ethers-io/ethers.js/issues/641); [6009a26](https://github.com/ethers-io/ethers.js/commit/6009a26c89c359ae44ef4b6e8a664ed57db24f67)).
|
||||
|
||||
ethers/v4.0.39 (2019-10-30 19:15)
|
||||
---------------------------------
|
||||
|
||||
- Fix filters by forcing a poll instantly when polling starts to capture the current block. ([#613](https://github.com/ethers-io/ethers.js/issues/613); [d0e0e30](https://github.com/ethers-io/ethers.js/commit/d0e0e30532baf387df6b4a8efe0805986cc265f2))
|
||||
|
||||
ethers/v4.0.38 (2019-10-17 01:28)
|
||||
---------------------------------
|
||||
|
||||
- Fixed TypeScript 3.7-beta import issue. ([#622](https://github.com/ethers-io/ethers.js/issues/622); [0609ea9](https://github.com/ethers-io/ethers.js/commit/0609ea96519bf4afe6badc5f43c0d03ca91b8363))
|
||||
|
||||
ethers/v4.0.37 (2019-09-06 19:10)
|
||||
---------------------------------
|
||||
|
||||
- Added pkg.ethereum key for donations. ([#593](https://github.com/ethers-io/ethers.js/issues/593); [004cb82](https://github.com/ethers-io/ethers.js/commit/004cb826d2441cd5b0770161e66d351b2ba5abb5))
|
||||
- Fixed typo in error message. ([#592](https://github.com/ethers-io/ethers.js/issues/592); [bfcf224](https://github.com/ethers-io/ethers.js/commit/bfcf224b2bcfa10ff1a1250c3943d33daa98d6d8))
|
||||
- Fixed typo in error message. ([#580](https://github.com/ethers-io/ethers.js/issues/580); [c969fe5](https://github.com/ethers-io/ethers.js/commit/c969fe5a68a0703a892dc5ab6e09a6938ccc9e4c))
|
||||
- Fixed typo in error message. ([#574](https://github.com/ethers-io/ethers.js/issues/574); [8737f12](https://github.com/ethers-io/ethers.js/commit/8737f12e1bbeee477413e1d96c4124463256161e))
|
||||
|
||||
ethers/v4.0.36 (2019-08-26 16:09)
|
||||
---------------------------------
|
||||
|
||||
- Updated package-lock for security reasons; dev dependency only. ([11c250f](https://github.com/ethers-io/ethers.js/commit/11c250ff7c78fa6c28c1bc22f91ea214526c467d))
|
||||
- Fixed typo in error message. ([#592](https://github.com/ethers-io/ethers.js/issues/592); [c303199](https://github.com/ethers-io/ethers.js/commit/c303199d26d6c5959b1a85a24ca162a1e405c63b))
|
||||
- Fixed ENS lookupAddress when the resolver isn't configured. ([#581](https://github.com/ethers-io/ethers.js/issues/581); [760a5ae](https://github.com/ethers-io/ethers.js/commit/760a5aec74cfc2ce7467ae89214606500ed7a762))
|
||||
- Allow Secret Storage wallet address to be optional. ([#582](https://github.com/ethers-io/ethers.js/issues/582); [24f243e](https://github.com/ethers-io/ethers.js/commit/24f243e689112048df502e10dbc2935303280c4d))
|
||||
- Updated package-lock for lodash security advisory; the package is only a development dependency, so no urgent need to publish, just for developers. ([lodash/lodash#4336](https://github.com/lodash/lodash/pull/4336); [d719064](https://github.com/ethers-io/ethers.js/commit/d7190646280af9bb36352fc502ba7f6e84559026))
|
||||
|
||||
ethers/v4.0.33 (2019-07-09 20:17)
|
||||
---------------------------------
|
||||
|
||||
- Reduce number of HDNode tests which cause TravisCI to timeout. ([a7d0b41](https://github.com/ethers-io/ethers.js/commit/a7d0b41d9865ffb9bdda497f77c316938f44cd46))
|
||||
|
||||
ethers/v4.0.32 (2019-07-09 16:56)
|
||||
---------------------------------
|
||||
|
||||
- Added test cases for case-agnostic mnemonics. ([#557](https://github.com/ethers-io/ethers.js/issues/557); [a34ca6b](https://github.com/ethers-io/ethers.js/commit/a34ca6b3a38d0854d5b57c908d523a98262c0f53))
|
||||
- Make mnemonics case-agnostic. ([#557](https://github.com/ethers-io/ethers.js/issues/557); [ef91dcd](https://github.com/ethers-io/ethers.js/commit/ef91dcd757349dfb31ad2fbd0b840abe6a4043be))
|
||||
- Added tests for testnet extended private key. ([#553](https://github.com/ethers-io/ethers.js/issues/553); [a5296a9](https://github.com/ethers-io/ethers.js/commit/a5296a9258a475b6d3ebe4c6b848945a77ba4887))
|
||||
|
||||
ethers/v4.0.31 (2019-06-28 15:39)
|
||||
---------------------------------
|
||||
|
||||
- Fixed testnet exteneded private keys. ([#553](https://github.com/ethers-io/ethers.js/issues/553); [fbf15c0](https://github.com/ethers-io/ethers.js/commit/fbf15c0ffe046290749fe307e9d4e8624b81664a))
|
||||
|
||||
ethers/v4.0.30 (2019-06-21 19:18)
|
||||
---------------------------------
|
||||
|
||||
- No longer use hard-coded id of 42 in Web3Provider. ([384fc32](https://github.com/ethers-io/ethers.js/commit/384fc328f2989882bf6027b2af48efa02f2fab53))
|
||||
|
||||
ethers/v4.0.29 (2019-06-10 01:58)
|
||||
---------------------------------
|
||||
|
||||
- Fixed error in throwing an error for ABI decode. ([#539](https://github.com/ethers-io/ethers.js/issues/539); [92c978e](https://github.com/ethers-io/ethers.js/commit/92c978e5c20aca96a4297c7d494e154c3a796e71))
|
||||
|
||||
ethers/v4.0.28 (2019-05-24 14:57)
|
||||
---------------------------------
|
||||
|
||||
- Warn on deprecated INFURA API Token; use Project ID instead. ([#462](https://github.com/ethers-io/ethers.js/issues/462); [19587ee](https://github.com/ethers-io/ethers.js/commit/19587eea3f3fadc301ff4d949646b700ebb4a85b))
|
||||
- Fixed typo in error message. ([#470](https://github.com/ethers-io/ethers.js/issues/470); [4a9373e](https://github.com/ethers-io/ethers.js/commit/4a9373e773dd78c62f4f5127f8357001e5940a22))
|
||||
- Export poll function. ([#514](https://github.com/ethers-io/ethers.js/issues/514); [2997bae](https://github.com/ethers-io/ethers.js/commit/2997bae93599294935d1e467d8ede2960ee92e50))
|
||||
- Fixed error message for unconfigured ENS names. ([#504](https://github.com/ethers-io/ethers.js/issues/504); [7075c8c](https://github.com/ethers-io/ethers.js/commit/7075c8c2352ec306b5679da6fbe7c2ddf7bd65d1))
|
||||
- Fixed security recommendations (development deps only; not a problem, but quiets automatic audits). ([a4a532f](https://github.com/ethers-io/ethers.js/commit/a4a532fe8e6a9fd8ef2ff069ea1b6c9ae28c4e5a))
|
||||
|
||||
ethers/v4.0.27 (2019-04-18 07:50)
|
||||
---------------------------------
|
||||
|
||||
- Increment JSON-RPC ID for JsonRpcProviders for environments that unsafely manage callbacks. ([#489](https://github.com/ethers-io/ethers.js/issues/489); [c93b489](https://github.com/ethers-io/ethers.js/commit/c93b48920e4861b4fe35c60be19344abbb19a184))
|
||||
|
||||
ethers/v4.0.26 (2019-03-08 14:29)
|
||||
---------------------------------
|
||||
|
||||
- Added goerli to InfuraProvider. ([#421](https://github.com/ethers-io/ethers.js/issues/421); [16c9745](https://github.com/ethers-io/ethers.js/commit/16c974532603b6ed7e49cedd6ce11f2e92158bf0))
|
||||
|
||||
ethers/v4.0.25 (2019-02-15 13:43)
|
||||
---------------------------------
|
||||
|
||||
- Added fastRetry to polling for JsonRpcSigner to improve polling for sent transactions. ([#402](https://github.com/ethers-io/ethers.js/issues/402); [f318fd9](https://github.com/ethers-io/ethers.js/commit/f318fd9cf1303fe2770f400cbce14c778f77e454))
|
||||
- Fix waitForTransaction delay. ([#424](https://github.com/ethers-io/ethers.js/issues/424); [c15a898](https://github.com/ethers-io/ethers.js/commit/c15a89832b2fd8ab06b9ec655487cb50e8ded7c1))
|
||||
- Fixed waitForTransaction and removeListener. ([#410](https://github.com/ethers-io/ethers.js/issues/410); [72edcd0](https://github.com/ethers-io/ethers.js/commit/72edcd054fa78c52c82c33bcc7e389d93ff517ec))
|
||||
- Updated BIP39 list in readme. ([e4a2f8a](https://github.com/ethers-io/ethers.js/commit/e4a2f8ac6c5c9bb5fc30d5720e1457381c82e608))
|
||||
|
||||
ethers/v4.0.24 (2019-02-11 19:22)
|
||||
---------------------------------
|
||||
|
||||
- Fixed support for calling self-destructed contracts. ([#411](https://github.com/ethers-io/ethers.js/issues/411); [0ed983a](https://github.com/ethers-io/ethers.js/commit/0ed983a264077d74d23da194b580fc702e9139a9))
|
||||
- Updated balance address for Goerli test cases. ([8fab48a](https://github.com/ethers-io/ethers.js/commit/8fab48a3803f521a77ad8cfc7176f3b819996f88))
|
||||
- Fixed utils test case for phantomjs. ([a2306f7](https://github.com/ethers-io/ethers.js/commit/a2306f7870ab75802af95cc0eab7fa77ca17d8d8))
|
||||
- Initial support for EIP-234; filter by blockHash. ([#412](https://github.com/ethers-io/ethers.js/issues/412); [60b75c1](https://github.com/ethers-io/ethers.js/commit/60b75c10d702b5a04ec1e381191fe1cd5a93274c))
|
||||
- Fixed out-of-safe-range hexlify values to throw an exception. ([#420](https://github.com/ethers-io/ethers.js/issues/420); [41c2c8a](https://github.com/ethers-io/ethers.js/commit/41c2c8a729816226bc38a5bc0e73e0c573afe25d))
|
||||
- Added goerli testnet support. ([#421](https://github.com/ethers-io/ethers.js/issues/421); [9785eed](https://github.com/ethers-io/ethers.js/commit/9785eed8dd227234afbfcb0eef9892e6a7a2b187))
|
||||
- Fixed missing TypeArray slice on constrained environments. ([14484e5](https://github.com/ethers-io/ethers.js/commit/14484e566edf60a493acb1128708136d4205e606))
|
||||
- Fixed test-hdnode for phantomjs; does not support let keyword. ([429af2c](https://github.com/ethers-io/ethers.js/commit/429af2c40db40dc2ff1fd33409f198c2ab3c9b16))
|
||||
- Added xpub and xpriv deserialization. ([#405](https://github.com/ethers-io/ethers.js/issues/405); [af3aed4](https://github.com/ethers-io/ethers.js/commit/af3aed4580da47be1f89fce94c37b91012f92b91))
|
||||
- Added xpub and xpriv test cases for HD nodes. ([#405](https://github.com/ethers-io/ethers.js/issues/405); [3a3764b](https://github.com/ethers-io/ethers.js/commit/3a3764bdb4838c81dcd7afbb6eabd2792d3a5b00))
|
||||
- Support for xpub and xpriv derivation and generating extended keys; no fromExtendedKey yet. ([#405](https://github.com/ethers-io/ethers.js/issues/405); [18ee2c5](https://github.com/ethers-io/ethers.js/commit/18ee2c518c252a18fa172a8a7092c58cf6c0b7c5))
|
||||
|
||||
ethers/v4.0.23 (2019-01-25 19:09)
|
||||
---------------------------------
|
||||
|
||||
- Fixed duplicate events from triggering. ([#404](https://github.com/ethers-io/ethers.js/issues/404); [908258f](https://github.com/ethers-io/ethers.js/commit/908258f8d4c56b58f6826011a805c2e690d9a4a0))
|
||||
|
||||
ethers/v4.0.22 (2019-01-24 16:53)
|
||||
---------------------------------
|
||||
|
||||
- Ganache does not include from in receipts. ([#400](https://github.com/ethers-io/ethers.js/issues/400); [b5f720a](https://github.com/ethers-io/ethers.js/commit/b5f720ace6ac3e43beb2aaeda774f00f050192f4))
|
||||
- Added to and from for Transaction Receipts. ([#398](https://github.com/ethers-io/ethers.js/issues/398); [700dd34](https://github.com/ethers-io/ethers.js/commit/700dd3413718ecfa3800aab361c4c5b91d1a7137))
|
||||
- Added v3 INFURA end-points to InfuraProvider. ([#286](https://github.com/ethers-io/ethers.js/issues/286); [f2dd977](https://github.com/ethers-io/ethers.js/commit/f2dd977de4fb6216d6a990d13999644a9be5815d))
|
||||
- Fixed long-response bug in IpcProvider. ([#384](https://github.com/ethers-io/ethers.js/issues/384); [5f01321](https://github.com/ethers-io/ethers.js/commit/5f013216c5f51830ef3fd3f725d42272f7ae5c99))
|
||||
|
||||
ethers/v4.0.21 (2019-01-17 16:33)
|
||||
---------------------------------
|
||||
|
||||
- Fixed path for x-ethers metadata and wallet. ([#392](https://github.com/ethers-io/ethers.js/issues/392); [e5bee7e](https://github.com/ethers-io/ethers.js/commit/e5bee7e5a34ba9cfddae8e3c43de10a8060f911a))
|
||||
- Fixed contract removeAllListeners which did not clean up the event loop properly. ([#391](https://github.com/ethers-io/ethers.js/issues/391); [6d08968](https://github.com/ethers-io/ethers.js/commit/6d08968b8789976ee5a7ef23e3dd73e73342cf5b))
|
||||
|
||||
ethers/v4.0.20 (2018-12-27 15:49)
|
||||
---------------------------------
|
||||
|
||||
- Added customizable log levels to quiet warnings. ([#379](https://github.com/ethers-io/ethers.js/issues/379); [f3ec27b](https://github.com/ethers-io/ethers.js/commit/f3ec27b95fcb56d521952c708fdc0229f6d6f7f3))
|
||||
|
||||
ethers/v4.0.19 (2018-12-14 18:37)
|
||||
---------------------------------
|
||||
|
||||
- Allow unchecked transactions which will remain unwrapped for the JsonRpcSigner. ([#340](https://github.com/ethers-io/ethers.js/issues/340); [99a2166](https://github.com/ethers-io/ethers.js/commit/99a21660ab5b360cc4cbdba87dc54245c00565b9))
|
||||
- Make it easier for sub-classes of Wallet to manage nonces. ([4bc62a1](https://github.com/ethers-io/ethers.js/commit/4bc62a1e8a2c240ff567140b981c6bf9da57594f))
|
||||
|
||||
ethers/v4.0.18 (2018-12-12 16:57)
|
||||
---------------------------------
|
||||
|
||||
- Allow nonce to be a BigNumber. ([#228](https://github.com/ethers-io/ethers.js/issues/228); [bcba17a](https://github.com/ethers-io/ethers.js/commit/bcba17a9e76e9ff7867e3d8e32a508fc1582e003))
|
||||
- Fixed typo in error strings. ([#376](https://github.com/ethers-io/ethers.js/issues/376); [918b66b](https://github.com/ethers-io/ethers.js/commit/918b66bc2e176fc3c6f3088cc10b9d03e2df1f6e))
|
||||
- Add isHexString to exported utils. ([#367](https://github.com/ethers-io/ethers.js/issues/367); [152d672](https://github.com/ethers-io/ethers.js/commit/152d672278477321d6ff5dab03b2d1e812151f45))
|
||||
- Add abs method to BigNumber. ([#375](https://github.com/ethers-io/ethers.js/issues/375); [51fb472](https://github.com/ethers-io/ethers.js/commit/51fb4728091a30d147b7dcd61e08562c6171b372))
|
||||
- Better error messages for namehash. ([#364](https://github.com/ethers-io/ethers.js/issues/364); [66440b8](https://github.com/ethers-io/ethers.js/commit/66440b8542e80e056bd96d94a1be9fcbb1c9b2d7))
|
||||
|
||||
ethers/v4.0.17 (2018-12-08 18:47)
|
||||
---------------------------------
|
||||
|
||||
- Fixed function name in parsed transactions. ([#370](https://github.com/ethers-io/ethers.js/issues/370); [6ca1d77](https://github.com/ethers-io/ethers.js/commit/6ca1d772986482b8be467d97fd9cd3107c959ab5))
|
||||
- Include request body in web errors. ([4f6748e](https://github.com/ethers-io/ethers.js/commit/4f6748ec4cc432a1bc2097619a25b9e7ce2b2faa))
|
||||
- Squashed unhandled promise exception for Providers that are never used. ([#362](https://github.com/ethers-io/ethers.js/issues/362); [f56fc57](https://github.com/ethers-io/ethers.js/commit/f56fc572f159e6375db27caa1b3d464dd67803c7))
|
||||
- Added gas estimation back into JsonRpcSigner. ([#365](https://github.com/ethers-io/ethers.js/issues/365); [16fdf6b](https://github.com/ethers-io/ethers.js/commit/16fdf6b621fd45bb1d6ab4e636388d9e7a9028d2))
|
||||
|
||||
ethers/v4.0.16 (2018-12-04 17:17)
|
||||
---------------------------------
|
||||
|
||||
|
||||
ethers/v4.0.15 (2018-12-04 17:14)
|
||||
---------------------------------
|
||||
|
||||
- Do not fill in implicit values for JSON-RPC based signers. ([#335](https://github.com/ethers-io/ethers.js/issues/335); [2d854bd](https://github.com/ethers-io/ethers.js/commit/2d854bd94c799271ce5a2aa4f5ad17d22c8d8dc0))
|
||||
- More relaxed transaction parsing. ([#357](https://github.com/ethers-io/ethers.js/issues/357); [9565c28](https://github.com/ethers-io/ethers.js/commit/9565c28a91b558a96a3895ccfc03975efc639432))
|
||||
- Allow any whitespace characters in human-readable ABI. ([#360](https://github.com/ethers-io/ethers.js/issues/360); [bc457bb](https://github.com/ethers-io/ethers.js/commit/bc457bb3bde7f3c3f1ca2e8345cdf1a4e0701454))
|
||||
|
||||
ethers/v4.0.14 (2018-11-27 17:33)
|
||||
---------------------------------
|
||||
|
||||
- Fixed contract proxied tx.wait receipt properties. ([#355](https://github.com/ethers-io/ethers.js/issues/355); [3f76f60](https://github.com/ethers-io/ethers.js/commit/3f76f603d9de66cb38b8c5d2e2fc6f7c6794d234))
|
||||
|
||||
ethers/v4.0.13 (2018-11-27 15:60)
|
||||
---------------------------------
|
||||
|
||||
- Check for partially-working normalize support. ([bb6bc4c](https://github.com/ethers-io/ethers.js/commit/bb6bc4cac330120e691a4a0566ff547342f62c0c))
|
||||
- Support for platforms where UTF-8 is only half broken. ([ef8b9c3](https://github.com/ethers-io/ethers.js/commit/ef8b9c36ef42ce79d8b5db390eea3deec55d9a6b))
|
||||
- Throw exception instead of returning null for getDefaultProvider. ([#351](https://github.com/ethers-io/ethers.js/issues/351); [31d3ee8](https://github.com/ethers-io/ethers.js/commit/31d3ee899f4331cb75952eceb07b9a8ad7b30e9f))
|
||||
|
||||
ethers/v4.0.12 (2018-11-20 15:42)
|
||||
---------------------------------
|
||||
|
||||
- Added default provider support for Ethereum classic. ([#351](https://github.com/ethers-io/ethers.js/issues/351); [bffc557](https://github.com/ethers-io/ethers.js/commit/bffc557be1b84ae2b69edd5071f7a072c94421e9))
|
||||
|
||||
ethers/v4.0.11 (2018-11-13 07:49)
|
||||
---------------------------------
|
||||
|
||||
- Fixed 0 confirmation waiting. ([#346](https://github.com/ethers-io/ethers.js/issues/346); [048c571](https://github.com/ethers-io/ethers.js/commit/048c571d3d307f6b5a0094865b54106f6d7c5ffa))
|
||||
|
||||
ethers/v4.0.10 (2018-11-12 17:23)
|
||||
---------------------------------
|
||||
|
||||
- Fix spacing in checkArgument errors. ([#318](https://github.com/ethers-io/ethers.js/issues/318); [88f2f51](https://github.com/ethers-io/ethers.js/commit/88f2f51266a66cc8a5934ef5371e0458d08a46e8))
|
||||
- Do not replay block events when the provider event block is reset. ([#343](https://github.com/ethers-io/ethers.js/issues/343); [93152ef](https://github.com/ethers-io/ethers.js/commit/93152ef86394720e911aaf98011013e6dae87c77))
|
||||
|
||||
ethers/v4.0.9 (2018-11-09 14:37)
|
||||
ethers/v6.9.2 (2024-01-02 19:12)
|
||||
--------------------------------
|
||||
|
||||
- Force unorm shim when String.prototype.normalize is broken. ([#338](https://github.com/ethers-io/ethers.js/issues/338); [478aaf9](https://github.com/ethers-io/ethers.js/commit/478aaf9619bd2e75e559ac73f1e007457480cb61))
|
||||
- Better error message when normalize is missing. ([fad902b](https://github.com/ethers-io/ethers.js/commit/fad902b438ee86d5ade3adc6bd4cd4e4a6c9348d))
|
||||
- Added shims for React-Native support. ([7bfaf29](https://github.com/ethers-io/ethers.js/commit/7bfaf292db90f3e25d5563cff63517ae61f88617))
|
||||
- Fix Base58 padding for string representation of binary data ([#4527](https://github.com/ethers-io/ethers.js/issues/4527); [ccac24a](https://github.com/ethers-io/ethers.js/commit/ccac24a5b0a4d07a4b639c1c4d0a44703e32d418)).
|
||||
|
||||
ethers/v4.0.8 (2018-11-08 16:04)
|
||||
ethers/v6.9.1 (2023-12-19 04:53)
|
||||
--------------------------------
|
||||
|
||||
- Updated dist files. ([be0488a](https://github.com/ethers-io/ethers.js/commit/be0488a1a02fffb6a31906a674b4a81da2cffd38))
|
||||
- Fix uncatchable issue when sending transactions over JSON-RPC and provide some retry-recovery for missing v ([#4513](https://github.com/ethers-io/ethers.js/issues/4513); [1802215](https://github.com/ethers-io/ethers.js/commit/180221574c5d2af9ad85404af4fab8752d3d5029)).
|
||||
|
||||
ethers/v4.0.7 (2018-11-08 16:02)
|
||||
ethers/v6.9.0 (2023-11-27 06:15)
|
||||
--------------------------------
|
||||
|
||||
- Fix for when blockTag is specified as a null equivalent value in contract overrides. ([#329](https://github.com/ethers-io/ethers.js/issues/329); [28a52cd](https://github.com/ethers-io/ethers.js/commit/28a52cd485f48599ced1cbf58535e41e179a69bf))
|
||||
- Added "debug" event for providers; do not depend on the format as it may change, but this should help debugging in most cases. ([#320](https://github.com/ethers-io/ethers.js/issues/320); [3a19f43](https://github.com/ethers-io/ethers.js/commit/3a19f43844b3161d536455ee0cbb0712263cd061))
|
||||
- Fix for Kovan filters without an address. ([#339](https://github.com/ethers-io/ethers.js/issues/339); [4852e83](https://github.com/ethers-io/ethers.js/commit/4852e837d2f47b70038136f3a702e9e127ad6c9c))
|
||||
- Use provider-specified suggested priority fee when available, otherwise fallback onto existing logic of 1 gwei ([#4463](https://github.com/ethers-io/ethers.js/issues/4463); [f8f11c7](https://github.com/ethers-io/ethers.js/commit/f8f11c754aa2c9b541db73d3bde66a8ffa5146f0)).
|
||||
- Add auto-detected static network support to providers and allow customizing socket provider options ([#4199](https://github.com/ethers-io/ethers.js/issues/4199), [#4418](https://github.com/ethers-io/ethers.js/issues/4418), [#4441](https://github.com/ethers-io/ethers.js/issues/4441); [4681b83](https://github.com/ethers-io/ethers.js/commit/4681b83d516ab2eb41ddb68b5021c97e14c6f2cf)).
|
||||
- Added Base network to AlchemyProvider ([#4384](https://github.com/ethers-io/ethers.js/issues/4384); [9e74d14](https://github.com/ethers-io/ethers.js/commit/9e74d14432e6efebdff21b9a7d2e6143af55e143)).
|
||||
- Fixed ParamType formatting causing bad tuple full and minimal ABI output ([#4329](https://github.com/ethers-io/ethers.js/issues/4329), [#4479](https://github.com/ethers-io/ethers.js/issues/4479); [2b67488](https://github.com/ethers-io/ethers.js/commit/2b6748815169abf2c99a647131875c13b8b6a787)).
|
||||
- Adjust for provider config weight when kicking off a request in FallbackProvider ([#4298](https://github.com/ethers-io/ethers.js/issues/4298); [da34e35](https://github.com/ethers-io/ethers.js/commit/da34e3569e95357d9469209d926cb645f0750bfa)).
|
||||
- More robust FallbackProvider broadcast ([#4186](https://github.com/ethers-io/ethers.js/issues/4186), [#4297](https://github.com/ethers-io/ethers.js/issues/4297), [#4442](https://github.com/ethers-io/ethers.js/issues/4442); [e2485b8](https://github.com/ethers-io/ethers.js/commit/e2485b8ef927d18c7a15d2d29b3b0feffec9991a)).
|
||||
- Added safe and finalized provider events ([#3921](https://github.com/ethers-io/ethers.js/issues/3921); [a92766e](https://github.com/ethers-io/ethers.js/commit/a92766e56ad04185625037d84fc28adaac7fae8c)).
|
||||
|
||||
ethers/v4.0.6 (2018-10-14 19:02)
|
||||
ethers/v6.8.1 (2023-11-01 16:08)
|
||||
--------------------------------
|
||||
|
||||
- Fixed lingering polling timer when no events left to process in a provider. ([d54609a](https://github.com/ethers-io/ethers.js/commit/d54609a4582b96bbf0bcb8395f0e01b8784a1369))
|
||||
- Fixed utils.poll from mutating passed variables. ([f682861](https://github.com/ethers-io/ethers.js/commit/f682861e0b420e1dc8123587734600cb00f91f06))
|
||||
- Fixed and refactored populating transaction values for signers. ([#306](https://github.com/ethers-io/ethers.js/issues/306); [023a20f](https://github.com/ethers-io/ethers.js/commit/023a20ff470f73a91a72d57bc85dfafd77255d4e))
|
||||
- Fixed test cases for phantomjs (must use ES3 syntax). ([e39cd84](https://github.com/ethers-io/ethers.js/commit/e39cd849236bf33f32168cfaaab0faf64e0ba69d))
|
||||
- Fixed typo in error description when converting values to arrays ([#4427](https://github.com/ethers-io/ethers.js/issues/4427), [#4446](https://github.com/ethers-io/ethers.js/issues/4446); [8fed2f8](https://github.com/ethers-io/ethers.js/commit/8fed2f84768ace4bf3e5742c931a74841da7c637)).
|
||||
- Fix invalid token nonpayable being included in formatted constructor ([#4412](https://github.com/ethers-io/ethers.js/issues/4412); [2e0bd90](https://github.com/ethers-io/ethers.js/commit/2e0bd90744b8e76fcf03f75a66cb0061d50f7bd9)).
|
||||
- Add ENS support for Sepolia ([#4422](https://github.com/ethers-io/ethers.js/issues/4422); [1da50ae](https://github.com/ethers-io/ethers.js/commit/1da50ae286da01e58a70bb8df8aa5cc5d260e33e)).
|
||||
|
||||
ethers/v4.0.5 (2018-10-13 17:18)
|
||||
ethers/v6.8.0 (2023-10-10 22:42)
|
||||
--------------------------------
|
||||
|
||||
- Fixed filtering with null non-indexed parameters. ([#305](https://github.com/ethers-io/ethers.js/issues/305); [6ac2d92](https://github.com/ethers-io/ethers.js/commit/6ac2d923b75526ab663a677f6a712f5400c2a621))
|
||||
- Replicated former ENS normalize behaviour for empty strings and update namehash testcases ([125ff11](https://github.com/ethers-io/ethers.js/commit/125ff1189b9cefb8abfd7da9c104c75e382a50cc)).
|
||||
- Initial shortMessage support for errors ([#4241](https://github.com/ethers-io/ethers.js/issues/4241); [d6a8c14](https://github.com/ethers-io/ethers.js/commit/d6a8c14d907cf8b90347444c0186b83a5db2e293)).
|
||||
- Fixed resolving ENS addresses used as from parameters ([#3961](https://github.com/ethers-io/ethers.js/issues/3961); [2616f4c](https://github.com/ethers-io/ethers.js/commit/2616f4c30c82bd45449b73fa37ef269d60a07d80)).
|
||||
- Merge: 9a4b7534 0c9c23b0 Merge branch 'v5.8-progress' ([cd5f0fe](https://github.com/ethers-io/ethers.js/commit/cd5f0fe03f2137fbc47e295f8db38a5151111e72)).
|
||||
- Allow more loose input format for RLP encoder ([#4402](https://github.com/ethers-io/ethers.js/issues/4402); [9a4b753](https://github.com/ethers-io/ethers.js/commit/9a4b7534458fc79a0654b0eb57fc956bffa02a2f)).
|
||||
- Update to latest noble crypto libraries ([#3975](https://github.com/ethers-io/ethers.js/issues/3975); [b27faa0](https://github.com/ethers-io/ethers.js/commit/b27faa02ac8f90e2e54b188e8139c59d98c469e3)).
|
||||
- More robust configuration options for FetchRequest getUrl functions ([#4353](https://github.com/ethers-io/ethers.js/issues/4353); [9541f2f](https://github.com/ethers-io/ethers.js/commit/9541f2f70cd7f5c6f3caf93f5a3d5e34eae5281a)).
|
||||
- Ignore blockTag when calling Etherscan if it is the default block tag ([dcea9b3](https://github.com/ethers-io/ethers.js/commit/dcea9b353619d85878ad2ba340ae17e5c285d558)).
|
||||
|
||||
ethers/v4.0.4 (2018-10-11 16:04)
|
||||
ethers/v6.7.1 (2023-08-15 03:08)
|
||||
--------------------------------
|
||||
|
||||
- Added optional blockTag to call; note that this may not behave as expected on all nodes. ([#226](https://github.com/ethers-io/ethers.js/issues/226); [493273d](https://github.com/ethers-io/ethers.js/commit/493273d698b9cc71ce1c0555f9df2bd791cd851e))
|
||||
- Check all transaction parameters are valid; protect against typos. ([#299](https://github.com/ethers-io/ethers.js/issues/299); [84344ac](https://github.com/ethers-io/ethers.js/commit/84344ac4c2a2502234373c24c0f02d8912417039))
|
||||
- Prevent destroyed providers from emitting network detection errors ([7d41730](https://github.com/ethers-io/ethers.js/commit/7d4173049edc3b4ff2de1971c3ecca3b08588651)).
|
||||
- Fix VSCode reported lint issues ([#4153](https://github.com/ethers-io/ethers.js/issues/4153), [#4156](https://github.com/ethers-io/ethers.js/issues/4156), [#4158](https://github.com/ethers-io/ethers.js/issues/4158), [#4159](https://github.com/ethers-io/ethers.js/issues/4159); [4eb84da](https://github.com/ethers-io/ethers.js/commit/4eb84da865a82a27c5113c38102b6b710096958e), [203dfc3](https://github.com/ethers-io/ethers.js/commit/203dfc33b9c8e72c9cdfe0a349ac763ef17a4484)).
|
||||
- Add gasPrice to Polygon feeData for type 0 and type 1 legacy transactions ([#4315](https://github.com/ethers-io/ethers.js/issues/4315); [0df3ab9](https://github.com/ethers-io/ethers.js/commit/0df3ab93137039de1e1986bbfe9a5b32ceffa8a4)).
|
||||
|
||||
ethers/v4.0.3 (2018-10-07 01:10)
|
||||
ethers/v6.7.0 (2023-08-02 23:52)
|
||||
--------------------------------
|
||||
|
||||
- Added address to HDNode. ([#196](https://github.com/ethers-io/ethers.js/issues/196); [e39e2ed](https://github.com/ethers-io/ethers.js/commit/e39e2ed718364cfccb6921518500dd19f2a479fe))
|
||||
- Added French and Spanish to test-hdnode. ([71f781d](https://github.com/ethers-io/ethers.js/commit/71f781d5425f08fe3c88861e23b8a55860b3d074))
|
||||
- Mark progressCallback as optional. ([#293](https://github.com/ethers-io/ethers.js/issues/293); [b2db10e](https://github.com/ethers-io/ethers.js/commit/b2db10e216748e4c4d5d359bded904af7bd1128f))
|
||||
- Fixed receipt wait not throwing on reverted transactions ([25fef4f](https://github.com/ethers-io/ethers.js/commit/25fef4f8d756f5bbf5a2a05e38233248a8eb43ac)).
|
||||
- Added custom priority fee to Optimism chain (via telegram) ([ff80b04](https://github.com/ethers-io/ethers.js/commit/ff80b04f31da21496e72d3687cecd1c01efaecc5)).
|
||||
- Add context to Logs that fail decoding due to ABI issues to help debugging ([f3c46f2](https://github.com/ethers-io/ethers.js/commit/f3c46f22994d194ff78b3b176407b2ecb7af1c77)).
|
||||
- Added new exports for FallbackProviderOptions and FetchUrlFeeDataNetworkPlugin ([#2828](https://github.com/ethers-io/ethers.js/issues/2828), [#4160](https://github.com/ethers-io/ethers.js/issues/4160); [b1dbbb0](https://github.com/ethers-io/ethers.js/commit/b1dbbb0de3f10a3d9e12d6a84ad5c52bea25c7f6)).
|
||||
- Allow overriding pollingInterval in JsonRpcProvider constructor (via discord) ([f42f258](https://github.com/ethers-io/ethers.js/commit/f42f258beb305a06e563ad16522f095a72da32eb)).
|
||||
- Fixed FallbackProvider priority sorting ([#4150](https://github.com/ethers-io/ethers.js/issues/4150); [78538eb](https://github.com/ethers-io/ethers.js/commit/78538eb100addd135d29e60c9fa4fed3946278fa)).
|
||||
- Added linea network to InfuraProvider and Network ([#4184](https://github.com/ethers-io/ethers.js/issues/4184), [#4190](https://github.com/ethers-io/ethers.js/issues/4190); [d3e5e2c](https://github.com/ethers-io/ethers.js/commit/d3e5e2c45b28c377f306091acfc024e30c49ef20)).
|
||||
- Added whitelist support to getDefaultProvider ([82bb936](https://github.com/ethers-io/ethers.js/commit/82bb936542e29c6441ac8dc2d3ebbdd4edb708ee)).
|
||||
- Add Polygon RPC endpoints to the default provider ([#3689](https://github.com/ethers-io/ethers.js/issues/3689); [23704a9](https://github.com/ethers-io/ethers.js/commit/23704a9c44d5857817e138fb19d44ce2103ca005)).
|
||||
- Added customizable quorum to FallbackProvider ([#4160](https://github.com/ethers-io/ethers.js/issues/4160); [8f0a509](https://github.com/ethers-io/ethers.js/commit/8f0a50921a12a866addcf5b0fabc576bfc287689)).
|
||||
- Added basic Gas Station support via a NetworkPlugin ([#2828](https://github.com/ethers-io/ethers.js/issues/2828); [229145d](https://github.com/ethers-io/ethers.js/commit/229145ddf566a962517588eaeed155734c7d4598)).
|
||||
- Add BNB URLs to EtherscanProvider networks ([ec39abe](https://github.com/ethers-io/ethers.js/commit/ec39abe067259fad4ea8607a6c5aece61890eb41)).
|
||||
- Added tests for JSON format ([#4248](https://github.com/ethers-io/ethers.js/issues/4248); [ba36079](https://github.com/ethers-io/ethers.js/commit/ba36079a285706694532ce726568c4c447acad47)).
|
||||
- Use empty string for unnamed parameters in JSON output instead of undefined ([#4248](https://github.com/ethers-io/ethers.js/issues/4248); [8c2652c](https://github.com/ethers-io/ethers.js/commit/8c2652c8cb4d054207d89688d30930869d9d3f8b)).
|
||||
- Return undefined for Contract properties that do not exist instead of throwing an error ([#4266](https://github.com/ethers-io/ethers.js/issues/4266); [5bf7b34](https://github.com/ethers-io/ethers.js/commit/5bf7b3494ed62952fc387b4368a0bdc86dfe163e)).
|
||||
|
||||
ethers/v4.0.2 (2018-10-04 19:55)
|
||||
ethers/v6.6.7 (2023-07-28 14:50)
|
||||
--------------------------------
|
||||
|
||||
- Added automatic event parsing for contract transaction receipts from tx.wait. ([2481581](https://github.com/ethers-io/ethers.js/commit/248158130e437b14f9d42666e0cdefa33a6be74d))
|
||||
- Added ability to wait for a specific number of confirmations. ([#229](https://github.com/ethers-io/ethers.js/issues/229); [f5c7ccb](https://github.com/ethers-io/ethers.js/commit/f5c7ccbb80e157ad27a51f310686d4ca3e1db7c8))
|
||||
- Fix for geth-etc. (official geth is fine; [24335d0](https://github.com/ethers-io/ethers.js/commit/24335d0dd71d11a2a9088c05728ed8507062434d))
|
||||
- Fixed confirmations tests and bootstrap fast blockNumber. ([908c2c1](https://github.com/ethers-io/ethers.js/commit/908c2c1096920c729669d8abc0fad10ad8f5b7e7))
|
||||
- Added confirmations to TransactionResponse. ([#156](https://github.com/ethers-io/ethers.js/issues/156); [#238](https://github.com/ethers-io/ethers.js/issues/238); [9797b36](https://github.com/ethers-io/ethers.js/commit/9797b36186add496aafc29c96b44d61fa62b23e3))
|
||||
- Fixed nested errors for providers that were masking true error. ([#292](https://github.com/ethers-io/ethers.js/issues/292); [731f189](https://github.com/ethers-io/ethers.js/commit/731f189010f03b22c085fa87f197d77988d7d0c2))
|
||||
- Added version to errors. ([99fed75](https://github.com/ethers-io/ethers.js/commit/99fed75202c19b976fa744d7e27c230da12f0f10))
|
||||
- Fixed French and Spanish for browsers without Uint8Array.forEach. ([cb5f9f5](https://github.com/ethers-io/ethers.js/commit/cb5f9f576aa6747f4ce85b727ea1c3b62c8fd047))
|
||||
- Added French and Spanish includes to phantomjs test page. ([aeac2cd](https://github.com/ethers-io/ethers.js/commit/aeac2cdb867380f3fc321c3b8cc1f5e733bb0d22))
|
||||
- Increased timeout for querying npm registry. ([0dafd83](https://github.com/ethers-io/ethers.js/commit/0dafd83033d16b73dc0d744cfd00d045e9623bd6))
|
||||
- Prevent malformed logs from preventing other logs being decoded ([#4275](https://github.com/ethers-io/ethers.js/issues/4275); [0dca645](https://github.com/ethers-io/ethers.js/commit/0dca645632d73488bf6ad460e0d779361a537bbe)).
|
||||
- Allow visibility on human-readable constructors ([#4278](https://github.com/ethers-io/ethers.js/issues/4278); [3a52201](https://github.com/ethers-io/ethers.js/commit/3a52201fe2ba68a00105cca2c0901da5ffa18d6b)).
|
||||
|
||||
ethers/v4.0.1 (2018-10-03 20:02)
|
||||
ethers/v6.6.6 (2023-07-28 01:14)
|
||||
--------------------------------
|
||||
|
||||
- Added French and Spanish wordlist dist files. ([b9c07b5](https://github.com/ethers-io/ethers.js/commit/b9c07b549ca23b11bfac9abc147cad75a6db17b5))
|
||||
- Added French and Spanish BIP-39 wordlists. ([#191](https://github.com/ethers-io/ethers.js/issues/191); [c34a1f7](https://github.com/ethers-io/ethers.js/commit/c34a1f73c6e05a098bd15e760971f68c0a471770))
|
||||
- Added support for JSON serialized BigNumbers in the constructor. ([#288](https://github.com/ethers-io/ethers.js/issues/288); [281bd06](https://github.com/ethers-io/ethers.js/commit/281bd0613d9da2542b519122496387e9e25c51ac))
|
||||
- Fixed scrypt for long passwords. ([#223](https://github.com/ethers-io/ethers.js/issues/223); [d936b4c](https://github.com/ethers-io/ethers.js/commit/d936b4cd09126f395d5478b65c076049e560940c))
|
||||
- Better error message when passing invalid overrides object into a contract deployment ([#4182](https://github.com/ethers-io/ethers.js/issues/4182); [aa2ea3d](https://github.com/ethers-io/ethers.js/commit/aa2ea3d5296956fd0d40b83888e1ca053bb250ee)).
|
||||
|
||||
ethers/v4.0.0 (2018-10-01 17:34)
|
||||
ethers/v6.6.5 (2023-07-24 00:04)
|
||||
--------------------------------
|
||||
|
||||
- Initial v4 release
|
||||
- Reflect symbols in the Contract Proxy to target ([#4084](https://github.com/ethers-io/ethers.js/issues/4048); [ac2f5e5](https://github.com/ethers-io/ethers.js/commit/ac2f5e563b8ec0e91a931470eb6ea58b0c01fb3d)).
|
||||
- Allow arrays of address for indexed filter topics ([#4259](https://github.com/ethers-io/ethers.js/issues/4259); [93af87c](https://github.com/ethers-io/ethers.js/commit/93af87c447eeb77090e29bd940612603b3f74026)).
|
||||
- Fixed filter encoding for bytesX ([#4244](https://github.com/ethers-io/ethers.js/issues/4244); [fa3a883](https://github.com/ethers-io/ethers.js/commit/fa3a883ff7c88611ce766f58bdd4b8ac90814470)).
|
||||
- Fix JSON formatting for tuple arrays ([#4237](https://github.com/ethers-io/ethers.js/issues/4237); [a8bc49b](https://github.com/ethers-io/ethers.js/commit/a8bc49bdcf07a51b35f38cf209db27e116cc1a59)).
|
||||
- Better error messages when parsing fragment strings ([#4246](https://github.com/ethers-io/ethers.js/issues/4246); [e36b6c3](https://github.com/ethers-io/ethers.js/commit/e36b6c35b7bc777c9adbe0055b32b31a13185240)).
|
||||
- Include the missing fragment key and args when no matching Contract method or event is present ([#3809](https://github.com/ethers-io/ethers.js/issues/3809); [450a176](https://github.com/ethers-io/ethers.js/commit/450a176ee25f88a2ddb9ff23b153ef70bf1dc546)).
|
||||
- Prevent a single malformed event from preventing other Contract logs; reported on Discord ([b1375f4](https://github.com/ethers-io/ethers.js/commit/b1375f4e4463b856855ebc684b45945455ac082e)).
|
||||
|
||||
ethers/v6.6.4 (2023-07-16 00:35)
|
||||
--------------------------------
|
||||
|
||||
- More robust support for Signatures with less standard parameter values ([#3835](https://github.com/ethers-io/ethers.js/issues/3835), [#4228](https://github.com/ethers-io/ethers.js/issues/4228); [a7e4048](https://github.com/ethers-io/ethers.js/commit/a7e4048fe3b75a743cec8c8ef2a5fad4bdc8b14c)).
|
||||
- Fixed CCIP-read in the EnsResolver ([#4221](https://github.com/ethers-io/ethers.js/issues/4221); [57f1e1c](https://github.com/ethers-io/ethers.js/commit/57f1e1c47148921148e35c10c83539531942923e)).
|
||||
- Skip checking confirmation count if confirms is 0 ([#4229](https://github.com/ethers-io/ethers.js/issues/4229), [#4242](https://github.com/ethers-io/ethers.js/issues/4242); [492919d](https://github.com/ethers-io/ethers.js/commit/492919d14f646c630f29e1596e5564df1e51f309)).
|
||||
- Fixed waiting for confirmations in deployment transactions ([#4212](https://github.com/ethers-io/ethers.js/issues/4212), [#4230](https://github.com/ethers-io/ethers.js/issues/4230); [43c253a](https://github.com/ethers-io/ethers.js/commit/43c253a402f52a08353c424f6c4e236836cfaf36)).
|
||||
|
||||
ethers/v6.6.3 (2023-07-11 20:55)
|
||||
--------------------------------
|
||||
|
||||
- Throw more desscriptive error for unconfigured ENS name contract targets ([#4213](https://github.com/ethers-io/ethers.js/issues/4213); [80f62ef](https://github.com/ethers-io/ethers.js/commit/80f62efc41c3a29e690af40a1976928b7f886a0e)).
|
||||
- Fixed contract once not running stop callback ([7d061b7](https://github.com/ethers-io/ethers.js/commit/7d061b786f72cbfc461bf80d139d10aeff533a6e)).
|
||||
|
||||
ethers/v6.6.2 (2023-06-27 23:30)
|
||||
--------------------------------
|
||||
|
||||
- Wider error detection for call exceptions on certain backends ([#4154](https://github.com/ethers-io/ethers.js/issues/4154), [#4155](https://github.com/ethers-io/ethers.js/issues/4155); [9197f9f](https://github.com/ethers-io/ethers.js/commit/9197f9f938b5f3b5f97c043f2dab06854656c932)).
|
||||
- Added wider error deetection for JSON-RPC unsupported operation ([#4162](https://github.com/ethers-io/ethers.js/issues/4162); [1dc8986](https://github.com/ethers-io/ethers.js/commit/1dc8986a33be9dce536b24189326cbfaabf1342e)).
|
||||
- Fixed formatUnits and parseUnits for values over 128 bits ([#4037](https://github.com/ethers-io/ethers.js/issues/4037), [#4133](https://github.com/ethers-io/ethers.js/issues/4133); [3d141b4](https://github.com/ethers-io/ethers.js/commit/3d141b44b528f52b3c9205125b64ce342f91643c)).
|
||||
|
||||
ethers/v6.6.1 (2023-06-23 00:35)
|
||||
--------------------------------
|
||||
|
||||
- Fixed CCIP read in contract calls ([#4043](https://github.com/ethers-io/ethers.js/issues/4043); [d51e3fb](https://github.com/ethers-io/ethers.js/commit/d51e3fbff43c31d88353ac71151626312d22c0b9), [857aa8c](https://github.com/ethers-io/ethers.js/commit/857aa8ccc30f25eda8e83dcac3e0ad2c1a5ce2b3)).
|
||||
|
||||
ethers/v6.6.0 (2023-06-13 21:42)
|
||||
--------------------------------
|
||||
|
||||
- Add exports for AbstractProviderOptions and for MulticoinProviderPlugin ([203a759](https://github.com/ethers-io/ethers.js/commit/203a759efc65bf6901d3e574a601525ea3936238)).
|
||||
- Add option to adjust perform cache timeout in AbstractProvider ([de0f518](https://github.com/ethers-io/ethers.js/commit/de0f5189f695c181a5fa09100af96a691a338e2b)).
|
||||
- Add full support for MultiCoin plugins and automatic detection for EVM-compatible coin types ([#3888](https://github.com/ethers-io/ethers.js/issues/3888), [#4081](https://github.com/ethers-io/ethers.js/issues/4081); [84375be](https://github.com/ethers-io/ethers.js/commit/84375be92d32a2939cf4a2f713e4c554b5b54a32)).
|
||||
- Allow Interface instances where InterfaceAbi are allowed ([#4142](https://github.com/ethers-io/ethers.js/issues/4142); [2318005](https://github.com/ethers-io/ethers.js/commit/2318005dfd996c8a7c51603d0264ceabe9bb6141)).
|
||||
- Allow Numeric type for decimals in FixedNumber ([#4141](https://github.com/ethers-io/ethers.js/issues/4141); [9055ef6](https://github.com/ethers-io/ethers.js/commit/9055ef6c69291f1a44ea23a2e7b5aaf3140a5577)).
|
||||
|
||||
ethers/v6.5.1 (2023-06-07 20:19)
|
||||
--------------------------------
|
||||
|
||||
- Fix lost promise fulfillment when a batch has an error response ([#4126](https://github.com/ethers-io/ethers.js/issues/4126); [8dd21f0](https://github.com/ethers-io/ethers.js/commit/8dd21f03334ffd3cdb7ac532376d51fd4130c7ab)).
|
||||
|
||||
ethers/v6.5.0 (2023-06-06 22:41)
|
||||
--------------------------------
|
||||
|
||||
- Fix CJS browser bundling ([#4033](https://github.com/ethers-io/ethers.js/issues/4033); [38ee319](https://github.com/ethers-io/ethers.js/commit/38ee3195b0192d8180899fd61308e03fa3a0eb32)).
|
||||
- Fixed type guard for non-Typed instances ([#4087](https://github.com/ethers-io/ethers.js/issues/4087); [20c3d1b](https://github.com/ethers-io/ethers.js/commit/20c3d1b109743e33ab60a75d69bf7ede73b15ce2)).
|
||||
- Add confirmations to TransactionResponse ([#4094](https://github.com/ethers-io/ethers.js/issues/4094); [bb8685b](https://github.com/ethers-io/ethers.js/commit/bb8685b112ce1c689c740d4dbcb358c16fb9b22d)).
|
||||
- Fix stray promises when a node returns invalid results ([#4118](https://github.com/ethers-io/ethers.js/issues/4118); [3c1bad2](https://github.com/ethers-io/ethers.js/commit/3c1bad2fb7ad4a6ff90ff11f3e382fd18e41c800)).
|
||||
- Added support to detect and stop providers spinning on intitial network detection ([#4015](https://github.com/ethers-io/ethers.js/issues/4015); [f37a52d](https://github.com/ethers-io/ethers.js/commit/f37a52da28ac130b7f4de52901618320994ea87a)).
|
||||
|
||||
ethers/v6.4.2 (2023-06-05 22:41)
|
||||
--------------------------------
|
||||
|
||||
- Bump ens-normalize version ([#4071](https://github.com/ethers-io/ethers.js/issues/4071), [#4077](https://github.com/ethers-io/ethers.js/issues/4077), [#4080](https://github.com/ethers-io/ethers.js/issues/4080), [#4102](https://github.com/ethers-io/ethers.js/issues/4102); [c135784](https://github.com/ethers-io/ethers.js/commit/c1357847dcdec93d72f28d890f9271d0289ccefd)).
|
||||
- Fix for networks with polling with non-consistent block and filter events ([#4119](https://github.com/ethers-io/ethers.js/issues/4119); [9b0e992](https://github.com/ethers-io/ethers.js/commit/9b0e9920c09577296ec0e2abb3acc3f3299d96c7)).
|
||||
|
||||
ethers/v6.4.1 (2023-06-01 17:52)
|
||||
--------------------------------
|
||||
|
||||
- Fixed AbstractProvider lookupAddress bug ([#4086](https://github.com/ethers-io/ethers.js/issues/4086); [15ed2f5](https://github.com/ethers-io/ethers.js/commit/15ed2f5b32084527961332481c9442a313036a01)).
|
||||
- Fix FixedNumber comparison bug ([#4112](https://github.com/ethers-io/ethers.js/issues/4112); [d8e9586](https://github.com/ethers-io/ethers.js/commit/d8e9586044e888e424b5ead0f6e01f88140dba8a)).
|
||||
|
||||
ethers/v6.4.0 (2023-05-18 17:28)
|
||||
--------------------------------
|
||||
|
||||
- Coerce value into BigInt when checking for value ([83d7f43](https://github.com/ethers-io/ethers.js/commit/83d7f43b9ca4b9868a3952510e56b41ea8610baa)).
|
||||
- Better errors when junk passed as Contract target ([#3947](https://github.com/ethers-io/ethers.js/issues/3947), [#4053](https://github.com/ethers-io/ethers.js/issues/4053); [219b16d](https://github.com/ethers-io/ethers.js/commit/219b16dc284b0c6a532c8c49e824d8234f94222b)).
|
||||
- More robust message checking in socket providers ([#4051](https://github.com/ethers-io/ethers.js/issues/4051); [f58990b](https://github.com/ethers-io/ethers.js/commit/f58990b80cfd83579014339315e58663c0aa6ae3)).
|
||||
- More robust defaultProvider start-up when a backend fails on bootstrap ([#3979](https://github.com/ethers-io/ethers.js/issues/3979); [984f6fa](https://github.com/ethers-io/ethers.js/commit/984f6fa155fca08ebec2353c75ee0a0b974e8568)).
|
||||
- Fix Result.map when Array contains zero elements ([#4036](https://github.com/ethers-io/ethers.js/issues/4036), [#4048](https://github.com/ethers-io/ethers.js/issues/4048); [2e5935b](https://github.com/ethers-io/ethers.js/commit/2e5935b91cff462165a054b33c8b8413f51e3f39)).
|
||||
- Fixed error handling for contracts with receive and non-payable fallback ([6db7458](https://github.com/ethers-io/ethers.js/commit/6db7458cf0a09e8e8a2abb712239972ab81dc9df)).
|
||||
- Remove superfluous logging in defaultProvider ([f87f6ef](https://github.com/ethers-io/ethers.js/commit/f87f6ef9a01ca399664f9fe106b0a677dba0c8e8)).
|
||||
- Removed superfluous logging ([1bc8b55](https://github.com/ethers-io/ethers.js/commit/1bc8b55d502a95c4ae58352bdcfce9e5f9ea72d3)).
|
||||
- Fix receipt gas price when effectiveGasPrice is 0 on testnets ([#4014](https://github.com/ethers-io/ethers.js/issues/4014); [2b0fe61](https://github.com/ethers-io/ethers.js/commit/2b0fe611335432aee334d777a64d8c7827881618)).
|
||||
- Added error event to provider ([#3970](https://github.com/ethers-io/ethers.js/issues/3970), [#3982](https://github.com/ethers-io/ethers.js/issues/3982); [af0291c](https://github.com/ethers-io/ethers.js/commit/af0291c01639674658f5049343da88a84da763a1)).
|
||||
- Removed superfluous parameters for internal transaction functions ([e848978](https://github.com/ethers-io/ethers.js/commit/e8489787585c2e69a23f6cdec6901f22b096aebe)).
|
||||
- More aggresive tree-shaking ([076edad](https://github.com/ethers-io/ethers.js/commit/076edad81ef62474f48f2b4c8af0edc6e4fd64f2)).
|
||||
- More flexible static network checking ([#3834](https://github.com/ethers-io/ethers.js/issues/3834); [7c0465c](https://github.com/ethers-io/ethers.js/commit/7c0465c5fb834eba18d4e5535072685bdc1029f0)).
|
||||
- Support transitive dependants that use non-node16 moduleResolution ([#3920](https://github.com/ethers-io/ethers.js/issues/3920); [df685b1](https://github.com/ethers-io/ethers.js/commit/df685b1bd9ad346ee7863beb6c3ca3f4e94932a2)).
|
||||
- Populate any missing log.removed with false ([#3959](https://github.com/ethers-io/ethers.js/issues/3959); [4e478e6](https://github.com/ethers-io/ethers.js/commit/4e478e625d5648f2172631eef5fda5776ee776b0)).
|
||||
|
||||
ethers/v6.3.0 (2023-04-06 04:35)
|
||||
--------------------------------
|
||||
|
||||
- Added support for legacy ABI JSON fragments ([#3932](https://github.com/ethers-io/ethers.js/issues/3932); [8c5973e](https://github.com/ethers-io/ethers.js/commit/8c5973e3a9b8d4d4ed80bdf209d8a0b6cc6b8d6d)).
|
||||
- Add _in_ operator support for contract and contract.filters ([#3901](https://github.com/ethers-io/ethers.js/issues/3901); [c58ab3a](https://github.com/ethers-io/ethers.js/commit/c58ab3a97687e15a3ffe30b038089c5f4b570bb9)).
|
||||
- Fixed TypedData unsigned value range ([#3873](https://github.com/ethers-io/ethers.js/issues/3873); [a851b24](https://github.com/ethers-io/ethers.js/commit/a851b24d0af009ecf277766d2a5f81f9b3e7f9f8)).
|
||||
- Added missing export for getIndexedAccountPath ([#3875](https://github.com/ethers-io/ethers.js/issues/3875); [356ff2b](https://github.com/ethers-io/ethers.js/commit/356ff2becb4f4d3622b281d3825770af5caf71ca)).
|
||||
- Fixed TypedData payloads for JSON-restricted chainId field ([#3836](https://github.com/ethers-io/ethers.js/issues/3836); [50b74b8](https://github.com/ethers-io/ethers.js/commit/50b74b8806ef2064f2764b09f89c7ac75fda3a3c)).
|
||||
|
||||
ethers/v6.2.3 (2023-03-27 21:22)
|
||||
--------------------------------
|
||||
|
||||
- Fixed events when emitted in WebSocketProvider ([#3767](https://github.com/ethers-io/ethers.js/issues/3767), [#3922](https://github.com/ethers-io/ethers.js/issues/3922); [ffaafc0](https://github.com/ethers-io/ethers.js/commit/ffaafc0ce1cf40d1d76d8d814c9c445057bf6989)).
|
||||
|
||||
ethers/v6.2.2 (2023-03-24 00:49)
|
||||
--------------------------------
|
||||
|
||||
- Fixed FetchRequest when using credentials ([#3897](https://github.com/ethers-io/ethers.js/issues/3897); [88e8124](https://github.com/ethers-io/ethers.js/commit/88e8124c37d377628f9b8abdf140fc07ad06259f)).
|
||||
|
||||
ethers/v6.2.1 (2023-03-23 17:33)
|
||||
--------------------------------
|
||||
|
||||
- Stall block polling bootstrap when the network is down ([#3924](https://github.com/ethers-io/ethers.js/issues/3924); [603d474](https://github.com/ethers-io/ethers.js/commit/603d47496e2b667c15b72f315261d6e299381848)).
|
||||
|
||||
ethers/v6.2.0 (2023-03-20 15:53)
|
||||
--------------------------------
|
||||
|
||||
- Added extra details in the error info field for RPC errors ([30ffa78](https://github.com/ethers-io/ethers.js/commit/30ffa78d1441fa033677fa09237fc135a314f373)).
|
||||
- Remove Ankr as a deafult for now as the provided API key is failing ([6e01e54](https://github.com/ethers-io/ethers.js/commit/6e01e5448f4a3e2d30288d4c8447db295c3a2e7a)).
|
||||
- Fixed deferred filters after unsafe-eval changes ([#3749](https://github.com/ethers-io/ethers.js/issues/3749), [#3763](https://github.com/ethers-io/ethers.js/issues/3763); [2e3802a](https://github.com/ethers-io/ethers.js/commit/2e3802a83b8ad2f5a6269d79fbd1c83c9f2d1047)).
|
||||
- Remove use of Function sub-class to address unsafe-eval issues ([#3749](https://github.com/ethers-io/ethers.js/issues/3749), [#3763](https://github.com/ethers-io/ethers.js/issues/3763); [7d3af51](https://github.com/ethers-io/ethers.js/commit/7d3af512c75b4c24027ec2daef1e9f4c1064194a)).
|
||||
- Added verifyTypedData utility (reported on Farcaster) ([f06a445](https://github.com/ethers-io/ethers.js/commit/f06a445247f3b294f9fc805cc8fe0752accb8edc)).
|
||||
- Removed stray logging in IpcProvider ([#3908](https://github.com/ethers-io/ethers.js/issues/3908), [#3909](https://github.com/ethers-io/ethers.js/issues/3909); [e11d4c1](https://github.com/ethers-io/ethers.js/commit/e11d4c1c20cc5b6fd5803cf9636c4f5bc082dab7)).
|
||||
- Fixed legacy serialization for implicit chainId transactions ([#3898](https://github.com/ethers-io/ethers.js/issues/3898), [#3899](https://github.com/ethers-io/ethers.js/issues/3899); [fcf6c8f](https://github.com/ethers-io/ethers.js/commit/fcf6c8fcee95ec412aaafba8ec84d5049b077a4e)).
|
||||
- Fix Webpack issue (reported on discord) ([3ad4273](https://github.com/ethers-io/ethers.js/commit/3ad4273b8b714bff344ccbfb1eb71ed8a8b7cfa4)).
|
||||
- Fix some bundlers which cannot handle recursive pkg.exports ([#3848](https://github.com/ethers-io/ethers.js/issues/3848); [6315e78](https://github.com/ethers-io/ethers.js/commit/6315e78ea32147653b72ca06f6800f3e2df6ffbf)).
|
||||
- Fixed typo in signature.s error ([#3891](https://github.com/ethers-io/ethers.js/issues/3891); [47ef3eb](https://github.com/ethers-io/ethers.js/commit/47ef3ebde37bfa0c015c258c3d8a6800d751e147)).
|
||||
- Fixed stray unreachable code ([#3890](https://github.com/ethers-io/ethers.js/issues/3890); [c220fe2](https://github.com/ethers-io/ethers.js/commit/c220fe2ea747ccc80cd3c4020e0278e3daf3c4fc)).
|
||||
- Move all wrapping to proper _wrap functions ([#3818](https://github.com/ethers-io/ethers.js/issues/3818); [02a0aad](https://github.com/ethers-io/ethers.js/commit/02a0aad61212c35e8d2723a8ae589989b97dae3e)).
|
||||
|
||||
ethers/v6.1.0 (2023-03-07 02:10)
|
||||
--------------------------------
|
||||
|
||||
- Fixed ethers imported in web workers ([#3856](https://github.com/ethers-io/ethers.js/issues/3856); [5f2678f](https://github.com/ethers-io/ethers.js/commit/5f2678fb059d643638b9cc1dc59cbfc61ce7a7b8)).
|
||||
- Added Sepolia support ([#3863](https://github.com/ethers-io/ethers.js/issues/3863); [abeaa74](https://github.com/ethers-io/ethers.js/commit/abeaa74da04fbe25e837a2ffa7d1e9c1257a5da5)).
|
||||
- Added missing exports ([#3734](https://github.com/ethers-io/ethers.js/issues/3734); [06aa303](https://github.com/ethers-io/ethers.js/commit/06aa30363f88144db672376d39012d7fe3f86c33)).
|
||||
- Allow null values for TypedData domain ([#3623](https://github.com/ethers-io/ethers.js/issues/3623); [a32af3a](https://github.com/ethers-io/ethers.js/commit/a32af3adc104c4b07a45097a4a3725a4ce9e0be6)).
|
||||
- Added listAccounts to JsonRpcProvider ([#3778](https://github.com/ethers-io/ethers.js/issues/3778); [287d94f](https://github.com/ethers-io/ethers.js/commit/287d94fc454d03f1b3086ea98745131cdf40129a)).
|
||||
- Allow BigInt for blockTag ([#3780](https://github.com/ethers-io/ethers.js/issues/3780); [fe1f04c](https://github.com/ethers-io/ethers.js/commit/fe1f04c6e5fb4254a100f492d7dcbdc3cf19a446)).
|
||||
- Fixed typo in error messages ([#3822](https://github.com/ethers-io/ethers.js/issues/3822), [#3824](https://github.com/ethers-io/ethers.js/issues/3824); [f1a810d](https://github.com/ethers-io/ethers.js/commit/f1a810dcb56df54b1e1567f2a59c73500619472f)).
|
||||
- Re-adding definition files to require exports ([#3703](https://github.com/ethers-io/ethers.js/issues/3703); [76fab92](https://github.com/ethers-io/ethers.js/commit/76fab923da33e71e6bb751bb0b5e3ba3faa27ab2)).
|
||||
|
||||
ethers/v6.0.8 (2023-02-23 06:30)
|
||||
--------------------------------
|
||||
|
||||
- Fix matic-mumbai network and include aliases to legacy names ([#3811](https://github.com/ethers-io/ethers.js/issues/3811); [20bbd12](https://github.com/ethers-io/ethers.js/commit/20bbd1281911d31b360f6f5032251c9257943541)).
|
||||
- Fixed getSigner bug ([#3821](https://github.com/ethers-io/ethers.js/issues/3821); [388edf6](https://github.com/ethers-io/ethers.js/commit/388edf6abc168f89f1ca609e9e5b025dc9205add)).
|
||||
|
||||
ethers/v6.0.7 (2023-02-23 01:41)
|
||||
--------------------------------
|
||||
|
||||
- Fixed getContentHash ([#3819](https://github.com/ethers-io/ethers.js/issues/3819); [b993f7c](https://github.com/ethers-io/ethers.js/commit/b993f7c3b6c0e135c460c8b8dc5943215628231a)).
|
||||
|
||||
ethers/v6.0.6 (2023-02-22 21:53)
|
||||
--------------------------------
|
||||
|
||||
- Added chain parameters for Arbitrum and Optimism ([#3811](https://github.com/ethers-io/ethers.js/issues/3811); [77a7323](https://github.com/ethers-io/ethers.js/commit/77a7323119923e596f4def4f1bc90beae5447320)).
|
||||
- Fix NonceManager race condition ([#3812](https://github.com/ethers-io/ethers.js/issues/3812), [#3813](https://github.com/ethers-io/ethers.js/issues/3813); [5a3c10a](https://github.com/ethers-io/ethers.js/commit/5a3c10a29c047609a50828adb620d88aa8cf0014)).
|
||||
- Add UMD output to dist builds ([#3814](https://github.com/ethers-io/ethers.js/issues/3814); [f9eed4c](https://github.com/ethers-io/ethers.js/commit/f9eed4cdb190b06dd4ddaa2382c1de42e8e98de6)).
|
||||
|
||||
ethers/v6.0.5 (2023-02-18 22:36)
|
||||
--------------------------------
|
||||
|
||||
- Fixed Result to behave correctly like an array using slice and toArray ([#3787](https://github.com/ethers-io/ethers.js/issues/3787); [399356b](https://github.com/ethers-io/ethers.js/commit/399356b91227db04e496628af60c4b8e38207760)).
|
||||
- Replaced substring from 0 index with startsWith ([#3691](https://github.com/ethers-io/ethers.js/issues/3691); [4512e97](https://github.com/ethers-io/ethers.js/commit/4512e97f9b55607ce388aa6eb63a37fc196a5d9d)).
|
||||
- Fixed inverted assert in duplicate name detection for ABI encoding ([#3792](https://github.com/ethers-io/ethers.js/issues/3792); [762c2f3](https://github.com/ethers-io/ethers.js/commit/762c2f34eac848c5464389f11d1697dcd8ebcbb5)).
|
||||
- Fixed missing property during transaction copy ([#3793](https://github.com/ethers-io/ethers.js/issues/3793); [48bbef7](https://github.com/ethers-io/ethers.js/commit/48bbef7ade69bcfe86542f752f15049cc62f4141)).
|
||||
- Add support for Wallet private keys without 0x prefix ([#3768](https://github.com/ethers-io/ethers.js/issues/3768); [4665fb4](https://github.com/ethers-io/ethers.js/commit/4665fb4c6886c8b344dee316ba9f4fde57ce7557)).
|
||||
- Fixed quicknode property for defaultProvider ([#3741](https://github.com/ethers-io/ethers.js/issues/3741); [a8afb72](https://github.com/ethers-io/ethers.js/commit/a8afb72fbbceb6a5024c1edb85badb72099787ea)).
|
||||
- Fixed exports field order ([#3703](https://github.com/ethers-io/ethers.js/issues/3703), [#3755](https://github.com/ethers-io/ethers.js/issues/3755); [085a905](https://github.com/ethers-io/ethers.js/commit/085a9054f349afb816ca1a123737293ec9bd2532)).
|
||||
|
||||
ethers/v6.0.4 (2023-02-16 08:55)
|
||||
--------------------------------
|
||||
|
||||
- Fixed custom error decoding ([#3785](https://github.com/ethers-io/ethers.js/issues/3785); [4d9b29d](https://github.com/ethers-io/ethers.js/commit/4d9b29de751e2387c143e474bb96d271da892ea6)).
|
||||
- Removed stray debug logging ([e1e0929](https://github.com/ethers-io/ethers.js/commit/e1e09293483a9d07fd8e8f96552aa958b5ec45ed)).
|
||||
- Fixed lookupAddress when bad resolver is present ([#3782](https://github.com/ethers-io/ethers.js/issues/3782); [92def9c](https://github.com/ethers-io/ethers.js/commit/92def9c1489bb35ad13fe58a1cd107ee3a05a112)).
|
||||
- Fixed FallbackProvider median calculation ([#3746](https://github.com/ethers-io/ethers.js/issues/3746); [83957dc](https://github.com/ethers-io/ethers.js/commit/83957dc283043b9af8f6e89920faac3e09ca69fc)).
|
||||
- Move the xnf normalize variant to pkg.browser instead of import ([#3724](https://github.com/ethers-io/ethers.js/issues/3724); [179e6ca](https://github.com/ethers-io/ethers.js/commit/179e6ca520392177c7dea5e477b29930952ed637)).
|
||||
|
||||
ethers/v6.0.3 (2023-02-12 22:45)
|
||||
--------------------------------
|
||||
|
||||
- Allow null type in transaction receipt for legacy type 0 networks ([#3459](https://github.com/ethers-io/ethers.js/issues/3459); [6372a46](https://github.com/ethers-io/ethers.js/commit/6372a46b1b273db3e4c1189daebb4b888bd588bc)).
|
||||
- Fixed events when slicing immutable Result ([#3765](https://github.com/ethers-io/ethers.js/issues/3765); [2ba4a17](https://github.com/ethers-io/ethers.js/commit/2ba4a172555b7e17ac01fedfc944549defab61bc)).
|
||||
- More robust support on networks which throw when filters are not supported ([#3767](https://github.com/ethers-io/ethers.js/issues/3767); [37bf4fb](https://github.com/ethers-io/ethers.js/commit/37bf4fb55563d7ff66edee15c7515c8a0d6a2266)).
|
||||
- Fixed ignored polling override for JsonRpcApiProvider ([400d576](https://github.com/ethers-io/ethers.js/commit/400d57621b3e9a33679a528b5072449699f0a068)).
|
||||
|
||||
ethers/v6.0.2 (2023-02-04 08:50)
|
||||
--------------------------------
|
||||
|
||||
- Fixed crossed assert in Fetch ([#3733](https://github.com/ethers-io/ethers.js/issues/3733); [6c338c1](https://github.com/ethers-io/ethers.js/commit/6c338c1c5b4013db9754c9d1a33dcbf54330e5c7)).
|
||||
|
||||
ethers/v6.0.1 (2023-02-04 04:06)
|
||||
--------------------------------
|
||||
|
||||
- Fix Subscriber model when removed within emit callback ([d0ed918](https://github.com/ethers-io/ethers.js/commit/d0ed91840c9f51c7ce9061ebb1d36727dbdd51a4)).
|
||||
- Fixed human-readable parser when identifier begins with valid type prefix ([#3728](https://github.com/ethers-io/ethers.js/issues/3728); [522fd16](https://github.com/ethers-io/ethers.js/commit/522fd16f68aabc53e4dc8745d4128e0d61260ed5)).
|
||||
- Update to latest secp256k1 library ([#3719](https://github.com/ethers-io/ethers.js/issues/3719); [803e8f9](https://github.com/ethers-io/ethers.js/commit/803e8f9821950b83efa876d64b1cfb35f6bccc38)).
|
||||
|
||||
ethers/v6.0.0 (2023-02-02 22:48)
|
||||
--------------------------------
|
||||
|
||||
- Initial release ([90afd9b](https://github.com/ethers-io/ethers.js/commit/90afd9bd81ed1408421a0247fa0845a74c9eb319)).
|
||||
|
@ -1,46 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@ethers.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
7
FUNDING.json
Normal file
7
FUNDING.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"drips": {
|
||||
"ethereum": {
|
||||
"ownedBy": "0x89EdE5cBE53473A64d6C8DF14176a0d658dAAeDC"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Richard Moore
|
||||
Copyright (c) 2016-2023 Richard Moore
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
165
README.md
165
README.md
@ -1,105 +1,140 @@
|
||||
ethers.js
|
||||
=========
|
||||
The Ethers Project
|
||||
==================
|
||||
|
||||
[![npm version](https://badge.fury.io/js/ethers.svg)](https://badge.fury.io/js/ethers)
|
||||
[![npm (tag)](https://img.shields.io/npm/v/ethers)](https://www.npmjs.com/package/ethers)
|
||||
[![CI Tests](https://github.com/ethers-io/ethers.js/actions/workflows/test-ci.yml/badge.svg?branch=main)](https://github.com/ethers-io/ethers.js/actions/workflows/test-ci.yml)
|
||||
![npm bundle size (version)](https://img.shields.io/bundlephobia/minzip/ethers)
|
||||
![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)
|
||||
|
||||
Complete Ethereum wallet implementation and utilities in JavaScript (and TypeScript).
|
||||
-----
|
||||
|
||||
**Features:**
|
||||
A complete, compact and simple library for Ethereum and ilk, written
|
||||
in [TypeScript](https://www.typescriptlang.org).
|
||||
|
||||
**Features**
|
||||
|
||||
- Keep your private keys in your client, **safe** and sound
|
||||
- Import and export **JSON wallets** (Geth, Parity and crowdsale)
|
||||
- Import and export BIP 39 **mnemonic phrases** (12 word backup phrases) and **HD Wallets** (English, French, Italian, Japanese, Korean, Simplified Chinese, Spanish, Traditional Chinese)
|
||||
- Import and export BIP 39 **mnemonic phrases** (12 word backup phrases) and **HD Wallets** (English as well as Czech, French, Italian, Japanese, Korean, Simplified Chinese, Spanish, Traditional Chinese)
|
||||
- Meta-classes create JavaScript objects from any contract ABI, including **ABIv2** and **Human-Readable ABI**
|
||||
- Connect to Ethereum nodes over [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC), [INFURA](https://infura.io), [Etherscan](https://etherscan.io), or [MetaMask](https://metamask.io)
|
||||
- Connect to Ethereum nodes over [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC), [INFURA](https://infura.io), [Etherscan](https://etherscan.io), [Alchemy](https://alchemyapi.io), [Ankr](https://ankr.com) or [MetaMask](https://metamask.io)
|
||||
- **ENS names** are first-class citizens; they can be used anywhere an Ethereum addresses can be used
|
||||
- **Tiny** (~84kb compressed; 270kb uncompressed)
|
||||
- **Complete** functionality for all your Ethereum needs
|
||||
- Extensive [documentation](https://docs.ethers.io/ethers.js/html/)
|
||||
- **Small** (~144kb compressed; 460kb uncompressed)
|
||||
- **Tree-shaking** focused; include only what you need during bundling
|
||||
- **Complete** functionality for all your Ethereum desires
|
||||
- Extensive [documentation](https://docs.ethers.org/v6/)
|
||||
- Large collection of **test cases** which are maintained and added to
|
||||
- Fully **TypeScript** ready, with definition files and full TypeScript source
|
||||
- Fully written in **TypeScript**, with strict types for security and safety
|
||||
- **MIT License** (including ALL dependencies); completely open source to do with as you please
|
||||
|
||||
|
||||
Keep Updated
|
||||
------------
|
||||
|
||||
For the latest news and advisories, please follow [@ethersproject](https://twitter.com/ethersproject) on Twitter as well as this GitHub project.
|
||||
For advisories and important notices, follow [@ethersproject](https://twitter.com/ethersproject)
|
||||
on Twitter (low-traffic, non-marketing, important information only) as well as watch this GitHub project.
|
||||
|
||||
For more general news, discussions, and feedback, follow or DM me,
|
||||
[@ricmoo](https://twitter.com/ricmoo) on Twitter or on the
|
||||
[Ethers Discord](https://discord.gg/qYtSscGYYc).
|
||||
|
||||
|
||||
For the latest changes, see the
|
||||
[CHANGELOG](https://github.com/ethers-io/ethers.js/blob/main/CHANGELOG.md).
|
||||
|
||||
|
||||
**Summaries**
|
||||
|
||||
- [August 2023](https://blog.ricmoo.com/highlights-ethers-js-august-2023-fb68354c576c)
|
||||
- [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)
|
||||
- [September 2021](https://blog.ricmoo.com/highlights-ethers-js-september-2021-1bf7cb47d348)
|
||||
- [May 2021](https://blog.ricmoo.com/highlights-ethers-js-may-2021-2826e858277d)
|
||||
- [March 2021](https://blog.ricmoo.com/highlights-ethers-js-march-2021-173d3a545b8d)
|
||||
- [December 2020](https://blog.ricmoo.com/highlights-ethers-js-december-2020-2e2db8bc800a)
|
||||
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
To use in a browser:
|
||||
**NodeJS**
|
||||
|
||||
```html
|
||||
<script charset="utf-8"
|
||||
src="https://cdn.ethers.io/scripts/ethers-v4.min.js"
|
||||
type="text/javascript">
|
||||
```
|
||||
/home/ricmoo/some_project> npm install ethers
|
||||
```
|
||||
|
||||
**Browser (ESM)**
|
||||
|
||||
The bundled library is available in the `./dist/` folder in this repo.
|
||||
|
||||
```
|
||||
<script type="module">
|
||||
import { ethers } from "./dist/ethers.min.js";
|
||||
</script>
|
||||
```
|
||||
|
||||
To use in [node.js](https://nodejs.org/):
|
||||
|
||||
```
|
||||
/Users/ethers/my-app> npm install --save ethers
|
||||
```
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Browse the [API Documentation](https://docs.ethers.io/ethers.js/html/) online.
|
||||
Browse the [documentation](https://docs.ethers.org) online:
|
||||
|
||||
To fork and submit pull requests to the documentation, please see the
|
||||
[documentation repository](https://github.com/ethers-io/documentation).
|
||||
- [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/)
|
||||
|
||||
|
||||
Related Libraries
|
||||
---------------
|
||||
|
||||
- [Command Line Interface](https://github.com/ethers-io/ethers-cli) - Command Line Tools for ethers
|
||||
- [CryptoKitties](https://github.com/ricmoo/ethers-meow) - CryptoKitties utility libraries
|
||||
- [ENS](https://github.com/ethers-io/ethers-ens) - ENS utility libraries for managing names
|
||||
- [LedgerSigner](https://github.com/ethers-io/ethers-ledger) - Use a Ledger Hardware Wallet as an ethers Signer (supports HID (node.js) and U2F (browser); or specify your own transport)
|
||||
- [Web3 Bridge](https://github.com/ethers-io/ethers-web3-bridge) - Use ethers as the backend for a Web3 front-end
|
||||
|
||||
|
||||
Hacking and Contributing
|
||||
------------------------
|
||||
|
||||
The JavaScript code is now generated from TypeScript, so make sure you modify the
|
||||
TypeScript and compile it, rather than modifying the JavaScript directly. To start
|
||||
auto-compiling the TypeScript code, you may use:
|
||||
|
||||
```
|
||||
/home/ethers> npm run auto-build
|
||||
```
|
||||
|
||||
A very important part of ethers is its exhaustive test cases, so before making any
|
||||
bug fix, please add a test case that fails prior to the fix, and succeeds after the
|
||||
fix. All regression tests must pass.
|
||||
|
||||
Pull requests are always welcome, but please keep a few points in mind:
|
||||
|
||||
- Compatibility-breaking changes will not be accepted; they may be considered for the next major version
|
||||
- Security is important; adding dependencies require fairly convincing arguments
|
||||
- The library aims to be lean, so keep an eye on the `dist/ethers.min.js` file size before and after your changes
|
||||
- Add test cases for both expected and unexpected input
|
||||
- Any new features need to be supported by us (issues, documentation, testing), so anything that is overly complicated or specific may not be accepted
|
||||
|
||||
In general, **please start an issue before beginning a pull request**, so we can have a public discussion. :)
|
||||
|
||||
|
||||
Donations
|
||||
Providers
|
||||
---------
|
||||
|
||||
I do this because I love it, but if you want to buy me a coffee, I won't say no. **:o)**
|
||||
Ethers works closely with an ever-growing list of third-party providers
|
||||
to ensure getting started is quick and easy, by providing default keys
|
||||
to each service.
|
||||
|
||||
Ethereum: `0xEA517D5a070e6705Cc5467858681Ed953d285Eb9`
|
||||
These built-in keys mean you can use `ethers.getDefaultProvider()` and
|
||||
start developing right away.
|
||||
|
||||
However, the API keys provided to ethers are also shared and are
|
||||
intentionally throttled to encourage developers to eventually get
|
||||
their own keys, which unlock many other features, such as faster
|
||||
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.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)
|
||||
|
||||
|
||||
Extension Packages
|
||||
------------------
|
||||
|
||||
The `ethers` package only includes the most common and most core
|
||||
functionality to interact with Ethereum. There are many other
|
||||
packages designed to further enhance the functionality and experience.
|
||||
|
||||
- [MulticallProvider](https://github.com/ethers-io/ext-provider-multicall) - A Provider which bundles multiple call requests into a single `call` to reduce latency and backend request capacity
|
||||
- [MulticoinPlugin](https://github.com/ethers-io/ext-provider-plugin-multicoin) - A Provider plugin to expand the support of ENS coin types
|
||||
- [GanaceProvider](https://github.com/ethers-io/ext-provider-ganache) - A Provider for in-memory node instances, for fast debugging, testing and simulating blockchain operations
|
||||
- [Optimism Utilities](https://github.com/ethers-io/ext-utils-optimism) - A collection of Optimism utilities
|
||||
- [LedgerSigner](https://github.com/ethers-io/ext-signer-ledger) - A Signer to interact directly with Ledger Hardware Wallets
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Completely MIT Licensed. Including ALL dependencies.
|
||||
MIT License (including **all** dependencies).
|
||||
|
||||
|
34
SECURITY.md
Normal file
34
SECURITY.md
Normal 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.
|
1
_version.d.ts
vendored
1
_version.d.ts
vendored
@ -1 +0,0 @@
|
||||
export declare const version = "4.0.49";
|
11
abstract-signer.d.ts
vendored
11
abstract-signer.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
import { Provider } from './providers/abstract-provider';
|
||||
import { Arrayish } from './utils/bytes';
|
||||
import { TransactionRequest, TransactionResponse } from './providers/abstract-provider';
|
||||
export declare abstract class Signer {
|
||||
readonly provider?: Provider;
|
||||
abstract getAddress(): Promise<string>;
|
||||
abstract signMessage(message: Arrayish | string): Promise<string>;
|
||||
abstract sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse>;
|
||||
constructor();
|
||||
static isSigner(value: any): value is Signer;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var properties_1 = require("./utils/properties");
|
||||
var Signer = /** @class */ (function () {
|
||||
function Signer() {
|
||||
properties_1.setType(this, 'Signer');
|
||||
}
|
||||
Signer.isSigner = function (value) {
|
||||
return properties_1.isType(value, 'Signer');
|
||||
};
|
||||
return Signer;
|
||||
}());
|
||||
exports.Signer = Signer;
|
||||
//defineReadOnly(Signer, 'inherits', inheritable(Signer));
|
11
constants.d.ts
vendored
11
constants.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
import { BigNumber } from './utils/bignumber';
|
||||
declare const AddressZero = "0x0000000000000000000000000000000000000000";
|
||||
declare const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
||||
declare const EtherSymbol = "\u039E";
|
||||
declare const NegativeOne: BigNumber;
|
||||
declare const Zero: BigNumber;
|
||||
declare const One: BigNumber;
|
||||
declare const Two: BigNumber;
|
||||
declare const WeiPerEther: BigNumber;
|
||||
declare const MaxUint256: BigNumber;
|
||||
export { AddressZero, HashZero, EtherSymbol, NegativeOne, Zero, One, Two, WeiPerEther, MaxUint256 };
|
24
constants.js
24
constants.js
@ -1,24 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var bignumber_1 = require("./utils/bignumber");
|
||||
var AddressZero = '0x0000000000000000000000000000000000000000';
|
||||
exports.AddressZero = AddressZero;
|
||||
var HashZero = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
||||
exports.HashZero = HashZero;
|
||||
// NFKD (decomposed)
|
||||
//const EtherSymbol = '\uD835\uDF63';
|
||||
// NFKC (composed)
|
||||
var EtherSymbol = '\u039e';
|
||||
exports.EtherSymbol = EtherSymbol;
|
||||
var NegativeOne = bignumber_1.bigNumberify(-1);
|
||||
exports.NegativeOne = NegativeOne;
|
||||
var Zero = bignumber_1.bigNumberify(0);
|
||||
exports.Zero = Zero;
|
||||
var One = bignumber_1.bigNumberify(1);
|
||||
exports.One = One;
|
||||
var Two = bignumber_1.bigNumberify(2);
|
||||
exports.Two = Two;
|
||||
var WeiPerEther = bignumber_1.bigNumberify('1000000000000000000');
|
||||
exports.WeiPerEther = WeiPerEther;
|
||||
var MaxUint256 = bignumber_1.bigNumberify('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');
|
||||
exports.MaxUint256 = MaxUint256;
|
86
contract.d.ts
vendored
86
contract.d.ts
vendored
@ -1,86 +0,0 @@
|
||||
import { BigNumber } from './utils/bignumber';
|
||||
import { Indexed, Interface } from './utils/interface';
|
||||
import { UnsignedTransaction } from './utils/transaction';
|
||||
import { BlockTag, Provider } from './providers/abstract-provider';
|
||||
import { Signer } from './abstract-signer';
|
||||
import { Arrayish } from './utils/bytes';
|
||||
import { EventFragment, FunctionFragment, ParamType } from './utils/abi-coder';
|
||||
import { Block, Listener, Log, TransactionReceipt, TransactionRequest, TransactionResponse } from './providers/abstract-provider';
|
||||
export declare type ContractFunction = (...params: Array<any>) => Promise<any>;
|
||||
export declare type EventFilter = {
|
||||
address?: string;
|
||||
topics?: Array<string>;
|
||||
};
|
||||
export interface Event extends Log {
|
||||
args?: Array<any>;
|
||||
decode?: (data: string, topics?: Array<string>) => any;
|
||||
event?: string;
|
||||
eventSignature?: string;
|
||||
removeListener: () => void;
|
||||
getBlock: () => Promise<Block>;
|
||||
getTransaction: () => Promise<TransactionResponse>;
|
||||
getTransactionReceipt: () => Promise<TransactionReceipt>;
|
||||
}
|
||||
export interface ContractReceipt extends TransactionReceipt {
|
||||
events?: Array<Event>;
|
||||
}
|
||||
export interface ContractTransaction extends TransactionResponse {
|
||||
wait(confirmations?: number): Promise<ContractReceipt>;
|
||||
}
|
||||
export declare class VoidSigner extends Signer {
|
||||
readonly address: string;
|
||||
constructor(address: string, provider: Provider);
|
||||
getAddress(): Promise<string>;
|
||||
_fail(message: string, operation: string): Promise<any>;
|
||||
signMessage(message: Arrayish | string): Promise<string>;
|
||||
sendTransaction(transaction: TransactionRequest): Promise<TransactionResponse>;
|
||||
connect(provider: Provider): VoidSigner;
|
||||
}
|
||||
interface Bucket<T> {
|
||||
[name: string]: T;
|
||||
}
|
||||
export declare class Contract {
|
||||
readonly address: string;
|
||||
readonly interface: Interface;
|
||||
readonly signer: Signer;
|
||||
readonly provider: Provider;
|
||||
readonly estimate: Bucket<(...params: Array<any>) => Promise<BigNumber>>;
|
||||
readonly functions: Bucket<ContractFunction>;
|
||||
readonly filters: Bucket<(...params: Array<any>) => EventFilter>;
|
||||
readonly [name: string]: ContractFunction | any;
|
||||
readonly addressPromise: Promise<string>;
|
||||
readonly deployTransaction: TransactionResponse;
|
||||
private _deployedPromise;
|
||||
constructor(addressOrName: string, contractInterface: Array<string | FunctionFragment | EventFragment | ParamType> | string | Interface, signerOrProvider: Signer | Provider);
|
||||
deployed(): Promise<Contract>;
|
||||
_deployed(blockTag?: BlockTag): Promise<Contract>;
|
||||
fallback(overrides?: TransactionRequest): Promise<TransactionResponse>;
|
||||
connect(signerOrProvider: Signer | Provider | string): Contract;
|
||||
attach(addressOrName: string): Contract;
|
||||
static isIndexed(value: any): value is Indexed;
|
||||
private _events;
|
||||
private _getEventFilter;
|
||||
private _addEventListener;
|
||||
on(event: EventFilter | string, listener: Listener): Contract;
|
||||
once(event: EventFilter | string, listener: Listener): Contract;
|
||||
addListener(eventName: EventFilter | string, listener: Listener): Contract;
|
||||
emit(eventName: EventFilter | string, ...args: Array<any>): boolean;
|
||||
listenerCount(eventName?: EventFilter | string): number;
|
||||
listeners(eventName: EventFilter | string): Array<Listener>;
|
||||
removeAllListeners(eventName: EventFilter | string): Contract;
|
||||
removeListener(eventName: any, listener: Listener): Contract;
|
||||
}
|
||||
export declare class ContractFactory {
|
||||
readonly interface: Interface;
|
||||
readonly bytecode: string;
|
||||
readonly signer: Signer;
|
||||
constructor(contractInterface: Array<string | FunctionFragment | EventFragment | ParamType> | string | Interface, bytecode: Arrayish | string | {
|
||||
object: string;
|
||||
}, signer?: Signer);
|
||||
getDeployTransaction(...args: Array<any>): UnsignedTransaction;
|
||||
deploy(...args: Array<any>): Promise<Contract>;
|
||||
attach(address: string): Contract;
|
||||
connect(signer: Signer): ContractFactory;
|
||||
static fromSolidity(compilerOutput: any, signer?: Signer): ContractFactory;
|
||||
}
|
||||
export {};
|
714
contract.js
714
contract.js
@ -1,714 +0,0 @@
|
||||
'use strict';
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var constants_1 = require("./constants");
|
||||
var errors = __importStar(require("./errors"));
|
||||
var abi_coder_1 = require("./utils/abi-coder");
|
||||
var address_1 = require("./utils/address");
|
||||
var bignumber_1 = require("./utils/bignumber");
|
||||
var bytes_1 = require("./utils/bytes");
|
||||
var interface_1 = require("./utils/interface");
|
||||
var properties_1 = require("./utils/properties");
|
||||
///////////////////////////////
|
||||
// Imported Abstracts
|
||||
var abstract_provider_1 = require("./providers/abstract-provider");
|
||||
var abstract_signer_1 = require("./abstract-signer");
|
||||
///////////////////////////////
|
||||
var VoidSigner = /** @class */ (function (_super) {
|
||||
__extends(VoidSigner, _super);
|
||||
function VoidSigner(address, provider) {
|
||||
var _this = _super.call(this) || this;
|
||||
properties_1.defineReadOnly(_this, 'address', address);
|
||||
properties_1.defineReadOnly(_this, 'provider', provider);
|
||||
return _this;
|
||||
}
|
||||
VoidSigner.prototype.getAddress = function () {
|
||||
return Promise.resolve(this.address);
|
||||
};
|
||||
VoidSigner.prototype._fail = function (message, operation) {
|
||||
return Promise.resolve().then(function () {
|
||||
errors.throwError(message, errors.UNSUPPORTED_OPERATION, { operation: operation });
|
||||
});
|
||||
};
|
||||
VoidSigner.prototype.signMessage = function (message) {
|
||||
return this._fail('VoidSigner cannot sign messages', 'signMessage');
|
||||
};
|
||||
VoidSigner.prototype.sendTransaction = function (transaction) {
|
||||
return this._fail('VoidSigner cannot sign transactions', 'sendTransaction');
|
||||
};
|
||||
VoidSigner.prototype.connect = function (provider) {
|
||||
return new VoidSigner(this.address, provider);
|
||||
};
|
||||
return VoidSigner;
|
||||
}(abstract_signer_1.Signer));
|
||||
exports.VoidSigner = VoidSigner;
|
||||
var allowedTransactionKeys = {
|
||||
chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true
|
||||
};
|
||||
// Recursively replaces ENS names with promises to resolve the name and
|
||||
// stalls until all promises have returned
|
||||
// @TODO: Expand this to resolve any promises too
|
||||
function resolveAddresses(provider, value, paramType) {
|
||||
if (Array.isArray(paramType)) {
|
||||
var promises_1 = [];
|
||||
paramType.forEach(function (paramType, index) {
|
||||
var v = null;
|
||||
if (Array.isArray(value)) {
|
||||
v = value[index];
|
||||
}
|
||||
else {
|
||||
v = value[paramType.name];
|
||||
}
|
||||
promises_1.push(resolveAddresses(provider, v, paramType));
|
||||
});
|
||||
return Promise.all(promises_1);
|
||||
}
|
||||
if (paramType.type === 'address') {
|
||||
return provider.resolveName(value);
|
||||
}
|
||||
if (paramType.type === 'tuple') {
|
||||
return resolveAddresses(provider, value, paramType.components);
|
||||
}
|
||||
// Strips one level of array indexing off the end to recuse into
|
||||
var isArrayMatch = paramType.type.match(/(.*)(\[[0-9]*\]$)/);
|
||||
if (isArrayMatch) {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new Error('invalid value for array');
|
||||
}
|
||||
var promises = [];
|
||||
var subParamType = {
|
||||
components: paramType.components,
|
||||
type: isArrayMatch[1],
|
||||
};
|
||||
value.forEach(function (v) {
|
||||
promises.push(resolveAddresses(provider, v, subParamType));
|
||||
});
|
||||
return Promise.all(promises);
|
||||
}
|
||||
return Promise.resolve(value);
|
||||
}
|
||||
function runMethod(contract, functionName, estimateOnly) {
|
||||
var method = contract.interface.functions[functionName];
|
||||
return function () {
|
||||
var params = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
params[_i] = arguments[_i];
|
||||
}
|
||||
var tx = {};
|
||||
var blockTag = null;
|
||||
// If 1 extra parameter was passed in, it contains overrides
|
||||
if (params.length === method.inputs.length + 1 && typeof (params[params.length - 1]) === 'object') {
|
||||
tx = properties_1.shallowCopy(params.pop());
|
||||
if (tx.blockTag != null) {
|
||||
blockTag = tx.blockTag;
|
||||
}
|
||||
delete tx.blockTag;
|
||||
// Check for unexpected keys (e.g. using "gas" instead of "gasLimit")
|
||||
for (var key in tx) {
|
||||
if (!allowedTransactionKeys[key]) {
|
||||
throw new Error('unknown transaction override ' + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.length != method.inputs.length) {
|
||||
throw new Error('incorrect number of arguments');
|
||||
}
|
||||
// Check overrides make sense
|
||||
['data', 'to'].forEach(function (key) {
|
||||
if (tx[key] != null) {
|
||||
errors.throwError('cannot override ' + key, errors.UNSUPPORTED_OPERATION, { operation: key });
|
||||
}
|
||||
});
|
||||
tx.to = contract._deployed(blockTag).then(function () {
|
||||
return contract.addressPromise;
|
||||
});
|
||||
return resolveAddresses(contract.provider, params, method.inputs).then(function (params) {
|
||||
tx.data = method.encode(params);
|
||||
if (method.type === 'call') {
|
||||
// Call (constant functions) always cost 0 ether
|
||||
if (estimateOnly) {
|
||||
return Promise.resolve(constants_1.Zero);
|
||||
}
|
||||
if (!contract.provider) {
|
||||
errors.throwError('call (constant functions) require a provider or a signer with a provider', errors.UNSUPPORTED_OPERATION, { operation: 'call' });
|
||||
}
|
||||
// Check overrides make sense
|
||||
['gasLimit', 'gasPrice', 'value'].forEach(function (key) {
|
||||
if (tx[key] != null) {
|
||||
throw new Error('call cannot override ' + key);
|
||||
}
|
||||
});
|
||||
if (tx.from == null && contract.signer) {
|
||||
tx.from = contract.signer.getAddress();
|
||||
}
|
||||
return contract.provider.call(tx, blockTag).then(function (value) {
|
||||
if ((bytes_1.hexDataLength(value) % 32) === 4 && bytes_1.hexDataSlice(value, 0, 4) === '0x08c379a0') {
|
||||
var reason = abi_coder_1.defaultAbiCoder.decode(['string'], bytes_1.hexDataSlice(value, 4));
|
||||
errors.throwError('call revert exception', errors.CALL_EXCEPTION, {
|
||||
address: contract.address,
|
||||
args: params,
|
||||
method: method.signature,
|
||||
errorSignature: 'Error(string)',
|
||||
errorArgs: [reason],
|
||||
reason: reason,
|
||||
transaction: tx
|
||||
});
|
||||
}
|
||||
try {
|
||||
var result = method.decode(value);
|
||||
if (method.outputs.length === 1) {
|
||||
result = result[0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (error) {
|
||||
if (value === '0x' && method.outputs.length > 0) {
|
||||
errors.throwError('call exception', errors.CALL_EXCEPTION, {
|
||||
address: contract.address,
|
||||
method: method.signature,
|
||||
args: params
|
||||
});
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (method.type === 'transaction') {
|
||||
// Only computing the transaction estimate
|
||||
if (estimateOnly) {
|
||||
if (!contract.provider) {
|
||||
errors.throwError('estimate gas require a provider or a signer with a provider', errors.UNSUPPORTED_OPERATION, { operation: 'estimateGas' });
|
||||
}
|
||||
if (tx.from == null && contract.signer) {
|
||||
tx.from = contract.signer.getAddress();
|
||||
}
|
||||
return contract.provider.estimateGas(tx);
|
||||
}
|
||||
if (tx.gasLimit == null && method.gas != null) {
|
||||
tx.gasLimit = bignumber_1.bigNumberify(method.gas).add(21000);
|
||||
}
|
||||
if (!contract.signer) {
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' });
|
||||
}
|
||||
// Make sure they aren't overriding something they shouldn't
|
||||
if (tx.from != null) {
|
||||
errors.throwError('cannot override from in a transaction', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction' });
|
||||
}
|
||||
return contract.signer.sendTransaction(tx).then(function (tx) {
|
||||
var wait = tx.wait.bind(tx);
|
||||
tx.wait = function (confirmations) {
|
||||
return wait(confirmations).then(function (receipt) {
|
||||
receipt.events = receipt.logs.map(function (log) {
|
||||
var event = properties_1.deepCopy(log);
|
||||
var parsed = contract.interface.parseLog(log);
|
||||
if (parsed) {
|
||||
event.args = parsed.values;
|
||||
event.decode = parsed.decode;
|
||||
event.event = parsed.name;
|
||||
event.eventSignature = parsed.signature;
|
||||
}
|
||||
event.removeListener = function () { return contract.provider; };
|
||||
event.getBlock = function () {
|
||||
return contract.provider.getBlock(receipt.blockHash);
|
||||
};
|
||||
event.getTransaction = function () {
|
||||
return contract.provider.getTransaction(receipt.transactionHash);
|
||||
};
|
||||
event.getTransactionReceipt = function () {
|
||||
return Promise.resolve(receipt);
|
||||
};
|
||||
return event;
|
||||
});
|
||||
return receipt;
|
||||
});
|
||||
};
|
||||
return tx;
|
||||
});
|
||||
}
|
||||
throw new Error('invalid type - ' + method.type);
|
||||
return null;
|
||||
});
|
||||
};
|
||||
}
|
||||
function getEventTag(filter) {
|
||||
if (filter.address && (filter.topics == null || filter.topics.length === 0)) {
|
||||
return '*';
|
||||
}
|
||||
return (filter.address || '*') + '@' + (filter.topics ? filter.topics.join(':') : '');
|
||||
}
|
||||
var Contract = /** @class */ (function () {
|
||||
// https://github.com/Microsoft/TypeScript/issues/5453
|
||||
// Once this issue is resolved (there are open PR) we can do this nicer
|
||||
// by making addressOrName default to null for 2 operand calls. :)
|
||||
// ParamType is not actually correct here, but for legacy reasons,
|
||||
// we need it. See #721.
|
||||
function Contract(addressOrName, contractInterface, signerOrProvider) {
|
||||
var _this = this;
|
||||
errors.checkNew(this, Contract);
|
||||
// @TODO: Maybe still check the addressOrName looks like a valid address or name?
|
||||
//address = getAddress(address);
|
||||
if (interface_1.Interface.isInterface(contractInterface)) {
|
||||
properties_1.defineReadOnly(this, 'interface', contractInterface);
|
||||
}
|
||||
else {
|
||||
properties_1.defineReadOnly(this, 'interface', new interface_1.Interface(contractInterface));
|
||||
}
|
||||
if (abstract_signer_1.Signer.isSigner(signerOrProvider)) {
|
||||
properties_1.defineReadOnly(this, 'provider', signerOrProvider.provider);
|
||||
properties_1.defineReadOnly(this, 'signer', signerOrProvider);
|
||||
}
|
||||
else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) {
|
||||
properties_1.defineReadOnly(this, 'provider', signerOrProvider);
|
||||
properties_1.defineReadOnly(this, 'signer', null);
|
||||
}
|
||||
else {
|
||||
errors.throwError('invalid signer or provider', errors.INVALID_ARGUMENT, { arg: 'signerOrProvider', value: signerOrProvider });
|
||||
}
|
||||
properties_1.defineReadOnly(this, 'estimate', {});
|
||||
properties_1.defineReadOnly(this, 'functions', {});
|
||||
properties_1.defineReadOnly(this, 'filters', {});
|
||||
Object.keys(this.interface.events).forEach(function (eventName) {
|
||||
var event = _this.interface.events[eventName];
|
||||
properties_1.defineReadOnly(_this.filters, eventName, function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return {
|
||||
address: _this.address,
|
||||
topics: event.encodeTopics(args)
|
||||
};
|
||||
});
|
||||
});
|
||||
this._events = [];
|
||||
properties_1.defineReadOnly(this, 'address', addressOrName);
|
||||
if (this.provider) {
|
||||
properties_1.defineReadOnly(this, 'addressPromise', this.provider.resolveName(addressOrName).then(function (address) {
|
||||
if (address == null) {
|
||||
throw new Error('name not found');
|
||||
}
|
||||
return address;
|
||||
}).catch(function (error) {
|
||||
throw error;
|
||||
}));
|
||||
}
|
||||
else {
|
||||
try {
|
||||
properties_1.defineReadOnly(this, 'addressPromise', Promise.resolve(address_1.getAddress(addressOrName)));
|
||||
}
|
||||
catch (error) {
|
||||
// Without a provider, we cannot use ENS names
|
||||
errors.throwError('provider is required to use non-address contract address', errors.INVALID_ARGUMENT, { argument: 'addressOrName', value: addressOrName });
|
||||
}
|
||||
}
|
||||
Object.keys(this.interface.functions).forEach(function (name) {
|
||||
var run = runMethod(_this, name, false);
|
||||
if (_this[name] == null) {
|
||||
properties_1.defineReadOnly(_this, name, run);
|
||||
}
|
||||
else {
|
||||
errors.warn('WARNING: Multiple definitions for ' + name);
|
||||
}
|
||||
if (_this.functions[name] == null) {
|
||||
properties_1.defineReadOnly(_this.functions, name, run);
|
||||
properties_1.defineReadOnly(_this.estimate, name, runMethod(_this, name, true));
|
||||
}
|
||||
});
|
||||
}
|
||||
// @TODO: Allow timeout?
|
||||
Contract.prototype.deployed = function () {
|
||||
return this._deployed();
|
||||
};
|
||||
Contract.prototype._deployed = function (blockTag) {
|
||||
var _this = this;
|
||||
if (!this._deployedPromise) {
|
||||
// If we were just deployed, we know the transaction we should occur in
|
||||
if (this.deployTransaction) {
|
||||
this._deployedPromise = this.deployTransaction.wait().then(function () {
|
||||
return _this;
|
||||
});
|
||||
}
|
||||
else {
|
||||
// @TODO: Once we allow a timeout to be passed in, we will wait
|
||||
// up to that many blocks for getCode
|
||||
// Otherwise, poll for our code to be deployed
|
||||
this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function (code) {
|
||||
if (code === '0x') {
|
||||
errors.throwError('contract not deployed', errors.UNSUPPORTED_OPERATION, {
|
||||
contractAddress: _this.address,
|
||||
operation: 'getDeployed'
|
||||
});
|
||||
}
|
||||
return _this;
|
||||
});
|
||||
}
|
||||
}
|
||||
return this._deployedPromise;
|
||||
};
|
||||
// @TODO:
|
||||
// estimateFallback(overrides?: TransactionRequest): Promise<BigNumber>
|
||||
// @TODO:
|
||||
// estimateDeploy(bytecode: string, ...args): Promise<BigNumber>
|
||||
Contract.prototype.fallback = function (overrides) {
|
||||
var _this = this;
|
||||
if (!this.signer) {
|
||||
errors.throwError('sending a transaction requires a signer', errors.UNSUPPORTED_OPERATION, { operation: 'sendTransaction(fallback)' });
|
||||
}
|
||||
var tx = properties_1.shallowCopy(overrides || {});
|
||||
['from', 'to'].forEach(function (key) {
|
||||
if (tx[key] == null) {
|
||||
return;
|
||||
}
|
||||
errors.throwError('cannot override ' + key, errors.UNSUPPORTED_OPERATION, { operation: key });
|
||||
});
|
||||
tx.to = this.addressPromise;
|
||||
return this.deployed().then(function () {
|
||||
return _this.signer.sendTransaction(tx);
|
||||
});
|
||||
};
|
||||
// Reconnect to a different signer or provider
|
||||
Contract.prototype.connect = function (signerOrProvider) {
|
||||
if (typeof (signerOrProvider) === 'string') {
|
||||
signerOrProvider = new VoidSigner(signerOrProvider, this.provider);
|
||||
}
|
||||
var contract = new Contract(this.address, this.interface, signerOrProvider);
|
||||
if (this.deployTransaction) {
|
||||
properties_1.defineReadOnly(contract, 'deployTransaction', this.deployTransaction);
|
||||
}
|
||||
return contract;
|
||||
};
|
||||
// Re-attach to a different on=chain instance of this contract
|
||||
Contract.prototype.attach = function (addressOrName) {
|
||||
return new Contract(addressOrName, this.interface, this.signer || this.provider);
|
||||
};
|
||||
Contract.isIndexed = function (value) {
|
||||
return interface_1.Interface.isIndexed(value);
|
||||
};
|
||||
Contract.prototype._getEventFilter = function (eventName) {
|
||||
var _this = this;
|
||||
if (typeof (eventName) === 'string') {
|
||||
// Listen for any event
|
||||
if (eventName === '*') {
|
||||
return {
|
||||
prepareEvent: function (e) {
|
||||
var parsed = _this.interface.parseLog(e);
|
||||
if (parsed) {
|
||||
e.args = parsed.values;
|
||||
e.decode = parsed.decode;
|
||||
e.event = parsed.name;
|
||||
e.eventSignature = parsed.signature;
|
||||
}
|
||||
return [e];
|
||||
},
|
||||
eventTag: '*',
|
||||
filter: { address: this.address },
|
||||
};
|
||||
}
|
||||
// Normalize the eventName
|
||||
if (eventName.indexOf('(') !== -1) {
|
||||
eventName = abi_coder_1.formatSignature(abi_coder_1.parseSignature('event ' + eventName));
|
||||
}
|
||||
var event_1 = this.interface.events[eventName];
|
||||
if (!event_1) {
|
||||
errors.throwError('unknown event - ' + eventName, errors.INVALID_ARGUMENT, { argumnet: 'eventName', value: eventName });
|
||||
}
|
||||
var filter_1 = {
|
||||
address: this.address,
|
||||
topics: [event_1.topic]
|
||||
};
|
||||
return {
|
||||
prepareEvent: function (e) {
|
||||
var args = event_1.decode(e.data, e.topics);
|
||||
e.args = args;
|
||||
var result = Array.prototype.slice.call(args);
|
||||
result.push(e);
|
||||
return result;
|
||||
},
|
||||
event: event_1,
|
||||
eventTag: getEventTag(filter_1),
|
||||
filter: filter_1
|
||||
};
|
||||
}
|
||||
var filter = {
|
||||
address: this.address
|
||||
};
|
||||
// Find the matching event in the ABI; if none, we still allow filtering
|
||||
// since it may be a filter for an otherwise unknown event
|
||||
var event = null;
|
||||
if (eventName.topics && eventName.topics[0]) {
|
||||
filter.topics = eventName.topics;
|
||||
for (var name_1 in this.interface.events) {
|
||||
if (name_1.indexOf('(') === -1) {
|
||||
continue;
|
||||
}
|
||||
var e = this.interface.events[name_1];
|
||||
if (e.topic === eventName.topics[0].toLowerCase()) {
|
||||
event = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
prepareEvent: function (e) {
|
||||
if (!event) {
|
||||
return [e];
|
||||
}
|
||||
var args = event.decode(e.data, e.topics);
|
||||
e.args = args;
|
||||
var result = Array.prototype.slice.call(args);
|
||||
result.push(e);
|
||||
return result;
|
||||
},
|
||||
event: event,
|
||||
eventTag: getEventTag(filter),
|
||||
filter: filter
|
||||
};
|
||||
};
|
||||
Contract.prototype._addEventListener = function (eventFilter, listener, once) {
|
||||
var _this = this;
|
||||
if (!this.provider) {
|
||||
errors.throwError('events require a provider or a signer with a provider', errors.UNSUPPORTED_OPERATION, { operation: 'once' });
|
||||
}
|
||||
var wrappedListener = function (log) {
|
||||
var event = properties_1.deepCopy(log);
|
||||
var args = eventFilter.prepareEvent(event);
|
||||
if (eventFilter.event) {
|
||||
event.decode = eventFilter.event.decode;
|
||||
event.event = eventFilter.event.name;
|
||||
event.eventSignature = eventFilter.event.signature;
|
||||
}
|
||||
event.removeListener = function () { _this.removeListener(eventFilter.filter, listener); };
|
||||
event.getBlock = function () { return _this.provider.getBlock(log.blockHash); };
|
||||
event.getTransaction = function () { return _this.provider.getTransaction(log.transactionHash); };
|
||||
event.getTransactionReceipt = function () { return _this.provider.getTransactionReceipt(log.transactionHash); };
|
||||
_this.emit.apply(_this, [eventFilter.filter].concat(args));
|
||||
};
|
||||
this.provider.on(eventFilter.filter, wrappedListener);
|
||||
this._events.push({ eventFilter: eventFilter, listener: listener, wrappedListener: wrappedListener, once: once });
|
||||
};
|
||||
Contract.prototype.on = function (event, listener) {
|
||||
this._addEventListener(this._getEventFilter(event), listener, false);
|
||||
return this;
|
||||
};
|
||||
Contract.prototype.once = function (event, listener) {
|
||||
this._addEventListener(this._getEventFilter(event), listener, true);
|
||||
return this;
|
||||
};
|
||||
Contract.prototype.addListener = function (eventName, listener) {
|
||||
return this.on(eventName, listener);
|
||||
};
|
||||
Contract.prototype.emit = function (eventName) {
|
||||
var _this = this;
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
if (!this.provider) {
|
||||
return false;
|
||||
}
|
||||
var result = false;
|
||||
var eventFilter = this._getEventFilter(eventName);
|
||||
this._events = this._events.filter(function (event) {
|
||||
// Not this event (keep it for later)
|
||||
if (event.eventFilter.eventTag !== eventFilter.eventTag) {
|
||||
return true;
|
||||
}
|
||||
// Call the callback in the next event loop
|
||||
setTimeout(function () {
|
||||
event.listener.apply(_this, args);
|
||||
}, 0);
|
||||
result = true;
|
||||
// Reschedule it if it not "once"
|
||||
return !(event.once);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
Contract.prototype.listenerCount = function (eventName) {
|
||||
if (!this.provider) {
|
||||
return 0;
|
||||
}
|
||||
var eventFilter = this._getEventFilter(eventName);
|
||||
return this._events.filter(function (event) {
|
||||
return event.eventFilter.eventTag === eventFilter.eventTag;
|
||||
}).length;
|
||||
};
|
||||
Contract.prototype.listeners = function (eventName) {
|
||||
if (!this.provider) {
|
||||
return [];
|
||||
}
|
||||
var eventFilter = this._getEventFilter(eventName);
|
||||
return this._events.filter(function (event) {
|
||||
return event.eventFilter.eventTag === eventFilter.eventTag;
|
||||
}).map(function (event) { return event.listener; });
|
||||
};
|
||||
Contract.prototype.removeAllListeners = function (eventName) {
|
||||
var _this = this;
|
||||
if (!this.provider) {
|
||||
return this;
|
||||
}
|
||||
var eventFilter = this._getEventFilter(eventName);
|
||||
this._events = this._events.filter(function (event) {
|
||||
// Keep all other events
|
||||
if (event.eventFilter.eventTag !== eventFilter.eventTag) {
|
||||
return true;
|
||||
}
|
||||
// Deregister this event from the provider and filter it out
|
||||
_this.provider.removeListener(event.eventFilter.filter, event.wrappedListener);
|
||||
return false;
|
||||
});
|
||||
return this;
|
||||
};
|
||||
Contract.prototype.removeListener = function (eventName, listener) {
|
||||
var _this = this;
|
||||
if (!this.provider) {
|
||||
return this;
|
||||
}
|
||||
var found = false;
|
||||
var eventFilter = this._getEventFilter(eventName);
|
||||
this._events = this._events.filter(function (event) {
|
||||
// Make sure this event and listener match
|
||||
if (event.eventFilter.eventTag !== eventFilter.eventTag) {
|
||||
return true;
|
||||
}
|
||||
if (event.listener !== listener) {
|
||||
return true;
|
||||
}
|
||||
_this.provider.removeListener(event.eventFilter.filter, event.wrappedListener);
|
||||
// Already found a matching event in a previous loop
|
||||
if (found) {
|
||||
return true;
|
||||
}
|
||||
// REmove this event (returning false filters us out)
|
||||
found = true;
|
||||
return false;
|
||||
});
|
||||
return this;
|
||||
};
|
||||
return Contract;
|
||||
}());
|
||||
exports.Contract = Contract;
|
||||
var ContractFactory = /** @class */ (function () {
|
||||
// ParamType is not actually correct here, but for legacy reasons,
|
||||
// we need it. See #721.
|
||||
function ContractFactory(contractInterface, bytecode, signer) {
|
||||
var bytecodeHex = null;
|
||||
// Allow the bytecode object from the Solidity compiler
|
||||
if (typeof (bytecode) === 'string') {
|
||||
bytecodeHex = bytecode;
|
||||
}
|
||||
else if (bytes_1.isArrayish(bytecode)) {
|
||||
bytecodeHex = bytes_1.hexlify(bytecode);
|
||||
}
|
||||
else if (typeof (bytecode.object) === 'string') {
|
||||
bytecodeHex = bytecode.object;
|
||||
}
|
||||
else {
|
||||
errors.throwError('bytecode must be a valid hex string', errors.INVALID_ARGUMENT, { arg: 'bytecode', value: bytecode });
|
||||
}
|
||||
// Make sure it is 0x prefixed
|
||||
if (bytecodeHex.substring(0, 2) !== '0x') {
|
||||
bytecodeHex = '0x' + bytecodeHex;
|
||||
}
|
||||
if (!bytes_1.isHexString(bytecodeHex)) {
|
||||
errors.throwError('bytecode must be a valid hex string', errors.INVALID_ARGUMENT, { arg: 'bytecode', value: bytecode });
|
||||
}
|
||||
if ((bytecodeHex.length % 2) !== 0) {
|
||||
errors.throwError('bytecode must be valid data (even length)', errors.INVALID_ARGUMENT, { arg: 'bytecode', value: bytecode });
|
||||
}
|
||||
properties_1.defineReadOnly(this, 'bytecode', bytecodeHex);
|
||||
if (interface_1.Interface.isInterface(contractInterface)) {
|
||||
properties_1.defineReadOnly(this, 'interface', contractInterface);
|
||||
}
|
||||
else {
|
||||
properties_1.defineReadOnly(this, 'interface', new interface_1.Interface(contractInterface));
|
||||
}
|
||||
if (signer && !abstract_signer_1.Signer.isSigner(signer)) {
|
||||
errors.throwError('invalid signer', errors.INVALID_ARGUMENT, { arg: 'signer', value: null });
|
||||
}
|
||||
properties_1.defineReadOnly(this, 'signer', signer || null);
|
||||
}
|
||||
ContractFactory.prototype.getDeployTransaction = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var tx = {};
|
||||
// If we have 1 additional argument, we allow transaction overrides
|
||||
if (args.length === this.interface.deployFunction.inputs.length + 1) {
|
||||
tx = properties_1.shallowCopy(args.pop());
|
||||
for (var key in tx) {
|
||||
if (!allowedTransactionKeys[key]) {
|
||||
throw new Error('unknown transaction override ' + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do not allow these to be overridden in a deployment transaction
|
||||
['data', 'from', 'to'].forEach(function (key) {
|
||||
if (tx[key] == null) {
|
||||
return;
|
||||
}
|
||||
errors.throwError('cannot override ' + key, errors.UNSUPPORTED_OPERATION, { operation: key });
|
||||
});
|
||||
// Make sure the call matches the constructor signature
|
||||
errors.checkArgumentCount(args.length, this.interface.deployFunction.inputs.length, ' in Contract constructor');
|
||||
// Set the data to the bytecode + the encoded constructor arguments
|
||||
tx.data = this.interface.deployFunction.encode(this.bytecode, args);
|
||||
return tx;
|
||||
};
|
||||
ContractFactory.prototype.deploy = function () {
|
||||
var _this = this;
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
// Get the deployment transaction (with optional overrides)
|
||||
var tx = this.getDeployTransaction.apply(this, args);
|
||||
// Send the deployment transaction
|
||||
return this.signer.sendTransaction(tx).then(function (tx) {
|
||||
var contract = new Contract(address_1.getContractAddress(tx), _this.interface, _this.signer);
|
||||
properties_1.defineReadOnly(contract, 'deployTransaction', tx);
|
||||
return contract;
|
||||
});
|
||||
};
|
||||
ContractFactory.prototype.attach = function (address) {
|
||||
return new Contract(address, this.interface, this.signer);
|
||||
};
|
||||
ContractFactory.prototype.connect = function (signer) {
|
||||
return new ContractFactory(this.interface, this.bytecode, signer);
|
||||
};
|
||||
ContractFactory.fromSolidity = function (compilerOutput, signer) {
|
||||
if (compilerOutput == null) {
|
||||
errors.throwError('missing compiler output', errors.MISSING_ARGUMENT, { argument: 'compilerOutput' });
|
||||
}
|
||||
if (typeof (compilerOutput) === 'string') {
|
||||
compilerOutput = JSON.parse(compilerOutput);
|
||||
}
|
||||
var abi = compilerOutput.abi;
|
||||
var bytecode = null;
|
||||
if (compilerOutput.bytecode) {
|
||||
bytecode = compilerOutput.bytecode;
|
||||
}
|
||||
else if (compilerOutput.evm && compilerOutput.evm.bytecode) {
|
||||
bytecode = compilerOutput.evm.bytecode;
|
||||
}
|
||||
return new ContractFactory(abi, bytecode, signer);
|
||||
};
|
||||
return ContractFactory;
|
||||
}());
|
||||
exports.ContractFactory = ContractFactory;
|
22
dist/README.md
vendored
Normal file
22
dist/README.md
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
Distribution Folder
|
||||
===================
|
||||
|
||||
The contents of this folder are for using `import` in ESM
|
||||
browser-base projects.
|
||||
|
||||
The `ethers.js` (and `ethers.min.js`) files only include the
|
||||
English wordlist to conserve space.
|
||||
|
||||
For additional Wordlist support, the `wordlist-extra.js` (and
|
||||
`wordlist-extra.min.js`) should be imported too.
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
The contents are generated via the `npm build dist` target using
|
||||
`rollup` and the `/rollup.config.js` configuration.
|
||||
|
||||
Do not modify the files in this folder. They are deleted on `build-clean`.
|
||||
|
||||
To modify this `README.md`, see the `/output/post-build/dist`.
|
474
dist/demo/index.html
vendored
474
dist/demo/index.html
vendored
@ -1,474 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Ethereum Wallet</title>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="centerer" id="screen-select">
|
||||
<div class="centered">
|
||||
<h1>Ethereum Wallet Tool</h1>
|
||||
<hr />
|
||||
<h2>Load JSON Wallet</h2>
|
||||
<p>
|
||||
If you have a JSON wallet file from <i>geth</i> or from the initial <i>Ethereum</i>
|
||||
crowd sale, you can decrypt it here. No information is shared with <b>any</b>
|
||||
server.
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>JSON Wallet:</th>
|
||||
<td><div class="file" id="select-wallet-drop">Drop JSON wallet file here</div><input type="file" id="select-wallet-file" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Password:</th>
|
||||
<td><input type="password" placeholder="(password)" id="select-wallet-password" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<div id="select-submit-wallet" class="submit disable">Unlock JSON Wallet</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
<h2>Mnemonic Phrase Wallet</h2>
|
||||
<p>
|
||||
If you have a 12 word mnemonic phrase, you can generate your wallet here.
|
||||
No information is shared with <b>any</b> server.
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Mnemonic Phrase:</th>
|
||||
<td><input type="text" placeholder="(mnemonic phrase)" id="select-mnemonic-phrase" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Path:</th>
|
||||
<td><input type="text" placeholder="(path)" id="select-mnemonic-path" value="m/44'/60'/0'/0/0" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<div id="select-submit-mnemonic" class="submit disable">Derive Wallet</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
<h2>Raw Private Key</h2>
|
||||
<p>
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Private Key:</th>
|
||||
<td><input type="text" placeholder="(private key)" id="select-privatekey" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<div id="select-submit-privatekey" class="submit disable">Load Raw Private Key</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
<h3>Disclaimer:</h3>
|
||||
<p>
|
||||
This is beta software, with no warranty. <b>Use at your own risk.</b>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="centerer hidden" id="screen-loading">
|
||||
<div class="centered">
|
||||
<h1>Loading Wallet</h1>
|
||||
<hr />
|
||||
<h2 id="loading-header"></h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Progress:</th>
|
||||
<td>
|
||||
<input type="text" readonly="readonly" class="readonly" id="loading-status" value="" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<div id="loading-cancel" class="submit">Cancel</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr />
|
||||
<h3>Disclaimer:</h3>
|
||||
<p>
|
||||
This is beta software, with no warranty. <b>Use at your own risk.</b>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="centerer hidden" id="screen-wallet">
|
||||
<div class="centered">
|
||||
<h1>Ethereum Wallet<span id="wallet-username" class="username right"></span></h1>
|
||||
<hr />
|
||||
<h3>Wallet Details:</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Address:</th>
|
||||
<td>
|
||||
<input type="text" readonly="readonly" class="readonly" id="wallet-address" value="" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Network:</th>
|
||||
<td>
|
||||
<div class="clearfix"></div>
|
||||
<div class="network option" data-network="ropsten">Ropsten<br /><span>testnet</span></div>
|
||||
<div class="network option" data-network="rinkeby">Rinkeby<br /><span>testnet</span></div>
|
||||
<div class="network option" data-network="kovan">Kovan<br /><span>testnet</span></div>
|
||||
<div class="network option last selected" data-network="homestead">Homestead<br /><span>mainnet</span></div>
|
||||
<div class="clearfix"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Balance:</th>
|
||||
<td>
|
||||
<input type="text" readonly="readonly" class="readonly" id="wallet-balance" value="0.0" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Nonce:</th>
|
||||
<td>
|
||||
<input type="text" readonly="readonly" class="readonly" id="wallet-transaction-count" value="0" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<div id="wallet-submit-refresh" class="submit">Refresh</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>Send Ether:</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Target Address:</th>
|
||||
<td><input type="text" placeholder="(target address)" id="wallet-send-target-address" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Amount:</th>
|
||||
<td><input type="text" placeholder="(amount)" id="wallet-send-amount" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<div id="wallet-submit-send" class="submit disable">Send Ether</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>Session Activity</h3>
|
||||
<div id="wallet-activity" class="activity"></div>
|
||||
|
||||
<hr />
|
||||
<h3>Disclaimer:</h3>
|
||||
<p>
|
||||
This is beta software, with no warranty. <b>Use at your own risk.</b>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="../../dist/ethers.js"></script>
|
||||
<script type="text/javascript">
|
||||
function query(el, selector) {
|
||||
if (!selector) {
|
||||
selector = el;
|
||||
el = document;
|
||||
}
|
||||
return Array.prototype.slice.call(el.querySelectorAll(selector));
|
||||
}
|
||||
|
||||
function setEnter(source, target) {
|
||||
source.onkeyup = function(e) {
|
||||
if (e.which === 13) { target.click(); }
|
||||
}
|
||||
}
|
||||
|
||||
var cancelScrypt = false;
|
||||
document.getElementById('loading-cancel').onclick = function() {
|
||||
cancelScrypt = true;
|
||||
};
|
||||
|
||||
var updateLoading = (function() {
|
||||
var loadingStatus = document.getElementById('loading-status');
|
||||
return (function(progress) {
|
||||
loadingStatus.value = (parseInt(progress * 100)) + '%';
|
||||
return cancelScrypt;
|
||||
});
|
||||
})();
|
||||
|
||||
// JSON Wallet
|
||||
(function() {
|
||||
var inputFile = document.getElementById('select-wallet-file');
|
||||
var targetDrop = document.getElementById('select-wallet-drop');
|
||||
var inputPassword = document.getElementById('select-wallet-password');
|
||||
var submit = document.getElementById('select-submit-wallet');
|
||||
|
||||
function check() {
|
||||
if (inputFile.files && inputFile.files.length === 1) {
|
||||
submit.classList.remove('disable');
|
||||
targetDrop.textContent = inputFile.files[0].name;
|
||||
} else {
|
||||
submit.classList.add('disable');
|
||||
}
|
||||
}
|
||||
inputFile.onchange = check;
|
||||
inputPassword.oninput = check;
|
||||
|
||||
setEnter(inputPassword, submit);
|
||||
|
||||
inputFile.addEventListener('dragover', function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
targetDrop.classList.add('highlight');
|
||||
}, true);
|
||||
|
||||
inputFile.addEventListener('drop', function(event) {
|
||||
targetDrop.classList.remove('highlight');
|
||||
}, true);
|
||||
|
||||
submit.onclick = function() {
|
||||
if (submit.classList.contains('disable')) { return; }
|
||||
|
||||
var fileReader = new FileReader();
|
||||
fileReader.onload = function(e) {
|
||||
var json = e.target.result;
|
||||
|
||||
if (ethers.utils.getJsonWalletAddress(json)) {
|
||||
showLoading('Decrypting Wallet...');
|
||||
|
||||
cancelScrypt = false;
|
||||
|
||||
ethers.Wallet.fromEncryptedJson(json, inputPassword.value, updateLoading).then(function(wallet) {
|
||||
showWallet(wallet);
|
||||
|
||||
}, function(error) {
|
||||
if (error.message === 'invalid password') {
|
||||
alert('Wrong Password');
|
||||
} else {
|
||||
console.log(error);
|
||||
alert('Error Decrypting Wallet');
|
||||
}
|
||||
showSelect();
|
||||
});
|
||||
} else {
|
||||
alert('Unknown JSON wallet format');
|
||||
}
|
||||
};
|
||||
fileReader.readAsText(inputFile.files[0]);
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
// Raw Private Key
|
||||
(function() {
|
||||
var inputPrivatekey = document.getElementById('select-privatekey');
|
||||
var submit = document.getElementById('select-submit-privatekey');
|
||||
|
||||
function check() {
|
||||
if (inputPrivatekey.value.match(/^(0x)?[0-9A-fa-f]{64}$/)) {
|
||||
submit.classList.remove('disable');
|
||||
} else {
|
||||
submit.classList.add('disable');
|
||||
}
|
||||
}
|
||||
inputPrivatekey.oninput = check;
|
||||
|
||||
setEnter(inputPrivatekey, submit);
|
||||
|
||||
submit.onclick = function() {
|
||||
if (submit.classList.contains('disable')) { return; }
|
||||
var privateKey = inputPrivatekey.value;
|
||||
if (privateKey.substring(0, 2) !== '0x') { privateKey = '0x' + privateKey; }
|
||||
showWallet(new ethers.Wallet(privateKey));
|
||||
}
|
||||
})();
|
||||
|
||||
// Mnemonic Phrase
|
||||
(function() {
|
||||
var inputPhrase = document.getElementById('select-mnemonic-phrase');
|
||||
var inputPath = document.getElementById('select-mnemonic-path');
|
||||
var submit = document.getElementById('select-submit-mnemonic');
|
||||
|
||||
function check() {
|
||||
if (ethers.HDNode.isValidMnemonic(inputPhrase.value)) {
|
||||
submit.classList.remove('disable');
|
||||
} else {
|
||||
submit.classList.add('disable');
|
||||
}
|
||||
}
|
||||
inputPhrase.oninput = check;
|
||||
inputPath.oninput = check;
|
||||
|
||||
setEnter(inputPhrase, submit);
|
||||
setEnter(inputPath, submit);
|
||||
|
||||
submit.onclick = function() {
|
||||
if (submit.classList.contains('disable')) { return; }
|
||||
showWallet(ethers.Wallet.fromMnemonic(inputPhrase.value, inputPath.value));
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
var activeWallet = null;
|
||||
|
||||
function showError(error) {
|
||||
alert('Error \u2014 ' + error.message);
|
||||
}
|
||||
|
||||
// Refresh balance and transaction count in the UI
|
||||
var refresh = (function() {
|
||||
var inputBalance = document.getElementById('wallet-balance');
|
||||
var inputTransactionCount = document.getElementById('wallet-transaction-count');
|
||||
var submit = document.getElementById('wallet-submit-refresh');
|
||||
|
||||
function refresh() {
|
||||
addActivity('> Refreshing details...');
|
||||
activeWallet.getBalance('pending').then(function(balance) {
|
||||
addActivity('< Balance: ' + balance.toString(10));
|
||||
inputBalance.value = ethers.utils.formatEther(balance, { commify: true });
|
||||
}, function(error) {
|
||||
showError(error);
|
||||
});
|
||||
activeWallet.getTransactionCount('pending').then(function(transactionCount) {
|
||||
addActivity('< TransactionCount: ' + transactionCount);
|
||||
inputTransactionCount.value = transactionCount;
|
||||
}, function(error) {
|
||||
showError(error);
|
||||
});
|
||||
}
|
||||
submit.onclick = refresh;
|
||||
|
||||
return refresh;
|
||||
})();
|
||||
|
||||
var addActivity = (function() {
|
||||
var activity = document.getElementById('wallet-activity');
|
||||
return function(message, url) {
|
||||
var line = document.createElement('a');
|
||||
line.textContent = message;
|
||||
if (url) {
|
||||
line.setAttribute('href', url);
|
||||
line.setAttribute('target', '_blank');
|
||||
}
|
||||
activity.appendChild(line);
|
||||
}
|
||||
})();
|
||||
|
||||
// Set up the wallet page
|
||||
(function() {
|
||||
|
||||
var inputTargetAddress = document.getElementById('wallet-send-target-address');
|
||||
var inputAmount = document.getElementById('wallet-send-amount');
|
||||
var submit = document.getElementById('wallet-submit-send');
|
||||
|
||||
// Validate the address and value (to enable the send button)
|
||||
function check() {
|
||||
try {
|
||||
ethers.utils.getAddress(inputTargetAddress.value);
|
||||
ethers.utils.parseEther(inputAmount.value);
|
||||
} catch (error) {
|
||||
submit.classList.add('disable');
|
||||
return;
|
||||
}
|
||||
submit.classList.remove('disable');
|
||||
}
|
||||
inputTargetAddress.oninput = check;
|
||||
inputAmount.oninput = check;
|
||||
|
||||
query('.network.option').forEach(function(el) {
|
||||
var network = el.getAttribute('data-network');
|
||||
el.onclick = function() {
|
||||
addActivity('! Switched network: ' + network);
|
||||
activeWallet = activeWallet.connect(ethers.providers.getDefaultProvider(network));
|
||||
query('.network.option.selected').forEach(function(el) {
|
||||
el.classList.remove('selected');
|
||||
});
|
||||
el.classList.add('selected');
|
||||
refresh();
|
||||
};
|
||||
});
|
||||
|
||||
// Send ether
|
||||
submit.onclick = function() {
|
||||
|
||||
// Matt (from Etherscan) is working on a gasPrice API call, which
|
||||
// should be done within a week or so.
|
||||
// @TODO
|
||||
//var gasPrice = (activeWallet.provider.testnet ? 0x4a817c800: 0xba43b7400);
|
||||
//console.log('GasPrice: ' + gasPrice);
|
||||
|
||||
var targetAddress = ethers.utils.getAddress(inputTargetAddress.value);
|
||||
var amountWei = ethers.utils.parseEther(inputAmount.value);
|
||||
activeWallet.sendTransaction({
|
||||
to: targetAddress,
|
||||
value: amountWei,
|
||||
//gasPrice: activeWallet.provider.getGasPrice(),
|
||||
//gasLimit: 21000,
|
||||
}).then(function(tx) {
|
||||
console.log(tx);
|
||||
|
||||
// Since we only use standard networks, network will always be known
|
||||
var tag = activeWallet.provider.network.name + '.';
|
||||
if (tag === 'homestead.') { tag = ''; }
|
||||
var url = 'https://' + tag + 'etherscan.io/tx/' + tx.hash;
|
||||
addActivity('< Transaction sent: ' + tx.hash.substring(0, 20) + '...', url);
|
||||
alert('Success!');
|
||||
|
||||
inputTargetAddress.value = '';
|
||||
inputAmount.value = '';
|
||||
submit.classList.add('disable');
|
||||
|
||||
refresh();
|
||||
}, function(error) {
|
||||
console.log(error);
|
||||
showError(error);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
function showSelect() {
|
||||
document.getElementById('screen-select').style.display = 'block';
|
||||
document.getElementById('screen-loading').style.display = 'none';
|
||||
document.getElementById('screen-wallet').style.display = 'none';
|
||||
}
|
||||
|
||||
function showLoading(title) {
|
||||
document.getElementById('screen-select').style.display = 'none';
|
||||
document.getElementById('screen-loading').style.display = 'block';
|
||||
document.getElementById('screen-wallet').style.display = 'none';
|
||||
|
||||
document.getElementById('loading-header').textContent = title;
|
||||
}
|
||||
|
||||
function showWallet(wallet) {
|
||||
var network = document.querySelector('.network.option.selected').getAttribute('data-network');
|
||||
activeWallet = wallet.connect(new ethers.providers.getDefaultProvider(network));
|
||||
|
||||
document.getElementById('screen-select').style.display = 'none';
|
||||
document.getElementById('screen-loading').style.display = 'none';
|
||||
document.getElementById('screen-wallet').style.display = 'block';
|
||||
|
||||
var inputWalletAddress = document.getElementById('wallet-address');
|
||||
inputWalletAddress.value = wallet.address;
|
||||
inputWalletAddress.onclick = function() {
|
||||
this.select();
|
||||
};
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
//var privateKey = '0x3141592653589793238462643383279502884197169399375105820974944592';
|
||||
//showWallet(new ethers.Wallet(privateKey));
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
199
dist/demo/style.css
vendored
199
dist/demo/style.css
vendored
@ -1,199 +0,0 @@
|
||||
body {
|
||||
background-color: #eee;
|
||||
font-family: sans-serif;
|
||||
font-size: 18px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.centerer {
|
||||
margin-left: 50%;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.centered:before {
|
||||
box-shadow: -10px 0 15px -10px #999 inset;
|
||||
content: " ";
|
||||
height: 100%;
|
||||
left: -10px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
.centered:after {
|
||||
box-shadow: 10px 0 15px -10px #999 inset;
|
||||
content: " ";
|
||||
height: 100%;
|
||||
right: -10px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
.centered {
|
||||
background-color: #fff;
|
||||
border-left: 1px solid #888;
|
||||
border-right: 1px solid #888;
|
||||
dbox-shadow: -1px 0 15px 0 #999;
|
||||
margin-left: -370px;
|
||||
min-height: 100%;
|
||||
padding: 20px;
|
||||
position: relative;
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: justify;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
th {
|
||||
text-align: left;
|
||||
padding: 0 15px 15px 0;
|
||||
}
|
||||
td {
|
||||
padding: 0 15px 15px 0;
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
border: 1px solid #555;
|
||||
font-size: 16px;
|
||||
padding: 10px;
|
||||
width: 501px;
|
||||
}
|
||||
|
||||
input[type=password] {
|
||||
border: 1px solid #555;
|
||||
font-size: 16px;
|
||||
padding: 10px;
|
||||
width: 501px;
|
||||
}
|
||||
|
||||
input[type=file] {
|
||||
dbackground: #fff;
|
||||
border: 1px solid #555;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
opacity: 0;
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
dvisibility: hidden;
|
||||
width: 501px;
|
||||
}
|
||||
|
||||
input[type=text].readonly {
|
||||
border: 1px solid #ccc;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.file {
|
||||
border: 1px solid green;
|
||||
color: #444;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
margin-top: 2px;
|
||||
padding: 13px 10px 12px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
width: 478px;
|
||||
}
|
||||
|
||||
.file.highlight {
|
||||
box-shadow: 0px 0px 5px #888;
|
||||
}
|
||||
|
||||
.clearfix {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.option {
|
||||
border: 1px solid #999;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
font-size: 16px;
|
||||
opacity: 0.3;
|
||||
padding: 10px;
|
||||
margin-right: 20px;
|
||||
text-align: center;
|
||||
transition: opacity 0.1s linear;
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.option span {
|
||||
font-size: 0.8em;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.option.selected {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.option:hover {
|
||||
box-shadow: 0px 0px 5px #888;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
table {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
div.activity {
|
||||
font-family: monospace;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
div.activity a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.username {
|
||||
color: #888;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.submit {
|
||||
border: 1px solid #555;
|
||||
box-shadow: 0px 0px 5px #888;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
transition: opacity 0.1s linear;
|
||||
width: 480px;
|
||||
}
|
||||
|
||||
.submit:hover {
|
||||
border: 1px solid #999;
|
||||
box-shadow: 0px 0px 5px #aaa;
|
||||
}
|
||||
|
||||
.submit:active {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.submit.disable {
|
||||
box-shadow: none;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.submit.disable:hover {
|
||||
border: 1px solid #555;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.submit.disable:active {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.right {
|
||||
float: right;
|
||||
}
|
42615
dist/ethers.js
vendored
42615
dist/ethers.js
vendored
File diff suppressed because one or more lines are too long
1
dist/ethers.js.map
vendored
Normal file
1
dist/ethers.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
3
dist/ethers.min.js
vendored
3
dist/ethers.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/ethers.min.js.map
vendored
1
dist/ethers.min.js.map
vendored
File diff suppressed because one or more lines are too long
1066
dist/ethers.types.txt
vendored
1066
dist/ethers.types.txt
vendored
File diff suppressed because it is too large
Load Diff
25825
dist/ethers.umd.js
vendored
Normal file
25825
dist/ethers.umd.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/ethers.umd.js.map
vendored
Normal file
1
dist/ethers.umd.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/ethers.umd.min.js
vendored
Normal file
1
dist/ethers.umd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/shims.js
vendored
1
dist/shims.js
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlist-es.js
vendored
1
dist/wordlist-es.js
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlist-fr.js
vendored
1
dist/wordlist-fr.js
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlist-it.js
vendored
1
dist/wordlist-it.js
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlist-ja.js
vendored
1
dist/wordlist-ja.js
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlist-ko.js
vendored
1
dist/wordlist-ko.js
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlist-zh.js
vendored
1
dist/wordlist-zh.js
vendored
File diff suppressed because one or more lines are too long
1540
dist/wordlists-extra.js
vendored
Normal file
1540
dist/wordlists-extra.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/wordlists-extra.js.map
vendored
Normal file
1
dist/wordlists-extra.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/wordlists-extra.min.js
vendored
Normal file
1
dist/wordlists-extra.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
docs.wrm/README.md
Normal file
5
docs.wrm/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Documentation Source
|
||||
====================
|
||||
|
||||
This folder contains all the Flatworm source for the documentation.
|
||||
|
97
docs.wrm/basics/abi.wrm
Normal file
97
docs.wrm/basics/abi.wrm
Normal file
@ -0,0 +1,97 @@
|
||||
_section: Application Binary Interfaces @<docs-abi>
|
||||
|
||||
When interacting with any application, whether it is on Ethereum,
|
||||
over the internet or within a compiled application on a computer
|
||||
all information is stored and sent as binary data which is just a
|
||||
sequence of bytes.
|
||||
|
||||
So every application must agree on how to encode and decode their
|
||||
information as a sequence of bytes.
|
||||
|
||||
An **Application Binary Interface** (ABI) provides a way to describe
|
||||
the encoding and decoding process, in a generic way so that a variety
|
||||
of types and structures of types can be defined.
|
||||
|
||||
For example, a string is often encoded as a UTF-8 sequence of bytes,
|
||||
which uses specific bits within sub-sequences to indicate emoji and
|
||||
other special characters. Every implementation of UTF-8 must understand
|
||||
and operate under the same rules so that strings work universally. In
|
||||
this way, UTF-8 standard is itself an ABI.
|
||||
|
||||
When interacting with Ethereum, a contract received a sequence of bytes
|
||||
as input (provided by sending a transaction or through a call) and
|
||||
returns a result as a sequence of bytes. So, each Contract has its own
|
||||
ABI that helps specify how to encode the input and how to decode the output.
|
||||
|
||||
It is up to the contract developer to make this ABI available. Many
|
||||
Contracts implement a standard (such as ERC-20), in which case the
|
||||
ABI for that standard can be used. Many developers choose to verify their
|
||||
source code on Etherscan, in which case Etherscan computes the ABI and
|
||||
provides it through their website (which can be fetched using the ``getContract``
|
||||
method). Otherwise, beyond reverse engineering the Contract there is
|
||||
not a meaningful way to extract the contract ABI.
|
||||
|
||||
_subsection: Call Data Representation
|
||||
|
||||
When calling a Contract on Ethereum, the input data must be encoded
|
||||
according to the ABI.
|
||||
|
||||
The first 4 bytes of the data are the **method selector**, which is
|
||||
the keccak256 hash of the normalized method signature.
|
||||
|
||||
Then the method parameters are encoded and concatenated to the selector.
|
||||
|
||||
All encoded data is made up of components padded to 32 bytes, so the length
|
||||
of input data will always be congruent to ``4 mod 32``.
|
||||
|
||||
The result of a successful call will be encoded values, whose components
|
||||
are padded to 32 bytes each as well, so the length of a result will always
|
||||
be congruent to ``0 mod 32``, on success.
|
||||
|
||||
The result of a reverted call will contain the **error selector** as the
|
||||
first 4 bytes, which is the keccak256 of the normalized error signature,
|
||||
followed by the encoded values, whose components are padded to 32 bytes
|
||||
each, so the length of a revert will be congruent to ``4 mod 32``.
|
||||
|
||||
The one exception to all this is that ``revert(false)`` will return a
|
||||
result or ``0x``.
|
||||
|
||||
|
||||
_subsection: Event Data Representation
|
||||
|
||||
When an Event is emitted from a contract, there are two places data is
|
||||
logged in a Log: the **topics** and the **data**.
|
||||
|
||||
An additonal fee is paid for each **topic**, but this affords a topic
|
||||
to be indexed in a bloom filter within the block, which allows efficient
|
||||
filtering.
|
||||
|
||||
The **topic hash** is always the first topic in a Log, which is the
|
||||
keccak256 of the normalized event signature. This allows a specific
|
||||
event to be efficiently filtered, finding the matching events in a block.
|
||||
|
||||
Each additional **indexed** parameter (i.e. parameters marked with
|
||||
``indexed`` in the signautre) are placed in the topics as well, but may be
|
||||
filtered to find matching values.
|
||||
|
||||
All non-indexed parameters are encoded and placed in the **data**. This
|
||||
is cheaper and more compact, but does not allow filtering on these values.
|
||||
|
||||
For example, the event ``Transfer(address indexed from, address indexed to, uint value)``
|
||||
would require 3 topics, which are the topic hash, the ``from`` address
|
||||
and the ``to`` address and the data would contain 32 bytes, which is
|
||||
the padded big-endian representation of ``value``. This allows for
|
||||
efficient filtering by the event (i.e. ``Transfer``) as well as the ``from``
|
||||
address and ``to`` address.
|
||||
|
||||
|
||||
_subsection: Deployment
|
||||
|
||||
When deploying a transaction, the data provided is treated as **initcode**,
|
||||
which executes the data as normal EVM bytecode, which returns a sequence
|
||||
of bytes, but instead of that sequence of bytes being treated as data that
|
||||
result is instead the bytecode to install as the bytecode of the contract.
|
||||
|
||||
The bytecode produced by Solidity is designed to have all constructor
|
||||
parameters encoded normally and concatenated to the bytecode and provided
|
||||
as the ``data`` to a transaction with no ``to`` address.
|
8
docs.wrm/basics/index.wrm
Normal file
8
docs.wrm/basics/index.wrm
Normal file
@ -0,0 +1,8 @@
|
||||
_section: Ethereum Basics @<docs-basics> @priority<99>
|
||||
|
||||
This section aims to cover some of the basics for those interested
|
||||
in a deeper understanding of the inner-workings of Ethereum.
|
||||
|
||||
_subsection: Topics
|
||||
|
||||
- [Application Binary Interface](docs-abi)
|
86
docs.wrm/config.mjs
Normal file
86
docs.wrm/config.mjs
Normal file
@ -0,0 +1,86 @@
|
||||
import { inspect } from "util";
|
||||
|
||||
import * as ethers from "../lib.esm/index.js";
|
||||
import { version } from "../lib.esm/_version.js";
|
||||
|
||||
import { getModifiedTime } from "../lib.esm/_admin/utils/git.js";
|
||||
|
||||
const title = "ethers";
|
||||
|
||||
const subtitle = (function(version) {
|
||||
const dash = version.indexOf("-");
|
||||
if (dash === -1) { return 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();
|
||||
context.Uint8Array = Uint8Array;
|
||||
|
||||
ethers.InfuraProvider.prototype[inspect.custom] = function(depth, options, inspect) {
|
||||
if (depth > 0) { return `InfuraProvider { ... }`; }
|
||||
// Does this cause infinite recursion??
|
||||
return this;
|
||||
};
|
||||
|
||||
ethers.Interface.prototype[inspect.custom] = function(depth, options, inspect) {
|
||||
if (depth > 0) { return `Interface { ... }`; }
|
||||
// Does this cause infinite recursion??
|
||||
return this;
|
||||
};
|
||||
|
||||
ethers.Fragment.prototype[inspect.custom] = function(depth, options, inspect) {
|
||||
if (depth > 0) { return `${ this.constructor.name } { ... }`; }
|
||||
// Does this cause infinite recursion??
|
||||
return this;
|
||||
};
|
||||
},
|
||||
|
||||
// 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);
|
||||
},
|
||||
|
||||
// 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",
|
||||
extraLinks
|
||||
],
|
||||
|
||||
// Extra files to copy over to the /static folder
|
||||
staticFiles: [
|
||||
"logo.svg",
|
||||
"social.jpg"
|
||||
]
|
||||
};
|
123
docs.wrm/contributing.wrm
Normal file
123
docs.wrm/contributing.wrm
Normal file
@ -0,0 +1,123 @@
|
||||
_section: Contributions and Hacking @<about-contrib> @priority<-90>
|
||||
|
||||
Pull requests are welcome, but please keep the following in mind:
|
||||
|
||||
- Backwards-compatibility-breaking changes will not be accepted;
|
||||
they may be considered for the next major version
|
||||
- Security is important; adding dependencies require fairly
|
||||
convincing arguments as to why
|
||||
- The library aims to be lean, so keep an eye on the
|
||||
``dist/ethers.min.js`` file size before and after your
|
||||
changes (the ``build-clean`` target includes these stats)
|
||||
- Keep the PR simple, readable and confined to the relevant
|
||||
files; see below for which files to change
|
||||
- Add test cases for both expected and unexpected input
|
||||
- Any new features need to be supported by me (future issues,
|
||||
documentation, testing, migration), so anything that is
|
||||
overly complicated or specific may not be accepted
|
||||
- Everyone is working hard; **be kind and respectful**
|
||||
|
||||
It is always //highly recommended// that you open a [[link-discussion]]
|
||||
**before** beginning a PR.
|
||||
|
||||
|
||||
_subsection: Documentation @<about-contrib-docs>
|
||||
|
||||
The documentation is an area which can always benefit from extra
|
||||
eyes, extra knowledge and extra examples.
|
||||
|
||||
Contributing to the documentation is welcome, but when making
|
||||
changes to documentation, please ensure that all changes are
|
||||
made **only** to:
|
||||
|
||||
- Updating ``/docs.wrm/*\*.wrm``
|
||||
- Adding links: ``/docs.wrm/links/*.txt``
|
||||
- Updating API jsdocs: ``/*\* ... */`` comment blocks within ``/src.ts/``
|
||||
|
||||
Generally changes to ``/docs.wrm/config.wrm`` should not be
|
||||
made, and if you feel it is necessary, please consider opening
|
||||
a [[link-discussion]] first.
|
||||
|
||||
Similarly, when adding a new sections, a [[link-discussion]] is
|
||||
preferred.
|
||||
|
||||
All changes should be in the Flatworm Markdown Dialect.
|
||||
|
||||
_heading: Building the Documentation
|
||||
|
||||
Currently, the documentation is built using an experimental v2 of the
|
||||
Flatworm documentation system, a system originally specifically made
|
||||
to maintain the Ethers documentation.
|
||||
|
||||
The new ``tsdocs`` branch has the ability to parse ``jsdocs`` from
|
||||
from TypeScript source files to create an API reference.
|
||||
|
||||
_code: Building with the v2 Flatworm @lang<shell>
|
||||
|
||||
# Clone the repo
|
||||
/home/ricmoo> git clone https://github.com/ricmoo/flatworm.git
|
||||
/home/ricmoo> cd flatworm
|
||||
|
||||
# Check out the tsdocs branch
|
||||
/home/ricmoo/flatworm> git checkout tsdocs
|
||||
|
||||
# Install the necessary dependencies
|
||||
/home/ricmoo/flatworm> npm install
|
||||
|
||||
# Ready to build the docs; output to a folder ./output/
|
||||
/home/ricmoo/flatworm> node lib/cli-test PATH_TO_WRM_ROOT
|
||||
|
||||
Eventually the code for the v2 branch will be cleaned up, and it
|
||||
will be much easier to include as a ``devDependency`` for Ethers.
|
||||
|
||||
In the meantime, expect new changes to be made frequently to the
|
||||
``tsdocs`` branch, so for stability you may wish to checkout a
|
||||
specific hash.
|
||||
|
||||
|
||||
_subsection: Fixing Bugs @<about-contrib-bugs>
|
||||
|
||||
In general the **only** files you should ever include in a PR are:
|
||||
|
||||
- TypeScript source: ``/src.ts/*\*.ts``
|
||||
|
||||
Do not include a ``package.json`` with the updated ``tarballHash``
|
||||
or ``version``, and do not include any generated files in your PR.
|
||||
|
||||
A bug fix **must not** modify anything requiring a minor version
|
||||
bump (see [[about-contrib-feature]]), such as changing a method
|
||||
signature or altering the exports.
|
||||
|
||||
|
||||
_subsection: Adding Features @<about-contrib-feature>
|
||||
|
||||
Contributing new features usually require a deeper understanding
|
||||
of the internal interactions with Ethers and its components, and
|
||||
generally requires a minor version bump.
|
||||
|
||||
When making any of the following changes, you must first open a
|
||||
[[link-discussion]] as the minor version will need to be bumped.
|
||||
|
||||
- any signature change (such as adding a parameter, changing a
|
||||
parameter type, changing the return type)
|
||||
- adding any new export; such as a class, function or constants
|
||||
- adding any method to any class
|
||||
- changing any ``exports`` property within the ``package.json``
|
||||
|
||||
Changes of this sort should not be made without serious consideration
|
||||
and discussion.
|
||||
|
||||
|
||||
_subsection: Building @<building>
|
||||
|
||||
_code: @lang<shell>
|
||||
/home/ricmoo> git clone @TODO
|
||||
/home/ricmoo> cd ethers
|
||||
/home/ricmoo/ethers> npm install
|
||||
/home/ricmoo/ethers> npm run auto-build
|
||||
|
||||
_null:
|
||||
|
||||
|
||||
_subsection: Previewing Documentation
|
||||
|
66
docs.wrm/cookbook/ens.wrm
Normal file
66
docs.wrm/cookbook/ens.wrm
Normal file
@ -0,0 +1,66 @@
|
||||
_section: Cookbook: ENS Recipes @<cookbook-ens>
|
||||
|
||||
Here is a collection of short, but useful examples of working with
|
||||
ENS entries.
|
||||
|
||||
|
||||
_subsection: Get all Text records @<cookbook-ens-allText>
|
||||
|
||||
Here is a short recipe to get all the text records set for an ENS
|
||||
name.
|
||||
|
||||
It first queries all ``TextChanged`` events on the resovler, and
|
||||
uses a MulticallProvider to batch all the ``eth_call`` queries
|
||||
for each key into a single ``eth_call``. As such, you will need
|
||||
to install:
|
||||
|
||||
``/home/ricmoo> npm install @ethers-ext/provider-multicall``
|
||||
|
||||
|
||||
_code: Fetching all ENS text records. @lang<script>
|
||||
|
||||
import { ethers } from "ethers";
|
||||
import { MulticallProvider } from "@ethers-ext/provider-multicall";
|
||||
|
||||
async function getTextRecords(_provider, name) {
|
||||
// Prepare a multicall-based provider to batch all the call operations
|
||||
const provider = new MulticallProvider(_provider);
|
||||
|
||||
// Get the resolver for the given name
|
||||
const resolver = await provider.getResolver(name);
|
||||
|
||||
// A contract instance; used filter and parse logs
|
||||
const contract = new ethers.Contract(resolver.address, [
|
||||
"event TextChanged(bytes32 indexed node, string indexed _key, string key)"
|
||||
], provider);
|
||||
|
||||
// A filter for the given name
|
||||
const filter = contract.filters.TextChanged(ethers.namehash(name));
|
||||
|
||||
// Get the matching logs
|
||||
const logs = await contract.queryFilter(filter);
|
||||
|
||||
// Filter the *unique* keys
|
||||
const keys = [ ...(new Set(logs.map((log) => log.args.key))) ];
|
||||
|
||||
// Get the values for the keys; failures are discarded
|
||||
const values = await Promise.all(keys.map((key) => {
|
||||
try {
|
||||
return resolver.getText(key);
|
||||
} catch (error) { }
|
||||
return null;
|
||||
}));
|
||||
|
||||
// Return a Map of the key/value pairs
|
||||
return keys.reduce((accum, key, index) => {
|
||||
const value = values[index];
|
||||
if (value != null) { accum.set(key, value); }
|
||||
return accum;
|
||||
}, new Map());
|
||||
}
|
||||
|
||||
// Example usage
|
||||
(async function() {
|
||||
const provider = new ethers.InfuraProvider();
|
||||
console.log(await getTextRecords(provider, "ricmoo.eth"));
|
||||
})();
|
7
docs.wrm/cookbook/index.wrm
Normal file
7
docs.wrm/cookbook/index.wrm
Normal file
@ -0,0 +1,7 @@
|
||||
_section: Cookbook @<cookbook>
|
||||
|
||||
A growing collection of code snippets for common problems and use cases
|
||||
when developing dapps and other blockchain tools.
|
||||
|
||||
- [Signing Messages and Data](cookbook-signing)
|
||||
- [React Native Performance](cookbook-react-native)
|
36
docs.wrm/cookbook/react-native.wrm
Normal file
36
docs.wrm/cookbook/react-native.wrm
Normal file
@ -0,0 +1,36 @@
|
||||
_section: React Native @<cookbook-react-native>
|
||||
|
||||
When using React Native, many of the built-in cryptographic primitives
|
||||
can be replaced by native, substantially faster implementations.
|
||||
|
||||
This should be available in its own package in the future, but for now
|
||||
this is highly recommended, and requires installing the
|
||||
[[link-npm-react-native-quick-crypto]] package.
|
||||
|
||||
|
||||
_code:
|
||||
|
||||
import { ethers } from "ethers";
|
||||
|
||||
import crypto from "react-native-quick-crypto";
|
||||
|
||||
ethers.randomBytes.register((length) => {
|
||||
return new Uint8Array(crypto.randomBytes(length));
|
||||
});
|
||||
|
||||
ethers.computeHmac.register((algo, key, data) => {
|
||||
return crypto.createHmac(algo, key).update(data).digest();
|
||||
});
|
||||
|
||||
ethers.pbkdf2.register((passwd, salt, iter, keylen, algo) => {
|
||||
return crypto.pbkdf2Sync(passwd, salt, iter, keylen, algo);
|
||||
});
|
||||
|
||||
ethers.sha256.register((data) => {
|
||||
return crypto.createHash('sha256').update(data).digest();
|
||||
});
|
||||
|
||||
ethers.sha512.register((data) => {
|
||||
return crypto.createHash('sha512').update(data).digest();
|
||||
});
|
||||
|
273
docs.wrm/cookbook/signing.wrm
Normal file
273
docs.wrm/cookbook/signing.wrm
Normal file
@ -0,0 +1,273 @@
|
||||
_section: Signing @<cookbook-signing>
|
||||
|
||||
Signing content and providing the content and signature to a
|
||||
Contract allows on-chain validation that a signer has access
|
||||
to the private key of a specific address.
|
||||
|
||||
The ecrecover algorithm allows the public key to be determined
|
||||
given some message digest and the signature generated by the
|
||||
private key for that digest. From the public key, the address
|
||||
can then be computed.
|
||||
|
||||
How a digest is derived depends on the type of data being
|
||||
signed and a variety of encoding formats are employed. Each
|
||||
format is designed to ensure that they do not collide, so for
|
||||
example, a user **cannot** be tricked into signing a message
|
||||
which is actually a valid transaction.
|
||||
|
||||
For this reason, most APIs in Ethereum do not permit signing a
|
||||
raw digest, and instead require a separate API for each format
|
||||
type and require the related data be specified, protecting the
|
||||
user from accidentally authorizing an action they didn't intend.
|
||||
|
||||
_subsection: Messages @<cookbook-signing-messages>
|
||||
|
||||
A signed message can be any data, but it is generally recommended
|
||||
to use human-readable text, as this is easier for a user to
|
||||
verify visually.
|
||||
|
||||
This technique could be used, for example, to sign into a service
|
||||
by using the text ``"I am signing into ethers.org on 2023-06-04 12:57pm"``.
|
||||
The user can then see the message in MetaMask or on a Ledger
|
||||
Hardware Wallet and accept that they wish to sign the message which
|
||||
the site can then authenticate them with. By providing a timestamp
|
||||
the site can ensure that an older signed message cannot be used again
|
||||
in the future.
|
||||
|
||||
The format that is signed uses [[link-eip-191]] with the
|
||||
**personal sign** version code (``0x45``, or ``"E"``).
|
||||
|
||||
For those interested in the choice of this prefix, signed messages
|
||||
began as a Bitcoin feature, which used ``"\\x18Bitcoin Signed Message:\\n"``,
|
||||
which was a Bitcoin var-int length-prefixed string (as ``0x18`` is 24,
|
||||
the length of ``"Bitcoin Signed Message:\\n"``.). When Ethereum adopted
|
||||
the similar feature, the relevant string was ``"\\x19Ethereum Signed Message:\\n"``.
|
||||
|
||||
In one of the most brilliant instances of technical retcon-ing,
|
||||
since 0x19 is invalid as the first byte of a transaction (in [[link-rlp]] it
|
||||
indicates a single byte of value 25), the initial byte ``\\x19`` has
|
||||
now been adopted as a prefix for //some sort of signed data//,
|
||||
where the second byte determines how to interpret that data. If the
|
||||
second byte is 69 (the letter ``"E"``, as in
|
||||
``"Ethereum Signed Message:\\n"``), then the format is a
|
||||
the above prefixed message format.
|
||||
|
||||
So, all existing messages, tools and instances using the signed
|
||||
message format were already EIP-191 compliant, long before the
|
||||
standard existed or was even conceived and allowed for an extensible
|
||||
format for future formats (of which there now a few).
|
||||
|
||||
Anyways, the necessary JavaScript and Solidity are provided below.
|
||||
|
||||
_code: JavaScript @lang<javascript>
|
||||
|
||||
// The contract below is deployed to Sepolia at this address
|
||||
contractAddress = "0xf554DA5e35b2e40C09DDB481545A395da1736513";
|
||||
contract = new Contract(contractAddress, [
|
||||
"function recoverStringFromCompact(string message, (bytes32 r, bytes32 yParityAndS) sig) pure returns (address)",
|
||||
"function recoverStringFromExpanded(string message, (uint8 v, bytes32 r, bytes32 s) sig) pure returns (address)",
|
||||
"function recoverStringFromVRS(string message, uint8 v, bytes32 r, bytes32 s) pure returns (address)",
|
||||
"function recoverStringFromRaw(string message, bytes sig) pure returns (address)",
|
||||
"function recoverHashFromCompact(bytes32 hash, (bytes32 r, bytes32 yParityAndS) sig) pure returns (address)"
|
||||
], new ethers.InfuraProvider("sepolia"));
|
||||
|
||||
// The Signer; it does not need to be connected to a Provider to sign
|
||||
signer = new Wallet(id("foobar"));
|
||||
signer.address
|
||||
//_result:
|
||||
|
||||
// Our message
|
||||
message = "Hello World";
|
||||
|
||||
// The raw signature; 65 bytes
|
||||
rawSig = await signer.signMessage(message);
|
||||
//_result:
|
||||
|
||||
// Converting it to a Signature object provides more
|
||||
// flexibility, such as using it as a struct
|
||||
sig = Signature.from(rawSig);
|
||||
//_result:
|
||||
|
||||
|
||||
// If the signature matches the EIP-2098 format, a Signature
|
||||
// can be passed as the struct value directly, since the
|
||||
// parser will pull out the matching struct keys from sig.
|
||||
await contract.recoverStringFromCompact(message, sig);
|
||||
//_result:
|
||||
|
||||
// Likewise, if the struct keys match an expanded signature
|
||||
// struct, it can also be passed as the struct value directly.
|
||||
await contract.recoverStringFromExpanded(message, sig);
|
||||
//_result:
|
||||
|
||||
// If using an older API which requires the v, r and s be passed
|
||||
// separately, those members are present on the Signature.
|
||||
await contract.recoverStringFromVRS(message, sig.v, sig.r, sig.s);
|
||||
//_result:
|
||||
|
||||
// Or if using an API that expects a raw signature.
|
||||
await contract.recoverStringFromRaw(message, rawSig);
|
||||
//_result:
|
||||
|
||||
// Note: The above recovered addresses matches the signer address
|
||||
|
||||
_null:
|
||||
|
||||
The Solidity Contract has been deployed and verified on
|
||||
the Sepolia testnet at the address
|
||||
[0xf554DA5e35b2e40C09DDB481545A395da1736513](link-sol-recovermessage).
|
||||
|
||||
It provides a variety of examples using various Signature
|
||||
encodings and formats, to recover the address for an [[link-eip-191]]
|
||||
signed message.
|
||||
|
||||
_code: Solidity @lang<solidity>
|
||||
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// For more info, see: https://docs.ethers.org
|
||||
|
||||
|
||||
pragma solidity ^0.8.21;
|
||||
|
||||
// Returns the decimal string representation of value
|
||||
function itoa(uint value) pure returns (string memory) {
|
||||
|
||||
// Count the length of the decimal string representation
|
||||
uint length = 1;
|
||||
uint v = value;
|
||||
while ((v /= 10) != 0) { length++; }
|
||||
|
||||
// Allocated enough bytes
|
||||
bytes memory result = new bytes(length);
|
||||
|
||||
// Place each ASCII string character in the string,
|
||||
// right to left
|
||||
while (true) {
|
||||
length--;
|
||||
|
||||
// The ASCII value of the modulo 10 value
|
||||
result[length] = bytes1(uint8(0x30 + (value % 10)));
|
||||
|
||||
value /= 10;
|
||||
|
||||
if (length == 0) { break; }
|
||||
}
|
||||
|
||||
return string(result);
|
||||
}
|
||||
|
||||
contract RecoverMessage {
|
||||
|
||||
// This is the EIP-2098 compact representation, which reduces gas costs
|
||||
struct SignatureCompact {
|
||||
bytes32 r;
|
||||
bytes32 yParityAndS;
|
||||
}
|
||||
|
||||
// This is an expaned Signature representation
|
||||
struct SignatureExpanded {
|
||||
uint8 v;
|
||||
bytes32 r;
|
||||
bytes32 s;
|
||||
}
|
||||
|
||||
// Helper function
|
||||
function _ecrecover(string memory message, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
|
||||
// Compute the EIP-191 prefixed message
|
||||
bytes memory prefixedMessage = abi.encodePacked(
|
||||
"\x19Ethereum Signed Message:\n",
|
||||
itoa(bytes(message).length),
|
||||
message
|
||||
);
|
||||
|
||||
// Compute the message digest
|
||||
bytes32 digest = keccak256(prefixedMessage);
|
||||
|
||||
// Use the native ecrecover provided by the EVM
|
||||
return ecrecover(digest, v, r, s);
|
||||
}
|
||||
|
||||
// Recover the address from an EIP-2098 compact Signature, which packs the bit for
|
||||
// v into an unused bit within s, which saves gas overall, costing a little extra
|
||||
// in computation, but saves far more in calldata length.
|
||||
//
|
||||
// This Signature format is 64 bytes in length.
|
||||
function recoverStringFromCompact(string calldata message, SignatureCompact calldata sig) public pure returns (address) {
|
||||
|
||||
// Decompose the EIP-2098 signature (the struct is 64 bytes in length)
|
||||
uint8 v = 27 + uint8(uint256(sig.yParityAndS) >> 255);
|
||||
bytes32 s = bytes32((uint256(sig.yParityAndS) << 1) >> 1);
|
||||
|
||||
return _ecrecover(message, v, sig.r, s);
|
||||
}
|
||||
|
||||
// Recover the address from the expanded Signature struct.
|
||||
//
|
||||
// This Signature format is 96 bytes in length.
|
||||
function recoverStringFromExpanded(string calldata message, SignatureExpanded calldata sig) public pure returns (address) {
|
||||
|
||||
// The v, r and s are included directly within the struct, which is 96 bytes in length
|
||||
return _ecrecover(message, sig.v, sig.r, sig.s);
|
||||
}
|
||||
|
||||
// Recover the address from a v, r and s passed directly into the method.
|
||||
//
|
||||
// This Signature format is 96 bytes in length.
|
||||
function recoverStringFromVRS(string calldata message, uint8 v, bytes32 r, bytes32 s) public pure returns (address) {
|
||||
|
||||
// The v, r and s are included directly within the struct, which is 96 bytes in length
|
||||
return _ecrecover(message, v, r, s);
|
||||
}
|
||||
|
||||
// Recover the address from a raw signature. The signature is 65 bytes, which when
|
||||
// ABI encoded is 160 bytes long (a pointer, a length and the padded 3 words of data).
|
||||
//
|
||||
// When using raw signatures, some tools return the v as 0 or 1. In this case you must
|
||||
// add 27 to that value as v must be either 27 or 28.
|
||||
//
|
||||
// This Signature format is 65 bytes of data, but when ABI encoded is 160 bytes in length;
|
||||
// a pointer (32 bytes), a length (32 bytes) and the padded 3 words of data (96 bytes).
|
||||
function recoverStringFromRaw(string calldata message, bytes calldata sig) public pure returns (address) {
|
||||
|
||||
// Sanity check before using assembly
|
||||
require(sig.length == 65, "invalid signature");
|
||||
|
||||
// Decompose the raw signature into r, s and v (note the order)
|
||||
uint8 v;
|
||||
bytes32 r;
|
||||
bytes32 s;
|
||||
assembly {
|
||||
r := calldataload(sig.offset)
|
||||
s := calldataload(add(sig.offset, 0x20))
|
||||
v := calldataload(add(sig.offset, 0x21))
|
||||
}
|
||||
|
||||
return _ecrecover(message, v, r, s);
|
||||
}
|
||||
|
||||
// This is provided as a quick example for those that only need to recover a signature
|
||||
// for a signed hash (highly discouraged; but common), which means we can hardcode the
|
||||
// length in the prefix. This means we can drop the itoa and _ecrecover functions above.
|
||||
function recoverHashFromCompact(bytes32 hash, SignatureCompact calldata sig) public pure returns (address) {
|
||||
bytes memory prefixedMessage = abi.encodePacked(
|
||||
// Notice the length of the message is hard-coded to 32
|
||||
// here -----------------------v
|
||||
"\x19Ethereum Signed Message:\n32",
|
||||
hash
|
||||
);
|
||||
|
||||
bytes32 digest = keccak256(prefixedMessage);
|
||||
|
||||
// Decompose the EIP-2098 signature
|
||||
uint8 v = 27 + uint8(uint256(sig.yParityAndS) >> 255);
|
||||
bytes32 s = bytes32((uint256(sig.yParityAndS) << 1) >> 1);
|
||||
|
||||
return ecrecover(digest, v, sig.r, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_subsection: EIP-712 Typed Data @<cookbook-signing-eip712>
|
||||
|
||||
//Coming soon...//
|
BIN
docs.wrm/favicon.ico
Normal file
BIN
docs.wrm/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
505
docs.wrm/getting-started.wrm
Normal file
505
docs.wrm/getting-started.wrm
Normal file
@ -0,0 +1,505 @@
|
||||
_section: Getting Started @<getting-started> @priority<100>
|
||||
|
||||
This is a very short introduction to Ethers, but covers many of the
|
||||
most common operations that developers require and provides a
|
||||
starting point for those newer to Ethereum.
|
||||
|
||||
|
||||
_heading: Getting Ethers
|
||||
|
||||
If using NPM, you must first install Ethers.
|
||||
|
||||
_code: installing via NPM @lang<shell>
|
||||
# Install ethers
|
||||
/home/ricmoo/test-ethers> npm install ethers
|
||||
|
||||
_null:
|
||||
|
||||
Everything in Ethers is exported from its root as well as on the ``ethers``
|
||||
object. There are also ``exports`` in the ``package.json`` to facilitate
|
||||
more fine-grained importing.
|
||||
|
||||
Generally this documentation will presume all exports from ethers
|
||||
have been imported in the code examples, but you may import the
|
||||
necessary objects in any way you wish.
|
||||
|
||||
_code: importing in Node.js @lang<script>
|
||||
// Import everything
|
||||
import { ethers } from "ethers";
|
||||
|
||||
// Import just a few select items
|
||||
import { BrowserProvider, parseUnits } from "ethers";
|
||||
|
||||
// Import from a specific export
|
||||
import { HDNodeWallet } from "ethers/wallet";
|
||||
|
||||
_code: importing ESM in a browser @lang<script>
|
||||
<script type="module">
|
||||
import { ethers } from "https://cdnjs.cloudflare.com/ajax/libs/ethers/6.7.0/ethers.min.js";
|
||||
// Your code here...
|
||||
</script>
|
||||
|
||||
|
||||
_subsection: Some Common Terminology @<starting-glossary>
|
||||
|
||||
To begin, it is useful to have a basic understanding of the types of
|
||||
objects available and what they are responsible for, at a high level.
|
||||
|
||||
_heading: Provider
|
||||
|
||||
A [[Provider]] is a read-only connection to the blockchain, which allows
|
||||
querying the blockchain state, such as account, block or transaction details,
|
||||
querying event logs or evaluating read-only code using call.
|
||||
|
||||
If you are coming from Web3.js, you are used to a **Provider** offering
|
||||
both read and write access. In Ethers, all write operations are further
|
||||
abstracted into another Object, the **Signer**.
|
||||
|
||||
_heading: Signer
|
||||
|
||||
A [[Signer]] wraps all operations that interact with an account. An
|
||||
account generally has a private key located //somewhere//, which can be
|
||||
used to sign a variety of types of payloads.
|
||||
|
||||
The private key may be located in memory (using a [[Wallet]]) or
|
||||
protected via some IPC layer, such as MetaMask which proxies interaction
|
||||
from a website to a browser plug-in, which keeps the private key out of
|
||||
the reach of the website and only permits interaction after requesting
|
||||
permission from the user and receiving authorization.
|
||||
|
||||
_heading: Transaction
|
||||
|
||||
To make any state changes to the blockchain, a transaction is required,
|
||||
which requires a fee to be paid, where the fee covers the associated costs
|
||||
with executing the transaction (such as reading the disk and performing
|
||||
maths) and storing the updated information.
|
||||
|
||||
If a transaction reverts, a fee must still be paid, since the validator
|
||||
still had to expend resources to try running the transaction to determine
|
||||
that it reverted and the details of its failure are still be recorded.
|
||||
|
||||
Transactions include sending ether from one user to another, deploying
|
||||
a **Contract** or executing a state-changing operation against a
|
||||
**Contract**.
|
||||
|
||||
_heading: Contract
|
||||
|
||||
A [[Contract]] is a program that has been deployed to the blockchain,
|
||||
which includes some code and has allocated storage which it can read
|
||||
from and write to.
|
||||
|
||||
It may be read from when it is connected to a [[Provider]] or
|
||||
state-changing operations can be called when connected to a [[Signer]].
|
||||
|
||||
_heading: Receipt
|
||||
|
||||
Once a **Transaction** has been submitted to the blockchain, it is placed
|
||||
in the memory pool (mempool) until a validator decides to include it.
|
||||
|
||||
A transaction's changes are only made once it has been included in the
|
||||
blockchain, at which time a receipt is available, which includes details
|
||||
about the transaction, such as which block it was included in, the actual
|
||||
fee paid, gas used, all the events that it emitted and whether it was
|
||||
successful or reverted.
|
||||
|
||||
|
||||
_subsection: Connecting to Ethereum @<starting-connecting>
|
||||
|
||||
This very first thing needed to begin interacting with the blockchain is
|
||||
connecting to it using a [[Provider]].
|
||||
|
||||
_heading: MetaMask (and other injected providers)
|
||||
|
||||
The quickest and easiest way to experiment and begin developing
|
||||
on Ethereum is to use [[link-metamask]], which is a browser
|
||||
extension that injects objects into the ``window``, providing:
|
||||
|
||||
- read-only access to the Ethereum network (a [[Provider]])
|
||||
- authenticated write access backed by a private key (a [[Signer]])
|
||||
|
||||
When requesting access to the authenticated methods, such as
|
||||
sending a transaction or even requesting the private key address,
|
||||
MetaMask will show a pop-up to the user asking for permission.
|
||||
|
||||
_code: @lang<script>
|
||||
let signer = null;
|
||||
|
||||
let provider;
|
||||
if (window.ethereum == null) {
|
||||
|
||||
// If MetaMask is not installed, we use the default provider,
|
||||
// which is backed by a variety of third-party services (such
|
||||
// as INFURA). They do not have private keys installed,
|
||||
// so they only have read-only access
|
||||
console.log("MetaMask not installed; using read-only defaults")
|
||||
provider = ethers.getDefaultProvider()
|
||||
|
||||
} else {
|
||||
|
||||
// Connect to the MetaMask EIP-1193 object. This is a standard
|
||||
// protocol that allows Ethers access to make all read-only
|
||||
// requests through MetaMask.
|
||||
provider = new ethers.BrowserProvider(window.ethereum)
|
||||
|
||||
// It also provides an opportunity to request access to write
|
||||
// operations, which will be performed by the private key
|
||||
// that MetaMask manages for the user.
|
||||
signer = await provider.getSigner();
|
||||
}
|
||||
|
||||
|
||||
_heading: Custom RPC Backend
|
||||
|
||||
If you are running your own Ethereum node (e.g. [[link-geth]])
|
||||
or using a custom third-party service (e.g. [[link-infura]]),
|
||||
you can use the [[JsonRpcProvider]] directly, which communicates
|
||||
using the [[link-jsonrpc]] protocol.
|
||||
|
||||
When using your own Ethereum node or a developer-base blockchain,
|
||||
such as Hardhat or Ganache, you can get access to the accounts with
|
||||
[[JsonRpcProvider-getSigner]].
|
||||
|
||||
_code: connecting to a JSON-RPC URL @lang<script>
|
||||
|
||||
// If no %%url%% is provided, it connects to the default
|
||||
// http://localhost:8545, which most nodes use.
|
||||
provider = new ethers.JsonRpcProvider(url)
|
||||
|
||||
// Get write access as an account by getting the signer
|
||||
signer = await provider.getSigner()
|
||||
|
||||
|
||||
_subsection: User Interaction @<starting-display>
|
||||
|
||||
All units in Ethereum tend to be integer values, since dealing with
|
||||
decimals and floating points can lead to imprecise and non-obvious
|
||||
results when performing mathematic operations.
|
||||
|
||||
As a result, the internal units used (e.g. wei) which are suited for
|
||||
machine-readable purposes and maths are often very large and not
|
||||
easily human-readable.
|
||||
|
||||
For example, imagine dealing with dollars and cents; you would show
|
||||
values like ``"$2.56"``. In the blockchain world, we would keep all
|
||||
values as cents, so that would be ``256`` cents, internally.
|
||||
|
||||
So, when accepting data that a user types, it must be converted from
|
||||
its decimal string representation (e.g. ``"2.56"``) to its lowest-unit
|
||||
integer representation (e.g. ``256``). And when displaying a value to
|
||||
a user the opposite operation is necessary.
|
||||
|
||||
In Ethereum, //one ether// is equal to ``10 *\* 18`` wei and //one gwei//
|
||||
is equal to ``10 *\* 9`` wei, so the values get very large very quickly,
|
||||
so some convenience functions are provided to help convert between
|
||||
representations.
|
||||
|
||||
_code: @lang<javascript>
|
||||
// Convert user-provided strings in ether to wei for a value
|
||||
eth = parseEther("1.0")
|
||||
//_result:
|
||||
|
||||
// Convert user-provided strings in gwei to wei for max base fee
|
||||
feePerGas = parseUnits("4.5", "gwei")
|
||||
//_result:
|
||||
|
||||
// Convert a value in wei to a string in ether to display in a UI
|
||||
formatEther(eth)
|
||||
//_result:
|
||||
|
||||
// Convert a value in wei to a string in gwei to display in a UI
|
||||
formatUnits(feePerGas, "gwei")
|
||||
//_result:
|
||||
|
||||
|
||||
_subsection: Interacting with the Blockchain @<starting-blockchain>
|
||||
|
||||
_heading: Querying State
|
||||
|
||||
Once you have a [[Provider]], you have a read-only connection to
|
||||
the data on the blockchain. This can be used to query the current
|
||||
account state, fetch historic logs, look up contract code and so on.
|
||||
|
||||
_code: @lang<javascript>
|
||||
//_hide: provider = new InfuraProvider();
|
||||
|
||||
// Look up the current block number (i.e. height)
|
||||
await provider.getBlockNumber()
|
||||
//_result:
|
||||
|
||||
// Get the current balance of an account (by address or ENS name)
|
||||
balance = await provider.getBalance("ethers.eth")
|
||||
//_result:
|
||||
|
||||
// Since the balance is in wei, you may wish to display it
|
||||
// in ether instead.
|
||||
formatEther(balance)
|
||||
//_result:
|
||||
|
||||
// Get the next nonce required to send a transaction
|
||||
await provider.getTransactionCount("ethers.eth")
|
||||
//_result:
|
||||
|
||||
_heading: Sending Transactions
|
||||
|
||||
To write to the blockchain you require access to a private key
|
||||
which controls some account. In most cases, those private keys
|
||||
are not accessible directly to your code, and instead you make
|
||||
requests via a [[Signer]], which dispatches the request to a
|
||||
service (such as [[link-metamask]]) which provides strictly
|
||||
gated access and requires feedback to the user to approve or
|
||||
reject operations.
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
//_hide: provider = new JsonRpcProvider("http:/\/localhost:8545")
|
||||
//_hide: provider.resolveName = () => "0x643aA0A61eADCC9Cc202D1915D942d35D005400C";
|
||||
//_hide: signer = new Wallet(id("test"), provider);
|
||||
|
||||
// When sending a transaction, the value is in wei, so parseEther
|
||||
// converts ether to wei.
|
||||
tx = await signer.sendTransaction({
|
||||
to: "ethers.eth",
|
||||
value: parseEther("1.0")
|
||||
});
|
||||
//_result:
|
||||
|
||||
// Often you may wish to wait until the transaction is mined
|
||||
receipt = await tx.wait();
|
||||
//_result:
|
||||
|
||||
|
||||
_subsection: Contracts @<starting-contracts>
|
||||
|
||||
A **Contract** is a meta-class, which means that its definition
|
||||
its derived at run-time, based on the ABI it is passed, which then
|
||||
determined what methods and properties are available on it.
|
||||
|
||||
_heading: Application Binary Interface (ABI)
|
||||
|
||||
Since all operations that occur on the blockchain must be encoded
|
||||
as binary data, we need a concise way to define how to convert
|
||||
between common objects (like strings and numbers) and its binary
|
||||
representation, as well as encode the ways to call and interpret
|
||||
the Contract.
|
||||
|
||||
For any method, event or error you wish to use, you must include a
|
||||
[[Fragment]] to inform Ethers how it should encode the request and
|
||||
decode the result.
|
||||
|
||||
Any methods or events that are not needed can be safely excluded.
|
||||
|
||||
There are several common formats available to describe an ABI. The
|
||||
Solidity compiler usually dumps a JSON representation but when typing
|
||||
an ABI by hand it is often easier (and more readable) to use the
|
||||
human-readable ABI, which is just the Solidity signature.
|
||||
|
||||
_code: simplified ERC-20 ABI @lang<script>
|
||||
abi = [
|
||||
"function decimals() view returns (string)",
|
||||
"function symbol() view returns (string)",
|
||||
"function balanceOf(address addr) view returns (uint)"
|
||||
]
|
||||
|
||||
// Create a contract
|
||||
contract = new Contract("dai.tokens.ethers.eth", abi, provider)
|
||||
|
||||
_heading: Read-only methods (i.e. ``view`` and ``pure``)
|
||||
|
||||
A read-only method is one which cannot change the state of the
|
||||
blockchain, but often provide a simple interface to get important
|
||||
data about a Contract.
|
||||
|
||||
_code: reading the DAI ERC-20 contract @lang<javascript>
|
||||
// The contract ABI (fragments we care about)
|
||||
abi = [
|
||||
"function decimals() view returns (uint8)",
|
||||
"function symbol() view returns (string)",
|
||||
"function balanceOf(address a) view returns (uint)"
|
||||
]
|
||||
|
||||
// Create a contract; connected to a Provider, so it may
|
||||
// only access read-only methods (like view and pure)
|
||||
contract = new Contract("dai.tokens.ethers.eth", abi, provider)
|
||||
|
||||
// The symbol name for the token
|
||||
sym = await contract.symbol()
|
||||
//_result:
|
||||
|
||||
// The number of decimals the token uses
|
||||
decimals = await contract.decimals()
|
||||
//_result:
|
||||
|
||||
// Read the token balance for an account
|
||||
balance = await contract.balanceOf("ethers.eth")
|
||||
//_result:
|
||||
|
||||
// Format the balance for humans, such as in a UI
|
||||
formatUnits(balance, decimals)
|
||||
//_result:
|
||||
|
||||
_heading: State-changing Methods
|
||||
|
||||
_code: change state on an ERC-20 contract @lang<script>
|
||||
|
||||
abi = [
|
||||
"function transfer(address to, uint amount)"
|
||||
]
|
||||
|
||||
// Connected to a Signer; can make state changing transactions,
|
||||
// which will cost the account ether
|
||||
contract = new Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
|
||||
// Send 1 DAI
|
||||
amount = parseUnits("1.0", 18);
|
||||
|
||||
// Send the transaction
|
||||
tx = await contract.transfer("ethers.eth", amount)
|
||||
//_result: @TODO
|
||||
|
||||
// Currently the transaction has been sent to the mempool,
|
||||
// but has not yet been included. So, we...
|
||||
|
||||
// ...wait for the transaction to be included.
|
||||
await tx.wait()
|
||||
//_result: @TODO
|
||||
|
||||
_code: forcing a call (simulation) of a state-changing method @lang<javascript>
|
||||
|
||||
abi = [
|
||||
"function transfer(address to, uint amount) returns (bool)"
|
||||
]
|
||||
|
||||
// Connected to a Provider since we only require read access
|
||||
contract = new Contract("dai.tokens.ethers.eth", abi, provider)
|
||||
|
||||
amount = parseUnits("1.0", 18)
|
||||
|
||||
// There are many limitations to using a static call, but can
|
||||
// often be useful to preflight a transaction.
|
||||
await contract.transfer.staticCall("ethers.eth", amount)
|
||||
//_result:
|
||||
|
||||
// We can also simulate the transaction as another account
|
||||
other = new VoidSigner("0x643aA0A61eADCC9Cc202D1915D942d35D005400C")
|
||||
contractAsOther = contract.connect(other.connect(provider))
|
||||
await contractAsOther.transfer.staticCall("ethers.eth", amount)
|
||||
//_result:
|
||||
|
||||
_heading: Listening to Events
|
||||
|
||||
When adding event listeners for a named event, the event parameters
|
||||
are destructed for the listener.
|
||||
|
||||
There is always one additional parameter passed to a listener, which
|
||||
is an [[EventPayload]], which includes more information about the event
|
||||
including the filter and a method to remove that listener.
|
||||
|
||||
_code: listen for ERC-20 events @lang<script>
|
||||
abi = [
|
||||
"event Transfer(address indexed from, address indexed to, uint amount)"
|
||||
]
|
||||
|
||||
// Create a contract; connected to a Provider, so it may
|
||||
// only access read-only methods (like view and pure)
|
||||
contract = new Contract("dai.tokens.ethers.eth", abi, provider)
|
||||
|
||||
// Begin listening for any Transfer event
|
||||
contract.on("Transfer", (from, to, _amount, event) => {
|
||||
const amount = formatEther(_amount, 18)
|
||||
console.log(`${ from } => ${ to }: ${ amount }`);
|
||||
|
||||
// The `event.log` has the entire EventLog
|
||||
|
||||
// Optionally, stop listening
|
||||
event.removeListener();
|
||||
});
|
||||
|
||||
// Same as above
|
||||
contract.on(contract.filters.Transfer, (from, to, amount, event) => {
|
||||
// See above
|
||||
})
|
||||
|
||||
// Listen for any Transfer to "ethers.eth"
|
||||
filter = contract.filters.Transfer("ethers.eth")
|
||||
contract.on(filter, (from, to, amount, event) => {
|
||||
// `to` will always be equal to the address of "ethers.eth"
|
||||
});
|
||||
|
||||
// Listen for any event, whether it is present in the ABI
|
||||
// or not. Since unknown events can be picked up, the
|
||||
// parameters are not destructed.
|
||||
contract.on("*", (event) => {
|
||||
// The `event.log` has the entire EventLog
|
||||
});
|
||||
|
||||
|
||||
|
||||
_heading: Query Historic Events
|
||||
|
||||
When querying within a large range of blocks, some backends may
|
||||
be prohibitively slow, may return an error or may truncate the
|
||||
results without any indication. This is at the discretion of each
|
||||
backend.
|
||||
|
||||
_code: query historic ERC-20 events @lang<javascript>
|
||||
abi = [
|
||||
"event Transfer(address indexed from, address indexed to, uint amount)"
|
||||
]
|
||||
|
||||
// Create a contract; connected to a Provider, so it may
|
||||
// only access read-only methods (like view and pure)
|
||||
contract = new Contract("dai.tokens.ethers.eth", abi, provider)
|
||||
|
||||
// Query the last 100 blocks for any transfer
|
||||
filter = contract.filters.Transfer
|
||||
events = await contract.queryFilter(filter, -100)
|
||||
|
||||
// The events are a normal Array
|
||||
events.length
|
||||
//_result:
|
||||
|
||||
// The first matching event
|
||||
events[0]
|
||||
//_result:
|
||||
|
||||
// Query all time for any transfer to ethers.eth
|
||||
filter = contract.filters.Transfer("ethers.eth")
|
||||
events = await contract.queryFilter(filter)
|
||||
|
||||
// The first matching event
|
||||
events[0]
|
||||
//_result:
|
||||
|
||||
|
||||
_subsection: Signing Messages @<starting-signing>
|
||||
|
||||
A private key can do a lot more than just sign a transaction to authorize
|
||||
it. It can also be used to sign other forms of data, which are then able
|
||||
to be validated for other purposes.
|
||||
|
||||
For example, signing **a message** can be used to prove ownership of an
|
||||
account which a website could use to authenticate a user and log them in.
|
||||
|
||||
_code: @lang<javascript>
|
||||
|
||||
// Our signer; Signing messages does not require a Provider
|
||||
signer = new Wallet(id("test"))
|
||||
//_result:
|
||||
|
||||
message = "sign into ethers.org?"
|
||||
|
||||
// Signing the message
|
||||
sig = await signer.signMessage(message);
|
||||
//_result:
|
||||
|
||||
// Validating a message; notice the address matches the signer
|
||||
verifyMessage(message, sig)
|
||||
//_result:
|
||||
|
||||
_null:
|
||||
|
||||
Many other more advanced protocols built on top of signed messages are
|
||||
used to allow a private key to authorize other users to transfer their
|
||||
tokens, allowing the transaction fees of the transfer to be paid by
|
||||
someone else.
|
||||
|
28
docs.wrm/index.wrm
Normal file
28
docs.wrm/index.wrm
Normal file
@ -0,0 +1,28 @@
|
||||
_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.
|
||||
|
||||
It is often used to create decentralized applications (dapps),
|
||||
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
|
||||
every day.
|
||||
|
||||
Developers new to Ethers should be sure to read through the
|
||||
[[getting-started]] section.
|
||||
|
||||
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)
|
26
docs.wrm/license.wrm
Normal file
26
docs.wrm/license.wrm
Normal file
@ -0,0 +1,26 @@
|
||||
_section: License and Copyright @priority<-100>
|
||||
|
||||
The ethers library (including all dependencies) are available under the
|
||||
[[link-mit]], which permits a wide variety of uses.
|
||||
|
||||
_subsection: MIT License
|
||||
|
||||
Copyright © [Richard Moore](link-mail).
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
8
docs.wrm/links/javascript.txt
Normal file
8
docs.wrm/links/javascript.txt
Normal file
@ -0,0 +1,8 @@
|
||||
link-js-array [link-js-array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
link-js-bigint [link-js-bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
|
||||
link-js-date [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
|
||||
link-js-fetch [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
link-js-normalize [String.normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
||||
link-js-maxsafe [link-js-maxsafe](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER#Description)
|
||||
link-js-proxy [link-js-proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
|
||||
link-js-typedarray [link-js-typedarray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)
|
5
docs.wrm/links/npm.txt
Normal file
5
docs.wrm/links/npm.txt
Normal file
@ -0,0 +1,5 @@
|
||||
link-npm-ethers [link-ethers-npm](https://www.npmjs.com/search?q=%40ethersproject%2F)
|
||||
link-npm-events [EventEmitter](https://nodejs.org/dist/latest-v13.x/docs/api/events.html#events_class_eventemitter)
|
||||
link-npm-query-bignumber [link-npm-query-bignumber](https://www.npmjs.com/search?q=bignumber)
|
||||
link-npm-react-native-get-random-values [React Native get-random-values](https://www.npmjs.com/package/react-native-get-random-values)
|
||||
link-npm-react-native-quick-crypto [Quick Crypto](https://www.npmjs.com/package/react-native-quick-crypto)
|
50
docs.wrm/links/projects.txt
Normal file
50
docs.wrm/links/projects.txt
Normal file
@ -0,0 +1,50 @@
|
||||
link-alchemy [Alchemy](https://alchemy.com/?a=ethers)
|
||||
link-ankr [Ankr](https://www.ankr.com)
|
||||
link-chainstack [Chainstack](https://chainstack.com)
|
||||
link-cloudflare [Cloudflare](https://developers.cloudflare.com/distributed-web/ethereum-gateway/)
|
||||
link-ens [ENS](https://ens.domains/)
|
||||
link-ethereum [Ethereum](https://ethereumorg)
|
||||
link-etherscan [Etherscan](https://etherscan.io)
|
||||
link-expo [Expo](https://expo.io)
|
||||
link-etherscan-api [Etherscan API](https://etherscan.io/apis)
|
||||
link-flatworm [Flatworm](https://github.com/ricmoo/flatworm)
|
||||
link-geth [Geth](https://geth.ethereum.org)
|
||||
link-infura [INFURA](https://infura.io)
|
||||
link-javascriptcore [JavaScriptCore](https://developer.apple.com/documentation/javascriptcore?language=objc)
|
||||
link-ledger [Ledger](https://www.ledger.com)
|
||||
link-metamask [MetaMask](https://metamask.io/)
|
||||
link-node [Node.js](https://nodejs.org/)
|
||||
link-otto [Otto](https://github.com/robertkrimen/otto)
|
||||
link-parity [Parity](https://www.parity.io)
|
||||
link-pocket [Pocket Network](https://pokt.network)
|
||||
link-quicknode [QuickNode](https://www.quicknode.com/ethers)
|
||||
link-react-native [React Native](https://reactnative.dev)
|
||||
link-semver [semver](https://semver.org)
|
||||
link-solidity [Solidity](https://solidity.readthedocs.io/)
|
||||
link-tally [Tally](https://tallyho.org)
|
||||
|
||||
# Project-specific
|
||||
link-alchemy-signup [Alchemy Signup](https://dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d)
|
||||
link-ankr-public [link-ankr-public](https://www.ankr.com/protocol/public/)
|
||||
link-ankr-signup [link-ankr-premium](https://www.ankr.com/protocol/plan/)
|
||||
link-etherscan-signup [Etherscan Signup](https://etherscan.io/apis)
|
||||
link-etherscan-ratelimit [link-etherscan-ratelimit](https://info.etherscan.com/api-return-errors/)
|
||||
link-infura-signup [INFURA Signup](https://infura.io/register)
|
||||
link-geth-debug [link-geth-debug](https://github.com/ethereum/go-ethereum/wiki/Management-APIs#debug)
|
||||
link-geth-rpc [link-geth-rpc](https://github.com/ethereum/go-ethereum/wiki/Management-APIs)
|
||||
link-infura-secret [link-infura-secret](https://infura.io/docs/gettingStarted/authentication)
|
||||
link-parity-trace [link-parity-trace](https://openethereum.github.io/wiki/JSONRPC-trace-module)
|
||||
link-parity-rpc [link-parity-rpc](https://openethereum.github.io/wiki/JSONRPC)
|
||||
link-pocket-signup [link-pocket-signup](https://pokt.network/pocket-gateway-ethereum-mainnet/)
|
||||
link-web3js [link-web3](https://github.com/ethereum/web3.js)
|
||||
link-web3-http [link-web3-http](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-http)
|
||||
link-web3-ipc [link-web3-ipc](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ipc)
|
||||
link-web3-send [link-web3-send](https://github.com/ethereum/web3.js/blob/1.x/packages/web3-providers-http/types/index.d.ts#L57)
|
||||
link-web3-ws [link-web3-ws](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ws)
|
||||
|
||||
link-solidity-errors [link-solidity-errors](https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#errors)
|
||||
link-solidity-events [link-solidity-events](https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#events)
|
||||
|
||||
link-other-ethereum-dev-docs [link-other-ethereum-dev-docs](https://ethereum.org/en/developers/docs/)
|
||||
|
||||
link-sol-recovermessage [RecoverMessage.sol](https://sepolia.etherscan.io/address/0xf554da5e35b2e40c09ddb481545a395da1736513#code)
|
21
docs.wrm/links/ricmoo.txt
Normal file
21
docs.wrm/links/ricmoo.txt
Normal file
@ -0,0 +1,21 @@
|
||||
link-mail [me@ricmoo](mailto:me@ricmoo.com)
|
||||
link-website [ethers.org](https://ethers.org)
|
||||
|
||||
# Ethers links
|
||||
link-ci [Ethers CI](https://github.com/ethers-io/ethers.js/actions/runs/158006903)
|
||||
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.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)
|
||||
link-mastodon [@ethers on Mastodon](http://mochi.social/@ethers)
|
||||
link-twitter [@ethersproject on Twitter](https://twitter.com/ethersproject)
|
||||
|
||||
# Blog
|
||||
link-ricmoo-humanreadableabi [Human-Readable Contract ABIs](https://blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917)
|
||||
link-ricmoo-wisps [Wisps: The Magical World of Create2](https://blog.ricmoo.com/wisps-the-magical-world-of-create2-5c2177027604);
|
||||
|
54
docs.wrm/links/specs.txt
Normal file
54
docs.wrm/links/specs.txt
Normal file
@ -0,0 +1,54 @@
|
||||
# BIPs
|
||||
link-bip-39 [BIP-39](https://en.bitcoin.it/wiki/BIP_0039)
|
||||
link-bip-32 [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
|
||||
link-bip-44 [BIP-44](https://en.bitcoin.it/wiki/BIP_0044)
|
||||
|
||||
# BIP 39 lists
|
||||
link-bip39-wordlists [BIP-39 Wordlists](https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md)
|
||||
link-bip39-cz [Czech wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/czech.txt)
|
||||
link-bip39-es [Spanish wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/spanish.txt)
|
||||
link-bip39-en [English wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt)
|
||||
link-bip39-fr [French wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/french.txt)
|
||||
link-bip39-it [Italian wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/italian.txt)
|
||||
link-bip39-ja [Japanese wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/japanese.txt)
|
||||
link-bip39-ko [Korean wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/korean.txt)
|
||||
link-bip39-pt [Portuguese wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/portuguese.txt)
|
||||
link-bip39-zh_tw [Tradional Chinese wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/chinese_traditional.txt)
|
||||
link-bip39-zh_cn [Simplified Chinese wordlist](https://github.com/bitcoin/bips/blob/master/bip-0039/chinese_simplified.txt)
|
||||
|
||||
# EIPs; see https://eips.ethereum.org/all
|
||||
link-eip-155 [EIP-155](https://eips.ethereum.org/EIPS/eip-155)
|
||||
link-eip-191 [EIP-191](https://eips.ethereum.org/EIPS/eip-191)
|
||||
link-eip-609 [EIP-609](https://eips.ethereum.org/EIPS/eip-609)
|
||||
link-eip-634 [EIP-634](https://eips.ethereum.org/EIPS/eip-634)
|
||||
link-eip-712 [EIP-712](https://eips.ethereum.org/EIPS/eip-712)
|
||||
link-eip-1014 [EIP-1014](https://eips.ethereum.org/EIPS/eip-1014)
|
||||
link-eip-1193 [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193)
|
||||
link-eip-1559 [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
|
||||
link-eip-1577 [EIP-1577](https://eips.ethereum.org/EIPS/eip-1577)
|
||||
link-eip-2070 [EIP-2930](https://eips.ethereum.org/EIPS/eip-2070)
|
||||
link-eip-2098 [EIP-2098](https://eips.ethereum.org/EIPS/eip-2098)
|
||||
link-eip-2304 [EIP-2304](https://eips.ethereum.org/EIPS/eip-2304)
|
||||
link-eip-2718 [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)
|
||||
link-eip-2930 [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)
|
||||
link-eip-4788 [EIP-4844](https://eips.ethereum.org/EIPS/eip-4788)
|
||||
link-eip-4844 [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
|
||||
|
||||
# Open Standards
|
||||
link-base58 [Base58](https://en.bitcoinwiki.org/wiki/Base58)
|
||||
link-cors [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
|
||||
link-crowdsale [Crowdsale Wallet](https://github.com/ethereum/pyethsaletool)
|
||||
link-icap [ICAP Address](https://github.com/ethereum/wiki/wiki/Inter-exchange-Client-Address-Protocol-%28ICAP%29)
|
||||
link-jsonrpc [link-jsonrpc](https://github.com/ethereum/wiki/wiki/JSON-RPC)
|
||||
link-mit [MIT License](https://en.m.wikipedia.org/wiki/MIT_License)
|
||||
link-namehash [namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names)
|
||||
link-rlp [Recursive-Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/)
|
||||
link-pbkdf2 [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2)
|
||||
link-solc-abi [ABI Specification](https://docs.soliditylang.org/en/v0.8.19/abi-spec.html#formal-specification-of-the-encoding)
|
||||
link-solc-jsonabi [ABI JSON Specification](https://docs.soliditylang.org/en/v0.8.19/abi-spec.html#json)
|
||||
link-solc-errors [Solidity Custom Errors](https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#errors)
|
||||
link-solc-events [Solidity Events](https://docs.soliditylang.org/en/v0.8.4/abi-spec.html#events)
|
||||
link-solc-output [solc standard output](https://solidity.readthedocs.io/en/v0.6.0/using-the-compiler.html#output-description)
|
||||
link-solc-packed [Non-Standard Packed Mode](https://docs.soliditylang.org/en/v0.8.14/abi-spec.html#non-standard-packed-mode)
|
||||
link-uuid [UUID](https://www.ietf.org/rfc/rfc4122.txt)
|
||||
|
29
docs.wrm/links/wiki.txt
Normal file
29
docs.wrm/links/wiki.txt
Normal file
@ -0,0 +1,29 @@
|
||||
link-wiki-base64 [Base64](https://en.wikipedia.org/wiki/Base64)
|
||||
link-wiki-basicauth [Basic Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication)
|
||||
link-wiki-backoff [Exponential Backoff](https://en.wikipedia.org/wiki/Exponential_backoff)
|
||||
link-wiki-bloomfilter [Bloom Filter](https://en.wikipedia.org/wiki/Bloom_filter)
|
||||
link-wiki-bruteforce [link-wiki-bruteforce](https://en.wikipedia.org/wiki/Brute-force_attack)
|
||||
link-wiki-cryptographichash [link-wiki-cryptographichash](https://en.wikipedia.org/wiki/Cryptographic_hash_function)
|
||||
link-wiki-csrf [link-wiki-csrf](https://en.wikipedia.org/wiki/Cross-site_request_forgery)
|
||||
link-wiki-ecdh [ECDH](https://en.wikipedia.org/wiki/Elliptic-curve_Diffie-Hellman)
|
||||
link-wiki-ecrecover [ECDSA Public Key Recovery](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm#Public_key_recovery)
|
||||
link-wiki-homoglyph [link-wiki-homoglyph](https://en.wikipedia.org/wiki/IDN_homograph_attack)
|
||||
link-wiki-hmac [link-wiki-hmac](https://en.wikipedia.org/wiki/HMAC)
|
||||
link-wiki-iban [link-wiki-iban](https://en.wikipedia.org/wiki/International_Bank_Account_Number)
|
||||
link-wiki-ieee754 [link-wiki-ieee754](https://en.wikipedia.org/wiki/Double-precision_floating-point_format)
|
||||
link-wiki-iso639 [ISO 639-1 Codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
|
||||
link-wiki-observer-pattern [Observer Pattern](https://en.wikipedia.org/wiki/Observer_pattern)
|
||||
link-wiki-phishing [link-wiki-phishing](https://en.wikipedia.org/wiki/Phishing)
|
||||
link-wiki-ripemd [link-wiki-ripemd](https://en.m.wikipedia.org/wiki/RIPEMD)
|
||||
link-wiki-sha2 [link-wiki-sha2](https://en.wikipedia.org/wiki/SHA-2)
|
||||
link-wiki-twoscomplement [link-wiki-twoscomplement](https://en.wikipedia.org/wiki/Two%27s_complement)
|
||||
link-wiki-unicode-equivalence [link-wiki-unicode-equivalence](https://en.wikipedia.org/wiki/Unicode_equivalence)
|
||||
link-wiki-utf8-overlong [link-wiki-utf8-overlong](https://en.wikipedia.org/wiki/UTF-8#Overlong_encodings)
|
||||
link-wiki-utf8-replacement [link-wiki-utf8-replacement](https://en.wikipedia.org/wiki/Specials_%28Unicode_block%29#Replacement_character)
|
||||
link-wiki-scrypt [scrypt PBKDF](https://en.wikipedia.org/wiki/Scrypt)
|
||||
link-wiki-side-channel-attack [link-wiki-side-channel-attack](https://en.wikipedia.org/wiki/Side-channel_attack)
|
||||
link-wiki-sha3 [link-wiki-sha3](https://en.wikipedia.org/wiki/SHA-3)
|
||||
link-wiki-shuffle [Fisher-Yates Shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle)
|
||||
link-wiki-overflow [overflow](https://en.wikipedia.org/wiki/Integer_overflow)
|
||||
link-wiki-underflow [arithmetic underflow](https://en.wikipedia.org/wiki/Arithmetic_underflow)
|
||||
link-wiki-xss [link-wiki-xss](https://en.wikipedia.org/wiki/Cross-site_scripting)
|
1782
docs.wrm/logo.ai
Normal file
1782
docs.wrm/logo.ai
Normal file
File diff suppressed because it is too large
Load Diff
12
docs.wrm/logo.svg
Normal file
12
docs.wrm/logo.svg
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 100 58" style="enable-background:new 0 0 100 58;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
|
||||
</style>
|
||||
<path class="st0" d="M94.45,47.18c-42.62,5.57-73.04,12.26-73.49-15.2c0,0,0.93-10.64,13.98-11.31c0,0,0.44-9.45,10.41-10.52
|
||||
c5.36-0.58,11.45,4.94,12.11,10.75c0,0,13.19-2.44,13.76,10.42c0.2,4.48-0.81,12.1-13.53,11.77c0,0-7.36-1-8.36-12.38
|
||||
c-2.07,22.03,29.78,20.75,30.24,0.74c0.2-8.65-5.34-17.55-17.82-15.88C54.91-1.64,36.7-0.65,29.92,15.31
|
||||
c-9.69,0-17.1,7.46-16.99,17.2C13.3,63.86,56.93,54.41,94.45,47.18z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 853 B |
418
docs.wrm/migrating.wrm
Normal file
418
docs.wrm/migrating.wrm
Normal file
@ -0,0 +1,418 @@
|
||||
_section: Migrating from v5 @<migrating> @priority<-10>
|
||||
|
||||
This guide aims to capture some of the high-level differences
|
||||
between v5 and v6 to help those migrating an existing app and
|
||||
those already familiar with v5 that just need a quick primer.
|
||||
|
||||
The biggest difference in v6 is the use of modern ES6 features,
|
||||
so a lot of changes are largely internal.
|
||||
|
||||
- [BigNumbers](migrate-bigint)
|
||||
- [Contracts](migrate-contracts)
|
||||
- [Importing](migrate-importing)
|
||||
- [Providers](migrate-providers)
|
||||
- [Signatures](migrate-signatures)
|
||||
- [Transactions](migrate-transactions)
|
||||
- [Utilities](migrate-utils)
|
||||
- [Removed Items](migrate-missing)
|
||||
|
||||
|
||||
_subsection: Big Numbers @<migrate-bigint>
|
||||
|
||||
One of the biggest changes in v6 is that the //BigNumber// class has
|
||||
been replaced with the built-in ES2020 BigInt offered by modern
|
||||
JavaScript environments.
|
||||
|
||||
There is plenty of [online documentation](link-js-bigint) to get
|
||||
you started with JavaScript ES2020 BigInt. Keep in mind, just like
|
||||
//BigNumber//, a ES2020 BigInt can **only** operate on integers.
|
||||
|
||||
The [[FixedNumber]] class still exists for performing fixed-point
|
||||
maths.
|
||||
|
||||
|
||||
_code: creating large numbers @lang<script>
|
||||
|
||||
// Using BigNumber in v5
|
||||
value = BigNumber.from("1000")
|
||||
|
||||
// Using BigInt in v6 (using literal notation).
|
||||
// Notice the suffix n
|
||||
value = 1000n
|
||||
|
||||
// Using the BigInt function for strings
|
||||
value = BigInt("1000")
|
||||
|
||||
|
||||
_code: simple maths on large numbers @lang<script>
|
||||
|
||||
// Adding two values in v5
|
||||
sum = value1.add(value2)
|
||||
|
||||
// Using BigInt in v6; keep in mind, both values
|
||||
// must be a BigInt
|
||||
sum = value1 + value2
|
||||
|
||||
|
||||
_code: simple comparison on large numbers @lang<script>
|
||||
|
||||
// Checking equality in v5
|
||||
isEqual = value1.eq(value2)
|
||||
|
||||
// Using BigInt in v6
|
||||
isEqual = (value1 == value2)
|
||||
|
||||
|
||||
_subsection: Contracts @<migrate-contracts>
|
||||
|
||||
The [[Contract]] is an ES6 Proxy, which means it can resolve
|
||||
method names at run-time.
|
||||
|
||||
_heading: Ambiguous Methods
|
||||
|
||||
In v5, in the case of an ambiguous method, it was necessary to
|
||||
look up a method by its canonical normalized signature. In v6
|
||||
the signature does not need to be normalized and the Typed API
|
||||
provides a cleaner way to access the desired method.
|
||||
|
||||
In v5, duplicate definitions also injected warnings into the
|
||||
console, since there was no way to detect them at run-time.
|
||||
|
||||
_code: contracts in v5 @lang<script>
|
||||
abi = [
|
||||
"function foo(address bar)",
|
||||
"function foo(uint160 bar)",
|
||||
]
|
||||
contract = new Contract(address, abi, provider)
|
||||
|
||||
// In v5 it was necessary to specify the fully-qualified normalized
|
||||
// signature to access the desired method. For example:
|
||||
contract["foo(address)"](addr)
|
||||
|
||||
// These would fail, since there signature is not normalized:
|
||||
contract["foo(address )"](addr)
|
||||
contract["foo(address addr)"](addr)
|
||||
|
||||
// This would fail, since the method is ambiguous:
|
||||
contract.foo(addr)
|
||||
|
||||
_code: contracts in v6 @lang<script>
|
||||
abi = [
|
||||
"function foo(address bar)",
|
||||
"function foo(uint160 bar)",
|
||||
]
|
||||
contract = new Contract(address, abi, provider)
|
||||
|
||||
// Any of these work fine:
|
||||
contract["foo(address)"](addr)
|
||||
contract["foo(address )"](addr)
|
||||
contract["foo(address addr)"](addr)
|
||||
|
||||
// This still fails, since there is no way to know which
|
||||
// method was intended
|
||||
contract.foo(addr)
|
||||
|
||||
// However, the Typed API makes things a bit easier, since it
|
||||
// allows providing typing information to the Contract:
|
||||
contract.foo(Typed.address(addr))
|
||||
|
||||
_heading: Other Method Operations
|
||||
|
||||
In v5, contracts contained a series of method buckets, which
|
||||
then in turn had all signatures and non-ambiguous names
|
||||
attached to them to perform less-common operations.
|
||||
|
||||
In v6, the methods each have their own less-common operations
|
||||
attached directly to them.
|
||||
|
||||
_code: other operations in v5 @lang<script>
|
||||
|
||||
// The default action chooses send or call base on method
|
||||
// type (pure, view, constant, non-payable or payable)
|
||||
contract.foo(addr)
|
||||
|
||||
// This would perform the default action, but return a Result
|
||||
// object, instead of destructing the value
|
||||
contract.functions.foo(addr)
|
||||
|
||||
// Forces using call
|
||||
contract.callStatic.foo(addr)
|
||||
|
||||
// Estimate the gas
|
||||
contract.estimateGas.foo(addr)
|
||||
|
||||
// Populate a transaction
|
||||
contract.populateTransaction.foo(addr)
|
||||
|
||||
_code: other operations in v6 @lang<script>
|
||||
|
||||
// Still behaves the same
|
||||
contract.foo(addr)
|
||||
|
||||
// Perform a call, returning a Result object directly
|
||||
contract.foo.staticCallResult(addr)
|
||||
|
||||
// Forces using call (even for payable and non-payable)
|
||||
contract.foo.staticCall(addr)
|
||||
|
||||
// Forces sending a transaction (even for pure and view)
|
||||
contract.foo.send(addr)
|
||||
|
||||
// Estimate the gas
|
||||
contract.foo.estimateGas(addr)
|
||||
|
||||
// Populate a transaction
|
||||
contract.foo.populateTransaction(addr)
|
||||
|
||||
|
||||
_subsection: Importing @<migrate-importing>
|
||||
|
||||
In v5, the project was maintained as a large set of sub-packages
|
||||
managed as a monorepo.
|
||||
|
||||
In v6 all imports are available in the root package, and for those
|
||||
who wish to have finer-grained control, the ``pkg.exports`` makes
|
||||
certain folders available directly.
|
||||
|
||||
_code: importing in v5 @lang<script>
|
||||
|
||||
// Many things (but not all) we available on the root package
|
||||
import { ethers } from "ethers"
|
||||
|
||||
// But some packages were grouped behind an additional property
|
||||
import { providers } from "ethers"
|
||||
const { InfuraProvider } = providers
|
||||
|
||||
// For granular control, importing from the sub-package
|
||||
// was necessary
|
||||
import { InfuraProvider } from "@ethersproject/providers"
|
||||
|
||||
_code: importing in v6 @lang<script>
|
||||
|
||||
// Everything is available on the root package
|
||||
import { ethers } from "ethers"
|
||||
import { InfuraProvider } from "ethers"
|
||||
|
||||
// The pkg.exports provides granular access
|
||||
import { InfuraProvider } from "ethers/providers"
|
||||
|
||||
|
||||
_subsection: Providers @<migrate-providers>
|
||||
|
||||
In addition to all the ``ethers.providers.*`` being moved to
|
||||
``ethers.*``, the biggest change developers need to keep in
|
||||
mind is that ``Web3Provider`` (which historically was used
|
||||
to wrap [[link-web3js]] providers) is now called
|
||||
[[BrowserProvider]] which is designed to wrap EIP-1193
|
||||
providers, which is the standard that both modern Web3.js and
|
||||
injected providers offer.
|
||||
|
||||
_code: wrapping EIP-1193 providers @lang<script>
|
||||
// v5
|
||||
provider = new ethers.providers.Web3Provider(window.ethereum)
|
||||
|
||||
// v6:
|
||||
provider = new ethers.BrowserProvider(window.ethereum)
|
||||
|
||||
Also, the method for broadcasting transactions to the network has
|
||||
changed:
|
||||
|
||||
_code: broadcasting transactions @lang<script>
|
||||
// v5
|
||||
provider.sendTransaction(signedTx)
|
||||
|
||||
// v6
|
||||
provider.broadcastTransaction(signedTx)
|
||||
|
||||
|
||||
The ``StaticJsonRpcProvider`` in v5 is now integrated into the v6
|
||||
``JsonRpcProvider`` directly. When connecting to a network which
|
||||
cannot change its network, it is much more efficient to disable
|
||||
the automatic safety check ethers performs.
|
||||
|
||||
_code: Create a Provider on a static network @lang<script>
|
||||
// v5
|
||||
provider = new StaticJsonRpcProvider(url, network);
|
||||
|
||||
// v6: If you know the network ahead of time and wish
|
||||
// to avoid even a single eth_chainId call
|
||||
provider = new JsonRpcProvider(url, network, {
|
||||
staticNetwork: network
|
||||
});
|
||||
|
||||
// v6: If you want the network automatically detected,
|
||||
// this will query eth_chainId only once
|
||||
provider = new JsonRpcProvider(url, undefined, {
|
||||
staticNetwork: true
|
||||
});
|
||||
|
||||
_subsection: Signatures @<migrate-signatures>
|
||||
|
||||
The Signature is now a class which facilitates all the parsing
|
||||
and serializing.
|
||||
|
||||
_code: signature manipulation
|
||||
// v5
|
||||
splitSig = splitSignature(sigBytes)
|
||||
sigBytes = joinSignature(splitSig)
|
||||
|
||||
// v6
|
||||
splitSig = ethers.Signature.from(sigBytes)
|
||||
sigBytes = ethers.Signature.from(splitSig).serialized
|
||||
|
||||
|
||||
_subsection: Transactions @<migrate-transactions>
|
||||
|
||||
The transaction helpers present in v5 were all wrapped into a
|
||||
[[Transaction]] class, which can handle any supported transaction
|
||||
format to be further processed
|
||||
|
||||
_code: parsing transactions @lang<script>
|
||||
|
||||
// v5
|
||||
tx = parseTransaction(txBytes)
|
||||
txBytes = serializeTransaction(tx)
|
||||
txBytes = serializeTransaction(tx, sig)
|
||||
|
||||
// v6
|
||||
tx = Transaction.from(txBytes)
|
||||
|
||||
// v6 (the tx can optionally include the signature)
|
||||
txBytes = Transaction.from(tx).serialized
|
||||
|
||||
|
||||
_subsection: Utilities @<migrate-utils>
|
||||
|
||||
_code: Bytes32 string helpers @lang<script>
|
||||
// In v5:
|
||||
bytes32 = ethers.utils.formatBytes32String(text)
|
||||
text = ethers.utils.parseBytes32String(bytes32)
|
||||
|
||||
// In v6:
|
||||
bytes32 = ethers.encodeBytes32String(text)
|
||||
text = ethers.decodeBytes32String(bytes32)
|
||||
|
||||
_code: constants @lang<script>
|
||||
// v5:
|
||||
ethers.constants.AddressZero
|
||||
ethers.constants.HashZero
|
||||
|
||||
// v6:
|
||||
ethers.ZeroAddress
|
||||
ethers.ZeroHash
|
||||
|
||||
_code: data manipulation @lang<script>
|
||||
// v5
|
||||
slice = ethers.utils.hexDataSlice(value, start, end)
|
||||
padded = ethers.utils.hexZeroPad(value, length)
|
||||
|
||||
// v5; converting numbers to hexstrings
|
||||
hex = hexlify(35)
|
||||
|
||||
// v6
|
||||
slice = ethers.dataSlice(value, start, end)
|
||||
padded = ethers.zeroPadValue(value, length)
|
||||
|
||||
// v6; converting numbers to hexstrings
|
||||
hex = toBeHex(35)
|
||||
|
||||
_code: defaultAbiCoder @lang<script>
|
||||
// In v5, it is a property of AbiCoder
|
||||
coder = AbiCoder.defaultAbiCoder
|
||||
|
||||
// In v6, it is a static function on AbiCoder, which uses
|
||||
// a singleton pattern; the first time it is called, the
|
||||
// AbiCoder is created and on subsequent calls that initial
|
||||
// instance is returned.
|
||||
coder = AbiCoder.defaultAbiCoder()
|
||||
|
||||
_code: fetching content @lang<script>
|
||||
// v5, with a body and no weird things
|
||||
data = await ethers.utils.fetchJson(url, json, processFunc)
|
||||
|
||||
// v5 with Connection overrides
|
||||
req = {
|
||||
url, user: "username", password: "password"
|
||||
// etc. properties have FetchRequest equivalents
|
||||
};
|
||||
data = await ethers.utils.fetchJson(req, json, processFunc)
|
||||
|
||||
// v6
|
||||
req = new ethers.FetchRequest(url)
|
||||
|
||||
// set a body; optional
|
||||
req.body = json
|
||||
|
||||
// set credentials; optional
|
||||
req.setCredentials("username", "password")
|
||||
|
||||
// set a processFunc; optional
|
||||
req.processFunc = processFunc
|
||||
|
||||
// send the request!
|
||||
resp = await req.send()
|
||||
|
||||
// Get the response body; depending on desired format
|
||||
data = resp.body // Uint8Array
|
||||
data = resp.bodyText // Utf8String; throws if invalid
|
||||
data = resp.bodyJson // Object; throws if invalid
|
||||
|
||||
_code: hex conversion @lang<script>
|
||||
// v5
|
||||
hex = ethers.utils.hexValue(value)
|
||||
array = ethers.utils.arrayify(value)
|
||||
|
||||
// v6
|
||||
hex = ethers.toQuantity(value)
|
||||
array = ethers.getBytes(value)
|
||||
|
||||
_code: solidity non-standard packed @lang<script>
|
||||
// v5
|
||||
ethers.utils.solidityPack(types, values)
|
||||
ethers.utils.solidityKeccak256(types, values)
|
||||
ethers.utils.soliditySha256(types, values)
|
||||
|
||||
// v6
|
||||
ethers.solidityPacked(types, values)
|
||||
ethers.solidityPackedKeccak256(types, values)
|
||||
ethers.solidityPackedSha256(types, values)
|
||||
|
||||
_code: property manipulation @lang<script>
|
||||
// v5
|
||||
ethers.utils.defineReadOnly(obj, "name", value)
|
||||
|
||||
// v6
|
||||
ethers.defineProperties(obj, { name: value });
|
||||
|
||||
_code: commify @lang<script>
|
||||
// v5
|
||||
ethers.utils.commify("1234.5")
|
||||
|
||||
// v6; we removed some of these local-specific utilities,
|
||||
// however the functionality can be easily replicated
|
||||
// and adjusted depending on your desired output format,
|
||||
// for which everyone wanted their own tweaks anyways.
|
||||
//
|
||||
// However, to mimic v5 functionality, this can be used:
|
||||
function commify(value) {
|
||||
const match = value.match(/^(-?)([0-9]*)(\.?)([0-9]*)$/);
|
||||
if (!match || (!match[2] && !match[4])) {
|
||||
throw new Error(`bad formatted number: ${ JSON.stringify(value) }`);
|
||||
}
|
||||
|
||||
const neg = match[1];
|
||||
const whole = BigInt(match[2] || 0).toLocaleString("en-us");
|
||||
const frac = match[4] ? match[4].match(/^(.*?)0*$/)[1]: "0";
|
||||
|
||||
return `${ neg }${ whole }.${ frac }`;
|
||||
}
|
||||
|
||||
commify("1234.5");
|
||||
|
||||
_subsection: Removed Classes and functions @<migrate-missing>
|
||||
|
||||
The **Logger** class has been replaced by
|
||||
[several Error utility functions](about-errors).
|
||||
|
||||
The ``checkProperties`` and ``shallowCopy`` have been
|
||||
removed in favor of using ``.map`` and ``Object.assign``.
|
BIN
docs.wrm/social.jpg
Normal file
BIN
docs.wrm/social.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
20
errors.d.ts
vendored
20
errors.d.ts
vendored
@ -1,20 +0,0 @@
|
||||
export declare const UNKNOWN_ERROR = "UNKNOWN_ERROR";
|
||||
export declare const NOT_IMPLEMENTED = "NOT_IMPLEMENTED";
|
||||
export declare const MISSING_NEW = "MISSING_NEW";
|
||||
export declare const CALL_EXCEPTION = "CALL_EXCEPTION";
|
||||
export declare const INVALID_ARGUMENT = "INVALID_ARGUMENT";
|
||||
export declare const MISSING_ARGUMENT = "MISSING_ARGUMENT";
|
||||
export declare const UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT";
|
||||
export declare const NUMERIC_FAULT = "NUMERIC_FAULT";
|
||||
export declare const INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS";
|
||||
export declare const NONCE_EXPIRED = "NONCE_EXPIRED";
|
||||
export declare const REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED";
|
||||
export declare const UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION";
|
||||
export declare function throwError(message: string, code: string, params: any): never;
|
||||
export declare function checkNew(self: any, kind: any): void;
|
||||
export declare function checkArgumentCount(count: number, expectedCount: number, suffix?: string): void;
|
||||
export declare function setCensorship(censorship: boolean, permanent?: boolean): void;
|
||||
export declare function checkNormalize(): void;
|
||||
export declare function setLogLevel(logLevel: string): void;
|
||||
export declare function warn(...args: Array<any>): void;
|
||||
export declare function info(...args: Array<any>): void;
|
163
errors.js
163
errors.js
@ -1,163 +0,0 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var _version_1 = require("./_version");
|
||||
// Unknown Error
|
||||
exports.UNKNOWN_ERROR = 'UNKNOWN_ERROR';
|
||||
// Not implemented
|
||||
exports.NOT_IMPLEMENTED = 'NOT_IMPLEMENTED';
|
||||
// Missing new operator to an object
|
||||
// - name: The name of the class
|
||||
exports.MISSING_NEW = 'MISSING_NEW';
|
||||
// Call exception
|
||||
// - transaction: the transaction
|
||||
// - address?: the contract address
|
||||
// - args?: The arguments passed into the function
|
||||
// - method?: The Solidity method signature
|
||||
// - errorSignature?: The EIP848 error signature
|
||||
// - errorArgs?: The EIP848 error parameters
|
||||
// - reason: The reason (only for EIP848 "Error(string)")
|
||||
exports.CALL_EXCEPTION = 'CALL_EXCEPTION';
|
||||
// Invalid argument (e.g. value is incompatible with type) to a function:
|
||||
// - argument: The argument name that was invalid
|
||||
// - value: The value of the argument
|
||||
exports.INVALID_ARGUMENT = 'INVALID_ARGUMENT';
|
||||
// Missing argument to a function:
|
||||
// - count: The number of arguments received
|
||||
// - expectedCount: The number of arguments expected
|
||||
exports.MISSING_ARGUMENT = 'MISSING_ARGUMENT';
|
||||
// Too many arguments
|
||||
// - count: The number of arguments received
|
||||
// - expectedCount: The number of arguments expected
|
||||
exports.UNEXPECTED_ARGUMENT = 'UNEXPECTED_ARGUMENT';
|
||||
// Numeric Fault
|
||||
// - operation: the operation being executed
|
||||
// - fault: the reason this faulted
|
||||
exports.NUMERIC_FAULT = 'NUMERIC_FAULT';
|
||||
// Insufficien funds (< value + gasLimit * gasPrice)
|
||||
// - transaction: the transaction attempted
|
||||
exports.INSUFFICIENT_FUNDS = 'INSUFFICIENT_FUNDS';
|
||||
// Nonce has already been used
|
||||
// - transaction: the transaction attempted
|
||||
exports.NONCE_EXPIRED = 'NONCE_EXPIRED';
|
||||
// The replacement fee for the transaction is too low
|
||||
// - transaction: the transaction attempted
|
||||
exports.REPLACEMENT_UNDERPRICED = 'REPLACEMENT_UNDERPRICED';
|
||||
// Unsupported operation
|
||||
// - operation
|
||||
exports.UNSUPPORTED_OPERATION = 'UNSUPPORTED_OPERATION';
|
||||
var _permanentCensorErrors = false;
|
||||
var _censorErrors = false;
|
||||
// @TODO: Enum
|
||||
function throwError(message, code, params) {
|
||||
if (_censorErrors) {
|
||||
throw new Error('unknown error');
|
||||
}
|
||||
if (!code) {
|
||||
code = exports.UNKNOWN_ERROR;
|
||||
}
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
var messageDetails = [];
|
||||
Object.keys(params).forEach(function (key) {
|
||||
try {
|
||||
messageDetails.push(key + '=' + JSON.stringify(params[key]));
|
||||
}
|
||||
catch (error) {
|
||||
messageDetails.push(key + '=' + JSON.stringify(params[key].toString()));
|
||||
}
|
||||
});
|
||||
messageDetails.push("version=" + _version_1.version);
|
||||
var reason = message;
|
||||
if (messageDetails.length) {
|
||||
message += ' (' + messageDetails.join(', ') + ')';
|
||||
}
|
||||
// @TODO: Any??
|
||||
var error = new Error(message);
|
||||
error.reason = reason;
|
||||
error.code = code;
|
||||
Object.keys(params).forEach(function (key) {
|
||||
error[key] = params[key];
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
exports.throwError = throwError;
|
||||
function checkNew(self, kind) {
|
||||
if (!(self instanceof kind)) {
|
||||
throwError('missing new', exports.MISSING_NEW, { name: kind.name });
|
||||
}
|
||||
}
|
||||
exports.checkNew = checkNew;
|
||||
function checkArgumentCount(count, expectedCount, suffix) {
|
||||
if (!suffix) {
|
||||
suffix = '';
|
||||
}
|
||||
if (count < expectedCount) {
|
||||
throwError('missing argument' + suffix, exports.MISSING_ARGUMENT, { count: count, expectedCount: expectedCount });
|
||||
}
|
||||
if (count > expectedCount) {
|
||||
throwError('too many arguments' + suffix, exports.UNEXPECTED_ARGUMENT, { count: count, expectedCount: expectedCount });
|
||||
}
|
||||
}
|
||||
exports.checkArgumentCount = checkArgumentCount;
|
||||
function setCensorship(censorship, permanent) {
|
||||
if (_permanentCensorErrors) {
|
||||
throwError('error censorship permanent', exports.UNSUPPORTED_OPERATION, { operation: 'setCensorship' });
|
||||
}
|
||||
_censorErrors = !!censorship;
|
||||
_permanentCensorErrors = !!permanent;
|
||||
}
|
||||
exports.setCensorship = setCensorship;
|
||||
function checkNormalize() {
|
||||
try {
|
||||
// Make sure all forms of normalization are supported
|
||||
["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) {
|
||||
try {
|
||||
"test".normalize(form);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error('missing ' + form);
|
||||
}
|
||||
});
|
||||
if (String.fromCharCode(0xe9).normalize('NFD') !== String.fromCharCode(0x65, 0x0301)) {
|
||||
throw new Error('broken implementation');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
throwError('platform missing String.prototype.normalize', exports.UNSUPPORTED_OPERATION, { operation: 'String.prototype.normalize', form: error.message });
|
||||
}
|
||||
}
|
||||
exports.checkNormalize = checkNormalize;
|
||||
var LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 };
|
||||
var LogLevel = LogLevels["default"];
|
||||
function setLogLevel(logLevel) {
|
||||
var level = LogLevels[logLevel];
|
||||
if (level == null) {
|
||||
warn("invliad log level - " + logLevel);
|
||||
return;
|
||||
}
|
||||
LogLevel = level;
|
||||
}
|
||||
exports.setLogLevel = setLogLevel;
|
||||
function log(logLevel, args) {
|
||||
if (LogLevel > LogLevels[logLevel]) {
|
||||
return;
|
||||
}
|
||||
console.log.apply(console, args);
|
||||
}
|
||||
function warn() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
log("warn", args);
|
||||
}
|
||||
exports.warn = warn;
|
||||
function info() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
log("info", args);
|
||||
}
|
||||
exports.info = info;
|
13
ethers.d.ts
vendored
13
ethers.d.ts
vendored
@ -1,13 +0,0 @@
|
||||
import { Contract, ContractFactory, VoidSigner } from './contract';
|
||||
import { Signer } from './abstract-signer';
|
||||
import { Wallet } from './wallet';
|
||||
import * as constants from './constants';
|
||||
import * as errors from './errors';
|
||||
import * as providers from './providers';
|
||||
import * as utils from './utils';
|
||||
import * as wordlists from './wordlists';
|
||||
import { platform } from './utils/shims';
|
||||
import { version } from './_version';
|
||||
import { ContractFunction, ContractTransaction, Event, EventFilter } from './contract';
|
||||
declare function getDefaultProvider(network?: utils.Network | string): providers.BaseProvider;
|
||||
export { Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, constants, errors, utils, wordlists, platform, version, ContractFunction, ContractTransaction, Event, EventFilter };
|
51
ethers.js
51
ethers.js
@ -1,51 +0,0 @@
|
||||
'use strict';
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var contract_1 = require("./contract");
|
||||
exports.Contract = contract_1.Contract;
|
||||
exports.ContractFactory = contract_1.ContractFactory;
|
||||
exports.VoidSigner = contract_1.VoidSigner;
|
||||
var abstract_signer_1 = require("./abstract-signer");
|
||||
exports.Signer = abstract_signer_1.Signer;
|
||||
var wallet_1 = require("./wallet");
|
||||
exports.Wallet = wallet_1.Wallet;
|
||||
var constants = __importStar(require("./constants"));
|
||||
exports.constants = constants;
|
||||
var errors = __importStar(require("./errors"));
|
||||
exports.errors = errors;
|
||||
var providers = __importStar(require("./providers"));
|
||||
exports.providers = providers;
|
||||
var utils = __importStar(require("./utils"));
|
||||
exports.utils = utils;
|
||||
var wordlists = __importStar(require("./wordlists"));
|
||||
exports.wordlists = wordlists;
|
||||
////////////////////////
|
||||
// Compile-Time Constants
|
||||
// This is empty in node, and used by browserify to inject extra goodies
|
||||
var shims_1 = require("./utils/shims");
|
||||
exports.platform = shims_1.platform;
|
||||
// This is generated by "npm run dist"
|
||||
var _version_1 = require("./_version");
|
||||
exports.version = _version_1.version;
|
||||
////////////////////////
|
||||
// Helper Functions
|
||||
function getDefaultProvider(network) {
|
||||
if (network == null) {
|
||||
network = 'homestead';
|
||||
}
|
||||
var n = utils.getNetwork(network);
|
||||
if (!n || !n._defaultProvider) {
|
||||
errors.throwError('unsupported getDefaultProvider network', errors.UNSUPPORTED_OPERATION, {
|
||||
operation: 'getDefaultProvider',
|
||||
network: network
|
||||
});
|
||||
}
|
||||
return n._defaultProvider(providers);
|
||||
}
|
||||
exports.getDefaultProvider = getDefaultProvider;
|
356
gulpfile.js
356
gulpfile.js
@ -1,356 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var through = require('through');
|
||||
|
||||
var gulp = require("gulp");
|
||||
var ts = require("gulp-typescript");
|
||||
var tsProject = ts.createProject("tsconfig.json");
|
||||
|
||||
var browserify = require("browserify");
|
||||
var source = require('vinyl-source-stream');
|
||||
var tsify = require("tsify");
|
||||
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var uglify = require('gulp-uglify');
|
||||
var buffer = require('vinyl-buffer');
|
||||
|
||||
function createTransform(transforms, show) {
|
||||
if (!show) { show = { }; }
|
||||
|
||||
function padding(length) {
|
||||
let pad = '';
|
||||
while (pad.length < length) { pad += ' '; }
|
||||
return pad;
|
||||
}
|
||||
|
||||
function transformFile(path) {
|
||||
for (var pattern in transforms) {
|
||||
if (path.match(new RegExp('/' + pattern + '$'))) {
|
||||
return transforms[pattern];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return function(path, options) {
|
||||
var data = '';
|
||||
|
||||
return through(function(chunk) {
|
||||
data += chunk;
|
||||
}, function () {
|
||||
var transformed = transformFile(path);
|
||||
var shortPath = path;
|
||||
if (shortPath.substring(0, __dirname.length) == __dirname) {
|
||||
shortPath = shortPath.substring(__dirname.length);
|
||||
}
|
||||
var size = fs.readFileSync(path).length;
|
||||
if (transformed != null) {
|
||||
if (show.transformed) {
|
||||
console.log('Transformed:', shortPath, padding(70 - shortPath.length), size, padding(6 - String(size).length), '=>', transformed.length);
|
||||
}
|
||||
data = transformed;
|
||||
} else if (shortPath === '/src.ts/utils/wordlist.ts') {
|
||||
data += '\n\nexportWordlist = true;'
|
||||
if (show.transformed) {
|
||||
console.log('Transformed:', shortPath, padding(70 - shortPath.length), size, padding(6 - String(size).length), '=>', data.length);
|
||||
}
|
||||
} else {
|
||||
if (show.preserved) {
|
||||
console.log('Preserved: ', shortPath, padding(70 - shortPath.length), size);
|
||||
}
|
||||
}
|
||||
this.queue(data);
|
||||
this.queue(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bundled Library (browser)
|
||||
*
|
||||
* Source: src.ts/index.ts src.ts/{contracts,providers,utils,wallet}/*.ts src.ts/wordlists/lang-en.ts
|
||||
* Target: dist/ethers{.min,}.js
|
||||
*/
|
||||
function taskBundle(name, options) {
|
||||
var show = options.show || { };
|
||||
|
||||
// The elliptic package.json is only used for its version
|
||||
var ellipticPackage = require('elliptic/package.json');
|
||||
ellipticPackage = JSON.stringify({ version: ellipticPackage.version });
|
||||
|
||||
var version = require('./package.json').version;
|
||||
|
||||
var undef = "module.exports = undefined;";
|
||||
var empty = "module.exports = {};";
|
||||
|
||||
// This is only used in getKeyPair, which we do not use; but we'll
|
||||
// leave it in tact using the browser crypto functions
|
||||
var brorand = "module.exports = function(length) { var result = new Uint8Array(length); (global.crypto || global.msCrypto).getRandomValues(result); return result; }";
|
||||
|
||||
// setImmediate is installed globally by our src.browser/shims.ts, loaded from src.ts/index.ts
|
||||
var process = "module.exports = { browser: true };";
|
||||
var timers = "module.exports = { setImmediate: global.setImmediate }; ";
|
||||
|
||||
function readShim(filename) {
|
||||
return fs.readFileSync('./shims/' + filename + '.js').toString();
|
||||
}
|
||||
|
||||
|
||||
var transforms = {
|
||||
|
||||
// Remove the precomputed secp256k1 points
|
||||
"elliptic/lib/elliptic/precomputed/secp256k1.js": undef,
|
||||
|
||||
// Remove curves we don't care about
|
||||
"elliptic/curve/edwards.js": empty,
|
||||
"elliptic/curve/mont.js": empty,
|
||||
"elliptic/lib/elliptic/eddsa/.*": empty,
|
||||
|
||||
// We only use the version from this JSON package
|
||||
"elliptic/package.json" : ellipticPackage,
|
||||
|
||||
// Remove RIPEMD160 and unneeded hashing algorithms
|
||||
//"hash.js/lib/hash/ripemd.js": "module.exports = {ripemd160: null}",
|
||||
"hash.js/lib/hash/sha/1.js": empty,
|
||||
"hash.js/lib/hash/sha/224.js": empty,
|
||||
"hash.js/lib/hash/sha/384.js": empty,
|
||||
|
||||
// Swap out borland for the random bytes we already have
|
||||
"brorand/index.js": brorand,
|
||||
|
||||
"xmlhttprequest/lib/XMLHttpRequest.js": readShim("xmlhttprequest"),
|
||||
|
||||
// Used by sha3 if it exists; (so make it no exist)
|
||||
"process/browser.js": process,
|
||||
"timers-browserify/main.js": timers,
|
||||
|
||||
"ethers.js/utils/base64.js": readShim("base64"),
|
||||
"ethers.js/providers/ipc-provider.js": readShim("empty"),
|
||||
"ethers.js/utils/hmac.js": readShim("hmac"),
|
||||
"ethers.js/utils/pbkdf2.js": readShim("pbkdf2"),
|
||||
"ethers.js/utils/random-bytes.js": readShim("random-bytes"),
|
||||
"ethers.js/utils/shims.js": readShim("shims"),
|
||||
"ethers.js/wordlists/index.js": readShim("wordlists"),
|
||||
|
||||
};
|
||||
|
||||
gulp.task(name, function () {
|
||||
|
||||
var result = browserify({
|
||||
basedir: '.',
|
||||
debug: false,
|
||||
entries: [ './index.js' ],
|
||||
cache: { },
|
||||
packageCache: {},
|
||||
standalone: "ethers",
|
||||
transform: [ [ createTransform(transforms, show), { global: true } ] ],
|
||||
})
|
||||
.bundle()
|
||||
.pipe(source(options.filename))
|
||||
|
||||
if (options.minify) {
|
||||
result = result.pipe(buffer())
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(uglify({
|
||||
output: { ascii_only: true }
|
||||
}))
|
||||
.pipe(sourcemaps.write('./'))
|
||||
}
|
||||
|
||||
result = result.pipe(gulp.dest(options.dest));
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
// Creates dist/ethers.js
|
||||
taskBundle("default", { filename: "ethers.js", dest: 'dist', show: { transformed: true, preserved: true }, minify: false });
|
||||
|
||||
// Creates dist/ethers.js
|
||||
taskBundle("default-test", { filename: "ethers.js", dest: 'tests/dist', show: { transformed: true }, minify: false });
|
||||
|
||||
// Creates dist/ethers.min.js
|
||||
taskBundle("minified", { filename: "ethers.min.js", dest: 'dist', minify: true });
|
||||
|
||||
// Creates dist/ethers.min.js
|
||||
taskBundle("minified-test", { filename: "ethers.min.js", dest: 'tests/dist', minify: true });
|
||||
|
||||
gulp.task('shims', function () {
|
||||
|
||||
var result = browserify({
|
||||
basedir: '.',
|
||||
debug: false,
|
||||
entries: [ './tests/shims/index.js' ],
|
||||
cache: { },
|
||||
packageCache: {},
|
||||
standalone: "_shims",
|
||||
insertGlobalVars: {
|
||||
process: function() { return; },
|
||||
}
|
||||
})
|
||||
.bundle()
|
||||
.pipe(source('shims.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(uglify({
|
||||
output: { ascii_only: true }
|
||||
}))
|
||||
.pipe(gulp.dest('dist'));
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
/*
|
||||
// Dump the TypeScript definitions to dist/types/
|
||||
gulp.task("types", function() {
|
||||
return gulp.src(['./src.ts/index.ts', './src.ts / * * / * . ts'])
|
||||
.pipe(ts({
|
||||
declaration: true,
|
||||
esModuleInterop: true,
|
||||
moduleResolution: "node",
|
||||
lib: [ "es2015", "es5", "dom" ],
|
||||
module: "commonjs",
|
||||
outDir: './dist/types',
|
||||
target: "es5",
|
||||
}))
|
||||
.dts
|
||||
.pipe(gulp.dest("dist/types/"))
|
||||
});
|
||||
*/
|
||||
|
||||
/**
|
||||
* Browser Friendly BIP39 Wordlists
|
||||
*
|
||||
* source: src.ts/wordlist/lang-*.ts
|
||||
* target: dist/wordlist-*.js
|
||||
*
|
||||
* Since all of the functions these wordlists use is already
|
||||
* available from the global ethers library, we use this to
|
||||
* target the global ethers functions directly, rather than
|
||||
* re-include them.
|
||||
*/
|
||||
function taskLang(locale) {
|
||||
function transformBip39(path, options) {
|
||||
var data = '';
|
||||
|
||||
return through(function(chunk) {
|
||||
data += chunk;
|
||||
}, function () {
|
||||
var shortPath = path;
|
||||
if (shortPath.substring(0, __dirname.length) == __dirname) {
|
||||
shortPath = shortPath.substring(__dirname.length);
|
||||
}
|
||||
|
||||
// Word list files...
|
||||
if (shortPath.match(/^\/src\.ts\/wordlists\//)) {
|
||||
shortPath = '/';
|
||||
}
|
||||
|
||||
switch (shortPath) {
|
||||
// Use the existing "ethers.errors"
|
||||
case '/src.ts/errors.ts':
|
||||
data = "module.exports = global.ethers.errors";
|
||||
break;
|
||||
|
||||
// Use the existing "ethers.utils"
|
||||
case '/src.ts/utils/bytes.ts':
|
||||
case '/src.ts/utils/hash.ts':
|
||||
case '/src.ts/utils/properties.ts':
|
||||
case '/src.ts/utils/utf8.ts':
|
||||
data = "module.exports = global.ethers.utils";
|
||||
break;
|
||||
|
||||
// If it is the Wordlist class, register should export the wordlist
|
||||
case '/src.ts/utils/wordlist.ts':
|
||||
data += '\n\nexportWordlist = true;'
|
||||
break;
|
||||
|
||||
// Do nothing
|
||||
case '/':
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error('unhandled file: ' + shortPath);
|
||||
}
|
||||
|
||||
this.queue(data);
|
||||
this.queue(null);
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task("bip39-" + locale, function() {
|
||||
return browserify({
|
||||
basedir: '.',
|
||||
debug: false,
|
||||
entries: [ 'src.ts/wordlists/lang-' + locale + ".ts" ],
|
||||
cache: {},
|
||||
packageCache: {},
|
||||
transform: [ [ transformBip39, { global: true } ] ],
|
||||
})
|
||||
.plugin(tsify)
|
||||
.bundle()
|
||||
.pipe(source("wordlist-" + locale + ".js"))
|
||||
.pipe(buffer())
|
||||
.pipe(uglify({
|
||||
output: { ascii_only: true }
|
||||
}))
|
||||
.pipe(gulp.dest("dist"));
|
||||
});
|
||||
}
|
||||
|
||||
taskLang("es");
|
||||
taskLang("fr");
|
||||
taskLang("it");
|
||||
taskLang("ja");
|
||||
taskLang("ko");
|
||||
taskLang("zh");
|
||||
|
||||
// Package up all the test cases into tests/dist/tests.json
|
||||
gulp.task("tests", function() {
|
||||
|
||||
function readShim(filename) {
|
||||
return fs.readFileSync('./tests/' + filename + '.js').toString();
|
||||
}
|
||||
|
||||
var transforms = {
|
||||
"tests/utils-ethers.js": readShim('utils-ethers-browser')
|
||||
}
|
||||
|
||||
// Create a mock-fs module that can load our gzipped test cases
|
||||
var data = {};
|
||||
|
||||
fs.readdirSync('tests/tests').forEach(function(filename) {
|
||||
if (!filename.match(/\.json\.gz$/)) { return; }
|
||||
filename = 'tests/tests/' + filename;
|
||||
data['/' + filename] = fs.readFileSync(filename).toString('base64');
|
||||
});
|
||||
|
||||
fs.readdirSync('tests/tests/easyseed-bip39').forEach(function(filename) {
|
||||
if (!filename.match(/\.json$/)) { return; }
|
||||
filename = 'tests/tests/easyseed-bip39/' + filename;
|
||||
data['/' + filename] = fs.readFileSync(filename).toString('base64');
|
||||
});
|
||||
|
||||
fs.readdirSync('tests/wordlist-generation').forEach(function(filename) {
|
||||
if (!filename.match(/\.txt$/)) { return; }
|
||||
filename = 'tests/wordlist-generation/' + filename;
|
||||
data['/' + filename] = fs.readFileSync(filename).toString('base64');
|
||||
});
|
||||
|
||||
fs.writeFileSync('./tests/dist/tests.json', JSON.stringify(data));
|
||||
|
||||
return browserify({
|
||||
basedir: './',
|
||||
debug: false,
|
||||
entries: [ "./tests/browser.js" ],
|
||||
cache: {},
|
||||
packageCache: {},
|
||||
standalone: "tests",
|
||||
transform: [ [ createTransform(transforms), { global: true } ] ],
|
||||
})
|
||||
.bundle()
|
||||
.pipe(source("tests.js"))
|
||||
.pipe(gulp.dest("tests/dist/"));
|
||||
});
|
||||
|
||||
|
3
index.d.ts
vendored
3
index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
import * as ethers from './ethers';
|
||||
export { ethers };
|
||||
export * from './ethers';
|
15
index.js
15
index.js
@ -1,15 +0,0 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ethers = __importStar(require("./ethers"));
|
||||
exports.ethers = ethers;
|
||||
__export(require("./ethers"));
|
16
lib.commonjs/README.md
Normal file
16
lib.commonjs/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
CommonJS Files
|
||||
==============
|
||||
|
||||
The contents of this folder are for using `require` in CommonJS
|
||||
projects.
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
The contents are generated via the `npm run build-commonjs` target
|
||||
using `tsc` and the `/tsconfig.commonjs.json` configuration.
|
||||
|
||||
Do not modify the files in this folder. They are deleted on `build-clean`.
|
||||
|
||||
To modify this `README.md`, see the `/output/post-build/lib.commonjs`.
|
95
lib.commonjs/_tests/blockchain-data.d.ts
vendored
Normal file
95
lib.commonjs/_tests/blockchain-data.d.ts
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
export type TestBlockchainNetwork = "mainnet" | "goerli" | "sepolia";
|
||||
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;
|
||||
blobGasUsed?: bigint;
|
||||
excessBlobGas?: bigint;
|
||||
parentBeaconBlockRoot?: string;
|
||||
stateRoot?: string;
|
||||
receiptsRoot?: string;
|
||||
}
|
||||
export interface TestBlockchainTransaction {
|
||||
test: string;
|
||||
hash: string;
|
||||
blockHash: string;
|
||||
blockNumber: number;
|
||||
index: 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;
|
||||
maxFeePerBlobGas?: bigint;
|
||||
blobVersionedHashes?: Array<string>;
|
||||
}
|
||||
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;
|
||||
blobGasUsed?: bigint;
|
||||
blobGasPrice?: bigint;
|
||||
}
|
||||
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;
|
||||
//# sourceMappingURL=blockchain-data.d.ts.map
|
1
lib.commonjs/_tests/blockchain-data.d.ts.map
Normal file
1
lib.commonjs/_tests/blockchain-data.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"blockchain-data.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/blockchain-data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErC,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QACP,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;QACf,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAC;KAC3B,CAAC;IACF,OAAO,EAAE,IAAI,GAAG,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAEhB,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAElD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACtC;AAED,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAC;IAEb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,KAAK,CAAC;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC5B,CAAC,CAAA;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAEd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAyBnF,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAmK/E,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CA2F3F,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CA6GnF,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,qBAAqB,CAErD,CAAC;AACF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQ7E"}
|
406
lib.commonjs/_tests/blockchain-data.js
Normal file
406
lib.commonjs/_tests/blockchain-data.js
Normal file
@ -0,0 +1,406 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.networkFeatureAtBlock = exports.networkNames = exports.testReceipt = exports.testTransaction = exports.testBlock = exports.testAddress = void 0;
|
||||
;
|
||||
exports.testAddress = {
|
||||
mainnet: [
|
||||
{
|
||||
test: "old-account",
|
||||
address: "0xAC1639CF97a3A46D431e6d1216f576622894cBB5",
|
||||
balance: BigInt("4813414100000000"),
|
||||
nonce: 3,
|
||||
code: "0x"
|
||||
}, {
|
||||
test: "TheDAO-splitter-contract",
|
||||
address: "0x3474627D4F63A678266BC17171D87f8570936622",
|
||||
code: "0x606060405260e060020a60003504630b3ed5368114602e57806337b0574a14605257806356fa47f0146062575b005b602c6004356000546101009004600160a060020a03908116339091161460bb575b50565b60005460ff166060908152602090f35b602c60043560005460ff1615609657600160a060020a038116600034606082818181858883f193505050501515604f576002565b33600160a060020a0316600034606082818181858883f193505050501515604f576002565b600080546101009004600160a060020a03169082606082818181858883f193505050501515604f57600256",
|
||||
storage: {
|
||||
"0": "0x0000000000000000000000b2682160c482eb985ec9f3e364eec0a904c44c2300"
|
||||
}
|
||||
}, {
|
||||
test: "ricmoo.firefly.eth",
|
||||
address: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
|
||||
name: "ricmoo.firefly.eth"
|
||||
},
|
||||
],
|
||||
goerli: [],
|
||||
sepolia: []
|
||||
};
|
||||
exports.testBlock = {
|
||||
mainnet: [
|
||||
{
|
||||
test: "old-homestead-block",
|
||||
hash: "0x3d6122660cc824376f11ee842f83addc3525e2dd6756b9bcf0affa6aa88cf741",
|
||||
parentHash: "0xb495a1d7e6663152ae92708da4843337b958146015a2802f4193a410044698c9",
|
||||
number: 3,
|
||||
timestamp: 1438270048,
|
||||
nonce: "0x2e9344e0cbde83ce",
|
||||
difficulty: BigInt(17154715646),
|
||||
gasLimit: BigInt("0x1388"),
|
||||
gasUsed: BigInt("0"),
|
||||
miner: "0x5088D623ba0fcf0131E0897a91734A4D83596AA0",
|
||||
extraData: "0x476574682f76312e302e302d66633739643332642f6c696e75782f676f312e34",
|
||||
stateRoot: '0x76ab0b899e8387436ff2658e2988f83cbf1af1590b9fe9feca3714f8d1824940',
|
||||
receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
|
||||
transactions: []
|
||||
},
|
||||
{
|
||||
test: "london-block",
|
||||
number: 14413999,
|
||||
hash: "0x6c79356d40ebb6ed63dc19f5d407f8f1c876047b59dc1a4598cce0e64dcabec5",
|
||||
parentHash: "0xbf09b0e215f247a5066d19ece5b4c66960771d45fae62985e8d751fb1adcfe2f",
|
||||
timestamp: 1647654576,
|
||||
nonce: "0xb4bc9979af5369fe",
|
||||
difficulty: BigInt("12841513359509721"),
|
||||
gasLimit: BigInt("30087914"),
|
||||
gasUsed: BigInt("2008910"),
|
||||
miner: "0x2A20380DcA5bC24D052acfbf79ba23e988ad0050",
|
||||
extraData: "0x706f6f6c696e2e636f6d21f7092f019bb92a76",
|
||||
baseFeePerGas: BigInt("40911884304"),
|
||||
stateRoot: '0xd08663f630cfcf2d7d8fe4d52f7685ad09798b7e6150cabea5eeceb1d89e11c2',
|
||||
receiptsRoot: '0x473e83ec3df279f44c4fc6da50fe1d0c5a18f1929b90de8917bdcdb88a132750',
|
||||
transactions: [
|
||||
"0x1c3a398933db10634631f54b435c40c8805c13f12bbac7c3dab858ca44213fa2",
|
||||
"0xd98947cbdd892cc7f679c903903e6d18a5c5afb19e94437beba79372ad71c347",
|
||||
"0x4d66190deb55b5820cb0ce9adb972f646fa0f3e64eaeee674bbf3d054bf3d883",
|
||||
"0x9db7bd5f4c91d6103c714bcbc35df3dc708daa668aaef7449b589dbd3be24dac",
|
||||
"0x126a43ae4ade4b7fc5c8ac9ebd3dbcf7314f63c60f2804fb49aa25b5c7d80bb1",
|
||||
"0x82a90aa4b3b1b7873b117c3ff1ca7165ae34b2fc0788cc0cbfd41805d588590d",
|
||||
"0x7f694a6a9972457753ed3dec164f17272b1c8b1da4eab149df95e31a3e72f606",
|
||||
"0xdce1cba1ff33f0c23881087d49de3b34fe84c8a6883f3edd75b04fc23e458aac",
|
||||
"0xbe1c69f825279cebef42d1f0e07397dcddef7fb278b0195e295ede3e156836c4",
|
||||
"0x1d2f007b3c0f894403973a30e5ffaa78589f873d963e9554c6bb1bd7a3127245",
|
||||
"0x9c8c78191cf4ae9ae8eee1165153eabe24dbd8b9509b83d5f0caeea85251bb2f",
|
||||
"0x42e956f4b3dd6535359b272a0d2dab995c364cb48baaf8d0a1981995f3f8c808",
|
||||
"0xdc2c2e99393e24d5dc66e38665fa1d1ff007d92088ef3fd2549545fdbe862ef6",
|
||||
"0xaad7be28fffd2e77e8e40bf57f2ac140aa8283ec93c7f3f61a82c79405602f53",
|
||||
"0x4735f1421b7b30283e87e0799e82e54307d3e5ba14cd54ad8420b57577489a71",
|
||||
"0x0b9d6aa23aa439b41e86595f2ad91f498adffa3e6e7cb26ac7d73252e59fd3de",
|
||||
"0xcd93e19bd5d5c5a834fec613116fa01f46eddfd2faa20ef302271b874b9d812a",
|
||||
"0x5bf1976574a637f5ac0b8bda1a792fa16cc7ce9624d32e9bd6bd9aa6a8f19d2f",
|
||||
"0x2e778da4f66f10f7b681b605635c6599cdbeea167fc1c4396a097aef5d06de61",
|
||||
"0xd5fd68eebc4c870ccda081786a74c75c250e9e2d8269b8935edb3adb11b80bb2",
|
||||
"0x2aec42a11c1d8c1e5198d54aacbc6bebb09bcd5e78f6af81ea09d65c9064734a",
|
||||
"0xbea2e364ea4959ec438d9ccc2d2f7120c7eaba3b177cc0d7df8ff65d866ef89f",
|
||||
"0xf48bbb0f838353060da4126a555ce532abf497a9d1108001afffaac513a59ddf",
|
||||
"0xf5664e4372cce62733a6610efb7701a4a0e552d81f8caa764d8474b3070c6617",
|
||||
"0x9d3732ddbd20610008ff737da2f61120734a1cbfa864374bcbcf10051e6048cb",
|
||||
"0xc4d0df5bc6fa51b34ac3c898866d779d4e51a6be4d13be1ec3084b7229b03b47",
|
||||
"0x90c86ec98b8ad98049b4ee54cb3aa72c5ae743077b830e8a294aa5dc47a1fb18"
|
||||
]
|
||||
}
|
||||
],
|
||||
goerli: [],
|
||||
sepolia: [
|
||||
{
|
||||
test: "eip-4844-BLob-block",
|
||||
hash: "0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d",
|
||||
parentHash: "0x2b579cb7224abdbe7a66c76380d60329bba41d95d225feb80ca1a78cf83a5124",
|
||||
parentBeaconBlockRoot: '0xa05d27aa9c2f3d57943ca86134a08f6f7852ad5e9dbe360f86b466e2f0ed7bb5',
|
||||
number: 5198187,
|
||||
timestamp: 1706801700,
|
||||
nonce: "0x0000000000000000",
|
||||
difficulty: BigInt(0),
|
||||
gasLimit: BigInt("30000000"),
|
||||
gasUsed: BigInt("5622957"),
|
||||
baseFeePerGas: BigInt("48793932840"),
|
||||
miner: "0x008b3b2F992C0E14eDaa6E2c662Bec549CAA8df1",
|
||||
extraData: "0x",
|
||||
blobGasUsed: BigInt("524288"),
|
||||
excessBlobGas: BigInt("79691776"),
|
||||
stateRoot: '0xa78ad0e0f5d2b3383fdb13f4ad0523723816863556be3a5414536862f4d217df',
|
||||
receiptsRoot: '0xa254ed337328248b77011c70c2b85d6575f965f2fe65ed233c27e3750c0b7170',
|
||||
transactions: [
|
||||
"0xe8a096a98cd7b8d783cbb30687c3adc8e59f1e9563c0454623cc8af59f8bcab1",
|
||||
"0x5aac2d50b15e177e8edaae4819e989650a6cdb335dd8924b5a7a7ed1675d15e7",
|
||||
"0x21c94c24419f746efd2c1f470c0842df21ab8da14f7db8e30a12c53a4e7d5145",
|
||||
"0x85b40ce37262a7962487bd37bf36867b344525b425a90a25516ac3c2cb1f6535",
|
||||
"0x1a674ff3bd6bbe7bc7ada2ae3da893a7b74b4cfaadebc8c3f0fe0c9ad3c1c35b",
|
||||
"0x48cafe99a7d2284a1664e05c404dd88e4113ffb65bf49846716bd855ffc6835d",
|
||||
"0x658065003e8952782d121d9b5729845862c2a45ed24e46c634041a77c4577bed",
|
||||
"0xc5416e0a2383b1a9b3ba030803f88e45faebfb35ad5db022e44a09b15aeae385",
|
||||
"0x9030f7962f3f638f96bb703f45cdaa8778cf393ead767592aa50bce32230eae3",
|
||||
"0xce008888308a4c1d51f87a1c2a75b1d0bd15eb096c675ad091dcc9705e4d016d",
|
||||
"0xcf17c1f09a22c992a469da0023ad3c9bd2c29a8532146bcdf9ce3216609ea50c",
|
||||
"0x3933e49a215c80b35ec7d48e2741fda50c8cc7b92652e79663e4423c00e8e1e2",
|
||||
"0x82b2af4ed108880c151ee38cb3ab28e81ba86a2b0e707dd9cee9bf341f895a8a",
|
||||
"0x51ef5af42d572d6135bec154d5c754928465bad00d1ff7b769a5b65e0054a90e",
|
||||
"0x87cab3ae3a36d439a539ded7eb57e0ef07c5a1fbe1697c2e5ba8d7c03875fd22",
|
||||
"0x70371a20dfbff0ee753b52cd9445f431454b929c7375624a96f5dbc25e88afed",
|
||||
"0x57ee8a4a09875b7720f7d9e75fb93a1cc86d166ad9a1b4c2d7cf2c7c8324fbc0",
|
||||
"0xf004bd2b0119aca5f364b16421a5b2e7db811568761f5542fdcd74903cd9115d",
|
||||
"0x5b6635688362651e1cd33c668bd748d964ba93006661e53dc117d1c1e44886a5",
|
||||
"0xe5893e07bfec18dd206da279a47ee5cc9471930bbb3b85d64ee4945b98137348",
|
||||
"0x4f0f48032a77a80550f71cbcbe86f7d1b34009910f12dbe153a93cb66965393e",
|
||||
"0x5420c3f7b5118e0829df31794aa55a1a91e0009600bbff283b553d5ac7a248ff",
|
||||
"0xece2175e4b06bf6105f5be10a9ed48808a5f96f12f80b3941ee7cb1eeca99e03",
|
||||
"0x383ea6445cd183e32fbc7b846c00b34c419078fe4055cd078f8692fc02b300c8",
|
||||
"0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
|
||||
"0xe7e24b8c8182832e7b1113cd07ae68e4ca8618decdc527650f57d25d0b681fde",
|
||||
"0xef5f520662c133be33209249fbc93afb7c614c06a0b45086d15c33bd7c0ca47a",
|
||||
"0x4af20dc2e952e381789065f2cd0c88730fea820bcc3db82eaddf63b36e65b3ac",
|
||||
"0xf99eef2240abc5002c9d71a90ffd463935642aaf81213f37337327c1afcb502c",
|
||||
"0xf7d1ad53e2435e6d978563e39db89660d1b4de6084a3a3cefe7025d28507017f",
|
||||
"0xfc21e64a158ac26ea9afc754460e16fefc4316a3fb92ec9a6042b792d7855788",
|
||||
"0xee60e551bcf518853ef4f5c33551ad07fa95267814940c4203934c79355b1ac0",
|
||||
"0x2a3c649caf77b942b206b9eb1be4635d950cf9a15fea2b43d3d7cbeddf700739",
|
||||
"0xbbd7b9c1434eb98d177f2ff8911b0186309534dea942c40a86517d69247cd0ac",
|
||||
"0xd86daa6d16e2aee4fc6ae831336ada63623685fb998dc5c605284a034604d751",
|
||||
"0xcfc848dfbbbe76fe0095f04ef35c931799c294eb3623e5cb8c0d81362e8bf125",
|
||||
"0x71e3ea97c91bd14388d99d69d122314a1cf0d595cbad1e45040277b470c4e67b",
|
||||
"0xa9b2e44e46d38bb67cbd7a2d47d57e60892dff018f7754b54a221ae3f1b996c4",
|
||||
"0xd1b8f9d669bd7f5072a095476e94e90510f2a18b434551fb7852b5c38c41471a",
|
||||
"0xa3858e80680997080fddde083398e857b14cd4e2cfe74629f6a1245df0447efb",
|
||||
"0x97593f663b07f8a4555202abb691cf7997210284195c24980abee02040c60618",
|
||||
"0x03387f22b01919486338fbd874dd7059f8df62d5b16052cb0ab855b6a364777e",
|
||||
"0xf2561f5f487c3d20c42b42e697a49fb5d05e0fb844ca97b2f127b210475f457e",
|
||||
"0xa67951a1309f1c7ec07ee518ecad831d12c5c78619250681068e7973243f7d9b",
|
||||
"0x7b007997da62b3ac9e5a7005066941e74f5c14d0bdaf4ac44faa8c3479b3cf45",
|
||||
"0x74379408aa3518cbbb394886c91f77ba95ccd37f6b10517834f69a8ff5120ca7",
|
||||
"0xd4843ef02a0d9802d31a89e13e60b6e71870de9124d0b472047012f7a4320f83",
|
||||
"0xaa50331afeafd8f9e913a9f78e898e299314d0825936724cc31211ebf177a9bf",
|
||||
"0xf20c83f2e5d199ad84a7b5dc6fda9611772516e07e7fc71b9f7889af4f2a16aa",
|
||||
"0x89a7c645987dc079ce1af236ed3dd445ad805cc030e5a57766324d4a0a1def9a",
|
||||
"0xe8e7d1116c2c60afd063b9c1e87624426cf6c9fd8d3fa6befe25666e68459570",
|
||||
"0x50be079e71cabf80ca27c39a27f9c0759ac272151f4608b9b75ebfac8284a601",
|
||||
"0xca24f69d47438ebd0b8f304f2f6d7a513d056905f10b164ed6a2cff6da1d4fea",
|
||||
"0x08d2521e04dfd0decc2f556b11274212e84076ff84a0135e9b4e3434de09d42a",
|
||||
"0xcc1e01932a627e9aa20d2b72480d13b4826e128efbbe03526504f7cb9facfc1f",
|
||||
"0x0a3ac907b6d1584cb3d7f9f588ddb4bdd7878db34bc47bd8baf881dd71a98f7d",
|
||||
"0x487539ee9cc6933e13e75e94935c30faffa826c28460fed6d9c3a07d15e2617f",
|
||||
"0xad251856762796acc75dc2846def1f6995fe1b5c747bcab51c10f561d22ffd57",
|
||||
"0x27ca72aa253e009e5e4497dd838986c561e7bea129fec930bc276968525456a8",
|
||||
"0xe26391de668d3eb6f5a3c2f3e14f911dc683873b7ea60d883116c205610b36ff",
|
||||
"0x691c3c5583c5f6444dc6c2f26315a127fc72ebd4f3848055cc8abb8a941d065b",
|
||||
"0x449578293a1dce8d3c147fed564a765515d090e8cd8866209648eb86cd5c1090",
|
||||
"0xb79c6f59d533663ca4fa3a70e9c8be18a3761edc43923c2ecd0904447f654f90",
|
||||
"0xc03863ffa85dd15e0d774ea20006dffd01a868dbf3ff2abe04ccdbf4f027d7ec",
|
||||
"0x28bc1a65696947beb387adbbeabb5328e5f812c435db288688041d9a8c6ab372",
|
||||
"0x6dca99c2103d3894ba83c75e0fa0d42f722e5e93fe6f7a6a55a80cf2907a1a5e",
|
||||
"0x75a7c5f00d79f1b30f82855a8b25077182f1abfd5dbccdf18fe1276e6c9e6a1e",
|
||||
"0x3fc5a320d8c16bcfe2eda847582d34731abc12a3bffbf334a238b47c0bacb90d",
|
||||
"0x47a61770f0771ba34d8e8ab883a3d588769a8d387eb5531b4befccb7ea23a6d3",
|
||||
"0xdc8d0b20e8d8b0fbce50d24eaa36bc56467f35459139dda5e42ffebb1060535c",
|
||||
"0x65bebb9628b5bf5d5e1dbedf00a7e6610fb5615c7ff9d92adaa135bc88f90648",
|
||||
"0x9d2f5b7858631ee196bc24d14d2ef1ce07af081d8fe27b2be70ab90bd8edf930",
|
||||
"0xd7724915af54b4d2c896d05c039f5ba508c878d524eb132c09c3abc22f6111ca",
|
||||
"0xfda6f72dde86c0b8f84ea7c1e157f1d207dd2e974589cc351404bd5a01fe1d9d",
|
||||
"0x3fae3676e266af80b0cc810b6b491750b64b013da78935a288b93e33215bee32"
|
||||
]
|
||||
},
|
||||
],
|
||||
};
|
||||
exports.testTransaction = {
|
||||
mainnet: [
|
||||
{
|
||||
test: "legacy",
|
||||
hash: "0xccc90ab97a74c952fb3376c4a3efb566a58a10df62eb4d44a61e106fcf10ec61",
|
||||
blockHash: "0x9653f180a5720f3634816eb945a6d722adee52cc47526f6357ac10adaf368135",
|
||||
blockNumber: 4097745,
|
||||
index: 18,
|
||||
type: 0,
|
||||
from: "0x32DEF047DeFd076DB21A2D759aff2A591c972248",
|
||||
gasPrice: BigInt("0x4a817c800"),
|
||||
gasLimit: BigInt("0x3d090"),
|
||||
to: "0x6fC21092DA55B392b045eD78F4732bff3C580e2c",
|
||||
value: BigInt("0x186cc6acd4b0000"),
|
||||
nonce: 0,
|
||||
data: "0xf2c298be000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000067269636d6f6f0000000000000000000000000000000000000000000000000000",
|
||||
signature: {
|
||||
r: "0x1e5605197a03e3f0a168f14749168dfeefc44c9228312dacbffdcbbb13263265",
|
||||
s: "0x269c3e5b3558267ad91b0a887d51f9f10098771c67b82ea6cb74f29638754f54",
|
||||
yParity: 1,
|
||||
v: 28,
|
||||
networkV: BigInt(38),
|
||||
},
|
||||
creates: null,
|
||||
chainId: BigInt(1)
|
||||
},
|
||||
{
|
||||
test: "EIP-1559",
|
||||
hash: "0x8ff41d0ba5d239acc8c123ff12451a2c15721c838f657e583d355999af4a4349",
|
||||
blockHash: '0x9d4c3bef68e119841281105da96beb1c7252f357340d7a3355236b3332b197b0',
|
||||
blockNumber: 12966000,
|
||||
index: 185,
|
||||
type: 2,
|
||||
from: '0x5afFBa12E9332bbc0E221c8E7BEf7CB7cfB3F281',
|
||||
to: '0x2258CcD34ae29E6B199b6CD64eb2aEF157df7CdE',
|
||||
gasLimit: BigInt("21000"),
|
||||
nonce: 2,
|
||||
data: '0x',
|
||||
value: BigInt("1100000000000000"),
|
||||
gasPrice: BigInt("70578812137"),
|
||||
maxPriorityFeePerGas: BigInt("1000000000"),
|
||||
maxFeePerGas: BigInt("131115411100"),
|
||||
chainId: BigInt(1),
|
||||
signature: {
|
||||
r: "0xdd26e5478d0aa84e334a0393d335ab24b83de8ecae9290305f15ab884ded246c",
|
||||
s: "0x6494b4f61b0d9a5a82ecb86d72b301f859f404f0bec9682bbfff619903ecfbe2",
|
||||
yParity: 1,
|
||||
v: 28,
|
||||
networkV: null
|
||||
},
|
||||
creates: null,
|
||||
accessList: []
|
||||
}
|
||||
],
|
||||
goerli: [],
|
||||
sepolia: [
|
||||
{
|
||||
test: "EIP-4844-BLOb-tx",
|
||||
hash: "0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
|
||||
blockHash: '0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d',
|
||||
blockNumber: 5198187,
|
||||
index: 24,
|
||||
type: 3,
|
||||
from: '0x1803c760451DC8da8935c7B7E47e1c60910E6986',
|
||||
to: '0x4f56fFC63c28b72F79b02E91F11a4707bac4043C',
|
||||
gasLimit: BigInt("21000"),
|
||||
nonce: 1635,
|
||||
data: '0x',
|
||||
value: BigInt("0"),
|
||||
gasPrice: BigInt("54793932840"),
|
||||
maxPriorityFeePerGas: BigInt("6000000000"),
|
||||
maxFeePerGas: BigInt("600000000000"),
|
||||
maxFeePerBlobGas: BigInt("60000000000"),
|
||||
chainId: BigInt(11155111),
|
||||
signature: {
|
||||
r: "0x56fc10a770e9fa39a30f71a56d13affbdc390a1bfb419ff806e59b54bfc8bab1",
|
||||
s: "0x35be8b0c774c179520dd43df46925361c4817472441d7dd5162d43efc90679f1",
|
||||
yParity: 1,
|
||||
networkV: null
|
||||
},
|
||||
creates: null,
|
||||
accessList: [],
|
||||
blobVersionedHashes: [
|
||||
"0x010264a7b018f0edbe5caa5cb309ca50d3d7c6c7c990d21bf30a7f18ffd06cd6",
|
||||
"0x017fe9ef61e3c501acec804ec15849d977433f4cf87050c098272dd1257f9c68",
|
||||
"0x019975416c9d7c70ba9cc041464a6e1c3e4f176bdab463573504b55c681364c8",
|
||||
"0x0123ae55ad7d8e8afec2202bdc6dfb931efc8990acf29afbd0c3c0ef61eae92d"
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
exports.testReceipt = {
|
||||
mainnet: [
|
||||
{
|
||||
test: "legacy",
|
||||
//byzantium: false,
|
||||
blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566",
|
||||
blockNumber: 0x3c92b5,
|
||||
type: 0,
|
||||
contractAddress: null,
|
||||
cumulativeGasUsed: BigInt(0x1cca2e),
|
||||
from: "0x18C6045651826824FEBBD39d8560584078d1b247",
|
||||
gasUsed: BigInt(0x14bb7),
|
||||
gasPrice: BigInt(4100000000),
|
||||
logs: [
|
||||
{
|
||||
address: "0x314159265dD8dbb310642f98f50C066173C1259b",
|
||||
blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566",
|
||||
blockNumber: 0x3c92b5,
|
||||
data: "0x00000000000000000000000018c6045651826824febbd39d8560584078d1b247",
|
||||
index: 0x1a,
|
||||
topics: [
|
||||
"0xce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e82",
|
||||
"0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae",
|
||||
"0xf0106919d12469348e14ad6a051d0656227e1aba2fefed41737fdf78421b20e1"
|
||||
],
|
||||
transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616",
|
||||
transactionIndex: 0x39,
|
||||
},
|
||||
{
|
||||
address: "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef",
|
||||
blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566",
|
||||
blockNumber: 0x3c92b5,
|
||||
data: "0x000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000595a32ce",
|
||||
index: 0x1b,
|
||||
topics: [
|
||||
"0x0f0c27adfd84b60b6f456b0e87cdccb1e5fb9603991588d87fa99f5b6b61e670",
|
||||
"0xf0106919d12469348e14ad6a051d0656227e1aba2fefed41737fdf78421b20e1",
|
||||
"0x00000000000000000000000018c6045651826824febbd39d8560584078d1b247"
|
||||
],
|
||||
transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616",
|
||||
transactionIndex: 0x39,
|
||||
}
|
||||
],
|
||||
logsBloom: "0x00000000000000040000000000100000010000000000000040000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000200000010000000004000000000000000000000000000000000002000000000000000000000000400000000020000000000000000000000000000000000000004000000000000000000000000000000000000000000000000801000000000000000000000020000000000040000000040000000000000000002000000004000000000000000000000000000000000000000000000010000000000000000000000000000000000200000000000000000",
|
||||
root: "0x9b550a9a640ce50331b64504ef87aaa7e2aaf97344acb6ff111f879b319d2590",
|
||||
// Should be null for pre-byzantium, but some nodes have backfilled it
|
||||
status: 1,
|
||||
to: "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef",
|
||||
hash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616",
|
||||
index: 0x39
|
||||
}, {
|
||||
test: "byzantium",
|
||||
//byzantium: true,
|
||||
blockHash: "0x34e5a6cfbdbb84f7625df1de69d218ade4da72f4a2558064a156674e72e976c9",
|
||||
blockNumber: 0x444f76,
|
||||
type: 0,
|
||||
contractAddress: null,
|
||||
cumulativeGasUsed: BigInt(0x15bfe7),
|
||||
from: "0x18C6045651826824FEBBD39d8560584078d1b247",
|
||||
gasUsed: BigInt(0x1b968),
|
||||
gasPrice: BigInt(1000000000),
|
||||
logs: [
|
||||
{
|
||||
address: "0xb90E64082D00437e65A76d4c8187596BC213480a",
|
||||
blockHash: "0x34e5a6cfbdbb84f7625df1de69d218ade4da72f4a2558064a156674e72e976c9",
|
||||
blockNumber: 0x444f76,
|
||||
data: "0x",
|
||||
index: 0x10,
|
||||
topics: [
|
||||
"0x748d071d1992ee1bfe7a39058114d0a50d5798fe8eb3a9bfb4687f024629a2ce",
|
||||
"0x5574aa58f7191ccab6de6cf75fe2ea0484f010b852fdd8c6b7ae151d6c2f4b83"
|
||||
],
|
||||
transactionHash: "0x7f1c6a58dc880438236d0b0a4ae166e9e9a038dbea8ec074149bd8b176332cac",
|
||||
transactionIndex: 0x1e,
|
||||
}
|
||||
],
|
||||
logsBloom: "0x00000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000200000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000800000000000000000800000000000000000000000000000000000000",
|
||||
root: null,
|
||||
status: 1,
|
||||
to: "0xb90E64082D00437e65A76d4c8187596BC213480a",
|
||||
hash: "0x7f1c6a58dc880438236d0b0a4ae166e9e9a038dbea8ec074149bd8b176332cac",
|
||||
index: 0x1e
|
||||
}
|
||||
],
|
||||
goerli: [],
|
||||
sepolia: [
|
||||
{
|
||||
test: "eip-4844-BLOb-receipt",
|
||||
//byzantium: true,
|
||||
blockHash: "0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d",
|
||||
blockNumber: 5198187,
|
||||
type: 3,
|
||||
contractAddress: null,
|
||||
cumulativeGasUsed: BigInt("930313"),
|
||||
from: "0x1803c760451DC8da8935c7B7E47e1c60910E6986",
|
||||
gasUsed: BigInt("21000"),
|
||||
gasPrice: BigInt("54793932840"),
|
||||
logs: [],
|
||||
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
root: null,
|
||||
status: 1,
|
||||
to: "0x4f56fFC63c28b72F79b02E91F11a4707bac4043C",
|
||||
hash: "0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
|
||||
index: 24,
|
||||
blobGasUsed: BigInt("524288"),
|
||||
blobGasPrice: BigInt("23276216517"),
|
||||
}
|
||||
]
|
||||
};
|
||||
exports.networkNames = [
|
||||
"mainnet", "goerli", "sepolia"
|
||||
];
|
||||
function networkFeatureAtBlock(feature, block) {
|
||||
switch (feature) {
|
||||
case "byzantium":
|
||||
return block >= 4370000;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
throw new Error(`unknown feature: ${feature}`);
|
||||
}
|
||||
exports.networkFeatureAtBlock = networkFeatureAtBlock;
|
||||
//# sourceMappingURL=blockchain-data.js.map
|
1
lib.commonjs/_tests/blockchain-data.js.map
Normal file
1
lib.commonjs/_tests/blockchain-data.js.map
Normal file
File diff suppressed because one or more lines are too long
8
lib.commonjs/_tests/create-provider.d.ts
vendored
Normal file
8
lib.commonjs/_tests/create-provider.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
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;
|
||||
//# sourceMappingURL=create-provider.d.ts.map
|
1
lib.commonjs/_tests/create-provider.d.ts.map
Normal file
1
lib.commonjs/_tests/create-provider.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkGpD,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED,eAAO,MAAM,aAAa,mBAAuD,CAAC;AAQlF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAInE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,CAgBtF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGxE;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAIzD"}
|
158
lib.commonjs/_tests/create-provider.js
Normal file
158
lib.commonjs/_tests/create-provider.js
Normal file
@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.connect = exports.checkProvider = exports.getProvider = exports.getProviderNetworks = exports.providerNames = exports.setupProviders = void 0;
|
||||
const index_js_1 = require("../index.js");
|
||||
;
|
||||
const ethNetworks = ["default", "mainnet", "sepolia"];
|
||||
//const maticNetworks = [ "matic", "maticmum" ];
|
||||
const ProviderCreators = [
|
||||
{
|
||||
name: "AlchemyProvider",
|
||||
networks: ethNetworks,
|
||||
create: function (network) {
|
||||
return new index_js_1.AlchemyProvider(network, "YrPw6SWb20vJDRFkhWq8aKnTQ8JRNRHM");
|
||||
}
|
||||
},
|
||||
/*
|
||||
{
|
||||
name: "AnkrProvider",
|
||||
networks: ethNetworks.concat([ "matic", "arbitrum" ]),
|
||||
create: function(network: string) {
|
||||
return new AnkrProvider(network);
|
||||
}
|
||||
},
|
||||
*/
|
||||
/*
|
||||
{
|
||||
name: "CloudflareProvider",
|
||||
networks: [ "default", "mainnet" ],
|
||||
create: function(network: string) {
|
||||
return new CloudflareProvider(network);
|
||||
}
|
||||
},
|
||||
*/
|
||||
{
|
||||
name: "ChainstackProvider",
|
||||
networks: ["default", "mainnet", "arbitrum", "bnb", "matic"],
|
||||
create: function (network) {
|
||||
return new index_js_1.ChainstackProvider(network);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "EtherscanProvider",
|
||||
networks: ethNetworks,
|
||||
create: function (network) {
|
||||
return new index_js_1.EtherscanProvider(network, "FPFGK6JSW2UHJJ2666FG93KP7WC999MNW7");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "InfuraProvider",
|
||||
networks: ethNetworks,
|
||||
create: function (network) {
|
||||
return new index_js_1.InfuraProvider(network, "49a0efa3aaee4fd99797bfa94d8ce2f1");
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "InfuraWebsocketProvider",
|
||||
networks: ethNetworks,
|
||||
create: function (network) {
|
||||
return index_js_1.InfuraProvider.getWebSocketProvider(network, "49a0efa3aaee4fd99797bfa94d8ce2f1");
|
||||
}
|
||||
},
|
||||
/*
|
||||
{
|
||||
name: "PocketProvider",
|
||||
networks: ethNetworks,
|
||||
create: function(network: string) {
|
||||
return new PocketProvider(network);
|
||||
}
|
||||
},
|
||||
*/
|
||||
{
|
||||
name: "QuickNodeProvider",
|
||||
networks: ethNetworks,
|
||||
create: function (network) {
|
||||
return new index_js_1.QuickNodeProvider(network);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "FallbackProvider",
|
||||
networks: ethNetworks,
|
||||
create: function (network) {
|
||||
const providers = [];
|
||||
for (const providerName of ["AlchemyProvider", "AnkrProvider", "EtherscanProvider", "InfuraProvider"]) {
|
||||
const provider = getProvider(providerName, network);
|
||||
if (provider) {
|
||||
providers.push(provider);
|
||||
}
|
||||
}
|
||||
if (providers.length === 0) {
|
||||
throw new Error("UNSUPPORTED NETWORK");
|
||||
}
|
||||
return new index_js_1.FallbackProvider(providers);
|
||||
}
|
||||
},
|
||||
];
|
||||
let setup = false;
|
||||
const cleanup = [];
|
||||
function setupProviders() {
|
||||
after(function () {
|
||||
for (const func of cleanup) {
|
||||
func();
|
||||
}
|
||||
});
|
||||
setup = true;
|
||||
}
|
||||
exports.setupProviders = setupProviders;
|
||||
exports.providerNames = Object.freeze(ProviderCreators.map((c) => (c.name)));
|
||||
function getCreator(provider) {
|
||||
const creators = ProviderCreators.filter((c) => (c.name === provider));
|
||||
if (creators.length === 1) {
|
||||
return creators[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getProviderNetworks(provider) {
|
||||
const creator = getCreator(provider);
|
||||
if (creator) {
|
||||
return creator.networks;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
exports.getProviderNetworks = getProviderNetworks;
|
||||
function getProvider(provider, network) {
|
||||
if (setup == false) {
|
||||
throw new Error("MUST CALL setupProviders in root context");
|
||||
}
|
||||
const creator = getCreator(provider);
|
||||
try {
|
||||
if (creator) {
|
||||
const provider = creator.create(network);
|
||||
if (provider) {
|
||||
cleanup.push(() => { provider.destroy(); });
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
if (!(0, index_js_1.isError)(error, "INVALID_ARGUMENT")) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.getProvider = getProvider;
|
||||
function checkProvider(provider, network) {
|
||||
const creator = getCreator(provider);
|
||||
return (creator != null && creator.networks.indexOf(network) >= 0);
|
||||
}
|
||||
exports.checkProvider = checkProvider;
|
||||
function connect(network) {
|
||||
const provider = getProvider("InfuraProvider", network);
|
||||
if (provider == null) {
|
||||
throw new Error(`could not connect to ${network}`);
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
exports.connect = connect;
|
||||
//# sourceMappingURL=create-provider.js.map
|
1
lib.commonjs/_tests/create-provider.js.map
Normal file
1
lib.commonjs/_tests/create-provider.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":";;;AAAA,0CAYqB;AAQpB,CAAC;AAEF,MAAM,WAAW,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAE,CAAC;AACxD,gDAAgD;AAEhD,MAAM,gBAAgB,GAA2B;IAC7C;QACI,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,0BAAe,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;QAC5E,CAAC;KACJ;IACD;;;;;;;;MAQE;IACF;;;;;;;;MAQE;IACF;QACI,IAAI,EAAE,oBAAoB;QAC1B,QAAQ,EAAE,CAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAE;QAC9D,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,6BAAkB,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;KACJ;IACD;QACI,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,4BAAiB,CAAC,OAAO,EAAE,oCAAoC,CAAC,CAAC;QAChF,CAAC;KACJ;IACD;QACI,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,yBAAc,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;QAC3E,CAAC;KACJ;IACD;QACI,IAAI,EAAE,yBAAyB;QAC/B,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,yBAAc,CAAC,oBAAoB,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;QAC5F,CAAC;KACJ;IACL;;;;;;;;MAQE;IACE;QACI,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,4BAAiB,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;KACJ;IACD;QACI,IAAI,EAAE,kBAAkB;QACxB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,MAAM,SAAS,GAA4B,EAAE,CAAC;YAC9C,KAAK,MAAM,YAAY,IAAI,CAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,CAAE,EAAE;gBACrG,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;gBACpD,IAAI,QAAQ,EAAE;oBAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;iBAAE;aAC9C;YACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;aAAE;YACvE,OAAO,IAAI,2BAAgB,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;KACJ;CACJ,CAAC;AAEF,IAAI,KAAK,GAAG,KAAK,CAAC;AAClB,MAAM,OAAO,GAAsB,EAAG,CAAC;AACvC,SAAgB,cAAc;IAC1B,KAAK,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YAAE,IAAI,EAAE,CAAC;SAAE;IAC3C,CAAC,CAAC,CAAC;IACH,KAAK,GAAG,IAAI,CAAC;AACjB,CAAC;AALD,wCAKC;AAEY,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAElF,SAAS,UAAU,CAAC,QAAgB;IAChC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;IACvE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;KAAE;IAClD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,mBAAmB,CAAC,QAAgB;IAChD,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,OAAO,EAAE;QAAE,OAAO,OAAO,CAAC,QAAQ,CAAC;KAAE;IACzC,OAAO,EAAG,CAAC;AACf,CAAC;AAJD,kDAIC;AAED,SAAgB,WAAW,CAAC,QAAgB,EAAE,OAAe;IACzD,IAAI,KAAK,IAAI,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAAE;IAEpF,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI;QACA,IAAI,OAAO,EAAE;YACT,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACzC,IAAI,QAAQ,EAAE;gBACV,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;aAC/C;YACD,OAAO,QAAQ,CAAC;SACnB;KACJ;IAAC,OAAO,KAAK,EAAE;QACZ,IAAI,CAAC,IAAA,kBAAO,EAAC,KAAK,EAAE,kBAAkB,CAAC,EAAE;YAAE,MAAM,KAAK,CAAC;SAAE;KAC5D;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAhBD,kCAgBC;AAED,SAAgB,aAAa,CAAC,QAAgB,EAAE,OAAe;IAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,CAAC,OAAO,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC;AAHD,sCAGC;AAED,SAAgB,OAAO,CAAC,OAAe;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,QAAQ,IAAI,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAyB,OAAQ,EAAE,CAAC,CAAC;KAAE;IAC/E,OAAO,QAAQ,CAAC;AACpB,CAAC;AAJD,0BAIC"}
|
21
lib.commonjs/_tests/index.d.ts
vendored
Normal file
21
lib.commonjs/_tests/index.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import "./test-abi.js";
|
||||
import "./test-address.js";
|
||||
import "./test-contract.js";
|
||||
import "./test-crypto.js";
|
||||
import "./test-hash.js";
|
||||
import "./test-hash-typeddata.js";
|
||||
import "./test-providers-avatar.js";
|
||||
import "./test-providers-ccip.js";
|
||||
import "./test-providers-wildcard.js";
|
||||
import "./test-rlp.js";
|
||||
import "./test-transaction.js";
|
||||
import "./test-utils-maths.js";
|
||||
import "./test-utils-misc.js";
|
||||
import "./test-utils-units.js";
|
||||
import "./test-utils-utf8.js";
|
||||
import "./test-wallet.js";
|
||||
import "./test-wallet-hd.js";
|
||||
import "./test-wallet-json.js";
|
||||
import "./test-wallet-mnemonic.js";
|
||||
import "./test-wordlists.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
lib.commonjs/_tests/index.d.ts.map
Normal file
1
lib.commonjs/_tests/index.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,mBAAmB,CAAA;AAC1B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,gBAAgB,CAAC;AACxB,OAAO,0BAA0B,CAAC;AAClC,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,8BAA8B,CAAC;AACtC,OAAO,eAAe,CAAA;AACtB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,2BAA2B,CAAC;AACnC,OAAO,qBAAqB,CAAC"}
|
31
lib.commonjs/_tests/index.js
Normal file
31
lib.commonjs/_tests/index.js
Normal file
@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("./test-abi.js");
|
||||
require("./test-address.js");
|
||||
require("./test-contract.js");
|
||||
require("./test-crypto.js");
|
||||
require("./test-hash.js");
|
||||
require("./test-hash-typeddata.js");
|
||||
require("./test-providers-avatar.js");
|
||||
require("./test-providers-ccip.js");
|
||||
require("./test-providers-wildcard.js");
|
||||
require("./test-rlp.js");
|
||||
require("./test-transaction.js");
|
||||
require("./test-utils-maths.js");
|
||||
require("./test-utils-misc.js");
|
||||
require("./test-utils-units.js");
|
||||
require("./test-utils-utf8.js");
|
||||
require("./test-wallet.js");
|
||||
require("./test-wallet-hd.js");
|
||||
require("./test-wallet-json.js");
|
||||
require("./test-wallet-mnemonic.js");
|
||||
require("./test-wordlists.js");
|
||||
////import "./test-contract-integ.js";
|
||||
////import "./test-providers-data.js";
|
||||
//import "./test-providers-errors.js";
|
||||
////import "./test-providers-extra.js";
|
||||
////import "./test-providers-send.js";
|
||||
/*
|
||||
test-crypto-algoswap.ts
|
||||
*/
|
||||
//# sourceMappingURL=index.js.map
|
1
lib.commonjs/_tests/index.js.map
Normal file
1
lib.commonjs/_tests/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/_tests/index.ts"],"names":[],"mappings":";;AAAA,yBAAuB;AACvB,6BAA0B;AAC1B,8BAA4B;AAC5B,4BAA0B;AAC1B,0BAAwB;AACxB,oCAAkC;AAClC,sCAAoC;AACpC,oCAAkC;AAClC,wCAAsC;AACtC,yBAAsB;AACtB,iCAA+B;AAC/B,iCAA+B;AAC/B,gCAA8B;AAC9B,iCAA+B;AAC/B,gCAA8B;AAC9B,4BAA0B;AAC1B,+BAA6B;AAC7B,iCAA+B;AAC/B,qCAAmC;AACnC,+BAA6B;AAE7B,sCAAsC;AAEtC,sCAAsC;AACtC,sCAAsC;AACtC,uCAAuC;AACvC,sCAAsC;AAEtC;;EAEE"}
|
2
lib.commonjs/_tests/test-abi.d.ts
vendored
Normal file
2
lib.commonjs/_tests/test-abi.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-abi.d.ts.map
|
1
lib.commonjs/_tests/test-abi.d.ts.map
Normal file
1
lib.commonjs/_tests/test-abi.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"test-abi.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-abi.ts"],"names":[],"mappings":""}
|
284
lib.commonjs/_tests/test-abi.js
Normal file
284
lib.commonjs/_tests/test-abi.js
Normal file
@ -0,0 +1,284 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const utils_js_1 = require("./utils.js");
|
||||
const index_js_1 = require("../index.js");
|
||||
function equal(actual, expected) {
|
||||
switch (expected.type) {
|
||||
case "address":
|
||||
case "boolean":
|
||||
case "hexstring":
|
||||
case "string":
|
||||
assert_1.default.equal(actual, expected.value);
|
||||
return;
|
||||
case "number":
|
||||
assert_1.default.equal(actual, BigInt(expected.value));
|
||||
return;
|
||||
case "array":
|
||||
case "object":
|
||||
assert_1.default.ok(Array.isArray(actual), "!array");
|
||||
assert_1.default.equal(actual.length, expected.value.length, ".length mismatch");
|
||||
for (let i = 0; i < actual.length; i++) {
|
||||
equal(actual[i], expected.value[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Error(`unsupported: ${expected}`);
|
||||
}
|
||||
describe("Tests ABI Coder", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("abi");
|
||||
for (const test of tests) {
|
||||
it(`tests ABI encoding: (${test.name})`, function () {
|
||||
const encoded = index_js_1.AbiCoder.defaultAbiCoder().encode([test.type], [test.value]);
|
||||
assert_1.default.equal(encoded, test.encoded, "encoded");
|
||||
});
|
||||
}
|
||||
for (const test of tests) {
|
||||
it(`tests ABI decoding: (${test.name})`, function () {
|
||||
const decoded = index_js_1.AbiCoder.defaultAbiCoder().decode([test.type], test.encoded)[0];
|
||||
equal(decoded, test.verbose);
|
||||
});
|
||||
}
|
||||
});
|
||||
describe("Test Bytes32 strings", function () {
|
||||
const tests = [
|
||||
{
|
||||
name: "ricmoo.firefly.eth",
|
||||
str: "ricmoo.firefly.eth",
|
||||
expected: '0x7269636d6f6f2e66697265666c792e6574680000000000000000000000000000'
|
||||
},
|
||||
{
|
||||
name: "empty string",
|
||||
str: "",
|
||||
expected: '0x0000000000000000000000000000000000000000000000000000000000000000'
|
||||
}
|
||||
];
|
||||
for (const { name, str, expected } of tests) {
|
||||
it(`encodes and decodes Bytes32 strings: ${name}`, function () {
|
||||
const bytes32 = (0, index_js_1.encodeBytes32String)(str);
|
||||
const decoded = (0, index_js_1.decodeBytes32String)(bytes32);
|
||||
assert_1.default.equal(bytes32, expected, 'formatted correctly');
|
||||
assert_1.default.equal(decoded, str, "parsed correctly");
|
||||
});
|
||||
}
|
||||
});
|
||||
describe("Test Interface", function () {
|
||||
const iface = new index_js_1.Interface([
|
||||
"function balanceOf(address owner) returns (uint)",
|
||||
"event Transfer(address indexed from, address indexed to, uint amount)",
|
||||
// #4244
|
||||
"event RedemptionRequested(bytes20 indexed walletPubKeyHash, bytes redeemerOutputScript, address indexed redeemer, uint64 requestedAmount, uint64 treasuryFee, uint64 txMaxFee)"
|
||||
]);
|
||||
it("does interface stuff; @TODO expand this", function () {
|
||||
const addr = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
|
||||
const addr2 = "0xAC1639CF97a3A46D431e6d1216f576622894cBB5";
|
||||
const data = iface.encodeFunctionData("balanceOf", [addr]);
|
||||
assert_1.default.equal(data, "0x70a082310000000000000000000000008ba1f109551bd432803012645ac136ddd64dba72", "encoded");
|
||||
const decoded = iface.decodeFunctionData("balanceOf", data);
|
||||
assert_1.default.equal(decoded.length, 1, "decoded.length");
|
||||
assert_1.default.equal(decoded[0], addr, "decoded[0]");
|
||||
const tx = iface.parseTransaction({ data, value: 10 });
|
||||
assert_1.default.ok(tx != null, "tx == null");
|
||||
assert_1.default.equal(tx.name, "balanceOf", "tx.balanceOf");
|
||||
assert_1.default.equal(tx.signature, "balanceOf(address)", "tx.balanceOf");
|
||||
assert_1.default.equal(tx.args.length, 1, "tx.args.length");
|
||||
assert_1.default.equal(tx.args[0], addr, "tx.args[0]");
|
||||
assert_1.default.equal(tx.selector, "0x70a08231", "tx.selector");
|
||||
assert_1.default.equal(tx.value, BigInt(10), "tx.value");
|
||||
const result = iface.encodeFunctionResult("balanceOf", [123]);
|
||||
assert_1.default.equal(result, "0x000000000000000000000000000000000000000000000000000000000000007b", "result");
|
||||
const value = iface.decodeFunctionResult("balanceOf", result);
|
||||
assert_1.default.equal(value.length, 1, "result.length");
|
||||
assert_1.default.equal(value[0], BigInt(123), "result.value[0]");
|
||||
// @TODO: parseResult
|
||||
const filter = iface.encodeFilterTopics("Transfer", [addr, addr2]);
|
||||
assert_1.default.equal(filter.length, 3);
|
||||
assert_1.default.equal(filter[0], "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef");
|
||||
assert_1.default.equal(filter[1], "0x0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba72");
|
||||
assert_1.default.equal(filter[2], "0x000000000000000000000000ac1639cf97a3a46d431e6d1216f576622894cbb5");
|
||||
// See: #4244
|
||||
// https://goerli.etherscan.io/tx/0xe61cef4cd706db8e23114717a207d76cc6b0df0b74ec52805551c4d1bf347a27#eventlog
|
||||
// See `RedemptionRequested` event.
|
||||
{
|
||||
const walletPubKeyHash = "0x03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e";
|
||||
const redeemer = "0x086813525A7dC7dafFf015Cdf03896Fd276eab60";
|
||||
const filterWithBytes20 = iface.encodeFilterTopics("RedemptionRequested", [walletPubKeyHash, undefined, redeemer]);
|
||||
assert_1.default.equal(filterWithBytes20.length, 3);
|
||||
assert_1.default.equal(filterWithBytes20[0], "0x97a0199072f487232635d50ab75860891afe0b91c976ed2fc76502c4d82d0d95");
|
||||
assert_1.default.equal(filterWithBytes20[1], "0x03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e000000000000000000000000");
|
||||
assert_1.default.equal(filterWithBytes20[2], "0x000000000000000000000000086813525a7dc7dafff015cdf03896fd276eab60");
|
||||
}
|
||||
const eventLog = iface.encodeEventLog("Transfer", [addr, addr2, 234]);
|
||||
assert_1.default.equal(eventLog.data, "0x00000000000000000000000000000000000000000000000000000000000000ea");
|
||||
assert_1.default.deepEqual(eventLog.topics, [
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
||||
"0x0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba72",
|
||||
"0x000000000000000000000000ac1639cf97a3a46d431e6d1216f576622894cbb5"
|
||||
]);
|
||||
const values = iface.decodeEventLog("Transfer", eventLog.data, eventLog.topics);
|
||||
assert_1.default.equal(values.length, 3);
|
||||
assert_1.default.equal(values[0], addr);
|
||||
assert_1.default.equal(values[1], addr2);
|
||||
assert_1.default.equal(values[2], BigInt(234));
|
||||
const log = iface.parseLog(eventLog);
|
||||
assert_1.default.ok(log != null);
|
||||
assert_1.default.equal(log.name, "Transfer");
|
||||
assert_1.default.equal(log.signature, "Transfer(address,address,uint256)");
|
||||
assert_1.default.equal(log.topic, "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef");
|
||||
assert_1.default.equal(log.args.length, 3);
|
||||
assert_1.default.equal(log.args[0], "0x8ba1f109551bD432803012645Ac136ddd64DBA72");
|
||||
assert_1.default.equal(log.args[1], "0xAC1639CF97a3A46D431e6d1216f576622894cBB5");
|
||||
assert_1.default.equal(log.args[2], BigInt(234));
|
||||
});
|
||||
// See #4248
|
||||
it("formats JSON ABI parameters with default empty string for `name` key", function () {
|
||||
assert_1.default.deepEqual(JSON.parse(iface.getFunction("balanceOf").format('json')), {
|
||||
constant: false,
|
||||
inputs: [
|
||||
{ name: "owner", type: "address" }
|
||||
],
|
||||
name: "balanceOf",
|
||||
outputs: [
|
||||
{ name: "", type: "uint256" }
|
||||
],
|
||||
payable: false,
|
||||
type: "function",
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("Tests Legacy ABI formats", function () {
|
||||
// See: #3932
|
||||
const iface = new index_js_1.Interface([
|
||||
{
|
||||
name: "implicitView",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"constant": true,
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "implicitSendNonpay",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"constant": false,
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "implicitSendPay",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"constant": false,
|
||||
"payable": true,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "implicitSendImplicitPay",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"constant": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "implicitSendExplicitPay",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
payable: true,
|
||||
type: "function"
|
||||
},
|
||||
{
|
||||
name: "implicitSendExplicitNonpay",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
payable: false,
|
||||
type: "function"
|
||||
},
|
||||
{
|
||||
name: "implicitAll",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "explicitView",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"constant": true,
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "explicitPure",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"constant": true,
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "explicitPay",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"stateMutability": "payable",
|
||||
"constant": true,
|
||||
"payable": true,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
name: "explicitNonpay",
|
||||
outputs: [],
|
||||
inputs: [
|
||||
{ type: "int128", name: "arg0" }
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"constant": true,
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
]);
|
||||
function test(name, isConst, payable, stateMutability) {
|
||||
it(`tests ABI configuration: ${name}`, function () {
|
||||
const f = iface.getFunction(name);
|
||||
assert_1.default.ok(!!f, `missing ${name}`);
|
||||
assert_1.default.equal(f.constant, isConst, `${name}.constant`);
|
||||
assert_1.default.equal(f.stateMutability, stateMutability, `${name}.stateMutability`);
|
||||
assert_1.default.equal(f.payable, payable, `${name}.payable`);
|
||||
});
|
||||
}
|
||||
test("explicitView", true, false, "view");
|
||||
test("explicitPure", true, false, "pure");
|
||||
test("explicitPay", false, true, "payable");
|
||||
test("explicitNonpay", false, false, "nonpayable");
|
||||
test("implicitView", true, false, "view");
|
||||
test("implicitSendNonpay", false, false, "nonpayable");
|
||||
test("implicitSendPay", false, true, "payable");
|
||||
test("implicitSendImplicitPay", false, true, "payable");
|
||||
test("implicitSendExplicitPay", false, true, "payable");
|
||||
test("implicitSendExplicitNonpay", false, false, "nonpayable");
|
||||
test("implicitAll", false, true, "payable");
|
||||
});
|
||||
//# sourceMappingURL=test-abi.js.map
|
1
lib.commonjs/_tests/test-abi.js.map
Normal file
1
lib.commonjs/_tests/test-abi.js.map
Normal file
File diff suppressed because one or more lines are too long
2
lib.commonjs/_tests/test-address.d.ts
vendored
Normal file
2
lib.commonjs/_tests/test-address.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-address.d.ts.map
|
1
lib.commonjs/_tests/test-address.d.ts.map
Normal file
1
lib.commonjs/_tests/test-address.d.ts.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"test-address.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-address.ts"],"names":[],"mappings":""}
|
113
lib.commonjs/_tests/test-address.js
Normal file
113
lib.commonjs/_tests/test-address.js
Normal file
@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const utils_js_1 = require("./utils.js");
|
||||
const index_js_1 = require("../index.js");
|
||||
describe("computes checksum address", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("accounts");
|
||||
for (const test of tests) {
|
||||
it(`computes the checksum address: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_1.getAddress)(test.address), test.address);
|
||||
assert_1.default.equal((0, index_js_1.getAddress)(test.icap), test.address);
|
||||
assert_1.default.equal((0, index_js_1.getAddress)(test.address.substring(2)), test.address);
|
||||
assert_1.default.equal((0, index_js_1.getAddress)(test.address.toLowerCase()), test.address);
|
||||
assert_1.default.equal((0, index_js_1.getAddress)("0x" + test.address.substring(2).toUpperCase()), test.address);
|
||||
});
|
||||
}
|
||||
const invalidAddresses = [
|
||||
{ name: "null", value: null },
|
||||
{ name: "number", value: 1234 },
|
||||
{ name: "emtpy bytes", value: "0x" },
|
||||
{ name: "too short", value: "0x8ba1f109551bd432803012645ac136ddd64dba" },
|
||||
{ name: "too long", value: "0x8ba1f109551bd432803012645ac136ddd64dba7200" },
|
||||
];
|
||||
invalidAddresses.forEach(({ name, value }) => {
|
||||
it(`correctly fails on invalid address: ${name}`, function () {
|
||||
assert_1.default.throws(function () {
|
||||
(0, index_js_1.getAddress)(value);
|
||||
}, function (error) {
|
||||
return (error.code === "INVALID_ARGUMENT" &&
|
||||
error.message.match(/^invalid address/) &&
|
||||
error.argument === "address" &&
|
||||
error.value === value);
|
||||
});
|
||||
});
|
||||
});
|
||||
it("correctly fails on invalid checksum", function () {
|
||||
const value = "0x8ba1f109551bD432803012645Ac136ddd64DBa72";
|
||||
assert_1.default.throws(function () {
|
||||
(0, index_js_1.getAddress)(value);
|
||||
}, function (error) {
|
||||
return (error.code === "INVALID_ARGUMENT" &&
|
||||
error.message.match(/^bad address checksum/) &&
|
||||
error.argument === "address" &&
|
||||
error.value === value);
|
||||
});
|
||||
});
|
||||
it("correctly fails on invalid IBAN checksum", function () {
|
||||
const value = "XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37";
|
||||
assert_1.default.throws(function () {
|
||||
(0, index_js_1.getAddress)(value);
|
||||
}, function (error) {
|
||||
return (error.code === "INVALID_ARGUMENT" &&
|
||||
error.message.match(/^bad icap checksum/) &&
|
||||
error.argument === "address" &&
|
||||
error.value === value);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("computes ICAP address", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("accounts");
|
||||
for (const test of tests) {
|
||||
it(`computes the ICAP address: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_1.getIcapAddress)(test.address), test.icap);
|
||||
assert_1.default.equal((0, index_js_1.getAddress)(test.address.toLowerCase()), test.address);
|
||||
assert_1.default.equal((0, index_js_1.getAddress)("0x" + test.address.substring(2).toUpperCase()), test.address);
|
||||
});
|
||||
}
|
||||
});
|
||||
describe("computes create address", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("create");
|
||||
for (const { sender, creates } of tests) {
|
||||
for (const { name, nonce, address } of creates) {
|
||||
it(`computes the create address: ${name}`, function () {
|
||||
assert_1.default.equal((0, index_js_1.getCreateAddress)({ from: sender, nonce }), address);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
describe("computes create2 address", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("create2");
|
||||
for (const { sender, creates } of tests) {
|
||||
for (const { name, salt, initCodeHash, address } of creates) {
|
||||
it(`computes the create2 address: ${name}`, function () {
|
||||
assert_1.default.equal((0, index_js_1.getCreate2Address)(sender, salt, initCodeHash), address);
|
||||
});
|
||||
}
|
||||
}
|
||||
const sender = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
|
||||
const salt = "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8";
|
||||
const initCodeHash = "0x8452c9b9140222b08593a26daa782707297be9f7b3e8281d7b4974769f19afd0";
|
||||
it("correctly fails on invalid salt", function () {
|
||||
const badSalt = "0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36dea";
|
||||
assert_1.default.throws(function () {
|
||||
(0, index_js_1.getCreate2Address)(sender, badSalt, initCodeHash);
|
||||
}, function (error) {
|
||||
return (error.code === "INVALID_ARGUMENT" &&
|
||||
error.argument === "salt" &&
|
||||
error.value === badSalt);
|
||||
});
|
||||
});
|
||||
it("correctly fails on invalid initCodeHash", function () {
|
||||
const badInitCodeHash = "0x8452c9b9140222b08593a26daa782707297be9f7b3e8281d7b4974769f19af";
|
||||
assert_1.default.throws(function () {
|
||||
(0, index_js_1.getCreate2Address)(sender, salt, badInitCodeHash);
|
||||
}, function (error) {
|
||||
return (error.code === "INVALID_ARGUMENT" &&
|
||||
error.argument === "initCodeHash" &&
|
||||
error.value === badInitCodeHash);
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=test-address.js.map
|
1
lib.commonjs/_tests/test-address.js.map
Normal file
1
lib.commonjs/_tests/test-address.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"test-address.js","sourceRoot":"","sources":["../../src.ts/_tests/test-address.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,yCAAuC;AAQvC,0CAGqB;AAGrB,QAAQ,CAAC,2BAA2B,EAAE;IAClC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAkB,UAAU,CAAC,CAAC;IACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,EAAE,CAAC,kCAAmC,IAAI,CAAC,IAAK,EAAE,EAAE;YAChD,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACrD,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAClD,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAClE,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACnE,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3F,CAAC,CAAC,CAAC;KACN;IAED,MAAM,gBAAgB,GAAwC;QAC1D,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE;QAC7B,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;QAC/B,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE;QACpC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,0CAA0C,EAAE;QACxE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,8CAA8C,EAAE;KAC9E,CAAC;IAEF,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;QACzC,EAAE,CAAC,uCAAwC,IAAK,EAAE,EAAE;YAChD,gBAAM,CAAC,MAAM,CAAC;gBACV,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAC;YACtB,CAAC,EAAE,UAAS,KAAU;gBAClB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB;oBACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC;oBACvC,KAAK,CAAC,QAAQ,KAAK,SAAS;oBAC5B,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;YAC/B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE;QACtC,MAAM,KAAK,GAAG,4CAA4C,CAAA;QAC1D,gBAAM,CAAC,MAAM,CAAC;YACV,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAC;QACtB,CAAC,EAAE,UAAS,KAAU;YAClB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB;gBACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC;gBAC5C,KAAK,CAAC,QAAQ,KAAK,SAAS;gBAC5B,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE;QAC3C,MAAM,KAAK,GAAG,qCAAqC,CAAC;QACpD,gBAAM,CAAC,MAAM,CAAC;YACV,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAC;QACtB,CAAC,EAAE,UAAS,KAAU;YAClB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB;gBACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC;gBACzC,KAAK,CAAC,QAAQ,KAAK,SAAS;gBAC5B,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,uBAAuB,EAAE;IAC9B,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAkB,UAAU,CAAC,CAAC;IACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,EAAE,CAAC,8BAA+B,IAAI,CAAC,IAAK,EAAE,EAAE;YAC5C,gBAAM,CAAC,KAAK,CAAC,IAAA,yBAAc,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACtD,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACnE,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3F,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,yBAAyB,EAAE;IAChC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAiB,QAAQ,CAAC,CAAC;IAClD,KAAK,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,KAAK,EAAE;QACrC,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE;YAC5C,EAAE,CAAC,gCAAiC,IAAK,EAAE,EAAE;gBACzC,gBAAM,CAAC,KAAK,CAAC,IAAA,2BAAgB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;YACrE,CAAC,CAAC,CAAC;SACN;KACJ;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,0BAA0B,EAAE;IACjC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAkB,SAAS,CAAC,CAAC;IACpD,KAAK,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,KAAK,EAAE;QACrC,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE;YACzD,EAAE,CAAC,iCAAkC,IAAK,EAAE,EAAE;gBAC1C,gBAAM,CAAC,KAAK,CAAC,IAAA,4BAAiB,EAAC,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;YACzE,CAAC,CAAC,CAAC;SACN;KACJ;IAED,MAAM,MAAM,GAAG,4CAA4C,CAAC;IAC5D,MAAM,IAAI,GAAG,oEAAoE,CAAC;IAClF,MAAM,YAAY,GAAG,oEAAoE,CAAC;IAE1F,EAAE,CAAC,iCAAiC,EAAE;QAClC,MAAM,OAAO,GAAG,kEAAkE,CAAC;QACnF,gBAAM,CAAC,MAAM,CAAC;YACV,IAAA,4BAAiB,EAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACrD,CAAC,EAAE,UAAS,KAAU;YAClB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB;gBACrC,KAAK,CAAC,QAAQ,KAAK,MAAM;gBACzB,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE;QAC1C,MAAM,eAAe,GAAG,kEAAkE,CAAC;QAC3F,gBAAM,CAAC,MAAM,CAAC;YACV,IAAA,4BAAiB,EAAC,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;QACrD,CAAC,EAAE,UAAS,KAAU;YAClB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB;gBACrC,KAAK,CAAC,QAAQ,KAAK,cAAc;gBACjC,KAAK,CAAC,KAAK,KAAK,eAAe,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user