@arbiwallet/contracts 1.0.22 → 1.0.24

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/gen/aml.ts ADDED
@@ -0,0 +1,92 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v7.34.0
5
+ // source: aml.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "aml.v1";
12
+
13
+ export enum AmlDecision {
14
+ ALLOW = 0,
15
+ REVIEW = 1,
16
+ BLOCK = 2,
17
+ UNRECOGNIZED = -1,
18
+ }
19
+
20
+ export interface ScreenDepositRequest {
21
+ network: string;
22
+ asset: string;
23
+ txHash: string;
24
+ fromAddress: string;
25
+ toAddress: string;
26
+ amount: string;
27
+ confirmedAtUnix: number;
28
+ idempotencyKey: string;
29
+ }
30
+
31
+ export interface ScreenWithdrawalRequest {
32
+ network: string;
33
+ asset: string;
34
+ toAddress: string;
35
+ amount: string;
36
+ idempotencyKey: string;
37
+ }
38
+
39
+ export interface ScreenResponse {
40
+ decision: AmlDecision;
41
+ score: number;
42
+ reason: string;
43
+ provider: string;
44
+ providerRef: string;
45
+ rawStatus: string;
46
+ isFinal: boolean;
47
+ }
48
+
49
+ export interface HealthRequest {
50
+ }
51
+
52
+ export interface HealthResponse {
53
+ ok: boolean;
54
+ version: string;
55
+ }
56
+
57
+ export const AML_V1_PACKAGE_NAME = "aml.v1";
58
+
59
+ export interface AmlServiceClient {
60
+ screenDeposit(request: ScreenDepositRequest): Observable<ScreenResponse>;
61
+
62
+ screenWithdrawal(request: ScreenWithdrawalRequest): Observable<ScreenResponse>;
63
+
64
+ health(request: HealthRequest): Observable<HealthResponse>;
65
+ }
66
+
67
+ export interface AmlServiceController {
68
+ screenDeposit(request: ScreenDepositRequest): Promise<ScreenResponse> | Observable<ScreenResponse> | ScreenResponse;
69
+
70
+ screenWithdrawal(
71
+ request: ScreenWithdrawalRequest,
72
+ ): Promise<ScreenResponse> | Observable<ScreenResponse> | ScreenResponse;
73
+
74
+ health(request: HealthRequest): Promise<HealthResponse> | Observable<HealthResponse> | HealthResponse;
75
+ }
76
+
77
+ export function AmlServiceControllerMethods() {
78
+ return function (constructor: Function) {
79
+ const grpcMethods: string[] = ["screenDeposit", "screenWithdrawal", "health"];
80
+ for (const method of grpcMethods) {
81
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
82
+ GrpcMethod("AmlService", method)(constructor.prototype[method], method, descriptor);
83
+ }
84
+ const grpcStreamMethods: string[] = [];
85
+ for (const method of grpcStreamMethods) {
86
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
87
+ GrpcStreamMethod("AmlService", method)(constructor.prototype[method], method, descriptor);
88
+ }
89
+ };
90
+ }
91
+
92
+ export const AML_SERVICE_NAME = "AmlService";
package/gen/custody.ts CHANGED
@@ -23,6 +23,24 @@ export enum DepositTrackingStatus {
23
23
  UNRECOGNIZED = -1,
24
24
  }
25
25
 
