Skip to content

Commit

Permalink
deploy mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 committed Jan 22, 2024
1 parent 29f0f39 commit 7bf79a9
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 40 deletions.
6 changes: 4 additions & 2 deletions hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@
"dependencies": {
"@openzeppelin/contracts": "^4.7.3",
"@openzeppelin/contracts-upgradeable": "^4.7.3",
"@types/lodash": "^4.14.202",
"circomlibjs": "^0.1.7",
"dayjs": "^1.11.9",
"defender-relay-client": "^1.28.1",
"eth-sig-util": "^3.0.1",
"hardhat-interface-generator": "^0.0.6",
"hardhat-watcher": "^2.5.0"
"hardhat-watcher": "^2.5.0",
"lodash": "^4.17.21"
}
}
}
81 changes: 52 additions & 29 deletions hardhat/scripts/updateEventIdOfTokenId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,72 @@ import { ethers } from "hardhat";
import { MintNFT, EventManager } from "../typechain";
import { BigNumber } from "ethers";
import { eventManagerAddress, mintNFTAddress } from "./helper/getAddresses";
import { chunk } from "lodash";

async function main() {
const MINT_NFT_ADDRESS = mintNFTAddress();
const EVENT_MANAGER_ADDRESS = eventManagerAddress();
try {
const MINT_NFT_ADDRESS = mintNFTAddress();
const EVENT_MANAGER_ADDRESS = eventManagerAddress();

const MintNFTFactory = await ethers.getContractFactory("MintNFT");
const mintNFT = MintNFTFactory.attach(MINT_NFT_ADDRESS) as MintNFT;
const MintNFTFactory = await ethers.getContractFactory("MintNFT");
const mintNFT = MintNFTFactory.attach(MINT_NFT_ADDRESS) as MintNFT;

// EventManagerのインスタンスを作成
const EventManagerFactory = await ethers.getContractFactory("EventManager");
const eventManager = EventManagerFactory.attach(
EVENT_MANAGER_ADDRESS
) as EventManager;
// EventManagerのインスタンスを作成
const EventManagerFactory = await ethers.getContractFactory("EventManager");
const eventManager = EventManagerFactory.attach(
EVENT_MANAGER_ADDRESS
) as EventManager;

let eventIds: number[] = [];
let tokenIdsArr: number[][] = [];
let eventIds: number[] = [];
let tokenIdsArr: number[][] = [];

const eventRecordCountBigNumber = await eventManager.getEventRecordCount();
const eventRecordCount = eventRecordCountBigNumber.toNumber();
console.log("eventRecordCount", eventRecordCount);
const eventRecordCountBigNumber = await eventManager.getEventRecordCount();
const eventRecordCount = eventRecordCountBigNumber.toNumber();
console.log("eventRecordCount", eventRecordCount);

for (let i = 1; i <= eventRecordCount; i++) {
eventIds.push(i);
for (let i = 1; i <= eventRecordCount; i++) {
eventIds.push(i);

// @todo コントラクトをアップグレード後、以下のコメントアウトを外す
const tokenIds: BigNumber[] = await mintNFT.getTokenIdsByEvent(i);
console.log(tokenIds);
// @todo コントラクトをアップグレード後、以下のコメントアウトを外す
const tokenIds: BigNumber[] = await mintNFT.getTokenIdsByEvent(i);
console.log(tokenIds);

tokenIdsArr.push(tokenIds.map((tokenId) => tokenId.toNumber()));
}
tokenIdsArr.push(tokenIds.map((tokenId) => tokenId.toNumber()));
}

// chunk eventIds and tokenIdsArr 200
const chunkedEventIds = chunk(eventIds, 10);
const chunkedTokenIdsArr = chunk(tokenIdsArr, 10);

for (let index = 0; index < chunkedEventIds.length; index++) {
const eventIds = chunkedEventIds[index];
const tokenIdsArr = chunkedTokenIdsArr[index];

console.log("eventIds", eventIds);
console.log("tokenIdsArr", tokenIdsArr);

// @todo コントラクトをアップグレード後、以下のコメントアウトを外す
await (await mintNFT.setEventIdOfTokenIdsBatch(eventIds, tokenIdsArr)).wait();
// @todo コントラクトをアップグレード後、以下のコメントアウトを外す
await (
await mintNFT.setEventIdOfTokenIdsBatch(eventIds, tokenIdsArr)
).wait();

const lastEventIdOfTokenIds = tokenIdsArr[eventIds.length - 1];
await new Promise((resolve) => setTimeout(resolve, 10000));

console.log("lastEventIdOfTokenIds", lastEventIdOfTokenIds);
console.log("ok");
}

const eventIdOfTokenId = await mintNFT.getEventIdOfTokenId(
lastEventIdOfTokenIds[lastEventIdOfTokenIds.length - 1]
);
const lastEventIdOfTokenIds = tokenIdsArr[eventIds.length - 1];

console.log("check eventIdOfTokenId", eventIdOfTokenId.toNumber());
console.log("lastEventIdOfTokenIds", lastEventIdOfTokenIds);

const eventIdOfTokenId = await mintNFT.getEventIdOfTokenId(
lastEventIdOfTokenIds[lastEventIdOfTokenIds.length - 1]
);

console.log("check eventIdOfTokenId", eventIdOfTokenId.toNumber());
} catch (error) {
throw error;
}
}

main().catch((error) => {
Expand Down
17 changes: 8 additions & 9 deletions hardhat/scripts/upgrades/v1.3.0/upgrade_prd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ async function main() {
if (network.name !== "polygon") throw new Error("wrong network");

await upgradeMintNFT([
process.env.POLYGON_OWNER_ADDRESS,
process.env.POLYGON_FOWARDER_ADDRESS,
process.env.POLYGON_SECRETPHRASE_VERIFIER_ADDRESS,
process.env.POLYGON_OPERATION_CONTROLLER_ADDRESS,
process.env.POLYGON_OWNER_ADDRESS!,
process.env.POLYGON_FORWARDER_ADDRESS!,
process.env.POLYGON_SECRETPHRASE_VERIFIER_ADDRESS!,
process.env.POLYGON_OPERATION_CONTROLLER_ADDRESS!,
]);

await upgradeEventManager();
[
await upgradeEventManager([
process.env.POLYGON_OWNER_ADDRESS!,
process.env.POLYGON_RELAYER_ADDRESS,
process.env.POLYGON_RELAYER_ADDRESS!,
660000,
1000000,
process.env.POLYGON_OPERATION_CONTROLLER_ADDRESS,
];
process.env.POLYGON_OPERATION_CONTROLLER_ADDRESS!,
]);
}

main().catch((error) => {
Expand Down
5 changes: 5 additions & 0 deletions hardhat/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,11 @@
dependencies:
"@types/node" "*"

"@types/lodash@^4.14.202":
version "4.14.202"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.202.tgz#f09dbd2fb082d507178b2f2a5c7e74bd72ff98f8"
integrity sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==

"@types/lru-cache@^5.1.0":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.1.tgz#c48c2e27b65d2a153b19bfc1a317e30872e01eef"
Expand Down

0 comments on commit 7bf79a9

Please sign in to comment.