@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.
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,
@@ -3772,10 +3805,51 @@ var distribute = (options) => (options.client ?? client).post({
3772
3805
  }
3773
3806
  });
3774
3807
  var findAll2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions", ...options });
3808
+ var create2 = (options) => (options.client ?? client).post({
3809
+ url: "/api/v1/distributions",
3810
+ ...options,
3811
+ headers: {
3812
+ "Content-Type": "application/json",
3813
+ ...options.headers
3814
+ }
3815
+ });
3775
3816
  var findOne2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}", ...options });
3817
+ var update2 = (options) => (options.client ?? client).patch({
3818
+ url: "/api/v1/distributions/{id}",
3819
+ ...options,
3820
+ headers: {
3821
+ "Content-Type": "application/json",
3822
+ ...options.headers
3823
+ }
3824
+ });
3825
+ var updateRecipients = (options) => (options.client ?? client).patch({
3826
+ url: "/api/v1/distributions/{id}/recipients",
3827
+ ...options,
3828
+ headers: {
3829
+ "Content-Type": "application/json",
3830
+ ...options.headers
3831
+ }
3832
+ });
3833
+ var prepareTransactions = (options) => (options.client ?? client).post({
3834
+ url: "/api/v1/distributions/{id}/prepare",
3835
+ ...options,
3836
+ headers: {
3837
+ "Content-Type": "application/json",
3838
+ ...options.headers
3839
+ }
3840
+ });
3776
3841
  var getTransactions = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/transactions", ...options });
3777
3842
  var getStats = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/stats", ...options });
3778
3843
  var cancel = (options) => (options.client ?? client).post({ url: "/api/v1/distributions/{id}/cancel", ...options });
3844
+ var getApproveCalldata = (options) => (options.client ?? client).post({
3845
+ url: "/api/v1/approve-calldata",
3846
+ ...options,
3847
+ headers: {
3848
+ "Content-Type": "application/json",
3849
+ ...options.headers
3850
+ }
3851
+ });
3852
+ var getApproveCalldataForDistribution = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/approve-calldata", ...options });
3779
3853
  var getChains = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains", ...options });
3780
3854
  var getChain = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains/{chainId}", ...options });
3781
3855
  var getTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens", ...options });
@@ -3796,21 +3870,36 @@ function unwrapDistribution(result) {
3796
3870
  return raw.distribution;
3797
3871
  return result;
3798
3872
  }
3873
+ function unwrapDistributeResult(result) {
3874
+ const raw = result;
3875
+ if (raw?.data != null)
3876
+ return raw.data;
3877
+ return result;
3878
+ }
3879
+ function unwrapDistributionList(result) {
3880
+ if (result?.list == null) {
3881
+ throw new Error("API response missing list");
3882
+ }
3883
+ return result.list;
3884
+ }
3799
3885
  function normalizePaginatedResponse(result, page, limit) {
3800
3886
  const raw = result;
3801
3887
  if ("meta" in raw && raw.meta != null && Array.isArray(raw.data)) {
3802
3888
  return raw;
3803
3889
  }
3804
- const inner = raw.data && typeof raw.data === "object" && "data" in raw.data ? raw.data : null;
3890
+ 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
3891
  const items = inner && Array.isArray(inner.data) ? inner.data : [];
3806
3892
  const total = inner && typeof inner.total === "number" ? inner.total : items.length;
3893
+ const resolvedPage = inner && typeof inner.page === "number" ? inner.page : page;
3894
+ const resolvedLimit = inner && typeof inner.limit === "number" ? inner.limit : limit;
3895
+ const resolvedTotalPages = inner && typeof inner.totalPages === "number" ? inner.totalPages : Math.ceil(total / resolvedLimit) || 1;
3807
3896
  return {
3808
3897
  data: items,
3809
3898
  meta: {
3810
- page,
3811
- limit,
3899
+ page: resolvedPage,
3900
+ limit: resolvedLimit,
3812
3901
  total,
3813
- totalPages: Math.ceil(total / limit) || 1
3902
+ totalPages: resolvedTotalPages
3814
3903
  }
3815
3904
  };
3816
3905
  }
@@ -3824,13 +3913,74 @@ class DistributionsService {
3824
3913
  this.client = client2;
3825
3914
  }
