-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…take-fraction Feat/#2200 allow modifying stake fraction
- Loading branch information
Showing
6 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters