Skip to content

Commit

Permalink
Merge pull request #2386 from JoinColony/feat/#2200-allow-modifying-s…
Browse files Browse the repository at this point in the history
…take-fraction

Feat/#2200 allow modifying stake fraction
  • Loading branch information
davecreaser committed May 21, 2024
2 parents 1d5614b + 7e12e5d commit c638429
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker/colony-cdapp-dev-env-block-ingestor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM colony-cdapp-dev-env/base:latest

ENV BLOCK_INGESTOR_HASH=68cee46ff28c4a24054e87633172e51cf406be7f
ENV BLOCK_INGESTOR_HASH=d224a8c6430ad5022d12f13dc7a47453f686c071

# Declare volumes to set up metadata
VOLUME [ "/colonyCDapp/amplify/mock-data" ]
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@
"transaction.StakedExpenditureClient.cancelAndReclaimStake.description": "Cancel and Reclaim Stake",
"transaction.StakedExpenditureClient.cancelAndPunish.title": "Cancel Staked Expenditure",
"transaction.StakedExpenditureClient.cancelAndPunish.description": "Cancel Staked Expenditure",
"transaction.StakedExpenditureClient.setStakeFraction.title": "Set Stake Fraction",
"transaction.StakedExpenditureClient.setStakeFraction.description": "Set Stake Fraction",
"transaction.StreamingPaymentsClient.create.title": "Create Streaming Payment",
"transaction.StreamingPaymentsClient.create.description": "Create Streaming Payment",
"transaction.group.addExistingSafe.title": "Add Existing Safe",
Expand All @@ -422,6 +424,10 @@
"transaction.group.addVerifiedMembers.description": "Add verified members",
"transaction.group.removeVerifiedMembers.title": "Remove verified members",
"transaction.group.removeVerifiedMembers.description": "Remove verified members",
"transaction.group.setStakeFraction.title": "Set Stake Fraction",
"transaction.group.setStakeFraction.description": "Set Stake Fraction",
"transaction.ColonyClient.installExtension.title": "Install extension",
"transaction.ColonyClient.installExtension.description": "Install extension",
"metatransaction.debug.description": "DEBUG: context: {context} methodName: {methodName}",
"metatransaction.group.deposit.title": "Activate tokens",
"metatransaction.group.deposit.description": "Activate tokens",
Expand Down
3 changes: 3 additions & 0 deletions src/redux/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,7 @@ export enum ActionTypes {
STREAMING_PAYMENT_CREATE = 'STREAMING_PAYMENT_CREATE',
STREAMING_PAYMENT_CREATE_SUCCESS = 'STREAMING_PAYMENT_CREATE_SUCCESS',
STREAMING_PAYMENT_CREATE_ERROR = 'STREAMING_PAYMENT_CREATE_ERROR',
SET_STAKE_FRACTION = 'SET_STAKE_FRACTION',
SET_STAKE_FRACTION_SUCCESS = 'SET_STAKE_FRACTION_SUCCESS',
SET_STAKE_FRACTION_ERROR = 'SET_STAKE_FRACTION_ERROR',
}
2 changes: 2 additions & 0 deletions src/redux/sagas/expenditures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import fundExpenditureSaga from './fundExpenditure.ts';
import lockExpenditureSaga from './lockExpenditure.ts';
import reclaimExpenditureStakeSaga from './reclaimExpenditureStake.ts';
import releaseExpenditureStageSaga from './releaseExpenditureStage.ts';
import setStakeFractionSaga from './setStakeFraction.ts';

export default function* expendituresSagas() {
yield all([
Expand All @@ -27,5 +28,6 @@ export default function* expendituresSagas() {
call(releaseExpenditureStageSaga),
call(cancelStakedExpenditureSaga),
call(createStreamingPaymentSaga),
call(setStakeFractionSaga),
]);
}
66 changes: 66 additions & 0 deletions src/redux/sagas/expenditures/setStakeFraction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ClientType } from '@colony/colony-js';
import { fork, put, takeEvery } from 'redux-saga/effects';

import { ActionTypes } from '~redux/actionTypes.ts';
import { type AllActions, type Action } from '~redux/types/index.ts';

import {
type ChannelDefinition,
createTransaction,
createTransactionChannels,
waitForTxResult,
} from '../transactions/index.ts';
import { initiateTransaction, putError, takeFrom } from '../utils/index.ts';

export type SetStakeFractionPayload =
Action<ActionTypes.SET_STAKE_FRACTION>['payload'];

function* setStakeFractionAction({
payload: { colonyAddress, stakeFraction },
meta,
}: Action<ActionTypes.SET_STAKE_FRACTION>) {
const batchKey = 'setStakeFraction';

const { setStakeFraction }: Record<string, ChannelDefinition> =
yield createTransactionChannels(meta.id, ['setStakeFraction']);

try {
yield fork(createTransaction, setStakeFraction.id, {
context: ClientType.StakedExpenditureClient,
methodName: 'setStakeFraction',
identifier: colonyAddress,
group: {
key: batchKey,
id: meta.id,
index: 0,
},
params: [stakeFraction],
});

yield takeFrom(setStakeFraction.channel, ActionTypes.TRANSACTION_CREATED);

yield initiateTransaction({ id: setStakeFraction.id });
yield takeFrom(
setStakeFraction.channel,
ActionTypes.TRANSACTION_HASH_RECEIVED,
);

yield waitForTxResult(setStakeFraction.channel);

yield put<AllActions>({
type: ActionTypes.SET_STAKE_FRACTION_SUCCESS,
payload: {},
meta,
});
} catch (error) {
return yield putError(ActionTypes.SET_STAKE_FRACTION_ERROR, error, meta);
}

setStakeFraction.channel.close();

return null;
}

export default function* setStakeFractionSaga() {
yield takeEvery(ActionTypes.SET_STAKE_FRACTION, setStakeFractionAction);
}
12 changes: 11 additions & 1 deletion src/redux/types/actions/expenditures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,14 @@ export type ExpendituresActionTypes =
ActionTypes.STREAMING_PAYMENT_CREATE_SUCCESS,
object,
object
>;
>
| UniqueActionType<
ActionTypes.SET_STAKE_FRACTION,
{
colonyAddress: Address;
stakeFraction: string;
},
MetaWithSetter<object>
>
| ErrorActionType<ActionTypes.SET_STAKE_FRACTION_ERROR, object>
| UniqueActionType<ActionTypes.SET_STAKE_FRACTION_SUCCESS, object, object>;

0 comments on commit c638429

Please sign in to comment.