Skip to content

Commit e94a1c9

Browse files
committed
fix: make delegate description mandatory
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
1 parent bc79581 commit e94a1c9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/entities/SecurityToken/Permissions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ export class Permissions extends SubModule {
9292
*
9393
* @param delegateAddress wallet address of the delegate
9494
* @param role role to assign
95-
* @param description description of the delegate (defaults to empty string, is ignored if the delegate already exists)
95+
* @param description description of the delegate (is ignored if the delegate already exists)
9696
*/
9797
public assignRole = async (args: {
9898
delegateAddress: string;
9999
role: SecurityTokenRole;
100-
description?: string;
100+
description: string;
101101
}) => {
102102
const { symbol } = this.securityToken;
103103

@@ -126,6 +126,7 @@ export class Permissions extends SubModule {
126126
{
127127
symbol,
128128
assign: false,
129+
description: '', // this is not used when revoking
129130
...args,
130131
},
131132
this.context

src/procedures/AssignSecurityTokenRole.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class AssignSecurityTokenRole extends Procedure<AssignSecurityTokenRolePr
1313
public type = ProcedureType.AssignSecurityTokenRole;
1414

1515
public async prepareTransactions() {
16-
const { symbol, role, assign, description = '', delegateAddress } = this.args;
16+
const { symbol, role, assign, description, delegateAddress } = this.args;
1717
const { contractWrappers } = this.context;
1818
const delegate = conversionUtils.checksumAddress(delegateAddress);
1919

@@ -63,7 +63,8 @@ export class AssignSecurityTokenRole extends Procedure<AssignSecurityTokenRolePr
6363
))[0];
6464

6565
const delegates = await permissionModule.getAllDelegates();
66-
const exists = delegates.filter(element => element === delegate).length > 0;
66+
const exists =
67+
delegates.filter(element => element.toUpperCase() === delegate.toUpperCase()).length > 0;
6768

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

79-
const permitted = !!permittedDelegates.find(element => element === delegate);
80+
const permitted = !!permittedDelegates.find(
81+
element => element.toUpperCase() === delegate.toUpperCase()
82+
);
8083

8184
// Upcoming permission equals existing one
8285
if (permitted === assign) {

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export interface AssignSecurityTokenRoleProcedureArgs {
326326
delegateAddress: string;
327327
role: SecurityTokenRole;
328328
assign: boolean;
329-
description?: string;
329+
description: string;
330330
}
331331

332332
export interface AssignStoRoleProcedureArgs {

0 commit comments

Comments
 (0)