Skip to content

Commit a0083e8

Browse files
authored
Pull fixes from testnet (#1625)
2 parents 2440254 + dc613d9 commit a0083e8

39 files changed

+1283
-212
lines changed

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@
2222
[submodule "contracts/lib/openzeppelin-contracts-upgradeable"]
2323
path = contracts/lib/openzeppelin-contracts-upgradeable
2424
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
25+
[submodule "claim_contracts/lib/forge-std"]
26+
path = claim_contracts/lib/forge-std
27+
url = https://github.com/foundry-rs/forge-std
28+
[submodule "claim_contracts/lib/openzeppelin-contracts-upgradeable"]
29+
path = claim_contracts/lib/openzeppelin-contracts-upgradeable
30+
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
31+
[submodule "claim_contracts/lib/openzeppelin-contracts"]
32+
path = claim_contracts/lib/openzeppelin-contracts
33+
url = https://github.com/OpenZeppelin/openzeppelin-contracts

claim_contracts/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

claim_contracts/Makefile

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
.PHONY: help deploy-aligned-token-implementation deploy-aligned-token-proxy deploy-claimable-airdrop-implementation deploy-claimable-airdrop-proxy upgrade-aligned-token-implementation aligned-token-proxy-deploy-data aligned-token-init-data aligned-token-upgrade-data aligned-token-create2 aligned-token-proxy-create2
2+
3+
4+
help: ## 📚 Show help for each of the Makefile recipes
5+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6+
7+
# Deployments
8+
9+
RPC_URL?=http://localhost:8545
10+
PRIVATE_KEY?=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
11+
12+
deploy-all: ## 🚀 Deploy all contracts
13+
cd script && forge script DeployAll.s.sol --private-key $(PRIVATE_KEY) --rpc-url $(RPC_URL) --broadcast
14+
15+
CONFIG?=example
16+
deploy-token: ## 🚀 Deploy the token contract
17+
cd script && \
18+
forge script DeployAlignedToken.s.sol \
19+
--sig "run(string)" \
20+
$(CONFIG) \
21+
--private-key $(PRIVATE_KEY) \
22+
--rpc-url $(RPC_URL) \
23+
--broadcast
24+
25+
MINT?="1 ether"
26+
OWNER?=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
27+
BENEFICIARY1?=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
28+
BENEFICIARY2?=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
29+
BENEFICIARY3?=0x90F79bf6EB2c4f870365E785982E1f101E93b906
30+
31+
CLAIM_TIME_LIMIT?=1632960000
32+
MERKLE_ROOT?=0x90076b5fb9a6c81d9fce83dfd51760987b8c49e7c861ea25b328e6e63d2cd3df
33+
TOKEN_OWNER?=$(OWNER)
34+
35+
deploy-proxy-admin: ## 🚀 Deploy the ProxyAdmin contract
36+
cd script/proxy_admin && \
37+
forge script DeployProxyAdmin.s.sol \
38+
--sig "run(address)" \
39+
$(OWNER) \
40+
--rpc-url $(RPC_URL) \
41+
--private-key $(PRIVATE_KEY) \
42+
--broadcast
43+
44+
deploy-aligned-token-implementation: ## 🚀 Deploy the AlignedToken implementation contract
45+
cd script/aligned_token && \
46+
forge script DeployAlignedTokenImplementation.s.sol \
47+
--rpc-url $(RPC_URL) \
48+
--private-key $(PRIVATE_KEY) \
49+
--broadcast
50+
51+
deploy-aligned-token-proxy: ## 🚀 Deploy the AlignedToken proxy contract
52+
cd script/aligned_token && \
53+
forge script DeployAlignedTokenProxy.s.sol \
54+
--sig "run(address,address,address,address,address,address,uint256)" \
55+
$(PROXY_ADMIN) $(IMPLEMENTATION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT) \
56+
--rpc-url $(RPC_URL) \
57+
--private-key $(PRIVATE_KEY) \
58+
--broadcast
59+
60+
deploy-claimable-airdrop-implementation: ## 🚀 Deploy the ClaimableAirdrop implementation contract
61+
cd script/claimable_airdrop && \
62+
forge script DeployClaimableAirdropImplementation.s.sol \
63+
--rpc-url $(RPC_URL) \
64+
--private-key $(PRIVATE_KEY) \
65+
--broadcast
66+
67+
deploy-claimable-airdrop-proxy: ## 🚀 Deploy the ClaimableAirdrop proxy contract
68+
cd script/claimable_airdrop && \
69+
forge script DeployClaimableAirdropProxy.s.sol \
70+
--sig "run(address,address,address,address,address,uint256,bytes32)" \
71+
$(PROXY_ADMIN) $(IMPLEMENTATION) $(OWNER) $(TOKEN) $(BENEFICIARY1) $(CLAIM_TIME_LIMIT) $(MERKLE_ROOT) \
72+
--rpc-url $(RPC_URL) \
73+
--private-key $(PRIVATE_KEY) \
74+
--broadcast
75+
76+
# Upgrades
77+
78+
upgrade-aligned-token-implementation: ## 🚀 Upgrade the AlignedToken implementation contract
79+
cd script/aligned_token && \
80+
forge script UpgradeAlignedTokenImplementation.s.sol \
81+
--sig "function run(address,address,uint256,address,address,address,address,uint256)" \
82+
$(PROXY) $(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT)\
83+
--rpc-url $(RPC_URL) \
84+
--private-key $(PRIVATE_KEY) \
85+
--broadcast
86+
87+
# Deployment Data
88+
89+
aligned-token-proxy-deploy-data: ## 🚀 Generate the deployment data for the AlignedToken proxy contract
90+
cd script/aligned_token && \
91+
forge script AlignedTokenProxyDeploymentData.s.sol \
92+
--sig "run(address,uint256, address,address,address,address,uint256)" \
93+
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT)
94+
95+
aligned-token-init-data: ## 🚀 Generate the init data for the AlignedToken proxy contract
96+
cd script/aligned_token && \
97+
forge script AlignedTokenInitData.s.sol \
98+
--sig "run(address,uint256, address,address,address,address,uint256)" \
99+
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT)
100+
101+
aligned-token-upgrade-data: ## 🚀 Generate the upgrade data for the AlignedToken proxy contract
102+
cd script/aligned_token && \
103+
forge script AlignedTokenUpgradeData.s.sol \
104+
--sig "run(address,uint256, address,address,address,address,uint256)" \
105+
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT)
106+
107+
SALT?=0x0000000000000000000000000000000000000000000000000000000000000000
108+
# Sepolia Safe CreateCall contract.
109+
DEPLOYER?=0x9b35Af71d77eaf8d7e40252370304687390A1A52
110+
111+
aligned-token-create2: ## 🚀 Generate the create2 data for the AlignedToken proxy contract
112+
cd script/aligned_token && \
113+
forge script AlignedTokenCreate2.s.sol \
114+
--sig "run(uint256,bytes32,address)" \
115+
$(VERSION) $(SALT) $(DEPLOYER)
116+
117+
aligned-token-proxy-create2: ## 🚀 Generate the create2 data for the AlignedToken proxy contract
118+
cd script/aligned_token && \
119+
forge script AlignedTokenCreate2.s.sol \
120+
--sig "run(address,uint256, address,address,address,address,uint256,bytes32,address)" \
121+
$(IMPLEMENTATION) $(VERSION) $(OWNER) $(BENEFICIARY1) $(BENEFICIARY2) $(BENEFICIARY3) $(MINT) $(SALT) $(DEPLOYER
122+
123+
# Misc
124+
125+
approve:
126+
cd script && \
127+
forge script ApproveERC20.s.sol \
128+
--sig "run(address,address,uint256)" \
129+
$(TOKEN) $(AIRDROP) $(AMOUNT) \
130+
--rpc-url $(RPC_URL) \
131+
--private-key $(HOLDER_PRIVATE_KEY) \
132+
--broadcast
133+
134+
# Test targets
135+
136+
test-token:
137+
cast call $(ADDRESS) "name()(string)" --rpc-url $(RPC_URL)
138+
cast call $(ADDRESS) "totalSupply()(uint256)" --rpc-url $(RPC_URL)
139+
140+
# The following target needs the proof API running on localhost:4000
141+
AMOUNT_TO_CLAIM=$(shell curl -S -H "Content-Type: application/json" http://localhost:4000/api/proof/\$(CLAIMER) | jq -r .amount)
142+
MERKLE_PROOF_TO_CLAIM=$(shell curl -S -H "Content-Type: application/json" http://localhost:4000/api/proof/\$(CLAIMER) | jq .proof | tr -d '"\n ')
143+
test-claim:
144+
cast send $(AIRDROP) --private-key $(CLAIMER_PRIVATE_KEY) "claim(uint256,bytes32[])" $(AMOUNT_TO_CLAIM) "$(MERKLE_PROOF_TO_CLAIM)" --rpc-url $(RPC_URL)
145+
146+
test-claimed:
147+
cast call $(AIRDROP) "hasClaimed(address)(bool)" $(CLAIMER) --rpc-url $(RPC_URL)
148+
cast balance --erc20 $(TOKEN) $(CLAIMER) --rpc-url $(RPC_URL)
149+
150+
OWNER_PRIVATE_KEY?=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
151+
152+
test-pause:
153+
cast send $(AIRDROP) --private-key $(OWNER_PRIVATE_KEY) "pause()" --rpc-url $(RPC_URL)
154+
155+
test-unpause:
156+
cast send $(AIRDROP) --private-key $(OWNER_PRIVATE_KEY) "unpause()" --rpc-url $(RPC_URL)

claim_contracts/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## AlignedToken
2+
3+
## Requirements
4+
5+
- Foundry
6+
7+
## Local deploying
8+
9+
To deploy the contracts, set the following environment variables:
10+
11+
- `DEPLOYER_PRIVATE_KEY`: The private key of the account that's going to deploy the contracts.
12+
- `SAFE_ADDRESS`: The address of the safe that's going to own the Proxy admin that in turn owns the token and airdrop contracts.
13+
- `OWNER1_ADDRESS`, `OWNER2_ADDRESS`, and `OWNER3_ADDRESS`: The three owners of the token.
14+
- `MINT_AMOUNT`: The amount to mint to each account (the contract actually supports minting different amounts of the token to each owner, but in the deploy script we simplified it).
15+
- `RPC_URL`: The url of the network to deploy to.
16+
- `CLAIM_TIME_LIMIT`: The claim time limit timestamp.
17+
- `MERKLE_ROOT`: The merkle root of all valid token claims.
18+
19+
Example:
20+
```
21+
export DEPLOYER_PRIVATE_KEY=<deployer_private_key>
22+
export SAFE_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
23+
export OWNER1_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
24+
export OWNER2_ADDRESS=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
25+
export OWNER3_ADDRESS=0x90F79bf6EB2c4f870365E785982E1f101E93b906
26+
export MINT_AMOUNT=100
27+
export RPC_URL=http://localhost:8545
28+
export CLAIM_TIME_LIMIT=2733247661
29+
export MERKLE_ROOT=0x90076b5fb9a6c81d9fce83dfd51760987b8c49e7c861ea25b328e6e63d2cd3df
30+
```
31+
32+
Then run the following script:
33+
34+
```
35+
./deployClaim.sh
36+
```

claim_contracts/deployClaim.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
forge --version >/dev/null 2>&1
4+
if [ $? != 0 ]; then
5+
echo "Error: Please make sure you have forge installed and in your PATH"
6+
exit 2
7+
fi
8+
9+
safe=${SAFE_ADDRESS:-$1}
10+
owner1=${OWNER1_ADDRESS:-$2}
11+
owner2=${OWNER2_ADDRESS:-$3}
12+
owner3=${OWNER3_ADDRESS:-$4}
13+
mint_amount=${MINT_AMOUNT:-$5}
14+
rpc_url=${RPC_URL:-$6}
15+
claim_time_limit=${CLAIM_TIME_LIMIT:-2733247661}
16+
merkle_root=${MERKLE_ROOT:-$7}
17+
18+
cd script && forge script DeployScript $safe $owner1 $owner2 $owner3 $mint_amount $claim_time_limit $merkle_root --sig "run(address,address,address,address,uint256,uint256,bytes32)" --fork-url $rpc_url --broadcast

claim_contracts/foundry.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[profile.default]
2+
src = "src"
3+
out = "out"
4+
libs = ["lib"]
5+
optimizer = true
6+
optimizer_runs = 999_999
7+
8+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
9+
fs_permissions = [
10+
{ access = "read-write", path = "script-out/" },
11+
{ access = "read", path = "script-config/" },
12+
]

claim_contracts/lib/forge-std

Submodule forge-std added at 1eea5ba
Submodule openzeppelin-contracts added at 69c8def

claim_contracts/remappings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/
2+
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/

0 commit comments

Comments
 (0)