rango-sdk
Version:
Rango Exchange SDK for dApps
904 lines (891 loc) • 34 kB
JavaScript
import uuid from 'uuid-random';
import axios from 'axios';
function asyncGeneratorStep(n, t, e, r, o, a, c) {
try {
var i = n[a](c),
u = i.value;
} catch (n) {
return void e(n);
}
i.done ? t(u) : Promise.resolve(u).then(r, o);
}
function _asyncToGenerator(n) {
return function () {
var t = this,
e = arguments;
return new Promise(function (r, o) {
var a = n.apply(t, e);
function _next(n) {
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
}
function _throw(n) {
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
}
_next(void 0);
});
};
}
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _regeneratorRuntime() {
_regeneratorRuntime = function () {
return e;
};
var t,
e = {},
r = Object.prototype,
n = r.hasOwnProperty,
o = Object.defineProperty || function (t, e, r) {
t[e] = r.value;
},
i = "function" == typeof Symbol ? Symbol : {},
a = i.iterator || "@@iterator",
c = i.asyncIterator || "@@asyncIterator",
u = i.toStringTag || "@@toStringTag";
function define(t, e, r) {
return Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}), t[e];
}
try {
define({}, "");
} catch (t) {
define = function (t, e, r) {
return t[e] = r;
};
}
function wrap(t, e, r, n) {
var i = e && e.prototype instanceof Generator ? e : Generator,
a = Object.create(i.prototype),
c = new Context(n || []);
return o(a, "_invoke", {
value: makeInvokeMethod(t, r, c)
}), a;
}
function tryCatch(t, e, r) {
try {
return {
type: "normal",
arg: t.call(e, r)
};
} catch (t) {
return {
type: "throw",
arg: t
};
}
}
e.wrap = wrap;
var h = "suspendedStart",
l = "suspendedYield",
f = "executing",
s = "completed",
y = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var p = {};
define(p, a, function () {
return this;
});
var d = Object.getPrototypeOf,
v = d && d(d(values([])));
v && v !== r && n.call(v, a) && (p = v);
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
function defineIteratorMethods(t) {
["next", "throw", "return"].forEach(function (e) {
define(t, e, function (t) {
return this._invoke(e, t);
});
});
}
function AsyncIterator(t, e) {
function invoke(r, o, i, a) {
var c = tryCatch(t[r], t, o);
if ("throw" !== c.type) {
var u = c.arg,
h = u.value;
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
invoke("next", t, i, a);
}, function (t) {
invoke("throw", t, i, a);
}) : e.resolve(h).then(function (t) {
u.value = t, i(u);
}, function (t) {
return invoke("throw", t, i, a);
});
}
a(c.arg);
}
var r;
o(this, "_invoke", {
value: function (t, n) {
function callInvokeWithMethodAndArg() {
return new e(function (e, r) {
invoke(t, n, e, r);
});
}
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(e, r, n) {
var o = h;
return function (i, a) {
if (o === f) throw Error("Generator is already running");
if (o === s) {
if ("throw" === i) throw a;
return {
value: t,
done: !0
};
}
for (n.method = i, n.arg = a;;) {
var c = n.delegate;
if (c) {
var u = maybeInvokeDelegate(c, n);
if (u) {
if (u === y) continue;
return u;
}
}
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
if (o === h) throw o = s, n.arg;
n.dispatchException(n.arg);
} else "return" === n.method && n.abrupt("return", n.arg);
o = f;
var p = tryCatch(e, r, n);
if ("normal" === p.type) {
if (o = n.done ? s : l, p.arg === y) continue;
return {
value: p.arg,
done: n.done
};
}
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
}
};
}
function maybeInvokeDelegate(e, r) {
var n = r.method,
o = e.iterator[n];
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
var i = tryCatch(o, e.iterator, r.arg);
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
var a = i.arg;
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
}
function pushTryEntry(t) {
var e = {
tryLoc: t[0]
};
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
}
function resetTryEntry(t) {
var e = t.completion || {};
e.type = "normal", delete e.arg, t.completion = e;
}
function Context(t) {
this.tryEntries = [{
tryLoc: "root"
}], t.forEach(pushTryEntry, this), this.reset(!0);
}
function values(e) {
if (e || "" === e) {
var r = e[a];
if (r) return r.call(e);
if ("function" == typeof e.next) return e;
if (!isNaN(e.length)) {
var o = -1,
i = function next() {
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
return next.value = t, next.done = !0, next;
};
return i.next = i;
}
}
throw new TypeError(typeof e + " is not iterable");
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), o(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
var e = "function" == typeof t && t.constructor;
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
}, e.mark = function (t) {
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
}, e.awrap = function (t) {
return {
__await: t
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
return this;
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
void 0 === i && (i = Promise);
var a = new AsyncIterator(wrap(t, r, n, o), i);
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
return t.done ? t.value : a.next();
});
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
return this;
}), define(g, "toString", function () {
return "[object Generator]";
}), e.keys = function (t) {
var e = Object(t),
r = [];
for (var n in e) r.push(n);
return r.reverse(), function next() {
for (; r.length;) {
var t = r.pop();
if (t in e) return next.value = t, next.done = !1, next;
}
return next.done = !0, next;
};
}, e.values = values, Context.prototype = {
constructor: Context,
reset: function (e) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
},
stop: function () {
this.done = !0;
var t = this.tryEntries[0].completion;
if ("throw" === t.type) throw t.arg;
return this.rval;
},
dispatchException: function (e) {
if (this.done) throw e;
var r = this;
function handle(n, o) {
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
}
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
var i = this.tryEntries[o],
a = i.completion;
if ("root" === i.tryLoc) return handle("end");
if (i.tryLoc <= this.prev) {
var c = n.call(i, "catchLoc"),
u = n.call(i, "finallyLoc");
if (c && u) {
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
} else if (c) {
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
} else {
if (!u) throw Error("try statement without catch or finally");
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
}
}
}
},
abrupt: function (t, e) {
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
var o = this.tryEntries[r];
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
var i = o;
break;
}
}
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
var a = i ? i.completion : {};
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
},
complete: function (t, e) {
if ("throw" === t.type) throw t.arg;
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
},
finish: function (t) {
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
var r = this.tryEntries[e];
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
}
},
catch: function (t) {
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
var r = this.tryEntries[e];
if (r.tryLoc === t) {
var n = r.completion;
if ("throw" === n.type) {
var o = n.arg;
resetTryEntry(r);
}
return o;
}
}
throw Error("illegal catch attempt");
},
delegateYield: function (e, r, n) {
return this.delegate = {
iterator: values(e),
resultName: r,
nextLoc: n
}, "next" === this.method && (this.arg = t), y;
}
}, e;
}
var RangoClient = /*#__PURE__*/function () {
function RangoClient(apiKey, apiUrl) {
this.apiUrl = apiUrl || 'https://api.rango.exchange';
this.apiKey = apiKey;
try {
if (typeof window !== 'undefined') {
var deviceId = localStorage.getItem('deviceId');
if (deviceId) {
this.deviceId = deviceId;
} else {
var generatedId = uuid();
localStorage.setItem('deviceId', generatedId);
this.deviceId = generatedId;
}
} else {
this.deviceId = uuid();
}
} catch (e) {
this.deviceId = uuid();
}
this.httpService = axios.create({
baseURL: this.apiUrl
});
}
var _proto = RangoClient.prototype;
_proto.getAllMetadata = /*#__PURE__*/function () {
var _getAllMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(metaRequest, options) {
var _metaRequest$blockcha, _metaRequest$swappers, _metaRequest$swappers2, _metaRequest$transact;
var params, axiosResponse, reformatTokens, tokens, popularTokens;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
params = _extends({}, metaRequest, {
blockchains: metaRequest == null || (_metaRequest$blockcha = metaRequest.blockchains) == null ? void 0 : _metaRequest$blockcha.join(),
swappers: metaRequest == null || (_metaRequest$swappers = metaRequest.swappers) == null ? void 0 : _metaRequest$swappers.join(),
swappersGroups: metaRequest == null || (_metaRequest$swappers2 = metaRequest.swappersGroups) == null ? void 0 : _metaRequest$swappers2.join(),
transactionTypes: metaRequest == null || (_metaRequest$transact = metaRequest.transactionTypes) == null ? void 0 : _metaRequest$transact.join()
});
_context.next = 3;
return this.httpService.get("/meta/compact?apiKey=" + this.apiKey, _extends({
params: params
}, options));
case 3:
axiosResponse = _context.sent;
reformatTokens = function reformatTokens(tokens) {
return tokens.map(function (tm) {
return {
blockchain: tm.b,
symbol: tm.s,
image: tm.i,
address: tm.a || null,
usdPrice: tm.p || null,
isSecondaryCoin: tm.is || false,
coinSource: tm.c || null,
coinSourceUrl: tm.cu || null,
name: tm.n || null,
decimals: tm.d,
isPopular: tm.ip || false,
supportedSwappers: tm.ss || []
};
});
};
tokens = reformatTokens(axiosResponse.data.tokens);
popularTokens = reformatTokens(axiosResponse.data.popularTokens);
return _context.abrupt("return", _extends({}, axiosResponse.data, {
tokens: tokens,
popularTokens: popularTokens
}));
case 8:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function getAllMetadata(_x, _x2) {
return _getAllMetadata.apply(this, arguments);
}
return getAllMetadata;
}();
_proto.getBlockchains = /*#__PURE__*/function () {
var _getBlockchains = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this.httpService.get("/meta/blockchains?apiKey=" + this.apiKey, _extends({}, options));
case 2:
axiosResponse = _context2.sent;
return _context2.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
function getBlockchains(_x3) {
return _getBlockchains.apply(this, arguments);
}
return getBlockchains;
}();
_proto.getSwappers = /*#__PURE__*/function () {
var _getSwappers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return this.httpService.get("/meta/swappers?apiKey=" + this.apiKey, _extends({}, options));
case 2:
axiosResponse = _context3.sent;
return _context3.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context3.stop();
}
}, _callee3, this);
}));
function getSwappers(_x4) {
return _getSwappers.apply(this, arguments);
}
return getSwappers;
}();
_proto.getCustomToken = /*#__PURE__*/function () {
var _getCustomToken = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(customTokenRequest, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return this.httpService.get("/meta/custom-token?apiKey=" + this.apiKey, _extends({
params: customTokenRequest
}, options));
case 2:
axiosResponse = _context4.sent;
return _context4.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context4.stop();
}
}, _callee4, this);
}));
function getCustomToken(_x5, _x6) {
return _getCustomToken.apply(this, arguments);
}
return getCustomToken;
}();
_proto.searchCustomTokens = /*#__PURE__*/function () {
var _searchCustomTokens = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(searchCustomTokensRequest, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
while (1) switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return this.httpService.get("/meta/token/search?apiKey=" + this.apiKey, _extends({
params: searchCustomTokensRequest
}, options));
case 2:
axiosResponse = _context5.sent;
return _context5.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context5.stop();
}
}, _callee5, this);
}));
function searchCustomTokens(_x7, _x8) {
return _searchCustomTokens.apply(this, arguments);
}
return searchCustomTokens;
}();
_proto.getBestRoute = /*#__PURE__*/function () {
var _getBestRoute = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(requestBody, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
while (1) switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return this.httpService.post("/routing/best?apiKey=" + this.apiKey, requestBody, _extends({
headers: {
'X-Rango-Id': this.deviceId
}
}, options));
case 2:
axiosResponse = _context6.sent;
return _context6.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context6.stop();
}
}, _callee6, this);
}));
function getBestRoute(_x9, _x10) {
return _getBestRoute.apply(this, arguments);
}
return getBestRoute;
}();
_proto.getAllRoutes = /*#__PURE__*/function () {
var _getAllRoutes = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(requestBody, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
while (1) switch (_context7.prev = _context7.next) {
case 0:
_context7.next = 2;
return this.httpService.post("/routing/bests?apiKey=" + this.apiKey, requestBody, _extends({
headers: {
'X-Rango-Id': this.deviceId
}
}, options));
case 2:
axiosResponse = _context7.sent;
return _context7.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context7.stop();
}
}, _callee7, this);
}));
function getAllRoutes(_x11, _x12) {
return _getAllRoutes.apply(this, arguments);
}
return getAllRoutes;
}();
_proto.confirmRoute = /*#__PURE__*/function () {
var _confirmRoute = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(requestBody, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
while (1) switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return this.httpService.post("/routing/confirm?apiKey=" + this.apiKey, requestBody, _extends({
headers: {
'X-Rango-Id': this.deviceId
}
}, options));
case 2:
axiosResponse = _context8.sent;
return _context8.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context8.stop();
}
}, _callee8, this);
}));
function confirmRoute(_x13, _x14) {
return _confirmRoute.apply(this, arguments);
}
return confirmRoute;
}() // @deprecated use confirmRoute instead
;
_proto.confirmRouteRequest =
/*#__PURE__*/
function () {
var _confirmRouteRequest = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(requestBody, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
while (1) switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return this.httpService.post("/routing/confirm?apiKey=" + this.apiKey, requestBody, _extends({
headers: {
'X-Rango-Id': this.deviceId
}
}, options));
case 2:
axiosResponse = _context9.sent;
return _context9.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context9.stop();
}
}, _callee9, this);
}));
function confirmRouteRequest(_x15, _x16) {
return _confirmRouteRequest.apply(this, arguments);
}
return confirmRouteRequest;
}();
_proto.checkApproval = /*#__PURE__*/function () {
var _checkApproval = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(requestId, txId, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
while (1) switch (_context10.prev = _context10.next) {
case 0:
_context10.next = 2;
return this.httpService.get("/tx/" + requestId + "/check-approval?apiKey=" + this.apiKey, _extends({
params: {
txId: txId
}
}, options));
case 2:
axiosResponse = _context10.sent;
return _context10.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context10.stop();
}
}, _callee10, this);
}));
function checkApproval(_x17, _x18, _x19) {
return _checkApproval.apply(this, arguments);
}
return checkApproval;
}();
_proto.checkStatus = /*#__PURE__*/function () {
var _checkStatus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(requestBody, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
while (1) switch (_context11.prev = _context11.next) {
case 0:
_context11.next = 2;
return this.httpService.post("/tx/check-status?apiKey=" + this.apiKey, requestBody, _extends({}, options));
case 2:
axiosResponse = _context11.sent;
return _context11.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context11.stop();
}
}, _callee11, this);
}));
function checkStatus(_x20, _x21) {
return _checkStatus.apply(this, arguments);
}
return checkStatus;
}();
_proto.createTransaction = /*#__PURE__*/function () {
var _createTransaction = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(requestBody, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
while (1) switch (_context12.prev = _context12.next) {
case 0:
_context12.next = 2;
return this.httpService.post("/tx/create?apiKey=" + this.apiKey, requestBody, _extends({}, options));
case 2:
axiosResponse = _context12.sent;
return _context12.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context12.stop();
}
}, _callee12, this);
}));
function createTransaction(_x22, _x23) {
return _createTransaction.apply(this, arguments);
}
return createTransaction;
}();
_proto.reportFailure = /*#__PURE__*/function () {
var _reportFailure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(requestBody, options) {
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
while (1) switch (_context13.prev = _context13.next) {
case 0:
_context13.next = 2;
return this.httpService.post("/tx/report-tx?apiKey=" + this.apiKey, requestBody, _extends({}, options));
case 2:
case "end":
return _context13.stop();
}
}, _callee13, this);
}));
function reportFailure(_x24, _x25) {
return _reportFailure.apply(this, arguments);
}
return reportFailure;
}();
_proto.getWalletsDetails = /*#__PURE__*/function () {
var _getWalletsDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(walletAddresses, options) {
var walletAddressesQueryParams, i, walletAddress, axiosResponse;
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
while (1) switch (_context14.prev = _context14.next) {
case 0:
walletAddressesQueryParams = '';
for (i = 0; i < walletAddresses.length; i++) {
walletAddress = walletAddresses[i];
walletAddressesQueryParams += "&address=" + walletAddress.blockchain + "." + walletAddress.address;
}
_context14.next = 4;
return this.httpService.get("/wallets/details?apiKey=" + this.apiKey + walletAddressesQueryParams, _extends({}, options));
case 4:
axiosResponse = _context14.sent;
return _context14.abrupt("return", axiosResponse.data);
case 6:
case "end":
return _context14.stop();
}
}, _callee14, this);
}));
function getWalletsDetails(_x26, _x27) {
return _getWalletsDetails.apply(this, arguments);
}
return getWalletsDetails;
}();
_proto.getTokenBalance = /*#__PURE__*/function () {
var _getTokenBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tokenBalanceRequest, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
while (1) switch (_context15.prev = _context15.next) {
case 0:
_context15.next = 2;
return this.httpService.get("/wallets/token-balance?apiKey=" + this.apiKey, _extends({
params: tokenBalanceRequest
}, options));
case 2:
axiosResponse = _context15.sent;
return _context15.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context15.stop();
}
}, _callee15, this);
}));
function getTokenBalance(_x28, _x29) {
return _getTokenBalance.apply(this, arguments);
}
return getTokenBalance;
}();
_proto.getMultipleTokenBalance = /*#__PURE__*/function () {
var _getMultipleTokenBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(requestBody, options) {
var axiosResponse;
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
while (1) switch (_context16.prev = _context16.next) {
case 0:
_context16.next = 2;
return this.httpService.post("/wallets/multiple-token-balance?apiKey=" + this.apiKey, requestBody, _extends({}, options));
case 2:
axiosResponse = _context16.sent;
return _context16.abrupt("return", axiosResponse.data);
case 4:
case "end":
return _context16.stop();
}
}, _callee16, this);
}));
function getMultipleTokenBalance(_x30, _x31) {
return _getMultipleTokenBalance.apply(this, arguments);
}
return getMultipleTokenBalance;
}();
return RangoClient;
}();
var isEvmBlockchain = function isEvmBlockchain(blockchainMeta) {
return blockchainMeta.type === 'EVM';
};
var isCosmosBlockchain = function isCosmosBlockchain(blockchainMeta) {
return blockchainMeta.type === 'COSMOS';
};
var isSolanaBlockchain = function isSolanaBlockchain(blockchainMeta) {
return blockchainMeta.type === 'SOLANA';
};
var isTronBlockchain = function isTronBlockchain(blockchainMeta) {
return blockchainMeta.type === 'TRON';
};
var isTransferBlockchain = function isTransferBlockchain(blockchainMeta) {
return blockchainMeta.type === 'TRANSFER';
};
var isStarknetBlockchain = function isStarknetBlockchain(blockchainMeta) {
return blockchainMeta.type === 'STARKNET';
};
var isTonBlockchain = function isTonBlockchain(blockchainMeta) {
return blockchainMeta.type === 'TON';
};
var evmBlockchains = function evmBlockchains(blockchains) {
return blockchains.filter(isEvmBlockchain);
};
var solanaBlockchain = function solanaBlockchain(blockchains) {
return blockchains.filter(isSolanaBlockchain);
};
var starknetBlockchain = function starknetBlockchain(blockchains) {
return blockchains.filter(isStarknetBlockchain);
};
var tronBlockchain = function tronBlockchain(blockchains) {
return blockchains.filter(isTronBlockchain);
};
var cosmosBlockchains = function cosmosBlockchains(blockchains) {
return blockchains.filter(isCosmosBlockchain);
};
var transferBlockchains = function transferBlockchains(blockchains) {
return blockchains.filter(isTransferBlockchain);
};
var tonBlockchain = function tonBlockchain(blockchains) {
return blockchains.filter(isTonBlockchain);
};
/**
* Routing Result Type
*
*/
var RoutingResultType;
(function (RoutingResultType) {
RoutingResultType["OK"] = "OK";
RoutingResultType["HIGH_IMPACT"] = "HIGH_IMPACT";
RoutingResultType["NO_ROUTE"] = "NO_ROUTE";
RoutingResultType["INPUT_LIMIT_ISSUE"] = "INPUT_LIMIT_ISSUE";
RoutingResultType["HIGH_IMPACT_FOR_CREATE_TX"] = "HIGH_IMPACT_FOR_CREATE_TX";
})(RoutingResultType || (RoutingResultType = {}));
/**
* The type of transaction
*/
var TransactionType;
(function (TransactionType) {
TransactionType["EVM"] = "EVM";
TransactionType["TRANSFER"] = "TRANSFER";
TransactionType["COSMOS"] = "COSMOS";
TransactionType["SOLANA"] = "SOLANA";
TransactionType["TRON"] = "TRON";
TransactionType["STARKNET"] = "STARKNET";
TransactionType["TON"] = "TON";
TransactionType["SUI"] = "SUI";
})(TransactionType || (TransactionType = {}));
/**
* The type of transaction
* @deprecated use TransactionType instead
*/
var GenericTransactionType;
(function (GenericTransactionType) {
GenericTransactionType["EVM"] = "EVM";
GenericTransactionType["TRANSFER"] = "TRANSFER";
GenericTransactionType["COSMOS"] = "COSMOS";
GenericTransactionType["SOLANA"] = "SOLANA";
})(GenericTransactionType || (GenericTransactionType = {}));
/**
* The status of transaction in tracking
*/
var TransactionStatus;
(function (TransactionStatus) {
TransactionStatus["FAILED"] = "failed";
TransactionStatus["RUNNING"] = "running";
TransactionStatus["SUCCESS"] = "success";
})(TransactionStatus || (TransactionStatus = {}));
var isCosmosTransaction = function isCosmosTransaction(transaction) {
return transaction.type === TransactionType.COSMOS;
};
var isSolanaTransaction = function isSolanaTransaction(transaction) {
return transaction.type === TransactionType.SOLANA;
};
var isTransferTransaction = function isTransferTransaction(transaction) {
return transaction.type === TransactionType.TRANSFER;
};
var isTronTransaction = function isTronTransaction(transaction) {
return transaction.type === TransactionType.TRON;
};
var TonChainID;
(function (TonChainID) {
TonChainID["MAINNET"] = "-239";
TonChainID["TESTNET"] = "-3";
})(TonChainID || (TonChainID = {}));
var isTonTransaction = function isTonTransaction(transaction) {
return transaction.type === TransactionType.TON;
};
var isEvmTransaction = function isEvmTransaction(transaction) {
return transaction.type === TransactionType.EVM;
};
export { GenericTransactionType, RangoClient, RoutingResultType, TonChainID, TransactionStatus, TransactionType, cosmosBlockchains, evmBlockchains, isCosmosBlockchain, isCosmosTransaction, isEvmBlockchain, isEvmTransaction, isSolanaBlockchain, isSolanaTransaction, isStarknetBlockchain, isTonBlockchain, isTonTransaction, isTransferBlockchain, isTransferTransaction, isTronBlockchain, isTronTransaction, solanaBlockchain, starknetBlockchain, tonBlockchain, transferBlockchains, tronBlockchain };
//# sourceMappingURL=rango-sdk.esm.js.map