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

[BBE-01C] Inefficient Creation of Buyer #885

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions contracts/protocol/bases/BuyerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@ contract BuyerBase is ProtocolBase, IBosonAccountEvents {
//Check for zero address
if (_buyer.wallet == address(0)) revert InvalidAddress();

//Check active is not set to false
if (!_buyer.active) revert MustBeActive();

// Get the next account id and increment the counter
uint256 buyerId = protocolCounters().nextAccountId++;

//check that the wallet address is unique to one buyer id
if (protocolLookups().buyerIdByWallet[_buyer.wallet] != 0) revert BuyerAddressMustBeUnique();

_buyer.id = buyerId;
storeBuyer(_buyer);

Expand Down
6 changes: 6 additions & 0 deletions contracts/protocol/facets/BuyerHandlerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ contract BuyerHandlerFacet is BuyerBase {
* @param _buyer - the fully populated struct with buyer id set to 0x0
*/
function createBuyer(Buyer memory _buyer) external buyersNotPaused nonReentrant {
//Check active is not set to false
if (!_buyer.active) revert MustBeActive();

//check that the wallet address is unique to one buyer id
if (protocolLookups().buyerIdByWallet[_buyer.wallet] != 0) revert BuyerAddressMustBeUnique();

createBuyerInternal(_buyer);
}

Expand Down