Skip to content

Commit

Permalink
fix: 🐛 allow payee to set auto stake for themselves
Browse files Browse the repository at this point in the history
consider autoStake when calculating NoDataChange error
  • Loading branch information
polymath-eric committed Jan 27, 2025
1 parent 8403415 commit bb7f256
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/api/procedures/__tests__/setStakingPayee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ describe('setStakingPayee procedure', () => {
return expect(prepareSetStakingPayee.call(proc, args)).rejects.toThrow(expectedError);
});

it('should allow the same payee if auto stake value differs', async () => {
currentPayee.account = entityMockUtils.getAccountInstance({ isEqual: true });

const proc = procedureMockUtils.getInstance<Params, void, Storage>(mockContext, {
actingAccount,
currentPayee,
ledger,
});

const args = {
payee: newPayee,
autoStake: true,
};

return expect(prepareSetStakingPayee.call(proc, args)).resolves.not.toThrow();
});

it('should return a setPayee transaction spec', async () => {
const proc = procedureMockUtils.getInstance<Params, void, Storage>(mockContext, {
actingAccount,
Expand Down
2 changes: 1 addition & 1 deletion src/api/procedures/setStakingPayee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function prepareSetStakingPayee(

const payee = asAccount(payeeInput, context);

if (currentPayee.account.isEqual(payee)) {
if (currentPayee.autoStaked === autoStake && currentPayee.account.isEqual(payee)) {
throw new PolymeshError({
code: ErrorCode.NoDataChange,
message: 'The given payee is already set',
Expand Down

0 comments on commit bb7f256

Please sign in to comment.