Skip to content

Commit

Permalink
Merge pull request #1 from maxisch/patch-1
Browse files Browse the repository at this point in the history
Prevent double charging on idempotent register calls
  • Loading branch information
kingster-will authored Dec 12, 2024
2 parents ceda981 + 10129bd commit 9e81908
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions contracts/registries/IPAssetRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ contract IPAssetRegistry is
uint256 tokenId,
address registerFeePayer
) internal override returns (address id) {
id = _registerIpAccount(chainid, tokenContract, tokenId);
IIPAccount ipAccount = IIPAccount(payable(id));

// return if the IP was already registered
if (bytes(ipAccount.getString("NAME")).length != 0) {
return id;
}

IPAssetRegistryStorage storage $ = _getIPAssetRegistryStorage();

// Pay registration fee
Expand All @@ -112,14 +120,6 @@ contract IPAssetRegistry is
emit IPRegistrationFeePaid(registerFeePayer, treasury, feeToken, feeAmount);
}

id = _registerIpAccount(chainid, tokenContract, tokenId);
IIPAccount ipAccount = IIPAccount(payable(id));

// return if the IP was already registered
if (bytes(ipAccount.getString("NAME")).length != 0) {
return id;
}

(string memory name, string memory uri) = _getNameAndUri(chainid, tokenContract, tokenId);
uint256 registrationDate = block.timestamp;
ipAccount.setString("NAME", name);
Expand Down

0 comments on commit 9e81908

Please sign in to comment.