Skip to content

Commit 0869485

Browse files
polymath-ericprashantasdevelopermonitz87satyamakgec
authored
Update master (#40)
* feat: 🎸 add identity namespace APIs * test: πŸ’ Add test cases for identities controller * fix: πŸ› use proper validation decorators for input DTOs * fix: πŸ› use proper nested validation for inputs * fix: πŸ› resolve linting error and refactor params dto * fix: πŸ› Update parse permission method usage * feat: 🎸 Add Claim APIs * feat: 🎸 add Entity serialization capabilities Created the `FromEntity` and `FromMaybeEntityArray` transformer decorators. Also added the Class Serializer interceptor globally BREAKING CHANGE: 🧨 PIA is no longer being returned as part of the token details * fix: πŸ› use proper return type for settlement endpoints * fix: πŸ› pass constructor parameters to TQ constructor * ci: 🎑 Add Github Workflow (#9) * fix: πŸ› use fixed SDK version * chore: πŸ€– Separate util functions and fix test cases As agreed upon, moving parsing methods from respective services to their separate util files and fix test cases accordingly. Also, added description as part of custom ApiArrayResponse. * chore: πŸ€– Replace token details with ticker value * chore: πŸ€– Updated swagger docs and code refactoring Update swagger docs for models and controllers. Refactored authorization and portfolio related files in separate modules. Added decorator to handle Entity type objects. * test: πŸ’ Add tests for authorizations and portfolios service Added authorization filter DTO and added examples to swagger responses. * refactor: πŸ’‘ Move portfolio.util to portfolios folder * Swagger doc changes * chore: πŸ€– Separate filter dto and update swagger docs * refactor: πŸ’‘ Move claim APIs to identities controller * refactor: πŸ’‘ Remove polymesh deps and usage of partial objects Removed the extra injected PolymeshModule and PolymeshService from existing spec files. Also, refactored out IdentitySignerModel. * chore: πŸ€– Remove flatten use while fetching associated claims * chore: πŸ€– Remove unused imports from test modules Also, removed usage of explicit any * feat: 🎸 Add Asset APIs Added APIs to get asset identifiers, documents, asset holders, compliance requirements * test: πŸ’ Add test cases for Assets controller Along with the test cases, merged the identifiers API in details API, updated swagger docs, replaced nullable loaded ApiProperty decorators with ApiPropertyOptional * chore: πŸ€– Update typescript version to 4.3.5 * feat: 🎸 Add Settlement APIs * docs: ✏️ Update Settlements related Swagger docs * refactor: πŸ’‘ Rename constructor param to model * fix: πŸ› InstructionIdModel path update * refactor: πŸ’‘ Rename constructor param for txn queue model * feat: 🎸 Add modify venue endpoint Adds PATCH /venues/:id to support updating venue details from the api. βœ… Closes: 335 * Remove as any types * cleanup github lint warnings * Clean up param parsing * fix lint errors * Make modify venue params optional * dont use internal sdk type * Clean up * chore: πŸ€– Disable logging for tests (#15) * ci: 🎑 separate jobs in github actions (#17) * ci: 🎑 separate jobs in github actions * ci: 🎑 use coverage testing command to prepare for sonarcloud * feat: 🎸 NCBD-339 Add trusted Claim Issuers API (#16) * feat: 🎸 Add trusted Claim Issuers API * chore: πŸ€– Update imports and swagger docs Co-authored-by: Satyam Agrawal <[email protected]> * refactor: πŸ’‘ Use service method to find venue for modify venue (#18) * refactor: πŸ’‘ Use service method to find venue for modify venue Use the existing service method to lookup the Venue instead of using the SDK. * feat: 🎸 Get list of trusting Tokens for an Identity (#21) * feat: 🎸 Get list of trusting Tokens for an Identity * chore: πŸ€– Remove order by option from trusting tokens API Removed OrderDto and made changes to support new API structure * feat: 🎸 NCBD-356 GET Asset Offerings (#24) * feat: 🎸 GET Asset Offerings * refactor: πŸ’‘ Create separate Offerings Controller Also addressed review changes and updated swagger docs * test: πŸ’ Add test for process queue error handling (#19) * test: πŸ’ Add test for process queue error handling Adds tests for process queue error code mapping * add linter comments to allow any * Add types to table driven utils test * Use http exception type instead of generic constructor * Define Class type in its own file. * move class to src/common/types Co-authored-by: Satyam Agrawal <[email protected]> * chore: πŸ€– Upgrade polymesh SDK to 7.0.0-alpha.15 (#23) * chore: πŸ€– Upgrade polymesh SDK to 7.0.0-alpha.15 Upgrades the polymesh SDK so the REST API is compatible with the newer chain version * Configure jest transformIgnorePatterns * pin to specific babel version * chore: πŸ€– remove mismatching dependencies * Explicitly set coverageDirectory jest config Co-authored-by: Jeremias Diaz <[email protected]> Co-authored-by: Satyam Agrawal <[email protected]> * feat: 🎸 NCBD-359 GET Asset Checkpoints (#26) * feat: 🎸 GET Asset Offerings * refactor: πŸ’‘ Create separate Offerings Controller Also addressed review changes and updated swagger docs * feat: 🎸 GET Asset Checkpoints * chore: πŸ€– Make checkpoints model attributes readonly * chore: πŸ€– Update swagger docs * feat: 🎸 Add ability to create assets (#20) * feat: 🎸 Add ability to create assets Adds a POST /assets and POST /reservations/ticker endpoints so a user will be able to create an asset through the API βœ… Closes: NCBD-334 * feat: 🎸 NCBD-360 Get Checkpoint Schedules (#27) * feat: 🎸 Get Checkpoint Schedules * chore: πŸ€– Remove relative import paths * refactor: πŸ’‘ Change test case names to match controller methods * chore: πŸ€– Update swagger docs for checkpoints schedule API * feat: 🎸 NCBD-344 Add Portfolio transfer endpoint (#25) * feat: 🎸 NCBD-344 Add Portfolio transfer endpoint Add /portfolios/{id}/transfers to allow a user to transfer Assets between their Portfolios. βœ… Closes: NCBD-344 * parent 8b299dc author Eric <[email protected]> 1628790602 -0400 committer Eric <[email protected]> 1628870568 -0400 Address PR comments Moves portfolio transfers to be under /identities so that the owner is clear * refactor: πŸ’‘ Move get portfolios from identities to portofolios Move get portfolios function from identites controller into the portfolios controller. * fix routing * fix: πŸ› Workaround minimum memo requirement Left pad memos with null bytes * remove redundant owner form dto * add note about max memo length * refactor: πŸ’‘ Rename transfer to movement Renames transfer to movement to be more consistent * refactor: πŸ’‘ Remove memo padding workaaround by upgrading SDK Upgrades the SDK version to v9.0.0-alpha.2 which has a bug fix for PortfolioMovement.memo padding * Feat/ncbd 357 get sto investments (#28) * feat: 🎸 Add GET Investments for an Offering Adds paginated endpoint GET /assets/:ticker/offerings/:id/investments βœ… Closes: NCBD-357 * address PR comments * fix typo * refactor: πŸ’‘ Add findOne method to OfferingsService Adds findOne function to offeringsService * rename findOne test Co-authored-by: Satyam Agrawal <[email protected]> * feat: 🎸 Add Issue Asset endpoint (#29) * feat: 🎸 Add Issue Asset endpoint Adds /assets/:ticker/issuance which allows the Asset owner or the PIA to issue more of the Asset βœ… Closes: NCBD-345 * refactor: πŸ’‘ Rename issueAsset to issue on AssetsService Co-authored-by: Prashant Bajpai <[email protected]> * feat: 🎸 NCBD-392 Corporate Action Defaults API (#30) * feat: 🎸 Corporate Action Defaults API * docs: ✏️ Swagger docs updates * docs: ✏️ Stylize swagger doc * fix: πŸ› Run husky install as prepare script (#37) Run `husky install` as prepare script. When a user runs `yarn` husky git hooks will get configured. * feat: 🎸 NCBD-362 API to check asset transfer (#31) * feat: 🎸 API to check asset transfer * refactor: πŸ’‘ Convert post leg validations to get * docs: ✏️ Fix swagger docs * docs: ✏️ Update swagger desc for compliance * chore: πŸ€– Add IsDid decorator * docs: ✏️ Update swagger docs * chore: πŸ€– Logging interceptor (#33) * chore: πŸ€– Logging interceptor * chore: πŸ€– Address PR comments * style: πŸ’„ Add missing return type and fix the response template * feat: 🎸 Add POST /venue (#35) * feat: 🎸 Add POST /venue Adds ability to create a venue through the API βœ… Closes: NCBD-334 * chore: πŸ€– Address PR comments * chore: πŸ€– Tweak DTO documentation Co-authored-by: Satyam Agrawal <[email protected]> * feat: 🎸 NCBD-393 Get Dividend Distributions associated with an Asset (#32) * feat: 🎸 Corporate Action Defaults API * feat: 🎸 Get Dividend Distributions associated with an Asset * refactor: πŸ’‘ Flatten dividend distribution model * docs: ✏️ Change swagger model name * refactor: πŸ’‘ Portfolio and CA model refactored Created a PortfolioIdentifierModel to handle DefaultPortfolio and NumberedPortfolio. Also, removed inheritance from CorporateActionModel. * chore: πŸ€– Address PR comments * test: πŸ’ Fix broken test cases wrt Portfolio * chore: πŸ€– Use MockDistribution and refactor mock classes * refactor: πŸ’‘ Move module specific mocks to respective modules Co-authored-by: Satyam Agrawal <[email protected]> * chore: πŸ€– Add Dockerfile (#39) * chore: πŸ€– NCBD-424 Standardize default portfolio to 0 (#38) * chore: πŸ€– Standardize default portfolio to 0 * chore: πŸ€– Create FromPortfolioId decorator * docs: ✏️ Remove optional for portfolio id swagger * fix: πŸ› Portfolio equals condition change Bumps version of sdk to 11 also * chore: πŸ€– Add optional checks and address review comments * fix: πŸ› Add yarn lock file changes * chore: πŸ€– Address PR comments Co-authored-by: Satyam Agrawal <[email protected]> Co-authored-by: Prashant Bajpai <[email protected]> Co-authored-by: Jeremias Diaz <[email protected]> Co-authored-by: Prashant Bajpai <[email protected]> Co-authored-by: Satyam Agrawal <[email protected]>
1 parent 2ddb351 commit 0869485

File tree

144 files changed

+8377
-1590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+8377
-1590
lines changed

β€Ž.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
node_modules/

β€Ž.github/pull_request_template.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### JIRA Link
2+
3+
Insert JIRA url here
4+
5+
### Changelog / Description
6+
7+
Add description in points. Use bulleting/numbering to list the changes/features.
8+
9+
### Checklist -
10+
11+
- [ ] New Feature ?
12+
- [ ] Updated swagger annotation (if API structure is changed) ?
13+
- [ ] Unit Test (if possible) ?
14+
- [ ] Updated the Readme.md (if required) ?

β€Ž.github/workflows/main.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, develop]
6+
pull_request:
7+
types: [assigned, opened, synchronize, reopened]
8+
9+
jobs:
10+
lint:
11+
name: Linting
12+
runs-on: ubuntu-latest
13+
env:
14+
CI: true
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-node@v2
18+
with:
19+
node-version: '14.x'
20+
cache: 'yarn'
21+
- name: install dependencies
22+
run: yarn --frozen-lockfile
23+
- name: lint
24+
run: yarn lint
25+
26+
build:
27+
name: Building
28+
runs-on: ubuntu-latest
29+
env:
30+
CI: true
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: actions/setup-node@v2
34+
with:
35+
node-version: '14.x'
36+
cache: 'yarn'
37+
- name: install dependencies
38+
run: yarn --frozen-lockfile
39+
- name: build
40+
run: yarn build
41+
42+
test:
43+
name: Testing
44+
runs-on: ubuntu-latest
45+
env:
46+
CI: true
47+
steps:
48+
- uses: actions/checkout@v2
49+
- uses: actions/setup-node@v2
50+
with:
51+
node-version: '14.x'
52+
cache: 'yarn'
53+
- name: install dependencies
54+
run: yarn --frozen-lockfile
55+
- name: test
56+
run: yarn test:cov
57+
# TODO @monitz87: add SonarCloud step when the account confusion is sorted

β€ŽDockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:14
2+
WORKDIR /home/node
3+
4+
# cache yarn install step
5+
COPY --chown=node:node package.json /home/node
6+
COPY --chown=node:node yarn.lock /home/node
7+
RUN yarn --frozen-lockfile
8+
9+
COPY --chown=node:node . /home/node
10+
11+
USER node
12+
ENTRYPOINT ["/bin/bash", "./docker-entrypoint.sh"]

β€ŽREADME.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ REST API that communicates with the Polymesh blockchain
66

77
### Requirements
88

9-
- node.js version 12.x
9+
- node.js version 14.x
1010
- yarn version 1.x
1111

1212
### Installing Dependencies
@@ -18,7 +18,7 @@ $ yarn
1818
### Environment Variables
1919

2020
```bash
21-
PORT=## port in which the server will listen ##
21+
PORT=## port in which the server will listen. Defaults to 3000 ##
2222
POLYMESH_NODE_URL=## websocket URL for a Polymesh node ##
2323
POLYMESH_MIDDLEWARE_URL=## URL for an instance of the Polymesh GraphQL Middleware service ##
2424
POLYMESH_MIDDLEWARE_API_KEY=## API key for the Middleware GraphQL service ##
@@ -39,6 +39,16 @@ $ yarn start:dev
3939
$ yarn start:prod
4040
```
4141

42+
### With docker
43+
44+
To pass in the env variables you can use `-e` to pass them indiviudally, or use a file with `--env-file`.
45+
For documentation you will need to expose a port that maps to `:3000` (or its `$PORT` if set) in the container.
46+
47+
```bash
48+
docker build . -t $image_name
49+
docker run -it --env-file .pme.env -p $HOST_PORT:3000 $image_name
50+
```
51+
4252
Accessing `http://localhost:<PORT>` will take you to the swagger playground UI where all endpoints are documented and can be tested
4353

4454
## Test

β€Žbabel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
plugins: ['@babel/plugin-transform-modules-commonjs'],
3+
};

β€Ždocker-entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn start:prod

β€Žjest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
preset: 'ts-jest/presets/js-with-babel',
3+
transformIgnorePatterns: ['/node_modules/(?![@polymathnetwork/src]).+\\.js$'],
4+
testEnvironment: 'node',
5+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
6+
testPathIgnorePatterns: ['dist'],
7+
moduleNameMapper: {
8+
'~/(.*)': '<rootDir>/src/$1',
9+
},
10+
testRegex: '.*\\.spec\\.ts$',
11+
coverageDirectory: '../coverage',
12+
};

β€Žpackage.json

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"private": true,
77
"license": "UNLICENSED",
88
"scripts": {
9+
"prepare": "husky install",
910
"postinstall": "rimraf node_modules/@polymathnetwork/polymesh-sdk/node_modules/@polkadot/{util-crypto,wasm-crypto}",
1011
"prebuild": "rimraf dist",
1112
"build": "nest build",
@@ -28,7 +29,7 @@
2829
"@nestjs/core": "7.6.15",
2930
"@nestjs/platform-express": "7.6.15",
3031
"@nestjs/swagger": "4.8.0",
31-
"@polymathnetwork/polymesh-sdk": "6.0.0-beta.17",
32+
"@polymathnetwork/polymesh-sdk": "11.0.0-alpha.1",
3233
"class-transformer": "0.4.0",
3334
"class-validator": "0.13.1",
3435
"joi": "17.4.0",
@@ -39,6 +40,7 @@
3940
"swagger-ui-express": "4.1.6"
4041
},
4142
"devDependencies": {
43+
"@babel/plugin-transform-modules-commonjs": "7.15.0",
4244
"@commitlint/cli": "12.1.4",
4345
"@commitlint/config-conventional": "12.1.4",
4446
"@nestjs/cli": "7.6.0",
@@ -72,31 +74,11 @@
7274
"ts-loader": "8.0.18",
7375
"ts-node": "9.1.1",
7476
"tsconfig-paths": "3.9.0",
75-
"typescript": "4.2.3"
77+
"typescript": "4.3.5"
7678
},
7779
"config": {
7880
"commitizen": {
7981
"path": "./node_modules/cz-conventional-changelog"
8082
}
81-
},
82-
"jest": {
83-
"moduleFileExtensions": [
84-
"js",
85-
"json",
86-
"ts"
87-
],
88-
"rootDir": "src",
89-
"testRegex": ".*\\.spec\\.ts$",
90-
"transform": {
91-
"^.+\\.(t|j)s$": "ts-jest"
92-
},
93-
"collectCoverageFrom": [
94-
"**/*.(t|j)s"
95-
],
96-
"moduleNameMapper": {
97-
"~/(.*)": "<rootDir>/$1"
98-
},
99-
"coverageDirectory": "../coverage",
100-
"testEnvironment": "node"
10183
}
10284
}

