@sui-tracker/shared 1.0.77 → 1.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/grpc-services/account-user-grpc.service.d.ts +19 -0
- package/dist/modules/grpc-services/account-user-grpc.service.js +70 -0
- package/dist/modules/grpc-services/account-user-grpc.service.js.map +1 -0
- package/dist/modules/grpc-services/auth-grpc.service.d.ts +22 -0
- package/dist/modules/grpc-services/auth-grpc.service.js +113 -0
- package/dist/modules/grpc-services/auth-grpc.service.js.map +1 -0
- package/dist/modules/interfaces/auth.interface.d.ts +76 -0
- package/dist/modules/interfaces/auth.interface.js +3 -0
- package/dist/modules/interfaces/auth.interface.js.map +1 -0
- package/dist/modules/interfaces/swap-order.interface.d.ts +25 -1
- package/dist/modules/interfaces/swap-order.interface.js.map +1 -1
- package/dist/protos/auth.proto +117 -0
- package/dist/protos/swap-order.proto +26 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ClientGrpc } from '@nestjs/microservices';
|
|
2
|
+
import { UserResponse } from '../interfaces/auth.interface';
|
|
3
|
+
export declare class AccountUserGrpcService {
|
|
4
|
+
private grpcClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(grpcClient: ClientGrpc);
|
|
7
|
+
getOrCreateUser(telegramData: {
|
|
8
|
+
teleId: string;
|
|
9
|
+
firstName?: string;
|
|
10
|
+
lastName?: string;
|
|
11
|
+
username?: string;
|
|
12
|
+
}): Promise<UserResponse>;
|
|
13
|
+
signTransaction(user: UserResponse): Promise<{
|
|
14
|
+
signature: string;
|
|
15
|
+
msg: string;
|
|
16
|
+
signTime: number;
|
|
17
|
+
}>;
|
|
18
|
+
generateLoginUrl(user: UserResponse, signature: string, signTime: number): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var AccountUserGrpcService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.AccountUserGrpcService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const ethers_1 = require("ethers");
|
|
19
|
+
let AccountUserGrpcService = AccountUserGrpcService_1 = class AccountUserGrpcService {
|
|
20
|
+
constructor(grpcClient) {
|
|
21
|
+
this.grpcClient = grpcClient;
|
|
22
|
+
this.logger = new common_1.Logger(AccountUserGrpcService_1.name);
|
|
23
|
+
}
|
|
24
|
+
async getOrCreateUser(telegramData) {
|
|
25
|
+
const userService = this.grpcClient.getService('AuthService');
|
|
26
|
+
this.logger.log(`Getting or creating user for teleId: ${telegramData.teleId}`);
|
|
27
|
+
const res = await new Promise((resolve, reject) => {
|
|
28
|
+
userService.getOrCreateUser({
|
|
29
|
+
teleId: telegramData.teleId,
|
|
30
|
+
firstName: telegramData.firstName,
|
|
31
|
+
lastName: telegramData.lastName,
|
|
32
|
+
username: telegramData.username,
|
|
33
|
+
}).subscribe({
|
|
34
|
+
next: (response) => resolve(response),
|
|
35
|
+
error: (error) => reject(error),
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
if (!res.success || !res.user) {
|
|
39
|
+
throw new Error(res.message || 'Failed to get or create user');
|
|
40
|
+
}
|
|
41
|
+
this.logger.log(`User retrieved: ${res.user.id}`);
|
|
42
|
+
return res.user;
|
|
43
|
+
}
|
|
44
|
+
async signTransaction(user) {
|
|
45
|
+
const privateKey = process.env.ADMIN_WALLET_PK;
|
|
46
|
+
if (!privateKey) {
|
|
47
|
+
throw new Error('ADMIN_WALLET_PK is not set');
|
|
48
|
+
}
|
|
49
|
+
const wallet = new ethers_1.ethers.Wallet(privateKey);
|
|
50
|
+
const signTime = Date.now();
|
|
51
|
+
const msg = `${user.teleId}-${signTime}`;
|
|
52
|
+
const signature = await wallet.signMessage(msg);
|
|
53
|
+
return {
|
|
54
|
+
signature,
|
|
55
|
+
msg,
|
|
56
|
+
signTime,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
generateLoginUrl(user, signature, signTime) {
|
|
60
|
+
const appDomain = process.env.APP_DOMAIN || 'https://app.example.com';
|
|
61
|
+
return `${appDomain}?signature=${signature}&username=${user.teleUserName}&teleId=${user.teleId}&signTime=${signTime}`;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.AccountUserGrpcService = AccountUserGrpcService;
|
|
65
|
+
exports.AccountUserGrpcService = AccountUserGrpcService = AccountUserGrpcService_1 = __decorate([
|
|
66
|
+
(0, common_1.Injectable)(),
|
|
67
|
+
__param(0, (0, common_1.Inject)('AUTH')),
|
|
68
|
+
__metadata("design:paramtypes", [Object])
|
|
69
|
+
], AccountUserGrpcService);
|
|
70
|
+
//# sourceMappingURL=account-user-grpc.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-user-grpc.service.js","sourceRoot":"","sources":["../../../src/modules/grpc-services/account-user-grpc.service.ts"],"names":[],"mappings":";;;;;;;;;;;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,CAAC,eAAe,CAAC,IAAkB;QAKtC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAE/C,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEhD,OAAO;YACL,SAAS;YACT,GAAG;YACH,QAAQ;SACT,CAAC;IACJ,CAAC;IAKD,gBAAgB,CACd,IAAkB,EAClB,SAAiB,EACjB,QAAgB;QAEhB,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,yBAAyB,CAAC;QACtE,OAAO,GAAG,SAAS,cAAc,SAAS,aAAa,IAAI,CAAC,YAAY,WAAW,IAAI,CAAC,MAAM,aAAa,QAAQ,EAAE,CAAC;IACxH,CAAC;CACF,CAAA;AAlFY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,MAAM,CAAC,CAAA;;GAJN,sBAAsB,CAkFlC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ClientGrpc } from "@nestjs/microservices";
|
|
2
|
+
import { GetOrCreateUserRequest, GetOrCreateUserResponse } from "../interfaces/auth.interface";
|
|
3
|
+
export declare class AuthGrpcService {
|
|
4
|
+
private grpcClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(grpcClient: ClientGrpc);
|
|
7
|
+
getOrCreateUser(data: GetOrCreateUserRequest): Promise<GetOrCreateUserResponse>;
|
|
8
|
+
login(data: {
|
|
9
|
+
teleId: string;
|
|
10
|
+
signature: string;
|
|
11
|
+
signTime: string;
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
me(userId: string): Promise<any>;
|
|
14
|
+
signTransaction(userId: string): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
signature?: string;
|
|
18
|
+
msg?: string;
|
|
19
|
+
signTime?: number;
|
|
20
|
+
}>;
|
|
21
|
+
validateToken(token: string): Promise<any>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var AuthGrpcService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.AuthGrpcService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
19
|
+
let AuthGrpcService = AuthGrpcService_1 = class AuthGrpcService {
|
|
20
|
+
constructor(grpcClient) {
|
|
21
|
+
this.grpcClient = grpcClient;
|
|
22
|
+
this.logger = new common_1.Logger(AuthGrpcService_1.name);
|
|
23
|
+
}
|
|
24
|
+
async getOrCreateUser(data) {
|
|
25
|
+
const authService = this.grpcClient.getService("AuthService");
|
|
26
|
+
const res = await new Promise((resolve, reject) => {
|
|
27
|
+
authService.getOrCreateUser(data).subscribe({
|
|
28
|
+
next: (response) => resolve(response),
|
|
29
|
+
error: (error) => reject({
|
|
30
|
+
success: false,
|
|
31
|
+
message: error.message,
|
|
32
|
+
user: null,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
if (!res.success) {
|
|
37
|
+
throw new Error(res.message);
|
|
38
|
+
}
|
|
39
|
+
return res;
|
|
40
|
+
}
|
|
41
|
+
async login(data) {
|
|
42
|
+
const authService = this.grpcClient.getService("AuthService");
|
|
43
|
+
const res = await new Promise((resolve, reject) => {
|
|
44
|
+
authService.login(data).subscribe({
|
|
45
|
+
next: (response) => resolve(response),
|
|
46
|
+
error: (error) => reject(error),
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
if (!res.success) {
|
|
50
|
+
throw new Error(res.message);
|
|
51
|
+
}
|
|
52
|
+
return res;
|
|
53
|
+
}
|
|
54
|
+
async me(userId) {
|
|
55
|
+
const authService = this.grpcClient.getService("AuthService");
|
|
56
|
+
const metadata = new grpc_js_1.Metadata();
|
|
57
|
+
const res = await new Promise((resolve, reject) => {
|
|
58
|
+
authService.me({ userId }, metadata).subscribe({
|
|
59
|
+
next: (response) => resolve(response),
|
|
60
|
+
error: (error) => reject({
|
|
61
|
+
success: false,
|
|
62
|
+
message: error.message,
|
|
63
|
+
user: null,
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
if (!res.success) {
|
|
68
|
+
throw new Error(res.message);
|
|
69
|
+
}
|
|
70
|
+
return res;
|
|
71
|
+
}
|
|
72
|
+
async signTransaction(userId) {
|
|
73
|
+
const authService = this.grpcClient.getService("AuthService");
|
|
74
|
+
const res = await new Promise((resolve, reject) => {
|
|
75
|
+
authService.signTransaction({ userId }).subscribe({
|
|
76
|
+
next: (response) => resolve(response),
|
|
77
|
+
error: (error) => reject({
|
|
78
|
+
success: false,
|
|
79
|
+
message: error.message,
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
if (!res.success) {
|
|
84
|
+
throw new Error(res.message);
|
|
85
|
+
}
|
|
86
|
+
return res;
|
|
87
|
+
}
|
|
88
|
+
async validateToken(token) {
|
|
89
|
+
const authService = this.grpcClient.getService("AuthService");
|
|
90
|
+
const res = await new Promise((resolve, reject) => {
|
|
91
|
+
authService.validateToken({ token }).subscribe({
|
|
92
|
+
next: (response) => resolve(response),
|
|
93
|
+
error: (error) => resolve({
|
|
94
|
+
success: false,
|
|
95
|
+
message: error.message,
|
|
96
|
+
user: null,
|
|
97
|
+
isValid: false,
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
if (!res.success) {
|
|
102
|
+
throw new Error(res.message);
|
|
103
|
+
}
|
|
104
|
+
return res;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.AuthGrpcService = AuthGrpcService;
|
|
108
|
+
exports.AuthGrpcService = AuthGrpcService = AuthGrpcService_1 = __decorate([
|
|
109
|
+
(0, common_1.Injectable)(),
|
|
110
|
+
__param(0, (0, common_1.Inject)("AUTH")),
|
|
111
|
+
__metadata("design:paramtypes", [Object])
|
|
112
|
+
], AuthGrpcService);
|
|
113
|
+
//# sourceMappingURL=auth-grpc.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-grpc.service.js","sourceRoot":"","sources":["../../../src/modules/grpc-services/auth-grpc.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAS5D,2CAAyC;AAGlC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAG1B,YACkB,UAA8B;QAAtB,eAAU,GAAV,UAAU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|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { Metadata } from "@grpc/grpc-js";
|
|
3
|
+
export interface UserResponse {
|
|
4
|
+
id: string;
|
|
5
|
+
firstName: string;
|
|
6
|
+
lastName: string;
|
|
7
|
+
teleId: string;
|
|
8
|
+
teleUserName: string;
|
|
9
|
+
isActive: boolean;
|
|
10
|
+
referralCode: string;
|
|
11
|
+
parentId: string;
|
|
12
|
+
role: string;
|
|
13
|
+
mainWalletAddress?: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TokenResponse {
|
|
18
|
+
accessToken: string;
|
|
19
|
+
expiresIn: number;
|
|
20
|
+
}
|
|
21
|
+
export interface GetOrCreateUserRequest {
|
|
22
|
+
teleId: string;
|
|
23
|
+
firstName?: string;
|
|
24
|
+
lastName?: string;
|
|
25
|
+
username?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface GetOrCreateUserResponse {
|
|
28
|
+
success: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
user?: UserResponse;
|
|
31
|
+
}
|
|
32
|
+
export interface LoginRequest {
|
|
33
|
+
teleId: string;
|
|
34
|
+
signature: string;
|
|
35
|
+
signTime: string;
|
|
36
|
+
}
|
|
37
|
+
export interface LoginResponse {
|
|
38
|
+
success: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
user?: UserResponse;
|
|
41
|
+
token?: TokenResponse;
|
|
42
|
+
}
|
|
43
|
+
export interface MeRequest {
|
|
44
|
+
userId: string;
|
|
45
|
+
}
|
|
46
|
+
export interface MeResponse {
|
|
47
|
+
success: boolean;
|
|
48
|
+
message: string;
|
|
49
|
+
user?: UserResponse;
|
|
50
|
+
}
|
|
51
|
+
export interface SignTransactionRequest {
|
|
52
|
+
userId: string;
|
|
53
|
+
}
|
|
54
|
+
export interface SignTransactionResponse {
|
|
55
|
+
success: boolean;
|
|
56
|
+
message: string;
|
|
57
|
+
signature?: string;
|
|
58
|
+
msg?: string;
|
|
59
|
+
signTime?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface ValidateTokenRequest {
|
|
62
|
+
token: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ValidateTokenResponse {
|
|
65
|
+
success: boolean;
|
|
66
|
+
message: string;
|
|
67
|
+
user?: UserResponse;
|
|
68
|
+
isValid: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface AuthService {
|
|
71
|
+
getOrCreateUser(data: GetOrCreateUserRequest): Observable<GetOrCreateUserResponse>;
|
|
72
|
+
login(request: LoginRequest): Observable<LoginResponse>;
|
|
73
|
+
me(request: MeRequest, metadata?: Metadata): Observable<MeResponse>;
|
|
74
|
+
signTransaction(request: SignTransactionRequest): Observable<SignTransactionResponse>;
|
|
75
|
+
validateToken(request: ValidateTokenRequest): Observable<ValidateTokenResponse>;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.interface.js","sourceRoot":"","sources":["../../../src/modules/interfaces/auth.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { BaseResponse } from "./base-request.interface";
|
|
3
|
-
import { TradeType } from "src/interfaces/ISwapOrder.type";
|
|
3
|
+
import { TradeType, DexType } from "src/interfaces/ISwapOrder.type";
|
|
4
|
+
export interface GetListPoolsFilter {
|
|
5
|
+
minMaker?: number;
|
|
6
|
+
maxMaker?: number;
|
|
7
|
+
minTx?: number;
|
|
8
|
+
maxTx?: number;
|
|
9
|
+
minVolume?: number;
|
|
10
|
+
maxVolume?: number;
|
|
11
|
+
minPriceChange5m?: number;
|
|
12
|
+
maxPriceChange5m?: number;
|
|
13
|
+
minPriceChange60m?: number;
|
|
14
|
+
maxPriceChange60m?: number;
|
|
15
|
+
minPriceChange360m?: number;
|
|
16
|
+
maxPriceChange360m?: number;
|
|
17
|
+
minPriceChange1440m?: number;
|
|
18
|
+
maxPriceChange1440m?: number;
|
|
19
|
+
maxPriceChange?: number;
|
|
20
|
+
minMarketCap?: number;
|
|
21
|
+
maxMarketCap?: number;
|
|
22
|
+
minAge?: number;
|
|
23
|
+
maxAge?: number;
|
|
24
|
+
dex?: DexType[];
|
|
25
|
+
}
|
|
4
26
|
export interface TokenData {
|
|
5
27
|
id: string;
|
|
6
28
|
name?: string | null;
|
|
@@ -65,6 +87,7 @@ export interface GetListPoolsRequest {
|
|
|
65
87
|
label: 5 | 60 | 360 | 1440;
|
|
66
88
|
page?: number;
|
|
67
89
|
limit?: number;
|
|
90
|
+
filter?: GetListPoolsFilter;
|
|
68
91
|
}
|
|
69
92
|
export interface GetPoolRequest {
|
|
70
93
|
id: string;
|
|
@@ -102,6 +125,7 @@ export interface ListPool {
|
|
|
102
125
|
priceChange360m: number;
|
|
103
126
|
priceChange1440m: number;
|
|
104
127
|
aIsBase: boolean;
|
|
128
|
+
volumeChangePercentage: number;
|
|
105
129
|
}
|
|
106
130
|
export interface GetListPoolsResponse extends BaseResponse {
|
|
107
131
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap-order.interface.js","sourceRoot":"","sources":["../../../src/modules/interfaces/swap-order.interface.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"swap-order.interface.js","sourceRoot":"","sources":["../../../src/modules/interfaces/swap-order.interface.ts"],"names":[],"mappings":";;AA2IC,EAAE,CAAA"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Proto file for Auth Service
|
|
2
|
+
// Được tạo từ auth.interface.ts
|
|
3
|
+
|
|
4
|
+
// Proto3 syntax
|
|
5
|
+
syntax = "proto3";
|
|
6
|
+
|
|
7
|
+
package auth;
|
|
8
|
+
|
|
9
|
+
// Auth Service
|
|
10
|
+
service AuthService {
|
|
11
|
+
// Login with signature
|
|
12
|
+
rpc Login(LoginRequest) returns (LoginResponse);
|
|
13
|
+
|
|
14
|
+
// Get or create user from Telegram data
|
|
15
|
+
rpc GetOrCreateUser(GetOrCreateUserRequest) returns (GetOrCreateUserResponse);
|
|
16
|
+
|
|
17
|
+
// Get current user information
|
|
18
|
+
rpc Me(MeRequest) returns (MeResponse);
|
|
19
|
+
|
|
20
|
+
// Sign transaction for authentication
|
|
21
|
+
rpc SignTransaction(SignTransactionRequest) returns (SignTransactionResponse);
|
|
22
|
+
|
|
23
|
+
// Validate JWT token
|
|
24
|
+
rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// User entity
|
|
28
|
+
message UserResponse {
|
|
29
|
+
string id = 1;
|
|
30
|
+
string firstName = 2;
|
|
31
|
+
string lastName = 3;
|
|
32
|
+
string teleId = 4;
|
|
33
|
+
string teleUserName = 5;
|
|
34
|
+
bool isActive = 6;
|
|
35
|
+
string referralCode = 7;
|
|
36
|
+
string parentId = 8;
|
|
37
|
+
string role = 9;
|
|
38
|
+
string mainWalletAddress = 10;
|
|
39
|
+
string createdAt = 11;
|
|
40
|
+
string updatedAt = 12;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Get or create user request
|
|
44
|
+
message GetOrCreateUserRequest {
|
|
45
|
+
string teleId = 1;
|
|
46
|
+
string firstName = 2;
|
|
47
|
+
string lastName = 3;
|
|
48
|
+
string username = 4;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Get or create user response with user data
|
|
52
|
+
message GetOrCreateUserResponse {
|
|
53
|
+
bool success = 1;
|
|
54
|
+
string message = 2;
|
|
55
|
+
UserResponse user = 3;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Login request
|
|
59
|
+
message LoginRequest {
|
|
60
|
+
string teleId = 1;
|
|
61
|
+
string signature = 2;
|
|
62
|
+
string signTime = 3;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Token response
|
|
66
|
+
message TokenResponse {
|
|
67
|
+
string accessToken = 1;
|
|
68
|
+
int32 expiresIn = 2;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Login response
|
|
72
|
+
message LoginResponse {
|
|
73
|
+
bool success = 1;
|
|
74
|
+
string message = 2;
|
|
75
|
+
UserResponse user = 3;
|
|
76
|
+
TokenResponse token = 4;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Me request
|
|
80
|
+
message MeRequest {
|
|
81
|
+
string userId = 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Me response
|
|
85
|
+
message MeResponse {
|
|
86
|
+
bool success = 1;
|
|
87
|
+
string message = 2;
|
|
88
|
+
UserResponse user = 3;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Validate token request
|
|
92
|
+
message ValidateTokenRequest {
|
|
93
|
+
string token = 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Sign transaction request
|
|
97
|
+
message SignTransactionRequest {
|
|
98
|
+
string userId = 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Sign transaction response
|
|
102
|
+
message SignTransactionResponse {
|
|
103
|
+
bool success = 1;
|
|
104
|
+
string message = 2;
|
|
105
|
+
string signature = 3;
|
|
106
|
+
string msg = 4;
|
|
107
|
+
int64 signTime = 5;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Validate token response
|
|
111
|
+
message ValidateTokenResponse {
|
|
112
|
+
bool success = 1;
|
|
113
|
+
string message = 2;
|
|
114
|
+
UserResponse user = 3;
|
|
115
|
+
bool isValid = 4;
|
|
116
|
+
}
|
|
117
|
+
|
|
@@ -102,6 +102,7 @@ message ListPool {
|
|
|
102
102
|
double priceChange360m = 22;
|
|
103
103
|
double priceChange1440m = 23;
|
|
104
104
|
bool aIsBase = 24;
|
|
105
|
+
double volumeChangePercentage = 25;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
// Candle data structure matching CandleData interface
|
|
@@ -149,12 +150,37 @@ message TrendingTokenData {
|
|
|
149
150
|
string score = 14;
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
// Filter message for GetListPoolsRequest
|
|
154
|
+
message GetListPoolsFilter {
|
|
155
|
+
optional double minMaker = 1;
|
|
156
|
+
optional double maxMaker = 2;
|
|
157
|
+
optional int32 minTx = 3;
|
|
158
|
+
optional int32 maxTx = 4;
|
|
159
|
+
optional double minVolume = 5;
|
|
160
|
+
optional double maxVolume = 6;
|
|
161
|
+
optional double minPriceChange5m = 7;
|
|
162
|
+
optional double maxPriceChange5m = 8;
|
|
163
|
+
optional double minPriceChange60m = 9;
|
|
164
|
+
optional double maxPriceChange60m = 10;
|
|
165
|
+
optional double minPriceChange360m = 11;
|
|
166
|
+
optional double maxPriceChange360m = 12;
|
|
167
|
+
optional double minPriceChange1440m = 13;
|
|
168
|
+
optional double maxPriceChange1440m = 14;
|
|
169
|
+
optional double maxPriceChange = 15;
|
|
170
|
+
optional double minMarketCap = 16;
|
|
171
|
+
optional double maxMarketCap = 17;
|
|
172
|
+
optional int32 minAge = 18;
|
|
173
|
+
optional int32 maxAge = 19;
|
|
174
|
+
repeated string dex = 20;
|
|
175
|
+
}
|
|
176
|
+
|
|
152
177
|
// Request messages matching TypeScript interfaces
|
|
153
178
|
message GetListPoolsRequest {
|
|
154
179
|
string type = 1; // 'trending' | 'top-volume' | 'new-pools'
|
|
155
180
|
int32 label = 2; // 5 | 60 | 360 | 1440
|
|
156
181
|
optional int32 page = 3;
|
|
157
182
|
optional int32 limit = 4;
|
|
183
|
+
optional GetListPoolsFilter filter = 5;
|
|
158
184
|
}
|
|
159
185
|
|
|
160
186
|
message GetNewPoolsRequest {
|