Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add eventemitter3 #6823

Merged
merged 9 commits into from
Mar 7, 2024
Merged

add eventemitter3 #6823

merged 9 commits into from
Mar 7, 2024

Conversation

luu-alex
Copy link
Contributor

@luu-alex luu-alex commented Feb 21, 2024

replacing nodejs and web3js implemetation of eventemitter for the usage of eventemitter3 for react-native compatibiltiy.

Description

Please include a summary of the changes and be sure to follow our Contribution Guidelines.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run lint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:coverage and my test cases cover all the lines and branches of the added code.
  • I ran npm run build and tested dist/web3.min.js in a browser.
  • I have tested my code on the live network.
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have linked Issue(s) with this PR in "Linked Issues" menu.

Copy link

github-actions bot commented Feb 21, 2024

Bundle Stats

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
10 622.93 kB → 618.51 kB (-4.41 kB) -0.71%
Changeset
File Δ Size
../web3-utils/node_modules/eventemitter3/index.js 🆕 +8.93 kB 0 B → 8.93 kB
../web3-utils/lib/commonjs/web3_eip1193_provider.js 📈 +21 B (+0.47%) 4.4 kB → 4.42 kB
../web3-utils/lib/commonjs/event_emitter.js 📉 -2.76 kB (-63.58%) 4.34 kB → 1.58 kB
../../node_modules/events/events.js 🔥 -14.54 kB (-100%) 14.54 kB → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

Asset File Size % Changed
web3.min.js 603.92 kB → 599.5 kB (-4.41 kB) -0.73%

Unchanged

Asset File Size % Changed
../lib/commonjs/index.d.ts 8.63 kB 0%
../lib/commonjs/accounts.d.ts 3.89 kB 0%
../lib/commonjs/types.d.ts 2.45 kB 0%
../lib/commonjs/web3.d.ts 1.35 kB 0%
../lib/commonjs/web3_eip6963.d.ts 1.2 kB 0%
../lib/commonjs/abi.d.ts 999 B 0%
../lib/commonjs/eth.exports.d.ts 280 B 0%
../lib/commonjs/providers.exports.d.ts 183 B 0%
../lib/commonjs/version.d.ts 60 B 0%

Copy link

github-actions bot commented Feb 21, 2024

Benchmark

Benchmark suite Current: bb5ac86 Previous: 6c075db Ratio
processingTx 9536 ops/sec (±4.45%) 9301 ops/sec (±4.81%) 0.98
processingContractDeploy 43686 ops/sec (±6.16%) 39129 ops/sec (±7.62%) 0.90
processingContractMethodSend 20842 ops/sec (±6.89%) 19443 ops/sec (±5.19%) 0.93
processingContractMethodCall 40186 ops/sec (±6.32%) 38971 ops/sec (±6.34%) 0.97
abiEncode 49473 ops/sec (±6.27%) 44252 ops/sec (±6.92%) 0.89
abiDecode 33607 ops/sec (±6.79%) 30419 ops/sec (±8.89%) 0.91
sign 1655 ops/sec (±3.07%) 1656 ops/sec (±4.08%) 1.00
verify 381 ops/sec (±0.57%) 373 ops/sec (±0.78%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

codecov bot commented Feb 24, 2024

Codecov Report

Merging #6823 (111bcfb) into 4.x (4358140) will increase coverage by 4.61%.
Report is 192 commits behind head on 4.x.
The diff coverage is 100.00%.

❗ Current head 111bcfb differs from pull request most recent head bb5ac86. Consider uploading reports for the commit bb5ac86 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##              4.x    #6823      +/-   ##
==========================================
+ Coverage   87.37%   91.98%   +4.61%     
==========================================
  Files         197      215      +18     
  Lines        7548     8162     +614     
  Branches     2059     2201     +142     
==========================================
+ Hits         6595     7508     +913     
+ Misses        953      654     -299     
Flag Coverage Δ
UnitTests 91.98% <100.00%> (+4.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
web3 ∅ <ø> (∅)
web3-core ∅ <ø> (∅)
web3-errors ∅ <ø> (∅)
web3-eth ∅ <ø> (∅)
web3-eth-abi ∅ <ø> (∅)
web3-eth-accounts ∅ <ø> (∅)
web3-eth-contract ∅ <ø> (∅)
web3-eth-ens ∅ <ø> (∅)
web3-eth-iban ∅ <ø> (∅)
web3-eth-personal ∅ <ø> (∅)
web3-net ∅ <ø> (∅)
web3-providers-http ∅ <ø> (∅)
web3-providers-ipc ∅ <ø> (∅)
web3-providers-ws ∅ <ø> (∅)
web3-rpc-methods ∅ <ø> (∅)
web3-utils ∅ <ø> (∅)
web3-validator ∅ <ø> (∅)

@@ -97,23 +97,6 @@ describe('IPCProvider', () => {
expect(end).toHaveBeenCalled();
});

it('connection error', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed connection error test, mock implementation doesn't seem to emit error for this one unit test so i added an integration test to substitute it
https://github.com/web3/web3.js/pull/6823/files#diff-ea6da20dfb39c75b95f9a7cb4cf0e3f9d1e353fe0aab69f28ef83497e86ff556R140

@@ -755,7 +756,7 @@ describe('Contract', () => {

const clonnedContract = contract.clone();

expect(JSON.stringify(contract)).toStrictEqual(JSON.stringify(clonnedContract));
expect(stringify(contract)).toStrictEqual(stringify(clonnedContract));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eventemitter3 has a circular structure so we use stringify library to parse properly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats error for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    TypeError: Converting circular structure to JSON
        --> starting at object with constructor 'EventEmitter'

@@ -85,28 +85,14 @@ describe('WebSocketProvider', () => {
ws.disconnect(code, data);
expect(close).toHaveBeenCalledWith(code, data);
});
it('connection error', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed connection error test, mock implementation doesn't seem to emit error for this one unit test so i added an integration test to substitute it
https://github.com/web3/web3.js/pull/6823/files#diff-ea6da20dfb39c75b95f9a7cb4cf0e3f9d1e353fe0aab69f28ef83497e86ff556R140

@jdevcs
Copy link
Contributor

jdevcs commented Feb 27, 2024

Bundle Stats

Hey there, this message comes from a github action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Asset Old size New size Diff Diff %
Total 0 615 KB 615 KB -
View detailed bundle breakdown

Its not showing difference

@avkos avkos self-requested a review February 27, 2024 14:47
Copy link
Contributor

@avkos avkos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take a look at tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants