-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: scaffold pricing module lib #28
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d5d61bc
feat: scaffold pricing module lib
0xnigir1 e503a93
feat: add pricing service interface
0xnigir1 c75ad34
refactor: change pricing package alias to @zkchainhub
0xnigir1 2142c39
Merge remote-tracking branch 'origin/dev' into feat/scaffold-pricing-…
0xnigir1 25da8d2
feat: set base url as constructor param
0xnigir1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./pricing.module"; | ||
export * from "./services/coingecko.service"; | ||
export * from "./interfaces"; |
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 @@ | ||
export * from "./pricing.interface"; |
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,19 @@ | ||
/** | ||
* Represents a pricing service that provides token prices. | ||
*/ | ||
/** | ||
* Represents a pricing service that retrieves token prices. | ||
*/ | ||
export interface IPricingService { | ||
/** | ||
* Retrieves the prices of the specified tokens. | ||
* @param tokenIds - An array of token IDs. | ||
* @param [config] - Optional configuration object. | ||
* @param config.currency - The currency in which the prices should be returned. | ||
* @returns A promise that resolves to a record containing the token IDs as keys and their corresponding prices as values. | ||
*/ | ||
getTokenPrices<TokenId extends string = string>( | ||
tokenIds: TokenId[], | ||
config?: { currency: string }, | ||
): Promise<Record<string, number>>; | ||
} |
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,9 @@ | ||
import { Module } from "@nestjs/common"; | ||
|
||
import { CoingeckoService } from "./services"; | ||
|
||
@Module({ | ||
providers: [CoingeckoService], | ||
exports: [CoingeckoService], | ||
}) | ||
export class PricingModule {} |
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,27 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
|
||
import { CoingeckoService } from "./coingecko.service"; | ||
|
||
describe("CoingeckoService", () => { | ||
let service: CoingeckoService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
{ | ||
provide: CoingeckoService, | ||
useFactory: () => { | ||
const apiKey = "COINGECKO_API_KEY"; | ||
return new CoingeckoService(apiKey); | ||
}, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
service = module.get<CoingeckoService>(CoingeckoService); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
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,16 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
|
||
import { IPricingService } from "@zkchainhub/pricing/interfaces"; | ||
|
||
@Injectable() | ||
export class CoingeckoService implements IPricingService { | ||
private readonly API_BASE_URL = "https://api.coingecko.com/api/v3/"; | ||
constructor(private readonly apiKey: string) {} | ||
|
||
async getTokenPrices( | ||
_tokenIds: string[], | ||
_config: { currency: string } = { currency: "usd" }, | ||
): Promise<Record<string, number>> { | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
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 @@ | ||
export * from "./coingecko.service"; |
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,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"outDir": "../../dist/libs/pricing" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist", "test", "**/*spec.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
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 |
---|---|---|
@@ -1,102 +1,103 @@ | ||
{ | ||
"name": "zkchainHub", | ||
"version": "0.0.1", | ||
"description": "", | ||
"author": "", | ||
"private": true, | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"build": "nest build", | ||
"format": "prettier --write \"{apps,libs}/**/*.ts\"", | ||
"start": "nest start", | ||
"start:dev": "nest start --watch", | ||
"start:debug": "nest start --debug --watch", | ||
"start:prod": "node dist/apps/api/main", | ||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:cov": "jest --coverage", | ||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | ||
"test:e2e": "jest --config ./apps/api/test/jest-e2e.json", | ||
"prepare": "husky", | ||
"preinstall": "npx only-allow pnpm" | ||
}, | ||
"dependencies": { | ||
"@nestjs/common": "10.0.0", | ||
"@nestjs/core": "10.0.0", | ||
"@nestjs/platform-express": "10.0.0", | ||
"@nestjs/swagger": "7.4.0", | ||
"abitype": "1.0.5", | ||
"reflect-metadata": "0.1.13", | ||
"rxjs": "7.8.1", | ||
"viem": "2.17.5" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/config-conventional": "19.2.2", | ||
"@golevelup/ts-jest": "0.5.0", | ||
"@ianvs/prettier-plugin-sort-imports": "4.3.0", | ||
"@nestjs/cli": "10.0.0", | ||
"@nestjs/schematics": "10.0.0", | ||
"@nestjs/testing": "10.0.0", | ||
"@total-typescript/tsconfig": "1.0.4", | ||
"@types/express": "4.17.17", | ||
"@types/jest": "29.5.2", | ||
"@types/node": "20.3.1", | ||
"@types/supertest": "6.0.0", | ||
"@typescript-eslint/eslint-plugin": "7.0.0", | ||
"@typescript-eslint/parser": "7.0.0", | ||
"commitlint": "19.3.0", | ||
"eslint": "8.42.0", | ||
"eslint-config-prettier": "9.0.0", | ||
"eslint-plugin-prettier": "5.0.0", | ||
"husky": "9.0.11", | ||
"jest": "29.5.0", | ||
"lint-staged": "15.2.7", | ||
"prettier": "3.0.0", | ||
"source-map-support": "0.5.21", | ||
"supertest": "7.0.0", | ||
"ts-jest": "29.1.0", | ||
"ts-loader": "9.4.3", | ||
"ts-node": "10.9.1", | ||
"tsconfig-paths": "4.2.0", | ||
"typescript": "5.1.3" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"ts" | ||
], | ||
"rootDir": ".", | ||
"testRegex": ".*\\.spec\\.ts$", | ||
"transform": { | ||
".+\\.(t|j)s$": "ts-jest" | ||
"name": "zkchainHub", | ||
"version": "0.0.1", | ||
"description": "", | ||
"author": "", | ||
"private": true, | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"build": "nest build", | ||
"format": "prettier --write \"{apps,libs}/**/*.ts\"", | ||
"start": "nest start", | ||
"start:dev": "nest start --watch", | ||
"start:debug": "nest start --debug --watch", | ||
"start:prod": "node dist/apps/api/main", | ||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:cov": "jest --coverage", | ||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | ||
"test:e2e": "jest --config ./apps/api/test/jest-e2e.json", | ||
"prepare": "husky", | ||
"preinstall": "npx only-allow pnpm" | ||
}, | ||
"collectCoverageFrom": [ | ||
"**/*.(t|j)s" | ||
], | ||
"coverageDirectory": "./coverage", | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
".e2e-spec.ts", | ||
".module.ts", | ||
"main.ts" | ||
], | ||
"testEnvironment": "node", | ||
"roots": [ | ||
"<rootDir>/apps/", | ||
"<rootDir>/libs/" | ||
], | ||
"moduleNameMapper": { | ||
"^@packages/providers(|/.*)$": "<rootDir>/libs/providers/src/$1", | ||
"^@shared/dtos(|/.*)$": "<rootDir>/libs/dtos/src/$1" | ||
"dependencies": { | ||
"@nestjs/common": "10.0.0", | ||
"@nestjs/core": "10.0.0", | ||
"@nestjs/platform-express": "10.0.0", | ||
"@nestjs/swagger": "7.4.0", | ||
"abitype": "1.0.5", | ||
"reflect-metadata": "0.1.13", | ||
"rxjs": "7.8.1", | ||
"viem": "2.17.5" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/config-conventional": "19.2.2", | ||
"@golevelup/ts-jest": "0.5.0", | ||
"@ianvs/prettier-plugin-sort-imports": "4.3.0", | ||
"@nestjs/cli": "10.0.0", | ||
"@nestjs/schematics": "10.0.0", | ||
"@nestjs/testing": "10.0.0", | ||
"@total-typescript/tsconfig": "1.0.4", | ||
"@types/express": "4.17.17", | ||
"@types/jest": "29.5.2", | ||
"@types/node": "20.3.1", | ||
"@types/supertest": "6.0.0", | ||
"@typescript-eslint/eslint-plugin": "7.0.0", | ||
"@typescript-eslint/parser": "7.0.0", | ||
"commitlint": "19.3.0", | ||
"eslint": "8.42.0", | ||
"eslint-config-prettier": "9.0.0", | ||
"eslint-plugin-prettier": "5.0.0", | ||
"husky": "9.0.11", | ||
"jest": "29.5.0", | ||
"lint-staged": "15.2.7", | ||
"prettier": "3.0.0", | ||
"source-map-support": "0.5.21", | ||
"supertest": "7.0.0", | ||
"ts-jest": "29.1.0", | ||
"ts-loader": "9.4.3", | ||
"ts-node": "10.9.1", | ||
"tsconfig-paths": "4.2.0", | ||
"typescript": "5.1.3" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"ts" | ||
], | ||
"rootDir": ".", | ||
"testRegex": ".*\\.spec\\.ts$", | ||
"transform": { | ||
".+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"collectCoverageFrom": [ | ||
"**/*.(t|j)s" | ||
], | ||
"coverageDirectory": "./coverage", | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
".e2e-spec.ts", | ||
".module.ts", | ||
"main.ts" | ||
], | ||
"testEnvironment": "node", | ||
"roots": [ | ||
"<rootDir>/apps/", | ||
"<rootDir>/libs/" | ||
], | ||
"moduleNameMapper": { | ||
"^@packages/providers(|/.*)$": "<rootDir>/libs/providers/src/$1", | ||
"^@shared/dtos(|/.*)$": "<rootDir>/libs/dtos/src/$1", | ||
"^@packages/pricing(|/.*)$": "<rootDir>/libs/pricing/src/$1" | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d", | ||
"lint-staged": { | ||
"(apps|libs)/**/*.(ts|js)": [ | ||
"pnpm lint", | ||
"pnpm format" | ||
] | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d", | ||
"lint-staged": { | ||
"(apps|libs)/**/*.(ts|js)": [ | ||
"pnpm lint", | ||
"pnpm format" | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,37 +1,31 @@ | ||
{ | ||
"extends": "@total-typescript/tsconfig/tsc/no-dom/app", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "ES2021", | ||
"sourceMap": true, | ||
"outDir": "./dist", | ||
"baseUrl": "./", | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": true, | ||
"noImplicitAny": true, | ||
"strictBindCallApply": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"paths": { | ||
"@packages/providers": [ | ||
"libs/providers/src" | ||
], | ||
"@packages/providers/*": [ | ||
"libs/providers/src/*" | ||
], | ||
"@shared/dtos": [ | ||
"libs/dtos/src" | ||
], | ||
"@shared/dtos/*": [ | ||
"libs/dtos/src/*" | ||
] | ||
}, | ||
"verbatimModuleSyntax": false | ||
} | ||
} | ||
"extends": "@total-typescript/tsconfig/tsc/no-dom/app", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "ES2021", | ||
"sourceMap": true, | ||
"outDir": "./dist", | ||
"baseUrl": "./", | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": true, | ||
"noImplicitAny": true, | ||
"strictBindCallApply": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"paths": { | ||
"@packages/providers": ["libs/providers/src"], | ||
"@packages/providers/*": ["libs/providers/src/*"], | ||
"@shared/dtos": ["libs/dtos/src"], | ||
"@shared/dtos/*": ["libs/dtos/src/*"], | ||
"@zkchainhub/pricing": ["libs/pricing/src"], | ||
"@zkchainhub/pricing/*": ["libs/pricing/src/*"] | ||
}, | ||
"verbatimModuleSyntax": false | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt if we remove this hardcoded value and ask for 2 parameters
baseUrl
andapiKey
instead???There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okayy sound good to me