/
GateSealFactory.vy
76 lines (61 loc) · 2.26 KB
/
GateSealFactory.vy
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
# @version 0.3.7
"""
@title GateSealFactory
@author mymphe
@notice A factory contract for GateSeals
@dev This contract is meant to simplify the GateSeal deploy.
The factory features a single write function that deploys
a new GateSeal with the given parameters based
on the blueprint provided at the factory construction
using `create_from_blueprint`.
The blueprint must follow EIP-5202 and, thus, is not a
functioning GateSeal itself but only its initcode.
More on blueprints
https://docs.vyperlang.org/en/v0.3.7/built-in-functions.html#chain-interaction
More on EIP-5202
https://eips.ethereum.org/EIPS/eip-5202
"""
event GateSealCreated:
gate_seal: address
# First 3 bytes of the blueprint is the EIP-5202 header;
# The actual code of the contract starts at 4th byte
EIP5202_CODE_OFFSET: constant(uint256) = 3
# The maximum number of sealables is 8.
# GateSeals were originally designed to pause WithdrawalQueue and ValidatorExitBus,
# however, there is a non-zero chance that there might be more in the future, which
# is why we've opted to use a dynamic-size array.
MAX_SEALABLES: constant(uint256) = 8
# Address of the blueprint that must be deployed beforehand
BLUEPRINT: immutable(address)
@external
def __init__(_blueprint: address):
assert _blueprint != empty(address), "blueprint: zero address"
BLUEPRINT = _blueprint
@external
@view
def get_blueprint() -> address:
return BLUEPRINT
@external
def create_gate_seal(
_sealing_committee: address,
_seal_duration_seconds: uint256,
_sealables: DynArray[address, MAX_SEALABLES],
_expiry_timestamp: uint256
):
"""
@notice Create a new GateSeal.
@dev All of the security checks are done inside the GateSeal constructor.
@param _sealing_committee address of the multisig committee
@param _seal_duration_seconds duration of the seal in seconds
@param _sealables addresses of pausable contracts
@param _expiry_timestamp unix timestamp when the GateSeal will naturally expire
"""
gate_seal: address = create_from_blueprint(
BLUEPRINT,
_sealing_committee,
_seal_duration_seconds,
_sealables,
_expiry_timestamp,
code_offset=EIP5202_CODE_OFFSET,
)
log GateSealCreated(gate_seal)