rango-sdk-basic 0.0.10 → 0.0.12
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/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/services/client.d.ts +5 -2
- package/lib/services/client.d.ts.map +1 -1
- package/lib/services/client.js +46 -1
- package/lib/services/client.js.map +1 -1
- package/lib/services/executor.d.ts +8 -0
- package/lib/services/executor.d.ts.map +1 -0
- package/lib/services/executor.js +194 -0
- package/lib/services/executor.js.map +1 -0
- package/lib/types/api/balance.d.ts +3 -3
- package/lib/types/api/balance.d.ts.map +1 -1
- package/lib/types/api/common.d.ts +19 -14
- package/lib/types/api/common.d.ts.map +1 -1
- package/lib/types/api/meta.d.ts +122 -8
- package/lib/types/api/meta.d.ts.map +1 -1
- package/lib/types/api/routing.d.ts +5 -3
- package/lib/types/api/routing.d.ts.map +1 -1
- package/lib/types/api/transactions.d.ts +9 -9
- package/lib/types/api/transactions.d.ts.map +1 -1
- package/lib/types/api/txs/cosmos.d.ts +8 -7
- package/lib/types/api/txs/cosmos.d.ts.map +1 -1
- package/lib/types/api/txs/evm.d.ts +4 -3
- package/lib/types/api/txs/evm.d.ts.map +1 -1
- package/lib/types/api/txs/transfer.d.ts +4 -1
- package/lib/types/api/txs/transfer.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/utils/errors.d.ts +23 -0
- package/lib/types/utils/errors.d.ts.map +1 -0
- package/lib/types/utils/errors.js +26 -0
- package/lib/types/utils/errors.js.map +1 -0
- package/lib/utils/errors.d.ts +2 -0
- package/lib/utils/errors.d.ts.map +1 -0
- package/lib/utils/errors.js +31 -0
- package/lib/utils/errors.js.map +1 -0
- package/lib/utils/promise.d.ts +2 -0
- package/lib/utils/promise.d.ts.map +1 -0
- package/lib/utils/promise.js +8 -0
- package/lib/utils/promise.js.map +1 -0
- package/package.json +3 -1
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,cAAc,sBAAsB,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -17,5 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.RangoClient = void 0;
|
|
18
18
|
var services_1 = require("./services");
|
|
19
19
|
Object.defineProperty(exports, "RangoClient", { enumerable: true, get: function () { return services_1.RangoClient; } });
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
20
|
+
__exportStar(require("./types/utils/errors"), exports);
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAwC;AAA/B,uGAAA,WAAW,OAAA;AACpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAwC;AAA/B,uGAAA,WAAW,OAAA;AACpB,uDAAoC"}
|
package/lib/services/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MetaResponse, QuoteRequest, QuoteResponse, CheckApprovalResponse, StatusRequest, StatusResponse, SwapRequest, SwapResponse, ReportTransactionRequest, WalletDetailsResponse } from '../types';
|
|
2
|
-
|
|
1
|
+
import { MetaResponse, QuoteRequest, QuoteResponse, CheckApprovalResponse, StatusRequest, StatusResponse, SwapRequest, SwapResponse, ReportTransactionRequest, WalletDetailsResponse, BlockchainMeta, SwapperMetaDto } from '../types';
|
|
2
|
+
type WalletAddress = {
|
|
3
3
|
blockchain: string;
|
|
4
4
|
address: string;
|
|
5
5
|
};
|
|
@@ -8,12 +8,15 @@ export declare class RangoClient {
|
|
|
8
8
|
private readonly apiKey;
|
|
9
9
|
constructor(apiKey: string, debug?: boolean);
|
|
10
10
|
meta(): Promise<MetaResponse>;
|
|
11
|
+
chains(): Promise<BlockchainMeta[]>;
|
|
12
|
+
swappers(): Promise<SwapperMetaDto[]>;
|
|
11
13
|
quote(quoteRequest: QuoteRequest): Promise<QuoteResponse>;
|
|
12
14
|
isApproved(requestId: string, txId: string): Promise<CheckApprovalResponse>;
|
|
13
15
|
status(statusRequest: StatusRequest): Promise<StatusResponse>;
|
|
14
16
|
swap(swapRequest: SwapRequest): Promise<SwapResponse>;
|
|
15
17
|
reportFailure(requestBody: ReportTransactionRequest): Promise<void>;
|
|
16
18
|
balance(walletAddress: WalletAddress): Promise<WalletDetailsResponse>;
|
|
19
|
+
executeEvmRoute(signer: any, route: SwapResponse): Promise<StatusResponse>;
|
|
17
20
|
}
|
|
18
21
|
export {};
|
|
19
22
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +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,
|
|
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,EAErB,cAAc,EACd,cAAc,EACf,MAAM,UAAU,CAAA;AAKjB,KAAK,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,EAAE,KAAK,GAAE,OAAe;IA8BrC,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IAO7B,MAAM,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAOnC,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAOrC,KAAK,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAyBzD,UAAU,CACrB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC;IAWpB,MAAM,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAW7D,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAyBrD,aAAa,CACxB,WAAW,EAAE,wBAAwB,GACpC,OAAO,CAAC,IAAI,CAAC;IAUH,OAAO,CAClB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,qBAAqB,CAAC;IAWpB,eAAe,CAC1B,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,cAAc,CAAC;CAO3B"}
|
package/lib/services/client.js
CHANGED
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
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
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -51,6 +51,8 @@ exports.RangoClient = void 0;
|
|
|
51
51
|
var uuid_1 = require("uuid");
|
|
52
52
|
var httpService_1 = require("./httpService");
|
|
53
53
|
var types_1 = require("../types");
|
|
54
|
+
var executor_1 = require("./executor");
|
|
55
|
+
var errors_1 = require("../utils/errors");
|
|
54
56
|
var RangoClient = /** @class */ (function () {
|
|
55
57
|
function RangoClient(apiKey, debug) {
|
|
56
58
|
if (debug === void 0) { debug = false; }
|
|
@@ -98,6 +100,32 @@ var RangoClient = /** @class */ (function () {
|
|
|
98
100
|
});
|
|
99
101
|
});
|
|
100
102
|
};
|
|
103
|
+
RangoClient.prototype.chains = function () {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
+
var axiosResponse;
|
|
106
|
+
return __generator(this, function (_a) {
|
|
107
|
+
switch (_a.label) {
|
|
108
|
+
case 0: return [4 /*yield*/, httpService_1.httpService.get("/basic/meta/blockchains?apiKey=".concat(this.apiKey))];
|
|
109
|
+
case 1:
|
|
110
|
+
axiosResponse = _a.sent();
|
|
111
|
+
return [2 /*return*/, axiosResponse.data];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
RangoClient.prototype.swappers = function () {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var axiosResponse;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0: return [4 /*yield*/, httpService_1.httpService.get("/basic/meta/swappers?apiKey=".concat(this.apiKey))];
|
|
122
|
+
case 1:
|
|
123
|
+
axiosResponse = _a.sent();
|
|
124
|
+
return [2 /*return*/, axiosResponse.data];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
101
129
|
RangoClient.prototype.quote = function (quoteRequest) {
|
|
102
130
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
131
|
var body, axiosResponse;
|
|
@@ -206,6 +234,23 @@ var RangoClient = /** @class */ (function () {
|
|
|
206
234
|
});
|
|
207
235
|
});
|
|
208
236
|
};
|
|
237
|
+
RangoClient.prototype.executeEvmRoute = function (signer, route) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
var error_1;
|
|
240
|
+
return __generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0:
|
|
243
|
+
_a.trys.push([0, 2, , 3]);
|
|
244
|
+
return [4 /*yield*/, (0, executor_1.executeEvmRoute)(this, signer, route)];
|
|
245
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
246
|
+
case 2:
|
|
247
|
+
error_1 = _a.sent();
|
|
248
|
+
throw (0, errors_1.prettifyError)(error_1);
|
|
249
|
+
case 3: return [2 /*return*/];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
};
|
|
209
254
|
return RangoClient;
|
|
210
255
|
}());
|
|
211
256
|
exports.RangoClient = RangoClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAyB;AAEzB,6CAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAyB;AAEzB,6CAA2C;AAC3C,kCAci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er } from 'ethers';
|
|
2
|
+
import { RangoClient } from './client';
|
|
3
|
+
import { EvmTransaction } from '../types/api/txs';
|
|
4
|
+
import { StatusResponse, SwapResponse } from '../types/api/transactions';
|
|
5
|
+
export declare function prepareEvmTransaction(evmTx: EvmTransaction, isApprove: boolean): {};
|
|
6
|
+
export declare const checkTransactionStatusSync: (requestId: string, txId: string, rangoClient: RangoClient) => Promise<StatusResponse>;
|
|
7
|
+
export declare const executeEvmRoute: (client: RangoClient, signer: Signer, route: SwapResponse) => Promise<StatusResponse>;
|
|
8
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/services/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EACL,cAAc,EACd,YAAY,EAGb,MAAM,2BAA2B,CAAA;AAGlC,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,OAAO,MA0BnB;AAkBD,eAAO,MAAM,0BAA0B,cAC1B,MAAM,QACX,MAAM,eACC,WAAW,4BAwBzB,CAAA;AAED,eAAO,MAAM,eAAe,WAClB,WAAW,UACX,MAAM,SACP,YAAY,KAClB,QAAQ,cAAc,CAoCxB,CAAA"}
|
|
@@ -0,0 +1,194 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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.executeEvmRoute = exports.checkTransactionStatusSync = exports.prepareEvmTransaction = void 0;
|
|
51
|
+
var transactions_1 = require("../types/api/transactions");
|
|
52
|
+
var promise_1 = require("../utils/promise");
|
|
53
|
+
function prepareEvmTransaction(evmTx, isApprove) {
|
|
54
|
+
var gasPrice = !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x')
|
|
55
|
+
? '0x' + parseInt(evmTx.gasPrice).toString(16)
|
|
56
|
+
: null;
|
|
57
|
+
var manipulatedTx = __assign(__assign({}, evmTx), { gasPrice: gasPrice });
|
|
58
|
+
var tx = {};
|
|
59
|
+
if (!!manipulatedTx.from)
|
|
60
|
+
tx = __assign(__assign({}, tx), { from: manipulatedTx.from });
|
|
61
|
+
if (isApprove) {
|
|
62
|
+
if (!!manipulatedTx.approveTo)
|
|
63
|
+
tx = __assign(__assign({}, tx), { to: manipulatedTx.approveTo });
|
|
64
|
+
if (!!manipulatedTx.approveData)
|
|
65
|
+
tx = __assign(__assign({}, tx), { data: manipulatedTx.approveData });
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
if (!!manipulatedTx.txTo)
|
|
69
|
+
tx = __assign(__assign({}, tx), { to: manipulatedTx.txTo });
|
|
70
|
+
if (!!manipulatedTx.txData)
|
|
71
|
+
tx = __assign(__assign({}, tx), { data: manipulatedTx.txData });
|
|
72
|
+
if (!!manipulatedTx.value)
|
|
73
|
+
tx = __assign(__assign({}, tx), { value: manipulatedTx.value });
|
|
74
|
+
if (!!manipulatedTx.gasLimit)
|
|
75
|
+
tx = __assign(__assign({}, tx), { gasLimit: manipulatedTx.gasLimit });
|
|
76
|
+
if (!!manipulatedTx.gasPrice)
|
|
77
|
+
tx = __assign(__assign({}, tx), { gasPrice: manipulatedTx.gasPrice });
|
|
78
|
+
}
|
|
79
|
+
return tx;
|
|
80
|
+
}
|
|
81
|
+
exports.prepareEvmTransaction = prepareEvmTransaction;
|
|
82
|
+
function checkApprovalSync(requestId, txId, rangoClient) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var approvalResponse, err_1;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
if (!true) return [3 /*break*/, 6];
|
|
89
|
+
_a.label = 1;
|
|
90
|
+
case 1:
|
|
91
|
+
_a.trys.push([1, 3, , 4]);
|
|
92
|
+
return [4 /*yield*/, rangoClient.isApproved(requestId, txId)];
|
|
93
|
+
case 2:
|
|
94
|
+
approvalResponse = _a.sent();
|
|
95
|
+
if (approvalResponse.isApproved)
|
|
96
|
+
return [2 /*return*/, true];
|
|
97
|
+
return [3 /*break*/, 4];
|
|
98
|
+
case 3:
|
|
99
|
+
err_1 = _a.sent();
|
|
100
|
+
console.log('ignorinig error', { err: err_1 });
|
|
101
|
+
return [3 /*break*/, 4];
|
|
102
|
+
case 4: return [4 /*yield*/, (0, promise_1.sleep)(3000)];
|
|
103
|
+
case 5:
|
|
104
|
+
_a.sent();
|
|
105
|
+
return [3 /*break*/, 0];
|
|
106
|
+
case 6: return [2 /*return*/];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
var checkTransactionStatusSync = function (requestId, txId, rangoClient) { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var txStatus, err_2;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
if (!true) return [3 /*break*/, 6];
|
|
117
|
+
_a.label = 1;
|
|
118
|
+
case 1:
|
|
119
|
+
_a.trys.push([1, 3, , 4]);
|
|
120
|
+
return [4 /*yield*/, rangoClient.status({
|
|
121
|
+
requestId: requestId,
|
|
122
|
+
txId: txId,
|
|
123
|
+
})];
|
|
124
|
+
case 2:
|
|
125
|
+
txStatus = _a.sent();
|
|
126
|
+
return [3 /*break*/, 4];
|
|
127
|
+
case 3:
|
|
128
|
+
err_2 = _a.sent();
|
|
129
|
+
console.log('ignorinig error', { err: err_2 });
|
|
130
|
+
return [3 /*break*/, 4];
|
|
131
|
+
case 4:
|
|
132
|
+
if (!!txStatus) {
|
|
133
|
+
if (!!txStatus.status &&
|
|
134
|
+
[transactions_1.TransactionStatus.FAILED, transactions_1.TransactionStatus.SUCCESS].includes(txStatus.status)) {
|
|
135
|
+
return [2 /*return*/, txStatus];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return [4 /*yield*/, (0, promise_1.sleep)(3000)];
|
|
139
|
+
case 5:
|
|
140
|
+
_a.sent();
|
|
141
|
+
return [3 /*break*/, 0];
|
|
142
|
+
case 6: return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); };
|
|
146
|
+
exports.checkTransactionStatusSync = checkTransactionStatusSync;
|
|
147
|
+
var executeEvmRoute = function (client, signer, route) { return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
var tx, requestId, error, resultType, evmTransaction, txChainId, signerChainId, approveTxData, approveTx, mainTxData, mainTx, status;
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
switch (_a.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
tx = route.tx, requestId = route.requestId, error = route.error, resultType = route.resultType;
|
|
153
|
+
if (resultType != 'OK')
|
|
154
|
+
throw new Error(resultType);
|
|
155
|
+
if (!!error || !tx)
|
|
156
|
+
throw new Error(error || 'Error creating the transaction.');
|
|
157
|
+
if ((tx === null || tx === void 0 ? void 0 : tx.type) !== transactions_1.TransactionType.EVM)
|
|
158
|
+
throw new Error('Non Evm transactions are not supported yet.');
|
|
159
|
+
evmTransaction = tx;
|
|
160
|
+
txChainId = parseInt(evmTransaction.blockChain.chainId || '-1');
|
|
161
|
+
return [4 /*yield*/, signer.getChainId()];
|
|
162
|
+
case 1:
|
|
163
|
+
signerChainId = _a.sent();
|
|
164
|
+
if (signerChainId !== txChainId) {
|
|
165
|
+
throw new Error("Signer chainId ".concat(signerChainId, " doesn't match required chainId ").concat(txChainId, "."));
|
|
166
|
+
}
|
|
167
|
+
if (!(!!evmTransaction.approveTo && !!evmTransaction.approveData)) return [3 /*break*/, 3];
|
|
168
|
+
approveTxData = prepareEvmTransaction(evmTransaction, true);
|
|
169
|
+
return [4 /*yield*/, signer.sendTransaction(approveTxData)];
|
|
170
|
+
case 2:
|
|
171
|
+
approveTx = _a.sent();
|
|
172
|
+
approveTx.wait();
|
|
173
|
+
checkApprovalSync(requestId, approveTx.hash, client);
|
|
174
|
+
_a.label = 3;
|
|
175
|
+
case 3: return [4 /*yield*/, signer.getChainId()];
|
|
176
|
+
case 4:
|
|
177
|
+
signerChainId = _a.sent();
|
|
178
|
+
if (signerChainId !== txChainId) {
|
|
179
|
+
throw new Error("Signer chainId ".concat(signerChainId, " doesn't match required chainId ").concat(txChainId, "."));
|
|
180
|
+
}
|
|
181
|
+
mainTxData = prepareEvmTransaction(evmTransaction, false);
|
|
182
|
+
return [4 /*yield*/, signer.sendTransaction(mainTxData)];
|
|
183
|
+
case 5:
|
|
184
|
+
mainTx = _a.sent();
|
|
185
|
+
mainTx.wait();
|
|
186
|
+
return [4 /*yield*/, (0, exports.checkTransactionStatusSync)(requestId, mainTx.hash, client)];
|
|
187
|
+
case 6:
|
|
188
|
+
status = _a.sent();
|
|
189
|
+
return [2 /*return*/, status];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); };
|
|
193
|
+
exports.executeEvmRoute = executeEvmRoute;
|
|
194
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/services/executor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,0DAKkC;AAClC,4CAAwC;AAExC,SAAgB,qBAAqB,CACnC,KAAqB,EACrB,SAAkB;IAElB,IAAM,QAAQ,GACZ,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;QAClD,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,CAAC,CAAC,IAAI,CAAA;IACV,IAAM,aAAa,yBACd,KAAK,KACR,QAAQ,UAAA,GACT,CAAA;IACD,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI;QAAE,EAAE,yBAAQ,EAAE,KAAE,IAAI,EAAE,aAAa,CAAC,IAAI,GAAE,CAAA;IAClE,IAAI,SAAS,EAAE;QACb,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS;YAAE,EAAE,yBAAQ,EAAE,KAAE,EAAE,EAAE,aAAa,CAAC,SAAS,GAAE,CAAA;QAC1E,IAAI,CAAC,CAAC,aAAa,CAAC,WAAW;YAC7B,EAAE,yBAAQ,EAAE,KAAE,IAAI,EAAE,aAAa,CAAC,WAAW,GAAE,CAAA;KAClD;SAAM;QACL,IAAI,CAAC,CAAC,aAAa,CAAC,I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BAC/B,MAAM,IAAI,KAAK,CACb,yBAAkB,aAAa,6CAAmC,SAAS,MAAG,CAC/E,CAAA;iBACF;qBACG,CAAA,CAAC,CAAC,cAAc,CAAC,SAAS,IAAI,CAAC,CAAC,cAAc,CAAC,WAAW,CAAA,EAA1D,wBAA0D;gBACtD,aAAa,GAAG,qBAAqB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;gBAC/C,qBAAM,MAAM,CAAC,eAAe,CAAC,aAAa,CAAC,EAAA;;gBAAvD,SAAS,GAAG,SAA2C;gBAC7D,SAAS,CAAC,IAAI,EAAE,CAAA;gBAChB,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;;oBAEtC,qBAAM,MAAM,CAAC,UAAU,EAAE,EAAA;;gBAAzC,aAAa,GAAG,SAAyB,CAAA;gBACzC,IAAI,aAAa,KAAK,SAAS,EAAE;oBAC/B,MAAM,IAAI,KAAK,CACb,yBAAkB,aAAa,6CAAmC,SAAS,MAAG,CAC/E,CAAA;iBACF;gBACK,UAAU,GAAG,qBAAqB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;gBAChD,qBAAM,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EAAA;;gBAAjD,MAAM,GAAG,SAAwC;gBACvD,MAAM,CAAC,IAAI,EAAE,CAAA;gBACE,qBAAM,IAAA,kCAA0B,EAC7C,SAAS,EACT,MAAM,CAAC,IAAI,EACX,MAAM,CACP,EAAA;;gBAJK,MAAM,GAAG,SAId;gBACD,sBAAO,MAAM,EAAA;;;KACd,CAAA;AAxCY,QAAA,eAAe,mBAwC3B"}
|
|
@@ -6,7 +6,7 @@ import type { Asset, Amount } from './common';
|
|
|
6
6
|
* @property {Asset} asset
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type AssetAndAmount = {
|
|
10
10
|
amount: Amount;
|
|
11
11
|
asset: Asset;
|
|
12
12
|
};
|
|
@@ -20,7 +20,7 @@ export declare type AssetAndAmount = {
|
|
|
20
20
|
* @property {string} explorerUrl - The explorer url of the wallet, example: https://bscscan.com/address/0x7a3....fdsza
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type WalletDetail = {
|
|
24
24
|
failed: boolean;
|
|
25
25
|
blockChain: string;
|
|
26
26
|
address: string;
|
|
@@ -33,7 +33,7 @@ export declare type WalletDetail = {
|
|
|
33
33
|
* @property {WalletDetail[]} wallets - list of wallet assets
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
|
-
export
|
|
36
|
+
export type WalletDetailsResponse = {
|
|
37
37
|
wallets: WalletDetail[];
|
|
38
38
|
};
|
|
39
39
|
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -1 +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,
|
|
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,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,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,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { SwapperMetaDto, Token } from './meta';
|
|
|
7
7
|
* @property {string} symbol - The display token symbol, e.g. USDT, BTC, ...
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type Asset = {
|
|
11
11
|
blockchain: string;
|
|
12
12
|
address: string | null;
|
|
13
13
|
symbol: string;
|
|
@@ -21,7 +21,7 @@ export declare function assetToString(asset: Asset): string;
|
|
|
21
21
|
* @property {number} decimals - The decimals of the token in blockchain, example: 18
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export type Amount = {
|
|
25
25
|
amount: string;
|
|
26
26
|
decimals: number;
|
|
27
27
|
};
|
|
@@ -34,7 +34,7 @@ export declare type Amount = {
|
|
|
34
34
|
* @property {string} amount - The human readable amount of fee, example: 0.004
|
|
35
35
|
*
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type SwapFee = {
|
|
38
38
|
name: string;
|
|
39
39
|
token: Token;
|
|
40
40
|
expenseType: 'FROM_SOURCE_WALLET' | 'DECREASE_FROM_OUTPUT' | 'FROM_DESTINATION_WALLET';
|
|
@@ -44,7 +44,7 @@ export declare type SwapFee = {
|
|
|
44
44
|
* Type of the swapper
|
|
45
45
|
*
|
|
46
46
|
*/
|
|
47
|
-
export
|
|
47
|
+
export type SwapperType = 'BRIDGE' | 'DEX' | 'AGGREGATOR';
|
|
48
48
|
/**
|
|
49
49
|
* A quote path from asset x (from) to asset y (to)
|
|
50
50
|
*
|
|
@@ -53,14 +53,16 @@ export declare type SwapperType = 'BRIDGE' | 'DEX' | 'AGGREGATOR';
|
|
|
53
53
|
* @property {SwapperMetaDto} swapper - Swapper for this path
|
|
54
54
|
* @property {SwapperType} swapperType - Type of swapper
|
|
55
55
|
* @property {string} expectedOutput - Expected output
|
|
56
|
+
* @property {number} estimatedTimeInSeconds - Expected duration
|
|
56
57
|
*
|
|
57
58
|
*/
|
|
58
|
-
export
|
|
59
|
+
export type QuotePath = {
|
|
59
60
|
from: Token;
|
|
60
61
|
to: Token;
|
|
61
62
|
swapper: SwapperMetaDto;
|
|
62
63
|
swapperType: SwapperType;
|
|
63
64
|
expectedOutput: string;
|
|
65
|
+
estimatedTimeInSeconds: number;
|
|
64
66
|
};
|
|
65
67
|
/**
|
|
66
68
|
* Limitations on input amount for requested route
|
|
@@ -70,7 +72,7 @@ export declare type QuotePath = {
|
|
|
70
72
|
* @property {'INCLUSIVE' | 'EXCLUSIVE'} type - type of limitation
|
|
71
73
|
*
|
|
72
74
|
*/
|
|
73
|
-
export
|
|
75
|
+
export type AmountRestriction = {
|
|
74
76
|
min: string | null;
|
|
75
77
|
max: string | null;
|
|
76
78
|
type: 'INCLUSIVE' | 'EXCLUSIVE';
|
|
@@ -78,25 +80,28 @@ export declare type AmountRestriction = {
|
|
|
78
80
|
/**
|
|
79
81
|
* A step of a multi-step swap route
|
|
80
82
|
*
|
|
81
|
-
* @property {
|
|
82
|
-
*
|
|
83
|
+
* @property {Token} from - Source token
|
|
84
|
+
* @property {Token} to - Destination token
|
|
85
|
+
* @property {string} outputAmount - The estimation of Rango from output amount for Y
|
|
86
|
+
* @property {string} outputAmountMin - The estimation of Rango from output amount for Y
|
|
87
|
+
* @property {number | null} outputAmountUsd - The estimation of Rango from output usd value for Y
|
|
83
88
|
* @property {SwapperMetaDto} swapper - Swapper suggested for this path
|
|
84
|
-
*
|
|
85
89
|
* @property {QuotePath[] | null} path - The internal routing of this step showing how the initial swap request will
|
|
86
90
|
* be split and executed. This can be used for previewing purpose to give the user a sense of what's going to happen.
|
|
87
91
|
* Null indicates that there is no internal mechanism and swapping is simple and straight-forward.
|
|
88
|
-
*
|
|
89
92
|
* @property {SwapFee[]} fee - List of fees that are taken from user in this step
|
|
90
|
-
*
|
|
91
93
|
* @property {AmountRestriction | null} amountRestriction - restrictions on input amount. This field is informational
|
|
92
94
|
* and there is no need to apply it in client-side
|
|
93
|
-
*
|
|
94
95
|
* @property {number} estimatedTimeInSeconds - The estimated time (in seconds) that this step might take, beware that
|
|
95
96
|
* this number is just an estimation and should be used only for user preview, example: 15
|
|
96
97
|
*
|
|
97
98
|
*/
|
|
98
|
-
export
|
|
99
|
+
export type QuoteSimulationResult = {
|
|
100
|
+
from: Token;
|
|
101
|
+
to: Token;
|
|
99
102
|
outputAmount: string;
|
|
103
|
+
outputAmountMin: string;
|
|
104
|
+
outputAmountUsd: number | null;
|
|
100
105
|
swapper: SwapperMetaDto;
|
|
101
106
|
path: QuotePath[] | null;
|
|
102
107
|
fee: SwapFee[];
|
|
@@ -113,7 +118,7 @@ export declare type QuoteSimulationResult = {
|
|
|
113
118
|
* required by some javascript wallets
|
|
114
119
|
*
|
|
115
120
|
*/
|
|
116
|
-
export
|
|
121
|
+
export type AssetWithTicker = {
|
|
117
122
|
blockchain: string;
|
|
118
123
|
address: string | null;
|
|
119
124
|
symbol: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/types/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9C;;;;;;;GAOG;AACH,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/types/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9C;;;;;;;GAOG;AACH,MAAM,MAAM,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,CAIlD;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,E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G;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf,CAAA"}
|
package/lib/types/api/meta.d.ts
CHANGED
|
@@ -1,58 +1,172 @@
|
|
|
1
1
|
import type { Asset, SwapperType } from './common';
|
|
2
2
|
import { TransactionType } from './transactions';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* EVM Chain Info
|
|
5
|
+
*
|
|
6
|
+
* @property {string} chainName - Chain name, e.g. Polygon Mainnet
|
|
7
|
+
* @property {name: string, symbol: string, decimals: null} nativeCurrency
|
|
8
|
+
* @property {string[]} rpcUrls - e.g. "https://polygon-rpc.com"
|
|
9
|
+
* @property {string[]} blockExplorerUrls - e.g. "https://polygonscan.com"
|
|
10
|
+
* @property {string} addressUrl - Explorer address base url for this blockchain,
|
|
11
|
+
* e.g. "https://bscscan.com/address/{wallet}"
|
|
12
|
+
* @property {string} transactionUrl - Explorer transaction base url for this blockchain,
|
|
13
|
+
* e.g. "https://bscscan.com/tx/{txHash}"
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export type EVMChainInfo = {
|
|
17
|
+
chainName: string;
|
|
18
|
+
nativeCurrency: {
|
|
19
|
+
name: string;
|
|
20
|
+
symbol: string;
|
|
21
|
+
decimals: number;
|
|
22
|
+
};
|
|
23
|
+
rpcUrls: string[];
|
|
24
|
+
blockExplorerUrls: string[];
|
|
25
|
+
addressUrl: string;
|
|
26
|
+
transactionUrl: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Cosmos Chain Info - Used for adding experimental chains to keplr if needed
|
|
30
|
+
*
|
|
31
|
+
* @see https://github.com/osmosis-labs/osmosis-frontend/blob/0b88e39740cb087be576f464bfcd6cc2971ed2fd/packages/web/config/chain-infos.ts
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
export type CosmosChainInfo = {
|
|
35
|
+
experimental: boolean;
|
|
36
|
+
rpc: string;
|
|
37
|
+
rest: string;
|
|
38
|
+
cosmostationLcdUrl: string | null;
|
|
39
|
+
cosmostationApiUrl: string | null;
|
|
40
|
+
cosmostationDenomTracePath: string;
|
|
41
|
+
mintScanName: string | null;
|
|
42
|
+
chainName: string;
|
|
43
|
+
stakeCurrency: {
|
|
44
|
+
coinDenom: string;
|
|
45
|
+
coinMinimalDenom: string;
|
|
46
|
+
coinDecimals: number;
|
|
47
|
+
coinGeckoId: string;
|
|
48
|
+
coinImageUrl: string;
|
|
49
|
+
};
|
|
50
|
+
bip44: {
|
|
51
|
+
coinType: number;
|
|
52
|
+
};
|
|
53
|
+
bech32Config: {
|
|
54
|
+
bech32PrefixAccAddr: string;
|
|
55
|
+
bech32PrefixAccPub: string;
|
|
56
|
+
bech32PrefixValAddr: string;
|
|
57
|
+
bech32PrefixValPub: string;
|
|
58
|
+
bech32PrefixConsAddr: string;
|
|
59
|
+
bech32PrefixConsPub: string;
|
|
60
|
+
};
|
|
61
|
+
currencies: {
|
|
62
|
+
coinDenom: string;
|
|
63
|
+
coinMinimalDenom: string;
|
|
64
|
+
coinDecimals: number;
|
|
65
|
+
coinGeckoId: string;
|
|
66
|
+
coinImageUrl: string;
|
|
67
|
+
}[];
|
|
68
|
+
feeCurrencies: {
|
|
69
|
+
coinDenom: string;
|
|
70
|
+
coinMinimalDenom: string;
|
|
71
|
+
coinDecimals: number;
|
|
72
|
+
coinGeckoId: string;
|
|
73
|
+
coinImageUrl: string;
|
|
74
|
+
}[];
|
|
75
|
+
features: string[];
|
|
76
|
+
explorerUrlToTx: string;
|
|
77
|
+
gasPriceStep: {
|
|
78
|
+
low: number;
|
|
79
|
+
average: number;
|
|
80
|
+
high: number;
|
|
81
|
+
} | null;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Blockchain Meta Information
|
|
5
85
|
*
|
|
6
86
|
* @property {string} name - Unique name of blockchain, this field is used in all endpoints as the identifier
|
|
7
87
|
* @property {number} defaultDecimals - The default decimals of blockchain, do not use it in computations, use Token.decimals instead
|
|
8
88
|
* @property {Asset[]} feeAssets - List of assets that can be used as fee in this blockchain
|
|
9
89
|
* @property {string[]} addressPatterns - List of all regex patterns for wallet addresses of this blockchain, can be
|
|
10
90
|
* used for input validation, example: [ "^(0x)[0-9A-Fa-f]{40}$" ]
|
|
11
|
-
* @property {
|
|
12
|
-
* @property {string
|
|
91
|
+
* @property {string} logo - Logo of the blockchain
|
|
92
|
+
* @property {string} displayName - Display name for the blockchain
|
|
93
|
+
* @property {string} shortName - Short name for the blockchain
|
|
94
|
+
* @property {string} color - Suggested color for the blockchain
|
|
95
|
+
* @property {boolean} enabled - Is blockchain enabled or not in Rango
|
|
96
|
+
* @property {TransactionType} type - Type of the blockchain
|
|
97
|
+
* @property {string | null} chainId - e.g. "0xa86a" for Avax, "osmosis-1" for Osmosis, etc.
|
|
98
|
+
* @property {EVMChainInfo | CosmosChainInfo | null} info - Chain specific information
|
|
13
99
|
*
|
|
14
100
|
*/
|
|
15
|
-
export
|
|
101
|
+
export type BlockchainMetaBase = {
|
|
16
102
|
name: string;
|
|
103
|
+
shortName: string;
|
|
104
|
+
displayName: string;
|
|
17
105
|
defaultDecimals: number;
|
|
18
106
|
feeAssets: Asset[];
|
|
19
107
|
addressPatterns: string[];
|
|
20
|
-
|
|
108
|
+
logo: string;
|
|
109
|
+
color: string;
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
type: TransactionType;
|
|
21
112
|
chainId: string | null;
|
|
113
|
+
info: EVMChainInfo | CosmosChainInfo | null;
|
|
22
114
|
};
|
|
115
|
+
export interface EvmBlockchainMeta extends BlockchainMetaBase {
|
|
116
|
+
type: TransactionType.EVM;
|
|
117
|
+
chainId: string;
|
|
118
|
+
info: EVMChainInfo;
|
|
119
|
+
}
|
|
120
|
+
export interface CosmosBlockchainMeta extends BlockchainMetaBase {
|
|
121
|
+
type: TransactionType.COSMOS;
|
|
122
|
+
chainId: string;
|
|
123
|
+
info: CosmosChainInfo;
|
|
124
|
+
}
|
|
125
|
+
export interface TransferBlockchainMeta extends BlockchainMetaBase {
|
|
126
|
+
type: TransactionType.TRANSFER;
|
|
127
|
+
chainId: null;
|
|
128
|
+
info: null;
|
|
129
|
+
}
|
|
130
|
+
export type BlockchainMeta = EvmBlockchainMeta | CosmosBlockchainMeta | TransferBlockchainMeta;
|
|
23
131
|
/**
|
|
24
132
|
* Metadata of Swapper
|
|
25
133
|
*
|
|
26
134
|
* @property {string} id - Unique identifier for the swapper
|
|
27
135
|
* @property {string} title - Display name for the swapper
|
|
28
136
|
* @property {string} logo - Icon logo for the swapper
|
|
137
|
+
* @property {string} swapperGroup - Group name for swapper
|
|
29
138
|
* @property {SwapperType[]} types - Type of the transaction supported by the swapper
|
|
30
139
|
*
|
|
31
140
|
*/
|
|
32
|
-
export
|
|
141
|
+
export type SwapperMetaDto = {
|
|
33
142
|
id: string;
|
|
34
143
|
title: string;
|
|
35
144
|
logo: string;
|
|
145
|
+
swapperGroup: string;
|
|
36
146
|
types: SwapperType[];
|
|
37
147
|
};
|
|
38
148
|
/**
|
|
39
149
|
* All metadata info for a token, unique by (blockchain, symbol, address) tuple
|
|
40
150
|
*
|
|
41
151
|
* @property {string} blockchain - The blockchain which this token belongs to
|
|
152
|
+
* @property {string | null} chainId - The chainId which this token belongs to, e.g. 1 for ETH, 56 for BSC and ...
|
|
42
153
|
* @property {string | null} address - Smart contract address of token, null for native tokens
|
|
43
154
|
* @property {string} symbol - The token symbol, e.g: ADA
|
|
44
155
|
* @property {string} name - The token name, e.g: Binance Pegged ETH
|
|
45
156
|
* @property {number} decimals - Decimals of token in blockchain, example: 18
|
|
46
157
|
* @property {string} image - Url of its image, example: https://api.rango.exchange/tokens/ETH/ETH.png
|
|
158
|
+
* @property {string | decimals} usdPrice - The token unit price
|
|
47
159
|
*
|
|
48
160
|
*/
|
|
49
|
-
export
|
|
161
|
+
export type Token = {
|
|
50
162
|
blockchain: string;
|
|
163
|
+
chainId: string | null;
|
|
51
164
|
address: string | null;
|
|
52
165
|
symbol: string;
|
|
53
166
|
name: string;
|
|
54
167
|
decimals: number;
|
|
55
168
|
image: string;
|
|
169
|
+
usdPrice: string | null;
|
|
56
170
|
};
|
|
57
171
|
/**
|
|
58
172
|
* Metadata info for all blockchains and tokens supported
|
|
@@ -62,7 +176,7 @@ export declare type Token = {
|
|
|
62
176
|
* @property {SwapperMetaDto[]} swappers - List of all DEXes & Bridges
|
|
63
177
|
*
|
|
64
178
|
*/
|
|
65
|
-
export
|
|
179
|
+
export type MetaResponse = {
|
|
66
180
|
blockchains: BlockchainMeta[];
|
|
67
181
|
tokens: Token[];
|
|
68
182
|
swappers: SwapperMetaDto[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/types/api/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/types/api/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,iBAAiB,EAAE,MAAM,EAAE,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;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AA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,cAAc,EAAE,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC3B,CAAA"}
|
|
@@ -14,7 +14,7 @@ import type { Asset, QuoteSimulationResult } from './common';
|
|
|
14
14
|
* will filter routes that are not possible to be called from a contract
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type QuoteRequest = {
|
|
18
18
|
from: Asset;
|
|
19
19
|
to: Asset;
|
|
20
20
|
amount: string;
|
|
@@ -30,13 +30,15 @@ export declare type QuoteRequest = {
|
|
|
30
30
|
*
|
|
31
31
|
* @property {string} requestId - The unique requestId which is generated for this request by the server. It should be
|
|
32
32
|
* passed down to all other endpoints if this swap continues on. e.g. d10657ce-b13a-405c-825b-b47f8a5016ad
|
|
33
|
-
* @property {string} resultType - Type of result (OK or error type)
|
|
33
|
+
* @property {string} resultType - Type of result for route (OK or error type)
|
|
34
34
|
* @property {QuoteSimulationResult | null} route - Suggested route
|
|
35
|
+
* @property {string | null} error - Error message
|
|
35
36
|
*
|
|
36
37
|
*/
|
|
37
|
-
export
|
|
38
|
+
export type QuoteResponse = {
|
|
38
39
|
requestId: string;
|
|
39
40
|
resultType: 'OK' | 'HIGH_IMPACT' | 'INPUT_LIMIT_ISSUE' | 'NO_ROUTE';
|
|
40
41
|
route: QuoteSimulationResult | null;
|
|
42
|
+
error: string | null;
|
|
41
43
|
};
|
|
42
44
|
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/types/api/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAE5D;;;;;;;;;;;;;;GAcG;AACH,
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/types/api/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IACT,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,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;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA"}
|
|
@@ -17,7 +17,7 @@ export declare enum TransactionType {
|
|
|
17
17
|
* other. Example: Inbound, Outbound, Bridge, or null
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export type SwapExplorerUrl = {
|
|
21
21
|
description: string | null;
|
|
22
22
|
url: string;
|
|
23
23
|
};
|
|
@@ -28,7 +28,7 @@ export declare type SwapExplorerUrl = {
|
|
|
28
28
|
* @property {number} txId - Tx hash that wallet returned, example: 0xa1a37ce2063c4764da27d990a22a0c89ed8ac585286a77a...
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
|
-
export
|
|
31
|
+
export type StatusRequest = {
|
|
32
32
|
requestId: string;
|
|
33
33
|
txId: string;
|
|
34
34
|
};
|
|
@@ -53,7 +53,7 @@ export declare type StatusRequest = {
|
|
|
53
53
|
* will filter routes that are not possible to be called from a contract
|
|
54
54
|
*
|
|
55
55
|
*/
|
|
56
|
-
export
|
|
56
|
+
export type SwapRequest = {
|
|
57
57
|
from: Asset;
|
|
58
58
|
to: Asset;
|
|
59
59
|
amount: string;
|
|
@@ -80,7 +80,7 @@ export declare type SwapRequest = {
|
|
|
80
80
|
* @property {[key: string]: string} data - A list of key-value for extra details
|
|
81
81
|
*
|
|
82
82
|
*/
|
|
83
|
-
export
|
|
83
|
+
export type ReportTransactionRequest = {
|
|
84
84
|
requestId: string;
|
|
85
85
|
eventType: 'TX_FAIL';
|
|
86
86
|
data: {
|
|
@@ -103,7 +103,7 @@ export declare enum TransactionStatus {
|
|
|
103
103
|
* @property {string} type - type of received token
|
|
104
104
|
*
|
|
105
105
|
*/
|
|
106
|
-
export
|
|
106
|
+
export type StatusOutput = {
|
|
107
107
|
amount: string;
|
|
108
108
|
receivedToken: Token;
|
|
109
109
|
type: 'REVERTED_TO_INPUT' | 'MIDDLE_ASSET_IN_SRC' | 'MIDDLE_ASSET_IN_DEST' | 'DESIRED_OUTPUT';
|
|
@@ -125,7 +125,7 @@ export declare type StatusOutput = {
|
|
|
125
125
|
* @property {number | null} destTokenPrice - destination token price
|
|
126
126
|
*
|
|
127
127
|
*/
|
|
128
|
-
export
|
|
128
|
+
export type BridgeData = {
|
|
129
129
|
srcChainId: number;
|
|
130
130
|
srcTxHash: string | null;
|
|
131
131
|
srcToken: string | null;
|
|
@@ -151,7 +151,7 @@ export declare type BridgeData = {
|
|
|
151
151
|
* @property {BridgeData | null} bridgeData - Status of bridge
|
|
152
152
|
*
|
|
153
153
|
*/
|
|
154
|
-
export
|
|
154
|
+
export type StatusResponse = {
|
|
155
155
|
status: TransactionStatus | null;
|
|
156
156
|
error: string | null;
|
|
157
157
|
output: StatusOutput | null;
|
|
@@ -164,7 +164,7 @@ export declare type StatusResponse = {
|
|
|
164
164
|
* @property {boolean} isApproved - A flag which indicates that the approve tx is done or not
|
|
165
165
|
*
|
|
166
166
|
*/
|
|
167
|
-
export
|
|
167
|
+
export type CheckApprovalResponse = {
|
|
168
168
|
isApproved: boolean;
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
@@ -179,7 +179,7 @@ export declare type CheckApprovalResponse = {
|
|
|
179
179
|
* @property {EvmTransaction | CosmosTransaction | Transfer | null} transaction - Transaction data
|
|
180
180
|
*
|
|
181
181
|
*/
|
|
182
|
-
export
|
|
182
|
+
export type SwapResponse = {
|
|
183
183
|
requestId: string;
|
|
184
184
|
resultType: 'OK' | 'HIGH_IMPACT' | 'INPUT_LIMIT_ISSUE' | 'NO_ROUTE';
|
|
185
185
|
route: QuoteSimulationResult | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/types/api/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,C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,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,WAAW,EAAE,eAAe,EAAE,GAAG,IAAI,CAAA;IACrC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAA;CAC9B,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,IAAI,GAAG,aAAa,GAAG,mBAAmB,GAAG,UAAU,CAAA;IACnE,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,EAAE,EAAE,cAAc,GAAG,iBAAiB,GAAG,QAAQ,GAAG,IAAI,CAAA;CACzD,CAAA"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import type { AssetWithTicker } from '../common';
|
|
2
|
-
import {
|
|
2
|
+
import { CosmosBlockchainMeta } from '../meta';
|
|
3
|
+
import { TransactionType } from '../transactions';
|
|
3
4
|
/**
|
|
4
5
|
* CosmosCoin representing fee coins
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
+
export type CosmosCoin = {
|
|
7
8
|
amount: string;
|
|
8
9
|
denom: string;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* CosmosStdFee representing fee for cosmos transaction
|
|
12
13
|
*/
|
|
13
|
-
export
|
|
14
|
+
export type CosmosStdFee = {
|
|
14
15
|
amount: CosmosCoin[];
|
|
15
16
|
gas: string;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
19
|
* Main transaction object for COSMOS type transactions (including Terra, Osmosis, ...)
|
|
19
20
|
*/
|
|
20
|
-
export
|
|
21
|
+
export type CosmosMessage = {
|
|
21
22
|
signType: 'AMINO' | 'DIRECT';
|
|
22
23
|
sequence: string | null;
|
|
23
24
|
source: number | null;
|
|
@@ -40,7 +41,7 @@ export declare type CosmosMessage = {
|
|
|
40
41
|
* @property {string} recipient - The recipient address of transaction
|
|
41
42
|
*
|
|
42
43
|
*/
|
|
43
|
-
export
|
|
44
|
+
export type CosmosRawTransferData = {
|
|
44
45
|
amount: string;
|
|
45
46
|
asset: AssetWithTicker;
|
|
46
47
|
decimals: number;
|
|
@@ -52,7 +53,7 @@ export declare type CosmosRawTransferData = {
|
|
|
52
53
|
* A Cosmos transaction, child of GenericTransaction
|
|
53
54
|
*
|
|
54
55
|
* @property {TransactionType} type - This fields equals to TransactionType.COSMOS for all CosmosTransactions
|
|
55
|
-
* @property {
|
|
56
|
+
* @property {CosmosBlockchainMeta} blockChain - The blockchain that this transaction will be executed in, same as the input blockchain of creating transaction
|
|
56
57
|
* @property {string} fromWalletAddress - Address of wallet that this transaction should be executed in, same as the create transaction request's input
|
|
57
58
|
* @property {CosmosMessage} data - Transaction data
|
|
58
59
|
* @property {CosmosRawTransferData} rawTransfer - An alternative to CosmosMessage object for the cosmos wallets that do not support generic Cosmos messages
|
|
@@ -60,7 +61,7 @@ export declare type CosmosRawTransferData = {
|
|
|
60
61
|
*/
|
|
61
62
|
export interface CosmosTransaction {
|
|
62
63
|
type: TransactionType;
|
|
63
|
-
blockChain:
|
|
64
|
+
blockChain: CosmosBlockchainMeta;
|
|
64
65
|
fromWalletAddress: string;
|
|
65
66
|
data: CosmosMessage;
|
|
66
67
|
rawTransfer: CosmosRawTransferData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/cosmos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/cosmos.ts"],"names":[],"mappings":"AAAA,OAAO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AM,CAAA;IACzB,IAAI,EAAE,aAAa,CAAA;IACnB,WAAW,EAAE,qBAAqB,CAAA;CACnC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EvmBlockchainMeta } from '../meta';
|
|
2
|
+
import { TransactionType } from '../transactions';
|
|
2
3
|
/**
|
|
3
4
|
* The transaction object for all EVM-based blockchains, including Ethereum, BSC, Polygon, Harmony, etc
|
|
4
5
|
*
|
|
5
6
|
* @property {TransactionType} type - This fields equals to TransactionType.EVM for all EVMTransactions
|
|
6
|
-
* @property {
|
|
7
|
+
* @property {EvmBlockchainMeta} blockChain - The blockchain info that this transaction is going to run in
|
|
7
8
|
* @property {string | null} from - The source wallet address, it can be null
|
|
8
9
|
* @property {string} approveTo - Address of source token erc20 contract for increasing approve amount
|
|
9
10
|
* @property {string | null} approveData - The data of approve transaction
|
|
@@ -16,7 +17,7 @@ import { TransactionType } from "../transactions";
|
|
|
16
17
|
*/
|
|
17
18
|
export interface EvmTransaction {
|
|
18
19
|
type: TransactionType;
|
|
19
|
-
blockChain:
|
|
20
|
+
blockChain: EvmBlockchainMeta;
|
|
20
21
|
from: string | null;
|
|
21
22
|
approveTo: string | null;
|
|
22
23
|
approveData: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/evm.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,eAAe,CAAA;IACrB,UAAU,EAAE,iBAAiB,CAAA;IAC7B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AssetWithTicker } from '../common';
|
|
2
|
-
import {
|
|
2
|
+
import { TransferBlockchainMeta } from '../meta';
|
|
3
|
+
import { TransactionType } from '../transactions';
|
|
3
4
|
/**
|
|
4
5
|
* TransferTransaction. This type of transaction is used for non-EVM and non-Cosmos blockchains including BTC, LTC, BCH
|
|
5
6
|
*
|
|
6
7
|
* @property {TransactionType} type - This fields equals to TransactionType.TRANSFER for all TransferTransactions
|
|
8
|
+
* @property {TransferBlockchainMeta} blockChain - The blockchain that this transaction will be executed in, same as the input blockchain of creating transaction
|
|
7
9
|
* @property {string} method - The method that should be passed to wallet. examples: deposit, transfer
|
|
8
10
|
* @property {AssetWithTicker} asset
|
|
9
11
|
* @property {string} amount - The machine-readable amount of transaction, example: 1000000000000000000
|
|
@@ -15,6 +17,7 @@ import { TransactionType } from "../transactions";
|
|
|
15
17
|
*/
|
|
16
18
|
export interface Transfer {
|
|
17
19
|
type: TransactionType;
|
|
20
|
+
blockChain: TransferBlockchainMeta;
|
|
18
21
|
method: string;
|
|
19
22
|
asset: AssetWithTicker;
|
|
20
23
|
amount: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,eAAe,CAAA;IACrB,UAAU,EAAE,sBAAsB,CAAA;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB"}
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA"}
|
package/lib/types/index.js
CHANGED
|
@@ -20,4 +20,5 @@ __exportStar(require("./api/meta"), exports);
|
|
|
20
20
|
__exportStar(require("./api/routing"), exports);
|
|
21
21
|
__exportStar(require("./api/transactions"), exports);
|
|
22
22
|
__exportStar(require("./api/txs"), exports);
|
|
23
|
+
__exportStar(require("./utils/errors"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,+CAA4B;AAC5B,6CAA0B;AAC1B,gDAA6B;AAC7B,qDAAkC;AAClC,4CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,+CAA4B;AAC5B,6CAA0B;AAC1B,gDAA6B;AAC7B,qDAAkC;AAClC,4CAAyB;AACzB,iDAA8B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const MetamaskErrorCodes: {
|
|
2
|
+
rpc: {
|
|
3
|
+
invalidInput: number;
|
|
4
|
+
resourceNotFound: number;
|
|
5
|
+
resourceUnavailable: number;
|
|
6
|
+
transactionRejected: number;
|
|
7
|
+
methodNotSupported: number;
|
|
8
|
+
limitExceeded: number;
|
|
9
|
+
parse: number;
|
|
10
|
+
invalidRequest: number;
|
|
11
|
+
methodNotFound: number;
|
|
12
|
+
invalidParams: number;
|
|
13
|
+
internal: number;
|
|
14
|
+
};
|
|
15
|
+
provider: {
|
|
16
|
+
userRejectedRequest: number;
|
|
17
|
+
unauthorized: number;
|
|
18
|
+
unsupportedMethod: number;
|
|
19
|
+
disconnected: number;
|
|
20
|
+
chainDisconnected: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/types/utils/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;CAqB9B,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetamaskErrorCodes = void 0;
|
|
4
|
+
exports.MetamaskErrorCodes = {
|
|
5
|
+
rpc: {
|
|
6
|
+
invalidInput: -32000,
|
|
7
|
+
resourceNotFound: -32001,
|
|
8
|
+
resourceUnavailable: -32002,
|
|
9
|
+
transactionRejected: -32003,
|
|
10
|
+
methodNotSupported: -32004,
|
|
11
|
+
limitExceeded: -32005,
|
|
12
|
+
parse: -32700,
|
|
13
|
+
invalidRequest: -32600,
|
|
14
|
+
methodNotFound: -32601,
|
|
15
|
+
invalidParams: -32602,
|
|
16
|
+
internal: -32603,
|
|
17
|
+
},
|
|
18
|
+
provider: {
|
|
19
|
+
userRejectedRequest: 4001,
|
|
20
|
+
unauthorized: 4100,
|
|
21
|
+
unsupportedMethod: 4200,
|
|
22
|
+
disconnected: 4900,
|
|
23
|
+
chainDisconnected: 4901,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/types/utils/errors.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAChC,GAAG,EAAE;QACH,YAAY,EAAE,CAAC,KAAK;QACpB,gBAAgB,EAAE,CAAC,KAAK;QACxB,mBAAmB,EAAE,CAAC,KAAK;QAC3B,mBAAmB,EAAE,CAAC,KAAK;QAC3B,kBAAkB,EAAE,CAAC,KAAK;QAC1B,aAAa,EAAE,CAAC,KAAK;QACrB,KAAK,EAAE,CAAC,KAAK;QACb,cAAc,EAAE,CAAC,KAAK;QACtB,cAAc,EAAE,CAAC,KAAK;QACtB,aAAa,EAAE,CAAC,KAAK;QACrB,QAAQ,EAAE,CAAC,KAAK;KACjB;IACD,QAAQ,EAAE;QACR,mBAAmB,EAAE,IAAI;QACzB,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAAE,IAAI;QACvB,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAAE,IAAI;KACxB;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,UAAW,GAAG,QAwBvC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prettifyError = void 0;
|
|
4
|
+
var eth_rpc_errors_1 = require("eth-rpc-errors");
|
|
5
|
+
var errors_1 = require("../types/utils/errors");
|
|
6
|
+
var prettifyError = function (error) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
if (!error)
|
|
9
|
+
return error;
|
|
10
|
+
if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001))
|
|
11
|
+
return new Error('Transaction Rejected');
|
|
12
|
+
if (error && typeof error.code === 'number') {
|
|
13
|
+
if (Object.values(errors_1.MetamaskErrorCodes.provider).includes(error.code)) {
|
|
14
|
+
return new Error((0, eth_rpc_errors_1.getMessageFromCode)(error.code));
|
|
15
|
+
}
|
|
16
|
+
if (Object.values(errors_1.MetamaskErrorCodes.rpc).includes(error.code)) {
|
|
17
|
+
if (error.code === errors_1.MetamaskErrorCodes.rpc.internal &&
|
|
18
|
+
((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('underpriced')))
|
|
19
|
+
return new Error('Transaction underpriced');
|
|
20
|
+
if (((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('intrinsic gas too low')) ||
|
|
21
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('out of gas')))
|
|
22
|
+
return new Error('This Gas limit is low.');
|
|
23
|
+
return new Error((0, eth_rpc_errors_1.getMessageFromCode)(error.code));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (error.message)
|
|
27
|
+
return new Error(error.message);
|
|
28
|
+
return error;
|
|
29
|
+
};
|
|
30
|
+
exports.prettifyError = prettifyError;
|
|
31
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AACnD,gDAA0D;AAEnD,IAAM,aAAa,GAAG,UAAC,KAAU;;IACtC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IACxB,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,iBAAiB,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QACzE,OAAO,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IAC1C,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC3C,IAAI,MAAM,CAAC,MAAM,CAAC,2BAAkB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YACnE,OAAO,IAAI,KAAK,CAAC,IAAA,mCAAkB,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;SACjD;QACD,IAAI,MAAM,CAAC,MAAM,CAAC,2BAAkB,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC9D,IACE,KAAK,CAAC,IAAI,KAAK,2BAAkB,CAAC,GAAG,CAAC,QAAQ;iBAC9C,MAAA,KAAK,CAAC,OAAO,0CAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;gBAEtC,OAAO,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;YAC7C,IACE,CAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,QAAQ,CAAC,uBAAuB,CAAC;iBAChD,MAAA,KAAK,CAAC,OAAO,0CAAE,QAAQ,CAAC,YAAY,CAAC,CAAA;gBAErC,OAAO,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;YAC5C,OAAO,IAAI,KAAK,CAAC,IAAA,mCAAkB,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;SACjD;KACF;IACD,IAAI,KAAK,CAAC,OAAO;QAAE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAClD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAxBY,QAAA,aAAa,iBAwBzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/utils/promise.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAE/B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sleep = void 0;
|
|
4
|
+
function sleep(ms) {
|
|
5
|
+
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
6
|
+
}
|
|
7
|
+
exports.sleep = sleep;
|
|
8
|
+
//# sourceMappingURL=promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../../src/utils/promise.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,EAAvB,CAAuB,CAAC,CAAA;AAC1D,CAAC;AAFD,sBAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rango-sdk-basic",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Rango Exchange Basic SDK for dApps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib",
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"axios": "^0.24.0",
|
|
50
50
|
"bignumber.js": "^9.0.2",
|
|
51
|
+
"eth-rpc-errors": "^4.0.3",
|
|
52
|
+
"ethers": "^5.7.2",
|
|
51
53
|
"uuid": "^8.3.2"
|
|
52
54
|
},
|
|
53
55
|
"publishConfig": {
|