@predictorsdk/client 0.3.2 → 0.4.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/Client.d.ts +26 -0
- package/dist/Client.js +140 -0
- package/dist/api/client/requests/GetPolymarketWalletRequest.d.ts +12 -0
- package/dist/api/client/requests/GetPolymarketWalletRequest.js +2 -0
- package/dist/api/client/requests/index.d.ts +1 -0
- package/dist/api/errors/NotFoundError.d.ts +7 -0
- package/dist/api/errors/NotFoundError.js +17 -0
- package/dist/api/errors/index.d.ts +1 -0
- package/dist/api/errors/index.js +1 -0
- package/dist/api/types/PolymarketWalletResponse.d.ts +10 -0
- package/dist/api/types/PolymarketWalletResponse.js +2 -0
- package/dist/api/types/index.d.ts +1 -0
- package/dist/api/types/index.js +1 -0
- package/dist/serialization/types/PolymarketWalletResponse.d.ts +12 -0
- package/dist/serialization/types/PolymarketWalletResponse.js +8 -0
- package/dist/serialization/types/index.d.ts +1 -0
- package/dist/serialization/types/index.js +1 -0
- package/package.json +1 -1
package/dist/Client.d.ts
CHANGED
|
@@ -67,6 +67,32 @@ export declare class PredictorSDKClient {
|
|
|
67
67
|
*/
|
|
68
68
|
getBinanceCryptoPrices(request: PredictorSDK.GetBinanceCryptoPricesRequest, requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.CryptoPricesResponse>;
|
|
69
69
|
private __getBinanceCryptoPrices;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the public profile (image and display name) for a Polymarket wallet. Accepts either a wallet `address` (proxy or signer EOA) or a Polymarket `username`. Exactly one of the two must be supplied — passing both returns `400`.
|
|
72
|
+
*
|
|
73
|
+
* When `address` is the underlying signer EOA, the endpoint resolves it to the deterministic proxy address and returns the proxy's profile, with `signer` echoing the input.
|
|
74
|
+
*
|
|
75
|
+
* When `username` is supplied, the endpoint resolves it to the wallet via Polymarket's profile search. Match is case-insensitive and exact: a query of `Theo` resolves the user literally named `theo` but does not resolve `theo46` or `Theo47`. A leading `@` is accepted (and stripped) as a convenience for callers used to Twitter-style handles. `signer` is always `null` on the username path. Profiles that don't exist (or only match fuzzily) return `404`.
|
|
76
|
+
*
|
|
77
|
+
* @param {PredictorSDK.GetPolymarketWalletRequest} request
|
|
78
|
+
* @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
79
|
+
*
|
|
80
|
+
* @throws {@link PredictorSDK.BadRequestError}
|
|
81
|
+
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
82
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
83
|
+
* @throws {@link PredictorSDK.ForbiddenError}
|
|
84
|
+
* @throws {@link PredictorSDK.NotFoundError}
|
|
85
|
+
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
86
|
+
* @throws {@link PredictorSDK.BadGatewayError}
|
|
87
|
+
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* await client.getPolymarketWallet({
|
|
91
|
+
* address: "0x7c3db723f1d4d8cb9c550095203b686cb11e5c6b"
|
|
92
|
+
* })
|
|
93
|
+
*/
|
|
94
|
+
getPolymarketWallet(request?: PredictorSDK.GetPolymarketWalletRequest, requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.PolymarketWalletResponse>;
|
|
95
|
+
private __getPolymarketWallet;
|
|
70
96
|
/**
|
|
71
97
|
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
72
98
|
* This is useful for making requests to endpoints not yet supported in the SDK.
|
package/dist/Client.js
CHANGED
|
@@ -379,6 +379,146 @@ export class PredictorSDKClient {
|
|
|
379
379
|
}
|
|
380
380
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/crypto-prices/binance");
|
|
381
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Returns the public profile (image and display name) for a Polymarket wallet. Accepts either a wallet `address` (proxy or signer EOA) or a Polymarket `username`. Exactly one of the two must be supplied — passing both returns `400`.
|
|
384
|
+
*
|
|
385
|
+
* When `address` is the underlying signer EOA, the endpoint resolves it to the deterministic proxy address and returns the proxy's profile, with `signer` echoing the input.
|
|
386
|
+
*
|
|
387
|
+
* When `username` is supplied, the endpoint resolves it to the wallet via Polymarket's profile search. Match is case-insensitive and exact: a query of `Theo` resolves the user literally named `theo` but does not resolve `theo46` or `Theo47`. A leading `@` is accepted (and stripped) as a convenience for callers used to Twitter-style handles. `signer` is always `null` on the username path. Profiles that don't exist (or only match fuzzily) return `404`.
|
|
388
|
+
*
|
|
389
|
+
* @param {PredictorSDK.GetPolymarketWalletRequest} request
|
|
390
|
+
* @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
391
|
+
*
|
|
392
|
+
* @throws {@link PredictorSDK.BadRequestError}
|
|
393
|
+
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
394
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
395
|
+
* @throws {@link PredictorSDK.ForbiddenError}
|
|
396
|
+
* @throws {@link PredictorSDK.NotFoundError}
|
|
397
|
+
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
398
|
+
* @throws {@link PredictorSDK.BadGatewayError}
|
|
399
|
+
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* await client.getPolymarketWallet({
|
|
403
|
+
* address: "0x7c3db723f1d4d8cb9c550095203b686cb11e5c6b"
|
|
404
|
+
* })
|
|
405
|
+
*/
|
|
406
|
+
getPolymarketWallet(request = {}, requestOptions) {
|
|
407
|
+
return core.HttpResponsePromise.fromPromise(this.__getPolymarketWallet(request, requestOptions));
|
|
408
|
+
}
|
|
409
|
+
async __getPolymarketWallet(request = {}, requestOptions) {
|
|
410
|
+
const { address, username } = request;
|
|
411
|
+
const _queryParams = {
|
|
412
|
+
address,
|
|
413
|
+
username,
|
|
414
|
+
};
|
|
415
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
416
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
417
|
+
const _response = await core.fetcher({
|
|
418
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
419
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
420
|
+
environments.PredictorSDKEnvironment.Production, "v1/polymarket/wallet"),
|
|
421
|
+
method: "GET",
|
|
422
|
+
headers: _headers,
|
|
423
|
+
queryString: core.url
|
|
424
|
+
.queryBuilder()
|
|
425
|
+
.addMany(_queryParams)
|
|
426
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
427
|
+
.build(),
|
|
428
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
429
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
430
|
+
abortSignal: requestOptions?.abortSignal,
|
|
431
|
+
fetchFn: this._options?.fetch,
|
|
432
|
+
logging: this._options.logging,
|
|
433
|
+
});
|
|
434
|
+
if (_response.ok) {
|
|
435
|
+
return {
|
|
436
|
+
data: serializers.PolymarketWalletResponse.parseOrThrow(_response.body, {
|
|
437
|
+
unrecognizedObjectKeys: "passthrough",
|
|
438
|
+
allowUnrecognizedUnionMembers: true,
|
|
439
|
+
allowUnrecognizedEnumValues: true,
|
|
440
|
+
skipValidation: true,
|
|
441
|
+
breadcrumbsPrefix: ["response"],
|
|
442
|
+
}),
|
|
443
|
+
rawResponse: _response.rawResponse,
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
if (_response.error.reason === "status-code") {
|
|
447
|
+
switch (_response.error.statusCode) {
|
|
448
|
+
case 400:
|
|
449
|
+
throw new PredictorSDK.BadRequestError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
450
|
+
unrecognizedObjectKeys: "passthrough",
|
|
451
|
+
allowUnrecognizedUnionMembers: true,
|
|
452
|
+
allowUnrecognizedEnumValues: true,
|
|
453
|
+
skipValidation: true,
|
|
454
|
+
breadcrumbsPrefix: ["response"],
|
|
455
|
+
}), _response.rawResponse);
|
|
456
|
+
case 401:
|
|
457
|
+
throw new PredictorSDK.UnauthorizedError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
458
|
+
unrecognizedObjectKeys: "passthrough",
|
|
459
|
+
allowUnrecognizedUnionMembers: true,
|
|
460
|
+
allowUnrecognizedEnumValues: true,
|
|
461
|
+
skipValidation: true,
|
|
462
|
+
breadcrumbsPrefix: ["response"],
|
|
463
|
+
}), _response.rawResponse);
|
|
464
|
+
case 402:
|
|
465
|
+
throw new PredictorSDK.PaymentRequiredError(serializers.PaymentRequiredErrorBody.parseOrThrow(_response.error.body, {
|
|
466
|
+
unrecognizedObjectKeys: "passthrough",
|
|
467
|
+
allowUnrecognizedUnionMembers: true,
|
|
468
|
+
allowUnrecognizedEnumValues: true,
|
|
469
|
+
skipValidation: true,
|
|
470
|
+
breadcrumbsPrefix: ["response"],
|
|
471
|
+
}), _response.rawResponse);
|
|
472
|
+
case 403:
|
|
473
|
+
throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
474
|
+
unrecognizedObjectKeys: "passthrough",
|
|
475
|
+
allowUnrecognizedUnionMembers: true,
|
|
476
|
+
allowUnrecognizedEnumValues: true,
|
|
477
|
+
skipValidation: true,
|
|
478
|
+
breadcrumbsPrefix: ["response"],
|
|
479
|
+
}), _response.rawResponse);
|
|
480
|
+
case 404:
|
|
481
|
+
throw new PredictorSDK.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
482
|
+
unrecognizedObjectKeys: "passthrough",
|
|
483
|
+
allowUnrecognizedUnionMembers: true,
|
|
484
|
+
allowUnrecognizedEnumValues: true,
|
|
485
|
+
skipValidation: true,
|
|
486
|
+
breadcrumbsPrefix: ["response"],
|
|
487
|
+
}), _response.rawResponse);
|
|
488
|
+
case 429:
|
|
489
|
+
throw new PredictorSDK.TooManyRequestsError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
490
|
+
unrecognizedObjectKeys: "passthrough",
|
|
491
|
+
allowUnrecognizedUnionMembers: true,
|
|
492
|
+
allowUnrecognizedEnumValues: true,
|
|
493
|
+
skipValidation: true,
|
|
494
|
+
breadcrumbsPrefix: ["response"],
|
|
495
|
+
}), _response.rawResponse);
|
|
496
|
+
case 502:
|
|
497
|
+
throw new PredictorSDK.BadGatewayError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
498
|
+
unrecognizedObjectKeys: "passthrough",
|
|
499
|
+
allowUnrecognizedUnionMembers: true,
|
|
500
|
+
allowUnrecognizedEnumValues: true,
|
|
501
|
+
skipValidation: true,
|
|
502
|
+
breadcrumbsPrefix: ["response"],
|
|
503
|
+
}), _response.rawResponse);
|
|
504
|
+
case 503:
|
|
505
|
+
throw new PredictorSDK.ServiceUnavailableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
506
|
+
unrecognizedObjectKeys: "passthrough",
|
|
507
|
+
allowUnrecognizedUnionMembers: true,
|
|
508
|
+
allowUnrecognizedEnumValues: true,
|
|
509
|
+
skipValidation: true,
|
|
510
|
+
breadcrumbsPrefix: ["response"],
|
|
511
|
+
}), _response.rawResponse);
|
|
512
|
+
default:
|
|
513
|
+
throw new errors.PredictorSDKError({
|
|
514
|
+
statusCode: _response.error.statusCode,
|
|
515
|
+
body: _response.error.body,
|
|
516
|
+
rawResponse: _response.rawResponse,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/polymarket/wallet");
|
|
521
|
+
}
|
|
382
522
|
/**
|
|
383
523
|
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
384
524
|
* This is useful for making requests to endpoints not yet supported in the SDK.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* address: "0x7c3db723f1d4d8cb9c550095203b686cb11e5c6b"
|
|
5
|
+
* }
|
|
6
|
+
*/
|
|
7
|
+
export interface GetPolymarketWalletRequest {
|
|
8
|
+
/** Wallet address to look up. May be a Polymarket proxy address or the underlying signer EOA — the endpoint resolves either form. Must match `^0x[a-fA-F0-9]{40}$`. Mixed-case input is accepted and lowercased in the response. Mutually exclusive with `username`; exactly one of the two is required. */
|
|
9
|
+
address?: string;
|
|
10
|
+
/** Polymarket display name to look up. Match is case-insensitive and exact against the user's stored `name` (so `Car`, `car`, and `CAR` all resolve, but `Theo` does not match `Theo47`). A leading `@` is accepted and stripped before the lookup. Mutually exclusive with `address`; exactly one of the two is required. Example: `Car`. */
|
|
11
|
+
username?: string;
|
|
12
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { GetBinanceCryptoPricesRequest } from "./GetBinanceCryptoPricesRequest.js";
|
|
2
2
|
export type { GetMarketsRequest } from "./GetMarketsRequest.js";
|
|
3
|
+
export type { GetPolymarketWalletRequest } from "./GetPolymarketWalletRequest.js";
|
|
3
4
|
export type { GetSportsMatchingMarketsRequest } from "./GetSportsMatchingMarketsRequest.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as core from "../../core/index.js";
|
|
2
|
+
import * as errors from "../../errors/index.js";
|
|
3
|
+
import type * as PredictorSDK from "../index.js";
|
|
4
|
+
export declare class NotFoundError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
6
|
+
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as errors from "../../errors/index.js";
|
|
3
|
+
export class NotFoundError extends errors.PredictorSDKError {
|
|
4
|
+
constructor(body, rawResponse) {
|
|
5
|
+
super({
|
|
6
|
+
message: "NotFoundError",
|
|
7
|
+
statusCode: 404,
|
|
8
|
+
body: body,
|
|
9
|
+
rawResponse: rawResponse,
|
|
10
|
+
});
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
this.name = this.constructor.name;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./BadGatewayError.js";
|
|
2
2
|
export * from "./BadRequestError.js";
|
|
3
3
|
export * from "./ForbiddenError.js";
|
|
4
|
+
export * from "./NotFoundError.js";
|
|
4
5
|
export * from "./PaymentRequiredError.js";
|
|
5
6
|
export * from "./ServiceUnavailableError.js";
|
|
6
7
|
export * from "./TooManyRequestsError.js";
|
package/dist/api/errors/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./BadGatewayError.js";
|
|
2
2
|
export * from "./BadRequestError.js";
|
|
3
3
|
export * from "./ForbiddenError.js";
|
|
4
|
+
export * from "./NotFoundError.js";
|
|
4
5
|
export * from "./PaymentRequiredError.js";
|
|
5
6
|
export * from "./ServiceUnavailableError.js";
|
|
6
7
|
export * from "./TooManyRequestsError.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PolymarketWalletResponse {
|
|
2
|
+
/** Polymarket proxy address (lowercased) the profile is keyed on. When the input was a signer EOA, this is the resolved proxy. */
|
|
3
|
+
address: string;
|
|
4
|
+
/** Original signer EOA from the request, when the input was an EOA that resolved to a different proxy. `null` when the input was already a proxy address (no resolution needed) or when no populated profile could be found for the resolved proxy. */
|
|
5
|
+
signer: string | null;
|
|
6
|
+
/** URL of the wallet's profile image, or `null` if unset. */
|
|
7
|
+
profileImage: string | null;
|
|
8
|
+
/** User-chosen display name when set; otherwise the auto-generated pseudonym Polymarket assigns. `null` only when both are missing. */
|
|
9
|
+
displayName: string | null;
|
|
10
|
+
}
|
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|
package/dist/api/types/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as PredictorSDK from "../../api/index.js";
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
import type * as serializers from "../index.js";
|
|
4
|
+
export declare const PolymarketWalletResponse: core.serialization.ObjectSchema<serializers.PolymarketWalletResponse.Raw, PredictorSDK.PolymarketWalletResponse>;
|
|
5
|
+
export declare namespace PolymarketWalletResponse {
|
|
6
|
+
interface Raw {
|
|
7
|
+
address: string;
|
|
8
|
+
signer?: string | null;
|
|
9
|
+
profile_image?: string | null;
|
|
10
|
+
display_name?: string | null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
export const PolymarketWalletResponse = core.serialization.object({
|
|
4
|
+
address: core.serialization.string(),
|
|
5
|
+
signer: core.serialization.string().nullable(),
|
|
6
|
+
profileImage: core.serialization.property("profile_image", core.serialization.string().nullable()),
|
|
7
|
+
displayName: core.serialization.property("display_name", core.serialization.string().nullable()),
|
|
8
|
+
});
|
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|