@txnod/sdk 1.0.1
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/AGENTS.md +29 -0
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +434 -0
- package/dist/_shared/index.d.ts +68 -0
- package/dist/client-sandbox.d.ts +396 -0
- package/dist/client-sandbox.d.ts.map +1 -0
- package/dist/client-sandbox.js +448 -0
- package/dist/client-sandbox.js.map +1 -0
- package/dist/client.d.ts +429 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +588 -0
- package/dist/client.js.map +1 -0
- package/dist/env.d.ts +29 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +44 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +1887 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +2107 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/internals/error-ctor-map.d.ts +11 -0
- package/dist/internals/error-ctor-map.d.ts.map +1 -0
- package/dist/internals/error-ctor-map.js +75 -0
- package/dist/internals/error-ctor-map.js.map +1 -0
- package/dist/internals/fetch-with-retry.d.ts +34 -0
- package/dist/internals/fetch-with-retry.d.ts.map +1 -0
- package/dist/internals/fetch-with-retry.js +233 -0
- package/dist/internals/fetch-with-retry.js.map +1 -0
- package/dist/internals/hmac.d.ts +2 -0
- package/dist/internals/hmac.d.ts.map +1 -0
- package/dist/internals/hmac.js +10 -0
- package/dist/internals/hmac.js.map +1 -0
- package/dist/internals/logger.d.ts +9 -0
- package/dist/internals/logger.d.ts.map +1 -0
- package/dist/internals/logger.js +16 -0
- package/dist/internals/logger.js.map +1 -0
- package/dist/internals/parse-problem-details.d.ts +3 -0
- package/dist/internals/parse-problem-details.d.ts.map +1 -0
- package/dist/internals/parse-problem-details.js +76 -0
- package/dist/internals/parse-problem-details.js.map +1 -0
- package/dist/internals/synthetic-details.d.ts +12 -0
- package/dist/internals/synthetic-details.d.ts.map +1 -0
- package/dist/internals/synthetic-details.js +19 -0
- package/dist/internals/synthetic-details.js.map +1 -0
- package/dist/verify/chains/bsc.d.ts +17 -0
- package/dist/verify/chains/bsc.d.ts.map +1 -0
- package/dist/verify/chains/bsc.js +15 -0
- package/dist/verify/chains/bsc.js.map +1 -0
- package/dist/verify/chains/btc.d.ts +22 -0
- package/dist/verify/chains/btc.d.ts.map +1 -0
- package/dist/verify/chains/btc.js +55 -0
- package/dist/verify/chains/btc.js.map +1 -0
- package/dist/verify/chains/cardano.d.ts +73 -0
- package/dist/verify/chains/cardano.d.ts.map +1 -0
- package/dist/verify/chains/cardano.js +175 -0
- package/dist/verify/chains/cardano.js.map +1 -0
- package/dist/verify/chains/evm.d.ts +21 -0
- package/dist/verify/chains/evm.d.ts.map +1 -0
- package/dist/verify/chains/evm.js +46 -0
- package/dist/verify/chains/evm.js.map +1 -0
- package/dist/verify/chains/polygon.d.ts +17 -0
- package/dist/verify/chains/polygon.d.ts.map +1 -0
- package/dist/verify/chains/polygon.js +15 -0
- package/dist/verify/chains/polygon.js.map +1 -0
- package/dist/verify/chains/secp256k1-bip32.d.ts +20 -0
- package/dist/verify/chains/secp256k1-bip32.d.ts.map +1 -0
- package/dist/verify/chains/secp256k1-bip32.js +88 -0
- package/dist/verify/chains/secp256k1-bip32.js.map +1 -0
- package/dist/verify/chains/ton-cell.d.ts +179 -0
- package/dist/verify/chains/ton-cell.d.ts.map +1 -0
- package/dist/verify/chains/ton-cell.js +614 -0
- package/dist/verify/chains/ton-cell.js.map +1 -0
- package/dist/verify/chains/ton.d.ts +84 -0
- package/dist/verify/chains/ton.d.ts.map +1 -0
- package/dist/verify/chains/ton.js +131 -0
- package/dist/verify/chains/ton.js.map +1 -0
- package/dist/verify/chains/tron.d.ts +21 -0
- package/dist/verify/chains/tron.d.ts.map +1 -0
- package/dist/verify/chains/tron.js +42 -0
- package/dist/verify/chains/tron.js.map +1 -0
- package/dist/verify/config.d.ts +41 -0
- package/dist/verify/config.d.ts.map +1 -0
- package/dist/verify/config.js +120 -0
- package/dist/verify/config.js.map +1 -0
- package/dist/verify/errors.d.ts +56 -0
- package/dist/verify/errors.d.ts.map +1 -0
- package/dist/verify/errors.js +58 -0
- package/dist/verify/errors.js.map +1 -0
- package/dist/verify/index.d.ts +119 -0
- package/dist/verify/index.d.ts.map +1 -0
- package/dist/verify/index.js +166 -0
- package/dist/verify/index.js.map +1 -0
- package/dist/verify/xpub-safety.d.ts +33 -0
- package/dist/verify/xpub-safety.d.ts.map +1 -0
- package/dist/verify/xpub-safety.js +54 -0
- package/dist/verify/xpub-safety.js.map +1 -0
- package/dist/verify-webhook-signature.d.ts +30 -0
- package/dist/verify-webhook-signature.d.ts.map +1 -0
- package/dist/verify-webhook-signature.js +84 -0
- package/dist/verify-webhook-signature.js.map +1 -0
- package/docs/00-getting-started.md +135 -0
- package/docs/01-authentication.md +114 -0
- package/docs/02-invoices.md +216 -0
- package/docs/03-rates-and-quotes.md +82 -0
- package/docs/04-webhooks.md +126 -0
- package/docs/05-errors.md +199 -0
- package/docs/05-sandbox.md +159 -0
- package/docs/06-idempotency.md +132 -0
- package/docs/examples/express-webhook-receiver.md +97 -0
- package/docs/examples/nextjs-route-handler.md +206 -0
- package/docs/examples/sandbox-vitest-suite.md +263 -0
- package/docs/index.md +66 -0
- package/docs/reference/client.md +392 -0
- package/docs/reference/errors.md +161 -0
- package/docs/reference/types.md +400 -0
- package/package.json +53 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Type reference"
|
|
3
|
+
description: "Authoritative type shapes for requests, responses, and shared primitives."
|
|
4
|
+
sdk_version: 1.0.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Type reference
|
|
8
|
+
|
|
9
|
+
The `@txnod/sdk` package re-exports six type names directly for partner use in `import type` annotations:
|
|
10
|
+
|
|
11
|
+
- `Coin`
|
|
12
|
+
- `Chain`
|
|
13
|
+
- `Network`
|
|
14
|
+
- `InvoiceStatus`
|
|
15
|
+
- `WebhookEvent`
|
|
16
|
+
- `WebhookEventType`
|
|
17
|
+
|
|
18
|
+
All other request/response types are derived at build time from the server's Zod schemas, fully expanded to plain TypeScript, and shipped inside this tarball as `./dist/_shared/index.d.ts`. Partners install **only** `@txnod/sdk` — no `@txnod/*` package, no `zod`, no other peer dependency. **Authoritative source is `./dist/index.d.ts` inside this package.** When this markdown disagrees with `.d.ts`, trust `.d.ts`.
|
|
19
|
+
|
|
20
|
+
This file is a guided index — each section points at the TS source in the monorepo for context when needed, and summarizes the shape for quick agent consumption.
|
|
21
|
+
|
|
22
|
+
## `Coin`
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
type Coin =
|
|
26
|
+
| 'btc'
|
|
27
|
+
| 'eth'
|
|
28
|
+
| 'usdt_erc20'
|
|
29
|
+
| 'usdc_erc20'
|
|
30
|
+
| 'trx'
|
|
31
|
+
| 'usdt_trc20'
|
|
32
|
+
| 'ada'
|
|
33
|
+
| 'pol'
|
|
34
|
+
| 'usdt_polygon'
|
|
35
|
+
| 'usdc_polygon'
|
|
36
|
+
| 'bnb'
|
|
37
|
+
| 'usdt_bep20'
|
|
38
|
+
| 'usdc_bep20'
|
|
39
|
+
| 'ton'
|
|
40
|
+
| 'usdt_ton';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Source: `packages/shared/src/schemas/coin.ts`.
|
|
44
|
+
|
|
45
|
+
Chain mapping:
|
|
46
|
+
|
|
47
|
+
| Coin | Chain |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `btc` | `btc` |
|
|
50
|
+
| `eth`, `usdt_erc20`, `usdc_erc20` | `eth` |
|
|
51
|
+
| `trx`, `usdt_trc20` | `tron` |
|
|
52
|
+
| `ada` | `ada` |
|
|
53
|
+
| `pol`, `usdt_polygon`, `usdc_polygon` | `polygon` |
|
|
54
|
+
| `bnb`, `usdt_bep20`, `usdc_bep20` | `bsc` |
|
|
55
|
+
| `ton`, `usdt_ton` | `ton` |
|
|
56
|
+
|
|
57
|
+
## `Chain`
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
type Chain = 'btc' | 'eth' | 'ada' | 'ton' | 'tron' | 'polygon' | 'bsc';
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`Coin` resolves to a `Chain` per the table above.
|
|
64
|
+
|
|
65
|
+
## `InvoiceStatus`
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
type InvoiceStatus =
|
|
69
|
+
| 'pending'
|
|
70
|
+
| 'detected'
|
|
71
|
+
| 'paid'
|
|
72
|
+
| 'overpaid'
|
|
73
|
+
| 'partial'
|
|
74
|
+
| 'expired'
|
|
75
|
+
| 'expired_paid_late'
|
|
76
|
+
| 'reverted'
|
|
77
|
+
| 'cancelled';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
See [`../02-invoices.md`](../02-invoices.md#lifecycle) for semantics.
|
|
81
|
+
|
|
82
|
+
## `InvoiceCreateRequest`
|
|
83
|
+
|
|
84
|
+
Required fields: `external_id`, `coin`, and exactly one of `amount_usd` / `amount_crypto`.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
type InvoiceCreateRequest = {
|
|
88
|
+
external_id: string; // 1..128 chars
|
|
89
|
+
coin: Coin;
|
|
90
|
+
amount_usd?: number; // positive finite; XOR with amount_crypto
|
|
91
|
+
amount_crypto?: string; // decimal /^\d+(\.\d+)?$/; XOR with amount_usd
|
|
92
|
+
callback_url?: string; // https URL
|
|
93
|
+
metadata?: Record<string, unknown>;
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## `InvoiceResponse`
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
type InvoiceResponse = {
|
|
101
|
+
id: string; // ULID, txnod primary key
|
|
102
|
+
project_id: string; // ULID
|
|
103
|
+
external_id: string;
|
|
104
|
+
coin: Coin;
|
|
105
|
+
address: string; // deposit address
|
|
106
|
+
amount_crypto: string; // decimal string in display units
|
|
107
|
+
amount_crypto_units: string; // integer string in smallest unit
|
|
108
|
+
amount_usd: number | null; // null if request used amount_crypto
|
|
109
|
+
rate_snapshot: {
|
|
110
|
+
rate: string; // decimal USD per 1 coin
|
|
111
|
+
source: 'coingecko';
|
|
112
|
+
quoted_at: string; // ISO-8601 UTC
|
|
113
|
+
rate_is_stale: boolean;
|
|
114
|
+
rate_age_seconds: number; // int ≥ 0
|
|
115
|
+
} | null; // null if amount_crypto was supplied
|
|
116
|
+
payment_uri: string; // BIP-21 / EIP-681 / Cardano
|
|
117
|
+
callback_url: string | null;
|
|
118
|
+
metadata: Record<string, unknown> | null;
|
|
119
|
+
matching_mode: 'exact' | 'at_least' | 'any';
|
|
120
|
+
confirmation_threshold: number;
|
|
121
|
+
status: InvoiceStatus;
|
|
122
|
+
expires_at: number; // unix seconds
|
|
123
|
+
expires_at_iso: string; // ISO-8601 UTC
|
|
124
|
+
created_at: number;
|
|
125
|
+
created_at_iso: string;
|
|
126
|
+
transactions?: InvoiceTransactionResponse[]; // present when expanded
|
|
127
|
+
confirmations?: number; // present on detail
|
|
128
|
+
};
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## `InvoiceTransactionResponse`
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
type InvoiceTransactionResponse = {
|
|
135
|
+
id: string; // ULID
|
|
136
|
+
chain: Chain; // 'btc' | 'eth' | 'tron' | 'ada' | 'polygon' | 'bsc' | 'ton'
|
|
137
|
+
tx_hash: string;
|
|
138
|
+
to_address: string;
|
|
139
|
+
tx_output_index: number; // int ≥ 0
|
|
140
|
+
amount_units: string; // integer string in smallest unit
|
|
141
|
+
block_height: number | null;
|
|
142
|
+
confirmations: number;
|
|
143
|
+
received_at: number;
|
|
144
|
+
received_at_iso: string;
|
|
145
|
+
orphaned_at: number | null;
|
|
146
|
+
orphaned_at_iso: string | null;
|
|
147
|
+
};
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## `InvoiceSearchQuery`
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
type InvoiceSearchQuery = {
|
|
154
|
+
external_id?: string;
|
|
155
|
+
address?: string;
|
|
156
|
+
tx_hash?: string;
|
|
157
|
+
amount?: string;
|
|
158
|
+
status?: InvoiceStatus;
|
|
159
|
+
date_from?: string; // ISO-8601
|
|
160
|
+
date_to?: string; // ISO-8601
|
|
161
|
+
cursor?: string; // ULID
|
|
162
|
+
limit?: number; // 1..200, default 50
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## `WalletEdgeKind`
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
type WalletEdgeKind = 'production' | 'testnet';
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Source: `packages/shared/src/db/tables/kinds.ts`. Replaces the prior `Network` re-export. Sandbox is excluded by design — sandbox addresses are simulated, not derived from real chain provider URLs.
|
|
173
|
+
|
|
174
|
+
## `ProjectKind`
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
type ProjectKind = 'production' | 'testnet' | 'sandbox';
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The full discriminator on every project (and every wallet, binding, invoice). The webhook envelope `mode` field is typed `ProjectKind`.
|
|
181
|
+
|
|
182
|
+
## `CursorPaginatedInvoiceResponse`
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
type CursorPaginatedInvoiceResponse = {
|
|
186
|
+
items: InvoiceResponse[];
|
|
187
|
+
next_cursor?: string; // omitted on the last page; pass to the next call to continue
|
|
188
|
+
};
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## `WebhookEvent`
|
|
192
|
+
|
|
193
|
+
Discriminated union on `event_type` — `event.data` is fully typed after a narrowing switch on `event.event_type`. **No casts are needed** to read `event.data.invoice_id` once you have narrowed.
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
type WebhookEventType =
|
|
197
|
+
| 'invoice.detected'
|
|
198
|
+
| 'invoice.paid'
|
|
199
|
+
| 'invoice.overpaid'
|
|
200
|
+
| 'invoice.partial'
|
|
201
|
+
| 'invoice.expired'
|
|
202
|
+
| 'invoice.expired_paid_late'
|
|
203
|
+
| 'invoice.reverted';
|
|
204
|
+
|
|
205
|
+
type WebhookEventData = {
|
|
206
|
+
invoice_id: string;
|
|
207
|
+
project_id: string;
|
|
208
|
+
chain: Chain;
|
|
209
|
+
coin: Coin;
|
|
210
|
+
tx_hash: string;
|
|
211
|
+
to_address: string | null;
|
|
212
|
+
amount_units: string; // integer string in smallest unit
|
|
213
|
+
confirmations: number;
|
|
214
|
+
block_height: number | null;
|
|
215
|
+
payment_token: string | null; // TON only — 8-hex memo token
|
|
216
|
+
matched_payment_token: string | null;
|
|
217
|
+
chain_specific: { ton?: { tx_lt: string; mc_block_seqno: number; block_ref: { workchain: number; shard: string; seqno: number; }; jetton_master?: string; } } | null;
|
|
218
|
+
reason?: 'reorg' | 'late_arrival'; // present on reverted/expired_paid_late
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type WebhookEvent = {
|
|
222
|
+
event_id: string; // ULID, stable across retries
|
|
223
|
+
event_type: WebhookEventType; // discriminant
|
|
224
|
+
created_at: number; // unix seconds
|
|
225
|
+
created_at_iso: string; // ISO-8601 UTC
|
|
226
|
+
project_id: string; // ULID
|
|
227
|
+
data: WebhookEventData; // fully typed under each event_type branch
|
|
228
|
+
attempt: number; // 1-based
|
|
229
|
+
mode: 'production' | 'testnet' | 'sandbox'; // envelope discriminator across project kinds
|
|
230
|
+
};
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The `mode` field lets a single handler accept production, testnet, and sandbox traffic and assert which surface generated each delivery — the production secret signs production envelopes; the testnet secret signs `mode: 'testnet'` envelopes; the sandbox secret signs `mode: 'sandbox'` envelopes. Asserting `event.mode === expectedMode` after `verifyWebhookSignature` returns is the recommended fail-closed CI gate (see [`../05-sandbox.md`](../05-sandbox.md#recommended-ci-assertion)). The `mode` field is carried on the **delivered envelope** that arrives at your callback URL — not on the forensic-listing rows returned by `listWebhookEvents` (which omit the parsed payload entirely; they expose delivery state only).
|
|
234
|
+
|
|
235
|
+
Example narrowing:
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
if (event.event_type === 'invoice.paid') {
|
|
239
|
+
// event.data.invoice_id is string here, no cast needed
|
|
240
|
+
console.log('paid', event.data.invoice_id, 'with', event.data.amount_units, 'units');
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
The variants share the same `WebhookEventData` shape today; the discriminated-union type is preserved so future variant-specific fields (e.g. orphan-only fields) can land without breaking partner code.
|
|
245
|
+
|
|
246
|
+
## `WebhookEventListApiQuery` / `WebhookEventListResponse`
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
type WebhookEventListApiQuery = {
|
|
250
|
+
status?: 'delivered' | 'retrying' | 'dlq' | 'skipped';
|
|
251
|
+
event_type?: WebhookEventType;
|
|
252
|
+
since?: string; // ISO-8601
|
|
253
|
+
invoice_id?: string; // ULID
|
|
254
|
+
cursor?: string;
|
|
255
|
+
limit?: number; // 1..200, default 50
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
type WebhookEventListResponse = {
|
|
259
|
+
items: {
|
|
260
|
+
id: string;
|
|
261
|
+
event_type: WebhookEventType;
|
|
262
|
+
status: 'delivered' | 'retrying' | 'dlq' | 'skipped';
|
|
263
|
+
created_at: string; // ISO-8601
|
|
264
|
+
target_url: string | null;
|
|
265
|
+
attempt_count: number;
|
|
266
|
+
last_response_status: number | null;
|
|
267
|
+
invoice_id: string | null;
|
|
268
|
+
dlq_at: string | null;
|
|
269
|
+
delivered_at: string | null;
|
|
270
|
+
skip_reason: 'not_subscribed' | 'no_target_url' | null;
|
|
271
|
+
}[];
|
|
272
|
+
next_cursor?: string; // omitted on the last page; pass to the next call to continue
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## `WebhookEventResendResponse`
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
type WebhookEventResendResponse = {
|
|
280
|
+
event_id: string; // new id
|
|
281
|
+
original_event_id: string;
|
|
282
|
+
event_type: WebhookEventType;
|
|
283
|
+
project_id: string;
|
|
284
|
+
invoice_id: string | null;
|
|
285
|
+
target_url: string | null;
|
|
286
|
+
created_at: number;
|
|
287
|
+
created_at_iso: string;
|
|
288
|
+
};
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## `RatesQuery` / `RatesResponse`
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
type RatesQuery = { coins?: string }; // CSV, optional
|
|
295
|
+
|
|
296
|
+
type RatesResponse = {
|
|
297
|
+
quoted_at: string; // ISO-8601
|
|
298
|
+
source: 'coingecko';
|
|
299
|
+
rates: Partial<Record<Coin, {
|
|
300
|
+
rate: string; // decimal USD per 1 coin
|
|
301
|
+
rate_is_stale: boolean;
|
|
302
|
+
rate_age_seconds: number; // int ≥ 0
|
|
303
|
+
}>>;
|
|
304
|
+
indicative_notice: string;
|
|
305
|
+
};
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## `QuoteQuery` / `QuoteResponse`
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
type QuoteQuery = {
|
|
312
|
+
amount_usd: number; // positive finite
|
|
313
|
+
coins?: string; // CSV, optional
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
type QuoteResponse = {
|
|
317
|
+
amount_usd: number;
|
|
318
|
+
quoted_at: string;
|
|
319
|
+
source: 'coingecko';
|
|
320
|
+
quotes: Partial<Record<Coin, {
|
|
321
|
+
amount_crypto: string; // decimal
|
|
322
|
+
amount_crypto_units: string; // integer smallest unit
|
|
323
|
+
rate: string; // decimal USD per 1 coin
|
|
324
|
+
rate_is_stale: boolean;
|
|
325
|
+
rate_age_seconds: number;
|
|
326
|
+
}>>;
|
|
327
|
+
indicative_notice: string;
|
|
328
|
+
};
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## `OrphanPaymentListQuery`, `OrphanAttributeRequest`, `CursorPaginatedOrphanPaymentResponse`
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
type OrphanPaymentListQuery = {
|
|
335
|
+
attributed?: boolean;
|
|
336
|
+
chain?: 'btc' | 'eth' | 'tron' | 'ada' | 'polygon' | 'bsc' | 'ton';
|
|
337
|
+
tx_hash?: string;
|
|
338
|
+
date_from?: string;
|
|
339
|
+
date_to?: string;
|
|
340
|
+
amount_units_gte?: string;
|
|
341
|
+
amount_units_lte?: string;
|
|
342
|
+
cursor?: string;
|
|
343
|
+
limit?: number; // 1..200, default 50
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
type OrphanAttributeRequest = {
|
|
347
|
+
external_id: string; // 1..128
|
|
348
|
+
user_id?: string; // 1..256
|
|
349
|
+
metadata?: Record<string, unknown>;
|
|
350
|
+
to_address?: string;
|
|
351
|
+
tx_output_index?: number; // int ≥ 0
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
type CursorPaginatedOrphanPaymentResponse = {
|
|
355
|
+
items: {
|
|
356
|
+
id: string;
|
|
357
|
+
chain: Chain;
|
|
358
|
+
tx_hash: string;
|
|
359
|
+
to_address: string;
|
|
360
|
+
tx_output_index: number;
|
|
361
|
+
amount_units: string;
|
|
362
|
+
block_height: number | null;
|
|
363
|
+
received_at: number;
|
|
364
|
+
received_at_iso: string;
|
|
365
|
+
attributed: boolean;
|
|
366
|
+
attributed_invoice_id: string | null;
|
|
367
|
+
attributed_external_id: string | null;
|
|
368
|
+
attributed_at: number | null;
|
|
369
|
+
attributed_at_iso: string | null;
|
|
370
|
+
}[];
|
|
371
|
+
next_cursor?: string; // omitted on the last page
|
|
372
|
+
};
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
> **TRON activation events never appear here.** Story 31.3 server-side filter excludes inbound activation transactions (operator-funded TRX/USDT sends that activate a fresh address) from orphan classification — partners do not need to dedupe them client-side.
|
|
376
|
+
|
|
377
|
+
## `ProblemDetails`
|
|
378
|
+
|
|
379
|
+
Raw RFC 7807 envelope surfaced via `TxnodError.raw`:
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
type ProblemDetails = {
|
|
383
|
+
type: string;
|
|
384
|
+
title: string;
|
|
385
|
+
status: number;
|
|
386
|
+
detail?: string;
|
|
387
|
+
instance?: string;
|
|
388
|
+
error_code: ErrorCode;
|
|
389
|
+
request_id: string;
|
|
390
|
+
errors?: unknown; // per-field Zod issues on validation_error
|
|
391
|
+
meta?: Record<string, unknown>;
|
|
392
|
+
};
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
See [`errors.md`](./errors.md) for the `error_code` enum.
|
|
396
|
+
|
|
397
|
+
## Related
|
|
398
|
+
|
|
399
|
+
- [`client.md`](./client.md) — which method uses which type
|
|
400
|
+
- [`../02-invoices.md`](../02-invoices.md), [`../03-rates-and-quotes.md`](../03-rates-and-quotes.md), [`../04-webhooks.md`](../04-webhooks.md) — usage context
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@txnod/sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "TypeScript SDK for the txnod non-custodial crypto payment gateway — sign requests, verify webhook signatures, and verify invoice deposit-address derivation across BTC, ETH, TRON, Cardano, Polygon PoS, BNB Smart Chain, and TON. Pure Node >= 20; runs in any server-side framework (Express, Fastify, Hono, Next.js, Nuxt, SvelteKit, etc.).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"docs",
|
|
18
|
+
"AGENTS.md",
|
|
19
|
+
"README.md",
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20"
|
|
28
|
+
},
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@noble/curves": "2.2.0",
|
|
32
|
+
"@noble/ed25519": "3.1.0",
|
|
33
|
+
"@noble/hashes": "2.2.0",
|
|
34
|
+
"@scure/base": "2.2.0",
|
|
35
|
+
"@scure/bip32": "2.2.0",
|
|
36
|
+
"pino": "10.3.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@testcontainers/postgresql": "11.14.0",
|
|
40
|
+
"@ton/ton": "16.2.4"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "pnpm --filter @txnod/shared build && tsc --build && node scripts/bundle-shared-types.mjs",
|
|
44
|
+
"typecheck": "tsc --build",
|
|
45
|
+
"lint": "eslint src",
|
|
46
|
+
"test": "vitest run --config vitest.unit.config.ts",
|
|
47
|
+
"test:contract": "pnpm run build && vitest run --config vitest.contract.config.ts",
|
|
48
|
+
"check:bundle-size": "bash ../../scripts/ci/sdk-bundle-size.sh",
|
|
49
|
+
"check:dep-allowlist": "bash ../../scripts/ci/sdk-dep-allowlist.sh",
|
|
50
|
+
"check:pack-whitelist": "bash ../../scripts/ci/sdk-pack-whitelist.sh",
|
|
51
|
+
"check:dts-self-contained": "bash ../../scripts/ci/sdk-dts-self-contained.sh"
|
|
52
|
+
}
|
|
53
|
+
}
|