-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deploy): op mainnet and updated fee recipient b-sep
- Loading branch information
1 parent
618e445
commit 14e607a
Showing
9 changed files
with
263 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
contracts/src/deployments/deployment-marketplace-optimism-mainnet.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"TransferManager": { | ||
"address": "0x658c1695DCb298E57e6144F6dA3e83DdCF5e2BaB", | ||
"fullNamespace": "TransferManager", | ||
"args": ["0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35"], | ||
"encodedArgs": "0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35", | ||
"tx": "0x2f991683f500fafe1bbae84dd790d247195f13bf40847dca5db266ad886b607e" | ||
}, | ||
"ProtocolFeeRecipient": { | ||
"address": "0x4d99FE0b683874A6FC78A9FA4Fb677AdFc460Bd0", | ||
"fullNamespace": "ProtocolFeeRecipient", | ||
"args": ["0xE7C4531ad8828794904D332a12702beC8ff1A498", "0x4200000000000000000000000000000000000006"], | ||
"encodedArgs": "0xe7c4531ad8828794904d332a12702bec8ff1a4984200000000000000000000000000000000000006", | ||
"tx": "0xbad35b553a07496fb8a9f4b5703957febc5fa6fb3f16849ca42975c5c10cfe7d" | ||
}, | ||
"HypercertExchange": { | ||
"address": "0x2F7Ab1844594112E00708e18835ba2e731880Db1", | ||
"fullNamespace": "LooksRareProtocol", | ||
"args": [ | ||
"0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35", | ||
"0x4d99FE0b683874A6FC78A9FA4Fb677AdFc460Bd0", | ||
"0x658c1695DCb298E57e6144F6dA3e83DdCF5e2BaB", | ||
"0x4200000000000000000000000000000000000006" | ||
], | ||
"encodedArgs": "0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf354d99fe0b683874a6fc78a9fa4fb677adfc460bd0658c1695dcb298e57e6144f6da3e83ddcf5e2bab4200000000000000000000000000000000000006", | ||
"tx": "0xe9f7016b0ca1d9c3c2087ecc42ee8945f120ea5aa9befb0079e023d23d8a15ec" | ||
}, | ||
"RoyaltyFeeRegistry": { | ||
"address": "0xd97b92B740EAf655DFf4f93B0D6D38232cfE84C6", | ||
"fullNamespace": "RoyaltyFeeRegistry", | ||
"args": ["1000"], | ||
"encodedArgs": "0x00000000000000000000000000000000000000000000000000000000000003e8", | ||
"tx": "0x184e33f1ed0dc803a64d1be39758414382393a3797f1a18fe8eb2df1ba249034" | ||
}, | ||
"OrderValidator": { | ||
"address": "0x3B51f8c645b6d1894431A11109787c8814D22C32", | ||
"fullNamespace": "OrderValidatorV2A", | ||
"args": ["0x2F7Ab1844594112E00708e18835ba2e731880Db1"], | ||
"encodedArgs": "0x2f7ab1844594112e00708e18835ba2e731880db1" | ||
}, | ||
"CreatorFeeManager": { | ||
"address": "0x2585159c52180f81a7a5b26acea70d398e3a72f5", | ||
"fullNamespace": "CreatorFeeManagerWithRoyalties", | ||
"args": ["0xd97b92B740EAf655DFf4f93B0D6D38232cfE84C6"], | ||
"encodedArgs": "0xd97b92b740eaf655dff4f93b0d6d38232cfe84c6", | ||
"tx": "0xe72d790b946409a94241eac77bbf6c98be2b7e0bed493842d172ab00b31e2320" | ||
}, | ||
"StrategyHypercertFractionOffer": { | ||
"address": "0x9325027afcc9e86285070db2111d48005006026d", | ||
"fullNamespace": "StrategyHypercertFractionOffer", | ||
"args": [], | ||
"encodedArgs": "0x", | ||
"tx": "0x96ffab4e6d2d5e068ebeafcaf616586f545346bac25ae7c39a942f0e594ff8c0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
import { task } from "hardhat/config"; | ||
import { solidityPacked } from "ethers"; | ||
import { | ||
getContractAddress, | ||
slice, | ||
encodeDeployData, | ||
getContract, | ||
WalletClient, | ||
encodePacked, | ||
PublicClient, | ||
} from "viem"; | ||
import { writeFile } from "node:fs/promises"; | ||
import { getAdminAccount, getFeeRecipient, getTokenAddresses } from "./config"; | ||
|
||
function sleep(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
|
||
const getCreate2Address = async ( | ||
deployer: WalletClient, | ||
factory: `0x${string}`, | ||
bytecode: `0x${string}`, | ||
salt: `0x${string}`, | ||
) => { | ||
if (!deployer.account?.address) { | ||
throw new Error("Deployer account is undefined"); | ||
} | ||
|
||
const address = getContractAddress({ | ||
from: factory, | ||
salt, | ||
opcode: "CREATE2", | ||
bytecode, | ||
}); | ||
return { address, salt, deployData: bytecode }; | ||
}; | ||
|
||
const runCreate2Deployment = async ( | ||
publicClient: PublicClient, | ||
create2Instance: ReturnType<typeof getContract>, | ||
contractName: string, | ||
create2: { | ||
address: `0x${string}`; | ||
salt: `0x${string}`; | ||
deployData: `0x${string}`; | ||
}, | ||
args: string[], | ||
) => { | ||
console.log(`deploying ${contractName} with args: ${args}`); | ||
const { request } = await publicClient.simulateContract({ | ||
address: create2Instance.address, | ||
abi: create2Instance.abi, | ||
functionName: "safeCreate2", | ||
args: [create2.salt, create2.deployData], | ||
account: "0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35", | ||
}); | ||
|
||
const hash = await create2Instance.write.safeCreate2([create2.salt, create2.deployData]); | ||
const deployTx = await publicClient.waitForTransactionReceipt({ | ||
hash, | ||
}); | ||
|
||
console.log( | ||
deployTx.status === "success" ? `Deployed ${contractName} successfully` : `Failed to deploy ${contractName}`, | ||
); | ||
|
||
return hash; | ||
}; | ||
|
||
interface ContractDeployment { | ||
address: string; | ||
fullNamespace: string; | ||
args: string[]; | ||
encodedArgs: string; | ||
tx: `0x${string}`; | ||
} | ||
|
||
type ContractDeployments = { | ||
[name: string]: ContractDeployment; | ||
}; | ||
|
||
task("deploy-fee-recipient", "Deploy marketplace fee recipient and verify") | ||
.addOptionalParam("output", "write the details of the deployment to this file if this is set") | ||
.setAction(async ({ output }, hre) => { | ||
//TODO multichain support | ||
const { ethers, network, run, viem } = hre; | ||
const create2Address = "0x0000000000ffe8b47b3e2130213b802212439497"; | ||
const { wethAddress, usdceAddress, daiAddress } = getTokenAddresses(network.name); | ||
|
||
const publicClient = await viem.getPublicClient(); | ||
const [deployer] = await viem.getWalletClients(); | ||
const create2Instance = await viem.getContractAt("IImmutableCreate2Factory", create2Address, { | ||
walletClient: deployer, | ||
}); | ||
|
||
console.log("Deployer: ", deployer.account.address); | ||
|
||
const releaseVersion = "v1.0.2"; | ||
|
||
const salt = slice( | ||
encodePacked(["address", "string", "address"], [deployer.account?.address, releaseVersion, create2Address]), | ||
0, | ||
32, | ||
); | ||
console.log("Calculated salt: ", salt); | ||
|
||
const contracts: ContractDeployments = {}; | ||
|
||
const protocolFeeRecipientContract = await hre.artifacts.readArtifact("ProtocolFeeRecipient"); | ||
|
||
// Create2 ProtocolFeeRecipient | ||
const protocolFeeRecipientArgs = [getFeeRecipient(network.name), wethAddress]; | ||
console.log("ProtocolFeeRecipient args: ", protocolFeeRecipientArgs); | ||
const protocolFeeRecipientCreate2 = await getCreate2Address( | ||
deployer, | ||
create2Address, | ||
encodeDeployData({ | ||
abi: protocolFeeRecipientContract.abi, | ||
bytecode: protocolFeeRecipientContract.bytecode as `0x${string}`, | ||
args: protocolFeeRecipientArgs, | ||
}), | ||
salt, | ||
); | ||
|
||
// Deploy ProtocolFeeRecipient | ||
const protocolFeeRecipientTx = await runCreate2Deployment( | ||
publicClient, | ||
create2Instance, | ||
"ProtocolFeeRecipient", | ||
protocolFeeRecipientCreate2, | ||
protocolFeeRecipientArgs, | ||
); | ||
|
||
// Add to deployed contracts object | ||
contracts.ProtocolFeeRecipient = { | ||
address: protocolFeeRecipientCreate2.address, | ||
fullNamespace: "ProtocolFeeRecipient", | ||
args: protocolFeeRecipientArgs, | ||
encodedArgs: solidityPacked(["address", "address"], protocolFeeRecipientArgs), | ||
tx: protocolFeeRecipientTx, | ||
}; | ||
|
||
await sleep(2000); | ||
|
||
console.log("🚀 Done!"); | ||
|
||
// Validate | ||
if (network.name !== "hardhat" && network.name !== "localhost") { | ||
// Write deployment details to file | ||
console.log("Writing deployment details to file. Make sure to update the marketplace deployment file"); | ||
await writeFile( | ||
`src/deployments/deployment-fee-recipeint-${network.name}.json`, | ||
JSON.stringify(contracts), | ||
"utf-8", | ||
); | ||
|
||
// Verify contracts | ||
console.log("Verifying contracts..."); | ||
for (const [name, { address, tx, args }] of Object.entries(contracts)) { | ||
try { | ||
console.log(`Verifying ${name}...`); | ||
|
||
const code = await publicClient.getBytecode({ address: address as `0x${string}` }); | ||
if (code === "0x") { | ||
console.log(`${name} contract deployment has not completed. waiting to verify...`); | ||
const receipt = await publicClient.waitForTransactionReceipt({ | ||
hash: tx, | ||
}); | ||
|
||
await run("verify:verify", { | ||
address: receipt.contractAddress, | ||
constructorArguments: args, | ||
}); | ||
} else { | ||
await run("verify:verify", { | ||
address, | ||
constructorArguments: args, | ||
}); | ||
} | ||
} catch (error) { | ||
const errorMessage = (error as Error).message; | ||
|
||
if (errorMessage.includes("Reason: Already Verified")) { | ||
console.log("Reason: Already Verified"); | ||
} | ||
console.error(errorMessage); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters