@polymarket/client 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.d.ts +4 -4
- package/dist/actions/index.js +1 -1
- package/dist/chunk-HWJ7BEKG.js +2 -0
- package/dist/chunk-HWJ7BEKG.js.map +1 -0
- package/dist/chunk-IPPWXOOG.js +6 -0
- package/dist/chunk-IPPWXOOG.js.map +1 -0
- package/dist/chunk-WZQAMVAC.js +3 -0
- package/dist/chunk-WZQAMVAC.js.map +1 -0
- package/dist/ethers-v5.d.ts +1 -1
- package/dist/ethers-v5.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/node.js +1 -1
- package/dist/privy.js +1 -1
- package/dist/{sports-D5M6XUZP.d.ts → sports-C7mI-H0Z.d.ts} +1 -1
- package/dist/{types-BqK8Y3G5.d.ts → types-BE9qerqa.d.ts} +143 -10
- package/dist/viem.d.ts +1 -1
- package/dist/viem.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-DLZLJOGO.js +0 -6
- package/dist/chunk-DLZLJOGO.js.map +0 -1
- package/dist/chunk-LGU5PMHE.js +0 -3
- package/dist/chunk-LGU5PMHE.js.map +0 -1
- package/dist/chunk-ZH5ERGHG.js +0 -2
- package/dist/chunk-ZH5ERGHG.js.map +0 -1
package/dist/node.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {e}from'./chunk-
|
|
1
|
+
import {e}from'./chunk-HWJ7BEKG.js';import g from'process';import {invariant}from'@polymarket/types';async function u(t,e,r,i,n){let s=`${e}${r}${i}`;n!==void 0&&(s+=n);let y=await globalThis.crypto.subtle.importKey("raw",l(t),{name:"HMAC",hash:"SHA-256"},false,["sign"]),c=await globalThis.crypto.subtle.sign("HMAC",y,new TextEncoder().encode(s));return f(d(c))}function l(t){let e=t.replace(/-/g,"+").replace(/_/g,"/").replace(/[^A-Za-z0-9+/=]/g,""),r=atob(e),i=new Uint8Array(r.length);for(let n=0;n<r.length;n+=1)i[n]=r.charCodeAt(n);return i.buffer}function d(t){let e=new Uint8Array(t),r="";for(let i of e)r+=String.fromCharCode(i);return btoa(r)}function f(t){return t.replace(/\+/g,"-").replace(/\//g,"_")}invariant(g.release.name==="node","The @polymarket/client/node entrypoint requires a Node.js runtime.");invariant(typeof window>"u"&&typeof document>"u","The @polymarket/client/node entrypoint cannot be imported in a browser-like runtime.");function K(t){return new o(t)}var o=class{#e;constructor(e){this.#e=e;}get isBuilderKey(){return true}get supportGasless(){return true}async authorize(e){return this.#r(e)}async#r(e$1){try{let r=Math.floor(Date.now()/1e3);return {POLY_BUILDER_API_KEY:this.#e.key,POLY_BUILDER_PASSPHRASE:this.#e.passphrase,POLY_BUILDER_SIGNATURE:await u(this.#e.secret,r,e$1.method,e$1.path,e$1.body),POLY_BUILDER_TIMESTAMP:`${r}`}}catch(r){throw e.fromError(r,"Could not sign the builder-authenticated request")}}};
|
|
2
2
|
export{K as builderApiKey};//# sourceMappingURL=node.js.map
|
|
3
3
|
//# sourceMappingURL=node.js.map
|
package/dist/privy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {e as e$1,d,c,b as b$1,a}from'./chunk-
|
|
1
|
+
import {e as e$1,d,c,b as b$1,a}from'./chunk-HWJ7BEKG.js';import h from'process';import {invariant,expectEvmAddress,expectTxHash,expectEvmSignature,never}from'@polymarket/types';import {Hex}from'ox';import {createPublicClient,http,WaitForTransactionReceiptTimeoutError}from'viem';import {waitForTransactionReceipt}from'viem/actions';import*as E from'viem/chains';invariant(h.release.name==="node","The @polymarket/client/privy entrypoint requires a Node.js runtime.");invariant(typeof window>"u"&&typeof document>"u","The @polymarket/client/privy entrypoint cannot be imported in a browser-like runtime.");var P=Object.values(E);function D(r){return {getAddress(){return b(r)},signTypedData(t){return A(r,t)},signMessage(t){return H(r,t)},async sendTransaction(t){return new o(await I(r,t),t.chainId)}}}async function b(r){try{let t=await r.privy.wallets().get(r.walletId);return expectEvmAddress(t.address)}catch(t){throw e$1.fromError(t,"Could not resolve signer address")}}async function I(r,t){try{let n=await r.privy.wallets().ethereum().sendTransaction(r.walletId,{authorization_context:r.authorizationContext,caip2:`eip155:${t.chainId}`,params:{transaction:{chain_id:t.chainId,data:t.data,to:t.to,value:t.value?.toString()}}});return expectTxHash(n.hash)}catch(n){s(n);}}async function A(r,t){try{let n=await r.privy.wallets().ethereum().signTypedData(r.walletId,{authorization_context:r.authorizationContext,params:{typed_data:{domain:e(t.domain),message:e(t.message),primary_type:t.primaryType,types:t.types}}});return expectEvmSignature(n.signature)}catch(n){s(n);}}async function H(r,t){try{let n=await r.privy.wallets().ethereum().signMessage(r.walletId,{authorization_context:r.authorizationContext,message:Hex.toBytes(t)});return expectEvmSignature(n.signature)}catch(n){s(n);}}function e(r){return typeof r=="bigint"?`${r}`:Array.isArray(r)?r.map(t=>e(t)):typeof r=="object"&&r!==null?Object.fromEntries(Object.entries(r).flatMap(([t,n])=>n===void 0?[]:[[t,e(n)]])):r}function s(r){throw i(r)?new d("User rejected the signing request",{cause:r}):e$1.fromError(r)}function i(r,t=new Set){if(t.has(r)||r===null||typeof r!="object")return false;t.add(r);let n=r;return n.code===4001||n.code==="ACTION_REJECTED"||n.name==="APIUserAbortError"||i(n.error,t)||i(n.cause,t)}var o=class{transactionId=null;#r;#t;constructor(t,n){this.#r=n,this.#t=t;}get transactionHash(){return this.#t}async wait(){try{let t=await waitForTransactionReceipt(createPublicClient({chain:S(this.#r),transport:http()}),{hash:this.#t}),n=expectTxHash(t.transactionHash);if(this.#t=n,t.status==="reverted")throw new c(`Transaction ${n} reverted`);return {transactionHash:n,transactionId:null}}catch(t){throw t instanceof WaitForTransactionReceiptTimeoutError?new b$1(`Timed out waiting for transaction ${this.#t} to settle`,{cause:t}):a.fromError(t)}}};function S(r){let t=P.find(n=>n.id===r);if(t!==void 0)return t;never(`Unsupported chain ID for direct Privy transaction wait: ${r}`);}export{D as signerFrom};//# sourceMappingURL=privy.js.map
|
|
2
2
|
//# sourceMappingURL=privy.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrderResponse } from '@polymarket/bindings/clob';
|
|
2
|
-
import {
|
|
2
|
+
import { ci as RateLimitError, cq as RequestRejectedError, dk as SigningError, dw as TransportError, dz as UnexpectedResponseError, U as UserInputError, a$ as InsufficientLiquidityError, q as BaseSecureClient, g8 as PrepareLimitOrderRequest, fN as OrderWorkflow, fM as OrderPostingWorkflow, ga as PrepareMarketOrderRequest, y as CancelledSigningError, c5 as PostOrderError, dn as TimeoutError, ds as TransactionFailedError, dh as SignedOrder, B as BaseClient } from './types-BE9qerqa.js';
|
|
3
3
|
import { SportsMarketTypesResponse, SportsMetadata } from '@polymarket/bindings/gamma';
|
|
4
4
|
|
|
5
5
|
type PrepareMarketOrderError = InsufficientLiquidityError | RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError | UserInputError;
|
|
@@ -11,7 +11,7 @@ import { Activity, ComboActivity, Trade, ComboPositionStatus, PortfolioValue, Us
|
|
|
11
11
|
import * as _polymarket_bindings_combos from '@polymarket/bindings/combos';
|
|
12
12
|
import { ComboMarket, RfqRejectionCode, RfqQuoteId, RfqId, ComboAcceptFailureReason, BuilderRfqError, RfqQuoteRequest, RfqRequestedSize, RfqSide, RfqQuoteAck, RfqConfirmationRequest, RfqConfirmationAck as RfqConfirmationAck$1, RfqExecutionUpdate, RfqTrade, RfqQuoteCancelAck, ComboQuoteUnavailableReason, RfqStatus, RfqErrorCode, BuilderRfqStatusResponse, CollateralReturnPlanResponse } from '@polymarket/bindings/combos';
|
|
13
13
|
import { PerpsInstrument, PerpsTicker, PerpsBook, PerpsCandle, PerpsFundingRate, PerpsPublicTrade, PerpsFeeScheduleEntry, PerpsWithdrawalId, PerpsSortDirection, PerpsDepositStatus, PerpsWithdrawalStatus, PerpsPnlInterval, PerpsDecimalInput, PerpsTimeInForce, PerpsOrder, PerpsOrderId, PerpsCredentials, PerpsBalance, PerpsPortfolio, PerpsAccountStats, PerpsAccountConfig, PerpsAutoCancelStatus, PerpsAccountFill, PerpsAccountFundingPayment, PerpsDeposit, PerpsWithdrawal, PerpsEquityPoint, PerpsPnlPoint, PerpsNotificationEntry, PerpsPostOrderAck, PerpsCancelOrderResult, PerpsUpdateLeverageResult, PerpsInstrumentCategory, PerpsKlineInterval } from '@polymarket/bindings/perps';
|
|
14
|
-
import { PerpsSessionEvent, CommentsEvent, CryptoPricesTopic, CryptoPricesChainlinkTwapTopic, CryptoPricesChainlinkTwapWindowSeconds, EquityPricesTopic, EquityPricesEvent, MarketEvent, StandardMarketEvent, CryptoPricesChainlinkTwapThirtyEvent, CryptoPricesChainlinkTwapSixtyEvent, CryptoPricesChainlinkTwapEvent,
|
|
14
|
+
import { PerpsSessionEvent, CommentsEvent, CryptoPricesTopic, CryptoPricesChainlinkTwapTopic, CryptoPricesChainlinkTwapWindowSeconds, EquityPricesTopic, EquityPricesEvent, MarketEvent, StandardMarketEvent, CryptoPricesChainlinkTwapThirtyEvent, CryptoPricesChainlinkTwapSixtyEvent, CryptoPricesChainlinkTwapEvent, CryptoPriceEvent, CryptoTwapPriceEvent, EquityPriceEvent, CryptoPricesBinanceEvent, CryptoPricesChainlinkEvent, UserEvent, SportsEvent, PerpsTradeEvent, PerpsBboEvent, PerpsBookEvent, PerpsCandleEvent, PerpsTickerEvent, PerpsStatisticEvent, CryptoPricesEvent, PerpsMarketDataEvent } from '@polymarket/bindings/subscriptions';
|
|
15
15
|
import { Hex } from 'ox';
|
|
16
16
|
|
|
17
17
|
/** Independent rate-limit bucket affected by an order or cancellation. */
|
|
@@ -3746,6 +3746,13 @@ type SecureSubscriptionsActions = {
|
|
|
3746
3746
|
/**
|
|
3747
3747
|
* Starts one or more realtime subscriptions on this client.
|
|
3748
3748
|
*
|
|
3749
|
+
* The new `prices.crypto`, `prices.crypto.twap`, and `prices.equity` topics
|
|
3750
|
+
* require explicit filters and include history snapshots and live updates.
|
|
3751
|
+
* Legacy source-named topics retain their existing filter and event behavior.
|
|
3752
|
+
* Event `seq` values are scoped to one channel on one WebSocket connection
|
|
3753
|
+
* and reset after reconnecting. Subscriptions with more than 64 filters use
|
|
3754
|
+
* multiple connections, so their sequence values may interleave.
|
|
3755
|
+
*
|
|
3749
3756
|
* @throws {@link SubscribeError}
|
|
3750
3757
|
* Thrown when subscription input is invalid or a realtime subscription fails.
|
|
3751
3758
|
*
|
|
@@ -4857,6 +4864,8 @@ type EnvironmentConfigFork = {
|
|
|
4857
4864
|
collateralReturn?: Partial<RestEndpoint>;
|
|
4858
4865
|
};
|
|
4859
4866
|
perps?: EnvironmentConfigForkEndpoint;
|
|
4867
|
+
realtime?: Partial<WebSocketEndpoint>;
|
|
4868
|
+
/** @deprecated Retained temporarily for legacy RTDS streams. */
|
|
4860
4869
|
rtds?: Partial<WebSocketEndpoint>;
|
|
4861
4870
|
sports?: Partial<WebSocketEndpoint>;
|
|
4862
4871
|
relayerMaxPolls?: number;
|
|
@@ -9772,23 +9781,112 @@ type UserSubscription = {
|
|
|
9772
9781
|
type SportsSubscription = {
|
|
9773
9782
|
topic: 'sports';
|
|
9774
9783
|
};
|
|
9784
|
+
/**
|
|
9785
|
+
* @deprecated The comments stream is being discontinued.
|
|
9786
|
+
* Use `client.listComments()` to retrieve comments. This method does not
|
|
9787
|
+
* provide live comment or reaction events.
|
|
9788
|
+
*
|
|
9789
|
+
* @example
|
|
9790
|
+
* ```ts
|
|
9791
|
+
* const pages = client.listComments({
|
|
9792
|
+
* parentEntityId: '123',
|
|
9793
|
+
* parentEntityType: CommentParentEntityType.Event,
|
|
9794
|
+
* pageSize: 20,
|
|
9795
|
+
* });
|
|
9796
|
+
* const page = await pages.firstPage();
|
|
9797
|
+
*
|
|
9798
|
+
* for (const comment of page.items) {
|
|
9799
|
+
* console.log(comment);
|
|
9800
|
+
* }
|
|
9801
|
+
* ```
|
|
9802
|
+
*/
|
|
9775
9803
|
type CommentsSubscription = {
|
|
9776
9804
|
topic: 'comments';
|
|
9777
9805
|
types?: readonly CommentsEventType[];
|
|
9778
9806
|
parentEntityId?: number;
|
|
9779
9807
|
parentEntityType?: 'Event' | 'Market';
|
|
9780
9808
|
};
|
|
9809
|
+
/**
|
|
9810
|
+
* @deprecated Use `prices.crypto` with a secure client and explicit canonical
|
|
9811
|
+
* USD symbols. Events include history snapshots. Removal is planned one month
|
|
9812
|
+
* after the 0.11.0 release.
|
|
9813
|
+
*
|
|
9814
|
+
* Binance USDT prices and PolyBolt USD prices have different quote currencies
|
|
9815
|
+
* and feed sources; this is not a like-for-like replacement. Chainlink spot
|
|
9816
|
+
* consumers must also assess the change in feed source.
|
|
9817
|
+
*
|
|
9818
|
+
* @example
|
|
9819
|
+
* ```ts
|
|
9820
|
+
* // Before: Chainlink USD or Binance USDT prices.
|
|
9821
|
+
* const legacyPrices = await publicClient.subscribe([
|
|
9822
|
+
* { topic: 'prices.crypto.chainlink', symbols: ['btc/usd'] },
|
|
9823
|
+
* { topic: 'prices.crypto.binance', symbols: ['btcusdt'] },
|
|
9824
|
+
* ]);
|
|
9825
|
+
*
|
|
9826
|
+
* // After: secureClient is already authenticated; choose USD prices explicitly.
|
|
9827
|
+
* const prices = await secureClient.subscribe([
|
|
9828
|
+
* { topic: 'prices.crypto', symbols: ['btcusd'] },
|
|
9829
|
+
* ]);
|
|
9830
|
+
* for await (const event of prices) {
|
|
9831
|
+
* if (event.type !== 'update') continue;
|
|
9832
|
+
* console.log(event.payload.symbol, event.payload.value);
|
|
9833
|
+
* }
|
|
9834
|
+
* ```
|
|
9835
|
+
*/
|
|
9781
9836
|
type CryptoPricesSubscription = {
|
|
9782
9837
|
topic: CryptoPricesTopic;
|
|
9783
9838
|
symbols?: readonly string[];
|
|
9784
9839
|
};
|
|
9840
|
+
/**
|
|
9841
|
+
* @deprecated Use `prices.crypto.twap` with a secure client and explicit
|
|
9842
|
+
* canonical USD symbols. The replacement provides 60-second TWAP prices and
|
|
9843
|
+
* history snapshots. There is no replacement for the 30-second window.
|
|
9844
|
+
* Removal is planned one month after the 0.11.0 release.
|
|
9845
|
+
*
|
|
9846
|
+
* @example
|
|
9847
|
+
* ```ts
|
|
9848
|
+
* // Before
|
|
9849
|
+
* const legacyPrices = await publicClient.subscribe([
|
|
9850
|
+
* {
|
|
9851
|
+
* topic: 'prices.crypto.chainlink.twap',
|
|
9852
|
+
* symbols: ['btc/usd'],
|
|
9853
|
+
* windowSeconds: 60,
|
|
9854
|
+
* },
|
|
9855
|
+
* ]);
|
|
9856
|
+
*
|
|
9857
|
+
* // After: secureClient is already authenticated.
|
|
9858
|
+
* const prices = await secureClient.subscribe([
|
|
9859
|
+
* { topic: 'prices.crypto.twap', symbols: ['btcusd'] },
|
|
9860
|
+
* ]);
|
|
9861
|
+
* for await (const event of prices) {
|
|
9862
|
+
* if (event.type !== 'update') continue;
|
|
9863
|
+
* console.log(event.payload.symbol, event.payload.value);
|
|
9864
|
+
* }
|
|
9865
|
+
* ```
|
|
9866
|
+
*/
|
|
9785
9867
|
type CryptoPricesChainlinkTwapSubscription = {
|
|
9786
9868
|
topic: CryptoPricesChainlinkTwapTopic;
|
|
9787
|
-
/** Averaging window used to calculate each TWAP price. */
|
|
9788
9869
|
windowSeconds: CryptoPricesChainlinkTwapWindowSeconds;
|
|
9789
|
-
/** Lowercase slash-delimited symbols, such as `btc/usd`. */
|
|
9790
9870
|
symbols?: readonly string[];
|
|
9791
9871
|
};
|
|
9872
|
+
/**
|
|
9873
|
+
* @deprecated Use `prices.equity` with a secure client. The existing symbol
|
|
9874
|
+
* and event-type filters remain available. Removal is planned one month after
|
|
9875
|
+
* the 0.11.0 release.
|
|
9876
|
+
*
|
|
9877
|
+
* @example
|
|
9878
|
+
* ```ts
|
|
9879
|
+
* // Before
|
|
9880
|
+
* const legacyPrices = await publicClient.subscribe([
|
|
9881
|
+
* { topic: 'prices.equity.pyth', symbol: 'aapl', types: ['update'] },
|
|
9882
|
+
* ]);
|
|
9883
|
+
*
|
|
9884
|
+
* // After: secureClient is already authenticated.
|
|
9885
|
+
* const prices = await secureClient.subscribe([
|
|
9886
|
+
* { topic: 'prices.equity', symbol: 'aapl', types: ['update'] },
|
|
9887
|
+
* ]);
|
|
9888
|
+
* ```
|
|
9889
|
+
*/
|
|
9792
9890
|
type EquityPricesSubscription = {
|
|
9793
9891
|
topic: EquityPricesTopic;
|
|
9794
9892
|
symbol: string;
|
|
@@ -9842,19 +9940,47 @@ type PerpsStatisticsSubscription = {
|
|
|
9842
9940
|
*/
|
|
9843
9941
|
type PerpsMarketDataSubscription = PerpsTradesSubscription | PerpsBboSubscription | PerpsBookSubscription | PerpsCandlesSubscription | PerpsTickersSubscription | PerpsStatisticsSubscription;
|
|
9844
9942
|
type PublicSubscriptionSpec = MarketSubscription | SportsSubscription | CommentsSubscription | CryptoPricesSubscription | CryptoPricesChainlinkTwapSubscription | EquityPricesSubscription | PerpsMarketDataSubscription;
|
|
9845
|
-
|
|
9943
|
+
/**
|
|
9944
|
+
* Symbol-filtered cryptocurrency updates and recent history. Requires a secure
|
|
9945
|
+
* client and canonical lowercase USD pairs such as `btcusd`.
|
|
9946
|
+
* Slash-separated symbols and USDT pairs are rejected.
|
|
9947
|
+
*/
|
|
9948
|
+
type CryptoPriceSubscription = {
|
|
9949
|
+
topic: 'prices.crypto';
|
|
9950
|
+
symbols: readonly string[];
|
|
9951
|
+
};
|
|
9952
|
+
/**
|
|
9953
|
+
* 60-second time-weighted prices and recent history. Requires a secure client
|
|
9954
|
+
* and canonical lowercase USD pairs such as `btcusd`. The window is fixed;
|
|
9955
|
+
* returned events include `windowSeconds: 60` as metadata.
|
|
9956
|
+
*/
|
|
9957
|
+
type CryptoTwapPriceSubscription = {
|
|
9958
|
+
topic: 'prices.crypto.twap';
|
|
9959
|
+
symbols: readonly string[];
|
|
9960
|
+
};
|
|
9961
|
+
/** Equity updates and recent history. Requires a secure client. */
|
|
9962
|
+
type EquityPriceSubscription = {
|
|
9963
|
+
topic: 'prices.equity';
|
|
9964
|
+
symbol: string;
|
|
9965
|
+
types?: readonly ('subscribe' | 'update')[];
|
|
9966
|
+
};
|
|
9967
|
+
type PriceSubscription = CryptoPriceSubscription | CryptoTwapPriceSubscription | EquityPriceSubscription;
|
|
9968
|
+
type SecureSubscriptionSpec = PublicSubscriptionSpec | UserSubscription | PriceSubscription;
|
|
9846
9969
|
type PublicRealtimeEvent = MarketEvent | SportsEvent | CommentsEvent | CryptoPricesEvent | EquityPricesEvent | PerpsMarketDataEvent;
|
|
9847
|
-
type SecureRealtimeEvent = PublicRealtimeEvent | UserEvent;
|
|
9970
|
+
type SecureRealtimeEvent = PublicRealtimeEvent | UserEvent | CryptoPriceEvent | CryptoTwapPriceEvent | EquityPriceEvent;
|
|
9848
9971
|
type PublicRealtimeTopic = Prettify<PublicRealtimeEvent['topic']>;
|
|
9849
9972
|
type SecureRealtimeTopic = Prettify<SecureRealtimeEvent['topic']>;
|
|
9850
9973
|
type EventByTopic = {
|
|
9851
|
-
|
|
9852
|
-
|
|
9974
|
+
'prices.crypto': CryptoPriceEvent;
|
|
9975
|
+
'prices.crypto.twap': CryptoTwapPriceEvent;
|
|
9976
|
+
'prices.equity': EquityPriceEvent;
|
|
9853
9977
|
comments: CommentsEvent;
|
|
9854
9978
|
'prices.crypto.binance': CryptoPricesBinanceEvent;
|
|
9855
9979
|
'prices.crypto.chainlink': CryptoPricesChainlinkEvent;
|
|
9856
9980
|
'prices.crypto.chainlink.twap': CryptoPricesChainlinkTwapEvent;
|
|
9857
9981
|
'prices.equity.pyth': EquityPricesEvent;
|
|
9982
|
+
user: UserEvent;
|
|
9983
|
+
sports: SportsEvent;
|
|
9858
9984
|
'perps.trades': PerpsTradeEvent;
|
|
9859
9985
|
'perps.bbo': PerpsBboEvent;
|
|
9860
9986
|
'perps.book': PerpsBookEvent;
|
|
@@ -9880,13 +10006,20 @@ type SubscriptionHandle<TEvent> = {
|
|
|
9880
10006
|
*/
|
|
9881
10007
|
close(): Promise<void>;
|
|
9882
10008
|
} & AsyncIterable<TEvent>;
|
|
9883
|
-
type SubscribeError = TransportError | UserInputError;
|
|
10009
|
+
type SubscribeError = TransportError | UserInputError | RequestRejectedError | ConnectionLostError;
|
|
9884
10010
|
declare const SubscribeError: {
|
|
9885
|
-
isError(error: unknown): error is TransportError | UserInputError;
|
|
10011
|
+
isError(error: unknown): error is TransportError | UserInputError | ConnectionLostError | RequestRejectedError;
|
|
9886
10012
|
};
|
|
9887
10013
|
/**
|
|
9888
10014
|
* Starts one or more realtime subscriptions on this client.
|
|
9889
10015
|
*
|
|
10016
|
+
* The new `prices.crypto`, `prices.crypto.twap`, and `prices.equity` topics
|
|
10017
|
+
* require a secure client and explicit filters, and include history snapshots
|
|
10018
|
+
* and live updates. Legacy source-named topics retain their existing behavior.
|
|
10019
|
+
* Event `seq` values are scoped to one channel on one WebSocket connection and
|
|
10020
|
+
* reset after reconnecting. Subscriptions with more than 64 filters use
|
|
10021
|
+
* multiple connections, so their sequence values may interleave.
|
|
10022
|
+
*
|
|
9890
10023
|
* @remarks
|
|
9891
10024
|
* This is a low-level function. Most SDK consumers should prefer the client instance API.
|
|
9892
10025
|
*
|
|
@@ -10251,4 +10384,4 @@ type Signer = {
|
|
|
10251
10384
|
sendTransaction(request: SignerTransactionRequest): Promise<TransactionHandle>;
|
|
10252
10385
|
};
|
|
10253
10386
|
|
|
10254
|
-
export { type Erc1155TradingApproval as $, type ApiKeyAuthorization as A, type BaseClient as B, CancelAllError as C, type ClientActions as D, type ClientDecorator as E, type ClobEndpoints as F, type ComboPositionStatusFilter as G, type ComboQuote as H, type CombosEndpoints as I, ConnectionLostError as J, type ConnectionLostErrorOptions as K, type CreatePerpsSessionRequest as L, CreateSecureClientError as M, type CryptoPricesChainlinkTwapSubscription as N, type DataActions as O, DepositToPerpsError as P, type DepositToPerpsRequest as Q, type DisarmPerpsAutoCancelRequest as R, type Signer as S, type TypedDataPayload as T, UserInputError as U, type DiscoveryActions as V, DownloadAccountingSnapshotError as W, DropNotificationsError as X, type EnvironmentConfig as Y, type EnvironmentConfigFork as Z, type EnvironmentContracts as _, type TypedData as a, ListComboActivityError as a$, type Erc20TradingApproval as a0, EstimateMarketPriceError as a1, ExecuteCollateralReturnPlanError as a2, type ExecuteCollateralReturnPlanRequest as a3, FetchBuilderVolumeError as a4, FetchClosedOnlyModeError as a5, FetchCommentsByIdError as a6, FetchEventError as a7, FetchEventLiveVolumeError as a8, FetchEventTagsError as a9, FetchPriceError as aA, FetchPricesError as aB, FetchPublicProfileError as aC, FetchRelatedTagResourcesError as aD, FetchRelatedTagsError as aE, FetchResolutionsError as aF, FetchRewardPercentagesError as aG, FetchRfqStatusError as aH, type FetchRfqStatusParams as aI, FetchSeriesError as aJ, FetchSessionKeysError as aK, FetchSpreadError as aL, FetchSpreadsError as aM, FetchTagError as aN, FetchTotalEarningsForUserForDayError as aO, FetchTraderLeaderboardStandingError as aP, FetchTradingApprovalsStateError as aQ, type FetchTradingApprovalsStateRequest as aR, FetchUserPnlError as aS, FetchUserStatsError as aT, FetchUserVolumeError as aU, InsufficientLiquidityError as aV, ListAccountTradesError as aW, ListActivityError as aX, ListBiggestWinnersError as aY, ListBuilderLeaderboardError as aZ, ListBuilderTradesError as a_, FetchLastTradePriceError as aa, FetchLastTradePricesError as ab, FetchMarketError as ac, FetchMarketTagsError as ad, FetchMidpointError as ae, FetchMidpointsError as af, FetchNotificationsError as ag, FetchOpenInterestError as ah, FetchOrderBookError as ai, FetchOrderBooksError as aj, FetchOrderError as ak, FetchOrderScoringError as al, FetchOrdersScoringError as am, type FetchPerpsAccountConfigRequest as an, FetchPerpsBookError as ao, type FetchPerpsBookRequest as ap, FetchPerpsFeesError as aq, FetchPerpsInstrumentsError as ar, type FetchPerpsInstrumentsRequest as as, type FetchPerpsOpenOrdersRequest as at, type FetchPerpsOrdersRequest as au, FetchPerpsTickerError as av, type FetchPerpsTickerRequest as aw, FetchPerpsTickersError as ax, type FetchPerpsTickersRequest as ay, FetchPortfolioValueError as az, type TransactionCall as b, PostOrderError as b$, ListComboMarketsError as b0, ListComboPositionsError as b1, ListCommentsByUserAddressError as b2, ListCommentsError as b3, ListCurrentRewardsError as b4, ListEventsError as b5, ListMarketHoldersError as b6, ListMarketRewardsError as b7, ListMarketsError as b8, ListOpenOrdersError as b9, OpenRfqSessionError as bA, type OrderSignature as bB, type Page as bC, PageSizeSchema as bD, type Paginated as bE, type PerpsActions as bF, type PerpsBookDepth as bG, type PerpsEndpoints as bH, type PerpsOrderRequest as bI, type PerpsPlaceFokOrderRequest as bJ, type PerpsPlaceGtcOrderRequest as bK, type PerpsPlaceIocOrderRequest as bL, type PerpsPlacedTpSlOrder as bM, type PerpsPlacedTpSlOrders as bN, type PerpsPositionTpSlTrigger as bO, PerpsSession as bP, type PerpsSessionAccountError as bQ, type PerpsSessionLifecycleError as bR, type PerpsSessionTradingError as bS, type PerpsTpSlTrigger as bT, type PlacePerpsOrderRequest as bU, type PlacePerpsOrderResult as bV, type PlacePerpsOrderWithTpSlRequest as bW, type PlacePerpsOrderWithTpSlResult as bX, type PlacePerpsPositionTpSlRequest as bY, type PlacePerpsPositionTpSlResult as bZ, PlanCollateralReturnError as b_, ListPerpsCandlesError as ba, type ListPerpsCandlesRequest as bb, type ListPerpsDepositsRequest as bc, type ListPerpsEquityHistoryRequest as bd, type ListPerpsFillsRequest as be, ListPerpsFundingHistoryError as bf, type ListPerpsFundingHistoryRequest as bg, type ListPerpsFundingPaymentsRequest as bh, type ListPerpsNotificationsRequest as bi, type ListPerpsPnlHistoryRequest as bj, ListPerpsTradesError as bk, type ListPerpsTradesRequest as bl, type ListPerpsWithdrawalsRequest as bm, ListPositionsError as bn, ListPriceHistoryError as bo, ListSeriesError as bp, ListTagsError as bq, ListTeamsError as br, ListTraderLeaderboardError as bs, ListTradesError as bt, ListUserEarningsAndMarketsConfigError as bu, ListUserEarningsForDayError as bv, type MarkPerpsNotificationsReadRequest as bw, MergePositionsError as bx, OpenPerpsSessionError as by, type OpenPerpsSessionRequest as bz, AcceptComboQuoteError as c, type SecureListPositionsRequest as c$, PostOrdersError as c0, type PostPerpsOrdersRequest as c1, type PublicAccountActions as c2, type PublicActions as c3, type PublicClient as c4, type PublicClientOptions as c5, type PublicPerpsActions as c6, type PublicRewardsActions as c7, type PublicSubscriptionsActions as c8, type PublicWalletActions as c9, RfqQuoteError as cA, type RfqQuoteReference as cB, RfqQuoteRejectedError as cC, type RfqQuoteRejectedErrorOptions as cD, type RfqQuoteRequestEvent as cE, type RfqQuoteResponse as cF, type RfqQuoteSource as cG, RfqRequestRejectedError as cH, type RfqRequestRejectedErrorOptions as cI, type RfqSession as cJ, type RfqStatusResult as cK, type RfqTradeEvent as cL, SearchError as cM, SearchSort as cN, type SecureAccountActions as cO, type SecureActions as cP, type SecureClient as cQ, type SecureClientOptions as cR, type SecureDownloadAccountingSnapshotRequest as cS, type SecureFetchPortfolioValueRequest as cT, type SecureFetchTraderLeaderboardStandingRequest as cU, type SecureFetchUserPnlRequest as cV, type SecureFetchUserStatsRequest as cW, type SecureFetchUserVolumeRequest as cX, type SecureListActivityRequest as cY, type SecureListComboActivityRequest as cZ, type SecureListComboPositionsRequest as c_, type RateLimitBucket as ca, RateLimitError as cb, type RateLimitErrorOptions as cc, type RateLimitUpdate as cd, type RateLimitUpdateListener as ce, RedeemPositionsError as cf, RequestComboQuoteError as cg, type RequestComboQuoteParams as ch, type RequestComboQuoteResult as ci, RequestRejectedError as cj, type RequestRejectedErrorOptions as ck, type RestEndpoint as cl, type ResumePerpsSessionRequest as cm, RevokePerpsCredentialsError as cn, type RevokePerpsCredentialsRequest as co, RevokeSessionKeyError as cp, type RevokeSessionKeyRequest as cq, type RfqCancelQuoteAck as cr, RfqCancelQuoteError as cs, RfqCancelQuoteRejectedError as ct, type RfqCancelQuoteRejectedErrorOptions as cu, type RfqConfirmationAck as cv, RfqConfirmationError as cw, RfqConfirmationRejectedError as cx, type RfqConfirmationRequestEvent as cy, type RfqEvent as cz, type AcceptComboQuoteParams as d, type CancelOrdersRequest as d$, type SecurePerpsActions as d0, type SecureRewardsActions as d1, type SecureRfqActions as d2, type SecureSubscriptionsActions as d3, type SecureTradingActions as d4, type SecureWalletActions as d5, type SessionKey as d6, type SessionKeyActions as d7, SetupGaslessWalletError as d8, SetupTradingApprovalsError as d9, WaitForOrderFillSettlementError as dA, WaitForTransactionError as dB, type WalletDerivationConfig as dC, type WebSocketCloseCode as dD, type WebSocketEndpoint as dE, WebSocketKnownCloseCode as dF, WithdrawFromPerpsError as dG, type WithdrawFromPerpsRequest as dH, accountActions as dI, allActions as dJ, analyticsActions as dK, createPublicClient as dL, createSecureClient as dM, dataActions as dN, discoveryActions as dO, forkEnvironmentConfig as dP, makeErrorGuard as dQ, perpsActions as dR, production as dS, rewardsActions as dT, rfqActions as dU, sessionKeyActions as dV, subscriptionsActions as dW, tradingActions as dX, walletActions as dY, type CancelMarketOrdersRequest as dZ, type CancelOrderRequest as d_, type SignedOrder as da, type SignerTransactionRequest as db, SignerType as dc, SigningError as dd, SplitPositionError as de, SubscribeError as df, TimeoutError as dg, type TradingApprovalRequirements as dh, type TradingApprovalsState as di, TradingRestriction as dj, TransactionFailedError as dk, type TransactionHandle as dl, type TransactionOutcome as dm, TransferErc20Error as dn, TransportError as dp, type TypedDataDomain as dq, type TypedDataField as dr, UnexpectedResponseError as ds, UpdatePerpsLeverageError as dt, type UpdatePerpsLeverageRequest as du, UpdatePerpsMarginError as dv, type UpdatePerpsMarginRequest as dw, WaitForComboFillError as dx, type WaitForComboFillParams as dy, type WaitForComboFillResult as dz, type AcceptComboQuoteResult as e, FetchTickSizeError as e$, type CollateralReturnExecutionWorkflow as e0, type CommentsEventType as e1, type CommentsSubscription as e2, type CryptoPricesEventType as e3, type CryptoPricesSubscription as e4, DeployDepositWalletError as e5, type DownloadAccountingSnapshotRequest as e6, type DropNotificationsRequest as e7, type EquityPricesEventType as e8, type EquityPricesSubscription as e9, type FetchMarketInfoRequest as eA, type FetchMarketRequest as eB, type FetchMarketTagsRequest as eC, type FetchMidpointRequest as eD, type FetchMidpointsRequest as eE, FetchNegRiskError as eF, type FetchNegRiskRequest as eG, type FetchOpenInterestRequest as eH, type FetchOrderBookRequest as eI, type FetchOrderBooksRequest as eJ, type FetchOrderRequest as eK, type FetchOrderScoringRequest as eL, type FetchOrdersScoringRequest as eM, type FetchPortfolioValueRequest as eN, type FetchPriceRequest as eO, type FetchPricesRequest as eP, type FetchPublicProfileRequest as eQ, type FetchRelatedTagResourcesRequest as eR, type FetchRelatedTagsRequest as eS, type FetchResolutionsByConditionRequest as eT, type FetchResolutionsByEventRequest as eU, type FetchResolutionsByQuestionRequest as eV, type FetchResolutionsRequest as eW, type FetchSeriesRequest as eX, type FetchSpreadRequest as eY, type FetchSpreadsRequest as eZ, type FetchTagRequest as e_, type Erc1155ApprovalForAllWorkflow as ea, type Erc1155ApprovalForAllWorkflowRequest as eb, type Erc20ApprovalWorkflow as ec, type Erc20ApprovalWorkflowRequest as ed, type Erc20TransferWorkflow as ee, type Erc20TransferWorkflowRequest as ef, type EstimateMarketBuyPriceRequest as eg, type EstimateMarketPriceRequest as eh, type EstimateMarketSellPriceRequest as ei, type EventForSubscriptionSpec as ej, type EventForSubscriptionSpecs as ek, FetchBalanceAllowanceError as el, type FetchBalanceAllowanceRequest as em, FetchBuilderFeeRatesError as en, type FetchBuilderFeeRatesRequest as eo, type FetchBuilderVolumeRequest as ep, type FetchCommentsByIdRequest as eq, type FetchEventLiveVolumeRequest as er, type FetchEventRequest as es, type FetchEventTagsRequest as et, FetchExecuteParamsError as eu, type FetchExecuteParamsRequest as ev, type FetchGaslessTransactionRequest as ew, type FetchLastTradePriceRequest as ex, type FetchLastTradePricesRequest as ey, FetchMarketInfoError as ez, type AccountIdentity as f, type PrepareErc20ApprovalRequest as f$, type FetchTickSizeRequest as f0, type FetchTotalEarningsForUserForDayRequest as f1, type FetchTraderLeaderboardStandingRequest as f2, type FetchUserPnlRequest as f3, type FetchUserStatsRequest as f4, type FetchUserVolumeRequest as f5, GaslessTransactionMetadataSchema as f6, type GaslessWorkflow as f7, type GaslessWorkflowRequest as f8, IsWalletDeployedError as f9, type ListUserEarningsAndMarketsConfigRequest as fA, type ListUserEarningsForDayRequest as fB, type MarketEventType as fC, type MarketSubscription as fD, MergeComboPositionError as fE, MergeMarketPositionError as fF, type MergePositionsWorkflow as fG, type MergePositionsWorkflowRequest as fH, type OrderPostingWorkflow as fI, type OrderWorkflow as fJ, type OrderWorkflowRequest as fK, type PerpsBboSubscription as fL, type PerpsBookSubscription as fM, type PerpsCandlesSubscription as fN, type PerpsDepositWorkflow as fO, type PerpsDepositWorkflowRequest as fP, type PerpsMarketDataEventType as fQ, type PerpsMarketDataSubscription as fR, type PerpsStatisticsSubscription as fS, type PerpsStreamingCandleInterval as fT, type PerpsTickersSubscription as fU, type PerpsTradesSubscription as fV, type PostOrdersRequest as fW, PrepareCollateralReturnExecutionError as fX, PrepareErc1155ApprovalForAllError as fY, type PrepareErc1155ApprovalForAllRequest as fZ, PrepareErc20ApprovalError as f_, type IsWalletDeployedRequest as fa, type ListAccountTradesRequest as fb, type ListActivityRequest as fc, type ListBiggestWinnersRequest as fd, type ListBuilderLeaderboardRequest as fe, type ListBuilderTradesRequest as ff, type ListComboActivityRequest as fg, type ListComboMarketsRequest as fh, type ListComboPositionsRequest as fi, type ListCommentsByUserAddressRequest as fj, type ListCommentsRequest as fk, type ListCurrentRewardsRequest as fl, type ListEventsRequest as fm, ListMarketClarificationsError as fn, type ListMarketClarificationsRequest as fo, type ListMarketHoldersRequest as fp, type ListMarketRewardsRequest as fq, type ListMarketsRequest as fr, type ListOpenOrdersRequest as fs, type ListPositionsRequest as ft, type ListPriceHistoryRequest as fu, type ListSeriesRequest as fv, type ListTagsRequest as fw, type ListTeamsRequest as fx, type ListTraderLeaderboardRequest as fy, type ListTradesRequest as fz, type AnalyticsActions as g, authorizeSessionKey as g$, PrepareErc20TransferError as g0, type PrepareErc20TransferRequest as g1, PrepareGaslessTransactionError as g2, type PrepareGaslessTransactionRequest as g3, type PrepareLimitOrderRequest as g4, type PrepareMarketBuyOrderRequest as g5, type PrepareMarketOrderRequest as g6, type PrepareMarketSellOrderRequest as g7, PrepareMergeComboPositionError as g8, type PrepareMergeComboPositionRequest as g9, ResolveConditionByTokenError as gA, type ResolveConditionByTokenRequest as gB, type RfqConfirmationRejectedErrorOptions as gC, type RfqExecutionUpdateEvent as gD, type SearchRequest as gE, type SearchResults as gF, type SecureRealtimeEvent as gG, type SecureRealtimeTopic as gH, type SecureSubscriptionSpec as gI, SplitComboPositionError as gJ, SplitMarketPositionError as gK, type SplitPositionWorkflow as gL, type SplitPositionWorkflowRequest as gM, type SportsEventType as gN, type SportsSubscription as gO, type SubscriptionHandle as gP, type TradingApprovalsWorkflow as gQ, type TradingApprovalsWorkflowRequest as gR, UpdateBalanceAllowanceError as gS, type UpdateBalanceAllowanceRequest as gT, type UserEventType as gU, type UserSubscription as gV, WaitForGaslessTransactionError as gW, type WaitForOrderFillSettlementRequest as gX, acceptComboQuote as gY, approveErc1155ForAll as gZ, approveErc20 as g_, PrepareMergeMarketPositionError as ga, type PrepareMergeMarketPositionRequest as gb, PrepareMergePositionsError as gc, type PrepareMergePositionsRequest as gd, PreparePerpsDepositError as ge, PrepareRedeemComboPositionError as gf, type PrepareRedeemComboPositionRequest as gg, type PrepareRedeemMarketPositionsByConditionIdRequest as gh, type PrepareRedeemMarketPositionsByMarketIdRequest as gi, PrepareRedeemMarketPositionsError as gj, type PrepareRedeemMarketPositionsRequest as gk, type PrepareRedeemPositionRequest as gl, PrepareRedeemPositionsError as gm, type PrepareRedeemPositionsRequest as gn, PrepareSplitComboPositionError as go, type PrepareSplitComboPositionRequest as gp, PrepareSplitMarketPositionError as gq, type PrepareSplitMarketPositionRequest as gr, PrepareSplitPositionError as gs, type PrepareSplitPositionRequest as gt, PrepareTradingApprovalsError as gu, type PublicRealtimeEvent as gv, type PublicRealtimeTopic as gw, type PublicSubscriptionSpec as gx, type RedeemPositionsWorkflow as gy, type RedeemPositionsWorkflowRequest as gz, ApproveErc1155ForAllError as h, listActivity as h$, cancelAll as h0, cancelMarketOrders as h1, cancelOrder as h2, cancelOrders as h3, deployDepositWallet as h4, depositToPerps as h5, downloadAccountingSnapshot as h6, dropNotifications as h7, estimateMarketPrice as h8, executeCollateralReturnPlan as h9, fetchPerpsInstruments as hA, fetchPerpsTicker as hB, fetchPerpsTickers as hC, fetchPortfolioValue as hD, fetchPrice as hE, fetchPrices as hF, fetchPublicProfile as hG, fetchRelatedTagResources as hH, fetchRelatedTags as hI, fetchResolutions as hJ, fetchRewardPercentages as hK, fetchRfqStatus as hL, fetchSeries as hM, fetchSessionKeys as hN, fetchSpread as hO, fetchSpreads as hP, fetchTag as hQ, fetchTickSize as hR, fetchTotalEarningsForUserForDay as hS, fetchTraderLeaderboardStanding as hT, fetchTradingApprovalsState as hU, fetchTransaction as hV, fetchUserPnl as hW, fetchUserStats as hX, fetchUserVolume as hY, isWalletDeployed as hZ, listAccountTrades as h_, fetchBalanceAllowance as ha, fetchBuilderFeeRates as hb, fetchBuilderVolume as hc, fetchClosedOnlyMode as hd, fetchCommentsById as he, fetchEvent as hf, fetchEventLiveVolume as hg, fetchEventTags as hh, fetchExecuteParams as hi, fetchLastTradePrice as hj, fetchLastTradePrices as hk, fetchMarket as hl, fetchMarketInfo as hm, fetchMarketTags as hn, fetchMidpoint as ho, fetchMidpoints as hp, fetchNegRisk as hq, fetchNotifications as hr, fetchOpenInterest as hs, fetchOrder as ht, fetchOrderBook as hu, fetchOrderBooks as hv, fetchOrderScoring as hw, fetchOrdersScoring as hx, fetchPerpsBook as hy, fetchPerpsFees as hz, ApproveErc20Error as i, splitPosition as i$, listBiggestWinners as i0, listBuilderLeaderboard as i1, listBuilderTrades as i2, listComboActivity as i3, listComboMarkets as i4, listComboPositions as i5, listComments as i6, listCommentsByUserAddress as i7, listCurrentRewards as i8, listEvents as i9, postOrders as iA, prepareCollateralReturnExecution as iB, prepareErc1155ApprovalForAll as iC, prepareErc20Approval as iD, prepareErc20Transfer as iE, prepareGaslessTransaction as iF, prepareMergeComboPosition as iG, prepareMergeMarketPosition as iH, prepareMergePositions as iI, preparePerpsDeposit as iJ, prepareRedeemComboPosition as iK, prepareRedeemMarketPositions as iL, prepareRedeemPosition as iM, prepareRedeemPositions as iN, prepareSplitComboPosition as iO, prepareSplitMarketPosition as iP, prepareSplitPosition as iQ, prepareTradingApprovals as iR, redeemPositions as iS, requestComboQuote as iT, resolveConditionByToken as iU, revokePerpsCredentials as iV, revokeSessionKey as iW, search as iX, setupTradingApprovals as iY, splitComboPosition as iZ, splitMarketPosition as i_, listMarketClarifications as ia, listMarketHolders as ib, listMarketRewards as ic, listMarkets as id, listOpenOrders as ie, listPerpsCandles as ig, listPerpsFundingHistory as ih, listPerpsTrades as ii, listPositions as ij, listPriceHistory as ik, listSeries as il, listTags as im, listTeams as io, listTraderLeaderboard as ip, listTrades as iq, listUserEarningsAndMarketsConfig as ir, listUserEarningsForDay as is, mergeComboPosition as it, mergeMarketPosition as iu, mergePositions as iv, openPerpsSession as iw, openRfqSession as ix, planCollateralReturn as iy, postOrder as iz, ArmPerpsAutoCancelError as j, subscribe as j0, transferErc20 as j1, updateBalanceAllowance as j2, waitForComboFill as j3, waitForOrderFillSettlement as j4, withdrawFromPerps as j5, type ArmPerpsAutoCancelRequest as k, AuthorizeSessionKeyError as l, type AuthorizeSessionKeyRequest as m, type AuthorizeSessionKeyResult as n, AutoCancelDailyLimitError as o, BasePublicClient as p, BaseSecureClient as q, type BeginAuthenticationRequest as r, type CancelAllPerpsOrdersRequest as s, CancelMarketOrdersError as t, CancelOrderError as u, CancelOrdersError as v, type CancelPerpsOrderRequest as w, type CancelPerpsOrdersRequest as x, CancelledSigningError as y, type Client as z };
|
|
10387
|
+
export { DropNotificationsError as $, type ApiKeyAuthorization as A, type BaseClient as B, CancelAllError as C, type ClientActions as D, type ClientDecorator as E, type ClobEndpoints as F, type ComboPositionStatusFilter as G, type ComboQuote as H, type CombosEndpoints as I, type CommentsSubscription as J, ConnectionLostError as K, type ConnectionLostErrorOptions as L, type CreatePerpsSessionRequest as M, CreateSecureClientError as N, type CryptoPriceSubscription as O, type CryptoPricesChainlinkTwapSubscription as P, type CryptoPricesSubscription as Q, type CryptoTwapPriceSubscription as R, type Signer as S, type TypedDataPayload as T, UserInputError as U, type DataActions as V, DepositToPerpsError as W, type DepositToPerpsRequest as X, type DisarmPerpsAutoCancelRequest as Y, type DiscoveryActions as Z, DownloadAccountingSnapshotError as _, type TypedData as a, InsufficientLiquidityError as a$, type EnvironmentConfig as a0, type EnvironmentConfigFork as a1, type EnvironmentContracts as a2, type EquityPriceSubscription as a3, type EquityPricesSubscription as a4, type Erc1155TradingApproval as a5, type Erc20TradingApproval as a6, EstimateMarketPriceError as a7, ExecuteCollateralReturnPlanError as a8, type ExecuteCollateralReturnPlanRequest as a9, type FetchPerpsOrdersRequest as aA, FetchPerpsTickerError as aB, type FetchPerpsTickerRequest as aC, FetchPerpsTickersError as aD, type FetchPerpsTickersRequest as aE, FetchPortfolioValueError as aF, FetchPriceError as aG, FetchPricesError as aH, FetchPublicProfileError as aI, FetchRelatedTagResourcesError as aJ, FetchRelatedTagsError as aK, FetchResolutionsError as aL, FetchRewardPercentagesError as aM, FetchRfqStatusError as aN, type FetchRfqStatusParams as aO, FetchSeriesError as aP, FetchSessionKeysError as aQ, FetchSpreadError as aR, FetchSpreadsError as aS, FetchTagError as aT, FetchTotalEarningsForUserForDayError as aU, FetchTraderLeaderboardStandingError as aV, FetchTradingApprovalsStateError as aW, type FetchTradingApprovalsStateRequest as aX, FetchUserPnlError as aY, FetchUserStatsError as aZ, FetchUserVolumeError as a_, FetchBuilderVolumeError as aa, FetchClosedOnlyModeError as ab, FetchCommentsByIdError as ac, FetchEventError as ad, FetchEventLiveVolumeError as ae, FetchEventTagsError as af, FetchLastTradePriceError as ag, FetchLastTradePricesError as ah, FetchMarketError as ai, FetchMarketTagsError as aj, FetchMidpointError as ak, FetchMidpointsError as al, FetchNotificationsError as am, FetchOpenInterestError as an, FetchOrderBookError as ao, FetchOrderBooksError as ap, FetchOrderError as aq, FetchOrderScoringError as ar, FetchOrdersScoringError as as, type FetchPerpsAccountConfigRequest as at, FetchPerpsBookError as au, type FetchPerpsBookRequest as av, FetchPerpsFeesError as aw, FetchPerpsInstrumentsError as ax, type FetchPerpsInstrumentsRequest as ay, type FetchPerpsOpenOrdersRequest as az, type TransactionCall as b, type PlacePerpsOrderResult as b$, ListAccountTradesError as b0, ListActivityError as b1, ListBiggestWinnersError as b2, ListBuilderLeaderboardError as b3, ListBuilderTradesError as b4, ListComboActivityError as b5, ListComboMarketsError as b6, ListComboPositionsError as b7, ListCommentsByUserAddressError as b8, ListCommentsError as b9, ListUserEarningsAndMarketsConfigError as bA, ListUserEarningsForDayError as bB, type MarkPerpsNotificationsReadRequest as bC, MergePositionsError as bD, OpenPerpsSessionError as bE, type OpenPerpsSessionRequest as bF, OpenRfqSessionError as bG, type OrderSignature as bH, type Page as bI, PageSizeSchema as bJ, type Paginated as bK, type PerpsActions as bL, type PerpsBookDepth as bM, type PerpsEndpoints as bN, type PerpsOrderRequest as bO, type PerpsPlaceFokOrderRequest as bP, type PerpsPlaceGtcOrderRequest as bQ, type PerpsPlaceIocOrderRequest as bR, type PerpsPlacedTpSlOrder as bS, type PerpsPlacedTpSlOrders as bT, type PerpsPositionTpSlTrigger as bU, PerpsSession as bV, type PerpsSessionAccountError as bW, type PerpsSessionLifecycleError as bX, type PerpsSessionTradingError as bY, type PerpsTpSlTrigger as bZ, type PlacePerpsOrderRequest as b_, ListCurrentRewardsError as ba, ListEventsError as bb, ListMarketHoldersError as bc, ListMarketRewardsError as bd, ListMarketsError as be, ListOpenOrdersError as bf, ListPerpsCandlesError as bg, type ListPerpsCandlesRequest as bh, type ListPerpsDepositsRequest as bi, type ListPerpsEquityHistoryRequest as bj, type ListPerpsFillsRequest as bk, ListPerpsFundingHistoryError as bl, type ListPerpsFundingHistoryRequest as bm, type ListPerpsFundingPaymentsRequest as bn, type ListPerpsNotificationsRequest as bo, type ListPerpsPnlHistoryRequest as bp, ListPerpsTradesError as bq, type ListPerpsTradesRequest as br, type ListPerpsWithdrawalsRequest as bs, ListPositionsError as bt, ListPriceHistoryError as bu, ListSeriesError as bv, ListTagsError as bw, ListTeamsError as bx, ListTraderLeaderboardError as by, ListTradesError as bz, AcceptComboQuoteError as c, type SecureFetchTraderLeaderboardStandingRequest as c$, type PlacePerpsOrderWithTpSlRequest as c0, type PlacePerpsOrderWithTpSlResult as c1, type PlacePerpsPositionTpSlRequest as c2, type PlacePerpsPositionTpSlResult as c3, PlanCollateralReturnError as c4, PostOrderError as c5, PostOrdersError as c6, type PostPerpsOrdersRequest as c7, type PriceSubscription as c8, type PublicAccountActions as c9, RfqCancelQuoteRejectedError as cA, type RfqCancelQuoteRejectedErrorOptions as cB, type RfqConfirmationAck as cC, RfqConfirmationError as cD, RfqConfirmationRejectedError as cE, type RfqConfirmationRequestEvent as cF, type RfqEvent as cG, RfqQuoteError as cH, type RfqQuoteReference as cI, RfqQuoteRejectedError as cJ, type RfqQuoteRejectedErrorOptions as cK, type RfqQuoteRequestEvent as cL, type RfqQuoteResponse as cM, type RfqQuoteSource as cN, RfqRequestRejectedError as cO, type RfqRequestRejectedErrorOptions as cP, type RfqSession as cQ, type RfqStatusResult as cR, type RfqTradeEvent as cS, SearchError as cT, SearchSort as cU, type SecureAccountActions as cV, type SecureActions as cW, type SecureClient as cX, type SecureClientOptions as cY, type SecureDownloadAccountingSnapshotRequest as cZ, type SecureFetchPortfolioValueRequest as c_, type PublicActions as ca, type PublicClient as cb, type PublicClientOptions as cc, type PublicPerpsActions as cd, type PublicRewardsActions as ce, type PublicSubscriptionsActions as cf, type PublicWalletActions as cg, type RateLimitBucket as ch, RateLimitError as ci, type RateLimitErrorOptions as cj, type RateLimitUpdate as ck, type RateLimitUpdateListener as cl, RedeemPositionsError as cm, RequestComboQuoteError as cn, type RequestComboQuoteParams as co, type RequestComboQuoteResult as cp, RequestRejectedError as cq, type RequestRejectedErrorOptions as cr, type RestEndpoint as cs, type ResumePerpsSessionRequest as ct, RevokePerpsCredentialsError as cu, type RevokePerpsCredentialsRequest as cv, RevokeSessionKeyError as cw, type RevokeSessionKeyRequest as cx, type RfqCancelQuoteAck as cy, RfqCancelQuoteError as cz, type AcceptComboQuoteParams as d, rfqActions as d$, type SecureFetchUserPnlRequest as d0, type SecureFetchUserStatsRequest as d1, type SecureFetchUserVolumeRequest as d2, type SecureListActivityRequest as d3, type SecureListComboActivityRequest as d4, type SecureListComboPositionsRequest as d5, type SecureListPositionsRequest as d6, type SecurePerpsActions as d7, type SecureRewardsActions as d8, type SecureRfqActions as d9, UpdatePerpsLeverageError as dA, type UpdatePerpsLeverageRequest as dB, UpdatePerpsMarginError as dC, type UpdatePerpsMarginRequest as dD, WaitForComboFillError as dE, type WaitForComboFillParams as dF, type WaitForComboFillResult as dG, WaitForOrderFillSettlementError as dH, WaitForTransactionError as dI, type WalletDerivationConfig as dJ, type WebSocketCloseCode as dK, type WebSocketEndpoint as dL, WebSocketKnownCloseCode as dM, WithdrawFromPerpsError as dN, type WithdrawFromPerpsRequest as dO, accountActions as dP, allActions as dQ, analyticsActions as dR, createPublicClient as dS, createSecureClient as dT, dataActions as dU, discoveryActions as dV, forkEnvironmentConfig as dW, makeErrorGuard as dX, perpsActions as dY, production as dZ, rewardsActions as d_, type SecureSubscriptionsActions as da, type SecureTradingActions as db, type SecureWalletActions as dc, type SessionKey as dd, type SessionKeyActions as de, SetupGaslessWalletError as df, SetupTradingApprovalsError as dg, type SignedOrder as dh, type SignerTransactionRequest as di, SignerType as dj, SigningError as dk, SplitPositionError as dl, SubscribeError as dm, TimeoutError as dn, type TradingApprovalRequirements as dp, type TradingApprovalsState as dq, TradingRestriction as dr, TransactionFailedError as ds, type TransactionHandle as dt, type TransactionOutcome as du, TransferErc20Error as dv, TransportError as dw, type TypedDataDomain as dx, type TypedDataField as dy, UnexpectedResponseError as dz, type AcceptComboQuoteResult as e, type FetchSeriesRequest as e$, sessionKeyActions as e0, subscriptionsActions as e1, tradingActions as e2, walletActions as e3, type CancelMarketOrdersRequest as e4, type CancelOrderRequest as e5, type CancelOrdersRequest as e6, type CollateralReturnExecutionWorkflow as e7, type CommentsEventType as e8, type CryptoPricesEventType as e9, type FetchGaslessTransactionRequest as eA, type FetchLastTradePriceRequest as eB, type FetchLastTradePricesRequest as eC, FetchMarketInfoError as eD, type FetchMarketInfoRequest as eE, type FetchMarketRequest as eF, type FetchMarketTagsRequest as eG, type FetchMidpointRequest as eH, type FetchMidpointsRequest as eI, FetchNegRiskError as eJ, type FetchNegRiskRequest as eK, type FetchOpenInterestRequest as eL, type FetchOrderBookRequest as eM, type FetchOrderBooksRequest as eN, type FetchOrderRequest as eO, type FetchOrderScoringRequest as eP, type FetchOrdersScoringRequest as eQ, type FetchPortfolioValueRequest as eR, type FetchPriceRequest as eS, type FetchPricesRequest as eT, type FetchPublicProfileRequest as eU, type FetchRelatedTagResourcesRequest as eV, type FetchRelatedTagsRequest as eW, type FetchResolutionsByConditionRequest as eX, type FetchResolutionsByEventRequest as eY, type FetchResolutionsByQuestionRequest as eZ, type FetchResolutionsRequest as e_, DeployDepositWalletError as ea, type DownloadAccountingSnapshotRequest as eb, type DropNotificationsRequest as ec, type EquityPricesEventType as ed, type Erc1155ApprovalForAllWorkflow as ee, type Erc1155ApprovalForAllWorkflowRequest as ef, type Erc20ApprovalWorkflow as eg, type Erc20ApprovalWorkflowRequest as eh, type Erc20TransferWorkflow as ei, type Erc20TransferWorkflowRequest as ej, type EstimateMarketBuyPriceRequest as ek, type EstimateMarketPriceRequest as el, type EstimateMarketSellPriceRequest as em, type EventForSubscriptionSpec as en, type EventForSubscriptionSpecs as eo, FetchBalanceAllowanceError as ep, type FetchBalanceAllowanceRequest as eq, FetchBuilderFeeRatesError as er, type FetchBuilderFeeRatesRequest as es, type FetchBuilderVolumeRequest as et, type FetchCommentsByIdRequest as eu, type FetchEventLiveVolumeRequest as ev, type FetchEventRequest as ew, type FetchEventTagsRequest as ex, FetchExecuteParamsError as ey, type FetchExecuteParamsRequest as ez, type AccountIdentity as f, PrepareCollateralReturnExecutionError as f$, type FetchSpreadRequest as f0, type FetchSpreadsRequest as f1, type FetchTagRequest as f2, FetchTickSizeError as f3, type FetchTickSizeRequest as f4, type FetchTotalEarningsForUserForDayRequest as f5, type FetchTraderLeaderboardStandingRequest as f6, type FetchUserPnlRequest as f7, type FetchUserStatsRequest as f8, type FetchUserVolumeRequest as f9, type ListTagsRequest as fA, type ListTeamsRequest as fB, type ListTraderLeaderboardRequest as fC, type ListTradesRequest as fD, type ListUserEarningsAndMarketsConfigRequest as fE, type ListUserEarningsForDayRequest as fF, type MarketEventType as fG, type MarketSubscription as fH, MergeComboPositionError as fI, MergeMarketPositionError as fJ, type MergePositionsWorkflow as fK, type MergePositionsWorkflowRequest as fL, type OrderPostingWorkflow as fM, type OrderWorkflow as fN, type OrderWorkflowRequest as fO, type PerpsBboSubscription as fP, type PerpsBookSubscription as fQ, type PerpsCandlesSubscription as fR, type PerpsDepositWorkflow as fS, type PerpsDepositWorkflowRequest as fT, type PerpsMarketDataEventType as fU, type PerpsMarketDataSubscription as fV, type PerpsStatisticsSubscription as fW, type PerpsStreamingCandleInterval as fX, type PerpsTickersSubscription as fY, type PerpsTradesSubscription as fZ, type PostOrdersRequest as f_, GaslessTransactionMetadataSchema as fa, type GaslessWorkflow as fb, type GaslessWorkflowRequest as fc, IsWalletDeployedError as fd, type IsWalletDeployedRequest as fe, type ListAccountTradesRequest as ff, type ListActivityRequest as fg, type ListBiggestWinnersRequest as fh, type ListBuilderLeaderboardRequest as fi, type ListBuilderTradesRequest as fj, type ListComboActivityRequest as fk, type ListComboMarketsRequest as fl, type ListComboPositionsRequest as fm, type ListCommentsByUserAddressRequest as fn, type ListCommentsRequest as fo, type ListCurrentRewardsRequest as fp, type ListEventsRequest as fq, ListMarketClarificationsError as fr, type ListMarketClarificationsRequest as fs, type ListMarketHoldersRequest as ft, type ListMarketRewardsRequest as fu, type ListMarketsRequest as fv, type ListOpenOrdersRequest as fw, type ListPositionsRequest as fx, type ListPriceHistoryRequest as fy, type ListSeriesRequest as fz, type AnalyticsActions as g, type WaitForOrderFillSettlementRequest as g$, PrepareErc1155ApprovalForAllError as g0, type PrepareErc1155ApprovalForAllRequest as g1, PrepareErc20ApprovalError as g2, type PrepareErc20ApprovalRequest as g3, PrepareErc20TransferError as g4, type PrepareErc20TransferRequest as g5, PrepareGaslessTransactionError as g6, type PrepareGaslessTransactionRequest as g7, type PrepareLimitOrderRequest as g8, type PrepareMarketBuyOrderRequest as g9, type PublicRealtimeTopic as gA, type PublicSubscriptionSpec as gB, type RedeemPositionsWorkflow as gC, type RedeemPositionsWorkflowRequest as gD, ResolveConditionByTokenError as gE, type ResolveConditionByTokenRequest as gF, type RfqConfirmationRejectedErrorOptions as gG, type RfqExecutionUpdateEvent as gH, type SearchRequest as gI, type SearchResults as gJ, type SecureRealtimeEvent as gK, type SecureRealtimeTopic as gL, type SecureSubscriptionSpec as gM, SplitComboPositionError as gN, SplitMarketPositionError as gO, type SplitPositionWorkflow as gP, type SplitPositionWorkflowRequest as gQ, type SportsEventType as gR, type SportsSubscription as gS, type SubscriptionHandle as gT, type TradingApprovalsWorkflow as gU, type TradingApprovalsWorkflowRequest as gV, UpdateBalanceAllowanceError as gW, type UpdateBalanceAllowanceRequest as gX, type UserEventType as gY, type UserSubscription as gZ, WaitForGaslessTransactionError as g_, type PrepareMarketOrderRequest as ga, type PrepareMarketSellOrderRequest as gb, PrepareMergeComboPositionError as gc, type PrepareMergeComboPositionRequest as gd, PrepareMergeMarketPositionError as ge, type PrepareMergeMarketPositionRequest as gf, PrepareMergePositionsError as gg, type PrepareMergePositionsRequest as gh, PreparePerpsDepositError as gi, PrepareRedeemComboPositionError as gj, type PrepareRedeemComboPositionRequest as gk, type PrepareRedeemMarketPositionsByConditionIdRequest as gl, type PrepareRedeemMarketPositionsByMarketIdRequest as gm, PrepareRedeemMarketPositionsError as gn, type PrepareRedeemMarketPositionsRequest as go, type PrepareRedeemPositionRequest as gp, PrepareRedeemPositionsError as gq, type PrepareRedeemPositionsRequest as gr, PrepareSplitComboPositionError as gs, type PrepareSplitComboPositionRequest as gt, PrepareSplitMarketPositionError as gu, type PrepareSplitMarketPositionRequest as gv, PrepareSplitPositionError as gw, type PrepareSplitPositionRequest as gx, PrepareTradingApprovalsError as gy, type PublicRealtimeEvent as gz, ApproveErc1155ForAllError as h, fetchUserStats as h$, acceptComboQuote as h0, approveErc1155ForAll as h1, approveErc20 as h2, authorizeSessionKey as h3, cancelAll as h4, cancelMarketOrders as h5, cancelOrder as h6, cancelOrders as h7, deployDepositWallet as h8, depositToPerps as h9, fetchOrderScoring as hA, fetchOrdersScoring as hB, fetchPerpsBook as hC, fetchPerpsFees as hD, fetchPerpsInstruments as hE, fetchPerpsTicker as hF, fetchPerpsTickers as hG, fetchPortfolioValue as hH, fetchPrice as hI, fetchPrices as hJ, fetchPublicProfile as hK, fetchRelatedTagResources as hL, fetchRelatedTags as hM, fetchResolutions as hN, fetchRewardPercentages as hO, fetchRfqStatus as hP, fetchSeries as hQ, fetchSessionKeys as hR, fetchSpread as hS, fetchSpreads as hT, fetchTag as hU, fetchTickSize as hV, fetchTotalEarningsForUserForDay as hW, fetchTraderLeaderboardStanding as hX, fetchTradingApprovalsState as hY, fetchTransaction as hZ, fetchUserPnl as h_, downloadAccountingSnapshot as ha, dropNotifications as hb, estimateMarketPrice as hc, executeCollateralReturnPlan as hd, fetchBalanceAllowance as he, fetchBuilderFeeRates as hf, fetchBuilderVolume as hg, fetchClosedOnlyMode as hh, fetchCommentsById as hi, fetchEvent as hj, fetchEventLiveVolume as hk, fetchEventTags as hl, fetchExecuteParams as hm, fetchLastTradePrice as hn, fetchLastTradePrices as ho, fetchMarket as hp, fetchMarketInfo as hq, fetchMarketTags as hr, fetchMidpoint as hs, fetchMidpoints as ht, fetchNegRisk as hu, fetchNotifications as hv, fetchOpenInterest as hw, fetchOrder as hx, fetchOrderBook as hy, fetchOrderBooks as hz, ApproveErc20Error as i, search as i$, fetchUserVolume as i0, isWalletDeployed as i1, listAccountTrades as i2, listActivity as i3, listBiggestWinners as i4, listBuilderLeaderboard as i5, listBuilderTrades as i6, listComboActivity as i7, listComboMarkets as i8, listComboPositions as i9, openPerpsSession as iA, openRfqSession as iB, planCollateralReturn as iC, postOrder as iD, postOrders as iE, prepareCollateralReturnExecution as iF, prepareErc1155ApprovalForAll as iG, prepareErc20Approval as iH, prepareErc20Transfer as iI, prepareGaslessTransaction as iJ, prepareMergeComboPosition as iK, prepareMergeMarketPosition as iL, prepareMergePositions as iM, preparePerpsDeposit as iN, prepareRedeemComboPosition as iO, prepareRedeemMarketPositions as iP, prepareRedeemPosition as iQ, prepareRedeemPositions as iR, prepareSplitComboPosition as iS, prepareSplitMarketPosition as iT, prepareSplitPosition as iU, prepareTradingApprovals as iV, redeemPositions as iW, requestComboQuote as iX, resolveConditionByToken as iY, revokePerpsCredentials as iZ, revokeSessionKey as i_, listComments as ia, listCommentsByUserAddress as ib, listCurrentRewards as ic, listEvents as id, listMarketClarifications as ie, listMarketHolders as ig, listMarketRewards as ih, listMarkets as ii, listOpenOrders as ij, listPerpsCandles as ik, listPerpsFundingHistory as il, listPerpsTrades as im, listPositions as io, listPriceHistory as ip, listSeries as iq, listTags as ir, listTeams as is, listTraderLeaderboard as it, listTrades as iu, listUserEarningsAndMarketsConfig as iv, listUserEarningsForDay as iw, mergeComboPosition as ix, mergeMarketPosition as iy, mergePositions as iz, ArmPerpsAutoCancelError as j, setupTradingApprovals as j0, splitComboPosition as j1, splitMarketPosition as j2, splitPosition as j3, subscribe as j4, transferErc20 as j5, updateBalanceAllowance as j6, waitForComboFill as j7, waitForOrderFillSettlement as j8, withdrawFromPerps as j9, type ArmPerpsAutoCancelRequest as k, AuthorizeSessionKeyError as l, type AuthorizeSessionKeyRequest as m, type AuthorizeSessionKeyResult as n, AutoCancelDailyLimitError as o, BasePublicClient as p, BaseSecureClient as q, type BeginAuthenticationRequest as r, type CancelAllPerpsOrdersRequest as s, CancelMarketOrdersError as t, CancelOrderError as u, CancelOrdersError as v, type CancelPerpsOrderRequest as w, type CancelPerpsOrdersRequest as x, CancelledSigningError as y, type Client as z };
|
package/dist/viem.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PrivateKey } from '@polymarket/types';
|
|
2
2
|
import { Chain, Transport, WalletClient } from 'viem';
|
|
3
|
-
import { S as Signer } from './types-
|
|
3
|
+
import { S as Signer } from './types-BE9qerqa.js';
|
|
4
4
|
import '@polymarket/bindings';
|
|
5
5
|
import '@polymarket/bindings/gamma';
|
|
6
6
|
import '@polymarket/bindings/relayer';
|
package/dist/viem.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,n,k,j,i,c as c$1}from'./chunk-
|
|
1
|
+
import {a,n,k,j,i,c as c$1}from'./chunk-IPPWXOOG.js';import {invariant,expectEvmAddress,expectEvmSignature,isPrivateKey,expectTxHash}from'@polymarket/types';import {createWalletClient,http,UserRejectedRequestError,TransactionExecutionError,WaitForTransactionReceiptTimeoutError}from'viem';import {privateKeyToAccount}from'viem/accounts';import {waitForTransactionReceipt}from'viem/actions';import {polygon}from'viem/chains';function H(t){return t.account!==void 0}function q(t){invariant(H(t),"Wallet client with account is required");let n=t.account,e=expectEvmAddress(typeof t.account=="string"?t.account:t.account.address);return {getAddress(){return Promise.resolve(e)},async signTypedData(r){return expectEvmSignature(await I(t,{account:n,...r}))},async signMessage(r){return expectEvmSignature(await R(t,{account:n,message:{raw:r}}))},async sendTransaction({chainId:r,...f}){await K(t,r);let m=await A(t,{account:n,...f});return new s(m,t)}}}function b(t,n={}){if(!isPrivateKey(t))throw new a("Expected a hex-encoded 32-byte private key.");return q(createWalletClient({account:privateKeyToAccount(t),chain:n.chain??polygon,transport:n.transport??http()}))}async function A(t,n){try{let e=await t.sendTransaction(n);return expectTxHash(e)}catch(e){c(e);}}async function K(t,n$1){try{let e=t.chain?.id??await t.getChainId();if(e!==n$1)throw new n(`Wallet client is connected to chain ${e}, expected ${n$1}`)}catch(e){throw e instanceof n?e:n.fromError(e,"Could not resolve wallet client chain ID")}}async function I(t,n){try{return await t.signTypedData(n)}catch(e){c(e);}}async function R(t,n){try{return await t.signMessage(n)}catch(e){c(e);}}function c(t){if(t instanceof UserRejectedRequestError)throw k.fromError(t);if(t instanceof TransactionExecutionError){let n=t.walk(e=>e instanceof UserRejectedRequestError);if(n)throw k.fromError(n)}throw n.fromError(t)}var s=class{transactionId=null;#t;#n;constructor(n,e){this.#t=expectTxHash(n),this.#n=e;}get transactionHash(){return this.#t}async wait(){try{let n=await waitForTransactionReceipt(this.#n,{hash:this.#t}),e=expectTxHash(n.transactionHash);if(this.#t=e,n.status==="reverted")throw new j(`Transaction ${e} reverted`);return {transactionHash:e,transactionId:null}}catch(n){throw n instanceof WaitForTransactionReceiptTimeoutError?new i(`Timed out waiting for transaction ${this.#t} to settle`,{cause:n}):c$1.fromError(n)}}};export{b as privateKey,q as signerFrom};//# sourceMappingURL=viem.js.map
|
|
2
2
|
//# sourceMappingURL=viem.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarket/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "The Polymarket TypeScript client",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"ky": "^1.14.3",
|
|
94
94
|
"ox": "^0.14.16",
|
|
95
95
|
"zod": "^4.3.6",
|
|
96
|
-
"@polymarket/bindings": "0.
|
|
96
|
+
"@polymarket/bindings": "0.11.0",
|
|
97
97
|
"@polymarket/types": "0.2.0"
|
|
98
98
|
},
|
|
99
99
|
"publishConfig": {
|
package/dist/chunk-DLZLJOGO.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import {PolymarketError}from'@polymarket/types';var v=/^[$A-Z_a-z][$\w]*$/;function i(e){let r=c(e.issues);return r.length===0?"It was not possible to determine a more specific reason.":["Fix the following issues:",p(r)].join(`
|
|
2
|
-
`)}function u(e,r){let t=c(e.issues);return t.length===0?["Received an incompatible API response.",`Endpoint: ${r.endpoint}`,"This usually means the API response shape changed in a breaking way or the SDK is outdated.","It was not possible to determine a more specific reason."].join(`
|
|
3
|
-
`):["Received an incompatible API response.",`Endpoint: ${r.endpoint}`,"This usually means the API response shape changed in a breaking way or the SDK is outdated.","Fix the following issues:",p(t)].join(`
|
|
4
|
-
`)}function p(e){return e.map(t=>t.path===null?`- ${t.message}`:`- ${t.path}: ${t.message}`).join(`
|
|
5
|
-
`)}function c(e){return d(e).slice(0,99)}function d(e,r=[]){let t=e.flatMap(n=>{let a=[...r,...n.path];return n.code==="invalid_union"?n.errors.flatMap(A=>d(A,a)):[{code:n.code,message:n.message,path:a.length===0?null:T(a)}]});return U(t)}function U(e){let r=new Set,t=[];for(let n of e){let a=`${n.code}:${n.path??""}:${n.message}`;r.has(a)||(r.add(a),t.push(n));}return t.sort(Z)}function Z(e,r){return e.path===null&&r.path!==null?-1:e.path!==null&&r.path===null?1:(e.path??"").localeCompare(r.path??"")}function T(e){return e.reduce((r,t)=>typeof t=="number"?`${r}[${t.toString()}]`:typeof t!="string"?r:t.includes('"')?`${r}["${t.replaceAll('"','\\"')}"]`:v.test(t)?r.length===0?t:`${r}.${t}`:`${r}["${t}"]`,"")}var m=class e extends PolymarketError{name="UserInputError";constructor(r,t={}){super(r,t);}static fromZodError(r){return new e(i(r),{cause:r})}},l=class e extends PolymarketError{name="UnexpectedResponseError";constructor(r,t={}){super(r,t);}static fromZodError(r,t){return new e(u(r,t),{cause:r})}},f=class e extends PolymarketError{name="TransportError";constructor(r,t={}){super(r,t);}static fromError(r){return new e(r instanceof Error?r.message:"Request failed",{cause:r})}},L=(s=>(s[s.NormalClosure=1e3]="NormalClosure",s[s.GoingAway=1001]="GoingAway",s[s.ProtocolError=1002]="ProtocolError",s[s.UnsupportedData=1003]="UnsupportedData",s[s.NoStatusReceived=1005]="NoStatusReceived",s[s.AbnormalClosure=1006]="AbnormalClosure",s[s.InvalidFramePayload=1007]="InvalidFramePayload",s[s.PolicyViolation=1008]="PolicyViolation",s[s.MessageTooBig=1009]="MessageTooBig",s[s.InternalError=1011]="InternalError",s[s.ServiceRestart=1012]="ServiceRestart",s[s.TryAgainLater=1013]="TryAgainLater",s))(L||{}),g=class extends PolymarketError{name="ConnectionLostError";code;reason;constructor(r,t){super(r,t),this.code=t.code,this.reason=t.reason;}},P=(t=>(t.RESTARTING="restarting",t.POST_ONLY="post_only",t))(P||{}),y=class extends PolymarketError{name="RequestRejectedError";status;code;retryAfter;restriction;constructor(r,t){super(r,t),this.status=t.status,this.code=t.code,this.retryAfter=t.retryAfter,this.restriction=t.restriction;}},E=class extends PolymarketError{name="RateLimitError";retryAfter;rateLimit;constructor(r,t={}){super(r,t),this.retryAfter=t.retryAfter,this.rateLimit=t.rateLimit;}},I=class extends PolymarketError{name="TimeoutError";constructor(r,t={}){super(r,t);}},x=class extends PolymarketError{name="TransactionFailedError";constructor(r,t={}){super(r,t);}},h=class e extends PolymarketError{name="CancelledSigningError";constructor(r,t={}){super(r,t);}static fromError(r){return new e(r.message,{cause:r})}},R=class extends PolymarketError{name="InsufficientLiquidityError";constructor(r,t={}){super(r,t);}},$=class extends PolymarketError{name="AutoCancelDailyLimitError";constructor(r,t={}){super(r,t);}},O=class e extends PolymarketError{name="SigningError";constructor(r,t={}){super(r,t);}static fromError(r,t){let n=t??(r instanceof Error?r.message:"Signing failed");return new e(n,{cause:r})}};function N(...e){return {isError(r){return e.some(t=>r instanceof t)}}}export{m as a,l as b,f as c,L as d,g as e,P as f,y as g,E as h,I as i,x as j,h as k,R as l,$ as m,O as n,N as o};//# sourceMappingURL=chunk-DLZLJOGO.js.map
|
|
6
|
-
//# sourceMappingURL=chunk-DLZLJOGO.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/validation.ts","../src/errors.ts"],"names":["identifierRegex","formatInputZodError","error","issues","flattenIssues","formatIssues","formatResponseZodError","context","issue","flattenIssueBranches","pathPrefix","flattened","path","branch","formatPath","dedupeIssues","seen","deduped","key","compareIssues","left","right","result","segment","UserInputError","_UserInputError","PolymarketError","message","options","UnexpectedResponseError","_UnexpectedResponseError","TransportError","_TransportError","WebSocketKnownCloseCode","ConnectionLostError","TradingRestriction","RequestRejectedError","RateLimitError","TimeoutError","TransactionFailedError","CancelledSigningError","_CancelledSigningError","InsufficientLiquidityError","AutoCancelDailyLimitError","SigningError","_SigningError","msg","makeErrorGuard","classes","c"],"mappings":"gDAGA,IAAMA,CAAAA,CAAkB,oBAAA,CAejB,SAASC,CAAAA,CAAoBC,CAAAA,CAAyB,CAC3D,IAAMC,CAAAA,CAASC,CAAAA,CAAcF,CAAAA,CAAM,MAAM,CAAA,CAEzC,OAAIC,CAAAA,CAAO,MAAA,GAAW,CAAA,CACb,0DAAA,CAGF,CAAC,2BAAA,CAA6BE,CAAAA,CAAaF,CAAM,CAAC,CAAA,CAAE,IAAA,CAAK;AAAA,CAAI,CACtE,CAKO,SAASG,CAAAA,CACdJ,CAAAA,CACAK,CAAAA,CACQ,CACR,IAAMJ,CAAAA,CAASC,CAAAA,CAAcF,CAAAA,CAAM,MAAM,CAAA,CAEzC,OAAIC,CAAAA,CAAO,MAAA,GAAW,CAAA,CACb,CACL,wCAAA,CACA,CAAA,UAAA,EAAaI,CAAAA,CAAQ,QAAQ,CAAA,CAAA,CAC7B,6FAAA,CACA,0DACF,CAAA,CAAE,IAAA,CAAK;AAAA,CAAI,CAAA,CAGN,CACL,wCAAA,CACA,CAAA,UAAA,EAAaA,CAAAA,CAAQ,QAAQ,CAAA,CAAA,CAC7B,6FAAA,CACA,2BAAA,CACAF,CAAAA,CAAaF,CAAM,CACrB,EAAE,IAAA,CAAK;AAAA,CAAI,CACb,CAEA,SAASE,C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,CAAN,cAAwCjB,eAAgB,CACpD,IAAA,CAAO,2BAAA,CAEhB,YAAYC,CAAAA,CAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,CAAAA,CAASC,CAAO,EACxB,CACF,CAAA,CAMagB,CAAAA,CAAN,MAAMC,CAAAA,SAAqBnB,eAAgB,CACvC,IAAA,CAAO,cAAA,CAEhB,WAAA,CAAYC,EAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,MAAMD,CAAAA,CAASC,CAAO,EACxB,CAEA,OAAO,SAAA,CAAU1B,CAAAA,CAAgByB,CAAAA,CAAgC,CAC/D,IAAMmB,CAAAA,CACJnB,CAAAA,GAAYzB,CAAAA,YAAiB,KAAA,CAAQA,EAAM,OAAA,CAAU,gBAAA,CAAA,CACvD,OAAO,IAAI2C,EAAaC,CAAAA,CAAK,CAAE,KAAA,CAAO5C,CAAM,CAAC,CAC/C,CACF,EAEO,SAAS6C,KAIXC,CAAAA,CACmE,CACtE,OAAO,CACL,QAAQ9C,CAAAA,CAAyD,CAC/D,OAAO8C,CAAAA,CAAQ,KAAMC,CAAAA,EAAM/C,CAAAA,YAAiB+C,CAAC,CAC/C,CACF,CACF","file":"chunk-DLZLJOGO.js","sourcesContent":["import type { core, ZodError } from 'zod';\n\nconst maxIssuesInMessage = 99;\nconst identifierRegex = /^[$A-Z_a-z][$\\w]*$/;\n\ntype UserInputIssue = {\n code: string;\n message: string;\n path: string | null;\n};\n\nexport type ResponseValidationContext = {\n endpoint: string;\n};\n\n/**\n * Formats a `ZodError` into an SDK-oriented input validation message.\n */\nexport function formatInputZodError(error: ZodError): string {\n const issues = flattenIssues(error.issues);\n\n if (issues.length === 0) {\n return 'It was not possible to determine a more specific reason.';\n }\n\n return ['Fix the following issues:', formatIssues(issues)].join('\\n');\n}\n\n/**\n * Formats a `ZodError` into an SDK-oriented response validation message.\n */\nexport function formatResponseZodError(\n error: ZodError,\n context: ResponseValidationContext,\n): string {\n const issues = flattenIssues(error.issues);\n\n if (issues.length === 0) {\n return [\n 'Received an incompatible API response.',\n `Endpoint: ${context.endpoint}`,\n 'This usually means the API response shape changed in a breaking way or the SDK is outdated.',\n 'It was not possible to determine a more specific reason.',\n ].join('\\n');\n }\n\n return [\n 'Received an incompatible API response.',\n `Endpoint: ${context.endpoint}`,\n 'This usually means the API response shape changed in a breaking way or the SDK is outdated.',\n 'Fix the following issues:',\n formatIssues(issues),\n ].join('\\n');\n}\n\nfunction formatIssues(issues: readonly UserInputIssue[]): string {\n const lines = issues.map((issue) => {\n if (issue.path === null) {\n return `- ${issue.message}`;\n }\n\n return `- ${issue.path}: ${issue.message}`;\n });\n\n return lines.join('\\n');\n}\n\nfunction flattenIssues(issues: readonly core.$ZodIssue[]): UserInputIssue[] {\n return flattenIssueBranches(issues).slice(0, maxIssuesInMessage);\n}\n\nfunction flattenIssueBranches(\n issues: readonly core.$ZodIssue[],\n pathPrefix: readonly PropertyKey[] = [],\n): UserInputIssue[] {\n const flattened = issues.flatMap((issue) => {\n const path = [...pathPrefix, ...issue.path];\n\n if (issue.code === 'invalid_union') {\n return issue.errors.flatMap((branch) =>\n flattenIssueBranches(branch, path),\n );\n }\n\n return [\n {\n code: issue.code,\n message: issue.message,\n path: path.length === 0 ? null : formatPath(path),\n } satisfies UserInputIssue,\n ];\n });\n\n return dedupeIssues(flattened);\n}\n\nfunction dedupeIssues(issues: readonly UserInputIssue[]): UserInputIssue[] {\n const seen = new Set<string>();\n const deduped: UserInputIssue[] = [];\n\n for (const issue of issues) {\n const key = `${issue.code}:${issue.path ?? ''}:${issue.message}`;\n\n if (seen.has(key)) {\n continue;\n }\n\n seen.add(key);\n deduped.push(issue);\n }\n\n return deduped.sort(compareIssues);\n}\n\nfunction compareIssues(left: UserInputIssue, right: UserInputIssue): number {\n if (left.path === null && right.path !== null) {\n return -1;\n }\n\n if (left.path !== null && right.path === null) {\n return 1;\n }\n\n return (left.path ?? '').localeCompare(right.path ?? '');\n}\n\nfunction formatPath(path: readonly PropertyKey[]): string {\n return path.reduce<string>((result, segment) => {\n if (typeof segment === 'number') {\n return `${result}[${segment.toString()}]`;\n }\n\n if (typeof segment !== 'string') {\n return result;\n }\n\n if (segment.includes('\"')) {\n return `${result}[\"${segment.replaceAll('\"', '\\\\\"')}\"]`;\n }\n\n if (!identifierRegex.test(segment)) {\n return `${result}[\"${segment}\"]`;\n }\n\n if (result.length === 0) {\n return segment;\n }\n\n return `${result}.${segment}`;\n }, '');\n}\n","import { PolymarketError } from '@polymarket/types';\nimport type { ZodError } from 'zod';\nimport type { RateLimitUpdate } from './rate-limit';\nimport {\n formatInputZodError,\n formatResponseZodError,\n type ResponseValidationContext,\n} from './validation';\n\n/**\n * Error thrown when an action input fails SDK validation before a request is\n * sent.\n */\nexport class UserInputError extends PolymarketError {\n override name = 'UserInputError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromZodError(error: ZodError): UserInputError {\n return new UserInputError(formatInputZodError(error), {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when a service response does not match the action's expected\n * response shape.\n */\nexport class UnexpectedResponseError extends PolymarketError {\n override name = 'UnexpectedResponseError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromZodError(\n error: ZodError,\n context: ResponseValidationContext,\n ): UnexpectedResponseError {\n return new UnexpectedResponseError(formatResponseZodError(error, context), {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when the SDK cannot complete a request because of a network or\n * runtime transport failure.\n */\nexport class TransportError extends PolymarketError {\n override name = 'TransportError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: unknown): TransportError {\n return new TransportError(\n error instanceof Error ? error.message : 'Request failed',\n {\n cause: error,\n },\n );\n }\n}\n\n/**\n * WebSocket close codes defined by RFC 6455 and the IANA WebSocket Close Code\n * Number registry. Codes 4000-4999 are reserved for application use and are\n * intentionally not modeled here.\n */\nexport enum WebSocketKnownCloseCode {\n NormalClosure = 1000,\n GoingAway = 1001,\n ProtocolError = 1002,\n UnsupportedData = 1003,\n /** Synthesized locally when the peer closed without a status code. */\n NoStatusReceived = 1005,\n /** Synthesized locally when the connection dropped without a close frame. */\n AbnormalClosure = 1006,\n InvalidFramePayload = 1007,\n PolicyViolation = 1008,\n MessageTooBig = 1009,\n InternalError = 1011,\n ServiceRestart = 1012,\n TryAgainLater = 1013,\n}\n\n/**\n * A WebSocket close code. Codes enumerated in\n * {@link WebSocketKnownCloseCode} are defined by RFC 6455; other values, such\n * as application-defined 4000-4999 codes, flow through as plain numbers.\n */\nexport type WebSocketCloseCode = WebSocketKnownCloseCode | (number & {});\n\nexport type ConnectionLostErrorOptions = {\n /** WebSocket close code reported for the lost connection. */\n code: WebSocketCloseCode;\n /** Close reason provided by the peer. Empty when none was sent. */\n reason: string;\n};\n\n/**\n * Error thrown when a live connection ends without the SDK requesting it.\n */\nexport class ConnectionLostError extends PolymarketError {\n override name = 'ConnectionLostError' as const;\n\n readonly code: WebSocketCloseCode;\n readonly reason: string;\n\n constructor(\n message: string,\n options: ErrorOptions & ConnectionLostErrorOptions,\n ) {\n super(message, options);\n this.code = options.code;\n this.reason = options.reason;\n }\n}\n\n/**\n * Trading restriction reported by the venue while orders cannot be placed\n * normally. The SDK does not retry automatically; callers decide how to\n * react, honoring {@link RequestRejectedError.retryAfter} when provided.\n */\nexport enum TradingRestriction {\n /** The matching engine is restarting and rejects order requests until it is back. */\n RESTARTING = 'restarting',\n /** Cancels and post-only orders are accepted; other orders are rejected. */\n POST_ONLY = 'post_only',\n}\n\nexport type RequestRejectedErrorOptions = {\n status: number;\n /**\n * Machine-readable error code from the response body, when the service\n * provided one.\n */\n code?: string;\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n retryAfter?: number;\n /**\n * Trading restriction that caused the rejection, when the response\n * identified one.\n */\n restriction?: TradingRestriction;\n};\n\n/**\n * Error thrown when a service responds with a non-success status other than\n * rate limiting.\n */\nexport class RequestRejectedError extends PolymarketError {\n override name = 'RequestRejectedError' as const;\n\n readonly status: number;\n /**\n * Machine-readable error code from the response body, when the service\n * provided one.\n */\n readonly code?: string;\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n readonly retryAfter?: number;\n /**\n * Trading restriction that caused the rejection, when the response\n * identified one.\n */\n readonly restriction?: TradingRestriction;\n\n constructor(\n message: string,\n options: ErrorOptions & RequestRejectedErrorOptions,\n ) {\n super(message, options);\n this.status = options.status;\n this.code = options.code;\n this.retryAfter = options.retryAfter;\n this.restriction = options.restriction;\n }\n}\n\nexport type RateLimitErrorOptions = {\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n retryAfter?: number;\n /**\n * Rate-limit state reported with the rejection, when the response provided\n * it.\n */\n rateLimit?: RateLimitUpdate;\n};\n\n/**\n * Error thrown when the service rejects a request because the rate limit has\n * been exceeded.\n */\nexport class RateLimitError extends PolymarketError {\n override name = 'RateLimitError' as const;\n\n /**\n * Server-requested delay in seconds before retrying, when the response\n * provided one.\n */\n readonly retryAfter?: number;\n /**\n * Rate-limit state reported with the rejection, when the response provided\n * it.\n */\n readonly rateLimit?: RateLimitUpdate;\n\n constructor(\n message: string,\n options: ErrorOptions & RateLimitErrorOptions = {},\n ) {\n super(message, options);\n this.retryAfter = options.retryAfter;\n this.rateLimit = options.rateLimit;\n }\n}\n\n/**\n * Error thrown when an async wait operation exceeds its allotted polling time.\n */\nexport class TimeoutError extends PolymarketError {\n override name = 'TimeoutError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when a submitted transaction reaches a terminal failure state.\n */\nexport class TransactionFailedError extends PolymarketError {\n override name = 'TransactionFailedError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when the user cancels a required wallet signing action.\n */\nexport class CancelledSigningError extends PolymarketError {\n override name = 'CancelledSigningError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: Error): CancelledSigningError {\n return new CancelledSigningError(error.message, {\n cause: error,\n });\n }\n}\n\n/**\n * Error thrown when there is not enough resting market liquidity to satisfy the\n * requested execution semantics.\n */\nexport class InsufficientLiquidityError extends PolymarketError {\n override name = 'InsufficientLiquidityError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when arming auto-cancel is rejected because the account has\n * reached its daily auto-cancel trigger limit. Arming is rejected until the\n * daily counter resets at the next UTC midnight; clearing an existing\n * schedule is always allowed.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport class AutoCancelDailyLimitError extends PolymarketError {\n override name = 'AutoCancelDailyLimitError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Error thrown when the SDK cannot produce a required signature or\n * authentication payload.\n */\nexport class SigningError extends PolymarketError {\n override name = 'SigningError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromError(error: unknown, message?: string): SigningError {\n const msg =\n message ?? (error instanceof Error ? error.message : 'Signing failed');\n return new SigningError(msg, { cause: error });\n }\n}\n\nexport function makeErrorGuard<\n // biome-ignore lint/suspicious/noExplicitAny: constructor rest args require any[]\n TClasses extends ReadonlyArray<new (...args: any[]) => unknown>,\n>(\n ...classes: TClasses\n): { isError(error: unknown): error is InstanceType<TClasses[number]> } {\n return {\n isError(error: unknown): error is InstanceType<TClasses[number]> {\n return classes.some((c) => error instanceof c);\n },\n };\n}\n"]}
|