@covalenthq/client-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.
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.NameResolverService = void 0;
13
4
  const baseDelayMs = 1000; // Base delay in milliseconds
@@ -21,35 +12,33 @@ class NameResolverService {
21
12
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
22
13
  *
23
14
  */
24
- getResolvedAddress(chainName, walletAddress) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- let retryCount = 0;
27
- let success = false;
28
- while (!success) {
29
- try {
30
- const urlParams = new URLSearchParams();
31
- const response = yield fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/resolve_address/?${urlParams}`, {
32
- headers: {
33
- "Authorization": `Bearer ${this.apiKey}`
34
- }
35
- });
36
- const data = yield response.json();
37
- if (data.error && data.error_code === 429) {
38
- retryCount++;
39
- const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
40
- yield new Promise((resolve) => setTimeout(resolve, delayMs));
41
- }
42
- else {
43
- success = true;
44
- return data;
15
+ async getResolvedAddress(chainName, walletAddress) {
16
+ let retryCount = 0;
17
+ let success = false;
18
+ while (!success) {
19
+ try {
20
+ const urlParams = new URLSearchParams();
21
+ const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/resolve_address/?${urlParams}`, {
22
+ headers: {
23
+ "Authorization": `Bearer ${this.apiKey}`
45
24
  }
25
+ });
26
+ const data = await response.json();
27
+ if (data.error && data.error_code === 429) {
28
+ retryCount++;
29
+ const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
30
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
46
31
  }
47
- catch (error) {
32
+ else {
48
33
  success = true;
49
- return error.message;
34
+ return data;
50
35
  }
51
36
  }
52
- });
37
+ catch (error) {
38
+ success = true;
39
+ return error.message;
40
+ }
41
+ }
53
42
  }
54
43
  }
55
44
  exports.NameResolverService = NameResolverService;
@@ -1 +1 @@
1
- {"version":3,"file":"NameResolverService.js","sourceRoot":"","sources":["../src/services/NameResolverService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAwBA,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,6BAA6B;AAEvD,MAAa,mBAAmB;IAC5B,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAClC,CAAC;IAGD;;;;;OAKG;IACU,kBAAkB,CAAC,SAAkjE,EAAE,aAAqB;;YACrmE,IAAI,UAAU,GAAG,CAAC,CAAC;YACnB,IAAI,OAAO,GAAG,KAAK,CAAC;YACpB,OAAO,CAAC,OAAO,EAAE;gBACb,IAAI;oBACA,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;oBAGxC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,iCAAiC,SAAS,YAAY,aAAa,qBAAqB,SAAS,EAAE,EAAE;wBAC9H,OAAO,EAAE;4BACL,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;yBAC3C;qBACJ,CAAC,CAAC;oBACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;oBACnC,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,EA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