@multisender.app/multisender-sdk 0.0.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.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +410 -0
  3. package/dist/auth/api-key.d.ts +8 -0
  4. package/dist/auth/api-key.d.ts.map +1 -0
  5. package/dist/cli/commands/distribute.d.ts +3 -0
  6. package/dist/cli/commands/distribute.d.ts.map +1 -0
  7. package/dist/cli/commands/distributions.d.ts +3 -0
  8. package/dist/cli/commands/distributions.d.ts.map +1 -0
  9. package/dist/cli/commands/lists.d.ts +3 -0
  10. package/dist/cli/commands/lists.d.ts.map +1 -0
  11. package/dist/cli/index.cjs +4507 -0
  12. package/dist/cli/index.cjs.map +46 -0
  13. package/dist/cli/index.d.ts +3 -0
  14. package/dist/cli/index.d.ts.map +1 -0
  15. package/dist/cli/index.js +4514 -0
  16. package/dist/cli/index.js.map +46 -0
  17. package/dist/core/errors.d.ts +20 -0
  18. package/dist/core/errors.d.ts.map +1 -0
  19. package/dist/core/generated-transport.d.ts +3 -0
  20. package/dist/core/generated-transport.d.ts.map +1 -0
  21. package/dist/core/pagination.d.ts +4 -0
  22. package/dist/core/pagination.d.ts.map +1 -0
  23. package/dist/core/types.d.ts +19 -0
  24. package/dist/core/types.d.ts.map +1 -0
  25. package/dist/gen/client/client.gen.d.ts +3 -0
  26. package/dist/gen/client/client.gen.d.ts.map +1 -0
  27. package/dist/gen/client/index.d.ts +9 -0
  28. package/dist/gen/client/index.d.ts.map +1 -0
  29. package/dist/gen/client/types.gen.d.ts +118 -0
  30. package/dist/gen/client/types.gen.d.ts.map +1 -0
  31. package/dist/gen/client/utils.gen.d.ts +34 -0
  32. package/dist/gen/client/utils.gen.d.ts.map +1 -0
  33. package/dist/gen/client.gen.d.ts +13 -0
  34. package/dist/gen/client.gen.d.ts.map +1 -0
  35. package/dist/gen/core/auth.gen.d.ts +19 -0
  36. package/dist/gen/core/auth.gen.d.ts.map +1 -0
  37. package/dist/gen/core/bodySerializer.gen.d.ts +26 -0
  38. package/dist/gen/core/bodySerializer.gen.d.ts.map +1 -0
  39. package/dist/gen/core/params.gen.d.ts +44 -0
  40. package/dist/gen/core/params.gen.d.ts.map +1 -0
  41. package/dist/gen/core/pathSerializer.gen.d.ts +34 -0
  42. package/dist/gen/core/pathSerializer.gen.d.ts.map +1 -0
  43. package/dist/gen/core/queryKeySerializer.gen.d.ts +19 -0
  44. package/dist/gen/core/queryKeySerializer.gen.d.ts.map +1 -0
  45. package/dist/gen/core/serverSentEvents.gen.d.ts +72 -0
  46. package/dist/gen/core/serverSentEvents.gen.d.ts.map +1 -0
  47. package/dist/gen/core/types.gen.d.ts +79 -0
  48. package/dist/gen/core/types.gen.d.ts.map +1 -0
  49. package/dist/gen/core/utils.gen.d.ts +20 -0
  50. package/dist/gen/core/utils.gen.d.ts.map +1 -0
  51. package/dist/gen/index.d.ts +3 -0
  52. package/dist/gen/index.d.ts.map +1 -0
  53. package/dist/gen/sdk.gen.d.ts +168 -0
  54. package/dist/gen/sdk.gen.d.ts.map +1 -0
  55. package/dist/gen/types.gen.d.ts +2501 -0
  56. package/dist/gen/types.gen.d.ts.map +1 -0
  57. package/dist/index.cjs +1648 -0
  58. package/dist/index.cjs.map +31 -0
  59. package/dist/index.d.ts +16 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +1651 -0
  62. package/dist/index.js.map +31 -0
  63. package/dist/multisender.d.ts +46 -0
  64. package/dist/multisender.d.ts.map +1 -0
  65. package/dist/openapi-runtime.d.ts +10 -0
  66. package/dist/openapi-runtime.d.ts.map +1 -0
  67. package/dist/services/catalogs.d.ts +15 -0
  68. package/dist/services/catalogs.d.ts.map +1 -0
  69. package/dist/services/distributions.d.ts +17 -0
  70. package/dist/services/distributions.d.ts.map +1 -0
  71. package/dist/services/lists.d.ts +36 -0
  72. package/dist/services/lists.d.ts.map +1 -0
  73. package/dist/services/project.d.ts +19 -0
  74. package/dist/services/project.d.ts.map +1 -0
  75. package/dist/services/response-utils.d.ts +9 -0
  76. package/dist/services/response-utils.d.ts.map +1 -0
  77. package/dist/services/types.d.ts +33 -0
  78. package/dist/services/types.d.ts.map +1 -0
  79. package/dist/types.d.ts +5 -0
  80. package/dist/types.d.ts.map +1 -0
  81. package/dist/utils/csv.d.ts +9 -0
  82. package/dist/utils/csv.d.ts.map +1 -0
  83. package/dist/utils/validation.d.ts +7 -0
  84. package/dist/utils/validation.d.ts.map +1 -0
  85. package/package.json +64 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,1648 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __toCommonJS = (from) => {
33
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
34
+ if (entry)
35
+ return entry;
36
+ entry = __defProp({}, "__esModule", { value: true });
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (var key of __getOwnPropNames(from))
39
+ if (!__hasOwnProp.call(entry, key))
40
+ __defProp(entry, key, {
41
+ get: __accessProp.bind(from, key),
42
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
43
+ });
44
+ }
45
+ __moduleCache.set(from, entry);
46
+ return entry;
47
+ };
48
+ var __moduleCache;
49
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
50
+ var __returnValue = (v) => v;
51
+ function __exportSetter(name, newValue) {
52
+ this[name] = __returnValue.bind(null, newValue);
53
+ }
54
+ var __export = (target, all) => {
55
+ for (var name in all)
56
+ __defProp(target, name, {
57
+ get: all[name],
58
+ enumerable: true,
59
+ configurable: true,
60
+ set: __exportSetter.bind(all, name)
61
+ });
62
+ };
63
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
64
+
65
+ // src/index.ts
66
+ var exports_src = {};
67
+ __export(exports_src, {
68
+ validateTokenAddress: () => validateTokenAddress,
69
+ validateRecipients: () => validateRecipients,
70
+ validatePositiveNumber: () => validatePositiveNumber,
71
+ validateEthereumAddress: () => validateEthereumAddress,
72
+ validateCsv: () => validateCsv,
73
+ validateChainId: () => validateChainId,
74
+ validateApiKey: () => validateApiKey,
75
+ toCsv: () => toCsv,
76
+ parseCsv: () => parseCsv,
77
+ ValidationError: () => ValidationError,
78
+ TimeoutError: () => TimeoutError,
79
+ ProjectService: () => ProjectService,
80
+ NetworkError: () => NetworkError,
81
+ MultisenderError: () => MultisenderError,
82
+ Multisender: () => Multisender,
83
+ ListsService: () => ListsService,
84
+ DistributionsService: () => DistributionsService,
85
+ CatalogsService: () => CatalogsService,
86
+ ApiError: () => ApiError
87
+ });
88
+ module.exports = __toCommonJS(exports_src);
89
+
90
+ // src/gen/core/bodySerializer.gen.ts
91
+ var jsonBodySerializer = {
92
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
93
+ };
94
+ // src/gen/core/params.gen.ts
95
+ var extraPrefixesMap = {
96
+ $body_: "body",
97
+ $headers_: "headers",
98
+ $path_: "path",
99
+ $query_: "query"
100
+ };
101
+ var extraPrefixes = Object.entries(extraPrefixesMap);
102
+ // src/gen/core/serverSentEvents.gen.ts
103
+ var createSseClient = ({
104
+ onRequest,
105
+ onSseError,
106
+ onSseEvent,
107
+ responseTransformer,
108
+ responseValidator,
109
+ sseDefaultRetryDelay,
110
+ sseMaxRetryAttempts,
111
+ sseMaxRetryDelay,
112
+ sseSleepFn,
113
+ url,
114
+ ...options
115
+ }) => {
116
+ let lastEventId;
117
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
118
+ const createStream = async function* () {
119
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
120
+ let attempt = 0;
121
+ const signal = options.signal ?? new AbortController().signal;
122
+ while (true) {
123
+ if (signal.aborted)
124
+ break;
125
+ attempt++;
126
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
127
+ if (lastEventId !== undefined) {
128
+ headers.set("Last-Event-ID", lastEventId);
129
+ }
130
+ try {
131
+ const requestInit = {
132
+ redirect: "follow",
133
+ ...options,
134
+ body: options.serializedBody,
135
+ headers,
136
+ signal
137
+ };
138
+ let request = new Request(url, requestInit);
139
+ if (onRequest) {
140
+ request = await onRequest(url, requestInit);
141
+ }
142
+ const _fetch = options.fetch ?? globalThis.fetch;
143
+ const response = await _fetch(request);
144
+ if (!response.ok)
145
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
146
+ if (!response.body)
147
+ throw new Error("No body in SSE response");
148
+ const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
149
+ let buffer = "";
150
+ const abortHandler = () => {
151
+ try {
152
+ reader.cancel();
153
+ } catch {}
154
+ };
155
+ signal.addEventListener("abort", abortHandler);
156
+ try {
157
+ while (true) {
158
+ const { done, value } = await reader.read();
159
+ if (done)
160
+ break;
161
+ buffer += value;
162
+ buffer = buffer.replace(/\r\n/g, `
163
+ `).replace(/\r/g, `
164
+ `);
165
+ const chunks = buffer.split(`
166
+
167
+ `);
168
+ buffer = chunks.pop() ?? "";
169
+ for (const chunk of chunks) {
170
+ const lines = chunk.split(`
171
+ `);
172
+ const dataLines = [];
173
+ let eventName;
174
+ for (const line of lines) {
175
+ if (line.startsWith("data:")) {
176
+ dataLines.push(line.replace(/^data:\s*/, ""));
177
+ } else if (line.startsWith("event:")) {
178
+ eventName = line.replace(/^event:\s*/, "");
179
+ } else if (line.startsWith("id:")) {
180
+ lastEventId = line.replace(/^id:\s*/, "");
181
+ } else if (line.startsWith("retry:")) {
182
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
183
+ if (!Number.isNaN(parsed)) {
184
+ retryDelay = parsed;
185
+ }
186
+ }
187
+ }
188
+ let data;
189
+ let parsedJson = false;
190
+ if (dataLines.length) {
191
+ const rawData = dataLines.join(`
192
+ `);
193
+ try {
194
+ data = JSON.parse(rawData);
195
+ parsedJson = true;
196
+ } catch {
197
+ data = rawData;
198
+ }
199
+ }
200
+ if (parsedJson) {
201
+ if (responseValidator) {
202
+ await responseValidator(data);
203
+ }
204
+ if (responseTransformer) {
205
+ data = await responseTransformer(data);
206
+ }
207
+ }
208
+ onSseEvent?.({
209
+ data,
210
+ event: eventName,
211
+ id: lastEventId,
212
+ retry: retryDelay
213
+ });
214
+ if (dataLines.length) {
215
+ yield data;
216
+ }
217
+ }
218
+ }
219
+ } finally {
220
+ signal.removeEventListener("abort", abortHandler);
221
+ reader.releaseLock();
222
+ }
223
+ break;
224
+ } catch (error) {
225
+ onSseError?.(error);
226
+ if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
227
+ break;
228
+ }
229
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
230
+ await sleep(backoff);
231
+ }
232
+ }
233
+ };
234
+ const stream = createStream();
235
+ return { stream };
236
+ };
237
+
238
+ // src/gen/core/pathSerializer.gen.ts
239
+ var separatorArrayExplode = (style) => {
240
+ switch (style) {
241
+ case "label":
242
+ return ".";
243
+ case "matrix":
244
+ return ";";
245
+ case "simple":
246
+ return ",";
247
+ default:
248
+ return "&";
249
+ }
250
+ };
251
+ var separatorArrayNoExplode = (style) => {
252
+ switch (style) {
253
+ case "form":
254
+ return ",";
255
+ case "pipeDelimited":
256
+ return "|";
257
+ case "spaceDelimited":
258
+ return "%20";
259
+ default:
260
+ return ",";
261
+ }
262
+ };
263
+ var separatorObjectExplode = (style) => {
264
+ switch (style) {
265
+ case "label":
266
+ return ".";
267
+ case "matrix":
268
+ return ";";
269
+ case "simple":
270
+ return ",";
271
+ default:
272
+ return "&";
273
+ }
274
+ };
275
+ var serializeArrayParam = ({
276
+ allowReserved,
277
+ explode,
278
+ name,
279
+ style,
280
+ value
281
+ }) => {
282
+ if (!explode) {
283
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
284
+ switch (style) {
285
+ case "label":
286
+ return `.${joinedValues2}`;
287
+ case "matrix":
288
+ return `;${name}=${joinedValues2}`;
289
+ case "simple":
290
+ return joinedValues2;
291
+ default:
292
+ return `${name}=${joinedValues2}`;
293
+ }
294
+ }
295
+ const separator = separatorArrayExplode(style);
296
+ const joinedValues = value.map((v) => {
297
+ if (style === "label" || style === "simple") {
298
+ return allowReserved ? v : encodeURIComponent(v);
299
+ }
300
+ return serializePrimitiveParam({
301
+ allowReserved,
302
+ name,
303
+ value: v
304
+ });
305
+ }).join(separator);
306
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
307
+ };
308
+ var serializePrimitiveParam = ({
309
+ allowReserved,
310
+ name,
311
+ value
312
+ }) => {
313
+ if (value === undefined || value === null) {
314
+ return "";
315
+ }
316
+ if (typeof value === "object") {
317
+ throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
318
+ }
319
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
320
+ };
321
+ var serializeObjectParam = ({
322
+ allowReserved,
323
+ explode,
324
+ name,
325
+ style,
326
+ value,
327
+ valueOnly
328
+ }) => {
329
+ if (value instanceof Date) {
330
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
331
+ }
332
+ if (style !== "deepObject" && !explode) {
333
+ let values = [];
334
+ Object.entries(value).forEach(([key, v]) => {
335
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
336
+ });
337
+ const joinedValues2 = values.join(",");
338
+ switch (style) {
339
+ case "form":
340
+ return `${name}=${joinedValues2}`;
341
+ case "label":
342
+ return `.${joinedValues2}`;
343
+ case "matrix":
344
+ return `;${name}=${joinedValues2}`;
345
+ default:
346
+ return joinedValues2;
347
+ }
348
+ }
349
+ const separator = separatorObjectExplode(style);
350
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
351
+ allowReserved,
352
+ name: style === "deepObject" ? `${name}[${key}]` : key,
353
+ value: v
354
+ })).join(separator);
355
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
356
+ };
357
+
358
+ // src/gen/core/utils.gen.ts
359
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
360
+ var defaultPathSerializer = ({ path, url: _url }) => {
361
+ let url = _url;
362
+ const matches = _url.match(PATH_PARAM_RE);
363
+ if (matches) {
364
+ for (const match of matches) {
365
+ let explode = false;
366
+ let name = match.substring(1, match.length - 1);
367
+ let style = "simple";
368
+ if (name.endsWith("*")) {
369
+ explode = true;
370
+ name = name.substring(0, name.length - 1);
371
+ }
372
+ if (name.startsWith(".")) {
373
+ name = name.substring(1);
374
+ style = "label";
375
+ } else if (name.startsWith(";")) {
376
+ name = name.substring(1);
377
+ style = "matrix";
378
+ }
379
+ const value = path[name];
380
+ if (value === undefined || value === null) {
381
+ continue;
382
+ }
383
+ if (Array.isArray(value)) {
384
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
385
+ continue;
386
+ }
387
+ if (typeof value === "object") {
388
+ url = url.replace(match, serializeObjectParam({
389
+ explode,
390
+ name,
391
+ style,
392
+ value,
393
+ valueOnly: true
394
+ }));
395
+ continue;
396
+ }
397
+ if (style === "matrix") {
398
+ url = url.replace(match, `;${serializePrimitiveParam({
399
+ name,
400
+ value
401
+ })}`);
402
+ continue;
403
+ }
404
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
405
+ url = url.replace(match, replaceValue);
406
+ }
407
+ }
408
+ return url;
409
+ };
410
+ var getUrl = ({
411
+ baseUrl,
412
+ path,
413
+ query,
414
+ querySerializer,
415
+ url: _url
416
+ }) => {
417
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
418
+ let url = (baseUrl ?? "") + pathUrl;
419
+ if (path) {
420
+ url = defaultPathSerializer({ path, url });
421
+ }
422
+ let search = query ? querySerializer(query) : "";
423
+ if (search.startsWith("?")) {
424
+ search = search.substring(1);
425
+ }
426
+ if (search) {
427
+ url += `?${search}`;
428
+ }
429
+ return url;
430
+ };
431
+ function getValidRequestBody(options) {
432
+ const hasBody = options.body !== undefined;
433
+ const isSerializedBody = hasBody && options.bodySerializer;
434
+ if (isSerializedBody) {
435
+ if ("serializedBody" in options) {
436
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
437
+ return hasSerializedBody ? options.serializedBody : null;
438
+ }
439
+ return options.body !== "" ? options.body : null;
440
+ }
441
+ if (hasBody) {
442
+ return options.body;
443
+ }
444
+ return;
445
+ }
446
+
447
+ // src/gen/core/auth.gen.ts
448
+ var getAuthToken = async (auth, callback) => {
449
+ const token = typeof callback === "function" ? await callback(auth) : callback;
450
+ if (!token) {
451
+ return;
452
+ }
453
+ if (auth.scheme === "bearer") {
454
+ return `Bearer ${token}`;
455
+ }
456
+ if (auth.scheme === "basic") {
457
+ return `Basic ${btoa(token)}`;
458
+ }
459
+ return token;
460
+ };
461
+
462
+ // src/gen/client/utils.gen.ts
463
+ var createQuerySerializer = ({
464
+ parameters = {},
465
+ ...args
466
+ } = {}) => {
467
+ const querySerializer = (queryParams) => {
468
+ const search = [];
469
+ if (queryParams && typeof queryParams === "object") {
470
+ for (const name in queryParams) {
471
+ const value = queryParams[name];
472
+ if (value === undefined || value === null) {
473
+ continue;
474
+ }
475
+ const options = parameters[name] || args;
476
+ if (Array.isArray(value)) {
477
+ const serializedArray = serializeArrayParam({
478
+ allowReserved: options.allowReserved,
479
+ explode: true,
480
+ name,
481
+ style: "form",
482
+ value,
483
+ ...options.array
484
+ });
485
+ if (serializedArray)
486
+ search.push(serializedArray);
487
+ } else if (typeof value === "object") {
488
+ const serializedObject = serializeObjectParam({
489
+ allowReserved: options.allowReserved,
490
+ explode: true,
491
+ name,
492
+ style: "deepObject",
493
+ value,
494
+ ...options.object
495
+ });
496
+ if (serializedObject)
497
+ search.push(serializedObject);
498
+ } else {
499
+ const serializedPrimitive = serializePrimitiveParam({
500
+ allowReserved: options.allowReserved,
501
+ name,
502
+ value
503
+ });
504
+ if (serializedPrimitive)
505
+ search.push(serializedPrimitive);
506
+ }
507
+ }
508
+ }
509
+ return search.join("&");
510
+ };
511
+ return querySerializer;
512
+ };
513
+ var getParseAs = (contentType) => {
514
+ if (!contentType) {
515
+ return "stream";
516
+ }
517
+ const cleanContent = contentType.split(";")[0]?.trim();
518
+ if (!cleanContent) {
519
+ return;
520
+ }
521
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
522
+ return "json";
523
+ }
524
+ if (cleanContent === "multipart/form-data") {
525
+ return "formData";
526
+ }
527
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
528
+ return "blob";
529
+ }
530
+ if (cleanContent.startsWith("text/")) {
531
+ return "text";
532
+ }
533
+ return;
534
+ };
535
+ var checkForExistence = (options, name) => {
536
+ if (!name) {
537
+ return false;
538
+ }
539
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
540
+ return true;
541
+ }
542
+ return false;
543
+ };
544
+ var setAuthParams = async ({
545
+ security,
546
+ ...options
547
+ }) => {
548
+ for (const auth of security) {
549
+ if (checkForExistence(options, auth.name)) {
550
+ continue;
551
+ }
552
+ const token = await getAuthToken(auth, options.auth);
553
+ if (!token) {
554
+ continue;
555
+ }
556
+ const name = auth.name ?? "Authorization";
557
+ switch (auth.in) {
558
+ case "query":
559
+ if (!options.query) {
560
+ options.query = {};
561
+ }
562
+ options.query[name] = token;
563
+ break;
564
+ case "cookie":
565
+ options.headers.append("Cookie", `${name}=${token}`);
566
+ break;
567
+ case "header":
568
+ default:
569
+ options.headers.set(name, token);
570
+ break;
571
+ }
572
+ }
573
+ };
574
+ var buildUrl = (options) => getUrl({
575
+ baseUrl: options.baseUrl,
576
+ path: options.path,
577
+ query: options.query,
578
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
579
+ url: options.url
580
+ });
581
+ var mergeConfigs = (a, b) => {
582
+ const config = { ...a, ...b };
583
+ if (config.baseUrl?.endsWith("/")) {
584
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
585
+ }
586
+ config.headers = mergeHeaders(a.headers, b.headers);
587
+ return config;
588
+ };
589
+ var headersEntries = (headers) => {
590
+ const entries = [];
591
+ headers.forEach((value, key) => {
592
+ entries.push([key, value]);
593
+ });
594
+ return entries;
595
+ };
596
+ var mergeHeaders = (...headers) => {
597
+ const mergedHeaders = new Headers;
598
+ for (const header of headers) {
599
+ if (!header) {
600
+ continue;
601
+ }
602
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
603
+ for (const [key, value] of iterator) {
604
+ if (value === null) {
605
+ mergedHeaders.delete(key);
606
+ } else if (Array.isArray(value)) {
607
+ for (const v of value) {
608
+ mergedHeaders.append(key, v);
609
+ }
610
+ } else if (value !== undefined) {
611
+ mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
612
+ }
613
+ }
614
+ }
615
+ return mergedHeaders;
616
+ };
617
+
618
+ class Interceptors {
619
+ fns = [];
620
+ clear() {
621
+ this.fns = [];
622
+ }
623
+ eject(id) {
624
+ const index = this.getInterceptorIndex(id);
625
+ if (this.fns[index]) {
626
+ this.fns[index] = null;
627
+ }
628
+ }
629
+ exists(id) {
630
+ const index = this.getInterceptorIndex(id);
631
+ return Boolean(this.fns[index]);
632
+ }
633
+ getInterceptorIndex(id) {
634
+ if (typeof id === "number") {
635
+ return this.fns[id] ? id : -1;
636
+ }
637
+ return this.fns.indexOf(id);
638
+ }
639
+ update(id, fn) {
640
+ const index = this.getInterceptorIndex(id);
641
+ if (this.fns[index]) {
642
+ this.fns[index] = fn;
643
+ return id;
644
+ }
645
+ return false;
646
+ }
647
+ use(fn) {
648
+ this.fns.push(fn);
649
+ return this.fns.length - 1;
650
+ }
651
+ }
652
+ var createInterceptors = () => ({
653
+ error: new Interceptors,
654
+ request: new Interceptors,
655
+ response: new Interceptors
656
+ });
657
+ var defaultQuerySerializer = createQuerySerializer({
658
+ allowReserved: false,
659
+ array: {
660
+ explode: true,
661
+ style: "form"
662
+ },
663
+ object: {
664
+ explode: true,
665
+ style: "deepObject"
666
+ }
667
+ });
668
+ var defaultHeaders = {
669
+ "Content-Type": "application/json"
670
+ };
671
+ var createConfig = (override = {}) => ({
672
+ ...jsonBodySerializer,
673
+ headers: defaultHeaders,
674
+ parseAs: "auto",
675
+ querySerializer: defaultQuerySerializer,
676
+ ...override
677
+ });
678
+
679
+ // src/gen/client/client.gen.ts
680
+ var createClient = (config = {}) => {
681
+ let _config = mergeConfigs(createConfig(), config);
682
+ const getConfig = () => ({ ..._config });
683
+ const setConfig = (config2) => {
684
+ _config = mergeConfigs(_config, config2);
685
+ return getConfig();
686
+ };
687
+ const interceptors = createInterceptors();
688
+ const beforeRequest = async (options) => {
689
+ const opts = {
690
+ ..._config,
691
+ ...options,
692
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
693
+ headers: mergeHeaders(_config.headers, options.headers),
694
+ serializedBody: undefined
695
+ };
696
+ if (opts.security) {
697
+ await setAuthParams({
698
+ ...opts,
699
+ security: opts.security
700
+ });
701
+ }
702
+ if (opts.requestValidator) {
703
+ await opts.requestValidator(opts);
704
+ }
705
+ if (opts.body !== undefined && opts.bodySerializer) {
706
+ opts.serializedBody = opts.bodySerializer(opts.body);
707
+ }
708
+ if (opts.body === undefined || opts.serializedBody === "") {
709
+ opts.headers.delete("Content-Type");
710
+ }
711
+ const url = buildUrl(opts);
712
+ return { opts, url };
713
+ };
714
+ const request = async (options) => {
715
+ const { opts, url } = await beforeRequest(options);
716
+ const requestInit = {
717
+ redirect: "follow",
718
+ ...opts,
719
+ body: getValidRequestBody(opts)
720
+ };
721
+ let request2 = new Request(url, requestInit);
722
+ for (const fn of interceptors.request.fns) {
723
+ if (fn) {
724
+ request2 = await fn(request2, opts);
725
+ }
726
+ }
727
+ const _fetch = opts.fetch;
728
+ let response;
729
+ try {
730
+ response = await _fetch(request2);
731
+ } catch (error2) {
732
+ let finalError2 = error2;
733
+ for (const fn of interceptors.error.fns) {
734
+ if (fn) {
735
+ finalError2 = await fn(error2, undefined, request2, opts);
736
+ }
737
+ }
738
+ finalError2 = finalError2 || {};
739
+ if (opts.throwOnError) {
740
+ throw finalError2;
741
+ }
742
+ return opts.responseStyle === "data" ? undefined : {
743
+ error: finalError2,
744
+ request: request2,
745
+ response: undefined
746
+ };
747
+ }
748
+ for (const fn of interceptors.response.fns) {
749
+ if (fn) {
750
+ response = await fn(response, request2, opts);
751
+ }
752
+ }
753
+ const result = {
754
+ request: request2,
755
+ response
756
+ };
757
+ if (response.ok) {
758
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
759
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
760
+ let emptyData;
761
+ switch (parseAs) {
762
+ case "arrayBuffer":
763
+ case "blob":
764
+ case "text":
765
+ emptyData = await response[parseAs]();
766
+ break;
767
+ case "formData":
768
+ emptyData = new FormData;
769
+ break;
770
+ case "stream":
771
+ emptyData = response.body;
772
+ break;
773
+ case "json":
774
+ default:
775
+ emptyData = {};
776
+ break;
777
+ }
778
+ return opts.responseStyle === "data" ? emptyData : {
779
+ data: emptyData,
780
+ ...result
781
+ };
782
+ }
783
+ let data;
784
+ switch (parseAs) {
785
+ case "arrayBuffer":
786
+ case "blob":
787
+ case "formData":
788
+ case "text":
789
+ data = await response[parseAs]();
790
+ break;
791
+ case "json": {
792
+ const text = await response.text();
793
+ data = text ? JSON.parse(text) : {};
794
+ break;
795
+ }
796
+ case "stream":
797
+ return opts.responseStyle === "data" ? response.body : {
798
+ data: response.body,
799
+ ...result
800
+ };
801
+ }
802
+ if (parseAs === "json") {
803
+ if (opts.responseValidator) {
804
+ await opts.responseValidator(data);
805
+ }
806
+ if (opts.responseTransformer) {
807
+ data = await opts.responseTransformer(data);
808
+ }
809
+ }
810
+ return opts.responseStyle === "data" ? data : {
811
+ data,
812
+ ...result
813
+ };
814
+ }
815
+ const textError = await response.text();
816
+ let jsonError;
817
+ try {
818
+ jsonError = JSON.parse(textError);
819
+ } catch {}
820
+ const error = jsonError ?? textError;
821
+ let finalError = error;
822
+ for (const fn of interceptors.error.fns) {
823
+ if (fn) {
824
+ finalError = await fn(error, response, request2, opts);
825
+ }
826
+ }
827
+ finalError = finalError || {};
828
+ if (opts.throwOnError) {
829
+ throw finalError;
830
+ }
831
+ return opts.responseStyle === "data" ? undefined : {
832
+ error: finalError,
833
+ ...result
834
+ };
835
+ };
836
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
837
+ const makeSseFn = (method) => async (options) => {
838
+ const { opts, url } = await beforeRequest(options);
839
+ return createSseClient({
840
+ ...opts,
841
+ body: opts.body,
842
+ headers: opts.headers,
843
+ method,
844
+ onRequest: async (url2, init) => {
845
+ let request2 = new Request(url2, init);
846
+ for (const fn of interceptors.request.fns) {
847
+ if (fn) {
848
+ request2 = await fn(request2, opts);
849
+ }
850
+ }
851
+ return request2;
852
+ },
853
+ serializedBody: getValidRequestBody(opts),
854
+ url
855
+ });
856
+ };
857
+ return {
858
+ buildUrl,
859
+ connect: makeMethodFn("CONNECT"),
860
+ delete: makeMethodFn("DELETE"),
861
+ get: makeMethodFn("GET"),
862
+ getConfig,
863
+ head: makeMethodFn("HEAD"),
864
+ interceptors,
865
+ options: makeMethodFn("OPTIONS"),
866
+ patch: makeMethodFn("PATCH"),
867
+ post: makeMethodFn("POST"),
868
+ put: makeMethodFn("PUT"),
869
+ request,
870
+ setConfig,
871
+ sse: {
872
+ connect: makeSseFn("CONNECT"),
873
+ delete: makeSseFn("DELETE"),
874
+ get: makeSseFn("GET"),
875
+ head: makeSseFn("HEAD"),
876
+ options: makeSseFn("OPTIONS"),
877
+ patch: makeSseFn("PATCH"),
878
+ post: makeSseFn("POST"),
879
+ put: makeSseFn("PUT"),
880
+ trace: makeSseFn("TRACE")
881
+ },
882
+ trace: makeMethodFn("TRACE")
883
+ };
884
+ };
885
+ // src/openapi-runtime.ts
886
+ var DEFAULT_BASE_URL = "https://api.multisender.app";
887
+ var DEFAULT_TIMEOUT = 30000;
888
+ var defaultRuntimeConfig = {
889
+ apiKey: "",
890
+ baseUrl: DEFAULT_BASE_URL,
891
+ timeout: DEFAULT_TIMEOUT,
892
+ headers: {}
893
+ };
894
+ var mergeHeaders2 = (headers) => ({
895
+ ...headers
896
+ });
897
+ var withTimeoutFetch = (timeoutMs) => {
898
+ const timeout = timeoutMs ?? DEFAULT_TIMEOUT;
899
+ return async (input, init) => {
900
+ if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {
901
+ const timeoutSignal = AbortSignal.timeout(timeout);
902
+ if (!init?.signal) {
903
+ return fetch(input, { ...init, signal: timeoutSignal });
904
+ }
905
+ const controller2 = new AbortController;
906
+ const abort = () => controller2.abort();
907
+ timeoutSignal.addEventListener("abort", abort, { once: true });
908
+ init.signal.addEventListener("abort", abort, { once: true });
909
+ const signal2 = controller2.signal;
910
+ return fetch(input, { ...init, signal: signal2 });
911
+ }
912
+ const controller = new AbortController;
913
+ const timer = setTimeout(() => controller.abort(), timeout);
914
+ init?.signal?.addEventListener("abort", () => controller.abort(), { once: true });
915
+ const signal = controller.signal;
916
+ try {
917
+ return await fetch(input, { ...init, signal });
918
+ } finally {
919
+ clearTimeout(timer);
920
+ }
921
+ };
922
+ };
923
+ var toClientConfig = (config) => ({
924
+ baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,
925
+ fetch: withTimeoutFetch(config.timeout),
926
+ headers: {
927
+ ...mergeHeaders2(config.headers),
928
+ ...config.apiKey ? { "X-API-Key": config.apiKey } : {}
929
+ }
930
+ });
931
+ var setRuntimeConfig = (config) => {
932
+ return toClientConfig({
933
+ ...defaultRuntimeConfig,
934
+ ...config,
935
+ headers: {
936
+ ...defaultRuntimeConfig.headers,
937
+ ...mergeHeaders2(config.headers)
938
+ }
939
+ });
940
+ };
941
+ var createClientConfig = (override = {}) => ({
942
+ ...toClientConfig(defaultRuntimeConfig),
943
+ ...override,
944
+ headers: {
945
+ ...toClientConfig(defaultRuntimeConfig).headers,
946
+ ...override.headers ?? {}
947
+ }
948
+ });
949
+
950
+ // src/core/errors.ts
951
+ class MultisenderError extends Error {
952
+ constructor(message) {
953
+ super(message);
954
+ this.name = "MultisenderError";
955
+ Object.setPrototypeOf(this, MultisenderError.prototype);
956
+ }
957
+ }
958
+
959
+ class ApiError extends MultisenderError {
960
+ status;
961
+ body;
962
+ constructor(status, body, message) {
963
+ super(message || `API request failed with status ${status}`);
964
+ this.status = status;
965
+ this.body = body;
966
+ this.name = "ApiError";
967
+ Object.setPrototypeOf(this, ApiError.prototype);
968
+ }
969
+ }
970
+
971
+ class NetworkError extends MultisenderError {
972
+ cause;
973
+ constructor(message, cause) {
974
+ super(message);
975
+ this.cause = cause;
976
+ this.name = "NetworkError";
977
+ Object.setPrototypeOf(this, NetworkError.prototype);
978
+ }
979
+ }
980
+
981
+ class ValidationError extends MultisenderError {
982
+ fields;
983
+ constructor(message, fields) {
984
+ super(message);
985
+ this.fields = fields;
986
+ this.name = "ValidationError";
987
+ Object.setPrototypeOf(this, ValidationError.prototype);
988
+ }
989
+ }
990
+
991
+ class TimeoutError extends MultisenderError {
992
+ constructor(message = "Request timeout") {
993
+ super(message);
994
+ this.name = "TimeoutError";
995
+ Object.setPrototypeOf(this, TimeoutError.prototype);
996
+ }
997
+ }
998
+
999
+ // src/core/generated-transport.ts
1000
+ var isGeneratedHttpError = (error) => typeof error === "object" && error !== null && (("status" in error) || ("body" in error));
1001
+ var isGeneratedWrappedResponse = (value) => typeof value === "object" && value !== null && ("data" in value);
1002
+ var mapGeneratedError = (error) => {
1003
+ if (error instanceof Error) {
1004
+ if (error.name === "AbortError" || error.name === "TimeoutError") {
1005
+ throw new TimeoutError("Request timeout");
1006
+ }
1007
+ throw new NetworkError(error.message, error);
1008
+ }
1009
+ if (isGeneratedHttpError(error)) {
1010
+ throw new ApiError(error.status ?? 500, error.body ?? error);
1011
+ }
1012
+ if (typeof error === "string") {
1013
+ throw new ApiError(500, { message: error }, error);
1014
+ }
1015
+ throw new ApiError(500, error, "Unexpected API error");
1016
+ };
1017
+ var executeGenerated = async (operation) => {
1018
+ try {
1019
+ const result = await operation;
1020
+ return isGeneratedWrappedResponse(result) ? result.data : result;
1021
+ } catch (error) {
1022
+ return mapGeneratedError(error);
1023
+ }
1024
+ };
1025
+
1026
+ // src/core/pagination.ts
1027
+ function buildPaginationQuery(params) {
1028
+ if (!params)
1029
+ return {};
1030
+ const query = {};
1031
+ if (params.page !== undefined) {
1032
+ query.page = params.page.toString();
1033
+ }
1034
+ if (params.limit !== undefined) {
1035
+ query.limit = params.limit.toString();
1036
+ }
1037
+ if (params.orderBy) {
1038
+ query.orderBy = params.orderBy;
1039
+ }
1040
+ if (params.orderDir) {
1041
+ query.orderDir = params.orderDir;
1042
+ }
1043
+ if (params.search) {
1044
+ query.search = params.search;
1045
+ }
1046
+ return query;
1047
+ }
1048
+
1049
+ // src/gen/client.gen.ts
1050
+ var client = createClient(createClientConfig(createConfig()));
1051
+
1052
+ // src/gen/sdk.gen.ts
1053
+ var getProjectInfo = (options) => (options.client ?? client).get({ url: "/api/v1/project", ...options });
1054
+ var getProjectMembers = (options) => (options.client ?? client).get({ url: "/api/v1/project/members", ...options });
1055
+ var getApiKeys = (options) => (options.client ?? client).get({ url: "/api/v1/project/api-keys", ...options });
1056
+ var createApiKey = (options) => (options.client ?? client).post({
1057
+ url: "/api/v1/project/api-keys",
1058
+ ...options,
1059
+ headers: {
1060
+ "Content-Type": "application/json",
1061
+ ...options.headers
1062
+ }
1063
+ });
1064
+ var deleteApiKey = (options) => (options.client ?? client).delete({ url: "/api/v1/project/api-keys/{apiKeyId}", ...options });
1065
+ var updateApiKey = (options) => (options.client ?? client).patch({
1066
+ url: "/api/v1/project/api-keys/{apiKeyId}",
1067
+ ...options,
1068
+ headers: {
1069
+ "Content-Type": "application/json",
1070
+ ...options.headers
1071
+ }
1072
+ });
1073
+ var findAll = (options) => (options.client ?? client).get({ url: "/api/v1/lists", ...options });
1074
+ var create = (options) => (options.client ?? client).post({
1075
+ url: "/api/v1/lists",
1076
+ ...options,
1077
+ headers: {
1078
+ "Content-Type": "application/json",
1079
+ ...options.headers
1080
+ }
1081
+ });
1082
+ var remove = (options) => (options.client ?? client).delete({ url: "/api/v1/lists/{listId}", ...options });
1083
+ var findOne = (options) => (options.client ?? client).get({ url: "/api/v1/lists/{listId}", ...options });
1084
+ var update = (options) => (options.client ?? client).patch({
1085
+ url: "/api/v1/lists/{listId}",
1086
+ ...options,
1087
+ headers: {
1088
+ "Content-Type": "application/json",
1089
+ ...options.headers
1090
+ }
1091
+ });
1092
+ var getRecipients = (options) => (options.client ?? client).get({ url: "/api/v1/lists/{listId}/recipients", ...options });
1093
+ var addRecipient = (options) => (options.client ?? client).post({
1094
+ url: "/api/v1/lists/{listId}/recipients",
1095
+ ...options,
1096
+ headers: {
1097
+ "Content-Type": "application/json",
1098
+ ...options.headers
1099
+ }
1100
+ });
1101
+ var addRecipientsBulk = (options) => (options.client ?? client).post({
1102
+ url: "/api/v1/lists/{listId}/recipients/bulk",
1103
+ ...options,
1104
+ headers: {
1105
+ "Content-Type": "application/json",
1106
+ ...options.headers
1107
+ }
1108
+ });
1109
+ var removeRecipient = (options) => (options.client ?? client).delete({ url: "/api/v1/lists/{listId}/recipients/{recipientId}", ...options });
1110
+ var importFromFile = (options) => (options.client ?? client).post({ url: "/api/v1/lists/{listId}/import", ...options });
1111
+ var createDistributionList = (options) => (options.client ?? client).post({
1112
+ url: "/api/v1/lists/distribution",
1113
+ ...options,
1114
+ headers: {
1115
+ "Content-Type": "application/json",
1116
+ ...options.headers
1117
+ }
1118
+ });
1119
+ var importCsvDistribution = (options) => (options.client ?? client).post({
1120
+ url: "/api/v1/lists/distribution/csv",
1121
+ ...options,
1122
+ headers: {
1123
+ "Content-Type": "application/json",
1124
+ ...options.headers
1125
+ }
1126
+ });
1127
+ var distribute = (options) => (options.client ?? client).post({
1128
+ url: "/api/v1/distribute",
1129
+ ...options,
1130
+ headers: {
1131
+ "Content-Type": "application/json",
1132
+ ...options.headers
1133
+ }
1134
+ });
1135
+ var findAll2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions", ...options });
1136
+ var findOne2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}", ...options });
1137
+ var getTransactions = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/transactions", ...options });
1138
+ var getStats = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/stats", ...options });
1139
+ var cancel = (options) => (options.client ?? client).post({ url: "/api/v1/distributions/{id}/cancel", ...options });
1140
+ var getChains = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains", ...options });
1141
+ var getChain = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains/{chainId}", ...options });
1142
+ var getTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens", ...options });
1143
+ var searchTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens/search", ...options });
1144
+ var getToken = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens/{chainId}/{address}", ...options });
1145
+ // src/services/response-utils.ts
1146
+ function unwrapData(result) {
1147
+ const raw = result;
1148
+ if (raw?.data != null)
1149
+ return raw.data;
1150
+ return result;
1151
+ }
1152
+ function unwrapDistribution(result) {
1153
+ const raw = result;
1154
+ if (raw?.data?.distribution != null)
1155
+ return raw.data.distribution;
1156
+ if (raw?.distribution != null)
1157
+ return raw.distribution;
1158
+ return result;
1159
+ }
1160
+ function normalizePaginatedResponse(result, page, limit) {
1161
+ const raw = result;
1162
+ if ("meta" in raw && raw.meta != null && Array.isArray(raw.data)) {
1163
+ return raw;
1164
+ }
1165
+ const inner = raw.data && typeof raw.data === "object" && "data" in raw.data ? raw.data : null;
1166
+ const items = inner && Array.isArray(inner.data) ? inner.data : [];
1167
+ const total = inner && typeof inner.total === "number" ? inner.total : items.length;
1168
+ return {
1169
+ data: items,
1170
+ meta: {
1171
+ page,
1172
+ limit,
1173
+ total,
1174
+ totalPages: Math.ceil(total / limit) || 1
1175
+ }
1176
+ };
1177
+ }
1178
+
1179
+ // src/services/distributions.ts
1180
+ class DistributionsService {
1181
+ headers;
1182
+ client;
1183
+ constructor(headers, client2) {
1184
+ this.headers = headers;
1185
+ this.client = client2;
1186
+ }
1187
+ async distribute(request) {
1188
+ const result = await executeGenerated(distribute({
1189
+ body: request,
1190
+ client: this.client,
1191
+ headers: this.headers,
1192
+ throwOnError: true
1193
+ }));
1194
+ return unwrapDistribution(result);
1195
+ }
1196
+ async list(params) {
1197
+ const query = buildPaginationQuery(params);
1198
+ const page = params?.page ?? 1;
1199
+ const limit = params?.limit ?? 20;
1200
+ const result = await executeGenerated(findAll2({
1201
+ client: this.client,
1202
+ headers: this.headers,
1203
+ query,
1204
+ throwOnError: true
1205
+ }));
1206
+ return normalizePaginatedResponse(result, page, limit);
1207
+ }
1208
+ async get(id) {
1209
+ const result = await executeGenerated(findOne2({
1210
+ client: this.client,
1211
+ headers: this.headers,
1212
+ path: { id },
1213
+ throwOnError: true
1214
+ }));
1215
+ return unwrapData(result);
1216
+ }
1217
+ async getTransactions(id, params) {
1218
+ const query = buildPaginationQuery(params);
1219
+ const page = params?.page ?? 1;
1220
+ const limit = params?.limit ?? 20;
1221
+ const result = await executeGenerated(getTransactions({
1222
+ client: this.client,
1223
+ headers: this.headers,
1224
+ path: { id },
1225
+ query,
1226
+ throwOnError: true
1227
+ }));
1228
+ return normalizePaginatedResponse(result, page, limit);
1229
+ }
1230
+ async getStats(id) {
1231
+ const result = await executeGenerated(getStats({
1232
+ client: this.client,
1233
+ headers: this.headers,
1234
+ path: { id },
1235
+ throwOnError: true
1236
+ }));
1237
+ return unwrapData(result);
1238
+ }
1239
+ async cancel(id) {
1240
+ const result = await executeGenerated(cancel({
1241
+ client: this.client,
1242
+ headers: this.headers,
1243
+ path: { id },
1244
+ throwOnError: true
1245
+ }));
1246
+ return unwrapData(result);
1247
+ }
1248
+ }
1249
+
1250
+ // src/services/lists.ts
1251
+ class ListsService {
1252
+ headers;
1253
+ client;
1254
+ constructor(headers, client2) {
1255
+ this.headers = headers;
1256
+ this.client = client2;
1257
+ }
1258
+ async list(params) {
1259
+ const query = buildPaginationQuery(params);
1260
+ const page = params?.page ?? 1;
1261
+ const limit = params?.limit ?? 20;
1262
+ const result = await executeGenerated(findAll({
1263
+ client: this.client,
1264
+ headers: this.headers,
1265
+ query,
1266
+ throwOnError: true
1267
+ }));
1268
+ return normalizePaginatedResponse(result, page, limit);
1269
+ }
1270
+ async create(request) {
1271
+ const result = await executeGenerated(create({
1272
+ body: request,
1273
+ client: this.client,
1274
+ headers: this.headers,
1275
+ throwOnError: true
1276
+ }));
1277
+ return unwrapData(result);
1278
+ }
1279
+ async get(listId) {
1280
+ const result = await executeGenerated(findOne({
1281
+ client: this.client,
1282
+ headers: this.headers,
1283
+ path: { listId },
1284
+ throwOnError: true
1285
+ }));
1286
+ return unwrapData(result);
1287
+ }
1288
+ async update(listId, request) {
1289
+ const result = await executeGenerated(update({
1290
+ body: request,
1291
+ client: this.client,
1292
+ headers: this.headers,
1293
+ path: { listId },
1294
+ throwOnError: true
1295
+ }));
1296
+ return unwrapData(result);
1297
+ }
1298
+ async delete(listId) {
1299
+ await executeGenerated(remove({
1300
+ client: this.client,
1301
+ headers: this.headers,
1302
+ path: { listId },
1303
+ throwOnError: true
1304
+ }));
1305
+ }
1306
+ async getRecipients(listId, params) {
1307
+ const query = buildPaginationQuery(params);
1308
+ const page = params?.page ?? 1;
1309
+ const limit = params?.limit ?? 20;
1310
+ const result = await executeGenerated(getRecipients({
1311
+ client: this.client,
1312
+ headers: this.headers,
1313
+ path: { listId },
1314
+ query,
1315
+ throwOnError: true
1316
+ }));
1317
+ return normalizePaginatedResponse(result, page, limit);
1318
+ }
1319
+ async addRecipient(listId, request) {
1320
+ const result = await executeGenerated(addRecipient({
1321
+ body: request,
1322
+ client: this.client,
1323
+ headers: this.headers,
1324
+ path: { listId },
1325
+ throwOnError: true
1326
+ }));
1327
+ return unwrapData(result);
1328
+ }
1329
+ async addRecipientsBulk(listId, request) {
1330
+ const result = await executeGenerated(addRecipientsBulk({
1331
+ body: request,
1332
+ client: this.client,
1333
+ headers: this.headers,
1334
+ path: { listId },
1335
+ throwOnError: true
1336
+ }));
1337
+ return {
1338
+ added: result.added ?? 0,
1339
+ skippedAddresses: result.skippedAddresses ?? [],
1340
+ errors: result.errors ?? []
1341
+ };
1342
+ }
1343
+ async removeRecipient(listId, recipientId) {
1344
+ await executeGenerated(removeRecipient({
1345
+ client: this.client,
1346
+ headers: this.headers,
1347
+ path: { listId, recipientId },
1348
+ throwOnError: true
1349
+ }));
1350
+ }
1351
+ async importFromCsv(listId, file) {
1352
+ if (!file) {
1353
+ throw new Error("importFromCsv: file is required");
1354
+ }
1355
+ const formData = new FormData;
1356
+ if (file instanceof Buffer) {
1357
+ formData.append("file", new Blob([new Uint8Array(file)]), "import.csv");
1358
+ } else {
1359
+ const f = file;
1360
+ formData.append("file", f, f.name);
1361
+ }
1362
+ const result = await executeGenerated(importFromFile({
1363
+ path: { listId },
1364
+ body: formData,
1365
+ bodySerializer: (b) => b,
1366
+ client: this.client,
1367
+ headers: this.headers,
1368
+ throwOnError: true
1369
+ }));
1370
+ return unwrapData(result);
1371
+ }
1372
+ async createDistributionList(request) {
1373
+ const result = await executeGenerated(createDistributionList({
1374
+ body: request,
1375
+ client: this.client,
1376
+ headers: this.headers,
1377
+ throwOnError: true
1378
+ }));
1379
+ const raw = unwrapData(result);
1380
+ if (raw?.list == null)
1381
+ throw new Error("API response missing list");
1382
+ return raw.list;
1383
+ }
1384
+ async importCsvDistribution(request) {
1385
+ const result = await executeGenerated(importCsvDistribution({
1386
+ body: request,
1387
+ client: this.client,
1388
+ headers: this.headers,
1389
+ throwOnError: true
1390
+ }));
1391
+ const raw = unwrapData(result);
1392
+ if (raw?.list == null)
1393
+ throw new Error("API response missing list");
1394
+ return raw.list;
1395
+ }
1396
+ }
1397
+
1398
+ // src/services/project.ts
1399
+ class ProjectService {
1400
+ headers;
1401
+ client;
1402
+ constructor(headers, client2) {
1403
+ this.headers = headers;
1404
+ this.client = client2;
1405
+ }
1406
+ async getInfo() {
1407
+ const result = await executeGenerated(getProjectInfo({
1408
+ client: this.client,
1409
+ headers: this.headers,
1410
+ throwOnError: true
1411
+ }));
1412
+ return unwrapData(result);
1413
+ }
1414
+ async getMembers() {
1415
+ const result = await executeGenerated(getProjectMembers({
1416
+ client: this.client,
1417
+ headers: this.headers,
1418
+ throwOnError: true
1419
+ }));
1420
+ const members = unwrapData(result);
1421
+ return Array.isArray(members) ? members : [members];
1422
+ }
1423
+ async listApiKeys() {
1424
+ const result = await executeGenerated(getApiKeys({
1425
+ client: this.client,
1426
+ headers: this.headers,
1427
+ throwOnError: true
1428
+ }));
1429
+ const data = unwrapData(result);
1430
+ return Array.isArray(data) ? data : result;
1431
+ }
1432
+ async createApiKey(request) {
1433
+ const result = await executeGenerated(createApiKey({
1434
+ body: request,
1435
+ client: this.client,
1436
+ headers: this.headers,
1437
+ throwOnError: true
1438
+ }));
1439
+ return unwrapData(result);
1440
+ }
1441
+ async updateApiKey(apiKeyId, request) {
1442
+ const result = await executeGenerated(updateApiKey({
1443
+ body: request,
1444
+ client: this.client,
1445
+ headers: this.headers,
1446
+ path: { apiKeyId },
1447
+ throwOnError: true
1448
+ }));
1449
+ return unwrapData(result);
1450
+ }
1451
+ async deleteApiKey(apiKeyId) {
1452
+ await executeGenerated(deleteApiKey({
1453
+ client: this.client,
1454
+ headers: this.headers,
1455
+ path: { apiKeyId },
1456
+ throwOnError: true
1457
+ }));
1458
+ }
1459
+ }
1460
+
1461
+ // src/utils/validation.ts
1462
+ function validateEthereumAddress(address) {
1463
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
1464
+ }
1465
+ function validatePositiveNumber(value) {
1466
+ const num = typeof value === "string" ? parseFloat(value) : value;
1467
+ return !isNaN(num) && num > 0;
1468
+ }
1469
+ function validateChainId(chainId) {
1470
+ if (!Number.isInteger(chainId) || chainId <= 0) {
1471
+ throw new ValidationError("Chain ID must be a positive integer");
1472
+ }
1473
+ }
1474
+ function validateRecipients(recipients) {
1475
+ if (!Array.isArray(recipients) || recipients.length === 0) {
1476
+ throw new ValidationError("Recipients must be a non-empty array");
1477
+ }
1478
+ for (let i = 0;i < recipients.length; i++) {
1479
+ const [address, amount] = recipients[i];
1480
+ if (!address || typeof address !== "string") {
1481
+ throw new ValidationError(`Invalid address at index ${i}`);
1482
+ }
1483
+ if (!validateEthereumAddress(address)) {
1484
+ throw new ValidationError(`Invalid Ethereum address at index ${i}: ${address}`);
1485
+ }
1486
+ if (!validatePositiveNumber(amount)) {
1487
+ throw new ValidationError(`Invalid amount at index ${i}: ${amount}`);
1488
+ }
1489
+ }
1490
+ }
1491
+ function validateTokenAddress(address) {
1492
+ if (!validateEthereumAddress(address)) {
1493
+ throw new ValidationError(`Invalid token address: ${address}`);
1494
+ }
1495
+ }
1496
+ function validateApiKey(apiKey) {
1497
+ if (!apiKey || apiKey.trim().length < 10) {
1498
+ throw new ValidationError("Invalid API key format");
1499
+ }
1500
+ }
1501
+
1502
+ // src/services/catalogs.ts
1503
+ class CatalogsService {
1504
+ headers;
1505
+ client;
1506
+ constructor(headers, client2) {
1507
+ this.headers = headers;
1508
+ this.client = client2;
1509
+ }
1510
+ async getChains() {
1511
+ return executeGenerated(getChains({
1512
+ client: this.client,
1513
+ headers: this.headers,
1514
+ throwOnError: true
1515
+ }));
1516
+ }
1517
+ async getChain(chainId) {
1518
+ const parsedChainId = Number(chainId);
1519
+ validateChainId(parsedChainId);
1520
+ return executeGenerated(getChain({
1521
+ client: this.client,
1522
+ headers: this.headers,
1523
+ path: { chainId: parsedChainId },
1524
+ throwOnError: true
1525
+ }));
1526
+ }
1527
+ async getTokens(chainId) {
1528
+ const parsedChainId = chainId !== undefined ? Number(chainId) : undefined;
1529
+ if (parsedChainId !== undefined)
1530
+ validateChainId(parsedChainId);
1531
+ return executeGenerated(getTokens({
1532
+ client: this.client,
1533
+ headers: this.headers,
1534
+ query: parsedChainId !== undefined ? { chainId: parsedChainId } : undefined,
1535
+ throwOnError: true
1536
+ }));
1537
+ }
1538
+ async getToken(chainId, address) {
1539
+ const parsedChainId = Number(chainId);
1540
+ validateChainId(parsedChainId);
1541
+ return executeGenerated(getToken({
1542
+ client: this.client,
1543
+ headers: this.headers,
1544
+ path: { address, chainId: parsedChainId },
1545
+ throwOnError: true
1546
+ }));
1547
+ }
1548
+ async searchTokens(symbol, chainId) {
1549
+ const parsedChainId = Number(chainId);
1550
+ validateChainId(parsedChainId);
1551
+ return executeGenerated(searchTokens({
1552
+ client: this.client,
1553
+ headers: this.headers,
1554
+ query: {
1555
+ chainId: parsedChainId,
1556
+ symbol
1557
+ },
1558
+ throwOnError: true
1559
+ }));
1560
+ }
1561
+ }
1562
+
1563
+ // src/multisender.ts
1564
+ class Multisender {
1565
+ distributions;
1566
+ lists;
1567
+ project;
1568
+ catalogs;
1569
+ client;
1570
+ authHeaders;
1571
+ constructor(config) {
1572
+ validateApiKey(config.apiKey);
1573
+ const resolvedConfig = {
1574
+ baseUrl: config.baseUrl || "https://api.multisender.app",
1575
+ apiKey: config.apiKey,
1576
+ timeout: config.timeout,
1577
+ headers: config.headers
1578
+ };
1579
+ this.client = createClient(setRuntimeConfig(resolvedConfig));
1580
+ this.authHeaders = { "X-API-Key": config.apiKey };
1581
+ this.client.interceptors.error.use((error, response) => {
1582
+ if (!response) {
1583
+ return error;
1584
+ }
1585
+ return {
1586
+ body: error,
1587
+ status: response.status
1588
+ };
1589
+ });
1590
+ this.distributions = new DistributionsService(this.authHeaders, this.client);
1591
+ this.lists = new ListsService(this.authHeaders, this.client);
1592
+ this.project = new ProjectService(this.authHeaders, this.client);
1593
+ this.catalogs = new CatalogsService(this.authHeaders, this.client);
1594
+ }
1595
+ static getVersion() {
1596
+ return "1.0.0";
1597
+ }
1598
+ }
1599
+ // src/utils/csv.ts
1600
+ function parseCsv(csvData, options = {}) {
1601
+ const { delimiter = ",", skipRows = 0, hasHeader = true } = options;
1602
+ const lines = csvData.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
1603
+ if (lines.length === 0) {
1604
+ throw new ValidationError("CSV data is empty");
1605
+ }
1606
+ let startIndex = skipRows;
1607
+ if (hasHeader) {
1608
+ startIndex += 1;
1609
+ }
1610
+ const recipients = [];
1611
+ for (let i = startIndex;i < lines.length; i++) {
1612
+ const line = lines[i];
1613
+ const parts = line.split(delimiter).map((p) => p.trim());
1614
+ if (parts.length < 2) {
1615
+ throw new ValidationError(`Invalid CSV format at line ${i + 1}: expected at least 2 columns`);
1616
+ }
1617
+ const [address, amount] = parts;
1618
+ if (!address || !amount) {
1619
+ throw new ValidationError(`Invalid CSV format at line ${i + 1}: address and amount are required`);
1620
+ }
1621
+ recipients.push([address, amount]);
1622
+ }
1623
+ if (recipients.length === 0) {
1624
+ throw new ValidationError("CSV must contain at least one recipient");
1625
+ }
1626
+ return recipients;
1627
+ }
1628
+ function toCsv(recipients, includeHeader = true) {
1629
+ const lines = [];
1630
+ if (includeHeader) {
1631
+ lines.push("address,amount");
1632
+ }
1633
+ for (const [address, amount] of recipients) {
1634
+ lines.push(`${address},${amount}`);
1635
+ }
1636
+ return lines.join(`
1637
+ `);
1638
+ }
1639
+ function validateCsv(csvData, options = {}) {
1640
+ try {
1641
+ parseCsv(csvData, options);
1642
+ return true;
1643
+ } catch {
1644
+ return false;
1645
+ }
1646
+ }
1647
+
1648
+ //# debugId=271FBC6D9C835BF364756E2164756E21