@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.
package/dist/cli/index.js CHANGED
@@ -2727,6 +2727,31 @@ var {
2727
2727
  } = import__.default;
2728
2728
 
2729
2729
  // src/gen/core/bodySerializer.gen.ts
2730
+ var serializeFormDataPair = (data, key, value) => {
2731
+ if (typeof value === "string" || value instanceof Blob) {
2732
+ data.append(key, value);
2733
+ } else if (value instanceof Date) {
2734
+ data.append(key, value.toISOString());
2735
+ } else {
2736
+ data.append(key, JSON.stringify(value));
2737
+ }
2738
+ };
2739
+ var formDataBodySerializer = {
2740
+ bodySerializer: (body) => {
2741
+ const data = new FormData;
2742
+ Object.entries(body).forEach(([key, value]) => {
2743
+ if (value === undefined || value === null) {
2744
+ return;
2745
+ }
2746
+ if (Array.isArray(value)) {
2747
+ value.forEach((v) => serializeFormDataPair(data, key, v));
2748
+ } else {
2749
+ serializeFormDataPair(data, key, value);
2750
+ }
2751
+ });
2752
+ return data;
2753
+ }
2754
+ };
2730
2755
  var jsonBodySerializer = {
2731
2756
  bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
2732
2757
  };
@@ -3746,7 +3771,15 @@ var addRecipientsBulk = (options) => (options.client ?? client).post({
3746
3771
  }
3747
3772
  });
3748
3773
  var removeRecipient = (options) => (options.client ?? client).delete({ url: "/api/v1/lists/{listId}/recipients/{recipientId}", ...options });
