-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathRecordedDeployments.sol
More file actions
73 lines (67 loc) · 5.83 KB
/
Copy pathRecordedDeployments.sol
File metadata and controls
73 lines (67 loc) · 5.83 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
/// @title RecordedDeployments
/// @author Anoma Foundation, 2026
/// @notice The protocol adapter deployments each environment records.
/// @dev Generated from `crates/bindings/deployments.json`, the single source of truth, which the bindings crate
/// embeds and checks against the chains. Do not edit by hand: run `just contracts-gen-deployments`, which CI reruns
/// and fails on any diff. The records live with the bindings because that crate publishes them; this library carries
/// them into Solidity so the contracts package reads nothing outside itself.
/// @custom:security-contact security@anoma.foundation
library RecordedDeployments {
/// @notice A recorded protocol adapter proxy. The field `addr` holds the address, which is a reserved word.
/// @dev The genesis fields pin how the address was derived: the creation code and the constructor arguments
/// determine it together with the environment salt, and none of them can be read from the chain once the proxy is
/// upgraded.
struct Proxy {
address addr;
address initialImplementation;
bytes initializerData;
bytes creationCode;
}
/// @notice A recorded protocol adapter deployment.
struct Deployment {
uint256 chainId;
Proxy proxy;
}
/// @notice Returns whether the environment records a deployment for the chain.
/// @param isProduction Whether to check the production or the staging environment.
/// @param chainId The chain ID to look for.
/// @return recorded Whether the environment records a deployment for the chain.
function isRecorded(bool isProduction, uint256 chainId) internal pure returns (bool recorded) {
Deployment[] memory deployments = isProduction ? production() : staging();
for (uint256 i = 0; i < deployments.length; ++i) {
if (deployments[i].chainId == chainId) {
return true;
}
}
}
/// @notice Returns the deployments the staging environment records.
/// @return deployments The recorded staging deployments.
function staging() internal pure returns (Deployment[] memory deployments) {
deployments = new Deployment[](2);
deployments[0] = Deployment({
chainId: 11155111,
proxy: Proxy({
addr: 0xe23d3b3FC0944cB0c1184C6e04b9d26Ed50CeC51,
initialImplementation: 0x4d68d7A738FBAF0E81aB508F573B1C6A45a376d7,
initializerData: hex"c4d66de800000000000000000000000061462be56782568376f9cb069382efa72764a407",
creationCode: hex"6080604052610284803803806100148161016e565b9283398101604082820312610156578151916001600160a01b03831690818403610156576020810151906001600160401b038211610156570182601f82011215610156578051906001600160401b03821161015a5761007c601f8301601f191660200161016e565b938285526020838301011161015657815f9260208093018387015e8401015281511561014757823b15610135577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a280511561011e5761010e91610193565b505b604051606490816102208239f35b505034156101105763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b6330a289cf60e21b5f5260045ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040519190601f01601f191682016001600160401b0381118382101761015a57604052565b905f8091602081519101845af4808061020c575b156101c75750506040513d81523d5f602083013e60203d82010160405290565b156101ec57639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b3d156101fd576040513d5f823e3d90fd5b63d6bda27560e01b5f5260045ffd5b503d1515806101a75750813b15156101a756fe60806040525f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156053573d5ff35b3d5ffdfea164736f6c6343000824000a"
})
});
deployments[1] = Deployment({
chainId: 84532,
proxy: Proxy({
addr: 0xb5A5a52Af29dA0c8801D9caf4D75a4d6C3895f0A,
initialImplementation: 0xd29F13e08C3DAe49Dc99F65Bc0C51EBF6310682f,
initializerData: hex"c4d66de800000000000000000000000061462be56782568376f9cb069382efa72764a407",
creationCode: hex"6080604052610284803803806100148161016e565b9283398101604082820312610156578151916001600160a01b03831690818403610156576020810151906001600160401b038211610156570182601f82011215610156578051906001600160401b03821161015a5761007c601f8301601f191660200161016e565b938285526020838301011161015657815f9260208093018387015e8401015281511561014757823b15610135577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a280511561011e5761010e91610193565b505b604051606490816102208239f35b505034156101105763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b6330a289cf60e21b5f5260045ffd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040519190601f01601f191682016001600160401b0381118382101761015a57604052565b905f8091602081519101845af4808061020c575b156101c75750506040513d81523d5f602083013e60203d82010160405290565b156101ec57639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b3d156101fd576040513d5f823e3d90fd5b63d6bda27560e01b5f5260045ffd5b503d1515806101a75750813b15156101a756fe60806040525f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156053573d5ff35b3d5ffdfea164736f6c6343000824000a"
})
});
}
/// @notice Returns the deployments the production environment records.
/// @return deployments The recorded production deployments.
function production() internal pure returns (Deployment[] memory deployments) {
deployments = new Deployment[](0);
}
}