Skip to content

Commit

Permalink
refactor outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekard0 committed Aug 30, 2023
1 parent 3ea46e1 commit fd92edd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
18 changes: 7 additions & 11 deletions subgraph/src/ids/pluginRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ export function getPluginSetupId(pluginSetup: Address): string {
export function getPluginInstallationId(
dao: Address,
plugin: Address
): Bytes | null {
let installationIdTupleArray = new ethereum.Tuple();
installationIdTupleArray.push(ethereum.Value.fromAddress(dao));
installationIdTupleArray.push(ethereum.Value.fromAddress(plugin));
): string | null {
let installationIdTuple = new ethereum.Tuple();
installationIdTuple.push(ethereum.Value.fromAddress(dao));
installationIdTuple.push(ethereum.Value.fromAddress(plugin));

let installationIdTuple = installationIdTupleArray as ethereum.Tuple;
let installationIdTupleEncoded = ethereum.encode(
ethereum.Value.fromTuple(installationIdTuple)
);
Expand All @@ -54,7 +53,7 @@ export function getPluginInstallationId(
ByteArray.fromHexString(installationIdTupleEncoded.toHexString())
)
.toHexString()
);
).toHexString();
}
return null;
}
Expand All @@ -68,13 +67,10 @@ export function getPluginInstallationId(
* @returns A concatenated ID string for plugin preparation.
*/
export function getPluginPreparationId(
pluginInstallationId: Bytes,
pluginInstallationId: string,
prepareSetupId: Bytes
): string {
const ids = [
pluginInstallationId.toHexString(),
prepareSetupId.toHexString()
];
const ids = [pluginInstallationId, prepareSetupId.toHexString()];
return ids.join('_');
}

Expand Down
8 changes: 4 additions & 4 deletions subgraph/tests/ids/pluginRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ describe('PluginRepo ID generation', () => {

const expectedId = Bytes.fromHexString(
crypto.keccak256(expectedEncodedBytes).toHexString()
);
).toHexString();

assert.bytesEquals(pluginInstallationId, expectedId);
assert.stringEquals(pluginInstallationId, expectedId);

// The test is done.
return;
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('PluginRepo ID generation', () => {
);

// Expected result
const expectedPreparationId = `${pluginInstallationId.toHexString()}_${DUMMY_BYTES32_HEX}`;
const expectedPreparationId = `${pluginInstallationId}_${DUMMY_BYTES32_HEX}`;

assert.stringEquals(pluginPreparationId, expectedPreparationId);

Expand Down Expand Up @@ -136,7 +136,7 @@ describe('PluginRepo ID generation', () => {
const WHO_ADDRESS = Address.fromString(ADDRESS_TWO);
const PERMISSION_ID = Bytes.fromHexString(DUMMY_BYTES32_HEX);
const PLUGIN_PREPARATION_ID = getPluginPreparationId(
Bytes.fromHexString(DUMMY_BYTES32_HEX),
DUMMY_BYTES32_HEX,
Bytes.fromHexString(DUMMY_BYTES32_HEX)
);

Expand Down

0 comments on commit fd92edd

Please sign in to comment.