Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Advanced payments #225

Merged
merged 22 commits into from
Oct 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6e75296
Fix: Release expenditure stage via motion
iamsamgibbs May 17, 2024
c3bccb5
Create stake fraction set handler
davecreaser May 16, 2024
1d45260
Save new stake fraction in db
davecreaser May 16, 2024
a4f2e51
Merge pull request #223 from JoinColony/feat/#2200-allow-modifying-st…
davecreaser May 21, 2024
ac1586c
Refactor: Simplify setStakeFraction handler, remove network calls
jakubcolony Jun 7, 2024
0d2260e
Chore: post-rebase fixes
jakubcolony Jun 7, 2024
cce5aee
Cleanup: Remove all references to ColonyStake model
jakubcolony Jun 16, 2024
f6c1d29
Feat: Set relevant user stake type on creation
jakubcolony Jun 24, 2024
9c66d03
Fix: ensure release expenditure stage motion stores slot ids
jakubcolony Jun 11, 2024
052ac44
cleanup: remove unused listener types
jakubcolony Jun 16, 2024
b94263a
wip: releasing staged payments via multicall motion
jakubcolony Jun 16, 2024
75276a1
Refactor: Shared util to parse function data
jakubcolony Jun 18, 2024
254330e
Refactor: multicall function parsing, validation and handling
jakubcolony Jun 18, 2024
69f4d9a
Refactor: Add checkActionExists util
jakubcolony Jun 18, 2024
1538526
Feat: create colony action when releasing staged payment
jakubcolony Jun 18, 2024
78e01f2
Fix: Edit expenditure action being wrongly created
jakubcolony Jul 18, 2024
7fdc224
Fix: Edit expenditure action created when staged payment released
jakubcolony Jul 18, 2024
ac8f0b3
chore: update colony-js, colony/events
jakubcolony Jul 18, 2024
b372fa2
Fix: Expenditure changes overriden when editing with multicall
jakubcolony Jul 18, 2024
36e5700
feat: store initiator of staged payment release action
jakubcolony Jul 18, 2024
b162639
Chore: update generated types
jakubcolony Aug 29, 2024
001056d
Set expenditureId field for MOVE_FUNDS motions that are funding expen…
jakubcolony Sep 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix: Release expenditure stage via motion
iamsamgibbs authored and jakubcolony committed Sep 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6e752966b31af458838ada666fad813367561059
23 changes: 23 additions & 0 deletions src/graphql/generated.ts
Original file line number Diff line number Diff line change
@@ -624,6 +624,8 @@ export enum ColonyActionType {
PaymentMultisig = 'PAYMENT_MULTISIG',
/** An action related to the recovery functionality of a Colony */
Recovery = 'RECOVERY',
/** An action related to a motion to release a staged payment */
ReleaseStagedPaymentMotion = 'RELEASE_STAGED_PAYMENT_MOTION',
/** An action related to removing verified members */
RemoveVerifiedMembers = 'REMOVE_VERIFIED_MEMBERS',
RemoveVerifiedMembersMotion = 'REMOVE_VERIFIED_MEMBERS_MOTION',
@@ -1663,6 +1665,7 @@ export type CreateExpenditureInput = {
};

export type CreateExpenditureMetadataInput = {
distributionType?: InputMaybe<SplitPaymentDistributionType>;
fundFromDomainNativeId: Scalars['Int'];
id?: InputMaybe<Scalars['ID']>;
stages?: InputMaybe<Array<ExpenditureStageInput>>;
@@ -2277,6 +2280,11 @@ export type ExpenditureFundingItemInput = {
export type ExpenditureMetadata = {
__typename?: 'ExpenditureMetadata';
createdAt: Scalars['AWSDateTime'];
/**
* Specifies the distribution type selected when creating a split payment
* Will be null for other payment types
*/
distributionType?: Maybe<SplitPaymentDistributionType>;
fundFromDomainNativeId: Scalars['Int'];
id: Scalars['ID'];
stages?: Maybe<Array<ExpenditureStage>>;
@@ -3428,6 +3436,7 @@ export type ModelExpenditureFilterInput = {

export type ModelExpenditureMetadataConditionInput = {
and?: InputMaybe<Array<InputMaybe<ModelExpenditureMetadataConditionInput>>>;
distributionType?: InputMaybe<ModelSplitPaymentDistributionTypeInput>;
fundFromDomainNativeId?: InputMaybe<ModelIntInput>;
not?: InputMaybe<ModelExpenditureMetadataConditionInput>;
or?: InputMaybe<Array<InputMaybe<ModelExpenditureMetadataConditionInput>>>;
@@ -3441,6 +3450,7 @@ export type ModelExpenditureMetadataConnection = {

export type ModelExpenditureMetadataFilterInput = {
and?: InputMaybe<Array<InputMaybe<ModelExpenditureMetadataFilterInput>>>;
distributionType?: InputMaybe<ModelSplitPaymentDistributionTypeInput>;
fundFromDomainNativeId?: InputMaybe<ModelIntInput>;
id?: InputMaybe<ModelIdInput>;
not?: InputMaybe<ModelExpenditureMetadataFilterInput>;
@@ -3845,6 +3855,11 @@ export enum ModelSortDirection {
Desc = 'DESC',
}

export type ModelSplitPaymentDistributionTypeInput = {
eq?: InputMaybe<SplitPaymentDistributionType>;
ne?: InputMaybe<SplitPaymentDistributionType>;
};

export type ModelStreamingPaymentConditionInput = {
and?: InputMaybe<Array<InputMaybe<ModelStreamingPaymentConditionInput>>>;
createdAt?: InputMaybe<ModelStringInput>;
@@ -4310,6 +4325,7 @@ export type ModelSubscriptionExpenditureMetadataFilterInput = {
and?: InputMaybe<
Array<InputMaybe<ModelSubscriptionExpenditureMetadataFilterInput>>
>;
distributionType?: InputMaybe<ModelSubscriptionStringInput>;
fundFromDomainNativeId?: InputMaybe<ModelSubscriptionIntInput>;
id?: InputMaybe<ModelSubscriptionIdInput>;
or?: InputMaybe<
@@ -7688,6 +7704,12 @@ export enum SortingMethod {
ByMorePermissions = 'BY_MORE_PERMISSIONS',
}

export enum SplitPaymentDistributionType {
Equal = 'EQUAL',
Reputation = 'REPUTATION',
Unequal = 'UNEQUAL',
}

export type StakedExpenditureParams = {
__typename?: 'StakedExpenditureParams';
stakeFraction: Scalars['String'];
@@ -8891,6 +8913,7 @@ export type UpdateExpenditureInput = {
};

export type UpdateExpenditureMetadataInput = {
distributionType?: InputMaybe<SplitPaymentDistributionType>;
fundFromDomainNativeId?: InputMaybe<Scalars['Int']>;
id: Scalars['ID'];
stages?: InputMaybe<Array<ExpenditureStageInput>>;
2 changes: 1 addition & 1 deletion src/handlers/expenditures/stagedPaymentReleased.ts
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ export const handleStagedPaymentReleased: EventHandler = async (
});
const metadata = response?.data?.getExpenditureMetadata;

if (!metadata || !metadata.stages) {
if (!metadata?.stages) {
output(
`Could not find stages data for expenditure with ID: ${databaseId}. This is a bug and needs investigating.`,
);
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as handleCancelStakedExpenditureMotion } from './cancelStakedExpenditures';
export { default as handleCancelExpenditureViaArbitrationMotion } from './cancelExpenditureViaArbitration';
export { default as handleFinalizeExpenditureViaArbitrationMotion } from './finalizeExpenditureViaArbitration';
export { default as handleReleaseStagedPaymentViaArbitration } from './releaseStagedPaymentViaArbitration';
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { BigNumber } from 'ethers';
import { TransactionDescription } from 'ethers/lib/utils';
import { ContractEvent, motionNameMapping } from '~types';
import { createMotionInDB } from '../../helpers';
import {
getDomainDatabaseId,
getExpenditureDatabaseId,
toNumber,
} from '~utils';

export default async (
event: ContractEvent,
{ name, args: actionArgs }: TransactionDescription,
gasEstimate: BigNumber,
): Promise<void> => {
const { args, colonyAddress } = event;
const [, , , , expenditureId] = actionArgs;
const [, , domainId] = args;

if (!colonyAddress) {
return;
}

await createMotionInDB(event, {
type: motionNameMapping[name],
fromDomainId: colonyAddress
? getDomainDatabaseId(colonyAddress, domainId)
: undefined,
gasEstimate: gasEstimate.toString(),
expenditureId: getExpenditureDatabaseId(
colonyAddress,
toNumber(expenditureId),
),
});
};
10 changes: 10 additions & 0 deletions src/handlers/motions/motionCreated/motionCreated.ts
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ import {
handleMetadataDeltaMotion,
handleCancelExpenditureViaArbitrationMotion,
handleFinalizeExpenditureViaArbitrationMotion,
handleReleaseStagedPaymentViaArbitration,
} from './handlers';
import { ExtensionEventListener } from '~eventListeners';

@@ -186,6 +187,15 @@ export const handleMotionCreated: EventHandler = async (
break;
}

case ColonyOperations.ReleaseStagedPaymentViaArbitration: {
await handleReleaseStagedPaymentViaArbitration(
event,
parsedAction,
gasEstimate,
);
break;
}

default: {
break;
}
3 changes: 3 additions & 0 deletions src/types/motions.ts
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ export enum ColonyOperations {
EditColonyByDelta = 'editColonyByDelta',
CancelExpenditureViaArbitration = 'cancelExpenditureViaArbitration',
FinalizeExpenditureViaArbitration = 'finalizeExpenditureViaArbitration',
ReleaseStagedPaymentViaArbitration = 'releaseStagedPaymentViaArbitration',
}

export enum MotionEvents {
@@ -66,6 +67,8 @@ export const motionNameMapping: { [key: string]: ColonyActionType } = {
ColonyActionType.FinalizeExpenditureMotion,
[ColonyOperations.SetExpenditureState]:
ColonyActionType.SetExpenditureStateMotion,
[ColonyOperations.ReleaseStagedPaymentViaArbitration]:
ColonyActionType.ReleaseStagedPaymentMotion,
};

export enum MotionSide {