Skip to content

Refactor pledge processing in AllOrNothing and KeepWhatsRaised contracts#36

Open
mahabubAlahi wants to merge 1 commit intooz-audit-fixesfrom
oz-fix-issue-52
Open

Refactor pledge processing in AllOrNothing and KeepWhatsRaised contracts#36
mahabubAlahi wants to merge 1 commit intooz-audit-fixesfrom
oz-fix-issue-52

Conversation

@mahabubAlahi
Copy link
Collaborator

  • Updated the _pledge function to ensure pledgeAmount and shippingFee are always in the token's native decimals, removing the need for denormalization by the caller.
  • Enhanced documentation for the _pledge function to clarify parameter requirements and processing logic.
  • Adjusted related calculations and state updates to reflect the new handling of pledge amounts and fees.

- Updated the _pledge function to ensure pledgeAmount and shippingFee are always in the token's native decimals, removing the need for denormalization by the caller.
- Enhanced documentation for the _pledge function to clarify parameter requirements and processing logic.
- Adjusted related calculations and state updates to reflect the new handling of pledge amounts and fees.
@mahabubAlahi mahabubAlahi self-assigned this Mar 3, 2026
@mahabubAlahi mahabubAlahi added the enhancement New feature or request label Mar 3, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6573537315

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +302 to +303
uint256 pledgeAmountInTokenDecimals = _denormalizeAmount(pledgeToken, pledgeAmount);
uint256 shippingFeeInTokenDecimals = _denormalizeAmount(pledgeToken, shippingFee);

Choose a reason for hiding this comment

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

P2 Badge Validate token before denormalizing reward pledge values

pledgeForAReward now denormalizes pledgeAmount and shippingFee before _pledge runs the INFO.isTokenAccepted guard, so an unaccepted token address that does not implement decimals() (e.g., EOA or non-ERC20 contract) will revert during _denormalizeAmount instead of returning the expected AllOrNothingTokenNotAccepted error. This changes failure semantics for invalid token inputs and can break callers/tests that depend on deterministic custom-error handling for unsupported tokens.

Useful? React with 👍 / 👎.

pledgeAmount += tempReward.rewardValue;
}
_pledge(pledgeId, backer, pledgeToken, reward[0], pledgeAmount, tip, reward, tokenSource);
uint256 pledgeAmountInTokenDecimals = _denormalizeAmount(pledgeToken, pledgeAmount);

Choose a reason for hiding this comment

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

P2 Badge Check token acceptance before reward amount denormalization

The reward path now calls _denormalizeAmount(pledgeToken, pledgeAmount) before _pledge performs INFO.isTokenAccepted, so passing an unsupported token without a valid decimals() implementation reverts early with a low-level decode failure rather than KeepWhatsRaisedTokenNotAccepted. This is a regression in input-validation behavior for invalid tokens and makes error handling less predictable for integrations.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant