@multisender.app/multisender-sdk 0.0.1 → 0.0.3

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.
@@ -2720,6 +2720,31 @@ var {
2720
2720
  } = import__.default;
2721
2721
 
2722
2722
  // src/gen/core/bodySerializer.gen.ts
2723
+ var serializeFormDataPair = (data, key, value) => {
2724
+ if (typeof value === "string" || value instanceof Blob) {
2725
+ data.append(key, value);
2726
+ } else if (value instanceof Date) {
2727
+ data.append(key, value.toISOString());
2728
+ } else {
2729
+ data.append(key, JSON.stringify(value));
2730
+ }
2731
+ };
2732
+ var formDataBodySerializer = {
2733
+ bodySerializer: (body) => {
2734
+ const data = new FormData;
2735
+ Object.entries(body).forEach(([key, value]) => {
2736
+ if (value === undefined || value === null) {
2737
+ return;
2738
+ }
2739
+ if (Array.isArray(value)) {
2740
+ value.forEach((v) => serializeFormDataPair(data, key, v));
2741
+ } else {
2742
+ serializeFormDataPair(data, key, value);
2743
+ }
2744
+ });
2745
+ return data;
2746
+ }
2747
+ };
2723
2748
  var jsonBodySerializer = {
2724
2749
  bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
2725
2750
  };
@@ -3739,7 +3764,15 @@ var addRecipientsBulk = (options) => (options.client ?? client).post({
3739
3764
  }
3740
3765
  });
3741
3766
  var removeRecipient = (options) => (options.client ?? client).delete({ url: "/api/v1/lists/{listId}/recipients/{recipientId}", ...options });
