diff --git a/pkgs/contract/gas-report.txt b/pkgs/contract/gas-report.txt index 9070de9..717a33b 100644 --- a/pkgs/contract/gas-report.txt +++ b/pkgs/contract/gas-report.txt @@ -9,6 +9,8 @@ ··························|··············|·············|·············|···············|·············· | BigBang · - · - · 1248128 · 4.2 % · - │ ··························|··············|·············|·············|···············|·············· +| BigBang_Mock_v2 · - · - · 1326614 · 4.4 % · - │ +··························|··············|·············|·············|···············|·············· | FractionToken · - · - · 2893315 · 9.6 % · - │ ··························|··············|·············|·············|···············|·············· | FractionToken_Mock_v2 · - · - · 3037174 · 10.1 % · - │ @@ -17,7 +19,7 @@ ··························|··············|·············|·············|···············|·············· | HatsModule · - · - · 754132 · 2.5 % · - │ ··························|··············|·············|·············|···············|·············· -| HatsModuleFactory · 1101110 · 1101122 · 1101118 · 3.7 % · - │ +| HatsModuleFactory · - · - · 1101122 · 3.7 % · - │ ··························|··············|·············|·············|···············|·············· | HatsTimeFrameModule · - · - · 1287099 · 4.3 % · - │ ··························|··············|·············|·············|···············|·············· diff --git a/pkgs/contract/helpers/upgrade.ts/bigbang.ts b/pkgs/contract/helpers/upgrade.ts/bigbang.ts index 91c5758..a849d33 100644 --- a/pkgs/contract/helpers/upgrade.ts/bigbang.ts +++ b/pkgs/contract/helpers/upgrade.ts/bigbang.ts @@ -18,17 +18,10 @@ export const upgradeBigBang = async ( // アップグレードを実行 const _BigBang = (await upgrades.upgradeProxy( contractAddress, - BigBang_Mock_v2, - params && { - call: { - fn: "initialize", - args: params, - }, - } + BigBang_Mock_v2 )) as any; - await _BigBang.deployed(); - const address = await _BigBang.getAddress(); + const address = _BigBang.target; console.log("upgraded address:", address); diff --git a/pkgs/contract/helpers/upgrade.ts/fractionToken.ts b/pkgs/contract/helpers/upgrade.ts/fractionToken.ts index e898fdd..6cbc92c 100644 --- a/pkgs/contract/helpers/upgrade.ts/fractionToken.ts +++ b/pkgs/contract/helpers/upgrade.ts/fractionToken.ts @@ -24,6 +24,8 @@ export const upgradeFractionToken = async ( const address = _FractionToken.target; + console.log("upgraded address:", address); + // create a new instance of the contract const newFractionToken = await viem.getContractAt( contractName, diff --git a/pkgs/contract/test/BigBang.ts b/pkgs/contract/test/BigBang.ts index 1c87685..16ac216 100644 --- a/pkgs/contract/test/BigBang.ts +++ b/pkgs/contract/test/BigBang.ts @@ -24,6 +24,7 @@ import { SplitsCreatorFactory, SplitsWarehouse, } from "../helpers/deploy/Splits"; +import { upgradeBigBang } from "../helpers/upgrade.ts/bigbang"; describe("BigBang", () => { let Hats: Hats; @@ -131,4 +132,63 @@ describe("BigBang", () => { } catch (error) {} } }); + + /** + * 以降は、Upgradeのテストコードになる。 + * Upgrade後に再度機能をテストする。 + */ + describe("Upgrade Test", () => { + it("upgrde", async () => { + // BigBangをアップグレード + const newBigBang = await upgradeBigBang( + BigBang.address, + "BigBang_Mock_v2", + ["", 10000n, Hats.address, zeroAddress] + ); + + // upgrade後にしかないメソッドを実行 + const result = await newBigBang.read.testUpgradeFunction(); + expect(result).to.equal("testUpgradeFunction"); + }); + + it("should execute bigbang after upgrade", async () => { + // BigBangをアップグレード + const newBigBang = await upgradeBigBang( + BigBang.address, + "BigBang_Mock_v2", + ["", 10000n, Hats.address, zeroAddress] + ); + + const txHash = await newBigBang.write.bigbang( + [ + address1.account?.address!, + "tophatDetails", + "tophatURI", + "hatterhatDetails", + "hatterhatURI", + address1.account?.address!, + ], + { account: address1.account } + ); + + const receipt = await publicClient.waitForTransactionReceipt({ + hash: txHash, + }); + + for (const log of receipt.logs) { + try { + const decodedLog: any = decodeEventLog({ + abi: newBigBang.abi as any, + data: log.data, + topics: log.topics, + }); + if (decodedLog.eventName == "Executed") { + expect(decodedLog.args.owner.toLowerCase()).to.be.equal( + address1.account?.address! + ); + } + } catch (error) {} + } + }); + }); });