rango-sdk-basic 0.0.1

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.
Files changed (59) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +25 -0
  3. package/lib/index.d.ts +3 -0
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.js +21 -0
  6. package/lib/index.js.map +1 -0
  7. package/lib/services/client.d.ts +19 -0
  8. package/lib/services/client.d.ts.map +1 -0
  9. package/lib/services/client.js +191 -0
  10. package/lib/services/client.js.map +1 -0
  11. package/lib/services/httpService.d.ts +2 -0
  12. package/lib/services/httpService.d.ts.map +1 -0
  13. package/lib/services/httpService.js +11 -0
  14. package/lib/services/httpService.js.map +1 -0
  15. package/lib/services/index.d.ts +2 -0
  16. package/lib/services/index.d.ts.map +1 -0
  17. package/lib/services/index.js +6 -0
  18. package/lib/services/index.js.map +1 -0
  19. package/lib/types/api/balance.d.ts +39 -0
  20. package/lib/types/api/balance.d.ts.map +1 -0
  21. package/lib/types/api/balance.js +3 -0
  22. package/lib/types/api/balance.js.map +1 -0
  23. package/lib/types/api/common.d.ts +117 -0
  24. package/lib/types/api/common.d.ts.map +1 -0
  25. package/lib/types/api/common.js +11 -0
  26. package/lib/types/api/common.js.map +1 -0
  27. package/lib/types/api/meta.d.ts +61 -0
  28. package/lib/types/api/meta.d.ts.map +1 -0
  29. package/lib/types/api/meta.js +3 -0
  30. package/lib/types/api/meta.js.map +1 -0
  31. package/lib/types/api/routing.d.ts +31 -0
  32. package/lib/types/api/routing.d.ts.map +1 -0
  33. package/lib/types/api/routing.js +3 -0
  34. package/lib/types/api/routing.js.map +1 -0
  35. package/lib/types/api/transactions.d.ts +145 -0
  36. package/lib/types/api/transactions.d.ts.map +1 -0
  37. package/lib/types/api/transactions.js +22 -0
  38. package/lib/types/api/transactions.js.map +1 -0
  39. package/lib/types/api/txs/cosmos.d.ts +68 -0
  40. package/lib/types/api/txs/cosmos.d.ts.map +1 -0
  41. package/lib/types/api/txs/cosmos.js +3 -0
  42. package/lib/types/api/txs/cosmos.js.map +1 -0
  43. package/lib/types/api/txs/evm.d.ts +29 -0
  44. package/lib/types/api/txs/evm.d.ts.map +1 -0
  45. package/lib/types/api/txs/evm.js +3 -0
  46. package/lib/types/api/txs/evm.js.map +1 -0
  47. package/lib/types/api/txs/index.d.ts +4 -0
  48. package/lib/types/api/txs/index.d.ts.map +1 -0
  49. package/lib/types/api/txs/index.js +20 -0
  50. package/lib/types/api/txs/index.js.map +1 -0
  51. package/lib/types/api/txs/transfer.d.ts +26 -0
  52. package/lib/types/api/txs/transfer.d.ts.map +1 -0
  53. package/lib/types/api/txs/transfer.js +3 -0
  54. package/lib/types/api/txs/transfer.js.map +1 -0
  55. package/lib/types/index.d.ts +7 -0
  56. package/lib/types/index.d.ts.map +1 -0
  57. package/lib/types/index.js +23 -0
  58. package/lib/types/index.js.map +1 -0
  59. package/package.json +59 -0
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Rango Exchange SDK (BETA)
2
+
3
+ [![npm version](https://badge.fury.io/js/rango-sdk.svg)](https://badge.fury.io/js/rango-sdk)
4
+ [![license](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/rango-exchange/rango-sdk/blob/master/LICENSE)
5
+
6
+
7
+ This is the first phase of Rango SDK which only wraps Rest API calls. In the next phase, we will handle connecting to the wallet providers.
8
+
9
+ > **WARNING:** The Rango SDK is still beta. Please use it on your own risk.
10
+
11
+ > **WARNING:** The Rango SDK has not stabilized yet, and we might make some breaking changes.
12
+
13
+
14
+ ## Installation
15
+
16
+ ```shell
17
+ npm install rango-sdk --save
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Please checkout the examples' folder for sample usage of the SDK. We will add more examples there soon.
23
+
24
+ - [Documents](https://docs.rango.exchange/integration/overview)
25
+ - [Examples](https://github.com/rango-exchange/rango-sdk/tree/master/examples/)
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { RangoClient } from './services';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,cAAc,SAAS,CAAA"}
package/lib/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.RangoClient = void 0;
18
+ var services_1 = require("./services");
19
+ Object.defineProperty(exports, "RangoClient", { enumerable: true, get: function () { return services_1.RangoClient; } });
20
+ __exportStar(require("./types"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAwC;AAA/B,uGAAA,WAAW,OAAA;AACpB,0CAAuB"}
@@ -0,0 +1,19 @@
1
+ import { MetaResponse, QuoteRequest, QuoteResponse, CheckApprovalResponse, StatusRequest, StatusResponse, SwapRequest, SwapResponse, ReportTransactionRequest, WalletDetailsResponse } from "../types";
2
+ declare type WalletAddress = {
3
+ blockchain: string;
4
+ address: string;
5
+ };
6
+ export declare class RangoClient {
7
+ private readonly deviceId;
8
+ private readonly apiKey;
9
+ constructor(apiKey: string);
10
+ meta(): Promise<MetaResponse>;
11
+ quote(quoteRequest: QuoteRequest): Promise<QuoteResponse>;
12
+ isApproved(requestId: string, txId: string): Promise<CheckApprovalResponse>;
13
+ status(statusRequest: StatusRequest): Promise<StatusResponse>;
14
+ swap(swapRequest: SwapRequest): Promise<SwapResponse>;
15
+ reportFailure(requestBody: ReportTransactionRequest): Promise<void>;
16
+ balance(walletAddress: WalletAddress): Promise<WalletDetailsResponse>;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,UAAU,CAAA;AAGjB,aAAK,aAAa,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5D,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IAEjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAEnB,MAAM,EAAE,MAAM;IAoBb,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IAO7B,KAAK,CAChB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,aAAa,CAAC;IAeZ,UAAU,CACrB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC;IAUpB,MAAM,CACjB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,cAAc,CAAC;IAUb,IAAI,CACf,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,YAAY,CAAC;IAeX,aAAa,CACxB,WAAW,EAAE,wBAAwB,GACpC,OAAO,CAAC,IAAI,CAAC;IAMH,OAAO,CAClB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,qBAAqB,CAAC;CASlC"}
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.RangoClient = void 0;
51
+ var uuid_1 = require("uuid");
52
+ var httpService_1 = require("./httpService");
53
+ var types_1 = require("../types");
54
+ var RangoClient = /** @class */ (function () {
55
+ function RangoClient(apiKey) {
56
+ this.apiKey = apiKey;
57
+ try {
58
+ if (typeof window !== 'undefined') {
59
+ var deviceId = localStorage.getItem('deviceId');
60
+ if (deviceId) {
61
+ this.deviceId = deviceId;
62
+ }
63
+ else {
64
+ var generatedId = (0, uuid_1.v4)();
65
+ localStorage.setItem('deviceId', generatedId);
66
+ this.deviceId = generatedId;
67
+ }
68
+ }
69
+ else {
70
+ this.deviceId = (0, uuid_1.v4)();
71
+ }
72
+ }
73
+ catch (e) {
74
+ this.deviceId = (0, uuid_1.v4)();
75
+ }
76
+ }
77
+ RangoClient.prototype.meta = function () {
78
+ return __awaiter(this, void 0, void 0, function () {
79
+ var axiosResponse;
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
82
+ case 0: return [4 /*yield*/, httpService_1.httpService.get("/basic/meta?apiKey=".concat(this.apiKey))];
83
+ case 1:
84
+ axiosResponse = _a.sent();
85
+ return [2 /*return*/, axiosResponse.data];
86
+ }
87
+ });
88
+ });
89
+ };
90
+ RangoClient.prototype.quote = function (quoteRequest) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var body, axiosResponse;
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0:
96
+ body = __assign(__assign({}, quoteRequest), { from: (0, types_1.assetToString)(quoteRequest.from), to: (0, types_1.assetToString)(quoteRequest.to) });
97
+ return [4 /*yield*/, httpService_1.httpService.get("/basic/quote?apiKey=".concat(this.apiKey), {
98
+ params: body,
99
+ headers: { 'X-Rango-Id': this.deviceId }
100
+ })];
101
+ case 1:
102
+ axiosResponse = _a.sent();
103
+ return [2 /*return*/, axiosResponse.data];
104
+ }
105
+ });
106
+ });
107
+ };
108
+ RangoClient.prototype.isApproved = function (requestId, txId) {
109
+ return __awaiter(this, void 0, void 0, function () {
110
+ var axiosResponse;
111
+ return __generator(this, function (_a) {
112
+ switch (_a.label) {
113
+ case 0: return [4 /*yield*/, httpService_1.httpService.get("/basic/is-approved?apiKey=".concat(this.apiKey), {
114
+ params: { requestId: requestId, txId: txId },
115
+ headers: { 'X-Rango-Id': this.deviceId }
116
+ })];
117
+ case 1:
118
+ axiosResponse = _a.sent();
119
+ return [2 /*return*/, axiosResponse.data];
120
+ }
121
+ });
122
+ });
123
+ };
124
+ RangoClient.prototype.status = function (statusRequest) {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ var axiosResponse;
127
+ return __generator(this, function (_a) {
128
+ switch (_a.label) {
129
+ case 0: return [4 /*yield*/, httpService_1.httpService.get("/basic/status?apiKey=".concat(this.apiKey), {
130
+ params: statusRequest,
131
+ headers: { 'X-Rango-Id': this.deviceId }
132
+ })];
133
+ case 1:
134
+ axiosResponse = _a.sent();
135
+ return [2 /*return*/, axiosResponse.data];
136
+ }
137
+ });
138
+ });
139
+ };
140
+ RangoClient.prototype.swap = function (swapRequest) {
141
+ return __awaiter(this, void 0, void 0, function () {
142
+ var body, axiosResponse;
143
+ return __generator(this, function (_a) {
144
+ switch (_a.label) {
145
+ case 0:
146
+ body = __assign(__assign({}, swapRequest), { from: (0, types_1.assetToString)(swapRequest.from), to: (0, types_1.assetToString)(swapRequest.to) });
147
+ return [4 /*yield*/, httpService_1.httpService.get("/basic/swap?apiKey=".concat(this.apiKey), {
148
+ params: body,
149
+ headers: { 'X-Rango-Id': this.deviceId }
150
+ })];
151
+ case 1:
152
+ axiosResponse = _a.sent();
153
+ return [2 /*return*/, axiosResponse.data];
154
+ }
155
+ });
156
+ });
157
+ };
158
+ RangoClient.prototype.reportFailure = function (requestBody) {
159
+ return __awaiter(this, void 0, void 0, function () {
160
+ return __generator(this, function (_a) {
161
+ switch (_a.label) {
162
+ case 0: return [4 /*yield*/, httpService_1.httpService.post("/basic/report-tx?apiKey=".concat(this.apiKey), requestBody, {
163
+ headers: { 'X-Rango-Id': this.deviceId }
164
+ })];
165
+ case 1:
166
+ _a.sent();
167
+ return [2 /*return*/];
168
+ }
169
+ });
170
+ });
171
+ };
172
+ RangoClient.prototype.balance = function (walletAddress) {
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ var axiosResponse;
175
+ return __generator(this, function (_a) {
176
+ switch (_a.label) {
177
+ case 0: return [4 /*yield*/, httpService_1.httpService.get("/basic/balance?apiKey=".concat(this.apiKey), {
178
+ params: walletAddress,
179
+ headers: { 'X-Rango-Id': this.deviceId }
180
+ })];
181
+ case 1:
182
+ axiosResponse = _a.sent();
183
+ return [2 /*return*/, axiosResponse.data];
184
+ }
185
+ });
186
+ });
187
+ };
188
+ return RangoClient;
189
+ }());
190
+ exports.RangoClient = RangoClient;
191
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAyB;AAEzB,6CAA2C;AAC3C,kCAWiB;AAKjB;IAKE,qBAAY,MAAc;QACxB,IAAI,C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E,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE;yBACzC,CAAC,EAAA;;wBAFF,SAEE,CAAA;;;;;KACH;IAEY,6BAAO,GAApB,UACE,aAA4B;;;;;4BAEN,qBAAM,yBAAW,CAAC,GAAG,CACzC,gCAAyB,IAAI,CAAC,MAAM,CAAE,EAAE;4BACtC,MAAM,EAAE,aAAa;4BACrB,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE;yBACzC,CACF,EAAA;;wBALK,aAAa,GAAG,SAKrB;wBACD,sBAAO,aAAa,CAAC,IAAI,EAAA;;;;KAC1B;IACH,kBAAC;AAAD,CAAC,AA9GD,IA8GC;AA9GY,kCAAW"}
@@ -0,0 +1,2 @@
1
+ export declare const httpService: import("axios").AxiosInstance;
2
+ //# sourceMappingURL=httpService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpService.d.ts","sourceRoot":"","sources":["../../src/services/httpService.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,+BAEtB,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.httpService = void 0;
7
+ var axios_1 = __importDefault(require("axios"));
8
+ exports.httpService = axios_1.default.create({
9
+ baseURL: 'https://api.rango.exchange',
10
+ });
11
+ //# sourceMappingURL=httpService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpService.js","sourceRoot":"","sources":["../../src/services/httpService.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAyB;AAEZ,QAAA,WAAW,GAAG,eAAK,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,4BAA4B;CACtC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { RangoClient } from './client';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RangoClient = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "RangoClient", { enumerable: true, get: function () { return client_1.RangoClient; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAA7B,qGAAA,WAAW,OAAA"}
@@ -0,0 +1,39 @@
1
+ import type { Asset, Amount } from './common';
2
+ /**
3
+ * Pair of the asset and its amount in wallet balance
4
+ *
5
+ * @property {Amount} amount
6
+ * @property {Asset} asset
7
+ *
8
+ */
9
+ export declare type AssetAndAmount = {
10
+ amount: Amount;
11
+ asset: Asset;
12
+ };
13
+ /**
14
+ * Balance of a specific address inside a specific blockchain
15
+ *
16
+ * @property {boolean} failed - If true, Rango was not able to fetch balance of this wallet, maybe try again later
17
+ * @property {string} blockChain - Wallet blockchain
18
+ * @property {string} address - Wallet address
19
+ * @property {AssetAndAmount[] | null} balances - Examples: BSC, TERRA, OSMOSIS, ...
20
+ * @property {string} explorerUrl - The explorer url of the wallet, example: https://bscscan.com/address/0x7a3....fdsza
21
+ *
22
+ */
23
+ export declare type WalletDetail = {
24
+ failed: boolean;
25
+ blockChain: string;
26
+ address: string;
27
+ balances: AssetAndAmount[] | null;
28
+ explorerUrl: string;
29
+ };
30
+ /**
31
+ * Response of checking wallet balance
32
+ *
33
+ * @property {WalletDetail[]} wallets - list of wallet assets
34
+ *
35
+ */
36
+ export declare type WalletDetailsResponse = {
37
+ wallets: WalletDetail[];
38
+ };
39
+ //# sourceMappingURL=balance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../../src/types/api/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAE7C;;;;;;GAMG;AACH,oBAAY,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,YAAY,GAAG;IACzB,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,oBAAY,qBAAqB,GAAG;IAClC,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=balance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance.js","sourceRoot":"","sources":["../../../src/types/api/balance.ts"],"names":[],"mappings":""}
@@ -0,0 +1,117 @@
1
+ import { SwapperMetaDto, Token } from "./meta";
2
+ /**
3
+ * An asset which is unique by (blockchain, symbol, address)
4
+ *
5
+ * @property {string} blockchain - The blockchain which this token belongs to
6
+ * @property {string | null} address - Smart contract address of token, null for native tokens
7
+ * @property {string} symbol - The display token symbol, e.g. USDT, BTC, ...
8
+ *
9
+ */
10
+ export declare type Asset = {
11
+ blockchain: string;
12
+ address: string | null;
13
+ symbol: string;
14
+ };
15
+ export declare function assetToString(asset: Asset): string;
16
+ /**
17
+ * The amount of an asset, including value & decimals.
18
+ * The value is machine-readable, to make it human-readable it should be shifted by decimals.
19
+ *
20
+ * @property {string} amount - The machine-readable amount shifted by decimals, example: 1000000000000000000
21
+ * @property {number} decimals - The decimals of the token in blockchain, example: 18
22
+ *
23
+ */
24
+ export declare type Amount = {
25
+ amount: string;
26
+ decimals: number;
27
+ };
28
+ /**
29
+ * A fee unit, including the type of asset and the amount of fee
30
+ *
31
+ * @property {string} name - A display name for this fee, example: Network Fee
32
+ * @property {Asset} asset - Underlying asset for paying fee, example: BNB for BSC blockchain
33
+ * @property {string} amount - The human readable amount of fee, example: 0.004
34
+ * @property {string} expenseType - Type of the fee, example: FROM_SOURCE_WALLET
35
+ *
36
+ */
37
+ export declare type SwapFee = {
38
+ name: string;
39
+ expenseType: 'FROM_SOURCE_WALLET' | 'DECREASE_FROM_OUTPUT';
40
+ asset: Asset;
41
+ amount: string;
42
+ };
43
+ /**
44
+ * A quote path from asset x (from) to asset y (to)
45
+ *
46
+ * @property {Token} from - The source asset
47
+ * @property {Token} to - The destination asset
48
+ * @property {SwapperMetaDto} swapper - Swapper for this path
49
+ * @property {"BRIDGE" | "DEX" | "COMPOSER"} swapperType - Type of swapper
50
+ * @property {string} expectedOutput - Expected output
51
+ *
52
+ */
53
+ export declare type QuotePath = {
54
+ from: Token;
55
+ to: Token;
56
+ swapper: SwapperMetaDto;
57
+ swapperType: "BRIDGE" | "DEX" | "COMPOSER";
58
+ expectedOutput: string;
59
+ };
60
+ /**
61
+ * Limitations on input amount for requested route
62
+ *
63
+ * @property {string | null} min - Limitation on minimum input amount for this route
64
+ * @property {string | null} max - Limitation on maximum input amount for this route
65
+ * @property {'INCLUSIVE' | 'EXCLUSIVE'} type - type of limitation
66
+ *
67
+ */
68
+ export declare type AmountRestriction = {
69
+ min: string | null;
70
+ max: string | null;
71
+ type: 'INCLUSIVE' | 'EXCLUSIVE';
72
+ };
73
+ /**
74
+ * A step of a multi-step swap route
75
+ *
76
+ * @property {string} outputAmount - The estimation of Rango from output amount of Y
77
+ *
78
+ * @property {SwapperMetaDto} swapper - Swapper suggested for this path
79
+ *
80
+ * @property {QuotePath[] | null} path - The internal routing of this step showing how the initial swap request will
81
+ * be split and executed. This can be used for previewing purpose to give the user a sense of what's going to happen.
82
+ * Null indicates that there is no internal mechanism and swapping is simple and straight-forward.
83
+ *
84
+ * @property {SwapFee[]} fee - List of fees that are taken from user in this step
85
+ *
86
+ * @property {AmountRestriction | null} amountRestriction - restrictions on input amount. This field is informational
87
+ * and there is no need to apply it in client-side
88
+ *
89
+ * @property {number} estimatedTimeInSeconds - The estimated time (in seconds) that this step might take, beware that
90
+ * this number is just an estimation and should be used only for user preview, example: 15
91
+ *
92
+ */
93
+ export declare type QuoteSimulationResult = {
94
+ outputAmount: string;
95
+ swapper: SwapperMetaDto;
96
+ path: QuotePath[] | null;
97
+ fee: SwapFee[];
98
+ amountRestriction: AmountRestriction | null;
99
+ estimatedTimeInSeconds: number;
100
+ };
101
+ /**
102
+ * An asset with its ticker
103
+ *
104
+ * @property {string} blockchain - Blockchain of asset
105
+ * @property {string | null} address - Contract address of the asset, null for native tokens
106
+ * @property {string} symbol - Symbol of an asset, example: BUSD
107
+ * @property {string} ticker - The ticker of the asset which normally is a combination of symbol and address,
108
+ * required by some javascript wallets
109
+ *
110
+ */
111
+ export declare type AssetWithTicker = {
112
+ blockchain: string;
113
+ address: string | null;
114
+ symbol: string;
115
+ ticker: string;
116
+ };
117
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/types/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,KAAK,EAAC,MAAM,QAAQ,CAAA;AAE5C;;;;;;;GAOG;AACH,oBAAY,KAAK,GAAG;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAKlD;AAED;;;;;;;GAOG;AACH,oBAAY,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAGD;;;;;;;;GAQG;AACH,oBAAY,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,oBAAoB,GAAG,sBAAsB,CAAA;IAC1D,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IACT,OAAO,EAAE,cAAc,CAAA;IACvB,WAAW,EAAE,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAA;IAC1C,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;;;;;GAOG;AACH,oBAAY,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,IAAI,EAAE,WAAW,GAAG,WAAW,CAAA;CAChC,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,qBAAqB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;IACxB,GAAG,EAAE,OAAO,EAAE,CAAA;IACd,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC3C,sBAAsB,EAAE,MAAM,CAAA;CAC/B,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assetToString = void 0;
4
+ function assetToString(asset) {
5
+ if (!!asset.address)
6
+ return "".concat(asset.blockchain, ".").concat(asset.symbol, "--").concat(asset.address);
7
+ else
8
+ return "".concat(asset.blockchain, ".").concat(asset.symbol);
9
+ }
10
+ exports.assetToString = assetToString;
11
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/types/api/common.ts"],"names":[],"mappings":";;;AAgBA,SAAgB,aAAa,CAAC,KAAY;IACxC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO;QACjB,OAAO,UAAG,KAAK,CAAC,UAAU,cAAI,KAAK,CAAC,MAAM,eAAK,KAAK,CAAC,OAAO,CAAE,CAAA;;QAE9D,OAAO,UAAG,KAAK,CAAC,UAAU,cAAI,KAAK,CAAC,MAAM,CAAE,CAAA;AAChD,CAAC;AALD,sCAKC"}
@@ -0,0 +1,61 @@
1
+ import type { Asset } from './common';
2
+ import { TransactionType } from "./transactions";
3
+ /**
4
+ * Blockchain information
5
+ *
6
+ * @property {string} name - Unique name of blockchain, this field is used in all endpoints as the identifier
7
+ * @property {number} defaultDecimals - The default decimals of blockchain, do not use it in computations, use Token.decimals instead
8
+ * @property {Asset[]} feeAssets - List of assets that can be used as fee in this blockchain
9
+ * @property {string[]} addressPatterns - List of all regex patterns for wallet addresses of this blockchain, can be
10
+ * used for input validation, example: [ "^(0x)[0-9A-Fa-f]{40}$" ]
11
+ * @property {TransactionType | null} type - Type of transactions in this blockchain
12
+ * @property {string | null} chainId - Chain Id (e.g. 1 for Ethereum)
13
+ *
14
+ */
15
+ export declare type BlockchainMeta = {
16
+ name: string;
17
+ defaultDecimals: number;
18
+ feeAssets: Asset[];
19
+ addressPatterns: string[];
20
+ type: TransactionType | null;
21
+ chainId: string | null;
22
+ };
23
+ /**
24
+ * Metadata of Swapper
25
+ */
26
+ export declare type SwapperMetaDto = {
27
+ id: string;
28
+ title: string;
29
+ logo: string;
30
+ };
31
+ /**
32
+ * All metadata info for a token, unique by (blockchain, symbol, address) tuple
33
+ *
34
+ * @property {string} blockchain - The blockchain which this token belongs to
35
+ * @property {string | null} address - Smart contract address of token, null for native tokens
36
+ * @property {string} symbol - The token symbol, e.g: ADA
37
+ * @property {number} decimals - Decimals of token in blockchain, example: 18
38
+ * @property {string} image - Url of its image, example: https://api.rango.exchange/tokens/ETH/ETH.png
39
+ *
40
+ */
41
+ export declare type Token = {
42
+ blockchain: string;
43
+ address: string | null;
44
+ symbol: string;
45
+ decimals: number;
46
+ image: string;
47
+ };
48
+ /**
49
+ * Metadata info for all blockchains and tokens supported
50
+ *
51
+ * @property {BlockchainMeta[]} blockchains - List of all supported blockchains
52
+ * @property {Token[]} tokens - List of all tokens
53
+ * @property {SwapperMetaDto[]} swappers - List of all DEXes & Bridges
54
+ *
55
+ */
56
+ export declare type MetaResponse = {
57
+ blockchains: BlockchainMeta[];
58
+ tokens: Token[];
59
+ swappers: SwapperMetaDto[];
60
+ };
61
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/types/api/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,KAAK,EAAE,CAAA;IAClB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAA;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAAA;AAED;;GAEG;AACH,oBAAY,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,KAAK,GAAG;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;GAOG;AACH,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,cAAc,EAAE,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC3B,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/types/api/meta.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import type { Asset, QuoteSimulationResult } from './common';
2
+ /**
3
+ * Body of quote request
4
+ *
5
+ * @property {Asset} from - The source asset
6
+ * @property {Asset} to - The destination asset
7
+ * @property {string} amount - The human-readable amount of asset X that is going to be swapped, example: 0.28
8
+ * @property {string[]} [swappers] - List of all accepted swappers, an empty list means no filter is required
9
+ *
10
+ */
11
+ export declare type QuoteRequest = {
12
+ from: Asset;
13
+ to: Asset;
14
+ amount: string;
15
+ swappers?: string[];
16
+ };
17
+ /**
18
+ * The response of quote API, if the route field is null, it means that no route is found
19
+ *
20
+ * @property {string} requestId - The unique requestId which is generated for this request by the server. It should be
21
+ * passed down to all other endpoints if this swap continues on. e.g. d10657ce-b13a-405c-825b-b47f8a5016ad
22
+ * @property {string} resultType - Type of result (OK or error type)
23
+ * @property {QuoteSimulationResult | null} route - Suggested route
24
+ *
25
+ */
26
+ export declare type QuoteResponse = {
27
+ requestId: string;
28
+ resultType: "OK" | "HIGH_IMPACT" | "INPUT_LIMIT_ISSUE" | "NO_ROUTE";
29
+ route: QuoteSimulationResult | null;
30
+ };
31
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/types/api/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAE,qBAAqB,EAAC,MAAM,UAAU,CAAA;AAG1D;;;;;;;;GAQG;AACH,oBAAY,YAAY,GAAG;IACzB,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IACT,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED;;;;;;;;GAQG;AACH,oBAAY,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,IAAI,GAAG,aAAa,GAAG,mBAAmB,GAAG,UAAU,CAAA;IACnE,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAA;CACpC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../src/types/api/routing.ts"],"names":[],"mappings":""}