3826
3915
  async distribute(request) {
3916
+ const result = await this.distributeDetailed(request);
3917
+ return unwrapDistribution(result);
3918
+ }
3919
+ async distributeDetailed(request) {
3827
3920
  const result = await executeGenerated(distribute({
3828
3921
  body: request,
3829
3922
  client: this.client,
3830
3923
  headers: this.headers,
3831
3924
  throwOnError: true
3832
3925
  }));
3833
- return unwrapDistribution(result);
3926
+ return unwrapDistributeResult(result);
3927
+ }
3928
+ async createDraft(request) {
3929
+ const result = await executeGenerated(create2({
3930
+ body: request,
3931
+ client: this.client,
3932
+ headers: this.headers,
3933
+ throwOnError: true
3934
+ }));
3935
+ return unwrapData(result);
3936
+ }
3937
+ async updateDraft(id, request) {
3938
+ const result = await executeGenerated(update2({
3939
+ body: request,
3940
+ client: this.client,
3941
+ headers: this.headers,
3942
+ path: { id },
3943
+ throwOnError: true
3944
+ }));
3945
+ return unwrapData(result);
3946
+ }
3947
+ async replaceRecipients(id, request) {
3948
+ const result = await executeGenerated(updateRecipients({
3949
+ body: request,
3950
+ client: this.client,
3951
+ headers: this.headers,
3952
+ path: { id },
3953
+ throwOnError: true
3954
+ }));
3955
+ return unwrapData(result);
3956
+ }
3957
+ async prepare(id, request) {
3958
+ const result = await executeGenerated(prepareTransactions({
3959
+ body: request,
3960
+ client: this.client,
3961
+ headers: this.headers,
3962
+ path: { id },
3963
+ throwOnError: true
3964
+ }));
3965
+ return unwrapData(result);
3966
+ }
3967
+ async getApproveCalldata(request) {
3968
+ const result = await executeGenerated(getApproveCalldata({
3969
+ body: request,
3970
+ client: this.client,
3971
+ headers: this.headers,
3972
+ throwOnError: true
3973
+ }));
3974
+ return unwrapData(result);
3975
+ }
3976
+ async getApproveCalldataForDistribution(id) {
3977
+ const result = await executeGenerated(getApproveCalldataForDistribution({
3978
+ client: this.client,
3979
+ headers: this.headers,
3980
+ path: { id },
3981
+ throwOnError: true
3982
+ }));
3983
+ return unwrapData(result);
3834
3984
  }
3835
3985
  async list(params) {
3836
3986
  const query = buildPaginationQuery(params);
@@ -3842,7 +3992,7 @@ class DistributionsService {
3842
3992
  query,
3843
3993
  throwOnError: true
3844
3994
  }));
3845
- return normalizePaginatedResponse(result, page, limit);
3995
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3846
3996
  }
