-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 add endpoint to create permission group for asset
- Loading branch information
Showing
10 changed files
with
339 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { TxGroup } from '@polymeshassociation/polymesh-sdk/types'; | ||
import { Type } from 'class-transformer'; | ||
import { IsArray, IsEnum, ValidateNested } from 'class-validator'; | ||
|
||
import { IncompatibleWith } from '~/common/decorators'; | ||
import { TransactionBaseDto } from '~/common/dto/transaction-base-dto'; | ||
import { TransactionPermissionsDto } from '~/identities/dto/transaction-permissions.dto'; | ||
|
||
export class CreatePermissionGroupDto extends TransactionBaseDto { | ||
@ApiPropertyOptional({ | ||
description: | ||
'Transactions that the `external agent` has permission to execute. This value should not be passed along with the `transactionGroups`.', | ||
type: TransactionPermissionsDto, | ||
nullable: true, | ||
}) | ||
@ValidateNested() | ||
@IncompatibleWith(['transactionGroups'], { | ||
message: 'Cannot specify both transactions and transactionGroups', | ||
}) | ||
@Type(() => TransactionPermissionsDto) | ||
readonly transactions?: TransactionPermissionsDto; | ||
|
||
@ApiPropertyOptional({ | ||
description: | ||
'Transaction Groups that `external agent` has permission to execute. This value should not be passed along with the `transactions`.', | ||
isArray: true, | ||
enum: TxGroup, | ||
example: [TxGroup.Distribution], | ||
}) | ||
@IncompatibleWith(['transactions'], { | ||
message: 'Cannot specify both transactions and transactionGroups', | ||
}) | ||
@IsArray() | ||
@IsEnum(TxGroup, { each: true }) | ||
readonly transactionGroups?: TxGroup[]; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/assets/models/created-custom-permission-group.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { BigNumber } from 'bignumber.js'; | ||
|
||
import { TransactionQueueModel } from '~/common/models/transaction-queue.model'; | ||
|
||
export class CreatedCustomPermissionGroupModel extends TransactionQueueModel { | ||
@ApiPropertyOptional({ | ||
description: 'The newly created ID', | ||
example: '1', | ||
}) | ||
readonly id: BigNumber; | ||
|
||
constructor(model: CreatedCustomPermissionGroupModel) { | ||
const { transactions, details, ...rest } = model; | ||
super({ transactions, details }); | ||
|
||
Object.assign(this, rest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.