diff --git a/docker/colony-cdapp-dev-env-block-ingestor b/docker/colony-cdapp-dev-env-block-ingestor index 72e9bceaf9..75242901c0 100644 --- a/docker/colony-cdapp-dev-env-block-ingestor +++ b/docker/colony-cdapp-dev-env-block-ingestor @@ -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" ] diff --git a/src/i18n/en.json b/src/i18n/en.json index a196e2363a..894b49f475 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -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", @@ -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", diff --git a/src/redux/actionTypes.ts b/src/redux/actionTypes.ts index d9c576b581..a4cdc412ab 100644 --- a/src/redux/actionTypes.ts +++ b/src/redux/actionTypes.ts @@ -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', } diff --git a/src/redux/sagas/expenditures/index.ts b/src/redux/sagas/expenditures/index.ts index 1813fc2d9e..c1b8d0a21e 100644 --- a/src/redux/sagas/expenditures/index.ts +++ b/src/redux/sagas/expenditures/index.ts @@ -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([ @@ -27,5 +28,6 @@ export default function* expendituresSagas() { call(releaseExpenditureStageSaga), call(cancelStakedExpenditureSaga), call(createStreamingPaymentSaga), + call(setStakeFractionSaga), ]); } diff --git a/src/redux/sagas/expenditures/setStakeFraction.ts b/src/redux/sagas/expenditures/setStakeFraction.ts new file mode 100644 index 0000000000..9c82b0e4b8 --- /dev/null +++ b/src/redux/sagas/expenditures/setStakeFraction.ts @@ -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['payload']; + +function* setStakeFractionAction({ + payload: { colonyAddress, stakeFraction }, + meta, +}: Action) { + const batchKey = 'setStakeFraction'; + + const { setStakeFraction }: Record = + 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({ + 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); +} diff --git a/src/redux/types/actions/expenditures.ts b/src/redux/types/actions/expenditures.ts index fc911d087a..ce432bf374 100644 --- a/src/redux/types/actions/expenditures.ts +++ b/src/redux/types/actions/expenditures.ts @@ -207,4 +207,14 @@ export type ExpendituresActionTypes = ActionTypes.STREAMING_PAYMENT_CREATE_SUCCESS, object, object - >; + > + | UniqueActionType< + ActionTypes.SET_STAKE_FRACTION, + { + colonyAddress: Address; + stakeFraction: string; + }, + MetaWithSetter + > + | ErrorActionType + | UniqueActionType;