rango-sdk-basic 0.0.14 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE → lib/LICENSE} +0 -0
- package/{README.md → lib/README.md} +18 -7
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -21
- package/lib/package.json +39 -0
- package/lib/rango-sdk-basic.cjs.development.js +1008 -0
- package/lib/rango-sdk-basic.cjs.development.js.map +1 -0
- package/lib/rango-sdk-basic.cjs.production.min.js +2 -0
- package/lib/rango-sdk-basic.cjs.production.min.js.map +1 -0
- package/lib/rango-sdk-basic.esm.js +1005 -0
- package/lib/rango-sdk-basic.esm.js.map +1 -0
- package/lib/services/client.d.ts +21 -21
- package/lib/services/client.d.ts.map +1 -1
- package/lib/services/executor.d.ts +7 -7
- package/lib/services/executor.d.ts.map +1 -1
- package/lib/services/httpService.d.ts +1 -1
- package/lib/services/httpService.d.ts.map +1 -1
- package/lib/services/index.d.ts +1 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/types/api/balance.d.ts +1 -38
- package/lib/types/api/balance.d.ts.map +1 -1
- package/lib/types/api/common.d.ts +3 -128
- package/lib/types/api/common.d.ts.map +1 -1
- package/lib/types/api/meta.d.ts +1 -183
- package/lib/types/api/meta.d.ts.map +1 -1
- package/lib/types/api/routing.d.ts +1 -43
- package/lib/types/api/routing.d.ts.map +1 -1
- package/lib/types/api/transactions.d.ts +1 -188
- package/lib/types/api/transactions.d.ts.map +1 -1
- package/lib/types/api/txs/cosmos.d.ts +1 -68
- package/lib/types/api/txs/cosmos.d.ts.map +1 -1
- package/lib/types/api/txs/evm.d.ts +1 -29
- package/lib/types/api/txs/evm.d.ts.map +1 -1
- package/lib/types/api/txs/index.d.ts +3 -3
- package/lib/types/api/txs/index.d.ts.map +1 -1
- package/lib/types/api/txs/transfer.d.ts +1 -28
- package/lib/types/api/txs/transfer.d.ts.map +1 -1
- package/lib/types/index.d.ts +7 -7
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/utils/errors.d.ts +22 -22
- package/lib/types/utils/errors.d.ts.map +1 -1
- package/lib/utils/errors.d.ts +1 -1
- package/lib/utils/errors.d.ts.map +1 -1
- package/lib/utils/promise.d.ts +1 -1
- package/lib/utils/promise.d.ts.map +1 -1
- package/package.json +15 -26
- package/lib/index.js.map +0 -1
- package/lib/services/client.js +0 -257
- package/lib/services/client.js.map +0 -1
- package/lib/services/executor.js +0 -196
- package/lib/services/executor.js.map +0 -1
- package/lib/services/httpService.js +0 -14
- package/lib/services/httpService.js.map +0 -1
- package/lib/services/index.js +0 -6
- package/lib/services/index.js.map +0 -1
- package/lib/types/api/balance.js +0 -3
- package/lib/types/api/balance.js.map +0 -1
- package/lib/types/api/common.js +0 -11
- package/lib/types/api/common.js.map +0 -1
- package/lib/types/api/meta.js +0 -3
- package/lib/types/api/meta.js.map +0 -1
- package/lib/types/api/routing.js +0 -3
- package/lib/types/api/routing.js.map +0 -1
- package/lib/types/api/transactions.js +0 -22
- package/lib/types/api/transactions.js.map +0 -1
- package/lib/types/api/txs/cosmos.js +0 -3
- package/lib/types/api/txs/cosmos.js.map +0 -1
- package/lib/types/api/txs/evm.js +0 -3
- package/lib/types/api/txs/evm.js.map +0 -1
- package/lib/types/api/txs/index.js +0 -20
- package/lib/types/api/txs/index.js.map +0 -1
- package/lib/types/api/txs/transfer.js +0 -3
- package/lib/types/api/txs/transfer.js.map +0 -1
- package/lib/types/index.js +0 -24
- package/lib/types/index.js.map +0 -1
- package/lib/types/utils/errors.js +0 -26
- package/lib/types/utils/errors.js.map +0 -1
- package/lib/utils/errors.js +0 -31
- package/lib/utils/errors.js.map +0 -1
- package/lib/utils/promise.js +0 -8
- package/lib/utils/promise.js.map +0 -1
|
@@ -0,0 +1,1008 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var axios = _interopDefault(require('axios'));
|
|
8
|
+
var ethRpcErrors = require('eth-rpc-errors');
|
|
9
|
+
|
|
10
|
+
function _regeneratorRuntime() {
|
|
11
|
+
_regeneratorRuntime = function () {
|
|
12
|
+
return exports;
|
|
13
|
+
};
|
|
14
|
+
var exports = {},
|
|
15
|
+
Op = Object.prototype,
|
|
16
|
+
hasOwn = Op.hasOwnProperty,
|
|
17
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
18
|
+
obj[key] = desc.value;
|
|
19
|
+
},
|
|
20
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
21
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
22
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
23
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
24
|
+
function define(obj, key, value) {
|
|
25
|
+
return Object.defineProperty(obj, key, {
|
|
26
|
+
value: value,
|
|
27
|
+
enumerable: !0,
|
|
28
|
+
configurable: !0,
|
|
29
|
+
writable: !0
|
|
30
|
+
}), obj[key];
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
define({}, "");
|
|
34
|
+
} catch (err) {
|
|
35
|
+
define = function (obj, key, value) {
|
|
36
|
+
return obj[key] = value;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
40
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
41
|
+
generator = Object.create(protoGenerator.prototype),
|
|
42
|
+
context = new Context(tryLocsList || []);
|
|
43
|
+
return defineProperty(generator, "_invoke", {
|
|
44
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
45
|
+
}), generator;
|
|
46
|
+
}
|
|
47
|
+
function tryCatch(fn, obj, arg) {
|
|
48
|
+
try {
|
|
49
|
+
return {
|
|
50
|
+
type: "normal",
|
|
51
|
+
arg: fn.call(obj, arg)
|
|
52
|
+
};
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return {
|
|
55
|
+
type: "throw",
|
|
56
|
+
arg: err
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.wrap = wrap;
|
|
61
|
+
var ContinueSentinel = {};
|
|
62
|
+
function Generator() {}
|
|
63
|
+
function GeneratorFunction() {}
|
|
64
|
+
function GeneratorFunctionPrototype() {}
|
|
65
|
+
var IteratorPrototype = {};
|
|
66
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
67
|
+
return this;
|
|
68
|
+
});
|
|
69
|
+
var getProto = Object.getPrototypeOf,
|
|
70
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
71
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
72
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
73
|
+
function defineIteratorMethods(prototype) {
|
|
74
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
75
|
+
define(prototype, method, function (arg) {
|
|
76
|
+
return this._invoke(method, arg);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
81
|
+
function invoke(method, arg, resolve, reject) {
|
|
82
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
83
|
+
if ("throw" !== record.type) {
|
|
84
|
+
var result = record.arg,
|
|
85
|
+
value = result.value;
|
|
86
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
87
|
+
invoke("next", value, resolve, reject);
|
|
88
|
+
}, function (err) {
|
|
89
|
+
invoke("throw", err, resolve, reject);
|
|
90
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
91
|
+
result.value = unwrapped, resolve(result);
|
|
92
|
+
}, function (error) {
|
|
93
|
+
return invoke("throw", error, resolve, reject);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
reject(record.arg);
|
|
97
|
+
}
|
|
98
|
+
var previousPromise;
|
|
99
|
+
defineProperty(this, "_invoke", {
|
|
100
|
+
value: function (method, arg) {
|
|
101
|
+
function callInvokeWithMethodAndArg() {
|
|
102
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
103
|
+
invoke(method, arg, resolve, reject);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
111
|
+
var state = "suspendedStart";
|
|
112
|
+
return function (method, arg) {
|
|
113
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
114
|
+
if ("completed" === state) {
|
|
115
|
+
if ("throw" === method) throw arg;
|
|
116
|
+
return doneResult();
|
|
117
|
+
}
|
|
118
|
+
for (context.method = method, context.arg = arg;;) {
|
|
119
|
+
var delegate = context.delegate;
|
|
120
|
+
if (delegate) {
|
|
121
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
122
|
+
if (delegateResult) {
|
|
123
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
124
|
+
return delegateResult;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
128
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
129
|
+
context.dispatchException(context.arg);
|
|
130
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
131
|
+
state = "executing";
|
|
132
|
+
var record = tryCatch(innerFn, self, context);
|
|
133
|
+
if ("normal" === record.type) {
|
|
134
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
135
|
+
return {
|
|
136
|
+
value: record.arg,
|
|
137
|
+
done: context.done
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
145
|
+
var methodName = context.method,
|
|
146
|
+
method = delegate.iterator[methodName];
|
|
147
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
148
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
149
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
150
|
+
var info = record.arg;
|
|
151
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
152
|
+
}
|
|
153
|
+
function pushTryEntry(locs) {
|
|
154
|
+
var entry = {
|
|
155
|
+
tryLoc: locs[0]
|
|
156
|
+
};
|
|
157
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
158
|
+
}
|
|
159
|
+
function resetTryEntry(entry) {
|
|
160
|
+
var record = entry.completion || {};
|
|
161
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
162
|
+
}
|
|
163
|
+
function Context(tryLocsList) {
|
|
164
|
+
this.tryEntries = [{
|
|
165
|
+
tryLoc: "root"
|
|
166
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
167
|
+
}
|
|
168
|
+
function values(iterable) {
|
|
169
|
+
if (iterable) {
|
|
170
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
171
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
172
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
173
|
+
if (!isNaN(iterable.length)) {
|
|
174
|
+
var i = -1,
|
|
175
|
+
next = function next() {
|
|
176
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
177
|
+
return next.value = undefined, next.done = !0, next;
|
|
178
|
+
};
|
|
179
|
+
return next.next = next;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
next: doneResult
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function doneResult() {
|
|
187
|
+
return {
|
|
188
|
+
value: undefined,
|
|
189
|
+
done: !0
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
193
|
+
value: GeneratorFunctionPrototype,
|
|
194
|
+
configurable: !0
|
|
195
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
196
|
+
value: GeneratorFunction,
|
|
197
|
+
configurable: !0
|
|
198
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
199
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
200
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
201
|
+
}, exports.mark = function (genFun) {
|
|
202
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
203
|
+
}, exports.awrap = function (arg) {
|
|
204
|
+
return {
|
|
205
|
+
__await: arg
|
|
206
|
+
};
|
|
207
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
208
|
+
return this;
|
|
209
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
210
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
211
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
212
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
213
|
+
return result.done ? result.value : iter.next();
|
|
214
|
+
});
|
|
215
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
216
|
+
return this;
|
|
217
|
+
}), define(Gp, "toString", function () {
|
|
218
|
+
return "[object Generator]";
|
|
219
|
+
}), exports.keys = function (val) {
|
|
220
|
+
var object = Object(val),
|
|
221
|
+
keys = [];
|
|
222
|
+
for (var key in object) keys.push(key);
|
|
223
|
+
return keys.reverse(), function next() {
|
|
224
|
+
for (; keys.length;) {
|
|
225
|
+
var key = keys.pop();
|
|
226
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
227
|
+
}
|
|
228
|
+
return next.done = !0, next;
|
|
229
|
+
};
|
|
230
|
+
}, exports.values = values, Context.prototype = {
|
|
231
|
+
constructor: Context,
|
|
232
|
+
reset: function (skipTempReset) {
|
|
233
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
234
|
+
},
|
|
235
|
+
stop: function () {
|
|
236
|
+
this.done = !0;
|
|
237
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
238
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
239
|
+
return this.rval;
|
|
240
|
+
},
|
|
241
|
+
dispatchException: function (exception) {
|
|
242
|
+
if (this.done) throw exception;
|
|
243
|
+
var context = this;
|
|
244
|
+
function handle(loc, caught) {
|
|
245
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
246
|
+
}
|
|
247
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
248
|
+
var entry = this.tryEntries[i],
|
|
249
|
+
record = entry.completion;
|
|
250
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
251
|
+
if (entry.tryLoc <= this.prev) {
|
|
252
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
253
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
254
|
+
if (hasCatch && hasFinally) {
|
|
255
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
256
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
257
|
+
} else if (hasCatch) {
|
|
258
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
259
|
+
} else {
|
|
260
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
261
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
abrupt: function (type, arg) {
|
|
267
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
268
|
+
var entry = this.tryEntries[i];
|
|
269
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
270
|
+
var finallyEntry = entry;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
275
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
276
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
277
|
+
},
|
|
278
|
+
complete: function (record, afterLoc) {
|
|
279
|
+
if ("throw" === record.type) throw record.arg;
|
|
280
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
281
|
+
},
|
|
282
|
+
finish: function (finallyLoc) {
|
|
283
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
284
|
+
var entry = this.tryEntries[i];
|
|
285
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
catch: function (tryLoc) {
|
|
289
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
290
|
+
var entry = this.tryEntries[i];
|
|
291
|
+
if (entry.tryLoc === tryLoc) {
|
|
292
|
+
var record = entry.completion;
|
|
293
|
+
if ("throw" === record.type) {
|
|
294
|
+
var thrown = record.arg;
|
|
295
|
+
resetTryEntry(entry);
|
|
296
|
+
}
|
|
297
|
+
return thrown;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
throw new Error("illegal catch attempt");
|
|
301
|
+
},
|
|
302
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
303
|
+
return this.delegate = {
|
|
304
|
+
iterator: values(iterable),
|
|
305
|
+
resultName: resultName,
|
|
306
|
+
nextLoc: nextLoc
|
|
307
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
308
|
+
}
|
|
309
|
+
}, exports;
|
|
310
|
+
}
|
|
311
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
312
|
+
try {
|
|
313
|
+
var info = gen[key](arg);
|
|
314
|
+
var value = info.value;
|
|
315
|
+
} catch (error) {
|
|
316
|
+
reject(error);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (info.done) {
|
|
320
|
+
resolve(value);
|
|
321
|
+
} else {
|
|
322
|
+
Promise.resolve(value).then(_next, _throw);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function _asyncToGenerator(fn) {
|
|
326
|
+
return function () {
|
|
327
|
+
var self = this,
|
|
328
|
+
args = arguments;
|
|
329
|
+
return new Promise(function (resolve, reject) {
|
|
330
|
+
var gen = fn.apply(self, args);
|
|
331
|
+
function _next(value) {
|
|
332
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
333
|
+
}
|
|
334
|
+
function _throw(err) {
|
|
335
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
336
|
+
}
|
|
337
|
+
_next(undefined);
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function _extends() {
|
|
342
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
343
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
344
|
+
var source = arguments[i];
|
|
345
|
+
for (var key in source) {
|
|
346
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
347
|
+
target[key] = source[key];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return target;
|
|
352
|
+
};
|
|
353
|
+
return _extends.apply(this, arguments);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
357
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
358
|
+
// generators (like Math.random()).
|
|
359
|
+
var getRandomValues;
|
|
360
|
+
var rnds8 = /*#__PURE__*/new Uint8Array(16);
|
|
361
|
+
function rng() {
|
|
362
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
363
|
+
if (!getRandomValues) {
|
|
364
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
365
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
366
|
+
if (!getRandomValues) {
|
|
367
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return getRandomValues(rnds8);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
375
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
var byteToHex = [];
|
|
379
|
+
for (var i = 0; i < 256; ++i) {
|
|
380
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
381
|
+
}
|
|
382
|
+
function unsafeStringify(arr, offset) {
|
|
383
|
+
if (offset === void 0) {
|
|
384
|
+
offset = 0;
|
|
385
|
+
}
|
|
386
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
387
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
388
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && /*#__PURE__*/crypto.randomUUID.bind(crypto);
|
|
392
|
+
var _native = {
|
|
393
|
+
randomUUID: randomUUID
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
function v4(options, buf, offset) {
|
|
397
|
+
if (_native.randomUUID && !buf && !options) {
|
|
398
|
+
return _native.randomUUID();
|
|
399
|
+
}
|
|
400
|
+
options = options || {};
|
|
401
|
+
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
402
|
+
|
|
403
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
404
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
405
|
+
|
|
406
|
+
if (buf) {
|
|
407
|
+
offset = offset || 0;
|
|
408
|
+
for (var i = 0; i < 16; ++i) {
|
|
409
|
+
buf[offset + i] = rnds[i];
|
|
410
|
+
}
|
|
411
|
+
return buf;
|
|
412
|
+
}
|
|
413
|
+
return unsafeStringify(rnds);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
var baseURL = typeof process !== 'undefined' && process.env.REACT_APP_RANGO_BASE_URL ? process.env.REACT_APP_RANGO_BASE_URL : 'https://api.rango.exchange';
|
|
417
|
+
var httpService = /*#__PURE__*/axios.create({
|
|
418
|
+
baseURL: baseURL
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
function assetToString(asset) {
|
|
422
|
+
if (!!asset.address) return asset.blockchain + "." + asset.symbol + "--" + asset.address;else return asset.blockchain + "." + asset.symbol;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
var MetaInfoType;
|
|
426
|
+
(function (MetaInfoType) {
|
|
427
|
+
MetaInfoType["CosmosMetaInfo"] = "CosmosMetaInfo";
|
|
428
|
+
MetaInfoType["EvmMetaInfo"] = "EvmMetaInfo";
|
|
429
|
+
})(MetaInfoType || (MetaInfoType = {}));
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* The type of transaction
|
|
433
|
+
*/
|
|
434
|
+
(function (TransactionType) {
|
|
435
|
+
TransactionType["EVM"] = "EVM";
|
|
436
|
+
TransactionType["TRANSFER"] = "TRANSFER";
|
|
437
|
+
TransactionType["COSMOS"] = "COSMOS";
|
|
438
|
+
TransactionType["SOLANA"] = "SOLANA";
|
|
439
|
+
TransactionType["TRON"] = "TRON";
|
|
440
|
+
TransactionType["STARKNET"] = "STARKNET";
|
|
441
|
+
})(exports.TransactionType || (exports.TransactionType = {}));
|
|
442
|
+
(function (TransactionStatus) {
|
|
443
|
+
TransactionStatus["FAILED"] = "failed";
|
|
444
|
+
TransactionStatus["RUNNING"] = "running";
|
|
445
|
+
TransactionStatus["SUCCESS"] = "success";
|
|
446
|
+
})(exports.TransactionStatus || (exports.TransactionStatus = {}));
|
|
447
|
+
|
|
448
|
+
var MetamaskErrorCodes = {
|
|
449
|
+
rpc: {
|
|
450
|
+
invalidInput: -32000,
|
|
451
|
+
resourceNotFound: -32001,
|
|
452
|
+
resourceUnavailable: -32002,
|
|
453
|
+
transactionRejected: -32003,
|
|
454
|
+
methodNotSupported: -32004,
|
|
455
|
+
limitExceeded: -32005,
|
|
456
|
+
parse: -32700,
|
|
457
|
+
invalidRequest: -32600,
|
|
458
|
+
methodNotFound: -32601,
|
|
459
|
+
invalidParams: -32602,
|
|
460
|
+
internal: -32603
|
|
461
|
+
},
|
|
462
|
+
provider: {
|
|
463
|
+
userRejectedRequest: 4001,
|
|
464
|
+
unauthorized: 4100,
|
|
465
|
+
unsupportedMethod: 4200,
|
|
466
|
+
disconnected: 4900,
|
|
467
|
+
chainDisconnected: 4901
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
function sleep(ms) {
|
|
472
|
+
return new Promise(function (resolve) {
|
|
473
|
+
return setTimeout(resolve, ms);
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function prepareEvmTransaction(evmTx, isApprove) {
|
|
478
|
+
var gasPrice = !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x') ? '0x' + parseInt(evmTx.gasPrice).toString(16) : null;
|
|
479
|
+
var manipulatedTx = _extends({}, evmTx, {
|
|
480
|
+
gasPrice: gasPrice
|
|
481
|
+
});
|
|
482
|
+
var tx = {};
|
|
483
|
+
if (!!manipulatedTx.from) tx = _extends({}, tx, {
|
|
484
|
+
from: manipulatedTx.from
|
|
485
|
+
});
|
|
486
|
+
if (isApprove) {
|
|
487
|
+
if (!!manipulatedTx.approveTo) tx = _extends({}, tx, {
|
|
488
|
+
to: manipulatedTx.approveTo
|
|
489
|
+
});
|
|
490
|
+
if (!!manipulatedTx.approveData) tx = _extends({}, tx, {
|
|
491
|
+
data: manipulatedTx.approveData
|
|
492
|
+
});
|
|
493
|
+
} else {
|
|
494
|
+
if (!!manipulatedTx.txTo) tx = _extends({}, tx, {
|
|
495
|
+
to: manipulatedTx.txTo
|
|
496
|
+
});
|
|
497
|
+
if (!!manipulatedTx.txData) tx = _extends({}, tx, {
|
|
498
|
+
data: manipulatedTx.txData
|
|
499
|
+
});
|
|
500
|
+
if (!!manipulatedTx.value) tx = _extends({}, tx, {
|
|
501
|
+
value: manipulatedTx.value
|
|
502
|
+
});
|
|
503
|
+
if (!!manipulatedTx.gasLimit) tx = _extends({}, tx, {
|
|
504
|
+
gasLimit: manipulatedTx.gasLimit
|
|
505
|
+
});
|
|
506
|
+
if (!!manipulatedTx.gasPrice) tx = _extends({}, tx, {
|
|
507
|
+
gasPrice: manipulatedTx.gasPrice
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
return tx;
|
|
511
|
+
}
|
|
512
|
+
function checkApprovalSync(_x, _x2, _x3) {
|
|
513
|
+
return _checkApprovalSync.apply(this, arguments);
|
|
514
|
+
}
|
|
515
|
+
function _checkApprovalSync() {
|
|
516
|
+
_checkApprovalSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(requestId, txId, rangoClient) {
|
|
517
|
+
var approvalResponse;
|
|
518
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
519
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
520
|
+
case 0:
|
|
521
|
+
_context3.prev = 1;
|
|
522
|
+
_context3.next = 4;
|
|
523
|
+
return rangoClient.isApproved(requestId, txId);
|
|
524
|
+
case 4:
|
|
525
|
+
approvalResponse = _context3.sent;
|
|
526
|
+
if (!approvalResponse.isApproved) {
|
|
527
|
+
_context3.next = 7;
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
return _context3.abrupt("return", true);
|
|
531
|
+
case 7:
|
|
532
|
+
_context3.next = 12;
|
|
533
|
+
break;
|
|
534
|
+
case 9:
|
|
535
|
+
_context3.prev = 9;
|
|
536
|
+
_context3.t0 = _context3["catch"](1);
|
|
537
|
+
console.log('ignorinig error', {
|
|
538
|
+
err: _context3.t0
|
|
539
|
+
});
|
|
540
|
+
case 12:
|
|
541
|
+
_context3.next = 14;
|
|
542
|
+
return sleep(3000);
|
|
543
|
+
case 14:
|
|
544
|
+
_context3.next = 0;
|
|
545
|
+
break;
|
|
546
|
+
case 16:
|
|
547
|
+
case "end":
|
|
548
|
+
return _context3.stop();
|
|
549
|
+
}
|
|
550
|
+
}, _callee3, null, [[1, 9]]);
|
|
551
|
+
}));
|
|
552
|
+
return _checkApprovalSync.apply(this, arguments);
|
|
553
|
+
}
|
|
554
|
+
var checkTransactionStatusSync = /*#__PURE__*/function () {
|
|
555
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestId, txId, rangoClient) {
|
|
556
|
+
var txStatus;
|
|
557
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
558
|
+
while (1) switch (_context.prev = _context.next) {
|
|
559
|
+
case 0:
|
|
560
|
+
_context.prev = 1;
|
|
561
|
+
_context.next = 4;
|
|
562
|
+
return rangoClient.status({
|
|
563
|
+
requestId: requestId,
|
|
564
|
+
txId: txId
|
|
565
|
+
});
|
|
566
|
+
case 4:
|
|
567
|
+
txStatus = _context.sent;
|
|
568
|
+
_context.next = 10;
|
|
569
|
+
break;
|
|
570
|
+
case 7:
|
|
571
|
+
_context.prev = 7;
|
|
572
|
+
_context.t0 = _context["catch"](1);
|
|
573
|
+
console.log('ignorinig error', {
|
|
574
|
+
err: _context.t0
|
|
575
|
+
});
|
|
576
|
+
case 10:
|
|
577
|
+
if (!txStatus) {
|
|
578
|
+
_context.next = 13;
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
if (!(!!txStatus.status && [exports.TransactionStatus.FAILED, exports.TransactionStatus.SUCCESS].includes(txStatus.status))) {
|
|
582
|
+
_context.next = 13;
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
return _context.abrupt("return", txStatus);
|
|
586
|
+
case 13:
|
|
587
|
+
_context.next = 15;
|
|
588
|
+
return sleep(3000);
|
|
589
|
+
case 15:
|
|
590
|
+
_context.next = 0;
|
|
591
|
+
break;
|
|
592
|
+
case 17:
|
|
593
|
+
case "end":
|
|
594
|
+
return _context.stop();
|
|
595
|
+
}
|
|
596
|
+
}, _callee, null, [[1, 7]]);
|
|
597
|
+
}));
|
|
598
|
+
return function checkTransactionStatusSync(_x4, _x5, _x6) {
|
|
599
|
+
return _ref.apply(this, arguments);
|
|
600
|
+
};
|
|
601
|
+
}();
|
|
602
|
+
var executeEvmRoute = /*#__PURE__*/function () {
|
|
603
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, signer, route) {
|
|
604
|
+
var tx, requestId, error, resultType, evmTransaction, txChainId, signerChainId, approveTxData, approveTx, mainTxData, mainTx, status;
|
|
605
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
606
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
607
|
+
case 0:
|
|
608
|
+
tx = route.tx, requestId = route.requestId, error = route.error, resultType = route.resultType;
|
|
609
|
+
if (!(resultType != 'OK')) {
|
|
610
|
+
_context2.next = 3;
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
throw new Error(resultType);
|
|
614
|
+
case 3:
|
|
615
|
+
if (!(!!error || !tx)) {
|
|
616
|
+
_context2.next = 5;
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
throw new Error(error || 'Error creating the transaction.');
|
|
620
|
+
case 5:
|
|
621
|
+
if (!((tx == null ? void 0 : tx.type) !== exports.TransactionType.EVM)) {
|
|
622
|
+
_context2.next = 7;
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
throw new Error('Non Evm transactions are not supported yet.');
|
|
626
|
+
case 7:
|
|
627
|
+
evmTransaction = tx;
|
|
628
|
+
txChainId = parseInt(evmTransaction.blockChain.chainId || '-1');
|
|
629
|
+
_context2.next = 11;
|
|
630
|
+
return signer.getChainId();
|
|
631
|
+
case 11:
|
|
632
|
+
signerChainId = _context2.sent;
|
|
633
|
+
if (!(signerChainId !== txChainId)) {
|
|
634
|
+
_context2.next = 14;
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
throw new Error("Signer chainId " + signerChainId + " doesn't match required chainId " + txChainId + ".");
|
|
638
|
+
case 14:
|
|
639
|
+
if (!(!!evmTransaction.approveTo && !!evmTransaction.approveData)) {
|
|
640
|
+
_context2.next = 22;
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
approveTxData = prepareEvmTransaction(evmTransaction, true);
|
|
644
|
+
_context2.next = 18;
|
|
645
|
+
return signer.sendTransaction(approveTxData);
|
|
646
|
+
case 18:
|
|
647
|
+
approveTx = _context2.sent;
|
|
648
|
+
approveTx.wait();
|
|
649
|
+
_context2.next = 22;
|
|
650
|
+
return checkApprovalSync(requestId, approveTx.hash, client);
|
|
651
|
+
case 22:
|
|
652
|
+
_context2.next = 24;
|
|
653
|
+
return signer.getChainId();
|
|
654
|
+
case 24:
|
|
655
|
+
signerChainId = _context2.sent;
|
|
656
|
+
if (!(signerChainId !== txChainId)) {
|
|
657
|
+
_context2.next = 27;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
throw new Error("Signer chainId " + signerChainId + " doesn't match required chainId " + txChainId + ".");
|
|
661
|
+
case 27:
|
|
662
|
+
mainTxData = prepareEvmTransaction(evmTransaction, false);
|
|
663
|
+
_context2.next = 30;
|
|
664
|
+
return signer.sendTransaction(mainTxData);
|
|
665
|
+
case 30:
|
|
666
|
+
mainTx = _context2.sent;
|
|
667
|
+
mainTx.wait();
|
|
668
|
+
_context2.next = 34;
|
|
669
|
+
return checkTransactionStatusSync(requestId, mainTx.hash, client);
|
|
670
|
+
case 34:
|
|
671
|
+
status = _context2.sent;
|
|
672
|
+
return _context2.abrupt("return", status);
|
|
673
|
+
case 36:
|
|
674
|
+
case "end":
|
|
675
|
+
return _context2.stop();
|
|
676
|
+
}
|
|
677
|
+
}, _callee2);
|
|
678
|
+
}));
|
|
679
|
+
return function executeEvmRoute(_x7, _x8, _x9) {
|
|
680
|
+
return _ref2.apply(this, arguments);
|
|
681
|
+
};
|
|
682
|
+
}();
|
|
683
|
+
|
|
684
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
685
|
+
var prettifyError = function prettifyError(error) {
|
|
686
|
+
if (!error) return error;
|
|
687
|
+
if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001)) return new Error('Transaction Rejected');
|
|
688
|
+
if (error && typeof error.code === 'number') {
|
|
689
|
+
if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {
|
|
690
|
+
return new Error(ethRpcErrors.getMessageFromCode(error.code));
|
|
691
|
+
}
|
|
692
|
+
if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {
|
|
693
|
+
var _error$message, _error$message2, _error$message3;
|
|
694
|
+
if (error.code === MetamaskErrorCodes.rpc.internal && (_error$message = error.message) != null && _error$message.includes('underpriced')) return new Error('Transaction underpriced');
|
|
695
|
+
if ((_error$message2 = error.message) != null && _error$message2.includes('intrinsic gas too low') || (_error$message3 = error.message) != null && _error$message3.includes('out of gas')) return new Error('This Gas limit is low.');
|
|
696
|
+
return new Error(ethRpcErrors.getMessageFromCode(error.code));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if (error.message) return new Error(error.message);
|
|
700
|
+
return error;
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
var RangoClient = /*#__PURE__*/function () {
|
|
704
|
+
function RangoClient(apiKey, debug) {
|
|
705
|
+
if (debug === void 0) {
|
|
706
|
+
debug = false;
|
|
707
|
+
}
|
|
708
|
+
this.apiKey = apiKey;
|
|
709
|
+
try {
|
|
710
|
+
if (typeof window !== 'undefined') {
|
|
711
|
+
var deviceId = localStorage.getItem('deviceId');
|
|
712
|
+
if (deviceId) {
|
|
713
|
+
this.deviceId = deviceId;
|
|
714
|
+
} else {
|
|
715
|
+
var generatedId = v4();
|
|
716
|
+
localStorage.setItem('deviceId', generatedId);
|
|
717
|
+
this.deviceId = generatedId;
|
|
718
|
+
}
|
|
719
|
+
} else {
|
|
720
|
+
this.deviceId = v4();
|
|
721
|
+
}
|
|
722
|
+
} catch (e) {
|
|
723
|
+
this.deviceId = v4();
|
|
724
|
+
}
|
|
725
|
+
if (debug) {
|
|
726
|
+
httpService.interceptors.request.use(function (request) {
|
|
727
|
+
console.log('Starting Request', JSON.stringify(request, null, 2));
|
|
728
|
+
return request;
|
|
729
|
+
});
|
|
730
|
+
httpService.interceptors.response.use(function (response) {
|
|
731
|
+
console.log('Response:', JSON.stringify(response, null, 2));
|
|
732
|
+
return response;
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
var _proto = RangoClient.prototype;
|
|
737
|
+
_proto.meta = /*#__PURE__*/function () {
|
|
738
|
+
var _meta = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
739
|
+
var axiosResponse;
|
|
740
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
741
|
+
while (1) switch (_context.prev = _context.next) {
|
|
742
|
+
case 0:
|
|
743
|
+
_context.next = 2;
|
|
744
|
+
return httpService.get("/basic/meta?apiKey=" + this.apiKey);
|
|
745
|
+
case 2:
|
|
746
|
+
axiosResponse = _context.sent;
|
|
747
|
+
return _context.abrupt("return", axiosResponse.data);
|
|
748
|
+
case 4:
|
|
749
|
+
case "end":
|
|
750
|
+
return _context.stop();
|
|
751
|
+
}
|
|
752
|
+
}, _callee, this);
|
|
753
|
+
}));
|
|
754
|
+
function meta() {
|
|
755
|
+
return _meta.apply(this, arguments);
|
|
756
|
+
}
|
|
757
|
+
return meta;
|
|
758
|
+
}();
|
|
759
|
+
_proto.chains = /*#__PURE__*/function () {
|
|
760
|
+
var _chains = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
761
|
+
var axiosResponse;
|
|
762
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
763
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
764
|
+
case 0:
|
|
765
|
+
_context2.next = 2;
|
|
766
|
+
return httpService.get("/basic/meta/blockchains?apiKey=" + this.apiKey);
|
|
767
|
+
case 2:
|
|
768
|
+
axiosResponse = _context2.sent;
|
|
769
|
+
return _context2.abrupt("return", axiosResponse.data);
|
|
770
|
+
case 4:
|
|
771
|
+
case "end":
|
|
772
|
+
return _context2.stop();
|
|
773
|
+
}
|
|
774
|
+
}, _callee2, this);
|
|
775
|
+
}));
|
|
776
|
+
function chains() {
|
|
777
|
+
return _chains.apply(this, arguments);
|
|
778
|
+
}
|
|
779
|
+
return chains;
|
|
780
|
+
}();
|
|
781
|
+
_proto.swappers = /*#__PURE__*/function () {
|
|
782
|
+
var _swappers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
783
|
+
var axiosResponse;
|
|
784
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
785
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
786
|
+
case 0:
|
|
787
|
+
_context3.next = 2;
|
|
788
|
+
return httpService.get("/basic/meta/swappers?apiKey=" + this.apiKey);
|
|
789
|
+
case 2:
|
|
790
|
+
axiosResponse = _context3.sent;
|
|
791
|
+
return _context3.abrupt("return", axiosResponse.data);
|
|
792
|
+
case 4:
|
|
793
|
+
case "end":
|
|
794
|
+
return _context3.stop();
|
|
795
|
+
}
|
|
796
|
+
}, _callee3, this);
|
|
797
|
+
}));
|
|
798
|
+
function swappers() {
|
|
799
|
+
return _swappers.apply(this, arguments);
|
|
800
|
+
}
|
|
801
|
+
return swappers;
|
|
802
|
+
}();
|
|
803
|
+
_proto.quote = /*#__PURE__*/function () {
|
|
804
|
+
var _quote = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(quoteRequest) {
|
|
805
|
+
var body, axiosResponse;
|
|
806
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
807
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
808
|
+
case 0:
|
|
809
|
+
body = _extends({}, quoteRequest, {
|
|
810
|
+
from: assetToString(quoteRequest.from),
|
|
811
|
+
to: assetToString(quoteRequest.to),
|
|
812
|
+
swappers: !!quoteRequest.swappers && quoteRequest.swappers.length > 0 ? quoteRequest.swappers.join(',') : undefined,
|
|
813
|
+
messagingProtocols: !!quoteRequest.messagingProtocols && quoteRequest.messagingProtocols.length > 0 ? quoteRequest.messagingProtocols.join(',') : undefined
|
|
814
|
+
});
|
|
815
|
+
_context4.next = 3;
|
|
816
|
+
return httpService.get("/basic/quote?apiKey=" + this.apiKey, {
|
|
817
|
+
params: body,
|
|
818
|
+
headers: {
|
|
819
|
+
'X-Rango-Id': this.deviceId
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
case 3:
|
|
823
|
+
axiosResponse = _context4.sent;
|
|
824
|
+
return _context4.abrupt("return", axiosResponse.data);
|
|
825
|
+
case 5:
|
|
826
|
+
case "end":
|
|
827
|
+
return _context4.stop();
|
|
828
|
+
}
|
|
829
|
+
}, _callee4, this);
|
|
830
|
+
}));
|
|
831
|
+
function quote(_x) {
|
|
832
|
+
return _quote.apply(this, arguments);
|
|
833
|
+
}
|
|
834
|
+
return quote;
|
|
835
|
+
}();
|
|
836
|
+
_proto.isApproved = /*#__PURE__*/function () {
|
|
837
|
+
var _isApproved = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(requestId, txId) {
|
|
838
|
+
var axiosResponse;
|
|
839
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
840
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
841
|
+
case 0:
|
|
842
|
+
_context5.next = 2;
|
|
843
|
+
return httpService.get("/basic/is-approved?apiKey=" + this.apiKey, {
|
|
844
|
+
params: {
|
|
845
|
+
requestId: requestId,
|
|
846
|
+
txId: txId
|
|
847
|
+
},
|
|
848
|
+
headers: {
|
|
849
|
+
'X-Rango-Id': this.deviceId
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
case 2:
|
|
853
|
+
axiosResponse = _context5.sent;
|
|
854
|
+
return _context5.abrupt("return", axiosResponse.data);
|
|
855
|
+
case 4:
|
|
856
|
+
case "end":
|
|
857
|
+
return _context5.stop();
|
|
858
|
+
}
|
|
859
|
+
}, _callee5, this);
|
|
860
|
+
}));
|
|
861
|
+
function isApproved(_x2, _x3) {
|
|
862
|
+
return _isApproved.apply(this, arguments);
|
|
863
|
+
}
|
|
864
|
+
return isApproved;
|
|
865
|
+
}();
|
|
866
|
+
_proto.status = /*#__PURE__*/function () {
|
|
867
|
+
var _status = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(statusRequest) {
|
|
868
|
+
var axiosResponse;
|
|
869
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
870
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
871
|
+
case 0:
|
|
872
|
+
_context6.next = 2;
|
|
873
|
+
return httpService.get("/basic/status?apiKey=" + this.apiKey, {
|
|
874
|
+
params: statusRequest,
|
|
875
|
+
headers: {
|
|
876
|
+
'X-Rango-Id': this.deviceId
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
case 2:
|
|
880
|
+
axiosResponse = _context6.sent;
|
|
881
|
+
return _context6.abrupt("return", axiosResponse.data);
|
|
882
|
+
case 4:
|
|
883
|
+
case "end":
|
|
884
|
+
return _context6.stop();
|
|
885
|
+
}
|
|
886
|
+
}, _callee6, this);
|
|
887
|
+
}));
|
|
888
|
+
function status(_x4) {
|
|
889
|
+
return _status.apply(this, arguments);
|
|
890
|
+
}
|
|
891
|
+
return status;
|
|
892
|
+
}();
|
|
893
|
+
_proto.swap = /*#__PURE__*/function () {
|
|
894
|
+
var _swap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(swapRequest) {
|
|
895
|
+
var body, axiosResponse;
|
|
896
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
897
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
898
|
+
case 0:
|
|
899
|
+
body = _extends({}, swapRequest, {
|
|
900
|
+
from: assetToString(swapRequest.from),
|
|
901
|
+
to: assetToString(swapRequest.to),
|
|
902
|
+
swappers: !!swapRequest.swappers && swapRequest.swappers.length > 0 ? swapRequest.swappers.join(',') : undefined,
|
|
903
|
+
messagingProtocols: !!swapRequest.messagingProtocols && swapRequest.messagingProtocols.length > 0 ? swapRequest.messagingProtocols.join(',') : undefined
|
|
904
|
+
});
|
|
905
|
+
_context7.next = 3;
|
|
906
|
+
return httpService.get("/basic/swap?apiKey=" + this.apiKey, {
|
|
907
|
+
params: body,
|
|
908
|
+
headers: {
|
|
909
|
+
'X-Rango-Id': this.deviceId
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
case 3:
|
|
913
|
+
axiosResponse = _context7.sent;
|
|
914
|
+
return _context7.abrupt("return", axiosResponse.data);
|
|
915
|
+
case 5:
|
|
916
|
+
case "end":
|
|
917
|
+
return _context7.stop();
|
|
918
|
+
}
|
|
919
|
+
}, _callee7, this);
|
|
920
|
+
}));
|
|
921
|
+
function swap(_x5) {
|
|
922
|
+
return _swap.apply(this, arguments);
|
|
923
|
+
}
|
|
924
|
+
return swap;
|
|
925
|
+
}();
|
|
926
|
+
_proto.reportFailure = /*#__PURE__*/function () {
|
|
927
|
+
var _reportFailure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(requestBody) {
|
|
928
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
929
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
930
|
+
case 0:
|
|
931
|
+
_context8.next = 2;
|
|
932
|
+
return httpService.post("/basic/report-tx?apiKey=" + this.apiKey, requestBody, {
|
|
933
|
+
headers: {
|
|
934
|
+
'X-Rango-Id': this.deviceId
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
case 2:
|
|
938
|
+
case "end":
|
|
939
|
+
return _context8.stop();
|
|
940
|
+
}
|
|
941
|
+
}, _callee8, this);
|
|
942
|
+
}));
|
|
943
|
+
function reportFailure(_x6) {
|
|
944
|
+
return _reportFailure.apply(this, arguments);
|
|
945
|
+
}
|
|
946
|
+
return reportFailure;
|
|
947
|
+
}();
|
|
948
|
+
_proto.balance = /*#__PURE__*/function () {
|
|
949
|
+
var _balance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(walletAddress) {
|
|
950
|
+
var axiosResponse;
|
|
951
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
952
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
953
|
+
case 0:
|
|
954
|
+
_context9.next = 2;
|
|
955
|
+
return httpService.get("/basic/balance?apiKey=" + this.apiKey, {
|
|
956
|
+
params: walletAddress,
|
|
957
|
+
headers: {
|
|
958
|
+
'X-Rango-Id': this.deviceId
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
case 2:
|
|
962
|
+
axiosResponse = _context9.sent;
|
|
963
|
+
return _context9.abrupt("return", axiosResponse.data);
|
|
964
|
+
case 4:
|
|
965
|
+
case "end":
|
|
966
|
+
return _context9.stop();
|
|
967
|
+
}
|
|
968
|
+
}, _callee9, this);
|
|
969
|
+
}));
|
|
970
|
+
function balance(_x7) {
|
|
971
|
+
return _balance.apply(this, arguments);
|
|
972
|
+
}
|
|
973
|
+
return balance;
|
|
974
|
+
}();
|
|
975
|
+
_proto.executeEvmRoute = /*#__PURE__*/function () {
|
|
976
|
+
var _executeEvmRoute2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(
|
|
977
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
978
|
+
signer, route) {
|
|
979
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
980
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
981
|
+
case 0:
|
|
982
|
+
_context10.prev = 0;
|
|
983
|
+
_context10.next = 3;
|
|
984
|
+
return executeEvmRoute(this, signer, route);
|
|
985
|
+
case 3:
|
|
986
|
+
return _context10.abrupt("return", _context10.sent);
|
|
987
|
+
case 6:
|
|
988
|
+
_context10.prev = 6;
|
|
989
|
+
_context10.t0 = _context10["catch"](0);
|
|
990
|
+
throw prettifyError(_context10.t0);
|
|
991
|
+
case 9:
|
|
992
|
+
case "end":
|
|
993
|
+
return _context10.stop();
|
|
994
|
+
}
|
|
995
|
+
}, _callee10, this, [[0, 6]]);
|
|
996
|
+
}));
|
|
997
|
+
function executeEvmRoute$1(_x8, _x9) {
|
|
998
|
+
return _executeEvmRoute2.apply(this, arguments);
|
|
999
|
+
}
|
|
1000
|
+
return executeEvmRoute$1;
|
|
1001
|
+
}();
|
|
1002
|
+
return RangoClient;
|
|
1003
|
+
}();
|
|
1004
|
+
|
|
1005
|
+
exports.MetamaskErrorCodes = MetamaskErrorCodes;
|
|
1006
|
+
exports.RangoClient = RangoClient;
|
|
1007
|
+
exports.assetToString = assetToString;
|
|
1008
|
+
//# sourceMappingURL=rango-sdk-basic.cjs.development.js.map
|