Compare commits
No commits in common. "main" and "v6-beta-old" have entirely different histories.
main
...
v6-beta-ol
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@ -1,2 +0,0 @@
|
||||
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
81
.github/ISSUE_TEMPLATE/bug-report-legacy.yml
vendored
@ -1,81 +0,0 @@
|
||||
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
81
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
@ -1,81 +0,0 @@
|
||||
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
1
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1 +0,0 @@
|
||||
blank_issues_enabled: false
|
23
.github/ISSUE_TEMPLATE/documentation.yml
vendored
23
.github/ISSUE_TEMPLATE/documentation.yml
vendored
@ -1,23 +0,0 @@
|
||||
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
26
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@ -1,26 +0,0 @@
|
||||
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
48
.github/workflows/generate-docs.yml
vendored
@ -1,48 +0,0 @@
|
||||
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 }}
|
76
.github/workflows/nodejs.yml
vendored
Normal file
76
.github/workflows/nodejs.yml
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
name: Node.js CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v6-beta
|
||||
|
||||
jobs:
|
||||
test-node:
|
||||
|
||||
name: Run All Tests (node.js)
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [ 14.x, 16.x, 18.x ]
|
||||
|
||||
steps:
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies (and link per package)
|
||||
run: npm ci
|
||||
|
||||
- name: Build JavaScript (from TypeScript)
|
||||
run: npm run build && npm run build-dist
|
||||
|
||||
- name: Run tests
|
||||
run: npm run test
|
||||
|
||||
coverage:
|
||||
|
||||
name: Generate Coverage Report
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14.x
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies (and link per package)
|
||||
run: npm ci
|
||||
|
||||
- name: Build JavaScript (from TypeScript)
|
||||
run: npm run build && npm run build-dist
|
||||
|
||||
- name: Run tests with coverage output
|
||||
run: npm run test-coverage
|
||||
|
||||
- name: Upload coverage summary
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: coverage-summary
|
||||
path: ./output/summary.txt
|
||||
|
||||
- name: Tarball files
|
||||
run: tar -cvf ./output/coverage.tar ./output/lcov-report/
|
||||
|
||||
- name: Upload coverage
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: coverage-complete
|
||||
path: ./output/coverage.tar
|
46
.github/workflows/test-browser.yml
vendored
46
.github/workflows/test-browser.yml
vendored
@ -1,46 +0,0 @@
|
||||
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
109
.github/workflows/test-ci.yml
vendored
@ -1,109 +0,0 @@
|
||||
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
86
.github/workflows/test-env.yml
vendored
@ -1,86 +0,0 @@
|
||||
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
|
||||
|
30
.gitignore
vendored
30
.gitignore
vendored
@ -1,7 +1,27 @@
|
||||
node_modules/**
|
||||
# Normal things to ignore; temporary files, libs, monorepo goop
|
||||
node_modules/
|
||||
packages/*/node_modules
|
||||
.package_node_modules/
|
||||
.DS_Store
|
||||
.tmp/
|
||||
**/*.swp
|
||||
*~
|
||||
|
||||
# A random stash folder I use for code I'm not quite willing
|
||||
# to part ways with yet
|
||||
obsolete/
|
||||
|
||||
# Intermediate files tsc generates for references (sometimes)
|
||||
**/src.ts/*.js
|
||||
|
||||
# TypeScript build caches
|
||||
packages/*/tsconfig.tsbuildinfo
|
||||
|
||||
# Coverage and Testing output
|
||||
output/**
|
||||
|
||||
**/*.save
|
||||
**/*.swp
|
||||
**/*.tgz
|
||||
dist/*.gz
|
||||
# Issue tests
|
||||
misc/testing/**
|
||||
|
||||
# Temp
|
||||
#packages/*/lib/
|
||||
|
31
.npmignore
31
.npmignore
@ -1,31 +0,0 @@
|
||||
|
||||
# Ignore TypeScript config and caches
|
||||
tsconfig.*.json
|
||||
tsconfig.tsbuildinfo
|
||||
rollup.config.js
|
||||
output/**
|
||||
docs.wrm/**
|
||||
.github/**
|
||||
|
||||
# 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
|
||||
|
||||
# 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
1
.npmrc
@ -1 +0,0 @@
|
||||
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/
|
339
CHANGELOG.md
339
CHANGELOG.md
@ -1,339 +0,0 @@
|
||||
Change Log
|
||||
==========
|
||||
|
||||
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)
|
||||
---------------------------------
|
||||
|
||||
- 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)
|
||||
---------------------------------
|
||||
|
||||
- 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/v6.11.0 (2024-02-08 20:26)
|
||||
---------------------------------
|
||||
|
||||
- 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/v6.10.0 (2024-01-12 19:46)
|
||||
---------------------------------
|
||||
|
||||
- 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/v6.9.2 (2024-01-02 19:12)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.9.1 (2023-12-19 04:53)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.9.0 (2023-11-27 06:15)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.8.1 (2023-11-01 16:08)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.8.0 (2023-10-10 22:42)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.7.1 (2023-08-15 03:08)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.7.0 (2023-08-02 23:52)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.6.7 (2023-07-28 14:50)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.6.6 (2023-07-28 01:14)
|
||||
--------------------------------
|
||||
|
||||
- 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/v6.6.5 (2023-07-24 00:04)
|
||||
--------------------------------
|
||||
|
||||
- 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,7 +0,0 @@
|
||||
{
|
||||
"drips": {
|
||||
"ethereum": {
|
||||
"ownedBy": "0x89EdE5cBE53473A64d6C8DF14176a0d658dAAeDC"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2023 Richard Moore
|
||||
Copyright (c) 2022 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
|
||||
|
139
README.md
139
README.md
@ -1,140 +1,13 @@
|
||||
The Ethers Project
|
||||
==================
|
||||
Ethers - v6 beta
|
||||
================
|
||||
|
||||
[![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)
|
||||
This is VERY beta, but I want to start getting it into the hands
|
||||
of people to try out.
|
||||
|
||||
-----
|
||||
|
||||
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 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), [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
|
||||
- **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 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 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
|
||||
----------
|
||||
|
||||
**NodeJS**
|
||||
|
||||
```
|
||||
/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>
|
||||
```
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Browse the [documentation](https://docs.ethers.org) online:
|
||||
|
||||
- [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/)
|
||||
|
||||
|
||||
|
||||
Providers
|
||||
---------
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
This will be updated soon with some examples.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT License (including **all** dependencies).
|
||||
|
||||
MIT Licensed (including all dependencies)
|
||||
|
34
SECURITY.md
34
SECURITY.md
@ -1,34 +0,0 @@
|
||||
# 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.
|
79
bootstrap-hoist.js
vendored
Normal file
79
bootstrap-hoist.js
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = require("path");
|
||||
const root = path_1.resolve(".");
|
||||
function loadJson(path) {
|
||||
return JSON.parse(fs_1.default.readFileSync(path).toString());
|
||||
}
|
||||
function atomicWrite(path, value) {
|
||||
const tmp = path_1.resolve(root, ".atomic-tmp");
|
||||
fs_1.default.writeFileSync(tmp, value);
|
||||
fs_1.default.renameSync(tmp, path);
|
||||
}
|
||||
function saveJson(filename, data, sort) {
|
||||
let replacer = undefined;
|
||||
if (sort) {
|
||||
replacer = (key, value) => {
|
||||
if (Array.isArray(value)) {
|
||||
// pass
|
||||
}
|
||||
else if (value && typeof (value) === "object") {
|
||||
const keys = Object.keys(value);
|
||||
keys.sort();
|
||||
return keys.reduce((accum, key) => {
|
||||
accum[key] = value[key];
|
||||
return accum;
|
||||
}, {});
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
atomicWrite(filename, JSON.stringify(data, replacer, 2) + "\n");
|
||||
}
|
||||
(function () {
|
||||
const filename = path_1.resolve(root, "package.json");
|
||||
const pkg = loadJson(filename);
|
||||
const packageFolder = (pkg.reticulate || {}).pacakges || "packages";
|
||||
{
|
||||
// @TODO: Check within root
|
||||
}
|
||||
const pkgs = fs_1.default.readdirSync(packageFolder).reduce((accum, folder) => {
|
||||
const pkg = loadJson(path_1.resolve(root, packageFolder, folder, "package.json"));
|
||||
if (accum[pkg.name]) {
|
||||
throw new Error(`duplicate package named ${pkg.name}`);
|
||||
}
|
||||
accum[pkg.name] = pkg.dependencies || {};
|
||||
return accum;
|
||||
}, {});
|
||||
const result = {};
|
||||
Object.keys(pkgs).forEach((name) => {
|
||||
const versions = pkgs[name];
|
||||
for (const dep in versions) {
|
||||
// This package is managed by this monorepo
|
||||
if (dep in pkgs) {
|
||||
continue;
|
||||
}
|
||||
// The required dependency version
|
||||
const ver = versions[dep];
|
||||
// This already exists in the result...
|
||||
const existing = result[dep];
|
||||
if (existing) {
|
||||
// ...but doesn't match
|
||||
if (existing !== ver) {
|
||||
throw new Error(`package dependency version mismatch: ${dep}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result[dep] = ver;
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log(`Hoisting ${Object.keys(result).length} dependencies from ${packageFolder}/*/package.json...\n`);
|
||||
pkg.dependencies = result;
|
||||
saveJson(filename, pkg, true);
|
||||
})();
|
||||
//# sourceMappingURL=bootstrap-hoist.js.map
|
22
dist/README.md
vendored
22
dist/README.md
vendored
@ -1,22 +0,0 @@
|
||||
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`.
|
25628
dist/ethers.js
vendored
25628
dist/ethers.js
vendored
File diff suppressed because one or more lines are too long
1
dist/ethers.js.map
vendored
1
dist/ethers.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/ethers.min.js
vendored
1
dist/ethers.min.js
vendored
File diff suppressed because one or more lines are too long
25825
dist/ethers.umd.js
vendored
25825
dist/ethers.umd.js
vendored
File diff suppressed because one or more lines are too long
1
dist/ethers.umd.js.map
vendored
1
dist/ethers.umd.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/ethers.umd.min.js
vendored
1
dist/ethers.umd.min.js
vendored
File diff suppressed because one or more lines are too long
1540
dist/wordlists-extra.js
vendored
1540
dist/wordlists-extra.js
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlists-extra.js.map
vendored
1
dist/wordlists-extra.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/wordlists-extra.min.js
vendored
1
dist/wordlists-extra.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,5 +0,0 @@
|
||||
Documentation Source
|
||||
====================
|
||||
|
||||
This folder contains all the Flatworm source for the documentation.
|
||||
|
@ -1,97 +0,0 @@
|
||||
_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.
|
@ -1,8 +0,0 @@
|
||||
_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)
|
@ -1,86 +0,0 @@
|
||||
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"
|
||||
]
|
||||
};
|
@ -1,123 +0,0 @@
|
||||
_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
|
||||
|
@ -1,66 +0,0 @@
|
||||
_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"));
|
||||
})();
|
@ -1,7 +0,0 @@
|
||||
_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)
|
@ -1,36 +0,0 @@
|
||||
_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();
|
||||
});
|
||||
|
@ -1,273 +0,0 @@
|
||||
_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...//
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB |
@ -1,505 +0,0 @@
|
||||
_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.
|
||||
|
@ -1,28 +0,0 @@
|
||||
_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)
|
@ -1,26 +0,0 @@
|
||||
_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.
|
@ -1,8 +0,0 @@
|
||||
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)
|
@ -1,5 +0,0 @@
|
||||
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)
|
@ -1,50 +0,0 @@
|
||||
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)
|
@ -1,21 +0,0 @@
|
||||
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);
|
||||
|
@ -1,54 +0,0 @@
|
||||
# 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)
|
||||
|
@ -1,29 +0,0 @@
|
||||
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
1782
docs.wrm/logo.ai
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
<?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>
|
Before Width: | Height: | Size: 853 B |
@ -1,418 +0,0 @@
|
||||
_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``.
|
Binary file not shown.
Before Width: | Height: | Size: 43 KiB |
@ -1,16 +0,0 @@
|
||||
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
95
lib.commonjs/_tests/blockchain-data.d.ts
vendored
@ -1,95 +0,0 @@
|
||||
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 +0,0 @@
|
||||
{"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,WA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E,KAAK,CAAC,qBAAqB,CAErD,CAAC;AACF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQ7E"}
|
@ -1,406 +0,0 @@
|
||||
"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
|
File diff suppressed because one or more lines are too long
8
lib.commonjs/_tests/create-provider.d.ts
vendored
8
lib.commonjs/_tests/create-provider.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
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 +0,0 @@
|
||||
{"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"}
|
@ -1,158 +0,0 @@
|
||||
"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 +0,0 @@
|
||||
{"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,E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BD,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
21
lib.commonjs/_tests/index.d.ts
vendored
@ -1,21 +0,0 @@
|
||||
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 +0,0 @@
|
||||
{"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"}
|
@ -1,31 +0,0 @@
|
||||
"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 +0,0 @@
|
||||
{"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"}
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-abi.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-abi.ts"],"names":[],"mappings":""}
|
@ -1,284 +0,0 @@
|
||||
"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
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-address.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-address.ts"],"names":[],"mappings":""}
|
@ -1,113 +0,0 @@
|
||||
"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 +0,0 @@
|
||||
{"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,CAA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commonjs/_tests/test-contract-integ.d.ts
vendored
2
lib.commonjs/_tests/test-contract-integ.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-contract-integ.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-contract-integ.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-contract-integ.ts"],"names":[],"mappings":""}
|
@ -1,78 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const index_js_1 = require("../index.js");
|
||||
describe("Tests contract integration", function () {
|
||||
const provider = new index_js_1.ethers.JsonRpcProvider("http:/\/127.0.0.1:8545");
|
||||
const abi = [
|
||||
"constructor(address owner, uint maxSupply)",
|
||||
"function mint(address target) returns (bool minted)",
|
||||
"function totalSupply() view returns (uint supply)",
|
||||
"function balanceOf(address target) view returns (uint balance)",
|
||||
"event Minted(address target)"
|
||||
];
|
||||
let address = null;
|
||||
it("deploys a contract", async function () {
|
||||
this.timeout(10000);
|
||||
const bytecode = "0x60c060405234801561001057600080fd5b506040516105863803806105868339818101604052810190610032919061010e565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508060a08181525050505061014e565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a58261007a565b9050919050565b6100b58161009a565b81146100c057600080fd5b50565b6000815190506100d2816100ac565b92915050565b6000819050919050565b6100eb816100d8565b81146100f657600080fd5b50565b600081519050610108816100e2565b92915050565b6000806040838503121561012557610124610075565b5b6000610133858286016100c3565b9250506020610144858286016100f9565b9150509250929050565b60805160a051610414610172600039600060fa0152600061021f01526104146000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806318160ddd146100515780636a6278421461006f57806370a082311461009f5780638da5cb5b146100cf575b600080fd5b6100596100ed565b604051610066919061025c565b60405180910390f35b610089600480360381019061008491906102da565b6100f6565b6040516100969190610322565b60405180910390f35b6100b960048036038101906100b491906102da565b6101d2565b6040516100c6919061025c565b60405180910390f35b6100d761021b565b6040516100e4919061034c565b60405180910390f35b60008054905090565b60007f00000000000000000000000000000000000000000000000000000000000000006000541061012657600080fd5b600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061017690610396565b919050555060008081548092919061018d90610396565b91905055507f90ddedd5a25821bba11fbb98de02ec1f75c1be90ae147d6450ce873e7b78b5d8826040516101c1919061034c565b60405180910390a160019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60007f0000000000000000000000000000000000000000000000000000000000000000905090565b6000819050919050565b61025681610243565b82525050565b6000602082019050610271600083018461024d565b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102a78261027c565b9050919050565b6102b78161029c565b81146102c257600080fd5b50565b6000813590506102d4816102ae565b92915050565b6000602082840312156102f0576102ef610277565b5b60006102fe848285016102c5565b91505092915050565b60008115159050919050565b61031c81610307565b82525050565b60006020820190506103376000830184610313565b92915050565b6103468161029c565b82525050565b6000602082019050610361600083018461033d565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006103a182610243565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036103d3576103d2610367565b5b60018201905091905056fea26469706673582212200a979ea2bfdf429b5546fa25906c9d20a3d67ef5fbe531f31d2cc83533e3239564736f6c63430008120033";
|
||||
const signer = await provider.getSigner(0);
|
||||
const factory = new index_js_1.ethers.ContractFactory(abi, bytecode, signer);
|
||||
const contract = await factory.deploy(signer, 100);
|
||||
address = await contract.getAddress();
|
||||
await contract.waitForDeployment();
|
||||
const deployed = await provider.getCode(address);
|
||||
assert_1.default.ok(deployed != "0x", "has bytescode");
|
||||
});
|
||||
it("runs contract operations", async function () {
|
||||
this.timeout(10000);
|
||||
assert_1.default.ok(address != null);
|
||||
const signer = await provider.getSigner(0);
|
||||
const CustomContract = index_js_1.ethers.BaseContract.buildClass(abi);
|
||||
const contract = new CustomContract(address, signer); //ethers.Contract.from<ContractAbi>(address, abi, signer);
|
||||
// Test implicit staticCall (i.e. view/pure)
|
||||
{
|
||||
const supply0 = await contract.totalSupply();
|
||||
assert_1.default.equal(supply0, BigInt(0), "initial supply 0; default");
|
||||
}
|
||||
// Test explicit staticCall
|
||||
{
|
||||
const supply0 = await contract.totalSupply.staticCall();
|
||||
assert_1.default.equal(supply0, BigInt(0), "initial supply 0; staticCall");
|
||||
}
|
||||
// Test staticCallResult (positional and named)
|
||||
{
|
||||
const supply0 = await contract.totalSupply.staticCallResult();
|
||||
assert_1.default.equal(supply0[0], BigInt(0), "initial supply 0; staticCallResult");
|
||||
assert_1.default.equal(supply0.supply, BigInt(0), "initial supply 0; staticCallResult");
|
||||
}
|
||||
// Test populateTransaction
|
||||
const txInfo = await contract.mint.populateTransaction(signer);
|
||||
assert_1.default.equal(txInfo.to, address, "populateTransaction.to");
|
||||
const txInfoData = index_js_1.ethers.hexlify(index_js_1.ethers.concat([
|
||||
"0x6a627842",
|
||||
index_js_1.ethers.zeroPadValue(await signer.getAddress(), 32)
|
||||
]));
|
||||
assert_1.default.equal(txInfo.data, txInfoData, "populateTransaction.data");
|
||||
// Test minting (default)
|
||||
const tx = await contract.mint(signer);
|
||||
const receipt = await tx.wait();
|
||||
assert_1.default.ok(receipt, "receipt");
|
||||
// Check the receipt has parsed the events
|
||||
assert_1.default.equal(receipt.logs.length, 1, "logs.length");
|
||||
assert_1.default.ok(receipt instanceof index_js_1.ethers.ContractTransactionReceipt, "receipt typeof");
|
||||
assert_1.default.ok(receipt.logs[0] instanceof index_js_1.ethers.EventLog, "receipt.log typeof");
|
||||
assert_1.default.equal(receipt.logs[0].fragment && receipt.logs[0].fragment.name, "Minted", "logs[0].fragment.name");
|
||||
assert_1.default.equal(receipt.logs[0].args[0], await signer.getAddress(), "logs[0].args[0]");
|
||||
assert_1.default.equal(receipt.logs[0].args.target, await signer.getAddress(), "logs[0].args.target");
|
||||
// Check the state has been adjusted
|
||||
assert_1.default.equal(await contract.totalSupply(), BigInt(1), "initial supply 1; default");
|
||||
assert_1.default.equal(await contract.balanceOf(signer), BigInt(1), "balanceOf(signer)");
|
||||
// Test minting (explicit)
|
||||
const tx2 = await contract.mint.send(signer);
|
||||
await tx2.wait();
|
||||
// Check the state has been adjusted
|
||||
assert_1.default.equal(await contract.totalSupply(), BigInt(2), "initial supply 2; default");
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=test-contract-integ.js.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-contract-integ.js","sourceRoot":"","sources":["../../src.ts/_tests/test-contract-integ.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAG5B,0CAAqC;AAQrC,QAAQ,CAAC,4BAA4B,EAAE;IACnC,MAAM,QAAQ,GAAG,IAAI,iBAAM,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IAEtE,MAAM,GAAG,GAAG;QACR,4CAA4C;QAC5C,qDAAqD;QACrD,mDAAmD;QACnD,gEAAgE;QAChE,8BAA8B;KACjC,CAAC;IAEF,IAAI,OAAO,GAAkB,IAAI,CAAC;IAElC,EAAE,CAAC,oBAAoB,EAAE,KAAK;QAC1B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEpB,MAAM,QAAQ,GAAG,gxFAAgxF,CAAC;QAClyF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAE3C,MAAM,OAAO,GAAG,IAAI,iBAAM,CAAC,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAElE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACnD,OAAO,GAAG,MAAM,QAAQ,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AC,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,uBAAuB,CAAC,CAAC;QAC3G,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,iBAAiB,CAAC,CAAC;QACpF,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,qBAAqB,CAAC,CAAC;QAE5F,oCAAoC;QACpC,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACnF,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAE/E,0BAA0B;QAC1B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,oCAAoC;QACpC,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-contract.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-contract.ts"],"names":[],"mappings":""}
|
@ -1,366 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const create_provider_js_1 = require("./create-provider.js");
|
||||
const index_js_1 = require("../index.js");
|
||||
(0, create_provider_js_1.setupProviders)();
|
||||
describe("Test Contract", function () {
|
||||
const addr = "0x24264C81146c23bbF83Db1d3F87d2111C2935Ffa";
|
||||
const networkName = "sepolia";
|
||||
const abi = [
|
||||
"error CustomError1(uint256 code, string message)",
|
||||
"event EventUint256(uint256 indexed value)",
|
||||
"event EventAddress(address indexed value)",
|
||||
"event EventString(string value)",
|
||||
"event EventBytes(bytes value)",
|
||||
"function testCustomError1(bool pass, uint code, string calldata message) pure returns (uint256)",
|
||||
"function testErrorString(bool pass, string calldata message) pure returns (uint256)",
|
||||
"function testPanic(uint256 code) returns (uint256)",
|
||||
"function testEvent(uint256 valueUint256, address valueAddress, string valueString, bytes valueBytes) public",
|
||||
"function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)",
|
||||
];
|
||||
it("tests contract calls", async function () {
|
||||
this.timeout(10000);
|
||||
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
|
||||
const contract = new index_js_1.Contract(addr, abi, provider);
|
||||
assert_1.default.equal(await contract.testCallAdd(4, 5), BigInt(9), "testCallAdd(4, 5)");
|
||||
assert_1.default.equal(await contract.testCallAdd(6, 0), BigInt(6), "testCallAdd(6, 0)");
|
||||
});
|
||||
it("tests events", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
|
||||
assert_1.default.ok(provider);
|
||||
const contract = new index_js_1.Contract(addr, abi, provider);
|
||||
const signer = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY), provider);
|
||||
const contractSigner = contract.connect(signer);
|
||||
const vUint256 = 42;
|
||||
const vAddrName = "tests.eth";
|
||||
const vAddr = "0x228568EA92aC5Bc281c1E30b1893735c60a139F1";
|
||||
const vString = "Hello";
|
||||
const vBytes = "0x12345678";
|
||||
let hash = null;
|
||||
// Test running a listener for a specific event
|
||||
const specificEvent = new Promise((resolve, reject) => {
|
||||
contract.on("EventUint256", async (value, event) => {
|
||||
// Triggered by someone else
|
||||
if (hash == null || hash !== event.log.transactionHash) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
assert_1.default.equal(event.filter, "EventUint256", "event.filter");
|
||||
assert_1.default.equal(event.fragment.name, "EventUint256", "event.fragment.name");
|
||||
assert_1.default.equal(event.log.address, addr, "event.log.address");
|
||||
assert_1.default.equal(event.args.length, 1, "event.args.length");
|
||||
assert_1.default.equal(event.args[0], BigInt(42), "event.args[0]");
|
||||
const count = await contract.listenerCount("EventUint256");
|
||||
await event.removeListener();
|
||||
assert_1.default.equal(await contract.listenerCount("EventUint256"), count - 1, "decrement event count");
|
||||
resolve(null);
|
||||
}
|
||||
catch (e) {
|
||||
event.removeListener();
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
// Test running a listener on all (i.e. "*") events
|
||||
const allEvents = new Promise((resolve, reject) => {
|
||||
const waitingFor = {
|
||||
EventUint256: vUint256,
|
||||
EventAddress: vAddr,
|
||||
EventString: vString,
|
||||
EventBytes: vBytes
|
||||
};
|
||||
contract.on("*", (event) => {
|
||||
// Triggered by someone else
|
||||
if (hash == null || hash !== event.log.transactionHash) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const name = event.eventName;
|
||||
assert_1.default.equal(event.args[0], waitingFor[name], `${name}`);
|
||||
delete waitingFor[name];
|
||||
if (Object.keys(waitingFor).length === 0) {
|
||||
event.removeListener();
|
||||
resolve(null);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
// Send a transaction to trigger some events
|
||||
const tx = await contractSigner.testEvent(vUint256, vAddr, vString, vBytes);
|
||||
hash = tx.hash;
|
||||
const checkEvent = (filter, event) => {
|
||||
const values = {
|
||||
EventUint256: vUint256,
|
||||
EventString: vString,
|
||||
EventAddress: vAddr,
|
||||
EventBytes: vBytes
|
||||
};
|
||||
assert_1.default.ok(event instanceof index_js_1.EventLog, `queryFilter(${filter}):isEventLog`);
|
||||
const name = event.eventName;
|
||||
assert_1.default.equal(event.address, addr, `queryFilter(${filter}):address`);
|
||||
assert_1.default.equal(event.args[0], values[name], `queryFilter(${filter}):args[0]`);
|
||||
};
|
||||
const checkEventFilter = async (filter) => {
|
||||
const events = (await contract.queryFilter(filter, -10)).filter((e) => (e.transactionHash === hash));
|
||||
assert_1.default.equal(events.length, 1, `queryFilter(${filter}).length`);
|
||||
checkEvent(filter, events[0]);
|
||||
return events[0];
|
||||
};
|
||||
const receipt = await tx.wait();
|
||||
// Check the logs in the receipt
|
||||
for (const log of receipt.logs) {
|
||||
checkEvent("receipt", log);
|
||||
}
|
||||
// Various options for queryFilter
|
||||
await checkEventFilter("EventUint256");
|
||||
await checkEventFilter(["EventUint256"]);
|
||||
await checkEventFilter([["EventUint256"]]);
|
||||
await checkEventFilter("EventUint256(uint)");
|
||||
await checkEventFilter(["EventUint256(uint)"]);
|
||||
await checkEventFilter([["EventUint256(uint)"]]);
|
||||
await checkEventFilter([["EventUint256", "EventUint256(uint)"]]);
|
||||
await checkEventFilter("0x85c55bbb820e6d71c71f4894e57751de334b38c421f9c170b0e66d32eafea337");
|
||||
// Query by Event
|
||||
await checkEventFilter(contract.filters.EventUint256);
|
||||
// Query by Deferred Topic Filter; address
|
||||
await checkEventFilter(contract.filters.EventUint256(vUint256));
|
||||
// Query by Deferred Topic Filter; address
|
||||
await checkEventFilter(contract.filters.EventAddress(vAddr));
|
||||
// Query by Deferred Topic Filter; ENS name => address
|
||||
await checkEventFilter(contract.filters.EventAddress(vAddrName));
|
||||
// Multiple Methods
|
||||
{
|
||||
const filter = [["EventUint256", "EventString"]];
|
||||
const events = (await contract.queryFilter(filter, -10)).filter((e) => (e.transactionHash === hash));
|
||||
assert_1.default.equal(events.length, 2, `queryFilter(${filter}).length`);
|
||||
for (const event of events) {
|
||||
checkEvent(filter, event);
|
||||
}
|
||||
}
|
||||
await specificEvent;
|
||||
await allEvents;
|
||||
});
|
||||
it("tests the _in_ operator for functions", function () {
|
||||
const contract = new index_js_1.Contract(addr, abi);
|
||||
assert_1.default.equal("testCallAdd" in contract, true, "has(testCallAdd)");
|
||||
assert_1.default.equal("nonExist" in contract, false, "has(nonExist)");
|
||||
{
|
||||
const sig = "function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)";
|
||||
assert_1.default.equal(sig in contract, true, `has(${sig})`);
|
||||
assert_1.default.equal("function nonExist()" in contract, false, "has(function nonExist())");
|
||||
}
|
||||
assert_1.default.equal("0xf24684e5" in contract, true, "has(0xf24684e5)");
|
||||
assert_1.default.equal("0xbad01234" in contract, false, "has(0xbad01234)");
|
||||
});
|
||||
it("tests the _in_ operator for events", function () {
|
||||
const contract = new index_js_1.Contract(addr, abi);
|
||||
assert_1.default.equal("EventUint256" in contract.filters, true, "has(EventUint256)");
|
||||
assert_1.default.equal("NonExist" in contract.filters, false, "has(NonExist)");
|
||||
{
|
||||
const sig = "event EventUint256(uint256 indexed value)";
|
||||
assert_1.default.equal(sig in contract.filters, true, `has(${sig})`);
|
||||
assert_1.default.equal("event NonExist()" in contract.filters, false, "has(event NonExist())");
|
||||
}
|
||||
{
|
||||
const hash = "0x85c55bbb820e6d71c71f4894e57751de334b38c421f9c170b0e66d32eafea337";
|
||||
const badHash = "0xbad01234567890ffbad01234567890ffbad01234567890ffbad01234567890ff";
|
||||
assert_1.default.equal(hash in contract.filters, true, `has(${hash})`);
|
||||
assert_1.default.equal(badHash in contract.filters, false, `has(${badHash})`);
|
||||
}
|
||||
});
|
||||
});
|
||||
describe("Test Typed Contract Interaction", function () {
|
||||
const tests = [
|
||||
{
|
||||
types: ["uint8", "uint16", "uint24", "uint32", "uint40", "uint48", "uint56", "uint64", "uint72", "uint80", "uint88", "uint96", "uint104", "uint112", "uint120", "uint128", "uint136", "uint144", "uint152", "uint160", "uint168", "uint176", "uint184", "uint192", "uint200", "uint208", "uint216", "uint224", "uint232", "uint240", "uint248", "uint256", "int8", "int16", "int24", "int32", "int40", "int48", "int56", "int64", "int72", "int80", "int88", "int96", "int104", "int112", "int120", "int128", "int136", "int144", "int152", "int160", "int168", "int176", "int184", "int192", "int200", "int208", "int216", "int224", "int232", "int240", "int248", "int256"],
|
||||
valueFunc: (type) => { return 42; }
|
||||
},
|
||||
{
|
||||
types: [
|
||||
"bytes1", "bytes2", "bytes3", "bytes4", "bytes5", "bytes6", "bytes7", "bytes8", "bytes9", "bytes10", "bytes11", "bytes12", "bytes13", "bytes14", "bytes15", "bytes16", "bytes17", "bytes18", "bytes19", "bytes20", "bytes21", "bytes22", "bytes23", "bytes24", "bytes25", "bytes26", "bytes27", "bytes28", "bytes29", "bytes30", "bytes31", "bytes32",
|
||||
"bytes"
|
||||
],
|
||||
valueFunc: (type) => {
|
||||
const length = type.substring(5);
|
||||
if (length) {
|
||||
const value = new Uint8Array(parseInt(length));
|
||||
value.fill(42);
|
||||
return value;
|
||||
}
|
||||
return "0x123456";
|
||||
}
|
||||
}, {
|
||||
types: ["bool"],
|
||||
valueFunc: (type) => { return true; }
|
||||
}, {
|
||||
types: ["address"],
|
||||
valueFunc: (type) => { return "0x643aA0A61eADCC9Cc202D1915D942d35D005400C"; }
|
||||
}, {
|
||||
types: ["string"],
|
||||
valueFunc: (type) => { return "someString"; }
|
||||
}
|
||||
];
|
||||
const abi = [];
|
||||
for (let i = 1; i <= 32; i++) {
|
||||
abi.push(`function testTyped(uint${i * 8}) public pure returns (string memory)`);
|
||||
abi.push(`function testTyped(int${i * 8}) public pure returns (string memory)`);
|
||||
abi.push(`function testTyped(bytes${i}) public pure returns (string memory)`);
|
||||
}
|
||||
abi.push(`function testTyped(address) public pure returns (string memory)`);
|
||||
abi.push(`function testTyped(bool) public pure returns (string memory)`);
|
||||
abi.push(`function testTyped(bytes memory) public pure returns (string memory)`);
|
||||
abi.push(`function testTyped(string memory) public pure returns (string memory)`);
|
||||
const addr = "0xf20ba47c47a32fc2d9ad846ff06f2fa6e89eec74";
|
||||
const networkName = "sepolia";
|
||||
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
|
||||
const contract = new index_js_1.Contract(addr, abi, provider);
|
||||
for (const { types, valueFunc } of tests) {
|
||||
for (const type of types) {
|
||||
const value = valueFunc(type);
|
||||
it(`tests typed value: Typed.from(${type})`, async function () {
|
||||
this.timeout(10000);
|
||||
const v = index_js_1.Typed.from(type, value);
|
||||
const result = await contract.testTyped(v);
|
||||
assert_1.default.equal(result, type);
|
||||
});
|
||||
it(`tests typed value: Typed.${type}()`, async function () {
|
||||
this.timeout(10000);
|
||||
const v = index_js_1.Typed[type](value);
|
||||
const result = await contract.testTyped(v);
|
||||
assert_1.default.equal(result, type);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
describe("Test Contract Fallback", function () {
|
||||
const tests = [
|
||||
{
|
||||
name: "none",
|
||||
address: "0x0ccdace3d8353fed9b87a2d63c40452923ccdae5",
|
||||
abi: [],
|
||||
sendNone: { error: "no fallback" },
|
||||
sendData: { error: "no fallback" },
|
||||
sendValue: { error: "no fallback" },
|
||||
sendDataAndValue: { error: "no fallback" },
|
||||
},
|
||||
{
|
||||
name: "non-payable fallback",
|
||||
address: "0x3f10193f79a639b11ec9d2ab42a25a4a905a8870",
|
||||
abi: [
|
||||
"fallback()"
|
||||
],
|
||||
sendNone: { data: "0x" },
|
||||
sendData: { data: "0x1234" },
|
||||
sendValue: { error: "overrides.value" },
|
||||
sendDataAndValue: { error: "overrides.value" },
|
||||
},
|
||||
{
|
||||
name: "payable fallback",
|
||||
address: "0xe2de6b97c5eb9fee8a47ca6c0fa642331e0b6330",
|
||||
abi: [
|
||||
"fallback() payable"
|
||||
],
|
||||
sendNone: { data: "0x" },
|
||||
sendData: { data: "0x1234" },
|
||||
sendValue: { data: "0x" },
|
||||
sendDataAndValue: { data: "0x1234" },
|
||||
},
|
||||
{
|
||||
name: "receive-only",
|
||||
address: "0xf8f2afbbe37f6a4520e4db7f99495655aa31229b",
|
||||
abi: [
|
||||
"receive()"
|
||||
],
|
||||
sendNone: { data: "0x" },
|
||||
sendData: { error: "overrides.data" },
|
||||
sendValue: { data: "0x" },
|
||||
sendDataAndValue: { error: "overrides.data" },
|
||||
},
|
||||
{
|
||||
name: "receive and payable fallback",
|
||||
address: "0x7d97ca5d9dea1cd0364f1d493252006a3c4e18a0",
|
||||
abi: [
|
||||
"fallback() payable",
|
||||
"receive()"
|
||||
],
|
||||
sendNone: { data: "0x" },
|
||||
sendData: { data: "0x1234" },
|
||||
sendValue: { data: "0x" },
|
||||
sendDataAndValue: { data: "0x1234" },
|
||||
},
|
||||
{
|
||||
name: "receive and non-payable fallback",
|
||||
address: "0x5b59d934f0d22b15e73b5d6b9ae83486b70df67e",
|
||||
abi: [
|
||||
"fallback()",
|
||||
"receive()"
|
||||
],
|
||||
sendNone: { data: "0x" },
|
||||
sendData: { data: "0x" },
|
||||
sendValue: { data: "0x" },
|
||||
sendDataAndValue: { error: "overrides" },
|
||||
},
|
||||
];
|
||||
const networkName = "sepolia";
|
||||
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", networkName);
|
||||
const testGroups = [
|
||||
{
|
||||
group: "sendNone",
|
||||
tx: {}
|
||||
},
|
||||
{
|
||||
group: "sendData",
|
||||
tx: { data: "0x1234" }
|
||||
},
|
||||
{
|
||||
group: "sendValue",
|
||||
tx: { value: 123 }
|
||||
},
|
||||
{
|
||||
group: "sendDataAndValue",
|
||||
tx: { data: "0x1234", value: 123 }
|
||||
},
|
||||
];
|
||||
for (const { group, tx } of testGroups) {
|
||||
for (const test of tests) {
|
||||
const { name, address, abi } = test;
|
||||
const send = test[group];
|
||||
const contract = new index_js_1.Contract(address, abi, provider);
|
||||
it(`test contract fallback checks: ${group} - ${name}`, async function () {
|
||||
const func = async function () {
|
||||
if (abi.length === 0) {
|
||||
throw new Error("no fallback");
|
||||
}
|
||||
assert_1.default.ok(contract.fallback);
|
||||
return await contract.fallback.populateTransaction(tx);
|
||||
};
|
||||
if ("data" in send) {
|
||||
await func();
|
||||
//const result = await func();
|
||||
//@TODO: Test for the correct populated tx
|
||||
//console.log(result);
|
||||
assert_1.default.ok(true);
|
||||
}
|
||||
else {
|
||||
await assert_1.default.rejects(func, function (error) {
|
||||
if (error.message === send.error) {
|
||||
return true;
|
||||
}
|
||||
if ((0, index_js_1.isError)(error, "INVALID_ARGUMENT")) {
|
||||
return error.argument === send.error;
|
||||
}
|
||||
console.log("EE", error);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=test-contract.js.map
|
File diff suppressed because one or more lines are too long
@ -1,2 +0,0 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-crypto-algoswap.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-crypto-algoswap.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-crypto-algoswap.ts"],"names":[],"mappings":""}
|
@ -1,99 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const index_js_1 = require("../index.js");
|
||||
describe("test registration", function () {
|
||||
let hijack = "";
|
||||
function getHijack(algo) {
|
||||
return function (...args) {
|
||||
hijack = `hijacked ${algo}: ${JSON.stringify(args)}`;
|
||||
return "0x42";
|
||||
};
|
||||
}
|
||||
const tests = [
|
||||
{
|
||||
name: "keccak256",
|
||||
params: ["0x"],
|
||||
hijackTag: 'hijacked keccak256: [{}]',
|
||||
algorithm: index_js_1.keccak256
|
||||
},
|
||||
{
|
||||
name: "sha256",
|
||||
params: ["0x"],
|
||||
hijackTag: 'hijacked sha256: [{}]',
|
||||
algorithm: index_js_1.sha256
|
||||
},
|
||||
{
|
||||
name: "sha512",
|
||||
params: ["0x"],
|
||||
hijackTag: 'hijacked sha512: [{}]',
|
||||
algorithm: index_js_1.sha512
|
||||
},
|
||||
{
|
||||
name: "ripemd160",
|
||||
params: ["0x"],
|
||||
hijackTag: 'hijacked ripemd160: [{}]',
|
||||
algorithm: index_js_1.ripemd160
|
||||
},
|
||||
{
|
||||
name: "pbkdf2",
|
||||
params: ["0x", "0x", 1024, 32, "sha256"],
|
||||
hijackTag: 'hijacked pbkdf2: [{},{},1024,32,"sha256"]',
|
||||
algorithm: index_js_1.pbkdf2
|
||||
},
|
||||
{
|
||||
name: "scryptSync",
|
||||
params: ["0x", "0x", 1024, 8, 1, 32],
|
||||
hijackTag: 'hijacked scryptSync: [{},{},1024,8,1,32]',
|
||||
algorithm: index_js_1.scryptSync
|
||||
},
|
||||
{
|
||||
name: "scrypt",
|
||||
params: ["0x", "0x", 1024, 8, 1, 32],
|
||||
hijackTag: 'hijacked scrypt: [{},{},1024,8,1,32,null]',
|
||||
algorithm: index_js_1.scrypt
|
||||
},
|
||||
{
|
||||
name: "computeHmac",
|
||||
params: ["sha256", "0x", "0x"],
|
||||
hijackTag: 'hijacked computeHmac: ["sha256",{},{}]',
|
||||
algorithm: index_js_1.computeHmac
|
||||
},
|
||||
{
|
||||
name: "randomBytes",
|
||||
params: [32],
|
||||
hijackTag: "hijacked randomBytes: [32]",
|
||||
algorithm: index_js_1.randomBytes,
|
||||
postCheck: (value) => {
|
||||
return (value instanceof Uint8Array && value.length === 32);
|
||||
}
|
||||
}
|
||||
];
|
||||
tests.forEach(({ name, params, hijackTag, algorithm, postCheck }) => {
|
||||
it(`swaps in hijacked callback: ${name}`, async function () {
|
||||
const initial = await algorithm(...params);
|
||||
algorithm.register(getHijack(name));
|
||||
assert_1.default.equal(await algorithm(...params), "0x42");
|
||||
assert_1.default.equal(hijack, hijackTag);
|
||||
algorithm.register(algorithm._);
|
||||
if (postCheck) {
|
||||
assert_1.default.ok(postCheck(await algorithm(...params)));
|
||||
}
|
||||
else {
|
||||
assert_1.default.equal(await algorithm(...params), initial);
|
||||
}
|
||||
});
|
||||
});
|
||||
it("prevents swapping after locked", function () {
|
||||
(0, index_js_1.lock)();
|
||||
tests.forEach(({ name, params, hijackTag, algorithm }) => {
|
||||
assert_1.default.throws(function () {
|
||||
algorithm.register(getHijack("test"));
|
||||
}, function (error) {
|
||||
return (error.message === `${name} is locked`);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=test-crypto-algoswap.js.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-crypto-algoswap.js","sourceRoot":"","sources":["../../src.ts/_tests/test-crypto-algoswap.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,0CAMqB;AAmBrB,QAAQ,CAAC,mBAAmB,EAAE;IAE1B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,SAAS,SAAS,CAAC,IAAY;QAC3B,OAAO,UAAS,GAAG,IAAgB;YAC/B,MAAM,GAAG,YAAa,IAAK,KAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE,EAAE,CAAC;YACzD,OAAO,MAAM,CAAC;QAClB,CAAC,CAAA;IACL,CAAC;IAED,MAAM,KAAK,GAAoB;QAC3B;YACI,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,CAAE,IAAI,CAAE;YAChB,SAAS,EAAE,0BAA0B;YACrC,SAAS,EAAE,oBAAS;SACvB;QACD;YACI,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,CAAE,IAAI,CAAE;YAChB,SAAS,EAAE,uBAAuB;YAClC,SAAS,EAAE,iBAAM;SACpB;QACD;YACI,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,CAAE,IAAI,CAAE;YAChB,SAAS,EAAE,uBAAuB;YAClC,SAAS,EAAE,iBAAM;SACpB;QACD;YACI,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,CAAE,IAAI,CAAE;YAChB,SAAS,EAAE,0BAA0B;YACrC,SAAS,EAAE,oBAAS;SACvB;QACD;YACI,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAE;YAC1C,SAAS,E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,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAEhC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,SAAS,EAAE;gBACX,gBAAM,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;aACpD;iBAAM;gBACH,gBAAM,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;aACrD;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE;QACjC,IAAA,eAAI,GAAE,CAAC;QAEP,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE;YACrD,gBAAM,CAAC,MAAM,CAAC;gBACV,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YAC1C,CAAC,EAAE,UAAS,KAAU;gBAClB,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,GAAI,IAAK,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-crypto.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-crypto.ts"],"names":[],"mappings":""}
|
@ -1,478 +0,0 @@
|
||||
"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");
|
||||
const index_js_2 = require("../index.js");
|
||||
describe("test hashing", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("hashes");
|
||||
tests.forEach((test) => {
|
||||
it(`computes sha2-256: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_2.sha256)(test.data), test.sha256);
|
||||
});
|
||||
});
|
||||
tests.forEach((test) => {
|
||||
it(`computes sha2-512: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_2.sha512)(test.data), test.sha512);
|
||||
});
|
||||
});
|
||||
tests.forEach((test) => {
|
||||
it(`computes ripemd160: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_2.ripemd160)(test.data), test.ripemd160);
|
||||
});
|
||||
});
|
||||
tests.forEach((test) => {
|
||||
it(`computes keccak256: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_2.keccak256)(test.data), test.keccak256);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("test password-based key derivation", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("pbkdf");
|
||||
tests.forEach((test) => {
|
||||
it(`computes pbkdf2: ${test.name}`, function () {
|
||||
const password = (0, index_js_1.getBytes)(test.password);
|
||||
const salt = (0, index_js_1.getBytes)(test.salt);
|
||||
const { iterations, algorithm, key } = test.pbkdf2;
|
||||
const result = (0, index_js_2.pbkdf2)(password, salt, iterations, test.dkLen, algorithm);
|
||||
assert_1.default.equal(result, key);
|
||||
});
|
||||
});
|
||||
tests.forEach((test) => {
|
||||
it(`computes scrypt (sync): ${test.name}`, function () {
|
||||
this.timeout(1000);
|
||||
const password = (0, index_js_1.getBytes)(test.password);
|
||||
const salt = (0, index_js_1.getBytes)(test.salt);
|
||||
const { N, r, p, key } = test.scrypt;
|
||||
const result = (0, index_js_2.scryptSync)(password, salt, N, r, p, test.dkLen);
|
||||
assert_1.default.equal(result, key);
|
||||
});
|
||||
});
|
||||
tests.forEach((test) => {
|
||||
it(`computes scrypt (async): ${test.name}`, async function () {
|
||||
this.timeout(1000);
|
||||
const password = (0, index_js_1.getBytes)(test.password);
|
||||
const salt = (0, index_js_1.getBytes)(test.salt);
|
||||
const { N, r, p, key } = test.scrypt;
|
||||
let progressCount = 0, progressOk = true, lastProgress = -1;
|
||||
const result = await (0, index_js_2.scrypt)(password, salt, N, r, p, test.dkLen, (progress) => {
|
||||
if (progress < lastProgress) {
|
||||
progressOk = false;
|
||||
}
|
||||
lastProgress = progress;
|
||||
progressCount++;
|
||||
});
|
||||
assert_1.default.ok(progressOk, "progress was not monotonically increasing");
|
||||
assert_1.default.ok(progressCount > 100, "progress callback was called at leat 100 times");
|
||||
assert_1.default.equal(result, key);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("test hmac", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("hmac");
|
||||
tests.forEach((test) => {
|
||||
it(`computes hmac: ${test.name}`, async function () {
|
||||
const { algorithm, key, data } = test;
|
||||
assert_1.default.equal((0, index_js_2.computeHmac)(algorithm, key, data), test.hmac);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("tests ECDH shared secret", function () {
|
||||
const tests = [
|
||||
{
|
||||
"name": "test-0",
|
||||
"keyA": "0xb484f7e25b06a887c3a01c97db40b5d96a1bd1ce69f342442a8395bfc995c34c",
|
||||
"keyB": "0x407f75dc7d9f420c54bcc51189a16841b75aab53827d3ed54d5548448136f577",
|
||||
"shared": "0x04131c0361e18fbdfb1575b06763225e8e7d4b6d33a6b6f369f20ff05bb6bb79cf6f510154615774f14a68ec405244fc8cba9fecdf012d22988575bf7f72f55cea"
|
||||
},
|
||||
{
|
||||
"name": "test-1",
|
||||
"keyA": "0x953287b3e32f93c3ae8974d380b88f9a6d89ce2969c4b589cf4d068ec719c885",
|
||||
"keyB": "0xf92ec8bea281236772a90219e9c661d475c6dd457dbf71f3076e9f136a7dee2b",
|
||||
"shared": "0x04b0d910de1a56e19a300e4cf7d8946fab088da26bad0be01b3139af7f61633387c110d00a9f4059a75808c7471665242996b0999677bfef0f8c9b2eb9cb7ff3f0"
|
||||
},
|
||||
{
|
||||
"name": "test-2",
|
||||
"keyA": "0xe47de7c043683a3facabbd72097c5c1c9148fc2d66854dfc32df924bfdb45a13",
|
||||
"keyB": "0x5bfe0ef6a3c40797a4b013d01bbc02dfb150c46cb04c85a52be5d5d370d1f60a",
|
||||
"shared": "0x04abcb75054302b210ac0ab42d412e47cc08bfc0d29298edc3a1c0f11d88c49240a8f922ca57dfbc003e6655337c75d5598b704ea91546206d9495aa61213aa96a"
|
||||
},
|
||||
{
|
||||
"name": "test-3",
|
||||
"keyA": "0x3f0b65deb1a95ec280649e81b933ef382441fdc875f6280d782e45628f0dccd7",
|
||||
"keyB": "0x3aeb016c64f23b276f816aa5494a2cec07361d2a4a0d4992a5b99764127e8f9e",
|
||||
"shared": "0x04de883e02e1842f87796a83790b646615902e2a0612477bc63002f23a94d700c15632660cf6018f10a81785a9f294dd100309e397e88e7d1b7d70f601a4cf3b1b"
|
||||
},
|
||||
{
|
||||
"name": "test-4",
|
||||
"keyA": "0xb9f059a915d6421848ae4344c64f1803342a7991c1fd567d61238aaaab583a5a",
|
||||
"keyB": "0x0beb07549d6496d635c45152673455268f4beb89c07ff049c6e269dfa867ac2c",
|
||||
"shared": "0x0411f59f62bd3033dba981f23fac5cc0718737dabeea9f060d0fd572383007402b539dd60b23b936c7842fcf16f4fb0524cc07ab02a06c3be8b33113a20f3d47d0"
|
||||
},
|
||||
{
|
||||
"name": "test-5",
|
||||
"keyA": "0xb48da3af696d7893c818b5e38ff682ab77818dccb80599f36b5108ad25214cf0",
|
||||
"keyB": "0xac732d7e814ef45ef8a7acf31c4f04eef30247c992b558c8523f4894e599e772",
|
||||
"shared": "0x0499778f55f0e87e28d72991c380a2ea5147f0336f5bc7d7ef6a1b2ef25e8949d05e3a5e60a1d605abe69427daf321a118f648c4b4da2529843b5409df921fb927"
|
||||
},
|
||||
{
|
||||
"name": "test-6",
|
||||
"keyA": "0x90b5123740bf282e9622ff8a2511692e0abc897bd61a64f49c2497967cb45dd5",
|
||||
"keyB": "0x471e8f4b20e3328d4a25c20dad734e0bdc160c6c3dd3709858ca6ba6ce74d24b",
|
||||
"shared": "0x04428de953d7409c419a6f11622c4a4d087082b54bc8207c514534ecf7901723c1f58359631ba94e95c05d934a2eedcecd705bbb61dd8f57cbb08572dc69e6a782"
|
||||
},
|
||||
{
|
||||
"name": "test-7",
|
||||
"keyA": "0x9f7f6431c1318481003fd21871b4b8a86ca779caaef10fec2209479b5072ea15",
|
||||
"keyB": "0xb6be68f448ac1092a704613f3a75324b5c58157f3595c48a3825a0089d7f9d3c",
|
||||
"shared": "0x0468218704c8c364d4d1838c7f66ccab205797eab0b02b93b75cf4e4437dbe13e7d9d0830971758b3a65e75eab577954b42f6721c104e4b876b77b8db63d23d43d"
|
||||
},
|
||||
{
|
||||
"name": "test-8",
|
||||
"keyA": "0xb9113e35ac2f7ba2a315e9f4301275cf561b91860f612d14a351273e38c04966",
|
||||
"keyB": "0x00c3101f5d3d6272299180fd426dc1554854cb06dc911bc85fa97327d4fa3f21",
|
||||
"shared": "0x04532cc9a89b735f0a11a0dbbbd40b05460dcf8e41e9da8359c727336a245d5d9babcca050434b81c01a6c70bd27692123f99377f22c0651bc0b01ae9871624894"
|
||||
},
|
||||
{
|
||||
"name": "test-9",
|
||||
"keyA": "0xf569179eccaaf12c837a7362b7fbe41976dbf760270fa759e3dff18ae2bbe5fd",
|
||||
"keyB": "0xc8654bad899f2e827d581f45db8b7f295a0dcfe5253577d8604c08d589180527",
|
||||
"shared": "0x04d3568b0d1203d09cf9d1707c3ed1a44eb0230d2169c19c89433df8330010160885e6e626ce4505ac6ce7dda68bd57d2ddaa07a5ef5a4685c6a4e3784b8ad9184"
|
||||
},
|
||||
{
|
||||
"name": "test-10",
|
||||
"keyA": "0x0ffd74c78276a1bcffe332b0545400e5992c87f2a2f91caa71ad76215ed2b229",
|
||||
"keyB": "0x47dcfdf847d5b572784d546e0c5048aa4e613e74936fcc5438b75370d5f5525a",
|
||||
"shared": "0x040fc7a5c5a7f9bfb98b596d698dbb0a87e1dcd50457544644acfb09ee3802835bbadc7717d06f4cc19af3bd308755eedfb162055b08134d63a49231ef9a38e503"
|
||||
},
|
||||
{
|
||||
"name": "test-11",
|
||||
"keyA": "0x9777dd28dd62dbf7b17244b8e7b49b3cb673b81ef9dabbb196c23ccd3d0b22e6",
|
||||
"keyB": "0xbc1f73ca7cdc51e1264429d6f6b581c75b3a5986cb993f09ab779156764ae1b1",
|
||||
"shared": "0x04493d9be34f59077b11f56f8f883bb1f9ff247500f482f3ff6c1adcee9860442529b957a92ddc3a40391859e3b853b95c8e2159cf2dcfcf70ad4d6b7b55386f37"
|
||||
},
|
||||
{
|
||||
"name": "test-12",
|
||||
"keyA": "0xd0ae54b6b72ddc5b8ed416251671bb488f9bd18e63fc60ed10dbcd12920d2f65",
|
||||
"keyB": "0x2bcfd3837358a43cb181613ebdb152d72efc9fe7dada0c6bc44eb84d61070e2a",
|
||||
"shared": "0x049f2d2eb2a6ba4937ab44c8ab1769c4b64b74b4d187f965c5ec1272cbe53d79858c8bcadfc17a37d95633da3881fb0e2900a1dfd1ac7160d67fa3dbd81b3de268"
|
||||
},
|
||||
{
|
||||
"name": "test-13",
|
||||
"keyA": "0x14dbcd45b32a3ece2adb1691352096d395354928f7ceb5197c85cfe95b4e23eb",
|
||||
"keyB": "0x111ed2f1a9fafbe021cb07033f0a1d45084fbb6b2facd008fe1d89e7ad029ae8",
|
||||
"shared": "0x0441389bf60228a087c317d6a07b41ce9da09a4749c6b595ba5d8deef7eb7d8c21d266450b3df6a2a2d29ed149e909b3381604c74b5154da7cdcb9bb26336a6aa5"
|
||||
},
|
||||
{
|
||||
"name": "test-14",
|
||||
"keyA": "0x3e7d474097eb34d76c38d4bc586f9cefc3bed6d8c172e4e5fea4016e0f820e1c",
|
||||
"keyB": "0x3d8c224427a5cc554fd064020017c20f655c347f344afa68d133b1e3b8bfb0d6",
|
||||
"shared": "0x04acd1f4ff562dd474f6ecda6f94b9d6eac65c497f0b103f1b6bcf03fd306f82505d5c5aa9de302f9c0577e479392795eaa13d68e2c6fe665ed7dc249d5a9ca7bd"
|
||||
},
|
||||
{
|
||||
"name": "test-15",
|
||||
"keyA": "0xa79deef7a811761554cc019967eeb15ad61b6a69b266e3a091c1e00d3bcd2057",
|
||||
"keyB": "0x43fcca9678c66d1ef35617ade47cf015f75da19d1b7189144a0be0c1631a4a00",
|
||||
"shared": "0x0470131669ac84dc65ada0c23469b39cc42a54df3482577427a7aab58bddaf13dc05469397717be0882fa7c37b8b7bbfbf49b500d1f17a3b6fe8c7f233eb2ac2b1"
|
||||
},
|
||||
{
|
||||
"name": "test-16",
|
||||
"keyA": "0x1945930000f6a3bdf339d5b632c3864f9ce8a0370243dd2bdcf805aa8f9e80e8",
|
||||
"keyB": "0xa97c423f9cc5827730b33ba804d15c8c97406f154a71561e3ed263299781e591",
|
||||
"shared": "0x0414fca0eb5db9d0b52f64b5e7b794659e87f2ee6816e83076d1e16446f5e9646fb1dd042027eee659363958d472f4a38f9bc400556dd85c7802eb1b87d4250581"
|
||||
},
|
||||
{
|
||||
"name": "test-17",
|
||||
"keyA": "0x5f6e300343975539ba132a6bf26c2b3fa827ee558bb6698c86bbc84ea8a71577",
|
||||
"keyB": "0xc015b1dddc249815a81d9c7f54f4676b10a3ec321d9d0ddd35b800557fed6431",
|
||||
"shared": "0x0476371203edee28e291a2b0fabccdf1018c395b090a8ffff2feec116d3cd103e6d3fa1ea02ddecdbd392dc076ea959c318abf2d69c06e35a92e4f09249d4d73b6"
|
||||
},
|
||||
{
|
||||
"name": "test-18",
|
||||
"keyA": "0x3f4f0a728833e864f96e202060239743ceb1150cc75094195e6bd4f53e7bf62a",
|
||||
"keyB": "0x5a7b89392da6f39464967d315ecfbe8822b75062d68f3a43cc2a928a6abf2993",
|
||||
"shared": "0x04959db3cb80d503579bc587399d09b043778c66115d1354ce449e060d3599bf2faa4adcf7da0419aa0af732ab5b82fe3ed68e5e5860dd2f6610f3f4f2ca7351eb"
|
||||
},
|
||||
{
|
||||
"name": "test-19",
|
||||
"keyA": "0xc3106be0925e0d69703e4ea6d3dbee7903a8b8bb293ae59b2f90b0efdb0b3a1a",
|
||||
"keyB": "0x44cf9575f03af5afc03c36f62433ebd52579d894c759cab76d29a4b9d0bae083",
|
||||
"shared": "0x04a980b037da455ec856a7e3a9f63e8b9daf73f8e1e929f3f10e2c4b603b5bca48264c057ce04a25f5f48d87d27a43f7192aaac3340d7d5972e2ad3efc5de20c13"
|
||||
},
|
||||
{
|
||||
"name": "test-20",
|
||||
"keyA": "0xb6c7bd2ba0d2b30d3e56d038398c2c937fb5cae348accdc060fb882903312008",
|
||||
"keyB": "0x9ed8d5fb02fa0e825e7e095cfd32f9e817e8cd030c4363470f55d17e37cf73ef",
|
||||
"shared": "0x042aa9b64ce873f5a3005a8eaee54e823f17633eec0a808ce0e24286f3c169485c2b7145f10deee39073056ce69c7d8bbbd2ff693b33b8749ae2b2f47e2e342397"
|
||||
},
|
||||
{
|
||||
"name": "test-21",
|
||||
"keyA": "0x9f44756603bca7e87e2dd718ef2323f12854056aae86dc9e31715f97c0b3dc12",
|
||||
"keyB": "0xd1ae23664d6320f9989b031cd7357fe346e207ffe73ed51de7c485754b8f1578",
|
||||
"shared": "0x04037ab94245dad8282b4fabfec79ae5ca26367db2f45a183eb4c0f0c9ab7bf0d2b33503981159468f660711fb956eb730675b1e34f1e7d0aca07b936b64c47d56"
|
||||
},
|
||||
{
|
||||
"name": "test-22",
|
||||
"keyA": "0x4c6307b149f1052290dc0140d6d597c25ddd23bc0ca826a9f44215009d13dad5",
|
||||
"keyB": "0x9845254fdb40c7c74d0f9f3c6f73ce97a27f4306368685448b1f72dfbb3dd5d9",
|
||||
"shared": "0x04f0ea5528a2efa16d424dbc07d49d3d2943e842289c6472f1cdeded965438326af76bb47449b417ef3b82130096f3c019d0ae3ffc3c9631f065a3285ba8539bfd"
|
||||
},
|
||||
{
|
||||
"name": "test-23",
|
||||
"keyA": "0xab6ac9d67466cae30d31584104970e1093ebda6690dc9bf7bea1f66f07ddfcb7",
|
||||
"keyB": "0xc0f58e549e7984e780cbc307b2a6b4c4863302474d271637586fa7cc0e389df8",
|
||||
"shared": "0x045d5fd0d76d168b746462231a5bfb07fc175f43b206622781614e3df3491ba4c3738c4d3ae2d7f18ab0570c86aeb139778219fcc57cac3d42726de0f38d31b52a"
|
||||
},
|
||||
{
|
||||
"name": "test-24",
|
||||
"keyA": "0x5b0e950974450f38dba31e01379814f0ed1b0f983cfda62dfecff5cd3e8db391",
|
||||
"keyB": "0x4739f9e168dee9af2c8a9107b18738c9e3335115af8a431810ecce5269fba577",
|
||||
"shared": "0x04da8ab5cf841804f0b5845f36e46e3463dfa3d6d9e7a306962062b729c680b2e8fdbf2b3eb2bdcc90d2884b9217dbdb3ad3620cd844982f19920e5d4f59353504"
|
||||
},
|
||||
{
|
||||
"name": "test-25",
|
||||
"keyA": "0x9f3583cffcbe992d4a537defb5d8479c2bfa96a39a3f33fcf40123854bc96ea4",
|
||||
"keyB": "0x42fe9367ef668babd70d4f5e836627cc78990b8a1738a56adf23baebf9410b48",
|
||||
"shared": "0x0414edfdae5d2db370a51b5cf45ee6049621f52dd15eb5136c795ed364221c0a5c0f32e9ebbc9211b121ccc06516756e9280b210abe5b1a8f6c658dc69c39341f5"
|
||||
},
|
||||
{
|
||||
"name": "test-26",
|
||||
"keyA": "0x289406a24a7794b04469a4acf9846e905ed4cae37349101db835f90e25d09605",
|
||||
"keyB": "0xb2d58cdc470106c12f538b4516559d8ecaad0bcae063848a44f8639168453b93",
|
||||
"shared": "0x04a9a80e466ea54aa0651eccde081e47637d2c142e1aaaf42572ee0753a49f7667c94b99f5bc2bf632b1330e3ffef95d009560e61084cbc07aab020282af5721f9"
|
||||
},
|
||||
{
|
||||
"name": "test-27",
|
||||
"keyA": "0xd9bcf36ef585f59e1570904784f0a3df6435c798bec7e1c406e922d51f98b510",
|
||||
"keyB": "0x40244928c9d371a427a0ce96530120deee3d31af086db679ee6bd8c1a7773030",
|
||||
"shared": "0x04ac55594d87dfdd8af303c5f92745d49fba6ff15afb628212bc5d432d97bbd909938873c298fb93c851d901bf178e14ef1d590ff0dca7f7ead5613e97e3a824db"
|
||||
},
|
||||
{
|
||||
"name": "test-28",
|
||||
"keyA": "0x301b79d85431a2c8bc21236cc58e1221eeb0862d3e3cfb29534423e6992e7591",
|
||||
"keyB": "0xe6a62f0c49971b7b11477fc964d777de92267ab09f1465520ca31edcd7abaffe",
|
||||
"shared": "0x049b7326b33eacc5ee3c102cae791d1835219253b70596f6a36892f2bb35fda1aebd661c781ac38b2461ac67b80ea1c18cd0230d024712a4e1826a6c5463874b0f"
|
||||
},
|
||||
{
|
||||
"name": "test-29",
|
||||
"keyA": "0x49542517ff2bd70e851405cf285cf2280f84af838e2b0a68ed779f96d0ce62eb",
|
||||
"keyB": "0x48ffc78034851d2f4e610bc11b97c21d42f5d7bbada2415ee8f03f6b643c92b7",
|
||||
"shared": "0x04dc12a233b08ff25ee7806cfede3565dedd663e0cd25108ad233b6c5c8f8c25fe82d4b2820fa44e0ef86d51d0eada0033854a1199644204f9233887e457775bb0"
|
||||
},
|
||||
{
|
||||
"name": "test-30",
|
||||
"keyA": "0x6597a9b39b58bd47561fd4058894ee327368fdd8b8b267efa0596793c3852ed8",
|
||||
"keyB": "0xbcab19f22f0cca9fc791f998a5717bc4c81853ff4f1c974a7dde7ecef41b4802",
|
||||
"shared": "0x043d622a7f3255437c9f6459e68d5e3333d377b76ac053a50affbdf88c555508c42000b092dbb07b72ecf5887766ebb2e47afdb3d8324b7938d9255171d971b1a8"
|
||||
},
|
||||
{
|
||||
"name": "test-31",
|
||||
"keyA": "0x4127797885e7b8b7c882fec5cf38be273f42de47261e8ea4aab49769d606dd01",
|
||||
"keyB": "0xc82a9b18f2f060adaf4f7cf56f29a2f4859d12a452b8b9f079f8850423fba666",
|
||||
"shared": "0x045e7b62ced9cebd94d2115b11f2e9ca6f9a66119a17296613a60439d2960747f927c305822fe15582bb62f48c574aa7c89e7b2c8e5d4affc86f097e794bdf029d"
|
||||
},
|
||||
{
|
||||
"name": "test-32",
|
||||
"keyA": "0xf5ffbd9bf88dd867ace131df25fc9bd9ab87b7834d91786f110f40eb2e7b73b2",
|
||||
"keyB": "0x203fe0bd83081d65fe45f194c373dd84c61fcdcfd4783d18e0e060f56efde038",
|
||||
"shared": "0x04cddff70996f116a874442da0a33ac3df0e99f063bd1066644e6ca88442bda15d5b46fe8c6de7467a13c65febf4a6d258ffae99784c21fa61fa8a3b384b666154"
|
||||
},
|
||||
{
|
||||
"name": "test-33",
|
||||
"keyA": "0x5073d19c09be03d0c41cef0b950e13b85ee87c4c1642061addbdfd34c3258618",
|
||||
"keyB": "0x37cf3617c1728e613c738c9b61fc84b76490128b3a584a861862416b1bb5ca60",
|
||||
"shared": "0x046234004e627b076d7bb6b6aedae341ab755f5f3dbca295fb2a70ae3206f26543c8f031605764e7dfb377a12c0be3a61df6983707ba62955487cc36ba8e8c0812"
|
||||
},
|
||||
{
|
||||
"name": "test-34",
|
||||
"keyA": "0x0378dd63bb9f1fd4b0b7c266239ca574c7f6f7ca62645b3e9edcf763918eb110",
|
||||
"keyB": "0xfd144b5e82bb6dbbcc9e9b714d64e283b748e85ba93b0113727fc1670251c6dc",
|
||||
"shared": "0x0481f04971c2282e9850ee373aba6ec92390e3ff12b95d86d339dfce7dfa592f012ef71875aba27adec232a90f209f420c6e7c73fd40f165ba9b6196a10ca5e82b"
|
||||
},
|
||||
{
|
||||
"name": "test-35",
|
||||
"keyA": "0xfa99235e06ec83c103ab50653ff5af505b085892781a6e743c7398219562ffe4",
|
||||
"keyB": "0x6a8850083fdf6ecb9f9bdb613f1c6706fe233e2e74fad460f7c650751bf999e9",
|
||||
"shared": "0x0407117676960073ab08890efd07eb6222584b2c8ad9a1eb64f9e610138c10a4d59f4ca496910ac35a1fad24e56fc08020ffac2dfabb2d79bbcc041e70dffb203c"
|
||||
},
|
||||
{
|
||||
"name": "test-36",
|
||||
"keyA": "0x3abcf36699a174e462196891e49e72759f707d7f82ae5e64a49f1273927802ae",
|
||||
"keyB": "0x44212cd650066f2371908cc6ba520061745db823c64b8b99dae535e364fe7034",
|
||||
"shared": "0x04c354916600479cbbf9d91f5b851ee075f0aac99befa434f3f3b30fa887a0a7af71129ea47b388ac41538a71f9e52f68473ccc2611ace7cdd999ee036bc43b459"
|
||||
},
|
||||
{
|
||||
"name": "test-37",
|
||||
"keyA": "0x858512678a61f3d286fd1a90cb8fb8960d8cffaa31686706d0a879d66acabc7f",
|
||||
"keyB": "0x490e29655cb5da0dcd2f60e4583cb41b7ad9a801fbc00a2927968f06b0c14852",
|
||||
"shared": "0x040dde94c952ec15bcba15d773ba0dfa9cb5ed7731cda1b7f8110fa91f843173f83d577f601b61f2df21b9f7cbf2b1d54792a6f9403c2446a480af7b69e23b8d21"
|
||||
},
|
||||
{
|
||||
"name": "test-38",
|
||||
"keyA": "0xaeb4d6c2a817e5882f991f0c3c81d0f6f2d3d8854d472511a211cae67adae695",
|
||||
"keyB": "0x72c297384a02544ba9719c0ce1f0ad3cb4e89b57536880f65c0462d1f058a55f",
|
||||
"shared": "0x041a61bd828eacb1aaacbbb3b0291d691f5fc1462f16fc55f828b1f28e73342957de6b718501e66c3a1885ce16e124adb600457095ba770f58be012d0b69ca949a"
|
||||
},
|
||||
{
|
||||
"name": "test-39",
|
||||
"keyA": "0xb0fc529ff1bb4a7985663d54b279cbf4a597ec922a810ca16b87697ef3ef0dd3",
|
||||
"keyB": "0xaf6019921bc7db54c334102a766d32d3ff06fd68ed08efe8ca2a35ce5074dcd0",
|
||||
"shared": "0x04b49b24610350fde84bf067affc1d9f7ac549b3c4c05fa963aade41e65d6645cf867466f6c87e11298cb433f45f65eec4c5d88e76acdd5515a92802ded42c6e0a"
|
||||
},
|
||||
{
|
||||
"name": "test-40",
|
||||
"keyA": "0x160fdb84df11195fb0d33335e593499c3505cadce25ffdf6cdd8af0cb78d400c",
|
||||
"keyB": "0xb37568a52ead1debcb2d402fa3d58f212a37321aae2cea1b90b263a3276bfdce",
|
||||
"shared": "0x04091c2e14e517d9990425bb5d0a9e48f3bfe27a1cb673182fe1f7dc27bd6a56043a7745c9d27052e60ce72a1d82357f6675fadf9994add784c45821f52f2b094e"
|
||||
},
|
||||
{
|
||||
"name": "test-41",
|
||||
"keyA": "0x253ca7443d94998bab1f508e3424c662831c6be6ec5d387e97c79f078087ff15",
|
||||
"keyB": "0x38102245618fddf8a1bd7de152c6fa630523223b89a1649d5f2fa5f9e47ffe4a",
|
||||
"shared": "0x04046754be94d9ad925f67b1bc80fe32cd6920f9f80327cdc83f68e95d999b1d8ab7b41844db1c1ea66662b42737169daefc675c9364583565e3982b674d8a30dd"
|
||||
},
|
||||
{
|
||||
"name": "test-42",
|
||||
"keyA": "0xef558874b5b1d5915c83e3c1e4554d73de1e9943af445eba3f6516b731cc0126",
|
||||
"keyB": "0x956e32c2e87263215b8c31c7f2e7311d6acad863f3c428b0625c9376cbc405cd",
|
||||
"shared": "0x047e9265334e20ad8747098147b0eabb6d01c8ab12722cf0bbede05c1beaa67e8e770e04e19cf6035f48289fbe85cd4b9496a9ca5a90d088f8e75a0c1c6c7f1cc8"
|
||||
},
|
||||
{
|
||||
"name": "test-43",
|
||||
"keyA": "0x32c00e0d3a2ba3db6685058e1327dcee6425068190890439391fdb95857f27b0",
|
||||
"keyB": "0x8b39021f7ad57a101534977d323c0349cecc8405d93286c6e71a441f4cc16c86",
|
||||
"shared": "0x04c8095c862e64f6866fd3c177ed898fa3ca5da2d585c60ea4646d8f2cb9f332dbd54ca9d3b2a9e852a15189a0eb97a8edfaa114a01277418aa2ecfdfb3770caa0"
|
||||
},
|
||||
{
|
||||
"name": "test-44",
|
||||
"keyA": "0x40627c6987e20c07014833e23a0b9304bbaf66525a59b892e224944b56d3117a",
|
||||
"keyB": "0xe23607bff98d5699816836f65e5405f2e60d4fe2449979acd43ee2b3e9bfc218",
|
||||
"shared": "0x04be3ec3c188e7c74944d42beddf19003aeb0ccf8cccf8532b220dc666520f277e8b98b87ee694e8c76256e51ebf69433479c69a4ccef3032e9cb550632db539f8"
|
||||
},
|
||||
{
|
||||
"name": "test-45",
|
||||
"keyA": "0x46c25bcd7d2f8ce6d27148a11f18e0314046260433f8cc6421be4dcd72a6e088",
|
||||
"keyB": "0xf29022ca90a60d455d0b1470034d1c7fbba27a9997b1940a9373a97d092f965e",
|
||||
"shared": "0x041f5fd1dd02afa8ce5d2877a05ce92a4db5aef022a8203551590343352c1bd6e71cad811974a74f49d140949aa091dc4262cf7da0b48bdfa26939cf4b9c461f52"
|
||||
},
|
||||
{
|
||||
"name": "test-46",
|
||||
"keyA": "0x6d6b69d4f9fafd986e5b1a9c36f3021aae9ce64c027f1bf9bd9e9e12d86a276b",
|
||||
"keyB": "0xeed0cabb4ae5a696e762c98e6d697bd88a89d9a0b38458c6e696f0748e404fe6",
|
||||
"shared": "0x04f2f9c8fa945577d7188292f5c4a4fad80bdcc3db44d6d5c15bda5a23971ac7046cb8af44bb5864a9e0e82c921805663c539a22f8c5ef22187062564f1359f4d2"
|
||||
},
|
||||
{
|
||||
"name": "test-47",
|
||||
"keyA": "0xf6b6d733b8c473a562f7a23c7cbb23f40273d809d13aeb308149ad709c674300",
|
||||
"keyB": "0xd873a7d24c1f498a43c181f566f265cda248f9e2df8a825e69a73aeb1437dad9",
|
||||
"shared": "0x0495f669c1c7271be4c8e628017ef570a0cb903887c3ea4897f09cc9ecd2a4f6b043e1fa41d1ddbf8f01e60368bc95e81ae2a8bf4922374294b0836ff7e43ad2ab"
|
||||
},
|
||||
{
|
||||
"name": "test-48",
|
||||
"keyA": "0x28410a640558a5da5b7746a46a9cdefc704ba2944f23699d3767f6505a97eb78",
|
||||
"keyB": "0xfd1a548275be4d922cc294276d7b059cea0fbbcb629be29bb8072de597a96597",
|
||||
"shared": "0x04fca25ec051c8532f664fe2c2e213d1bd3e298422232dd34e821245256e0bff4ff80fb1f03524fd57d1d4a6effc076899cc21dde0be10d60016c20c33b7524d00"
|
||||
},
|
||||
{
|
||||
"name": "test-49",
|
||||
"keyA": "0x89e51abd416ad4579d523bed183da74b991c589decb982649a0abedfe6061c0f",
|
||||
"keyB": "0x22b4cad2ade397b86756c2457516cd23d0858700b0597fdb2433e891efa435e3",
|
||||
"shared": "0x049316e68898db5d7c987fbfa371b1fbd6a56d585bde1017a825d1dfaad406b428a505e773e63ddd0244b0e25ddc1b08dda6dd9968673f7b10c40d8fe8a1e1d55f"
|
||||
},
|
||||
{
|
||||
"name": "test-50",
|
||||
"keyA": "0x2c645e1abac8e5848617067e6c3d739a6f126484d27f73bc8fdfdc9f0ac3ff04",
|
||||
"keyB": "0x71252585fb806d9273c0103dcf642b419e7632ef3aeba3efc6c71863b50ae177",
|
||||
"shared": "0x04886ec11347e30fc5e68a353201d702c4425358791ea6a6213c444c7489e38103c953fe13f4238dbe769f0d6208f693e356f81e7037977cf8a5b04661e37d2569"
|
||||
},
|
||||
{
|
||||
"name": "test-51",
|
||||
"keyA": "0x572a1ce3adfc10ca3afc39262d36c329ba44d7cfa6ca5c62d2e882ac25480d47",
|
||||
"keyB": "0x2b9081d499417315277663c86e25dd7898ea67e969b632dd11e80d29e92b557f",
|
||||
"shared": "0x0424c5ae82f447c156d97ed31c83f36cf3416cb4a72666bb4e8a61687a4ba4ae22b42f7d18579ff204f7974af9f8dcc51d8f9eabc45c720f607478ba78c2b2921c"
|
||||
},
|
||||
{
|
||||
"name": "test-52",
|
||||
"keyA": "0x60ba350fb7e0729ad992f53a314eacce65da6897856e362d2ef0959e890b9e99",
|
||||
"keyB": "0x6a9629c655cf4f8b8816e95df1c14f769cb946431c6da17a04423ceef8979ee1",
|
||||
"shared": "0x04831e236ece1bde7db14b819c06e0a17964b88b5fc4e8253a8dc316d613fad8ffdb5117eb920f34ce838d6861caa0e885e3c20d37cfd20e19d1092d52976e0f91"
|
||||
},
|
||||
{
|
||||
"name": "test-53",
|
||||
"keyA": "0x32eb6769ade64560a016e080f5e16ea97b2d0cb96b730e9c5c809bfd19a002c4",
|
||||
"keyB": "0x7dff2eb8455b0e9c0fd38838db3d3de96067a6efc05d21d1bb303ca0bd52d87d",
|
||||
"shared": "0x04b0cf54b0590546e434a5e3d2071c3c022d4b3b571660b359cee7d199e525965e9f38d12436affda7741d5b752e0b430149a1ec6d7835a6999e64b3ea324e91c6"
|
||||
},
|
||||
{
|
||||
"name": "test-54",
|
||||
"keyA": "0x70446e5ede6e26b96d3cecfe8afc35055a0a90f83c7db4d1b8a819d5cddb6642",
|
||||
"keyB": "0x2df217bf6e92875e35af50bfa301059b2ddf593c0694b70116a8c87ee27ef4c9",
|
||||
"shared": "0x0458e1554b06a40b9508d86d5cedeb3dccb82053881393306b1894d198412500dc0efa4dad2265d7532e59d06f71cf33f3d48728b4707434a5c722eea8d9a9acbc"
|
||||
},
|
||||
{
|
||||
"name": "test-55",
|
||||
"keyA": "0x64e16f672ec5aba6be5a4965d44bd7224aae65d444ceee6dd58690e527b36186",
|
||||
"keyB": "0xefb054ff4222e8e493cb667f56129dc1b6a3437581280a3f984ff0ea09ec3029",
|
||||
"shared": "0x04c806576fb79b4d7d38d00a3ee2c2896dfb1b29ef3a42ac72a82c7bf7626f2073a79aec8ee2c3c101845ce5171b27a9f23075ed74ccdae088956e3dcdbae74e7d"
|
||||
},
|
||||
{
|
||||
"name": "test-56",
|
||||
"keyA": "0x284a5592ab3fa9b8df2bf927761a667118697cd7413c255ef3cce9e9de76c321",
|
||||
"keyB": "0x52d0033d83fbdeb0b7c8d21b475ec637fabfcc7c2593494d7e846ecd974083af",
|
||||
"shared": "0x04e092613c7552c3180bdb041c32b9763804e6703c2c116009f1012526002472b5b627a85cb50c90942fe177bd36e2d4fbd8e9d835c72a607ee07ffead29cf12eb"
|
||||
},
|
||||
{
|
||||
"name": "test-57",
|
||||
"keyA": "0x488e6c2d97fe0ff3f5357254658ae487ade54bdf7bf871ffdfe27079cbeff103",
|
||||
"keyB": "0x00f8632a6982d58c25236ce1952c19052f6b08edad61edd166570a8679a98f5c",
|
||||
"shared": "0x048f02436bb55798561a6a78aacbeec67f0acd8ba88e99af6ec1b7b5152d9a5d7691a905c11fe26c2ba3d72be918f6ee7c3e66115a31a7f199f33073f6f5087181"
|
||||
},
|
||||
{
|
||||
"name": "test-58",
|
||||
"keyA": "0x0067fd2eec16c7ddf9a364f591d47394bfc12fd2b3ccff1bf1013e92e969f6f0",
|
||||
"keyB": "0x76f1e3f4abfb237ec3ac6e72a56f25bfa06e7561bc5fdc4823282f9db40c49d4",
|
||||
"shared": "0x04975e88ffcd670b06e7752d3d375613d0cd614f2b3a812e684342dcc16be6de336af2bb30ab25da0362ecf43752b477b412081d723f5c6840ea78deacd5f76b4a"
|
||||
},
|
||||
{
|
||||
"name": "test-59",
|
||||
"keyA": "0x4ff02743564c317a3578c08f7961a204d48e511e31688ba069037f6090235b37",
|
||||
"keyB": "0xcf22489e1b9058b4a645e38504eaa32e031dea44e1465eb1122e14e4847c9744",
|
||||
"shared": "0x04e584b571a9f99087bc6cb7818741cfc3b630ec412f64da1ada72de17279afa60258c5844cc2c7c1416548497b083f2aeb035c8945c0aa03a25b97bad7870c136"
|
||||
},
|
||||
{
|
||||
"name": "test-60",
|
||||
"keyA": "0xd140deee768594cea37e2eb5c89c60228083f93866ebd62c7c07a1a9f8a9bf58",
|
||||
"keyB": "0xc9f2edf7ccd6db9f21ef5a3966ee11694dec652d60ef21a540802db8b990c370",
|
||||
"shared": "0x0451b4a54b1fcdcbe4f5b97b3003bce3cc91f362cf2baa696ad0abca3cd21b12d4e4f3d1b0dc1c18599917f5fc9be7825d23999769d3811edf61a7ecc34525b403"
|
||||
},
|
||||
{
|
||||
"name": "test-61",
|
||||
"keyA": "0x63dcf1d3db0d89a37df3734e88f601412a184030f15474a0d9687e3105361161",
|
||||
"keyB": "0x5370bec049bcd28507f4078783d9378cd84b8e05230089e8987d3a485c945b08",
|
||||
"shared": "0x04e27e5ec5eb72fa6bda376f832b4730d6f7b9104594fa191ac87198f0d4aeed47c79568cf8f59fae0e43e8bf0931c491eda0cce1f19efc4153aacde94e673ba7f"
|
||||
},
|
||||
{
|
||||
"name": "test-62",
|
||||
"keyA": "0x465d0d758d8c7664d9e1bfa46fb5fb8e27265cb4bc28c0f7752d596910545028",
|
||||
"keyB": "0xeff55416a21e627ec4c55a08c9a3f7378ae2953fd5bf0926bde15965cf6b4d5d",
|
||||
"shared": "0x0487b20dbad3b5443594fc66470559206c37440a01ef91c24c38a51bc7bcf7676409789c6bc214087947ab8d0359927080422b2ecbd23e765bf6a79e4bbb456796"
|
||||
},
|
||||
{
|
||||
"name": "test-63",
|
||||
"keyA": "0x28469aab3ebc9efdec35b19e7c42a26311c649267ac92ae2ef2f5c8880eb517c",
|
||||
"keyB": "0x786e828e92abb73818380b37395c67dcb6a72f3e0a440bdf1f5f132a0621fc78",
|
||||
"shared": "0x046bfff91c9b31abb6df020018b66734c7f9fc4f7294c809c706b76c308982e5d75c10200fbdf67d75ba4b154223f591bfe3504006ba69634d4025c57b9af4ab73"
|
||||
}
|
||||
];
|
||||
for (const { name, keyA, keyB, shared } of tests) {
|
||||
it(`tests shared secrets match: ${name}`, function () {
|
||||
const signA = new index_js_2.SigningKey(keyA);
|
||||
const signB = new index_js_2.SigningKey(keyB);
|
||||
assert_1.default.equal(signA.computeSharedSecret(signB.publicKey), shared, "privA + pubB");
|
||||
assert_1.default.equal(signB.computeSharedSecret(signA.publicKey), shared, "pubA + privB");
|
||||
assert_1.default.equal(signA.computeSharedSecret(signB.privateKey), shared, "privA + privB");
|
||||
});
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=test-crypto.js.map
|
File diff suppressed because one or more lines are too long
2
lib.commonjs/_tests/test-hash-typeddata.d.ts
vendored
2
lib.commonjs/_tests/test-hash-typeddata.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-hash-typeddata.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-hash-typeddata.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-hash-typeddata.ts"],"names":[],"mappings":""}
|
@ -1,154 +0,0 @@
|
||||
"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("Tests Typed Data (EIP-712)", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("typed-data");
|
||||
for (const test of tests) {
|
||||
it(`tests encoding typed-data: ${test.name}`, function () {
|
||||
const encoder = index_js_1.TypedDataEncoder.from(test.types);
|
||||
assert_1.default.equal(encoder.primaryType, test.primaryType, "primaryType");
|
||||
assert_1.default.equal(encoder.encode(test.data), test.encoded, "encoded");
|
||||
assert_1.default.equal(index_js_1.TypedDataEncoder.getPrimaryType(test.types), test.primaryType, "primaryType");
|
||||
assert_1.default.equal(index_js_1.TypedDataEncoder.hash(test.domain, test.types, test.data), test.digest, "digest");
|
||||
});
|
||||
}
|
||||
});
|
||||
describe("Tests Typed Data (EIP-712) aliases", function () {
|
||||
const tests = [
|
||||
{
|
||||
name: "uint",
|
||||
types: {
|
||||
foo: [
|
||||
{ name: "a", type: "uint256" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
typesAlias: {
|
||||
foo: [
|
||||
{ name: "a", type: "uint" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
data: {
|
||||
a: 35,
|
||||
b: "hello"
|
||||
},
|
||||
encoded: "0x859b6b4a5d436f85a809f6383b4b35a153aa6fe9c95946c366d9dfd634b89f4700000000000000000000000000000000000000000000000000000000000000231c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
|
||||
},
|
||||
{
|
||||
name: "int",
|
||||
types: {
|
||||
foo: [
|
||||
{ name: "a", type: "int256" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
typesAlias: {
|
||||
foo: [
|
||||
{ name: "a", type: "int" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
data: {
|
||||
a: 35,
|
||||
b: "hello"
|
||||
},
|
||||
encoded: "0xa272ada5f88085e4cb18acdb87bd057a8cbfec249fee53de0149409080947cf500000000000000000000000000000000000000000000000000000000000000231c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
|
||||
},
|
||||
{
|
||||
name: "array-uint",
|
||||
types: {
|
||||
foo: [
|
||||
{ name: "a", type: "uint256[]" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
typesAlias: {
|
||||
foo: [
|
||||
{ name: "a", type: "uint[]" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
data: {
|
||||
a: [35, 36, 37],
|
||||
b: "hello"
|
||||
},
|
||||
encoded: "0x1a961843d0002bdd66ec21afd6e4a5b0aac34a4b6112890378c6e3a38b752e0b0c22b846886e98aeffc1f1166d4b35868da4d4da853dcb3b2856cfc233fd10c81c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
|
||||
},
|
||||
{
|
||||
name: "array-int",
|
||||
types: {
|
||||
foo: [
|
||||
{ name: "a", type: "int256[]" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
typesAlias: {
|
||||
foo: [
|
||||
{ name: "a", type: "int[]" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
data: {
|
||||
a: [35, 36, 37],
|
||||
b: "hello"
|
||||
},
|
||||
encoded: "0x0b89085a01a3b67d2231c6a136f9c8eea75d7d479a83a127356f8540ee15af010c22b846886e98aeffc1f1166d4b35868da4d4da853dcb3b2856cfc233fd10c81c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
|
||||
},
|
||||
{
|
||||
name: "nested-array-uint",
|
||||
types: {
|
||||
foo: [
|
||||
{ name: "a", type: "uint256[][]" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
typesAlias: {
|
||||
foo: [
|
||||
{ name: "a", type: "uint[][]" },
|
||||
{ name: "b", type: "string" },
|
||||
],
|
||||
},
|
||||
data: {
|
||||
a: [[35, 36], [37]],
|
||||
b: "hello"
|
||||
},
|
||||
encoded: "0x5efa7c4b66979cf78fcc7c3e71cbfa04ec2c7529002642082bf20a91552c1147fa5ffe3a0504d850bc7c9eeda1cf960b596b73f4dc0272a6fa89dace08e320291c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
|
||||
},
|
||||
];
|
||||
for (const test of tests) {
|
||||
it(`tests encoding typed-data: ${test.name}`, function () {
|
||||
const encoder = index_js_1.TypedDataEncoder.from(test.types);
|
||||
assert_1.default.equal(encoder.primaryType, "foo", "primaryType");
|
||||
assert_1.default.equal(encoder.encodeData("foo", test.data), test.encoded, "encoded");
|
||||
const encoderAlias = index_js_1.TypedDataEncoder.from(test.typesAlias);
|
||||
assert_1.default.equal(encoderAlias.primaryType, "foo", "primaryType");
|
||||
assert_1.default.equal(encoderAlias.encodeData("foo", test.data), test.encoded, "encoded");
|
||||
const payload = index_js_1.TypedDataEncoder.getPayload({}, test.types, test.data);
|
||||
const payloadAlias = index_js_1.TypedDataEncoder.getPayload({}, test.typesAlias, test.data);
|
||||
assert_1.default.equal(JSON.stringify(payloadAlias), JSON.stringify(payload), "payload");
|
||||
});
|
||||
}
|
||||
it(`tests overriding an alias as a type`, function () {
|
||||
const encoder = index_js_1.TypedDataEncoder.from({
|
||||
uint: [
|
||||
{ name: "value", type: "uint256" }
|
||||
],
|
||||
foo: [
|
||||
{ name: "a", type: "uint" },
|
||||
{ name: "b", type: "string" },
|
||||
]
|
||||
});
|
||||
assert_1.default.equal(encoder.primaryType, "foo", "primaryType");
|
||||
const data = encoder.encodeData("foo", {
|
||||
a: { value: 42 },
|
||||
b: "hello"
|
||||
});
|
||||
const encoded = "0x87a4bfff36f1a2ecde6468d6acd51ecc5ef8f3a15d8115a412c686d82d3fdbe4628fc3080b86a044fb60153bb7dc3f904e9ed1cebadf35c17099a060ba4df90b1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8";
|
||||
assert_1.default.equal(data, encoded, "encoded");
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=test-hash-typeddata.js.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-hash-typeddata.js","sourceRoot":"","sources":["../../src.ts/_tests/test-hash-typeddata.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAC5B,yCAAuC;AAEvC,0CAA+C;AAG/C,QAAQ,CAAC,4BAA4B,EAAE;IACnC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAoB,YAAY,CAAC,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,EAAE,CAAC,8BAA+B,IAAI,CAAC,IAAK,EAAE,EAAE;YAC5C,MAAM,OAAO,GAAG,2BAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClD,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;YACnE,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAEjE,gBAAM,CAAC,KAAK,CAAC,2BAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;YAC3F,gBAAM,CAAC,KAAK,CAAC,2BAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACnG,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAC;AAUH,QAAQ,CAAC,oCAAoC,EAAE;IAC3C,MAAM,KAAK,GAAqB;QAC5B;YACI,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE;gBACH,GAAG,EAAE;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,EAAE,IAAI,EAAE,SAAS,EAAE;aACrC;YACD,GAAG,EAAE;gBACD,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE;gBAC3B,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE;aAChC;SACJ,CAAC,CAAC;QACH,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;QAExD,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE;YACnC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAChB,CAAC,EAAE,OAAO;SACb,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,oMAAoM,CAAC;QACrN,gBAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-hash.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-hash.ts"],"names":[],"mappings":""}
|
@ -1,134 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const index_js_1 = require("../index.js");
|
||||
const utils_js_1 = require("./utils.js");
|
||||
const index_js_2 = require("../index.js");
|
||||
describe("Tests Namehash", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("namehash");
|
||||
for (const test of tests) {
|
||||
if (!test.error) {
|
||||
it(`hashes ENS name: ${JSON.stringify(test.name)}`, function () {
|
||||
const actual = (0, index_js_1.namehash)(test.ensName);
|
||||
assert_1.default.equal(actual, test.namehash, "namehash");
|
||||
// The empty string is not a valid ENS name
|
||||
if (test.ensName) {
|
||||
assert_1.default.ok((0, index_js_1.isValidName)(test.ensName), "isValidName");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const test of tests) {
|
||||
if (test.error) {
|
||||
it(`correctly fails to hash ENS name: ${test.error} ${JSON.stringify(test.name)}`, function () {
|
||||
assert_1.default.throws(function () {
|
||||
const actual = (0, index_js_1.namehash)(test.ensName);
|
||||
console.log("Failed to throw", actual);
|
||||
}, (error) => {
|
||||
return ((0, index_js_1.isError)(error, "INVALID_ARGUMENT") &&
|
||||
error.argument === "name" && error.value === test.ensName);
|
||||
});
|
||||
// The empty string is not a valid ENS name
|
||||
if (test.ensName) {
|
||||
assert_1.default.ok(!(0, index_js_1.isValidName)(test.ensName), "!isValidName");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
describe("Test dnsEncode", function () {
|
||||
const tests = [
|
||||
{ name: "ricmoo.com", result: "0x067269636d6f6f03636f6d00" },
|
||||
{ name: "ricmoo.com", length: 5, error: "exceeds 5 bytes" },
|
||||
{
|
||||
name: "a-very-long-label-without-a-length-override-foo-12345678901234567890",
|
||||
error: "exceeds 63 bytes"
|
||||
},
|
||||
{
|
||||
name: "a-very-long-label-with-a-length-override-to-255-foo-12345678901234567890",
|
||||
length: 255, result: "0x48612d766572792d6c6f6e672d6c6162656c2d776974682d612d6c656e6774682d6f766572726964652d746f2d3235352d666f6f2d313233343536373839303132333435363738393000"
|
||||
},
|
||||
];
|
||||
for (const test of tests) {
|
||||
it(`tests dnsEncode: ${test.name}`, function () {
|
||||
if (test.error) {
|
||||
assert_1.default.throws(() => {
|
||||
let result;
|
||||
if (test.length != null) {
|
||||
result = (0, index_js_2.dnsEncode)(test.name, test.length);
|
||||
}
|
||||
else {
|
||||
result = (0, index_js_2.dnsEncode)(test.name);
|
||||
}
|
||||
console.log("result", result);
|
||||
}, (error) => {
|
||||
return ((0, index_js_1.isError)(error, "INVALID_ARGUMENT") &&
|
||||
error.argument === "name" && error.value === test.name &&
|
||||
error.message.indexOf(test.error || "") >= 0);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (test.length != null) {
|
||||
assert_1.default.equal((0, index_js_2.dnsEncode)(test.name, test.length), test.result, "dnsEncode(name, length)");
|
||||
}
|
||||
else {
|
||||
assert_1.default.equal((0, index_js_2.dnsEncode)(test.name), test.result, "dnsEncode(name)");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
describe("Test EIP-191 Personal Message Hash", function () {
|
||||
const tests = [
|
||||
{
|
||||
test: "hello-world",
|
||||
message: "Hello World",
|
||||
hash: "0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2"
|
||||
},
|
||||
{
|
||||
test: "binary-message",
|
||||
message: new Uint8Array([0x42, 0x43]),
|
||||
hash: "0x0d3abc18ec299cf9b42ba439ac6f7e3e6ec9f5c048943704e30fc2d9c7981438"
|
||||
},
|
||||
{
|
||||
test: "hex-looking-string",
|
||||
message: "0x4243",
|
||||
hash: "0x6d91b221f765224b256762dcba32d62209cf78e9bebb0a1b758ca26c76db3af4"
|
||||
}
|
||||
];
|
||||
for (const test of tests) {
|
||||
it(`tests hashMessage: ${test.test}`, function () {
|
||||
assert_1.default.equal((0, index_js_1.hashMessage)(test.message), test.hash);
|
||||
});
|
||||
}
|
||||
});
|
||||
describe("Test Solidity Hash functions", function () {
|
||||
const tests = (0, utils_js_1.loadTests)("solidity-hashes");
|
||||
for (const test of tests) {
|
||||
it(`computes the solidity keccak256: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_1.solidityPackedKeccak256)(test.types, test.values), test.keccak256);
|
||||
});
|
||||
}
|
||||
for (const test of tests) {
|
||||
it(`computes the solidity sha256: ${test.name}`, function () {
|
||||
assert_1.default.equal((0, index_js_1.solidityPackedSha256)(test.types, test.values), test.sha256);
|
||||
});
|
||||
}
|
||||
const badTypes = [
|
||||
{ types: ["uint5"], values: [1] },
|
||||
{ types: ["bytes0"], values: ["0x"] },
|
||||
{ types: ["blorb"], values: [false] },
|
||||
];
|
||||
for (const { types, values } of badTypes) {
|
||||
it("correctly fails on invalid type", function () {
|
||||
assert_1.default.throws(function () {
|
||||
const result = (0, index_js_1.solidityPacked)(types, values);
|
||||
console.log(result);
|
||||
}, function (error) {
|
||||
return ((0, index_js_1.isError)(error, "INVALID_ARGUMENT") && error.argument === "type");
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=test-hash.js.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-hash.js","sourceRoot":"","sources":["../../src.ts/_tests/test-hash.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,0CAKqB;AAErB,yCAAsC;AAKtC,0CAAwC;AAExC,QAAQ,CAAC,gBAAgB,EAAE;IACvB,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAmB,UAAU,CAAC,CAAC;IAEtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACb,EAAE,CAAC,oBAAqB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAE,EAAE,EAAE;gBAClD,MAAM,MAAM,GAAG,IAAA,mBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEtC,gBAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;gBAEhD,2CAA2C;gBAC3C,IAAI,IAAI,CAAC,OAAO,EAAE;oBACd,gBAAM,CAAC,EAAE,CAAC,IAAA,sBAAW,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC;iBACvD;YACL,CAAC,CAAC,CAAC;SACN;KACJ;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,EAAE,CAAC,qCAAsC,IAAI,CAAC,KAAM,IAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAE,EAAE,EAAE;gBACnF,gBAAM,CAAC,MAAM,CAAC;oBACV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,OAAO,CAAE,EAAE,MAAM,EAAE,CAAE,KAAK,CAAE,EAAE;KAC5C,CAAC;IAEF,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,QAAQ,EAAE;QACtC,EAAE,CAAC,iCAAiC,EAAE;YAClC,gBAAM,CAAC,MAAM,CAAC;gBACV,MAAM,MAAM,GAAG,IAAA,yBAAc,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAC7C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC,EAAE,UAAU,KAAK;gBACd,OAAO,CAAC,IAAA,kBAAO,EAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;YAC7E,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAC"}
|
@ -1,2 +0,0 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-providers-avatar.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-providers-avatar.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-avatar.ts"],"names":[],"mappings":""}
|
@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const create_provider_js_1 = require("./create-provider.js");
|
||||
(0, create_provider_js_1.setupProviders)();
|
||||
describe("Resolve ENS avatar", function () {
|
||||
[
|
||||
{ title: "data", name: "data-avatar.tests.eth", value: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAMAAACeL25MAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyVpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkI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ErkJggg==" },
|
||||
{ title: "ipfs", name: "ipfs-avatar.tests.eth", value: "https:/\/gateway.ipfs.io/ipfs/QmQsQgpda6JAYkFoeVcj5iPbwV3xRcvaiXv3bhp1VuYUqw" },
|
||||
{ title: "url", name: "url-avatar.tests.eth", value: "https:/\/ethers.org/static/logo.png" },
|
||||
].forEach((test) => {
|
||||
it(`Resolves avatar for ${test.title}`, async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)("sepolia");
|
||||
const avatar = await provider.getAvatar(test.name);
|
||||
assert_1.default.equal(test.value, avatar, "avatar url");
|
||||
});
|
||||
});
|
||||
/*
|
||||
// @TODO: Set up some examples on goerli
|
||||
[
|
||||
{ title: "ERC-1155", name: "nick.eth", value: "https:/\/lh3.googleusercontent.com/hKHZTZSTmcznonu8I6xcVZio1IF76fq0XmcxnvUykC-FGuVJ75UPdLDlKJsfgVXH9wOSmkyHw0C39VAYtsGyxT7WNybjQ6s3fM3macE" },
|
||||
// { title: "ERC-721", name: "brantly.eth", value: "https:/\/api.wrappedpunks.com/images/punks/2430.png" }
|
||||
].forEach((test) => {
|
||||
it(`Resolves avatar for ${ test.title }`, async function() {
|
||||
this.timeout(60000);
|
||||
const provider = connect("mainnet");
|
||||
const avatar = await provider.getAvatar(test.name);
|
||||
assert.equal(avatar, test.value, "avatar url");
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
//# sourceMappingURL=test-providers-avatar.js.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-providers-avatar.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-avatar.ts"],"names":[],"mappings":";;;AAAA,4DAA4B;AAE5B,6DAA+D;AAE/D,IAAA,mCAAc,GAAE,CAAC;AAEjB,QAAQ,CAAC,oBAAoB,EAAE;IAC3B;QACI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,owCAAowC,EAAE;QAC7zC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,8EAA8E,EAAE;QACvI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,qCAAqC,EAAE;KAC/F,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACf,EAAE,CAAC,uBAAwB,IAAI,CAAC,KAAM,EAAE,EAAE,KAAK;YAC3C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,QAAQ,GAAG,IAAA,4BAAO,EAAC,SAAS,CAAC,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,gBAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACP;;;;;;;;;;;;;MAaE;AACF,CAAC,CAAC,CAAC"}
|
2
lib.commonjs/_tests/test-providers-ccip.d.ts
vendored
2
lib.commonjs/_tests/test-providers-ccip.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export {};
|
||||
//# sourceMappingURL=test-providers-ccip.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"test-providers-ccip.d.ts","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-ccip.ts"],"names":[],"mappings":""}
|
@ -1,150 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const index_js_1 = require("../index.js");
|
||||
const create_provider_js_1 = require("./create-provider.js");
|
||||
(0, create_provider_js_1.setupProviders)();
|
||||
describe("Test CCIP execution", function () {
|
||||
// This matches the verify method in the Solidity contract against the
|
||||
// processed data from the endpoint
|
||||
const verify = function (sender, data, result) {
|
||||
const check = (0, index_js_1.concat)([
|
||||
(0, index_js_1.toBeArray)((0, index_js_1.dataLength)(sender)), sender,
|
||||
(0, index_js_1.toBeArray)((0, index_js_1.dataLength)(data)), data
|
||||
]);
|
||||
assert_1.default.equal(result, (0, index_js_1.keccak256)(check), "response is equal");
|
||||
};
|
||||
const address = "0xaeaa06a37e6421ac63120d6daddee0ffa04b43e8";
|
||||
const networkName = "sepolia";
|
||||
const calldata = "0x1234";
|
||||
it("testGet passes under normal operation", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
// testGet(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address, enableCcipRead: true,
|
||||
data: "0xa5f3271e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
|
||||
};
|
||||
const result = await provider.call(tx);
|
||||
verify(address, calldata, result);
|
||||
});
|
||||
it("testGet should fail with CCIP not explicitly enabled by overrides", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
// testGet(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address,
|
||||
data: "0xa5f3271e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
|
||||
};
|
||||
await assert_1.default.rejects(async function () {
|
||||
const result = await provider.call(tx);
|
||||
console.log(result);
|
||||
}, (error) => {
|
||||
const offchainErrorData = (0, index_js_1.concat)([
|
||||
"0x556f1830000000000000000000000000",
|
||||
address,
|
||||
"0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000"
|
||||
]);
|
||||
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData);
|
||||
});
|
||||
});
|
||||
it("testGet should fail with CCIP explicitly disabled on provider", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
provider.disableCcipRead = true;
|
||||
// testGetFail(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address, enableCcipRead: true,
|
||||
data: "0xa5f3271e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
|
||||
};
|
||||
await assert_1.default.rejects(async function () {
|
||||
const result = await provider.call(tx);
|
||||
console.log(result);
|
||||
}, (error) => {
|
||||
const offchainErrorData = (0, index_js_1.concat)([
|
||||
"0x556f1830000000000000000000000000",
|
||||
address,
|
||||
"0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000"
|
||||
]);
|
||||
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData);
|
||||
});
|
||||
});
|
||||
it("testGetFail should fail if all URLs 5xx", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
// testGetFail(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address, enableCcipRead: true,
|
||||
data: "0x36f9cea6000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
|
||||
};
|
||||
await assert_1.default.rejects(async function () {
|
||||
const result = await provider.call(tx);
|
||||
console.log(result);
|
||||
}, (error) => {
|
||||
const infoJson = '{"urls":["https:/\/ethers.ricmoo.workers.dev/status/500/{sender}/{data}"],"errorMessages":["hello world"]}';
|
||||
return ((0, index_js_1.isError)(error, "OFFCHAIN_FAULT") && error.reason === "500_SERVER_ERROR" &&
|
||||
JSON.stringify(error.info) === infoJson);
|
||||
});
|
||||
});
|
||||
it("testGetSenderFail should fail if sender does not match", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
// testGetSenderFail(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address, enableCcipRead: true,
|
||||
data: "0x64bff6d1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000",
|
||||
};
|
||||
await assert_1.default.rejects(async function () {
|
||||
const result = await provider.call(tx);
|
||||
console.log(result);
|
||||
}, (error) => {
|
||||
const errorArgsJson = '["0x0000000000000000000000000000000000000000",["https://ethers.ricmoo.workers.dev/test-ccip-read/{sender}/{data}"],"0x1234","0xb1494be1","0x4d792065787472612064617461"]';
|
||||
const offchainErrorData = "0x556f1830000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
|
||||
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData &&
|
||||
error.revert &&
|
||||
error.revert.signature === "OffchainLookup(address,string[],bytes,bytes4,bytes)" &&
|
||||
JSON.stringify(error.revert.args) === errorArgsJson);
|
||||
});
|
||||
});
|
||||
it("testGetMissing should fail if early URL 4xx", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
// testGetMissing(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address, enableCcipRead: true,
|
||||
data: "0x4ece8d7d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
|
||||
};
|
||||
await assert_1.default.rejects(async function () {
|
||||
const result = await provider.call(tx);
|
||||
console.log(result);
|
||||
}, (error) => {
|
||||
const infoJson = '{"url":"https:/\/ethers.ricmoo.workers.dev/status/404/{sender}/{data}","errorMessage":"hello world"}';
|
||||
return ((0, index_js_1.isError)(error, "OFFCHAIN_FAULT") && error.reason === "404_MISSING_RESOURCE" &&
|
||||
JSON.stringify(error.info || "") === infoJson);
|
||||
});
|
||||
});
|
||||
it("testGetFallback passes if any URL returns correctly", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
// testGetFallback(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address, enableCcipRead: true,
|
||||
data: "0xedf4a021000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
|
||||
};
|
||||
const result = await provider.call(tx);
|
||||
verify(address, calldata, result);
|
||||
});
|
||||
it("testPost passes under normal operation", async function () {
|
||||
this.timeout(60000);
|
||||
const provider = (0, create_provider_js_1.connect)(networkName);
|
||||
// testPost(bytes callData = "0x1234")
|
||||
const tx = {
|
||||
to: address, enableCcipRead: true,
|
||||
data: "0x66cab49d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
|
||||
};
|
||||
const result = await provider.call(tx);
|
||||
verify(address, calldata, result);
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=test-providers-ccip.js.map
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user