Skip to content

Commit

Permalink
fix: make delegate description mandatory
Browse files Browse the repository at this point in the history
This reflects what the smart contracts expect

BREAKING CHANGE: make the description parameter mandatory in the `assignRole` function in the
Security Token's permissions namespace

fix #100
  • Loading branch information
monitz87 committed Oct 27, 2019
1 parent bc79581 commit e94a1c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/entities/SecurityToken/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ export class Permissions extends SubModule {
*
* @param delegateAddress wallet address of the delegate
* @param role role to assign
* @param description description of the delegate (defaults to empty string, is ignored if the delegate already exists)
* @param description description of the delegate (is ignored if the delegate already exists)
*/
public assignRole = async (args: {
delegateAddress: string;
role: SecurityTokenRole;
description?: string;
description: string;
}) => {
const { symbol } = this.securityToken;

Expand Down Expand Up @@ -126,6 +126,7 @@ export class Permissions extends SubModule {
{
symbol,
assign: false,
description: '', // this is not used when revoking
...args,
},
this.context
Expand Down
9 changes: 6 additions & 3 deletions src/procedures/AssignSecurityTokenRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class AssignSecurityTokenRole extends Procedure<AssignSecurityTokenRolePr
public type = ProcedureType.AssignSecurityTokenRole;

public async prepareTransactions() {
const { symbol, role, assign, description = '', delegateAddress } = this.args;
const { symbol, role, assign, description, delegateAddress } = this.args;
const { contractWrappers } = this.context;
const delegate = conversionUtils.checksumAddress(delegateAddress);

Expand Down Expand Up @@ -63,7 +63,8 @@ export class AssignSecurityTokenRole extends Procedure<AssignSecurityTokenRolePr
))[0];

const delegates = await permissionModule.getAllDelegates();
const exists = delegates.filter(element => element === delegate).length > 0;
const exists =
delegates.filter(element => element.toUpperCase() === delegate.toUpperCase()).length > 0;

/**
* In the following block we attempt to:
Expand All @@ -76,7 +77,9 @@ export class AssignSecurityTokenRole extends Procedure<AssignSecurityTokenRolePr
perm,
});

const permitted = !!permittedDelegates.find(element => element === delegate);
const permitted = !!permittedDelegates.find(
element => element.toUpperCase() === delegate.toUpperCase()
);

// Upcoming permission equals existing one
if (permitted === assign) {
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export interface AssignSecurityTokenRoleProcedureArgs {
delegateAddress: string;
role: SecurityTokenRole;
assign: boolean;
description?: string;
description: string;
}

export interface AssignStoRoleProcedureArgs {
Expand Down

0 comments on commit e94a1c9

Please sign in to comment.