-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathAuctionOfferingFactory.sol
More file actions
114 lines (102 loc) · 4.07 KB
/
AuctionOfferingFactory.sol
File metadata and controls
114 lines (102 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* @title AuctionOfferingFactory
* @dev Factory for creating new Auction offerings
*/
import "./OfferingRegistry.sol";
import "./OfferingFactory.sol";
import "./AuctionOffering.sol";
import "./proxy/Forwarder.sol";
contract AuctionOfferingFactory is OfferingFactory {
constructor(ENSRegistry ens, OfferingRegistry offeringRegistry) OfferingFactory(ens, offeringRegistry) {}
/**
* @dev Deploys new auction offering and registers it to OfferingRegistry
* @param name string Plaintext ENS name
* @param startPrice uint The start price of the auction
* @param endTime uint The end time of the auction
* @param extensionDuration uint The extension duration of the auction
* @param minBidIncrease uint The min bid increase of the auction
*/
function createSubnameOffering(
// WARNING: The contract DOES NOT perform ENS name normalisation, which is up to responsibility of each offchain UI!
string calldata name,
uint startPrice,
uint64 endTime,
uint64 extensionDuration,
uint minBidIncrease
) external {
address payable forwarder = payable(address(new Forwarder()));
bytes32 node = namehash(name);
bytes32 labelHash = getLabelHash(name);
uint128 version = 100001; // versioning for Auction offerings starts at number 100000
AuctionOffering(forwarder).construct(
node,
name,
labelHash,
payable(msg.sender),
version,
startPrice,
endTime,
extensionDuration,
minBidIncrease
);
registerSubnameOffering(node, labelHash, forwarder, version);
}
/**
* @dev Deploys new TLD auction offering and registers it to OfferingRegistry
* @param name string Plaintext ENS name
* @param startPrice uint The start price of the auction
* @param endTime uint The end time of the auction
* @param extensionDuration uint The extension duration of the auction
* @param minBidIncrease uint The min bid increase of the auction
* @param originalOwner address Original owner of the name
*/
function createTLDOffering(
// WARNING: The contract DOES NOT perform ENS name normalisation, which is up to responsibility of each offchain UI!
string memory name,
uint startPrice,
uint64 endTime,
uint64 extensionDuration,
uint minBidIncrease,
address payable originalOwner
) internal {
address payable forwarder = payable(address(new Forwarder()));
bytes32 node = namehash(name);
bytes32 labelHash = getLabelHash(name);
uint128 version = 100001; // versioning for Auction offerings starts at number 100000
AuctionOffering(forwarder).construct(
node,
name,
labelHash,
originalOwner,
version,
startPrice,
endTime,
extensionDuration,
minBidIncrease
);
registerTLDOffering(node, labelHash, forwarder, version, originalOwner);
}
/**
* @dev Recognizes being sent .eth subdomain ownership via EthRegistrar and initiates offering creation
* @param operator address Who initiated the transfer
* @param from address Original owner of the domain
* @param tokenId uint256 EthRegistrar identifier of the domain
* @param data bytes memory Additional data sent with transfer encoding the desired offering parameters
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public
override
onlyRegistrar
returns (bytes4)
{
(string memory name,
uint startPrice,
uint64 endTime,
uint64 extensionDuration,
uint minBidIncrease) = abi.decode(data, (string, uint, uint64, uint64, uint));
createTLDOffering(name, startPrice, endTime, extensionDuration, minBidIncrease, payable(from));
return this.onERC721Received.selector;
}
}