Skip to content

Conversation

@kien-ngo
Copy link
Contributor

@kien-ngo kien-ngo commented Nov 1, 2024

Problem solved

Short description of the bug fixed or feature added


PR-Codex overview

This PR focuses on optimizing the transferBatch functionality for ERC20 token transfers by implementing a new method to group and consolidate transfer records, reducing redundant transactions.

Detailed summary

  • Introduced optimizeTransferContent function to consolidate transfers with the same recipient.
  • Updated transferBatch to utilize optimized transfer data.
  • Enhanced test cases to validate the new optimization logic.
  • Adjusted token minting amounts in tests to reflect changes.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@changeset-bot
Copy link

changeset-bot bot commented Nov 1, 2024

🦋 Changeset detected

Latest commit: f98059c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
thirdweb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Nov 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 1:34am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 1:34am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 1:34am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 1:34am

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 1, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Contributor Author

kien-ngo commented Nov 1, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @kien-ngo and the rest of your teammates on Graphite Graphite

@github-actions
Copy link
Contributor

github-actions bot commented Nov 1, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 43 KB (0%) 860 ms (0%) 3.3 s (+36.41% 🔺) 4.1 s
thirdweb (cjs) 103.02 KB (0%) 2.1 s (0%) 7.4 s (+36.74% 🔺) 9.4 s
thirdweb (minimal + tree-shaking) 4.85 KB (0%) 97 ms (0%) 861 ms (+159.69% 🔺) 958 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 72 ms (+74.88% 🔺) 81 ms
thirdweb/react (minimal + tree-shaking) 17.57 KB (0%) 352 ms (0%) 687 ms (+65.29% 🔺) 1.1 s

} else {
amountWei = item.amountWei;
}
const matchingIndex = optimizedData.findIndex(
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit messy. You should use reduce for this use case. Very useful to transform an array into a map (de duping keys in the process). Then you can get an array back from the map by just getting all the entries

@codecov
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 89.58333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 45.47%. Comparing base (70ed73e) to head (f98059c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...irdweb/src/extensions/erc20/write/transferBatch.ts 89.58% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5256      +/-   ##
==========================================
+ Coverage   45.44%   45.47%   +0.02%     
==========================================
  Files        1067     1067              
  Lines       55459    55486      +27     
  Branches     4009     4013       +4     
==========================================
+ Hits        25206    25230      +24     
- Misses      29562    29565       +3     
  Partials      691      691              
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 70ed73e
packages 40.54% <89.58%> (+0.02%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...irdweb/src/extensions/erc20/write/transferBatch.ts 91.80% <89.58%> (+0.62%) ⬆️

... and 1 file with indirect coverage changes

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 5, 2024

Merge activity

## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on optimizing the `transferBatch` functionality for ERC20 tokens by improving the way transfers are processed, allowing for batching of transfers to the same recipient, and enhancing the test coverage for these changes.

### Detailed summary
- Added `optimizeTransferContent` function to group transfers by recipient.
- Refactored `transferBatch` to use optimized transfer content.
- Updated tests to verify optimized transfers and ensure correctness.
- Increased token minting in tests from 100 to 200 tokens.
- Enhanced test cases to validate optimized transfer behavior.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants