@multisender.app/multisender-sdk 0.0.1 → 0.0.2

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,
@@ -3765,10 +3798,51 @@ var distribute = (options) => (options.client ?? client).post({
3765
3798
  }
3766
3799
  });
3767
3800
  var findAll2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions", ...options });
3801
+ var create2 = (options) => (options.client ?? client).post({
3802
+ url: "/api/v1/distributions",
3803
+ ...options,
3804
+ headers: {
3805
+ "Content-Type": "application/json",
3806
+ ...options.headers
3807
+ }
3808
+ });
3768
3809
  var findOne2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}", ...options });
3810
+ var update2 = (options) => (options.client ?? client).patch({
3811
+ url: "/api/v1/distributions/{id}",
3812
+ ...options,
3813
+ headers: {
3814
+ "Content-Type": "application/json",
3815
+ ...options.headers
3816
+ }
3817
+ });
3818
+ var updateRecipients = (options) => (options.client ?? client).patch({
3819
+ url: "/api/v1/distributions/{id}/recipients",
3820
+ ...options,
3821
+ headers: {
3822
+ "Content-Type": "application/json",
3823
+ ...options.headers
3824
+ }
3825
+ });
3826
+ var prepareTransactions = (options) => (options.client ?? client).post({
3827
+ url: "/api/v1/distributions/{id}/prepare",
3828
+ ...options,
3829
+ headers: {
3830
+ "Content-Type": "application/json",
3831
+ ...options.headers
3832
+ }
3833
+ });
3769
3834
  var getTransactions = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/transactions", ...options });
3770
3835
  var getStats = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/stats", ...options });
3771
3836
  var cancel = (options) => (options.client ?? client).post({ url: "/api/v1/distributions/{id}/cancel", ...options });
3837
+ var getApproveCalldata = (options) => (options.client ?? client).post({
3838
+ url: "/api/v1/approve-calldata",
3839
+ ...options,
3840
+ headers: {
3841
+ "Content-Type": "application/json",
3842
+ ...options.headers
3843
+ }
3844
+ });
3845
+ var getApproveCalldataForDistribution = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/approve-calldata", ...options });
3772
3846
  var getChains = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains", ...options });
3773
3847
  var getChain = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains/{chainId}", ...options });
3774
3848
  var getTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens", ...options });
@@ -3789,21 +3863,36 @@ function unwrapDistribution(result) {
3789
3863
  return raw.distribution;
3790
3864
  return result;
3791
3865
  }
3866
+ function unwrapDistributeResult(result) {
3867
+ const raw = result;
3868
+ if (raw?.data != null)
3869
+ return raw.data;
3870
+ return result;
3871
+ }
3872
+ function unwrapDistributionList(result) {
3873
+ if (result?.list == null) {
3874
+ throw new Error("API response missing list");
3875
+ }
3876
+ return result.list;
3877
+ }
3792
3878
  function normalizePaginatedResponse(result, page, limit) {
3793
3879
  const raw = result;
3794
3880
  if ("meta" in raw && raw.meta != null && Array.isArray(raw.data)) {
3795
3881
  return raw;
3796
3882
  }
3797
- const inner = raw.data && typeof raw.data === "object" && "data" in raw.data ? raw.data : null;
3883
+ 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
3884
  const items = inner && Array.isArray(inner.data) ? inner.data : [];
3799
3885
  const total = inner && typeof inner.total === "number" ? inner.total : items.length;
3886
+ const resolvedPage = inner && typeof inner.page === "number" ? inner.page : page;
3887
+ const resolvedLimit = inner && typeof inner.limit === "number" ? inner.limit : limit;
3888
+ const resolvedTotalPages = inner && typeof inner.totalPages === "number" ? inner.totalPages : Math.ceil(total / resolvedLimit) || 1;
3800
3889
  return {
3801
3890
  data: items,
3802
3891
  meta: {
3803
- page,
3804
- limit,
3892
+ page: resolvedPage,
3893
+ limit: resolvedLimit,
3805
3894
  total,
3806
- totalPages: Math.ceil(total / limit) || 1
3895
+ totalPages: resolvedTotalPages
3807
3896
  }
3808
3897
  };
3809
3898
  }
@@ -3817,13 +3906,74 @@ class DistributionsService {
3817
3906
  this.client = client2;
3818
3907
  }
