Skip to content

Conversation

Whytecrowe
Copy link
Collaborator

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds state validation functionality to ensure contract storage data remains consistent before and after V2 upgrades. The implementation creates utility functions to read and compare contract storage layouts, then integrates these into the existing upgrade test suite.

  • Added storage validation utilities for reading and comparing contract storage data
  • Integrated state validation test into the zDAOToken V2 upgrade test suite
  • Cleaned up configuration by removing unused imports and commenting out deprecated test networks

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 9 comments.

File Description
test/zDaoTokenV2.ts Adds pre/post upgrade state validation test using new storage utilities
scripts/utils/storage-check.ts Implements storage layout reading and comparison utilities for upgrade validation
package.json Adds protocol-utils dependency and removes postinstall script
hardhat.config.ts Comments out deprecated network configs and removes unused task imports
Comments suppressed due to low confidence (1)

scripts/utils/storage-check.ts:1

  • [nitpick] Variable declaration should follow consistent spacing conventions. Add space before the colon: preUpgradeState: ContractStorageData.
import { getStorageLayout, getUnlinkedBytecode, getVersion, StorageLayout } from '@openzeppelin/upgrades-core';

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


export type ContractStorageElement = string | number | BigNumber | Array<object>;
export type ContractStorageData = Array<{
[label : string] : ContractStorageElement;
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Type declaration should follow consistent spacing conventions. Remove spaces around colons: [label: string]: ContractStorageElement.

Suggested change
[label : string] : ContractStorageElement;
[label: string]: ContractStorageElement;

Copilot uses AI. Check for mistakes.

Comment on lines 9 to 14
[label : string] : ContractStorageElement;
}>;
export type ContractStorageDiff = Array<{
key : string;
valueBefore : ContractStorageElement;
valueAfter : ContractStorageElement;
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Type declarations should follow consistent spacing conventions. Remove spaces around colons: key: string, valueBefore: ContractStorageElement, valueAfter: ContractStorageElement.

Suggested change
[label : string] : ContractStorageElement;
}>;
export type ContractStorageDiff = Array<{
key : string;
valueBefore : ContractStorageElement;
valueAfter : ContractStorageElement;
[label: string]: ContractStorageElement;
}>;
export type ContractStorageDiff = Array<{
key: string;
valueBefore: ContractStorageElement;
valueAfter: ContractStorageElement;

Copilot uses AI. Check for mistakes.

Comment on lines 19 to 20
contractFactory : ContractFactory
) : Promise<StorageLayout> => {
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Parameter and return type declarations should follow consistent spacing conventions. Remove spaces around colons: contractFactory: ContractFactory and : Promise<StorageLayout>.

Copilot uses AI. Check for mistakes.

Comment on lines 29 to 31
contractFactory : ContractFactory,
contractObj : Contract
) : Promise<ContractStorageData> => {
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Parameter and return type declarations should follow consistent spacing conventions. Remove spaces around colons: contractFactory: ContractFactory, contractObj: Contract, and : Promise<ContractStorageData>.

Copilot uses AI. Check for mistakes.


return layout.storage.reduce(
async (
acc : Promise<ContractStorageData>,
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Parameter type declaration should follow consistent spacing conventions. Remove space around colon: acc: Promise<ContractStorageData>.

Suggested change
acc : Promise<ContractStorageData>,
acc: Promise<ContractStorageData>,

Copilot uses AI. Check for mistakes.

async (
acc : Promise<ContractStorageData>,
{ label, type }
) : Promise<ContractStorageData> => {
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Return type declaration should follow consistent spacing conventions. Remove space around colon: : Promise<ContractStorageData>.

Suggested change
) : Promise<ContractStorageData> => {
): Promise<ContractStorageData> => {

Copilot uses AI. Check for mistakes.

const value = await contractObj[(newLabel as keyof Contract)]();

newAcc.push({ [label]: value });
} catch (e : unknown) {
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Type annotation should follow consistent spacing conventions. Remove space around colon: e: unknown.

Suggested change
} catch (e : unknown) {
} catch (e: unknown) {

Copilot uses AI. Check for mistakes.

Comment on lines 64 to 65
dataBefore : ContractStorageData,
dataAfter : ContractStorageData,
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Parameter type declarations should follow consistent spacing conventions. Remove spaces around colons: dataBefore: ContractStorageData, dataAfter: ContractStorageData.

Copilot uses AI. Check for mistakes.

dataAfter : ContractStorageData,
) => {
const storageDiff = dataAfter.reduce(
(acc : ContractStorageDiff | undefined, stateVar, idx) => {
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Parameter type declaration should follow consistent spacing conventions. Remove space around colon: acc: ContractStorageDiff | undefined.

Suggested change
(acc : ContractStorageDiff | undefined, stateVar, idx) => {
(acc: ContractStorageDiff | undefined, stateVar, idx) => {

Copilot uses AI. Check for mistakes.

@Whytecrowe Whytecrowe merged commit 3edd214 into feat/token-upgrade Oct 2, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants