Skip to content

Commit

Permalink
Merge pull request #60 from JoinColony/feature/handle-permissions-events
Browse files Browse the repository at this point in the history
Handle Permissions Events
  • Loading branch information
rdig committed Jun 5, 2023
2 parents 488c823 + 8c80a84 commit 57d2a0d
Show file tree
Hide file tree
Showing 23 changed files with 1,276 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ VERBOSE_OUTPUT=false
CHAIN_RPC_ENDPOINT=http://localhost:8545
CHAIN_NETWORK_CONTRACT=0x5CC4a96B08e8C88f2c6FC5772496FeD9666e4D1F

AWS_APPSYNC_ENDPOINT=http://localhost:20002
AWS_APPSYNC_ENDPOINT=http://localhost:20002/grahpql
AWS_APPSYNC_KEY=da2-fakeApiId123456
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:16.16.0

ENV BLOCK_INGESTOR_HASH=e32c79bf0a242703b577daf5806053cc2164f41f

# Clone block ingestor repo
RUN git clone https://github.com/JoinColony/block-ingestor.git block-ingestor
WORKDIR /block-ingestor

RUN echo $BLOCK_INGESTOR_HASH

# Fetch the correct network repo commit/branch/tag
RUN git fetch origin $BLOCK_INGESTOR_HASH
RUN git checkout $BLOCK_INGESTOR_HASH

# Install block ingestor dependencies
RUN npm install

# the command that starts our app
CMD ["npm","run","prod"]
2 changes: 1 addition & 1 deletion codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CodegenConfig } from '@graphql-codegen/cli';

dotenv.config();

const endpoint = `${process.env.AWS_APPSYNC_ENDPOINT}/graphql`;
const endpoint = `${process.env.AWS_APPSYNC_ENDPOINT}`;

