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
Prev Previous commit
Next Next commit
Save new stake fraction in db
davecreaser authored and jakubcolony committed Sep 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1d45260cc2f46543bcc96ec88f12d1ea49fd8cf2
2 changes: 0 additions & 2 deletions src/eventListeners/colony.ts
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ import {
handleMoveFundsAction,
handleReputationMiningCycleComplete,
handleSetTokenAuthority,
handleStakeFractionSet,
handleTokenUnlockedAction,
handleTransfer,
} from '~handlers';
@@ -152,7 +151,6 @@ export const setupListenersForColony = (
handleExpenditurePayoutClaimed,
[ContractEventsSignatures.ExpenditureStateChanged]:
handleExpenditureStateChanged,
[ContractEventsSignatures.StakeFractionSet]: handleStakeFractionSet,
[ContractEventsSignatures.AnnotateTransaction]: handleAnnotateTransaction,
[ContractEventsSignatures.ArbitraryTransaction]:
handleMakeAbitraryTransactionAction,
2 changes: 2 additions & 0 deletions src/eventListeners/extension/stakedExpenditure.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import {
handleExpenditureMadeViaStake,
handleExpenditureStakerPunished,
handleExtensionInitialised,
handleStakeFractionSet,
handleStakeReclaimed,
} from '~handlers';

@@ -41,6 +42,7 @@ export const setupListenersForStakedExpenditure = (
handleExpenditureStakerPunished,
[ContractEventsSignatures.ExpenditureMadeViaStake]:
handleExpenditureMadeViaStake,
[ContractEventsSignatures.StakeFractionSet]: handleStakeFractionSet,
};

Object.entries(eventHandlers).forEach(([eventSignature, handler]) =>
71 changes: 26 additions & 45 deletions src/handlers/expenditures/stakeFractionSet.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
import { ContractEvent, EventHandler } from '~types';
import { ExtensionEventListener } from '~eventListeners';
import { EventHandler } from '~types';
import {
addStakedExpenditureParamsToDB,
getStakedExpenditureClient,
} from '~utils';

export const handleStakeFractionSet: EventHandler = async (
event: ContractEvent,
_,
listener,
): Promise<void> => {
console.log(event.args);
// const { colonyAddress, blockNumber } = event;
// const { streamingPaymentId } = event.args;
// const convertedNativeId = toNumber(streamingPaymentId);
// if (!colonyAddress) {
// return;
// }
// const streamingPaymentsClient = await getStreamingPaymentsClient(
// colonyAddress,
// );
// if (!streamingPaymentsClient) {
// return;
// }
// const streamingPayment = await streamingPaymentsClient.getStreamingPayment(
// streamingPaymentId,
// { blockTag: blockNumber },
// );
// if (!streamingPayment) {
// return;
// }
// const {
// recipient: recipientAddress,
// domainId,
// startTime,
// endTime,
// interval,
// } = streamingPayment;
// const databaseId = getExpenditureDatabaseId(colonyAddress, convertedNativeId);
// verbose(`Streaming payment with ID ${databaseId} created`);
// await mutate<
// CreateStreamingPaymentMutation,
// CreateStreamingPaymentMutationVariables
// >(CreateStreamingPaymentDocument, {
// input: {
// id: databaseId,
// nativeId: convertedNativeId,
// recipientAddress,
// nativeDomainId: toNumber(domainId),
// startTime: toNumber(startTime),
// endTime: toNumber(endTime),
// interval: interval.toString(),
// },
// });
const { colonyAddress } = listener as ExtensionEventListener;

if (!colonyAddress) {
return;
}

const stakedExpenditureClient = await getStakedExpenditureClient(
colonyAddress,
);

if (!stakedExpenditureClient) {
return;
}

await addStakedExpenditureParamsToDB(
stakedExpenditureClient?.address,
colonyAddress,
);
};
2 changes: 1 addition & 1 deletion src/types/events.ts
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ export enum ContractEventsSignatures {
StakeReclaimed = 'StakeReclaimed(uint256)',
ExpenditureStakerPunished = 'ExpenditureStakerPunished(address,uint256,bool)',
ExpenditureMadeViaStake = 'ExpenditureMadeViaStake(address,uint256,uint256)',
StakeFractionSet = 'StakeFractionSet(address, uint256)',
StakeFractionSet = 'StakeFractionSet(address,uint256)',

// Staged Expenditures
ExpenditureMadeStaged = 'ExpenditureMadeStaged(uint256,bool)',