Skip to content

Commit 7e1361b

Browse files
小白小白
authored andcommitted
feat: add initializeV2 reinitializer for upgrade migration
Address review feedback: totalAgentBalances must be initialized when upgrading from V1 to prevent withdrawal underflow and emergencyWithdraw bypass.
1 parent 3224c6b commit 7e1361b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

contracts/BAP578.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ contract BAP578 is
137137
freeMintsPerUser = 3;
138138
}
139139

140+
/**
141+
* @dev Reinitializer for upgrading from V1 (without totalAgentBalances tracking).
142+
* Must be called via upgradeToAndCall() when upgrading a deployed V1 proxy.
143+
* The caller should compute _totalAgentBalances off-chain by summing all
144+
* agentStates[tokenId].balance values for existing tokens.
145+
*/
146+
function initializeV2(uint256 _totalAgentBalances) external reinitializer(2) {
147+
totalAgentBalances = _totalAgentBalances;
148+
}
149+
140150
// ============================================
141151
// MAIN FUNCTIONS
142152
// ============================================

0 commit comments

Comments
 (0)