3749
- var importFromFile = (options) => (options.client ?? client).post({ url: "/api/v1/lists/{listId}/import", ...options });
3774
+ var importFromFile = (options) => (options.client ?? client).post({
3775
+ ...formDataBodySerializer,
3776
+ url: "/api/v1/lists/{listId}/import",
3777
+ ...options,
3778
+ headers: {
3779
+ "Content-Type": null,
3780
+ ...options.headers
3781
+ }
3782
+ });
3750
3783
  var createDistributionList = (options) => (options.client ?? client).post({
3751
3784
  url: "/api/v1/lists/distribution",
3752
3785
  ...options,
@@ -3755,6 +3788,14 @@ var createDistributionList = (options) => (options.client ?? client).post({
3755
3788
  ...options.headers
3756
3789
  }
3757
3790
  });
3791
+ var validateDistributionRecipients = (options) => (options.client ?? client).post({
3792
+ url: "/api/v1/lists/distribution/validate",
3793
+ ...options,
3794
+ headers: {
3795
+ "Content-Type": "application/json",
3796
+ ...options.headers
3797
+ }
3798
+ });
3758
3799
  var importCsvDistribution = (options) => (options.client ?? client).post({
3759
3800
  url: "/api/v1/lists/distribution/csv",
3760
3801
  ...options,
@@ -3772,10 +3813,51 @@ var distribute = (options) => (options.client ?? client).post({
3772
3813
  }
3773
3814
  });
3774
3815
  var findAll2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions", ...options });
3816
+ var create2 = (options) => (options.client ?? client).post({
3817
+ url: "/api/v1/distributions",
3818
+ ...options,
3819
+ headers: {
3820
+ "Content-Type": "application/json",
3821
+ ...options.headers
3822
+ }
3823
+ });
3775
3824
  var findOne2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}", ...options });
3825
+ var update2 = (options) => (options.client ?? client).patch({
3826
+ url: "/api/v1/distributions/{id}",
3827
+ ...options,
3828
+ headers: {
3829
+ "Content-Type": "application/json",
3830
+ ...options.headers
3831
+ }
3832
+ });
3833
+ var updateRecipients = (options) => (options.client ?? client).patch({
3834
+ url: "/api/v1/distributions/{id}/recipients",
3835
+ ...options,
3836
+ headers: {
3837
+ "Content-Type": "application/json",
3838
+ ...options.headers
3839
+ }
3840
+ });
3841
+ var prepareTransactions = (options) => (options.client ?? client).post({
3842
+ url: "/api/v1/distributions/{id}/prepare",
3843
+ ...options,
3844
+ headers: {
3845
+ "Content-Type": "application/json",
3846
+ ...options.headers
3847
+ }
3848
+ });
3776
3849
  var getTransactions = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/transactions", ...options });
3777
3850
  var getStats = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/stats", ...options });
3778
3851
  var cancel = (options) => (options.client ?? client).post({ url: "/api/v1/distributions/{id}/cancel", ...options });
3852
+ var getApproveCalldata = (options) => (options.client ?? client).post({
3853
+ url: "/api/v1/approve-calldata",
3854
+ ...options,
3855
+ headers: {
3856
+ "Content-Type": "application/json",
3857
+ ...options.headers
3858
+ }
3859
+ });
3860
+ var getApproveCalldataForDistribution = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/approve-calldata", ...options });
3779
3861
  var getChains = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains", ...options });
3780
3862
  var getChain = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains/{chainId}", ...options });
3781
3863
  var getTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens", ...options });
@@ -3796,21 +3878,36 @@ function unwrapDistribution(result) {
3796
3878
  return raw.distribution;
3797
3879
  return result;
3798
3880
  }
3881
+ function unwrapDistributeResult(result) {
3882
+ const raw = result;
3883
+ if (raw?.data != null)
3884
+ return raw.data;
3885
+ return result;
3886
+ }
3887
+ function unwrapDistributionList(result) {
3888
+ if (result?.list == null) {
3889
+ throw new Error("API response missing list");
3890
+ }
3891
+ return result.list;
3892
+ }
3799
3893
  function normalizePaginatedResponse(result, page, limit) {
3800
3894
  const raw = result;
3801
3895
  if ("meta" in raw && raw.meta != null && Array.isArray(raw.data)) {
3802
3896
  return raw;
3803
3897
  }
3804
- const inner = raw.data && typeof raw.data === "object" && "data" in raw.data ? raw.data : null;
3898
+ const inner = raw.data && typeof raw.data === "object" && !Array.isArray(raw.data) && "data" in raw.data ? raw.data : Array.isArray(raw.data) ? raw : null;
3805
3899
  const items = inner && Array.isArray(inner.data) ? inner.data : [];
3806
3900
  const total = inner && typeof inner.total === "number" ? inner.total : items.length;
3901
+ const resolvedPage = inner && typeof inner.page === "number" ? inner.page : page;
3902
+ const resolvedLimit = inner && typeof inner.limit === "number" ? inner.limit : limit;
3903
+ const resolvedTotalPages = inner && typeof inner.totalPages === "number" ? inner.totalPages : Math.ceil(total / resolvedLimit) || 1;
3807
3904
  return {
3808
3905
  data: items,
3809
3906
  meta: {
3810
- page,
3811
- limit,
3907
+ page: resolvedPage,
3908
+ limit: resolvedLimit,
3812
3909
  total,
3813
- totalPages: Math.ceil(total / limit) || 1
3910
+ totalPages: resolvedTotalPages
3814
3911
  }
3815
3912
  };
3816
3913
  }
@@ -3824,13 +3921,74 @@ class DistributionsService {
3824
3921
  this.client = client2;
3825
3922
  }
3826
3923
  async distribute(request) {
3924
+ const result = await this.distributeDetailed(request);
3925
+ return unwrapDistribution(result);
3926
+ }
3927
+ async distributeDetailed(request) {
3827
3928
  const result = await executeGenerated(distribute({
3828
3929
  body: request,
3829
3930
  client: this.client,
3830
3931
  headers: this.headers,
3831
3932
  throwOnError: true
3832
3933
  }));
3833
- return unwrapDistribution(result);
3934
+ return unwrapDistributeResult(result);
3935
+ }
3936
+ async createDraft(request) {
3937
+ const result = await executeGenerated(create2({
3938
+ body: request,
3939
+ client: this.client,
3940
+ headers: this.headers,
3941
+ throwOnError: true
3942
+ }));
3943
+ return unwrapData(result);
3944
+ }
3945
+ async updateDraft(id, request) {
3946
+ const result = await executeGenerated(update2({
3947
+ body: request,
3948
+ client: this.client,
3949
+ headers: this.headers,
3950
+ path: { id },
3951
+ throwOnError: true
3952
+ }));
3953
+ return unwrapData(result);
3954
+ }
3955
+ async replaceRecipients(id, request) {
3956
+ const result = await executeGenerated(updateRecipients({
3957
+ body: request,
3958
+ client: this.client,
3959
+ headers: this.headers,
3960
+ path: { id },
3961
+ throwOnError: true
3962
+ }));
3963
+ return unwrapData(result);
3964
+ }
3965
+ async prepare(id, request) {
3966
+ const result = await executeGenerated(prepareTransactions({
3967
+ body: request,
3968
+ client: this.client,
3969
+ headers: this.headers,
3970
+ path: { id },
3971
+ throwOnError: true
3972
+ }));
3973
+ return unwrapData(result);
3974
+ }
3975
+ async getApproveCalldata(request) {
3976
+ const result = await executeGenerated(getApproveCalldata({
3977
+ body: request,
3978
+ client: this.client,
3979
+ headers: this.headers,
3980
+ throwOnError: true
3981
+ }));
3982
+ return unwrapData(result);
3983
+ }
3984
+ async getApproveCalldataForDistribution(id) {
3985
+ const result = await executeGenerated(getApproveCalldataForDistribution({
3986
+ client: this.client,
3987
+ headers: this.headers,
3988
+ path: { id },
3989
+ throwOnError: true
3990
+ }));
3991
+ return unwrapData(result);
3834
3992
  }
3835
3993
  async list(params) {
3836
3994
  const query = buildPaginationQuery(params);
@@ -3842,7 +4000,7 @@ class DistributionsService {
3842
4000
  query,
3843
4001
  throwOnError: true
3844
4002
  }));
