Skip to content

Commit 44daee9

Browse files
authored
Merge pull request from NFTX-project/rescue-airdrop
create RescueAirdrop and Factory
2 parents 3da92a5 + 8ab9651 commit 44daee9

12 files changed

+563
-0
lines changed

.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ MAINNET_RPC_URL=
55
SEPOLIA_RPC_URL=
66
GOERLI_RPC_URL=
77
ARBITRUM_RPC_URL=
8+
BASE_RPC_URL=
89
ETHERSCAN_API_KEY=
910
ARBISCAN_API_KEY=
11+
BASESCAN_API_KEY=
1012
DEPLOYER_PRIVATE_KEY=0x......
1113
SENDER=

deploy/RescueAirdrop.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { HardhatRuntimeEnvironment, Network } from "hardhat/types";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { deployRescueAidrop } from "./modules/RescueAirdrop";
4+
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
6+
const { rescueAirdropImpl } = await deployRescueAidrop({
7+
hre,
8+
});
9+
};
10+
export default func;
11+
func.tags = ["RescueAirdrop"];
12+
func.dependencies = [];

deploy/modules/RescueAirdrop.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import { getConfig } from "../utils";
3+
4+
export const deployRescueAidrop = async ({
5+
hre,
6+
}: {
7+
hre: HardhatRuntimeEnvironment;
8+
}) => {
9+
const { deploy, deployer } = await getConfig(hre);
10+
11+
const rescueAirdropImpl = await deploy("RescueAirdropUpgradeable", {
12+
from: deployer,
13+
args: [],
14+
log: true,
15+
});
16+
17+
return {
18+
rescueAirdropImpl: rescueAirdropImpl.address,
19+
};
20+
};

deployments/base/.chainId

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8453

deployments/base/RescueAirdropUpgradeable.json

Lines changed: 233 additions & 0 deletions
Large diffs are not rendered by default.

deployments/base/solcInputs/b0e14ad2bc5c956706ef47424355ba00.json

Lines changed: 116 additions & 0 deletions
Large diffs are not rendered by default.

hardhat.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ const config: HardhatUserConfig = {
141141
},
142142
},
143143
},
144+
base: {
145+
url: process.env.BASE_RPC_URL!,
146+
accounts: [process.env.DEPLOYER_PRIVATE_KEY!],
147+
timeout: 600000,
148+
verify: {
149+
etherscan: {
150+
apiKey: process.env.BASESCAN_API_KEY,
151+
apiUrl: "https://api.basescan.org/",
152+
},
153+
},
154+
},
144155
},
145156
mocha: {
146157
timeout: 200000,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
"deploy:sepolia": "hardhat deploy --network sepolia",
1111
"deploy:mainnet": "hardhat deploy --network mainnet",
1212
"deploy:arbitrum": "hardhat deploy --network arbitrum",
13+
"deploy:base": "hardhat deploy --network base",
1314
"verify:goerli": "hardhat --network goerli etherscan-verify",
1415
"verify:sepolia": "hardhat --network sepolia etherscan-verify",
1516
"verify:mainnet": "hardhat --network mainnet etherscan-verify",
1617
"verify:arbitrum": "hardhat --network arbitrum etherscan-verify",
18+
"verify:base": "hardhat --network base etherscan-verify",
1719
"gen:addresses": "ts-node ./script/genAddressesJson.ts",
1820
"gen:readme": "ts-node ./script/genREADME.ts",
1921
"gen:addresses-and-readme": "yarn gen:addresses && yarn gen:readme"

src/RescueAirdropFactory.sol

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity =0.8.15;
3+
4+
// inheriting
5+
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
6+
import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
7+
8+
// interfaces
9+
import {IRescueAirdrop} from "@src/interfaces/IRescueAirdrop.sol";
10+
11+
/**
12+
* @title Rescue Airdrop Factory
13+
* @author @apoorvlathey
14+
*
15+
* @notice Factory that deploys RescueAirdrop beacon proxies, by iterating the nonces.
16+
*/
17+
contract RescueAirdropFactory is UpgradeableBeacon {
18+
uint256 public proxyCount;
19+
20+
event ProxyDeployed(uint256 indexed proxyCount, address proxy);
21+
22+
constructor(
23+
address beaconImplementation
24+
) UpgradeableBeacon(beaconImplementation) {}
25+
26+
function deployNewProxies(uint256 count) external {
27+
for (uint256 i; i < count; i++) {
28+
_deployNewProxy();
29+
}
30+
}
31+
32+
function _deployNewProxy() internal {
33+
address proxy = address(new BeaconProxy(address(this), ""));
34+
IRescueAirdrop(proxy).__RescueAirdrop_init();
35+
36+
emit ProxyDeployed(proxyCount, proxy);
37+
38+
proxyCount++;
39+
}
40+
41+
function rescueTokens(
42+
address proxy,
43+
address token,
44+
address to,
45+
uint256 amount
46+
) external onlyOwner {
47+
IRescueAirdrop(proxy).rescueTokens(token, to, amount);
48+
}
49+
}

src/RescueAirdropUpgradeable.sol

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity =0.8.15;
3+
4+
// inheriting
5+
import {OwnableUpgradeable} from "@src/custom/OwnableUpgradeable.sol";
6+
import {IRescueAirdrop} from "@src/interfaces/IRescueAirdrop.sol";
7+
8+
// libs
9+
import {SafeERC20Upgradeable, IERC20Upgradeable} from "@openzeppelin-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol";
10+
11+
/**
12+
* @title Rescue Airdrop
13+
* @author @apoorvlathey
14+
*
15+
* @notice Beacon Proxy implementation that allows to transfer ERC20 tokens stuck in a address, where this contract would eventually be deployed.
16+
*/
17+
contract RescueAirdropUpgradeable is OwnableUpgradeable, IRescueAirdrop {
18+
using SafeERC20Upgradeable for IERC20Upgradeable;
19+
20+
function __RescueAirdrop_init() external override initializer {
21+
// owner is the factory that'll deploy this contract
22+
__Ownable_init();
23+
}
24+
25+
function rescueTokens(
26+
address token,
27+
address to,
28+
uint256 amount
29+
) external override onlyOwner {
30+
IERC20Upgradeable(token).safeTransfer(to, amount);
31+
}
32+
}

0 commit comments

Comments
 (0)