Skip to content

Commit

Permalink
rename isPluginUpdateAction function
Browse files Browse the repository at this point in the history
  • Loading branch information
josemarinas committed Nov 21, 2023
1 parent 27ab967 commit f292f2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions modules/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ TEMPLATE:
- Rename `isDaoUpdateValid` to `isDaoUpdateProposalValid`
- Rename `isPluginUpdate` to `isPluginUpdateProposal`
- Rename `isPluginUpdateValid` to `isPluginUpdateProposalValid`
- Rename `isPluginUpdateAction` to `containsPluginUpdateAction`
- Rename `isPluginUpdateActionBlockWithRootPermission` to `containsPluginUpdateActionBlockWithRootPermission`



Expand Down
8 changes: 4 additions & 4 deletions modules/client/src/internal/client/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ import {
import {
classifyProposalActions,
containsDaoUpdateAction,
isPluginUpdateAction,
isPluginUpdateActionBlockWithRootPermission,
containsPluginUpdateActionBlock,
containsPluginUpdateActionBlockWithRootPermission,
toAssetBalance,
toDaoActions,
toDaoDetails,
Expand Down Expand Up @@ -1155,8 +1155,8 @@ export class ClientMethods extends ClientCore implements IClientMethods {
if(containsDaoUpdateAction(classifiedActions)) {
classifiedActions = classifiedActions.slice(1);
}
return isPluginUpdateAction(classifiedActions) ||
isPluginUpdateActionBlockWithRootPermission(classifiedActions);
return containsPluginUpdateActionBlock(classifiedActions) ||
containsPluginUpdateActionBlockWithRootPermission(classifiedActions);
}
/**
* Check if the specified proposal id is valid for updating a plugin
Expand Down
12 changes: 6 additions & 6 deletions modules/client/src/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ export function classifyProposalActions(
* @param {ProposalActionTypes[]} actions
* @return {*} {boolean}
*/
export function isPluginUpdateActionBlockWithRootPermission(
export function containsPluginUpdateActionBlockWithRootPermission(
actions: ProposalActionTypes[],
): boolean {
// get the first 5 actions
Expand All @@ -1346,7 +1346,7 @@ export function isPluginUpdateActionBlockWithRootPermission(
* @param {ProposalActionTypes[]} actions
* @return {*} {boolean}
*/
export function isPluginUpdateAction(actions: ProposalActionTypes[]): boolean {
export function containsPluginUpdateActionBlock(actions: ProposalActionTypes[]): boolean {
// get the first 3 action
const receivedPattern = actions.slice(0, 3);
// check if it matches the expected pattern
Expand Down Expand Up @@ -1478,7 +1478,7 @@ export async function validateUpdatePluginProposalActions(
let proposalSettingsErrorCauses: ProposalSettingsErrorCause[] = [];
const classifiedActions = classifyProposalActions(actions);
// check if is an update plugin proposal
if (isPluginUpdateAction(classifiedActions)) {
if (containsPluginUpdateActionBlock(classifiedActions)) {
// initialize the causes array
// we always use the index 0
// because this is going to be called recursively
Expand Down Expand Up @@ -1521,7 +1521,7 @@ export async function validateUpdatePluginProposalActions(
actionErrorCauses[0] = [...actionErrorCauses[0], ...resCauses];
break;
// other cases are not allowed and should have been
// caught by the isPluginUpdateAction function
// caught by the containsPluginUpdateActionBlock function
}
}
// slice the first 3 actions
Expand Down Expand Up @@ -1556,7 +1556,7 @@ export async function validateUpdatePluginProposalActions(
};
}

if (isPluginUpdateActionBlockWithRootPermission(classifiedActions)) {
if (containsPluginUpdateActionBlockWithRootPermission(classifiedActions)) {
// initialize the causes array
// we always use the index 0
// because this is going to be called recursively
Expand Down Expand Up @@ -1621,7 +1621,7 @@ export async function validateUpdatePluginProposalActions(
break;

// other cases are not allowed and should have been
// caught by the isPluginUpdateActionBlockWithRootPermission function
// caught by the containsPluginUpdateActionBlockWithRootPermission function
}
}
// slice the first 5 actions
Expand Down
8 changes: 4 additions & 4 deletions modules/client/test/unit/client/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import {
containsDaoUpdateAction,
isPluginUpdateAction,
isPluginUpdateActionBlockWithRootPermission,
containsPluginUpdateActionBlockWithRootPermission,
validateApplyUpdateFunction,
validateGrantRootPermissionAction,
validateGrantUpdatePluginPermissionAction,
Expand Down Expand Up @@ -1359,7 +1359,7 @@ describe("Test client utils", () => {
}
});
});
describe("isPluginUpdateAction", () => {
describe("containsPluginUpdateActionBlock", () => {
it("should return the expected output given a specific input", () => {
const cases = [
{ input: [ProposalActionTypes.UPGRADE_TO], expected: false },
Expand Down Expand Up @@ -1419,7 +1419,7 @@ describe("Test client utils", () => {
},
];
for (const { input, expected } of cases) {
const result = isPluginUpdateAction(input);
const result = containsPluginUpdateActionBlock(input);
expect(result).toEqual(expected);
}
});
Expand Down Expand Up @@ -1488,7 +1488,7 @@ describe("Test client utils", () => {
},
];
for (const { input, expected } of cases) {
const result = isPluginUpdateActionBlockWithRootPermission(input);
const result = containsPluginUpdateActionBlockWithRootPermission(input);
expect(result).toEqual(expected);
}
});
Expand Down

0 comments on commit f292f2a

Please sign in to comment.