rainbow-swap-sdk 1.4.5 → 1.4.6

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/README.md CHANGED
@@ -30,13 +30,16 @@ yarn add rainbow-swap-sdk
30
30
  ### Example: Swapping 1.35 TON to USDT
31
31
 
32
32
  ```typescript
33
- import {getAssetsRecord, getBestRoute, toNano} from 'rainbow-swap-sdk';
33
+ import {getAssetsList, getBestRoute, toNano} from 'rainbow-swap-sdk';
34
34
 
35
35
  // 1. Load the list of available tokens
36
- const assetsRecord = await getAssetsRecord();
36
+ const assetsList = await getAssetsList({
37
+ userAssets: [] // Array of asset addresses the user holds; see AssetsListParams for more details.
38
+ });
37
39
 
38
- const inputAsset = assetsRecord['ton']; // TON asset
39
- const outputAsset = assetsRecord['EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs']; // USDT asset
40
+ // Retrieve specific assets by their address
41
+ const inputAsset = assetsList.find(asset => asset.address === 'ton');
42
+ const outputAsset = assetsList.find(asset => asset.address === 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs');
40
43
 
41
44
  // 2. Load the best swap route and swap messages
42
45
  const bestRouteResponse = await getBestRoute({
package/dist/index.d.ts CHANGED
@@ -7,10 +7,11 @@ export type { RouteStep } from './interfaces/route-step.interface';
7
7
  export type { RouteStepWithCalculation } from './interfaces/route-step-with-calculation.interface';
8
8
  export type { AppStatus } from './types/app-status.type';
9
9
  export type { Asset } from './types/asset.type';
10
+ export type { AssetsListParams } from './types/assets-list-patams.type';
10
11
  export type { AssetsRecord } from './types/assets-record.type';
11
12
  export type { BestRouteParams } from './types/best-route-params.type';
12
13
  export type { BestRouteResponse } from './types/best-route-response.type';
13
14
  export type { CalculatedSwapRoute } from './types/calculated-swap-route.type';
14
- export { getAssetsRecord, getBestRoute, getAppStatus } from './utils/api.utils';
15
+ export { getAssetsRecord, getAssetsList, getBestRoute, getAppStatus } from './utils/api.utils';
15
16
  export { toNano, fromNano } from './utils/big-int.utils';
16
17
  export { getQueryId } from './utils/transfer-params.utils';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getQueryId = exports.fromNano = exports.toNano = exports.getAppStatus = exports.getBestRoute = exports.getAssetsRecord = exports.SwapRouteType = exports.RouteDirectionEnum = exports.DexTypeEnum = exports.mapSwapRouteToRoute = void 0;
3
+ exports.getQueryId = exports.fromNano = exports.toNano = exports.getAppStatus = exports.getBestRoute = exports.getAssetsList = exports.getAssetsRecord = exports.SwapRouteType = exports.RouteDirectionEnum = exports.DexTypeEnum = exports.mapSwapRouteToRoute = void 0;
4
4
  var calculated_swap_route_utils_1 = require("./dexes/shared/calculated-swap-route.utils");
5
5
  Object.defineProperty(exports, "mapSwapRouteToRoute", { enumerable: true, get: function () { return calculated_swap_route_utils_1.mapSwapRouteToRoute; } });
6
6
  var dex_type_enum_1 = require("./enums/dex-type.enum");
@@ -11,6 +11,7 @@ var swap_route_type_enum_1 = require("./enums/swap-route-type.enum");
11
11
  Object.defineProperty(exports, "SwapRouteType", { enumerable: true, get: function () { return swap_route_type_enum_1.SwapRouteType; } });
12
12
  var api_utils_1 = require("./utils/api.utils");
13
13
  Object.defineProperty(exports, "getAssetsRecord", { enumerable: true, get: function () { return api_utils_1.getAssetsRecord; } });
14
+ Object.defineProperty(exports, "getAssetsList", { enumerable: true, get: function () { return api_utils_1.getAssetsList; } });
14
15
  Object.defineProperty(exports, "getBestRoute", { enumerable: true, get: function () { return api_utils_1.getBestRoute; } });
15
16
  Object.defineProperty(exports, "getAppStatus", { enumerable: true, get: function () { return api_utils_1.getAppStatus; } });
16
17
  var big_int_utils_1 = require("./utils/big-int.utils");
@@ -0,0 +1,25 @@
1
+ export type AssetsListParams = {
2
+ /**
3
+ * A list of asset addresses that the user holds balances in.
4
+ *
5
+ * **Example values:**
6
+ * - `'ton'` for TON.
7
+ * - `'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'` for USDT.
8
+ *
9
+ * **Default:** An empty array (`[]`), indicating no specified user assets.
10
+ */
11
+ userAssets?: string[];
12
+ /**
13
+ * A text string used to filter assets by symbol, name, or address.
14
+ *
15
+ * **Default:** An empty string (`''`), indicating no specific filter applied.
16
+ */
17
+ searchValue?: string;
18
+ /**
19
+ * The maximum number of assets (excluding user-owned) to return in the response.
20
+ * Acceptable values range from 10 to 200.
21
+ *
22
+ * **Default:** `100`
23
+ */
24
+ limit?: number;
25
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,10 @@
1
1
  import { AppStatus } from '../types/app-status.type';
2
+ import { Asset } from '../types/asset.type';
3
+ import { AssetsListParams } from '../types/assets-list-patams.type';
2
4
  import { AssetsRecord } from '../types/assets-record.type';
3
5
  import { BestRouteParams } from '../types/best-route-params.type';
4
6
  import { BestRouteResponse } from '../types/best-route-response.type';
5
7
  export declare const getAssetsRecord: () => Promise<AssetsRecord>;
8
+ export declare const getAssetsList: (params: AssetsListParams) => Promise<Asset[]>;
6
9
  export declare const getBestRoute: (params: BestRouteParams) => Promise<BestRouteResponse>;
7
10
  export declare const getAppStatus: () => Promise<AppStatus>;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAppStatus = exports.getBestRoute = exports.getAssetsRecord = void 0;
3
+ exports.getAppStatus = exports.getBestRoute = exports.getAssetsList = exports.getAssetsRecord = void 0;
4
4
  const globals_1 = require("../globals");
5
5
  const getAssetsRecord = () => globals_1.API.get('/assets-record').then(response => response.data);
6
6
  exports.getAssetsRecord = getAssetsRecord;
7
+ const getAssetsList = (params) => globals_1.API.post('/assets-list', params).then(response => response.data);
8
+ exports.getAssetsList = getAssetsList;
7
9
  const getBestRoute = (params) => globals_1.API.get('/best-route', { params }).then(response => response.data);
8
10
  exports.getBestRoute = getBestRoute;
9
11
  const getAppStatus = () => globals_1.API.get('/app-status').then(response => response.data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rainbow-swap-sdk",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "SDK for building applications on top of Rainbow.ag - Swap Aggregator on TON 💎.",
5
5
  "repository": "https://github.com/0xblackbot/rainbow-swap-sdk.git",
6
6
  "license": "Apache-2.0",