Skip to content

refactor(erc1410): introduce balance and supply helper methods#833

Merged
marcosio merged 9 commits intodevelopmentfrom
feat/migrateTotalSupplyAndBalancesToERC20
Feb 16, 2026
Merged

refactor(erc1410): introduce balance and supply helper methods#833
marcosio merged 9 commits intodevelopmentfrom
feat/migrateTotalSupplyAndBalancesToERC20

Conversation

@marcosio
Copy link
Copy Markdown
Contributor

@marcosio marcosio commented Feb 8, 2026

  • rename storage fields and to and in ERC1410BasicStorage
  • replace direct balance updates with and methods
  • add and methods for total supply adjustments
  • remove redundant and implementations from ERC1410BasicStorageWrapperRead
  • update to handle migration from legacy storage to new balance/supply helpers
  • add to Internals abstract contract
  • add visibility override in ERC20StorageWrapper2
  • fix ProtectedPartitions initialize function to assign return value to success_

Description

Type of change

  • Bug fix 🐞
  • New feature ✨
  • Breaking change 💥
  • Documentation update 📖
  • Refactor 🔧

Testing

Node version:

  • 20
  • 22
  • 24

Checklist

  • Style Guidelines followed ✅
  • Documentation Updated 📚
  • Linters - No New Warnings ⚠️
  • Local Tests Pass ✅
  • Effective Tests Added ✔️
  • No reduction of Coverage

- rename storage fields  and  to  and  in ERC1410BasicStorage
- replace direct balance updates with  and  methods
- add  and  methods for total supply adjustments
- remove redundant  and  implementations from ERC1410BasicStorageWrapperRead
- update  to handle migration from legacy storage to new balance/supply helpers
- add  to Internals abstract contract
- add  visibility override in ERC20StorageWrapper2
- fix ProtectedPartitions initialize function to assign return value to success_

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
@hedera-eng-infrastructure
Copy link
Copy Markdown

hedera-eng-infrastructure commented Feb 8, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@marcosio marcosio self-assigned this Feb 9, 2026
@marcosio marcosio marked this pull request as draft February 9, 2026 08:14
…ategy

- create MigrationFacetTest contract for testing legacy ERC1410 storage
- rename _totalSupply_ to DEPRECATED_totalSupply and _balances_ to
  DEPRECATED_balances in ERC1410BasicStorage
- implement internal migration functions _migrateTotalSupplyIfNeeded and
  _migrateBalanceIfNeeded in ERC20StorageWrapper1
- add view functions to check legacy vs new storage state
- update _totalSupply and _balanceOf to prioritize legacy storage then
  fall back to new storage
- add comprehensive test suite for migration scenarios including
  transfer-triggered migration and idempotency
- create registerMigrationFacetFixture for test setup
- refactor variable names in existing tests to avoid naming conflicts
- remove unused imports and console.log statements

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
- add registerMigrationFacetFixture for ERC20 storage migration testing
- implement _migrateTotalSupplyIfNeeded and _migrateBalanceIfNeeded functions
- emit Transfer events in ERC3643, Lock, Hold, and Clearing storage wrappers
- update ERC1410 storage variable names to DEPRECATED_totalSupply and DEPRECATED_balances
- add comprehensive ERC20 storage migration test suite
- update atsRegistry.data.ts with new event signature for ERC1410BasicStorageWrapper
- reorder TransferByPartition emission in ERC1410BasicStorageWrapper

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
@marcosio marcosio marked this pull request as ready for review February 11, 2026 17:02
@marcosio marcosio changed the title 🔧 refactor(erc1410): introduce balance and supply helper methods refactor(erc1410): introduce balance and supply helper methods Feb 12, 2026
…RC20

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>

# Conflicts:
#	packages/ats/contracts/scripts/domain/atsRegistry.data.ts
…RC20

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
…justment execution

- add important note about on-chain view methods immediately reflecting adjusted amounts
- document event emission delay until next on-chain operation
- specify that backend systems may show mismatched balances during the interim window
- recommend periodic reconciliation with on-chain view methods around execution dates

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
… method

replace _emitTransferEvent calls with direct emit Transfer statements in ERC20StorageWrapper2
remove _emitTransferEvent function from Internals base contract
update clearing, hold, lock, and ERC3643 storage wrappers to use direct event emission
maintain identical functionality while reducing code complexity

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
…tion strategy

add totalSupply and balances fields to ERC20Storage struct in ERC20StorageWrapper1
implement _migrateTotalSupplyIfNeeded and _migrateBalanceIfNeeded lazy migration functions
maintain backward compatibility with legacy ERC1410BasicStorage values
rename totalSupply to DEPRECATED_totalSupply and balances to DEPRECATED_balances
replace _emitTransferEvent wrapper with direct emit Transfer statements
add _increaseBalance, _reduceBalance, _increaseTotalSupply, _reduceTotalSupply helper methods
add MigrationFacetTest contract for testing migration scenarios
achieve ~50-70 gas savings per transfer from simplified event emission

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
…nd implement resolver key

change base contract from ERC20StorageWrapper1 to Common
remove abstract keyword to make contract deployable for testing
add getStaticResolverKey function returning keccak256(MigrationFacetTest)

Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
@marcosio marcosio merged commit a942765 into development Feb 16, 2026
13 checks passed
@marcosio marcosio deleted the feat/migrateTotalSupplyAndBalancesToERC20 branch February 16, 2026 13:23
ruben-martinez-iob pushed a commit that referenced this pull request Feb 16, 2026
Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
Signed-off-by: Ruben Martinez <ruben.martinez@io.builders>
jaime-iobermudez pushed a commit that referenced this pull request Feb 27, 2026
Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
jaime-iobermudez pushed a commit that referenced this pull request Mar 2, 2026
Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
jaime-iobermudez pushed a commit that referenced this pull request Mar 2, 2026
Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
jaime-iobermudez pushed a commit that referenced this pull request Mar 3, 2026
Signed-off-by: Marcos Serradilla Diez <marcos@io.builders>
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