Skip to content

Commit

Permalink
feat: 馃幐 rename grantedAt
Browse files Browse the repository at this point in the history
improve documentation of `setGroup` parameters

BREAKING CHANGE: 馃Ж rename `tokenPermissions.grantedAt` to `enabledAt`
  • Loading branch information
monitz87 committed Sep 7, 2021
1 parent 2f5b024 commit a1bc8c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/api/entities/Identity/TokenPermissions.ts
Expand Up @@ -253,13 +253,13 @@ export class TokenPermissions extends Namespace<Identity> {
}

/**
* Retrieve the identifier data (block number, date and event index) of the event that was emitted when this Identity was granted
* permissions over a specific Security Token
* Retrieve the identifier data (block number, date and event index) of the event that was emitted when this Identity was enabled/added as
* an Agent with permissions over a specific Security Token
*
* @note uses the middleware
* @note there is a possibility that the data is not ready by the time it is requested. In that case, `null` is returned
*/
public async grantedAt({
public async enabledAt({
token,
}: {
token: string | SecurityToken;
Expand Down
6 changes: 3 additions & 3 deletions src/api/entities/Identity/__tests__/TokenPermissions.ts
Expand Up @@ -87,7 +87,7 @@ describe('TokenPermissions class', () => {
});
});

describe('method: grantedAt', () => {
describe('method: enabledAt', () => {
test('should return the event identifier object of the agent added', async () => {
const blockNumber = new BigNumber(1234);
const blockDate = new Date('4/14/2020');
Expand All @@ -109,7 +109,7 @@ describe('TokenPermissions class', () => {
/* eslint-enable @typescript-eslint/naming-convention */
});

const result = await tokenPermissions.grantedAt({ token });
const result = await tokenPermissions.enabledAt({ token });

expect(result).toEqual(fakeResult);
});
Expand All @@ -122,7 +122,7 @@ describe('TokenPermissions class', () => {
};

dsMockUtils.createApolloQueryStub(eventByIndexedArgs(variables), {});
const result = await tokenPermissions.grantedAt({ token });
const result = await tokenPermissions.enabledAt({ token });
expect(result).toBeNull();
});
});
Expand Down
44 changes: 24 additions & 20 deletions src/api/procedures/setPermissionGroup.ts
Expand Up @@ -20,28 +20,32 @@ import {
} from '~/utils/conversion';
import { getToken } from '~/utils/internal';

export interface SetPermissionGroupParams {
interface TokenBase {
/**
* Permission Group to assign to the Identity. The Security Token is inferred from the group.
* Optionally, transaction permissions and a Security Token can be passed directly.
* In that case, a new Permission Group will be created and consequently assigned to the Identity
* Security Token over which the Identity will be granted permissions
*/
group:
| KnownPermissionGroup
| CustomPermissionGroup
| ({
/**
* Security Token over which the Identity will be granted permissions
*/
token: string | SecurityToken;
} & (
| {
transactions: TransactionPermissions;
}
| {
transactionGroups: TxGroup[];
}
));
token: string | SecurityToken;
}

interface TransactionsParams extends TokenBase {
transactions: TransactionPermissions;
}

interface TxGroupParams extends TokenBase {
transactionGroups: TxGroup[];
}

/**
* This procedure can be called with:
* - A Security Token's existing Custom Permission Group. The Identity will be assigned as an Agent of that Group for that Token
* - A Known Permission Group and a Security Token. The Identity will be assigned as an Agent of that Group for that Token
* - A set of Transaction Permissions and a Security Token. A Custom Permission Group will be created for that Token with those permissions, and
* the Identity will be assigned as an Agent of that Group for that Token
* - An array of [[TxGroup]]s that represent a set of permissions. A Custom Permission Group will be created with those permissions, and
* the Identity will be assigned as an Agent of that Group for that Token
*/
export interface SetPermissionGroupParams {
group: KnownPermissionGroup | CustomPermissionGroup | TransactionsParams | TxGroupParams;
}

/**
Expand Down

0 comments on commit a1bc8c3

Please sign in to comment.