3742
- var importFromFile = (options) => (options.client ?? client).post({ url: "/api/v1/lists/{listId}/import", ...options });
3767
+ var importFromFile = (options) => (options.client ?? client).post({
3768
+ ...formDataBodySerializer,
3769
+ url: "/api/v1/lists/{listId}/import",
3770
+ ...options,
3771
+ headers: {
3772
+ "Content-Type": null,
3773
+ ...options.headers
3774
+ }
3775
+ });
3743
3776
  var createDistributionList = (options) => (options.client ?? client).post({
3744
3777
  url: "/api/v1/lists/distribution",
3745
3778
  ...options,
@@ -3748,6 +3781,14 @@ var createDistributionList = (options) => (options.client ?? client).post({
3748
3781
  ...options.headers
3749
3782
  }
3750
3783
  });
3784
+ var validateDistributionRecipients = (options) => (options.client ?? client).post({
3785
+ url: "/api/v1/lists/distribution/validate",
3786
+ ...options,
3787
+ headers: {
3788
+ "Content-Type": "application/json",
3789
+ ...options.headers
3790
+ }
3791
+ });
3751
3792
  var importCsvDistribution = (options) => (options.client ?? client).post({
3752
3793
  url: "/api/v1/lists/distribution/csv",
3753
3794
  ...options,
@@ -3765,10 +3806,51 @@ var distribute = (options) => (options.client ?? client).post({
3765
3806
  }
3766
3807
  });
3767
3808
  var findAll2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions", ...options });
3809
+ var create2 = (options) => (options.client ?? client).post({
3810
+ url: "/api/v1/distributions",
3811
+ ...options,
3812
+ headers: {
3813
+ "Content-Type": "application/json",
3814
+ ...options.headers
3815
+ }
3816
+ });
3768
3817
  var findOne2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}", ...options });
3818
+ var update2 = (options) => (options.client ?? client).patch({
3819
+ url: "/api/v1/distributions/{id}",
3820
+ ...options,
3821
+ headers: {
3822
+ "Content-Type": "application/json",
3823
+ ...options.headers
3824
+ }
3825
+ });
3826
+ var updateRecipients = (options) => (options.client ?? client).patch({
3827
+ url: "/api/v1/distributions/{id}/recipients",
3828
+ ...options,
3829
+ headers: {
3830
+ "Content-Type": "application/json",
3831
+ ...options.headers
3832
+ }
3833
+ });
3834
+ var prepareTransactions = (options) => (options.client ?? client).post({
3835
+ url: "/api/v1/distributions/{id}/prepare",
3836
+ ...options,
3837
+ headers: {
3838
+ "Content-Type": "application/json",
3839
+ ...options.headers
3840
+ }
3841
+ });
3769
3842
  var getTransactions = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/transactions", ...options });
3770
3843
  var getStats = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/stats", ...options });
3771
3844
  var cancel = (options) => (options.client ?? client).post({ url: "/api/v1/distributions/{id}/cancel", ...options });
3845
+ var getApproveCalldata = (options) => (options.client ?? client).post({
3846
+ url: "/api/v1/approve-calldata",
3847
+ ...options,
3848
+ headers: {
3849
+ "Content-Type": "application/json",
3850
+ ...options.headers
3851
+ }
3852
+ });
3853
+ var getApproveCalldataForDistribution = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/approve-calldata", ...options });
3772
3854
  var getChains = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains", ...options });
3773
3855
  var getChain = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains/{chainId}", ...options });
3774
3856
  var getTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens", ...options });
@@ -3789,21 +3871,36 @@ function unwrapDistribution(result) {
3789
3871
  return raw.distribution;
3790
3872
  return result;
3791
3873
  }
3874
+ function unwrapDistributeResult(result) {
3875
+ const raw = result;
3876
+ if (raw?.data != null)
3877
+ return raw.data;
3878
+ return result;
3879
+ }
3880
+ function unwrapDistributionList(result) {
3881
+ if (result?.list == null) {
3882
+ throw new Error("API response missing list");
3883
+ }
3884
+ return result.list;
3885
+ }
3792
3886
  function normalizePaginatedResponse(result, page, limit) {
3793
3887
  const raw = result;
3794
3888
  if ("meta" in raw && raw.meta != null && Array.isArray(raw.data)) {
3795
3889
  return raw;
3796
3890
  }
3797
- const inner = raw.data && typeof raw.data === "object" && "data" in raw.data ? raw.data : null;
3891
+ const inner = raw.data && typeof raw.data === "object" && !Array.isArray(raw.data) && "data" in raw.data ? raw.data : Array.isArray(raw.data) ? raw : null;
3798
3892
  const items = inner && Array.isArray(inner.data) ? inner.data : [];
3799
3893
  const total = inner && typeof inner.total === "number" ? inner.total : items.length;
3894
+ const resolvedPage = inner && typeof inner.page === "number" ? inner.page : page;
3895
+ const resolvedLimit = inner && typeof inner.limit === "number" ? inner.limit : limit;
3896
+ const resolvedTotalPages = inner && typeof inner.totalPages === "number" ? inner.totalPages : Math.ceil(total / resolvedLimit) || 1;
3800
3897
  return {
3801
3898
  data: items,
3802
3899
  meta: {
3803
- page,
3804
- limit,
3900
+ page: resolvedPage,
3901
+ limit: resolvedLimit,
3805
3902
  total,
3806
- totalPages: Math.ceil(total / limit) || 1
3903
+ totalPages: resolvedTotalPages
3807
3904
  }
3808
3905
  };
3809
3906
  }
@@ -3817,13 +3914,74 @@ class DistributionsService {
3817
3914
  this.client = client2;
3818
3915
  }
3819
3916
  async distribute(request) {
3917
+ const result = await this.distributeDetailed(request);
3918
+ return unwrapDistribution(result);
3919
+ }
3920
+ async distributeDetailed(request) {
3820
3921
  const result = await executeGenerated(distribute({
3821
3922
  body: request,
3822
3923
  client: this.client,
3823
3924
  headers: this.headers,
3824
3925
  throwOnError: true
3825
3926
  }));
3826
- return unwrapDistribution(result);
3927
+ return unwrapDistributeResult(result);
3928
+ }
3929
+ async createDraft(request) {
3930
+ const result = await executeGenerated(create2({
3931
+ body: request,
3932
+ client: this.client,
3933
+ headers: this.headers,
3934
+ throwOnError: true
3935
+ }));
3936
+ return unwrapData(result);
3937
+ }
3938
+ async updateDraft(id, request) {
3939
+ const result = await executeGenerated(update2({
3940
+ body: request,
3941
+ client: this.client,
3942
+ headers: this.headers,
3943
+ path: { id },
3944
+ throwOnError: true
3945
+ }));
3946
+ return unwrapData(result);
3947
+ }
3948
+ async replaceRecipients(id, request) {
3949
+ const result = await executeGenerated(updateRecipients({
3950
+ body: request,
3951
+ client: this.client,
3952
+ headers: this.headers,
3953
+ path: { id },
3954
+ throwOnError: true
3955
+ }));
3956
+ return unwrapData(result);
3957
+ }
3958
+ async prepare(id, request) {
3959
+ const result = await executeGenerated(prepareTransactions({
3960
+ body: request,
3961
+ client: this.client,
3962
+ headers: this.headers,
3963
+ path: { id },
3964
+ throwOnError: true
3965
+ }));
3966
+ return unwrapData(result);
3967
+ }
3968
+ async getApproveCalldata(request) {
3969
+ const result = await executeGenerated(getApproveCalldata({
3970
+ body: request,
3971
+ client: this.client,
3972
+ headers: this.headers,
3973
+ throwOnError: true
3974
+ }));
3975
+ return unwrapData(result);
3976
+ }
3977
+ async getApproveCalldataForDistribution(id) {
3978
+ const result = await executeGenerated(getApproveCalldataForDistribution({
3979
+ client: this.client,
3980
+ headers: this.headers,
3981
+ path: { id },
3982
+ throwOnError: true
3983
+ }));
3984
+ return unwrapData(result);
3827
3985
  }
3828
3986
  async list(params) {
3829
3987
  const query = buildPaginationQuery(params);
@@ -3835,7 +3993,7 @@ class DistributionsService {
3835
3993
  query,
3836
3994
  throwOnError: true
3837
3995
  }));
