@beeperbot/sdk 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +239 -100
- package/dist/index.cjs +217 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +789 -774
- package/dist/index.d.ts +789 -774
- package/dist/index.js +218 -181
- package/dist/index.js.map +1 -1
- package/package.json +71 -57
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { randomUUID } from 'crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
// src/client/http.ts
|
|
5
5
|
|
|
@@ -46,6 +46,7 @@ var ErrorCodes = {
|
|
|
46
46
|
DRAFT_NOT_FOUND: "DRAFT_NOT_FOUND",
|
|
47
47
|
DRAFT_INVALID: "DRAFT_INVALID",
|
|
48
48
|
// Generic
|
|
49
|
+
NOT_FOUND: "NOT_FOUND",
|
|
49
50
|
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
50
51
|
};
|
|
51
52
|
var RETRYABLE_ERROR_CODES = [
|
|
@@ -63,8 +64,7 @@ var HTTP_STATUS_TO_ERROR_CODE = {
|
|
|
63
64
|
400: ErrorCodes.VALIDATION_ERROR,
|
|
64
65
|
401: ErrorCodes.UNAUTHORIZED,
|
|
65
66
|
403: ErrorCodes.FORBIDDEN,
|
|
66
|
-
404: ErrorCodes.
|
|
67
|
-
// Specific 404s are mapped differently
|
|
67
|
+
404: ErrorCodes.NOT_FOUND,
|
|
68
68
|
408: ErrorCodes.TIMEOUT,
|
|
69
69
|
429: ErrorCodes.RATE_LIMITED,
|
|
70
70
|
500: ErrorCodes.INTERNAL_ERROR,
|
|
@@ -197,16 +197,35 @@ var BeeperError = class _BeeperError extends Error {
|
|
|
197
197
|
* Create from an HTTP response
|
|
198
198
|
*/
|
|
199
199
|
static fromHttpResponse(statusCode, body, requestId) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
let code = ErrorCodes.UNKNOWN_ERROR;
|
|
201
|
+
let message = `HTTP ${statusCode} error`;
|
|
202
|
+
let details;
|
|
203
|
+
if (body && typeof body === "object") {
|
|
204
|
+
const errorBody = body.error;
|
|
205
|
+
const parsed = errorBody && typeof errorBody === "object" ? errorBody : body;
|
|
206
|
+
if (parsed.code && typeof parsed.code === "string") {
|
|
207
|
+
const knownCodes = Object.values(ErrorCodes);
|
|
208
|
+
code = knownCodes.includes(parsed.code) ? parsed.code : ErrorCodes.UNKNOWN_ERROR;
|
|
209
|
+
}
|
|
210
|
+
if (parsed.message && typeof parsed.message === "string") {
|
|
211
|
+
message = parsed.message;
|
|
212
|
+
}
|
|
213
|
+
if (parsed.details && typeof parsed.details === "object") {
|
|
214
|
+
details = parsed.details;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (code === ErrorCodes.UNKNOWN_ERROR) {
|
|
218
|
+
const statusFallback = HTTP_STATUS_TO_ERROR_CODE[statusCode];
|
|
219
|
+
if (statusFallback) {
|
|
220
|
+
code = statusFallback;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
204
223
|
const context = { statusCode };
|
|
205
224
|
if (requestId !== void 0) {
|
|
206
225
|
context.requestId = requestId;
|
|
207
226
|
}
|
|
208
|
-
if (
|
|
209
|
-
context.details =
|
|
227
|
+
if (details !== void 0) {
|
|
228
|
+
context.details = details;
|
|
210
229
|
}
|
|
211
230
|
return new _BeeperError({
|
|
212
231
|
code,
|
|
@@ -224,22 +243,10 @@ var API_BASE_URLS = {
|
|
|
224
243
|
};
|
|
225
244
|
var TIMEOUTS = {
|
|
226
245
|
/** Default request timeout */
|
|
227
|
-
DEFAULT: 3e4
|
|
228
|
-
/** Timeout for quote requests */
|
|
229
|
-
QUOTE: 1e4,
|
|
230
|
-
/** Timeout for execute requests (longer due to blockchain) */
|
|
231
|
-
EXECUTE: 6e4,
|
|
232
|
-
/** Timeout for health checks */
|
|
233
|
-
HEALTH: 5e3
|
|
234
|
-
};
|
|
235
|
-
var ENDPOINTS = {
|
|
236
|
-
HEALTH: "/send/health",
|
|
237
|
-
QUOTES: "/send/quotes",
|
|
238
|
-
KEYS: "/keys"
|
|
246
|
+
DEFAULT: 3e4
|
|
239
247
|
};
|
|
240
248
|
var HEADERS = {
|
|
241
249
|
IDEMPOTENCY_KEY: "Idempotency-Key",
|
|
242
|
-
AUTHORIZATION: "Authorization",
|
|
243
250
|
REQUEST_ID: "X-Request-Id",
|
|
244
251
|
CONTENT_TYPE: "Content-Type"
|
|
245
252
|
};
|
|
@@ -532,7 +539,7 @@ var HttpClient = class {
|
|
|
532
539
|
buildHeaders(options) {
|
|
533
540
|
const headers = {
|
|
534
541
|
[HEADERS.CONTENT_TYPE]: "application/json",
|
|
535
|
-
|
|
542
|
+
"Authorization": `Bearer ${this.config.apiKey}`,
|
|
536
543
|
"User-Agent": `beeper-sdk/${SDK_VERSION}`,
|
|
537
544
|
...options.headers
|
|
538
545
|
};
|
|
@@ -582,8 +589,8 @@ var HttpClient = class {
|
|
|
582
589
|
mergeSignals(signal1, signal2) {
|
|
583
590
|
const controller = new AbortController();
|
|
584
591
|
const abort = () => controller.abort();
|
|
585
|
-
signal1.addEventListener("abort", abort);
|
|
586
|
-
signal2.addEventListener("abort", abort);
|
|
592
|
+
signal1.addEventListener("abort", abort, { once: true });
|
|
593
|
+
signal2.addEventListener("abort", abort, { once: true });
|
|
587
594
|
if (signal1.aborted || signal2.aborted) {
|
|
588
595
|
controller.abort();
|
|
589
596
|
}
|
|
@@ -591,9 +598,7 @@ var HttpClient = class {
|
|
|
591
598
|
}
|
|
592
599
|
};
|
|
593
600
|
function generateIdempotencyKey() {
|
|
594
|
-
|
|
595
|
-
const random = Math.random().toString(36).substring(2, 15);
|
|
596
|
-
return `${timestamp}-${random}`;
|
|
601
|
+
return `idk_${randomUUID()}`;
|
|
597
602
|
}
|
|
598
603
|
|
|
599
604
|
// src/client/filters.schema.ts
|
|
@@ -891,7 +896,7 @@ function generateFilterDocumentation() {
|
|
|
891
896
|
}
|
|
892
897
|
|
|
893
898
|
// src/client/AgentClient.ts
|
|
894
|
-
var
|
|
899
|
+
var ENDPOINTS = {
|
|
895
900
|
LOOKUP: "/agent/lookup",
|
|
896
901
|
INTENT: "/agent/intent",
|
|
897
902
|
PRICE: "/agent/price",
|
|
@@ -901,8 +906,6 @@ var ENDPOINTS2 = {
|
|
|
901
906
|
};
|
|
902
907
|
var AgentClient = class {
|
|
903
908
|
http;
|
|
904
|
-
// @ts-expect-error Reserved for future use
|
|
905
|
-
_debug;
|
|
906
909
|
constructor(config) {
|
|
907
910
|
if (!config.apiKey) {
|
|
908
911
|
throw BeeperError.validation("API key is required");
|
|
@@ -916,7 +919,6 @@ var AgentClient = class {
|
|
|
916
919
|
...config.debug && { debug: config.debug }
|
|
917
920
|
});
|
|
918
921
|
this.http = new HttpClient(httpConfig);
|
|
919
|
-
this._debug = config.debug ?? false;
|
|
920
922
|
}
|
|
921
923
|
/**
|
|
922
924
|
* Look up a user by username, FID, or wallet address
|
|
@@ -934,7 +936,7 @@ var AgentClient = class {
|
|
|
934
936
|
async lookup(identifier) {
|
|
935
937
|
const params = typeof identifier === "number" ? { fid: identifier } : { q: identifier };
|
|
936
938
|
const response = await this.http.get(
|
|
937
|
-
|
|
939
|
+
ENDPOINTS.LOOKUP,
|
|
938
940
|
{ params }
|
|
939
941
|
);
|
|
940
942
|
return response.data.data;
|
|
@@ -954,7 +956,7 @@ var AgentClient = class {
|
|
|
954
956
|
async getPrice(identifier) {
|
|
955
957
|
const params = typeof identifier === "number" ? { fid: identifier } : { q: identifier };
|
|
956
958
|
const response = await this.http.get(
|
|
957
|
-
|
|
959
|
+
ENDPOINTS.PRICE,
|
|
958
960
|
{ params }
|
|
959
961
|
);
|
|
960
962
|
return response.data.data;
|
|
@@ -988,7 +990,7 @@ var AgentClient = class {
|
|
|
988
990
|
throw BeeperError.validation("Amount must be a positive number");
|
|
989
991
|
}
|
|
990
992
|
const response = await this.http.post(
|
|
991
|
-
|
|
993
|
+
ENDPOINTS.INTENT,
|
|
992
994
|
{
|
|
993
995
|
to: input.to,
|
|
994
996
|
amountUsd: amountStr,
|
|
@@ -1046,7 +1048,7 @@ var AgentClient = class {
|
|
|
1046
1048
|
throw BeeperError.validation("Budget must be a positive number");
|
|
1047
1049
|
}
|
|
1048
1050
|
const response = await this.http.post(
|
|
1049
|
-
|
|
1051
|
+
ENDPOINTS.ESTIMATE,
|
|
1050
1052
|
{
|
|
1051
1053
|
filters: input.filters,
|
|
1052
1054
|
budgetUsd: budgetStr,
|
|
@@ -1076,7 +1078,7 @@ var AgentClient = class {
|
|
|
1076
1078
|
async preview(input) {
|
|
1077
1079
|
const limit = Math.min(input.limit ?? 10, 20);
|
|
1078
1080
|
const response = await this.http.post(
|
|
1079
|
-
|
|
1081
|
+
ENDPOINTS.PREVIEW,
|
|
1080
1082
|
{
|
|
1081
1083
|
filters: input.filters,
|
|
1082
1084
|
limit
|
|
@@ -1108,7 +1110,7 @@ var AgentClient = class {
|
|
|
1108
1110
|
throw BeeperError.validation("Budget must be a positive number");
|
|
1109
1111
|
}
|
|
1110
1112
|
const response = await this.http.post(
|
|
1111
|
-
|
|
1113
|
+
ENDPOINTS.BULK_INTENT,
|
|
1112
1114
|
{
|
|
1113
1115
|
filters: input.filters,
|
|
1114
1116
|
budgetUsd: budgetStr,
|
|
@@ -1182,9 +1184,6 @@ function getApiKeyEnvironment(apiKey) {
|
|
|
1182
1184
|
}
|
|
1183
1185
|
return null;
|
|
1184
1186
|
}
|
|
1185
|
-
function createAuthorizationHeader(apiKey) {
|
|
1186
|
-
return `Bearer ${apiKey}`;
|
|
1187
|
-
}
|
|
1188
1187
|
function maskApiKey(apiKey) {
|
|
1189
1188
|
if (!apiKey || apiKey.length < 12) {
|
|
1190
1189
|
return "***";
|
|
@@ -1213,15 +1212,7 @@ var QuoteSchema = z.object({
|
|
|
1213
1212
|
depositChainId: z.number(),
|
|
1214
1213
|
depositTokenAddress: z.string(),
|
|
1215
1214
|
expiresAt: z.string(),
|
|
1216
|
-
input: z.
|
|
1217
|
-
filter: z.record(z.unknown()),
|
|
1218
|
-
tokenAddress: z.string(),
|
|
1219
|
-
chainId: z.number(),
|
|
1220
|
-
amountPerRecipient: z.string(),
|
|
1221
|
-
budgetCap: z.string(),
|
|
1222
|
-
memo: z.string().optional(),
|
|
1223
|
-
metadata: z.record(z.unknown()).optional()
|
|
1224
|
-
}),
|
|
1215
|
+
input: z.record(z.unknown()),
|
|
1225
1216
|
createdAt: z.string(),
|
|
1226
1217
|
updatedAt: z.string()
|
|
1227
1218
|
});
|
|
@@ -1246,18 +1237,24 @@ var ConfirmResultSchema = z.object({
|
|
|
1246
1237
|
status: z.enum(["confirmed", "pending_verification"]),
|
|
1247
1238
|
detectedAmount: z.string(),
|
|
1248
1239
|
sufficient: z.boolean(),
|
|
1249
|
-
blockNumber: z.number(),
|
|
1250
|
-
confirmedAt: z.string()
|
|
1240
|
+
blockNumber: z.number().int().optional(),
|
|
1241
|
+
confirmedAt: z.string().datetime().optional()
|
|
1251
1242
|
});
|
|
1252
1243
|
var ExecuteResultSchema = z.object({
|
|
1253
1244
|
quoteId: z.string(),
|
|
1254
|
-
status: z.enum(["executing", "queued"]),
|
|
1255
|
-
estimatedCompletionAt: z.string(),
|
|
1256
|
-
batchId: z.string()
|
|
1245
|
+
status: z.enum(["executing", "queued", "pending_deployment"]),
|
|
1246
|
+
estimatedCompletionAt: z.string().datetime().optional(),
|
|
1247
|
+
batchId: z.string().optional(),
|
|
1248
|
+
deployment: z.object({
|
|
1249
|
+
to: z.string(),
|
|
1250
|
+
data: z.string(),
|
|
1251
|
+
value: z.string(),
|
|
1252
|
+
chainId: z.number()
|
|
1253
|
+
}).optional()
|
|
1257
1254
|
});
|
|
1258
1255
|
var ReceiptSchema = z.object({
|
|
1259
1256
|
quoteId: z.string(),
|
|
1260
|
-
status: z.enum(["completed", "partial", "failed"]),
|
|
1257
|
+
status: z.enum(["completed", "partial", "failed", "executing"]),
|
|
1261
1258
|
successCount: z.number(),
|
|
1262
1259
|
failureCount: z.number(),
|
|
1263
1260
|
totalSent: z.string(),
|
|
@@ -1272,7 +1269,12 @@ var ReceiptSchema = z.object({
|
|
|
1272
1269
|
error: z.string().optional()
|
|
1273
1270
|
})
|
|
1274
1271
|
),
|
|
1275
|
-
completedAt: z.string()
|
|
1272
|
+
completedAt: z.string().datetime().optional()
|
|
1273
|
+
});
|
|
1274
|
+
var ConfirmDeploymentResultSchema = z.object({
|
|
1275
|
+
quoteId: z.string(),
|
|
1276
|
+
status: z.string(),
|
|
1277
|
+
escrowId: z.string().optional()
|
|
1276
1278
|
});
|
|
1277
1279
|
var HealthSchema = z.object({
|
|
1278
1280
|
status: z.enum(["healthy", "degraded", "unhealthy"]),
|
|
@@ -1284,7 +1286,7 @@ var HealthSchema = z.object({
|
|
|
1284
1286
|
oracle: z.enum(["up", "down"])
|
|
1285
1287
|
})
|
|
1286
1288
|
});
|
|
1287
|
-
var
|
|
1289
|
+
var ENDPOINTS2 = {
|
|
1288
1290
|
QUOTES: "/api/v1/sdk/send/quotes",
|
|
1289
1291
|
HEALTH: "/api/v1/sdk/send/health"
|
|
1290
1292
|
};
|
|
@@ -1365,7 +1367,7 @@ var BeeperClient = class {
|
|
|
1365
1367
|
ttlSeconds: opts?.ttlSeconds ?? 300
|
|
1366
1368
|
};
|
|
1367
1369
|
const response = await this.http.post(
|
|
1368
|
-
|
|
1370
|
+
ENDPOINTS2.QUOTES,
|
|
1369
1371
|
body,
|
|
1370
1372
|
{},
|
|
1371
1373
|
QuoteSchema
|
|
@@ -1421,7 +1423,7 @@ var BeeperClient = class {
|
|
|
1421
1423
|
ttlSeconds: opts?.ttlSeconds ?? 300
|
|
1422
1424
|
};
|
|
1423
1425
|
const response = await this.http.post(
|
|
1424
|
-
|
|
1426
|
+
ENDPOINTS2.QUOTES,
|
|
1425
1427
|
body,
|
|
1426
1428
|
{},
|
|
1427
1429
|
AttentionQuoteSchema
|
|
@@ -1435,7 +1437,7 @@ var BeeperClient = class {
|
|
|
1435
1437
|
*/
|
|
1436
1438
|
async getQuote(quoteId) {
|
|
1437
1439
|
const response = await this.http.get(
|
|
1438
|
-
`${
|
|
1440
|
+
`${ENDPOINTS2.QUOTES}/${quoteId}`,
|
|
1439
1441
|
{},
|
|
1440
1442
|
QuoteSchema
|
|
1441
1443
|
);
|
|
@@ -1455,7 +1457,7 @@ var BeeperClient = class {
|
|
|
1455
1457
|
throw BeeperError.validation("Invalid transaction hash format");
|
|
1456
1458
|
}
|
|
1457
1459
|
const response = await this.http.post(
|
|
1458
|
-
`${
|
|
1460
|
+
`${ENDPOINTS2.QUOTES}/${quoteId}/confirm`,
|
|
1459
1461
|
{ txHash: params.txHash },
|
|
1460
1462
|
{ idempotencyKey: params.idempotencyKey },
|
|
1461
1463
|
ConfirmResultSchema
|
|
@@ -1465,21 +1467,46 @@ var BeeperClient = class {
|
|
|
1465
1467
|
/**
|
|
1466
1468
|
* Triggers execution of the send
|
|
1467
1469
|
* @param quoteId - The quote ID
|
|
1468
|
-
* @param params - Execution parameters including idempotencyKey
|
|
1470
|
+
* @param params - Execution parameters including idempotencyKey and optional deploymentMode
|
|
1469
1471
|
* @returns Execution result
|
|
1470
1472
|
*/
|
|
1471
1473
|
async executeSend(quoteId, params) {
|
|
1472
1474
|
if (!params.idempotencyKey) {
|
|
1473
1475
|
throw BeeperError.validation("Idempotency key is required for executeSend");
|
|
1474
1476
|
}
|
|
1477
|
+
const body = {};
|
|
1478
|
+
if (params.deploymentMode) {
|
|
1479
|
+
body.deploymentMode = params.deploymentMode;
|
|
1480
|
+
}
|
|
1475
1481
|
const response = await this.http.post(
|
|
1476
|
-
`${
|
|
1477
|
-
|
|
1482
|
+
`${ENDPOINTS2.QUOTES}/${quoteId}/execute`,
|
|
1483
|
+
body,
|
|
1478
1484
|
{ idempotencyKey: params.idempotencyKey },
|
|
1479
1485
|
ExecuteResultSchema
|
|
1480
1486
|
);
|
|
1481
1487
|
return response.data;
|
|
1482
1488
|
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Confirms a client-side deployment transaction
|
|
1491
|
+
* @param quoteId - The quote ID
|
|
1492
|
+
* @param input - Deployment confirmation parameters including txHash
|
|
1493
|
+
* @returns Deployment confirmation result
|
|
1494
|
+
*/
|
|
1495
|
+
async confirmDeployment(quoteId, input) {
|
|
1496
|
+
if (!quoteId) {
|
|
1497
|
+
throw BeeperError.validation("quoteId is required");
|
|
1498
|
+
}
|
|
1499
|
+
if (!input.txHash) {
|
|
1500
|
+
throw BeeperError.validation("txHash is required");
|
|
1501
|
+
}
|
|
1502
|
+
const response = await this.http.post(
|
|
1503
|
+
`${ENDPOINTS2.QUOTES}/${quoteId}/confirm-deployment`,
|
|
1504
|
+
{ txHash: input.txHash },
|
|
1505
|
+
{ idempotencyKey: `cdep_${quoteId}_${input.txHash.slice(0, 10)}` },
|
|
1506
|
+
ConfirmDeploymentResultSchema
|
|
1507
|
+
);
|
|
1508
|
+
return response.data;
|
|
1509
|
+
}
|
|
1483
1510
|
/**
|
|
1484
1511
|
* Gets the receipt for a completed (or failed) execution
|
|
1485
1512
|
* @param quoteId - The quote ID
|
|
@@ -1487,7 +1514,7 @@ var BeeperClient = class {
|
|
|
1487
1514
|
*/
|
|
1488
1515
|
async getReceiptByQuoteId(quoteId) {
|
|
1489
1516
|
const response = await this.http.get(
|
|
1490
|
-
`${
|
|
1517
|
+
`${ENDPOINTS2.QUOTES}/${quoteId}/receipt`,
|
|
1491
1518
|
{},
|
|
1492
1519
|
ReceiptSchema
|
|
1493
1520
|
);
|
|
@@ -1533,7 +1560,7 @@ var BeeperClient = class {
|
|
|
1533
1560
|
*/
|
|
1534
1561
|
async health() {
|
|
1535
1562
|
const response = await this.http.get(
|
|
1536
|
-
|
|
1563
|
+
ENDPOINTS2.HEALTH,
|
|
1537
1564
|
{},
|
|
1538
1565
|
HealthSchema
|
|
1539
1566
|
);
|
|
@@ -2155,6 +2182,18 @@ function updateDraft(draft, updates) {
|
|
|
2155
2182
|
function isReadyForQuote(draft) {
|
|
2156
2183
|
return draft.status === "draft" && draft.name.length > 0 && parseFloat(draft.amount) > 0;
|
|
2157
2184
|
}
|
|
2185
|
+
|
|
2186
|
+
// src/send/validation.ts
|
|
2187
|
+
function validateQuoteId(quoteId) {
|
|
2188
|
+
if (!quoteId || typeof quoteId !== "string") {
|
|
2189
|
+
throw BeeperError.validation("quoteId is required");
|
|
2190
|
+
}
|
|
2191
|
+
if (!/^qt_[a-zA-Z0-9]+$/.test(quoteId)) {
|
|
2192
|
+
throw BeeperError.validation(`Invalid quoteId format: ${quoteId}. Expected format: qt_<id>`);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
// src/send/quotes.ts
|
|
2158
2197
|
var ApiQuoteResponseSchema = z.object({
|
|
2159
2198
|
id: z.string().regex(/^qt_[a-zA-Z0-9]+$/),
|
|
2160
2199
|
status: z.enum([
|
|
@@ -2197,13 +2236,7 @@ async function createQuote(httpClient, draft, opts) {
|
|
|
2197
2236
|
return response.data;
|
|
2198
2237
|
}
|
|
2199
2238
|
async function getQuote(httpClient, quoteId) {
|
|
2200
|
-
|
|
2201
|
-
throw new BeeperError({
|
|
2202
|
-
code: ErrorCodes.VALIDATION_ERROR,
|
|
2203
|
-
message: "Invalid quote ID format. Expected format: qt_xxxxx",
|
|
2204
|
-
retryable: false
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2239
|
+
validateQuoteId(quoteId);
|
|
2207
2240
|
const response = await httpClient.get(
|
|
2208
2241
|
`/api/v1/sdk/send/quotes/${quoteId}`,
|
|
2209
2242
|
{},
|
|
@@ -2225,7 +2258,11 @@ function getChainId(network) {
|
|
|
2225
2258
|
polygon: 137,
|
|
2226
2259
|
optimism: 10
|
|
2227
2260
|
};
|
|
2228
|
-
|
|
2261
|
+
const id = chainIds[network];
|
|
2262
|
+
if (id === void 0) {
|
|
2263
|
+
throw BeeperError.validation(`Unsupported network: ${network}`);
|
|
2264
|
+
}
|
|
2265
|
+
return id;
|
|
2229
2266
|
}
|
|
2230
2267
|
function getTokenAddress(token, network) {
|
|
2231
2268
|
const addresses = {
|
|
@@ -2244,15 +2281,19 @@ function getTokenAddress(token, network) {
|
|
|
2244
2281
|
optimism: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"
|
|
2245
2282
|
}
|
|
2246
2283
|
};
|
|
2247
|
-
|
|
2284
|
+
const addr = addresses[token]?.[network];
|
|
2285
|
+
if (!addr) {
|
|
2286
|
+
throw BeeperError.validation(`Unsupported token ${token} on network ${network}`);
|
|
2287
|
+
}
|
|
2288
|
+
return addr;
|
|
2248
2289
|
}
|
|
2249
2290
|
var ConfirmDepositResponseSchema = z.object({
|
|
2250
2291
|
quoteId: z.string(),
|
|
2251
2292
|
status: z.enum(["confirmed", "pending_verification"]),
|
|
2252
2293
|
detectedAmount: z.string(),
|
|
2253
2294
|
sufficient: z.boolean(),
|
|
2254
|
-
blockNumber: z.number().int(),
|
|
2255
|
-
confirmedAt: z.string().datetime()
|
|
2295
|
+
blockNumber: z.number().int().optional(),
|
|
2296
|
+
confirmedAt: z.string().datetime().optional()
|
|
2256
2297
|
});
|
|
2257
2298
|
async function confirmDeposit(httpClient, quoteId, params) {
|
|
2258
2299
|
validateQuoteId(quoteId);
|
|
@@ -2291,26 +2332,23 @@ function validateTxHash(txHash) {
|
|
|
2291
2332
|
});
|
|
2292
2333
|
}
|
|
2293
2334
|
}
|
|
2294
|
-
function validateQuoteId(quoteId) {
|
|
2295
|
-
if (!quoteId.match(/^qt_[a-zA-Z0-9]+$/)) {
|
|
2296
|
-
throw new BeeperError({
|
|
2297
|
-
code: ErrorCodes.VALIDATION_ERROR,
|
|
2298
|
-
message: "Invalid quote ID format. Expected format: qt_xxxxx",
|
|
2299
|
-
retryable: false
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
2335
|
function generateDepositIdempotencyKey(quoteId) {
|
|
2304
2336
|
return `confirm-${quoteId}`;
|
|
2305
2337
|
}
|
|
2306
2338
|
var ExecuteSendResponseSchema = z.object({
|
|
2307
2339
|
quoteId: z.string(),
|
|
2308
|
-
status: z.enum(["executing", "queued"]),
|
|
2309
|
-
estimatedCompletionAt: z.string().datetime(),
|
|
2310
|
-
batchId: z.string()
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2340
|
+
status: z.enum(["executing", "queued", "pending_deployment"]),
|
|
2341
|
+
estimatedCompletionAt: z.string().datetime().optional(),
|
|
2342
|
+
batchId: z.string().optional(),
|
|
2343
|
+
deployment: z.object({
|
|
2344
|
+
to: z.string(),
|
|
2345
|
+
data: z.string(),
|
|
2346
|
+
value: z.string(),
|
|
2347
|
+
chainId: z.number()
|
|
2348
|
+
}).optional()
|
|
2349
|
+
});
|
|
2350
|
+
async function executeSend(httpClient, quoteId, params, options) {
|
|
2351
|
+
validateQuoteId(quoteId);
|
|
2314
2352
|
if (!params.idempotencyKey || params.idempotencyKey.length === 0) {
|
|
2315
2353
|
throw new BeeperError({
|
|
2316
2354
|
code: ErrorCodes.VALIDATION_ERROR,
|
|
@@ -2318,10 +2356,13 @@ async function executeSend(httpClient, quoteId, params) {
|
|
|
2318
2356
|
retryable: false
|
|
2319
2357
|
});
|
|
2320
2358
|
}
|
|
2359
|
+
const body = {};
|
|
2360
|
+
if (options?.deploymentMode) {
|
|
2361
|
+
body.deploymentMode = options.deploymentMode;
|
|
2362
|
+
}
|
|
2321
2363
|
const response = await httpClient.post(
|
|
2322
2364
|
`/api/v1/sdk/send/quotes/${quoteId}/execute`,
|
|
2323
|
-
|
|
2324
|
-
// Empty body as per HTTP contract
|
|
2365
|
+
body,
|
|
2325
2366
|
{ idempotencyKey: params.idempotencyKey },
|
|
2326
2367
|
ExecuteSendResponseSchema
|
|
2327
2368
|
);
|
|
@@ -2331,19 +2372,13 @@ function isExecuting(result) {
|
|
|
2331
2372
|
return result.status === "executing" || result.status === "queued";
|
|
2332
2373
|
}
|
|
2333
2374
|
function getEstimatedTimeRemaining(result) {
|
|
2375
|
+
if (!result.estimatedCompletionAt) {
|
|
2376
|
+
return 0;
|
|
2377
|
+
}
|
|
2334
2378
|
const estimatedCompletion = new Date(result.estimatedCompletionAt);
|
|
2335
2379
|
const now = /* @__PURE__ */ new Date();
|
|
2336
2380
|
return Math.max(0, estimatedCompletion.getTime() - now.getTime());
|
|
2337
2381
|
}
|
|
2338
|
-
function validateQuoteId2(quoteId) {
|
|
2339
|
-
if (!quoteId.match(/^qt_[a-zA-Z0-9]+$/)) {
|
|
2340
|
-
throw new BeeperError({
|
|
2341
|
-
code: ErrorCodes.VALIDATION_ERROR,
|
|
2342
|
-
message: "Invalid quote ID format. Expected format: qt_xxxxx",
|
|
2343
|
-
retryable: false
|
|
2344
|
-
});
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
2382
|
function generateExecuteIdempotencyKey(quoteId) {
|
|
2348
2383
|
return `execute-${quoteId}`;
|
|
2349
2384
|
}
|
|
@@ -2356,25 +2391,19 @@ var ReceiptTransactionSchema = z.object({
|
|
|
2356
2391
|
});
|
|
2357
2392
|
var ApiReceiptResponseSchema = z.object({
|
|
2358
2393
|
quoteId: z.string(),
|
|
2359
|
-
status: z.enum(["completed", "partial", "failed"]),
|
|
2394
|
+
status: z.enum(["completed", "partial", "failed", "executing"]),
|
|
2360
2395
|
successCount: z.number().int().min(0),
|
|
2361
2396
|
failureCount: z.number().int().min(0),
|
|
2362
2397
|
totalSent: z.string(),
|
|
2363
2398
|
refundAmount: z.string(),
|
|
2364
2399
|
refundTxHash: z.string().nullable().optional(),
|
|
2365
2400
|
transactions: z.array(ReceiptTransactionSchema),
|
|
2366
|
-
completedAt: z.string().datetime()
|
|
2401
|
+
completedAt: z.string().datetime().optional()
|
|
2367
2402
|
});
|
|
2368
2403
|
var DEFAULT_MAX_ATTEMPTS = 60;
|
|
2369
2404
|
var DEFAULT_INTERVAL_MS = 5e3;
|
|
2370
2405
|
async function getReceipt(httpClient, quoteId) {
|
|
2371
|
-
|
|
2372
|
-
throw new BeeperError({
|
|
2373
|
-
code: ErrorCodes.VALIDATION_ERROR,
|
|
2374
|
-
message: "Invalid quote ID format. Expected format: qt_xxxxx",
|
|
2375
|
-
retryable: false
|
|
2376
|
-
});
|
|
2377
|
-
}
|
|
2406
|
+
validateQuoteId(quoteId);
|
|
2378
2407
|
const response = await httpClient.get(
|
|
2379
2408
|
`/api/v1/sdk/send/quotes/${quoteId}/receipt`,
|
|
2380
2409
|
{},
|
|
@@ -2406,7 +2435,7 @@ async function pollUntilComplete(httpClient, quoteId, opts) {
|
|
|
2406
2435
|
}
|
|
2407
2436
|
}
|
|
2408
2437
|
throw new BeeperError({
|
|
2409
|
-
code: ErrorCodes.
|
|
2438
|
+
code: ErrorCodes.TIMEOUT,
|
|
2410
2439
|
message: `Polling timed out after ${maxAttempts} attempts`,
|
|
2411
2440
|
context: { details: { quoteId, maxAttempts } },
|
|
2412
2441
|
retryable: false
|
|
@@ -2427,11 +2456,27 @@ function getFailedTransactions(receipt) {
|
|
|
2427
2456
|
}
|
|
2428
2457
|
function sleep(ms, signal) {
|
|
2429
2458
|
return new Promise((resolve, reject) => {
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2459
|
+
if (signal?.aborted) {
|
|
2460
|
+
reject(new BeeperError({
|
|
2461
|
+
code: ErrorCodes.TIMEOUT,
|
|
2462
|
+
message: "Poll aborted by signal",
|
|
2463
|
+
retryable: false
|
|
2464
|
+
}));
|
|
2465
|
+
return;
|
|
2466
|
+
}
|
|
2467
|
+
const timer = setTimeout(() => {
|
|
2468
|
+
if (signal) signal.removeEventListener("abort", onAbort);
|
|
2469
|
+
resolve();
|
|
2470
|
+
}, ms);
|
|
2471
|
+
function onAbort() {
|
|
2472
|
+
clearTimeout(timer);
|
|
2473
|
+
reject(new BeeperError({
|
|
2474
|
+
code: ErrorCodes.TIMEOUT,
|
|
2475
|
+
message: "Poll aborted by signal",
|
|
2476
|
+
retryable: false
|
|
2477
|
+
}));
|
|
2478
|
+
}
|
|
2479
|
+
if (signal) signal.addEventListener("abort", onAbort, { once: true });
|
|
2435
2480
|
});
|
|
2436
2481
|
}
|
|
2437
2482
|
|
|
@@ -2466,7 +2511,7 @@ var FilterExpression = class {
|
|
|
2466
2511
|
return FilterBuilder.not(this);
|
|
2467
2512
|
}
|
|
2468
2513
|
};
|
|
2469
|
-
var FilterBuilder = class {
|
|
2514
|
+
var FilterBuilder = class _FilterBuilder {
|
|
2470
2515
|
// ===========================================================================
|
|
2471
2516
|
// Logical Combinators
|
|
2472
2517
|
// ===========================================================================
|
|
@@ -2476,7 +2521,7 @@ var FilterBuilder = class {
|
|
|
2476
2521
|
*/
|
|
2477
2522
|
static and(filters) {
|
|
2478
2523
|
if (filters.length === 0) {
|
|
2479
|
-
throw
|
|
2524
|
+
throw BeeperError.validation("and() requires at least one filter");
|
|
2480
2525
|
}
|
|
2481
2526
|
if (filters.length === 1) {
|
|
2482
2527
|
return filters[0];
|
|
@@ -2491,7 +2536,7 @@ var FilterBuilder = class {
|
|
|
2491
2536
|
*/
|
|
2492
2537
|
static or(filters) {
|
|
2493
2538
|
if (filters.length === 0) {
|
|
2494
|
-
throw
|
|
2539
|
+
throw BeeperError.validation("or() requires at least one filter");
|
|
2495
2540
|
}
|
|
2496
2541
|
if (filters.length === 1) {
|
|
2497
2542
|
return filters[0];
|
|
@@ -2528,7 +2573,7 @@ var FilterBuilder = class {
|
|
|
2528
2573
|
*/
|
|
2529
2574
|
static activeInLastDays(days) {
|
|
2530
2575
|
if (days < 1 || days > 365) {
|
|
2531
|
-
throw
|
|
2576
|
+
throw BeeperError.validation("activeInLastDays must be between 1 and 365");
|
|
2532
2577
|
}
|
|
2533
2578
|
return new FilterExpression({ activeInLastDays: days });
|
|
2534
2579
|
}
|
|
@@ -2541,7 +2586,7 @@ var FilterBuilder = class {
|
|
|
2541
2586
|
*/
|
|
2542
2587
|
static neynarScoreMin(score) {
|
|
2543
2588
|
if (score < 0 || score > 1) {
|
|
2544
|
-
throw
|
|
2589
|
+
throw BeeperError.validation("neynarScoreMin must be between 0 and 1");
|
|
2545
2590
|
}
|
|
2546
2591
|
return new FilterExpression({ neynarScoreMin: score });
|
|
2547
2592
|
}
|
|
@@ -2551,7 +2596,7 @@ var FilterBuilder = class {
|
|
|
2551
2596
|
*/
|
|
2552
2597
|
static neynarScoreMax(score) {
|
|
2553
2598
|
if (score < 0 || score > 1) {
|
|
2554
|
-
throw
|
|
2599
|
+
throw BeeperError.validation("neynarScoreMax must be between 0 and 1");
|
|
2555
2600
|
}
|
|
2556
2601
|
return new FilterExpression({ neynarScoreMax: score });
|
|
2557
2602
|
}
|
|
@@ -2562,10 +2607,10 @@ var FilterBuilder = class {
|
|
|
2562
2607
|
*/
|
|
2563
2608
|
static neynarScoreRange(min, max) {
|
|
2564
2609
|
if (min !== void 0 && (min < 0 || min > 1)) {
|
|
2565
|
-
throw
|
|
2610
|
+
throw BeeperError.validation("neynarScoreRange min must be between 0 and 1");
|
|
2566
2611
|
}
|
|
2567
2612
|
if (max !== void 0 && (max < 0 || max > 1)) {
|
|
2568
|
-
throw
|
|
2613
|
+
throw BeeperError.validation("neynarScoreRange max must be between 0 and 1");
|
|
2569
2614
|
}
|
|
2570
2615
|
const range = {};
|
|
2571
2616
|
if (min !== void 0) range.min = min;
|
|
@@ -2580,11 +2625,10 @@ var FilterBuilder = class {
|
|
|
2580
2625
|
return new FilterExpression({ spamLabel: label });
|
|
2581
2626
|
}
|
|
2582
2627
|
/**
|
|
2583
|
-
*
|
|
2584
|
-
* @deprecated Use spamLabel('not_spam_only') instead
|
|
2628
|
+
* Convenience method: exclude spam users (shorthand for spamLabel('not_spam_only'))
|
|
2585
2629
|
*/
|
|
2586
2630
|
static excludeSpam() {
|
|
2587
|
-
return
|
|
2631
|
+
return _FilterBuilder.spamLabel("not_spam_only");
|
|
2588
2632
|
}
|
|
2589
2633
|
// ===========================================================================
|
|
2590
2634
|
// Social Graph Filters (Followers)
|
|
@@ -2595,7 +2639,7 @@ var FilterBuilder = class {
|
|
|
2595
2639
|
*/
|
|
2596
2640
|
static minFollowers(count) {
|
|
2597
2641
|
if (count < 0) {
|
|
2598
|
-
throw
|
|
2642
|
+
throw BeeperError.validation("minFollowers must be >= 0");
|
|
2599
2643
|
}
|
|
2600
2644
|
return new FilterExpression({ minFollowers: count });
|
|
2601
2645
|
}
|
|
@@ -2605,7 +2649,7 @@ var FilterBuilder = class {
|
|
|
2605
2649
|
*/
|
|
2606
2650
|
static maxFollowers(count) {
|
|
2607
2651
|
if (count < 0) {
|
|
2608
|
-
throw
|
|
2652
|
+
throw BeeperError.validation("maxFollowers must be >= 0");
|
|
2609
2653
|
}
|
|
2610
2654
|
return new FilterExpression({ maxFollowers: count });
|
|
2611
2655
|
}
|
|
@@ -2616,10 +2660,10 @@ var FilterBuilder = class {
|
|
|
2616
2660
|
*/
|
|
2617
2661
|
static followerRange(min, max) {
|
|
2618
2662
|
if (min !== void 0 && min < 0) {
|
|
2619
|
-
throw
|
|
2663
|
+
throw BeeperError.validation("followerRange min must be >= 0");
|
|
2620
2664
|
}
|
|
2621
2665
|
if (max !== void 0 && max < 0) {
|
|
2622
|
-
throw
|
|
2666
|
+
throw BeeperError.validation("followerRange max must be >= 0");
|
|
2623
2667
|
}
|
|
2624
2668
|
const range = {};
|
|
2625
2669
|
if (min !== void 0) range.min = min;
|
|
@@ -2632,7 +2676,7 @@ var FilterBuilder = class {
|
|
|
2632
2676
|
*/
|
|
2633
2677
|
static followersOf(fid) {
|
|
2634
2678
|
if (fid < 1) {
|
|
2635
|
-
throw
|
|
2679
|
+
throw BeeperError.validation("followersOf FID must be >= 1");
|
|
2636
2680
|
}
|
|
2637
2681
|
return new FilterExpression({ followersOf: fid });
|
|
2638
2682
|
}
|
|
@@ -2642,7 +2686,7 @@ var FilterBuilder = class {
|
|
|
2642
2686
|
*/
|
|
2643
2687
|
static mutualsWith(fid) {
|
|
2644
2688
|
if (fid < 1) {
|
|
2645
|
-
throw
|
|
2689
|
+
throw BeeperError.validation("mutualsWith FID must be >= 1");
|
|
2646
2690
|
}
|
|
2647
2691
|
return new FilterExpression({ mutualsWith: fid });
|
|
2648
2692
|
}
|
|
@@ -2655,7 +2699,7 @@ var FilterBuilder = class {
|
|
|
2655
2699
|
*/
|
|
2656
2700
|
static maxAttentionPriceUsd(usd) {
|
|
2657
2701
|
if (usd < 0) {
|
|
2658
|
-
throw
|
|
2702
|
+
throw BeeperError.validation("maxAttentionPriceUsd must be >= 0");
|
|
2659
2703
|
}
|
|
2660
2704
|
return new FilterExpression({ maxAttentionPriceUsd: usd });
|
|
2661
2705
|
}
|
|
@@ -2668,11 +2712,11 @@ var FilterBuilder = class {
|
|
|
2668
2712
|
*/
|
|
2669
2713
|
static tokenHolder(opts) {
|
|
2670
2714
|
if (!/^0x[a-fA-F0-9]{40}$/.test(opts.tokenAddress)) {
|
|
2671
|
-
throw
|
|
2715
|
+
throw BeeperError.validation("tokenAddress must be a valid Ethereum address");
|
|
2672
2716
|
}
|
|
2673
2717
|
if (opts.minBalance !== void 0) {
|
|
2674
2718
|
if (!/^[0-9]+$/.test(opts.minBalance)) {
|
|
2675
|
-
throw
|
|
2719
|
+
throw BeeperError.validation("minBalance must be a numeric string (wei)");
|
|
2676
2720
|
}
|
|
2677
2721
|
return new FilterExpression({
|
|
2678
2722
|
walletMinBalance: {
|
|
@@ -2695,24 +2739,26 @@ var FilterBuilder = class {
|
|
|
2695
2739
|
*/
|
|
2696
2740
|
static tokenHolders(opts) {
|
|
2697
2741
|
if (opts.length === 0) {
|
|
2698
|
-
throw
|
|
2742
|
+
throw BeeperError.validation("tokenHolders requires at least one token option");
|
|
2699
2743
|
}
|
|
2700
2744
|
if (opts.length > 10) {
|
|
2701
2745
|
throw new Error("tokenHolders cannot exceed 10 tokens");
|
|
2702
2746
|
}
|
|
2703
2747
|
for (const opt of opts) {
|
|
2704
2748
|
if (!/^0x[a-fA-F0-9]{40}$/.test(opt.tokenAddress)) {
|
|
2705
|
-
throw
|
|
2749
|
+
throw BeeperError.validation("tokenAddress must be a valid Ethereum address");
|
|
2706
2750
|
}
|
|
2707
2751
|
if (opt.minBalance !== void 0 && !/^[0-9]+$/.test(opt.minBalance)) {
|
|
2708
|
-
throw
|
|
2752
|
+
throw BeeperError.validation("minBalance must be a numeric string (wei)");
|
|
2709
2753
|
}
|
|
2710
2754
|
}
|
|
2711
2755
|
return new FilterExpression({
|
|
2712
2756
|
tokenHolders: opts.map((o) => ({
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2757
|
+
contractAddress: o.tokenAddress,
|
|
2758
|
+
chain: o.chainId === 8453 ? "base" : "ethereum",
|
|
2759
|
+
tokenStandard: o.tokenStandard ?? "ERC20",
|
|
2760
|
+
...o.minBalance !== void 0 ? { minBalance: o.minBalance } : {},
|
|
2761
|
+
...o.tokenId !== void 0 ? { tokenId: o.tokenId } : {}
|
|
2716
2762
|
}))
|
|
2717
2763
|
});
|
|
2718
2764
|
}
|
|
@@ -2735,11 +2781,14 @@ var FilterBuilder = class {
|
|
|
2735
2781
|
throw new Error("minBalance must be a numeric string (wei)");
|
|
2736
2782
|
}
|
|
2737
2783
|
}
|
|
2784
|
+
const chainNames = { 1: "ethereum", 8453: "base", 42161: "arbitrum", 10: "optimism", 137: "polygon" };
|
|
2738
2785
|
return new FilterExpression({
|
|
2739
2786
|
cachedTokenHolders: opts.map((o) => ({
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2787
|
+
contractAddress: o.tokenAddress,
|
|
2788
|
+
chain: chainNames[o.chainId] ?? String(o.chainId),
|
|
2789
|
+
tokenStandard: o.tokenStandard ?? "ERC20",
|
|
2790
|
+
...o.minBalance !== void 0 ? { minBalance: o.minBalance } : {},
|
|
2791
|
+
...o.tokenId !== void 0 ? { tokenId: o.tokenId } : {}
|
|
2743
2792
|
}))
|
|
2744
2793
|
});
|
|
2745
2794
|
}
|
|
@@ -2801,7 +2850,7 @@ var FilterBuilder = class {
|
|
|
2801
2850
|
*/
|
|
2802
2851
|
static minTenureDays(days) {
|
|
2803
2852
|
if (days < 0) {
|
|
2804
|
-
throw
|
|
2853
|
+
throw BeeperError.validation("minTenureDays must be >= 0");
|
|
2805
2854
|
}
|
|
2806
2855
|
return new FilterExpression({ minTenureDays: days });
|
|
2807
2856
|
}
|
|
@@ -2821,10 +2870,10 @@ var FilterBuilder = class {
|
|
|
2821
2870
|
*/
|
|
2822
2871
|
static userIds(ids) {
|
|
2823
2872
|
if (ids.length === 0) {
|
|
2824
|
-
throw
|
|
2873
|
+
throw BeeperError.validation("userIds requires at least one ID");
|
|
2825
2874
|
}
|
|
2826
2875
|
if (ids.length > 1e3) {
|
|
2827
|
-
throw
|
|
2876
|
+
throw BeeperError.validation("userIds cannot exceed 1000 IDs");
|
|
2828
2877
|
}
|
|
2829
2878
|
return new FilterExpression({ userIds: ids });
|
|
2830
2879
|
}
|
|
@@ -2841,10 +2890,10 @@ var FilterBuilder = class {
|
|
|
2841
2890
|
*/
|
|
2842
2891
|
static fids(fids) {
|
|
2843
2892
|
if (fids.length === 0) {
|
|
2844
|
-
throw
|
|
2893
|
+
throw BeeperError.validation("fids requires at least one FID");
|
|
2845
2894
|
}
|
|
2846
2895
|
if (fids.length > 1e3) {
|
|
2847
|
-
throw
|
|
2896
|
+
throw BeeperError.validation("fids cannot exceed 1000 FIDs");
|
|
2848
2897
|
}
|
|
2849
2898
|
return new FilterExpression({ fids });
|
|
2850
2899
|
}
|
|
@@ -2857,7 +2906,7 @@ var FilterBuilder = class {
|
|
|
2857
2906
|
*/
|
|
2858
2907
|
static hasTag(tag) {
|
|
2859
2908
|
if (tag.length > 64) {
|
|
2860
|
-
throw
|
|
2909
|
+
throw BeeperError.validation("Tag must be 64 characters or less");
|
|
2861
2910
|
}
|
|
2862
2911
|
return new FilterExpression({ hasTag: tag });
|
|
2863
2912
|
}
|
|
@@ -2867,7 +2916,7 @@ var FilterBuilder = class {
|
|
|
2867
2916
|
*/
|
|
2868
2917
|
static hasAnyTag(tags) {
|
|
2869
2918
|
if (tags.length === 0 || tags.length > 20) {
|
|
2870
|
-
throw
|
|
2919
|
+
throw BeeperError.validation("hasAnyTag requires 1-20 tags");
|
|
2871
2920
|
}
|
|
2872
2921
|
return new FilterExpression({ hasAnyTag: tags });
|
|
2873
2922
|
}
|
|
@@ -2877,7 +2926,7 @@ var FilterBuilder = class {
|
|
|
2877
2926
|
*/
|
|
2878
2927
|
static hasAllTags(tags) {
|
|
2879
2928
|
if (tags.length === 0 || tags.length > 20) {
|
|
2880
|
-
throw
|
|
2929
|
+
throw BeeperError.validation("hasAllTags requires 1-20 tags");
|
|
2881
2930
|
}
|
|
2882
2931
|
return new FilterExpression({ hasAllTags: tags });
|
|
2883
2932
|
}
|
|
@@ -2948,17 +2997,17 @@ var FilterBuilder = class {
|
|
|
2948
2997
|
*/
|
|
2949
2998
|
static timezones(zones) {
|
|
2950
2999
|
if (zones.length === 0) {
|
|
2951
|
-
throw
|
|
3000
|
+
throw BeeperError.validation("timezones requires at least one timezone");
|
|
2952
3001
|
}
|
|
2953
3002
|
if (zones.length > 24) {
|
|
2954
3003
|
throw new Error("timezones cannot exceed 24 entries");
|
|
2955
3004
|
}
|
|
2956
3005
|
for (const zone of zones) {
|
|
2957
3006
|
if (zone.offset < -12 || zone.offset > 14) {
|
|
2958
|
-
throw
|
|
3007
|
+
throw BeeperError.validation("timezone offset must be between -12 and 14");
|
|
2959
3008
|
}
|
|
2960
3009
|
if (zone.range !== void 0 && (zone.range < 0 || zone.range > 12)) {
|
|
2961
|
-
throw
|
|
3010
|
+
throw BeeperError.validation("timezone range must be between 0 and 12");
|
|
2962
3011
|
}
|
|
2963
3012
|
}
|
|
2964
3013
|
return new FilterExpression({ timezones: zones });
|
|
@@ -2969,28 +3018,28 @@ var FilterBuilder = class {
|
|
|
2969
3018
|
*/
|
|
2970
3019
|
static countries(codes) {
|
|
2971
3020
|
if (codes.length === 0) {
|
|
2972
|
-
throw
|
|
3021
|
+
throw BeeperError.validation("countries requires at least one country code");
|
|
2973
3022
|
}
|
|
2974
3023
|
if (codes.length > 50) {
|
|
2975
3024
|
throw new Error("countries cannot exceed 50 country codes");
|
|
2976
3025
|
}
|
|
2977
3026
|
for (const code of codes) {
|
|
2978
3027
|
if (!/^[A-Z]{2}$/.test(code)) {
|
|
2979
|
-
throw
|
|
3028
|
+
throw BeeperError.validation("Country codes must be ISO 3166-1 alpha-2 format (e.g., US, CA, GB)");
|
|
2980
3029
|
}
|
|
2981
3030
|
}
|
|
2982
|
-
return new FilterExpression({ countries: codes.map((
|
|
3031
|
+
return new FilterExpression({ countries: codes.map((c) => ({ code: c })) });
|
|
2983
3032
|
}
|
|
2984
3033
|
// ===========================================================================
|
|
2985
3034
|
// Engagement & Quality Filters
|
|
2986
3035
|
// ===========================================================================
|
|
2987
3036
|
/**
|
|
2988
3037
|
* Filter users with quotient score >= minimum
|
|
2989
|
-
* @param score - Minimum quotient score (0-1
|
|
3038
|
+
* @param score - Minimum quotient score (0-1)
|
|
2990
3039
|
*/
|
|
2991
3040
|
static quotientScoreMin(score) {
|
|
2992
3041
|
if (score < 0 || score > 1) {
|
|
2993
|
-
throw
|
|
3042
|
+
throw BeeperError.validation("quotientScoreMin must be between 0 and 1");
|
|
2994
3043
|
}
|
|
2995
3044
|
return new FilterExpression({ quotientScoreMin: score });
|
|
2996
3045
|
}
|
|
@@ -3000,7 +3049,7 @@ var FilterBuilder = class {
|
|
|
3000
3049
|
*/
|
|
3001
3050
|
static quotientScoreMax(score) {
|
|
3002
3051
|
if (score < 0 || score > 1) {
|
|
3003
|
-
throw
|
|
3052
|
+
throw BeeperError.validation("quotientScoreMax must be between 0 and 1");
|
|
3004
3053
|
}
|
|
3005
3054
|
return new FilterExpression({ quotientScoreMax: score });
|
|
3006
3055
|
}
|
|
@@ -3027,7 +3076,7 @@ var FilterBuilder = class {
|
|
|
3027
3076
|
*/
|
|
3028
3077
|
static minBatteryPercentage(pct) {
|
|
3029
3078
|
if (pct < 0 || pct > 100) {
|
|
3030
|
-
throw
|
|
3079
|
+
throw BeeperError.validation("minBatteryPercentage must be between 0 and 100");
|
|
3031
3080
|
}
|
|
3032
3081
|
return new FilterExpression({ minBatteryPercentage: pct });
|
|
3033
3082
|
}
|
|
@@ -3037,7 +3086,7 @@ var FilterBuilder = class {
|
|
|
3037
3086
|
*/
|
|
3038
3087
|
static hasRechargedInLastDays(days) {
|
|
3039
3088
|
if (days < 1) {
|
|
3040
|
-
throw
|
|
3089
|
+
throw BeeperError.validation("hasRechargedInLastDays must be >= 1");
|
|
3041
3090
|
}
|
|
3042
3091
|
return new FilterExpression({ hasRechargedInLastDays: days });
|
|
3043
3092
|
}
|
|
@@ -3071,7 +3120,7 @@ var FilterBuilder = class {
|
|
|
3071
3120
|
*/
|
|
3072
3121
|
static minCastCount(count) {
|
|
3073
3122
|
if (count < 0) {
|
|
3074
|
-
throw
|
|
3123
|
+
throw BeeperError.validation("minCastCount must be >= 0");
|
|
3075
3124
|
}
|
|
3076
3125
|
return new FilterExpression({ minCastCount: count });
|
|
3077
3126
|
}
|
|
@@ -3085,18 +3134,6 @@ var FilterBuilder = class {
|
|
|
3085
3134
|
static orderBy(order) {
|
|
3086
3135
|
return new FilterExpression({ orderBy: order });
|
|
3087
3136
|
}
|
|
3088
|
-
/**
|
|
3089
|
-
* Limit the number of results
|
|
3090
|
-
* @param n - Maximum number of results
|
|
3091
|
-
* @deprecated Limit is controlled by budgetCap, not this filter. This method will be removed.
|
|
3092
|
-
*/
|
|
3093
|
-
static limit(n) {
|
|
3094
|
-
console.warn("FilterBuilder.limit() is deprecated. Use budgetCap to control result count.");
|
|
3095
|
-
if (n < 1 || n > 1e4) {
|
|
3096
|
-
throw new Error("limit must be between 1 and 10000");
|
|
3097
|
-
}
|
|
3098
|
-
return new FilterExpression({ limit: n });
|
|
3099
|
-
}
|
|
3100
3137
|
};
|
|
3101
3138
|
var GasTierSchema = z.enum(["slow", "standard", "fast"]);
|
|
3102
3139
|
var QuoteOptionsSchema = z.object({
|
|
@@ -3197,6 +3234,6 @@ function parseReceipt(receipt) {
|
|
|
3197
3234
|
return ReceiptSchema2.parse(receipt);
|
|
3198
3235
|
}
|
|
3199
3236
|
|
|
3200
|
-
export { API_BASE_URLS, API_KEY_PREFIXES, ActiveInLastDaysFilterSchema, AgentClient, ApiQuoteResponseSchema, ApiReceiptResponseSchema, BeeperClient, BeeperEconomicsFilterSchema, BeeperError, CachedTokenHolderFilterSchema, CachedTokenHolderSchema, ConfirmDepositResponseSchema, ConfirmResultSchema2 as ConfirmResultSchema, CountryFilterSchema, DistributionStrategySchema, DraftInputSchema, DraftSchema, DraftStatusSchema, DraftUpdateSchema,
|
|
3237
|
+
export { API_BASE_URLS, API_KEY_PREFIXES, ActiveInLastDaysFilterSchema, AgentClient, ApiQuoteResponseSchema, ApiReceiptResponseSchema, BeeperClient, BeeperEconomicsFilterSchema, BeeperError, CachedTokenHolderFilterSchema, CachedTokenHolderSchema, ConfirmDepositResponseSchema, ConfirmResultSchema2 as ConfirmResultSchema, CountryFilterSchema, DistributionStrategySchema, DraftInputSchema, DraftSchema, DraftStatusSchema, DraftUpdateSchema, ErrorCodes, ExcludePingedTodayFilterSchema, ExcludeUsersFilterSchema, ExecuteResultSchema2 as ExecuteResultSchema, ExecuteSendResponseSchema, ExecuteStatusSchema, FILTER_SCHEMA, FieldComparisonSchema, FilterBuilder, FilterExpression, FilterExpressionSchema, FilterOperatorSchema, FilterValueSchema, FollowersOfFilterSchema, FollowingOfFilterSchema, GasTierSchema, HEADERS, HTTP_STATUS_TO_ERROR_CODE, HasBaseWalletFilterSchema, HasRechargedInLastDaysFilterSchema, HasTierFilterSchema, HasVerifiedWalletFilterSchema, HttpClient, IsWaitlistedFilterSchema, LegacyFieldComparisonSchema, LegacyFilterOperatorSchema, LegacyFilterValueSchema, LegacyRecipientFilterDSLSchema, MaxAttentionPriceFilterSchema, MaxFidFilterSchema, MaxFollowersFilterSchema, MaxFollowingFilterSchema, MinAttentionPriceFilterSchema, MinBatteryPercentageFilterSchema, MinCastCountFilterSchema, MinClickThroughRateFilterSchema, MinFidFilterSchema, MinFollowersFilterSchema, MinFollowingFilterSchema, MinProTenureDaysFilterSchema, MinTenureDaysFilterSchema, MutualsWithFilterSchema, NetworkSchema, NeynarScoreMaxFilterSchema, NeynarScoreMinFilterSchema, OnchainFilterSchema, OrderBySchema, PlatformFilterSchema, ProSubscriptionFilterSchema, QUOTE_EXPIRATION_SECONDS, QuoteOptionsSchema, QuoteRecipientSchema, QuoteSchema2 as QuoteSchema, QuotientScoreMaxFilterSchema, QuotientScoreMinFilterSchema, RETRYABLE_ERROR_CODES, RETRY_CONFIG, ReceiptSchema2 as ReceiptSchema, ReceiptTransactionSchema, ReceiptTransferSchema, RecipientFilterDSLSchema, RecipientFilterSchema, ReputationFilterSchema, RequireLotteryOptInFilterSchema, RequireQuizOptInFilterSchema, RolesFilterSchema, SDK_VERSION, SignalTokenFilterSchema, SocialFilterSchema, SpamLabelFilterSchema, SpecificUsersFilterSchema, TIMEOUTS, TimezoneFilterSchema, TokenHolderDiscoverySchema, TokenHolderFilterSchema, TokenTypeSchema, TransferStatusSchema, VerifiedOnlyFilterSchema, createHttpConfig, BeeperClient_default as default, describeFilters, generateDepositIdempotencyKey, generateExecuteIdempotencyKey, generateFilterDocumentation, generateIdempotencyKey, getAllFilterNames, getApiKeyEnvironment, getFilterSchema, isRetryableCode, isValidApiKeyFormat, maskApiKey, parseDraft, parseDraftInput, parseExecuteResult, parseFilter, parseQuote, parseQuoteOptions, parseReceipt, parseRecipientFilter, safeParseFilter, safeParseRecipientFilter, confirmDeposit as sendConfirmDeposit, createDraft as sendCreateDraft, createQuote as sendCreateQuote, executeSend as sendExecuteSend, getEstimatedTimeRemaining as sendGetEstimatedTimeRemaining, getFailedTransactions as sendGetFailedTransactions, getQuote as sendGetQuote, getReceipt as sendGetReceipt, getSuccessRate as sendGetSuccessRate, isComplete as sendIsComplete, isDepositSufficient as sendIsDepositSufficient, isExecuting as sendIsExecuting, isQuoteExpired as sendIsQuoteExpired, isReadyForDeposit as sendIsReadyForDeposit, isReadyForQuote as sendIsReadyForQuote, isSuccess as sendIsSuccess, pollUntilComplete as sendPollUntilComplete, updateDraft as sendUpdateDraft, validateDraftInput2 as sendValidateDraftInput, validateDraft, validateDraftInput, validateExecuteResult, validateFilter, validateFilterHasTargeting, validateQuote, validateQuoteOptions, validateReceipt, validateRecipientFilter };
|
|
3201
3238
|
//# sourceMappingURL=index.js.map
|
|
3202
3239
|
//# sourceMappingURL=index.js.map
|