@kuest/sdk 0.0.0-stage → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/actions/index.d.ts +180 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/chunk-3QTVWIZS.js +3 -0
- package/dist/chunk-3QTVWIZS.js.map +1 -0
- package/dist/chunk-EH4TD6KD.js +2 -0
- package/dist/chunk-EH4TD6KD.js.map +1 -0
- package/dist/chunk-LDEY5CK7.js +6 -0
- package/dist/chunk-LDEY5CK7.js.map +1 -0
- package/dist/ethers-v5.d.ts +24 -0
- package/dist/ethers-v5.js +2 -0
- package/dist/ethers-v5.js.map +1 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +24 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/privy.d.ts +13 -0
- package/dist/privy.js +2 -0
- package/dist/privy.js.map +1 -0
- package/dist/sports-Bt7NXBWp.d.ts +232 -0
- package/dist/types-CI9Rwzhy.d.ts +12021 -0
- package/dist/types-DDzoOHmH.d.ts +66 -0
- package/dist/viem.d.ts +35 -0
- package/dist/viem.js +2 -0
- package/dist/viem.js.map +1 -0
- package/package.json +103 -3
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'@kuest/bindings';import'@kuest/bindings/subscriptions';import {MarketSdkError}from'@kuest/types';var n=class t extends MarketSdkError{name="TransportError";constructor(r,e={}){super(r,e);}static fromError(r){return new t(r instanceof Error?r.message:"Request failed",{cause:r})}};var o=class extends MarketSdkError{name="TimeoutError";constructor(r,e={}){super(r,e);}};var a=class extends MarketSdkError{name="TransactionFailedError";constructor(r,e={}){super(r,e);}},i=class t extends MarketSdkError{name="CancelledSigningError";constructor(r,e={}){super(r,e);}static fromError(r){return new t(r.message,{cause:r})}};var p=class t extends MarketSdkError{name="SigningError";constructor(r,e={}){super(r,e);}static fromError(r,e){let c=e??(r instanceof Error?r.message:"Signing failed");return new t(c,{cause:r})}};export{n as a,o as b,a as c,i as d,p as e};//# sourceMappingURL=chunk-EH4TD6KD.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-EH4TD6KD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"names":["TransportError","_TransportError","MarketSdkError","message","options","error","TimeoutError","TransactionFailedError","CancelledSigningError","_CancelledSigningError","SigningError","_SigningError","msg"],"mappings":"wGAoFO,IAAMA,CAAAA,CAAN,MAAMC,CAAAA,SAAuBC,cAAe,CACxC,IAAA,CAAO,gBAAA,CAEhB,WAAA,CAAYC,EAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,MAAMD,CAAAA,CAASC,CAAO,EACxB,CAEA,OAAO,SAAA,CAAUC,CAAAA,CAAgC,CAC/C,OAAO,IAAIJ,EACTI,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,iBACzC,CACE,KAAA,CAAOA,CACT,CACF,CACF,CACF,EAsMO,IAAMC,CAAAA,CAAN,cAA2BJ,cAAe,CACtC,KAAO,cAAA,CAEhB,WAAA,CAAYC,EAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,MAAMD,CAAAA,CAASC,CAAO,EACxB,CACF,EAsBO,IAAMG,CAAAA,CAAN,cAAqCL,cAAe,CAChD,IAAA,CAAO,wBAAA,CAEhB,YAAYC,CAAAA,CAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,CAAAA,CAASC,CAAO,EACxB,CACF,CAAA,CAKaI,CAAAA,CAAN,MAAMC,CAAAA,SAA8BP,cAAe,CAC/C,IAAA,CAAO,wBAEhB,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAwB,GAAI,CACvD,KAAA,CAAMD,CAAAA,CAASC,CAAO,EACxB,CAEA,OAAO,SAAA,CAAUC,CAAAA,CAAqC,CACpD,OAAO,IAAII,CAAAA,CAAsBJ,CAAAA,CAAM,QAAS,CAC9C,KAAA,CAAOA,CACT,CAAC,CACH,CACF,EA0EO,IAAMK,CAAAA,CAAN,MAAMC,UAAqBT,cAAe,CACtC,IAAA,CAAO,cAAA,CAEhB,YAAYC,CAAAA,CAAiBC,CAAAA,CAAwB,EAAC,CAAG,CACvD,KAAA,CAAMD,CAAAA,CAASC,CAAO,EACxB,CAEA,OAAO,SAAA,CAAUC,CAAAA,CAAgBF,CAAAA,CAAgC,CAC/D,IAAMS,CAAAA,CACJT,CAAAA,GAAYE,CAAAA,YAAiB,KAAA,CAAQA,EAAM,OAAA,CAAU,gBAAA,CAAA,CACvD,OAAO,IAAIM,EAAaC,CAAAA,CAAK,CAAE,MAAOP,CAAM,CAAC,CAC/C,CACF","file":"chunk-EH4TD6KD.js","sourcesContent":["import type { GatewayErrorCode } from '@kuest/bindings';\n\nexport {\n type GatewayErrorCode,\n GatewayKnownErrorCode,\n} from '@kuest/bindings';\n\nimport type { PerpsCancelOrderResult } from '@kuest/bindings/perps';\n\nexport {\n type RealtimeErrorCode,\n RealtimeKnownErrorCode,\n} from '@kuest/bindings/subscriptions';\n\nimport { MarketSdkError } from '@kuest/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 MarketSdkError {\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 pagination would pass the deepest page the service serves\n * for a list.\n *\n * Some list endpoints cap how far an offset-paginated read may go and reject\n * requests past the cap. The SDK throws this before sending such a request;\n * the pages already returned stay valid, but whether more items exist past\n * the cap cannot be established. Automatic iteration stops normally on a page\n * with `limitReached: true`; explicitly resuming past the cap still throws.\n */\nexport class PaginationLimitError extends MarketSdkError {\n override name = 'PaginationLimitError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\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 MarketSdkError {\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 MarketSdkError {\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 * Error thrown when a caller cancels a read through its AbortSignal.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport class RequestAbortedError extends MarketSdkError {\n override name = 'RequestAbortedError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\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 MarketSdkError {\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?: GatewayErrorCode;\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 MarketSdkError {\n override name: 'RequestRejectedError' | 'OrderHeartbeatMismatchError' =\n 'RequestRejectedError';\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?: GatewayErrorCode;\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\n/**\n * An order heartbeat used a stale ID. Retry explicitly with heartbeatId and retain\n * the new ID from the successful response. A rejected send does not refresh the deadline.\n */\nexport class OrderHeartbeatMismatchError extends RequestRejectedError {\n override name = 'OrderHeartbeatMismatchError' as const;\n\n /** Currently expected ID. It can be empty after a legacy heartbeat. */\n readonly heartbeatId: string;\n\n constructor(heartbeatId: string) {\n super('Invalid Heartbeat ID', { status: 400 });\n this.heartbeatId = heartbeatId;\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 MarketSdkError {\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 MarketSdkError {\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 an operation is interrupted through an abort signal.\n */\nexport class OperationAbortedError extends MarketSdkError {\n override name = 'OperationAbortedError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromReason(reason: unknown): OperationAbortedError {\n return new OperationAbortedError('Operation was aborted.', {\n cause: reason,\n });\n }\n}\n\n/**\n * Error thrown when a submitted transaction reaches a terminal failure state.\n */\nexport class TransactionFailedError extends MarketSdkError {\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 MarketSdkError {\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 MarketSdkError {\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 MarketSdkError {\n override name = 'AutoCancelDailyLimitError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Details retained when a Perps cancellation retry fails.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport type PerpsCancelRetryErrorOptions = {\n /** Last received per-order outcomes, in the original request order. */\n results: readonly PerpsCancelOrderResult[];\n /** Zero-based original request positions retried in the failed attempt. */\n pendingIndexes: readonly number[];\n};\n\n/**\n * Error thrown when a Perps cancellation retry fails after per-order results\n * have already been received. The original failure is available as `cause`.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport class PerpsCancelRetryError extends MarketSdkError {\n override name = 'PerpsCancelRetryError' as const;\n\n /** Last received per-order outcomes, in the original request order. */\n readonly results: readonly PerpsCancelOrderResult[];\n /**\n * Zero-based original request positions retried in the failed attempt.\n * Their retained rejections are historical: a transport failure can conceal\n * completion, so these results do not establish the current order state.\n */\n readonly pendingIndexes: readonly number[];\n\n constructor(\n message: string,\n options: ErrorOptions & PerpsCancelRetryErrorOptions,\n ) {\n super(message, options);\n this.results = [...options.results];\n this.pendingIndexes = [...options.pendingIndexes];\n }\n}\n\n/**\n * Error thrown when the SDK cannot produce a required signature or\n * authentication payload.\n */\nexport class SigningError extends MarketSdkError {\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"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export{GatewayKnownErrorCode as u}from'@kuest/bindings';export{RealtimeKnownErrorCode as v}from'@kuest/bindings/subscriptions';import {MarketSdkError}from'@kuest/types';var L=/^[$A-Z_a-z][$\w]*$/;function u(t){let r=d(t.issues);return r.length===0?"It was not possible to determine a more specific reason.":["Fix the following issues:",c(r)].join(`
|
|
2
|
+
`)}function p(t,r){let e=d(t.issues);return e.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:",c(e)].join(`
|
|
4
|
+
`)}function c(t){return t.map(e=>e.path===null?`- ${e.message}`:`- ${e.path}: ${e.message}`).join(`
|
|
5
|
+
`)}function d(t){return l(t).slice(0,99)}function l(t,r=[]){let e=t.flatMap(o=>{let a=[...r,...o.path];return o.code==="invalid_union"?o.errors.flatMap(T=>l(T,a)):[{code:o.code,message:o.message,path:a.length===0?null:j(a)}]});return b(e)}function b(t){let r=new Set,e=[];for(let o of t){let a=`${o.code}:${o.path??""}:${o.message}`;r.has(a)||(r.add(a),e.push(o));}return e.sort(G)}function G(t,r){return t.path===null&&r.path!==null?-1:t.path!==null&&r.path===null?1:(t.path??"").localeCompare(r.path??"")}function j(t){return t.reduce((r,e)=>typeof e=="number"?`${r}[${e.toString()}]`:typeof e!="string"?r:e.includes('"')?`${r}["${e.replaceAll('"','\\"')}"]`:L.test(e)?r.length===0?e:`${r}.${e}`:`${r}["${e}"]`,"")}var m=class t extends MarketSdkError{name="UserInputError";constructor(r,e={}){super(r,e);}static fromZodError(r){return new t(u(r),{cause:r})}},y=class extends MarketSdkError{name="PaginationLimitError";constructor(r,e={}){super(r,e);}},f=class t extends MarketSdkError{name="UnexpectedResponseError";constructor(r,e={}){super(r,e);}static fromZodError(r,e){return new t(p(r,e),{cause:r})}},E=class t extends MarketSdkError{name="TransportError";constructor(r,e={}){super(r,e);}static fromError(r){return new t(r instanceof Error?r.message:"Request failed",{cause:r})}},g=class extends MarketSdkError{name="RequestAbortedError";constructor(r,e={}){super(r,e);}},w=(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))(w||{}),x=class extends MarketSdkError{name="ConnectionLostError";code;reason;constructor(r,e){super(r,e),this.code=e.code,this.reason=e.reason;}},M=(e=>(e.RESTARTING="restarting",e.POST_ONLY="post_only",e))(M||{}),i=class extends MarketSdkError{name="RequestRejectedError";status;code;retryAfter;restriction;constructor(r,e){super(r,e),this.status=e.status,this.code=e.code,this.retryAfter=e.retryAfter,this.restriction=e.restriction;}},I=class extends i{name="OrderHeartbeatMismatchError";heartbeatId;constructor(r){super("Invalid Heartbeat ID",{status:400}),this.heartbeatId=r;}},h=class extends MarketSdkError{name="RateLimitError";retryAfter;rateLimit;constructor(r,e={}){super(r,e),this.retryAfter=e.retryAfter,this.rateLimit=e.rateLimit;}},R=class extends MarketSdkError{name="TimeoutError";constructor(r,e={}){super(r,e);}},O=class t extends MarketSdkError{name="OperationAbortedError";constructor(r,e={}){super(r,e);}static fromReason(r){return new t("Operation was aborted.",{cause:r})}},v=class extends MarketSdkError{name="TransactionFailedError";constructor(r,e={}){super(r,e);}},$=class t extends MarketSdkError{name="CancelledSigningError";constructor(r,e={}){super(r,e);}static fromError(r){return new t(r.message,{cause:r})}},A=class extends MarketSdkError{name="InsufficientLiquidityError";constructor(r,e={}){super(r,e);}},P=class extends MarketSdkError{name="AutoCancelDailyLimitError";constructor(r,e={}){super(r,e);}},U=class extends MarketSdkError{name="PerpsCancelRetryError";results;pendingIndexes;constructor(r,e){super(r,e),this.results=[...e.results],this.pendingIndexes=[...e.pendingIndexes];}},Z=class t extends MarketSdkError{name="SigningError";constructor(r,e={}){super(r,e);}static fromError(r,e){let o=e??(r instanceof Error?r.message:"Signing failed");return new t(o,{cause:r})}};function N(...t){return {isError(r){return t.some(e=>r instanceof e)}}}export{m as a,y as b,f as c,E as d,g as e,w as f,x as g,M as h,i,I as j,h as k,R as l,O as m,v as n,$ as o,A as p,P as q,U as r,Z as s,N as t};//# sourceMappingURL=chunk-LDEY5CK7.js.map
|
|
6
|
+
//# sourceMappingURL=chunk-LDEY5CK7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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","MarketSdkError","message","options","PaginationLimitError","UnexpectedResponseError","_UnexpectedResponseError","TransportError","_TransportError","RequestAbortedError","WebSocketKnownCloseCode","ConnectionLostError","TradingRestriction","RequestRejectedError","OrderHeartbeatMismatchError","heartbeatId","RateLimitError","TimeoutError","OperationAbortedError","_OperationAbortedError","reason","TransactionFailedError","CancelledSigningError","_CancelledSigningError","InsufficientLiquidityError","AutoCancelDailyLimitError","PerpsCancelRetryError","SigningError","_SigningError","msg","makeErrorGuard","classes","c"],"mappings":"yKAGA,IAAMA,CAAAA,CAAkB,oBAAA,CAejB,SAASC,CAAAA,CAAoBC,CAAAA,CAAyB,CAC3D,IAAMC,EAASC,CAAAA,CAAcF,CAAAA,CAAM,MAAM,CAAA,CAEzC,OAAIC,CAAAA,CAAO,MAAA,GAAW,CAAA,CACb,0DAAA,CAGF,CAAC,2BAAA,CAA6BE,CAAAA,CAAaF,CAAM,CAAC,EAAE,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,C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,CAAU,gBAAA,CAAA,CACvD,OAAO,IAAImD,CAAAA,CAAaC,EAAK,CAAE,KAAA,CAAOpD,CAAM,CAAC,CAC/C,CACF,EAEO,SAASqD,KAIXC,CAAAA,CACmE,CACtE,OAAO,CACL,OAAA,CAAQtD,EAAyD,CAC/D,OAAOsD,EAAQ,IAAA,CAAMC,CAAAA,EAAMvD,aAAiBuD,CAAC,CAC/C,CACF,CACF","file":"chunk-LDEY5CK7.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 type { GatewayErrorCode } from '@kuest/bindings';\n\nexport {\n type GatewayErrorCode,\n GatewayKnownErrorCode,\n} from '@kuest/bindings';\n\nimport type { PerpsCancelOrderResult } from '@kuest/bindings/perps';\n\nexport {\n type RealtimeErrorCode,\n RealtimeKnownErrorCode,\n} from '@kuest/bindings/subscriptions';\n\nimport { MarketSdkError } from '@kuest/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 MarketSdkError {\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 pagination would pass the deepest page the service serves\n * for a list.\n *\n * Some list endpoints cap how far an offset-paginated read may go and reject\n * requests past the cap. The SDK throws this before sending such a request;\n * the pages already returned stay valid, but whether more items exist past\n * the cap cannot be established. Automatic iteration stops normally on a page\n * with `limitReached: true`; explicitly resuming past the cap still throws.\n */\nexport class PaginationLimitError extends MarketSdkError {\n override name = 'PaginationLimitError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\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 MarketSdkError {\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 MarketSdkError {\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 * Error thrown when a caller cancels a read through its AbortSignal.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport class RequestAbortedError extends MarketSdkError {\n override name = 'RequestAbortedError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\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 MarketSdkError {\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?: GatewayErrorCode;\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 MarketSdkError {\n override name: 'RequestRejectedError' | 'OrderHeartbeatMismatchError' =\n 'RequestRejectedError';\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?: GatewayErrorCode;\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\n/**\n * An order heartbeat used a stale ID. Retry explicitly with heartbeatId and retain\n * the new ID from the successful response. A rejected send does not refresh the deadline.\n */\nexport class OrderHeartbeatMismatchError extends RequestRejectedError {\n override name = 'OrderHeartbeatMismatchError' as const;\n\n /** Currently expected ID. It can be empty after a legacy heartbeat. */\n readonly heartbeatId: string;\n\n constructor(heartbeatId: string) {\n super('Invalid Heartbeat ID', { status: 400 });\n this.heartbeatId = heartbeatId;\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 MarketSdkError {\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 MarketSdkError {\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 an operation is interrupted through an abort signal.\n */\nexport class OperationAbortedError extends MarketSdkError {\n override name = 'OperationAbortedError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n\n static fromReason(reason: unknown): OperationAbortedError {\n return new OperationAbortedError('Operation was aborted.', {\n cause: reason,\n });\n }\n}\n\n/**\n * Error thrown when a submitted transaction reaches a terminal failure state.\n */\nexport class TransactionFailedError extends MarketSdkError {\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 MarketSdkError {\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 MarketSdkError {\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 MarketSdkError {\n override name = 'AutoCancelDailyLimitError' as const;\n\n constructor(message: string, options: ErrorOptions = {}) {\n super(message, options);\n }\n}\n\n/**\n * Details retained when a Perps cancellation retry fails.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport type PerpsCancelRetryErrorOptions = {\n /** Last received per-order outcomes, in the original request order. */\n results: readonly PerpsCancelOrderResult[];\n /** Zero-based original request positions retried in the failed attempt. */\n pendingIndexes: readonly number[];\n};\n\n/**\n * Error thrown when a Perps cancellation retry fails after per-order results\n * have already been received. The original failure is available as `cause`.\n *\n * @experimental This API may change in a breaking way in any release, including patch releases.\n */\nexport class PerpsCancelRetryError extends MarketSdkError {\n override name = 'PerpsCancelRetryError' as const;\n\n /** Last received per-order outcomes, in the original request order. */\n readonly results: readonly PerpsCancelOrderResult[];\n /**\n * Zero-based original request positions retried in the failed attempt.\n * Their retained rejections are historical: a transport failure can conceal\n * completion, so these results do not establish the current order state.\n */\n readonly pendingIndexes: readonly number[];\n\n constructor(\n message: string,\n options: ErrorOptions & PerpsCancelRetryErrorOptions,\n ) {\n super(message, options);\n this.results = [...options.results];\n this.pendingIndexes = [...options.pendingIndexes];\n }\n}\n\n/**\n * Error thrown when the SDK cannot produce a required signature or\n * authentication payload.\n */\nexport class SigningError extends MarketSdkError {\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"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ethers } from 'ethers-v5';
|
|
2
|
+
import { T as TypedDataPayload, a as TypedData, S as Signer } from './types-CI9Rwzhy.js';
|
|
3
|
+
import '@kuest/bindings';
|
|
4
|
+
import '@kuest/types';
|
|
5
|
+
import '@kuest/bindings/gamma';
|
|
6
|
+
import '@kuest/bindings/relayer';
|
|
7
|
+
import 'zod';
|
|
8
|
+
import '@kuest/bindings/clob';
|
|
9
|
+
import '@kuest/bindings/data';
|
|
10
|
+
import '@kuest/bindings/perps';
|
|
11
|
+
import '@kuest/bindings/combos';
|
|
12
|
+
import '@kuest/bindings/subscriptions';
|
|
13
|
+
import 'ox';
|
|
14
|
+
|
|
15
|
+
type EthersV5Signer = ethers.Signer & {
|
|
16
|
+
_signTypedData(domain: TypedDataPayload['domain'], types: ReturnType<typeof removeEip712Domain>, value: TypedDataPayload['message']): Promise<string>;
|
|
17
|
+
};
|
|
18
|
+
declare function signerFrom(signer: EthersV5Signer): Signer;
|
|
19
|
+
declare function removeEip712Domain(types: TypedData): Record<string, Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}>>;
|
|
23
|
+
|
|
24
|
+
export { signerFrom };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {s as s$1,o,d,n}from'./chunk-LDEY5CK7.js';import {expectEvmAddress,expectEvmSignature,expectTxHash}from'@kuest/types';import {ethers}from'ethers-v5';function A(n){return {getAddress(){return m(n)},signTypedData(r){return w(n,r)},signMessage(r){return T(n,r)},async sendTransaction(r){return new i(await f(n,r))}}}async function m(n){try{return expectEvmAddress(await n.getAddress())}catch(r){throw s$1.fromError(r,"Could not resolve signer address")}}async function f(n,r){try{return await n.sendTransaction({chainId:r.chainId,data:r.data,to:r.to,value:r.value?.toString()})}catch(t){c(t);}}async function w(n,r){try{return expectEvmSignature(await n._signTypedData(r.domain,S(r.types),r.message))}catch(t){c(t);}}async function T(n,r){try{return expectEvmSignature(await n.signMessage(ethers.utils.arrayify(r)))}catch(t){c(t);}}function S(n){let r=Object.entries(n).filter(([t])=>t!=="EIP712Domain");return Object.fromEntries(r.map(([t,p])=>[t,p.map(y=>({...y}))]))}function c(n){throw s(n)?new o("User rejected the signing request",{cause:n}):s$1.fromError(n)}function s(n,r=new Set){if(r.has(n)||n===null||typeof n!="object")return false;r.add(n);let t=n;return t.code===4001||t.code==="ACTION_REJECTED"||s(t.error,r)||s(t.cause,r)}function v(n){return g(n,"CALL_EXCEPTION")}function D(n){return g(n,"TRANSACTION_REPLACED")}function g(n,r){return n instanceof Error&&"code"in n&&n.code===r}var i=class{transactionId=null;#r;#n;constructor(r){this.#n=r,this.#r=expectTxHash(r.hash);}get transactionHash(){return this.#r}async wait(){try{let r=await this.#n.wait(),t=expectTxHash(r.transactionHash);return this.#r=t,{transactionHash:t,transactionId:null}}catch(r){if(D(r)){if(r.cancelled)throw d.fromError(r);let t=expectTxHash(r.receipt.transactionHash);return this.#r=t,{transactionHash:t,transactionId:null}}throw v(r)?new n(`Transaction ${this.#r} reverted`,{cause:r}):d.fromError(r)}}};export{A as signerFrom};//# sourceMappingURL=ethers-v5.js.map
|
|
2
|
+
//# sourceMappingURL=ethers-v5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ethers-v5.ts"],"names":["signerFrom","signer","getAddress","payload","signTypedData","message","signMessage","request","DirectTransactionHandle","sendTransaction","expectEvmAddress","error","SigningError","throwSigningWorkflowError","expectEvmSignature","removeEip712Domain","ethers","types","entries","name","fields","field","isUserRejectedError","CancelledSigningError","seen","candidate","isCallExceptionError","hasErrorCode","isTransactionReplacedError","code","#transactionHash","#transaction","transaction","expectTxHash","receipt","transactionHash","TransportError","TransactionFailedError"],"mappings":"4JA6BO,SAASA,CAAAA,CAAWC,CAAAA,CAAgC,CACzD,OAAO,CACL,YAAa,CACX,OAAOC,CAAAA,CAAWD,CAAM,CAC1B,CAAA,CACA,cAAcE,CAAAA,CAAS,CACrB,OAAOC,CAAAA,CAAcH,CAAAA,CAAQE,CAAO,CACtC,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n expectTxHash,\n type HexString,\n type TxHash,\n} from '@kuest/types';\nimport { ethers } from 'ethers-v5';\nimport {\n CancelledSigningError,\n SigningError,\n TransactionFailedError,\n TransportError,\n} from './errors';\nimport type {\n Signer,\n TransactionHandle,\n TypedData,\n TypedDataPayload,\n} from './types';\n\ntype EthersV5Signer = ethers.Signer & {\n _signTypedData(\n domain: TypedDataPayload['domain'],\n types: ReturnType<typeof removeEip712Domain>,\n value: TypedDataPayload['message'],\n ): Promise<string>;\n};\n\nexport function signerFrom(signer: EthersV5Signer): Signer {\n return {\n getAddress() {\n return getAddress(signer);\n },\n signTypedData(payload) {\n return signTypedData(signer, payload);\n },\n signMessage(message) {\n return signMessage(signer, message);\n },\n async sendTransaction(request) {\n return new DirectTransactionHandle(\n await sendTransaction(signer, request),\n );\n },\n };\n}\n\nasync function getAddress(signer: EthersV5Signer) {\n try {\n return expectEvmAddress(await signer.getAddress());\n } catch (error) {\n throw SigningError.fromError(error, 'Could not resolve signer address');\n }\n}\n\nasync function sendTransaction(\n signer: EthersV5Signer,\n request: { chainId: number; data?: HexString; to: string; value?: bigint },\n): Promise<ethers.providers.TransactionResponse> {\n try {\n return await signer.sendTransaction({\n chainId: request.chainId,\n data: request.data,\n to: request.to,\n value: request.value?.toString(),\n });\n } catch (error) {\n throwSigningWorkflowError(error);\n }\n}\n\nasync function signTypedData(\n signer: EthersV5Signer,\n payload: TypedDataPayload,\n) {\n try {\n return expectEvmSignature(\n await signer._signTypedData(\n payload.domain,\n removeEip712Domain(payload.types),\n payload.message,\n ),\n );\n } catch (error) {\n throwSigningWorkflowError(error);\n }\n}\n\nasync function signMessage(signer: EthersV5Signer, message: HexString) {\n try {\n return expectEvmSignature(\n await signer.signMessage(ethers.utils.arrayify(message)),\n );\n } catch (error) {\n throwSigningWorkflowError(error);\n }\n}\n\nfunction removeEip712Domain(\n types: TypedData,\n): Record<string, Array<{ name: string; type: string }>> {\n const entries = Object.entries(types).filter(\n ([name]) => name !== 'EIP712Domain',\n );\n\n return Object.fromEntries(\n entries.map(([name, fields]) => [\n name,\n fields.map((field) => ({ ...field })),\n ]),\n );\n}\n\nfunction throwSigningWorkflowError(error: unknown): never {\n if (isUserRejectedError(error)) {\n throw new CancelledSigningError('User rejected the signing request', {\n cause: error,\n });\n }\n\n throw SigningError.fromError(error);\n}\n\nfunction isUserRejectedError(\n error: unknown,\n seen = new Set<unknown>(),\n): boolean {\n if (seen.has(error) || error === null || typeof error !== 'object') {\n return false;\n }\n\n seen.add(error);\n\n const candidate = error as {\n cause?: unknown;\n code?: unknown;\n error?: unknown;\n };\n\n return (\n // ethers v5 normalizes user-rejected wallet actions to ACTION_REJECTED,\n // but some provider-shaped errors can still surface the raw EIP-1193 4001.\n candidate.code === 4001 ||\n candidate.code === 'ACTION_REJECTED' ||\n isUserRejectedError(candidate.error, seen) ||\n isUserRejectedError(candidate.cause, seen)\n );\n}\n\nfunction isCallExceptionError(error: unknown): error is Error {\n return hasErrorCode(error, 'CALL_EXCEPTION');\n}\n\nfunction isTransactionReplacedError(error: unknown): error is Error & {\n cancelled: boolean;\n receipt: { transactionHash: string };\n} {\n return hasErrorCode(error, 'TRANSACTION_REPLACED');\n}\n\nfunction hasErrorCode(error: unknown, code: string): error is Error {\n return (\n error instanceof Error &&\n 'code' in error &&\n (error as { code?: unknown }).code === code\n );\n}\n\nclass DirectTransactionHandle implements TransactionHandle {\n readonly transactionId = null;\n #transactionHash: TxHash;\n readonly #transaction: ethers.providers.TransactionResponse;\n\n constructor(transaction: ethers.providers.TransactionResponse) {\n this.#transaction = transaction;\n this.#transactionHash = expectTxHash(transaction.hash);\n }\n\n get transactionHash() {\n return this.#transactionHash;\n }\n\n async wait() {\n try {\n const receipt = await this.#transaction.wait();\n\n const transactionHash = expectTxHash(receipt.transactionHash);\n this.#transactionHash = transactionHash;\n\n return {\n transactionHash,\n transactionId: null,\n };\n } catch (error) {\n if (isTransactionReplacedError(error)) {\n if (error.cancelled) {\n throw TransportError.fromError(error);\n }\n\n const transactionHash = expectTxHash(error.receipt.transactionHash);\n this.#transactionHash = transactionHash;\n\n return {\n transactionHash,\n transactionId: null,\n };\n }\n\n if (isCallExceptionError(error)) {\n throw new TransactionFailedError(\n `Transaction ${this.#transactionHash} reverted`,\n { cause: error },\n );\n }\n\n throw TransportError.fromError(error);\n }\n }\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { U as UserInputError, b as TransactionCall, A as ApiKeyAuthorization, c as ServiceClient$1 } from './types-CI9Rwzhy.js';
|
|
2
|
+
export { d as AcceptComboQuoteError, e as AcceptComboQuoteParams, f as AcceptComboQuoteResult, g as AccountIdentity, h as AnalyticsActions, i as ApproveErc1155ForAllError, j as ApproveErc20Error, k as ApprovePerpsBuilderFeeError, l as ApprovePerpsBuilderFeeRequest, m as ArmPerpsAutoCancelError, n as ArmPerpsAutoCancelRequest, o as AuthorizeSessionKeyError, p as AuthorizeSessionKeyRequest, q as AuthorizeSessionKeyResult, r as AutoCancelDailyLimitError, B as BaseClient, s as BasePublicClient, t as BaseSecureClient, u as BeginAuthenticationRequest, C as CancelAllError, v as CancelAllPerpsOrdersRequest, w as CancelMarketOrdersError, x as CancelOrderError, y as CancelOrdersError, z as CancelPerpsChaseError, D as CancelPerpsChaseRequest, E as CancelPerpsOrderRequest, F as CancelPerpsOrdersRequest, G as CancelPerpsTwapError, H as CancelPerpsTwapRequest, I as CancelledSigningError, J as Client, K as ClientActions, L as ClientDecorator, M as ClobEndpoints, N as ComboPositionStatusFilter, O as ComboQuote, P as CombosEndpoints, Q as CommentsSubscription, R as ConnectionLostError, V as ConnectionLostErrorOptions, W as ConvertError, X as ConvertWorkflow, Y as CreatePerpsChaseError, Z as CreatePerpsChaseRequest, _ as CreatePerpsSessionRequest, $ as CreatePerpsTwapError, a0 as CreatePerpsTwapRequest, a1 as CreateSecureClientError, a2 as CryptoPriceSubscription, a3 as CryptoPricesChainlinkTwapSubscription, a4 as CryptoPricesSubscription, a5 as CryptoTwapPriceSubscription, a6 as DEFAULT_SITE_CONFIG, a7 as DataActions, a8 as DepositToPerpsError, a9 as DepositToPerpsRequest, aa as DisarmPerpsAutoCancelRequest, ab as DiscoveryActions, ac as DownloadAccountingSnapshotError, ad as DropNotificationsError, ae as EnvironmentConfig, af as EnvironmentConfigFork, ag as EnvironmentContracts, ah as EquityPriceSubscription, ai as EquityPricesSubscription, aj as EquityTwapPriceSubscription, ak as Erc1155TradingApproval, al as Erc20TradingApproval, am as EstimateMarketPriceError, an as ExecuteCollateralReturnPlanError, ao as ExecuteCollateralReturnPlanRequest, ap as Fetch, aq as FetchBuilderVolumeError, ar as FetchClosedOnlyModeError, as as FetchCommentsByIdError, at as FetchCurrentRebatesError, au as FetchCurrentRebatesRequest, av as FetchEventError, aw as FetchEventLiveVolumeError, ax as FetchEventTagsError, ay as FetchLastTradePriceError, az as FetchLastTradePricesError, aA as FetchMarketError, aB as FetchMarketTagsError, aC as FetchMidpointError, aD as FetchMidpointsError, aE as FetchNotificationsError, aF as FetchOpenInterestError, aG as FetchOrderBookError, aH as FetchOrderBooksError, aI as FetchOrderError, aJ as FetchOrderScoringError, aK as FetchOrdersScoringError, aL as FetchPerpsAccountConfigRequest, aM as FetchPerpsBookError, aN as FetchPerpsBookRequest, aO as FetchPerpsBuilderApprovalsError, aP as FetchPerpsBuilderApprovalsRequest, aQ as FetchPerpsBuilderEarningsSummaryError, aR as FetchPerpsBuilderEarningsSummaryRequest, aS as FetchPerpsBuilderStatusError, aT as FetchPerpsBuilderStatusRequest, aU as FetchPerpsChasesError, aV as FetchPerpsFeesError, aW as FetchPerpsInstrumentsError, aX as FetchPerpsInstrumentsRequest, aY as FetchPerpsOpenOrdersRequest, aZ as FetchPerpsOrdersRequest, a_ as FetchPerpsPositionSnapshotsError, a$ as FetchPerpsPositionSnapshotsRequest, b0 as FetchPerpsRegistrationError, b1 as FetchPerpsRegistrationRequest, b2 as FetchPerpsTickerError, b3 as FetchPerpsTickerRequest, b4 as FetchPerpsTickersError, b5 as FetchPerpsTickersRequest, b6 as FetchPerpsTwapsError, b7 as FetchPortfolioValueError, b8 as FetchPriceError, b9 as FetchPricesError, ba as FetchPublicProfileError, bb as FetchRelatedTagResourcesError, bc as FetchRelatedTagsError, bd as FetchResolutionsError, be as FetchRewardPercentagesError, bf as FetchRfqStatusError, bg as FetchRfqStatusParams, bh as FetchSeriesError, bi as FetchSessionKeysError, bj as FetchSpreadError, bk as FetchSpreadsError, bl as FetchTagError, bm as FetchTokenReferencesError, bn as FetchTokenReferencesRequest, bo as FetchTotalEarningsForUserForDayError, bp as FetchTraderLeaderboardStandingError, bq as FetchTradingApprovalsStateError, br as FetchTradingApprovalsStateRequest, bs as FetchUserPnlError, bt as FetchUserStatsError, bu as FetchUserVolumeError, bv as HorizontalMergeError, bw as HorizontalMergeWorkflow, bx as HorizontalSplitError, by as HorizontalSplitWorkflow, bz as InsufficientLiquidityError, bA as ListAccountTradesError, bB as ListActivityError, bC as ListBiggestWinnersError, bD as ListBuilderLeaderboardError, bE as ListBuilderTradesError, bF as ListComboActivityError, bG as ListComboMarketsError, bH as ListComboPositionsError, bI as ListCommentsByUserAddressError, bJ as ListCommentsError, bK as ListCurrentRewardsError, bL as ListEventsError, bM as ListMarketHoldersError, bN as ListMarketRewardsError, bO as ListMarketsError, bP as ListOpenOrdersError, bQ as ListPerpsBuilderEarningsError, bR as ListPerpsBuilderEarningsRequest, bS as ListPerpsCandlesError, bT as ListPerpsCandlesRequest, bU as ListPerpsDepositsRequest, bV as ListPerpsEquityHistoryRequest, bW as ListPerpsFillsRequest, bX as ListPerpsFundingHistoryError, bY as ListPerpsFundingHistoryRequest, bZ as ListPerpsFundingPaymentsRequest, b_ as ListPerpsInternalTransfersRequest, b$ as ListPerpsNotificationsRequest, c0 as ListPerpsPnlHistoryRequest, c1 as ListPerpsTradesError, c2 as ListPerpsTradesRequest, c3 as ListPerpsWithdrawalsRequest, c4 as ListPositionsError, c5 as ListPriceHistoryError, c6 as ListRewardMarketsError, c7 as ListRewardMarketsRequest, c8 as ListSeriesError, c9 as ListTagsError, ca as ListTeamsError, cb as ListTraderLeaderboardError, cc as ListTradesError, cd as ListUserEarningsAndMarketsConfigError, ce as ListUserEarningsForDayError, cf as MarkPerpsNotificationsReadRequest, cg as MergePositionsError, ch as NegRiskWorkflow, ci as OpenPerpsSessionError, cj as OpenPerpsSessionRequest, ck as OpenRfqSessionError, cl as OperationAbortedError, cm as OrderHeartbeatMismatchError, cn as OrderSignature, co as Page, cp as PageSizeSchema, cq as Paginated, cr as PaginationLimitError, cs as PausePerpsTwapError, ct as PausePerpsTwapRequest, cu as PerpsActions, cv as PerpsBookDepth, cw as PerpsBuilderTermsInput, cx as PerpsCancelOptions, cy as PerpsCancelRetryError, cz as PerpsCancelRetryErrorOptions, cA as PerpsCancelRetryOptions, cB as PerpsEndpoints, cC as PerpsOrderRequest, cD as PerpsPlaceFokOrderRequest, cE as PerpsPlaceGtcOrderRequest, cF as PerpsPlaceGtdOrderRequest, cG as PerpsPlaceIocOrderRequest, cH as PerpsPlacedTpSlOrder, cI as PerpsPlacedTpSlOrders, cJ as PerpsPositionSnapshotFill, cK as PerpsPositionSnapshotSelection, cL as PerpsPositionTpSlTrigger, cM as PerpsPositionTrailingStop, cN as PerpsSession, cO as PerpsSessionAccountError, cP as PerpsSessionLifecycleError, cQ as PerpsSessionTradingError, cR as PerpsTpSlTrigger, cS as PerpsTrailingStop, cT as PlacePerpsOrderRequest, cU as PlacePerpsOrderResult, cV as PlacePerpsOrderWithTpSlRequest, cW as PlacePerpsOrderWithTpSlResult, cX as PlacePerpsPositionTpSlRequest, cY as PlacePerpsPositionTpSlResult, cZ as PlanCollateralReturnError, c_ as PostOrderError, c$ as PostOrdersError, d0 as PostPerpsOrdersRequest, d1 as PrepareConvertError, d2 as PrepareConvertRequest, d3 as PrepareHorizontalMergeError, d4 as PrepareHorizontalMergeRequest, d5 as PrepareHorizontalSplitError, d6 as PrepareHorizontalSplitRequest, d7 as PriceSubscription, d8 as PriceSubscriptionConfirmation, d9 as PublicAccountActions, da as PublicActions, db as PublicClient, dc as PublicClientOptions, dd as PublicPerpsActions, de as PublicRewardsActions, df as PublicSubscriptionsActions, dg as PublicWalletActions, dh as RateLimitBucket, di as RateLimitError, dj as RateLimitErrorOptions, dk as RateLimitUpdate, dl as RateLimitUpdateListener, dm as RedeemPositionsError, dn as RequestAbortedError, dp as RequestComboQuoteError, dq as RequestComboQuoteParams, dr as RequestComboQuoteResult, ds as RequestOptions, dt as RequestRejectedError, du as RequestRejectedErrorOptions, dv as RestEndpoint, dw as ResumePerpsSessionRequest, dx as ResumePerpsTwapError, dy as ResumePerpsTwapRequest, dz as RevokePerpsBuilderFeeError, dA as RevokePerpsCredentialsError, dB as RevokePerpsCredentialsRequest, dC as RevokeSessionKeyError, dD as RevokeSessionKeyRequest, dE as RfqCancelQuoteAck, dF as RfqCancelQuoteError, dG as RfqCancelQuoteRejectedError, dH as RfqCancelQuoteRejectedErrorOptions, dI as RfqConfirmationAck, dJ as RfqConfirmationError, dK as RfqConfirmationRejectedError, dL as RfqConfirmationRequestEvent, dM as RfqEvent, dN as RfqQuoteError, dO as RfqQuoteReference, dP as RfqQuoteRejectedError, dQ as RfqQuoteRejectedErrorOptions, dR as RfqQuoteRequestEvent, dS as RfqQuoteResponse, dT as RfqQuoteSource, dU as RfqRequestRejectedError, dV as RfqRequestRejectedErrorOptions, dW as RfqSession, dX as RfqStatusResult, dY as RfqTradeEvent, dZ as SearchError, d_ as SearchSort, d$ as SecureAccountActions, e0 as SecureActions, e1 as SecureClient, e2 as SecureClientOptions, e3 as SecureDownloadAccountingSnapshotRequest, e4 as SecureFetchPortfolioValueRequest, e5 as SecureFetchTraderLeaderboardStandingRequest, e6 as SecureFetchUserPnlRequest, e7 as SecureFetchUserStatsRequest, e8 as SecureFetchUserVolumeRequest, e9 as SecureListActivityRequest, ea as SecureListComboActivityRequest, eb as SecureListComboPositionsRequest, ec as SecureListPositionsRequest, ed as SecurePerpsActions, ee as SecureRewardsActions, ef as SecureRfqActions, eg as SecureSubscriptionsActions, eh as SecureTradingActions, ei as SecureWalletActions, ej as SendOrderHeartbeatError, ek as SendOrderHeartbeatRequest, el as ServiceClientDeleteOptions, em as ServiceClientGetOptions, en as ServiceClientJsonResponseOptions, eo as ServiceClientNonJsonResponseOptions, ep as ServiceClientNonJsonResponseType, eq as ServiceClientPatchOptions, er as ServiceClientPostOptions, es as ServiceClientRequestError, et as ServiceClientRequestOptions, eu as ServiceClientResponse, ev as ServiceClientResponseOptions, ew as ServiceClientResponseType, ex as SessionKey, ey as SessionKeyActions, ez as SetupGaslessWalletError, eA as SetupTradingApprovalsError, eB as SignedOrder, S as Signer, eC as SignerTransactionRequest, eD as SignerType, eE as SigningError, eF as SiteConfig, eG as SplitPositionError, eH as SubscribeError, eI as SubscriptionHandle, eJ as TimeoutError, eK as TradingApprovalRequirements, eL as TradingApprovalsState, eM as TradingRestriction, eN as TransactionFailedError, eO as TransactionHandle, eP as TransactionOutcome, eQ as TransferErc20Error, eR as TransferPerpsCollateralError, eS as TransferPerpsCollateralRequest, eT as TransportError, a as TypedData, eU as TypedDataDomain, eV as TypedDataField, T as TypedDataPayload, eW as UnexpectedResponseError, eX as UpdatePerpsLeverageError, eY as UpdatePerpsLeverageRequest, eZ as UpdatePerpsLeveragesError, e_ as UpdatePerpsLeveragesRequest, e$ as UpdatePerpsMarginError, f0 as UpdatePerpsMarginRequest, f1 as WaitForComboFillError, f2 as WaitForComboFillParams, f3 as WaitForComboFillResult, f4 as WaitForOrderFillSettlementError, f5 as WaitForTransactionError, f6 as WalletDerivationConfig, f7 as WebSocketCloseCode, f8 as WebSocketEndpoint, f9 as WebSocketKnownCloseCode, fa as WithdrawFromPerpsError, fb as WithdrawFromPerpsRequest, fc as accountActions, fd as allActions, fe as analyticsActions, ff as createPublicClient, fg as createSecureClient, fh as dataActions, fi as discoveryActions, fj as forkEnvironmentConfig, fk as makeErrorGuard, fl as parseSiteConfig, fm as perpsActions, fn as production, fo as rewardsActions, fp as rfqActions, fq as sessionKeyActions, fr as subscriptionsActions, fs as tradingActions, ft as walletActions } from './types-CI9Rwzhy.js';
|
|
3
|
+
import { ConditionId, ComboConditionId } from '@kuest/bindings';
|
|
4
|
+
export * from '@kuest/bindings';
|
|
5
|
+
export { CommentParentEntityType, GatewayErrorCode, GatewayKnownErrorCode, OrderSide, OrderType, SessionSignerKnownScope as SessionKeyKnownScope, SessionSignerScope as SessionKeyScope } from '@kuest/bindings';
|
|
6
|
+
export * from '@kuest/bindings/clob';
|
|
7
|
+
export { AssetType, NotificationType, OrderPostStatus, OrderResponseErrorCode, RewardMarketSort, SignatureType } from '@kuest/bindings/clob';
|
|
8
|
+
export * from '@kuest/bindings/data';
|
|
9
|
+
export { ActivityType, BiggestWinnerKind, BuilderVolumeInterval, ComboActivityType, ComboPositionSortBy, ComboPositionStatus, LeaderboardWindow, PositionFilterType, PositionSortBy, PositionStatus, PriceHistoryInterval, ResolutionMarketType, ResolutionReporter, ResolutionSettlementTimeBasis, ResolutionSource, ResolutionStatus, SortDirection, TipSide, TokenModule, TradeFilterType, TraderLeaderboardSort, UserPnlFidelity, UserPnlInterval } from '@kuest/bindings/data';
|
|
10
|
+
export * from '@kuest/bindings/gamma';
|
|
11
|
+
export { ComboKnownStatus, MarketResolutionStatus, ProtocolVersion, TeamOrdering, WalletType } from '@kuest/bindings/gamma';
|
|
12
|
+
export * from '@kuest/bindings/perps';
|
|
13
|
+
export { PerpsAutoCancelStatus, PerpsCancelOrderResult, PerpsChase, PerpsChaseAccepted, PerpsChaseId, PerpsDepositStatus, PerpsInstrumentCategory, PerpsInstrumentType, PerpsInternalTransferDirection, PerpsKlineInterval, PerpsKnownCancelOrderErrorCode, PerpsKnownInternalTransferType, PerpsKnownWithdrawalStatus, PerpsLiquidationMethod, PerpsLiquidityRole, PerpsMarginType, PerpsNotificationOrderType, PerpsNotificationType, PerpsOrderStatus, PerpsPositionSnapshotMarkerKind, PerpsPositionSnapshotStatus, PerpsPostOrderAck, PerpsSide, PerpsSortDirection, PerpsTimeInForce, PerpsTwap, PerpsTwapAccepted, PerpsTwapId, PerpsTwapStatus, PerpsUpdateLeverageBatchResult, PerpsUpdateLeverageRejection, PerpsUpdateLeverageResult } from '@kuest/bindings/perps';
|
|
14
|
+
export * from '@kuest/bindings/relayer';
|
|
15
|
+
import { Tagged, EvmAddress } from '@kuest/types';
|
|
16
|
+
export { C as CreateLimitOrderError, a as CreateMarketOrderError, F as FetchSportsMarketTypesError, L as ListSportsError, P as PlaceLimitOrderError, b as PlaceMarketOrderError } from './sports-Bt7NXBWp.js';
|
|
17
|
+
export { BuilderRfqError, CollateralReturnKnownOperationKind, CollateralReturnOperation, CollateralReturnOperationKind, CollateralReturnPlanResponse, CollateralReturnPositionAmount, CollateralReturnPositionSummary, CollateralReturnRouterCall, ComboAcceptFailureReason, ComboQuoteUnavailableReason, RfqConfirmationDecision, RfqConfirmationRequest, RfqDirection, RfqErrorCode, RfqExecutionStatus, RfqExecutionUpdate, RfqId, RfqKnownErrorCode, RfqQuoteId, RfqQuoteRequest, RfqRejectionCode, RfqRequestedSize, RfqRequestedSizeUnit, RfqRequestorPublicId, RfqSide, RfqStatus, RfqTrade } from '@kuest/bindings/combos';
|
|
18
|
+
export { CommentsEvent, CryptoPriceEvent, CryptoPriceSnapshotEvent, CryptoPricesBinanceEvent, CryptoPricesChainlinkEvent, CryptoPricesChainlinkTwapEvent, CryptoPricesChainlinkTwapSixtyEvent, CryptoPricesChainlinkTwapThirtyEvent, CryptoPricesChainlinkTwapWindowSeconds, CryptoPricesEvent, CryptoTwapPriceEvent, CryptoTwapPriceSnapshotEvent, EquityPriceEvent, EquityPricesEvent, EquityTwapPriceEvent, EquityTwapPriceSnapshotEvent, KnownPriceSource, PerpsBuilderFillUpdateEvent, PerpsSessionEvent, PriceProvider, PriceSource, RealtimeErrorCode, RealtimeKnownErrorCode } from '@kuest/bindings/subscriptions';
|
|
19
|
+
import 'zod';
|
|
20
|
+
import 'ox';
|
|
21
|
+
|
|
22
|
+
type CanonicalComboLegs = Tagged<readonly bigint[], 'CanonicalComboLegs'>;
|
|
23
|
+
|
|
24
|
+
type Erc20ApprovalCallError = UserInputError;
|
|
25
|
+
declare const Erc20ApprovalCallError: {
|
|
26
|
+
isError(error: unknown): error is UserInputError;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Creates a transaction call for `approve(address,uint256)` on an ERC-20 token.
|
|
30
|
+
*
|
|
31
|
+
* @throws {@link Erc20ApprovalCallError}
|
|
32
|
+
* Thrown when the approval amount is invalid.
|
|
33
|
+
*/
|
|
34
|
+
declare function erc20ApprovalCall(tokenAddress: EvmAddress, spender: EvmAddress, amount: bigint): TransactionCall;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a transaction call for `setApprovalForAll(address,bool)` on an ERC-1155 token.
|
|
37
|
+
*/
|
|
38
|
+
declare function erc1155ApprovalForAllCall(tokenAddress: EvmAddress, operator: EvmAddress, approved: boolean): TransactionCall;
|
|
39
|
+
type Erc20TransferCallError = UserInputError;
|
|
40
|
+
declare const Erc20TransferCallError: {
|
|
41
|
+
isError(error: unknown): error is UserInputError;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Creates a transaction call for `transfer(address,uint256)` on an ERC-20 token.
|
|
45
|
+
*
|
|
46
|
+
* @throws {@link Erc20TransferCallError}
|
|
47
|
+
* Thrown when the transfer amount is invalid.
|
|
48
|
+
*/
|
|
49
|
+
declare function erc20TransferCall(tokenAddress: EvmAddress, recipient: EvmAddress, amount: bigint): TransactionCall;
|
|
50
|
+
/**
|
|
51
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
52
|
+
*/
|
|
53
|
+
type PerpsDepositCallError = UserInputError;
|
|
54
|
+
/**
|
|
55
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
56
|
+
*/
|
|
57
|
+
declare const PerpsDepositCallError: {
|
|
58
|
+
isError(error: unknown): error is UserInputError;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Creates a transaction call for Perps `deposit(address,uint256,address)`.
|
|
62
|
+
*
|
|
63
|
+
* @throws {@link PerpsDepositCallError}
|
|
64
|
+
* Thrown when the deposit amount is invalid.
|
|
65
|
+
*
|
|
66
|
+
* @experimental This API may change in a breaking way in any release, including patch releases.
|
|
67
|
+
*/
|
|
68
|
+
declare function perpsDepositCall(depositContractAddress: EvmAddress, tokenAddress: EvmAddress, amount: bigint, to: EvmAddress): TransactionCall;
|
|
69
|
+
type CtfSplitPositionCallError = UserInputError;
|
|
70
|
+
declare const CtfSplitPositionCallError: {
|
|
71
|
+
isError(error: unknown): error is UserInputError;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Creates a transaction call for `splitPosition(address,bytes32,bytes32,uint256[],uint256)`.
|
|
75
|
+
* Works with Conditional Tokens and the deployed NegRisk adapter.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* This is a low-level transaction builder that most SDK consumers will not need.
|
|
79
|
+
*
|
|
80
|
+
* @throws {@link CtfSplitPositionCallError}
|
|
81
|
+
* Thrown when the amount is invalid.
|
|
82
|
+
*/
|
|
83
|
+
declare function ctfSplitPositionCall(targetAddress: EvmAddress, collateralTokenAddress: EvmAddress, conditionId: ConditionId, amount: bigint): TransactionCall;
|
|
84
|
+
type CtfMergePositionsCallError = UserInputError;
|
|
85
|
+
declare const CtfMergePositionsCallError: {
|
|
86
|
+
isError(error: unknown): error is UserInputError;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Creates a transaction call for `mergePositions(address,bytes32,bytes32,uint256[],uint256)`.
|
|
90
|
+
* Works with both the standard and neg-risk collateral adapters.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* This is a low-level transaction builder that most SDK consumers will not need.
|
|
94
|
+
*
|
|
95
|
+
* @throws {@link CtfMergePositionsCallError}
|
|
96
|
+
* Thrown when the amount is invalid.
|
|
97
|
+
*/
|
|
98
|
+
declare function ctfMergePositionsCall(targetAddress: EvmAddress, collateralTokenAddress: EvmAddress, conditionId: ConditionId, amount: bigint): TransactionCall;
|
|
99
|
+
type CtfRedeemPositionsCallError = UserInputError;
|
|
100
|
+
declare const CtfRedeemPositionsCallError: {
|
|
101
|
+
isError(error: unknown): error is UserInputError;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Creates a transaction call for `redeemPositions(address,bytes32,bytes32,uint256[])`
|
|
105
|
+
* on the deployed Conditional Tokens contract for a standard CTF market.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* This is a low-level transaction builder that most SDK consumers will not need.
|
|
109
|
+
*
|
|
110
|
+
* @throws {@link CtfRedeemPositionsCallError}
|
|
111
|
+
* Thrown when the condition is invalid.
|
|
112
|
+
*/
|
|
113
|
+
declare function ctfRedeemPositionsCall(conditionalTokensAddress: EvmAddress, collateralTokenAddress: EvmAddress, conditionId: ConditionId): TransactionCall;
|
|
114
|
+
/** Redeems NegRisk YES/NO CTF balances through the deployed adapter. */
|
|
115
|
+
declare function negRiskRedeemPositionsCall(adapterAddress: EvmAddress, conditionId: ConditionId, amounts: readonly [bigint, bigint]): TransactionCall;
|
|
116
|
+
type RouterConvertCallError = UserInputError;
|
|
117
|
+
declare const RouterConvertCallError: {
|
|
118
|
+
isError(error: unknown): error is UserInputError;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Encodes a Router conversion of NO into every other condition's YES.
|
|
122
|
+
* Includes Other unless converting NO(Other).
|
|
123
|
+
* Accepts a bytes29 or zero-padded bytes32 protocol event ID, an index from zero through
|
|
124
|
+
* the event arity (Other), and a positive uint256 amount in six-decimal base units.
|
|
125
|
+
* @throws {@link RouterConvertCallError} Thrown when input is invalid.
|
|
126
|
+
*/
|
|
127
|
+
declare function routerConvertCall(routerAddress: EvmAddress, protocolEventId: string, conditionIndex: number, amount: bigint): TransactionCall;
|
|
128
|
+
type RouterHorizontalSplitCallError = UserInputError;
|
|
129
|
+
declare const RouterHorizontalSplitCallError: {
|
|
130
|
+
isError(error: unknown): error is UserInputError;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Encodes a Router split of pUSD into YES for every condition, including Other.
|
|
134
|
+
* Accepts a bytes29 or zero-padded bytes32 protocol event ID and a positive uint256 amount
|
|
135
|
+
* in six-decimal base units.
|
|
136
|
+
* @throws {@link RouterHorizontalSplitCallError} Thrown when input is invalid.
|
|
137
|
+
*/
|
|
138
|
+
declare function routerHorizontalSplitCall(routerAddress: EvmAddress, protocolEventId: string, amount: bigint): TransactionCall;
|
|
139
|
+
type RouterHorizontalMergeCallError = UserInputError;
|
|
140
|
+
declare const RouterHorizontalMergeCallError: {
|
|
141
|
+
isError(error: unknown): error is UserInputError;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Encodes a Router merge of equal YES amounts from every condition, including Other, into pUSD.
|
|
145
|
+
* Accepts a bytes29 or zero-padded bytes32 protocol event ID and a positive uint256 amount
|
|
146
|
+
* per condition in six-decimal base units.
|
|
147
|
+
* @throws {@link RouterHorizontalMergeCallError} Thrown when input is invalid.
|
|
148
|
+
*/
|
|
149
|
+
declare function routerHorizontalMergeCall(routerAddress: EvmAddress, protocolEventId: string, amount: bigint): TransactionCall;
|
|
150
|
+
type RouterSplitCallError = UserInputError;
|
|
151
|
+
declare const RouterSplitCallError: {
|
|
152
|
+
isError(error: unknown): error is UserInputError;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Creates a transaction call for protocol v2 Router `split(bytes31,uint256)`.
|
|
156
|
+
*
|
|
157
|
+
* @throws {@link RouterSplitCallError}
|
|
158
|
+
* Thrown when the condition ID or amount is invalid.
|
|
159
|
+
*/
|
|
160
|
+
declare function routerSplitCall(routerAddress: EvmAddress, conditionId: ConditionId | ComboConditionId, amount: bigint): TransactionCall;
|
|
161
|
+
type RouterMergeCallError = UserInputError;
|
|
162
|
+
declare const RouterMergeCallError: {
|
|
163
|
+
isError(error: unknown): error is UserInputError;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Creates a transaction call for protocol v2 Router `merge(bytes31,uint256)`.
|
|
167
|
+
*
|
|
168
|
+
* @throws {@link RouterMergeCallError}
|
|
169
|
+
* Thrown when the condition ID or amount is invalid.
|
|
170
|
+
*/
|
|
171
|
+
declare function routerMergeCall(routerAddress: EvmAddress, conditionId: ConditionId | ComboConditionId, amount: bigint): TransactionCall;
|
|
172
|
+
type RouterRedeemCallError = UserInputError;
|
|
173
|
+
declare const RouterRedeemCallError: {
|
|
174
|
+
isError(error: unknown): error is UserInputError;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Creates a transaction call for protocol v2 Router `redeem(bytes31,uint256,uint256)`.
|
|
178
|
+
*
|
|
179
|
+
* @throws {@link RouterRedeemCallError}
|
|
180
|
+
* Thrown when the condition ID, outcome index, or amount is invalid.
|
|
181
|
+
*/
|
|
182
|
+
declare function routerRedeemCall(routerAddress: EvmAddress, conditionId: ConditionId | ComboConditionId, outcomeIndex: 0 | 1, amount: bigint): TransactionCall;
|
|
183
|
+
type CombinatorialPrepareConditionCallError = UserInputError;
|
|
184
|
+
declare const CombinatorialPrepareConditionCallError: {
|
|
185
|
+
isError(error: unknown): error is UserInputError;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Creates a transaction call for CombinatorialModule `prepareCondition(uint256[])`.
|
|
189
|
+
*
|
|
190
|
+
* @throws {@link CombinatorialPrepareConditionCallError}
|
|
191
|
+
* Thrown when any leg position ID is invalid.
|
|
192
|
+
*/
|
|
193
|
+
declare function combinatorialPrepareConditionCall(combinatorialModuleAddress: EvmAddress, legs: CanonicalComboLegs): TransactionCall;
|
|
194
|
+
|
|
195
|
+
type RelayerApiKeyConfig = {
|
|
196
|
+
key: string;
|
|
197
|
+
address: string;
|
|
198
|
+
};
|
|
199
|
+
type RemoteBuilderSigningConfig = {
|
|
200
|
+
/**
|
|
201
|
+
* URL for the application's remote builder-signing endpoint.
|
|
202
|
+
*
|
|
203
|
+
* This may be an absolute `http` or `https` URL, or a root-relative path
|
|
204
|
+
* such as `/api/builder/sign` in browser environments.
|
|
205
|
+
*/
|
|
206
|
+
url: string;
|
|
207
|
+
/**
|
|
208
|
+
* Fetch credential mode for requests to the remote signer.
|
|
209
|
+
*
|
|
210
|
+
* Set this when the signer relies on cookie-backed authentication, especially
|
|
211
|
+
* for cross-origin requests that require `include`.
|
|
212
|
+
*/
|
|
213
|
+
credentials?: RequestCredentials;
|
|
214
|
+
/**
|
|
215
|
+
* Additional headers to send to the remote signer.
|
|
216
|
+
*
|
|
217
|
+
* Use this for application-specific authorization such as bearer tokens,
|
|
218
|
+
* tenant headers, or CSRF headers. The SDK always sends JSON.
|
|
219
|
+
*/
|
|
220
|
+
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
221
|
+
};
|
|
222
|
+
declare function remoteBuilderSigning(config: RemoteBuilderSigningConfig): ApiKeyAuthorization;
|
|
223
|
+
declare function relayerApiKey(config: RelayerApiKeyConfig): ApiKeyAuthorization;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Builds the canonical HMAC signature for authenticated requests.
|
|
227
|
+
*
|
|
228
|
+
* The signed payload is the raw string concatenation of `timestamp`, `method`,
|
|
229
|
+
* `requestPath`, and, when present, the serialized request `body`, matching the
|
|
230
|
+
* remote signing contract.
|
|
231
|
+
*
|
|
232
|
+
* The `secret` is expected to be base64-encoded and is decoded before signing.
|
|
233
|
+
* The returned signature is base64url-encoded with padding preserved.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* Server-side signing example for builder-authenticated requests:
|
|
237
|
+
*
|
|
238
|
+
* ```ts
|
|
239
|
+
* async function handleSignRequest(request: Request): Promise<Response> {
|
|
240
|
+
* const { body, method, path } = await request.json();
|
|
241
|
+
*
|
|
242
|
+
* const timestamp = Math.floor(Date.now() / 1000);
|
|
243
|
+
* const signature = await buildHmacSignature(
|
|
244
|
+
* process.env.SDK_BUILDER_SECRET!,
|
|
245
|
+
* timestamp,
|
|
246
|
+
* method,
|
|
247
|
+
* path,
|
|
248
|
+
* body,
|
|
249
|
+
* );
|
|
250
|
+
*
|
|
251
|
+
* return Response.json({
|
|
252
|
+
* KUEST_BUILDER_API_KEY: process.env.KUEST_BUILDER_API_KEY!,
|
|
253
|
+
* KUEST_BUILDER_PASSPHRASE: process.env.KUEST_BUILDER_PASSPHRASE!,
|
|
254
|
+
* KUEST_BUILDER_SIGNATURE: signature,
|
|
255
|
+
* KUEST_BUILDER_TIMESTAMP: `${timestamp}`,
|
|
256
|
+
* });
|
|
257
|
+
* }
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
declare function buildHmacSignature(secret: string, timestamp: number, method: string, requestPath: string, body?: string): Promise<string>;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Service client returned by the experimental `predictions` getter.
|
|
264
|
+
*
|
|
265
|
+
* @experimental Upstream-only service, unconfigured for SDK. Breaking changes may occur in any release, including patch releases.
|
|
266
|
+
*/
|
|
267
|
+
type ServiceClient = ServiceClient$1;
|
|
268
|
+
|
|
269
|
+
export { ApiKeyAuthorization, CombinatorialPrepareConditionCallError, CtfMergePositionsCallError, CtfRedeemPositionsCallError, CtfSplitPositionCallError, Erc20ApprovalCallError, Erc20TransferCallError, PerpsDepositCallError, type RelayerApiKeyConfig, type RemoteBuilderSigningConfig, RouterConvertCallError, RouterHorizontalMergeCallError, RouterHorizontalSplitCallError, RouterMergeCallError, RouterRedeemCallError, RouterSplitCallError, type ServiceClient, TransactionCall, UserInputError, buildHmacSignature, combinatorialPrepareConditionCall, ctfMergePositionsCall, ctfRedeemPositionsCall, ctfSplitPositionCall, erc1155ApprovalForAllCall, erc20ApprovalCall, erc20TransferCall, negRiskRedeemPositionsCall, perpsDepositCall, relayerApiKey, remoteBuilderSigning, routerConvertCall, routerHorizontalMergeCall, routerHorizontalSplitCall, routerMergeCall, routerRedeemCall, routerSplitCall };
|