3845
- return normalizePaginatedResponse(result, page, limit);
4003
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3846
4004
  }
3847
4005
  async get(id) {
3848
4006
  const result = await executeGenerated(findOne2({
@@ -3864,7 +4022,7 @@ class DistributionsService {
3864
4022
  query,
3865
4023
  throwOnError: true
3866
4024
  }));
3867
- return normalizePaginatedResponse(result, page, limit);
4025
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3868
4026
  }
3869
4027
  async getStats(id) {
3870
4028
  const result = await executeGenerated(getStats({
@@ -3887,6 +4045,17 @@ class DistributionsService {
3887
4045
  }
3888
4046
 
3889
4047
  // src/services/lists.ts
4048
+ var createImportFormData = (file) => {
4049
+ const formData = new FormData;
4050
+ if (file instanceof Buffer) {
4051
+ formData.append("file", new Blob([new Uint8Array(file)]), "import.csv");
4052
+ return formData;
4053
+ }
4054
+ const browserFile = file;
4055
+ formData.append("file", browserFile, browserFile.name);
4056
+ return formData;
4057
+ };
4058
+
3890
4059
  class ListsService {
3891
4060
  headers;
3892
4061
  client;
@@ -3904,7 +4073,7 @@ class ListsService {
3904
4073
  query,
3905
4074
  throwOnError: true
3906
4075
  }));
3907
- return normalizePaginatedResponse(result, page, limit);
4076
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3908
4077
  }
3909
4078
  async create(request) {
3910
4079
  const result = await executeGenerated(create({
@@ -3935,12 +4104,16 @@ class ListsService {
3935
4104
  return unwrapData(result);
3936
4105
  }
3937
4106
  async delete(listId) {
3938
- await executeGenerated(remove({
4107
+ await this.deleteDetailed(listId);
4108
+ }
4109
+ async deleteDetailed(listId) {
4110
+ const result = await executeGenerated(remove({
3939
4111
  client: this.client,
3940
4112
  headers: this.headers,
3941
4113
  path: { listId },
3942
4114
  throwOnError: true
3943
4115
  }));
4116
+ return unwrapData(result);
3944
4117
  }
3945
4118
  async getRecipients(listId, params) {
3946
4119
  const query = buildPaginationQuery(params);
@@ -3953,7 +4126,7 @@ class ListsService {
3953
4126
  query,
3954
4127
  throwOnError: true
3955
4128
  }));
3956
- return normalizePaginatedResponse(result, page, limit);
4129
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3957
4130
  }
3958
4131
  async addRecipient(listId, request) {
3959
4132
  const result = await executeGenerated(addRecipient({
@@ -3973,31 +4146,25 @@ class ListsService {
3973
4146
  path: { listId },
3974
4147
  throwOnError: true
3975
4148
  }));
3976
- return {
3977
- added: result.added ?? 0,
3978
- skippedAddresses: result.skippedAddresses ?? [],
3979
- errors: result.errors ?? []
3980
- };
4149
+ return unwrapData(result);
3981
4150
  }
3982
4151
  async removeRecipient(listId, recipientId) {
3983
- await executeGenerated(removeRecipient({
4152
+ await this.removeRecipientDetailed(listId, recipientId);
4153
+ }
4154
+ async removeRecipientDetailed(listId, recipientId) {
4155
+ const result = await executeGenerated(removeRecipient({
3984
4156
  client: this.client,
3985
4157
  headers: this.headers,
3986
4158
  path: { listId, recipientId },
3987
4159
  throwOnError: true
3988
4160
  }));
4161
+ return unwrapData(result);
3989
4162
  }
3990
4163
  async importFromCsv(listId, file) {
3991
4164
  if (!file) {
3992
4165
  throw new Error("importFromCsv: file is required");
3993
4166
  }
3994
- const formData = new FormData;
3995
- if (file instanceof Buffer) {
3996
- formData.append("file", new Blob([new Uint8Array(file)]), "import.csv");
3997
- } else {
3998
- const f = file;
3999
- formData.append("file", f, f.name);
4000
- }
4167
+ const formData = createImportFormData(file);
4001
4168
  const result = await executeGenerated(importFromFile({
4002
4169
  path: { listId },
4003
4170
  body: formData,
@@ -4009,28 +4176,30 @@ class ListsService {
4009
4176
  return unwrapData(result);
4010
4177
  }
4011
4178
  async createDistributionList(request) {
4179
+ const result = await this.createDistributionListDetailed(request);
4180
+ return unwrapDistributionList(result);
4181
+ }
4182
+ async createDistributionListDetailed(request) {
4012
4183
  const result = await executeGenerated(createDistributionList({
4013
4184
  body: request,
4014
4185
  client: this.client,
4015
4186
  headers: this.headers,
4016
4187
  throwOnError: true
4017
4188
  }));
4018
- const raw = unwrapData(result);
4019
- if (raw?.list == null)
4020
- throw new Error("API response missing list");
4021
- return raw.list;
4189
+ return unwrapData(result);
4022
4190
  }
4023
4191
  async importCsvDistribution(request) {
4192
+ const result = await this.importCsvDistributionDetailed(request);
4193
+ return unwrapDistributionList(result);
4194
+ }
4195
+ async importCsvDistributionDetailed(request) {
4024
4196
  const result = await executeGenerated(importCsvDistribution({
4025
4197
  body: request,
4026
4198
  client: this.client,
4027
4199
  headers: this.headers,
4028
4200
  throwOnError: true
4029
4201
  }));
4030
- const raw = unwrapData(result);
4031
- if (raw?.list == null)
4032
- throw new Error("API response missing list");
4033
- return raw.list;
4202
+ return unwrapData(result);
4034
4203
  }
4035
4204
  }
4036
4205
 
@@ -4056,8 +4225,7 @@ class ProjectService {
4056
4225
  headers: this.headers,
4057
4226
  throwOnError: true
4058
4227
  }));
4059
- const members = unwrapData(result);
4060
- return Array.isArray(members) ? members : [members];
4228
+ return unwrapData(result);
4061
4229
  }
4062
4230
  async listApiKeys() {
4063
4231
  const result = await executeGenerated(getApiKeys({
@@ -4065,8 +4233,7 @@ class ProjectService {
4065
4233
  headers: this.headers,
4066
4234
  throwOnError: true
4067
4235
  }));
4068
- const data = unwrapData(result);
4069
- return Array.isArray(data) ? data : result;
4236
+ return unwrapData(result);
4070
4237
  }
4071
4238
  async createApiKey(request) {
4072
4239
  const result = await executeGenerated(createApiKey({
@@ -4088,12 +4255,16 @@ class ProjectService {
4088
4255
  return unwrapData(result);
4089
4256
  }
4090
4257
  async deleteApiKey(apiKeyId) {
4091
- await executeGenerated(deleteApiKey({
4258
+ await this.deleteApiKeyDetailed(apiKeyId);
4259
+ }
4260
+ async deleteApiKeyDetailed(apiKeyId) {
4261
+ const result = await executeGenerated(deleteApiKey({
4092
4262
  client: this.client,
4093
4263
  headers: this.headers,
4094
4264
  path: { apiKeyId },
4095
4265
  throwOnError: true
4096
4266
  }));
4267
+ return unwrapData(result);
4097
4268
  }
4098
4269
  }
4099
4270
 
@@ -4185,14 +4356,15 @@ class CatalogsService {
4185
4356
  }));
4186
4357
  }
4187
4358
  async searchTokens(symbol, chainId) {
4188
- const parsedChainId = Number(chainId);
4189
- validateChainId(parsedChainId);
4359
+ const parsedChainId = chainId !== undefined ? Number(chainId) : undefined;
4360
+ if (parsedChainId !== undefined)
4361
+ validateChainId(parsedChainId);
4190
4362
  return executeGenerated(searchTokens({
4191
4363
  client: this.client,
4192
4364
  headers: this.headers,
4193
4365
  query: {
4194
- chainId: parsedChainId,
4195
- symbol
4366
+ symbol,
4367
+ ...parsedChainId !== undefined ? { chainId: parsedChainId } : {}
4196
4368
  },
4197
4369
  throwOnError: true
4198
4370
  }));
@@ -4511,4 +4683,4 @@ function main() {
4511
4683
  }
4512
4684
  main();
4513
4685
 
4514
- //# debugId=DAB00AC65560094464756E2164756E21
4686
+ //# debugId=B82D29B523A3AE9964756E2164756E21