β€Žsrc/app.module.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ import { Module } from '@nestjs/common';
44
import { ConfigModule } from '@nestjs/config';
55
import Joi from 'joi';
66

7+
import { ClaimsModule } from '~/claims/claims.module';
8+
9+
import { AssetsModule } from './assets/assets.module';
10+
import { AuthorizationsModule } from './authorizations/authorizations.module';
11+
import { CheckpointsModule } from './checkpoints/checkpoints.module';
12+
import { CorporateActionsModule } from './corporate-actions/corporate-actions.module';
713
import { IdentitiesModule } from './identities/identities.module';
14+
import { OfferingsModule } from './offerings/offerings.module';
815
import { PolymeshModule } from './polymesh/polymesh.module';
16+
import { PortfoliosModule } from './portfolios/portfolios.module';
917
import { RelayerAccountsModule } from './relayer-accounts/relayer-accounts.module';
1018
import { SettlementsModule } from './settlements/settlements.module';
11-
import { TokensModule } from './tokens/tokens.module';
1219

1320
@Module({
1421
imports: [
@@ -20,11 +27,17 @@ import { TokensModule } from './tokens/tokens.module';
2027
POLYMESH_MIDDLEWARE_API_KEY: Joi.string(),
2128
}).and('POLYMESH_MIDDLEWARE_URL', 'POLYMESH_MIDDLEWARE_API_KEY'),
2229
}),
23-
TokensModule,
30+
AssetsModule,
2431
PolymeshModule,
2532
IdentitiesModule,
2633
SettlementsModule,
2734
RelayerAccountsModule,
35+
AuthorizationsModule,
36+
PortfoliosModule,
37+
ClaimsModule,
38+
OfferingsModule,
39+
CheckpointsModule,
40+
CorporateActionsModule,
2841
],
2942
})
3043
export class AppModule {}

β€Žsrc/assets/assets.consts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const MAX_TICKER_LENGTH = 12;
2+
3+
export const MAX_CONTENT_HASH_LENGTH = 130;

0 commit comments

Comments
Β (0)