infra-sdk-typescript 0.1.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.
- package/LICENSE +21 -0
- package/README.md +249 -0
- package/dist/index.cjs +908 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +912 -0
- package/dist/index.d.ts +912 -0
- package/dist/index.js +882 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,912 @@
|
|
|
1
|
+
type HttpMethod = "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
2
|
+
type QueryValue = string | number | boolean | undefined | null;
|
|
3
|
+
interface RequestOptions {
|
|
4
|
+
method: HttpMethod;
|
|
5
|
+
path: string;
|
|
6
|
+
query?: Record<string, QueryValue>;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Sent as the `Idempotency-Key` header. Besides the header itself, its presence tells
|
|
11
|
+
* the retry logic that a connection failure is safe to retry — the server can dedupe
|
|
12
|
+
* a resubmission with the same key.
|
|
13
|
+
*/
|
|
14
|
+
idempotencyKey?: string;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Base class every resource namespace (`client.wallet`, `client.tokenization`, `client.indexer`) extends. */
|
|
20
|
+
declare abstract class APIResource {
|
|
21
|
+
protected readonly client: InfraClient;
|
|
22
|
+
constructor(client: InfraClient);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The Infra API uses three different pagination envelopes depending on the service
|
|
27
|
+
* (see the Conventions doc). {@link Page} normalizes all three into one ergonomic type so
|
|
28
|
+
* callers can iterate any list endpoint the same way:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const page = await client.tokenization.listTokens();
|
|
32
|
+
* for await (const token of page) {
|
|
33
|
+
* console.log(token.ticker);
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* // or, page by page:
|
|
37
|
+
* let page = await client.wallet.getTransactionHistory();
|
|
38
|
+
* while (true) {
|
|
39
|
+
* for (const tx of page.data) handle(tx);
|
|
40
|
+
* if (!page.hasNextPage()) break;
|
|
41
|
+
* page = await page.getNextPage();
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare class Page<T> implements AsyncIterable<T> {
|
|
46
|
+
readonly data: readonly T[];
|
|
47
|
+
private readonly nextParams;
|
|
48
|
+
private readonly fetchNext;
|
|
49
|
+
constructor(opts: {
|
|
50
|
+
data: readonly T[];
|
|
51
|
+
nextParams: Record<string, unknown> | null;
|
|
52
|
+
fetchNext: ((params: Record<string, unknown>) => Promise<Page<T>>) | null;
|
|
53
|
+
});
|
|
54
|
+
hasNextPage(): boolean;
|
|
55
|
+
getNextPage(): Promise<Page<T>>;
|
|
56
|
+
/** Walks every page starting with this one, yielding each `Page<T>` in turn. */
|
|
57
|
+
iterPages(): AsyncGenerator<Page<T>, void, void>;
|
|
58
|
+
/** Yields every item across all pages, fetching subsequent pages lazily as iteration proceeds. */
|
|
59
|
+
[Symbol.asyncIterator](): AsyncGenerator<T, void, void>;
|
|
60
|
+
/** Eagerly fetches every remaining page and returns all items as a single array. Use with caution on large collections. */
|
|
61
|
+
toArray(): Promise<T[]>;
|
|
62
|
+
}
|
|
63
|
+
/** Raw shape returned by limit/offset endpoints (currently: Wallet transaction history). */
|
|
64
|
+
interface OffsetPaginatedResponse<T> {
|
|
65
|
+
items: readonly T[];
|
|
66
|
+
pagination: {
|
|
67
|
+
total: number;
|
|
68
|
+
limit: number;
|
|
69
|
+
offset: number;
|
|
70
|
+
hasMore: boolean;
|
|
71
|
+
nextOffset: number | null;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Raw shape returned by page/pageSize endpoints with inline totals (currently: Tokenization). */
|
|
75
|
+
interface FlatPaginatedResponse<T> {
|
|
76
|
+
items: readonly T[];
|
|
77
|
+
total: number;
|
|
78
|
+
page: number;
|
|
79
|
+
pageSize: number;
|
|
80
|
+
}
|
|
81
|
+
/** Raw shape returned by page/limit endpoints with a `meta` block (currently: Indexer). */
|
|
82
|
+
interface MetaPaginatedResponse<T> {
|
|
83
|
+
data: readonly T[];
|
|
84
|
+
meta: {
|
|
85
|
+
total: number;
|
|
86
|
+
page: number;
|
|
87
|
+
limit: number;
|
|
88
|
+
totalPages: number;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A string literal union that still accepts any other string, so autocomplete surfaces
|
|
94
|
+
* the known values without rejecting new ones the API adds before this SDK is updated.
|
|
95
|
+
*/
|
|
96
|
+
type LooseUnion<T extends string> = T | (string & Record<never, never>);
|
|
97
|
+
/** Chain family used by the Wallet service's HD tree. */
|
|
98
|
+
type ChainType = "EVM" | "SOLANA";
|
|
99
|
+
/** `MAINNET` for real funds, `TESTNET` for sponsored/free test transfers. */
|
|
100
|
+
type Network = "MAINNET" | "TESTNET";
|
|
101
|
+
/** Lifecycle of an async Wallet transaction (transfer or sponsored sign). */
|
|
102
|
+
type TransactionStatus = "PENDING" | "PROCESSING" | "COMPLETED" | "FAILED";
|
|
103
|
+
/**
|
|
104
|
+
* Chain identifier used by Tokenization and the Indexer (e.g. `"BASE"`, `"ETH"`). Distinct
|
|
105
|
+
* from {@link ChainType}, which only distinguishes the EVM/Solana wallet-derivation family.
|
|
106
|
+
*/
|
|
107
|
+
type Chain = LooseUnion<"ATC" | "BSC" | "ETH" | "BASE" | "POL" | "SOL" | "LISK">;
|
|
108
|
+
/** Per-call overrides accepted by every SDK method. */
|
|
109
|
+
interface RequestOverrides {
|
|
110
|
+
/** Abort this specific call independent of the client's default timeout. */
|
|
111
|
+
signal?: AbortSignal;
|
|
112
|
+
/** Overrides the client's default request timeout, in milliseconds, for this call only. */
|
|
113
|
+
timeoutMs?: number;
|
|
114
|
+
}
|
|
115
|
+
/** Per-call overrides for methods that accept (or require) an `Idempotency-Key`. */
|
|
116
|
+
interface IdempotentRequestOverrides extends RequestOverrides {
|
|
117
|
+
/**
|
|
118
|
+
* Client-generated key that makes this request safe to retry — a retry sent with the
|
|
119
|
+
* same key returns the original result instead of submitting again. Defaults to an
|
|
120
|
+
* auto-generated UUIDv4 when omitted; pass your own to control retries across separate
|
|
121
|
+
* SDK calls (e.g. after a process restart).
|
|
122
|
+
*/
|
|
123
|
+
idempotencyKey?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** A derived HD wallet address. */
|
|
127
|
+
interface Wallet {
|
|
128
|
+
id: string;
|
|
129
|
+
businessName: string;
|
|
130
|
+
address: string;
|
|
131
|
+
chainType: ChainType;
|
|
132
|
+
purpose: string;
|
|
133
|
+
derivationPath: string;
|
|
134
|
+
addressIndex: number;
|
|
135
|
+
isActive: boolean;
|
|
136
|
+
createdAt: string;
|
|
137
|
+
deactivatedAt: string | null;
|
|
138
|
+
metadata: Record<string, unknown> | null;
|
|
139
|
+
}
|
|
140
|
+
/** The minimal shape returned immediately after deriving new addresses. */
|
|
141
|
+
interface GeneratedWallet {
|
|
142
|
+
address: string;
|
|
143
|
+
chainType: ChainType;
|
|
144
|
+
isActive: boolean;
|
|
145
|
+
addressIndex: number;
|
|
146
|
+
}
|
|
147
|
+
/** A Wallet-service on-chain transaction (transfer or sponsored sign), in any lifecycle state. */
|
|
148
|
+
interface WalletTransaction {
|
|
149
|
+
id: string;
|
|
150
|
+
type: string;
|
|
151
|
+
chainType: ChainType;
|
|
152
|
+
network: Network;
|
|
153
|
+
chainId: number;
|
|
154
|
+
signerType: string;
|
|
155
|
+
fromAddress: string;
|
|
156
|
+
addressIndex: number | null;
|
|
157
|
+
toAddress: string;
|
|
158
|
+
amount: string | null;
|
|
159
|
+
/** USD-equivalent value at execution time, when available. */
|
|
160
|
+
valueUsd?: string;
|
|
161
|
+
tokenAddress: string | null;
|
|
162
|
+
data: string | null;
|
|
163
|
+
value: string | null;
|
|
164
|
+
txHash: string | null;
|
|
165
|
+
status: TransactionStatus;
|
|
166
|
+
gasUsed: string | null;
|
|
167
|
+
feeWei: string | null;
|
|
168
|
+
explorerUrl?: string;
|
|
169
|
+
explorerTxUrl?: string | null;
|
|
170
|
+
/** Present only when `status` is `FAILED`. */
|
|
171
|
+
error?: string;
|
|
172
|
+
createdAt: string;
|
|
173
|
+
updatedAt: string;
|
|
174
|
+
}
|
|
175
|
+
/** Result of a local-only sign (non-EVM chain, nothing broadcast) — always returned synchronously. */
|
|
176
|
+
interface SignedTransactionResult {
|
|
177
|
+
signedTransaction: string;
|
|
178
|
+
}
|
|
179
|
+
interface SupportedChain {
|
|
180
|
+
chainType: ChainType;
|
|
181
|
+
name: string;
|
|
182
|
+
chainId: number | null;
|
|
183
|
+
network: Network;
|
|
184
|
+
}
|
|
185
|
+
interface WalletBalance {
|
|
186
|
+
/** Spendable USD balance as a decimal string. */
|
|
187
|
+
balance: string;
|
|
188
|
+
currency: "USD";
|
|
189
|
+
updatedAt: string;
|
|
190
|
+
}
|
|
191
|
+
interface WalletCount {
|
|
192
|
+
count: number;
|
|
193
|
+
}
|
|
194
|
+
interface HdEnabledStatus {
|
|
195
|
+
enabled: boolean;
|
|
196
|
+
}
|
|
197
|
+
interface GenerateWalletsParams {
|
|
198
|
+
chainType: ChainType;
|
|
199
|
+
/** Logical tag for the addresses, e.g. `"deposit"`. */
|
|
200
|
+
purpose?: string;
|
|
201
|
+
}
|
|
202
|
+
interface ListWalletsParams {
|
|
203
|
+
chainType?: ChainType;
|
|
204
|
+
isActive?: boolean;
|
|
205
|
+
/** Page size. Default 50. */
|
|
206
|
+
limit?: number;
|
|
207
|
+
offset?: number;
|
|
208
|
+
}
|
|
209
|
+
interface GetWalletCountParams {
|
|
210
|
+
chainType?: ChainType;
|
|
211
|
+
}
|
|
212
|
+
interface GetWalletByAddressParams {
|
|
213
|
+
/** Disambiguates the chain when the same address string could exist on more than one. */
|
|
214
|
+
chainType?: ChainType;
|
|
215
|
+
}
|
|
216
|
+
interface GetWalletByAddressIndexParams {
|
|
217
|
+
chainType?: ChainType;
|
|
218
|
+
}
|
|
219
|
+
interface SignTransactionRequest {
|
|
220
|
+
to: string;
|
|
221
|
+
/** Native value in the chain's smallest unit. */
|
|
222
|
+
value?: string;
|
|
223
|
+
/** Calldata, hex-encoded. */
|
|
224
|
+
data?: string;
|
|
225
|
+
}
|
|
226
|
+
interface SignTransactionParams {
|
|
227
|
+
chainType: ChainType;
|
|
228
|
+
/** HD index of the signing wallet. */
|
|
229
|
+
addressIndex: number;
|
|
230
|
+
/** Target chain id (e.g. `8453`). Required for EVM. */
|
|
231
|
+
chainId?: number;
|
|
232
|
+
network?: Network;
|
|
233
|
+
transaction: SignTransactionRequest;
|
|
234
|
+
/**
|
|
235
|
+
* `true` = legacy synchronous mode: hold the request open for the relay outcome
|
|
236
|
+
* instead of `202` + poll. Default `false`.
|
|
237
|
+
*/
|
|
238
|
+
waitForCompletion?: boolean;
|
|
239
|
+
/** HTTPS URL to receive the final transaction once execution settles. */
|
|
240
|
+
webhookUrl?: string;
|
|
241
|
+
/** Your own HMAC key (16-256 chars) for the webhook signature. Requires `webhookUrl`. */
|
|
242
|
+
webhookSecret?: string;
|
|
243
|
+
}
|
|
244
|
+
interface DeactivateWalletParams {
|
|
245
|
+
chainType?: ChainType;
|
|
246
|
+
}
|
|
247
|
+
interface InitiateTransferParams {
|
|
248
|
+
/** Sending wallet — either its full on-chain address or its HD `addressIndex`. */
|
|
249
|
+
fromAddress: string | number;
|
|
250
|
+
toAddress: string;
|
|
251
|
+
/** Amount in the token's smallest unit (e.g. `"1000000"`). */
|
|
252
|
+
amount: string;
|
|
253
|
+
chainType: ChainType;
|
|
254
|
+
/** Target chain id. Use `84532` (Base Sepolia) for sponsored testnet transfers. Required for EVM. */
|
|
255
|
+
chainId?: number;
|
|
256
|
+
network?: Network;
|
|
257
|
+
/** ERC-20 token contract. Omit for a native transfer. */
|
|
258
|
+
tokenAddress?: string;
|
|
259
|
+
/** Set `true` to transfer cNGN. Default `false`. */
|
|
260
|
+
cNGN?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* `true` = legacy synchronous mode: hold the request open for the final outcome
|
|
263
|
+
* (`201`/`422`) instead of `202` + poll. Default `false`.
|
|
264
|
+
*/
|
|
265
|
+
waitForCompletion?: boolean;
|
|
266
|
+
webhookUrl?: string;
|
|
267
|
+
webhookSecret?: string;
|
|
268
|
+
}
|
|
269
|
+
interface GetTransactionHistoryParams {
|
|
270
|
+
chainType?: ChainType;
|
|
271
|
+
/** e.g. `"COMPLETED"`. */
|
|
272
|
+
status?: TransactionStatus;
|
|
273
|
+
/** Page size. Default 20. */
|
|
274
|
+
limit?: number;
|
|
275
|
+
offset?: number;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The Wallet service — manages the business HD wallet tree: deriving addresses, reading
|
|
280
|
+
* them, signing and submitting transactions, and tracking the USD balance used to pay gas
|
|
281
|
+
* on mainnet transfers.
|
|
282
|
+
*
|
|
283
|
+
* [Initiate transfer]{@link WalletResource.initiateTransfer} and sponsored
|
|
284
|
+
* [Sign transaction]{@link WalletResource.signTransaction} are asynchronous by default:
|
|
285
|
+
* they return a `PENDING` transaction immediately, and you poll
|
|
286
|
+
* {@link WalletResource.getTransaction} (or supply `webhookUrl`) for the outcome. Pass
|
|
287
|
+
* `waitForCompletion: true` for the legacy synchronous behavior.
|
|
288
|
+
*/
|
|
289
|
+
declare class WalletResource extends APIResource {
|
|
290
|
+
/** Derives one or more new addresses on the business HD tree. Requires `wallet.hd.generate`. */
|
|
291
|
+
generateWallets(params: GenerateWalletsParams, overrides?: IdempotentRequestOverrides): Promise<GeneratedWallet[]>;
|
|
292
|
+
/**
|
|
293
|
+
* Lists derived wallets for the business. Requires `wallet.hd.read`.
|
|
294
|
+
*
|
|
295
|
+
* Note: unlike {@link getTransactionHistory}, the API does not return pagination
|
|
296
|
+
* metadata for this endpoint — it always answers with a plain array sized by `limit`.
|
|
297
|
+
*/
|
|
298
|
+
listWallets(params?: ListWalletsParams, overrides?: RequestOverrides): Promise<Wallet[]>;
|
|
299
|
+
/** Returns the number of derived wallets, optionally filtered by chain. Requires `wallet.hd.read`. */
|
|
300
|
+
getWalletCount(params?: GetWalletCountParams, overrides?: RequestOverrides): Promise<WalletCount>;
|
|
301
|
+
/** Reports whether HD wallets are enabled for the business. Requires `wallet.hd.read`. */
|
|
302
|
+
getHdEnabled(overrides?: RequestOverrides): Promise<HdEnabledStatus>;
|
|
303
|
+
/** Fetches a single wallet by its on-chain address. Requires `wallet.hd.read`. */
|
|
304
|
+
getWalletByAddress(address: string, params?: GetWalletByAddressParams, overrides?: RequestOverrides): Promise<Wallet>;
|
|
305
|
+
/** Fetches a wallet by its HD `addressIndex`. Requires `wallet.hd.read`. */
|
|
306
|
+
getWalletByAddressIndex(addressIndex: number, params?: GetWalletByAddressIndexParams, overrides?: RequestOverrides): Promise<Wallet>;
|
|
307
|
+
/**
|
|
308
|
+
* Signs (and, where applicable, sponsors and submits) a transaction from a derived
|
|
309
|
+
* wallet. Requires `wallet.hd.sign`.
|
|
310
|
+
*
|
|
311
|
+
* Returns a {@link SignedTransactionResult} for local-only signing (a non-EVM chain
|
|
312
|
+
* with `addressIndex` — nothing broadcast), or a {@link WalletTransaction} for a
|
|
313
|
+
* sponsored sign (async `PENDING` by default, or the settled result with
|
|
314
|
+
* `waitForCompletion: true`).
|
|
315
|
+
*/
|
|
316
|
+
signTransaction(params: SignTransactionParams, overrides?: IdempotentRequestOverrides): Promise<SignedTransactionResult | WalletTransaction>;
|
|
317
|
+
/** Deactivates a wallet so it is no longer used for new operations. Requires `wallet.hd.deactivate`. */
|
|
318
|
+
deactivateWallet(walletId: string, params?: DeactivateWalletParams, overrides?: RequestOverrides): Promise<null>;
|
|
319
|
+
/** Lists the chains the platform can sign and broadcast on. */
|
|
320
|
+
getSupportedChains(overrides?: RequestOverrides): Promise<SupportedChain[]>;
|
|
321
|
+
/**
|
|
322
|
+
* Submits a token (or native) transfer from a derived wallet. Requires
|
|
323
|
+
* `wallet.transfer.create`.
|
|
324
|
+
*
|
|
325
|
+
* On a `422` (transfer reverted after broadcast, `waitForCompletion: true` only), the
|
|
326
|
+
* thrown {@link UnprocessableEntityError} still carries the failed transaction — read it
|
|
327
|
+
* from `error.body` (shaped like `{ data: WalletTransaction }`) if you need the details
|
|
328
|
+
* rather than just the message.
|
|
329
|
+
*/
|
|
330
|
+
initiateTransfer(params: InitiateTransferParams, overrides?: IdempotentRequestOverrides): Promise<WalletTransaction>;
|
|
331
|
+
/**
|
|
332
|
+
* Returns a paginated history of the business's transactions. Requires
|
|
333
|
+
* `wallet.transfer.read`.
|
|
334
|
+
*
|
|
335
|
+
* ```ts
|
|
336
|
+
* const page = await client.wallet.getTransactionHistory({ status: "COMPLETED" });
|
|
337
|
+
* for await (const tx of page) {
|
|
338
|
+
* console.log(tx.id, tx.status);
|
|
339
|
+
* }
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
getTransactionHistory(params?: GetTransactionHistoryParams, overrides?: RequestOverrides): Promise<Page<WalletTransaction>>;
|
|
343
|
+
/**
|
|
344
|
+
* Fetches a single transaction record — the authoritative view of a transfer's outcome.
|
|
345
|
+
* Poll this after an async `202` until `status` is `COMPLETED` or `FAILED`. Requires
|
|
346
|
+
* `wallet.transfer.read`.
|
|
347
|
+
*/
|
|
348
|
+
getTransaction(id: string, overrides?: RequestOverrides): Promise<WalletTransaction>;
|
|
349
|
+
/** Returns the business's spendable USD balance, used to pay gas on mainnet transfers. Requires `wallet.balance.read`. */
|
|
350
|
+
getBalance(overrides?: RequestOverrides): Promise<WalletBalance>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
type TokenType = "ASSET" | "YIELD_BEARING";
|
|
354
|
+
type TokenStatus = LooseUnion<"PENDING" | "ACTIVE" | "PAUSED">;
|
|
355
|
+
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER">;
|
|
356
|
+
type TokenTransactionStatus = LooseUnion<"PENDING" | "CONFIRMED" | "FAILED">;
|
|
357
|
+
interface YieldParams {
|
|
358
|
+
/** Annual yield rate as a percentage, e.g. `5.5` for 5.5%. */
|
|
359
|
+
annualRate: number;
|
|
360
|
+
/** Maturity date, `YYYY-MM-DD`. */
|
|
361
|
+
maturityDate: string;
|
|
362
|
+
/** First coupon date, `YYYY-MM-DD`. */
|
|
363
|
+
firstCouponDate: string;
|
|
364
|
+
/** Coupon interval, in days. */
|
|
365
|
+
couponInterval: number;
|
|
366
|
+
/** Day-count convention, e.g. `"ACT_365"`. */
|
|
367
|
+
dayCount: string;
|
|
368
|
+
/** Face value per token, in fiat major units. */
|
|
369
|
+
faceValuePerToken: number;
|
|
370
|
+
/** Grace period, in seconds. */
|
|
371
|
+
gracePeriod?: number;
|
|
372
|
+
callable?: boolean;
|
|
373
|
+
/** Call date, `YYYY-MM-DD`. Only meaningful when `callable` is `true`. */
|
|
374
|
+
callDate?: string;
|
|
375
|
+
}
|
|
376
|
+
interface CreateTokenParams {
|
|
377
|
+
/** Short token symbol, e.g. `"ACMB3"`. */
|
|
378
|
+
ticker: string;
|
|
379
|
+
name: string;
|
|
380
|
+
/** Issue price per token, in fiat major units. */
|
|
381
|
+
price?: number;
|
|
382
|
+
chain: Chain;
|
|
383
|
+
decimals: number;
|
|
384
|
+
/** Asset class, e.g. `"MONEY_MARKET"`. */
|
|
385
|
+
assetClass: string;
|
|
386
|
+
tokenType: TokenType;
|
|
387
|
+
/** Maximum holders; `0` for unlimited. */
|
|
388
|
+
maxShareholders?: number;
|
|
389
|
+
/** Per-investor cap; `0` for unlimited. */
|
|
390
|
+
maxTokensPerInvestor?: number;
|
|
391
|
+
/** Lock-up duration, in seconds; `0` for none. */
|
|
392
|
+
lockUpDuration?: number;
|
|
393
|
+
/** Required when `tokenType` is `"YIELD_BEARING"`. */
|
|
394
|
+
yieldParams?: YieldParams;
|
|
395
|
+
}
|
|
396
|
+
/** Result of a token deployment submission — `status` starts `PENDING` until the chain confirms it. */
|
|
397
|
+
interface TokenDeploymentResult {
|
|
398
|
+
id: string;
|
|
399
|
+
chain: Chain;
|
|
400
|
+
status: TokenStatus;
|
|
401
|
+
operationRef: string;
|
|
402
|
+
tokenAdmin: string;
|
|
403
|
+
txHash: string;
|
|
404
|
+
}
|
|
405
|
+
/** Summary shape returned by {@link TokenizationResource.listTokens}. */
|
|
406
|
+
interface TokenSummary {
|
|
407
|
+
id: string;
|
|
408
|
+
projectId: string;
|
|
409
|
+
businessId: string;
|
|
410
|
+
ticker: string;
|
|
411
|
+
name: string;
|
|
412
|
+
assetClass: string;
|
|
413
|
+
tokenType: TokenType;
|
|
414
|
+
decimals: number;
|
|
415
|
+
totalSupply: string;
|
|
416
|
+
circulatingSupply: string;
|
|
417
|
+
chain: Chain;
|
|
418
|
+
status: TokenStatus;
|
|
419
|
+
deploymentRef: string;
|
|
420
|
+
contractAddress: string;
|
|
421
|
+
createdAt: string;
|
|
422
|
+
updatedAt: string;
|
|
423
|
+
createdBy: string;
|
|
424
|
+
}
|
|
425
|
+
/** Per-chain deployment details within a {@link TokenDetail}. */
|
|
426
|
+
interface TokenChainDeployment {
|
|
427
|
+
id: string;
|
|
428
|
+
chain: Chain;
|
|
429
|
+
tokenAdmin: string;
|
|
430
|
+
decimals: number;
|
|
431
|
+
status: TokenStatus;
|
|
432
|
+
deploymentRef: string;
|
|
433
|
+
contractAddress: string;
|
|
434
|
+
}
|
|
435
|
+
/** Detailed shape returned by {@link TokenizationResource.getToken}, including every chain it's deployed on. */
|
|
436
|
+
interface TokenDetail {
|
|
437
|
+
id: string;
|
|
438
|
+
projectId: string;
|
|
439
|
+
businessId: string;
|
|
440
|
+
ticker: string;
|
|
441
|
+
name: string;
|
|
442
|
+
price?: string | number;
|
|
443
|
+
assetClass: string;
|
|
444
|
+
tokenType: TokenType;
|
|
445
|
+
status: TokenStatus;
|
|
446
|
+
createdAt: string;
|
|
447
|
+
updatedAt: string;
|
|
448
|
+
chains: TokenChainDeployment[];
|
|
449
|
+
}
|
|
450
|
+
interface ListTokensParams {
|
|
451
|
+
/** Default `1`. */
|
|
452
|
+
page?: number;
|
|
453
|
+
/** Default `20`. */
|
|
454
|
+
pageSize?: number;
|
|
455
|
+
}
|
|
456
|
+
interface BurnTokenParams {
|
|
457
|
+
tokenId: string;
|
|
458
|
+
chain: Chain;
|
|
459
|
+
/** Holder address to burn from. */
|
|
460
|
+
fromAddress: string;
|
|
461
|
+
/** Amount to burn, in token units. */
|
|
462
|
+
amount: number;
|
|
463
|
+
/** Optional note recorded with the operation. */
|
|
464
|
+
memo?: string;
|
|
465
|
+
}
|
|
466
|
+
interface MintTokenParams {
|
|
467
|
+
tokenId: string;
|
|
468
|
+
chain: Chain;
|
|
469
|
+
/** Recipient wallet address. */
|
|
470
|
+
toAddress: string;
|
|
471
|
+
/** Amount to mint, in token units. */
|
|
472
|
+
amount: number;
|
|
473
|
+
memo?: string;
|
|
474
|
+
}
|
|
475
|
+
interface TransferTokenParams {
|
|
476
|
+
tokenId: string;
|
|
477
|
+
chain: Chain;
|
|
478
|
+
fromAddress: string;
|
|
479
|
+
toAddress: string;
|
|
480
|
+
/** Amount to transfer, in token units. */
|
|
481
|
+
amount: number;
|
|
482
|
+
memo?: string;
|
|
483
|
+
}
|
|
484
|
+
/** Result of {@link TokenizationResource.mintToken} / {@link TokenizationResource.burnToken}. */
|
|
485
|
+
interface TokenOperationResult {
|
|
486
|
+
operationRef: string;
|
|
487
|
+
transactionId: string;
|
|
488
|
+
txHash: string;
|
|
489
|
+
}
|
|
490
|
+
/** Result of {@link TokenizationResource.transferToken} — the settled on-chain transfer record. */
|
|
491
|
+
interface TokenTransferResult {
|
|
492
|
+
id: string;
|
|
493
|
+
type: string;
|
|
494
|
+
chainType: ChainType;
|
|
495
|
+
network: Network;
|
|
496
|
+
chainId: number;
|
|
497
|
+
signerType: string;
|
|
498
|
+
fromAddress: string;
|
|
499
|
+
addressIndex: number | null;
|
|
500
|
+
toAddress: string;
|
|
501
|
+
/** Amount in token units, as a decimal string. */
|
|
502
|
+
amount: string;
|
|
503
|
+
tokenAddress: string | null;
|
|
504
|
+
data: string | null;
|
|
505
|
+
value: string | null;
|
|
506
|
+
txHash: string;
|
|
507
|
+
status: TokenTransactionStatus;
|
|
508
|
+
gasUsed: string | null;
|
|
509
|
+
feeWei: string | null;
|
|
510
|
+
createdAt: string;
|
|
511
|
+
updatedAt: string;
|
|
512
|
+
}
|
|
513
|
+
interface RegisterTokenWalletParams {
|
|
514
|
+
tokenId: string;
|
|
515
|
+
chain: Chain;
|
|
516
|
+
walletAddress: string;
|
|
517
|
+
}
|
|
518
|
+
interface RegisterTokenWalletResult {
|
|
519
|
+
tokenId: string;
|
|
520
|
+
chain: Chain;
|
|
521
|
+
walletAddress: string;
|
|
522
|
+
}
|
|
523
|
+
interface GetTokenHoldersParams {
|
|
524
|
+
tokenId: string;
|
|
525
|
+
chain?: Chain;
|
|
526
|
+
page?: number;
|
|
527
|
+
pageSize?: number;
|
|
528
|
+
}
|
|
529
|
+
interface TokenHolder {
|
|
530
|
+
walletAddress: string;
|
|
531
|
+
/** Balance in token units, as a decimal string. */
|
|
532
|
+
balance: string;
|
|
533
|
+
}
|
|
534
|
+
interface ListTokenTransactionsParams {
|
|
535
|
+
tokenId?: string;
|
|
536
|
+
page?: number;
|
|
537
|
+
pageSize?: number;
|
|
538
|
+
}
|
|
539
|
+
/** A recorded on-chain operation against a token (mint, burn, or transfer). */
|
|
540
|
+
interface TokenTransactionRecord {
|
|
541
|
+
id: string;
|
|
542
|
+
tokenId: string;
|
|
543
|
+
chain: Chain;
|
|
544
|
+
projectId?: string;
|
|
545
|
+
type: TokenTransactionType;
|
|
546
|
+
status: TokenTransactionStatus;
|
|
547
|
+
fromAddress?: string;
|
|
548
|
+
toAddress?: string;
|
|
549
|
+
/** Amount in token units, as a decimal string. */
|
|
550
|
+
amount: string;
|
|
551
|
+
txHash: string;
|
|
552
|
+
blockNumber?: number;
|
|
553
|
+
blockHash?: string;
|
|
554
|
+
gasUsed?: string;
|
|
555
|
+
feeWei?: string;
|
|
556
|
+
operationRef?: string;
|
|
557
|
+
memo?: string;
|
|
558
|
+
createdAt?: string;
|
|
559
|
+
confirmedAt?: string;
|
|
560
|
+
}
|
|
561
|
+
interface UpdateTokenYieldParams {
|
|
562
|
+
/** Yield-bearing token id. */
|
|
563
|
+
tokenId: string;
|
|
564
|
+
chain: Chain;
|
|
565
|
+
/** New annual yield rate, as a percentage. */
|
|
566
|
+
annualRate: number;
|
|
567
|
+
}
|
|
568
|
+
interface DistributeYieldParams {
|
|
569
|
+
tokenId: string;
|
|
570
|
+
chain: Chain;
|
|
571
|
+
/** Amount to fund the distribution, in fiat major units. */
|
|
572
|
+
fundAmount: number;
|
|
573
|
+
/** Seconds after which unclaimed funds may be reclaimed. */
|
|
574
|
+
reclaimAfter?: number;
|
|
575
|
+
memo?: string;
|
|
576
|
+
}
|
|
577
|
+
interface PayCouponParams {
|
|
578
|
+
tokenId: string;
|
|
579
|
+
chain: Chain;
|
|
580
|
+
/** Push the coupon to investors instead of letting them claim it. */
|
|
581
|
+
pushYield?: boolean;
|
|
582
|
+
reclaimAfter?: number;
|
|
583
|
+
memo?: string;
|
|
584
|
+
}
|
|
585
|
+
interface ClaimYieldParams {
|
|
586
|
+
tokenId: string;
|
|
587
|
+
chain: Chain;
|
|
588
|
+
/** HD address index of the claiming investor. */
|
|
589
|
+
investorAddressIndex: number;
|
|
590
|
+
/** Distribution snapshot to claim against. */
|
|
591
|
+
snapshotId: number;
|
|
592
|
+
}
|
|
593
|
+
interface RedeemPrincipalParams {
|
|
594
|
+
tokenId: string;
|
|
595
|
+
chain: Chain;
|
|
596
|
+
/** Push redeemed funds to investors instead of letting them claim. */
|
|
597
|
+
pushYield?: boolean;
|
|
598
|
+
}
|
|
599
|
+
/** Result of a yield operation that only returns a transaction hash. */
|
|
600
|
+
interface YieldTxResult {
|
|
601
|
+
txHash: string;
|
|
602
|
+
}
|
|
603
|
+
/** Result of a yield operation that also returns an operation reference (distribute, pay-coupon). */
|
|
604
|
+
interface YieldOperationResult {
|
|
605
|
+
operationRef: string;
|
|
606
|
+
txHash: string;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* The Tokenization service — issues and manages tokenized real-world assets: deployment,
|
|
611
|
+
* mint/burn/transfer, wallet whitelisting, holder balances, and the yield lifecycle
|
|
612
|
+
* (rate updates, coupon payments, claims, and principal redemption) for `YIELD_BEARING`
|
|
613
|
+
* tokens.
|
|
614
|
+
*/
|
|
615
|
+
declare class TokenizationResource extends APIResource {
|
|
616
|
+
/**
|
|
617
|
+
* Issues a new tokenized asset and deploys it on the target chain. Returns immediately
|
|
618
|
+
* with a `PENDING` token plus a deployment `operationRef` and `txHash` — poll
|
|
619
|
+
* {@link getToken} until `status` is `ACTIVE`. Supply `yieldParams` for a
|
|
620
|
+
* `YIELD_BEARING` token.
|
|
621
|
+
*/
|
|
622
|
+
createToken(params: CreateTokenParams, overrides?: RequestOverrides): Promise<TokenDeploymentResult>;
|
|
623
|
+
/**
|
|
624
|
+
* Returns a paginated list of tokens for the calling project.
|
|
625
|
+
*
|
|
626
|
+
* ```ts
|
|
627
|
+
* const page = await client.tokenization.listTokens();
|
|
628
|
+
* for await (const token of page) console.log(token.ticker, token.status);
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
listTokens(params?: ListTokensParams, overrides?: RequestOverrides): Promise<Page<TokenSummary>>;
|
|
632
|
+
/** Fetches a single token by id, including its per-chain deployment details. */
|
|
633
|
+
getToken(id: string, overrides?: RequestOverrides): Promise<TokenDetail>;
|
|
634
|
+
/** Mints new units of a token to a recipient address. */
|
|
635
|
+
mintToken(params: MintTokenParams, overrides?: RequestOverrides): Promise<TokenOperationResult>;
|
|
636
|
+
/** Burns units of a token from a holder address. */
|
|
637
|
+
burnToken(params: BurnTokenParams, overrides?: RequestOverrides): Promise<TokenOperationResult>;
|
|
638
|
+
/** Transfers token units between holder addresses. */
|
|
639
|
+
transferToken(params: TransferTokenParams, overrides?: RequestOverrides): Promise<TokenTransferResult>;
|
|
640
|
+
/** Registers (whitelists) a wallet address so it can hold a given token. */
|
|
641
|
+
registerWallet(params: RegisterTokenWalletParams, overrides?: RequestOverrides): Promise<RegisterTokenWalletResult>;
|
|
642
|
+
/** Returns the paginated list of holder wallet addresses and balances for a token on a chain. */
|
|
643
|
+
getTokenHolders(params: GetTokenHoldersParams, overrides?: RequestOverrides): Promise<Page<TokenHolder>>;
|
|
644
|
+
/** Fetches a single token transaction by its reference. */
|
|
645
|
+
getTokenTransaction(ref: string, overrides?: RequestOverrides): Promise<TokenTransactionRecord>;
|
|
646
|
+
/** Returns token transactions, optionally filtered by token. */
|
|
647
|
+
listTokenTransactions(params?: ListTokenTransactionsParams, overrides?: RequestOverrides): Promise<Page<TokenTransactionRecord>>;
|
|
648
|
+
/** Updates the annual yield rate for a yield-bearing token. */
|
|
649
|
+
updateYield(params: UpdateTokenYieldParams, overrides?: RequestOverrides): Promise<YieldTxResult>;
|
|
650
|
+
/** Funds and distributes a yield payout to holders. Unclaimed funds may be reclaimed after `reclaimAfter`. */
|
|
651
|
+
distributeYield(params: DistributeYieldParams, overrides?: RequestOverrides): Promise<YieldOperationResult>;
|
|
652
|
+
/** Pays the scheduled coupon for a yield-bearing token. Set `pushYield` to push funds rather than let investors claim. */
|
|
653
|
+
payCoupon(params: PayCouponParams, overrides?: RequestOverrides): Promise<YieldOperationResult>;
|
|
654
|
+
/** Claims an investor's yield for a given distribution snapshot. */
|
|
655
|
+
claimYield(params: ClaimYieldParams, overrides?: RequestOverrides): Promise<YieldTxResult>;
|
|
656
|
+
/** Redeems principal to holders at maturity. Set `pushYield` to push funds rather than let investors claim. */
|
|
657
|
+
redeemPrincipal(params: RedeemPrincipalParams, overrides?: RequestOverrides): Promise<YieldTxResult>;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
type SubscriptionStatus = LooseUnion<"active" | "paused" | "deleted">;
|
|
661
|
+
type EventFamily = "EVM" | "SOL";
|
|
662
|
+
type EventKind = LooseUnion<"onchain" | "derived">;
|
|
663
|
+
/** A Blockchain Events subscription streaming decoded contract events to your webhook. */
|
|
664
|
+
interface IndexerSubscription {
|
|
665
|
+
id: string;
|
|
666
|
+
projectId: string;
|
|
667
|
+
network: Chain;
|
|
668
|
+
contractAddress: string;
|
|
669
|
+
webhookUrl: string;
|
|
670
|
+
/** Subscribed event catalog keys, e.g. `["transfer", "burn"]`. */
|
|
671
|
+
events: string[];
|
|
672
|
+
status: SubscriptionStatus;
|
|
673
|
+
createdBy: string;
|
|
674
|
+
createdAt: string;
|
|
675
|
+
updatedAt: string;
|
|
676
|
+
lastDeliveryAt: string | null;
|
|
677
|
+
deliveredCount: number;
|
|
678
|
+
failedCount: number;
|
|
679
|
+
droppedCount: number;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* An {@link IndexerSubscription} augmented with the HMAC signing secret. Only returned by
|
|
683
|
+
* {@link IndexerResource.createSubscription} and {@link IndexerResource.rotateSigningSecret}
|
|
684
|
+
* — the secret is never shown again after that response, so store it immediately.
|
|
685
|
+
*/
|
|
686
|
+
interface IndexerSubscriptionWithSecret extends IndexerSubscription {
|
|
687
|
+
signingSecret: string;
|
|
688
|
+
secretWarning: string;
|
|
689
|
+
}
|
|
690
|
+
interface CreateSubscriptionParams {
|
|
691
|
+
network: Chain;
|
|
692
|
+
/** Contract to watch (1-128 chars). */
|
|
693
|
+
contractAddress: string;
|
|
694
|
+
/** HTTPS URL to deliver events to. */
|
|
695
|
+
webhookUrl: string;
|
|
696
|
+
/** Catalog keys to subscribe to. Omit to subscribe to all events for the contract. */
|
|
697
|
+
events?: string[];
|
|
698
|
+
}
|
|
699
|
+
interface ListSubscriptionsParams {
|
|
700
|
+
/** Default `1`. */
|
|
701
|
+
page?: number;
|
|
702
|
+
/** Default `20`. */
|
|
703
|
+
limit?: number;
|
|
704
|
+
}
|
|
705
|
+
interface UpdateSubscriptionParams {
|
|
706
|
+
/** New HTTPS URL. */
|
|
707
|
+
webhookUrl?: string;
|
|
708
|
+
/** Replacement event keys (at least one). */
|
|
709
|
+
events?: string[];
|
|
710
|
+
/** Use {@link IndexerResource.deleteSubscription} to remove a subscription instead of setting a "deleted" status. */
|
|
711
|
+
status?: "active" | "paused";
|
|
712
|
+
}
|
|
713
|
+
interface ListEventCatalogParams {
|
|
714
|
+
family?: EventFamily;
|
|
715
|
+
}
|
|
716
|
+
/** A subscribable event key in the Blockchain Events catalog. */
|
|
717
|
+
interface EventCatalogEntry {
|
|
718
|
+
key: string;
|
|
719
|
+
family: EventFamily;
|
|
720
|
+
kind: EventKind;
|
|
721
|
+
label: string;
|
|
722
|
+
/** Solidity event signature, e.g. `"Transfer(address,address,uint256)"`. */
|
|
723
|
+
signature: string;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* The Blockchain Events (Indexer) service — subscribe to decoded on-chain events for a
|
|
728
|
+
* contract and receive them at your webhook, signed with a per-subscription secret.
|
|
729
|
+
*
|
|
730
|
+
* Every operation requires a token bound to a project and business, and is gated on a
|
|
731
|
+
* capability granted by your plan (e.g. `indexer.subscribe.evm`).
|
|
732
|
+
*/
|
|
733
|
+
declare class IndexerResource extends APIResource {
|
|
734
|
+
/**
|
|
735
|
+
* Creates a subscription that streams decoded events for a contract to your webhook.
|
|
736
|
+
* Requires the network's subscribe capability (e.g. `indexer.subscribe.evm`).
|
|
737
|
+
*
|
|
738
|
+
* The response includes `signingSecret` only on creation — store it securely, it is
|
|
739
|
+
* never shown again (see {@link rotateSigningSecret} if you lose it).
|
|
740
|
+
*/
|
|
741
|
+
createSubscription(params: CreateSubscriptionParams, overrides?: RequestOverrides): Promise<IndexerSubscriptionWithSecret>;
|
|
742
|
+
/** Lists the project's subscriptions. Requires `indexer.subscription.list`. */
|
|
743
|
+
listSubscriptions(params?: ListSubscriptionsParams, overrides?: RequestOverrides): Promise<Page<IndexerSubscription>>;
|
|
744
|
+
/** Fetches one subscription. Requires `indexer.subscription.read`. */
|
|
745
|
+
getSubscription(id: string, overrides?: RequestOverrides): Promise<IndexerSubscription>;
|
|
746
|
+
/** Updates a subscription's webhook, events, or status. At least one field is required. Requires `indexer.subscription.update`. */
|
|
747
|
+
updateSubscription(id: string, params: UpdateSubscriptionParams, overrides?: RequestOverrides): Promise<IndexerSubscription>;
|
|
748
|
+
/** Soft-deletes a subscription (`status` becomes `"deleted"`; deliveries stop). Requires `indexer.subscription.delete`. */
|
|
749
|
+
deleteSubscription(id: string, overrides?: RequestOverrides): Promise<IndexerSubscription>;
|
|
750
|
+
/**
|
|
751
|
+
* Generates a new signing secret and invalidates the old one. Requires
|
|
752
|
+
* `indexer.subscription.rotate_secret`. The response includes the new `signingSecret`
|
|
753
|
+
* once — store it immediately.
|
|
754
|
+
*/
|
|
755
|
+
rotateSigningSecret(id: string, overrides?: RequestOverrides): Promise<IndexerSubscriptionWithSecret>;
|
|
756
|
+
/** Returns the catalog of subscribable event keys. Requires `indexer.subscription.list`. */
|
|
757
|
+
listEventCatalog(params?: ListEventCatalogParams, overrides?: RequestOverrides): Promise<EventCatalogEntry[]>;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
interface InfraClientOptions {
|
|
761
|
+
/** Your Convexity Infra project API key (`sk_live_...` or `sk_test_...`). Exchanged internally for a bearer token. */
|
|
762
|
+
apiKey: string;
|
|
763
|
+
/** Overrides the API host. Defaults to `"https://api.withconvexity.com"`. */
|
|
764
|
+
baseURL?: string;
|
|
765
|
+
/** Space-separated OAuth scopes to request for minted tokens. Omit for full access. */
|
|
766
|
+
scope?: string;
|
|
767
|
+
/** Default per-request timeout in milliseconds. Default 30000. */
|
|
768
|
+
timeoutMs?: number;
|
|
769
|
+
/** Default number of retries for rate limits, service-unavailable responses, and safe connection errors. Default 2. */
|
|
770
|
+
maxRetries?: number;
|
|
771
|
+
/** Override the fetch implementation (mainly for testing). Defaults to the global `fetch`. */
|
|
772
|
+
fetch?: typeof fetch;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Client for the Convexity Infra API — Wallet, Tokenization, and Blockchain Events (Indexer).
|
|
776
|
+
*
|
|
777
|
+
* ```ts
|
|
778
|
+
* import { InfraClient } from "infra-sdk-typescript";
|
|
779
|
+
*
|
|
780
|
+
* const infra = new InfraClient({ apiKey: process.env.INFRA_API_KEY! });
|
|
781
|
+
* const balance = await infra.wallet.getBalance();
|
|
782
|
+
* ```
|
|
783
|
+
*/
|
|
784
|
+
declare class InfraClient {
|
|
785
|
+
readonly wallet: WalletResource;
|
|
786
|
+
readonly tokenization: TokenizationResource;
|
|
787
|
+
readonly indexer: IndexerResource;
|
|
788
|
+
private readonly http;
|
|
789
|
+
private readonly auth;
|
|
790
|
+
constructor(options: InfraClientOptions);
|
|
791
|
+
/**
|
|
792
|
+
* Low-level escape hatch that issues a raw request against the Infra API using this
|
|
793
|
+
* client's auth, retry, and timeout configuration. The typed resource methods
|
|
794
|
+
* (`client.wallet.*`, `client.tokenization.*`, `client.indexer.*`) are built on top of
|
|
795
|
+
* this and should be preferred — reach for this only to call an endpoint this SDK
|
|
796
|
+
* version doesn't wrap yet.
|
|
797
|
+
*/
|
|
798
|
+
request<T>(options: RequestOptions): Promise<T>;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/** Base class for every error raised by this SDK. */
|
|
802
|
+
declare class InfraError extends Error {
|
|
803
|
+
constructor(message: string);
|
|
804
|
+
}
|
|
805
|
+
/** The request never reached the server (DNS/TCP/TLS failure, aborted connection, etc). */
|
|
806
|
+
declare class InfraConnectionError extends InfraError {
|
|
807
|
+
readonly cause?: unknown | undefined;
|
|
808
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
809
|
+
}
|
|
810
|
+
declare class InfraConnectionTimeoutError extends InfraConnectionError {
|
|
811
|
+
constructor(timeoutMs: number);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Constructed via {@link errorFromResponse}, which picks the most specific subclass for
|
|
815
|
+
* the HTTP status code — prefer catching a subclass (e.g. {@link RateLimitError}) over
|
|
816
|
+
* this base class when you need to branch on the failure kind.
|
|
817
|
+
*/
|
|
818
|
+
declare class InfraAPIError extends InfraError {
|
|
819
|
+
readonly status: number;
|
|
820
|
+
/** Field-level validation messages, when the server included an `errors` array. */
|
|
821
|
+
readonly errors: readonly string[] | undefined;
|
|
822
|
+
/** The raw, parsed JSON response body, for callers that need fields this SDK doesn't model. */
|
|
823
|
+
readonly body: unknown;
|
|
824
|
+
/** Response headers, lower-cased keys. */
|
|
825
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
826
|
+
constructor(status: number, message: string,
|
|
827
|
+
/** Field-level validation messages, when the server included an `errors` array. */
|
|
828
|
+
errors: readonly string[] | undefined,
|
|
829
|
+
/** The raw, parsed JSON response body, for callers that need fields this SDK doesn't model. */
|
|
830
|
+
body: unknown,
|
|
831
|
+
/** Response headers, lower-cased keys. */
|
|
832
|
+
headers: Readonly<Record<string, string>>);
|
|
833
|
+
}
|
|
834
|
+
declare class BadRequestError extends InfraAPIError {
|
|
835
|
+
}
|
|
836
|
+
declare class AuthenticationError extends InfraAPIError {
|
|
837
|
+
}
|
|
838
|
+
declare class PaymentRequiredError extends InfraAPIError {
|
|
839
|
+
}
|
|
840
|
+
declare class PermissionDeniedError extends InfraAPIError {
|
|
841
|
+
}
|
|
842
|
+
declare class NotFoundError extends InfraAPIError {
|
|
843
|
+
}
|
|
844
|
+
declare class ConflictError extends InfraAPIError {
|
|
845
|
+
}
|
|
846
|
+
declare class UnprocessableEntityError extends InfraAPIError {
|
|
847
|
+
}
|
|
848
|
+
declare class RateLimitError extends InfraAPIError {
|
|
849
|
+
/** Seconds to wait before retrying, from the response body's `retryAfter` or a `Retry-After` header. */
|
|
850
|
+
readonly retryAfterSeconds: number | undefined;
|
|
851
|
+
constructor(status: number, message: string, errors: readonly string[] | undefined, body: unknown, headers: Readonly<Record<string, string>>,
|
|
852
|
+
/** Seconds to wait before retrying, from the response body's `retryAfter` or a `Retry-After` header. */
|
|
853
|
+
retryAfterSeconds: number | undefined);
|
|
854
|
+
}
|
|
855
|
+
declare class InternalServerError extends InfraAPIError {
|
|
856
|
+
}
|
|
857
|
+
declare class ServiceUnavailableError extends InfraAPIError {
|
|
858
|
+
}
|
|
859
|
+
declare class UnknownAPIError extends InfraAPIError {
|
|
860
|
+
}
|
|
861
|
+
/** Raised by `POST /v1/oauth/token` failures, which use an OAuth 2.0 error body instead of the standard envelope. */
|
|
862
|
+
declare class InfraAuthTokenError extends InfraError {
|
|
863
|
+
readonly status: number;
|
|
864
|
+
readonly error: string;
|
|
865
|
+
readonly errorDescription: string | undefined;
|
|
866
|
+
constructor(status: number, error: string, errorDescription: string | undefined);
|
|
867
|
+
}
|
|
868
|
+
declare class WebhookSignatureVerificationError extends InfraError {
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
interface VerifyWalletWebhookOptions {
|
|
872
|
+
/** The exact, unparsed request body as received (Buffer or string) — do not re-serialize parsed JSON. */
|
|
873
|
+
payload: string | Buffer;
|
|
874
|
+
/** Value of the `x-wallet-timestamp` header. */
|
|
875
|
+
timestampHeader: string;
|
|
876
|
+
/** Value of the `x-wallet-signature` header. */
|
|
877
|
+
signatureHeader: string;
|
|
878
|
+
/** The `webhookSecret` you supplied when creating the transfer/sign request. */
|
|
879
|
+
secret: string;
|
|
880
|
+
/** How old (in seconds) a timestamp may be before it's rejected as a possible replay. Default 300 (5 minutes). */
|
|
881
|
+
toleranceSeconds?: number;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Verifies a Wallet outcome webhook delivery (`wallet.transfer.completed` /
|
|
885
|
+
* `wallet.transfer.failed` / `wallet.sign.completed` / `wallet.sign.failed`).
|
|
886
|
+
*
|
|
887
|
+
* The signature is `HMAC-SHA256("<timestamp>.<rawBody>")`, hex-encoded, and the delivery
|
|
888
|
+
* is rejected if the timestamp is older than `toleranceSeconds` to block replay attacks.
|
|
889
|
+
*
|
|
890
|
+
* @throws {WebhookSignatureVerificationError} if the timestamp is missing/stale or the signature doesn't match.
|
|
891
|
+
*/
|
|
892
|
+
declare function verifyWalletWebhookSignature(options: VerifyWalletWebhookOptions): void;
|
|
893
|
+
interface VerifyIndexerWebhookOptions {
|
|
894
|
+
/** The exact, unparsed request body as received (Buffer or string) — do not re-serialize parsed JSON. */
|
|
895
|
+
payload: string | Buffer;
|
|
896
|
+
/** Value of the `X-Indexer-Signature` header. */
|
|
897
|
+
signatureHeader: string;
|
|
898
|
+
/** The subscription's `signingSecret`, returned once on creation or secret rotation. */
|
|
899
|
+
secret: string;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Verifies a Blockchain Events (Indexer) webhook delivery. The signature is
|
|
903
|
+
* `HMAC-SHA256(rawBody)`, hex-encoded, with no timestamp component.
|
|
904
|
+
*
|
|
905
|
+
* @throws {WebhookSignatureVerificationError} if the signature doesn't match.
|
|
906
|
+
*/
|
|
907
|
+
declare function verifyIndexerWebhookSignature(options: VerifyIndexerWebhookOptions): void;
|
|
908
|
+
|
|
909
|
+
/** Generates a UUIDv4 suitable for use as an `Idempotency-Key` header value. */
|
|
910
|
+
declare function generateIdempotencyKey(): string;
|
|
911
|
+
|
|
912
|
+
export { AuthenticationError, BadRequestError, type BurnTokenParams, type Chain, type ChainType, type ClaimYieldParams, ConflictError, type CreateSubscriptionParams, type CreateTokenParams, type DeactivateWalletParams, type DistributeYieldParams, type EventCatalogEntry, type EventFamily, type EventKind, type FlatPaginatedResponse, type GenerateWalletsParams, type GeneratedWallet, type GetTokenHoldersParams, type GetTransactionHistoryParams, type GetWalletByAddressIndexParams, type GetWalletByAddressParams, type GetWalletCountParams, type HdEnabledStatus, type HttpMethod, type IdempotentRequestOverrides, IndexerResource, type IndexerSubscription, type IndexerSubscriptionWithSecret, InfraAPIError, InfraAuthTokenError, InfraClient, type InfraClientOptions, InfraConnectionError, InfraConnectionTimeoutError, InfraError, type InitiateTransferParams, InternalServerError, type ListEventCatalogParams, type ListSubscriptionsParams, type ListTokenTransactionsParams, type ListTokensParams, type ListWalletsParams, type LooseUnion, type MetaPaginatedResponse, type MintTokenParams, type Network, NotFoundError, type OffsetPaginatedResponse, Page, type PayCouponParams, PaymentRequiredError, PermissionDeniedError, type QueryValue, RateLimitError, type RedeemPrincipalParams, type RegisterTokenWalletParams, type RegisterTokenWalletResult, type RequestOptions, type RequestOverrides, ServiceUnavailableError, type SignTransactionParams, type SignTransactionRequest, type SignedTransactionResult, type SubscriptionStatus, type SupportedChain, type TokenChainDeployment, type TokenDeploymentResult, type TokenDetail, type TokenHolder, type TokenOperationResult, type TokenStatus, type TokenSummary, type TokenTransactionRecord, type TokenTransactionStatus, type TokenTransactionType, type TokenTransferResult, type TokenType, TokenizationResource, type TransactionStatus, type TransferTokenParams, UnknownAPIError, UnprocessableEntityError, type UpdateSubscriptionParams, type UpdateTokenYieldParams, type VerifyIndexerWebhookOptions, type VerifyWalletWebhookOptions, type Wallet, type WalletBalance, type WalletCount, WalletResource, type WalletTransaction, WebhookSignatureVerificationError, type YieldOperationResult, type YieldParams, type YieldTxResult, generateIdempotencyKey, verifyIndexerWebhookSignature, verifyWalletWebhookSignature };
|