@nktkas/hyperliquid 0.24.3 → 0.25.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -18
- package/esm/mod.d.ts +11 -11
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/src/clients/exchange.d.ts +29 -18
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +50 -48
- package/esm/src/clients/info.d.ts +17 -19
- package/esm/src/clients/info.d.ts.map +1 -1
- package/esm/src/clients/info.js +236 -73
- package/esm/src/clients/multiSign.d.ts +11 -7
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/subscription.d.ts +9 -9
- package/esm/src/clients/subscription.d.ts.map +1 -1
- package/esm/src/clients/subscription.js +28 -27
- package/esm/src/{base.d.ts → errors.d.ts} +1 -1
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/schemas/_base.d.ts +10 -0
- package/esm/src/schemas/_base.d.ts.map +1 -0
- package/esm/src/schemas/_base.js +12 -0
- package/esm/src/schemas/exchange/requests.d.ts +8953 -0
- package/esm/src/schemas/exchange/requests.d.ts.map +1 -0
- package/esm/src/schemas/exchange/requests.js +1413 -0
- package/esm/src/schemas/exchange/responses.d.ts +567 -0
- package/esm/src/schemas/exchange/responses.d.ts.map +1 -0
- package/esm/src/schemas/exchange/responses.js +243 -0
- package/esm/src/schemas/explorer/requests.d.ts +44 -0
- package/esm/src/schemas/explorer/requests.d.ts.map +1 -0
- package/esm/src/schemas/explorer/requests.js +32 -0
- package/esm/src/schemas/explorer/responses.d.ts +360 -0
- package/esm/src/schemas/explorer/responses.d.ts.map +1 -0
- package/esm/src/schemas/explorer/responses.js +56 -0
- package/esm/src/schemas/info/accounts.d.ts +2159 -0
- package/esm/src/schemas/info/accounts.d.ts.map +1 -0
- package/esm/src/schemas/info/accounts.js +622 -0
- package/esm/src/schemas/info/assets.d.ts +945 -0
- package/esm/src/schemas/info/assets.d.ts.map +1 -0
- package/esm/src/schemas/info/assets.js +265 -0
- package/esm/src/schemas/info/markets.d.ts +138 -0
- package/esm/src/schemas/info/markets.d.ts.map +1 -0
- package/esm/src/schemas/info/markets.js +58 -0
- package/esm/src/schemas/info/orders.d.ts +957 -0
- package/esm/src/schemas/info/orders.d.ts.map +1 -0
- package/esm/src/schemas/info/orders.js +297 -0
- package/esm/src/schemas/info/requests.d.ts +882 -0
- package/esm/src/schemas/info/requests.d.ts.map +1 -0
- package/esm/src/schemas/info/requests.js +655 -0
- package/esm/src/schemas/info/validators.d.ts +305 -0
- package/esm/src/schemas/info/validators.d.ts.map +1 -0
- package/esm/src/schemas/info/validators.js +112 -0
- package/esm/src/schemas/info/vaults.d.ts +447 -0
- package/esm/src/schemas/info/vaults.d.ts.map +1 -0
- package/esm/src/schemas/info/vaults.js +110 -0
- package/esm/src/schemas/mod.d.ts +100 -0
- package/esm/src/schemas/mod.d.ts.map +1 -0
- package/esm/src/schemas/mod.js +113 -0
- package/esm/src/schemas/subscriptions/requests.d.ts +332 -0
- package/esm/src/schemas/subscriptions/requests.d.ts.map +1 -0
- package/esm/src/schemas/subscriptions/requests.js +258 -0
- package/esm/src/schemas/subscriptions/responses.d.ts +3643 -0
- package/esm/src/schemas/subscriptions/responses.d.ts.map +1 -0
- package/esm/src/schemas/subscriptions/responses.js +233 -0
- package/esm/src/signing/mod.d.ts +109 -29
- package/esm/src/signing/mod.d.ts.map +1 -1
- package/esm/src/signing/mod.js +135 -29
- package/esm/src/transports/base.d.ts +2 -2
- package/esm/src/transports/base.d.ts.map +1 -1
- package/esm/src/transports/base.js +2 -2
- package/esm/src/transports/http/http_transport.d.ts +2 -1
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.d.ts +2 -1
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/package.json +6 -5
- package/script/mod.d.ts +11 -11
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -1
- package/script/src/clients/exchange.d.ts +29 -18
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +56 -54
- package/script/src/clients/info.d.ts +17 -19
- package/script/src/clients/info.d.ts.map +1 -1
- package/script/src/clients/info.js +236 -73
- package/script/src/clients/multiSign.d.ts +11 -7
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/subscription.d.ts +9 -9
- package/script/src/clients/subscription.d.ts.map +1 -1
- package/script/src/clients/subscription.js +28 -27
- package/script/src/{base.d.ts → errors.d.ts} +1 -1
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/schemas/_base.d.ts +10 -0
- package/script/src/schemas/_base.d.ts.map +1 -0
- package/script/src/schemas/_base.js +48 -0
- package/script/src/schemas/exchange/requests.d.ts +8953 -0
- package/script/src/schemas/exchange/requests.d.ts.map +1 -0
- package/script/src/schemas/exchange/requests.js +1449 -0
- package/script/src/schemas/exchange/responses.d.ts +567 -0
- package/script/src/schemas/exchange/responses.d.ts.map +1 -0
- package/script/src/schemas/exchange/responses.js +279 -0
- package/script/src/schemas/explorer/requests.d.ts +44 -0
- package/script/src/schemas/explorer/requests.d.ts.map +1 -0
- package/script/src/schemas/explorer/requests.js +68 -0
- package/script/src/schemas/explorer/responses.d.ts +360 -0
- package/script/src/schemas/explorer/responses.d.ts.map +1 -0
- package/script/src/schemas/explorer/responses.js +92 -0
- package/script/src/schemas/info/accounts.d.ts +2159 -0
- package/script/src/schemas/info/accounts.d.ts.map +1 -0
- package/script/src/schemas/info/accounts.js +658 -0
- package/script/src/schemas/info/assets.d.ts +945 -0
- package/script/src/schemas/info/assets.d.ts.map +1 -0
- package/script/src/schemas/info/assets.js +301 -0
- package/script/src/schemas/info/markets.d.ts +138 -0
- package/script/src/schemas/info/markets.d.ts.map +1 -0
- package/script/src/schemas/info/markets.js +94 -0
- package/script/src/schemas/info/orders.d.ts +957 -0
- package/script/src/schemas/info/orders.d.ts.map +1 -0
- package/script/src/schemas/info/orders.js +333 -0
- package/script/src/schemas/info/requests.d.ts +882 -0
- package/script/src/schemas/info/requests.d.ts.map +1 -0
- package/script/src/schemas/info/requests.js +692 -0
- package/script/src/schemas/info/validators.d.ts +305 -0
- package/script/src/schemas/info/validators.d.ts.map +1 -0
- package/script/src/schemas/info/validators.js +148 -0
- package/script/src/schemas/info/vaults.d.ts +447 -0
- package/script/src/schemas/info/vaults.d.ts.map +1 -0
- package/script/src/schemas/info/vaults.js +146 -0
- package/script/src/schemas/mod.d.ts +100 -0
- package/script/src/schemas/mod.d.ts.map +1 -0
- package/script/src/schemas/mod.js +154 -0
- package/script/src/schemas/subscriptions/requests.d.ts +332 -0
- package/script/src/schemas/subscriptions/requests.d.ts.map +1 -0
- package/script/src/schemas/subscriptions/requests.js +294 -0
- package/script/src/schemas/subscriptions/responses.d.ts +3643 -0
- package/script/src/schemas/subscriptions/responses.d.ts.map +1 -0
- package/script/src/schemas/subscriptions/responses.js +269 -0
- package/script/src/signing/mod.d.ts +109 -29
- package/script/src/signing/mod.d.ts.map +1 -1
- package/script/src/signing/mod.js +137 -33
- package/script/src/transports/base.d.ts +2 -2
- package/script/src/transports/base.d.ts.map +1 -1
- package/script/src/transports/base.js +3 -3
- package/script/src/transports/http/http_transport.d.ts +2 -1
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.d.ts +2 -1
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/base.d.ts.map +0 -1
- package/esm/src/signing/_sorter.d.ts +0 -127
- package/esm/src/signing/_sorter.d.ts.map +0 -1
- package/esm/src/signing/_sorter.js +0 -693
- package/esm/src/types/exchange/requests.d.ts +0 -1345
- package/esm/src/types/exchange/requests.d.ts.map +0 -1
- package/esm/src/types/exchange/requests.js +0 -1
- package/esm/src/types/exchange/responses.d.ts +0 -233
- package/esm/src/types/exchange/responses.d.ts.map +0 -1
- package/esm/src/types/exchange/responses.js +0 -1
- package/esm/src/types/explorer/requests.d.ts +0 -32
- package/esm/src/types/explorer/requests.d.ts.map +0 -1
- package/esm/src/types/explorer/requests.js +0 -1
- package/esm/src/types/explorer/responses.d.ts +0 -58
- package/esm/src/types/explorer/responses.d.ts.map +0 -1
- package/esm/src/types/explorer/responses.js +0 -1
- package/esm/src/types/info/accounts.d.ts +0 -864
- package/esm/src/types/info/accounts.d.ts.map +0 -1
- package/esm/src/types/info/accounts.js +0 -1
- package/esm/src/types/info/assets.d.ts +0 -354
- package/esm/src/types/info/assets.d.ts.map +0 -1
- package/esm/src/types/info/assets.js +0 -1
- package/esm/src/types/info/markets.d.ts +0 -79
- package/esm/src/types/info/markets.d.ts.map +0 -1
- package/esm/src/types/info/markets.js +0 -1
- package/esm/src/types/info/orders.d.ts +0 -266
- package/esm/src/types/info/orders.d.ts.map +0 -1
- package/esm/src/types/info/orders.js +0 -1
- package/esm/src/types/info/requests.d.ts +0 -640
- package/esm/src/types/info/requests.d.ts.map +0 -1
- package/esm/src/types/info/requests.js +0 -1
- package/esm/src/types/info/validators.d.ts +0 -147
- package/esm/src/types/info/validators.d.ts.map +0 -1
- package/esm/src/types/info/validators.js +0 -1
- package/esm/src/types/info/vaults.d.ts +0 -119
- package/esm/src/types/info/vaults.d.ts.map +0 -1
- package/esm/src/types/info/vaults.js +0 -1
- package/esm/src/types/mod.d.ts +0 -38
- package/esm/src/types/mod.d.ts.map +0 -1
- package/esm/src/types/mod.js +0 -24
- package/esm/src/types/subscriptions/requests.d.ts +0 -154
- package/esm/src/types/subscriptions/requests.d.ts.map +0 -1
- package/esm/src/types/subscriptions/requests.js +0 -1
- package/esm/src/types/subscriptions/responses.d.ts +0 -238
- package/esm/src/types/subscriptions/responses.d.ts.map +0 -1
- package/esm/src/types/subscriptions/responses.js +0 -1
- package/script/src/base.d.ts.map +0 -1
- package/script/src/signing/_sorter.d.ts +0 -127
- package/script/src/signing/_sorter.d.ts.map +0 -1
- package/script/src/signing/_sorter.js +0 -696
- package/script/src/types/exchange/requests.d.ts +0 -1345
- package/script/src/types/exchange/requests.d.ts.map +0 -1
- package/script/src/types/exchange/requests.js +0 -2
- package/script/src/types/exchange/responses.d.ts +0 -233
- package/script/src/types/exchange/responses.d.ts.map +0 -1
- package/script/src/types/exchange/responses.js +0 -2
- package/script/src/types/explorer/requests.d.ts +0 -32
- package/script/src/types/explorer/requests.d.ts.map +0 -1
- package/script/src/types/explorer/requests.js +0 -2
- package/script/src/types/explorer/responses.d.ts +0 -58
- package/script/src/types/explorer/responses.d.ts.map +0 -1
- package/script/src/types/explorer/responses.js +0 -2
- package/script/src/types/info/accounts.d.ts +0 -864
- package/script/src/types/info/accounts.d.ts.map +0 -1
- package/script/src/types/info/accounts.js +0 -2
- package/script/src/types/info/assets.d.ts +0 -354
- package/script/src/types/info/assets.d.ts.map +0 -1
- package/script/src/types/info/assets.js +0 -2
- package/script/src/types/info/markets.d.ts +0 -79
- package/script/src/types/info/markets.d.ts.map +0 -1
- package/script/src/types/info/markets.js +0 -2
- package/script/src/types/info/orders.d.ts +0 -266
- package/script/src/types/info/orders.d.ts.map +0 -1
- package/script/src/types/info/orders.js +0 -2
- package/script/src/types/info/requests.d.ts +0 -640
- package/script/src/types/info/requests.d.ts.map +0 -1
- package/script/src/types/info/requests.js +0 -2
- package/script/src/types/info/validators.d.ts +0 -147
- package/script/src/types/info/validators.d.ts.map +0 -1
- package/script/src/types/info/validators.js +0 -2
- package/script/src/types/info/vaults.d.ts +0 -119
- package/script/src/types/info/vaults.d.ts.map +0 -1
- package/script/src/types/info/vaults.js +0 -2
- package/script/src/types/mod.d.ts +0 -38
- package/script/src/types/mod.d.ts.map +0 -1
- package/script/src/types/mod.js +0 -25
- package/script/src/types/subscriptions/requests.d.ts +0 -154
- package/script/src/types/subscriptions/requests.d.ts.map +0 -1
- package/script/src/types/subscriptions/requests.js +0 -2
- package/script/src/types/subscriptions/responses.d.ts +0 -238
- package/script/src/types/subscriptions/responses.d.ts.map +0 -1
- package/script/src/types/subscriptions/responses.js +0 -2
- /package/esm/src/{base.js → errors.js} +0 -0
- /package/script/src/{base.js → errors.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { IRequestTransport } from "../transports/base.js";
|
|
2
|
-
import type { CancelSuccessResponse, CreateSubAccountResponse, CreateVaultResponse,
|
|
2
|
+
import type { CancelSuccessResponse, CreateSubAccountResponse, CreateVaultResponse, MultiSigRequest, OrderSuccessResponse, SuccessResponse, TwapCancelSuccessResponse, TwapOrderSuccessResponse } from "../schemas/mod.js";
|
|
3
3
|
import { ExchangeClient, type ExchangeClientParameters } from "./exchange.js";
|
|
4
|
-
import { type AbstractWallet,
|
|
4
|
+
import { type AbstractWallet, userSignedActionEip712Types } from "../signing/mod.js";
|
|
5
5
|
/** Parameters for the {@linkcode MultiSignClient} constructor. */
|
|
6
6
|
export interface MultiSignClientParameters<T extends IRequestTransport = IRequestTransport, S extends readonly AbstractWallet[] = AbstractWallet[]> extends Omit<ExchangeClientParameters<T, S[0]>, "wallet"> {
|
|
7
7
|
/** The multi-signature account address. */
|
|
8
|
-
multiSignAddress:
|
|
8
|
+
multiSignAddress: `0x${string}`;
|
|
9
9
|
/** Array of wallets used for multi-signature operations. The first wallet acts as the leader. */
|
|
10
10
|
signers: S;
|
|
11
11
|
}
|
|
@@ -15,7 +15,7 @@ export interface MultiSignClientParameters<T extends IRequestTransport = IReques
|
|
|
15
15
|
* @typeParam S Array of wallets where the first wallet acts as the leader.
|
|
16
16
|
*/
|
|
17
17
|
export declare class MultiSignClient<T extends IRequestTransport = IRequestTransport, S extends readonly AbstractWallet[] = AbstractWallet[]> extends ExchangeClient<T, S[0]> implements MultiSignClientParameters<T, S> {
|
|
18
|
-
multiSignAddress:
|
|
18
|
+
multiSignAddress: `0x${string}`;
|
|
19
19
|
signers: S;
|
|
20
20
|
/**
|
|
21
21
|
* @multisign Is the first wallet from {@linkcode signers}. Changing the property also changes the first element in the {@linkcode signers} array.
|
|
@@ -40,12 +40,16 @@ export declare class MultiSignClient<T extends IRequestTransport = IRequestTrans
|
|
|
40
40
|
*/
|
|
41
41
|
constructor(args: MultiSignClientParameters<T, S>);
|
|
42
42
|
protected _executeL1Action<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
|
|
43
|
-
action:
|
|
44
|
-
|
|
43
|
+
action: Exclude<MultiSigRequest["action"]["payload"]["action"], {
|
|
44
|
+
type: keyof typeof userSignedActionEip712Types;
|
|
45
|
+
}>;
|
|
46
|
+
vaultAddress?: `0x${string}`;
|
|
45
47
|
expiresAfter: number | undefined;
|
|
46
48
|
}, signal?: AbortSignal): Promise<T>;
|
|
47
49
|
protected _executeUserSignedAction<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
|
|
48
|
-
action:
|
|
50
|
+
action: Extract<MultiSigRequest["action"]["payload"]["action"], {
|
|
51
|
+
type: keyof typeof userSignedActionEip712Types;
|
|
52
|
+
}>;
|
|
49
53
|
}, signal?: AbortSignal): Promise<T>;
|
|
50
54
|
}
|
|
51
55
|
//# sourceMappingURL=multiSign.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiSign.d.ts","sourceRoot":"","sources":["../../../src/src/clients/multiSign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EACR,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"multiSign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B,gBAAgB,CACrC,CAAC,SACK,eAAe,GACf,qBAAqB,GACrB,wBAAwB,GACxB,mBAAmB,GACnB,oBAAoB,GACpB,wBAAwB,GACxB,yBAAyB,EAE/B,OAAO,EAAE;QACL,MAAM,EAAE,OAAO,CACX,eAAe,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EAC9C;YAAE,IAAI,EAAE,MAAM,OAAO,2BAA2B,CAAA;SAAE,CACrD,CAAC;QACF,YAAY,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;QAC7B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;KACpC,EACD,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,CAAC,CAAC;cAgCY,wBAAwB,CAC7C,CAAC,SACK,eAAe,GACf,qBAAqB,GACrB,wBAAwB,GACxB,mBAAmB,GACnB,oBAAoB,GACpB,wBAAwB,GACxB,yBAAyB,EAE/B,OAAO,EAAE;QACL,MAAM,EAAE,OAAO,CACX,eAAe,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EAC9C;YAAE,IAAI,EAAE,MAAM,OAAO,2BAA2B,CAAA;SAAE,CACrD,CAAC;KACL,EACD,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,CAAC,CAAC;CAgChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ISubscriptionTransport, Subscription } from "../transports/base.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ActiveAssetData, type Book, type Candle, type OrderStatus, type TxDetails, type WsActiveAssetCtx, WsActiveAssetCtxRequest, WsActiveAssetDataRequest, type WsActiveSpotAssetCtx, type WsAllMids, WsAllMidsRequest, type WsAssetCtxs, WsAssetCtxsRequest, type WsBbo, WsBboRequest, type WsBlockDetails, WsCandleRequest, type WsClearinghouseState, WsClearinghouseStateRequest, WsL2BookRequest, type WsNotification, WsNotificationRequest, type WsOpenOrders, WsOpenOrdersRequest, WsOrderUpdatesRequest, type WsTrade, WsTradesRequest, type WsUserEvent, WsUserEventsRequest, type WsUserFills, WsUserFillsRequest, type WsUserFundings, WsUserFundingsRequest, type WsUserNonFundingLedgerUpdates, WsUserNonFundingLedgerUpdatesRequest, type WsUserTwapHistory, WsUserTwapHistoryRequest, type WsUserTwapSliceFills, WsUserTwapSliceFillsRequest, type WsWebData2, WsWebData2Request } from "../schemas/mod.js";
|
|
3
3
|
/** @see https://github.com/microsoft/TypeScript/issues/13923#issuecomment-2191862501 */
|
|
4
4
|
type DeepImmutable<T> = {
|
|
5
5
|
readonly [K in keyof T]: DeepImmutable<T[K]>;
|
|
@@ -12,9 +12,9 @@ export interface SubscriptionClientParameters<T extends ISubscriptionTransport =
|
|
|
12
12
|
/** Subscription parameters for the {@linkcode SubscriptionClient.activeAssetCtx} method. */
|
|
13
13
|
export type WsActiveAssetCtxParameters = Omit<WsActiveAssetCtxRequest, "type">;
|
|
14
14
|
/** Subscription parameters for the {@linkcode SubscriptionClient.activeAssetData} method. */
|
|
15
|
-
export type WsActiveAssetDataParameters = Omit<
|
|
15
|
+
export type WsActiveAssetDataParameters = Omit<WsActiveAssetDataRequest, "type">;
|
|
16
16
|
/** Subscription parameters for the {@linkcode SubscriptionClient.allMids} method. */
|
|
17
|
-
export type WsAllMidsParameters = Omit<
|
|
17
|
+
export type WsAllMidsParameters = Omit<WsAllMidsRequest, "type">;
|
|
18
18
|
/** Subscription parameters for the {@linkcode SubscriptionClient.assetCtxs} method. */
|
|
19
19
|
export type WsAssetCtxsParameters = Omit<WsAssetCtxsRequest, "type">;
|
|
20
20
|
/** Subscription parameters for the {@linkcode SubscriptionClient.bbo} method. */
|
|
@@ -22,13 +22,13 @@ export type WsBboParameters = Omit<WsBboRequest, "type">;
|
|
|
22
22
|
/** Subscription parameters for the {@linkcode SubscriptionClient.candle} method. */
|
|
23
23
|
export type WsCandleParameters = Omit<WsCandleRequest, "type">;
|
|
24
24
|
/** Subscription parameters for the {@linkcode SubscriptionClient.clearinghouseState} method. */
|
|
25
|
-
export type WsClearinghouseStateParameters = Omit<
|
|
25
|
+
export type WsClearinghouseStateParameters = Omit<WsClearinghouseStateRequest, "type">;
|
|
26
26
|
/** Subscription parameters for the {@linkcode SubscriptionClient.l2Book} method. */
|
|
27
|
-
export type WsL2BookParameters = Omit<
|
|
27
|
+
export type WsL2BookParameters = Omit<WsL2BookRequest, "type">;
|
|
28
28
|
/** Subscription parameters for the {@linkcode SubscriptionClient.notification} method. */
|
|
29
29
|
export type WsNotificationParameters = Omit<WsNotificationRequest, "type">;
|
|
30
30
|
/** Subscription parameters for the {@linkcode SubscriptionClient.openOrders} method. */
|
|
31
|
-
export type WsOpenOrdersParameters = Omit<
|
|
31
|
+
export type WsOpenOrdersParameters = Omit<WsOpenOrdersRequest, "type">;
|
|
32
32
|
/** Subscription parameters for the {@linkcode SubscriptionClient.orderUpdates} method. */
|
|
33
33
|
export type WsOrderUpdatesParameters = Omit<WsOrderUpdatesRequest, "type">;
|
|
34
34
|
/** Subscription parameters for the {@linkcode SubscriptionClient.trades} method. */
|
|
@@ -36,7 +36,7 @@ export type WsTradesParameters = Omit<WsTradesRequest, "type">;
|
|
|
36
36
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userEvents} method. */
|
|
37
37
|
export type WsUserEventsParameters = Omit<WsUserEventsRequest, "type">;
|
|
38
38
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userFills} method. */
|
|
39
|
-
export type WsUserFillsParameters = Omit<
|
|
39
|
+
export type WsUserFillsParameters = Omit<WsUserFillsRequest, "type">;
|
|
40
40
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userFundings} method. */
|
|
41
41
|
export type WsUserFundingsParameters = Omit<WsUserFundingsRequest, "type">;
|
|
42
42
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userNonFundingLedgerUpdates} method. */
|
|
@@ -44,7 +44,7 @@ export type WsUserNonFundingLedgerUpdatesParameters = Omit<WsUserNonFundingLedge
|
|
|
44
44
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userTwapHistory} method. */
|
|
45
45
|
export type WsUserTwapHistoryParameters = Omit<WsUserTwapHistoryRequest, "type">;
|
|
46
46
|
/** Subscription parameters for the {@linkcode SubscriptionClient.userTwapSliceFills} method. */
|
|
47
|
-
export type WsUserTwapSliceFillsParameters = Omit<
|
|
47
|
+
export type WsUserTwapSliceFillsParameters = Omit<WsUserTwapSliceFillsRequest, "type">;
|
|
48
48
|
/** Subscription parameters for the {@linkcode SubscriptionClient.webData2} method. */
|
|
49
49
|
export type WsWebData2Parameters = Omit<WsWebData2Request, "type">;
|
|
50
50
|
/**
|
|
@@ -353,7 +353,7 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
|
|
|
353
353
|
* });
|
|
354
354
|
* ```
|
|
355
355
|
*/
|
|
356
|
-
orderUpdates(params: DeepImmutable<WsOrderUpdatesParameters>, listener: (data: OrderStatus
|
|
356
|
+
orderUpdates(params: DeepImmutable<WsOrderUpdatesParameters>, listener: (data: OrderStatus[]) => void): Promise<Subscription>;
|
|
357
357
|
/**
|
|
358
358
|
* Subscribe to real-time trade updates for a specific asset.
|
|
359
359
|
* @param params - Subscription-specific parameters.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/src/clients/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/src/clients/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,WAAW,EAEhB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,uBAAuB,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AAO,CAAC,YAAY,CAAC;IAYxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAAe,CACX,MAAM,EAAE,aAAa,CAAC,2BAA2B,CAAC,EAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,GAC5C,OAAO,CAAC,YAAY,CAAC;IASxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,kBAAkB,CACd,MAAM,EAAE,aAAa,CAAC,8BAA8B,CAAC,EACrD,QAAQ,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,GAC/C,OAAO,CAAC,YAAY,CAAC;IASxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CACJ,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAC3C,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GACrC,OAAO,CAAC,YAAY,CAAC;IASlB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubscriptionClient = void 0;
|
|
4
|
+
const mod_js_1 = require("../schemas/mod.js");
|
|
4
5
|
/**
|
|
5
6
|
* Subscription client for subscribing to various Hyperliquid events.
|
|
6
7
|
* @typeParam T The type of transport used to connect to the Hyperliquid Websocket API.
|
|
@@ -44,8 +45,8 @@ class SubscriptionClient {
|
|
|
44
45
|
* ```
|
|
45
46
|
*/
|
|
46
47
|
activeAssetCtx(params, listener) {
|
|
48
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsActiveAssetCtxRequest)({ type: "activeAssetCtx", ...params });
|
|
47
49
|
const channel = params.coin.startsWith("@") ? "activeSpotAssetCtx" : "activeAssetCtx";
|
|
48
|
-
const payload = { type: "activeAssetCtx", ...params };
|
|
49
50
|
return this.transport.subscribe(channel, payload, (e) => {
|
|
50
51
|
if (e.detail.coin === payload.coin) {
|
|
51
52
|
listener(e.detail);
|
|
@@ -74,7 +75,7 @@ class SubscriptionClient {
|
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
77
|
activeAssetData(params, listener) {
|
|
77
|
-
const payload = { type: "activeAssetData", ...params };
|
|
78
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsActiveAssetDataRequest)({ type: "activeAssetData", ...params });
|
|
78
79
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
79
80
|
if (e.detail.coin === payload.coin && e.detail.user === payload.user.toLowerCase()) {
|
|
80
81
|
listener(e.detail);
|
|
@@ -84,7 +85,7 @@ class SubscriptionClient {
|
|
|
84
85
|
allMids(params_or_listener, maybeListener) {
|
|
85
86
|
const params = typeof params_or_listener === "function" ? {} : params_or_listener;
|
|
86
87
|
const listener = typeof params_or_listener === "function" ? params_or_listener : maybeListener;
|
|
87
|
-
const payload = { type: "allMids", ...params };
|
|
88
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsAllMidsRequest)({ type: "allMids", ...params });
|
|
88
89
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
89
90
|
listener(e.detail);
|
|
90
91
|
});
|
|
@@ -92,11 +93,11 @@ class SubscriptionClient {
|
|
|
92
93
|
assetCtxs(params_or_listener, maybeListener) {
|
|
93
94
|
const params = typeof params_or_listener === "function" ? {} : params_or_listener;
|
|
94
95
|
const listener = typeof params_or_listener === "function" ? params_or_listener : maybeListener;
|
|
95
|
-
const payload = {
|
|
96
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsAssetCtxsRequest)({
|
|
96
97
|
type: "assetCtxs",
|
|
97
98
|
...params,
|
|
98
99
|
dex: params.dex ?? "",
|
|
99
|
-
};
|
|
100
|
+
});
|
|
100
101
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
101
102
|
if (e.detail.dex === payload.dex) {
|
|
102
103
|
listener(e.detail);
|
|
@@ -125,7 +126,7 @@ class SubscriptionClient {
|
|
|
125
126
|
* ```
|
|
126
127
|
*/
|
|
127
128
|
bbo(params, listener) {
|
|
128
|
-
const payload = { type: "bbo", ...params };
|
|
129
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsBboRequest)({ type: "bbo", ...params });
|
|
129
130
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
130
131
|
if (e.detail.coin === payload.coin) {
|
|
131
132
|
listener(e.detail);
|
|
@@ -154,7 +155,7 @@ class SubscriptionClient {
|
|
|
154
155
|
* ```
|
|
155
156
|
*/
|
|
156
157
|
candle(params, listener) {
|
|
157
|
-
const payload = { type: "candle", ...params };
|
|
158
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsCandleRequest)({ type: "candle", ...params });
|
|
158
159
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
159
160
|
if (e.detail.s === payload.coin && e.detail.i === payload.interval) {
|
|
160
161
|
listener(e.detail);
|
|
@@ -183,11 +184,11 @@ class SubscriptionClient {
|
|
|
183
184
|
* ```
|
|
184
185
|
*/
|
|
185
186
|
clearinghouseState(params, listener) {
|
|
186
|
-
const payload = {
|
|
187
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsClearinghouseStateRequest)({
|
|
187
188
|
type: "clearinghouseState",
|
|
188
189
|
...params,
|
|
189
190
|
dex: params.dex ?? "",
|
|
190
|
-
};
|
|
191
|
+
});
|
|
191
192
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
192
193
|
if (e.detail.user === payload.user.toLowerCase() && e.detail.dex === payload.dex) {
|
|
193
194
|
listener(e.detail);
|
|
@@ -216,7 +217,7 @@ class SubscriptionClient {
|
|
|
216
217
|
* ```
|
|
217
218
|
*/
|
|
218
219
|
explorerBlock(listener) {
|
|
219
|
-
const payload = { type: "explorerBlock" };
|
|
220
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsExplorerBlockRequest)({ type: "explorerBlock" });
|
|
220
221
|
return this.transport.subscribe("_explorerBlock", payload, (e) => {
|
|
221
222
|
listener(e.detail);
|
|
222
223
|
});
|
|
@@ -243,7 +244,7 @@ class SubscriptionClient {
|
|
|
243
244
|
* ```
|
|
244
245
|
*/
|
|
245
246
|
explorerTxs(listener) {
|
|
246
|
-
const payload = { type: "explorerTxs" };
|
|
247
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsExplorerTxsRequest)({ type: "explorerTxs" });
|
|
247
248
|
return this.transport.subscribe("_explorerTxs", payload, (e) => {
|
|
248
249
|
listener(e.detail);
|
|
249
250
|
});
|
|
@@ -270,12 +271,12 @@ class SubscriptionClient {
|
|
|
270
271
|
* ```
|
|
271
272
|
*/
|
|
272
273
|
l2Book(params, listener) {
|
|
273
|
-
const payload = {
|
|
274
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsL2BookRequest)({
|
|
274
275
|
type: "l2Book",
|
|
275
276
|
...params,
|
|
276
277
|
nSigFigs: params.nSigFigs ?? null,
|
|
277
278
|
mantissa: params.mantissa ?? null,
|
|
278
|
-
};
|
|
279
|
+
});
|
|
279
280
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
280
281
|
if (e.detail.coin === payload.coin) {
|
|
281
282
|
listener(e.detail);
|
|
@@ -304,7 +305,7 @@ class SubscriptionClient {
|
|
|
304
305
|
* ```
|
|
305
306
|
*/
|
|
306
307
|
notification(params, listener) {
|
|
307
|
-
const payload = { type: "notification", ...params };
|
|
308
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsNotificationRequest)({ type: "notification", ...params });
|
|
308
309
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
309
310
|
listener(e.detail);
|
|
310
311
|
});
|
|
@@ -331,11 +332,11 @@ class SubscriptionClient {
|
|
|
331
332
|
* ```
|
|
332
333
|
*/
|
|
333
334
|
openOrders(params, listener) {
|
|
334
|
-
const payload = {
|
|
335
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsOpenOrdersRequest)({
|
|
335
336
|
type: "openOrders",
|
|
336
337
|
...params,
|
|
337
338
|
dex: params.dex ?? "",
|
|
338
|
-
};
|
|
339
|
+
});
|
|
339
340
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
340
341
|
if (e.detail.user === payload.user.toLowerCase() && e.detail.dex === payload.dex) {
|
|
341
342
|
listener(e.detail);
|
|
@@ -364,7 +365,7 @@ class SubscriptionClient {
|
|
|
364
365
|
* ```
|
|
365
366
|
*/
|
|
366
367
|
orderUpdates(params, listener) {
|
|
367
|
-
const payload = { type: "orderUpdates", ...params };
|
|
368
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsOrderUpdatesRequest)({ type: "orderUpdates", ...params });
|
|
368
369
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
369
370
|
listener(e.detail);
|
|
370
371
|
});
|
|
@@ -391,7 +392,7 @@ class SubscriptionClient {
|
|
|
391
392
|
* ```
|
|
392
393
|
*/
|
|
393
394
|
trades(params, listener) {
|
|
394
|
-
const payload = { type: "trades", ...params };
|
|
395
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsTradesRequest)({ type: "trades", ...params });
|
|
395
396
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
396
397
|
if (e.detail[0]?.coin === payload.coin) {
|
|
397
398
|
listener(e.detail);
|
|
@@ -421,7 +422,7 @@ class SubscriptionClient {
|
|
|
421
422
|
* ```
|
|
422
423
|
*/
|
|
423
424
|
userEvents(params, listener) {
|
|
424
|
-
const payload = { type: "userEvents", ...params };
|
|
425
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsUserEventsRequest)({ type: "userEvents", ...params });
|
|
425
426
|
return this.transport.subscribe("user", payload, (e) => {
|
|
426
427
|
listener(e.detail);
|
|
427
428
|
});
|
|
@@ -448,11 +449,11 @@ class SubscriptionClient {
|
|
|
448
449
|
* ```
|
|
449
450
|
*/
|
|
450
451
|
userFills(params, listener) {
|
|
451
|
-
const payload = {
|
|
452
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsUserFillsRequest)({
|
|
452
453
|
type: "userFills",
|
|
453
454
|
...params,
|
|
454
455
|
aggregateByTime: params.aggregateByTime ?? false,
|
|
455
|
-
};
|
|
456
|
+
});
|
|
456
457
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
457
458
|
if (e.detail.user === payload.user.toLowerCase()) {
|
|
458
459
|
listener(e.detail);
|
|
@@ -481,7 +482,7 @@ class SubscriptionClient {
|
|
|
481
482
|
* ```
|
|
482
483
|
*/
|
|
483
484
|
userFundings(params, listener) {
|
|
484
|
-
const payload = { type: "userFundings", ...params };
|
|
485
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsUserFundingsRequest)({ type: "userFundings", ...params });
|
|
485
486
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
486
487
|
if (e.detail.user === payload.user.toLowerCase()) {
|
|
487
488
|
listener(e.detail);
|
|
@@ -510,10 +511,10 @@ class SubscriptionClient {
|
|
|
510
511
|
* ```
|
|
511
512
|
*/
|
|
512
513
|
userNonFundingLedgerUpdates(params, listener) {
|
|
513
|
-
const payload = {
|
|
514
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsUserNonFundingLedgerUpdatesRequest)({
|
|
514
515
|
type: "userNonFundingLedgerUpdates",
|
|
515
516
|
...params,
|
|
516
|
-
};
|
|
517
|
+
});
|
|
517
518
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
518
519
|
if (e.detail.user === payload.user.toLowerCase()) {
|
|
519
520
|
listener(e.detail);
|
|
@@ -542,7 +543,7 @@ class SubscriptionClient {
|
|
|
542
543
|
* ```
|
|
543
544
|
*/
|
|
544
545
|
userTwapHistory(params, listener) {
|
|
545
|
-
const payload = { type: "userTwapHistory", ...params };
|
|
546
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsUserTwapHistoryRequest)({ type: "userTwapHistory", ...params });
|
|
546
547
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
547
548
|
if (e.detail.user === payload.user.toLowerCase()) {
|
|
548
549
|
listener(e.detail);
|
|
@@ -571,7 +572,7 @@ class SubscriptionClient {
|
|
|
571
572
|
* ```
|
|
572
573
|
*/
|
|
573
574
|
userTwapSliceFills(params, listener) {
|
|
574
|
-
const payload = { type: "userTwapSliceFills", ...params };
|
|
575
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsUserTwapSliceFillsRequest)({ type: "userTwapSliceFills", ...params });
|
|
575
576
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
576
577
|
if (e.detail.user === payload.user.toLowerCase()) {
|
|
577
578
|
listener(e.detail);
|
|
@@ -600,7 +601,7 @@ class SubscriptionClient {
|
|
|
600
601
|
* ```
|
|
601
602
|
*/
|
|
602
603
|
webData2(params, listener) {
|
|
603
|
-
const payload = { type: "webData2", ...params };
|
|
604
|
+
const payload = (0, mod_js_1.parser)(mod_js_1.WsWebData2Request)({ type: "webData2", ...params });
|
|
604
605
|
return this.transport.subscribe(payload.type, payload, (e) => {
|
|
605
606
|
if (e.detail.user === payload.user.toLowerCase()) {
|
|
606
607
|
listener(e.detail);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/src/errors.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,qBAAa,gBAAiB,SAAQ,KAAK;gBAC3B,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIvD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const UnsignedDecimal: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, string>]>;
|
|
3
|
+
export type UnsignedDecimal = v.InferOutput<typeof UnsignedDecimal>;
|
|
4
|
+
export declare const SignedDecimal: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, string>]>;
|
|
5
|
+
export type SignedDecimal = v.InferOutput<typeof SignedDecimal>;
|
|
6
|
+
export declare const Hex: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, `0x${string}`>]>;
|
|
7
|
+
export type Hex = v.InferOutput<typeof Hex>;
|
|
8
|
+
export declare const TokenId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.TransformAction<string, `${string}:0x${string}`>]>;
|
|
9
|
+
export type TokenId = v.InferOutput<typeof TokenId>;
|
|
10
|
+
//# sourceMappingURL=_base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_base.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/_base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,eAAe,6HAI3B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,eAAe,CAAC,CAAC;AAEpE,eAAO,MAAM,aAAa,6HAIzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC;AAEhE,eAAO,MAAM,GAAG,oIAIf,CAAC;AACF,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,GAAG,CAAC,CAAC;AAE5C,eAAO,MAAM,OAAO,8IAInB,CAAC;AACF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TokenId = exports.Hex = exports.SignedDecimal = exports.UnsignedDecimal = void 0;
|
|
37
|
+
const v = __importStar(require("valibot"));
|
|
38
|
+
exports.UnsignedDecimal = v.pipe(v.string(), v.regex(/^[0-9]+(\.[0-9]+)?$/), v.transform((value) => formatDecimal(value)));
|
|
39
|
+
exports.SignedDecimal = v.pipe(v.string(), v.regex(/^-?[0-9]+(\.[0-9]+)?$/), v.transform((value) => formatDecimal(value)));
|
|
40
|
+
exports.Hex = v.pipe(v.string(), v.regex(/^0[xX][0-9a-fA-F]+$/), v.transform((value) => value.toLowerCase()));
|
|
41
|
+
exports.TokenId = v.pipe(v.string(), v.regex(/^[^:]+:0x[0-9a-fA-F]+$/), v.transform((value) => value));
|
|
42
|
+
/** Removes leading/trailing zeros from decimal string without precision loss. */
|
|
43
|
+
function formatDecimal(numStr) {
|
|
44
|
+
return numStr
|
|
45
|
+
.replace(/^(-?)0+(?=\d)/, "$1") // Remove leading zeros, keep sign
|
|
46
|
+
.replace(/(\.\d*?)0+$/, "$1") // Remove trailing zeros after decimal
|
|
47
|
+
.replace(/\.$/, ""); // Remove lone decimal point
|
|
48
|
+
}
|