@v3finance/core-sdk 0.2.1 → 0.2.3

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +2 -1
  3. package/dist/cjs/generated/operations.js +1 -1
  4. package/dist/cjs/generated/types.d.ts +13 -7
  5. package/dist/cjs/generated/types.d.ts.map +1 -1
  6. package/dist/cjs/resources/approvals.d.ts +22 -0
  7. package/dist/cjs/resources/approvals.d.ts.map +1 -1
  8. package/dist/cjs/resources/approvals.js +22 -0
  9. package/dist/cjs/resources/approvals.js.map +1 -1
  10. package/dist/cjs/resources/transfers.d.ts +64 -16
  11. package/dist/cjs/resources/transfers.d.ts.map +1 -1
  12. package/dist/cjs/resources/transfers.js +64 -16
  13. package/dist/cjs/resources/transfers.js.map +1 -1
  14. package/dist/cjs/version.d.ts +1 -1
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/esm/generated/operations.js +1 -1
  17. package/dist/esm/generated/types.d.ts +13 -7
  18. package/dist/esm/generated/types.d.ts.map +1 -1
  19. package/dist/esm/resources/approvals.d.ts +22 -0
  20. package/dist/esm/resources/approvals.d.ts.map +1 -1
  21. package/dist/esm/resources/approvals.js +22 -0
  22. package/dist/esm/resources/approvals.js.map +1 -1
  23. package/dist/esm/resources/transfers.d.ts +64 -16
  24. package/dist/esm/resources/transfers.d.ts.map +1 -1
  25. package/dist/esm/resources/transfers.js +64 -16
  26. package/dist/esm/resources/transfers.js.map +1 -1
  27. package/dist/esm/version.d.ts +1 -1
  28. package/dist/esm/version.js +1 -1
  29. package/docs/concepts.md +2 -1
  30. package/docs/errors.md +36 -16
  31. package/package.json +1 -1
  32. package/src/generated/operations.ts +1 -1
  33. package/src/generated/types.ts +13 -7
  34. package/src/resources/approvals.ts +22 -0
  35. package/src/resources/transfers.ts +64 -16
  36. package/src/version.ts +1 -1
