@v3finance/core-sdk 0.20.1 → 0.22.0

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 (76) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/generated/operations.d.ts +24 -0
  4. package/dist/cjs/generated/operations.d.ts.map +1 -1
  5. package/dist/cjs/generated/operations.js +26 -2
  6. package/dist/cjs/generated/operations.js.map +1 -1
  7. package/dist/cjs/generated/types.d.ts +167 -3
  8. package/dist/cjs/generated/types.d.ts.map +1 -1
  9. package/dist/cjs/index.d.ts +1 -1
  10. package/dist/cjs/index.d.ts.map +1 -1
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/query-keys.d.ts +5 -0
  13. package/dist/cjs/query-keys.d.ts.map +1 -1
  14. package/dist/cjs/query-keys.js +5 -0
  15. package/dist/cjs/query-keys.js.map +1 -1
  16. package/dist/cjs/resources/addresses.d.ts +47 -4
  17. package/dist/cjs/resources/addresses.d.ts.map +1 -1
  18. package/dist/cjs/resources/addresses.js +38 -3
  19. package/dist/cjs/resources/addresses.js.map +1 -1
  20. package/dist/cjs/resources/admin.d.ts +20 -1
  21. package/dist/cjs/resources/admin.d.ts.map +1 -1
  22. package/dist/cjs/resources/admin.js +21 -0
  23. package/dist/cjs/resources/admin.js.map +1 -1
  24. package/dist/cjs/resources/registries.d.ts +26 -1
  25. package/dist/cjs/resources/registries.d.ts.map +1 -1
  26. package/dist/cjs/resources/registries.js +26 -1
  27. package/dist/cjs/resources/registries.js.map +1 -1
  28. package/dist/cjs/resources/transfers.d.ts +20 -0
  29. package/dist/cjs/resources/transfers.d.ts.map +1 -1
  30. package/dist/cjs/resources/transfers.js +20 -0
  31. package/dist/cjs/resources/transfers.js.map +1 -1
  32. package/dist/cjs/version.d.ts +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/generated/operations.d.ts +24 -0
  35. package/dist/esm/generated/operations.d.ts.map +1 -1
  36. package/dist/esm/generated/operations.js +26 -2
  37. package/dist/esm/generated/operations.js.map +1 -1
  38. package/dist/esm/generated/types.d.ts +167 -3
  39. package/dist/esm/generated/types.d.ts.map +1 -1
  40. package/dist/esm/index.d.ts +1 -1
  41. package/dist/esm/index.d.ts.map +1 -1
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/esm/query-keys.d.ts +5 -0
  44. package/dist/esm/query-keys.d.ts.map +1 -1
  45. package/dist/esm/query-keys.js +5 -0
  46. package/dist/esm/query-keys.js.map +1 -1
  47. package/dist/esm/resources/addresses.d.ts +47 -4
  48. package/dist/esm/resources/addresses.d.ts.map +1 -1
  49. package/dist/esm/resources/addresses.js +38 -3
  50. package/dist/esm/resources/addresses.js.map +1 -1
  51. package/dist/esm/resources/admin.d.ts +20 -1
  52. package/dist/esm/resources/admin.d.ts.map +1 -1
  53. package/dist/esm/resources/admin.js +21 -0
  54. package/dist/esm/resources/admin.js.map +1 -1
  55. package/dist/esm/resources/registries.d.ts +26 -1
  56. package/dist/esm/resources/registries.d.ts.map +1 -1
  57. package/dist/esm/resources/registries.js +26 -1
  58. package/dist/esm/resources/registries.js.map +1 -1
  59. package/dist/esm/resources/transfers.d.ts +20 -0
  60. package/dist/esm/resources/transfers.d.ts.map +1 -1
  61. package/dist/esm/resources/transfers.js +20 -0
  62. package/dist/esm/resources/transfers.js.map +1 -1
  63. package/dist/esm/version.d.ts +1 -1
  64. package/dist/esm/version.js +1 -1
  65. package/docs/concepts.md +9 -0
  66. package/docs/errors.md +45 -5
  67. package/package.json +1 -1
  68. package/src/generated/operations.ts +26 -2
  69. package/src/generated/types.ts +172 -3
  70. package/src/index.ts +1 -0
  71. package/src/query-keys.ts +6 -0
  72. package/src/resources/addresses.ts +53 -3
  73. package/src/resources/admin.ts +25 -0
  74. package/src/resources/registries.ts +26 -1
  75. package/src/resources/transfers.ts +20 -0
  76. package/src/version.ts +1 -1
package/docs/errors.md CHANGED
@@ -117,9 +117,15 @@ the authentication middleware with `UNAUTHENTICATED`.
117
117
  | `IDEMPOTENCY_KEY_REUSED` | 409 | The `idempotencyKey` already belongs to a different transfer: another sending address, recipient, amount, asset or network — their names are in `details.fields` (the amount is compared by value, `1.5` equals `1.50`); or it was used by another person or in another vault, and then there is no `details`. Nothing was created or moved. | Not a replay — a key reused for a new attempt. A new transfer needs a new key; a retry of the same transfer needs the old key with the same body. |
118
118
  | `APPROVAL_FAILED` | 409 | The approval request could not be created for some other reason. The reserve has already been returned, so no funds are stuck. | Retry once with a **new** idempotency key. If it repeats, it is a server-side fault — escalate. |
119
119
  | `VAULT_HAS_NO_WALLET_SERVICE` | 500 | The vault has no `walletServiceUrl` configured. | Configuration fault, not a user error. Transfers from this vault cannot work at all. Contact an administrator. |
