Skip to content

Commit 358b23f

Browse files
committed
fix: check that corresponding feature is enabled
1 parent d81d24b commit 358b23f

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/entities/SecurityToken/Permissions.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,25 @@ export class Permissions extends SubModule {
197197
securityToken: { symbol, features },
198198
} = this;
199199

200-
const isPermissionsEnabled = await features.isEnabled({ feature: Feature.Permissions });
200+
const [isPermissionsEnabled, requiredFeature] = await Promise.all([
201+
features.isEnabled({ feature: Feature.Permissions }),
202+
this.getFeatureFromRole({ role }),
203+
]);
201204
if (!isPermissionsEnabled) {
202205
throw new PolymathError({
203206
code: ErrorCode.FeatureNotEnabled,
204207
message: 'You must enable the Permissions feature',
205208
});
206209
}
207210

211+
const isFeatureEnabled = await features.isEnabled({ feature: requiredFeature });
212+
if (!isFeatureEnabled) {
213+
throw new PolymathError({
214+
code: ErrorCode.FeatureNotEnabled,
215+
message: `You must enable the ${requiredFeature} feature to check delegates for role ${role}`,
216+
});
217+
}
218+
208219
const generalPermissionManager = (await contractWrappers.getAttachedModules(
209220
{ moduleName: ModuleName.GeneralPermissionManager, symbol },
210221
{ unarchived: true }

src/procedures/AssignSecurityTokenRole.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class AssignSecurityTokenRole extends Procedure<AssignSecurityTokenRolePr
3434
if (!permissionModule) {
3535
throw new PolymathError({
3636
code: ErrorCode.ProcedureValidationError,
37-
message: 'You must enable the Permissions feature',
37+
message: 'You must enable the Permissions feature in order to assign roles',
3838
});
3939
}
4040

@@ -51,7 +51,7 @@ export class AssignSecurityTokenRole extends Procedure<AssignSecurityTokenRolePr
5151
if (!isAvailable) {
5252
throw new PolymathError({
5353
code: ErrorCode.FeatureNotEnabled,
54-
message: `You must enable the ${requiredFeature} feature`,
54+
message: `You must enable the ${requiredFeature} feature in order to assign the ${role} role`,
5555
});
5656
}
5757

0 commit comments

Comments
 (0)