3847
3997
  async get(id) {
3848
3998
  const result = await executeGenerated(findOne2({
@@ -3864,7 +4014,7 @@ class DistributionsService {
3864
4014
  query,
3865
4015
  throwOnError: true
3866
4016
  }));
3867
- return normalizePaginatedResponse(result, page, limit);
4017
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3868
4018
  }
3869
4019
  async getStats(id) {
3870
4020
  const result = await executeGenerated(getStats({
@@ -3887,6 +4037,17 @@ class DistributionsService {
3887
4037
  }
3888
4038
 
3889
4039
  // src/services/lists.ts
4040
+ var createImportFormData = (file) => {
4041
+ const formData = new FormData;
4042
+ if (file instanceof Buffer) {
4043
+ formData.append("file", new Blob([new Uint8Array(file)]), "import.csv");
4044
+ return formData;
4045
+ }
4046
+ const browserFile = file;
4047
+ formData.append("file", browserFile, browserFile.name);
4048
+ return formData;
4049
+ };
4050
+
3890
4051
  class ListsService {
3891
4052
  headers;
3892
4053
  client;
@@ -3904,7 +4065,7 @@ class ListsService {
3904
4065
  query,
3905
4066
  throwOnError: true
3906
4067
  }));
3907
- return normalizePaginatedResponse(result, page, limit);
4068
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3908
4069
  }
3909
4070
  async create(request) {
3910
4071
  const result = await executeGenerated(create({
@@ -3935,12 +4096,16 @@ class ListsService {
3935
4096
  return unwrapData(result);
3936
4097
  }
3937
4098
  async delete(listId) {
3938
- await executeGenerated(remove({
4099
+ await this.deleteDetailed(listId);
4100
+ }
4101
+ async deleteDetailed(listId) {
4102
+ const result = await executeGenerated(remove({
3939
4103
  client: this.client,
3940
4104
  headers: this.headers,
3941
4105
  path: { listId },
3942
4106
  throwOnError: true
3943
4107
  }));
4108
+ return unwrapData(result);
3944
4109
  }
3945
4110
  async getRecipients(listId, params) {
3946
4111
  const query = buildPaginationQuery(params);
@@ -3953,7 +4118,7 @@ class ListsService {
3953
4118
  query,
3954
4119
  throwOnError: true
3955
4120
  }));
3956
- return normalizePaginatedResponse(result, page, limit);
4121
+ return normalizePaginatedResponse(unwrapData(result), page, limit);
3957
4122
  }
3958
4123
  async addRecipient(listId, request) {
3959
4124
  const result = await executeGenerated(addRecipient({
@@ -3973,31 +4138,25 @@ class ListsService {
3973
4138
  path: { listId },
3974
4139
  throwOnError: true
3975
4140
  }));
3976
- return {
3977
- added: result.added ?? 0,
3978
- skippedAddresses: result.skippedAddresses ?? [],
3979
- errors: result.errors ?? []
3980
- };
4141
+ return unwrapData(result);
3981
4142
  }
3982
4143
  async removeRecipient(listId, recipientId) {
3983
- await executeGenerated(removeRecipient({
4144
+ await this.removeRecipientDetailed(listId, recipientId);
4145
+ }
4146
+ async removeRecipientDetailed(listId, recipientId) {
4147
+ const result = await executeGenerated(removeRecipient({
3984
4148
  client: this.client,
3985
4149
  headers: this.headers,
3986
4150
  path: { listId, recipientId },
3987
4151
  throwOnError: true
3988
4152
  }));
4153
+ return unwrapData(result);
3989
4154
  }
3990
4155
  async importFromCsv(listId, file) {
3991
4156
  if (!file) {
3992
4157
  throw new Error("importFromCsv: file is required");
3993
4158
  }
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
- }
4159
+ const formData = createImportFormData(file);
4001
4160
  const result = await executeGenerated(importFromFile({
4002
4161
  path: { listId },
4003
4162
  body: formData,
@@ -4009,28 +4168,30 @@ class ListsService {
4009
4168
  return unwrapData(result);
4010
4169
  }
4011
4170
  async createDistributionList(request) {
4171
+ const result = await this.createDistributionListDetailed(request);
4172
+ return unwrapDistributionList(result);
4173
+ }
4174
+ async createDistributionListDetailed(request) {
4012
4175
  const result = await executeGenerated(createDistributionList({
4013
4176
  body: request,
4014
4177
  client: this.client,
4015
4178
  headers: this.headers,
4016
4179
  throwOnError: true
4017
4180
  }));
4018
- const raw = unwrapData(result);
4019
- if (raw?.list == null)
4020
- throw new Error("API response missing list");
4021
- return raw.list;
4181
+ return unwrapData(result);
4022
4182
  }
4023
4183
  async importCsvDistribution(request) {
4184
+ const result = await this.importCsvDistributionDetailed(request);
4185
+ return unwrapDistributionList(result);
4186
+ }
4187
+ async importCsvDistributionDetailed(request) {
4024
4188
  const result = await executeGenerated(importCsvDistribution({
4025
4189
  body: request,
4026
4190
  client: this.client,
4027
4191
  headers: this.headers,
4028
4192
  throwOnError: true
4029
4193
  }));
4030
- const raw = unwrapData(result);
4031
- if (raw?.list == null)
4032
- throw new Error("API response missing list");
4033
- return raw.list;
4194
+ return unwrapData(result);
4034
4195
  }
4035
4196
  }
4036
4197
 
@@ -4056,8 +4217,7 @@ class ProjectService {
4056
4217
  headers: this.headers,
4057
4218
  throwOnError: true
4058
4219
  }));
4059
- const members = unwrapData(result);
4060
- return Array.isArray(members) ? members : [members];
4220
+ return unwrapData(result);
4061
4221
  }
4062
4222
  async listApiKeys() {
4063
4223
  const result = await executeGenerated(getApiKeys({
@@ -4065,8 +4225,7 @@ class ProjectService {
4065
4225
  headers: this.headers,
4066
4226
  throwOnError: true
4067
4227
  }));
4068
- const data = unwrapData(result);
4069
- return Array.isArray(data) ? data : result;
4228
+ return unwrapData(result);
4070
4229
  }
4071
4230
  async createApiKey(request) {
4072
4231
  const result = await executeGenerated(createApiKey({
@@ -4088,12 +4247,16 @@ class ProjectService {
4088
4247
  return unwrapData(result);
4089
4248
  }
4090
4249
  async deleteApiKey(apiKeyId) {
4091
- await executeGenerated(deleteApiKey({
4250
+ await this.deleteApiKeyDetailed(apiKeyId);
4251
+ }
4252
+ async deleteApiKeyDetailed(apiKeyId) {
4253
+ const result = await executeGenerated(deleteApiKey({
4092
4254
  client: this.client,
4093
4255
  headers: this.headers,
4094
4256
  path: { apiKeyId },
4095
4257
  throwOnError: true
4096
4258
  }));
4259
+ return unwrapData(result);
4097
4260
  }
4098
4261
  }
4099
4262
 
@@ -4185,14 +4348,15 @@ class CatalogsService {
4185
4348
  }));
4186
4349
  }
4187
4350
  async searchTokens(symbol, chainId) {
4188
- const parsedChainId = Number(chainId);
4189
- validateChainId(parsedChainId);
4351
+ const parsedChainId = chainId !== undefined ? Number(chainId) : undefined;
4352
+ if (parsedChainId !== undefined)
4353
+ validateChainId(parsedChainId);
4190
4354
  return executeGenerated(searchTokens({
4191
4355
  client: this.client,
4192
4356
  headers: this.headers,
4193
4357
  query: {
4194
- chainId: parsedChainId,
4195
- symbol
4358
+ symbol,
4359
+ ...parsedChainId !== undefined ? { chainId: parsedChainId } : {}
4196
4360
  },
4197
4361
  throwOnError: true
4198
4362
  }));
@@ -4511,4 +4675,4 @@ function main() {
4511
4675
  }
4512
4676
  main();
4513
4677
 
4514
- //# debugId=DAB00AC65560094464756E2164756E21
4678
+ //# debugId=BA58823A1682002164756E2164756E21