Skip to content

Commit e7a4ee0

Browse files
committed
Updates token holder extension to match erc-7590.
1 parent e0f1e59 commit e7a4ee0

File tree

7 files changed

+260
-784
lines changed

7 files changed

+260
-784
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
pragma solidity ^0.8.21;
4+
5+
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6+
7+
interface IERC7590 is IERC165 {
8+
/**
9+
* @notice Used to notify listeners that the token received ERC-20 tokens.
10+
* @param erc20Contract The address of the ERC-20 smart contract
11+
* @param toTokenId The ID of the token receiving the ERC-20 tokens
12+
* @param from The address of the account from which the tokens are being transferred
13+
* @param amount The number of ERC-20 tokens received
14+
*/
15+
event ReceivedERC20(
16+
address indexed erc20Contract,
17+
uint256 indexed toTokenId,
18+
address indexed from,
19+
uint256 amount
20+
);
21+
22+
/**
23+
* @notice Used to notify the listeners that the ERC-20 tokens have been transferred.
24+
* @param erc20Contract The address of the ERC-20 smart contract
25+
* @param fromTokenId The ID of the token from which the ERC-20 tokens have been transferred
26+
* @param to The address receiving the ERC-20 tokens
27+
* @param amount The number of ERC-20 tokens transferred
28+
*/
29+
event TransferredERC20(
30+
address indexed erc20Contract,
31+
uint256 indexed fromTokenId,
32+
address indexed to,
33+
uint256 amount
34+
);
35+
36+
/**
37+
* @notice Used to retrieve the given token's specific ERC-20 balance
38+
* @param erc20Contract The address of the ERC-20 smart contract
39+
* @param tokenId The ID of the token being checked for ERC-20 balance
40+
* @return The amount of the specified ERC-20 tokens owned by a given token
41+
*/
42+
function balanceOfERC20(
43+
address erc20Contract,
44+
uint256 tokenId
45+
) external view returns (uint256);
46+
47+
/**
48+
* @notice Transfer ERC-20 tokens from a specific token.
49+
* @dev The balance MUST be transferred from this smart contract.
50+
* @dev Implementers should validate that the `msg.sender` is either the token owner or approved to manage it before calling this.
51+
* @dev Must increase the transfer-out-nonce for the tokenId
52+
* @param erc20Contract The address of the ERC-20 smart contract
53+
* @param tokenId The ID of the token to transfer the ERC-20 tokens from
54+
* @param amount The number of ERC-20 tokens to transfer
55+
* @param data Additional data with no specified format, to allow for custom logic
56+
*/
57+
function transferHeldERC20FromToken(
58+
address erc20Contract,
59+
uint256 tokenId,
60+
address to,
61+
uint256 amount,
62+
bytes memory data
63+
) external;
64+
65+
/**
66+
* @notice Transfer ERC-20 tokens to a specific token.
67+
* @dev The ERC-20 smart contract must have approval for this contract to transfer the ERC-20 tokens.
68+
* @dev The balance MUST be transferred from the `msg.sender`.
69+
* @param erc20Contract The address of the ERC-20 smart contract
70+
* @param tokenId The ID of the token to transfer ERC-20 tokens to
71+
* @param amount The number of ERC-20 tokens to transfer
72+
* @param data Additional data with no specified format, to allow for custom logic
73+
*/
74+
function transferERC20ToToken(
75+
address erc20Contract,
76+
uint256 tokenId,
77+
uint256 amount,
78+
bytes memory data
79+
) external;
80+
81+
/**
82+
* @notice Nonce increased every time an ERC20 token is transferred out of a token
83+
* @param tokenId The ID of the token to check the nonce for
84+
* @return The nonce of the token
85+
*/
86+
function erc20TransferOutNonce(
87+
uint256 tokenId
88+
) external view returns (uint256);
89+
}

contracts/RMRK/extension/tokenHolder/IRMRKTokenHolder.sol

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)