@polymarket/client 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +177 -0
- package/dist/actions/index.d.ts +10 -10
- package/dist/actions/index.js +1 -1
- package/dist/chunk-IRLMIGOU.js +3 -0
- package/dist/chunk-IRLMIGOU.js.map +1 -0
- package/dist/chunk-U54M5MQK.js +2 -0
- package/dist/chunk-U54M5MQK.js.map +1 -0
- package/dist/chunk-XUX2UYIW.js +6 -0
- package/dist/chunk-XUX2UYIW.js.map +1 -0
- package/dist/ethers-v5.d.ts +1 -1
- package/dist/ethers-v5.js +1 -1
- package/dist/ethers-v5.js.map +1 -1
- package/dist/index.d.ts +51 -10
- 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-DxgyI41A.d.ts → sports-CW4y_VKL.d.ts} +7 -7
- package/dist/{types-BGxCI8uu.d.ts → types-CprSC_sB.d.ts} +1029 -383
- package/dist/viem.d.ts +1 -1
- package/dist/viem.js +1 -1
- package/dist/viem.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-6GBGW5CG.js +0 -2
- package/dist/chunk-6GBGW5CG.js.map +0 -1
- package/dist/chunk-MY66WYAN.js +0 -3
- package/dist/chunk-MY66WYAN.js.map +0 -1
- package/dist/chunk-VLNLVY4C.js +0 -6
- package/dist/chunk-VLNLVY4C.js.map +0 -1
package/dist/node.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {e}from'./chunk-
|
|
1
|
+
import {e}from'./chunk-U54M5MQK.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-U54M5MQK.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 { dh as RateLimitError, ds as RequestRejectedError, eD as SigningError, eR as TransportError, eU as UnexpectedResponseError, U as UserInputError, by as InsufficientLiquidityError, t as BaseSecureClient, hw as PrepareLimitOrderRequest, h9 as OrderWorkflow, h8 as OrderPostingWorkflow, hy as PrepareMarketOrderRequest, I as CancelledSigningError, cZ as PostOrderError, eH as TimeoutError, eL as TransactionFailedError, eA as SignedOrder, dm as RequestAbortedError, B as BaseClient, dr as RequestOptions } from './types-CprSC_sB.js';
|
|
3
3
|
import { SportsMarketTypesResponse, SportsMetadata } from '@polymarket/bindings/gamma';
|
|
4
4
|
|
|
5
5
|
type PrepareMarketOrderError = InsufficientLiquidityError | RateLimitError | RequestRejectedError | SigningError | TransportError | UnexpectedResponseError | UserInputError;
|
|
@@ -186,9 +186,9 @@ declare const PlaceLimitOrderError: {
|
|
|
186
186
|
*/
|
|
187
187
|
declare function placeLimitOrder(client: BaseSecureClient, request: PrepareLimitOrderRequest): Promise<OrderResponse>;
|
|
188
188
|
|
|
189
|
-
type ListSportsError = RateLimitError | RequestRejectedError | TransportError | UnexpectedResponseError;
|
|
189
|
+
type ListSportsError = RequestAbortedError | RateLimitError | RequestRejectedError | TransportError | UnexpectedResponseError | UserInputError;
|
|
190
190
|
declare const ListSportsError: {
|
|
191
|
-
isError(error: unknown): error is TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
|
|
191
|
+
isError(error: unknown): error is TransportError | UserInputError | UnexpectedResponseError | RequestAbortedError | RequestRejectedError | RateLimitError;
|
|
192
192
|
};
|
|
193
193
|
/**
|
|
194
194
|
* Lists available sports metadata.
|
|
@@ -206,10 +206,10 @@ declare const ListSportsError: {
|
|
|
206
206
|
* // sports: SportsMetadata[]
|
|
207
207
|
* ```
|
|
208
208
|
*/
|
|
209
|
-
declare function listSports(client: BaseClient): Promise<SportsMetadata[]>;
|
|
210
|
-
type FetchSportsMarketTypesError = RateLimitError | RequestRejectedError | TransportError | UnexpectedResponseError;
|
|
209
|
+
declare function listSports(client: BaseClient, options?: RequestOptions): Promise<SportsMetadata[]>;
|
|
210
|
+
type FetchSportsMarketTypesError = RequestAbortedError | RateLimitError | RequestRejectedError | TransportError | UnexpectedResponseError | UserInputError;
|
|
211
211
|
declare const FetchSportsMarketTypesError: {
|
|
212
|
-
isError(error: unknown): error is TransportError | UnexpectedResponseError | RequestRejectedError | RateLimitError;
|
|
212
|
+
isError(error: unknown): error is TransportError | UserInputError | UnexpectedResponseError | RequestAbortedError | RequestRejectedError | RateLimitError;
|
|
213
213
|
};
|
|
214
214
|
/**
|
|
215
215
|
* Fetches the available market types grouped by sport.
|
|
@@ -227,6 +227,6 @@ declare const FetchSportsMarketTypesError: {
|
|
|
227
227
|
* // marketTypes === SportsMarketTypesResponse
|
|
228
228
|
* ```
|
|
229
229
|
*/
|
|
230
|
-
declare function fetchSportsMarketTypes(client: BaseClient): Promise<SportsMarketTypesResponse>;
|
|
230
|
+
declare function fetchSportsMarketTypes(client: BaseClient, options?: RequestOptions): Promise<SportsMarketTypesResponse>;
|
|
231
231
|
|
|
232
232
|
export { CreateLimitOrderError as C, FetchSportsMarketTypesError as F, ListSportsError as L, PlaceLimitOrderError as P, CreateMarketOrderError as a, PlaceMarketOrderError as b, PrepareLimitOrderError as c, PrepareLimitOrderPostingError as d, PrepareMarketOrderError as e, PrepareMarketOrderPostingError as f, createLimitOrder as g, createMarketOrder as h, fetchSportsMarketTypes as i, placeMarketOrder as j, prepareLimitOrder as k, listSports as l, prepareLimitOrderPosting as m, prepareMarketOrder as n, prepareMarketOrderPosting as o, placeLimitOrder as p };
|