26
+ export interface ListDepositAddressesRequest {
27
+ /** TRON | BSC */
28
+ network: string;
29
+ /** По умолчанию USDT */
30
+ asset: string;
31
+ }
32
+
33
+ export interface ListDepositAddressRow {
34
+ userId: number;
35
+ network: string;
36
+ asset: string;
37
+ address: string;
38
+ }
39
+
40
+ export interface ListDepositAddressesResponse {
41
+ items: ListDepositAddressRow[];
42
+ }
43
+
26
44
  export interface GetDepositAddressRequest {
27
45
  /** Идентификатор пользователя (на wire при longs:String — строка). */
28
46
  userId: number;
@@ -49,6 +67,8 @@ export interface CreateWithdrawalRequest {
49
67
  amount: string;
50
68
  /** Адрес получателя в целевой сети. */
51
69
  toAddress: string;
70
+ /** USDT и т.д. (опционально для обратной совместимости). */
71
+ asset?: string | undefined;
52
72
  }
53
73
 
54
74
  export interface CreateWithdrawalResponse {
@@ -102,6 +122,10 @@ export interface CustodyServiceClient {
102
122
 
103
123
  getOrCreateDepositAddress(request: GetDepositAddressRequest): Observable<GetDepositAddressResponse>;
104
124
 
125
+ /** Список всех депозитных адресов для сканирования on-chain (внутренний вызов Deposit Service и др.). */
126
+
127
+ listDepositAddresses(request: ListDepositAddressesRequest): Observable<ListDepositAddressesResponse>;
128
+
105
129
  /** Инициировать вывод средств на указанный on-chain адрес; возвращает id трансфера в custody и унифицированный статус. */
106
130
 
107
131
  createWithdrawal(request: CreateWithdrawalRequest): Observable<CreateWithdrawalResponse>;
@@ -127,6 +151,12 @@ export interface CustodyServiceController {
127
151
  request: GetDepositAddressRequest,
128
152
  ): Promise<GetDepositAddressResponse> | Observable<GetDepositAddressResponse> | GetDepositAddressResponse;
129
153
 
154
+ /** Список всех депозитных адресов для сканирования on-chain (внутренний вызов Deposit Service и др.). */
155
+
156
+ listDepositAddresses(
157
+ request: ListDepositAddressesRequest,
158
+ ): Promise<ListDepositAddressesResponse> | Observable<ListDepositAddressesResponse> | ListDepositAddressesResponse;
159
+
130
160
  /** Инициировать вывод средств на указанный on-chain адрес; возвращает id трансфера в custody и унифицированный статус. */
131
161
 
132
162
  createWithdrawal(
@@ -150,6 +180,7 @@ export function CustodyServiceControllerMethods() {
150
180
  return function (constructor: Function) {
151
181
  const grpcMethods: string[] = [
152
182
  "getOrCreateDepositAddress",
183
+ "listDepositAddresses",
153
184
  "createWithdrawal",
154
185
  "getWithdrawalStatus",
155
186
  "getDepositStatus",
package/gen/deposit.ts ADDED
@@ -0,0 +1,60 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v7.34.0
5
+ // source: deposit.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "deposit.v1";
12
+
13
+ export interface ApplyBitGoCustodyAckRequest {
14
+ /** TRON | BSC */
15
+ network: string;
16
+ txHash: string;
17
+ logIndex?: number | undefined;
18
+ bitgoTransferId: string;
19
+ bitgoState: string;
20
+ /** может быть пустым */
21
+ webhookEventId: string;
22
+ }
23
+
24
+ export interface ApplyBitGoCustodyAckResponse {
25
+ matched: number;
26
+ depositTxIds: string[];
27
+ }
28
+
29
+ export const DEPOSIT_V1_PACKAGE_NAME = "deposit.v1";
30
+
31
+ export interface DepositIntegrationClient {
32
+ /** Привязать событие BitGo к уже найденному ончейн-депозиту (mpc webhook). */
33
+
34
+ applyBitGoCustodyAck(request: ApplyBitGoCustodyAckRequest): Observable<ApplyBitGoCustodyAckResponse>;
35
+ }
36
+
37
+ export interface DepositIntegrationController {
38
+ /** Привязать событие BitGo к уже найденному ончейн-депозиту (mpc webhook). */
39
+
40
+ applyBitGoCustodyAck(
41
+ request: ApplyBitGoCustodyAckRequest,
42
+ ): Promise<ApplyBitGoCustodyAckResponse> | Observable<ApplyBitGoCustodyAckResponse> | ApplyBitGoCustodyAckResponse;
43
+ }
44
+
45
+ export function DepositIntegrationControllerMethods() {
46
+ return function (constructor: Function) {
47
+ const grpcMethods: string[] = ["applyBitGoCustodyAck"];
48
+ for (const method of grpcMethods) {
49
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
50
+ GrpcMethod("DepositIntegration", method)(constructor.prototype[method], method, descriptor);
51
+ }
52
+ const grpcStreamMethods: string[] = [];
53
+ for (const method of grpcStreamMethods) {
54
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
55
+ GrpcStreamMethod("DepositIntegration", method)(constructor.prototype[method], method, descriptor);
56
+ }
57
+ };
58
+ }
59
+
60
+ export const DEPOSIT_INTEGRATION_SERVICE_NAME = "DepositIntegration";
@@ -0,0 +1,49 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v7.34.0
5
+ // source: kyc_gate.proto
6
+
7
+ /* eslint-disable */
8
+ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { Observable } from "rxjs";
10
+
11
+ export const protobufPackage = "kyc.v1";
12
+
13
+ export interface IsWithdrawalAllowedRequest {
14
+ userId: string;
15
+ }
16
+
17
+ export interface IsWithdrawalAllowedResponse {
18
+ allowed: boolean;
19
+ reason: string;
20
+ }
21
+
22
+ export const KYC_V1_PACKAGE_NAME = "kyc.v1";
23
+
24
+ export interface KycGateServiceClient {
25
+ isWithdrawalAllowed(request: IsWithdrawalAllowedRequest): Observable<IsWithdrawalAllowedResponse>;
26
+ }
27
+
28
+ export interface KycGateServiceController {
29
+ isWithdrawalAllowed(
30
+ request: IsWithdrawalAllowedRequest,
31
+ ): Promise<IsWithdrawalAllowedResponse> | Observable<IsWithdrawalAllowedResponse> | IsWithdrawalAllowedResponse;
32
+ }
33
+
34
+ export function KycGateServiceControllerMethods() {
35
+ return function (constructor: Function) {
36
+ const grpcMethods: string[] = ["isWithdrawalAllowed"];
37
+ for (const method of grpcMethods) {
38
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
39
+ GrpcMethod("KycGateService", method)(constructor.prototype[method], method, descriptor);
40
+ }
41
+ const grpcStreamMethods: string[] = [];
42
+ for (const method of grpcStreamMethods) {
43
+ const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
44
+ GrpcStreamMethod("KycGateService", method)(constructor.prototype[method], method, descriptor);
45
+ }
46
+ };
47
+ }
48
+
49
+ export const KYC_GATE_SERVICE_NAME = "KycGateService";
package/gen/ledger.ts CHANGED
@@ -50,7 +50,11 @@ export interface CreditUserBalanceRequest {
50
50
  /** Ключ идемпотентности вызова. */
51
51
  idempotencyKey: string;
52
52
  /** Опционально: число подтверждений на момент зачисления. */
53
- confirmations?: number | undefined;
53
+ confirmations?:
54
+ | number
55
+ | undefined;
56
+ /** Для EVM: индекс лога; для TRON — 0 или не задано. */
57
+ logIndex?: number | undefined;
54
58
  }
55
59
 
56
60
  export interface CreditUserBalanceResponse {
@@ -64,6 +68,55 @@ export interface CreditUserBalanceResponse {
64
68
  total: string;
65
69
  }
66
70
 
71
+ export interface CreditDepositHoldRequest {
72
+ userId: string;
73
+ asset: string;
74
+ network: string;
75
+ amount: string;
76
+ txHash: string;
77
+ externalOperationId: string;
78
+ idempotencyKey: string;
79
+ confirmations?: number | undefined;
80
+ logIndex?: number | undefined;
81
+ }
82
+
83
+ export interface CreditDepositHoldResponse {
84
+ depositId: string;
85
+ ledgerOperationId: string;
86
+ available: string;
87
+ reserved: string;
88
+ total: string;
89
+ }
90
+
91
+ export interface ReleaseDepositHoldRequest {
92
+ userId: string;
93
+ externalOperationId: string;
94
+ idempotencyKey: string;
95
+ }
96
+
97
+ export interface ReleaseDepositHoldResponse {
98
+ depositId: string;
99
+ ledgerOperationId: string;
100
+ available: string;
101
+ reserved: string;
102
+ total: string;
103
+ }
104
+
105
+ export interface ForfeitDepositHoldRequest {
106
+ userId: string;
107
+ externalOperationId: string;
108
+ idempotencyKey: string;
109
+ reason: string;
110
+ }
111
+
112
+ export interface ForfeitDepositHoldResponse {
113
+ depositId: string;
114
+ ledgerOperationId: string;
115
+ available: string;
116
+ reserved: string;
117
+ total: string;
118
+ }
119
+
67
120
  export interface RegisterWithdrawalRequest {
68
121
  userId: string;
69
122
  asset: string;
@@ -240,6 +293,18 @@ export interface LedgerServiceClient {
240
293
 
241
294
  creditUserBalance(request: CreditUserBalanceRequest): Observable<CreditUserBalanceResponse>;
242
295
 
296
+ /** Зачисление депозита в резерв (AML review): total и reserved растут, available без изменений. */
297
+
298
+ creditDepositHold(request: CreditDepositHoldRequest): Observable<CreditDepositHoldResponse>;
299
+
300
+ /** Перевод суммы из резерва в available (админ: HELD → зачислено). */
301
+
302
+ releaseDepositHold(request: ReleaseDepositHoldRequest): Observable<ReleaseDepositHoldResponse>;
303
+
304
+ /** Списание из резерва и уменьшение total без возврата в available (блокировка / compliance). */
305
+
306
+ forfeitDepositHold(request: ForfeitDepositHoldRequest): Observable<ForfeitDepositHoldResponse>;
307
+
243
308
  /** Создание записи о выводе в учёте (черновик заявки); дальнейшие шаги — резерв, смена статусов, финализация. */
244
309
 
245
310
  registerWithdrawal(request: RegisterWithdrawalRequest): Observable<RegisterWithdrawalResponse>;
@@ -289,6 +354,24 @@ export interface LedgerServiceController {
289
354
  request: CreditUserBalanceRequest,
290
355
  ): Promise<CreditUserBalanceResponse> | Observable<CreditUserBalanceResponse> | CreditUserBalanceResponse;
291
356
 
357
+ /** Зачисление депозита в резерв (AML review): total и reserved растут, available без изменений. */
358
+
359
+ creditDepositHold(
360
+ request: CreditDepositHoldRequest,
361
+ ): Promise<CreditDepositHoldResponse> | Observable<CreditDepositHoldResponse> | CreditDepositHoldResponse;
362
+
363
+ /** Перевод суммы из резерва в available (админ: HELD → зачислено). */
364
+
365
+ releaseDepositHold(
366
+ request: ReleaseDepositHoldRequest,
367
+ ): Promise<ReleaseDepositHoldResponse> | Observable<ReleaseDepositHoldResponse> | ReleaseDepositHoldResponse;
368
+
369
+ /** Списание из резерва и уменьшение total без возврата в available (блокировка / compliance). */
370
+
371
+ forfeitDepositHold(
372
+ request: ForfeitDepositHoldRequest,
373
+ ): Promise<ForfeitDepositHoldResponse> | Observable<ForfeitDepositHoldResponse> | ForfeitDepositHoldResponse;
374
+
292
375
  /** Создание записи о выводе в учёте (черновик заявки); дальнейшие шаги — резерв, смена статусов, финализация. */
293
376
 
294
377
  registerWithdrawal(
@@ -346,6 +429,9 @@ export function LedgerServiceControllerMethods() {
346
429
  const grpcMethods: string[] = [
347
430
  "registerDepositAddress",
348
431
  "creditUserBalance",
432
+ "creditDepositHold",
433
+ "releaseDepositHold",
434
+ "forfeitDepositHold",
349
435
  "registerWithdrawal",
350
436
  "reserveFunds",
351
437
  "releaseFunds",
package/gen/webhook.ts CHANGED
@@ -12,7 +12,7 @@ export const protobufPackage = "webhook.v1";
12
12
 
13
13
  export interface ProcessWebhookRequest {
14
14
  /**
15
- * Полное тело webhook от BitGo в виде одной JSON-строки (как получено после парсинга HTTP, объекты сериализованы стандартно).
15
+ * Полное тело события от BitGo в виде одной JSON-строки (как передал gateway после приёма webhook).
16
16
  * Клиент (gateway) обязан передавать валидный JSON; mpc парсит и маппит поля transfer / state / data и т.д.
17
17
  */
18
18
  jsonPayload: string;
@@ -30,7 +30,7 @@ export const WEBHOOK_V1_PACKAGE_NAME = "webhook.v1";
30
30
  export interface WebhookServiceClient {
31
31
  /**
32
32
  * Обработка одного события webhook BitGo: разбор JSON, дедупликация по event_id, обновление custody-транзакций,
33
- * при необходимости — gRPC в Ledger (статус вывода, зачисление депозита) и уведомления.
33
+ * при необходимости — gRPC в Ledger (статус вывода, зачисление депозита).
34
34
  */
35
35
 
36
36
  processBitGoWebhook(request: ProcessWebhookRequest): Observable<ProcessWebhookResponse>;
@@ -39,7 +39,7 @@ export interface WebhookServiceClient {
39
39
  export interface WebhookServiceController {
40
40
  /**
41
41
  * Обработка одного события webhook BitGo: разбор JSON, дедупликация по event_id, обновление custody-транзакций,
42
- * при необходимости — gRPC в Ledger (статус вывода, зачисление депозита) и уведомления.
42
+ * при необходимости — gRPC в Ledger (статус вывода, зачисление депозита).
43
43
  */
44
44
 
45
45
  processBitGoWebhook(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arbiwallet/contracts",
3
3
  "descriptions": "Generate and manage smart contracts for ArbiWallet",
4
- "version": "1.0.22",
4
+ "version": "1.0.24",
5
5
  "scripts": {
6
6
  "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
7
7
  },
@@ -0,0 +1,51 @@
1
+ syntax = "proto3";
2
+
3
+ package aml.v1;
4
+
5
+ service AmlService {
6
+ rpc ScreenDeposit(ScreenDepositRequest) returns (ScreenResponse);
7
+ rpc ScreenWithdrawal(ScreenWithdrawalRequest) returns (ScreenResponse);
8
+ rpc Health(HealthRequest) returns (HealthResponse);
9
+ }
10
+
11
+ enum AmlDecision {
12
+ ALLOW = 0;
13
+ REVIEW = 1;
14
+ BLOCK = 2;
15
+ }
16
+
17
+ message ScreenDepositRequest {
18
+ string network = 1;
19
+ string asset = 2;
20
+ string tx_hash = 3;
21
+ string from_address = 4;
22
+ string to_address = 5;
23
+ string amount = 6;
24
+ int64 confirmed_at_unix = 7;
25
+ string idempotency_key = 8;
26
+ }
27
+
28
+ message ScreenWithdrawalRequest {
29
+ string network = 1;
30
+ string asset = 2;
31
+ string to_address = 3;
32
+ string amount = 4;
33
+ string idempotency_key = 5;
34
+ }
35
+
36
+ message ScreenResponse {
37
+ AmlDecision decision = 1;
38
+ int32 score = 2;
39
+ string reason = 3;
40
+ string provider = 4;
41
+ string provider_ref = 5;
42
+ string raw_status = 6;
43
+ bool is_final = 7;
44
+ }
45
+
46
+ message HealthRequest {}
47
+
48
+ message HealthResponse {
49
+ bool ok = 1;
50
+ string version = 2;
51
+ }
@@ -9,6 +9,8 @@ service CustodyService {
9
9
  // Выдать существующий или создать новый депозитный адрес пользователя для пары (сеть, актив).
10
10
  // При создании адрес регистрируется в Ledger через исходящий gRPC mpc → ledger.
11
11
  rpc GetOrCreateDepositAddress(GetDepositAddressRequest) returns (GetDepositAddressResponse);
12
+ // Список всех депозитных адресов для сканирования on-chain (внутренний вызов Deposit Service и др.).
13
+ rpc ListDepositAddresses(ListDepositAddressesRequest) returns (ListDepositAddressesResponse);
12
14
  // Инициировать вывод средств на указанный on-chain адрес; возвращает id трансфера в custody и унифицированный статус.
13
15
  rpc CreateWithdrawal(CreateWithdrawalRequest) returns (CreateWithdrawalResponse);
14
16
  // Получить текущий статус ранее созданного вывода по внешнему id заявки (withdraw_request_id).
@@ -17,6 +19,22 @@ service CustodyService {
17
19
  rpc GetDepositStatus(GetDepositStatusRequest) returns (GetDepositStatusResponse);
18
20
  }
19
21
 
22
+ message ListDepositAddressesRequest {
23
+ string network = 1; // TRON | BSC
24
+ string asset = 2; // По умолчанию USDT
25
+ }
26
+
27
+ message ListDepositAddressRow {
28
+ int64 user_id = 1;
29
+ string network = 2;
30
+ string asset = 3;
31
+ string address = 4;
32
+ }
33
+
34
+ message ListDepositAddressesResponse {
35
+ repeated ListDepositAddressRow items = 1;
36
+ }
37
+
20
38
  message GetDepositAddressRequest {
21
39
  int64 user_id = 1; // Идентификатор пользователя (на wire при longs:String — строка).
22
40
  string network = 2; // TRON | BSC и т.д.
@@ -36,6 +54,7 @@ message CreateWithdrawalRequest {
36
54
  string network = 3;
37
55
  string amount = 4; // Сумма в decimal-строке.
38
56
  string to_address = 5; // Адрес получателя в целевой сети.
57
+ optional string asset = 6; // USDT и т.д. (опционально для обратной совместимости).
39
58
  }
40
59
 
41
60
  message CreateWithdrawalResponse {
@@ -0,0 +1,27 @@
1
+ syntax = "proto3";
2
+
3
+ // Внутренний gRPC deposit_service (ончейн-депозиты, привязка BitGo и т.п.).
4
+ package deposit.v1;
5
+
6
+ option csharp_namespace = "Deposit.V1";
7
+ option java_multiple_files = true;
8
+ option java_package = "com.arbiwallet.deposit.v1";
9
+
10
+ service DepositIntegration {
11
+ // Привязать событие BitGo к уже найденному ончейн-депозиту (mpc webhook).
12
+ rpc ApplyBitGoCustodyAck(ApplyBitGoCustodyAckRequest) returns (ApplyBitGoCustodyAckResponse);
13
+ }
14
+
15
+ message ApplyBitGoCustodyAckRequest {
16
+ string network = 1; // TRON | BSC
17
+ string tx_hash = 2;
18
+ optional int32 log_index = 3;
19
+ string bitgo_transfer_id = 4;
20
+ string bitgo_state = 5;
21
+ string webhook_event_id = 6; // может быть пустым
22
+ }
23
+
24
+ message ApplyBitGoCustodyAckResponse {
25
+ int32 matched = 1;
26
+ repeated string deposit_tx_ids = 2;
27
+ }
@@ -0,0 +1,19 @@
1
+ syntax = "proto3";
2
+
3
+ // Опциональный сервис проверки права на вывод (KYC / compliance gate).
4
+ // Реализация — отдельный микросервис; при отключённой проверке Withdrawal Service не вызывает RPC.
5
+ package kyc.v1;
6
+
7
+ service KycGateService {
8
+ rpc IsWithdrawalAllowed(IsWithdrawalAllowedRequest) returns (IsWithdrawalAllowedResponse);
9
+ }
10
+
11
+ message IsWithdrawalAllowedRequest {
12
+ string user_id = 1;
13
+ }
14
+
15
+ message IsWithdrawalAllowedResponse {
16
+ bool allowed = 1;
17
+ string reason = 2;
18
+ }
19
+
@@ -13,6 +13,12 @@ service LedgerService {
13
13
  rpc RegisterDepositAddress(RegisterDepositAddressRequest) returns (RegisterDepositAddressResponse);
14
14
  // Зачисление средств на доступный баланс пользователя (подтверждённый депозит); идемпотентность по ключу и внешнему id операции.
15
15
  rpc CreditUserBalance(CreditUserBalanceRequest) returns (CreditUserBalanceResponse);
16
+ // Зачисление депозита в резерв (AML review): total и reserved растут, available без изменений.
17
+ rpc CreditDepositHold(CreditDepositHoldRequest) returns (CreditDepositHoldResponse);
18
+ // Перевод суммы из резерва в available (админ: HELD → зачислено).
19
+ rpc ReleaseDepositHold(ReleaseDepositHoldRequest) returns (ReleaseDepositHoldResponse);
20
+ // Списание из резерва и уменьшение total без возврата в available (блокировка / compliance).
21
+ rpc ForfeitDepositHold(ForfeitDepositHoldRequest) returns (ForfeitDepositHoldResponse);
16
22
  // Создание записи о выводе в учёте (черновик заявки); дальнейшие шаги — резерв, смена статусов, финализация.
17
23
  rpc RegisterWithdrawal(RegisterWithdrawalRequest) returns (RegisterWithdrawalResponse);
18
24
  // Блокировка (резерв) средств на балансе под конкретный вывод после прохождения проверок.
@@ -58,6 +64,7 @@ message CreditUserBalanceRequest {
58
64
  string external_operation_id = 6; // Внешний id операции (custody, провайдер).
59
65
  string idempotency_key = 7; // Ключ идемпотентности вызова.
60
66
  optional int32 confirmations = 8; // Опционально: число подтверждений на момент зачисления.
67
+ optional int32 log_index = 9; // Для EVM: индекс лога; для TRON — 0 или не задано.
61
68
  }
62
69
 
63
70
  message CreditUserBalanceResponse {
@@ -68,6 +75,55 @@ message CreditUserBalanceResponse {
68
75
  string total = 5;
69
76
  }
70
77
 
78
+ message CreditDepositHoldRequest {
79
+ string user_id = 1;
80
+ string asset = 2;
81
+ string network = 3;
82
+ string amount = 4;
83
+ string tx_hash = 5;
84
+ string external_operation_id = 6;
85
+ string idempotency_key = 7;
86
+ optional int32 confirmations = 8;
87
+ optional int32 log_index = 9;
88
+ }
89
+
90
+ message CreditDepositHoldResponse {
91
+ string deposit_id = 1;
92
+ string ledger_operation_id = 2;
93
+ string available = 3;
94
+ string reserved = 4;
95
+ string total = 5;
96
+ }
97
+
98
+ message ReleaseDepositHoldRequest {
99
+ string user_id = 1;
100
+ string external_operation_id = 2;
101
+ string idempotency_key = 3;
102
+ }
103
+
104
+ message ReleaseDepositHoldResponse {
105
+ string deposit_id = 1;
106
+ string ledger_operation_id = 2;
107
+ string available = 3;
108
+ string reserved = 4;
109
+ string total = 5;
110
+ }
111
+
112
+ message ForfeitDepositHoldRequest {
113
+ string user_id = 1;
114
+ string external_operation_id = 2;
115
+ string idempotency_key = 3;
116
+ string reason = 4;
117
+ }
118
+
119
+ message ForfeitDepositHoldResponse {
120
+ string deposit_id = 1;
121
+ string ledger_operation_id = 2;
122
+ string available = 3;
123
+ string reserved = 4;
124
+ string total = 5;
125
+ }
126
+
71
127
  message RegisterWithdrawalRequest {
72
128
  string user_id = 1;
73
129
  string asset = 2;
@@ -1,18 +1,18 @@
1
1
  syntax = "proto3";
2
2
 
3
- // Пакет внутреннего gRPC для передачи событий BitGo в mpc_service без публичного HTTP на mpc.
4
- // Типичный поток: WalletGateway принимает POST /webhooks/bitgo → вызывает ProcessBitGoWebhook с JSON телом.
5
- // Та же бизнес-логика, что у HTTP-обработчика webhook в mpc (дедуп, обновление транзакций, вызовы Ledger/Notification).
3
+ // Пакет внутреннего gRPC: события BitGo передаются в mpc_service только по gRPC (публичный ingress — Wallet Gateway).
4
+ // Типичный поток: WalletGateway принимает webhook от BitGo → вызывает ProcessBitGoWebhook с JSON-телом в json_payload.
5
+ // Бизнес-логика: дедуп, обновление транзакций, исходящие вызовы в Ledger.
6
6
  package webhook.v1;
7
7
 
8
8
  service WebhookService {
9
9
  // Обработка одного события webhook BitGo: разбор JSON, дедупликация по event_id, обновление custody-транзакций,
10
- // при необходимости — gRPC в Ledger (статус вывода, зачисление депозита) и уведомления.
10
+ // при необходимости — gRPC в Ledger (статус вывода, зачисление депозита).
11
11
  rpc ProcessBitGoWebhook(ProcessWebhookRequest) returns (ProcessWebhookResponse);
12
12
  }
13
13
 
14
14
  message ProcessWebhookRequest {
15
- // Полное тело webhook от BitGo в виде одной JSON-строки (как получено после парсинга HTTP, объекты сериализованы стандартно).
15
+ // Полное тело события от BitGo в виде одной JSON-строки (как передал gateway после приёма webhook).
16
16
  // Клиент (gateway) обязан передавать валидный JSON; mpc парсит и маппит поля transfer / state / data и т.д.
17
17
  string json_payload = 1;
18
18
  }