forked from farcasterxyz/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBundler.sol
More file actions
102 lines (88 loc) · 3.21 KB
/
Bundler.sol
File metadata and controls
102 lines (88 loc) · 3.21 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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.29;
import {IBundler} from "./interfaces/IBundler.sol";
import {IIdGateway} from "./interfaces/IIdGateway.sol";
import {IKeyGateway} from "./interfaces/IKeyGateway.sol";
import {TransferHelper} from "./libraries/TransferHelper.sol";
/**
* @title Farcaster Bundler
*
* @notice See https://github.com/farcasterxyz/contracts/blob/v3.1.0/docs/docs.md for an overview.
*
* @custom:security-contact security@merklemanufactory.com
*/
contract Bundler is IBundler {
using TransferHelper for address;
/*//////////////////////////////////////////////////////////////
CONSTANTS
//////////////////////////////////////////////////////////////*/
/**
* @inheritdoc IBundler
*/
string public constant VERSION = "2025.06.16";
/*//////////////////////////////////////////////////////////////
IMMUTABLES
//////////////////////////////////////////////////////////////*/
/**
* @inheritdoc IBundler
*/
IIdGateway public immutable idGateway;
/**
* @inheritdoc IBundler
*/
IKeyGateway public immutable keyGateway;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
/**
* @notice Configure the addresses of the IdGateway and KeyGateway contracts.
*
* @param _idGateway Address of the IdGateway contract
* @param _keyGateway Address of the KeyGateway contract
*/
constructor(address _idGateway, address _keyGateway) {
idGateway = IIdGateway(payable(_idGateway));
keyGateway = IKeyGateway(payable(_keyGateway));
}
/**
* @inheritdoc IBundler
*/
function price(
uint256 extraStorage
) external view returns (uint256) {
return idGateway.price(extraStorage);
}
/**
* @inheritdoc IBundler
*/
function register(
RegistrationParams calldata registerParams,
SignerParams[] calldata signerParams,
uint256 extraStorage
) external payable returns (uint256) {
(uint256 fid, uint256 overpayment) = idGateway.registerFor{value: msg.value}(
registerParams.to, registerParams.recovery, registerParams.deadline, registerParams.sig, extraStorage
);
_addKeys(registerParams.to, signerParams);
if (overpayment > 0) msg.sender.sendNative(overpayment);
return fid;
}
/**
* @inheritdoc IBundler
*/
function addKeys(address fidOwner, SignerParams[] calldata signerParams) external {
_addKeys(fidOwner, signerParams);
}
function _addKeys(address fidOwner, SignerParams[] calldata signerParams) internal {
uint256 signersLen = signerParams.length;
for (uint256 i; i < signersLen; ++i) {
SignerParams calldata signer = signerParams[i];
keyGateway.addFor(
fidOwner, signer.keyType, signer.key, signer.metadataType, signer.metadata, signer.deadline, signer.sig
);
}
}
receive() external payable {
if (msg.sender != address(idGateway)) revert Unauthorized();
}
}