3819
3908
  async distribute(request) {
3909
+ const result = await this.distributeDetailed(request);
3910
+ return unwrapDistribution(result);
3911
+ }
3912
+ async distributeDetailed(request) {
3820
3913
  const result = await executeGenerated(distribute({
3821
3914
  body: request,
3822
3915
  client: this.client,
3823
3916
  headers: this.headers,
3824
3917
  throwOnError: true
3825
3918
  }));
3826
- return unwrapDistribution(result);
3919
+ return unwrapDistributeResult(result);
3920
+ }
3921
+ async createDraft(request) {
3922
+ const result = await executeGenerated(create2({
3923
+ body: request,
3924
+ client: this.client,
3925
+ headers: this.headers,
3926
+ throwOnError: true
3927
+ }));
3928
+ return unwrapData(result);
3929
+ }
3930
+ async updateDraft(id, request) {
3931
+ const result = await executeGenerated(update2({
3932
+ body: request,
3933
+ client: this.client,
3934
+ headers: this.headers,
3935
+ path: { id },
3936
+ throwOnError: true
3937
+ }));
3938
+ return unwrapData(result);
3939
+ }
3940
+ async replaceRecipients(id, request) {
3941
+ const result = await executeGenerated(updateRecipients({
3942
+ body: request,
3943
+ client: this.client,
3944
+ headers: this.headers,
3945
+ path: { id },
3946
+ throwOnError: true
3947
+ }));
3948
+ return unwrapData(result);
3949
+ }
3950
+ async prepare(id, request) {
3951
+ const result = await executeGenerated(prepareTransactions({
3952
+ body: request,
3953
+ client: this.client,
3954
+ headers: this.headers,
3955
+ path: { id },
3956
+ throwOnError: true
3957
+ }));
3958
+ return unwrapData(result);
3959
+ }
3960
+ async getApproveCalldata(request) {
3961
+ const result = await executeGenerated(getApproveCalldata({
3962
+ body: request,
3963
+ client: this.client,
3964
+ headers: this.headers,
3965
+ throwOnError: true
3966
+ }));
3967
+ return unwrapData(result);
3968
+ }
3969
+ async getApproveCalldataForDistribution(id) {
3970
+ const result = await executeGenerated(getApproveCalldataForDistribution({
3971
+ client: this.client,
3972
+ headers: this.headers,
3973
+ path: { id },
3974
+ throwOnError: true
3975
+ }));
3976
+ return unwrapData(result);
3827
3977
  }
3828
3978
  async list(params) {
3829
3979
  const query = buildPaginationQuery(params);
@@ -3835,7 +3985,7 @@ class DistributionsService {
3835
3985
  query,
3836
3986
  throwOnError: true
3837
3987
  }));
3838
- return normalizePaginatedResponse(result, page, limit);
3988
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3839
3989
  }
