Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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.2",
"@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
3 changes: 2 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { OfflineRecorderModule } from '~/offline-recorder/offline-recorder.modul
import { OfflineSignerModule } from '~/offline-signer/offline-signer.module';
import { OfflineStarterModule } from '~/offline-starter/offline-starter.module';
import { OfflineSubmitterModule } from '~/offline-submitter/offline-submitter.module';
import { PermissionGroupsModule } from '~/permission-groups/permission-groups.module';
import { PolymeshModule } from '~/polymesh/polymesh.module';
import { PortfoliosModule } from '~/portfolios/portfolios.module';
import { ScheduleModule } from '~/schedule/schedule.module';
Expand All @@ -37,7 +38,6 @@ import { SubsidyModule } from '~/subsidy/subsidy.module';
import { TickerReservationsModule } from '~/ticker-reservations/ticker-reservations.module';
import { TransactionsModule } from '~/transactions/transactions.module';
import { UsersModule } from '~/users/users.module';

@Module({
imports: [
ConfigModule.forRoot({
Expand Down Expand Up @@ -107,6 +107,7 @@ import { UsersModule } from '~/users/users.module';
OfflineStarterModule,
OfflineRecorderModule,
MultiSigsModule,
PermissionGroupsModule,
],
})
export class AppModule {}
35 changes: 32 additions & 3 deletions src/assets/assets.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/* 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 {
Identity,
KnownAssetType,
SecurityIdentifierType,
} 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 +72,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 +82,7 @@ describe('AssetsController', () => {
did,
},
totalSupply: new BigNumber(1),
ticker: 'TICKER',
};
const mockIdentifiers = [
{
Expand All @@ -85,7 +92,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 +106,7 @@ describe('AssetsController', () => {

const mockResult = {
...mockAssetDetails,
agents: [did],
assetId: mockAsset.id,
securityIdentifiers: mockIdentifiers,
fundingRound: mockFundingRound,
Expand Down Expand Up @@ -439,4 +447,25 @@ 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 });
});
});
});
44 changes: 44 additions & 0 deletions src/assets/assets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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 { 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';
Expand Down Expand Up @@ -583,4 +584,47 @@ 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);
}
}
78 changes: 76 additions & 2 deletions src/assets/assets.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { mockTransactionsProvider, MockTransactionsService } from '~/test-utils/service-mocks';
import * as transactionsUtilModule from '~/transactions/transactions.util';

const { did, signer } = testValues;
const { did, signer, assetId } = testValues;

jest.mock('@polymeshassociation/polymesh-sdk/utils', () => ({
...jest.requireActual('@polymeshassociation/polymesh-sdk/utils'),
Expand Down Expand Up @@ -71,13 +71,25 @@ describe('AssetsService', () => {
it('should return the Asset for a valid ticker', async () => {
const mockAsset = new MockAsset();

mockPolymeshApi.assets.getAsset.mockResolvedValue(mockAsset);
when(mockPolymeshApi.assets.getAsset)
.calledWith({ ticker: 'TICKER' })
.mockResolvedValue(mockAsset);

const result = await service.findOne('TICKER');

expect(result).toEqual(mockAsset);
});

it('should return the Asset for a valid Asset ID', async () => {
const mockAsset = new MockAsset();

when(mockPolymeshApi.assets.getAsset).calledWith({ assetId }).mockResolvedValue(mockAsset);

const result = await service.findOne(assetId);

expect(result).toEqual(mockAsset);
});

describe('otherwise', () => {
it('should call the handleSdkError method and throw an error', async () => {
const mockError = new Error('Some Error');
Expand Down Expand Up @@ -704,4 +716,66 @@ describe('AssetsService', () => {
);
});
});

describe('linkTickerToAsset', () => {
it('should link the given ticker', async () => {
const transaction = {
blockHash: '0x1',
txHash: '0x2',
blockNumber: new BigNumber(1),
tag: TxTags.asset.LinkTickerToAssetId,
};
const findSpy = jest.spyOn(service, 'findOne');

const mockTransaction = new MockTransaction(transaction);
const mockAsset = new MockAsset();
mockTransactionsService.submit.mockResolvedValue({ transactions: [mockTransaction] });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
findSpy.mockResolvedValue(mockAsset as any);

const result = await service.linkTickerToAsset(assetId, { signer, ticker: 'TICKER' });
expect(result).toEqual({
result: undefined,
transactions: [mockTransaction],
});

expect(mockTransactionsService.submit).toHaveBeenCalledWith(
mockAsset.linkTicker,
{
ticker: 'TICKER',
},
expect.objectContaining({ signer })
);
});
});

describe('unlinkTickerFromAsset', () => {
it('should unlink the ticker from the asset', async () => {
const transaction = {
blockHash: '0x1',
txHash: '0x2',
blockNumber: new BigNumber(1),
tag: TxTags.asset.UnlinkTickerFromAssetId,
};
const findSpy = jest.spyOn(service, 'findOne');

const mockTransaction = new MockTransaction(transaction);
const mockAsset = new MockAsset();
mockTransactionsService.submit.mockResolvedValue({ transactions: [mockTransaction] });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
findSpy.mockResolvedValue(mockAsset as any);

const result = await service.unlinkTickerFromAsset(assetId, { signer });
expect(result).toEqual({
result: undefined,
transactions: [mockTransaction],
});

expect(mockTransactionsService.submit).toHaveBeenCalledWith(
mockAsset.unlinkTicker,
{},
expect.objectContaining({ signer })
);
});
});
});
Loading
Loading