Skip to content

Commit

Permalink
improve deploy scripts
Browse files Browse the repository at this point in the history
jfschwarz committed Nov 17, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent cf118e8 commit f8dc3cd
Showing 3 changed files with 36 additions and 8 deletions.
4 changes: 2 additions & 2 deletions deploy/01_deploy_mastercopy_ERC721Tokenbound.ts
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ const deployMastercopyERC721Tokenbound: DeployFunction = async (hre) => {
if (await deployerClient.extend(publicActions).getBytecode({ address })) {
console.log(` ✔ Contract is already deployed at ${address}`)
} else {
await deployERC721TokenboundMechMastercopy(deployerClient)
console.log(` ✔ Contract deployed at ${address}`)
const txHash = await deployERC721TokenboundMechMastercopy(deployerClient)
console.log(` ✔ Contract deployed at ${address} (tx hash: ${txHash})`)
}

try {
20 changes: 17 additions & 3 deletions sdk/src/deploy/deployERC1155TokenboundMech.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { encodeFunctionData, getCreate2Address, WalletClient } from "viem"
import {
encodeFunctionData,
getContract,
getCreate2Address,
WalletClient,
} from "viem"

import { ERC1155TokenboundMech__factory } from "../../../typechain-types"
import {
DEFAULT_SALT,
ERC2470_SINGLETON_FACTORY_ABI,
ERC2470_SINGLETON_FACTORY_ADDRESS,
ERC6551_REGISTRY_ABI,
ERC6551_REGISTRY_ADDRESS,
@@ -113,8 +119,16 @@ export const deployERC1155TokenboundMech = async (
export const deployERC1155TokenboundMechMastercopy = async (
walletClient: WalletClient
) => {
return await deployMastercopy(
const singletonFactory = getContract({
address: ERC2470_SINGLETON_FACTORY_ADDRESS,
abi: ERC2470_SINGLETON_FACTORY_ABI,
walletClient,
ERC1155TokenboundMech__factory.bytecode
})

return await singletonFactory.write.deploy(
[ERC1155TokenboundMech__factory.bytecode, DEFAULT_SALT],
{
gas: 2000000,
}
)
}
20 changes: 17 additions & 3 deletions sdk/src/deploy/deployERC721TokenboundMech.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { encodeFunctionData, getCreate2Address, WalletClient } from "viem"
import {
encodeFunctionData,
getContract,
getCreate2Address,
WalletClient,
} from "viem"

import { ERC721TokenboundMech__factory } from "../../../typechain-types"
import {
DEFAULT_SALT,
ERC2470_SINGLETON_FACTORY_ABI,
ERC2470_SINGLETON_FACTORY_ADDRESS,
ERC6551_REGISTRY_ABI,
ERC6551_REGISTRY_ADDRESS,
@@ -113,8 +119,16 @@ export const deployERC721TokenboundMech = async (
export const deployERC721TokenboundMechMastercopy = async (
walletClient: WalletClient
) => {
return await deployMastercopy(
const singletonFactory = getContract({
address: ERC2470_SINGLETON_FACTORY_ADDRESS,
abi: ERC2470_SINGLETON_FACTORY_ABI,
walletClient,
ERC721TokenboundMech__factory.bytecode
})

return await singletonFactory.write.deploy(
[ERC721TokenboundMech__factory.bytecode, DEFAULT_SALT],
{
gas: 2000000,
}
)
}

0 comments on commit f8dc3cd

Please sign in to comment.