3840
3990
  async get(id) {
3841
3991
  const result = await executeGenerated(findOne2({
@@ -3857,7 +4007,7 @@ class DistributionsService {
3857
4007
  query,
3858
4008
  throwOnError: true
3859
4009
  }));
3860
- return normalizePaginatedResponse(result, page, limit);
4010
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3861
4011
  }
3862
4012
  async getStats(id) {
3863
4013
  const result = await executeGenerated(getStats({
@@ -3880,6 +4030,17 @@ class DistributionsService {
3880
4030
  }
3881
4031
 
3882
4032
  // src/services/lists.ts
4033
+ var createImportFormData = (file) => {
4034
+ const formData = new FormData;
4035
+ if (file instanceof Buffer) {
4036
+ formData.append("file", new Blob([new Uint8Array(file)]), "import.csv");
4037
+ return formData;
4038
+ }
4039
+ const browserFile = file;
4040
+ formData.append("file", browserFile, browserFile.name);
4041
+ return formData;
4042
+ };
4043
+
3883
4044
  class ListsService {
3884
4045
  headers;
3885
4046
  client;
@@ -3897,7 +4058,7 @@ class ListsService {
3897
4058
  query,
3898
4059
  throwOnError: true
3899
4060
  }));
3900
- return normalizePaginatedResponse(result, page, limit);
4061
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3901
4062
  }
3902
4063
  async create(request) {
3903
4064
  const result = await executeGenerated(create({
@@ -3928,12 +4089,16 @@ class ListsService {
3928
4089
  return unwrapData(result);
3929
4090
  }
3930
4091
  async delete(listId) {
3931
- await executeGenerated(remove({
4092
+ await this.deleteDetailed(listId);
4093
+ }
4094
+ async deleteDetailed(listId) {
4095
+ const result = await executeGenerated(remove({
3932
4096
  client: this.client,
3933
4097
  headers: this.headers,
3934
4098
  path: { listId },
3935
4099
  throwOnError: true
3936
4100
  }));
4101
+ return unwrapData(result);
3937
4102
  }
3938
4103
  async getRecipients(listId, params) {
3939
4104
  const query = buildPaginationQuery(params);
@@ -3946,7 +4111,7 @@ class ListsService {
3946
4111
  query,
3947
4112
  throwOnError: true
3948
4113
  }));
3949
- return normalizePaginatedResponse(result, page, limit);
4114
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3950
4115
  }
3951
4116
  async addRecipient(listId, request) {
3952
4117
  const result = await executeGenerated(addRecipient({
@@ -3966,31 +4131,25 @@ class ListsService {
3966
4131
  path: { listId },
3967
4132
  throwOnError: true
3968
4133
  }));
3969
- return {
3970
- added: result.added ?? 0,
3971
- skippedAddresses: result.skippedAddresses ?? [],
3972
- errors: result.errors ?? []
3973
- };
4134
+ return unwrapData(result);
3974
4135
  }
3975
4136
  async removeRecipient(listId, recipientId) {
3976
- await executeGenerated(removeRecipient({
4137
+ await this.removeRecipientDetailed(listId, recipientId);
4138
+ }
4139
+ async removeRecipientDetailed(listId, recipientId) {
4140
+ const result = await executeGenerated(removeRecipient({
3977
4141
  client: this.client,
3978
4142
  headers: this.headers,
3979
4143
  path: { listId, recipientId },
3980
4144
  throwOnError: true
3981
4145
  }));
4146
+ return unwrapData(result);
3982
4147
  }
3983
4148
  async importFromCsv(listId, file) {
3984
4149
  if (!file) {
3985
4150
  throw new Error("importFromCsv: file is required");
3986
4151
  }
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
- }
4152
+ const formData = createImportFormData(file);
3994
4153
  const result = await executeGenerated(importFromFile({
3995
4154
  path: { listId },
3996
4155
  body: formData,
@@ -4002,28 +4161,30 @@ class ListsService {
4002
4161
  return unwrapData(result);
4003
4162
  }
4004
4163
  async createDistributionList(request) {
4164
+ const result = await this.createDistributionListDetailed(request);
4165
+ return unwrapDistributionList(result);
4166
+ }
4167
+ async createDistributionListDetailed(request) {
4005
4168
  const result = await executeGenerated(createDistributionList({
4006
4169
  body: request,
4007
4170
  client: this.client,
4008
4171
  headers: this.headers,
4009
4172
  throwOnError: true
4010
4173
  }));
4011
- const raw = unwrapData(result);
4012
- if (raw?.list == null)
4013
- throw new Error("API response missing list");
4014
- return raw.list;
4174
+ return unwrapData(result);
4015
4175
  }
4016
4176
  async importCsvDistribution(request) {
4177
+ const result = await this.importCsvDistributionDetailed(request);
4178
+ return unwrapDistributionList(result);
4179
+ }
4180
+ async importCsvDistributionDetailed(request) {
4017
4181
  const result = await executeGenerated(importCsvDistribution({
4018
4182
  body: request,
4019
4183
  client: this.client,
4020
4184
  headers: this.headers,
4021
4185
  throwOnError: true
4022
4186
  }));
4023
- const raw = unwrapData(result);
4024
- if (raw?.list == null)
4025
- throw new Error("API response missing list");
4026
- return raw.list;
4187
+ return unwrapData(result);
4027
4188
  }
4028
4189
  }
4029
4190
 
@@ -4049,8 +4210,7 @@ class ProjectService {
4049
4210
  headers: this.headers,
4050
4211
  throwOnError: true
4051
4212
  }));
4052
- const members = unwrapData(result);
4053
- return Array.isArray(members) ? members : [members];
4213
+ return unwrapData(result);
4054
4214
  }
4055
4215
  async listApiKeys() {
4056
4216
  const result = await executeGenerated(getApiKeys({
@@ -4058,8 +4218,7 @@ class ProjectService {
4058
4218
  headers: this.headers,
4059
4219
  throwOnError: true
4060
4220
  }));
4061
- const data = unwrapData(result);
4062
- return Array.isArray(data) ? data : result;
4221
+ return unwrapData(result);
4063
4222
  }
4064
4223
  async createApiKey(request) {
4065
4224
  const result = await executeGenerated(createApiKey({
@@ -4081,12 +4240,16 @@ class ProjectService {
4081
4240
  return unwrapData(result);
4082
4241
  }
4083
4242
  async deleteApiKey(apiKeyId) {
4084
- await executeGenerated(deleteApiKey({
4243
+ await this.deleteApiKeyDetailed(apiKeyId);
4244
+ }
4245
+ async deleteApiKeyDetailed(apiKeyId) {
4246
+ const result = await executeGenerated(deleteApiKey({
4085
4247
  client: this.client,
4086
4248
  headers: this.headers,
4087
4249
  path: { apiKeyId },
4088
4250
  throwOnError: true
4089
4251
  }));
4252
+ return unwrapData(result);
4090
4253
  }
4091
4254
  }
4092
4255
 
@@ -4178,14 +4341,15 @@ class CatalogsService {
4178
4341
  }));
4179
4342
  }
4180
4343
  async searchTokens(symbol, chainId) {
4181
- const parsedChainId = Number(chainId);
4182
- validateChainId(parsedChainId);
4344
+ const parsedChainId = chainId !== undefined ? Number(chainId) : undefined;
4345
+ if (parsedChainId !== undefined)
4346
+ validateChainId(parsedChainId);
4183
4347
  return executeGenerated(searchTokens({
4184
4348
  client: this.client,
4185
4349
  headers: this.headers,
4186
4350
  query: {
4187
- chainId: parsedChainId,
4188
- symbol
4351
+ symbol,
4352
+ ...parsedChainId !== undefined ? { chainId: parsedChainId } : {}
4189
4353
  },
4190
4354
  throwOnError: true
4191
4355
  }));
@@ -4504,4 +4668,4 @@ function main() {
4504
4668
  }
4505
4669
  main();
4506
4670
 
4507
- //# debugId=FC84DDECDCB912FE64756E2164756E21
4671
+ //# debugId=AA9AF03658C402AE64756E2164756E21