mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
feat/implement ERC721 deposit/withdraw
This commit is contained in:
parent
9a070412d5
commit
f4b4cbfc5e
14
contracts/mainnet/connectors/basic-ERC721/events.sol
Normal file
14
contracts/mainnet/connectors/basic-ERC721/events.sol
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
contract Events {
|
||||||
|
event LogDepositERC721(
|
||||||
|
address indexed erc721,
|
||||||
|
address from,
|
||||||
|
uint256 tokenId
|
||||||
|
);
|
||||||
|
event LogWithdrawERC721(
|
||||||
|
address indexed erc721,
|
||||||
|
uint256 tokenId,
|
||||||
|
address indexed to
|
||||||
|
);
|
||||||
|
}
|
58
contracts/mainnet/connectors/basic-ERC721/main.sol
Normal file
58
contracts/mainnet/connectors/basic-ERC721/main.sol
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title Basic.
|
||||||
|
* @dev Deposit & Withdraw from DSA.
|
||||||
|
*/
|
||||||
|
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||||
|
|
||||||
|
import {DSMath} from "../../common/math.sol";
|
||||||
|
import {Basic} from "../../common/basic.sol";
|
||||||
|
import {Events} from "./events.sol";
|
||||||
|
|
||||||
|
abstract contract BasicResolver is Events, DSMath, Basic {
|
||||||
|
/**
|
||||||
|
* @dev Deposit Assets To Smart Account.
|
||||||
|
* @notice Deposit a ERC721 token to DSA
|
||||||
|
* @param token The address of the token to deposit.
|
||||||
|
* @param tokenId The id of token to deposit.
|
||||||
|
*/
|
||||||
|
function depositERC721(address token, uint256 tokenId)
|
||||||
|
public
|
||||||
|
payable
|
||||||
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
|
{
|
||||||
|
IERC721 tokenContract = IERC721(token);
|
||||||
|
tokenContract.safeTransferFrom(msg.sender, address(this), tokenId);
|
||||||
|
|
||||||
|
_eventName = "LogDepositERC721(address,address,uint256)";
|
||||||
|
_eventParam = abi.encode(token, msg.sender, tokenId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Withdraw Assets To Smart Account.
|
||||||
|
* @notice Withdraw a ERC721 token from DSA
|
||||||
|
* @param token The address of the token to deposit.
|
||||||
|
* @param tokenId The id of token to deposit.
|
||||||
|
* @param to The address to receive the token upon withdrawal
|
||||||
|
*/
|
||||||
|
function withdrawERC721(
|
||||||
|
address token,
|
||||||
|
uint256 tokenId,
|
||||||
|
address payable to
|
||||||
|
)
|
||||||
|
public
|
||||||
|
payable
|
||||||
|
returns (string memory _eventName, bytes memory _eventParam)
|
||||||
|
{
|
||||||
|
IERC721 tokenContract = IERC721(token);
|
||||||
|
tokenContract.safeTransferFrom(address(this), to, tokenId);
|
||||||
|
|
||||||
|
_eventName = "LogWithdrawERC721(address,uint256,address)";
|
||||||
|
_eventParam = abi.encode(token, tokenId, to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract ConnectV2Basic is BasicResolver {
|
||||||
|
string public constant name = "BASIC-ERC721-A";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user