From 4c6ff7dcaa2383d086881e657cb3fecd686d162b Mon Sep 17 00:00:00 2001 From: MrDeadCe11 Date: Tue, 11 Jun 2024 22:29:13 -0500 Subject: [PATCH] successfully created a listing with the deployed zone --- script/createListing.ts | 85 +++++++++++++++++++++------------------ script/utils/constants.ts | 27 +++++++------ 2 files changed, 60 insertions(+), 52 deletions(-) diff --git a/script/createListing.ts b/script/createListing.ts index ea8438f..6d786f0 100644 --- a/script/createListing.ts +++ b/script/createListing.ts @@ -4,16 +4,18 @@ import { VAULT721_ANVIL_ADDRESS, VAULT721_SEPOLIA_ADAPTER_ADDRESS, VAULT721_ANVIL_ADAPTER_ADDRESS, - VAULT721_MAINNET_ADAPTER_ADDRESS, + // VAULT721_MAINNET_ADAPTER_ADDRESS, VAULT721_MAINNET_ADDRESS, SIP15_ZONE_SEPOLIA_ADDRESS, ANVIL_ONE, ANVIL_RPC, ARB_SEPOLIA_RPC, ARB_MAINNET_RPC, - WALLET_PRIV_KEY, - ENCODING_HELPER, + ARB_SEPOLIA_PK, + ARB_MAINNET_PK, + ENCODING_HELPER_SEPOLIA, ENCODING_HELPER_ANVIL, + // ENCODING_HELPER_MAINNET } from "./utils/constants"; import { ItemType } from "@opensea/seaport-js/src/constants"; import { CreateOrderInput } from "@opensea/seaport-js/lib/types"; @@ -28,12 +30,16 @@ const vault721AdapterABI = require("../out/Vault721Adapter.sol/Vault721Adapter.j const EncodeSubstandard5ForEthersABI = require("../out/EncodeSubstandard5ForEthers.sol/EncodeSubstandard5ForEthers.json"); const createSIP15ZoneListing = async (chain: string) => { + let provider: Provider; let wallet: Wallet; let seaport: Seaport; let encodeSubstandard5Helper: EncodeSubstandard5ForEthers; let vault721AdapterAddress: AddressLike; let vault721Address: AddressLike; + let sip15ZoneAddress: AddressLike; + + if (chain == "anvil") { provider = new ethers.JsonRpcProvider(ANVIL_RPC); @@ -43,6 +49,7 @@ const createSIP15ZoneListing = async (chain: string) => { if (VAULT721_ANVIL_ADAPTER_ADDRESS && VAULT721_ANVIL_ADDRESS) { vault721AdapterAddress = VAULT721_ANVIL_ADAPTER_ADDRESS; vault721Address = VAULT721_ANVIL_ADDRESS; + sip15ZoneAddress = SIP15_ZONE_SEPOLIA_ADDRESS; } else { throw new Error("VAULT721_ANVIL_ADAPTER_ADDRESS undefined"); } @@ -66,18 +73,19 @@ const createSIP15ZoneListing = async (chain: string) => { } } else if (chain == "sepolia") { provider = new ethers.JsonRpcProvider(ARB_SEPOLIA_RPC); - wallet = new ethers.Wallet(WALLET_PRIV_KEY as string, provider); + wallet = new ethers.Wallet(ARB_SEPOLIA_PK as string, provider); seaport = new Seaport(wallet); - if (VAULT721_SEPOLIA_ADAPTER_ADDRESS && VAULT721_SEPOLIA_ADDRESS) { + if (VAULT721_SEPOLIA_ADAPTER_ADDRESS) { vault721AdapterAddress = VAULT721_SEPOLIA_ADAPTER_ADDRESS; vault721Address = VAULT721_SEPOLIA_ADDRESS; + sip15ZoneAddress = SIP15_ZONE_SEPOLIA_ADDRESS; } else { throw new Error("VAULT721_SEPOLIA_ADAPTER_ADDRESS undefined"); } // if no helper exists deploy helper - if (!ENCODING_HELPER) { + if (!ENCODING_HELPER_SEPOLIA) { const encodeSubstandard5Factory = new ethers.ContractFactory( EncodeSubstandard5ForEthersABI.abi, EncodeSubstandard5ForEthersABI.bytecode, @@ -87,45 +95,45 @@ const createSIP15ZoneListing = async (chain: string) => { (await encodeSubstandard5Factory.deploy()) as EncodeSubstandard5ForEthers; } else { encodeSubstandard5Helper = new ethers.Contract( - ENCODING_HELPER, - EncodeSubstandard5ForEthersABI.abi, - wallet - ) as unknown as EncodeSubstandard5ForEthers; - } - } else if (chain == 'mainnet'){ - provider = new ethers.JsonRpcProvider(ARB_MAINNET_RPC); - wallet = new ethers.Wallet(WALLET_PRIV_KEY as string, provider); - seaport = new Seaport(wallet); - - if (VAULT721_MAINNET_ADAPTER_ADDRESS && VAULT721_MAINNET_ADDRESS) { - vault721AdapterAddress = VAULT721_MAINNET_ADAPTER_ADDRESS; - vault721Address = VAULT721_MAINNET_ADDRESS; - } else { - throw new Error("VAULT721_MAINNET_ADAPTER_ADDRESS undefined"); - } - - // if no helper exists deploy helper - if (!ENCODING_HELPER) { - const encodeSubstandard5Factory = new ethers.ContractFactory( - EncodeSubstandard5ForEthersABI.abi, - EncodeSubstandard5ForEthersABI.bytecode, - wallet - ); - encodeSubstandard5Helper = - (await encodeSubstandard5Factory.deploy()) as EncodeSubstandard5ForEthers; - } else { - encodeSubstandard5Helper = new ethers.Contract( - ENCODING_HELPER, + ENCODING_HELPER_SEPOLIA, EncodeSubstandard5ForEthersABI.abi, wallet ) as unknown as EncodeSubstandard5ForEthers; } + // } else if (chain == 'mainnet'){ + // provider = new ethers.JsonRpcProvider(ARB_MAINNET_RPC); + // wallet = new ethers.Wallet(ARB_MAINNET_PK as string, provider); + // seaport = new Seaport(wallet); + + // if (VAULT721_MAINNET_ADAPTER_ADDRESS && VAULT721_MAINNET_ADDRESS) { + // vault721AdapterAddress = VAULT721_MAINNET_ADAPTER_ADDRESS; + // vault721Address = VAULT721_MAINNET_ADDRESS; + // } else { + // throw new Error("VAULT721_MAINNET_ADAPTER_ADDRESS undefined"); + // } + + // // if no helper exists deploy helper + // if (!ENCODING_HELPER_MAINNET) { + // const encodeSubstandard5Factory = new ethers.ContractFactory( + // EncodeSubstandard5ForEthersABI.abi, + // EncodeSubstandard5ForEthersABI.bytecode, + // wallet + // ); + // encodeSubstandard5Helper = + // (await encodeSubstandard5Factory.deploy()) as EncodeSubstandard5ForEthers; + // } else { + // encodeSubstandard5Helper = new ethers.Contract( + // ENCODING_HELPER_MAINNET, + // EncodeSubstandard5ForEthersABI.abi, + // wallet + // ) as unknown as EncodeSubstandard5ForEthers; + // } } else { throw new Error("unsupported chain"); } // TODO: Fill in the token address and token ID of the NFT you want to sell, as well as the price - let considerationTokenAddress: string = ""; - let vaultId: string = "1"; + let considerationTokenAddress: string = "0x8c12A21C8D62d794f78E02aE9e377Abee4750E87"; + let vaultId: string = "120"; let listingAmount: string = ethers.parseEther("1").toString(); @@ -166,7 +174,7 @@ const createSIP15ZoneListing = async (chain: string) => { offer: [ { itemType: ItemType.ERC721, - token: VAULT721_SEPOLIA_ADDRESS!, + token: vault721Address, identifier: vaultId, }, ], @@ -184,7 +192,6 @@ const createSIP15ZoneListing = async (chain: string) => { }; try { - const { executeAllActions } = await seaport.createOrder( createOrderInput, wallet.address diff --git a/script/utils/constants.ts b/script/utils/constants.ts index 66e2346..ccd25fb 100644 --- a/script/utils/constants.ts +++ b/script/utils/constants.ts @@ -1,5 +1,6 @@ require('dotenv').config(); +import { AddressLike } from "ethers"; import fs from "fs"; import path from "path"; @@ -48,28 +49,30 @@ function stringToObject(str: string): ParsedObjectType{ export const OPENSEA_API_KEY = process.env.OPENSEA_API_KEY; - export const WALLET_PRIV_KEY = process.env.ARB_SEPOLIA_PK; + export const ARB_SEPOLIA_PK = process.env.ARB_SEPOLIA_PK; + export const ARB_MAINNET_PK = process.env.ARB_MAINNET_PK; export const ARB_SEPOLIA_RPC = process.env.ARB_SEPOLIA_RPC; export const ARB_MAINNET_RPC = process.env.ARB_MAINNET_RPC; export const ANVIL_ONE = process.env.ANVIL_ONE; export const ANVIL_RPC = process.env.ANVIL_RPC; - export const SIP15_ZONE_MAINNET_ADDRESS = checkMainnetAddress(mainnetDeployments, 0); - export const SIP15_ZONE_SEPOLIA_ADDRESS = checkSepoliaAddress(sepoliaDeployments, 0); +// export const SIP15_ZONE_MAINNET_ADDRESS = mainnetDeployments.receipts[0].contractAddress + export const SIP15_ZONE_SEPOLIA_ADDRESS = sepoliaDeployments.receipts[0].contractAddress export const SIP15_ZONE_ANVIL_ADDRESS = anvilDeployments.receipts[0].contractAddress; - export const VAULT721_SEPOLIA_ADAPTER_ADDRESS = checkSepoliaAddress(sepoliaDeployments, 1); + + export const VAULT721_SEPOLIA_ADAPTER_ADDRESS = sepoliaDeployments.receipts[1].contractAddress export const VAULT721_ANVIL_ADAPTER_ADDRESS = anvilDeployments.receipts[1].contractAddress; - export const VAULT721_MAINNET_ADAPTER_ADDRESS =checkMainnetAddress(mainnetDeployments, 1); +// export const VAULT721_MAINNET_ADAPTER_ADDRESS = mainnetDeployments.receipts[1].contractAddress export const VAULT721_SEPOLIA_ADDRESS = sepoliaContracts.Vault721_Address; export const VAULT721_MAINNET_ADDRESS = mainnetContracts.Vault721_Address; export const VAULT721_ANVIL_ADDRESS = process.env.VAULT721_ANVIL_ADDRESS; - export const ENCODING_HELPER_MAINNET = checkMainnetAddress(mainnetDeployments,2); - export const ENCODING_HELPER_SEPOLIA = checkSepoliaAddress(sepoliaDeployments, 2); +// export const ENCODING_HELPER_MAINNET = mainnetDeployments.receipts[2].contractAddress + export const ENCODING_HELPER_SEPOLIA = sepoliaDeployments.receipts[2].contractAddress export const ENCODING_HELPER_ANVIL = anvilDeployments.receipts[2].contractAddress; - function checkMainnetAddress(deployment: any, index: number): string | unknown{ - const result = ((): string | unknown => { + function checkMainnetAddress(deployment: any, index: number): AddressLike | undefined{ + return (() => { try { return deployment.receipts[index].contractAddress } catch(error){ @@ -80,19 +83,17 @@ function stringToObject(str: string): ParsedObjectType{ } else if (index == 2 && process.env.ENCODING_HELPER_MAINNET){ return process.env.ENCODING_HELPER_MAINNET; } else { - console.error(error); + console.error(error); } } })(); - return result; } - function checkSepoliaAddress(deployment: any, index: number): string | unknown{ + function checkSepoliaAddress(deployment: any, index: number): AddressLike | undefined{ return(() => { try { return deployment.receipts[index].contractAddress } catch(error){ - console.log(process.env.SIP15_ZONE_SEPOLIA_ADDRESS, process.env.VAULT721_SEPOLIA_ADAPTER_ADDRESS, process.env.ENCODING_HELPER_SEPOLIA) if(index == 0 && process.env.SIP15_ZONE_SEPOLIA_ADDRESS){ return process.env.SIP15_ZONE_SEPOLIA_ADDRESS; } else if (index == 1 && process.env.VAULT721_SEPOLIA_ADAPTER_ADDRESS){