@coinlist-co/react 0.11.0 → 0.11.1-rc.22d81d4
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/dist/chunk-AQIHCFW4.js +279 -0
- package/dist/chunk-AQIHCFW4.js.map +1 -0
- package/dist/{chunk-B2HCVPCQ.js → chunk-PRG3EDQJ.js} +25 -10
- package/dist/chunk-PRG3EDQJ.js.map +1 -0
- package/dist/{chunk-UIIXXLA7.js → chunk-ZVB6KWZ2.js} +484 -141
- package/dist/chunk-ZVB6KWZ2.js.map +1 -0
- package/dist/client/index.cjs +1307 -461
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +216 -211
- package/dist/client/index.d.ts +216 -211
- package/dist/client/index.js +464 -108
- package/dist/client/index.js.map +1 -1
- package/dist/collections-DrJFEDHl.d.cts +116 -0
- package/dist/collections-pLtrj6fw.d.ts +116 -0
- package/dist/{config-B5mwS_2l.d.cts → config-C6vlghJY.d.cts} +713 -22
- package/dist/{config-B5mwS_2l.d.ts → config-C6vlghJY.d.ts} +713 -22
- package/dist/server/index.cjs +766 -209
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +80 -3
- package/dist/server/index.d.ts +80 -3
- package/dist/server/index.js +120 -51
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +486 -123
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +18 -5
- package/dist/shared/index.d.ts +18 -5
- package/dist/shared/index.js +8 -2
- package/package.json +3 -2
- package/dist/chunk-B2HCVPCQ.js.map +0 -1
- package/dist/chunk-KDGNDAHA.js +0 -146
- package/dist/chunk-KDGNDAHA.js.map +0 -1
- package/dist/chunk-UIIXXLA7.js.map +0 -1
- package/dist/collections-BhDkYmzV.d.cts +0 -65
- package/dist/collections-CZhHoQHr.d.ts +0 -65
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hex } from 'viem';
|
|
1
|
+
import { Hash, Hex } from 'viem';
|
|
2
2
|
|
|
3
3
|
declare const __brand: unique symbol;
|
|
4
4
|
type Newtype<Base, Branding> = Base & {
|
|
@@ -20,6 +20,523 @@ declare const ClientId: (value: string) => ClientId;
|
|
|
20
20
|
type ClientSecret = Newtype<string, 'ClientSecret'>;
|
|
21
21
|
declare const ClientSecret: (value: string) => ClientSecret;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* A classified wallet or transaction failure. The SDK derives this from
|
|
25
|
+
* whatever the {@link EvmWallet} throws, so hosts get a stable, typed error
|
|
26
|
+
* shape regardless of the wallet library underneath.
|
|
27
|
+
*
|
|
28
|
+
* Lives here rather than beside its classifier because it is the failure half
|
|
29
|
+
* of the {@link EvmWallet} contract, and because both `@/shared` and
|
|
30
|
+
* `@/client` name it: {@link LogCause} carries one, and classifying a thrown
|
|
31
|
+
* error into one needs viem's error classes, which are browser-side.
|
|
32
|
+
*/
|
|
33
|
+
type WalletError = {
|
|
34
|
+
type: 'user_rejected';
|
|
35
|
+
} | {
|
|
36
|
+
type: 'insufficient_funds';
|
|
37
|
+
} | {
|
|
38
|
+
type: 'contract_reverted';
|
|
39
|
+
/**
|
|
40
|
+
* What the contract said, when it said anything: a `require` string, a
|
|
41
|
+
* panic description, a custom error's name, or the four-byte selector of
|
|
42
|
+
* an error the ABI could not decode.
|
|
43
|
+
*
|
|
44
|
+
* `null` when a revert carried no data, since the string the RPC node
|
|
45
|
+
* offers in its place is not the contract's - see `classifyWalletError`.
|
|
46
|
+
* Nullable rather than optional so that every arm has to answer the
|
|
47
|
+
* question: "it reverted and said nothing" is a fact about the revert,
|
|
48
|
+
* and a caller should have to read it rather than miss it.
|
|
49
|
+
*
|
|
50
|
+
* Never the custom error's arguments. A name is a compile-time
|
|
51
|
+
* identifier; its operands are runtime values - an address, a balance -
|
|
52
|
+
* and those are `'debug'` material.
|
|
53
|
+
*/
|
|
54
|
+
reason: string | null;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'timeout';
|
|
57
|
+
hash: Hash;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'unknown';
|
|
60
|
+
cause: unknown;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A {@link WalletError} as it may be reported above `'debug'`: the
|
|
64
|
+
* classification, never the throw.
|
|
65
|
+
*
|
|
66
|
+
* Only the `unknown` arm differs, and it differs because it is the one arm
|
|
67
|
+
* carrying a value the SDK did not author - the raw error the wallet library
|
|
68
|
+
* threw, whose message and metadata hold the transaction's `from`, `to`,
|
|
69
|
+
* `value` and calldata. The other four carry compile-time constants or a
|
|
70
|
+
* server-minted identifier already, so they pass through as they stand.
|
|
71
|
+
*
|
|
72
|
+
* This exists as a type rather than as a scrub some function remembers to
|
|
73
|
+
* apply: `LogCause` names it, so an arm that grew a raw field would fail the
|
|
74
|
+
* build instead of quietly reaching {@link Logger.error}.
|
|
75
|
+
*/
|
|
76
|
+
type RedactedWalletError = Exclude<WalletError, {
|
|
77
|
+
type: 'unknown';
|
|
78
|
+
}> | {
|
|
79
|
+
type: 'unknown';
|
|
80
|
+
};
|
|
81
|
+
declare const RedactedWalletError: {
|
|
82
|
+
fromWalletError: (error: WalletError) => RedactedWalletError;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The observability seam a host implements to see inside the SDK.
|
|
87
|
+
*
|
|
88
|
+
* Pass an implementation as {@link Config.logger} and the SDK reports every
|
|
89
|
+
* request it makes, every failure it classifies, and every state a hook
|
|
90
|
+
* settles into. Leave it out and the SDK logs nothing at all - there is no
|
|
91
|
+
* fallback to `console`, at any level, on any codepath.
|
|
92
|
+
*
|
|
93
|
+
* Four methods over a {@link LogEvent} lambda, plus {@link level}. An event is
|
|
94
|
+
* a constant `msg`, the {@link LogScope} it came from, the accumulated
|
|
95
|
+
* {@link LogBindings}, and a bag of `fields` - so a host forwards structured
|
|
96
|
+
* records rather than parsing strings.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* const logger: Logger = {
|
|
100
|
+
* level: () => 'info',
|
|
101
|
+
* debug: () => {},
|
|
102
|
+
* info: (event) => sink.info(toRecord(event())),
|
|
103
|
+
* warn: (event) => sink.warn(toRecord(event())),
|
|
104
|
+
* error: (event) => sink.error(toRecord(event())),
|
|
105
|
+
* };
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* {@link pinoClientLogger} and {@link pinoServerLogger} are ready-made
|
|
109
|
+
* implementations over pino, and are what most hosts should reach for.
|
|
110
|
+
*
|
|
111
|
+
* ## Where to run it
|
|
112
|
+
*
|
|
113
|
+
* **Not in production, as the default answer.** Development, tests, staging,
|
|
114
|
+
* and reproducing a reported bug are where this seam earns its keep. Left
|
|
115
|
+
* undefined elsewhere it discloses nothing, and that holds no matter what a
|
|
116
|
+
* later revision of the SDK puts on a line.
|
|
117
|
+
*
|
|
118
|
+
* Where you do run one in production, `'info'` and above is the only sane
|
|
119
|
+
* choice, and the shipped implementations make the alternative unrepresentable
|
|
120
|
+
* rather than merely discouraged: `isDev: false` narrows the level to
|
|
121
|
+
* {@link ProductionLogLevel}, so `'debug'` does not compile. That narrowing is
|
|
122
|
+
* a guard for the partner who ignored this paragraph, not an endorsement of
|
|
123
|
+
* the practice.
|
|
124
|
+
*
|
|
125
|
+
* The distinction worth holding onto: `'info'` and above are **redacted by
|
|
126
|
+
* construction** - see the next section for exactly what that covers, and the
|
|
127
|
+
* type that enforces it. Redacted is a mechanism the SDK can hold itself to. A
|
|
128
|
+
* blanket "safe in production" is a promise about your environment that the
|
|
129
|
+
* SDK is in no position to make, and one that a single future field could
|
|
130
|
+
* quietly break.
|
|
131
|
+
*
|
|
132
|
+
* `'debug'` is for reproducing a bug: a developer's machine, tests, and beta
|
|
133
|
+
* or staging environments where the data flowing through the SDK is not real
|
|
134
|
+
* customer data.
|
|
135
|
+
*
|
|
136
|
+
* ## What each level may disclose
|
|
137
|
+
*
|
|
138
|
+
* **`'debug'` is unredacted. Every other level is not.**
|
|
139
|
+
*
|
|
140
|
+
* At `'debug'` the SDK reports request and response bodies, request headers,
|
|
141
|
+
* the full URL including its query string, and operation parameters
|
|
142
|
+
* **verbatim** - bearer tokens, KYC answers, tax-document fields, wallet
|
|
143
|
+
* signatures, the lot. There is no denylist and no redaction: see ADR-8 for
|
|
144
|
+
* why a partial guarantee was rejected in favour of an honest absence of one.
|
|
145
|
+
*
|
|
146
|
+
* At `'info'`, `'warn'` and `'error'` the SDK emits only its own
|
|
147
|
+
* classification of what happened and identifiers the server minted: a method
|
|
148
|
+
* and a bare path, a status, a duration, a {@link RequestId}, a frontline
|
|
149
|
+
* error code and event id, a {@link LogCause} arm. No request body, no
|
|
150
|
+
* response body, no query string, no host-supplied parameters, and no message
|
|
151
|
+
* text read off a thrown error the SDK did not author.
|
|
152
|
+
*
|
|
153
|
+
* The type carries that boundary rather than merely documenting it:
|
|
154
|
+
* {@link SafeEvent} constrains every field value to a {@link LogValue} scalar,
|
|
155
|
+
* so spreading a body, a DTO or an operation's params into an `info`, `warn`
|
|
156
|
+
* or `error` line does not compile. Only {@link DebugEvent} accepts arbitrary
|
|
157
|
+
* values.
|
|
158
|
+
*
|
|
159
|
+
* The one deliberate exception is an SDK-authored validation message, which
|
|
160
|
+
* quotes the single scalar that failed to map - `Unsupported chain:
|
|
161
|
+
* "solana_mainnet"`. It is a hand-written template naming one offending value,
|
|
162
|
+
* not a payload, and it is the whole reason this seam exists.
|
|
163
|
+
*
|
|
164
|
+
* ## Your responsibility
|
|
165
|
+
*
|
|
166
|
+
* The SDK hands you events. What happens next is yours: **you own the final
|
|
167
|
+
* filtering, redaction and retention** before anything is written to a file, a
|
|
168
|
+
* console, or a third-party sink such as Sentry or Datadog. In particular, if
|
|
169
|
+
* you implement {@link debug} and forward it anywhere durable, you have taken
|
|
170
|
+
* on storing live credentials and personal data, deliberately. Implement
|
|
171
|
+
* `debug` as a no-op - or return a level below it from {@link level} - in any
|
|
172
|
+
* environment where that is not acceptable.
|
|
173
|
+
*
|
|
174
|
+
* **Every event is a lambda, and that is load bearing.** The SDK consults
|
|
175
|
+
* {@link level} first and never invokes the lambda when the level forbids it,
|
|
176
|
+
* so an expensive debug event - a serialized DTO, a loop over balances - costs
|
|
177
|
+
* nothing in production where the level is `'error'` or `'none'`. Build the
|
|
178
|
+
* event inside the lambda, never outside it.
|
|
179
|
+
*
|
|
180
|
+
* ## Every method must be total
|
|
181
|
+
*
|
|
182
|
+
* **None of the five methods may throw, and that includes {@link level}.** The
|
|
183
|
+
* SDK calls them inline, on the codepath of the work it is reporting, and it
|
|
184
|
+
* does not catch them: a `logger.error` that throws while reporting a failed
|
|
185
|
+
* request turns that request's rejection into your logger's exception, and a
|
|
186
|
+
* `level()` that throws breaks the call it was asked about even when nothing
|
|
187
|
+
* else went wrong.
|
|
188
|
+
*
|
|
189
|
+
* That is deliberate. Swallowing would hide a logger that is broken in every
|
|
190
|
+
* environment, and the SDK cannot tell a transport blip in your sink from a
|
|
191
|
+
* bug in your implementation. So the contract is on this side of the seam:
|
|
192
|
+
* catch inside your implementation, and never let an exception out. The
|
|
193
|
+
* shipped pino implementations do exactly that.
|
|
194
|
+
*
|
|
195
|
+
* ```ts
|
|
196
|
+
* error: (event) => {
|
|
197
|
+
* try {
|
|
198
|
+
* const e = event();
|
|
199
|
+
* Sentry.captureMessage(e.msg, { extra: e });
|
|
200
|
+
* } catch {
|
|
201
|
+
* // never rethrow: the SDK is on the other side of this call
|
|
202
|
+
* }
|
|
203
|
+
* },
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
interface Logger {
|
|
207
|
+
/**
|
|
208
|
+
* The most detailed level this logger wants. Consulted before **every** log
|
|
209
|
+
* call, so keep it cheap and pure: return a captured constant or read a
|
|
210
|
+
* plain field. Do not read an environment variable, hit storage, or call
|
|
211
|
+
* out to a feature-flag service here.
|
|
212
|
+
*
|
|
213
|
+
* Returning `'none'` silences the SDK as completely as omitting the logger.
|
|
214
|
+
*
|
|
215
|
+
* **Must not throw.** It is consulted inside every SDK operation, so an
|
|
216
|
+
* exception here fails the operation itself.
|
|
217
|
+
*/
|
|
218
|
+
level(): LogLevel;
|
|
219
|
+
/**
|
|
220
|
+
* Fine-grained detail: request and response bodies, full URLs, headers,
|
|
221
|
+
* operation parameters, hook transitions.
|
|
222
|
+
*
|
|
223
|
+
* **Unredacted.** This is the only level that may carry credentials or
|
|
224
|
+
* personal data, and it always may. Its event is a {@link DebugEvent}, whose
|
|
225
|
+
* fields accept arbitrary values for exactly that reason. Do not forward it
|
|
226
|
+
* to a durable or third-party sink outside development and beta.
|
|
227
|
+
*
|
|
228
|
+
* **Must not throw**, here and on every method below.
|
|
229
|
+
*/
|
|
230
|
+
debug(event: () => DebugEvent): void;
|
|
231
|
+
/** Notable, expected events: a request completing, a flow advancing. */
|
|
232
|
+
info(event: () => SafeEvent): void;
|
|
233
|
+
/**
|
|
234
|
+
* Recoverable trouble: a retried request, a renewed session, a poll tick
|
|
235
|
+
* that failed while the last value still stands.
|
|
236
|
+
*
|
|
237
|
+
* Carries a {@link LogCause} when one was classified, the same as
|
|
238
|
+
* {@link error} does. What separates the two levels is whether anything
|
|
239
|
+
* actually broke, not how much is known about it.
|
|
240
|
+
*/
|
|
241
|
+
warn(event: () => SafeEvent): void;
|
|
242
|
+
/**
|
|
243
|
+
* A failure. {@link SafeEvent.cause} carries what the SDK knows about it,
|
|
244
|
+
* classified into {@link LogCause}, and is absent when the failure is not an
|
|
245
|
+
* error the SDK caught - a flow reporting the step it stopped at, for
|
|
246
|
+
* instance.
|
|
247
|
+
*
|
|
248
|
+
* Every part of the event is SDK-authored classification or server-authored
|
|
249
|
+
* identifiers, so forwarding it as it stands is safe. `scope` says which
|
|
250
|
+
* part of the SDK the line came from, which is what to route or filter on.
|
|
251
|
+
*/
|
|
252
|
+
error(event: () => SafeEvent): void;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* A value the SDK is willing to put in a structured field above `'debug'`.
|
|
256
|
+
*
|
|
257
|
+
* Scalars only, and that is the redaction boundary made structural rather than
|
|
258
|
+
* documentary. Every leak ADR-8 found was an *object* spread onto a line that
|
|
259
|
+
* a host forwards to a tracker - an operation's params, a thrown wallet error,
|
|
260
|
+
* a response body. None of them is assignable to this, so each is now a
|
|
261
|
+
* compile error rather than a review catch.
|
|
262
|
+
*
|
|
263
|
+
* It does not stop a call site writing `{ token: accessToken }`, and it is not
|
|
264
|
+
* meant to: a string is a string. What it stops is the mistake that actually
|
|
265
|
+
* happened.
|
|
266
|
+
*/
|
|
267
|
+
type LogValue = string | number | boolean | null;
|
|
268
|
+
/**
|
|
269
|
+
* Fields safe at every level: SDK-authored classification and server-minted
|
|
270
|
+
* identifiers, constrained to {@link LogValue}.
|
|
271
|
+
*/
|
|
272
|
+
type SafeFields = Readonly<Record<string, LogValue>>;
|
|
273
|
+
/**
|
|
274
|
+
* Fields for `'debug'` only: bodies, headers, full URLs, operation params,
|
|
275
|
+
* raw thrown values. Arbitrary values, because that is the point of the level.
|
|
276
|
+
*
|
|
277
|
+
* The SDK's own implementations render these into a form that cannot fail to
|
|
278
|
+
* serialize - a `bigint`, a cycle or a getter that throws must never turn a
|
|
279
|
+
* log line into a second failure - but they are otherwise passed through.
|
|
280
|
+
*/
|
|
281
|
+
type UnredactedFields = Readonly<Record<string, unknown>>;
|
|
282
|
+
/**
|
|
283
|
+
* One narrowing applied to a logger by {@link InternalLogger.child}.
|
|
284
|
+
*
|
|
285
|
+
* A union of single-key objects rather than a positional `string`, because the
|
|
286
|
+
* three things the SDK narrows by are not the same kind of thing: a request id
|
|
287
|
+
* correlates retries of one wire call, a flow name names an on-chain
|
|
288
|
+
* procedure, a hook name names a React binding. Rendered into one `[SCOPE:x]`
|
|
289
|
+
* prefix they were indistinguishable; as fields they must not be.
|
|
290
|
+
*
|
|
291
|
+
* `requestId` keeps its {@link RequestId} newtype rather than widening to
|
|
292
|
+
* `string` at the seam.
|
|
293
|
+
*/
|
|
294
|
+
type LogBinding = {
|
|
295
|
+
readonly requestId: RequestId;
|
|
296
|
+
} | {
|
|
297
|
+
readonly flow: string;
|
|
298
|
+
} | {
|
|
299
|
+
readonly hook: string;
|
|
300
|
+
} | {
|
|
301
|
+
readonly op: string;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Every {@link LogBinding} applied so far, merged. This is what reaches a
|
|
305
|
+
* host, so a line from `prepareOndoSwap` carries `flow: 'prepareSwap'` as its
|
|
306
|
+
* own key and is filterable without parsing anything.
|
|
307
|
+
*/
|
|
308
|
+
type LogBindings = {
|
|
309
|
+
readonly [K in LogBinding as keyof K]?: K[keyof K];
|
|
310
|
+
};
|
|
311
|
+
type BaseEvent = {
|
|
312
|
+
/**
|
|
313
|
+
* What happened, as a **constant string literal**.
|
|
314
|
+
*
|
|
315
|
+
* Never interpolated. A log aggregator groups by message, so a `msg` that
|
|
316
|
+
* embeds a status, a count or a reason produces one group per distinct
|
|
317
|
+
* value and is not groupable at all. Every varying value belongs in
|
|
318
|
+
* `fields`, which is what a host filters and facets on.
|
|
319
|
+
*
|
|
320
|
+
* This is a convention, not a checked rule: deslop reasons about import
|
|
321
|
+
* edges and cannot see a template literal, and the type-level approximations
|
|
322
|
+
* catch only some interpolations. ADR-8 records why a partial guarantee was
|
|
323
|
+
* refused here as elsewhere.
|
|
324
|
+
*/
|
|
325
|
+
readonly msg: string;
|
|
326
|
+
/**
|
|
327
|
+
* Which part of the SDK reported this. Stamped by
|
|
328
|
+
* {@link internalLogger}, never by a call site.
|
|
329
|
+
*/
|
|
330
|
+
readonly scope: LogScope;
|
|
331
|
+
/** Every {@link LogBinding} applied by {@link InternalLogger.child}. */
|
|
332
|
+
readonly bindings: LogBindings;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* An event for `'info'`, `'warn'` and `'error'` - the levels a host may run in
|
|
336
|
+
* production.
|
|
337
|
+
*
|
|
338
|
+
* Its fields are {@link SafeFields}, so nothing but a scalar can reach it.
|
|
339
|
+
*/
|
|
340
|
+
type SafeEvent = BaseEvent & {
|
|
341
|
+
readonly fields: SafeFields;
|
|
342
|
+
/**
|
|
343
|
+
* What the SDK knows about an accompanying failure, classified. Absent when
|
|
344
|
+
* there is nothing to classify.
|
|
345
|
+
*/
|
|
346
|
+
readonly cause?: LogCause;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* An event for `'debug'`, the unredacted level. Its fields accept anything.
|
|
350
|
+
*/
|
|
351
|
+
type DebugEvent = BaseEvent & {
|
|
352
|
+
readonly fields: UnredactedFields;
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* How much the SDK may report, from silent to everything.
|
|
356
|
+
*
|
|
357
|
+
* Ordered: each level admits itself and everything before it, so `'info'`
|
|
358
|
+
* shows errors, warnings and info but not debug. `'none'` admits nothing.
|
|
359
|
+
*
|
|
360
|
+
* `'debug'` is the unredacted level, and it is deliberately the bottom of the
|
|
361
|
+
* ladder: the guarantee "`debug` is unredacted and every other level is not"
|
|
362
|
+
* only closes if there is nothing below it. That is why the SDK keeps its own
|
|
363
|
+
* five levels rather than adopting pino's seven, which put `trace` underneath.
|
|
364
|
+
*/
|
|
365
|
+
type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
366
|
+
/**
|
|
367
|
+
* The redacted levels: the only ones to consider running in production.
|
|
368
|
+
*
|
|
369
|
+
* Every level except `'debug'`, which is unredacted by design. Used by the
|
|
370
|
+
* shipped pino implementations to make a production `'debug'` logger
|
|
371
|
+
* unrepresentable rather than merely discouraged - see
|
|
372
|
+
* {@link PinoLoggerOptions}.
|
|
373
|
+
*
|
|
374
|
+
* The name marks which levels are *redacted*, not a verdict that running them
|
|
375
|
+
* in production is safe. The SDK's advice is to leave {@link Config.logger}
|
|
376
|
+
* undefined there; this type is what stops the partner who does not take it
|
|
377
|
+
* from reaching the unredacted level as well.
|
|
378
|
+
*/
|
|
379
|
+
type ProductionLogLevel = Exclude<LogLevel, 'debug'>;
|
|
380
|
+
/**
|
|
381
|
+
* How to build one of the SDK's pino-backed loggers.
|
|
382
|
+
*
|
|
383
|
+
* A union rather than `{ level, isDev }`, and that is the whole point:
|
|
384
|
+
* `{ isDev: false, level: 'debug' }` does not typecheck, so a production
|
|
385
|
+
* build cannot ship a logger that prints bearer tokens to a browser console.
|
|
386
|
+
*
|
|
387
|
+
* `isDev` does exactly one thing - decide whether `'debug'` is a legal level.
|
|
388
|
+
* It changes no formatting: dev output and production output are the same
|
|
389
|
+
* shape, so what you debug is what you ship. Pretty-printing is a pipe the
|
|
390
|
+
* host owns (`node server.js | npx pino-pretty`), not a dependency the SDK
|
|
391
|
+
* takes.
|
|
392
|
+
*/
|
|
393
|
+
type PinoLoggerOptions = {
|
|
394
|
+
readonly isDev: true;
|
|
395
|
+
readonly level: LogLevel;
|
|
396
|
+
} | {
|
|
397
|
+
readonly isDev: false;
|
|
398
|
+
readonly level: ProductionLogLevel;
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* Which part of the SDK a line came from, carried as the `scope` field on
|
|
402
|
+
* every event.
|
|
403
|
+
*
|
|
404
|
+
* It names the seam that **reported** the line, not the layer that raised what
|
|
405
|
+
* it reports: an error from `OFFERS` surfaced by `useOffers` is reported on a
|
|
406
|
+
* `HOOKS` line, because that is the hook telling you what it did with it. The
|
|
407
|
+
* `OFFERS` line for the same error is emitted separately, by the namespace.
|
|
408
|
+
*
|
|
409
|
+
* A closed union rather than a free string so that `ONDO` and `Ondo` cannot
|
|
410
|
+
* both appear, so that adding a namespace without giving it a scope fails to
|
|
411
|
+
* compile, and so that a host can `switch` on it when routing. Anything finer
|
|
412
|
+
* - an operation, a flow, a hook - is a {@link LogBinding} and appears as its
|
|
413
|
+
* own field.
|
|
414
|
+
*/
|
|
415
|
+
type LogScope = 'HTTP' | 'AUTH' | 'OFFERS' | 'REQUIREMENTS' | 'WALLETS' | 'ERC20' | 'TOKEN_SALE' | 'SUPERSTATE' | 'ONDO' | 'TOKENS' | 'SUPPORT' | 'HOOKS';
|
|
416
|
+
/**
|
|
417
|
+
* Correlates every line one logical request produces. The first attempt, each
|
|
418
|
+
* retry, and the re-send after a session renewal all carry the same id, so a
|
|
419
|
+
* failure can be read back to the request that caused it.
|
|
420
|
+
*/
|
|
421
|
+
type RequestId = Newtype<string, 'RequestId'>;
|
|
422
|
+
/**
|
|
423
|
+
* The id frontline keys its own logs by, minted server-side and returned as
|
|
424
|
+
* `event_id` on an error envelope. Quote it when raising a ticket with
|
|
425
|
+
* CoinList support: it is what leads from a partner's log line to the request
|
|
426
|
+
* as the backend saw it.
|
|
427
|
+
*
|
|
428
|
+
* A {@link Newtype} rather than a bare `string` because it sits next to
|
|
429
|
+
* {@link RequestId} and frontline's `code` on the same cause, and the three
|
|
430
|
+
* are not interchangeable: an id swapped for a code reads plausibly and points
|
|
431
|
+
* a support engineer at nothing.
|
|
432
|
+
*/
|
|
433
|
+
type FrontlineEventId = Newtype<string, 'FrontlineEventId'>;
|
|
434
|
+
/**
|
|
435
|
+
* What the SDK knows about a failure, classified.
|
|
436
|
+
*
|
|
437
|
+
* **Safe to forward as it stands.** Every arm is SDK-authored classification
|
|
438
|
+
* or a server-authored identifier: no request or response body, no host-
|
|
439
|
+
* supplied parameter, and no value read off a thrown error the SDK did not
|
|
440
|
+
* author. There is nothing here to strip before handing it to an error
|
|
441
|
+
* tracker, which is deliberate - a `LogCause` reaches {@link Logger.error},
|
|
442
|
+
* the level a host actually runs in production, and a guarantee that depends
|
|
443
|
+
* on the host remembering to strip a field is not a guarantee.
|
|
444
|
+
*
|
|
445
|
+
* It is the SDK's **only** structured classification of a thrown error, and it
|
|
446
|
+
* reaches {@link Logger.warn} as well as {@link Logger.error}: a recoverable
|
|
447
|
+
* failure is no less worth naming than a fatal one, and rendering it into a
|
|
448
|
+
* string instead would have meant interpolating into `msg`.
|
|
449
|
+
*
|
|
450
|
+
* Bodies are a `'debug'`-only disclosure and stay on the `HTTP` lines, which
|
|
451
|
+
* {@link RequestId} points at.
|
|
452
|
+
*
|
|
453
|
+
* The arms are the remedies, not the exception classes: a `validation` cause
|
|
454
|
+
* means the backend sent something the SDK does not understand and is worth
|
|
455
|
+
* reporting to CoinList, while an `invariant` cause means the SDK itself
|
|
456
|
+
* computed something impossible and is worth reporting as an SDK bug. Reading
|
|
457
|
+
* `type` should tell you who has to fix it.
|
|
458
|
+
*
|
|
459
|
+
* It carries no scope of its own. The {@link SafeEvent} it arrives on has one,
|
|
460
|
+
* and a cause could only ever have repeated it: the scope is stamped by the
|
|
461
|
+
* logger that *emits* the line, not by the layer that raised the error, so a
|
|
462
|
+
* `validation` failure from `OFFERS` surfaced by `useOffers` would have been
|
|
463
|
+
* tagged `HOOKS` on the hook's line. Forward the event, not the cause alone.
|
|
464
|
+
*/
|
|
465
|
+
type LogCause =
|
|
466
|
+
/**
|
|
467
|
+
* A request reached the backend and came back non-2xx.
|
|
468
|
+
*
|
|
469
|
+
* Deliberately carries no response body. `requestId` is how you get the
|
|
470
|
+
* rest: the `HTTP` lines for the same request carry the method, the path,
|
|
471
|
+
* the duration, every retry, and at `'debug'` the body itself. `code` and
|
|
472
|
+
* `eventId` are frontline's own - quote `eventId` when raising a ticket with
|
|
473
|
+
* CoinList support.
|
|
474
|
+
*/
|
|
475
|
+
{
|
|
476
|
+
type: 'http';
|
|
477
|
+
requestId: RequestId | null;
|
|
478
|
+
status: number;
|
|
479
|
+
code: string | null;
|
|
480
|
+
eventId: FrontlineEventId | null;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* The wire succeeded; the payload was not a shape the SDK can map.
|
|
484
|
+
*
|
|
485
|
+
* `message` is an SDK-authored template and may quote the single scalar that
|
|
486
|
+
* failed - `Unsupported chain: "solana_mainnet"`, `expires_at: not a date
|
|
487
|
+
* ("13/40/2026")`. That one value is the point of the arm; it is never a
|
|
488
|
+
* body and never a whole field set.
|
|
489
|
+
*/
|
|
490
|
+
| {
|
|
491
|
+
type: 'validation';
|
|
492
|
+
message: string;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* The SDK computed something impossible. An SDK bug - please report it.
|
|
496
|
+
* `message` is an SDK-authored template, like `validation`'s.
|
|
497
|
+
*/
|
|
498
|
+
| {
|
|
499
|
+
type: 'invariant';
|
|
500
|
+
message: string;
|
|
501
|
+
}
|
|
502
|
+
/** An API-backed call was made without a logged-in user. */
|
|
503
|
+
| {
|
|
504
|
+
type: 'not-authenticated';
|
|
505
|
+
}
|
|
506
|
+
/** A code path the SDK has not shipped yet. */
|
|
507
|
+
| {
|
|
508
|
+
type: 'not-implemented';
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* The user's wallet, or the chain, refused.
|
|
512
|
+
*
|
|
513
|
+
* {@link RedactedWalletError} rather than the full `WalletError`: its
|
|
514
|
+
* `unknown` arm arrives with its `cause` dropped, that field holding the raw
|
|
515
|
+
* wallet-library error whose message and metadata carry the transaction's
|
|
516
|
+
* `from`, `to`, `value` and calldata. It is still on the flow's own returned
|
|
517
|
+
* result, and on the `'debug'` line the flow seam emits beside this one.
|
|
518
|
+
*
|
|
519
|
+
* A type rather than a scrub applied at the call site, so an arm that grew a
|
|
520
|
+
* raw field would fail the build.
|
|
521
|
+
*/
|
|
522
|
+
| {
|
|
523
|
+
type: 'wallet';
|
|
524
|
+
error: RedactedWalletError;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Something the SDK does not recognise - usually a host-supplied lambda
|
|
528
|
+
* (`getAccessToken`, an {@link EvmWallet} method) throwing, or a
|
|
529
|
+
* network-level `fetch` failure.
|
|
530
|
+
*
|
|
531
|
+
* `name` is the error's class name and nothing else. The message and the
|
|
532
|
+
* thrown value itself are host-authored, so they are a `'debug'` disclosure:
|
|
533
|
+
* the paired debug line renders them in full.
|
|
534
|
+
*/
|
|
535
|
+
| {
|
|
536
|
+
type: 'generic-error';
|
|
537
|
+
name: string;
|
|
538
|
+
};
|
|
539
|
+
|
|
23
540
|
/**
|
|
24
541
|
* The exhaustive chain set: a new {@link EthereumChain} is a compile error
|
|
25
542
|
* here until it is listed, which is what keeps the constructor total.
|
|
@@ -147,11 +664,25 @@ declare const MAX_UINT_256: bigint;
|
|
|
147
664
|
*/
|
|
148
665
|
type Uint256 = bigint;
|
|
149
666
|
/**
|
|
150
|
-
* Asserts a
|
|
151
|
-
*
|
|
152
|
-
*
|
|
667
|
+
* Asserts a computed bigint falls within uint256 bounds. Use at on-chain
|
|
668
|
+
* arithmetic boundaries (bps math, price computation) where the SDK's own
|
|
669
|
+
* arithmetic could underflow below zero or overflow above 2^256-1.
|
|
670
|
+
*
|
|
671
|
+
* Throws {@link InvariantError}, because reaching it means the SDK computed
|
|
672
|
+
* something no chain could represent. **For a value that came off the wire,
|
|
673
|
+
* use {@link parseUint256} instead**: the backend sending an unrepresentable
|
|
674
|
+
* number is a {@link ValidationError}, and the two have different remedies.
|
|
153
675
|
*/
|
|
154
676
|
declare const assertUint256: (value: bigint) => Uint256;
|
|
677
|
+
/**
|
|
678
|
+
* {@link assertUint256} at a wire boundary: the same bounds check, reported as
|
|
679
|
+
* a {@link ValidationError} against the named field, because a value out of
|
|
680
|
+
* range here is the backend's, not the SDK's.
|
|
681
|
+
*
|
|
682
|
+
* `label` names the field the way a DTO mapper's other failures do, so a log
|
|
683
|
+
* line says which one - `SwapPreview.pay_input_amount`, not `a number`.
|
|
684
|
+
*/
|
|
685
|
+
declare const parseUint256: (value: bigint, label: string) => Uint256;
|
|
155
686
|
type BlockchainAmount = Newtype<{
|
|
156
687
|
raw: Uint256;
|
|
157
688
|
decimals: AssetDecimals;
|
|
@@ -225,6 +756,13 @@ declare const OAuthSession: {
|
|
|
225
756
|
};
|
|
226
757
|
|
|
227
758
|
type HttpRequestAttributes = {
|
|
759
|
+
/**
|
|
760
|
+
* Correlates the log lines of one logical request. Minted by
|
|
761
|
+
* {@link HttpClient} on the first attempt and carried onto every retry and
|
|
762
|
+
* post-renewal re-send by {@link concat}, which is what lets a reader tell
|
|
763
|
+
* three attempts of one request from three separate requests.
|
|
764
|
+
*/
|
|
765
|
+
requestId?: RequestId;
|
|
228
766
|
protected?: boolean;
|
|
229
767
|
userAgent?: boolean;
|
|
230
768
|
idempotencyKey?: boolean;
|
|
@@ -272,10 +810,25 @@ type HttpResponse<TBody = unknown> = {
|
|
|
272
810
|
status: number;
|
|
273
811
|
headers?: Record<string, string>;
|
|
274
812
|
body: TBody | null;
|
|
813
|
+
/**
|
|
814
|
+
* The id of the request that produced this response, stamped by
|
|
815
|
+
* {@link HttpClient} so that whoever turns a non-2xx into an
|
|
816
|
+
* {@link HttpError} can carry it without threading the request alongside.
|
|
817
|
+
* Absent when the response did not come from an `HttpClient`.
|
|
818
|
+
*/
|
|
819
|
+
requestId?: RequestId;
|
|
275
820
|
};
|
|
276
821
|
declare class HttpError<TBody = unknown> extends Error {
|
|
277
822
|
readonly response: HttpResponse<TBody>;
|
|
278
823
|
constructor(response: HttpResponse<TBody>);
|
|
824
|
+
/**
|
|
825
|
+
* Correlates this failure with the `[HTTP]` log lines for the same request,
|
|
826
|
+
* which carry the method, the URL, the duration and every retry. `null` when
|
|
827
|
+
* the response did not come from an {@link HttpClient}.
|
|
828
|
+
*
|
|
829
|
+
* Worth quoting in a bug report: it is what makes a log excerpt readable.
|
|
830
|
+
*/
|
|
831
|
+
get requestId(): RequestId | null;
|
|
279
832
|
}
|
|
280
833
|
/**
|
|
281
834
|
* The machine-readable `code` frontline attaches to an error, or `null` for
|
|
@@ -304,6 +857,15 @@ interface Sender {
|
|
|
304
857
|
|
|
305
858
|
interface SharedNamespaceContext {
|
|
306
859
|
readonly api: Sender;
|
|
860
|
+
/**
|
|
861
|
+
* The host's logger, or `null` when they supplied none.
|
|
862
|
+
*
|
|
863
|
+
* Deliberately the raw port rather than a pre-scoped {@link InternalLogger}:
|
|
864
|
+
* one context serves every namespace, and each namespace owns its own scope.
|
|
865
|
+
* A namespace turns it into something usable in its constructor, with
|
|
866
|
+
* `internalLogger(ctx.logger, 'OFFERS')`.
|
|
867
|
+
*/
|
|
868
|
+
readonly logger: Logger | null;
|
|
307
869
|
ensureUserAuthenticated(): Promise<void>;
|
|
308
870
|
}
|
|
309
871
|
|
|
@@ -430,11 +992,89 @@ interface Erc20Namespace {
|
|
|
430
992
|
}
|
|
431
993
|
declare class Erc20NamespaceImpl implements Erc20Namespace {
|
|
432
994
|
private readonly ctx;
|
|
995
|
+
private readonly log;
|
|
433
996
|
constructor(ctx: SharedNamespaceContext);
|
|
434
997
|
getAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
|
|
435
998
|
getBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
|
|
436
999
|
}
|
|
437
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* The logging surface SDK code uses. Never exported to hosts: they implement
|
|
1003
|
+
* {@link Logger}, which is deliberately smaller.
|
|
1004
|
+
*/
|
|
1005
|
+
type InternalLogger = {
|
|
1006
|
+
/**
|
|
1007
|
+
* A logger narrowed by one more {@link LogBinding}, which every line it
|
|
1008
|
+
* emits carries as its own field.
|
|
1009
|
+
*/
|
|
1010
|
+
child(binding: LogBinding): InternalLogger;
|
|
1011
|
+
/**
|
|
1012
|
+
* The unredacted level. Request and response bodies, full URLs, headers,
|
|
1013
|
+
* operation params and raw thrown errors belong here and **only** here.
|
|
1014
|
+
*/
|
|
1015
|
+
debug(event: () => InternalDebugEvent): void;
|
|
1016
|
+
info(event: () => InternalSafeEvent): void;
|
|
1017
|
+
warn(event: () => InternalSafeEvent): void;
|
|
1018
|
+
/**
|
|
1019
|
+
* Reports a failure whose cause is already known, or has none. Prefer
|
|
1020
|
+
* {@link failure}, which classifies a thrown error for you.
|
|
1021
|
+
*/
|
|
1022
|
+
error(event: () => InternalSafeEvent): void;
|
|
1023
|
+
/**
|
|
1024
|
+
* Reports a thrown error, classifying it into a {@link LogCause}. Prefer
|
|
1025
|
+
* this over `error` at a `catch`: classification only happens when the level
|
|
1026
|
+
* admits it.
|
|
1027
|
+
*
|
|
1028
|
+
* The `error` line names the error's class but never its message, since an
|
|
1029
|
+
* error the SDK did not author may say anything at all. The verbatim
|
|
1030
|
+
* rendering goes onto a paired `debug` line instead.
|
|
1031
|
+
*
|
|
1032
|
+
* For a failure the SDK recovers from, use {@link warning} instead. An
|
|
1033
|
+
* `error` line a host cannot act on is worse than no line at all: it trains
|
|
1034
|
+
* them to ignore the ones that matter.
|
|
1035
|
+
*/
|
|
1036
|
+
failure(event: () => InternalSafeEvent, error: unknown): void;
|
|
1037
|
+
/**
|
|
1038
|
+
* {@link failure} for trouble that did not break anything: a poll tick that
|
|
1039
|
+
* failed while the last value still stands, a retried request.
|
|
1040
|
+
*
|
|
1041
|
+
* Carries the classified {@link LogCause} exactly as `failure` does. The two
|
|
1042
|
+
* differ in level and in nothing else, because what separates them is
|
|
1043
|
+
* whether anything actually broke - not how much is known about it.
|
|
1044
|
+
*/
|
|
1045
|
+
warning(event: () => InternalSafeEvent, error: unknown): void;
|
|
1046
|
+
/**
|
|
1047
|
+
* Runs one namespace operation with logging around it: the call and its
|
|
1048
|
+
* params at `debug`, and any throw at `error` with the cause classified.
|
|
1049
|
+
* Every line carries `op` as a binding.
|
|
1050
|
+
*
|
|
1051
|
+
* **The params never reach the `error` line.** They routinely hold the
|
|
1052
|
+
* things this SDK must not put in front of a production error tracker - an
|
|
1053
|
+
* app bearer token, a document's signing fields, a wallet signature - and
|
|
1054
|
+
* the `debug` line plus the request id is how you get them back. The type
|
|
1055
|
+
* says so: `params` is `unknown`, which is not a {@link SafeFields} value.
|
|
1056
|
+
*
|
|
1057
|
+
* Always rethrows. Logging observes behaviour, it never changes it.
|
|
1058
|
+
*/
|
|
1059
|
+
wrap<T>(op: string, params: unknown, run: () => Promise<T>): Promise<T>;
|
|
1060
|
+
};
|
|
1061
|
+
/**
|
|
1062
|
+
* What a call site hands to `info`, `warn`, `error`, `failure` or `warning` -
|
|
1063
|
+
* a {@link SafeEvent} minus the scope and bindings the logger stamps itself.
|
|
1064
|
+
*/
|
|
1065
|
+
type InternalSafeEvent = {
|
|
1066
|
+
/** A **constant** string literal. Every varying value belongs in `fields`. */
|
|
1067
|
+
readonly msg: string;
|
|
1068
|
+
readonly fields?: SafeFields;
|
|
1069
|
+
readonly cause?: LogCause;
|
|
1070
|
+
};
|
|
1071
|
+
/** What a call site hands to `debug`. Its fields accept anything. */
|
|
1072
|
+
type InternalDebugEvent = {
|
|
1073
|
+
/** A **constant** string literal. Every varying value belongs in `fields`. */
|
|
1074
|
+
readonly msg: string;
|
|
1075
|
+
readonly fields?: UnredactedFields;
|
|
1076
|
+
};
|
|
1077
|
+
|
|
438
1078
|
/**
|
|
439
1079
|
* The product an offer is checked out through. The backend sends one compound
|
|
440
1080
|
* `{supplier}::{saleType}` string, verbatim as spelled below: a double colon
|
|
@@ -456,6 +1096,12 @@ type OfferDto = {
|
|
|
456
1096
|
logo_url: string;
|
|
457
1097
|
starts_at: string;
|
|
458
1098
|
ends_at: string | null;
|
|
1099
|
+
tokens: OfferTokenDto[];
|
|
1100
|
+
};
|
|
1101
|
+
type OfferTokenDto = {
|
|
1102
|
+
role: 'funding' | 'distribution' | 'swap';
|
|
1103
|
+
chain: string;
|
|
1104
|
+
address: string;
|
|
459
1105
|
};
|
|
460
1106
|
|
|
461
1107
|
type OfferId = Newtype<string, 'OfferId'>;
|
|
@@ -472,10 +1118,20 @@ type Offer = {
|
|
|
472
1118
|
logoUrl: string;
|
|
473
1119
|
startsAt: Date;
|
|
474
1120
|
endsAt: Date | null;
|
|
1121
|
+
tokens: OfferToken[];
|
|
475
1122
|
};
|
|
476
1123
|
declare const Offer: {
|
|
477
1124
|
fromDto: (dto: OfferDto) => Offer;
|
|
478
1125
|
};
|
|
1126
|
+
type TokenRole = 'funding' | 'distribution' | 'swap';
|
|
1127
|
+
type OfferToken = {
|
|
1128
|
+
role: TokenRole;
|
|
1129
|
+
chain: Chain;
|
|
1130
|
+
address: EvmContractAddress;
|
|
1131
|
+
};
|
|
1132
|
+
declare const OfferToken: {
|
|
1133
|
+
fromDto: (dto: OfferTokenDto) => OfferToken;
|
|
1134
|
+
};
|
|
479
1135
|
|
|
480
1136
|
/**
|
|
481
1137
|
* The cursor-paginated envelope every list endpoint returns.
|
|
@@ -563,7 +1219,7 @@ type OfferDetailDto = {
|
|
|
563
1219
|
asset: AssetDto;
|
|
564
1220
|
faqs: OfferDetailFaqDto[];
|
|
565
1221
|
funding_assets: AssetDto[];
|
|
566
|
-
tokens:
|
|
1222
|
+
tokens: OfferTokenDto[];
|
|
567
1223
|
id: string;
|
|
568
1224
|
links: OfferDetailLinkDto[];
|
|
569
1225
|
milestones: OfferDetailMilestoneDto[];
|
|
@@ -608,11 +1264,6 @@ type OfferDetailTermDto = {
|
|
|
608
1264
|
key: string | null;
|
|
609
1265
|
value: string | null;
|
|
610
1266
|
};
|
|
611
|
-
type OfferDetailTokenDto = {
|
|
612
|
-
role: 'funding' | 'distribution' | 'swap';
|
|
613
|
-
chain: string;
|
|
614
|
-
address: string;
|
|
615
|
-
};
|
|
616
1267
|
|
|
617
1268
|
type OfferOptionId = Newtype<string, 'OfferOptionId'>;
|
|
618
1269
|
declare const OfferOptionId: (value: string) => OfferOptionId;
|
|
@@ -684,15 +1335,6 @@ type Milestone = {
|
|
|
684
1335
|
declare const Milestone: {
|
|
685
1336
|
fromDto: (dto: OfferDetailMilestoneDto) => Milestone;
|
|
686
1337
|
};
|
|
687
|
-
type TokenRole = 'funding' | 'distribution' | 'swap';
|
|
688
|
-
type OfferToken = {
|
|
689
|
-
role: TokenRole;
|
|
690
|
-
chain: Chain;
|
|
691
|
-
address: EvmContractAddress;
|
|
692
|
-
};
|
|
693
|
-
declare const OfferToken: {
|
|
694
|
-
fromDto: (dto: OfferDetailTokenDto) => OfferToken;
|
|
695
|
-
};
|
|
696
1338
|
|
|
697
1339
|
/** Unique identifier for a participation. */
|
|
698
1340
|
type ParticipationId = Newtype<string, 'ParticipationId'>;
|
|
@@ -812,6 +1454,7 @@ interface CoinListTokenSaleNamespace {
|
|
|
812
1454
|
}
|
|
813
1455
|
declare class CoinListTokenSaleNamespaceImpl implements CoinListTokenSaleNamespace {
|
|
814
1456
|
private readonly ctx;
|
|
1457
|
+
protected readonly log: InternalLogger;
|
|
815
1458
|
constructor(ctx: SharedNamespaceContext);
|
|
816
1459
|
list(offerId?: OfferId): Promise<Participation[]>;
|
|
817
1460
|
listPage(params: ParticipationsPaginationParams): Promise<PaginatedResponse<Participation>>;
|
|
@@ -1216,6 +1859,7 @@ interface OndoNamespace {
|
|
|
1216
1859
|
}
|
|
1217
1860
|
declare class OndoNamespaceImpl implements OndoNamespace {
|
|
1218
1861
|
private readonly ctx;
|
|
1862
|
+
protected readonly log: InternalLogger;
|
|
1219
1863
|
constructor(ctx: SharedNamespaceContext);
|
|
1220
1864
|
getTradingStatus(params: GetOndoTradingStatusParams): Promise<OndoTradingStatus>;
|
|
1221
1865
|
getQuote(params: GetOndoQuoteParams): Promise<OndoQuote>;
|
|
@@ -1272,6 +1916,7 @@ interface SuperstateSwapNamespace {
|
|
|
1272
1916
|
}
|
|
1273
1917
|
declare class SuperstateSwapNamespaceImpl implements SuperstateSwapNamespace {
|
|
1274
1918
|
private readonly ctx;
|
|
1919
|
+
protected readonly log: InternalLogger;
|
|
1275
1920
|
constructor(ctx: SharedNamespaceContext);
|
|
1276
1921
|
getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
|
|
1277
1922
|
getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
|
|
@@ -1465,6 +2110,7 @@ interface WalletsNamespace {
|
|
|
1465
2110
|
}
|
|
1466
2111
|
declare class WalletsNamespaceImpl implements WalletsNamespace {
|
|
1467
2112
|
private readonly ctx;
|
|
2113
|
+
private readonly log;
|
|
1468
2114
|
constructor(ctx: SharedNamespaceContext);
|
|
1469
2115
|
createOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
|
|
1470
2116
|
connectExternal(params: ConnectExternalWalletParams): Promise<OfferOptionAddress>;
|
|
@@ -1577,7 +2223,7 @@ declare const Pii: {
|
|
|
1577
2223
|
fromDto: (dto: PiiDto) => Pii;
|
|
1578
2224
|
};
|
|
1579
2225
|
|
|
1580
|
-
type RequirementTypeDto = 'kyc_approved' | '
|
|
2226
|
+
type RequirementTypeDto = 'kyc_approved' | 'external_wallet' | 'whitelisted_wallet' | 'jurisdiction' | 'accreditation' | 'document';
|
|
1581
2227
|
type RequirementDto = {
|
|
1582
2228
|
object: 'requirement';
|
|
1583
2229
|
id: string;
|
|
@@ -1701,6 +2347,7 @@ interface RequirementsNamespace {
|
|
|
1701
2347
|
}
|
|
1702
2348
|
declare class RequirementsNamespaceImpl implements RequirementsNamespace {
|
|
1703
2349
|
protected readonly ctx: SharedNamespaceContext;
|
|
2350
|
+
protected readonly log: InternalLogger;
|
|
1704
2351
|
constructor(ctx: SharedNamespaceContext);
|
|
1705
2352
|
forOffer(offerId: OfferId): Promise<Record<OfferOptionId, Requirement[]>>;
|
|
1706
2353
|
statuses(offerId: OfferId): Promise<RequirementStatusInfo[]>;
|
|
@@ -1738,6 +2385,7 @@ interface OffersNamespace {
|
|
|
1738
2385
|
}
|
|
1739
2386
|
declare class OffersNamespaceImpl implements OffersNamespace {
|
|
1740
2387
|
private readonly ctx;
|
|
2388
|
+
private readonly log;
|
|
1741
2389
|
constructor(ctx: SharedNamespaceContext);
|
|
1742
2390
|
list(): Promise<Offer[]>;
|
|
1743
2391
|
listPage(params: PaginationParams): Promise<PaginatedResponse<Offer>>;
|
|
@@ -1891,12 +2539,13 @@ interface TokensNamespace {
|
|
|
1891
2539
|
}
|
|
1892
2540
|
declare class TokensNamespaceImpl implements TokensNamespace {
|
|
1893
2541
|
private readonly api;
|
|
2542
|
+
private readonly log;
|
|
1894
2543
|
/**
|
|
1895
2544
|
* Takes the registry origin rather than a `SharedNamespaceContext`: the
|
|
1896
2545
|
* registry is unauthenticated and on its own host, so the frontline sender
|
|
1897
2546
|
* and the auth check would both be dead weight here.
|
|
1898
2547
|
*/
|
|
1899
|
-
constructor(baseUrl: string);
|
|
2548
|
+
constructor(baseUrl: string, logger?: Logger | null);
|
|
1900
2549
|
get(token: TokenIdentifier): Promise<TokenMetadata | null>;
|
|
1901
2550
|
list(chain: EthereumChain): Promise<TokenMetadata[]>;
|
|
1902
2551
|
}
|
|
@@ -1921,6 +2570,48 @@ interface Config {
|
|
|
1921
2570
|
* registry.
|
|
1922
2571
|
*/
|
|
1923
2572
|
readonly tokensBaseUrl?: string;
|
|
2573
|
+
/**
|
|
2574
|
+
* Where the SDK reports what it is doing. **Omit it and the SDK logs nothing
|
|
2575
|
+
* at all** - no `console` fallback, at any level, on any codepath. Supply
|
|
2576
|
+
* one and every request, every classified failure and every hook state
|
|
2577
|
+
* transition is reported at the level your logger asks for.
|
|
2578
|
+
*
|
|
2579
|
+
* Absent, the SDK says nothing at all - there is no fallback to `console`,
|
|
2580
|
+
* at any level, on any codepath.
|
|
2581
|
+
*
|
|
2582
|
+
* **Running the SDK's logging in production is not advised.** The safest
|
|
2583
|
+
* posture is to leave this undefined outside development, staging and
|
|
2584
|
+
* incident reproduction: a seam that emits nothing cannot disclose anything,
|
|
2585
|
+
* and that property does not depend on the SDK continuing to get redaction
|
|
2586
|
+
* right.
|
|
2587
|
+
*
|
|
2588
|
+
* If you do run one there, run it at `'info'` or above and know what that
|
|
2589
|
+
* does and does not buy you. Those levels are **redacted by construction**:
|
|
2590
|
+
* they carry only SDK-authored classification and server-authored
|
|
2591
|
+
* identifiers, and the type system holds that line rather than a convention -
|
|
2592
|
+
* an event at those levels accepts scalar fields only, so a body, a DTO or
|
|
2593
|
+
* an operation's parameters cannot be put on one. What the SDK does **not**
|
|
2594
|
+
* give you is a warranty that the result is safe for your environment. The
|
|
2595
|
+
* mechanism is checkable and stated; the conclusion depends on your sink,
|
|
2596
|
+
* your retention and your threat model, and it is yours to draw.
|
|
2597
|
+
*
|
|
2598
|
+
* **`'debug'` is not.** It reports request and response bodies, full URLs,
|
|
2599
|
+
* headers and operation parameters verbatim - bearer tokens, KYC answers,
|
|
2600
|
+
* tax-document fields, wallet signatures - and **the SDK does not redact**.
|
|
2601
|
+
* Run it on a developer's machine, in tests, and in beta or staging
|
|
2602
|
+
* environments where the data flowing through is not real customer data.
|
|
2603
|
+
* The shipped implementations make that structural: built with
|
|
2604
|
+
* `isDev: false`, `'debug'` does not typecheck. Either way, filtering,
|
|
2605
|
+
* redaction and retention at your sink are yours, not the SDK's.
|
|
2606
|
+
*
|
|
2607
|
+
* Every method you implement here **must be total**: the SDK calls them on
|
|
2608
|
+
* the codepath of the work they report and does not catch them, so a logger
|
|
2609
|
+
* that throws fails the operation it was describing.
|
|
2610
|
+
*
|
|
2611
|
+
* See {@link Logger} for the full contract, and {@link pinoClientLogger} or
|
|
2612
|
+
* {@link pinoServerLogger} for a ready-made implementation over pino.
|
|
2613
|
+
*/
|
|
2614
|
+
readonly logger?: Logger;
|
|
1924
2615
|
}
|
|
1925
2616
|
|
|
1926
|
-
export { type
|
|
2617
|
+
export { type TokenIdentifier as $, AuthorizationCode as A, BlockchainAmount as B, CodeVerifier as C, type RequirementType as D, type Erc20Namespace as E, type RequirementStatusValue as F, OfferOptionAddress as G, RequirementId as H, DocumentSubmission as I, type WalletChallengeType as J, type KycLevelName as K, type Logger as L, type PinoLoggerOptions as M, OndoTradingStatus as N, OfferId as O, Participation as P, AssetDecimals as Q, type RequirementsNamespace as R, type SharedNamespaceContext as S, type TokensNamespace as T, OndoQuote as U, type OrderBookSide as V, type WalletError as W, type OndoQuoteSize as X, type BuildOndoSwapTransactionParams as Y, OfferOptionAddressId as Z, TokenMetadata as _, EthereumChain as a, OfferSlug as a$, type DebugEvent as a0, type FrontlineEventId as a1, HttpError as a2, type HttpResponse as a3, KycToken as a4, type LogBinding as a5, type LogBindings as a6, type LogCause as a7, type LogLevel as a8, type LogScope as a9, ConnectExternalWalletParams as aA, type CreateKycTokenParams as aB, CreateParticipationParams as aC, CreateWalletOwnershipChallengeParams as aD, Cursor as aE, type DocumentFormType as aF, type DocumentSubmissionStatus as aG, type DocumentType as aH, ETHEREUM_CHAINS as aI, Erc20NamespaceImpl as aJ, FaqItem as aK, type GetOndoQuoteParams as aL, type GetOndoTradingStatusParams as aM, type GetSwapAuthorizationParams as aN, type GetSwapPreviewParams as aO, type GetTokenAllowanceParams as aP, type GetTokenBalanceParams as aQ, HexEncodedTransactionData as aR, Iso2CountryCode as aS, Link as aT, type ListOptionAddressesParams as aU, MAX_ASSET_DECIMALS as aV, MAX_UINT_256 as aW, Milestone as aX, OAuthRefreshToken as aY, OfferOption as aZ, OfferOptionSlug as a_, type LogValue as aa, type ProductionLogLevel as ab, RedactedWalletError as ac, type RequestId as ad, type SafeEvent as ae, type SafeFields as af, type UnredactedFields as ag, OAuthSession as ah, ClientCredentialsOAuth as ai, ClientSecret as aj, type Sender as ak, PaginationParams as al, PaginatedResponse as am, type Uint256 as an, KnownAssetSymbol as ao, DecimalString as ap, SwapStatus as aq, type Newtype as ar, type AllowWalletParams as as, AllowWalletResponse as at, Asset as au, AssetCode as av, Blockchain as aw, Chain as ax, ClientId as ay, CodeChallenge as az, EvmContractAddress as b, OfferToken as b0, OffersNamespaceImpl as b1, type OndoQuoteDuration as b2, PKCEState as b3, type PaginatedResponseDto as b4, ParticipationId as b5, type ParticipationStatus as b6, ParticipationsPaginationParams as b7, Pii as b8, PiiAddress as b9, type WalletProtocol as bA, WalletsNamespaceImpl as bB, apiErrorCode as bC, assertUint256 as bD, parseUint256 as bE, PiiJurisdiction as ba, type PiiKind as bb, type QueryParamValue as bc, type QueryParamValues as bd, RedirectUri as be, type RemoveOptionAddressParams as bf, type RequirementActionNeededReason as bg, SOLANA_CHAINS as bh, STABLE_DECIMALS as bi, SolanaChain as bj, type SubmitDocumentParams as bk, SwapAuthorization as bl, type SwapContractRef as bm, SwapPreview as bn, TermItem as bo, Ticker as bp, TokenAllowance as bq, TokenBalance as br, TokenLogo as bs, type TokenLogoImage as bt, TokenLogoUrl as bu, type TokenRole as bv, TokensNamespaceImpl as bw, type Tx as bx, WalletAddress as by, WalletOwnershipChallenge as bz, type CoinListTokenSaleNamespace as c, OfferOptionId as d, AssetId as e, CoinListTokenSaleNamespaceImpl as f, type OndoNamespace as g, AssetSymbol as h, OndoSwapTransaction as i, OndoNamespaceImpl as j, type SuperstateSwapNamespace as k, type WalletsNamespace as l, Bps as m, EvmWalletAddress as n, SuperstateSwapNamespaceImpl as o, Requirement as p, RequirementsNamespaceImpl as q, type Config as r, type OAuthAccessToken as s, type OffersNamespace as t, type Erc20Asset as u, OfferDetail as v, StablecoinSymbol as w, type OfferType as x, Offer as y, RequirementStatusInfo as z };
|