@gala-chain/gswap-sdk 1.2.0 → 2.0.0-rc.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/README.md +42 -8
- package/dist/browser/classes/apply_results.js +1 -1
- package/dist/browser/classes/apply_results.js.map +1 -1
- package/dist/browser/classes/assets.js +1 -1
- package/dist/browser/classes/assets.js.map +1 -1
- package/dist/browser/classes/dex_fees.js +1 -1
- package/dist/browser/classes/dex_fees.js.map +1 -1
- package/dist/browser/classes/gateway.js +1 -1
- package/dist/browser/classes/gateway.js.map +1 -1
- package/dist/browser/classes/gdex_stream.js +1 -1
- package/dist/browser/classes/gdex_stream.js.map +1 -1
- package/dist/browser/classes/gswap.js +1 -1
- package/dist/browser/classes/gswap.js.map +1 -1
- package/dist/browser/classes/gswap_error_catalog.js +2 -0
- package/dist/browser/classes/gswap_error_catalog.js.map +1 -0
- package/dist/browser/classes/gswap_error_phase_table.js +2 -0
- package/dist/browser/classes/gswap_error_phase_table.js.map +1 -0
- package/dist/browser/classes/gswap_sdk_error.js +1 -1
- package/dist/browser/classes/gswap_sdk_error.js.map +1 -1
- package/dist/browser/classes/http_client.js +1 -1
- package/dist/browser/classes/http_client.js.map +1 -1
- package/dist/browser/classes/leaderboard.js +2 -0
- package/dist/browser/classes/leaderboard.js.map +1 -0
- package/dist/browser/classes/market.js +2 -0
- package/dist/browser/classes/market.js.map +1 -0
- package/dist/browser/classes/pending_swap_fate.js.map +1 -1
- package/dist/browser/classes/pending_swaps.js +1 -1
- package/dist/browser/classes/pending_swaps.js.map +1 -1
- package/dist/browser/classes/pools.js +1 -1
- package/dist/browser/classes/pools.js.map +1 -1
- package/dist/browser/classes/positions.js +1 -1
- package/dist/browser/classes/positions.js.map +1 -1
- package/dist/browser/classes/quoting.js +1 -1
- package/dist/browser/classes/quoting.js.map +1 -1
- package/dist/browser/classes/shadow_submit.js.map +1 -1
- package/dist/browser/classes/storage_adapters.js.map +1 -1
- package/dist/browser/classes/submitted_transaction.js +1 -1
- package/dist/browser/classes/submitted_transaction.js.map +1 -1
- package/dist/browser/classes/swaps.js +1 -1
- package/dist/browser/classes/swaps.js.map +1 -1
- package/dist/browser/classes/symbols.js +1 -1
- package/dist/browser/classes/symbols.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/types/env.js.map +1 -1
- package/dist/browser/types/fees.js.map +1 -1
- package/dist/browser/types/market.js +2 -0
- package/dist/browser/types/market.js.map +1 -0
- package/dist/browser/utils/classification.js.map +1 -1
- package/dist/browser/utils/confirmation_schedule.js.map +1 -1
- package/dist/browser/utils/confirmation_state.js +1 -1
- package/dist/browser/utils/confirmation_state.js.map +1 -1
- package/dist/browser/utils/debug.js.map +1 -1
- package/dist/browser/utils/dto_builders.js +1 -1
- package/dist/browser/utils/dto_builders.js.map +1 -1
- package/dist/browser/utils/failure_classification.js +1 -1
- package/dist/browser/utils/failure_classification.js.map +1 -1
- package/dist/browser/utils/failure_guards.js +1 -1
- package/dist/browser/utils/failure_guards.js.map +1 -1
- package/dist/browser/utils/lenient.js +1 -1
- package/dist/browser/utils/lenient.js.map +1 -1
- package/dist/browser/utils/ordering.js +1 -1
- package/dist/browser/utils/ordering.js.map +1 -1
- package/dist/browser/utils/reconnection.js +1 -1
- package/dist/browser/utils/reconnection.js.map +1 -1
- package/dist/browser/utils/resolve_pre_send.js +2 -0
- package/dist/browser/utils/resolve_pre_send.js.map +1 -0
- package/dist/browser/utils/server_message.js.map +1 -1
- package/dist/browser/utils/shadow_errors.js +1 -1
- package/dist/browser/utils/shadow_errors.js.map +1 -1
- package/dist/browser/utils/submit_state.js.map +1 -1
- package/dist/browser/utils/tick_align.js.map +1 -1
- package/dist/browser/utils/tick_math.js.map +1 -1
- package/dist/browser/utils/tick_range.js.map +1 -1
- package/dist/browser/utils/ticks.js +1 -1
- package/dist/browser/utils/ticks.js.map +1 -1
- package/dist/browser/utils/validation.js +1 -1
- package/dist/browser/utils/validation.js.map +1 -1
- package/dist/index.cjs +1033 -2925
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +439 -1604
- package/dist/index.d.ts +439 -1604
- package/dist/index.mjs +964 -2810
- package/dist/index.mjs.map +1 -1
- package/package.json +36 -60
- package/dist/browser/classes/error_catalog.js +0 -2
- package/dist/browser/classes/error_catalog.js.map +0 -1
- package/dist/browser/classes/error_phase_table.js +0 -2
- package/dist/browser/classes/error_phase_table.js.map +0 -1
- package/dist/browser/classes/error_phases.js +0 -2
- package/dist/browser/classes/error_phases.js.map +0 -1
- package/dist/browser/classes/signers.js +0 -2
- package/dist/browser/classes/signers.js.map +0 -1
- package/dist/browser/utils/axios_requestor.js +0 -2
- package/dist/browser/utils/axios_requestor.js.map +0 -1
- package/dist/browser/utils/chain_dto_signing.js +0 -3
- package/dist/browser/utils/chain_dto_signing.js.map +0 -1
- package/dist/browser/utils/class_key.js +0 -2
- package/dist/browser/utils/class_key.js.map +0 -1
- package/dist/browser/utils/eip712.js +0 -4
- package/dist/browser/utils/eip712.js.map +0 -1
- package/dist/browser/utils/error_brand.js +0 -2
- package/dist/browser/utils/error_brand.js.map +0 -1
- package/dist/browser/utils/ethers_provider.js +0 -2
- package/dist/browser/utils/ethers_provider.js.map +0 -1
- package/dist/browser/utils/failure_outcomes.js +0 -2
- package/dist/browser/utils/failure_outcomes.js.map +0 -1
- package/dist/browser/utils/failure_view.js +0 -2
- package/dist/browser/utils/failure_view.js.map +0 -1
- package/dist/browser/utils/fetch_failure.js +0 -2
- package/dist/browser/utils/fetch_failure.js.map +0 -1
- package/dist/browser/utils/pre_send.js +0 -2
- package/dist/browser/utils/pre_send.js.map +0 -1
- package/dist/browser/utils/signing.js +0 -3
- package/dist/browser/utils/signing.js.map +0 -1
- package/dist/browser/utils/transport.js +0 -2
- package/dist/browser/utils/transport.js.map +0 -1
- package/dist/browser/utils/typed_data.js +0 -2
- package/dist/browser/utils/typed_data.js.map +0 -1
- package/dist/browser/utils/unique_key.js +0 -2
- package/dist/browser/utils/unique_key.js.map +0 -1
- package/dist/browser/utils/unique_key_syntax.js +0 -2
- package/dist/browser/utils/unique_key_syntax.js.map +0 -1
- package/dist/browser/utils/wallet_rejection.js +0 -2
- package/dist/browser/utils/wallet_rejection.js.map +0 -1
- package/dist/browser/version.js +0 -2
- package/dist/browser/version.js.map +0 -1
- package/dist/browser/wallet.js +0 -2
- package/dist/browser/wallet.js.map +0 -1
- package/dist/wallet.cjs +0 -159
- package/dist/wallet.cjs.map +0 -1
- package/dist/wallet.d.cts +0 -74
- package/dist/wallet.d.ts +0 -74
- package/dist/wallet.mjs +0 -156
- package/dist/wallet.mjs.map +0 -1
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/defineProperty.js +0 -0
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPrimitive.js +0 -0
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPropertyKey.js +0 -0
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/typeof.js +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorParamsOf, FailureOutcome, GALA_ERROR_CATALOG, GalaChainSigner, GalaChainTokenClassKey, GalaErrorCode, GalaErrorContext, GalaSDKError, HTTPResponse, HttpRequestor, UniqueKeyOptions, WireOptions } from "@gala-chain/gala-core-sdk";
|
|
1
2
|
import BigNumber from "bignumber.js";
|
|
2
3
|
import "decimal.js";
|
|
3
4
|
//#region src/types/confirm_options.d.ts
|
|
@@ -20,19 +21,6 @@ export interface ConfirmOptions {
|
|
|
20
21
|
signal?: AbortSignal | undefined;
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
|
23
|
-
//#region src/types/http_requestor.d.ts
|
|
24
|
-
type FetchReturnValue = Awaited<ReturnType<typeof fetch>>;
|
|
25
|
-
interface HTTPResponse {
|
|
26
|
-
ok: FetchReturnValue['ok'];
|
|
27
|
-
status: FetchReturnValue['status'];
|
|
28
|
-
json: FetchReturnValue['json'];
|
|
29
|
-
text: FetchReturnValue['text'];
|
|
30
|
-
headers?: {
|
|
31
|
-
get(name: string): string | null;
|
|
32
|
-
} | Record<string, string | undefined>;
|
|
33
|
-
}
|
|
34
|
-
type HttpRequestor = (uri: string, options?: Parameters<typeof fetch>[1]) => Promise<HTTPResponse>;
|
|
35
|
-
//#endregion
|
|
36
24
|
//#region src/types/v2_results.d.ts
|
|
37
25
|
/** Pool metadata returned by GalaChainDex. */
|
|
38
26
|
export interface PoolInfo {
|
|
@@ -256,80 +244,7 @@ export interface ChainSubmissionResult {
|
|
|
256
244
|
uniqueKey?: string;
|
|
257
245
|
}
|
|
258
246
|
//#endregion
|
|
259
|
-
//#region src/
|
|
260
|
-
/**
|
|
261
|
-
* How the SDK writes a read request on the wire. The defaults suit a server-side caller; an app
|
|
262
|
-
* that already issues the same requests from its own HTTP stack (frontend_v2, the Gala Wallet)
|
|
263
|
-
* sets these so the SDK's requests are indistinguishable from the ones it replaces.
|
|
264
|
-
*
|
|
265
|
-
* One object, carried by {@link ChainGateway}, so every service built on a gateway (symbols,
|
|
266
|
-
* pools, positions, quoting) shares it without per-service plumbing.
|
|
267
|
-
*/
|
|
268
|
-
export interface WireOptions {
|
|
269
|
-
/**
|
|
270
|
-
* Query-string encoding of GET parameters.
|
|
271
|
-
*
|
|
272
|
-
* - `'standard'` (default): `URLSearchParams` (`application/x-www-form-urlencoded`), where `$`
|
|
273
|
-
* and `|` become `%24` and `%7C`.
|
|
274
|
-
* - `'readable'`: keeps `$ | : ,` and the RFC 3986 sub-delimiters `! ' ( ) *` unescaped, so a
|
|
275
|
-
* composite key such as `GALA$Unit$none$none` or `client|abc` reads as written. Everything
|
|
276
|
-
* that would change a query's meaning (`& = # % +`, space, non-ASCII, controls) is still
|
|
277
|
-
* percent-encoded (a space is `+`), so the server decodes exactly the value that was passed.
|
|
278
|
-
* This is the text frontend_v2's `formatUrl` produces for every value it can represent.
|
|
279
|
-
*/
|
|
280
|
-
queryEncoding?: 'standard' | 'readable' | undefined;
|
|
281
|
-
/**
|
|
282
|
-
* The `User-Agent` request header. Defaults to `GalaChain-SDK/<version>`; `false` omits it
|
|
283
|
-
* (browsers forbid setting it, and an app whose own requests carry none can match them).
|
|
284
|
-
* `Content-Type` is only ever sent with a request body, never on a GET.
|
|
285
|
-
*/
|
|
286
|
-
userAgent?: string | false | undefined;
|
|
287
|
-
/**
|
|
288
|
-
* Extra request headers for every read, sent after (and so able to replace) the defaults above;
|
|
289
|
-
* for example axios' `Accept: application/json, text/plain, *\/*`, so a request is the same as
|
|
290
|
-
* the one an app's own HTTP stack used to send.
|
|
291
|
-
*/
|
|
292
|
-
headers?: Record<string, string> | undefined;
|
|
293
|
-
}
|
|
294
|
-
//#endregion
|
|
295
|
-
//#region src/classes/error_phases.d.ts
|
|
296
|
-
/**
|
|
297
|
-
* How far an operation had got when it failed, measured against the request it exists to send:
|
|
298
|
-
* for a write, the POST that carries the signed DTO to the gateway; for a read, the GET.
|
|
299
|
-
*
|
|
300
|
-
* - `pre_send`: NOTHING was transmitted. Everything up to the request (validation, symbol
|
|
301
|
-
* resolution, the signer, the wallet, a key provider) ran and failed, so no write can have been
|
|
302
|
-
* queued. A write that failed `pre_send` is never "maybe applied".
|
|
303
|
-
* - `in_flight`: the request left (or may have left) and no answer was read: a timeout, a broken
|
|
304
|
-
* connection, a stream that dropped. For a write the outcome is unknown.
|
|
305
|
-
* - `post_send`: an answer was read, or the write was already accepted: a refusal, an
|
|
306
|
-
* acknowledgement that proves nothing, an unusable body, and every failure of a confirmation.
|
|
307
|
-
*
|
|
308
|
-
* Each catalog entry declares the phase its code is thrown in; a throw site where the same code
|
|
309
|
-
* can occur in another phase overrides it (`GSwapErrorContext.phase`). It is a typed property of
|
|
310
|
-
* every `GSwapSDKError` (`error.phase`) and `isPreSendError(error)` reads it.
|
|
311
|
-
*
|
|
312
|
-
* This module has no imports, on purpose: it is the closed set of phases, shared by the catalog,
|
|
313
|
-
* the light phase table (`error_phase_table.ts`) and the failure view.
|
|
314
|
-
*/
|
|
315
|
-
export declare const GSWAP_ERROR_PHASES: readonly ['pre_send', 'in_flight', 'post_send'];
|
|
316
|
-
/** One member of {@link GSWAP_ERROR_PHASES}. */
|
|
317
|
-
type GSwapErrorPhase = (typeof GSWAP_ERROR_PHASES)[number];
|
|
318
|
-
//#endregion
|
|
319
|
-
//#region src/classes/error_catalog.d.ts
|
|
320
|
-
/**
|
|
321
|
-
* Why a private key was refused (`INVALID_PRIVATE_KEY.params.reason`). A token for the app to map
|
|
322
|
-
* to its own text, never English and never any part of the key.
|
|
323
|
-
*
|
|
324
|
-
* - `wrong_length`: raw bytes that are not 32 bytes long.
|
|
325
|
-
* - `bad_encoding`: a string that is neither 64 hex characters (optionally `0x`-prefixed, 63 is
|
|
326
|
-
* left-padded) nor a 44-character base64 string.
|
|
327
|
-
* - `not_on_curve`: 32 bytes that are not a valid secp256k1 secret scalar.
|
|
328
|
-
* - `no_key_provided`: a lazy key provider returned something that is not a string.
|
|
329
|
-
*/
|
|
330
|
-
export declare const INVALID_PRIVATE_KEY_REASONS: readonly ['wrong_length', 'bad_encoding', 'not_on_curve', 'no_key_provided'];
|
|
331
|
-
/** One member of {@link INVALID_PRIVATE_KEY_REASONS}. */
|
|
332
|
-
type InvalidPrivateKeyReason = (typeof INVALID_PRIVATE_KEY_REASONS)[number];
|
|
247
|
+
//#region src/classes/gswap_error_catalog.d.ts
|
|
333
248
|
/**
|
|
334
249
|
* Why the outcome of a write submission is unknown (`SUBMISSION_OUTCOME_UNKNOWN.params.reason`).
|
|
335
250
|
* Both say the same thing about the swap (it MAY have been queued: never resubmit under a fresh
|
|
@@ -343,20 +258,7 @@ type InvalidPrivateKeyReason = (typeof INVALID_PRIVATE_KEY_REASONS)[number];
|
|
|
343
258
|
export declare const SUBMISSION_OUTCOME_UNKNOWN_REASONS: readonly ['timeout', 'transport'];
|
|
344
259
|
/** One member of {@link SUBMISSION_OUTCOME_UNKNOWN_REASONS}. */
|
|
345
260
|
type SubmissionOutcomeUnknownReason = (typeof SUBMISSION_OUTCOME_UNKNOWN_REASONS)[number];
|
|
346
|
-
/**
|
|
347
|
-
* Why a signer could not produce a signature (`SIGNING_FAILED.params.reason`). A token for the
|
|
348
|
-
* app to map to its own text.
|
|
349
|
-
*
|
|
350
|
-
* - `user_rejected`: the person declined in their wallet (an EIP-1193 `4001`, an ethers
|
|
351
|
-
* `ACTION_REJECTED`, or a wallet that words it "User rejected/denied ..."). Nothing is wrong:
|
|
352
|
-
* they may simply try again.
|
|
353
|
-
* - `failed`: anything else the signer threw (a locked wallet, an unreachable extension, a wallet
|
|
354
|
-
* that refused). The original error is `cause`.
|
|
355
|
-
*/
|
|
356
|
-
export declare const SIGNING_FAILURE_REASONS: readonly ['user_rejected', 'failed'];
|
|
357
|
-
/** One member of {@link SIGNING_FAILURE_REASONS}. */
|
|
358
|
-
type SigningFailureReason = (typeof SIGNING_FAILURE_REASONS)[number];
|
|
359
|
-
/** The whole catalog. Add a code here before throwing it anywhere. */
|
|
261
|
+
/** The whole DEX catalog. Add a code here before throwing it anywhere in gswap-sdk. */
|
|
360
262
|
export declare const GSWAP_ERROR_CATALOG: {
|
|
361
263
|
readonly HTTP_ERROR: {
|
|
362
264
|
readonly phase: 'post_send';
|
|
@@ -375,21 +277,6 @@ export declare const GSWAP_ERROR_CATALOG: {
|
|
|
375
277
|
readonly status: 'number';
|
|
376
278
|
};
|
|
377
279
|
};
|
|
378
|
-
readonly REQUEST_TIMEOUT: {
|
|
379
|
-
readonly phase: 'in_flight';
|
|
380
|
-
readonly template: 'Request to {url} timed out after {timeoutMs} ms.';
|
|
381
|
-
readonly params: {
|
|
382
|
-
readonly url: 'string';
|
|
383
|
-
readonly timeoutMs: 'number';
|
|
384
|
-
};
|
|
385
|
-
};
|
|
386
|
-
readonly TRANSPORT_ERROR: {
|
|
387
|
-
readonly phase: 'in_flight';
|
|
388
|
-
readonly template: 'The request to {url} failed before the server answered.';
|
|
389
|
-
readonly params: {
|
|
390
|
-
readonly url: 'string';
|
|
391
|
-
};
|
|
392
|
-
};
|
|
393
280
|
readonly REQUEST_FAILED: {
|
|
394
281
|
readonly phase: 'in_flight';
|
|
395
282
|
readonly template: 'The {operation} request failed.';
|
|
@@ -397,14 +284,6 @@ export declare const GSWAP_ERROR_CATALOG: {
|
|
|
397
284
|
readonly operation: 'string';
|
|
398
285
|
};
|
|
399
286
|
};
|
|
400
|
-
readonly INVALID_TIMEOUT: {
|
|
401
|
-
readonly phase: 'pre_send';
|
|
402
|
-
readonly template: '{field} must be a positive number of milliseconds, or Infinity for no timeout (got {value}).';
|
|
403
|
-
readonly params: {
|
|
404
|
-
readonly field: 'string';
|
|
405
|
-
readonly value: 'number';
|
|
406
|
-
};
|
|
407
|
-
};
|
|
408
287
|
readonly METHOD_NOT_SUPPORTED: {
|
|
409
288
|
readonly phase: 'pre_send';
|
|
410
289
|
readonly template: 'The method {method} is not supported; swaps are queued through RequestTrade.';
|
|
@@ -668,69 +547,6 @@ export declare const GSWAP_ERROR_CATALOG: {
|
|
|
668
547
|
readonly closeCode: 'number';
|
|
669
548
|
};
|
|
670
549
|
};
|
|
671
|
-
readonly GALA_WALLET_NOT_AVAILABLE: {
|
|
672
|
-
readonly phase: 'pre_send';
|
|
673
|
-
readonly template: 'Gala wallet is not available. Please ensure the Gala wallet is connected.';
|
|
674
|
-
readonly params: {};
|
|
675
|
-
};
|
|
676
|
-
readonly WALLET_UNAVAILABLE: {
|
|
677
|
-
readonly phase: 'pre_send';
|
|
678
|
-
readonly template: 'No wallet is connected.';
|
|
679
|
-
readonly params: {};
|
|
680
|
-
};
|
|
681
|
-
readonly MALFORMED_WALLET_REQUEST: {
|
|
682
|
-
readonly phase: 'pre_send';
|
|
683
|
-
readonly template: 'Wallet {method} request is malformed.';
|
|
684
|
-
readonly params: {
|
|
685
|
-
readonly method: 'string';
|
|
686
|
-
};
|
|
687
|
-
};
|
|
688
|
-
readonly UNSUPPORTED_WALLET_METHOD: {
|
|
689
|
-
readonly phase: 'pre_send';
|
|
690
|
-
readonly template: 'Unsupported wallet method {method}.';
|
|
691
|
-
readonly params: {
|
|
692
|
-
readonly method: 'string';
|
|
693
|
-
};
|
|
694
|
-
};
|
|
695
|
-
readonly INVALID_SIGNATURE: {
|
|
696
|
-
readonly phase: 'pre_send';
|
|
697
|
-
readonly template: 'Wallet returned an invalid {scheme} signature.';
|
|
698
|
-
readonly params: {
|
|
699
|
-
readonly scheme: 'string';
|
|
700
|
-
};
|
|
701
|
-
};
|
|
702
|
-
readonly INVALID_CHAIN_ID: {
|
|
703
|
-
readonly phase: 'pre_send';
|
|
704
|
-
readonly template: 'Wallet returned an invalid chain id ({chainId}).';
|
|
705
|
-
readonly params: {
|
|
706
|
-
readonly chainId: 'string';
|
|
707
|
-
};
|
|
708
|
-
};
|
|
709
|
-
readonly SIGNER_ADDRESS_MISMATCH: {
|
|
710
|
-
readonly phase: 'pre_send';
|
|
711
|
-
readonly template: 'The signing key does not belong to the expected account.';
|
|
712
|
-
readonly params: {};
|
|
713
|
-
};
|
|
714
|
-
readonly INVALID_PRIVATE_KEY: {
|
|
715
|
-
readonly phase: 'pre_send';
|
|
716
|
-
readonly template: 'Invalid private key: {reason}.';
|
|
717
|
-
readonly params: {
|
|
718
|
-
readonly reason: readonly ["wrong_length", "bad_encoding", "not_on_curve", "no_key_provided"];
|
|
719
|
-
};
|
|
720
|
-
};
|
|
721
|
-
readonly SIGNING_FAILED: {
|
|
722
|
-
readonly phase: 'pre_send';
|
|
723
|
-
readonly template: 'Signing the {method} request failed ({reason}); nothing was sent.';
|
|
724
|
-
readonly params: {
|
|
725
|
-
readonly method: 'string';
|
|
726
|
-
readonly reason: readonly ["user_rejected", "failed"];
|
|
727
|
-
};
|
|
728
|
-
};
|
|
729
|
-
readonly KEY_PROVIDER_FAILED: {
|
|
730
|
-
readonly phase: 'pre_send';
|
|
731
|
-
readonly template: 'The signing key could not be fetched; nothing was sent.';
|
|
732
|
-
readonly params: {};
|
|
733
|
-
};
|
|
734
550
|
readonly TOKEN_RESOLUTION_FAILED: {
|
|
735
551
|
readonly phase: 'pre_send';
|
|
736
552
|
readonly template: 'Token {token} could not be looked up; nothing was sent.';
|
|
@@ -738,248 +554,11 @@ export declare const GSWAP_ERROR_CATALOG: {
|
|
|
738
554
|
readonly token: 'string';
|
|
739
555
|
};
|
|
740
556
|
};
|
|
741
|
-
readonly INVALID_SIGNING_HASH_LENGTH: {
|
|
742
|
-
readonly phase: 'pre_send';
|
|
743
|
-
readonly template: 'secp256k1 can only sign a 32-byte hash (got {length}).';
|
|
744
|
-
readonly params: {
|
|
745
|
-
readonly length: 'number';
|
|
746
|
-
};
|
|
747
|
-
};
|
|
748
557
|
readonly MISSING_WALLET_ADDRESS: {
|
|
749
558
|
readonly phase: 'pre_send';
|
|
750
559
|
readonly template: 'Invalid wallet address: No wallet address provided. Either provide a wallet address to the function you are calling, or set one when instantiating GSwapSDK.';
|
|
751
560
|
readonly params: {};
|
|
752
561
|
};
|
|
753
|
-
readonly INVALID_WALLET_ADDRESS: {
|
|
754
|
-
readonly phase: 'pre_send';
|
|
755
|
-
readonly template: 'Invalid {field}: "{value}" is not an accepted wallet address form.';
|
|
756
|
-
readonly params: {
|
|
757
|
-
readonly field: 'string';
|
|
758
|
-
readonly value: 'string';
|
|
759
|
-
};
|
|
760
|
-
};
|
|
761
|
-
readonly INVALID_DECIMAL: {
|
|
762
|
-
readonly phase: 'pre_send';
|
|
763
|
-
readonly template: 'Invalid decimal quantity: {value}';
|
|
764
|
-
readonly params: {
|
|
765
|
-
readonly value: 'string';
|
|
766
|
-
};
|
|
767
|
-
};
|
|
768
|
-
readonly PERSONAL_SIGN_NOT_JSON: {
|
|
769
|
-
readonly phase: 'pre_send';
|
|
770
|
-
readonly template: 'Personal-sign DTO is not valid JSON';
|
|
771
|
-
readonly params: {};
|
|
772
|
-
};
|
|
773
|
-
readonly PERSONAL_SIGN_NOT_OBJECT: {
|
|
774
|
-
readonly phase: 'pre_send';
|
|
775
|
-
readonly template: 'Personal-sign DTO must be a JSON object';
|
|
776
|
-
readonly params: {};
|
|
777
|
-
};
|
|
778
|
-
readonly PERSONAL_SIGN_BAD_PREFIX: {
|
|
779
|
-
readonly phase: 'pre_send';
|
|
780
|
-
readonly template: 'Personal-sign DTO prefix is not an EIP-191 "Ethereum Signed Message" header';
|
|
781
|
-
readonly params: {};
|
|
782
|
-
};
|
|
783
|
-
readonly PERSONAL_SIGN_ENVELOPE_FIELDS: {
|
|
784
|
-
readonly phase: 'pre_send';
|
|
785
|
-
readonly template: 'Personal-sign DTO carries signing-envelope field(s): {fields}';
|
|
786
|
-
readonly params: {
|
|
787
|
-
readonly fields: 'string';
|
|
788
|
-
};
|
|
789
|
-
};
|
|
790
|
-
readonly PERSONAL_SIGN_NOT_CANONICAL: {
|
|
791
|
-
readonly phase: 'pre_send';
|
|
792
|
-
readonly template: 'Personal-sign DTO is not in canonical serialized form';
|
|
793
|
-
readonly params: {};
|
|
794
|
-
};
|
|
795
|
-
readonly EIP712_NAME_COLLISION: {
|
|
796
|
-
readonly phase: 'pre_send';
|
|
797
|
-
readonly template: 'Name collisions are not supported when deriving EIP-712 types ({name}).';
|
|
798
|
-
readonly params: {
|
|
799
|
-
readonly name: 'string';
|
|
800
|
-
};
|
|
801
|
-
};
|
|
802
|
-
readonly EIP712_UNSUPPORTED_VALUE: {
|
|
803
|
-
readonly phase: 'pre_send';
|
|
804
|
-
readonly template: 'Unsupported EIP-712 value of type {valueType}.';
|
|
805
|
-
readonly params: {
|
|
806
|
-
readonly valueType: 'string';
|
|
807
|
-
};
|
|
808
|
-
};
|
|
809
|
-
readonly TYPED_DATA_NOT_STRING: {
|
|
810
|
-
readonly phase: 'pre_send';
|
|
811
|
-
readonly template: 'Invalid typed data: {what} must be a string';
|
|
812
|
-
readonly params: {
|
|
813
|
-
readonly what: 'string';
|
|
814
|
-
};
|
|
815
|
-
};
|
|
816
|
-
readonly TYPED_DATA_UNPAIRED_SURROGATE: {
|
|
817
|
-
readonly phase: 'pre_send';
|
|
818
|
-
readonly template: 'Invalid typed data: {what} has an unpaired surrogate';
|
|
819
|
-
readonly params: {
|
|
820
|
-
readonly what: 'string';
|
|
821
|
-
};
|
|
822
|
-
};
|
|
823
|
-
readonly TYPED_DATA_NOT_HEX_BYTES: {
|
|
824
|
-
readonly phase: 'pre_send';
|
|
825
|
-
readonly template: 'Invalid typed data: {what} must be an even-length 0x hex string';
|
|
826
|
-
readonly params: {
|
|
827
|
-
readonly what: 'string';
|
|
828
|
-
};
|
|
829
|
-
};
|
|
830
|
-
readonly TYPED_DATA_NOT_SAFE_INTEGER: {
|
|
831
|
-
readonly phase: 'pre_send';
|
|
832
|
-
readonly template: 'Invalid typed data: {what} must be a safe integer';
|
|
833
|
-
readonly params: {
|
|
834
|
-
readonly what: 'string';
|
|
835
|
-
};
|
|
836
|
-
};
|
|
837
|
-
readonly TYPED_DATA_NOT_INTEGER: {
|
|
838
|
-
readonly phase: 'pre_send';
|
|
839
|
-
readonly template: 'Invalid typed data: {what} must be an integer';
|
|
840
|
-
readonly params: {
|
|
841
|
-
readonly what: 'string';
|
|
842
|
-
};
|
|
843
|
-
};
|
|
844
|
-
readonly TYPED_DATA_NOT_BOOLEAN: {
|
|
845
|
-
readonly phase: 'pre_send';
|
|
846
|
-
readonly template: 'Invalid typed data: bool must be a boolean';
|
|
847
|
-
readonly params: {};
|
|
848
|
-
};
|
|
849
|
-
readonly TYPED_DATA_BAD_ADDRESS: {
|
|
850
|
-
readonly phase: 'pre_send';
|
|
851
|
-
readonly template: 'Invalid typed data: address must be 0x followed by 40 hex digits';
|
|
852
|
-
readonly params: {};
|
|
853
|
-
};
|
|
854
|
-
readonly TYPED_DATA_BAD_CHECKSUM: {
|
|
855
|
-
readonly phase: 'pre_send';
|
|
856
|
-
readonly template: 'Invalid typed data: address has a bad checksum';
|
|
857
|
-
readonly params: {};
|
|
858
|
-
};
|
|
859
|
-
readonly TYPED_DATA_BYTES_LENGTH: {
|
|
860
|
-
readonly phase: 'pre_send';
|
|
861
|
-
readonly template: 'Invalid typed data: {type} must be exactly {width} bytes';
|
|
862
|
-
readonly params: {
|
|
863
|
-
readonly type: 'string';
|
|
864
|
-
readonly width: 'number';
|
|
865
|
-
};
|
|
866
|
-
};
|
|
867
|
-
readonly TYPED_DATA_OUT_OF_BOUNDS: {
|
|
868
|
-
readonly phase: 'pre_send';
|
|
869
|
-
readonly template: 'Invalid typed data: value out of bounds for {type}';
|
|
870
|
-
readonly params: {
|
|
871
|
-
readonly type: 'string';
|
|
872
|
-
};
|
|
873
|
-
};
|
|
874
|
-
readonly TYPED_DATA_UNSUPPORTED_TYPE: {
|
|
875
|
-
readonly phase: 'pre_send';
|
|
876
|
-
readonly template: 'Invalid typed data: unsupported type "{type}"';
|
|
877
|
-
readonly params: {
|
|
878
|
-
readonly type: 'string';
|
|
879
|
-
};
|
|
880
|
-
};
|
|
881
|
-
readonly TYPED_DATA_FIELDS_NOT_LIST: {
|
|
882
|
-
readonly phase: 'pre_send';
|
|
883
|
-
readonly template: 'Invalid typed data: type {typeName} must be a list of fields';
|
|
884
|
-
readonly params: {
|
|
885
|
-
readonly typeName: 'string';
|
|
886
|
-
};
|
|
887
|
-
};
|
|
888
|
-
readonly TYPED_DATA_FIELD_MALFORMED: {
|
|
889
|
-
readonly phase: 'pre_send';
|
|
890
|
-
readonly template: 'Invalid typed data: type {typeName} has a field without a string name and type';
|
|
891
|
-
readonly params: {
|
|
892
|
-
readonly typeName: 'string';
|
|
893
|
-
};
|
|
894
|
-
};
|
|
895
|
-
readonly TYPED_DATA_INVALID_FIELD_NAME: {
|
|
896
|
-
readonly phase: 'pre_send';
|
|
897
|
-
readonly template: 'Invalid typed data: invalid field name "{name}"';
|
|
898
|
-
readonly params: {
|
|
899
|
-
readonly name: 'string';
|
|
900
|
-
};
|
|
901
|
-
};
|
|
902
|
-
readonly TYPED_DATA_DUPLICATE_FIELD: {
|
|
903
|
-
readonly phase: 'pre_send';
|
|
904
|
-
readonly template: 'Invalid typed data: duplicate field "{name}" in {typeName}';
|
|
905
|
-
readonly params: {
|
|
906
|
-
readonly name: 'string';
|
|
907
|
-
readonly typeName: 'string';
|
|
908
|
-
};
|
|
909
|
-
};
|
|
910
|
-
readonly TYPED_DATA_INVALID_TYPE_NAME: {
|
|
911
|
-
readonly phase: 'pre_send';
|
|
912
|
-
readonly template: 'Invalid typed data: invalid type name "{name}"';
|
|
913
|
-
readonly params: {
|
|
914
|
-
readonly name: 'string';
|
|
915
|
-
};
|
|
916
|
-
};
|
|
917
|
-
readonly TYPED_DATA_CIRCULAR_TYPE: {
|
|
918
|
-
readonly phase: 'pre_send';
|
|
919
|
-
readonly template: 'Invalid typed data: circular type reference in {typeName}';
|
|
920
|
-
readonly params: {
|
|
921
|
-
readonly typeName: 'string';
|
|
922
|
-
};
|
|
923
|
-
};
|
|
924
|
-
readonly TYPED_DATA_UNKNOWN_FIELD_TYPE: {
|
|
925
|
-
readonly phase: 'pre_send';
|
|
926
|
-
readonly template: 'Invalid typed data: unknown type "{type}" in {typeName}';
|
|
927
|
-
readonly params: {
|
|
928
|
-
readonly type: 'string';
|
|
929
|
-
readonly typeName: 'string';
|
|
930
|
-
};
|
|
931
|
-
};
|
|
932
|
-
readonly TYPED_DATA_NO_PRIMARY_TYPE: {
|
|
933
|
-
readonly phase: 'pre_send';
|
|
934
|
-
readonly template: 'Invalid typed data: missing primary type';
|
|
935
|
-
readonly params: {};
|
|
936
|
-
};
|
|
937
|
-
readonly TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE: {
|
|
938
|
-
readonly phase: 'pre_send';
|
|
939
|
-
readonly template: 'Invalid typed data: ambiguous primary types or unused types ({roots})';
|
|
940
|
-
readonly params: {
|
|
941
|
-
readonly roots: 'string';
|
|
942
|
-
};
|
|
943
|
-
};
|
|
944
|
-
readonly TYPED_DATA_ARRAY_EXPECTED: {
|
|
945
|
-
readonly phase: 'pre_send';
|
|
946
|
-
readonly template: 'Invalid typed data: {type} array value must be an array';
|
|
947
|
-
readonly params: {
|
|
948
|
-
readonly type: 'string';
|
|
949
|
-
};
|
|
950
|
-
};
|
|
951
|
-
readonly TYPED_DATA_ARRAY_LENGTH_MISMATCH: {
|
|
952
|
-
readonly phase: 'pre_send';
|
|
953
|
-
readonly template: 'Invalid typed data: array length mismatch';
|
|
954
|
-
readonly params: {};
|
|
955
|
-
};
|
|
956
|
-
readonly TYPED_DATA_STRUCT_NOT_OBJECT: {
|
|
957
|
-
readonly phase: 'pre_send';
|
|
958
|
-
readonly template: 'Invalid typed data: {typeName} value must be an object';
|
|
959
|
-
readonly params: {
|
|
960
|
-
readonly typeName: 'string';
|
|
961
|
-
};
|
|
962
|
-
};
|
|
963
|
-
readonly TYPED_DATA_MISSING_FIELD: {
|
|
964
|
-
readonly phase: 'pre_send';
|
|
965
|
-
readonly template: 'Invalid typed data: {typeName} value is missing field "{field}"';
|
|
966
|
-
readonly params: {
|
|
967
|
-
readonly typeName: 'string';
|
|
968
|
-
readonly field: 'string';
|
|
969
|
-
};
|
|
970
|
-
};
|
|
971
|
-
readonly TYPED_DATA_DOMAIN_NOT_OBJECT: {
|
|
972
|
-
readonly phase: 'pre_send';
|
|
973
|
-
readonly template: 'Invalid typed data: domain must be an object';
|
|
974
|
-
readonly params: {};
|
|
975
|
-
};
|
|
976
|
-
readonly TYPED_DATA_INVALID_DOMAIN_KEY: {
|
|
977
|
-
readonly phase: 'pre_send';
|
|
978
|
-
readonly template: 'Invalid typed data: invalid typed-data domain key {key}';
|
|
979
|
-
readonly params: {
|
|
980
|
-
readonly key: 'string';
|
|
981
|
-
};
|
|
982
|
-
};
|
|
983
562
|
readonly NON_CANONICAL_PAIR: {
|
|
984
563
|
readonly phase: 'pre_send';
|
|
985
564
|
readonly template: 'The pair {token0}/{token1} is not in canonical order: token0 must sort before token1.';
|
|
@@ -1048,21 +627,6 @@ export declare const GSWAP_ERROR_CATALOG: {
|
|
|
1048
627
|
readonly token: 'string';
|
|
1049
628
|
};
|
|
1050
629
|
};
|
|
1051
|
-
readonly INVALID_UNIQUE_KEY: {
|
|
1052
|
-
readonly phase: 'pre_send';
|
|
1053
|
-
readonly template: 'The uniqueKey "{uniqueKey}" must be 1-128 characters of A-Z, a-z, 0-9, ".", "_", ":" or "-".';
|
|
1054
|
-
readonly params: {
|
|
1055
|
-
readonly uniqueKey: 'string';
|
|
1056
|
-
};
|
|
1057
|
-
};
|
|
1058
|
-
readonly INVALID_UNIQUE_KEY_PREFIX: {
|
|
1059
|
-
readonly phase: 'pre_send';
|
|
1060
|
-
readonly template: 'uniqueKeyPrefix "{uniqueKeyPrefix}" must be at most {maxLength} characters of A-Z, a-z, 0-9, ".", "_", ":" or "-".';
|
|
1061
|
-
readonly params: {
|
|
1062
|
-
readonly uniqueKeyPrefix: 'string';
|
|
1063
|
-
readonly maxLength: 'number';
|
|
1064
|
-
};
|
|
1065
|
-
};
|
|
1066
630
|
readonly AMOUNT_IS_JS_NUMBER: {
|
|
1067
631
|
readonly phase: 'pre_send';
|
|
1068
632
|
readonly template: 'Invalid {field}: use a decimal string or BigNumber, not a JavaScript number';
|
|
@@ -1293,69 +857,49 @@ export declare const GSWAP_ERROR_CATALOG: {
|
|
|
1293
857
|
readonly max: 'number';
|
|
1294
858
|
};
|
|
1295
859
|
};
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
*
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
*
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
*/
|
|
1340
|
-
declare const GSWAP_ERROR_BRAND: unique symbol;
|
|
1341
|
-
/** The least an object must have to be read as an SDK error or its plain-object view. */
|
|
1342
|
-
interface GSwapErrorShape {
|
|
1343
|
-
readonly code: string;
|
|
1344
|
-
readonly params: Readonly<Record<string, unknown>>;
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* True when `value` is an SDK error (it carries the brand) or a plain-object VIEW of one: a string
|
|
1348
|
-
* `code` and an object `params`, which is the shape of `GSwapSDKError` and of the wrapper objects
|
|
1349
|
-
* an app builds from one (`{ code, params, status?, phase?, ... }`). A wallet's own error (an
|
|
1350
|
-
* EIP-1193 numeric `code`, an ethers error with a string `code` and no `params`) is neither. It
|
|
1351
|
-
* says the value has the SDK's shape, not that `code` is a code the SDK knows.
|
|
1352
|
-
*
|
|
1353
|
-
* @example
|
|
1354
|
-
* ```ts
|
|
1355
|
-
* if (isGSwapErrorLike(error)) report(error.code, error.params); // no `instanceof`, no SDK import
|
|
1356
|
-
* ```
|
|
1357
|
-
*/
|
|
1358
|
-
export declare function isGSwapErrorLike(value: unknown): value is GSwapErrorShape;
|
|
860
|
+
readonly INVALID_MARKET_TOKEN: {
|
|
861
|
+
readonly phase: 'pre_send';
|
|
862
|
+
readonly template: 'A market read names a token by a symbol or class key of 1 to 120 letters, digits and . _ $ + / : | - characters (got "{token}").';
|
|
863
|
+
readonly params: {
|
|
864
|
+
readonly token: 'string';
|
|
865
|
+
};
|
|
866
|
+
};
|
|
867
|
+
readonly INVALID_TIMEFRAME: {
|
|
868
|
+
readonly phase: 'pre_send';
|
|
869
|
+
readonly template: 'timeframe "{value}" is not allowed; it must be one of {allowed}.';
|
|
870
|
+
readonly params: {
|
|
871
|
+
readonly value: 'string';
|
|
872
|
+
readonly allowed: 'string';
|
|
873
|
+
};
|
|
874
|
+
};
|
|
875
|
+
readonly INVALID_SEASON_ID: {
|
|
876
|
+
readonly phase: 'pre_send';
|
|
877
|
+
readonly template: 'seasonId must be an integer of at least 1 (got {value}).';
|
|
878
|
+
readonly params: {
|
|
879
|
+
readonly value: 'string';
|
|
880
|
+
};
|
|
881
|
+
};
|
|
882
|
+
readonly INVALID_POLL_INTERVAL: {
|
|
883
|
+
readonly phase: 'pre_send';
|
|
884
|
+
readonly template: 'intervalMs must be a finite number of milliseconds of at least 1 (got {value}).';
|
|
885
|
+
readonly params: {
|
|
886
|
+
readonly value: 'string';
|
|
887
|
+
};
|
|
888
|
+
};
|
|
889
|
+
};
|
|
890
|
+
/** Every code a `GSwapSDKError` can carry: the core codes and gswap-sdk's own DEX codes. */
|
|
891
|
+
type GSwapErrorCode = GalaErrorCode | keyof typeof GSWAP_ERROR_CATALOG;
|
|
892
|
+
/** Both catalogs as one type: a code of either reads its entry here. */
|
|
893
|
+
type GSwapCatalog = typeof GALA_ERROR_CATALOG & typeof GSWAP_ERROR_CATALOG;
|
|
894
|
+
/** The named params of one error code (core or DEX): a flat object of primitives (or closed string tokens). */
|
|
895
|
+
type GSwapErrorParams<C extends GSwapErrorCode> = ErrorParamsOf<GSwapCatalog, C>;
|
|
896
|
+
/**
|
|
897
|
+
* The English template of every DEX error code, `{placeholder}` markers included. An optional seed
|
|
898
|
+
* or fallback for an app's own translations; the SDK's `message` is generated from it. The core
|
|
899
|
+
* codes' templates are `galaErrorTemplates` from `@gala-chain/gala-core-sdk`: an app that seeds
|
|
900
|
+
* every code a `GSwapSDKError` can carry merges the two.
|
|
901
|
+
*/
|
|
902
|
+
export declare const gswapErrorTemplates: { readonly [C in keyof typeof GSWAP_ERROR_CATALOG]: string; };
|
|
1359
903
|
//#endregion
|
|
1360
904
|
//#region src/classes/gswap_sdk_error.d.ts
|
|
1361
905
|
/**
|
|
@@ -1364,48 +908,6 @@ export declare function isGSwapErrorLike(value: unknown): value is GSwapErrorSha
|
|
|
1364
908
|
* says; a confirmation read keeps `CONFIRMATION_FAILED` because the write it confirms may be applied.
|
|
1365
909
|
*/
|
|
1366
910
|
export declare const UPDATE_REQUIRED_STATUS = 426;
|
|
1367
|
-
/**
|
|
1368
|
-
* The facts of an error that are not placeholders of its message: where it happened and what the
|
|
1369
|
-
* server said. All optional; none is localized text.
|
|
1370
|
-
*/
|
|
1371
|
-
export interface GSwapErrorContext {
|
|
1372
|
-
/** The HTTP status of the response that caused the error. */
|
|
1373
|
-
status?: number | undefined;
|
|
1374
|
-
/**
|
|
1375
|
-
* The response body: parsed JSON when the failing response had it, else the raw text (which
|
|
1376
|
-
* the error then exposes as {@link GSwapSDKError.bodyText}).
|
|
1377
|
-
*/
|
|
1378
|
-
body?: unknown;
|
|
1379
|
-
/** The URL the failing request went to. */
|
|
1380
|
-
url?: string | undefined;
|
|
1381
|
-
/** The `uniqueKey` of the write this error is about: the handle for `confirm()` and recovery. */
|
|
1382
|
-
uniqueKey?: string | undefined;
|
|
1383
|
-
/** The transaction id of the queued request, `null` when unknown. */
|
|
1384
|
-
requestTransactionId?: string | null | undefined;
|
|
1385
|
-
/** The transaction id of the apply, `null` when unknown. */
|
|
1386
|
-
applyTransactionId?: string | null | undefined;
|
|
1387
|
-
/** The block the apply landed in, `null` when unknown. */
|
|
1388
|
-
blockNumber?: number | null | undefined;
|
|
1389
|
-
/** How long to wait before retrying, from the server's `Retry-After`. */
|
|
1390
|
-
retryAfterMs?: number | undefined;
|
|
1391
|
-
/** The error that caused this one (a transport failure, a wallet rejection). */
|
|
1392
|
-
cause?: unknown;
|
|
1393
|
-
/**
|
|
1394
|
-
* The phase of THIS occurrence when it differs from the code's catalog phase (see
|
|
1395
|
-
* {@link GSwapErrorPhase}): for example `UNKNOWN_TOKEN` is `pre_send` from the symbol registry
|
|
1396
|
-
* but `post_send` when it is derived from a quote answer.
|
|
1397
|
-
*/
|
|
1398
|
-
phase?: GSwapErrorPhase | undefined;
|
|
1399
|
-
/** True when the failing operation was on the shadow (dark) path; see {@link GSwapSDKError.shadow}. */
|
|
1400
|
-
shadow?: boolean | undefined;
|
|
1401
|
-
/**
|
|
1402
|
-
* `false` for the failure of a READ (see {@link GSwapSDKError.write}); anything else, including
|
|
1403
|
-
* absent, is a write (fail-closed). Ignored when `uniqueKey` is set: that is a write.
|
|
1404
|
-
*/
|
|
1405
|
-
write?: boolean | undefined;
|
|
1406
|
-
/** The wallet's own code on the error a signer threw; see {@link GSwapSDKError.walletCode}. */
|
|
1407
|
-
walletCode?: number | string | undefined;
|
|
1408
|
-
}
|
|
1409
911
|
/** What {@link GSwapSDKError.fromStatus} may be told about the HTTP answer. */
|
|
1410
912
|
export interface GSwapStatusErrorOptions {
|
|
1411
913
|
/** The URL the request went to. */
|
|
@@ -1422,86 +924,21 @@ export interface GSwapStatusErrorOptions {
|
|
|
1422
924
|
retryAfterMs?: number | undefined;
|
|
1423
925
|
}
|
|
1424
926
|
/**
|
|
1425
|
-
* Error raised by
|
|
927
|
+
* Error raised by gswap-sdk for validation, gateway, chain, or transaction failures. It is a
|
|
928
|
+
* `GalaSDKError` (`@gala-chain/gala-core-sdk`), and can carry any code of the core catalog or of
|
|
929
|
+
* gswap-sdk's own DEX catalog: the signing, transport and wallet failures of a gswap flow are core
|
|
930
|
+
* codes, thrown either as a `GSwapSDKError` by gswap-sdk or as a plain `GalaSDKError` by core
|
|
931
|
+
* itself (a signer, the fetch requestor). Catch both with `isGSwapError` (or core's `isGalaError`);
|
|
932
|
+
* `instanceof GSwapSDKError` alone misses the second kind.
|
|
1426
933
|
*
|
|
1427
934
|
* Branch on {@link code} (stable) and render {@link params} through your own localization.
|
|
1428
935
|
* {@link message} is English generated from the catalog template for logs and developers: it
|
|
1429
936
|
* is not stable and must never be shown to a user or matched on.
|
|
1430
937
|
*/
|
|
1431
|
-
export declare class GSwapSDKError<C extends GSwapErrorCode = GSwapErrorCode> extends
|
|
1432
|
-
/**
|
|
1433
|
-
readonly
|
|
1434
|
-
|
|
1435
|
-
readonly params: GSwapErrorParams<C>;
|
|
1436
|
-
/** The server's `Retry-After` in milliseconds (a `RATE_LIMITED` answer), when it sent one. */
|
|
1437
|
-
readonly retryAfterMs: number | undefined;
|
|
1438
|
-
/** The HTTP status of the response that caused this error, when there was one. */
|
|
1439
|
-
readonly status: number | undefined;
|
|
1440
|
-
/**
|
|
1441
|
-
* The response body parsed as JSON, when the failing response had one; `undefined` for a body
|
|
1442
|
-
* that was not JSON (see {@link bodyText}). Never part of {@link message}.
|
|
1443
|
-
*/
|
|
1444
|
-
readonly body: unknown;
|
|
1445
|
-
/**
|
|
1446
|
-
* The raw text of a failing response whose body was NOT JSON (a proxy's HTML 502, a WAF page,
|
|
1447
|
-
* an empty body). It is kept here for diagnostics and is never copied into {@link message},
|
|
1448
|
-
* so it cannot reach a user interface by accident.
|
|
1449
|
-
*/
|
|
1450
|
-
readonly bodyText: string | undefined;
|
|
1451
|
-
/** The URL the failing request went to, when there was one. */
|
|
1452
|
-
readonly url: string | undefined;
|
|
1453
|
-
/** The `uniqueKey` of the write this error is about, when there is one. */
|
|
1454
|
-
readonly uniqueKey: string | undefined;
|
|
1455
|
-
/** The transaction id of the queued request, when known. */
|
|
1456
|
-
readonly requestTransactionId: string | null | undefined;
|
|
1457
|
-
/** The transaction id of the apply, when known. */
|
|
1458
|
-
readonly applyTransactionId: string | null | undefined;
|
|
1459
|
-
/** The block the apply landed in, when known. */
|
|
1460
|
-
readonly blockNumber: number | null | undefined;
|
|
1461
|
-
/**
|
|
1462
|
-
* How far the operation had got when this was thrown, against the request it exists to send
|
|
1463
|
-
* (see {@link GSwapErrorPhase}): `pre_send` means NOTHING was transmitted, so a write that
|
|
1464
|
-
* failed this way cannot have been queued; `in_flight` means the request left and no answer was
|
|
1465
|
-
* read; `post_send` means an answer was read or the write was already accepted. Every catalog
|
|
1466
|
-
* code declares its phase, and a throw site can refine it. Read it with
|
|
1467
|
-
* {@link isPreSendError}; `classifyFailure` already folds it into `outcome` and `retryable`.
|
|
1468
|
-
*/
|
|
1469
|
-
readonly phase: GSwapErrorPhase;
|
|
1470
|
-
/**
|
|
1471
|
-
* True when this error came from the shadow (dark) path: `swapShadow`, `submitSwapShadow` or
|
|
1472
|
-
* `ChainGateway.submitShadow`, whatever failed there (a validation error, the signer, the
|
|
1473
|
-
* transport, `SHADOW_NOT_QUEUED`). The classification is the same as on the public path; this
|
|
1474
|
-
* is how an app applies its own dark-swap policy (the wallet and frontend_v2 never offer a
|
|
1475
|
-
* public fallback or Retry after one). A shadow gateway refusal that RESOLVES (`{ ok: false }`)
|
|
1476
|
-
* is not an error and has no flag: the call itself says it was shadow.
|
|
1477
|
-
*/
|
|
1478
|
-
readonly shadow: boolean;
|
|
1479
|
-
/**
|
|
1480
|
-
* Whether this failure is a WRITE's, as the guards read it: `false` only for the failure of a
|
|
1481
|
-
* READ (a quote, a pool list, an apply-results read), which has no `uniqueKey` to confirm and
|
|
1482
|
-
* nothing pending, so a 5xx there is `transient` and retryable. It is `true` for everything else,
|
|
1483
|
-
* and always when {@link uniqueKey} is set. That is fail-closed: a failure that does not say it
|
|
1484
|
-
* is a read is judged a write, where a 5xx is `unknown` and never retried. Apps that carry an
|
|
1485
|
-
* error through their own wrapper copy this field next to `uniqueKey` (`FailureView.write`).
|
|
1486
|
-
*/
|
|
1487
|
-
readonly write: boolean;
|
|
1488
|
-
/**
|
|
1489
|
-
* On `SIGNING_FAILED`: the code the wallet put on the error its signer threw, when it set one: an
|
|
1490
|
-
* EIP-1193 / JSON-RPC number such as `4001` (the person declined) or `-32603`, or an ethers /
|
|
1491
|
-
* viem string such as `'ACTION_REJECTED'`. It is read from the `cause`'s own `code` and is
|
|
1492
|
-
* always a short primitive; `undefined` when the wallet sent none, and on every other code. It is
|
|
1493
|
-
* a typed field, not a param: it is data for an app's analytics or its own wallet-specific
|
|
1494
|
-
* wording, never part of `message`, and `params.reason` stays the stable thing to branch on.
|
|
1495
|
-
*/
|
|
1496
|
-
readonly walletCode: number | string | undefined;
|
|
1497
|
-
constructor(code: C, params: GSwapErrorParams<C>, context?: GSwapErrorContext);
|
|
1498
|
-
/**
|
|
1499
|
-
* The SDK error brand (`Symbol.for('@gala-chain/gswap-sdk/error')`), always `true`. The
|
|
1500
|
-
* dependency-free helpers (`isWalletUserRejection`, `isGSwapErrorLike`) recognise an SDK error
|
|
1501
|
-
* by it instead of `instanceof`, so they work across copies of the SDK and without importing
|
|
1502
|
-
* this class. It lives on the prototype: it is not an own property and is never copied or logged.
|
|
1503
|
-
*/
|
|
1504
|
-
get [GSWAP_ERROR_BRAND](): true;
|
|
938
|
+
export declare class GSwapSDKError<C extends GSwapErrorCode = GSwapErrorCode> extends GalaSDKError<C, GSwapErrorParams<C>> {
|
|
939
|
+
/** Core's catalog entries and the DEX entries: a `GSwapSDKError` can carry a code of either. */
|
|
940
|
+
static readonly catalog: Readonly<Record<GSwapErrorCode, import("@gala-chain/gala-core-sdk").GalaErrorCatalogEntry>>;
|
|
941
|
+
constructor(code: C, params: GSwapErrorParams<C>, context?: GalaErrorContext);
|
|
1505
942
|
/**
|
|
1506
943
|
* True when the failure means "that market, pool or position does not exist" rather than
|
|
1507
944
|
* "something went wrong": an HTTP 404, a pair with no pool at any fee tier
|
|
@@ -1530,7 +967,7 @@ export declare class GSwapSDKError<C extends GSwapErrorCode = GSwapErrorCode> ex
|
|
|
1530
967
|
*/
|
|
1531
968
|
static fromGatewayBounce(gatewayCode: string, serverMessage: string, status: number, body: unknown, url: string, retryAfterMs?: number, uniqueKey?: string): GSwapSDKError;
|
|
1532
969
|
/** Convert a GalaChain `Status: 0` response into a typed SDK error. */
|
|
1533
|
-
static fromChainError(errorKey: string, serverMessage: string, context?:
|
|
970
|
+
static fromChainError(errorKey: string, serverMessage: string, context?: GalaErrorContext): GSwapSDKError<'CHAIN_REJECTED'>;
|
|
1534
971
|
/**
|
|
1535
972
|
* Create the error used when a token is not registered by the current DEX contract. `source` is
|
|
1536
973
|
* the backend answer that said so (a quote); its status, body and url are kept.
|
|
@@ -1565,11 +1002,17 @@ export declare class GSwapSDKError<C extends GSwapErrorCode = GSwapErrorCode> ex
|
|
|
1565
1002
|
/** Convert an unexpected HTTP response into an SDK error. */
|
|
1566
1003
|
static fromErrorResponse(url: string, response: HTTPResponse): Promise<GSwapSDKError>;
|
|
1567
1004
|
}
|
|
1568
|
-
/** Any thrown value that is an SDK error, narrowed to the union of every code. */
|
|
1005
|
+
/** Any thrown value that is an SDK error of a gswap flow, narrowed to the union of every code. */
|
|
1569
1006
|
export type AnyGSwapError = { [C in GSwapErrorCode]: GSwapSDKError<C>; }[GSwapErrorCode];
|
|
1570
1007
|
/**
|
|
1571
|
-
* True when `value` is an SDK error and, when `code` is given, carries
|
|
1572
|
-
* code, `error.params` narrows to that code's params.
|
|
1008
|
+
* True when `value` is an SDK error a gswap flow can throw and, when `code` is given, carries
|
|
1009
|
+
* exactly that code. With a code, `error.params` narrows to that code's params.
|
|
1010
|
+
*
|
|
1011
|
+
* It recognises every `GalaSDKError` (`instanceof`), not only a `GSwapSDKError`: the signing,
|
|
1012
|
+
* transport and wallet failures of a gswap flow come from `@gala-chain/gala-core-sdk` (a signer,
|
|
1013
|
+
* the fetch requestor), carry a core code, and are core `GalaSDKError`s. For such an error the
|
|
1014
|
+
* fields are exactly a `GSwapSDKError`'s (`notFound` differs only for the DEX not-found codes,
|
|
1015
|
+
* which core never throws), so the narrowing holds for everything a gswap flow throws.
|
|
1573
1016
|
*
|
|
1574
1017
|
* @example
|
|
1575
1018
|
* ```ts
|
|
@@ -1593,8 +1036,9 @@ export declare function isGSwapError<C extends GSwapErrorCode>(value: unknown, c
|
|
|
1593
1036
|
* error is pre-send too, and repeating the same call fails the same way.
|
|
1594
1037
|
*
|
|
1595
1038
|
* It also answers for a plain-object view of an SDK error (`{ code, phase? }`, see
|
|
1596
|
-
* `FailureView`): the view's own `phase`, else the catalog's phase for its `code
|
|
1597
|
-
* `boolean`, not a type guard (a view is not a `GSwapSDKError`); use
|
|
1039
|
+
* `FailureView`): the view's own `phase`, else the catalog's phase for its `code` (a core code or
|
|
1040
|
+
* a DEX code). It is a plain `boolean`, not a type guard (a view is not a `GSwapSDKError`); use
|
|
1041
|
+
* `isGSwapError` to narrow.
|
|
1598
1042
|
*
|
|
1599
1043
|
* @example
|
|
1600
1044
|
* ```ts
|
|
@@ -1606,8 +1050,6 @@ export declare function isPreSendError(value: unknown): boolean;
|
|
|
1606
1050
|
export declare function getObjectProperty(value: unknown, property: string): Record<string, unknown> | undefined;
|
|
1607
1051
|
/** Read a string property from an unknown object. */
|
|
1608
1052
|
export declare function getStringProperty(value: unknown, property: string): string | undefined;
|
|
1609
|
-
/** Parse a response body, preserving non-JSON text for error reporting. */
|
|
1610
|
-
export declare function parseJson(text: string): unknown;
|
|
1611
1053
|
//#endregion
|
|
1612
1054
|
//#region src/classes/apply_results.d.ts
|
|
1613
1055
|
/**
|
|
@@ -1632,7 +1074,7 @@ export declare function parseJson(text: string): unknown;
|
|
|
1632
1074
|
* `blockNumber`, `status`, `body`, `url` and the last transport `cause`.
|
|
1633
1075
|
*/
|
|
1634
1076
|
export declare class AppliedTradeError<C extends GSwapErrorCode = GSwapErrorCode> extends GSwapSDKError<C> {
|
|
1635
|
-
constructor(code: C, params: GSwapErrorParams<C>, context?:
|
|
1077
|
+
constructor(code: C, params: GSwapErrorParams<C>, context?: GalaErrorContext);
|
|
1636
1078
|
}
|
|
1637
1079
|
/** The transport and backend a confirmation reads from. */
|
|
1638
1080
|
export interface ApplyResultsClient {
|
|
@@ -1717,235 +1159,6 @@ export declare class Assets {
|
|
|
1717
1159
|
getUserAssets(ownerAddress: string, page?: number, limit?: number): Promise<UserAssetsResult>;
|
|
1718
1160
|
}
|
|
1719
1161
|
//#endregion
|
|
1720
|
-
//#region src/classes/signers.d.ts
|
|
1721
|
-
/** The signing schemes supported by the Gala Wallet signer. */
|
|
1722
|
-
export type GalaWalletScheme = 'native' | 'personal-sign';
|
|
1723
|
-
/** The request surface used by an EIP-1193 browser wallet. */
|
|
1724
|
-
export interface BrowserWalletProvider {
|
|
1725
|
-
request(args: {
|
|
1726
|
-
method: string;
|
|
1727
|
-
params?: unknown[];
|
|
1728
|
-
}): Promise<unknown>;
|
|
1729
|
-
}
|
|
1730
|
-
/** A DTO together with the signature that belongs in the gateway request body. */
|
|
1731
|
-
export type SignedDto<T extends Record<string, unknown>> = T & {
|
|
1732
|
-
signature: string;
|
|
1733
|
-
};
|
|
1734
|
-
/**
|
|
1735
|
-
* A signer for complete GalaChain write bodies.
|
|
1736
|
-
*
|
|
1737
|
-
* Implementations return the DTO fields together with the signature that belongs in the
|
|
1738
|
-
* gateway request body. Signer identity is recovered from that signature; implementations do
|
|
1739
|
-
* not add signer hints, typed-data metadata, or a domain.
|
|
1740
|
-
*/
|
|
1741
|
-
export interface GalaChainSigner {
|
|
1742
|
-
/**
|
|
1743
|
-
* Signs a DTO for a named GalaChain contract method.
|
|
1744
|
-
*
|
|
1745
|
-
* @example
|
|
1746
|
-
* ```typescript
|
|
1747
|
-
* const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
|
|
1748
|
-
* ```
|
|
1749
|
-
*/
|
|
1750
|
-
signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* The `0x`-prefixed Ethereum address a Gala account is signed by, or `undefined` when the account
|
|
1754
|
-
* names no key (a `client|` alias or a bare GalaChain id is not derivable from a key). Accepts
|
|
1755
|
-
* `0x` plus 40 hex digits and `eth|` plus 40 hex digits, with or without `0x`; the caller's casing
|
|
1756
|
-
* is kept. For {@link LazyPrivateKeySignerOptions.expectedAddress}, which should only be set for
|
|
1757
|
-
* an account whose key can be checked.
|
|
1758
|
-
*
|
|
1759
|
-
* @example
|
|
1760
|
-
* ```ts
|
|
1761
|
-
* createLazyPrivateKeySigner(getKey, { expectedAddress: ethereumAddressOfAccount(account) });
|
|
1762
|
-
* ```
|
|
1763
|
-
*/
|
|
1764
|
-
export declare function ethereumAddressOfAccount(account: string): string | undefined;
|
|
1765
|
-
/**
|
|
1766
|
-
* A GalaChain native signer backed by a secp256k1 private key.
|
|
1767
|
-
*
|
|
1768
|
-
* Native signing produces the bare GalaChain signature format, without a personal-sign prefix
|
|
1769
|
-
* or EIP-712 metadata. The private-key identity is recovered by the chain.
|
|
1770
|
-
*/
|
|
1771
|
-
export declare class PrivateKeySigner implements GalaChainSigner {
|
|
1772
|
-
private readonly privateKey;
|
|
1773
|
-
/**
|
|
1774
|
-
* Creates a native signer from a hex or base64 secp256k1 private key.
|
|
1775
|
-
*
|
|
1776
|
-
* @example
|
|
1777
|
-
* ```typescript
|
|
1778
|
-
* const signer = new PrivateKeySigner('1'.padStart(64, '0'));
|
|
1779
|
-
* const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
|
|
1780
|
-
* ```
|
|
1781
|
-
*/
|
|
1782
|
-
constructor(privateKey: string);
|
|
1783
|
-
/**
|
|
1784
|
-
* Signs the DTO with GalaChain native signing.
|
|
1785
|
-
*
|
|
1786
|
-
* @example
|
|
1787
|
-
* ```typescript
|
|
1788
|
-
* const signed = await signer.signObject('RequestTrade', {
|
|
1789
|
-
* token0: 'GALA',
|
|
1790
|
-
* token1: 'GUSDC',
|
|
1791
|
-
* fee: 3000,
|
|
1792
|
-
* });
|
|
1793
|
-
* ```
|
|
1794
|
-
*/
|
|
1795
|
-
signObject<T extends Record<string, unknown>>(_methodName: string, dto: T): Promise<SignedDto<T>>;
|
|
1796
|
-
}
|
|
1797
|
-
/** Supplies a private key at sign time: a hex/base64 string, possibly fetched asynchronously. */
|
|
1798
|
-
export type PrivateKeyProvider = () => Promise<string> | string;
|
|
1799
|
-
/** Options for {@link createLazyPrivateKeySigner}. */
|
|
1800
|
-
export interface LazyPrivateKeySignerOptions {
|
|
1801
|
-
/**
|
|
1802
|
-
* When set, every signature first checks that the fetched key belongs to this account (`0x...`
|
|
1803
|
-
* or the Gala `eth|0x...` / `eth|<40 hex>` form, case-insensitive) and refuses to sign otherwise
|
|
1804
|
-
* (`SIGNER_ADDRESS_MISMATCH`). Use it when the key lives in a slot another surface can switch
|
|
1805
|
-
* between the moment a request was approved and the moment it is signed.
|
|
1806
|
-
*/
|
|
1807
|
-
expectedAddress?: string | undefined;
|
|
1808
|
-
}
|
|
1809
|
-
/**
|
|
1810
|
-
* Creates the native-signing equivalent of {@link PrivateKeySigner} for apps that must not hold a
|
|
1811
|
-
* key in a long-lived object (an extension that reads its session key at sign time).
|
|
1812
|
-
*
|
|
1813
|
-
* `getPrivateKey` is called once per `signObject` call, never cached, never shared between calls
|
|
1814
|
-
* (concurrent signatures each fetch their own key), and the normalized key bytes are zeroed
|
|
1815
|
-
* before `signObject` settles, also on failure. A rejection or exception from `getPrivateKey` (the
|
|
1816
|
-
* app's "wallet is locked", a storage read that failed) is a `KEY_PROVIDER_FAILED` error with the
|
|
1817
|
-
* original error as `cause`: nothing has been sent, so `classifyFailure` says `not_sent` and Retry
|
|
1818
|
-
* is safe, and the app needs no error class of its own to tell this apart. A provider that returns
|
|
1819
|
-
* no usable string (`''`, `undefined`) is `INVALID_PRIVATE_KEY` with `reason: 'no_key_provided'`,
|
|
1820
|
-
* classified the same way; any other key that is not a valid secp256k1 key string is an
|
|
1821
|
-
* `INVALID_PRIVATE_KEY` error. An SDK error the provider throws itself is passed through.
|
|
1822
|
-
* Signatures are byte-identical to `new PrivateKeySigner(key).signObject(...)`.
|
|
1823
|
-
*
|
|
1824
|
-
* A JavaScript string cannot be wiped; the provider owns the lifetime of the string it returns.
|
|
1825
|
-
*
|
|
1826
|
-
* @example
|
|
1827
|
-
* ```typescript
|
|
1828
|
-
* const signer = createLazyPrivateKeySigner(
|
|
1829
|
-
* () => SecurityHelper.getSessionSecret(SecurityHelper.SESSION_PRIVATE_KEY_KEY),
|
|
1830
|
-
* { expectedAddress: account.address },
|
|
1831
|
-
* );
|
|
1832
|
-
* const gswap = new GSwap({ signer });
|
|
1833
|
-
* ```
|
|
1834
|
-
*/
|
|
1835
|
-
export declare function createLazyPrivateKeySigner(getPrivateKey: PrivateKeyProvider, options?: LazyPrivateKeySignerOptions): GalaChainSigner;
|
|
1836
|
-
/**
|
|
1837
|
-
* A Gala Wallet signer using native GalaChain signing, with an opt-in personal-sign mode.
|
|
1838
|
-
*
|
|
1839
|
-
* The selected Ethereum account is passed to Gala Wallet. There is NO automatic fallback: a
|
|
1840
|
-
* wallet that rejects `native` surfaces its error to the caller, because the only alternative,
|
|
1841
|
-
* `personal-sign`, silently recovers a phantom signer on every released Gala Wallet.
|
|
1842
|
-
*
|
|
1843
|
-
* `scheme: 'personal-sign'` calls
|
|
1844
|
-
* `gala_signChainDto([serialize({ ...dto, prefix }), walletAddress, methodName])` and REQUIRES
|
|
1845
|
-
* a wallet build that contains wallet_extension commit 34ca4e4 (strips the embedded `prefix`
|
|
1846
|
-
* field and hashes `prefix` + the prefix-less canonical body, the chain's scheme). Wallets
|
|
1847
|
-
* released before that fix hash the string with the `prefix` field still inside it and the
|
|
1848
|
-
* signature recovers to an address nobody holds, so only opt in once the fixed wallet is
|
|
1849
|
-
* released. See SIGNING-PARITY.md.
|
|
1850
|
-
*/
|
|
1851
|
-
export declare class GalaWalletSigner implements GalaChainSigner {
|
|
1852
|
-
/** The wallet address supplied to Gala Wallet for each signing request. */
|
|
1853
|
-
readonly walletAddress: string;
|
|
1854
|
-
/** The signing scheme used for every request; it never changes after construction. */
|
|
1855
|
-
readonly scheme: GalaWalletScheme;
|
|
1856
|
-
/**
|
|
1857
|
-
* Creates a Gala Wallet signer.
|
|
1858
|
-
*
|
|
1859
|
-
* @example
|
|
1860
|
-
* ```typescript
|
|
1861
|
-
* const signer = new GalaWalletSigner('0x0123456789012345678901234567890123456789');
|
|
1862
|
-
* const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
|
|
1863
|
-
* ```
|
|
1864
|
-
*
|
|
1865
|
-
* @param walletAddress - The account passed to Gala Wallet as the signer address. An Ethereum
|
|
1866
|
-
* account is `0x` plus 40 hex digits (Gala Wallet's `eth|...` form is normalized to it and held
|
|
1867
|
-
* to the same check); a GalaChain id is `client|` plus 24 hex digits, or the bare 24 hex digits
|
|
1868
|
-
* frontend_v2 keeps for a direct `client|` login, and is passed through unchanged.
|
|
1869
|
-
* @param options - Select native signing (default) or personal-sign explicitly.
|
|
1870
|
-
* `'personal-sign'` requires a Gala Wallet build with wallet_extension commit 34ca4e4.
|
|
1871
|
-
* `selectAddress` is the identity (`client|...` / `eth|...`) Gala Wallet is switched to with
|
|
1872
|
-
* `window.gala.setAddress` before every signature, when the wallet offers it.
|
|
1873
|
-
*/
|
|
1874
|
-
constructor(walletAddress: string, options?: {
|
|
1875
|
-
scheme?: GalaWalletScheme | undefined;
|
|
1876
|
-
selectAddress?: string | undefined;
|
|
1877
|
-
});
|
|
1878
|
-
/** The identity Gala Wallet is switched to before each signature, if one was given. */
|
|
1879
|
-
readonly selectAddress: string | undefined;
|
|
1880
|
-
/**
|
|
1881
|
-
* Signs a DTO through `gala_signChainDto`.
|
|
1882
|
-
*
|
|
1883
|
-
* @example
|
|
1884
|
-
* ```typescript
|
|
1885
|
-
* const signed = await signer.signObject('AddLiquidity', {
|
|
1886
|
-
* token0: 'GALA',
|
|
1887
|
-
* token1: 'GUSDC',
|
|
1888
|
-
* tickLower: -60,
|
|
1889
|
-
* tickUpper: 60,
|
|
1890
|
-
* });
|
|
1891
|
-
* ```
|
|
1892
|
-
*/
|
|
1893
|
-
signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
|
|
1894
|
-
}
|
|
1895
|
-
/**
|
|
1896
|
-
* A personal-sign signer for MetaMask and other EIP-1193 browser wallets.
|
|
1897
|
-
*
|
|
1898
|
-
* The chain recovers this signature using the EIP-191 wrap applied by the wallet to
|
|
1899
|
-
* `personal_sign`. This is the browser-wallet path used by the v2 frontend and resolves the
|
|
1900
|
-
* bare `eth|` identity.
|
|
1901
|
-
*/
|
|
1902
|
-
export declare class BrowserWalletSigner implements GalaChainSigner {
|
|
1903
|
-
private readonly provider;
|
|
1904
|
-
/**
|
|
1905
|
-
* Creates a browser-wallet signer.
|
|
1906
|
-
*
|
|
1907
|
-
* Defaults to `personal_sign` — unchanged from every existing integration, since it only ever
|
|
1908
|
-
* resolves the bare `eth|` identity and changing that silently would be a real behavior
|
|
1909
|
-
* break for anyone already depending on it. Pass `{ scheme: 'eip712' }` to correctly resolve
|
|
1910
|
-
* a registered `client|` alias instead, for `RequestTrade`/`AddLiquidity`/`RemoveLiquidity`/
|
|
1911
|
-
* `CollectPositionFees` (`EIP712_CAPABLE_METHODS`) — `CreatePool` and any other method still
|
|
1912
|
-
* falls back to `personal_sign` even in `'eip712'` mode, since its EIP-712 signing is a
|
|
1913
|
-
* separate, unsolved chain-side problem.
|
|
1914
|
-
*
|
|
1915
|
-
* @example
|
|
1916
|
-
* ```typescript
|
|
1917
|
-
* const signer = new BrowserWalletSigner(window.ethereum, '0x0123456789012345678901234567890123456789');
|
|
1918
|
-
* const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
|
|
1919
|
-
* ```
|
|
1920
|
-
* @example
|
|
1921
|
-
* ```typescript
|
|
1922
|
-
* // Correctly resolves a registered client| alias instead of the bare eth| address.
|
|
1923
|
-
* const signer = new BrowserWalletSigner(window.ethereum, walletAddress, { scheme: 'eip712' });
|
|
1924
|
-
* ```
|
|
1925
|
-
*/
|
|
1926
|
-
constructor(provider: BrowserWalletProvider, walletAddress: string, options?: {
|
|
1927
|
-
scheme?: 'personal-sign' | 'eip712';
|
|
1928
|
-
});
|
|
1929
|
-
/** The selected `0x` Ethereum account every signature is requested for. */
|
|
1930
|
-
readonly walletAddress: string;
|
|
1931
|
-
private readonly scheme;
|
|
1932
|
-
/**
|
|
1933
|
-
* Signs the DTO with `eth_signTypedData_v4` (when constructed with `{ scheme: 'eip712' }` and
|
|
1934
|
-
* `methodName` is in `EIP712_CAPABLE_METHODS`) or the EIP-1193 `personal_sign` method
|
|
1935
|
-
* (otherwise — the default).
|
|
1936
|
-
*
|
|
1937
|
-
* @example
|
|
1938
|
-
* ```typescript
|
|
1939
|
-
* const signed = await signer.signObject('RequestTrade', {
|
|
1940
|
-
* token0: 'GALA',
|
|
1941
|
-
* token1: 'GUSDC',
|
|
1942
|
-
* fee: 3000,
|
|
1943
|
-
* });
|
|
1944
|
-
* ```
|
|
1945
|
-
*/
|
|
1946
|
-
signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
|
|
1947
|
-
}
|
|
1948
|
-
//#endregion
|
|
1949
1162
|
//#region src/classes/dex_fees.d.ts
|
|
1950
1163
|
/** DEX methods the backend accepts a fee quote for (its allow-list enumerates the same six). */
|
|
1951
1164
|
export declare const DEX_FEE_METHODS: readonly ['Swap', 'RequestTrade', 'AddLiquidity', 'RemoveLiquidity', 'CollectPositionFees', 'CreatePool'];
|
|
@@ -2269,6 +1482,12 @@ export declare class SubmittedTransaction<TConfirmation = AppliedTrade | Positio
|
|
|
2269
1482
|
* For RequestTrade, calling this method is required to learn the outcome: the queued
|
|
2270
1483
|
* acknowledgement proves acceptance, not execution.
|
|
2271
1484
|
*
|
|
1485
|
+
* Every failure is the write's (it carries `uniqueKey`, so `mayHaveBeenQueued` is true): a
|
|
1486
|
+
* re-read that cannot succeed is `CONFIRMATION_FAILED` (a terminal HTTP status) or
|
|
1487
|
+
* `CONFIRMATION_MALFORMED` (an unusable answer); one that may (no answer, a 5xx, 404, 408,
|
|
1488
|
+
* 429) is read again until the deadline, then `CONFIRMATION_TIMEOUT` with the last read error
|
|
1489
|
+
* as `cause`. Confirm the same transaction again; never resubmit the write.
|
|
1490
|
+
*
|
|
2272
1491
|
* @example
|
|
2273
1492
|
* ```ts
|
|
2274
1493
|
* const applied = await submitted.confirm({ initialDelayMs: 3_000 });
|
|
@@ -2666,31 +1885,111 @@ export declare class GdexStreamService {
|
|
|
2666
1885
|
private isRecord;
|
|
2667
1886
|
}
|
|
2668
1887
|
//#endregion
|
|
2669
|
-
//#region src/types/
|
|
1888
|
+
//#region src/types/market.d.ts
|
|
1889
|
+
/**
|
|
1890
|
+
* The swap backend's market data and trading-competition reads: what `GSwap.market` and
|
|
1891
|
+
* `GSwap.leaderboard` return. Values are the backend's, unconverted: USD prices as numbers, times
|
|
1892
|
+
* as unix seconds or `Date`s, XP as decimal strings.
|
|
1893
|
+
*/
|
|
1894
|
+
/** The windows `GET /market/price-series` serves (the backend refuses any other with a 400). */
|
|
1895
|
+
export declare const PRICE_SERIES_TIMEFRAMES: readonly ['1D', '1W', '1M', '1Y', 'ALL'];
|
|
1896
|
+
/** One member of {@link PRICE_SERIES_TIMEFRAMES}. */
|
|
1897
|
+
export type PriceSeriesTimeframe = (typeof PRICE_SERIES_TIMEFRAMES)[number];
|
|
1898
|
+
/** The most tokens one `GET /market/price` request may name (the backend's limit). */
|
|
1899
|
+
export declare const MARKET_PRICE_BATCH_LIMIT = 500;
|
|
1900
|
+
/** One token's market price, as `GET /market/price` answered it. */
|
|
1901
|
+
export interface MarketPrice {
|
|
1902
|
+
/** The id the price was asked for: the token string as given, or an object key's `$` form. */
|
|
1903
|
+
token: string;
|
|
1904
|
+
/** USD price; `null` when the backend knows the token but has no price for it. */
|
|
1905
|
+
price: number | null;
|
|
1906
|
+
/** 24-hour change in percent (`-2.1` is -2.1 %); `null` when unknown. */
|
|
1907
|
+
change24h: number | null;
|
|
1908
|
+
/** Whether the token is on the backend's CoinGecko list (what the swap app's "trending" uses). */
|
|
1909
|
+
listed: boolean;
|
|
1910
|
+
}
|
|
1911
|
+
/** One point of a price series. */
|
|
1912
|
+
export interface PriceSeriesPoint {
|
|
1913
|
+
/** Unix time in seconds. */
|
|
1914
|
+
time: number;
|
|
1915
|
+
/** USD price at `time`. */
|
|
1916
|
+
price: number;
|
|
1917
|
+
}
|
|
1918
|
+
/** A token's USD price line, as `GET /market/price-series` answered it. */
|
|
1919
|
+
export interface PriceSeries {
|
|
1920
|
+
/** The id the series was asked for: the token string as given, or an object key's `$` form. */
|
|
1921
|
+
token: string;
|
|
1922
|
+
timeframe: PriceSeriesTimeframe;
|
|
1923
|
+
/** In the backend's order (oldest first). Empty for a token the backend has no prices for. */
|
|
1924
|
+
prices: PriceSeriesPoint[];
|
|
1925
|
+
/** USD price now; `null` when unknown. */
|
|
1926
|
+
currentPrice: number | null;
|
|
1927
|
+
/** 24-hour change in percent; `null` when unknown. */
|
|
1928
|
+
change24h: number | null;
|
|
1929
|
+
}
|
|
2670
1930
|
/**
|
|
2671
|
-
*
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
/**
|
|
2681
|
-
|
|
1931
|
+
* Totals across every current-contract pool, as `GET /v2/trade/volume` answered them. USD amounts;
|
|
1932
|
+
* a delta is a fraction (`-0.11` is 11 % less than the previous period, `0` when that period had
|
|
1933
|
+
* no volume), not a percentage.
|
|
1934
|
+
*/
|
|
1935
|
+
export interface VolumeSummary {
|
|
1936
|
+
tvl: number;
|
|
1937
|
+
volume1d: number;
|
|
1938
|
+
volume7d: number;
|
|
1939
|
+
volume30d: number;
|
|
1940
|
+
/** Number of trades in the last 24 hours. */
|
|
1941
|
+
trades1d: number;
|
|
1942
|
+
volume1dDelta: number;
|
|
1943
|
+
volume7dDelta: number;
|
|
1944
|
+
volume30dDelta: number;
|
|
1945
|
+
}
|
|
1946
|
+
/** A trading-competition season, as `GET /leaderboard/seasons` answered it. */
|
|
1947
|
+
export interface LeaderboardSeason {
|
|
1948
|
+
id: number;
|
|
1949
|
+
name: string;
|
|
1950
|
+
/** First instant of the season. */
|
|
1951
|
+
start: Date;
|
|
1952
|
+
/** Last instant of the season (inclusive). */
|
|
1953
|
+
end: Date;
|
|
1954
|
+
/** The scoring rules the season uses. */
|
|
1955
|
+
rulesId: number;
|
|
1956
|
+
}
|
|
1957
|
+
/** An achievement shown on a leaderboard entry. */
|
|
1958
|
+
export interface MasteryTitle {
|
|
1959
|
+
name: string;
|
|
1960
|
+
/** For example `trade` or `liquidity`; the backend's own word, passed on as it is. */
|
|
1961
|
+
type: string;
|
|
1962
|
+
/** Display order. */
|
|
1963
|
+
order: number;
|
|
1964
|
+
}
|
|
1965
|
+
/** One wallet's row on a season's leaderboard. */
|
|
1966
|
+
export interface LeaderboardEntry {
|
|
1967
|
+
wallet: string;
|
|
1968
|
+
/** 1 for the top wallet. */
|
|
1969
|
+
rank: number;
|
|
1970
|
+
/** Decimal string; `null` when the backend has no XP breakdown for the wallet yet. */
|
|
1971
|
+
totalXp: string | null;
|
|
1972
|
+
/** The wallet's share of the season's XP, in percent, as a decimal string (`'12.34'`). */
|
|
1973
|
+
distributionPercent: string;
|
|
1974
|
+
liquidityXp: string;
|
|
1975
|
+
tradingXp: string;
|
|
1976
|
+
masteryTitles: MasteryTitle[];
|
|
1977
|
+
}
|
|
1978
|
+
/** A season's leaderboard (the backend returns at most its top 100 wallets). */
|
|
1979
|
+
export interface SeasonLeaderboard {
|
|
1980
|
+
seasonId: number;
|
|
1981
|
+
entries: LeaderboardEntry[];
|
|
2682
1982
|
}
|
|
2683
|
-
/** Tick spacing required by the current GalaChainDex contract for each fee tier. */
|
|
2684
|
-
export declare const TICK_SPACING_BY_FEE: Readonly<Record<FEE_TIER, number>>;
|
|
2685
|
-
/** All fee tiers supported by the current GalaChainDex contract. */
|
|
2686
|
-
export declare const ALL_FEE_TIERS: readonly FEE_TIER[];
|
|
2687
1983
|
//#endregion
|
|
2688
1984
|
//#region src/utils/lenient.d.ts
|
|
2689
1985
|
/** One row of a list answer that the SDK skipped because it was not usable. */
|
|
2690
1986
|
interface InvalidEntry {
|
|
2691
1987
|
/** Which read the row came from. */
|
|
2692
|
-
source: 'pools' | 'symbols' | 'positions';
|
|
2693
|
-
/**
|
|
1988
|
+
source: 'pools' | 'symbols' | 'positions' | 'prices' | 'priceSeries' | 'seasons' | 'leaderboard';
|
|
1989
|
+
/**
|
|
1990
|
+
* Position of the row in the answer's array; for `prices` (an answer keyed by token), the
|
|
1991
|
+
* position of the token in the list asked for.
|
|
1992
|
+
*/
|
|
2694
1993
|
index: number;
|
|
2695
1994
|
/** The row exactly as the backend sent it. */
|
|
2696
1995
|
entry: unknown;
|
|
@@ -2711,6 +2010,86 @@ type EntryParse<T> = {
|
|
|
2711
2010
|
reason: string;
|
|
2712
2011
|
};
|
|
2713
2012
|
//#endregion
|
|
2013
|
+
//#region src/classes/leaderboard.d.ts
|
|
2014
|
+
/** Options of every leaderboard read. */
|
|
2015
|
+
export interface LeaderboardReadOptions {
|
|
2016
|
+
signal?: AbortSignal | undefined;
|
|
2017
|
+
/** Overrides the service-level handler for this call. */
|
|
2018
|
+
onInvalidEntry?: InvalidEntryHandler | undefined;
|
|
2019
|
+
}
|
|
2020
|
+
/** Options of the reads that pick the season running now. */
|
|
2021
|
+
export interface CurrentSeasonOptions extends LeaderboardReadOptions {
|
|
2022
|
+
/** The instant "now" is (default: the current time). */
|
|
2023
|
+
now?: Date | undefined;
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* The swap backend's trading-competition reads: seasons (`GET /leaderboard/seasons`) and a
|
|
2027
|
+
* season's rankings (`GET /leaderboard?seasonId=`). Public reads: no signer, no wallet. A row that
|
|
2028
|
+
* is not usable is skipped and reported to `onInvalidEntry`; an answer that is not the expected
|
|
2029
|
+
* list is `INVALID_CHAIN_RESPONSE`.
|
|
2030
|
+
*/
|
|
2031
|
+
export declare class Leaderboard {
|
|
2032
|
+
private readonly dexBackendBaseUrl;
|
|
2033
|
+
private readonly httpClient;
|
|
2034
|
+
private readonly options;
|
|
2035
|
+
/**
|
|
2036
|
+
* Creates a leaderboard service. `options.onInvalidEntry` is told about every season or entry
|
|
2037
|
+
* row that was skipped as unusable.
|
|
2038
|
+
*
|
|
2039
|
+
* @example
|
|
2040
|
+
* ```ts
|
|
2041
|
+
* const leaderboard = new Leaderboard('https://dex-backend-prod1.defi.gala.com', httpClient);
|
|
2042
|
+
* ```
|
|
2043
|
+
*/
|
|
2044
|
+
constructor(dexBackendBaseUrl: string, httpClient: HttpClient, options?: {
|
|
2045
|
+
onInvalidEntry?: InvalidEntryHandler | undefined;
|
|
2046
|
+
});
|
|
2047
|
+
/**
|
|
2048
|
+
* Every active season, in the backend's order (newest first).
|
|
2049
|
+
*
|
|
2050
|
+
* @example
|
|
2051
|
+
* ```ts
|
|
2052
|
+
* const seasons = await gSwap.leaderboard.getSeasons();
|
|
2053
|
+
* console.log(seasons.map((season) => season.name));
|
|
2054
|
+
* ```
|
|
2055
|
+
*/
|
|
2056
|
+
getSeasons(options?: LeaderboardReadOptions): Promise<LeaderboardSeason[]>;
|
|
2057
|
+
/**
|
|
2058
|
+
* The season running at `options.now` (default: now; `start` and `end` both count as inside),
|
|
2059
|
+
* or `null` between seasons. When seasons overlap, the first in the backend's order.
|
|
2060
|
+
*
|
|
2061
|
+
* @example
|
|
2062
|
+
* ```ts
|
|
2063
|
+
* const season = await gSwap.leaderboard.getCurrentSeason();
|
|
2064
|
+
* console.log(season === null ? 'no season running' : season.name);
|
|
2065
|
+
* ```
|
|
2066
|
+
*/
|
|
2067
|
+
getCurrentSeason(options?: CurrentSeasonOptions): Promise<LeaderboardSeason | null>;
|
|
2068
|
+
/**
|
|
2069
|
+
* A season's rankings (the backend's top 100 wallets). `seasonId` must be an integer of at
|
|
2070
|
+
* least 1 (`INVALID_SEASON_ID` before anything is sent); a season with no rankings, or none at
|
|
2071
|
+
* all, is an empty list.
|
|
2072
|
+
*
|
|
2073
|
+
* @example
|
|
2074
|
+
* ```ts
|
|
2075
|
+
* const { entries } = await gSwap.leaderboard.getLeaderboard(1);
|
|
2076
|
+
* console.log(entries[0]?.wallet, entries[0]?.totalXp);
|
|
2077
|
+
* ```
|
|
2078
|
+
*/
|
|
2079
|
+
getLeaderboard(seasonId: number, options?: LeaderboardReadOptions): Promise<SeasonLeaderboard>;
|
|
2080
|
+
/**
|
|
2081
|
+
* The rankings of the season running at `options.now` (see
|
|
2082
|
+
* {@link Leaderboard.getCurrentSeason}), or `null` between seasons.
|
|
2083
|
+
*
|
|
2084
|
+
* @example
|
|
2085
|
+
* ```ts
|
|
2086
|
+
* const current = await gSwap.leaderboard.getCurrentLeaderboard();
|
|
2087
|
+
* if (current !== null) console.log(current.seasonId, current.entries.length);
|
|
2088
|
+
* ```
|
|
2089
|
+
*/
|
|
2090
|
+
getCurrentLeaderboard(options?: CurrentSeasonOptions): Promise<SeasonLeaderboard | null>;
|
|
2091
|
+
}
|
|
2092
|
+
//#endregion
|
|
2714
2093
|
//#region src/utils/ordering.d.ts
|
|
2715
2094
|
/** A symbol or a GalaChain token class key accepted by v2 operations. */
|
|
2716
2095
|
export type TokenRef = string | GalaChainTokenClassKey;
|
|
@@ -2724,25 +2103,144 @@ export declare function orderSymbols(a: string, b: string): [string, string];
|
|
|
2724
2103
|
* console.log(pair.token0);
|
|
2725
2104
|
* ```
|
|
2726
2105
|
*/
|
|
2727
|
-
export declare function readOrderedSymbols(value: unknown): {
|
|
2728
|
-
token0: string;
|
|
2729
|
-
token1: string;
|
|
2730
|
-
};
|
|
2106
|
+
export declare function readOrderedSymbols(value: unknown): {
|
|
2107
|
+
token0: string;
|
|
2108
|
+
token1: string;
|
|
2109
|
+
};
|
|
2110
|
+
/**
|
|
2111
|
+
* Parse a pipe- or dollar-separated token class key.
|
|
2112
|
+
*
|
|
2113
|
+
* The LAST three segments are always `category`, `type` and `additionalKey`; everything before
|
|
2114
|
+
* them is the `collection`. Parsing from the right is required because real collections contain
|
|
2115
|
+
* the `$` delimiter themselves (for example `$GMUSIC`), so a plain left-to-right `split('$')`
|
|
2116
|
+
* shifts every field. Nothing here says anything about the token's symbol: a class key carries
|
|
2117
|
+
* no symbol, which must come from the token class or trading-symbol registry.
|
|
2118
|
+
*
|
|
2119
|
+
* @example
|
|
2120
|
+
* ```ts
|
|
2121
|
+
* parseTokenClassKey('$GMUSIC$Unit$none$none').collection; // '$GMUSIC'
|
|
2122
|
+
* ```
|
|
2123
|
+
*/
|
|
2124
|
+
export declare function parseTokenClassKey(tokenClassKey: TokenRef): GalaChainTokenClassKey;
|
|
2125
|
+
//#endregion
|
|
2126
|
+
//#region src/classes/market.d.ts
|
|
2127
|
+
/** Options of every market read. */
|
|
2128
|
+
export interface MarketReadOptions {
|
|
2129
|
+
signal?: AbortSignal | undefined;
|
|
2130
|
+
}
|
|
2131
|
+
/** Options of {@link Market.getPrices} and {@link Market.getPriceSeries}. */
|
|
2132
|
+
export interface MarketListOptions extends MarketReadOptions {
|
|
2133
|
+
/** Overrides the service-level handler for this call. */
|
|
2134
|
+
onInvalidEntry?: InvalidEntryHandler | undefined;
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Market data from the swap backend: USD prices (`GET /market/price`), price series
|
|
2138
|
+
* (`GET /market/price-series`) and the platform volume totals (`GET /v2/trade/volume`). Public
|
|
2139
|
+
* reads: no signer, no wallet.
|
|
2140
|
+
*
|
|
2141
|
+
* A token is named by a symbol (`GALA`) or a class key (`GALA$Unit$none$none`,
|
|
2142
|
+
* `GALA|Unit|none|none` or the object). The backend answers each token under the exact id it was
|
|
2143
|
+
* asked for, so the answer is read back under that id: a token the backend has no entry for is
|
|
2144
|
+
* `undefined`, never another token's price.
|
|
2145
|
+
*/
|
|
2146
|
+
export declare class Market {
|
|
2147
|
+
private readonly dexBackendBaseUrl;
|
|
2148
|
+
private readonly httpClient;
|
|
2149
|
+
private readonly options;
|
|
2150
|
+
/**
|
|
2151
|
+
* Creates a market service. `options.onInvalidEntry` is told about every price or price point
|
|
2152
|
+
* that was skipped as unusable.
|
|
2153
|
+
*
|
|
2154
|
+
* @example
|
|
2155
|
+
* ```ts
|
|
2156
|
+
* const market = new Market('https://dex-backend-prod1.defi.gala.com', httpClient);
|
|
2157
|
+
* ```
|
|
2158
|
+
*/
|
|
2159
|
+
constructor(dexBackendBaseUrl: string, httpClient: HttpClient, options?: {
|
|
2160
|
+
onInvalidEntry?: InvalidEntryHandler | undefined;
|
|
2161
|
+
});
|
|
2162
|
+
/**
|
|
2163
|
+
* USD prices of 1 to 500 tokens, in the order asked (a token named twice is asked for once).
|
|
2164
|
+
* The ids go in as many requests as their length needs (see {@link MARKET_PRICE_QUERY_BYTES}),
|
|
2165
|
+
* one after another; any request failing fails the call. A token the backend did not answer
|
|
2166
|
+
* for is `undefined`; one it answered for unusably is `undefined` too, and reported to
|
|
2167
|
+
* `onInvalidEntry`. An answer that is not an object is `INVALID_CHAIN_RESPONSE`.
|
|
2168
|
+
*
|
|
2169
|
+
* @example
|
|
2170
|
+
* ```ts
|
|
2171
|
+
* const [gala, gusdc] = await gSwap.market.getPrices(['GALA$Unit$none$none', 'GUSDC$Unit$none$none']);
|
|
2172
|
+
* console.log(gala?.price, gusdc?.price);
|
|
2173
|
+
* ```
|
|
2174
|
+
*/
|
|
2175
|
+
getPrices(tokens: readonly TokenRef[], options?: MarketListOptions): Promise<Array<MarketPrice | undefined>>;
|
|
2176
|
+
/**
|
|
2177
|
+
* The USD price of one token, or `undefined` when the backend has no entry for it (see
|
|
2178
|
+
* {@link Market.getPrices}).
|
|
2179
|
+
*
|
|
2180
|
+
* @example
|
|
2181
|
+
* ```ts
|
|
2182
|
+
* const gala = await gSwap.market.getPrice('GALA$Unit$none$none');
|
|
2183
|
+
* if (gala?.price != null) console.log(`GALA: $${gala.price}`);
|
|
2184
|
+
* ```
|
|
2185
|
+
*/
|
|
2186
|
+
getPrice(token: TokenRef, options?: MarketListOptions): Promise<MarketPrice | undefined>;
|
|
2187
|
+
/**
|
|
2188
|
+
* A token's USD price line for one window (1D, 1W, 1M, 1Y or ALL; any other is
|
|
2189
|
+
* `INVALID_TIMEFRAME` before anything is sent). The whole series in one answer, oldest first; a
|
|
2190
|
+
* token the backend has no prices for is an empty series. An unusable point is skipped and
|
|
2191
|
+
* reported to `onInvalidEntry`; an answer that is not a series is `INVALID_CHAIN_RESPONSE`.
|
|
2192
|
+
*
|
|
2193
|
+
* @example
|
|
2194
|
+
* ```ts
|
|
2195
|
+
* const series = await gSwap.market.getPriceSeries('GALA$Unit$none$none', '1W');
|
|
2196
|
+
* console.log(series.prices.length, series.currentPrice);
|
|
2197
|
+
* ```
|
|
2198
|
+
*/
|
|
2199
|
+
getPriceSeries(token: TokenRef, timeframe: PriceSeriesTimeframe, options?: MarketListOptions): Promise<PriceSeries>;
|
|
2200
|
+
/**
|
|
2201
|
+
* TVL, volume and trade totals across every current-contract pool. Every field must be a finite
|
|
2202
|
+
* number, or the answer is `INVALID_CHAIN_RESPONSE`.
|
|
2203
|
+
*
|
|
2204
|
+
* @example
|
|
2205
|
+
* ```ts
|
|
2206
|
+
* const volume = await gSwap.market.getVolumeSummary();
|
|
2207
|
+
* console.log(`24h: $${volume.volume1d.toFixed(0)} (${(volume.volume1dDelta * 100).toFixed(1)} %)`);
|
|
2208
|
+
* ```
|
|
2209
|
+
*/
|
|
2210
|
+
getVolumeSummary(options?: MarketReadOptions): Promise<VolumeSummary>;
|
|
2211
|
+
}
|
|
2212
|
+
/**
|
|
2213
|
+
* The most query bytes one `GET /market/price` carries. The backend refuses a request line over
|
|
2214
|
+
* 16 KB (Node's default header limit: 300 launchpad keys, 17.7 KB encoded, answer HTTP 431,
|
|
2215
|
+
* recorded on prod 2026-10-13), so a long list is split well under it (about 135 launchpad keys
|
|
2216
|
+
* per request, 270 short ones).
|
|
2217
|
+
*/
|
|
2218
|
+
export declare const MARKET_PRICE_QUERY_BYTES = 8000;
|
|
2731
2219
|
/**
|
|
2732
|
-
*
|
|
2733
|
-
*
|
|
2734
|
-
*
|
|
2735
|
-
* them is the `collection`. Parsing from the right is required because real collections contain
|
|
2736
|
-
* the `$` delimiter themselves (for example `$GMUSIC`), so a plain left-to-right `split('$')`
|
|
2737
|
-
* shifts every field. Nothing here says anything about the token's symbol: a class key carries
|
|
2738
|
-
* no symbol, which must come from the token class or trading-symbol registry.
|
|
2739
|
-
*
|
|
2740
|
-
* @example
|
|
2741
|
-
* ```ts
|
|
2742
|
-
* parseTokenClassKey('$GMUSIC$Unit$none$none').collection; // '$GMUSIC'
|
|
2743
|
-
* ```
|
|
2220
|
+
* The ids in request-sized batches: at most {@link MARKET_PRICE_BATCH_LIMIT} ids and
|
|
2221
|
+
* {@link MARKET_PRICE_QUERY_BYTES} of encoded `assetIds` each (the standard encoding's size, the
|
|
2222
|
+
* larger of the two, with a `%2C` per id).
|
|
2744
2223
|
*/
|
|
2745
|
-
export declare function
|
|
2224
|
+
export declare function priceBatches(ids: readonly string[]): string[][];
|
|
2225
|
+
//#endregion
|
|
2226
|
+
//#region src/types/fees.d.ts
|
|
2227
|
+
/**
|
|
2228
|
+
* Fee tiers for pools.
|
|
2229
|
+
*/
|
|
2230
|
+
export declare enum FEE_TIER {
|
|
2231
|
+
/** No trading fee. */
|
|
2232
|
+
PERCENT_00_00 = 0,
|
|
2233
|
+
/** 0.05% fee tier */
|
|
2234
|
+
PERCENT_00_05 = 500,
|
|
2235
|
+
/** 0.3% fee tier */
|
|
2236
|
+
PERCENT_00_30 = 3000,
|
|
2237
|
+
/** 1.0% fee tier */
|
|
2238
|
+
PERCENT_01_00 = 10000
|
|
2239
|
+
}
|
|
2240
|
+
/** Tick spacing required by the current GalaChainDex contract for each fee tier. */
|
|
2241
|
+
export declare const TICK_SPACING_BY_FEE: Readonly<Record<FEE_TIER, number>>;
|
|
2242
|
+
/** All fee tiers supported by the current GalaChainDex contract. */
|
|
2243
|
+
export declare const ALL_FEE_TIERS: readonly FEE_TIER[];
|
|
2746
2244
|
//#endregion
|
|
2747
2245
|
//#region src/classes/symbols.d.ts
|
|
2748
2246
|
/** Symbol registry client for the current GalaChainDex contract. */
|
|
@@ -2819,8 +2317,6 @@ export declare class Symbols {
|
|
|
2819
2317
|
flipped: boolean;
|
|
2820
2318
|
}>;
|
|
2821
2319
|
}
|
|
2822
|
-
/** Alias exported for callers that use the contract's shorter type name. */
|
|
2823
|
-
export type TokenClassKey = GalaChainTokenClassKey;
|
|
2824
2320
|
/**
|
|
2825
2321
|
* What the services need from a token resolver: how a token reference becomes a trading symbol,
|
|
2826
2322
|
* and whether requests carry the caller's references untouched. {@link Symbols} is the registry
|
|
@@ -2893,6 +2389,17 @@ export interface PoolListOptions {
|
|
|
2893
2389
|
/** Overrides the service-level handler for this call. */
|
|
2894
2390
|
onInvalidEntry?: InvalidEntryHandler | undefined;
|
|
2895
2391
|
}
|
|
2392
|
+
/** Options of {@link Pools.watchNewPools}. */
|
|
2393
|
+
export interface WatchNewPoolsOptions {
|
|
2394
|
+
/** Milliseconds between polls (default 30 000; a finite number of at least 1). */
|
|
2395
|
+
intervalMs?: number | undefined;
|
|
2396
|
+
/** Report only a pool whose `tvlUsd` is at least this (a pool without `tvlUsd` counts as 0). */
|
|
2397
|
+
minTvl?: number | undefined;
|
|
2398
|
+
/** Report only a pool with one of these symbols as `token0` or `token1`. */
|
|
2399
|
+
tokens?: readonly string[] | undefined;
|
|
2400
|
+
/** Told about a poll that failed and about an `onPool` that threw; polling goes on either way. */
|
|
2401
|
+
onError?: ((error: unknown) => void) | undefined;
|
|
2402
|
+
}
|
|
2896
2403
|
/** Read-only pool and current-price access for the current GalaChainDex contract. */
|
|
2897
2404
|
export declare class Pools {
|
|
2898
2405
|
private readonly gateway;
|
|
@@ -2924,6 +2431,25 @@ export declare class Pools {
|
|
|
2924
2431
|
* ```
|
|
2925
2432
|
*/
|
|
2926
2433
|
getPools(options?: PoolListOptions): Promise<PoolListInfo[]>;
|
|
2434
|
+
/**
|
|
2435
|
+
* Watches for pools created from now on, by polling {@link Pools.getPools} every `intervalMs`
|
|
2436
|
+
* (the polling alternative to the realtime stream's `GSwap.stream.subscribePoolCreated`, for a
|
|
2437
|
+
* client that cannot hold a WebSocket open). The first answer is the baseline: a pool that
|
|
2438
|
+
* existed then is never reported. Each later pool is judged once, when it first appears, against
|
|
2439
|
+
* `minTvl` and `tokens`. A poll never overlaps the previous one (a tick that finds one still in
|
|
2440
|
+
* flight is skipped), and nothing is reported after the returned function stops the watcher.
|
|
2441
|
+
*
|
|
2442
|
+
* @example
|
|
2443
|
+
* ```ts
|
|
2444
|
+
* const stop = gSwap.pools.watchNewPools((pool) => console.log('new pool', pool.poolRef), {
|
|
2445
|
+
* intervalMs: 60_000,
|
|
2446
|
+
* tokens: ['GALA'],
|
|
2447
|
+
* });
|
|
2448
|
+
* // later
|
|
2449
|
+
* stop();
|
|
2450
|
+
* ```
|
|
2451
|
+
*/
|
|
2452
|
+
watchNewPools(onPool: (pool: PoolListInfo) => void, options?: WatchNewPoolsOptions): () => void;
|
|
2927
2453
|
/**
|
|
2928
2454
|
* Fetches one pool from the backend, preserving whether the request order was flipped.
|
|
2929
2455
|
*
|
|
@@ -3104,42 +2630,6 @@ export interface FetchLiquidityPositionsDTO extends PageDTO {
|
|
|
3104
2630
|
pool?: string | undefined;
|
|
3105
2631
|
}
|
|
3106
2632
|
//#endregion
|
|
3107
|
-
//#region src/utils/unique_key.d.ts
|
|
3108
|
-
/**
|
|
3109
|
-
* The `uniqueKey` prefix frontend_v2 and wallet_extension have always sent
|
|
3110
|
-
* (`galaswap-operation-<uuid>`). defi-backend does not depend on it: the chain-write verifier
|
|
3111
|
-
* only requires a non-empty key of at most 256 characters, and apply-results accepts
|
|
3112
|
-
* `[A-Za-z0-9._:-]{1,128}`; the only code that mints a prefixed key itself is the server-side v1
|
|
3113
|
-
* trade builder, which nothing reads back by prefix.
|
|
3114
|
-
*/
|
|
3115
|
-
export declare const DEFAULT_UNIQUE_KEY_PREFIX = "galaswap-operation-";
|
|
3116
|
-
/** Options shared by the services that mint `uniqueKey`s for writes. */
|
|
3117
|
-
export interface UniqueKeyOptions {
|
|
3118
|
-
/**
|
|
3119
|
-
* Prefix of every minted `uniqueKey` (`<prefix><uuid>`). Defaults to
|
|
3120
|
-
* `DEFAULT_UNIQUE_KEY_PREFIX` (`galaswap-operation-`).
|
|
3121
|
-
*/
|
|
3122
|
-
uniqueKeyPrefix?: string | undefined;
|
|
3123
|
-
}
|
|
3124
|
-
/**
|
|
3125
|
-
* Validates a caller-supplied `uniqueKey` prefix. The whole key (`<prefix><uuid>`) must stay a
|
|
3126
|
-
* valid apply-results key, otherwise `confirm()` could never read the outcome of the write.
|
|
3127
|
-
*
|
|
3128
|
-
* @throws GSwapSDKError `INVALID_UNIQUE_KEY_PREFIX` when the prefix has characters outside
|
|
3129
|
-
* `A-Za-z0-9._:-` or is longer than 92 characters.
|
|
3130
|
-
*/
|
|
3131
|
-
export declare function resolveUniqueKeyPrefix(prefix: string | undefined): string;
|
|
3132
|
-
/**
|
|
3133
|
-
* Validates a caller-supplied write `uniqueKey`: 1 to 128 characters of `A-Za-z0-9._:-`, the
|
|
3134
|
-
* shape the apply-results route accepts, so the write's outcome can always be read back with
|
|
3135
|
-
* `confirm()`. A key is one attempt's identity: reuse it only to retry that same attempt.
|
|
3136
|
-
*
|
|
3137
|
-
* @throws GSwapSDKError `INVALID_UNIQUE_KEY` otherwise.
|
|
3138
|
-
*/
|
|
3139
|
-
export declare function assertUniqueKey(uniqueKey: string): void;
|
|
3140
|
-
/** A fresh per-attempt key: `<prefix><random UUID>`. */
|
|
3141
|
-
export declare function createUniqueKey(prefix: string): string;
|
|
3142
|
-
//#endregion
|
|
3143
2633
|
//#region src/classes/positions.d.ts
|
|
3144
2634
|
type PositionGateway = Pick<ChainGateway, 'httpRequestor' | 'dexBackendBaseUrl'> & {
|
|
3145
2635
|
submit: (method: string, signedBody: Record<string, unknown>, options?: ChainSubmitOptions) => Promise<SubmittedTransaction<Position | null>>;
|
|
@@ -3753,8 +3243,9 @@ export interface GSwapOptions {
|
|
|
3753
3243
|
*/
|
|
3754
3244
|
symbolResolution?: 'registry' | 'canonical' | undefined;
|
|
3755
3245
|
/**
|
|
3756
|
-
* Told about every row of a pool, symbol
|
|
3757
|
-
* {@link InvalidEntryHandler}); without it such rows are
|
|
3246
|
+
* Told about every row of a pool, symbol, position, price, price-series, season or leaderboard
|
|
3247
|
+
* answer that was skipped as unusable (see {@link InvalidEntryHandler}); without it such rows are
|
|
3248
|
+
* skipped silently.
|
|
3758
3249
|
*/
|
|
3759
3250
|
onInvalidEntry?: InvalidEntryHandler | undefined;
|
|
3760
3251
|
/** Realtime stream endpoint. Defaults to the environment's, or is derived from `dexBackendBaseUrl`. */
|
|
@@ -3775,7 +3266,8 @@ export interface GSwapOptions {
|
|
|
3775
3266
|
/**
|
|
3776
3267
|
* Main entry point for the current GalaChainDex SDK: one client bundling the services that read
|
|
3777
3268
|
* and write through the swap backend (`quoting`, `swaps`, `pools`, `positions`, `assets`,
|
|
3778
|
-
* `symbols`, `fees`, `stream`). See {@link GSwapOptions} for
|
|
3269
|
+
* `market`, `leaderboard`, `symbols`, `fees`, `stream`). See {@link GSwapOptions} for
|
|
3270
|
+
* configuration.
|
|
3779
3271
|
*/
|
|
3780
3272
|
export declare class GSwap {
|
|
3781
3273
|
/** The swap backend base URL every request goes to, without a trailing slash. */
|
|
@@ -3800,6 +3292,10 @@ export declare class GSwap {
|
|
|
3800
3292
|
readonly swaps: Swaps;
|
|
3801
3293
|
/** User token balances. */
|
|
3802
3294
|
readonly assets: Assets;
|
|
3295
|
+
/** USD prices, price series and the platform volume totals. */
|
|
3296
|
+
readonly market: Market;
|
|
3297
|
+
/** Trading-competition seasons and rankings. */
|
|
3298
|
+
readonly leaderboard: Leaderboard;
|
|
3803
3299
|
/** Network-fee quotes (DryRun) signed with this client's signer. */
|
|
3804
3300
|
readonly fees: DexFees;
|
|
3805
3301
|
/** The realtime stream endpoint {@link GSwap.stream} connects to. */
|
|
@@ -3831,133 +3327,19 @@ export declare class GSwap {
|
|
|
3831
3327
|
get stream(): GdexStreamService;
|
|
3832
3328
|
}
|
|
3833
3329
|
//#endregion
|
|
3834
|
-
//#region src/
|
|
3835
|
-
/**
|
|
3836
|
-
* What a failure means for the operation that raised it, as one vocabulary for every app.
|
|
3837
|
-
*
|
|
3838
|
-
* - `rejected`: the CHAIN refused the request (a definite no). Nothing was applied, so a NEW
|
|
3839
|
-
* request is safe.
|
|
3840
|
-
* - `unknown`: the request MAY have been applied (a timeout, a broken connection, an
|
|
3841
|
-
* acknowledgement that proves nothing, a failed confirmation). Never submit again under a fresh
|
|
3842
|
-
* key: keep `error.uniqueKey` and confirm it.
|
|
3843
|
-
* - `not_queued`: the gateway refused the write before queueing it. Nothing is pending.
|
|
3844
|
-
* - `not_sent`: the request never left (`error.phase === 'pre_send'`) for a reason outside the
|
|
3845
|
-
* call itself: the signer or the wallet failed (locked, unreachable, the person declined), the
|
|
3846
|
-
* key provider or the token resolver failed, or no key was available yet. Nothing is pending and
|
|
3847
|
-
* nothing was transmitted, so repeating the call is safe and may succeed once the cause (an
|
|
3848
|
-
* unlocked wallet) is gone.
|
|
3849
|
-
* - `invalid_input`: the call itself cannot work (a bad argument, a missing signer or wallet, an
|
|
3850
|
-
* unknown token or pool, a corrupt stored key). Repeating the same call fails the same way.
|
|
3851
|
-
* Such an error is also pre-send (`isPreSendError`), but the input is what has to change.
|
|
3852
|
-
* - `transient`: a read or connection failed with no state change. Repeating the same call is safe
|
|
3853
|
-
* and may succeed.
|
|
3854
|
-
*
|
|
3855
|
-
* This module has no imports: the failure view (`FailureView.outcome`) and the classifier both
|
|
3856
|
-
* read the closed set from here.
|
|
3857
|
-
*/
|
|
3858
|
-
export declare const FAILURE_OUTCOMES: readonly ['rejected', 'unknown', 'not_queued', 'not_sent', 'invalid_input', 'transient'];
|
|
3859
|
-
/** One member of {@link FAILURE_OUTCOMES}. */
|
|
3860
|
-
type FailureOutcome = (typeof FAILURE_OUTCOMES)[number];
|
|
3861
|
-
//#endregion
|
|
3862
|
-
//#region src/utils/failure_view.d.ts
|
|
3863
|
-
/**
|
|
3864
|
-
* A failure as a PLAIN OBJECT: the facts the SDK's guards and `classifyFailure` read, and nothing
|
|
3865
|
-
* else. A real `GSwapSDKError` is one (every field below is on it); so is the wrapper an app makes
|
|
3866
|
-
* from an SDK error to carry through its own layers (frontend_v2's `V2Failure`, the wallet's
|
|
3867
|
-
* `WalletSwapError` data), which has a `code` and `params` but is not an `instanceof` anything the
|
|
3868
|
-
* SDK owns. `classifyFailure`, `isRelayableRefusal`, `isUnprovenAcknowledgement`,
|
|
3869
|
-
* `isUninterpretedAnswer`, `isPreSendError`, `isShadowError`, `isNoMarket` and `mayHaveBeenQueued`
|
|
3870
|
-
* all accept such an object wherever they accept an SDK error, and decide from the SAME fields in
|
|
3871
|
-
* the same way, so an app never has to keep the original error just to ask.
|
|
3872
|
-
*
|
|
3873
|
-
* Only `code` is required. A field that is missing, or has the wrong type, reads as absent: a view
|
|
3874
|
-
* with no `status` is not a 404. Nothing here is text: the SDK never reads `message` of a view.
|
|
3875
|
-
*
|
|
3876
|
-
* READ OR WRITE: a view is a WRITE's unless it says it is a read. This fails CLOSED on purpose:
|
|
3877
|
-
* a 5xx on a write may have been queued (`unknown`, no retry) and the same 5xx on a read changed
|
|
3878
|
-
* nothing (`transient`, retry), so a wrapper that drops its `uniqueKey` must never turn the first
|
|
3879
|
-
* into the second. A view is a read ONLY when it states `write: false` and has no `uniqueKey`;
|
|
3880
|
-
* `GSwapSDKError.write` is already set that way for every SDK read. {@link isWriteView}
|
|
3881
|
-
* is the one definition.
|
|
3882
|
-
*
|
|
3883
|
-
* APP ERRORS: a code the SDK catalog does not define is `unknown` (the SDK cannot say what
|
|
3884
|
-
* happened, and a wrong "failed" invites a duplicate), unless the view declares `outcome`.
|
|
3885
|
-
*/
|
|
3886
|
-
interface FailureView {
|
|
3887
|
-
/** The catalog code (`'HTTP_ERROR'`, `'CHAIN_REJECTED'`, ...). A string the SDK does not know classifies as `unknown`. */
|
|
3888
|
-
readonly code: string;
|
|
3889
|
-
/** The error's flat params (`status` of an `HTTP_ERROR`, `reason` of a `SIGNING_FAILED`, ...). */
|
|
3890
|
-
readonly params?: Readonly<Record<string, unknown>> | undefined;
|
|
3891
|
-
/** The HTTP status of the answer the failure was made from. */
|
|
3892
|
-
readonly status?: number | undefined;
|
|
3893
|
-
/** How far the request got; when absent, the catalog's phase for `code`. */
|
|
3894
|
-
readonly phase?: GSwapErrorPhase | undefined;
|
|
3895
|
-
/** The `uniqueKey` of the WRITE this is about; its presence makes the failure a write's. */
|
|
3896
|
-
readonly uniqueKey?: string | undefined;
|
|
3897
|
-
/**
|
|
3898
|
-
* `false` says the failed call was a READ (no `uniqueKey` to confirm, nothing pending). Anything
|
|
3899
|
-
* else, including absent, is a write: see the note on {@link FailureView}. With a `uniqueKey`
|
|
3900
|
-
* the failure is a write whatever this says.
|
|
3901
|
-
*/
|
|
3902
|
-
readonly write?: boolean | undefined;
|
|
3903
|
-
/**
|
|
3904
|
-
* What an error the APP raised means, for a `code` the SDK catalog does not define (`'POSITION_STALE'`,
|
|
3905
|
-
* `'AMOUNT_SIDE'`): `not_sent` for a step that failed before anything was signed or sent, and so
|
|
3906
|
-
* on. The SDK honours it ONLY for such a code: for a catalog code the SDK's own table decides, so
|
|
3907
|
-
* an app cannot declare a refusal the SDK knows to be unknown as safe. A non-catalog code with no
|
|
3908
|
-
* `outcome` stays `unknown`, and `mayHaveBeenQueued` is then `true`.
|
|
3909
|
-
*/
|
|
3910
|
-
readonly outcome?: FailureOutcome | undefined;
|
|
3911
|
-
/**
|
|
3912
|
-
* WITHHOLD-ONLY: `false` takes Retry away from the declared `outcome` (an app's `DID_NOT_QUEUE`
|
|
3913
|
-
* is `{ outcome: 'not_queued', retryable: false }`, the SDK's `NOT_QUEUED_FINAL`). Any other
|
|
3914
|
-
* value, `true` included, reads as absent: a view can never GRANT Retry to an outcome that does
|
|
3915
|
-
* not have it, and it is read only together with `outcome`, for a code the catalog does not
|
|
3916
|
-
* define.
|
|
3917
|
-
*/
|
|
3918
|
-
readonly retryable?: false | undefined;
|
|
3919
|
-
/** True when the failure came from the shadow (dark) path. */
|
|
3920
|
-
readonly shadow?: boolean | undefined;
|
|
3921
|
-
/** True for "that market does not exist" (`GSwapSDKError.notFound`). */
|
|
3922
|
-
readonly notFound?: boolean | undefined;
|
|
3923
|
-
}
|
|
3924
|
-
/**
|
|
3925
|
-
* Reads the failure view of any value: a `GSwapSDKError`, or a plain object with a string `code`
|
|
3926
|
-
* (and, optionally, `params`, `status`, `phase`, `uniqueKey`, `shadow`, `notFound`). Anything else
|
|
3927
|
-
* (a string, a wallet error with a numeric `code`, `null`) has no view and is `undefined`.
|
|
3928
|
-
*
|
|
3929
|
-
* Having a view does not mean the SDK knows the code: an ethers error is `{ code:
|
|
3930
|
-
* 'ACTION_REJECTED' }` and has a view too. The SDK's guards compare the code with the catalog.
|
|
3931
|
-
*
|
|
3932
|
-
* @example
|
|
3933
|
-
* ```ts
|
|
3934
|
-
* const view = toFailureView(error); // an SDK error, or an app's `{ code, params, status }` wrapper
|
|
3935
|
-
* if (view?.code === 'CHAIN_REJECTED') showChainRejection(view.params);
|
|
3936
|
-
* ```
|
|
3937
|
-
*/
|
|
3938
|
-
export declare function toFailureView(value: unknown): FailureView | undefined;
|
|
3939
|
-
/**
|
|
3940
|
-
* True when a failure is a WRITE's: it names a `uniqueKey`, or it does not say `write: false`.
|
|
3941
|
-
* Fail-closed (see {@link FailureView}): only an explicit read is a read.
|
|
3942
|
-
*/
|
|
3943
|
-
export declare function isWriteView(view: FailureView): boolean;
|
|
3944
|
-
//#endregion
|
|
3945
|
-
//#region src/classes/error_phase_table.d.ts
|
|
3330
|
+
//#region src/classes/gswap_error_phase_table.d.ts
|
|
3946
3331
|
/**
|
|
3947
|
-
* The phase of every catalog code, WITHOUT the catalog. The failure guards (`classifyFailure`,
|
|
3332
|
+
* The phase of every DEX catalog code, WITHOUT the catalog. The failure guards (`classifyFailure`,
|
|
3948
3333
|
* `mayHaveBeenQueued`, ...) need only a code's phase, and the catalog's English templates are
|
|
3949
|
-
* ~
|
|
3334
|
+
* ~15 kB: reading the phase from here keeps an app shell that imports a guard from loading them.
|
|
3950
3335
|
* The catalog entry is still where a code is declared; this table is checked against it AT
|
|
3951
3336
|
* COMPILE TIME, in both directions (a missing code, an extra code or a different phase is a type
|
|
3952
|
-
* error), so the two cannot drift.
|
|
3337
|
+
* error), so the two cannot drift. The core codes' phases are core's `GALA_ERROR_PHASE_BY_CODE`.
|
|
3953
3338
|
*/
|
|
3954
3339
|
export declare const GSWAP_ERROR_PHASE_BY_CODE: {
|
|
3955
3340
|
readonly HTTP_ERROR: 'post_send';
|
|
3956
3341
|
readonly UPDATE_REQUIRED: 'post_send';
|
|
3957
|
-
readonly REQUEST_TIMEOUT: 'in_flight';
|
|
3958
|
-
readonly TRANSPORT_ERROR: 'in_flight';
|
|
3959
3342
|
readonly REQUEST_FAILED: 'in_flight';
|
|
3960
|
-
readonly INVALID_TIMEOUT: 'pre_send';
|
|
3961
3343
|
readonly METHOD_NOT_SUPPORTED: 'pre_send';
|
|
3962
3344
|
readonly SUBMISSION_OUTCOME_UNKNOWN: 'in_flight';
|
|
3963
3345
|
readonly GATEWAY_REPORTED_ERROR: 'post_send';
|
|
@@ -3999,54 +3381,8 @@ export declare const GSWAP_ERROR_PHASE_BY_CODE: {
|
|
|
3999
3381
|
readonly STREAM_CONNECT_FAILED: 'in_flight';
|
|
4000
3382
|
readonly STREAM_CLOSED_BEFORE_CONNECT: 'in_flight';
|
|
4001
3383
|
readonly STREAM_CONNECTION_CLOSED: 'in_flight';
|
|
4002
|
-
readonly GALA_WALLET_NOT_AVAILABLE: 'pre_send';
|
|
4003
|
-
readonly WALLET_UNAVAILABLE: 'pre_send';
|
|
4004
|
-
readonly MALFORMED_WALLET_REQUEST: 'pre_send';
|
|
4005
|
-
readonly UNSUPPORTED_WALLET_METHOD: 'pre_send';
|
|
4006
|
-
readonly INVALID_SIGNATURE: 'pre_send';
|
|
4007
|
-
readonly INVALID_CHAIN_ID: 'pre_send';
|
|
4008
|
-
readonly SIGNER_ADDRESS_MISMATCH: 'pre_send';
|
|
4009
|
-
readonly INVALID_PRIVATE_KEY: 'pre_send';
|
|
4010
|
-
readonly SIGNING_FAILED: 'pre_send';
|
|
4011
|
-
readonly KEY_PROVIDER_FAILED: 'pre_send';
|
|
4012
3384
|
readonly TOKEN_RESOLUTION_FAILED: 'pre_send';
|
|
4013
|
-
readonly INVALID_SIGNING_HASH_LENGTH: 'pre_send';
|
|
4014
3385
|
readonly MISSING_WALLET_ADDRESS: 'pre_send';
|
|
4015
|
-
readonly INVALID_WALLET_ADDRESS: 'pre_send';
|
|
4016
|
-
readonly INVALID_DECIMAL: 'pre_send';
|
|
4017
|
-
readonly PERSONAL_SIGN_NOT_JSON: 'pre_send';
|
|
4018
|
-
readonly PERSONAL_SIGN_NOT_OBJECT: 'pre_send';
|
|
4019
|
-
readonly PERSONAL_SIGN_BAD_PREFIX: 'pre_send';
|
|
4020
|
-
readonly PERSONAL_SIGN_ENVELOPE_FIELDS: 'pre_send';
|
|
4021
|
-
readonly PERSONAL_SIGN_NOT_CANONICAL: 'pre_send';
|
|
4022
|
-
readonly EIP712_NAME_COLLISION: 'pre_send';
|
|
4023
|
-
readonly EIP712_UNSUPPORTED_VALUE: 'pre_send';
|
|
4024
|
-
readonly TYPED_DATA_NOT_STRING: 'pre_send';
|
|
4025
|
-
readonly TYPED_DATA_UNPAIRED_SURROGATE: 'pre_send';
|
|
4026
|
-
readonly TYPED_DATA_NOT_HEX_BYTES: 'pre_send';
|
|
4027
|
-
readonly TYPED_DATA_NOT_SAFE_INTEGER: 'pre_send';
|
|
4028
|
-
readonly TYPED_DATA_NOT_INTEGER: 'pre_send';
|
|
4029
|
-
readonly TYPED_DATA_NOT_BOOLEAN: 'pre_send';
|
|
4030
|
-
readonly TYPED_DATA_BAD_ADDRESS: 'pre_send';
|
|
4031
|
-
readonly TYPED_DATA_BAD_CHECKSUM: 'pre_send';
|
|
4032
|
-
readonly TYPED_DATA_BYTES_LENGTH: 'pre_send';
|
|
4033
|
-
readonly TYPED_DATA_OUT_OF_BOUNDS: 'pre_send';
|
|
4034
|
-
readonly TYPED_DATA_UNSUPPORTED_TYPE: 'pre_send';
|
|
4035
|
-
readonly TYPED_DATA_FIELDS_NOT_LIST: 'pre_send';
|
|
4036
|
-
readonly TYPED_DATA_FIELD_MALFORMED: 'pre_send';
|
|
4037
|
-
readonly TYPED_DATA_INVALID_FIELD_NAME: 'pre_send';
|
|
4038
|
-
readonly TYPED_DATA_DUPLICATE_FIELD: 'pre_send';
|
|
4039
|
-
readonly TYPED_DATA_INVALID_TYPE_NAME: 'pre_send';
|
|
4040
|
-
readonly TYPED_DATA_CIRCULAR_TYPE: 'pre_send';
|
|
4041
|
-
readonly TYPED_DATA_UNKNOWN_FIELD_TYPE: 'pre_send';
|
|
4042
|
-
readonly TYPED_DATA_NO_PRIMARY_TYPE: 'pre_send';
|
|
4043
|
-
readonly TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE: 'pre_send';
|
|
4044
|
-
readonly TYPED_DATA_ARRAY_EXPECTED: 'pre_send';
|
|
4045
|
-
readonly TYPED_DATA_ARRAY_LENGTH_MISMATCH: 'pre_send';
|
|
4046
|
-
readonly TYPED_DATA_STRUCT_NOT_OBJECT: 'pre_send';
|
|
4047
|
-
readonly TYPED_DATA_MISSING_FIELD: 'pre_send';
|
|
4048
|
-
readonly TYPED_DATA_DOMAIN_NOT_OBJECT: 'pre_send';
|
|
4049
|
-
readonly TYPED_DATA_INVALID_DOMAIN_KEY: 'pre_send';
|
|
4050
3386
|
readonly NON_CANONICAL_PAIR: 'pre_send';
|
|
4051
3387
|
readonly UNORDERABLE_SYMBOLS: 'pre_send';
|
|
4052
3388
|
readonly INVALID_TOKEN_CLASS_KEY: 'pre_send';
|
|
@@ -4056,8 +3392,6 @@ export declare const GSWAP_ERROR_PHASE_BY_CODE: {
|
|
|
4056
3392
|
readonly TOKEN_SYMBOL_NOT_REGISTERED: 'pre_send';
|
|
4057
3393
|
readonly SYMBOL_DISAGREES_WITH_REGISTRY: 'pre_send';
|
|
4058
3394
|
readonly CREATE_POOL_NEEDS_CLASS_KEY: 'pre_send';
|
|
4059
|
-
readonly INVALID_UNIQUE_KEY: 'pre_send';
|
|
4060
|
-
readonly INVALID_UNIQUE_KEY_PREFIX: 'pre_send';
|
|
4061
3395
|
readonly AMOUNT_IS_JS_NUMBER: 'pre_send';
|
|
4062
3396
|
readonly AMOUNT_NOT_FINITE: 'pre_send';
|
|
4063
3397
|
readonly AMOUNT_NOT_POSITIVE: 'pre_send';
|
|
@@ -4087,6 +3421,10 @@ export declare const GSWAP_ERROR_PHASE_BY_CODE: {
|
|
|
4087
3421
|
readonly INVALID_SORT_ORDER: 'pre_send';
|
|
4088
3422
|
readonly INVALID_PAGE: 'pre_send';
|
|
4089
3423
|
readonly INVALID_LIMIT: 'pre_send';
|
|
3424
|
+
readonly INVALID_MARKET_TOKEN: 'pre_send';
|
|
3425
|
+
readonly INVALID_TIMEFRAME: 'pre_send';
|
|
3426
|
+
readonly INVALID_SEASON_ID: 'pre_send';
|
|
3427
|
+
readonly INVALID_POLL_INTERVAL: 'pre_send';
|
|
4090
3428
|
};
|
|
4091
3429
|
//#endregion
|
|
4092
3430
|
//#region src/classes/pending_swap_fate.d.ts
|
|
@@ -4364,255 +3702,6 @@ export declare class PendingSwapStore {
|
|
|
4364
3702
|
private fromStored;
|
|
4365
3703
|
}
|
|
4366
3704
|
//#endregion
|
|
4367
|
-
//#region src/utils/signing.d.ts
|
|
4368
|
-
/**
|
|
4369
|
-
* GalaChain's deterministic JSON: object keys sorted (UTF-16 code-unit order) at every depth, no
|
|
4370
|
-
* whitespace, `undefined`/function members dropped, `toJSON()` honored. Byte-identical to
|
|
4371
|
-
* `serialize` from `@gala-chain/api` / `json-stringify-deterministic` for every JSON-shaped
|
|
4372
|
-
* value, which is all a DTO ever is.
|
|
4373
|
-
*
|
|
4374
|
-
* @throws TypeError for circular structures and BigInt values (as `JSON.stringify` does) and
|
|
4375
|
-
* when the value itself has no JSON representation (`undefined`, a function, a symbol).
|
|
4376
|
-
*/
|
|
4377
|
-
export declare function serialize(value: unknown): string;
|
|
4378
|
-
/**
|
|
4379
|
-
* The exact string GalaChain hashes for a DTO: the (optional, string) `prefix` field PREPENDED to
|
|
4380
|
-
* the deterministic serialization of the DTO WITHOUT `signature`, `multisig`, `trace` and `prefix`.
|
|
4381
|
-
* Equivalent to `@gala-chain/api` 3.x `getPayloadToSign` for every non-EIP-712 DTO.
|
|
4382
|
-
*/
|
|
4383
|
-
export declare function getPayloadToSign(dto: Record<string, unknown>): string;
|
|
4384
|
-
/**
|
|
4385
|
-
* The EIP-191 header for `message`: `"\x19Ethereum Signed Message:\n"` + the message's UTF-8 BYTE
|
|
4386
|
-
* length. This is what a wallet's `personal_sign` prepends, and what the chain recomputes when it
|
|
4387
|
-
* recovers a personal-signed DTO.
|
|
4388
|
-
*/
|
|
4389
|
-
export declare function calculatePersonalSignPrefix(message: string): string;
|
|
4390
|
-
/**
|
|
4391
|
-
* The EIP-191 header for `serialize(dto)` (any `prefix` already on the DTO is ignored). This is
|
|
4392
|
-
* deliberately the same string the signers hand a wallet to sign, so the header's length can never
|
|
4393
|
-
* disagree with the signed message. Wallet-neutral: it is the value both a browser wallet's
|
|
4394
|
-
* `personal_sign` and Gala Wallet's `gala_signChainDto` (personal-sign scheme) prepend.
|
|
4395
|
-
*/
|
|
4396
|
-
export declare function personalSignPrefixFor(dto: Record<string, unknown>): string;
|
|
4397
|
-
/**
|
|
4398
|
-
* The `@gala-chain/connect`-style prefix frontend_v2 puts in the body of an EIP-712 write: the
|
|
4399
|
-
* EIP-191 header whose number counts the prefix string ITSELF plus the body (the UTF-8 length of
|
|
4400
|
-
* `getPayloadToSign({ ...dto, prefix })`), found by fixpoint because adding the prefix changes the
|
|
4401
|
-
* length (a body of 99 bytes settles on 101).
|
|
4402
|
-
*
|
|
4403
|
-
* It is NOT a personal-sign prefix (a personal-sign write with this value recovers a phantom
|
|
4404
|
-
* signer; use `personalSignPrefixFor`). Under EIP-712 the field is an untyped extra that the
|
|
4405
|
-
* typed-data hash ignores and defi-backend recomputes, so it only exists to keep the submitted
|
|
4406
|
-
* body byte-identical to what frontend_v2 has always sent.
|
|
4407
|
-
*/
|
|
4408
|
-
export declare function fixpointPrefixFor(dto: Record<string, unknown>): string;
|
|
4409
|
-
/**
|
|
4410
|
-
* Normalizes a secp256k1 private key to a fresh 32-byte array (the caller may zero it). Also
|
|
4411
|
-
* accepts 32 raw bytes, which are validated and copied. For strings it accepts what `@gala-chain/api`'s
|
|
4412
|
-
* `normalizePrivateKey` accepted for a usable key: 64 hex characters (optionally `0x`-prefixed;
|
|
4413
|
-
* a 63-character hex key is left-padded with a zero) or a 44-character base64 string.
|
|
4414
|
-
*
|
|
4415
|
-
* @throws GSwapSDKError (`INVALID_PRIVATE_KEY`; `params.reason` is one of
|
|
4416
|
-
* `INVALID_PRIVATE_KEY_REASONS`: `wrong_length` for raw bytes that are not 32 long,
|
|
4417
|
-
* `bad_encoding` for any other string shape, `not_on_curve` for an out-of-range scalar).
|
|
4418
|
-
*/
|
|
4419
|
-
export declare function normalizePrivateKey(input: string | Uint8Array): Uint8Array;
|
|
4420
|
-
/**
|
|
4421
|
-
* The lowercase `0x` Ethereum address (last 20 bytes of keccak256 of the uncompressed public key)
|
|
4422
|
-
* of a normalized private key. The Gala `eth|` identity of a key is this address.
|
|
4423
|
-
*/
|
|
4424
|
-
export declare function ethAddressOfPrivateKey(privateKey: Uint8Array): string;
|
|
4425
|
-
/**
|
|
4426
|
-
* GalaChain NATIVE signature over an already-serialized DTO: keccak256 of the exact bytes, with no
|
|
4427
|
-
* prefix and no signature envelope. The caller owns serialization, so the bytes shown to a user
|
|
4428
|
-
* and the bytes signed can never diverge.
|
|
4429
|
-
*/
|
|
4430
|
-
export declare function signSerializedNative(privateKey: Uint8Array, serializedDto: string): string;
|
|
4431
|
-
/**
|
|
4432
|
-
* GalaChain NATIVE signature for a DTO: keccak256 of `getPayloadToSign(dto)`, signed with
|
|
4433
|
-
* secp256k1. Byte-identical to `signatures.getSignature` from `@gala-chain/api`.
|
|
4434
|
-
*/
|
|
4435
|
-
export declare function signNative(privateKey: Uint8Array, dto: Record<string, unknown>): string;
|
|
4436
|
-
/**
|
|
4437
|
-
* Personal-sign hash and signature: keccak256(`prefix` + `message`), both hashed VERBATIM with no
|
|
4438
|
-
* further EIP-191 wrapping. Passing `prefix = calculatePersonalSignPrefix(message)` reproduces a
|
|
4439
|
-
* wallet's `personal_sign` of `message`. Gala Wallet's `gala_signChainDto` (personal-sign
|
|
4440
|
-
* scheme) hashes `prefix` + the exact string it is handed, which can differ from the bare message
|
|
4441
|
-
* (see the `signatureOverPrefixlessBody` vectors); that quirk is why the two inputs stay separate.
|
|
4442
|
-
*/
|
|
4443
|
-
export declare function signPersonalMessage(privateKey: Uint8Array, prefix: string, message: string): string;
|
|
4444
|
-
//#endregion
|
|
4445
|
-
//#region src/utils/chain_dto_signing.d.ts
|
|
4446
|
-
/** A secp256k1 private key as a hex/base64 string or as raw 32 bytes. */
|
|
4447
|
-
type PrivateKeyInput = string | Uint8Array;
|
|
4448
|
-
/**
|
|
4449
|
-
* Runs `action` with a private normalized copy of the key, zeroed afterwards (also when `action`
|
|
4450
|
-
* throws). Bytes given by the caller are copied, never modified: the caller owns them.
|
|
4451
|
-
*/
|
|
4452
|
-
export declare function withPrivateKey<T>(privateKey: PrivateKeyInput, action: (key: Uint8Array) => T): T;
|
|
4453
|
-
/**
|
|
4454
|
-
* GalaChain NATIVE signature over an already-serialized DTO: keccak256 of the exact bytes with no
|
|
4455
|
-
* prefix and no envelope (wallet `signChainDtoNative`). The caller owns serialization, so the
|
|
4456
|
-
* bytes a user reviewed and the bytes signed cannot diverge.
|
|
4457
|
-
*
|
|
4458
|
-
* @returns 130 lowercase hex characters, `r || s || v` with `v` = `1b`/`1c`, no `0x`.
|
|
4459
|
-
*/
|
|
4460
|
-
export declare function signChainDtoNative(privateKey: PrivateKeyInput, serializedDto: string): string;
|
|
4461
|
-
/**
|
|
4462
|
-
* The personal-sign hash primitive (wallet `signChainDtoHash`): keccak256(`prefix` + `message`),
|
|
4463
|
-
* both verbatim, with no further EIP-191 wrap. `message` must be the DTO's serialization WITHOUT
|
|
4464
|
-
* its `prefix` field; callers holding a dApp-supplied string go through `signChainDtoPersonalSign`,
|
|
4465
|
-
* which derives both inputs from it.
|
|
4466
|
-
*/
|
|
4467
|
-
export declare function signChainDtoHash(privateKey: PrivateKeyInput, prefix: string, message: string): string;
|
|
4468
|
-
/** What a `gala_signChainDto` personal-sign request hashes. */
|
|
4469
|
-
interface PersonalSignChainDtoPayload {
|
|
4470
|
-
/** The `prefix` the chain prepends: the DTO's own `prefix` field, or `''` when it has none. */
|
|
4471
|
-
prefix: string;
|
|
4472
|
-
/** The exact message hashed after `prefix`. */
|
|
4473
|
-
message: string;
|
|
4474
|
-
}
|
|
4475
|
-
/**
|
|
4476
|
-
* Derives what to hash for a `gala_signChainDto` personal-sign request from the exact string the
|
|
4477
|
-
* dApp sent (and the approval card displayed): wallet `resolvePersonalSignChainDtoPayload`.
|
|
4478
|
-
*
|
|
4479
|
-
* The dApp submits `{ ...dto, prefix, signature }`, which the chain recovers from
|
|
4480
|
-
* `keccak256(prefix + serialize(dto WITHOUT prefix))`. So when the string embeds a `prefix`
|
|
4481
|
-
* field, that field is removed and the remainder re-serialized; the prefix used is the dApp's own
|
|
4482
|
-
* value byte for byte. A string with no `prefix` field is hashed verbatim with an empty prefix
|
|
4483
|
-
* (chain-equivalent to a native signature of that exact string).
|
|
4484
|
-
*
|
|
4485
|
-
* Fails closed (throws `GSwapSDKError` `PERSONAL_SIGN_NOT_JSON`, `PERSONAL_SIGN_NOT_OBJECT`,
|
|
4486
|
-
* `PERSONAL_SIGN_BAD_PREFIX`, `PERSONAL_SIGN_ENVELOPE_FIELDS` or `PERSONAL_SIGN_NOT_CANONICAL`) on:
|
|
4487
|
-
* malformed JSON; JSON that is not a plain object; a `prefix` that is not an EIP-191
|
|
4488
|
-
* "Ethereum Signed Message" header; any signing-envelope field (`signature`, `multisig`, `trace`,
|
|
4489
|
-
* `types`, `domain`, `stringsInstructions`); and a string that is not already the canonical
|
|
4490
|
-
* serialization of what it parses to (duplicate keys, lossy numbers, key-order tricks the card
|
|
4491
|
-
* would render differently). Stripping `prefix` is therefore the ONLY byte change between the
|
|
4492
|
-
* reviewed string and the signed message.
|
|
4493
|
-
*/
|
|
4494
|
-
export declare function resolvePersonalSignChainDtoPayload(data: string): PersonalSignChainDtoPayload;
|
|
4495
|
-
/**
|
|
4496
|
-
* Signs a GalaChain personal-sign scheme DTO from the exact string a dApp sent through
|
|
4497
|
-
* `gala_signChainDto` (wallet `signChainDtoPersonalSign`). See
|
|
4498
|
-
* `resolvePersonalSignChainDtoPayload` for what is signed and what is refused; the signature
|
|
4499
|
-
* recovers, under the chain's `getPayloadToSign`, to this key for the DTO the dApp submits with
|
|
4500
|
-
* its `prefix`, and equals a `personal_sign` of the bare body when that prefix is the EIP-191
|
|
4501
|
-
* header of the bare body's byte length.
|
|
4502
|
-
*
|
|
4503
|
-
* @throws GSwapSDKError (`PERSONAL_SIGN_*`, see `resolvePersonalSignChainDtoPayload`) before any
|
|
4504
|
-
* signing when the input is refused.
|
|
4505
|
-
*/
|
|
4506
|
-
export declare function signChainDtoPersonalSign(privateKey: PrivateKeyInput, data: string): string;
|
|
4507
|
-
/**
|
|
4508
|
-
* Raw object signing (wallet `signObject`), used for transfers, bridge and fee-dry-run DTOs the
|
|
4509
|
-
* wallet signs itself. Removes ONLY `signature`, signs `keccak256(serialize(rest))` natively
|
|
4510
|
-
* (no `prefix` handling, and `trace` / `multisig` stay in the signed bytes, unlike
|
|
4511
|
-
* `signNative`), and returns `{ signature, ...rest }` with the signature as the FIRST key, exactly
|
|
4512
|
-
* like the wallet. Callers that must not sign extra fields strip them first.
|
|
4513
|
-
*/
|
|
4514
|
-
export declare function signRawObject(privateKey: PrivateKeyInput, obj: Record<string, unknown>): {
|
|
4515
|
-
signature: string;
|
|
4516
|
-
} & Record<string, unknown>;
|
|
4517
|
-
/**
|
|
4518
|
-
* Drops the `EIP712Domain` entry from a dApp-supplied types map (a typed-data encoder derives the
|
|
4519
|
-
* domain type itself and rejects an explicit one). The order of the remaining types is preserved.
|
|
4520
|
-
*/
|
|
4521
|
-
export declare function stripEip712DomainType<T>(types: Record<string, T>): Record<string, T>;
|
|
4522
|
-
/**
|
|
4523
|
-
* `collection$category$type$additionalKey` for a token-class object (wallet `decodeTokenData`).
|
|
4524
|
-
* Lenient on purpose: any missing or non-string part becomes `''`, so a display layer never
|
|
4525
|
-
* throws on odd input.
|
|
4526
|
-
*/
|
|
4527
|
-
export declare function tokenClassDollarKey(token: Record<string, unknown> | null | undefined): string;
|
|
4528
|
-
/**
|
|
4529
|
-
* A quantity in the form GalaChain's `IsBigNumber` validator accepts: FIXED notation, no leading
|
|
4530
|
-
* zeros, no trailing decimal zeros (`BigNumber#toFixed()`; never `toString()`, which turns
|
|
4531
|
-
* `0.00000001` into `1e-8`, and never a JS number in between).
|
|
4532
|
-
*
|
|
4533
|
-
* @throws GSwapSDKError (`INVALID_DECIMAL`) for a value that is not a finite number. The wallet's
|
|
4534
|
-
* `cleanNumber` returned the string `'NaN'` there; signing that text can only fail on chain.
|
|
4535
|
-
*/
|
|
4536
|
-
export declare function canonicalDecimalString(value: string | number): string;
|
|
4537
|
-
//#endregion
|
|
4538
|
-
//#region src/utils/eip712.d.ts
|
|
4539
|
-
/** EIP-712 `types`: each struct name mapped to its ordered `{ name, type }` fields. */
|
|
4540
|
-
type EIP712Types = Record<string, Array<{
|
|
4541
|
-
name: string;
|
|
4542
|
-
type: string;
|
|
4543
|
-
}>>;
|
|
4544
|
-
/**
|
|
4545
|
-
* Derives the EIP-712 `types` for a DTO from its runtime shape.
|
|
4546
|
-
*
|
|
4547
|
-
* The generated `types` travel with the signed payload and are what BOTH sides hash, so they
|
|
4548
|
-
* must enumerate EVERY field the chain-side DTO will carry. GalaChain refuses any signature
|
|
4549
|
-
* whose `types` leave a DTO field uncovered (`assertNoUnsignedFields`, the fix for the
|
|
4550
|
-
* 2026-08-18 unsigned-field-injection drain); when that happens signature recovery fails
|
|
4551
|
-
* outright and the chain reports "Missing signerPublicKey or signerAddress field in dto".
|
|
4552
|
-
*/
|
|
4553
|
-
export declare function generateEIP712Types(typeName: string, params: Record<string, unknown>): EIP712Types;
|
|
4554
|
-
/** The EIP-712 domain carried by a signed payload: GalaChain only uses `name` and `chainId`. */
|
|
4555
|
-
interface EIP712DomainValue {
|
|
4556
|
-
name: string;
|
|
4557
|
-
chainId: number;
|
|
4558
|
-
}
|
|
4559
|
-
/**
|
|
4560
|
-
* Builds the EIP-712 domain from the wallet's LIVE `eth_chainId` result, exactly like frontend_v2
|
|
4561
|
-
* (DEFI-1895): a wallet hashes whatever domain it is handed, and MetaMask refuses a `chainId` that
|
|
4562
|
-
* differs from its active network, so a hardcoded `1` breaks every wallet that is not on Mainnet.
|
|
4563
|
-
* defi-backend recovers the signer from the `domain` the payload carries (live-proven for chain
|
|
4564
|
-
* ids 1, 56 and 11155111), so following the wallet is correct on every network.
|
|
4565
|
-
*
|
|
4566
|
-
* @param chainId - The raw `eth_chainId` result: a `0x` hex string (the JSON-RPC form) or an integer.
|
|
4567
|
-
* @throws GSwapSDKError (`INVALID_CHAIN_ID`) when the wallet answers with anything else.
|
|
4568
|
-
*/
|
|
4569
|
-
export declare function eip712DomainFor(chainId: unknown): EIP712DomainValue;
|
|
4570
|
-
/**
|
|
4571
|
-
* The four v2 operations proven to recover the signer correctly via genuine EIP-712: `RequestTrade`
|
|
4572
|
-
* never had the problem (one numeric field). `AddLiquidity`/`RemoveLiquidity`/
|
|
4573
|
-
* `CollectPositionFees` each need their `types` completed with a handful of fields their real
|
|
4574
|
-
* server-side DTO always carries — see the `complete*Fields` functions below. `CreatePool` is a
|
|
4575
|
-
* genuinely different, unsolved problem (nested `TokenClassKey` structs, not a flat
|
|
4576
|
-
* missing-field gap) and is NOT in this set — callers must keep using `personal-sign` for it.
|
|
4577
|
-
*/
|
|
4578
|
-
export declare const EIP712_CAPABLE_METHODS: ReadonlySet<string>;
|
|
4579
|
-
/**
|
|
4580
|
-
* Completes a DTO's fields for EIP-712 signing (a no-op for methods with no known gap, e.g.
|
|
4581
|
-
* `RequestTrade`) and derives its `types`. Exported separately from the signing call itself so tests
|
|
4582
|
-
* can assert on the exact payload without needing a live provider.
|
|
4583
|
-
*/
|
|
4584
|
-
export declare function buildEIP712Payload(methodName: string, dto: Record<string, unknown>): {
|
|
4585
|
-
completedDto: Record<string, unknown>;
|
|
4586
|
-
types: EIP712Types;
|
|
4587
|
-
};
|
|
4588
|
-
//#endregion
|
|
4589
|
-
//#region src/utils/typed_data.d.ts
|
|
4590
|
-
/** A typed-data payload as `eth_signTypedData_v4` carries it, minus `primaryType` (it is inferred). */
|
|
4591
|
-
interface TypedDataPayload {
|
|
4592
|
-
domain: Record<string, unknown>;
|
|
4593
|
-
/** Struct definitions WITHOUT `EIP712Domain` (see `stripEip712DomainType`). */
|
|
4594
|
-
types: Record<string, readonly unknown[]>;
|
|
4595
|
-
message: Record<string, unknown>;
|
|
4596
|
-
}
|
|
4597
|
-
/**
|
|
4598
|
-
* The EIP-712 digest `keccak256(0x1901 || domainSeparator || hashStruct(primaryType, message))`
|
|
4599
|
-
* that a wallet signs for `eth_signTypedData_v4`. The primary type is inferred, as ethers does.
|
|
4600
|
-
*
|
|
4601
|
-
* @throws GSwapSDKError (`TYPED_DATA_*`) for any type graph or value it cannot encode
|
|
4602
|
-
* exactly (see the module note on strictness).
|
|
4603
|
-
*/
|
|
4604
|
-
export declare function hashTypedData(payload: TypedDataPayload): Uint8Array;
|
|
4605
|
-
/**
|
|
4606
|
-
* Signs a dApp's EIP-712 typed-data approval (the wallet's `signTypedMessage` path), replacing
|
|
4607
|
-
* `new ethers.Wallet(key).signTypedData(domain, types, message)`. `types` must already have
|
|
4608
|
-
* `EIP712Domain` removed (`stripEip712DomainType`).
|
|
4609
|
-
*
|
|
4610
|
-
* @returns `0x` + r + s + v with `v` = `0x1b`/`0x1c` (27/28): ethers' serialized signature form,
|
|
4611
|
-
* recoverable with `verifyTypedData` / `eth_signTypedData_v4` verifiers. Rejects (never throws
|
|
4612
|
-
* synchronously) on invalid input.
|
|
4613
|
-
*/
|
|
4614
|
-
export declare function signTypedDataPayload(privateKey: PrivateKeyInput, payload: TypedDataPayload): Promise<string>;
|
|
4615
|
-
//#endregion
|
|
4616
3705
|
//#region src/utils/dto_builders.d.ts
|
|
4617
3706
|
/** The pool a RequestTrade trades in, its fee tier, the `uniqueKey` and what is traded. */
|
|
4618
3707
|
type RequestTradeInput = {
|
|
@@ -4716,122 +3805,6 @@ type V2WriteMethod = 'RequestTrade' | 'AddLiquidity' | 'RemoveLiquidity' | 'Coll
|
|
|
4716
3805
|
*/
|
|
4717
3806
|
export declare function assertCanonicalV2Dto(method: V2WriteMethod, dto: Record<string, unknown>): void;
|
|
4718
3807
|
//#endregion
|
|
4719
|
-
//#region src/utils/axios_requestor.d.ts
|
|
4720
|
-
/** What the adapter reads of an axios response. */
|
|
4721
|
-
export interface AxiosLikeResponse {
|
|
4722
|
-
status: number;
|
|
4723
|
-
data?: unknown;
|
|
4724
|
-
/** axios' `AxiosHeaders` (has `get`) or a plain header record. */
|
|
4725
|
-
headers?: unknown;
|
|
4726
|
-
}
|
|
4727
|
-
/** The request config the adapter hands to axios. */
|
|
4728
|
-
export interface AxiosLikeConfig {
|
|
4729
|
-
headers: Record<string, string>;
|
|
4730
|
-
signal?: AbortSignal;
|
|
4731
|
-
validateStatus?: () => boolean;
|
|
4732
|
-
}
|
|
4733
|
-
/**
|
|
4734
|
-
* The part of an axios instance the adapter calls. Declared structurally, so the SDK takes no
|
|
4735
|
-
* dependency on axios and any axios instance (with its interceptors) satisfies it.
|
|
4736
|
-
*/
|
|
4737
|
-
export interface AxiosLikeInstance {
|
|
4738
|
-
get(url: string, config?: AxiosLikeConfig): Promise<unknown>;
|
|
4739
|
-
post(url: string, data?: unknown, config?: AxiosLikeConfig): Promise<unknown>;
|
|
4740
|
-
}
|
|
4741
|
-
/** Options of {@link httpRequestorFromAxios}. */
|
|
4742
|
-
export interface AxiosRequestorOptions {
|
|
4743
|
-
/**
|
|
4744
|
-
* `true`: leave axios' default status validation alone, so a 4xx/5xx REJECTS through the
|
|
4745
|
-
* instance's own interceptors and the SDK rethrows what the app's error handling produced.
|
|
4746
|
-
* `false`: every HTTP status resolves, so the SDK classifies it itself (shadow submits,
|
|
4747
|
-
* apply-results reads); transport failures still reject.
|
|
4748
|
-
*/
|
|
4749
|
-
rejectOnHttpError: boolean;
|
|
4750
|
-
/**
|
|
4751
|
-
* Request headers NOT to hand to axios, matched case-insensitively. Default `['content-type']`:
|
|
4752
|
-
* axios derives `Content-Type: application/json` from the object body it is given, and an
|
|
4753
|
-
* interceptor may set its own, so the SDK's copy would only be a second opinion.
|
|
4754
|
-
*/
|
|
4755
|
-
omitHeaders?: readonly string[] | undefined;
|
|
4756
|
-
}
|
|
4757
|
-
/**
|
|
4758
|
-
* An SDK {@link HttpRequestor} over an axios instance, so the SDK's requests travel through the
|
|
4759
|
-
* app's own base URL, interceptors and error handling.
|
|
4760
|
-
*
|
|
4761
|
-
* A POST's string body is parsed back to the object the SDK serialized it from (axios serializes
|
|
4762
|
-
* again, and an interceptor may read the object); a GET goes through `instance.get`. The answer
|
|
4763
|
-
* is an HTTP response whose `json()`/`text()` read `response.data`. An answer that is not an
|
|
4764
|
-
* axios response is a `TRANSPORT_ERROR` rejection, and so is a rejection that means no HTTP
|
|
4765
|
-
* answer arrived (the original error is `cause`): any rejection with `rejectOnHttpError: false`
|
|
4766
|
-
* (every status resolves there), an axios error without a `response` with `true`. Any other
|
|
4767
|
-
* rejection (an interceptor's error for a 4xx, say) is rethrown unchanged, and so is an abort.
|
|
4768
|
-
*
|
|
4769
|
-
* Pair it with `ChainGateway`'s `dexBackendBaseUrl: ''` when the instance owns the base URL.
|
|
4770
|
-
*
|
|
4771
|
-
* @example
|
|
4772
|
-
* ```ts
|
|
4773
|
-
* const submitGateway = new ChainGateway({
|
|
4774
|
-
* dexBackendBaseUrl: '',
|
|
4775
|
-
* httpRequestor: httpRequestorFromAxios(chainGatewayInstance, { rejectOnHttpError: true }),
|
|
4776
|
-
* });
|
|
4777
|
-
* ```
|
|
4778
|
-
*/
|
|
4779
|
-
export declare function httpRequestorFromAxios(instance: AxiosLikeInstance, options: AxiosRequestorOptions): HttpRequestor;
|
|
4780
|
-
//#endregion
|
|
4781
|
-
//#region src/utils/ethers_provider.d.ts
|
|
4782
|
-
/**
|
|
4783
|
-
* The part of an ethers v6 signer (`JsonRpcSigner`, `Wallet`) the adapter calls. Declared
|
|
4784
|
-
* structurally, so the SDK takes no dependency on ethers and an ethers object satisfies it as is.
|
|
4785
|
-
*/
|
|
4786
|
-
export interface EthersLikeSigner {
|
|
4787
|
-
signTypedData(domain: Record<string, unknown>, types: Record<string, Array<{
|
|
4788
|
-
name: string;
|
|
4789
|
-
type: string;
|
|
4790
|
-
}>>, value: Record<string, unknown>): Promise<string>;
|
|
4791
|
-
signMessage(message: string): Promise<string>;
|
|
4792
|
-
}
|
|
4793
|
-
/** The part of an ethers v6 provider (`BrowserProvider`) the adapter calls. */
|
|
4794
|
-
export interface EthersLikeProvider {
|
|
4795
|
-
getSigner(): Promise<EthersLikeSigner>;
|
|
4796
|
-
/** The raw JSON-RPC passthrough (`BrowserProvider.send`). */
|
|
4797
|
-
send(method: string, params: unknown[]): Promise<unknown>;
|
|
4798
|
-
}
|
|
4799
|
-
/** Options of {@link eip1193ProviderFromEthers}. */
|
|
4800
|
-
export interface EthersEip1193Options {
|
|
4801
|
-
/**
|
|
4802
|
-
* Signs a `personal_sign` message when the provider cannot or should not: a wallet SDK that
|
|
4803
|
-
* signs through its own object (TrustWallet's `web3Wallet.signMessage`). When set it answers
|
|
4804
|
-
* every `personal_sign`, and the provider is not touched for it.
|
|
4805
|
-
*/
|
|
4806
|
-
personalSign?: ((message: string) => Promise<string>) | undefined;
|
|
4807
|
-
}
|
|
4808
|
-
/**
|
|
4809
|
-
* An EIP-1193 provider over an ethers v6 provider, for {@link BrowserWalletSigner}: apps whose
|
|
4810
|
-
* wallet connection is an ethers `BrowserProvider` sign through the very ethers calls they always
|
|
4811
|
-
* made, with no hand-written shim.
|
|
4812
|
-
*
|
|
4813
|
-
* - `eth_chainId` is `provider.send('eth_chainId', [])`: the wallet's LIVE chain. Never
|
|
4814
|
-
* `provider.getNetwork()`, which ethers caches and does not invalidate on `chainChanged`, so a
|
|
4815
|
-
* user who switches networks after connecting would sign against a stale chainId.
|
|
4816
|
-
* - `eth_signTypedData_v4` parses the `[account, JSON]` params and calls
|
|
4817
|
-
* `signer.signTypedData(domain, types, message)` with `EIP712Domain` removed from `types`.
|
|
4818
|
-
* - `personal_sign` is `options.personalSign(message)` when given, else `signer.signMessage`.
|
|
4819
|
-
* - Anything else is `UNSUPPORTED_WALLET_METHOD`; a malformed request is
|
|
4820
|
-
* `MALFORMED_WALLET_REQUEST`; a missing provider is `WALLET_UNAVAILABLE`.
|
|
4821
|
-
*
|
|
4822
|
-
* `provider` may be `null`/`undefined` (nothing connected): a request that needs it then fails
|
|
4823
|
-
* with `WALLET_UNAVAILABLE` rather than at construction, so a signer can be built before the
|
|
4824
|
-
* connection state is known.
|
|
4825
|
-
*
|
|
4826
|
-
* @example
|
|
4827
|
-
* ```ts
|
|
4828
|
-
* const signer = new BrowserWalletSigner(eip1193ProviderFromEthers(browserProvider), account, {
|
|
4829
|
-
* scheme: 'eip712',
|
|
4830
|
-
* });
|
|
4831
|
-
* ```
|
|
4832
|
-
*/
|
|
4833
|
-
export declare function eip1193ProviderFromEthers(provider: EthersLikeProvider | null | undefined, options?: EthersEip1193Options): BrowserWalletProvider;
|
|
4834
|
-
//#endregion
|
|
4835
3808
|
//#region src/utils/confirmation_state.d.ts
|
|
4836
3809
|
/**
|
|
4837
3810
|
* Where a failed CONFIRMATION of a queued write stopped, as a closed set a screen can switch on:
|
|
@@ -4867,33 +3840,6 @@ export declare function isConfirmationAborted(error: unknown): boolean;
|
|
|
4867
3840
|
/** True when the wait for the apply result ran out of time (`CONFIRMATION_TIMEOUT`). */
|
|
4868
3841
|
export declare function isConfirmationTimeout(error: unknown): boolean;
|
|
4869
3842
|
//#endregion
|
|
4870
|
-
//#region src/utils/fetch_failure.d.ts
|
|
4871
|
-
/**
|
|
4872
|
-
* True when a rejection of a `fetch`-based requestor means NO HTTP ANSWER ARRIVED: the network
|
|
4873
|
-
* failed, the connection was reset, the host did not resolve, CORS blocked it. For a write that
|
|
4874
|
-
* is not a refusal (the request may have been queued), so this is the default
|
|
4875
|
-
* `ChainGatewayOptions.isTransportFailure` for a requestor that wraps `fetch` and rejects with
|
|
4876
|
-
* its own errors.
|
|
4877
|
-
*
|
|
4878
|
-
* - Yes: a `TypeError` (what `fetch` rejects with in every engine: `Failed to fetch`, `Load failed`,
|
|
4879
|
-
* `NetworkError when attempting to fetch resource`, undici's `fetch failed`), recognised by name
|
|
4880
|
-
* too so one from another realm (an extension page, an iframe) still counts, and a
|
|
4881
|
-
* `DOMException` named `NetworkError`.
|
|
4882
|
-
* - No: an abort (`AbortError`) or a timeout (`TimeoutError`). The SDK's own request layer knows
|
|
4883
|
-
* whether its timer or the caller's signal aborted, and reports those itself
|
|
4884
|
-
* (`REQUEST_TIMEOUT`, or the caller's own abort unchanged); claiming them here would turn the
|
|
4885
|
-
* caller's cancel into "maybe queued".
|
|
4886
|
-
* - No: anything else, including an SDK error and a value that is not an object.
|
|
4887
|
-
*
|
|
4888
|
-
* It never throws.
|
|
4889
|
-
*
|
|
4890
|
-
* @example
|
|
4891
|
-
* ```ts
|
|
4892
|
-
* new ChainGateway({ dexBackendBaseUrl, httpRequestor: galaFetch, isTransportFailure: isFetchTransportFailure });
|
|
4893
|
-
* ```
|
|
4894
|
-
*/
|
|
4895
|
-
export declare function isFetchTransportFailure(error: unknown): boolean;
|
|
4896
|
-
//#endregion
|
|
4897
3843
|
//#region src/utils/classification.d.ts
|
|
4898
3844
|
/**
|
|
4899
3845
|
* The classification values an app shell may need on their own: what an outcome allows. This module
|
|
@@ -4953,7 +3899,7 @@ export declare function notSentClassification(): FailureClassification;
|
|
|
4953
3899
|
//#endregion
|
|
4954
3900
|
//#region src/utils/failure_classification.d.ts
|
|
4955
3901
|
/**
|
|
4956
|
-
* Classifies any thrown value from its code (and, for
|
|
3902
|
+
* Classifies any thrown value from its code (and, for a few codes, its HTTP status), never from
|
|
4957
3903
|
* message text, so an app does not have to re-derive "may I offer Retry?" and "is the outcome
|
|
4958
3904
|
* unknown?" for every code. The decision for each code is in this module's table; a new catalog
|
|
4959
3905
|
* code cannot be added without one.
|
|
@@ -5151,52 +4097,6 @@ export declare function chainErrorKeyOf(error: unknown): string | undefined;
|
|
|
5151
4097
|
*/
|
|
5152
4098
|
export declare function isNoMarket(error: unknown): boolean;
|
|
5153
4099
|
//#endregion
|
|
5154
|
-
//#region src/utils/class_key.d.ts
|
|
5155
|
-
/**
|
|
5156
|
-
* Token class keys that never throw: the `$`-joined composite key and the non-throwing parsers.
|
|
5157
|
-
* This module imports nothing at run time (the key type is erased), so an app shell that reads a
|
|
5158
|
-
* stored key pays for a few hundred bytes, never for the error class or the catalog. The parser
|
|
5159
|
-
* that THROWS an SDK error on a bad key (`parseTokenClassKey`) lives in `ordering.ts`.
|
|
5160
|
-
*/
|
|
5161
|
-
/** Return the `$`-joined composite key used by GalaChain object identities. */
|
|
5162
|
-
export declare function compositeKeyOf(token: GalaChainTokenClassKey): string;
|
|
5163
|
-
/**
|
|
5164
|
-
* The non-throwing `parseTokenClassKey`: the class key, or `undefined` when `value` is not
|
|
5165
|
-
* one. A string is split exactly as `parseTokenClassKey` splits it (`|` form when it contains a
|
|
5166
|
-
* `|`, else `$`, from the right, all four parts non-empty). Unlike `parseTokenClassKey`, an
|
|
5167
|
-
* object is VALIDATED, not just copied: all four fields must be non-empty strings. Anything else
|
|
5168
|
-
* (`undefined`, `null`, a number, an array) is `undefined`, so it is safe on untrusted input (a
|
|
5169
|
-
* stored token, a URL parameter, a wallet row) without a `try`/`catch`.
|
|
5170
|
-
*
|
|
5171
|
-
* Use {@link tryParseCompositeKey} instead when only the `$` form is valid input.
|
|
5172
|
-
*
|
|
5173
|
-
* @example
|
|
5174
|
-
* ```ts
|
|
5175
|
-
* const key = tryParseTokenClassKey(row.compositeKey);
|
|
5176
|
-
* if (key === undefined) return failClosed(); // no class is known: never invent one from a symbol
|
|
5177
|
-
* ```
|
|
5178
|
-
*/
|
|
5179
|
-
export declare function tryParseTokenClassKey(value: unknown): GalaChainTokenClassKey | undefined;
|
|
5180
|
-
/**
|
|
5181
|
-
* Parses a `$`-joined composite key (`Collection$Category$Type$AdditionalKey`, what
|
|
5182
|
-
* {@link compositeKeyOf} writes) and nothing else, or `undefined`. It is {@link tryParseTokenClassKey}
|
|
5183
|
-
* for a string that may ONLY be in the `$` form: a key that contains `|` is NOT read as the pipe
|
|
5184
|
-
* form here (it stays part of a segment), and only a string is accepted. The split is from the
|
|
5185
|
-
* right, so a collection that itself contains `$` (production's `$GMUSIC`, stage's
|
|
5186
|
-
* `$GMUSIC_TEST1`) stays whole; `'GALA'`, `'GALA$Unit$none'`, `'ETIME$$$'`, `'GALA$Unit$none$'` and
|
|
5187
|
-
* `'$$$$'` are `undefined`.
|
|
5188
|
-
*
|
|
5189
|
-
* It replaces an app's own `parseCompositeKey(key): Components | null` (`?? null`), which had
|
|
5190
|
-
* exactly these semantics.
|
|
5191
|
-
*
|
|
5192
|
-
* @example
|
|
5193
|
-
* ```ts
|
|
5194
|
-
* tryParseCompositeKey('$GMUSIC_TEST1$Unit$none$none')?.collection; // '$GMUSIC_TEST1'
|
|
5195
|
-
* tryParseCompositeKey('GALA$Unit$none'); // undefined
|
|
5196
|
-
* ```
|
|
5197
|
-
*/
|
|
5198
|
-
export declare function tryParseCompositeKey(value: unknown): GalaChainTokenClassKey | undefined;
|
|
5199
|
-
//#endregion
|
|
5200
4100
|
//#region src/utils/shadow_errors.d.ts
|
|
5201
4101
|
/**
|
|
5202
4102
|
* True when `value` is a failure of the shadow (dark) path: an SDK error with `shadow: true`, a
|
|
@@ -5374,19 +4274,6 @@ export declare function frameSlot0(slot0: {
|
|
|
5374
4274
|
flippedFromRequest?: boolean | undefined;
|
|
5375
4275
|
}): FramedSlot0;
|
|
5376
4276
|
//#endregion
|
|
5377
|
-
//#region src/utils/unique_key_syntax.d.ts
|
|
5378
|
-
/**
|
|
5379
|
-
* The shape of a write `uniqueKey`, with NO imports: the pending-swap store and the failure guards
|
|
5380
|
-
* need only this check, and importing it from `unique_key.ts` would drag in `GSwapSDKError` and the
|
|
5381
|
-
* whole error catalog for it.
|
|
5382
|
-
*/
|
|
5383
|
-
/**
|
|
5384
|
-
* True when `uniqueKey` is a usable write key: 1 to 128 characters of `A-Za-z0-9._:-`, the shape
|
|
5385
|
-
* the apply-results route accepts. The one definition behind `assertUniqueKey`, `confirm()` and
|
|
5386
|
-
* the pending-swap store, so they can never disagree about what a valid key is.
|
|
5387
|
-
*/
|
|
5388
|
-
export declare function isValidUniqueKey(uniqueKey: unknown): uniqueKey is string;
|
|
5389
|
-
//#endregion
|
|
5390
4277
|
//#region src/utils/validation.d.ts
|
|
5391
4278
|
/**
|
|
5392
4279
|
* Validates a decimal amount: a string or `BigNumber`, never a JavaScript number.
|
|
@@ -5453,57 +4340,5 @@ export declare function isProposableTradingSymbol(symbol: string): boolean;
|
|
|
5453
4340
|
*/
|
|
5454
4341
|
export declare function assertCanonicalPair(token0: string, token1: string): void;
|
|
5455
4342
|
//#endregion
|
|
5456
|
-
|
|
5457
|
-
/**
|
|
5458
|
-
* What the SDK knows about a failure thrown by a WALLET (the signer an app supplies, or wallet
|
|
5459
|
-
* code of the app's own): the code the wallet put on it, and whether it means the person declined.
|
|
5460
|
-
* Both read only the wallet's own error value; neither shows or forwards its text.
|
|
5461
|
-
*/
|
|
5462
|
-
/**
|
|
5463
|
-
* True when a wallet's error (or just its message text) says the person DECLINED the request in
|
|
5464
|
-
* their wallet. This is exactly the test behind `SIGNING_FAILED` with `params.reason ===
|
|
5465
|
-
* 'user_rejected'`, exported for wallet code outside the SDK (connect and registration flows, a
|
|
5466
|
-
* v1 write path) so an app keeps no matcher of its own.
|
|
5467
|
-
*
|
|
5468
|
-
* It is decided from the wallet's own fields first: a `code` of `4001` (EIP-1193), `'ACTION_REJECTED'`
|
|
5469
|
-
* (ethers) or `'USER_REJECTED'`, or `name === 'UserRejectedRequestError'` (viem). Only when those are
|
|
5470
|
-
* absent is the wallet's TEXT read (`message`, `Message`, `shortMessage`, `details`, `errorDetails`,
|
|
5471
|
-
* `reason`, up to three levels deep, or a bare string): "user rejected", "user denied", "user
|
|
5472
|
-
* cancelled", "request rejected", "rejected by user", "rejected the request", "cancelled" /
|
|
5473
|
-
* "canceled", or a "signature ... cancel" sentence. The wording fallback is a last resort for
|
|
5474
|
-
* wallets that do not set codes; prefer `code` and `name` wherever you control the wallet.
|
|
5475
|
-
*
|
|
5476
|
-
* An SDK error is never read by its text: a `SIGNING_FAILED` is a decline exactly when its
|
|
5477
|
-
* `params.reason` is `user_rejected`, and every other SDK error is not one. The same holds for a
|
|
5478
|
-
* plain-object VIEW of an SDK error (`{ code: 'SIGNING_FAILED', params: { reason } }`, the shape
|
|
5479
|
-
* of an app's wrapper): a string `code` plus an object `params` is decided by the code alone, with
|
|
5480
|
-
* the wallet code list above still honoured for a view that is not branded, and its English is
|
|
5481
|
-
* never read. This works without `instanceof`, so it is safe across two copies of the SDK.
|
|
5482
|
-
*
|
|
5483
|
-
* @example
|
|
5484
|
-
* ```ts
|
|
5485
|
-
* try {
|
|
5486
|
-
* await wallet.connect();
|
|
5487
|
-
* } catch (error) {
|
|
5488
|
-
* if (isWalletUserRejection(error)) return; // the person said no: not an error to report
|
|
5489
|
-
* report(error);
|
|
5490
|
-
* }
|
|
5491
|
-
* ```
|
|
5492
|
-
*/
|
|
5493
|
-
export declare function isWalletUserRejection(value: unknown): boolean;
|
|
5494
|
-
/**
|
|
5495
|
-
* The code a wallet put on its error: an EIP-1193 / JSON-RPC number (`4001`, `-32603`) or an
|
|
5496
|
-
* ethers / viem string (`'ACTION_REJECTED'`), read from the error's own top-level `code`. Anything
|
|
5497
|
-
* else (no code, a non-finite number, an empty or very long string, an object) is `undefined`, so
|
|
5498
|
-
* the value is always a safe primitive. Used for `GSwapSDKError.walletCode`.
|
|
5499
|
-
*
|
|
5500
|
-
* @example
|
|
5501
|
-
* ```ts
|
|
5502
|
-
* walletDeclineCode({ code: 4001, message: 'User rejected the request.' }); // 4001
|
|
5503
|
-
* walletDeclineCode(new Error('locked')); // undefined
|
|
5504
|
-
* ```
|
|
5505
|
-
*/
|
|
5506
|
-
export declare function walletDeclineCode(value: unknown): number | string | undefined;
|
|
5507
|
-
//#endregion
|
|
5508
|
-
export type { AddLiquidityInput, ConfirmationState, CreatePoolInput, EIP712DomainValue, EIP712Types, EntryParse, FailureOutcome, FailureView, GSwapErrorCode, GSwapErrorParams, GSwapErrorPhase, GSwapErrorShape, InvalidEntry, InvalidEntryHandler, InvalidPrivateKeyReason, PersonalSignChainDtoPayload, PoolPositionInput, PrivateKeyInput, RemoveLiquidityInput, RequestTradeInput, SigningFailureReason, SubmissionOutcomeUnknownReason, TickFromPriceOptions, TickInput, TypedDataPayload, V2WriteMethod };
|
|
4343
|
+
export type { AddLiquidityInput, ConfirmationState, CreatePoolInput, EntryParse, GSwapErrorCode, GSwapErrorParams, InvalidEntry, InvalidEntryHandler, PoolPositionInput, RemoveLiquidityInput, RequestTradeInput, SubmissionOutcomeUnknownReason, TickFromPriceOptions, TickInput, V2WriteMethod };
|
|
5509
4344
|
//# sourceMappingURL=index.d.cts.map
|