Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
596bd9d
feat: 🎸 support customClaim withouth scope
sansan Nov 8, 2024
953f835
feat: 🎸 Return ticker value with asset details
prashantasdeveloper Nov 11, 2024
bbfbda8
feat: 🎸 Add endpoints to link, unlink ticker
prashantasdeveloper Nov 11, 2024
db90ed5
style: 💄 throw better error message for missing `type`
polymath-eric Nov 14, 2024
bd68846
docs: ✏️ update `asset` to `assets` in for metadata tag
polymath-eric Nov 14, 2024
b1aec9c
feat: 🎸 Bump package version
prashantasdeveloper Nov 15, 2024
4a662ec
feat: 🎸 get all eligible dividend distributions for did
sansan Nov 21, 2024
375297a
feat: 🎸 add endpoint to get paymentHistory for a distribution
sansan Nov 21, 2024
661b132
feat: 🎸 Return newly created nft collection when creating one
prashantasdeveloper Nov 22, 2024
06e9dc8
feat: 🎸 Make ticker optional while creating nft collection
prashantasdeveloper Nov 22, 2024
e4b04c9
feat: 🎸 enable fetching agents for an asset
sansan Nov 22, 2024
8849d34
fix: 🐛 Add missing `IsOptional` to `CreateVenueDto.signers`
prashantasdeveloper Nov 26, 2024
5ccb402
fix: 🐛 Fix validations for `ScopeType.Asset` in `ScopeDto`
prashantasdeveloper Nov 26, 2024
89f96d0
docs: ✏️ Update swagger examples to display asset IDs
prashantasdeveloper Nov 26, 2024
49378b1
fix: 🐛 Add missing `IsOptional` to `securityIdentifiers`
prashantasdeveloper Nov 26, 2024
38dcfae
fix: 🐛 Add missing support for NFT collection in UUID format
prashantasdeveloper Nov 26, 2024
4156d0e
chore: 🤖 bump package version
prashantasdeveloper Nov 26, 2024
eb1ea7a
feat: 🎸 remove POST /mock-cdd use /create-test-accounts instead
polymath-eric Nov 26, 2024
b0d380c
fix: 🐛 Use `getLegsFromChain` for getting legs after creation
prashantasdeveloper Nov 27, 2024
e24b94d
feat: 🎸 add endpoint to create permission group for asset
sansan Nov 22, 2024
8b60c96
feat: 🎸 Bump SDK version to v27.0.0-alpha.6
prashantasdeveloper Nov 28, 2024
e4f2699
feat: 🎸 Bump SDK version to 27.0.0-alpha.9
prashantasdeveloper Nov 28, 2024
4d0846a
feat: 🎸 add/remove agent to a PermissionGroup
sansan Nov 26, 2024
fa17c34
refactor: 💡 pr comments
sansan Dec 4, 2024
f6ef682
feat: 🎸 modify permission group permissions
sansan Dec 4, 2024
4722a46
feat: 🎸 check asset permissions for did
sansan Dec 4, 2024
8bf926b
feat: 🎸 get asset groups for did
sansan Dec 6, 2024
311924f
fix: 🐛 bump sdk to v27.0.2
polymath-eric Dec 6, 2024
d81c793
feat: 🎸 update code to accomodate sdk v27.0.2
polymath-eric Dec 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed AccountsService
Empty file.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymesh-rest-api",
"version": "5.1.0",
"version": "7.0.0",
"description": "Provides a REST like interface for interacting with the Polymesh blockchain",
"author": "Polymesh Association",
"private": true,
Expand Down Expand Up @@ -49,7 +49,7 @@
"@polymeshassociation/fireblocks-signing-manager": "^2.5.0",
"@polymeshassociation/hashicorp-vault-signing-manager": "^3.4.0",
"@polymeshassociation/local-signing-manager": "^3.3.0",
"@polymeshassociation/polymesh-sdk": "^26.1.0",
"@polymeshassociation/polymesh-sdk": "^27.0.0-alpha.9",
"@polymeshassociation/signing-manager-types": "^3.2.0",
"class-transformer": "0.5.1",
"class-validator": "^0.14.0",
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/models/asset-permissions.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class AssetPermissionsModel extends PermissionTypeModel {
description: 'List of included/excluded Assets',
type: 'string',
isArray: true,
example: ['TICKER123456'],
example: ['3616b82e-8e10-80ae-dc95-2ea28b9db8b3'],
})
readonly values: string[];

