Skip to content

Commit

Permalink
use jup client in ddca app
Browse files Browse the repository at this point in the history
  • Loading branch information
vasemkin committed Jan 30, 2024
1 parent 638b6c3 commit d0a7a7b
Show file tree
Hide file tree
Showing 50 changed files with 14,293 additions and 14,410 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.7.0
8 changes: 7 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"singleQuote": true
"trailingComma": "all",
"printWidth": 100,
"useTabs": true,
"singleQuote": true,
"bracketSpacing": true,
"tabWidth": 4,
"semi": false
}
33 changes: 0 additions & 33 deletions apps/ddca-e2e/.eslintrc.json

This file was deleted.

16 changes: 0 additions & 16 deletions apps/ddca-e2e/jest.config.ts

This file was deleted.

26 changes: 0 additions & 26 deletions apps/ddca-e2e/project.json

This file was deleted.

10 changes: 0 additions & 10 deletions apps/ddca-e2e/src/ddca/ddca.spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apps/ddca-e2e/src/support/global-setup.ts

This file was deleted.

7 changes: 0 additions & 7 deletions apps/ddca-e2e/src/support/global-teardown.ts

This file was deleted.

10 changes: 0 additions & 10 deletions apps/ddca-e2e/src/support/test-setup.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/ddca-e2e/tsconfig.json

This file was deleted.

34 changes: 17 additions & 17 deletions apps/ddca/src/app/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Test, TestingModule } from '@nestjs/testing'

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AppController } from './app.controller'
import { AppService } from './app.service'

describe('AppController', () => {
let app: TestingModule;
let app: TestingModule

beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile()
})

describe('getData', () => {
it('should return "Hello API"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({message: 'Hello API'});
});
});
});
describe('getData', () => {
it('should return "Hello API"', () => {
const appController = app.get<AppController>(AppController)
expect(appController.getData()).toEqual({ message: 'Hello API' })
})
})
})
14 changes: 7 additions & 7 deletions apps/ddca/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get } from '@nestjs/common'

import { AppService } from './app.service';
import { AppService } from './app.service'

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly appService: AppService) {}

@Get()
getData() {
return this.appService.getData();
}
@Get()
getData() {
return this.appService.getData()
}
}
12 changes: 6 additions & 6 deletions apps/ddca/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Module } from '@nestjs/common';
import { Module } from '@nestjs/common'

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AppController } from './app.controller'
import { AppService } from './app.service'

@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
48 changes: 30 additions & 18 deletions apps/ddca/src/app/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
import { Test } from '@nestjs/testing';
import { Test } from '@nestjs/testing'

import { AppService } from './app.service';
import { AppService } from './app.service'

import { SOLANA_NATIVE_SOL_ADDRESS, SOLANA_WEN_ADDRESS } from '@jupjup/constants'
import { getQuote } from '@jupjup/jupiter-client'

describe('AppService', () => {
let service: AppService;

beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile();

service = app.get<AppService>(AppService);
});

describe('getData', () => {
it('should return "Hello API"', () => {
expect(service.getData()).toEqual({message: 'Hello API'});
});
});
});
let service: AppService

beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile()

service = app.get<AppService>(AppService)
})

describe.only('getData', () => {
it('should get data from jupiter client', async () => {
const res = await getQuote({
inputMint: SOLANA_NATIVE_SOL_ADDRESS,
outputMint: SOLANA_WEN_ADDRESS,
amount: 100000,
})

console.log({ res })

// expect(
// ).not.toThrow
})
})
})
8 changes: 4 additions & 4 deletions apps/ddca/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common'

@Injectable()
export class AppService {
getData(): { message: string } {
return ({ message: 'Hello API' });
}
getData(): { message: string } {
return { message: 'Hello API' }
}
}
6 changes: 3 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getJestProjects } from '@nx/jest';
import { getJestProjects } from '@nx/jest'

export default {
projects: getJestProjects()
};
projects: getJestProjects(),
}
30 changes: 30 additions & 0 deletions libs/constants/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
}
]
}
}
]
}
11 changes: 11 additions & 0 deletions libs/constants/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# constants

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build constants` to build the library.

## Running unit tests

Run `nx test constants` to execute the unit tests via [Jest](https://jestjs.io).
11 changes: 11 additions & 0 deletions libs/constants/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'constants',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/libs/constants',
}
8 changes: 8 additions & 0 deletions libs/constants/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@jupjup/constants",
"version": "0.0.1",
"dependencies": {},
"main": "./index.js",
"module": "./index.mjs",
"typings": "./index.d.ts"
}
27 changes: 27 additions & 0 deletions libs/constants/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "constants",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/constants/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/constants"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/constants/jest.config.ts"
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions libs/constants/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/solana'
2 changes: 2 additions & 0 deletions libs/constants/src/lib/solana.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const SOLANA_NATIVE_SOL_ADDRESS = 'So11111111111111111111111111111111111111112'
export const SOLANA_WEN_ADDRESS = 'WENWENvqqNya429ubCdR81ZmD69brwQaaBYY6p3LCpk'
Loading

0 comments on commit d0a7a7b

Please sign in to comment.