Skip to content

Commit

Permalink
Feat: create action when creating streaming payment
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubcolony committed Jun 4, 2024
1 parent 83184e2 commit 256576e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ export enum ColonyActionType {
CreateDomainMotion = 'CREATE_DOMAIN_MOTION',
/** An action related to creating an expenditure (advanced payment) */
CreateExpenditure = 'CREATE_EXPENDITURE',
/** An action related to creating a streaming payment */
CreateStreamingPayment = 'CREATE_STREAMING_PAYMENT',
/** An action related to editing a domain's details */
EditDomain = 'EDIT_DOMAIN',
/** An action related to editing a domain's details via a motion */
Expand Down
12 changes: 11 additions & 1 deletion src/handlers/expenditures/streamingPaymentCreated.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { mutate } from '~amplifyClient';
import {
ColonyActionType,
CreateStreamingPaymentDocument,
CreateStreamingPaymentMutation,
CreateStreamingPaymentMutationVariables,
} from '~graphql';
import { ContractEvent } from '~types';
import {
getDomainDatabaseId,
getExpenditureDatabaseId,
getStreamingPaymentsClient,
toNumber,
verbose,
writeActionFromEvent,
} from '~utils';

export default async (event: ContractEvent): Promise<void> => {
const { colonyAddress, blockNumber } = event;
const { streamingPaymentId } = event.args;
const { streamingPaymentId, agent: initiatorAddress } = event.args;
const convertedNativeId = toNumber(streamingPaymentId);

if (!colonyAddress) {
Expand Down Expand Up @@ -62,4 +65,11 @@ export default async (event: ContractEvent): Promise<void> => {
interval: interval.toString(),
},
});

await writeActionFromEvent(event, colonyAddress, {
type: ColonyActionType.CreateStreamingPayment,
initiatorAddress,
expenditureId: databaseId,
fromDomainId: getDomainDatabaseId(colonyAddress, toNumber(domainId)),
});
};

0 comments on commit 256576e

Please sign in to comment.