const config: CodegenConfig = {
schema: [
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"homepage": "https://github.com/JoinColony/tx-ingestor",
"dependencies": {
"@colony/colony-js": "^6.1.0",
"@colony/colony-js": "^6.3.6",
"aws-amplify": "^4.3.43",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
Expand Down
166 changes: 1 addition & 165 deletions src/amplifyClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,173 +5,9 @@ import { DocumentNode, isExecutableDefinitionNode } from 'graphql';

dotenv.config();

/*
* @TODO There needs to be a better way of fetching queries and mutations
* inside the ingestor, as currently we can't update these if the schema
* ever changes, other than manually
*/

export const mutations = {
createColonyFundsClaim: /* GraphQL */ `
mutation CreateColonyFundsClaim(
$input: CreateColonyFundsClaimInput!
$condition: ModelColonyFundsClaimConditionInput
) {
createColonyFundsClaim(input: $input, condition: $condition) {
id
}
}
`,
deleteColonyFundsClaim: /* GraphQL */ `
mutation DeleteColonyFundsClaim(
$input: DeleteColonyFundsClaimInput!
$condition: ModelColonyFundsClaimConditionInput
) {
deleteColonyFundsClaim(input: $input, condition: $condition) {
id
}
}
`,
createContractEvent: /* GraphQL */ `
mutation CreateContractEvent(
$input: CreateContractEventInput!
$condition: ModelContractEventConditionInput
) {
createContractEvent(input: $input, condition: $condition) {
id
}
}
`,
setCurrentVersion: /* GraphQL */ `
mutation SetCurrentVersion($input: SetCurrentVersionInput!) {
setCurrentVersion(input: $input)
}
`,
createCurrentNetworkInverseFee: /* GraphQL */ `
mutation CreateCurrentNetworkInverseFee(
$input: CreateCurrentNetworkInverseFeeInput!
) {
createCurrentNetworkInverseFee(input: $input) {
id
}
}
`,
updateCurrentNetworkInverseFee: /* GraphQL */ `
mutation UpdateCurrentNetworkInverseFee(
$input: UpdateCurrentNetworkInverseFeeInput!
) {
updateCurrentNetworkInverseFee(input: $input) {
id
}
}
`,
createColonyExtension: /* GraphQL */ `
mutation CreateColonyExtension($input: CreateColonyExtensionInput!) {
createColonyExtension(input: $input) {
id
}
}
`,
updateColonyExtensionByColonyAndHash: /* GraphQL */ `
mutation UpdateColonyExtensionByColonyAndHash(
$input: UpdateExtensionByColonyAndHashInput!
) {
updateExtensionByColonyAndHash(input: $input) {
id
}
}
`,
updateColonyExtensionByAddress: /* GraphQL */ `
mutation UpdateColonyExtensionByAddress(
$input: UpdateColonyExtensionInput!
) {
updateColonyExtension(input: $input) {
id
}
}
`,
updateColony: /* GraphQL */ `
mutation UpdateColony($input: UpdateColonyInput!) {
updateColony(input: $input) {
id
}
}
`,
createColonyAction: /* GraphQL */ `
mutation CreateColonyAction($input: CreateColonyActionInput!) {
createColonyAction(input: $input) {
id
}
}
`,
updateColonyAction: /* GraphQL */ `
mutation UpdateColonyAction($input: UpdateColonyActionInput!) {
updateColonyAction(input: $input) {
id
}
}
`,
createDomain: /* GraphQL */ `
mutation CreateDomain($input: CreateDomainInput!) {
createDomain(input: $input) {
id
}
}
`,
};

/*
* @NOTE These queries are custom
*/
export const queries = {
getColonyUnclaimedFunds: /* GraphQL */ `
query GetColonyUnclaimedFunds(
$colonyAddress: ID!
$tokenAddress: ID!
$upToBlock: Int = 1
) {
listColonyFundsClaims(
filter: {
colonyFundsClaimsId: { eq: $colonyAddress }
colonyFundsClaimTokenId: { eq: $tokenAddress }
createdAtBlock: { le: $upToBlock }
}
) {
items {
id
}
}
}
`,
getColonyUnclaimedFund: /* GraphQL */ `
query GetColonyUnclaimedFund($claimId: ID!) {
getColonyFundsClaim(id: $claimId) {
id
}
}
`,
getContractEvent: /* GraphQL */ `
query GetContractEvent($id: ID!) {
getContractEvent(id: $id) {
id
}
}
`,
getCurrentNetworkInverseFee: /* GraphQL */ `
query GetCurrentNetworkInverseFee {
listCurrentNetworkInverseFees(limit: 1) {
items {
id
inverseFee
}
}
}
`,
};

export default (): void => {
Amplify.configure({
aws_appsync_graphqlEndpoint: `${process.env.AWS_APPSYNC_ENDPOINT}/graphql`,
aws_appsync_graphqlEndpoint: `${process.env.AWS_APPSYNC_ENDPOINT}`,
aws_appsync_authenticationType: 'API_KEY',
aws_appsync_apiKey: process.env.AWS_APPSYNC_KEY,
});
Expand Down
16 changes: 16 additions & 0 deletions src/eventProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
handleVersionUpgradeAction,
handleEmitDomainReputationAction,
handleNetworkFeeInverseSet,
handleManagePermissionsAction,
} from './handlers';

dotenv.config();
Expand Down Expand Up @@ -158,6 +159,21 @@ export default async (event: ContractEvent): Promise<void> => {
return;
}

case ContractEventsSignatures.ColonyRoleSet: {
await handleManagePermissionsAction(event);
return;
}

case ContractEventsSignatures.ColonyRoleSet_OLD: {
await handleManagePermissionsAction(event);
return;
}

case ContractEventsSignatures.RecoveryRoleSet: {
await handleManagePermissionsAction(event);
return;
}

default: {
return;
}
Expand Down
Loading

0 comments on commit 57d2a0d

Please sign in to comment.