@zoralabs/coins-sdk 0.5.1 → 0.6.0

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/index.js CHANGED
@@ -179,6 +179,18 @@ var getCoinHolders = (options) => {
179
179
  ...options
180
180
  });
181
181
  };
182
+ var getCoinPriceHistory = (options) => {
183
+ return (options.client ?? client).get({
184
+ security: [
185
+ {
186
+ name: "api-key",
187
+ type: "apiKey"
188
+ }
189
+ ],
190
+ url: "/coinPriceHistory",
191
+ ...options
192
+ });
193
+ };
182
194
  var getCoinSwaps = (options) => {
183
195
  return (options.client ?? client).get({
184
196
  security: [
@@ -243,6 +255,18 @@ var getCreatorCoinPoolConfig = (options) => {
243
255
  ...options
244
256
  });
245
257
  };
258
+ var getCreatorLivestreamComments = (options) => {
259
+ return (options.client ?? client).get({
260
+ security: [
261
+ {
262
+ name: "api-key",
263
+ type: "apiKey"
264
+ }
265
+ ],
266
+ url: "/creatorLivestreamComments",
267
+ ...options
268
+ });
269
+ };
246
270
  var getExplore = (options) => {
247
271
  return (options.client ?? client).get({
248
272
  security: [
@@ -291,6 +315,18 @@ var getProfileBalances = (options) => {
291
315
  ...options
292
316
  });
293
317
  };
318
+ var getProfileBySocialHandle = (options) => {
319
+ return (options.client ?? client).get({
320
+ security: [
321
+ {
322
+ name: "api-key",
323
+ type: "apiKey"
324
+ }
325
+ ],
326
+ url: "/profileBySocialHandle",
327
+ ...options
328
+ });
329
+ };
294
330
  var getProfileCoins = (options) => {
295
331
  return (options.client ?? client).get({
296
332
  security: [
@@ -363,6 +399,18 @@ var getTrendsByName = (options) => {
363
399
  ...options
364
400
  });
365
401
  };
402
+ var getWalletTradeActivity = (options) => {
403
+ return (options.client ?? client).get({
404
+ security: [
405
+ {
406
+ name: "api-key",
407
+ type: "apiKey"
408
+ }
409
+ ],
410
+ url: "/walletTradeActivity",
411
+ ...options
412
+ });
413
+ };
366
414
  var postQuote = (options) => {
367
415
  return (options?.client ?? client).post({
368
416
  security: [
@@ -478,6 +526,13 @@ var getCoinHolders2 = async (query, options) => {
478
526
  ...options
479
527
  });
480
528
  };
529
+ var getCoinPriceHistory2 = async (query, options) => {
530
+ return await getCoinPriceHistory({
531
+ query,
532
+ ...getApiKeyMeta(),
533
+ ...options
534
+ });
535
+ };
481
536
  var getCoinSwaps2 = async (query, options) => {
482
537
  return await getCoinSwaps({
483
538
  query,
@@ -555,6 +610,20 @@ var getCreatorCoinPoolConfig2 = async (query, options) => {
555
610
  ...options
556
611
  });
557
612
  };
613
+ var getCreatorLivestreamComments2 = async (query, options) => {
614
+ return await getCreatorLivestreamComments({
615
+ query,
616
+ ...getApiKeyMeta(),
617
+ ...options
618
+ });
619
+ };
620
+ var getWalletTradeActivity2 = async (query, options) => {
621
+ return await getWalletTradeActivity({
622
+ query,
623
+ ...getApiKeyMeta(),
624
+ ...options
625
+ });
626
+ };
558
627
 
559
628
  // src/api/create.ts
560
629
  var postCreateContent2 = async (body, options) => {
@@ -565,6 +634,15 @@ var postCreateContent2 = async (body, options) => {
565
634
  });
566
635
  };
567
636
 
637
+ // src/api/social.ts
638
+ var getProfileBySocialHandle2 = async (query, options) => {
639
+ return await getProfileBySocialHandle({
640
+ ...options,
641
+ query,
642
+ ...getApiKeyMeta()
643
+ });
644
+ };
645
+
568
646
  // src/utils/rethrowDecodedRevert.ts
569
647
  import {
570
648
  BaseError,
@@ -1150,6 +1228,8 @@ var setCreateUploadJwt2 = async (body, options) => {
1150
1228
  };
1151
1229
 
1152
1230
  // src/uploader/providers/zora.ts
1231
+ var JWT_TTL_MS = 1e3 * 60 * 60;
1232
+ var JWT_FETCH_TIMEOUT_MS = 15e3;
1153
1233
  var ZoraUploader = class {
1154
1234
  constructor(creatorAddress) {
1155
1235
  this.creatorAddress = creatorAddress;
@@ -1157,35 +1237,61 @@ var ZoraUploader = class {
1157
1237
  throw new Error("API key is required for metadata interactions");
1158
1238
  }
1159
1239
  }
1160
- async getJWTApiKey() {
1240
+ invalidateJwt() {
1241
+ this.jwtApiKey = void 0;
1242
+ this.jwtApiKeyExpiresAt = void 0;
1243
+ }
1244
+ async getJWTApiKey(signal) {
1161
1245
  if (this.jwtApiKey && this.jwtApiKeyExpiresAt && this.jwtApiKeyExpiresAt > Date.now()) {
1162
1246
  return this.jwtApiKey;
1163
1247
  }
1164
- this.jwtApiKeyExpiresAt = Date.now() + 1e3 * 60 * 60;
1165
- const response = await setCreateUploadJwt2({
1166
- creatorAddress: this.creatorAddress
1167
- });
1248
+ const jwtSignal = AbortSignal.timeout(JWT_FETCH_TIMEOUT_MS);
1249
+ const combinedSignal = signal ? AbortSignal.any([signal, jwtSignal]) : jwtSignal;
1250
+ const response = await setCreateUploadJwt2(
1251
+ {
1252
+ creatorAddress: this.creatorAddress
1253
+ },
1254
+ { signal: combinedSignal }
1255
+ );
1168
1256
  this.jwtApiKey = response.data?.createUploadJwtFromApiKey;
1169
1257
  if (!this.jwtApiKey) {
1170
1258
  throw new Error("Failed to create upload JWT");
1171
1259
  }
1260
+ this.jwtApiKeyExpiresAt = Date.now() + JWT_TTL_MS;
1172
1261
  return this.jwtApiKey;
1173
1262
  }
1174
- async upload(file) {
1175
- const jwtApiKey = await this.getJWTApiKey();
1263
+ buildUploadSignal(options) {
1264
+ const { signal, timeout } = options ?? {};
1265
+ if (signal && timeout) {
1266
+ return AbortSignal.any([signal, AbortSignal.timeout(timeout)]);
1267
+ }
1268
+ if (timeout) {
1269
+ return AbortSignal.timeout(timeout);
1270
+ }
1271
+ return signal;
1272
+ }
1273
+ async doUpload(file, jwt, signal) {
1176
1274
  const formData = new FormData();
1177
1275
  formData.append("file", file, file.name);
1178
- const response = await fetch(
1179
- "https://ipfs-uploader.zora.co/api/v0/add?cid-version=1",
1180
- {
1181
- method: "POST",
1182
- headers: {
1183
- Authorization: `Bearer ${jwtApiKey}`,
1184
- Accept: "*/*"
1185
- },
1186
- body: formData
1187
- }
1188
- );
1276
+ return fetch("https://ipfs-uploader.zora.co/api/v0/add?cid-version=1", {
1277
+ method: "POST",
1278
+ headers: {
1279
+ Authorization: `Bearer ${jwt}`,
1280
+ Accept: "*/*"
1281
+ },
1282
+ body: formData,
1283
+ signal
1284
+ });
1285
+ }
1286
+ async upload(file, options) {
1287
+ const uploadSignal = this.buildUploadSignal(options);
1288
+ const jwt = await this.getJWTApiKey(uploadSignal);
1289
+ let response = await this.doUpload(file, jwt, uploadSignal);
1290
+ if (response.status === 401) {
1291
+ this.invalidateJwt();
1292
+ const freshJwt = await this.getJWTApiKey(uploadSignal);
1293
+ response = await this.doUpload(file, freshJwt, uploadSignal);
1294
+ }
1189
1295
  if (!response.ok) {
1190
1296
  console.error(await response.text());
1191
1297
  throw new Error(`Failed to upload file: ${response.statusText}`);
@@ -1217,6 +1323,7 @@ export {
1217
1323
  getCoinComments2 as getCoinComments,
1218
1324
  getCoinCreateFromLogs,
1219
1325
  getCoinHolders2 as getCoinHolders,
1326
+ getCoinPriceHistory2 as getCoinPriceHistory,
1220
1327
  getCoinSwaps2 as getCoinSwaps,
1221
1328
  getCoins2 as getCoins,
1222
1329
  getCoinsLastTraded,
@@ -1228,6 +1335,7 @@ export {
1228
1335
  getContentCoinPoolConfig2 as getContentCoinPoolConfig,
1229
1336
  getCreatorCoinPoolConfig2 as getCreatorCoinPoolConfig,
1230
1337
  getCreatorCoins,
1338
+ getCreatorLivestreamComments2 as getCreatorLivestreamComments,
1231
1339
  getExploreFeaturedCreators,
1232
1340
  getExploreFeaturedVideos,
1233
1341
  getExploreList,
@@ -1241,6 +1349,7 @@ export {
1241
1349
  getNewTrends,
1242
1350
  getProfile2 as getProfile,
1243
1351
  getProfileBalances2 as getProfileBalances,
1352
+ getProfileBySocialHandle2 as getProfileBySocialHandle,
1244
1353
  getProfileCoins2 as getProfileCoins,
1245
1354
  getProfileSocial2 as getProfileSocial,
1246
1355
  getTokenInfo2 as getTokenInfo,
@@ -1253,6 +1362,7 @@ export {
1253
1362
  getTrendingTrends,
1254
1363
  getTrends,
1255
1364
  getURLFromUploadResult,
1365
+ getWalletTradeActivity2 as getWalletTradeActivity,
1256
1366
  setApiBaseUrl,
1257
1367
  setApiKey,
1258
1368
  tradeCoin,