@@ -11,7 +11,10 @@ export interface VoteInput {
11
11
  * The result of sending is `Gated`, and that is the main thing to understand
12
12
  * here. The same `{transaction}` body comes back in three situations:
13
13
  *
14
- * applied (201) — executed, the money left;
14
+ * applied (201) — executed, the money left (rarely the status is still
15
+ * `pending` with a `txHash`: it went out, but its
16
+ * accounting was not recorded, and an administrator's
17
+ * reconciliation finishes it — do not send it again);
15
18
  * pending (202) — awaiting signatures, funds RESERVED but not sent;
16
19
  * replayed (200) — a transfer with this `idempotencyKey` already existed,
17
20
  * and this is that transfer as it stands NOW.
@@ -24,7 +27,10 @@ export interface VoteInput {
24
27
  *
25
28
  * confirmed, submitted — it left;
26
29
  * awaiting_approval — waiting for signatures, funds reserved;
27
- * pending — still executing;
30
+ * pending — still executing, or its outcome is unknown
31
+ * (the first answer was 502
32
+ * `TRANSFER_OUTCOME_UNKNOWN`) until an
33
+ * administrator reconciles it;
28
34
  * failed, rejected,
29
35
  * cancelled — it did not leave.
30
36
  */
@@ -37,6 +43,12 @@ export declare class TransfersResource {
37
43
  * On `outcome: 'replayed'` read `data.transaction.status` before telling
38
44
  * anyone anything — a replay of an attempt that failed, or that is still
39
45
  * waiting for signatures, comes back the same way as one that went out.
46
+ *
47
+ * A thrown 502 `TRANSFER_OUTCOME_UNKNOWN` is not a failure: the signing
48
+ * service gave no definite answer, the transaction may have left, and the
49
+ * transfer stays `pending` with its funds reserved (`details.transactionId`).
50
+ * Retry it only with the SAME key — that returns the transfer without
51
+ * executing it again; a new key can send the money twice.
40
52
  */
41
53
  send(input: CreateTransferBody, options?: {
42
54
  signal?: AbortSignal;
@@ -45,7 +57,9 @@ export declare class TransfersResource {
45
57
  /**
46
58
  * One transfer in full. Note the shape: this is the transaction itself, not
47
59
  * the `{ transaction }` wrapper that `send()` returns — and it carries more,
48
- * including `amlLevel`, `approvers`, `usdRate` and `failureReason`.
60
+ * including `amlLevel`, `approvers`, `usdRate` and `failureReason` — the
61
+ * last only on `failed`, `rejected` and `cancelled`, `null` on any other
62
+ * status.
49
63
  */
50
64
  get(transferId: string): Promise<TransactionDetail>;
51
65
  /**
@@ -61,11 +75,30 @@ export declare class TransfersResource {
61
75
  * awaiting_approval — counted, more signatures still needed;
62
76
  * rejected — a `reject` is a veto, and the reserve is released;
63
77
  * confirmed/failed — this vote completed the threshold, so execution ran
64
- * INSIDE this request (gas, then broadcast, ~10s).
78
+ * INSIDE this request (gas, then broadcast, ~10s);
79
+ * pending — with no `executionError`: the outcome is NOT
80
+ * established by this answer. The signing service
81
+ * gave no definite answer (the transaction may have
82
+ * left; an administrator's reconciliation settles
83
+ * it), another call is executing the transfer, or
84
+ * the execution broke off. Re-read the transfer:
85
+ * `confirmed`/`failed` is the outcome, `pending` for
86
+ * over 10 minutes by `updatedAt` is waiting for
87
+ * reconciliation. Never send it again.
65
88
  *
66
89
  * `failed` means the money is back: execution broke after approval and the
67
90
  * reserve was released, with the reason in `executionError`. Treating the
68
- * call as "approved, done" hides both the success and that failure.
91
+ * call as "approved, done" hides both the success and that failure. The
92
+ * exception is a `failed` transfer that has a `txHash`: it went out after
93
+ * reconciliation had already returned the reserve, and an administrator has
94
+ * to correct the ledger. `executionError` beside `rejected` or `cancelled`
95
+ * means the transfer was no longer waiting for signatures when approved,
96
+ * and nothing was executed.
97
+ *
98
+ * Repeating the same decision while the transfer is still waiting finishes
99
+ * what an earlier call left undone (it recorded the vote and broke off) — a
100
+ * veto, or execution once the threshold is met — instead of 409
101
+ * `ALREADY_VOTED`.
69
102
  */
70
103
  vote(transferId: string, input: VoteInput): Promise<VoteResult>;
71
104
  /**
@@ -84,19 +117,34 @@ export declare class TransfersResource {
84
117
  */
85
118
  cancel(transferId: string): Promise<CancelResult>;
86
119
  /**
87
- * Settles a transfer stuck in `pending` — the case where the worker died
88
- * mid-execution, so cancelling does not apply. Administrators only.
120
+ * Settles a transfer nothing else can close. Administrators only.
121
+ *
122
+ * pending — execution died, or its outcome is unknown (the
123
+ * send answered 502 `TRANSFER_OUTCOME_UNKNOWN`);
124
+ * awaiting_approval — with no live approval request to vote on;
125
+ * failed, rejected,
126
+ * cancelled — closed, but the reserve is still held: it is
127
+ * returned, and the status stays.
128
+ *
129
+ * A pending transfer is decided by the HASH: send `txHash` and it is driven
130
+ * to `confirmed`; send none and the reserve is returned (`failed`). Sending
131
+ * none is YOUR statement that nothing was broadcast — the server does not
132
+ * check it, so look on the chain first: returning the reserve of a
133
+ * transaction that did go out creates money. If the transfer already holds
134
+ * a hash from the signing service, only that hash, sent explicitly, settles
135
+ * it — 409 `TRANSFER_BROADCAST` without one, `TXHASH_MISMATCH` with another,
136
+ * the saved hash in `details.txHash`. The other two cases never executed
137
+ * and take no hash.
89
138
  *
90
- * The decision is made by the HASH: send `txHash` and the transfer is
91
- * driven to `confirmed`, because the signing service did put it on the
92
- * chain; send none and the reserve is returned, because there was no
93
- * broadcast. A FRESH pending transfer is refused on purpose — while
94
- * execution may still be in flight, intervening risks a SECOND broadcast,
95
- * which costs more than waiting.
139
+ * A FRESH transfer is refused on purpose — while execution may still be in
140
+ * flight, intervening risks a SECOND broadcast, which costs more than
141
+ * waiting.
96
142
  *
97
- * Pass `fee` along with the hash if you know it: this is the only moment
98
- * it can be recorded on a transfer settled this way, and it stays null
99
- * otherwise. The answer says which way it went — `confirmed` or `failed`.
143
+ * Pass `fee` along with the hash if you know it: this is the only moment it
144
+ * can be recorded on a transfer settled this way; otherwise it stays as it
145
+ * is, null unless the signing service reported one. The answer says which
146
+ * way it went — `confirmed`, `failed`, or the unchanged `rejected` /
147
+ * `cancelled` of a closed transfer.
100
148
  */
101
149
  reconcile(transferId: string, input?: ReconcileTransferBody): Promise<ReconcileTransferResult>;
102
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transfers.d.ts","sourceRoot":"","sources":["../../../src/resources/transfers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,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vB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACX,MAAM,uBAAuB,CAAA;AAE9B,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,iBAAiB;;IAI5B,YAAY,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAG9C;IAED;;;;;;;;;;;;OAYG;IACG,IAAI,CACR,KAAK,EAAE,kBAAkB,EACzB,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACzD,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAUzC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAElD;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAM9D;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAEhD;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,SAAS,CACP,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,qBAA0B,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAMlC;CACF"}
@@ -9,7 +9,10 @@ const gated_js_1 = require("../core/gated.js");
9
9
  * The result of sending is `Gated`, and that is the main thing to understand
10
10
  * here. The same `{transaction}` body comes back in three situations:
11
11
  *
12
- * applied (201) — executed, the money left;
12
+ * applied (201) — executed, the money left (rarely the status is still
13
+ * `pending` with a `txHash`: it went out, but its
14
+ * accounting was not recorded, and an administrator's
15
+ * reconciliation finishes it — do not send it again);
13
16
  * pending (202) — awaiting signatures, funds RESERVED but not sent;
14
17
  * replayed (200) — a transfer with this `idempotencyKey` already existed,
15
18
  * and this is that transfer as it stands NOW.
@@ -22,7 +25,10 @@ const gated_js_1 = require("../core/gated.js");
22
25
  *
23
26
  * confirmed, submitted — it left;
24
27
  * awaiting_approval — waiting for signatures, funds reserved;
25
- * pending — still executing;
28
+ * pending — still executing, or its outcome is unknown
29
+ * (the first answer was 502
30
+ * `TRANSFER_OUTCOME_UNKNOWN`) until an
31
+ * administrator reconciles it;
26
32
  * failed, rejected,
27
33
  * cancelled — it did not leave.
28
34
  */
@@ -39,6 +45,12 @@ class TransfersResource {
39
45
  * On `outcome: 'replayed'` read `data.transaction.status` before telling
40
46
  * anyone anything — a replay of an attempt that failed, or that is still
41
47
  * waiting for signatures, comes back the same way as one that went out.
48
+ *
49
+ * A thrown 502 `TRANSFER_OUTCOME_UNKNOWN` is not a failure: the signing
50
+ * service gave no definite answer, the transaction may have left, and the
51
+ * transfer stays `pending` with its funds reserved (`details.transactionId`).
52
+ * Retry it only with the SAME key — that returns the transfer without
53
+ * executing it again; a new key can send the money twice.
42
54
  */
43
55
  async send(input, options = {}) {
44
56
  const res = await this.#http.requestRaw('POST', this.#base, {
@@ -54,7 +66,9 @@ class TransfersResource {
54
66
  /**
55
67
  * One transfer in full. Note the shape: this is the transaction itself, not
56
68
  * the `{ transaction }` wrapper that `send()` returns — and it carries more,
57
- * including `amlLevel`, `approvers`, `usdRate` and `failureReason`.
69
+ * including `amlLevel`, `approvers`, `usdRate` and `failureReason` — the
70
+ * last only on `failed`, `rejected` and `cancelled`, `null` on any other
71
+ * status.
58
72
  */
59
73
  get(transferId) {
60
74
  return this.#http.request('GET', `${this.#base}/${(0, http_js_1.seg)(transferId)}`);
@@ -72,11 +86,30 @@ class TransfersResource {
72
86
  * awaiting_approval — counted, more signatures still needed;
73
87
  * rejected — a `reject` is a veto, and the reserve is released;
74
88
  * confirmed/failed — this vote completed the threshold, so execution ran
75
- * INSIDE this request (gas, then broadcast, ~10s).
89
+ * INSIDE this request (gas, then broadcast, ~10s);
90
+ * pending — with no `executionError`: the outcome is NOT
91
+ * established by this answer. The signing service
92
+ * gave no definite answer (the transaction may have
93
+ * left; an administrator's reconciliation settles
94
+ * it), another call is executing the transfer, or
95
+ * the execution broke off. Re-read the transfer:
96
+ * `confirmed`/`failed` is the outcome, `pending` for
97
+ * over 10 minutes by `updatedAt` is waiting for
98
+ * reconciliation. Never send it again.
76
99
  *
77
100
  * `failed` means the money is back: execution broke after approval and the
78
101
  * reserve was released, with the reason in `executionError`. Treating the
79
- * call as "approved, done" hides both the success and that failure.
102
+ * call as "approved, done" hides both the success and that failure. The
103
+ * exception is a `failed` transfer that has a `txHash`: it went out after
104
+ * reconciliation had already returned the reserve, and an administrator has
105
+ * to correct the ledger. `executionError` beside `rejected` or `cancelled`
106
+ * means the transfer was no longer waiting for signatures when approved,
107
+ * and nothing was executed.
108
+ *
109
+ * Repeating the same decision while the transfer is still waiting finishes
110
+ * what an earlier call left undone (it recorded the vote and broke off) — a
111
+ * veto, or execution once the threshold is met — instead of 409
112
+ * `ALREADY_VOTED`.
80
113
  */
81
114
  vote(transferId, input) {
82
115
  return this.#http.request('POST', `${this.#base}/${(0, http_js_1.seg)(transferId)}/approvals`, { body: input });
@@ -99,19 +132,34 @@ class TransfersResource {
99
132
  return this.#http.request('POST', `${this.#base}/${(0, http_js_1.seg)(transferId)}/cancel`);
100
133
  }
101
134
  /**
102
- * Settles a transfer stuck in `pending` — the case where the worker died
103
- * mid-execution, so cancelling does not apply. Administrators only.
135
+ * Settles a transfer nothing else can close. Administrators only.
136
+ *
137
+ * pending — execution died, or its outcome is unknown (the
138
+ * send answered 502 `TRANSFER_OUTCOME_UNKNOWN`);
139
+ * awaiting_approval — with no live approval request to vote on;
140
+ * failed, rejected,
141
+ * cancelled — closed, but the reserve is still held: it is
142
+ * returned, and the status stays.
143
+ *
144
+ * A pending transfer is decided by the HASH: send `txHash` and it is driven
145
+ * to `confirmed`; send none and the reserve is returned (`failed`). Sending
146
+ * none is YOUR statement that nothing was broadcast — the server does not
147
+ * check it, so look on the chain first: returning the reserve of a
148
+ * transaction that did go out creates money. If the transfer already holds
149
+ * a hash from the signing service, only that hash, sent explicitly, settles
150
+ * it — 409 `TRANSFER_BROADCAST` without one, `TXHASH_MISMATCH` with another,
151
+ * the saved hash in `details.txHash`. The other two cases never executed
152
+ * and take no hash.
104
153
  *
105
- * The decision is made by the HASH: send `txHash` and the transfer is
106
- * driven to `confirmed`, because the signing service did put it on the
107
- * chain; send none and the reserve is returned, because there was no
108
- * broadcast. A FRESH pending transfer is refused on purpose — while
109
- * execution may still be in flight, intervening risks a SECOND broadcast,
110
- * which costs more than waiting.
154
+ * A FRESH transfer is refused on purpose — while execution may still be in
155
+ * flight, intervening risks a SECOND broadcast, which costs more than
156
+ * waiting.
111
157
  *
112
- * Pass `fee` along with the hash if you know it: this is the only moment
113
- * it can be recorded on a transfer settled this way, and it stays null
114
- * otherwise. The answer says which way it went — `confirmed` or `failed`.
158
+ * Pass `fee` along with the hash if you know it: this is the only moment it
159
+ * can be recorded on a transfer settled this way; otherwise it stays as it
160
+ * is, null unless the signing service reported one. The answer says which
161
+ * way it went — `confirmed`, `failed`, or the unchanged `rejected` /
162
+ * `cancelled` of a closed transfer.
115
163
  */
116
164
  reconcile(transferId, input = {}) {
117
165
  return this.#http.request('POST', `${this.#base}/${(0, http_js_1.seg)(transferId)}/reconcile`, { body: input });
@@ -1 +1 @@
1
- {"version":3,"file":"transfers.js","sourceRoot":"","sources":["../../../src/resources/transfers.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AACtD,+CAAsD;AAgBtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;IACW,KAAK,CAAY;IACjB,KAAK,CAAQ;IAEtB,YAAY,IAAgB,EAAE,SAAiB;QAC7C,IAA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EAClB,KAAK,GAA0B,EAAE;QAEjC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,MAAM,EACN,GAAG,IAAI,CAAC,KAAK,IAAI,IAAA,aAAG,EAAC,UAAU,CAAC,YAAY,EAC5C,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAA;IACH,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
1
  /** SDK version, sent in the `user-agent` header. */
2
- export declare const SDK_VERSION = "0.2.1";
2
+ export declare const SDK_VERSION = "0.2.3";
3
3
  /** Default API base URL. */
4
4
  export declare const DEFAULT_BASE_URL = "https://policy-engine-rest.ezig.workers.dev";
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_BASE_URL = exports.SDK_VERSION = void 0;
4
4
  /** SDK version, sent in the `user-agent` header. */
5
- exports.SDK_VERSION = '0.2.1';
5
+ exports.SDK_VERSION = '0.2.3';
6
6
  /** Default API base URL. */
7
7
  exports.DEFAULT_BASE_URL = 'https://policy-engine-rest.ezig.workers.dev';
8
8
  //# sourceMappingURL=version.js.map
@@ -9,7 +9,7 @@
9
9
  // the API does not slip in unclassified.
10
10
  //
11
11
  // Operations: 171 · admin: 40 · both: 1 · member: 127 · service: 3
12
- // Spec sha256: 017bae30075b232ab4efdcfb7785335020be3060b46e3569b1cd887fcf037597
12
+ // Spec sha256: 1f0f2a38668572c443a84cb0207d4070b419a16c293b8e975f5e21c68e85b15a
13
13
  export const OPERATIONS = {
14
14
  "DELETE /api/v1/me/push-tokens/{token}": {
15
15
  "method": "delete",
@@ -297,6 +297,7 @@ export interface OutgoingTxSummary {
297
297
  status: string;
298
298
  txHash: string | null;
299
299
  fee: string | null;
300
+ /** Причина закрытия — только у failed/rejected/cancelled. У остальных статусов (awaiting_approval, pending, submitted, confirmed) — ВСЕГДА null: у незакрытого перевода причины отказа нет. Неясный исход исполнения (pending, транзакция могла уйти в сеть) здесь не показывается — его признак pending дольше 10 минут по updatedAt («ждёт сверки администратором») */
300
301
  failureReason: string | null;
301
302
  /** format: date-time */
302
303
  createdAt: string;
@@ -1625,7 +1626,7 @@ export interface CreateTransactionResult {
1625
1626
  amountDecimal: string;
1626
1627
  asset: string;
1627
1628
  network: string;
1628
- /** confirmed — новый успешный перевод; pending/failed возможны при replay по idempotencyKey */
1629
+ /** 201 — confirmed (исполнен сейчас); редко pending с заполненным txHash (транзакция ушла в сеть, а учёт не записался — доводит сверка, повторять перевод нельзя); 202 — awaiting_approval; 200 (replay по idempotencyKey) — ТЕКУЩИЙ статус перевода, любой: pending (первый запрос ещё исполняется — или его исход неизвестен: первый ответ был 502 TRANSFER_OUTCOME_UNKNOWN; повтор НЕ исполняет перевод заново, исход устанавливает сверка), awaiting_approval, confirmed, failed, rejected, cancelled */
1629
1630
  status: string;
1630
1631
  txHash: string | null;
1631
1632
  fee: string | null;
@@ -1639,12 +1640,13 @@ export interface CreateTransactionResult {
1639
1640
  }
1640
1641
  export interface CreateTransferBody {
1641
1642
  fromAddressId: string;
1643
+ /** Адрес получателя. Формат проверяется по типу сети адреса-отправителя ДО резерва средств: TRON — base58check (34 символа, «T…», контрольная сумма), EVM — 0x + 40 hex (смешанный регистр — контрольная сумма EIP-55). Не подошёл — 400 INVALID_DESTINATION_ADDRESS. Строка проверяется как есть, пробелы по краям — ошибка формата */
1642
1644
  toAddress: string;
1643
1645
  /** DECIMAL строка — конвертируется по token.decimals */
1644
1646
  amount: string;
1645
1647
  asset: string;
1646
1648
  /**
1647
- * Уникальный ключ попытки перевода (рекомендуется: uuid). Повторный запрос с тем же ключом вернёт существующую транзакцию без второго broadcast. Для новой попытки после failed — новый ключ.
1649
+ * Уникальный ключ попытки перевода (рекомендуется: uuid). Повторный запрос с тем же ключом и теми же параметрами вернёт 200 с существующим переводом — без второго broadcast, без повторной оценки политик. Тот же ключ с другими параметрами — 409 IDEMPOTENCY_KEY_REUSED. Для новой попытки после failed — новый ключ.
1648
1650
  *
1649
1651
  * length: 8..128
1650
1652
  */
@@ -1915,6 +1917,7 @@ export interface HistoryOutItem {
1915
1917
  asset: string;
1916
1918
  assetSymbol: string;
1917
1919
  fee: string | null;
1920
+ /** Причина закрытия — только у failed/rejected/cancelled. У остальных статусов (awaiting_approval, pending, submitted, confirmed) — ВСЕГДА null: у незакрытого перевода причины отказа нет. Неясный исход исполнения (pending, транзакция могла уйти в сеть) здесь не показывается — его признак pending дольше 10 минут по updatedAt («ждёт сверки администратором») */
1918
1921
  failureReason: string | null;
1919
1922
  fromAddress: {
1920
1923
  id: string;
@@ -2991,7 +2994,7 @@ export interface RatesResponse {
2991
2994
  }>;
2992
2995
  }
2993
2996
  export interface ReconcileTransferBody {
2994
- /** Хеш от подписывающего сервиса. ЕСТЬ — транзакция ушла в сеть, перевод доводится до confirmed. НЕТ (или null) — считаем, что broadcast'а не было, и возвращаем резерв (failed) */
2997
+ /** Хеш от подписывающего сервиса. ЕСТЬ — транзакция ушла в сеть, перевод доводится до confirmed. НЕТ (или null) — сверяющий утверждает, что broadcast'а не было, и резерв возвращается (failed). Для pending с неясным исходом (у pending без txHash его не отличить по ответам API — failureReason у незакрытого перевода null) это утверждение нужно ПРОВЕРИТЬ по сети: возврат за ушедшую транзакцию печатает деньги. Если у pending-перевода хеш уже сохранён (broadcast прошёл), он обязателен: без него — 409 TRANSFER_BROADCAST, с другим — 409 TXHASH_MISMATCH (сохранённый — в error.details.txHash) */
2995
2998
  txHash?: string | null;
2996
2999
  /** Комиссия, если известна */
2997
3000
  fee?: string | null;
@@ -2999,7 +3002,8 @@ export interface ReconcileTransferBody {
2999
3002
  reason?: string | null;
3000
3003
  }
3001
3004
  export interface ReconcileTransferResult {
3002
- status: "confirmed" | "failed";
3005
+ /** Статус перевода после сверки: confirmed (по хешу) | failed (резерв возвращён). rejected/cancelled — у закрытого перевода с невозвращённым резервом: резерв возвращён, статус прежний */
3006
+ status: "confirmed" | "failed" | "rejected" | "cancelled";
3003
3007
  txHash: string | null;
3004
3008
  }
3005
3009
  export interface RegisterPushTokenBody {
@@ -3018,8 +3022,9 @@ export interface RequestVoteResult {
3018
3022
  approvals: number;
3019
3023
  /** range: -9007199254740991..9007199254740991 */
3020
3024
  threshold: number;
3021
- /** true — этот голос финализировал заявку (применена/отклонена) */
3025
+ /** true — этот голос финализировал заявку (применена/отклонена). У заявки на перевод status=APPROVED при finalized=false значит, что исход рассчитал НЕ этот вызов: applyError пуст — перевод исполняет (исполнил) параллельный запрос ЛИБО исполнение, начатое другим вызовом, оборвалось (сам перевод тогда не закроется); исход — только по GET /transfers/{id}: confirmed/failed, а pending дольше 10 минут по updatedAt — ждёт сверки (admin). applyError TRANSFER_EXECUTION_FAILED — к моменту одобрения перевод уже не ждал подписей. finalized=false с пустым applyError приходит и тогда, когда одобрил ЭТОТ голос, но исход перевода им не установлен (перевод pending: подписывающий сервис не дал определённого ответа, транзакция могла уйти в сеть, а могла и нет): показывайте «голос учтён», не «применено». finalized=true с пустым applyError у перевода — исполнен этим вызовом (confirmed) */
3022
3026
  finalized: boolean;
3027
+ /** Голос финализировал заявку, а применение не дало результата; status при этом итоговый. Коды: STALE — цель изменилась (status=REJECTED); APPLY_FAILED / APPLY_FAILED_ROLLED_BACK / APPLY_FAILED_PARTIAL — мутация не применена (целиком / цепочка откатана / частично). У action=transfer финальный approve ИСПОЛНЯЕТ перевод, status=APPROVED: TRANSFER_EXECUTION_FAILED — перевод не исполнен (обычно failed, резерв возвращён; точный статус — GET /transfers/{id}; при finalized=false — перевод уже не ждал подписей, одобрение его не исполняло). Неясный исход перевода (подписывающий сервис не дал определённого ответа, перевод pending, средства зарезервированы, транзакция могла уйти в сеть, исход установит сверка, admin) ошибкой НЕ отдаётся: applyError null, status APPROVED, finalized=false. Кода TRANSFER_OUTCOME_UNKNOWN здесь нет — он только у POST /transfers */
3023
3028
  applyError: {
3024
3029
  code: string;
3025
3030
  message: string;
@@ -3179,6 +3184,7 @@ export interface TransactionDetail {
3179
3184
  decisionPolicyCode: string | null;
3180
3185
  /** Человеческое название решающей политики (для UI вместо кода) */
3181
3186
  decisionPolicyName: string | null;
3187
+ /** Причина закрытия — только у failed/rejected/cancelled. У остальных статусов (awaiting_approval, pending, submitted, confirmed) — ВСЕГДА null: у незакрытого перевода причины отказа нет. Неясный исход исполнения (pending, транзакция могла уйти в сеть) здесь не показывается — его признак pending дольше 10 минут по updatedAt («ждёт сверки администратором») */
3182
3188
  failureReason: string | null;
3183
3189
  /** format: date-time */
3184
3190
  createdAt: string;
@@ -3496,7 +3502,7 @@ export interface VoteRequestBody {
3496
3502
  comment?: string;
3497
3503
  }
3498
3504
  export interface VoteResult {
3499
- /** Статус перевода ПОСЛЕ голоса: awaiting_approval (голосов мало) | rejected | confirmed/failed (финальный approve исполняет сразу) */
3505
+ /** Статус перевода ПОСЛЕ голоса: awaiting_approval (голосов мало) | rejected | confirmed/failed (финальный approve исполняет сразу). pending — исполнение не закончено, повторять перевод нельзя; executionError у pending всегда null, исход этим ответом НЕ установлен, ждать его «через секунды» нельзя. Так отдаётся и неясный исход (подписывающий сервис не дал определённого ответа, транзакция могла уйти в сеть, резерв стоит — доводит сверка, admin), и: txHash в GET /transfers/{id} есть — транзакция ушла в сеть, а учёт не записался, доводит сверка (admin) по этому хешу; перевод исполняет параллельный запрос (одновременный голос другого подписанта или исходный вызов при повторе голоса) ЛИБО исполнение оборвалось (клиент, который его начал, отключился — сам перевод тогда не закроется). Различает только время: перечитывайте GET; confirmed/failed — исход; pending дольше 10 минут по updatedAt — «ждёт сверки администратором» */
3500
3506
  status: string;
3501
3507
  /**
3502
3508
  * Собрано approve-голосов
@@ -3506,7 +3512,7 @@ export interface VoteResult {
3506
3512
  approvals: number;
3507
3513
  /** range: -9007199254740991..9007199254740991 */
3508
3514
  threshold: number;
3509
- /** Если финальный approve запустил исполнение и оно упало (средства возвращены) */
3515
+ /** Финальный approve запустил исполнение, и оно перевод НЕ исполнило. code: TRANSFER_EXECUTION_FAILED — не исполнен (status=failed, средства возвращены; исключения: failed с txHash у перевода, см. описание ручки, и status=pending, если сам возврат резерва не записался — тогда перевод доводит сверка). Тот же код — если к моменту одобрения перевод уже не ждал подписей (status — его фактический: failed/rejected/cancelled): одобрение его не исполнило. Неясный исход (подписывающий сервис не дал определённого ответа, транзакция могла уйти в сеть) ошибкой НЕ отдаётся: status=pending, executionError=null — показывайте «исполняется, исход уточняется». Кода TRANSFER_OUTCOME_UNKNOWN в голосе нет, он только у POST /transfers */
3510
3516
  executionError: {
3511
3517
  code: string;
3512
3518
  message: string;