Skip to content

Commit

Permalink
f: used the common 0.0.5 for generateActionEntityId
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaniza committed Apr 2, 2024
1 parent 50e1ab3 commit 970a49f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 61 deletions.
2 changes: 1 addition & 1 deletion packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@aragon/osx-commons-subgraph": "^0.0.4"
"@aragon/osx-commons-subgraph": "^0.0.5"
}
}
7 changes: 2 additions & 5 deletions packages/subgraph/src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ import {
} from '../../generated/templates/TokenVoting/TokenVoting';
import {RATIO_BASE, VOTER_OPTIONS, VOTING_MODES} from '../utils/constants';
import {identifyAndFetchOrCreateERC20TokenEntity} from '../utils/erc20';
import {
generateActionEntityId,
generateMemberEntityId,
generateVoteEntityId,
} from '../utils/ids';
import {generateMemberEntityId, generateVoteEntityId} from '../utils/ids';
import {
generatePluginEntityId,
generateProposalEntityId,
generateActionEntityId,
} from '@aragon/osx-commons-subgraph';
import {
Address,
Expand Down
29 changes: 1 addition & 28 deletions packages/subgraph/src/utils/ids.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {bigIntToBytes32} from './bytes';
import {
generateEntityIdFromAddress,
generateActionEntityId as _generateActionEntityId,
generateEntityIdFromBytes,
} from '@aragon/osx-commons-subgraph';
import {Address, BigInt, Bytes} from '@graphprotocol/graph-ts';
Expand Down Expand Up @@ -56,31 +57,3 @@ export function getProposalId(
.concat('_')
.concat(bigIntToBytes32(pluginProposalId));
}

/**
* @dev TODO: move this to OSx commons subgraph
*
* @param caller the user/plugin that will invoke the execute function on the DAO
* @param daoAddress the DAO address
* @param callId the callID determined by the user or plugin
* @param index the index # of the action in the batch
*
* @returns a deterministic Action ID for an action on the DAO.
* This implementation only relies on data that can be fetched
* from the event logs of the `Executed` event, so can be used
* by client applications to query both the OSx core and the plugin
* subgraphs.
*/
export function generateActionEntityId(
caller: Address,
daoAddress: Address,
callId: string,
index: i32
): string {
return [
generateEntityIdFromAddress(caller),
generateEntityIdFromAddress(daoAddress),
callId,
index.toString(),
].join('_');
}
27 changes: 4 additions & 23 deletions packages/subgraph/tests/plugin/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '../../src/plugin/plugin';
import {VOTING_MODES} from '../../src/utils/constants';
import {GOVERNANCE_WRAPPED_ERC20_INTERFACE_ID} from '../../src/utils/constants';
import {generateActionEntityId} from '../../src/utils/ids';
import {
ExtendedERC20Contract,
ExtendedERC20WrapperContract,
Expand All @@ -28,7 +27,10 @@ import {
ERC20_AMOUNT_FULL,
DAO_ADDRESS,
} from '../utils/constants';
import {createDummyAction} from '@aragon/osx-commons-subgraph';
import {
createDummyAction,
generateActionEntityId,
} from '@aragon/osx-commons-subgraph';
import {Address, bigInt, BigInt, ethereum} from '@graphprotocol/graph-ts';
import {
assert,
Expand Down Expand Up @@ -401,25 +403,4 @@ describe('Testing Actions', () => {
assert.fieldEquals('Action', actionID, 'data', dummyActionData);
assert.fieldEquals('Action', actionID, 'proposal', proposal.id);
});

test('We correctly generate the action ID from the arguments', () => {
let caller = PLUGIN_REPO_ADDRESS;
let daoAddress = DAO_ADDRESS;
let callId = 'c4ll me';
let index = 255;

let actionId = generateActionEntityId(
Address.fromString(caller),
Address.fromString(daoAddress),
callId,
index
);

assert.stringEquals(
actionId,
[checksum(caller), checksum(daoAddress), callId, index.toString()].join(
'_'
)
);
});
});
8 changes: 4 additions & 4 deletions packages/subgraph/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
dependencies:
tslib "^2.6.2"

"@aragon/osx-commons-subgraph@^0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-subgraph/-/osx-commons-subgraph-0.0.4.tgz#2aa52f3089d21189c9152d2f3d14c0d7c66d129f"
integrity sha512-cqhusJ3HNvMx+t9lXfN+Hy/5ipefNs1Tdxe+y0GvD4qgBMVU4tCbsxOpB9U2JEJNBCzFQj4E/872FFLpIErB4w==
"@aragon/osx-commons-subgraph@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-subgraph/-/osx-commons-subgraph-0.0.5.tgz#7e0c0f854e4ca52de1d937595c9bb6ef0370f840"
integrity sha512-M5edVTYyHbkcDLr2H8ySCbOpLA+5pUdN7tCYCif0pDP99Wb+/njgO23G2B2FjB4Q3hB0fCkLkQwNp9QplJjqGA==
dependencies:
"@graphprotocol/graph-ts" "0.31.0"

Expand Down

0 comments on commit 970a49f

Please sign in to comment.