Expand Down
52 changes: 49 additions & 3 deletions src/assets/assets.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/* eslint-disable import/first */
const mockIsFungibleAsset = jest.fn();

import { DeepMocked } from '@golevelup/ts-jest';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { Test, TestingModule } from '@nestjs/testing';
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
import { KnownAssetType, SecurityIdentifierType } from '@polymeshassociation/polymesh-sdk/types';
import {
CustomPermissionGroup,
Identity,
KnownAssetType,
SecurityIdentifierType,
TxGroup,
} from '@polymeshassociation/polymesh-sdk/types';

import { MAX_CONTENT_HASH_LENGTH } from '~/assets/assets.consts';
import { AssetsController } from '~/assets/assets.controller';
Expand Down Expand Up @@ -68,6 +74,8 @@ describe('AssetsController', () => {

describe('getDetails', () => {
it('should return the details', async () => {
const mockFullAgents = [createMock<Identity>({ did })];

const mockAssetDetails = {
assetType: KnownAssetType.EquityCommon,
isDivisible: false,
Expand All @@ -76,6 +84,7 @@ describe('AssetsController', () => {
did,
},
totalSupply: new BigNumber(1),
ticker: 'TICKER',
};
const mockIdentifiers = [
{
Expand All @@ -85,7 +94,7 @@ describe('AssetsController', () => {
];
const mockAssetIsFrozen = false;
const mockAsset = new MockAsset();
mockAsset.details.mockResolvedValue(mockAssetDetails);
mockAsset.details.mockResolvedValue({ ...mockAssetDetails, fullAgents: mockFullAgents });
mockAsset.getIdentifiers.mockResolvedValue(mockIdentifiers);
mockAsset.isFrozen.mockResolvedValue(mockAssetIsFrozen);

Expand All @@ -99,6 +108,7 @@ describe('AssetsController', () => {

const mockResult = {
...mockAssetDetails,
agents: [did],
assetId: mockAsset.id,
securityIdentifiers: mockIdentifiers,
fundingRound: mockFundingRound,
Expand Down Expand Up @@ -439,4 +449,40 @@ describe('AssetsController', () => {
});
});
});

describe('linkTicker', () => {
it('should call the service and return the results', async () => {
const ticker = 'TICKER';
mockAssetsService.linkTickerToAsset.mockResolvedValue(txResult);

const result = await controller.linkTicker({ asset: assetId }, { signer, ticker });
expect(result).toEqual(processedTxResult);
expect(mockAssetsService.linkTickerToAsset).toHaveBeenCalledWith(assetId, { signer, ticker });
});
});

describe('unlinkTicker', () => {
it('should call the service and return the results', async () => {
mockAssetsService.unlinkTickerFromAsset.mockResolvedValue(txResult);

const result = await controller.unlinkTicker({ asset: assetId }, { signer });
expect(result).toEqual(processedTxResult);
expect(mockAssetsService.unlinkTickerFromAsset).toHaveBeenCalledWith(assetId, { signer });
});
});

describe('createGroup', () => {
it('should call the service and return the results', async () => {
const mockGroup = createMock<CustomPermissionGroup>({ id: 'someId' });

mockAssetsService.createPermissionGroup.mockResolvedValue({ ...txResult, result: mockGroup });

const result = await controller.createGroup(
{ asset: assetId },
{ signer, transactionGroups: [TxGroup.Distribution] }
);

expect(result).toEqual({ ...processedTxResult, id: mockGroup.id });
});
});
});
94 changes: 91 additions & 3 deletions src/assets/assets.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { Body, Controller, Get, HttpStatus, Param, Post, Query } from '@nestjs/common';
import {
ApiBadRequestResponse,
ApiGoneResponse,
Expand All @@ -10,26 +10,33 @@ import {
ApiTags,
ApiUnprocessableEntityResponse,
} from '@nestjs/swagger';
import { Asset } from '@polymeshassociation/polymesh-sdk/types';
import { Asset, CustomPermissionGroup } from '@polymeshassociation/polymesh-sdk/types';

import { AssetsService } from '~/assets/assets.service';
import { createAssetDetailsModel } from '~/assets/assets.util';
import { AssetParamsDto } from '~/assets/dto/asset-params.dto';
import { ControllerTransferDto } from '~/assets/dto/controller-transfer.dto';
import { CreateAssetDto } from '~/assets/dto/create-asset.dto';
import { CreatePermissionGroupDto } from '~/assets/dto/create-permission-group.dto';
import { IssueDto } from '~/assets/dto/issue.dto';
import { LinkTickerDto } from '~/assets/dto/link-ticker.dto';
import { RedeemTokensDto } from '~/assets/dto/redeem-tokens.dto';
import { RequiredMediatorsDto } from '~/assets/dto/required-mediators.dto';
import { SetAssetDocumentsDto } from '~/assets/dto/set-asset-documents.dto';
import { AgentOperationModel } from '~/assets/models/agent-operation.model';
import { AssetDetailsModel } from '~/assets/models/asset-details.model';
import { AssetDocumentModel } from '~/assets/models/asset-document.model';
import { CreatedAssetModel } from '~/assets/models/created-asset.model';
import { CreatedCustomPermissionGroupModel } from '~/assets/models/created-custom-permission-group.model';
import { IdentityBalanceModel } from '~/assets/models/identity-balance.model';
import { RequiredMediatorsModel } from '~/assets/models/required-mediators.model';
import { authorizationRequestResolver } from '~/authorizations/authorizations.util';
import { CreatedAuthorizationRequestModel } from '~/authorizations/models/created-authorization-request.model';
import { ApiArrayResponse, ApiTransactionResponse } from '~/common/decorators/';
import {
ApiArrayResponse,
ApiTransactionFailedResponse,
ApiTransactionResponse,
} from '~/common/decorators/';
import { PaginatedParamsDto } from '~/common/dto/paginated-params.dto';
import { TransactionBaseDto } from '~/common/dto/transaction-base-dto';
import { TransferOwnershipDto } from '~/common/dto/transfer-ownership.dto';
Expand Down Expand Up @@ -583,4 +590,85 @@ export class AssetsController {

return handleServiceResult(result);
}

@ApiOperation({
summary: 'Link a ticker to an Asset',
description: 'This endpoint allows linking a ticker to an existing Asset',
})
@ApiTransactionResponse({
description: 'Details about the transaction',
type: TransactionQueueModel,
})
@ApiNotFoundResponse({
description: 'The Asset does not exist',
})
@ApiUnprocessableEntityResponse({
description: 'Ticker is already linked with another asset',
})
@Post(':asset/link-ticker')
public async linkTicker(
@Param() { asset }: AssetParamsDto,
@Body() params: LinkTickerDto
): Promise<TransactionResponseModel> {
const result = await this.assetsService.linkTickerToAsset(asset, params);
return handleServiceResult(result);
}

@ApiOperation({
summary: 'Unlink a ticker from an Asset',
description: 'This endpoint allows unlinking a ticker from an existing Asset',
})
@ApiTransactionResponse({
description: 'Details about the transaction',
type: TransactionQueueModel,
})
@ApiNotFoundResponse({
description: 'The Asset does not exist',
})
@Post(':asset/unlink-ticker')
public async unlinkTicker(
@Param() { asset }: AssetParamsDto,
@Body() params: TransactionBaseDto
): Promise<TransactionResponseModel> {
const result = await this.assetsService.unlinkTickerFromAsset(asset, params);
return handleServiceResult(result);
}

@ApiOperation({
summary: 'Create a permission group',
description: 'This endpoint allows for the creation of a permission group for an asset',
})
@ApiTransactionResponse({
description: 'Details about the transaction',
type: TransactionQueueModel,
})
@ApiNotFoundResponse({
description: 'The Asset does not exist',
})
@ApiTransactionFailedResponse({
[HttpStatus.BAD_REQUEST]: ['There already exists a group with the exact same permissions'],
[HttpStatus.UNAUTHORIZED]: [
'The signing identity does not have the required permissions to create a permission group',
],
})
@Post(':asset/create-permission-group')
public async createGroup(
@Param() { asset }: AssetParamsDto,
@Body() params: CreatePermissionGroupDto
): Promise<TransactionResponseModel> {
const result = await this.assetsService.createPermissionGroup(asset, params);

const resolver: TransactionResolver<CustomPermissionGroup> = ({
result: group,
transactions,
details,
}) =>
new CreatedCustomPermissionGroupModel({
id: group.id,
transactions,
details,
});

return handleServiceResult(result, resolver);
}
}
Loading
Loading