3838
- return normalizePaginatedResponse(result, page, limit);
3996
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3839
3997
  }
3840
3998
  async get(id) {
3841
3999
  const result = await executeGenerated(findOne2({
@@ -3857,7 +4015,7 @@ class DistributionsService {
3857
4015
  query,
3858
4016
  throwOnError: true
3859
4017
  }));
3860
- return normalizePaginatedResponse(result, page, limit);
4018
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3861
4019
  }
3862
4020
  async getStats(id) {
3863
4021
  const result = await executeGenerated(getStats({
@@ -3880,6 +4038,17 @@ class DistributionsService {
3880
4038
  }
3881
4039
 
3882
4040
  // src/services/lists.ts
4041
+ var createImportFormData = (file) => {
4042
+ const formData = new FormData;
4043
+ if (file instanceof Buffer) {
4044
+ formData.append("file", new Blob([new Uint8Array(file)]), "import.csv");
4045
+ return formData;
4046
+ }
4047
+ const browserFile = file;
4048
+ formData.append("file", browserFile, browserFile.name);
4049
+ return formData;
4050
+ };
4051
+
3883
4052
  class ListsService {
3884
4053
  headers;
3885
4054
  client;
@@ -3897,7 +4066,7 @@ class ListsService {
3897
4066
  query,
3898
4067
  throwOnError: true
3899
4068
  }));
3900
- return normalizePaginatedResponse(result, page, limit);
4069
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3901
4070
  }
3902
4071
  async create(request) {
3903
4072
  const result = await executeGenerated(create({
@@ -3928,12 +4097,16 @@ class ListsService {
3928
4097
  return unwrapData(result);
3929
4098
  }
3930
4099
  async delete(listId) {
3931
- await executeGenerated(remove({
4100
+ await this.deleteDetailed(listId);
4101
+ }
4102
+ async deleteDetailed(listId) {
4103
+ const result = await executeGenerated(remove({
3932
4104
  client: this.client,
3933
4105
  headers: this.headers,
3934
4106
  path: { listId },
3935
4107
  throwOnError: true
3936
4108
  }));
4109
+ return unwrapData(result);
3937
4110
  }
3938
4111
  async getRecipients(listId, params) {
3939
4112
  const query = buildPaginationQuery(params);
@@ -3946,7 +4119,7 @@ class ListsService {
3946
4119
  query,
3947
4120
  throwOnError: true
3948
4121
  }));
3949
- return normalizePaginatedResponse(result, page, limit);
4122
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3950
4123
  }
3951
4124
  async addRecipient(listId, request) {
3952
4125
  const result = await executeGenerated(addRecipient({
@@ -3966,31 +4139,25 @@ class ListsService {
3966
4139
  path: { listId },
3967
4140
  throwOnError: true
3968
4141
  }));
3969
- return {
3970
- added: result.added ?? 0,
3971
- skippedAddresses: result.skippedAddresses ?? [],
3972
- errors: result.errors ?? []
3973
- };
4142
+ return unwrapData(result);
3974
4143
  }
3975
4144
  async removeRecipient(listId, recipientId) {
3976
- await executeGenerated(removeRecipient({
4145
+ await this.removeRecipientDetailed(listId, recipientId);
4146
+ }
4147
+ async removeRecipientDetailed(listId, recipientId) {
4148
+ const result = await executeGenerated(removeRecipient({
3977
4149
  client: this.client,
3978
4150
  headers: this.headers,
3979
4151
  path: { listId, recipientId },
3980
4152
  throwOnError: true
3981
4153
  }));
4154
+ return unwrapData(result);
3982
4155
  }
3983
4156
  async importFromCsv(listId, file) {
3984
4157
  if (!file) {
3985
4158
  throw new Error("importFromCsv: file is required");
3986
4159
  }
3987
- const formData = new FormData;
3988
- if (file instanceof Buffer) {
3989
- formData.append("file", new Blob([new Uint8Array(file)]), "import.csv");
3990
- } else {
3991
- const f = file;
3992
- formData.append("file", f, f.name);
3993
- }
4160
+ const formData = createImportFormData(file);
3994
4161
  const result = await executeGenerated(importFromFile({
3995
4162
  path: { listId },
3996
4163
  body: formData,
@@ -4002,28 +4169,30 @@ class ListsService {
4002
4169
  return unwrapData(result);
4003
4170
  }
4004
4171
  async createDistributionList(request) {
4172
+ const result = await this.createDistributionListDetailed(request);
4173
+ return unwrapDistributionList(result);
4174
+ }
4175
+ async createDistributionListDetailed(request) {
4005
4176
  const result = await executeGenerated(createDistributionList({
4006
4177
  body: request,
4007
4178
  client: this.client,
4008
4179
  headers: this.headers,
4009
4180
  throwOnError: true
4010
4181
  }));
4011
- const raw = unwrapData(result);
4012
- if (raw?.list == null)
4013
- throw new Error("API response missing list");
4014
- return raw.list;
4182
+ return unwrapData(result);
4015
4183
  }
4016
4184
  async importCsvDistribution(request) {
4185
+ const result = await this.importCsvDistributionDetailed(request);
4186
+ return unwrapDistributionList(result);
4187
+ }
4188
+ async importCsvDistributionDetailed(request) {
4017
4189
  const result = await executeGenerated(importCsvDistribution({
4018
4190
  body: request,
4019
4191
  client: this.client,
4020
4192
  headers: this.headers,
4021
4193
  throwOnError: true
4022
4194
  }));
4023
- const raw = unwrapData(result);
4024
- if (raw?.list == null)
4025
- throw new Error("API response missing list");
4026
- return raw.list;
4195
+ return unwrapData(result);
4027
4196
  }
4028
4197
  }
4029
4198
 
@@ -4049,8 +4218,7 @@ class ProjectService {
4049
4218
  headers: this.headers,
4050
4219
  throwOnError: true
4051
4220
  }));
4052
- const members = unwrapData(result);
4053
- return Array.isArray(members) ? members : [members];
4221
+ return unwrapData(result);
4054
4222
  }
4055
4223
  async listApiKeys() {
4056
4224
  const result = await executeGenerated(getApiKeys({
@@ -4058,8 +4226,7 @@ class ProjectService {
4058
4226
  headers: this.headers,
4059
4227
  throwOnError: true
4060
4228
  }));
4061
- const data = unwrapData(result);
4062
- return Array.isArray(data) ? data : result;
4229
+ return unwrapData(result);
4063
4230
  }
4064
4231
  async createApiKey(request) {
4065
4232
  const result = await executeGenerated(createApiKey({
@@ -4081,12 +4248,16 @@ class ProjectService {
4081
4248
  return unwrapData(result);
4082
4249
  }
4083
4250
  async deleteApiKey(apiKeyId) {
4084
- await executeGenerated(deleteApiKey({
4251
+ await this.deleteApiKeyDetailed(apiKeyId);
4252
+ }
4253
+ async deleteApiKeyDetailed(apiKeyId) {
4254
+ const result = await executeGenerated(deleteApiKey({
4085
4255
  client: this.client,
4086
4256
  headers: this.headers,
4087
4257
  path: { apiKeyId },
4088
4258
  throwOnError: true
4089
4259
  }));
4260
+ return unwrapData(result);
4090
4261
  }
4091
4262
  }
4092
4263
 
@@ -4178,14 +4349,15 @@ class CatalogsService {
4178
4349
  }));
4179
4350
  }
4180
4351
  async searchTokens(symbol, chainId) {
4181
- const parsedChainId = Number(chainId);
4182
- validateChainId(parsedChainId);
4352
+ const parsedChainId = chainId !== undefined ? Number(chainId) : undefined;
4353
+ if (parsedChainId !== undefined)
4354
+ validateChainId(parsedChainId);
4183
4355
  return executeGenerated(searchTokens({
4184
4356
  client: this.client,
4185
4357
  headers: this.headers,
4186
4358
  query: {
4187
- chainId: parsedChainId,
4188
- symbol
4359
+ symbol,
4360
+ ...parsedChainId !== undefined ? { chainId: parsedChainId } : {}
4189
4361
  },
4190
4362
  throwOnError: true
4191
4363
  }));
@@ -4504,4 +4676,4 @@ function main() {
4504
4676
  }
4505
4677
  main();
4506
4678
 
4507
- //# debugId=FC84DDECDCB912FE64756E2164756E21
4679
+ //# debugId=D8DC8222CC625D0264756E2164756E21