-
Notifications
You must be signed in to change notification settings - Fork 59
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(tx-construction): throw when deregistering reward accounts with … #1547
feat(tx-construction): throw when deregistering reward accounts with … #1547
Conversation
packages/tx-construction/src/tx-builder/ensureNoDeRegistrationsWithRewardsLocked.ts
Outdated
Show resolved
Hide resolved
10c64d5
to
a169345
Compare
|
import { hasCorrectVoteDelegation } from './hasCorrectVoteDelegation'; | ||
import type { RewardAccountWithPoolId } from '../types'; | ||
|
||
export const ensureNoDeRegistrationsWithRewardsLocked = (rewardAccountsToBeDeRegistered: RewardAccountWithPoolId[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the nitpicking. Could you reduce this type too?
- export const ensureNoDeRegistrationsWithRewardsLocked = (rewardAccountsToBeDeRegistered: RewardAccountWithPoolId[]) => {
+ export const ensureNoDeRegistrationsWithRewardsLocked = (rewardAccountsToBeDeRegistered: Pick<RewardAccountWithPoolId, 'dRepDelegatee' | 'rewardBalance'>[]) => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not reduce it here. This function uses hasCorrectVoteDelegation
function which has that type already reduced so reducing it here would create an implicit relation between them as the ensureNoDeRegistrationsWithRewardsLocked
would need to pick dRepDelegatee
despite not using it
export class DeRegistrationsWithRewardsLocked extends CustomError { | ||
keysWithLockedRewards: DataOfKeyWithLockedRewards[]; | ||
|
||
public constructor(rewardAccounts: RewardAccountWithPoolId[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- public constructor(rewardAccounts: RewardAccountWithPoolId[]) {
+ public constructor(rewardAccounts: Pick<RewardAccountWithPoolId, 'address'>[]) {
const createTxBuilderWithDreps = createTxBuilderWithRewardBalance(0n); | ||
const txBuilderFactory = await createTxBuilderWithDreps(...drepValues); | ||
|
||
await txBuilderFactory.txBuilder.delegatePortfolio(null).build().inspect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe best to wrap in an expect statement:
- await txBuilderFactory.txBuilder.delegatePortfolio(null).build().inspect();
+ await expect(() => txBuilderFactory.txBuilder.delegatePortfolio(null).build().inspect()).resolves.not.toThrow();
@@ -853,4 +865,131 @@ describe('TxBuilder/delegatePortfolio', () => { | |||
expect(roundRobinRandomImprove).toHaveBeenCalled(); | |||
}); | |||
}); | |||
|
|||
// eslint-disable-next-line sonarjs/cognitive-complexity | |||
describe('DRep delegation', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well written tests. Great coverage and easy to ready ❤️ 👏
}); | ||
}); | ||
|
||
it('attaches data of all locked locked reward account to the DeRegistrationsWithRewardsLocked error', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny typo
- it('attaches data of all locked locked reward account to the DeRegistrationsWithRewardsLocked error', async () => {
+ it('attaches data of all locked reward accounts to the DeRegistrationsWithRewardsLocked error', async () => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work @szymonmaslowski 👏 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 🚀
c03d01f
a169345
to
c03d01f
Compare
…rewards without drep
c03d01f
to
c594937
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏🏻
…rewards without drep
Context
After Chang Fork it will become impossible to deregister stake keys with rewards but without vote delegation. We want to show an error in lace when this situation occur during removing stake pools from portfolio.
Proposed Solution
Detect such case and throw an error with a set of required data so lace could list the affected keys.
Important Changes Introduced