120
+ | `ONCHAIN_BALANCE_UNAVAILABLE` | 409 | For a token whose balance is checked on the network before sending (A7A5): the network did not answer, so the transfer was not sent. A definite refusal — the transfer is `failed`, the reserve is returned. 409 and not 5xx on purpose: nothing is uncertain. | Retry with a **new** idempotency key a little later. |
121
+ | `SIGNER_PATH_UNSUPPORTED` | 409 | The sending address has a derivation path the signing service cannot use — deeper than 10 levels, or outside `m/44/195/…` and `m/44/60/…`. Checked before energy is bought; the transfer is `failed`, the reserve is returned. For an approved transfer it comes as `applyError` on the vote. | Do not retry: the address cannot send until an administrator changes the signing service. Receiving on it still works. |
122
+ | `INSUFFICIENT_GAS` | 400 | Ethereum, where the sending address pays the network fee itself, in the network's coin (ETH): the address does not hold enough of it, however much of the token is there. `message` says how much is missing and the fee ceiling. A definite refusal — nothing was sent, the transfer is `failed`, the reserve is returned. For an approved transfer the vote answers `failed` with this text in `executionError.message`. | Ask to top up the address with the coin, then send again with a **new** idempotency key. `addresses.gas()` shows the coin balance, and whether it covers a given transfer, before anything is sent. |
123
+ | `ADDRESS_BUSY` | 409 | Ethereum: transactions of one address go out strictly one at a time, and an earlier transfer from this address is at the signing service, has an unknown outcome, or its transaction is not in a block yet. A definite refusal — nothing was sent, the transfer is `failed`, the reserve is returned. An approved transfer does not wait either: the vote answers `failed`, the reason in `executionError.message`. | Retry with a **new** idempotency key once the earlier transfer is settled — usually within a minute; one with an unknown outcome waits for an administrator's reconciliation. An approved transfer has to be created anew. |
124
+ | `ONCHAIN_STATE_UNAVAILABLE` | 409 | Ethereum: the network node did not answer when the state of the sending address was read, so the transfer was not sent — `failed`, the reserve is returned. 409 and not 5xx on purpose: nothing is uncertain. The same code answers a reconciliation that could not read the chain and `registries.createToken()` that could not read the contract — nothing changed in either; `addresses.gas()` answers it with 502. | Retry a little later; a transfer — with a **new** idempotency key. |
125
+ | `NETWORK_NOT_READY` | 409 | The network of the sending address is not set up for sending: no `chainId` in the registry, no node to read the chain from, or the token is recorded without a contract. The transfer is `failed`, the reserve is returned. Also from `addresses.create()`, `addresses.gas()` and `registries.createToken()` — see [Addresses](#addresses) and [Network and token registries](#network-and-token-registries). | Not a retry: a configuration gap an administrator has to close. |
120
126
  | `GAS_STATION_FAILED` | 502 | Energy/bandwidth provisioning failed. The transfer is marked `failed` and the reserve is already returned. | Retry with a **new** idempotency key (the old one is bound to the failed row). If it persists, an upstream service is down. |
121
- | `WALLET_SERVICE_ERROR` | 400 | The signing service refused the request (answered 4xx). A definite refusal: the transfer is `failed` and the reserve is returned. Every other failure of the signing service is `TRANSFER_OUTCOME_UNKNOWN`, not this. | A retry will fail identically. `message` gives only the service's status (`Wallet Service returned 400`): its own body is not echoed to clients, it goes to the worker log. Show that the signing service refused and report it; do not try to explain the refusal from `message`. A new attempt needs a new key. |
122
- | `TRANSFER_OUTCOME_UNKNOWN` | 502 | The signing service gave no definite answer — none within 60 s, a broken connection, a 5xx or 524, or a 2xx without a transaction id — so the transaction may or may not have reached the network. The transfer stays `pending` with the funds reserved; `details` is `{transactionId, status: "pending"}`. An administrator's reconciliation settles it. | **Neither a refusal nor a success.** Show that the outcome is being established. **Never retry with a new key** — that can send the money twice. A retry with the same key answers 200 (`replayed`) with the transfer as it stands and does not execute it again. Follow the transfer by `details.transactionId`. |
127
+ | `WALLET_SERVICE_ERROR` | 400 | The signing service refused the request. A definite refusal: nothing reached the network, the transfer is `failed` and the reserve is returned. It answered 4xx — or, with the unified signing service, said itself that the transaction never reached the network: the node rejected it before its pool, or a step before sending failed (reading the balance, building, signing). Every other failure of the signing service is `TRANSFER_OUTCOME_UNKNOWN`, not this. | A retry of the same request will usually fail identically. `message` starts with the service's status (`Wallet Service returned 400`). With the unified signing service it continues with the service's own reason — `: Insufficient TRC20 balance`, `: Failed to broadcast transaction — CONTRACT_VALIDATE_ERROR: …` — at most 300 characters; show it as the reason. With the older service the status is all there is: its body is not echoed, it goes to the worker log. A new attempt needs a new key. |
128
+ | `TRANSFER_OUTCOME_UNKNOWN` | 502 | The signing service gave no definite answer — none within 60 s, a broken connection, a 5xx or 524 that does not say the transaction never reached the network, a 409 (the transfer's key is already in use at the service), or a 2xx without a transaction id — so the transaction may or may not have reached the network. The transfer stays `pending` with the funds reserved; `details` is `{transactionId, status: "pending"}`. An administrator's reconciliation settles it. | **Neither a refusal nor a success.** Show that the outcome is being established. **Never retry with a new key** — that can send the money twice. A retry with the same key answers 200 (`replayed`) with the transfer as it stands and does not execute it again. Follow the transfer by `details.transactionId`. |
123
129
  | `TRANSFER_BROADCAST_UNRECORDED` | 502 | The transaction went to the network (`details.txHash`), but by then reconciliation had already returned its reserve, so the send is not recorded in the ledger. | **The money left — do not retry.** An administrator has to post a correcting entry; report the hash. |
124
130
  | `TRANSFER_NOT_EXECUTABLE` | 404 / 409 / 500 | The transfer is missing, or is not in the status execution requires. | Re-read the transfer and drive the UI from its real status. Do not retry. |
125
131
 
@@ -142,17 +148,22 @@ the authentication middleware with `UNAUTHENTICATED`.
142
148
 
143
149
  A `pending` transfer is decided by the hash: with `txHash` it is driven to `confirmed`; without one the reserve is returned (`failed`) — that is the reconciler's statement that nothing was broadcast, not something the server checks. So for a `pending` transfer with no hash, look on the chain from the sending address first: returning the reserve of a transaction that did go out creates money. A `pending` transfer that already has a hash saved from the signing service is settled only by that hash, sent explicitly. The other two cases never executed: they take no hash, and the reserve is returned.
144
150
 
151
+ On Ethereum the server does check the chain, for a `pending` transfer that reached the signing service. Without `txHash` the reserve is returned only if the network shows that no transaction has left the address since then — none in a block, none in the node's queue; otherwise 409 `BROADCAST_DETECTED`. With `txHash` the transaction has to be from the transfer's address, not older than the transfer, and already in a block. A transaction the contract reverted settles the transfer as `failed` **with** that `txHash`, the reserve returned: the answer's `status` is `failed`, not `confirmed`, so read it. One gap is left without a hash: a transaction that is in no block and not in the node's queue can still be delivered by someone else, until the address's next transaction takes its number. So prefer waiting for the hash to reconciling without one.
152
+
145
153
  | Code | Status | When | What to do |
146
154
  |---|---|---|---|
147
155
  | `TRANSFER_STILL_EXECUTING` | 409 | The transfer changed less than 10 minutes ago (`updatedAt`). An unknown outcome counts as a change: the clock starts when execution stopped waiting for the signing service. | **This is "wait", not "no".** Execution may still be in flight; intervening now risks a second broadcast. Back off and offer the action again after the window. See [Easily confused](#easily-confused). |
148
156
  | `TRANSFER_NOT_STUCK` | 409 | Nothing to reconcile: the transfer is in none of the states above (an `awaiting_approval` one still has a live request, a closed one holds no reserve), or another path changed it while you were reconciling. | Re-read it. It resolved itself, or it is closed by a vote or a cancel; nothing to do here. |
149
157
  | `RESERVE_ALREADY_CONSUMED` | 409 | Without `txHash`: a `confirm` posting has already spent the reserve — the transaction went to the network. With `txHash`: the reserve was returned in parallel, for instance by a reconciliation without a hash. | Without a hash: **never retry as a release.** The money left. Finish the transfer by supplying its `txHash` instead. With a hash: re-read the transfer. |
150
158
  | `TRANSFER_BROADCAST` | 409 | No `txHash` sent, but the `pending` transfer has a hash saved from the signing service — it went to the network. `details.txHash` is that hash. Nothing moved. | Reconcile again with that `txHash`. Never as a release. |
151
- | `TXHASH_MISMATCH` | 409 | The `txHash` differs from the hash saved on the transfer, which is in `details.txHash`. Nothing moved. | Check the hash. The saved one came from the signing service. |
159
+ | `TXHASH_MISMATCH` | 409 | The `txHash` differs from the hash saved on the transfer, which is in `details.txHash`. On Ethereum also: the transaction was sent from another address, or from this one before the transfer — it belongs to another transfer; no `details`. Nothing moved. | Check the hash. The saved one came from the signing service. |
152
160
  | `TXHASH_IN_USE` | 409 | The `txHash` is already recorded on another transfer. Nothing moved. | Almost certainly the wrong hash. Check it. |
153
161
  | `TRANSFER_NOT_EXECUTED` | 409 | `txHash` sent for a transfer that never executed — `awaiting_approval`, or closed with its reserve still held. | Reconcile without `txHash`; the reserve is returned. |
154
162
  | `RESERVE_MISSING` | 409 | `txHash` sent for a transfer whose funds were never reserved, so it cannot have executed. | Reconcile without `txHash`; it closes as `failed` with no money moved. |
155
163
  | `RESERVE_RELEASED` | 409 | `txHash` sent, but the reserve had already been returned: on a `pending` transfer the returned funds are already spent and the send cannot be charged to them; a closed transfer is not confirmed by reconciliation at all. Nothing moved. | An administrator has to post a correcting entry. Escalate. |
164
+ | `INVALID_TXHASH` | 400 | Ethereum: `txHash` is not a transaction hash — `0x` and 64 hex digits (the `0x` may be omitted, the case does not matter). Nothing moved. | Fix the hash. |
165
+ | `TX_NOT_INCLUDED` | 409 | Ethereum: the network does not know the transaction, or it is not in a block yet. Nothing moved. | Check the hash; if it is right, wait for the block and reconcile again. |
166
+ | `BROADCAST_DETECTED` | 409 | Ethereum, no `txHash` sent: since the transfer went to the signing service a transaction from its address got into a block, or one is in the node's queue — the transfer's own. The reserve is not returned; `details.address` is the sending address. Nothing moved. | Find the transaction of that address in a block explorer and reconcile with its `txHash`; one still in the queue — after it gets into a block. Never as a release. |
156
167
 
157
168
  ### Transfer drafts
158
169
 
@@ -225,7 +236,8 @@ Two sets of uppercase strings travel inside **successful** bodies and will misle
225
236
  |---|---|---|---|
226
237
  | `CONCURRENCY_CONFLICT` | 409 | A unique derivation index could not be allocated after 3 attempts — too many simultaneous creations. | **Retry.** This is the one conflict here where a plain retry is the correct answer. |
227
238
  | `NETWORK_NOT_IN_VAULT` | 400 | The network is not connected to this vault. | Offer only the vault's own networks. Terminal otherwise. |
228
- | `NETWORK_NOT_MONITORED` | 400 | The network has no deposit monitoring — only TRON has it — so no address is created on it. Checked before the signing service and before any approval request; `details.network` names it. (Until 2026-11-22 such an address was created and registered with TRON's monitoring, which never watched it.) | Offer only monitored networks for new addresses. Terminal otherwise. |
239
+ | `NETWORK_NOT_MONITORED` | 400 | The network has no deposit monitoring, so no address is created on it: TRON has it; an EVM network (Ethereum) has it once the API is connected to that network's monitoring. Checked before the signing service and before any approval request; `details.network` names it. (Until 2026-11-22 such an address was created and registered with TRON's monitoring, which never watched it.) | Offer only monitored networks for new addresses. Terminal otherwise. |
240
+ | `NETWORK_NOT_READY` | 409 | An EVM network in a vault whose signing service cannot derive EVM addresses. Checked before the policy and before any approval request; nothing was created. `details.network` names it. | Not a retry: an administrator has to move the vault to a signing service that supports the network. |
229
241
  | `IDEMPOTENCY_KEY_REUSED` | 409 | The `idempotencyKey` was already used for an attempt with another body. | Not a replay. A new address needs a new key; a retry of the same one needs the old key with the same body. |
230
242
  | `IDEMPOTENCY_KEY_IN_PROGRESS` | 409 | The attempt with this key went for approval, the request was approved, and the address is being created right now. | Wait and retry with the same key and body: it then answers 200 (`replayed`) with the address. |
231
243
  | `IDEMPOTENCY_KEY_CLOSED` | 409 | The attempt with this key went for approval and the request closed without an address — rejected, cancelled, or it failed to apply. `details` has `{approvalRequestId, requestStatus}`. | The outcome is settled. A new attempt needs a new key. |
@@ -238,6 +250,7 @@ Two sets of uppercase strings travel inside **successful** bodies and will misle
238
250
  | `VAULT_NOT_FOUND` | 404 | The vault code does not resolve. | A client bug or a deleted vault. |
239
251
  | `VAULT_HAS_NO_WALLET_SERVICE` | 500 | No `walletServiceUrl` on the vault. | Configuration fault. Contact an administrator. |
240
252
  | `NO_DYNAMIC_ROUTE` | 500 | The vault's derivation scheme has no incrementing segment. | Configuration fault — address creation is impossible in this vault until an admin fixes it. |
253
+ | `DERIVATION_PATH_UNSUPPORTED` | 409 | The vault's routes give a derivation path the signing service cannot use — deeper than 10 levels, or outside `m/44/195/…` and `m/44/60/…`. Checked before the policy and before any approval request; nothing was created. `details` has `{derivationPath, network, maxDepth}`. | Do not retry — the next index gives the same depth. An administrator has to shorten the vault's route configuration (fewer segments). |
241
254
  | `TOKEN_NOT_REGISTERED` | 500 | An asset segment points at a token missing from the registry. | Configuration fault. Contact an administrator. |
242
255
  | `POLICY_DENIED` | 403 | `block`, or no policy permits `create_address`. `details` holds the decision. | Terminal. Show `message`. |
243
256
  | `APPROVAL_UNSATISFIABLE` | 409 | `create_address` requires signatures, but fewer people can give them than the threshold asks for (the initiator does not count unless the policy allows approving one's own request). Neither the address nor an approval request was created. Unlike the transfer's, it carries no `details`. | **Do not retry.** An administrator has to change the policy or the approver group. See [Easily confused](#easily-confused). |
@@ -257,6 +270,33 @@ Creating an address **into a folder** (`groupId`) can succeed without the folder
257
270
 
258
271
  The same three arrive in `applyWarnings` of a **200** vote that applied an approved `create_address`: there the folder is checked when the request is applied, not when it was filed, and the request's history gets a `folder_skipped` event. Nothing is thrown in either case, so read the field. The address is fine; do not show it inside the folder.
259
272
 
273
+ ### Gas of an address
274
+
275
+ `addresses.gas()` — `GET /addresses/{id}/gas`. Reads the network at the moment of the call; nothing is changed. `estimate: null` in a 200 is not an error: the fee could not be computed (the node did not answer, or the address does not hold the token amount itself).
276
+
277
+ | Code | Status | When | What to do |
278
+ |---|---|---|---|
279
+ | `GAS_QUERY_INCOMPLETE` | 400 | `to`, `asset` and `amount` were not passed all together. | A client bug: pass the three, or none for the balance alone. |
280
+ | `NETWORK_NOT_READY` | 409 | The address's network is not set up for reading the chain — no `chainId`, or no node. | Configuration gap; hide the gas line until an administrator closes it. |
281
+ | `ONCHAIN_STATE_UNAVAILABLE` | 502 | The network node did not answer. | Retry. Do not show a zero balance in the meantime. |
282
+
283
+ With the three parameters the transfer is checked as a send would check it, with the same codes: `TOKEN_NOT_FOUND`, `TOKEN_NETWORK_MISMATCH`, `INVALID_DESTINATION_ADDRESS`, `INVALID_AMOUNT` (all 400). An address you cannot view is 404.
284
+
285
+ ## Network and token registries
286
+
287
+ `registries.createNetwork()`, `registries.updateNetwork()`, `registries.createToken()` — administrators only. The network checks have no code of their own (400 `BAD_REQUEST` with the reason in `message`): an EVM network without `chainId`, `chainId` or `nativeSymbol` on a network that is not EVM, a `chainId` already taken; changing `chainId` of a network that has addresses is a 409.
288
+
289
+ A token of an EVM network:
290
+
291
+ | Code | Status | When | What to do |
292
+ |---|---|---|---|
293
+ | `EVM_NATIVE_NOT_SUPPORTED` | 400 | `isNative: true` on an EVM network. The network's coin (ETH) is what addresses pay the fee in; it is not an asset of the vault, has no balance in the ledger and is not sent or credited. | Do not register it. Its balance on an address is `addresses.gas()`. |
294
+ | `TOKEN_DECIMALS_UNSUPPORTED` | 400 | `decimals` above 9: the ledger keeps amounts in 64-bit integers, and such a token would overflow it. | The token cannot be supported. Terminal. |
295
+ | `INVALID_CONTRACT_ADDRESS` | 400 | `contractAddress` is not an EVM address (`0x` + 40 hex, the EIP-55 checksum when mixed-case), or there is no token contract at it on this network — it does not answer `decimals()`. | Fix the address; check the network. |
296
+ | `TOKEN_DECIMALS_MISMATCH` | 400 | `decimals` differs from what the contract itself reports; `message` has both numbers. Refused because the signing service converts amounts by the contract and the ledger by the registry — a difference would send 10^k times what was booked, and `decimals` cannot be edited afterwards. | Send the contract's number. |
297
+ | `NETWORK_NOT_READY` | 409 | The network has no `chainId` or no node to read from, so `decimals` cannot be checked against the contract. The token was not created. | Finish the network's configuration first. |
298
+ | `ONCHAIN_STATE_UNAVAILABLE` | 409 | The node did not answer; `decimals` was not checked and the token was not created. | Retry. |
299
+
260
300
  ## Grants and sharing
261
301
 
262
302
  Address shares, folder shares, member-visibility grants. All grant `POST`s are idempotent: repeating a pair changes the rights, and a revoked grant is reactivated. There is no `GRANT_EXISTS` anywhere.
@@ -591,7 +631,7 @@ One more is named because the API documents it: `VALIDATION_ERROR`, the library'
591
631
 
592
632
  A changing request (`POST`, `PUT`, `PATCH`, `DELETE`) to `/api/v1/*` from a page of a site the API does not trust is refused before anything else with 403 `CROSS_SITE_REQUEST_REFUSED` — an `Origin` outside the trusted list (`Origin: null` included), or no `Origin` with `Sec-Fetch-Site: cross-site`. The session cookie is `SameSite=None`, so without this a foreign page could act with it. Native clients and servers send no `Origin` and are not affected; a web client gets it only when served from an origin the API was not told about — a configuration fix, not a retry.
593
633
 
594
- `/webhooks/wallet` is the signing service's inbound channel, not a client endpoint; its 401 `WEBHOOK_UNAUTHORIZED` (a signature missing or wrong while the secret is configured) is for that service.
634
+ `/webhooks/wallet` is the signing service's inbound channel, not a client endpoint; its 401 `WEBHOOK_UNAUTHORIZED` (a signature missing or wrong while the secret is configured) is for that service. `/webhooks/monitoring` is the same for the deposit monitoring of EVM networks: 401 `WEBHOOK_UNAUTHORIZED` on a missing or wrong signature, and 503 `WEBHOOK_NOT_CONFIGURED` while the API has no secret for it — no event is accepted unsigned.
595
635
 
596
636
  Three refusals the API puts **in front of** the library are its own: they arrive in the API's envelope, and their codes can be branched on.
597
637
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v3finance/core-sdk",
3
- "version": "0.20.1",
3
+ "version": "0.22.0",
4
4
  "description": "The official TypeScript SDK for the V3 Finance Core API — custodial addresses, transfers under policy control, approvals, shared access, labelling and reports",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,8 +8,8 @@
8
8
  // resource method calls an operation that exists, and that a new endpoint in
9
9
  // the API does not slip in unclassified.
10
10
  //
11
- // Operations: 255 · admin: 45 · both: 1 · member: 206 · service: 3
12
- // Spec sha256: 0229b7952a998cd70aecbf79c9dab66a5c8f9e122f12d65123c819589a70fee2
11
+ // Operations: 258 · admin: 46 · both: 1 · member: 207 · service: 4
12
+ // Spec sha256: 124ba1ba93348e18e6998662349a7b5016f15f655c7f9bbeead84f98307f5984
13
13
 
14
14
  export type Audience = 'member' | 'admin' | 'service' | 'both' | 'unknown'
15
15
 
@@ -280,6 +280,14 @@ export const OPERATIONS = {
280
280
  "summary": "On-chain адреса, заведённые в нескольких Vault'ах",
281
281
  "audience": "admin"
282
282
  },
283
+ "GET /api/v1/admin/addresses/signer-check": {
284
+ "method": "get",
285
+ "path": "/api/v1/admin/addresses/signer-check",
286
+ "operationId": "getApiV1AdminAddressesSignerCheck",
287
+ "tag": "Admin",
288
+ "summary": "Сверка адресов с подписывающим сервисом",
289
+ "audience": "admin"
290
+ },
283
291
  "GET /api/v1/aml/providers": {
284
292
  "method": "get",
285
293
  "path": "/api/v1/aml/providers",
@@ -544,6 +552,14 @@ export const OPERATIONS = {
544
552
  "summary": "Детали адреса",
545
553
  "audience": "member"
546
554
  },
555
+ "GET /api/v1/vaults/{code}/addresses/{id}/gas": {
556
+ "method": "get",
557
+ "path": "/api/v1/vaults/{code}/addresses/{id}/gas",
558
+ "operationId": "getApiV1VaultsByCodeAddressesByIdGas",
559
+ "tag": "Addresses",
560
+ "summary": "Газ адреса: остаток монеты сети и оценка комиссии",
561
+ "audience": "member"
562
+ },
547
563
  "GET /api/v1/vaults/{code}/addresses/{id}/logo": {
548
564
  "method": "get",
549
565
  "path": "/api/v1/vaults/{code}/addresses/{id}/logo",
@@ -2032,6 +2048,14 @@ export const OPERATIONS = {
2032
2048
  "summary": "Открыть видимость участников (admin)",
2033
2049
  "audience": "admin"
2034
2050
  },
2051
+ "POST /webhooks/monitoring": {
2052
+ "method": "post",
2053
+ "path": "/webhooks/monitoring",
2054
+ "operationId": "postWebhooksMonitoring",
2055
+ "tag": "Webhooks",
2056
+ "summary": "Событие мониторинга V3 Finance (TOPUP, EVM-сети)",
2057
+ "audience": "service"
2058
+ },
2035
2059
  "POST /webhooks/wallet": {
2036
2060
  "method": "post",
2037
2061
  "path": "/webhooks/wallet",
@@ -378,6 +378,53 @@ export interface IncomingTxSummary {
378
378
  assetSymbol: string
379
379
  }
380
380
 
381
+ export interface AddressGasQuery {
382
+ /**
383
+ * Получатель перевода, для которого нужна оценка комиссии
384
+ *
385
+ * length: 1..128
386
+ */
387
+ to?: string
388
+ /**
389
+ * Код токена перевода (Token.code)
390
+ *
391
+ * length: 1..64
392
+ */
393
+ asset?: string
394
+ /**
395
+ * Сумма перевода в целых единицах токена, десятичной строкой
396
+ *
397
+ * length: 1..64
398
+ */
399
+ amount?: string
400
+ }
401
+
402
+ export interface AddressGas {
403
+ /** Network.slug адреса */
404
+ network: string
405
+ /** Кто платит комиссию сети. `address` — сам адрес, своей монетой (Ethereum: нет ETH — перевод токена не уйдёт). `platform` — платформа (Tron): держать на адресе ничего не нужно, остальные поля — null */
406
+ payer: "address" | "platform"
407
+ /** Тикер монеты газа */
408
+ symbol: string | null
409
+ /** Знаков у монеты газа */
410
+ decimals: number | null
411
+ /** Остаток монеты газа на адресе, десятичной строкой. Читается из сети в момент запроса: монета газа в учёте не ведётся, в `balances[]` адреса её нет */
412
+ balance: string | null
413
+ /** Тот же остаток в wei */
414
+ balanceRaw: string | null
415
+ /** Когда остаток прочитан из сети */
416
+ checkedAt: string | null
417
+ /** Оценка комиссии. null — не запрошена (нет to/asset/amount) или посчитать не удалось: не ответил узел, либо на адресе нет самой суммы токена. null — НЕ значит «газа хватает» */
418
+ estimate: {
419
+ /** ПОТОЛОК комиссии запрошенного перевода в монете газа: столько должно лежать на адресе, чтобы перевод ушёл. Спишется обычно меньше */
420
+ fee: string
421
+ /** Тот же потолок в wei */
422
+ feeRaw: string
423
+ /** Хватает ли остатка на эту комиссию (тем же расчётом проверяет отправка) */
424
+ enough: boolean
425
+ } | null
426
+ }
427
+
381
428
  export interface AddressGroupDetail {
382
429
  /** cuid */
383
430
  id: string
@@ -1769,6 +1816,14 @@ export interface CreateNetworkBody {
1769
1816
  logoUri?: string
1770
1817
  /** Тип сети, напр. "TRON", "EVM" */
1771
1818
  type?: string
1819
+ /**
1820
+ * Номер EVM-сети (EIP-155). ОБЯЗАТЕЛЕН для EVM-сети (Ethereum — 1) и запрещён для остальных
1821
+ *
1822
+ * range: 1..9007199254740991
1823
+ */
1824
+ chainId?: number
1825
+ /** Тикер монеты газа EVM-сети (ETH). Только для EVM-сетей */
1826
+ nativeSymbol?: string
1772
1827
  }
1773
1828
 
1774
1829
  export interface CreateOperationCategoryBody {
@@ -3047,6 +3102,36 @@ export interface Membership {
3047
3102
  createdAt: string
3048
3103
  }
3049
3104
 
3105
+ export interface MonitoringWebhookBody {
3106
+ tx: {
3107
+ /** Имя сети у мониторинга, ПРОПИСНЫМИ; в нижнем регистре обязано совпадать со `slug` сети в реестре */
3108
+ network: string
3109
+ /** Тикер; токен определяется по `contract`, не по нему */
3110
+ asset: string
3111
+ /** Адрес контракта токена или `native` (монета сети — не зачисляется) */
3112
+ contract: string
3113
+ type: "TOPUP"
3114
+ /** Хеш транзакции (EVM — с `0x`) */
3115
+ id: string
3116
+ /** range: -9007199254740991..9007199254740991 */
3117
+ block: number
3118
+ /** МИЛЛИСЕКУНДЫ (не секунды) */
3119
+ timestamp: number
3120
+ from: string
3121
+ to: string
3122
+ /** raw smallest units; только цифры, > 0 и ≤ 10^17 */
3123
+ value: string
3124
+ /**
3125
+ * Место перевода в блоке (EVM): различает одинаковые переводы одной транзакции
3126
+ *
3127
+ * range: 0..9007199254740991
3128
+ */
3129
+ logIndex?: number
3130
+ }
3131
+ /** Только у пробного события — оно не зачисляется */
3132
+ test?: true
3133
+ }
3134
+
3050
3135
  export interface MySessionList {
3051
3136
  items: MySession[]
3052
3137
  nextCursor: string | null
@@ -3103,6 +3188,10 @@ export interface Network {
3103
3188
  logoUri: string | null
3104
3189
  /** Тип сети (свободная строка) */
3105
3190
  type: string | null
3191
+ /** Номер EVM-сети (EIP-155): Ethereum — 1. null — у не-EVM сетей. По нему подписывающий сервис выбирает сеть: путь у всех EVM-сетей один */
3192
+ chainId: number | null
3193
+ /** Тикер монеты, которой адрес сам платит за газ (ETH). null — газ не оплачивается с адреса (Tron: ресурсы покупает платформа). Монета газа — не актив учёта: её остаток — `GET …/addresses/{id}/gas` */
3194
+ nativeSymbol: string | null
3106
3195
  /** format: date-time */
3107
3196
  createdAt: string
3108
3197
  /** format: date-time */
@@ -3480,7 +3569,7 @@ export interface PatchGroupGrantBody {
3480
3569
  canCreateAddress?: boolean
3481
3570
  }
3482
3571
 
3483
- /** Частичное обновление метаданных сети (admin). coinType/code/slug неизменяемы — на них ссылаются адреса, токены и webhook-матчинг */
3572
+ /** Частичное обновление метаданных сети (admin). coinType/code/slug неизменяемы — на них ссылаются адреса, токены и webhook-матчинг; chainId — только пока в сети нет адресов */
3484
3573
  export interface PatchNetworkBody {
3485
3574
  /** length: 1..∞ */
3486
3575
  name?: string
@@ -3489,6 +3578,14 @@ export interface PatchNetworkBody {
3489
3578
  logoUri?: string | null
3490
3579
  /** Тип сети, напр. "TRON", "EVM"; null — очистить */
3491
3580
  type?: string | null
3581
+ /**
3582
+ * Номер EVM-сети. Задать или сменить можно, только пока в сети нет адресов: тот же ключ в другой цепи — другой счёт
3583
+ *
3584
+ * range: 1..9007199254740991
3585
+ */
3586
+ chainId?: number
3587
+ /** Тикер монеты газа; null — очистить */
3588
+ nativeSymbol?: string | null
3492
3589
  }
3493
3590
 
3494
3591
  export interface PatchOperationCategoryBody {
@@ -4042,7 +4139,7 @@ export interface ReconcileLegacyMetadataResult {
4042
4139
  }
4043
4140
 
4044
4141
  export interface ReconcileTransferBody {
4045
- /** Хеш от подписывающего сервиса. ЕСТЬ — транзакция ушла в сеть, перевод доводится до confirmed. НЕТ (или null) — сверяющий утверждает, что broadcast'а не было, и резерв возвращается (failed). Для pending с неясным исходом (у pending без txHash его не отличить по ответам API — failureReason у незакрытого перевода null) это утверждение нужно ПРОВЕРИТЬ по сети: возврат за ушедшую транзакцию печатает деньги. Если у pending-перевода хеш уже сохранён (broadcast прошёл), он обязателен: без него — 409 TRANSFER_BROADCAST, с другим — 409 TXHASH_MISMATCH (сохранённый — в error.details.txHash) */
4142
+ /** Хеш от подписывающего сервиса. ЕСТЬ — транзакция ушла в сеть, перевод доводится до confirmed. НЕТ (или null) — сверяющий утверждает, что broadcast'а не было, и резерв возвращается (failed). Для pending с неясным исходом (у pending без txHash его не отличить по ответам API — failureReason у незакрытого перевода null) это утверждение нужно ПРОВЕРИТЬ по сети: возврат за ушедшую транзакцию печатает деньги. Если у pending-перевода хеш уже сохранён (broadcast прошёл), он обязателен: без него — 409 TRANSFER_BROADCAST, с другим — 409 TXHASH_MISMATCH (сохранённый — в error.details.txHash). EVM-сети: сервер проверяет сеть сам — без хеша резерв возвращается, только если транзакции перевода нет ни в блоке, ни в очереди узла (иначе 409 BROADCAST_DETECTED); с хешем перевод подтверждается, только если транзакция отправлена с адреса перевода и уже в блоке (иначе 409 TX_NOT_INCLUDED / TXHASH_MISMATCH, не хеш — 400 INVALID_TXHASH). Хеш EVM принимается с `0x` и без, в любом регистре */
4046
4143
  txHash?: string | null
4047
4144
  /** DEPRECATED: пишется в legacy-поле `fee` перевода как есть (свободный текст, единица не определена). На `networkFee` (комиссию сети) это поле не влияет */
4048
4145
  fee?: string | null
@@ -4053,6 +4150,7 @@ export interface ReconcileTransferBody {
4053
4150
  export interface ReconcileTransferResult {
4054
4151
  /** Статус перевода после сверки: confirmed (по хешу) | failed (резерв возвращён). rejected/cancelled — у закрытого перевода с невозвращённым резервом: резерв возвращён, статус прежний */
4055
4152
  status: "confirmed" | "failed" | "rejected" | "cancelled"
4153
+ /** Хеш транзакции перевода. У confirmed — всегда. У failed — null, кроме EVM-перевода, чья транзакция попала в блок, но отклонена контрактом (revert): перевода в сети не было, резерв возвращён, хеш оставлен как след */
4056
4154
  txHash: string | null
4057
4155
  }
4058
4156
 
@@ -4091,6 +4189,10 @@ export interface RegistryNetwork {
4091
4189
  logoUri: string | null
4092
4190
  /** Тип сети (свободная строка) */
4093
4191
  type: string | null
4192
+ /** Номер EVM-сети (EIP-155): Ethereum — 1. null — у не-EVM сетей. По нему подписывающий сервис выбирает сеть: путь у всех EVM-сетей один */
4193
+ chainId: number | null
4194
+ /** Тикер монеты, которой адрес сам платит за газ (ETH). null — газ не оплачивается с адреса (Tron: ресурсы покупает платформа). Монета газа — не актив учёта: её остаток — `GET …/addresses/{id}/gas` */
4195
+ nativeSymbol: string | null
4094
4196
  /** format: date-time */
4095
4197
  createdAt: string
4096
4198
  /** format: date-time */
@@ -4256,6 +4358,73 @@ export interface SharedAddressList {
4256
4358
  }>
4257
4359
  }
4258
4360
 
4361
+ export interface SignerCheckQuery {
4362
+ /**
4363
+ * Код Vault'а; пусто — все Vault'ы
4364
+ *
4365
+ * length: 1..∞
4366
+ */
4367
+ vault?: string
4368
+ /**
4369
+ * Адресов за вызов (каждый — один запрос к сайнеру)
4370
+ *
4371
+ * range: 1..40
4372
+ * @defaultValue 25
4373
+ */
4374
+ limit?: number
4375
+ /**
4376
+ * `nextCursor` предыдущей страницы
4377
+ *
4378
+ * length: 1..∞
4379
+ */
4380
+ cursor?: string
4381
+ }
4382
+
4383
+ export interface SignerCheckResult {
4384
+ /**
4385
+ * Сколько адресов спрошено у сайнера на этой странице
4386
+ *
4387
+ * range: -9007199254740991..9007199254740991
4388
+ */
4389
+ checked: number
4390
+ /**
4391
+ * Сайнер вывел тот же адрес, что записан в базе
4392
+ *
4393
+ * range: -9007199254740991..9007199254740991
4394
+ */
4395
+ matched: number
4396
+ /** Сайнер вывел ДРУГОЙ адрес: ключ сайнера не тот, под которым создавался адрес. Хотя бы одна строка здесь — переводы с этих адресов подписать нечем */
4397
+ mismatched: Array<{
4398
+ addressId: string
4399
+ vaultCode: string
4400
+ network: string
4401
+ derivationPath: string
4402
+ /** Адрес, записанный в базе */
4403
+ address: string
4404
+ /** Что вывел сайнер */
4405
+ derived: string
4406
+ }>
4407
+ /** Сайнер не ответил адресом (недоступен, путь не поддерживается) */
4408
+ failed: Array<{
4409
+ addressId: string
4410
+ vaultCode: string
4411
+ network: string
4412
+ derivationPath: string
4413
+ /** Адрес, записанный в базе */
4414
+ address: string
4415
+ /** HTTP-статус сайнера; null — ответа не было */
4416
+ status: number | null
4417
+ reason: string
4418
+ }>
4419
+ /**
4420
+ * Адреса Vault'ов без подписывающего сервиса
4421
+ *
4422
+ * range: -9007199254740991..9007199254740991
4423
+ */
4424
+ skipped: number
4425
+ nextCursor: string | null
4426
+ }
4427
+
4259
4428
  export interface Token {
4260
4429
  /** cuid */
4261
4430
  id: string
@@ -4823,7 +4992,7 @@ export type WebhookResult = {
4823
4992
  receivedAsset: string
4824
4993
  } | {
4825
4994
  ignored: true
4826
- reason: "trx_events_disabled" | "address_not_found" | "token_not_registered"
4995
+ reason: "trx_events_disabled" | "native_events_disabled" | "address_not_found" | "token_not_registered" | "test_event" | "wrong_endpoint"
4827
4996
  } | {
4828
4997
  duplicate: true
4829
4998
  eventId: string
package/src/index.ts CHANGED
@@ -87,6 +87,7 @@ export {
87
87
  AddressesResource,
88
88
  type AddressFilters,
89
89
  type AddressFacet,
90
+ type AddressGasParams,
90
91
  type AddressesSummaryParams,
91
92
  type ListAddressesParams,
92
93
  type PendingApproval,
package/src/query-keys.ts CHANGED
@@ -11,6 +11,12 @@ export const queryKeys = {
11
11
  addresses: (code: string, filters?: Record<string, unknown>) =>
12
12
  ['v3', 'vault', code, 'addresses', filters ?? null] as const,
13
13
  address: (code: string, id: string) => ['v3', 'vault', code, 'address', id] as const,
14
+ /**
15
+ * Under the address's own key on purpose: invalidating `address(code, id)`
16
+ * drops its gas too, and after a transfer from the address both are stale.
17
+ */
18
+ addressGas: (code: string, id: string, transfer?: Record<string, unknown>) =>
19
+ ['v3', 'vault', code, 'address', id, 'gas', transfer ?? null] as const,
14
20
  transfer: (code: string, id: string) => ['v3', 'vault', code, 'transfer', id] as const,
15
21
  history: (code: string, filters?: Record<string, unknown>) =>
16
22
  ['v3', 'vault', code, 'history', filters ?? null] as const,
@@ -3,6 +3,7 @@ import type { Page, PageParams } from '../core/pagination.js'
3
3
  import { toGated, type Gated } from '../core/gated.js'
4
4
  import type { Address, AddressDetail } from './types.js'
5
5
  import type {
6
+ AddressGas,
6
7
  AddressesSummary,
7
8
  CreateAddressBody,
8
9
  CreateAddressResult,
@@ -75,6 +76,19 @@ export interface ListAddressesParams extends AddressFilters, PageParams {
75
76
  sort?: 'createdAt' | 'lastActivity' | undefined
76
77
  }
77
78
 
79
+ /**
80
+ * The transfer `gas()` should estimate the fee of. All three together or none:
81
+ * a partial set is 400 `GAS_QUERY_INCOMPLETE`.
82
+ */
83
+ export interface AddressGasParams {
84
+ /** The recipient. */
85
+ to?: string | undefined
86
+ /** Token code: `usdt_eth`. */
87
+ asset?: string | undefined
88
+ /** The amount in whole units of the token, as a decimal string — what `transfers.send` takes. */
89
+ amount?: string | undefined
90
+ }
91
+
78
92
  /** What `summary()` can count by. */
79
93
  export type AddressFacet = keyof AddressesSummary['facets']
80
94
 
@@ -139,6 +153,39 @@ export class AddressesResource {
139
153
  return this.#http.request<AddressDetail>('GET', `${this.#base}/${seg(addressId)}`)
140
154
  }
141
155
 
156
+ /**
157
+ * Who pays the network fee for transfers from this address, and whether
158
+ * there is enough to pay it.
159
+ *
160
+ * `payer: 'platform'` (TRON) — the platform buys the resources, nothing has
161
+ * to be kept on the address, and every other field is `null`.
162
+ * `payer: 'address'` (Ethereum) — the address pays itself, in the network's
163
+ * coin (`symbol`, ETH): without it a token transfer does not leave, however
164
+ * much of the token is there, and `transfers.send` answers 400
165
+ * `INSUFFICIENT_GAS`. Show `balance` next to the token balances and check
166
+ * `estimate.enough` before offering to send.
167
+ *
168
+ * THE COIN IS NOT AN ASSET OF THE VAULT. `balance` is read from the network
169
+ * at the moment of the call (`checkedAt`); it is not in the address's
170
+ * `balances[]`, a top-up of it does not arrive as a deposit, and it cannot
171
+ * be sent with `transfers.send`.
172
+ *
173
+ * With `to`, `asset` and `amount` the answer carries `estimate` — the
174
+ * CEILING of the fee for that transfer, computed the way sending checks it;
175
+ * what is charged is usually less. `estimate: null` with all three passed is
176
+ * not a refusal: the fee could not be computed — the node did not answer, or
177
+ * the address does not hold the token amount itself.
178
+ *
179
+ * Needs the `view` right on the address (404 otherwise). 409
180
+ * `NETWORK_NOT_READY` — the network is not set up for reading the chain;
181
+ * 502 `ONCHAIN_STATE_UNAVAILABLE` — the node did not answer, ask again.
182
+ */
183
+ gas(addressId: string, params: AddressGasParams = {}): Promise<AddressGas> {
184
+ return this.#http.request<AddressGas>('GET', `${this.#base}/${seg(addressId)}/gas`, {
185
+ query: { ...params },
186
+ })
187
+ }
188
+
142
189
  /**
143
190
  * 201 — the address is ready (`applied`); 202 — it went for approval and a
144
191
  * request came back (`pending`); 200 — a replay of `idempotencyKey`
@@ -157,9 +204,12 @@ export class AddressesResource {
157
204
  * rolled back) does not consume the key. The key is per member of the
158
205
  * vault.
159
206
  *
160
- * Only TRON has deposit monitoring, so an address on any other network of
161
- * the vault is refused with 400 `NETWORK_NOT_MONITORED` before anything is
162
- * asked of the signing service.
207
+ * An address is created only on a network whose deposits are monitored:
208
+ * TRON, and an EVM network (Ethereum) once the API is connected to its
209
+ * monitoring. On any other network of the vault it is refused with 400
210
+ * `NETWORK_NOT_MONITORED` before anything is asked of the signing service;
211
+ * 409 `NETWORK_NOT_READY` — an EVM network in a vault whose signing service
212
+ * cannot derive EVM addresses.
163
213
  */
164
214
  async create(input: CreateAddressBody): Promise<Gated<CreateAddressResult, PendingApproval>> {
165
215
  const res = await this.#http.requestRaw<unknown>('POST', this.#base, { body: input })
@@ -30,6 +30,8 @@ import type {
30
30
  ReconcileLegacyMetadataResult,
31
31
  SearchIndexRebuildResult,
32
32
  SharedAddressList,
33
+ SignerCheckQuery,
34
+ SignerCheckResult,
33
35
  UserGroupItem,
34
36
  VaultPoliciesPage,
35
37
  VisibilityGrant,
@@ -276,6 +278,29 @@ export class AdminResource {
276
278
  * collide (the next derivation index is taken instead).
277
279
  */
278
280
  shared: () => this.#http.request<SharedAddressList>('GET', '/api/v1/admin/addresses/shared'),
281
+
282
+ /**
283
+ * Checks stored addresses against the signing service: for each address
284
+ * the vault's signer is asked to derive the address at its derivation
285
+ * path, and the answer is compared with the stored one. Read-only — it
286
+ * creates nothing and signs nothing.
287
+ *
288
+ * This is the check that the signer still holds the SAME key after its
289
+ * code or secrets were replaced: every address in `matched` means the
290
+ * keys are intact. One row in `mismatched` means the signer derives
291
+ * another address — transfers from those addresses cannot be signed.
292
+ * `failed` are addresses the signer did not answer for (unavailable, or
293
+ * a path it does not support — deeper than 10 levels); `skipped` counts
294
+ * addresses of vaults without a signing service.
295
+ *
296
+ * Each address costs one call to the signer, so the result is paged:
297
+ * `limit` is at most 40 (25 by default); pass `nextCursor` as `cursor`
298
+ * until it is `null`. `vault` narrows the check to one vault.
299
+ */
300
+ signerCheck: (params: SignerCheckQuery = {}) =>
301
+ this.#http.request<SignerCheckResult>('GET', '/api/v1/admin/addresses/signer-check', {
302
+ query: { ...params },
303
+ }),
279
304
  }
280
305
 
281
306
  readonly legacyMetadata = {
@@ -188,12 +188,22 @@ export class RegistriesResource {
188
188
  * A derivation path is written WITHOUT apostrophes — `m/44/195/…`, not
189
189
  * `m/44'/…`. The hardened marker is implied; writing it out produces a
190
190
  * different path and therefore different addresses.
191
+ *
192
+ * An EVM network (`type: 'EVM'`, `coinType: 60`) needs `chainId` — Ethereum
193
+ * is 1 — and takes `nativeSymbol`, the coin its addresses pay the fee in
194
+ * (`ETH`); both are refused on any other network. `slug` must be the
195
+ * network's name at the deposit monitoring, in lower case (`ethereum`):
196
+ * incoming payments are matched to the network by it.
191
197
  */
192
198
  createNetwork(input: CreateNetworkBody): Promise<Network> {
193
199
  return this.#http.request<Network>('POST', '/api/v1/networks', { body: input })
194
200
  }
195
201
 
196
- /** Administrators only. */
202
+ /**
203
+ * Administrators only. `chainId` can be set or changed only while the
204
+ * network has no addresses (409 otherwise): the same key on another chain is
205
+ * another account.
206
+ */
197
207
  updateNetwork(networkId: string, input: PatchNetworkBody): Promise<Network> {
198
208
  return this.#http.request<Network>('PATCH', `/api/v1/networks/${encodeURIComponent(networkId)}`, {
199
209
  body: input,
@@ -206,6 +216,21 @@ export class RegistriesResource {
206
216
  * The contract address is the key: an incoming payment is matched to a
207
217
  * token by it, so a wrong one means deposits land on the wrong asset or
208
218
  * nowhere at all.
219
+ *
220
+ * On an EVM network `decimals` is checked against the contract itself:
221
+ * the signing service converts an amount by the contract's `decimals()`,
222
+ * the ledger by the registry's, and one digit of difference sends ten times
223
+ * what was booked. 400 `TOKEN_DECIMALS_MISMATCH` (the contract's number is
224
+ * in `message`); 400 `INVALID_CONTRACT_ADDRESS` — not an address, or no
225
+ * token contract there; 400 `TOKEN_DECIMALS_UNSUPPORTED` — more than 9;
226
+ * 400 `EVM_NATIVE_NOT_SUPPORTED` — the network's coin (ETH) is not an asset
227
+ * and is not registered; 409 `NETWORK_NOT_READY` — the network has no
228
+ * `chainId` or no node to read from; 409 `ONCHAIN_STATE_UNAVAILABLE` — the
229
+ * node did not answer, the token was not created, try again.
230
+ *
231
+ * A token code is unique across networks, so USDT on Ethereum is a token of
232
+ * its own (`usdt_eth`): policies and limits written for `usdt` do not apply
233
+ * to it.
209
234
  */
210
235
  createToken(input: CreateTokenBody): Promise<TokenWithNetwork> {
211
236
  return this.#http.request<TokenWithNetwork>('POST', '/api/v1/tokens', { body: input })