Skip to content

Commit

Permalink
Optimize buyer creation (#885)
Browse files Browse the repository at this point in the history
  • Loading branch information
zajck committed Jan 9, 2024
1 parent 71e80a8 commit d7d16e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit d7d16e6

Please sign in to comment.