Skip to content

Commit 2420ae7

Browse files
committed
PVE002-2: Revisited Logic to Forward collectedTokens
1 parent ae39b45 commit 2420ae7

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

contracts/addon/SelfNftAddon.sol

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ contract SelfNftAddon is
2323
{
2424
using SafeERC20 for IERC20;
2525

26+
/**
27+
* @title SelfNft
28+
* @author Self dev team
29+
* @custom:version v2.3.1
30+
* @custom:date 28 sept 2023
31+
32+
------------v2.3.1 changes------------
33+
- update NameRegistered event to include agent and payment token address
34+
- update removeChainlinkPricefeed to transfer the collected tokens of the respective price feed to the owner.
35+
36+
*/
37+
2638
/**
2739
* The SelfNftMultitokenAddon smart contract serves as an extension to the SelfNft.sol contract, enhancing its capabilities by allowing users to register names as Non-Fungible Tokens (NFTs) using multiple types of tokens, rather than being restricted to a single token. This is made possible through real-time price feeds provided by Chainlink oracles, which ensure that the cost of name registration is accurately calculated in the chosen token at the time of purchase. It also incorporates a server-maintained $SELF price to ensure accurate and up-to-date pricing for name registrations.
2840
*
@@ -127,7 +139,7 @@ contract SelfNftAddon is
127139
selfNft.safeTransferFrom(address(this), msg.sender, _hashString(_name));
128140

129141
// Emit an event to log the successful name registration
130-
emit NameRegistered(msg.sender, _name, _hashString(_name));
142+
emit NameRegistered(msg.sender, _name, _agentAddress, _paymentToken);
131143

132144
return true;
133145
}
@@ -415,6 +427,13 @@ contract SelfNftAddon is
415427
// Remove the Chainlink price feed for the payment token
416428
chainlinkPriceFeeds[_paymentToken].paymentToken = address(0);
417429

430+
// Transfer the collected tokens to the contract owner if any
431+
uint _collectedTokens = chainlinkPriceFeeds[_paymentToken]
432+
.collectedTokens;
433+
434+
if (_collectedTokens > 0)
435+
IERC20(_paymentToken).safeTransfer(msg.sender, _collectedTokens);
436+
418437
// Emit an event to log the removal of the Chainlink price feed
419438
emit ChainlinkPriceFeedRemoved(_paymentToken);
420439
}
@@ -637,5 +656,4 @@ contract SelfNftAddon is
637656
) external pure returns (bytes4) {
638657
return IERC721Receiver.onERC721Received.selector;
639658
}
640-
641659
}

contracts/addon/SelfNftAddonStorage.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ contract SelfNftAddonStorage {
4949
mapping(address => Agent) public agents;
5050

5151
//=================Events======================
52-
event NameRegistered(address indexed owner, string name, uint tokenId);
52+
event NameRegistered(
53+
address indexed owner,
54+
string name,
55+
address indexed agent,
56+
address indexed paymentToken
57+
);
5358
event CollectedTokensForwarded(address indexed receiver, uint256 amount);
5459
event SelfNftUpdated(address indexed newSelfNft);
5560
event PaymentTokenUpdated(address indexed newBuyToken);

0 commit comments

Comments
 (0)