@toruslabs/ethereum-controllers 6.1.3 → 6.2.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.
@@ -246,6 +246,15 @@ class PreferencesController extends baseControllers.BasePreferencesController {
246
246
  return [];
247
247
  }
248
248
  }
249
+ async fetchQuote(parameters) {
250
+ try {
251
+ const response = await this.wsApiClient.authPost("quote", parameters, this.authCredentials());
252
+ return response.success ? response.data : [];
253
+ } catch (error) {
254
+ log.error("unable to get swap quote", error);
255
+ return [];
256
+ }
257
+ }
249
258
  async getEtherScanTokens(address, chainId) {
250
259
  const selectedAddress = address;
251
260
  const result = await this.wsApiClient.authGet(`tokens?chainId=${chainId}&address=${selectedAddress}`, this.authCredentials());
@@ -244,6 +244,15 @@ class PreferencesController extends BasePreferencesController {
244
244
  return [];
245
245
  }
246
246
  }
247
+ async fetchQuote(parameters) {
248
+ try {
249
+ const response = await this.wsApiClient.authPost("quote", parameters, this.authCredentials());
250
+ return response.success ? response.data : [];
251
+ } catch (error) {
252
+ log.error("unable to get swap quote", error);
253
+ return [];
254
+ }
255
+ }
247
256
  async getEtherScanTokens(address, chainId) {
248
257
  const selectedAddress = address;
249
258
  const result = await this.wsApiClient.authGet(`tokens?chainId=${chainId}&address=${selectedAddress}`, this.authCredentials());
@@ -26,5 +26,5 @@ export declare class CurrencyController extends BaseCurrencyController<BaseCurre
26
26
  * fetched from an external API
27
27
  */
28
28
  updateConversionRate(): Promise<void>;
29
- private retrieveConversionRate;
29
+ retrieveConversionRate(fromCurrency: string, toCurrency: string, commonDenomination: string): Promise<Record<string, string>>;
30
30
  }
@@ -30,6 +30,22 @@ export declare class PreferencesController extends BasePreferencesController<Ext
30
30
  selectedAddress: string;
31
31
  chainId: string;
32
32
  }): Promise<T[]>;
33
+ fetchQuote<T>(parameters: {
34
+ chainId: string;
35
+ fromToken: string;
36
+ toToken: string;
37
+ fromValue: string;
38
+ recipient: string;
39
+ nativeToken: {
40
+ chainId: string;
41
+ name: string;
42
+ symbol: string;
43
+ logoURI: string;
44
+ decimals: number;
45
+ };
46
+ slippageTolerance?: string;
47
+ transactionDeadline?: number;
48
+ }): Promise<T[]>;
33
49
  getEtherScanTokens(address: string, chainId: string): Promise<CustomTokenInfo[]>;
34
50
  getSimpleHashNfts(address: string, chainId: string): Promise<CustomNftInfo[]>;
35
51
  getCustomTokens(address?: string): CustomToken[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toruslabs/ethereum-controllers",
3
- "version": "6.1.3",
3
+ "version": "6.2.0",
4
4
  "homepage": "https://github.com/torusresearch/controllers#readme",
5
5
  "license": "ISC",
6
6
  "sideEffects": false,
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@ethereumjs/util": "^9.1.0",
24
- "@toruslabs/base-controllers": "^6.1.2",
24
+ "@toruslabs/base-controllers": "^6.2.0",
25
25
  "@toruslabs/http-helpers": "^7.0.0",
26
26
  "@web3auth/auth": "^9.3.3",
27
27
  "async-mutex": "^0.5.0",
@@ -61,7 +61,7 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "2b07fc141f76cd05bfc7a1f9a18a34157a39d1b7",
64
+ "gitHead": "14437406216427df89ef1ee3329d473efff35e12",
65
65
  "devDependencies": {
66
66
  "@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
67
67
  "@nomicfoundation/hardhat-ethers": "^3.0.8",