Skip to content

Commit

Permalink
refactor: bytes and metadata encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
heueristik committed Apr 15, 2024
1 parent 9d0c061 commit b43e614
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
6 changes: 2 additions & 4 deletions packages/contracts/test/10_unit-testing/11_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ async function fixture(): Promise<FixtureResult> {
const [deployer, alice, bob, carol, dave, eve] = await ethers.getSigners();

// Deploy a DAO proxy.
const dummyMetadata = ethers.utils.hexlify(
ethers.utils.toUtf8Bytes('0x123456789')
);
const dummyMetadata = '0x12345678';
const dao = await createDaoProxy(deployer, dummyMetadata);

// Deploy a plugin proxy factory containing the multisig implementation.
Expand Down Expand Up @@ -95,7 +93,7 @@ async function fixture(): Promise<FixtureResult> {
deployer
);

// Deploy an initialized plugin proxy.
// Deploy an uninitialized plugin proxy.
const deploymentTx2 = await proxyFactory.deployUUPSProxy([]);
const proxyCreatedEvent2 = await findEvent<ProxyCreatedEvent>(
deploymentTx2,
Expand Down
6 changes: 2 additions & 4 deletions packages/contracts/test/10_unit-testing/12_plugin-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ async function fixture(): Promise<FixtureResult> {
const [deployer, alice, bob, carol] = await ethers.getSigners();

// Deploy a DAO proxy.
const dummyMetadata = ethers.utils.hexlify(
ethers.utils.toUtf8Bytes('0x123456789')
);
const dummyMetadata = '0x12345678';
const dao = await createDaoProxy(deployer, dummyMetadata);

// Deploy a plugin setup contract
Expand Down Expand Up @@ -354,7 +352,7 @@ describe('MultisigSetup', function () {
ethers.Wallet.createRandom().address,
ethers.Wallet.createRandom().address,
],
data: '0x00',
data: [],
plugin: ethers.Wallet.createRandom().address,
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ async function fixture(): Promise<FixtureResult> {
await deployments.fixture(tags);

const [deployer, alice, bob] = await ethers.getSigners();
const dummyMetadata = ethers.utils.hexlify(
ethers.utils.toUtf8Bytes('0x123456789')
);
const dummyMetadata = '0x12345678';
const dao = await createDaoProxy(deployer, dummyMetadata);

const network = getNetworkNameByAlias(productionNetworkName);
Expand Down
14 changes: 12 additions & 2 deletions packages/contracts/test/20_integration-testing/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ export async function installPLugin(
pluginSetupRef: pluginSetupRef,
plugin: plugin,
permissions: preparedPermissions,
helpersHash: hashHelpers(preparedEvent.args.preparedSetupData.helpers),
helpersHash: ethers.utils.keccak256(
ethers.utils.defaultAbiCoder.encode(
['address[]'],
[preparedEvent.args.preparedSetupData.helpers]
)
),
});

const appliedEvent =
Expand Down Expand Up @@ -183,7 +188,12 @@ export async function updatePlugin(
pluginSetupRef: pluginSetupRefUpdate,
initData: preparedEvent.args.initData,
permissions: preparedPermissions,
helpersHash: hashHelpers(preparedEvent.args.preparedSetupData.helpers),
helpersHash: ethers.utils.keccak256(
ethers.utils.defaultAbiCoder.encode(
['address[]'],
[preparedEvent.args.preparedSetupData.helpers]
)
),
});
const appliedEvent =
await findEvent<PluginSetupProcessorEvents.UpdateAppliedEvent>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
deployAndUpgradeSelfCheck,
getProtocolVersion,
} from '../test-utils/uups-upgradeable';
import {PLUGIN_UUPS_UPGRADEABLE_PERMISSIONS} from '@aragon/osx-commons-sdk';
import {
PLUGIN_UUPS_UPGRADEABLE_PERMISSIONS,
hexToBytes,

Check failure on line 15 in packages/contracts/test/30_regression-testing/31_upgradeability.ts

View workflow job for this annotation

GitHub Actions / checks

'hexToBytes' is defined but never used. Allowed unused vars must match /_/u

Check failure on line 15 in packages/contracts/test/30_regression-testing/31_upgradeability.ts

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

'hexToBytes' is defined but never used. Allowed unused vars must match /_/u

Check failure on line 15 in packages/contracts/test/30_regression-testing/31_upgradeability.ts

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

'hexToBytes' is defined but never used. Allowed unused vars must match /_/u
} from '@aragon/osx-commons-sdk';
import {DAO} from '@aragon/osx-ethers';
import {loadFixture} from '@nomicfoundation/hardhat-network-helpers';
import {SignerWithAddress} from '@nomiclabs/hardhat-ethers/signers';
Expand Down Expand Up @@ -109,9 +112,7 @@ type FixtureResult = {
async function fixture(): Promise<FixtureResult> {
const [deployer, alice, bob, carol] = await ethers.getSigners();

const dummyMetadata = ethers.utils.hexlify(
ethers.utils.toUtf8Bytes('0x123456789')
);
const dummyMetadata = '0x12345678';

const dao = await createDaoProxy(deployer, dummyMetadata);

Expand Down
4 changes: 0 additions & 4 deletions packages/contracts/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@ export async function getPastVersionCreatedEvents(
});
}

export function hashHelpers(helpers: string[]) {
return keccak256(defaultAbiCoder.encode(['address[]'], [helpers]));
}

export type LatestVersion = {
versionTag: VersionTag;
pluginSetupContract: string;
Expand Down

0 comments on commit b43e614

Please sign in to comment.