WebhooksСобытие от Wallet Service (TOPUP)

Событие от Wallet Service (TOPUP)

Принимает входящие on-chain события. Сейчас обрабатывается только TOPUP. БЕЗ auth/подписи (демо; в проде добавим HMAC). Валидация тела — вручную внутри handler'а (внешний контракт, строгая схема не навязывается).

Токен резолвится из реестра по contract address (приоритет) или по коду (fallback с warning'ом); незнакомый токен игнорируется.

Зачисление — ledger-проводка topup атомарным batch'ем: address:available ← vault:external. Для основного токена адреса баланс берётся из ledger; для «неосновного» (asset_mismatch) средства учитываются на отдельном ledger-счёте и видны в GET /vaults/{code}/balances.

Идемпотентность: unique(network, txHash) и unique(webhookEventId) — дубликат вернёт 200 {duplicate: true}. TRX-события и незнакомые адреса игнорируются (200 {ignored: true}).

curl -X POST "https://policy-engine-rest.ezig.workers.dev/webhooks/wallet" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
  "tx": {
    "network": "TRON",
    "asset": "USDT",
    "contract": "example_string",
    "type": "example_string",
    "id": "example_string",
    "block": 42,
    "timestamp": 3.14,
    "from": "example_string",
    "to": "example_string",
    "value": "example_string"
  }
}'
{
  "ok": true,
  "incomingId": "example_string",
  "balanceUpdated": true,
  "newBalance": "example_string"
}
POST
/webhooks/wallet
POST
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token
Bearer Tokenstring
Required

better-auth session token. Мобилка/сервисы. Веб использует cookie.

better-auth session token. Мобилка/сервисы. Веб использует cookie.
API Key (cookie: better-auth.session_token)
Content-Typestring
Required

The media type of the request body

Options: application/json
Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token. better-auth session token. Мобилка/сервисы. Веб использует cookie.

path
parameterstring
Required

API Key for authentication. Provide your API key in the cookie.

Body

application/json
txobject
Required

Responses

okboolean
Required
incomingIdstring
Required
balanceUpdatedboolean
Required
newBalancestring
Required