@glacislabs/stablegenie-zerodelta 3.3.0 → 4.0.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/dist/{chunk-QKGRMRS4.js → chunk-ABI6ZH7O.js} +547 -76
- package/dist/{chunk-OOURZ5DL.js → chunk-FJQQLB2K.js} +795 -63
- package/dist/core/index.cjs +841 -62
- package/dist/core/index.d.cts +103 -7
- package/dist/core/index.d.ts +103 -7
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +1357 -145
- package/dist/index.d.cts +23 -4
- package/dist/index.d.ts +23 -4
- package/dist/index.js +2 -2
- package/dist/{mount-DNvmtX0y.d.cts → mount-D5k_u92L.d.ts} +46 -6
- package/dist/{mount-jxrT-DMe.d.ts → mount-mcyZAzZc.d.cts} +46 -6
- package/dist/mount.cjs +1322 -145
- package/dist/mount.d.cts +2 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +106 -9
- package/dist/verify-C9vzpm4T.d.cts +855 -0
- package/dist/verify-C9vzpm4T.d.ts +855 -0
- package/package.json +1 -1
- package/dist/verify-7lk90Ado.d.cts +0 -367
- package/dist/verify-7lk90Ado.d.ts +0 -367
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
type Hex = `0x${string}`;
|
|
2
|
-
type Address = `0x${string}`;
|
|
3
|
-
interface Chain {
|
|
4
|
-
chainId: number;
|
|
5
|
-
name?: string;
|
|
6
|
-
displayName?: string;
|
|
7
|
-
/** Gas-token symbol ("ETH", "S", …). Used only to label a native-balance shortfall. */
|
|
8
|
-
nativeCurrency?: string;
|
|
9
|
-
escrowContract?: string;
|
|
10
|
-
rpcUrl?: string;
|
|
11
|
-
rpcUrls?: string[];
|
|
12
|
-
publicRpcUrl?: string;
|
|
13
|
-
rpc?: string;
|
|
14
|
-
rpcEndpoint?: string;
|
|
15
|
-
isEnabled?: boolean;
|
|
16
|
-
[k: string]: unknown;
|
|
17
|
-
}
|
|
18
|
-
interface Token {
|
|
19
|
-
symbol: string;
|
|
20
|
-
name?: string;
|
|
21
|
-
chainId: number;
|
|
22
|
-
address: string;
|
|
23
|
-
decimals: number;
|
|
24
|
-
logoUrl?: string;
|
|
25
|
-
bridge?: string;
|
|
26
|
-
isEnabled?: boolean;
|
|
27
|
-
[k: string]: unknown;
|
|
28
|
-
}
|
|
29
|
-
interface Route {
|
|
30
|
-
tokenId?: string;
|
|
31
|
-
tokenName?: string;
|
|
32
|
-
fromChainId: number;
|
|
33
|
-
toChainId: number;
|
|
34
|
-
bridge?: string;
|
|
35
|
-
isEnabled?: boolean;
|
|
36
|
-
[k: string]: unknown;
|
|
37
|
-
}
|
|
38
|
-
interface OrderRequest {
|
|
39
|
-
owner?: string;
|
|
40
|
-
bidToken?: string;
|
|
41
|
-
bidTokenAmount?: string | number;
|
|
42
|
-
askToken?: string;
|
|
43
|
-
askTokenAmount?: string | number;
|
|
44
|
-
destinationReceiver?: string;
|
|
45
|
-
destinationChainId?: string | number;
|
|
46
|
-
/** Chain the escrow executes the order on. Mandatory on-chain; the gateway always issues it. */
|
|
47
|
-
executionChainId?: string | number;
|
|
48
|
-
deadline?: string | number;
|
|
49
|
-
}
|
|
50
|
-
interface NormalizedOrder {
|
|
51
|
-
owner: string;
|
|
52
|
-
bidToken: string;
|
|
53
|
-
bidTokenAmount: string;
|
|
54
|
-
askToken: string;
|
|
55
|
-
askTokenAmount: string;
|
|
56
|
-
destinationReceiver: string;
|
|
57
|
-
destinationChainId: string;
|
|
58
|
-
executionChainId: string;
|
|
59
|
-
deadline: string;
|
|
60
|
-
}
|
|
61
|
-
interface Quote {
|
|
62
|
-
fromChainId: number;
|
|
63
|
-
toChainId: number;
|
|
64
|
-
fromToken: string;
|
|
65
|
-
toToken: string;
|
|
66
|
-
fromAmount?: string;
|
|
67
|
-
toAmount?: string;
|
|
68
|
-
finalAmount?: string;
|
|
69
|
-
bridge?: string;
|
|
70
|
-
feeBps?: number;
|
|
71
|
-
estimatedDuration?: number;
|
|
72
|
-
gasCostSource?: string;
|
|
73
|
-
gasCostDest?: string;
|
|
74
|
-
escrowAddress?: string;
|
|
75
|
-
/** Escrow on the execution chain. Informational: approve/submitOrder go to the SOURCE-chain
|
|
76
|
-
* escrow, which is what checkEscrow binds. */
|
|
77
|
-
executionEscrowAddress?: string;
|
|
78
|
-
executionChainId?: number | string;
|
|
79
|
-
/** Every leg of the order, first to last. A plain swap is one leg; a chained (RWA) quote is
|
|
80
|
-
* two or more, all encoded into one submitOrder call. */
|
|
81
|
-
orderRequests?: OrderRequest[] | null;
|
|
82
|
-
/** Legacy single-leg shape, accepted for backward compatibility. */
|
|
83
|
-
orderRequest?: OrderRequest | null;
|
|
84
|
-
[k: string]: unknown;
|
|
85
|
-
}
|
|
86
|
-
interface PayOption {
|
|
87
|
-
symbol: string;
|
|
88
|
-
symbolKey: string;
|
|
89
|
-
name: string;
|
|
90
|
-
chainId: number;
|
|
91
|
-
chainName: string;
|
|
92
|
-
address: string;
|
|
93
|
-
decimals: number;
|
|
94
|
-
logoUrl?: string;
|
|
95
|
-
bridge?: string;
|
|
96
|
-
sameChain?: boolean;
|
|
97
|
-
direct: boolean;
|
|
98
|
-
}
|
|
99
|
-
interface SolveResult {
|
|
100
|
-
directTransfer: boolean;
|
|
101
|
-
quote: Quote;
|
|
102
|
-
youPayRaw: string;
|
|
103
|
-
recipientReceivesRaw: string;
|
|
104
|
-
targetRaw: string;
|
|
105
|
-
overageBps: number;
|
|
106
|
-
meetsTarget: boolean;
|
|
107
|
-
iterations: number;
|
|
108
|
-
}
|
|
109
|
-
type PlannedTxKind = "transfer" | "approve" | "submitOrder";
|
|
110
|
-
interface PlannedTx {
|
|
111
|
-
id: string;
|
|
112
|
-
kind: PlannedTxKind;
|
|
113
|
-
label: string;
|
|
114
|
-
chainId: number;
|
|
115
|
-
to: string;
|
|
116
|
-
data: string;
|
|
117
|
-
value: string;
|
|
118
|
-
token?: string;
|
|
119
|
-
spender?: string;
|
|
120
|
-
escrow?: string;
|
|
121
|
-
amountRaw?: string;
|
|
122
|
-
mock?: boolean;
|
|
123
|
-
}
|
|
124
|
-
interface RouteResult {
|
|
125
|
-
id: string;
|
|
126
|
-
recommended: boolean;
|
|
127
|
-
state: "DIRECT" | "ROUTE" | "SHORT";
|
|
128
|
-
source: {
|
|
129
|
-
asset: string;
|
|
130
|
-
chainId: number;
|
|
131
|
-
chainName: string;
|
|
132
|
-
tokenAddress?: string;
|
|
133
|
-
decimals?: number;
|
|
134
|
-
amount: string;
|
|
135
|
-
payAmount: string;
|
|
136
|
-
};
|
|
137
|
-
receive: {
|
|
138
|
-
asset: string;
|
|
139
|
-
chainId: number;
|
|
140
|
-
chainName: string;
|
|
141
|
-
tokenAddress?: string;
|
|
142
|
-
decimals?: number;
|
|
143
|
-
amount: string;
|
|
144
|
-
};
|
|
145
|
-
routeLabel: string;
|
|
146
|
-
deltaLabel: string;
|
|
147
|
-
transactions: PlannedTx[];
|
|
148
|
-
quote: {
|
|
149
|
-
bridge?: string;
|
|
150
|
-
feeBps?: number;
|
|
151
|
-
estimatedDuration?: number;
|
|
152
|
-
gasCostSource?: string;
|
|
153
|
-
msgValue?: string;
|
|
154
|
-
deadline?: string;
|
|
155
|
-
iterations: number;
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
interface Destination {
|
|
159
|
-
address: string;
|
|
160
|
-
chainId: number;
|
|
161
|
-
chainName?: string;
|
|
162
|
-
asset: string;
|
|
163
|
-
amount: string;
|
|
164
|
-
}
|
|
165
|
-
interface Plan {
|
|
166
|
-
mode: "zerodelta" | "swap" | "mock";
|
|
167
|
-
requestId: string;
|
|
168
|
-
expiresAt: string;
|
|
169
|
-
apiBase?: string;
|
|
170
|
-
routes: RouteResult[];
|
|
171
|
-
/** Wallet balances already read while choosing funding candidates. Payment UIs reuse these so
|
|
172
|
-
* route rendering does not trigger the same RPC scan a second time. */
|
|
173
|
-
fundingBalances?: Record<string, {
|
|
174
|
-
raw: string;
|
|
175
|
-
formatted: string;
|
|
176
|
-
}>;
|
|
177
|
-
/** Normalized account that `fundingBalances` belongs to. */
|
|
178
|
-
fundingAccount?: string;
|
|
179
|
-
destination: {
|
|
180
|
-
asset: string;
|
|
181
|
-
chainId: number;
|
|
182
|
-
chainName: string;
|
|
183
|
-
tokenAddress?: string;
|
|
184
|
-
decimals?: number;
|
|
185
|
-
amount: string;
|
|
186
|
-
address: string;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
interface SwapInput {
|
|
190
|
-
fromChainId: number | string;
|
|
191
|
-
toChainId: number | string;
|
|
192
|
-
fromToken: string;
|
|
193
|
-
toToken: string;
|
|
194
|
-
amountIn: string;
|
|
195
|
-
recipient?: string;
|
|
196
|
-
}
|
|
197
|
-
interface TxHistoryEntry {
|
|
198
|
-
kind?: "payment" | "swap";
|
|
199
|
-
hash?: string;
|
|
200
|
-
/** The on-chain KIND of the recorded hash. History records only the SETTLING tx (transfer /
|
|
201
|
-
* submitOrder), never the allowance `approve` — this discriminator lets the UI defend that. */
|
|
202
|
-
txKind?: PlannedTxKind;
|
|
203
|
-
chainId?: number;
|
|
204
|
-
chainName?: string;
|
|
205
|
-
fromAsset?: string;
|
|
206
|
-
toAsset?: string;
|
|
207
|
-
payAmount?: string;
|
|
208
|
-
receiveAmount?: string;
|
|
209
|
-
/** The signer (payer) — history is scoped per connected wallet. */
|
|
210
|
-
account?: string;
|
|
211
|
-
recipient?: string;
|
|
212
|
-
settlement?: "direct" | "escrow";
|
|
213
|
-
status?: "confirmed" | "unconfirmed" | "error" | "submitted";
|
|
214
|
-
}
|
|
215
|
-
/** A display-safe, sanitized history entry (no keys/calldata/secrets). */
|
|
216
|
-
interface SanitizedTxEntry {
|
|
217
|
-
kind: "payment" | "swap";
|
|
218
|
-
hash: string;
|
|
219
|
-
/** On-chain tx kind of `hash`. Always the settling tx (never `approve`) when set by the engine;
|
|
220
|
-
* optional for backward-compatibility with entries persisted before this field existed. */
|
|
221
|
-
txKind?: PlannedTxKind;
|
|
222
|
-
chainId: number | null;
|
|
223
|
-
chainName: string;
|
|
224
|
-
fromAsset: string;
|
|
225
|
-
toAsset: string;
|
|
226
|
-
payAmount: string;
|
|
227
|
-
receiveAmount: string;
|
|
228
|
-
/** Normalized signer address, or "" when unknown. */
|
|
229
|
-
account: string;
|
|
230
|
-
recipient: string;
|
|
231
|
-
settlement: "direct" | "escrow";
|
|
232
|
-
status: "confirmed" | "unconfirmed" | "error" | "submitted";
|
|
233
|
-
at: string;
|
|
234
|
-
}
|
|
235
|
-
/** Config injected into the engine by the host application. */
|
|
236
|
-
interface EngineConfig {
|
|
237
|
-
/** Request base. Default: {@link DEFAULT_WIDGET_API_BASE} (same-origin keyless proxy). */
|
|
238
|
-
apiBase?: string;
|
|
239
|
-
/** Optional viewer key. Attached as x-api-key ONLY when canAttachApiKey passes — i.e. a
|
|
240
|
-
* same-origin (relative) `apiBase`, or an absolute one matching {@link trustedApiOrigin}.
|
|
241
|
-
* Not needed against the keyless proxy, which injects the key server-side. */
|
|
242
|
-
apiKey?: string;
|
|
243
|
-
getApiKey?: () => string | Promise<string>;
|
|
244
|
-
/** Absolute origin that may receive `apiKey` when `apiBase` is absolute (e.g.
|
|
245
|
-
* `https://pay.example.com`). Omit and no absolute origin is trusted — same-origin only.
|
|
246
|
-
*
|
|
247
|
-
* There is no built-in default on purpose: the correct trusted origin is whichever proxy YOU
|
|
248
|
-
* deploy, so only this integration can know it. Set it to an origin you control — it is the
|
|
249
|
-
* sole destination permitted to receive the key. */
|
|
250
|
-
trustedApiOrigin?: string;
|
|
251
|
-
/** Injectable fetch (tests / SSR). Defaults to global fetch. */
|
|
252
|
-
fetchImpl?: typeof fetch;
|
|
253
|
-
/** Per-chain RPC overrides for settlement verification / balances. */
|
|
254
|
-
rpcOverrides?: Record<number, string>;
|
|
255
|
-
/** Called with a display-safe history entry after a submit (optional persistence). */
|
|
256
|
-
onTransaction?: (entry: SanitizedTxEntry) => void;
|
|
257
|
-
}
|
|
258
|
-
type FetchQuoteFn = (body: Record<string, unknown>, retries?: number) => Promise<Quote>;
|
|
259
|
-
|
|
260
|
-
interface ResolvedConfig {
|
|
261
|
-
apiBase: string;
|
|
262
|
-
getApiKey: () => Promise<string>;
|
|
263
|
-
fetchImpl: typeof fetch;
|
|
264
|
-
rpcOverrides: Record<number, string>;
|
|
265
|
-
onTransaction?: EngineConfig["onTransaction"];
|
|
266
|
-
}
|
|
267
|
-
declare function parseAllowedApiBase(value: unknown): string | null;
|
|
268
|
-
/** Resolve the request base. A relative base (e.g. `/api/widget/v1`) is same-origin and allowed as
|
|
269
|
-
* is; an absolute base must pass parseAllowedApiBase; anything invalid falls back to the default. */
|
|
270
|
-
declare function resolveApiBase(value?: string): string;
|
|
271
|
-
/**
|
|
272
|
-
* Only attach the viewer key to a same-origin (relative) base, or to an origin the INTEGRATOR has
|
|
273
|
-
* explicitly declared trusted via `EngineConfig.trustedApiOrigin`.
|
|
274
|
-
*
|
|
275
|
-
* There is deliberately no hardcoded default origin. The API is normally reached through a
|
|
276
|
-
* server-side proxy that injects the key (`/api/widget/v1`), and that proxy origin differs per
|
|
277
|
-
* integrator deployment — so there is no single correct value to bake in. Shipping a fixed hostname
|
|
278
|
-
* here would make one unrelated origin the sole permitted key destination for everyone, and silently
|
|
279
|
-
* disable the key for every integrator not using it.
|
|
280
|
-
*
|
|
281
|
-
* Default is therefore same-origin only: fail closed, and let a host opt in to an absolute origin
|
|
282
|
-
* it controls.
|
|
283
|
-
*/
|
|
284
|
-
declare function canAttachApiKey(apiBase: string, trustedOrigin?: string): boolean;
|
|
285
|
-
declare function resolveConfig(config?: EngineConfig): ResolvedConfig;
|
|
286
|
-
|
|
287
|
-
interface ApiError extends Error {
|
|
288
|
-
code?: string;
|
|
289
|
-
status?: number;
|
|
290
|
-
reasons?: string[];
|
|
291
|
-
fieldErrors?: Array<{
|
|
292
|
-
message?: string;
|
|
293
|
-
}>;
|
|
294
|
-
blocked?: boolean;
|
|
295
|
-
blockedCategory?: string;
|
|
296
|
-
blockedReason?: string;
|
|
297
|
-
}
|
|
298
|
-
declare function apiError(message: string, props?: Partial<ApiError>): ApiError;
|
|
299
|
-
interface QuoteBlock {
|
|
300
|
-
blocked: true;
|
|
301
|
-
category: string;
|
|
302
|
-
reason: string;
|
|
303
|
-
message: string;
|
|
304
|
-
}
|
|
305
|
-
declare function classifyQuoteError(error: any): QuoteBlock | null;
|
|
306
|
-
interface ApiClient {
|
|
307
|
-
apiRequest: <T = any>(path: string, init?: RequestInit & {
|
|
308
|
-
timeoutMs?: number;
|
|
309
|
-
}) => Promise<T>;
|
|
310
|
-
fetchChains: () => Promise<Chain[]>;
|
|
311
|
-
fetchTokens: () => Promise<Token[]>;
|
|
312
|
-
fetchRoutes: () => Promise<Route[]>;
|
|
313
|
-
fetchQuote: (body: Record<string, unknown>, retries?: number) => Promise<Quote>;
|
|
314
|
-
apiBase: string;
|
|
315
|
-
}
|
|
316
|
-
/** Build an API client bound to a resolved config. The 60s resource cache is per-instance. */
|
|
317
|
-
declare function createApiClient(cfg: ResolvedConfig): ApiClient;
|
|
318
|
-
|
|
319
|
-
declare function registryRpc(chain: Chain | null): string;
|
|
320
|
-
interface TxPlan {
|
|
321
|
-
from?: string;
|
|
322
|
-
to?: string;
|
|
323
|
-
data?: string;
|
|
324
|
-
value?: string;
|
|
325
|
-
minNonce?: number;
|
|
326
|
-
}
|
|
327
|
-
declare function txMatchesPlan(tx: any, plan: TxPlan): boolean;
|
|
328
|
-
interface VerifyResult {
|
|
329
|
-
/** `confirmed` means MINED WITH A SUCCESS RECEIPT — never merely broadcast. `reverted` is a real
|
|
330
|
-
* on-chain failure (receipt status 0x0). `unconfirmed` means we could not establish either, and
|
|
331
|
-
* must NOT be presented to the payer as a completed payment. */
|
|
332
|
-
status: "confirmed" | "mismatch" | "reverted" | "unconfirmed";
|
|
333
|
-
reason?: string;
|
|
334
|
-
}
|
|
335
|
-
/** One ERC-20 balance to read: the token, its chain, and its decimals (for display formatting). */
|
|
336
|
-
interface BalanceTarget {
|
|
337
|
-
chainId: number;
|
|
338
|
-
tokenAddress: string;
|
|
339
|
-
decimals: number;
|
|
340
|
-
}
|
|
341
|
-
/** A read balance. `raw` is the base-unit integer as a decimal string; `formatted` is display-safe. */
|
|
342
|
-
interface BalanceEntry {
|
|
343
|
-
raw: string;
|
|
344
|
-
formatted: string;
|
|
345
|
-
}
|
|
346
|
-
interface Verifier {
|
|
347
|
-
payerNonceBaseline: (chainId: number, account: string) => Promise<number | null>;
|
|
348
|
-
verifySubmittedTx: (args: {
|
|
349
|
-
chainId: number;
|
|
350
|
-
hash: string;
|
|
351
|
-
from?: string;
|
|
352
|
-
to?: string;
|
|
353
|
-
data?: string;
|
|
354
|
-
value?: string;
|
|
355
|
-
minNonce?: number;
|
|
356
|
-
}) => Promise<VerifyResult>;
|
|
357
|
-
/** Read the payer's ERC-20 balance for each target, keyed `${chainId}:${tokenAddress.toLowerCase()}`.
|
|
358
|
-
* Read-only, off the same public-RPC path as settlement verification. Fail-open: a target whose
|
|
359
|
-
* RPC read fails is simply omitted from the result (never throws, never blocks a route). */
|
|
360
|
-
readBalances: (account: string, targets: BalanceTarget[]) => Promise<Record<string, BalanceEntry>>;
|
|
361
|
-
/** Payer's native (gas-token) balance in wei on `chainId`, or null when it cannot be read.
|
|
362
|
-
* Fail-open by contract: callers must treat null as "unknown", never as "zero". */
|
|
363
|
-
readNativeBalance: (chainId: number, account: string) => Promise<bigint | null>;
|
|
364
|
-
}
|
|
365
|
-
declare function createVerifier(api: ApiClient, fetchImpl: typeof fetch, rpcOverrides?: Record<number, string>): Verifier;
|
|
366
|
-
|
|
367
|
-
export { type ApiClient as A, type BalanceTarget as B, type Chain as C, type Destination as D, type EngineConfig as E, type FetchQuoteFn as F, type Hex as H, type NormalizedOrder as N, type OrderRequest as O, type Plan as P, type Quote as Q, type RouteResult as R, type SanitizedTxEntry as S, type TxHistoryEntry as T, type VerifyResult as V, type Token as a, type PayOption as b, type Route as c, type SolveResult as d, type BalanceEntry as e, type SwapInput as f, type PlannedTx as g, type Verifier as h, type Address as i, type ApiError as j, type PlannedTxKind as k, type QuoteBlock as l, type ResolvedConfig as m, type TxPlan as n, apiError as o, canAttachApiKey as p, classifyQuoteError as q, createApiClient as r, createVerifier as s, parseAllowedApiBase as t, registryRpc as u, resolveApiBase as v, resolveConfig as w, txMatchesPlan as x };
|