@fileverse-dev/formulajs 4.4.21-price-and-wallet-6 → 4.4.21-price-and-wallet-8
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/browser/formula.js +53 -41
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +20 -6
- package/lib/esm/crypto-constants.mjs +1 -1
- package/lib/esm/index.mjs +20 -6
- package/package.json +1 -1
package/lib/browser/formula.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @fileverse-dev/formulajs v4.4.21-price-and-wallet-
|
|
1
|
+
/* @fileverse-dev/formulajs v4.4.21-price-and-wallet-8 */
|
|
2
2
|
var _excluded = [ "confirmations", "dataDecoded" ];
|
|
3
3
|
|
|
4
4
|
function _objectWithoutProperties(e, t) {
|
|
@@ -19062,7 +19062,7 @@ function _typeof(o) {
|
|
|
19062
19062
|
input2: stringType().optional(),
|
|
19063
19063
|
input3: stringType().optional()
|
|
19064
19064
|
}).superRefine((function(data, ctx) {
|
|
19065
|
-
var _data$input;
|
|
19065
|
+
var _data$input, _data$input2;
|
|
19066
19066
|
if (!isAddress$1.isAddress(data.input1)) return;
|
|
19067
19067
|
if (!data.input2) {
|
|
19068
19068
|
ctx.addIssue({
|
|
@@ -19078,13 +19078,20 @@ function _typeof(o) {
|
|
|
19078
19078
|
path: [ "input2" ]
|
|
19079
19079
|
});
|
|
19080
19080
|
}
|
|
19081
|
+
if (((_data$input2 = data.input1) === null || _data$input2 === void 0 ? void 0 : _data$input2.split(",").length) > 1) {
|
|
19082
|
+
ctx.addIssue({
|
|
19083
|
+
code: ZodIssueCode.custom,
|
|
19084
|
+
message: "You can query a single token address at a time.",
|
|
19085
|
+
path: [ "input1" ]
|
|
19086
|
+
});
|
|
19087
|
+
}
|
|
19081
19088
|
}));
|
|
19082
19089
|
function PRICE() {
|
|
19083
19090
|
return _PRICE.apply(this, arguments);
|
|
19084
19091
|
}
|
|
19085
19092
|
function _PRICE() {
|
|
19086
19093
|
_PRICE = _asyncToGenerator(_regeneratorRuntime().mark((function _callee32() {
|
|
19087
|
-
var _argsToArray33, _argsToArray34, input1, input2, input3, baseUrl, url, returnSingleValue, tokenAddress, coin, res, errorData, _data9, _args36 = arguments;
|
|
19094
|
+
var _input, _input2, _input3, _argsToArray33, _argsToArray34, input1, input2, input3, baseUrl, url, returnSingleValue, tokenAddress, coin, res, errorData, _data9, _args36 = arguments;
|
|
19088
19095
|
return _regeneratorRuntime().wrap((function _callee32$(_context36) {
|
|
19089
19096
|
while (1) switch (_context36.prev = _context36.next) {
|
|
19090
19097
|
case 0:
|
|
@@ -19096,6 +19103,9 @@ function _typeof(o) {
|
|
|
19096
19103
|
input2: input2,
|
|
19097
19104
|
input3: input3
|
|
19098
19105
|
});
|
|
19106
|
+
input1 = (_input = input1) === null || _input === void 0 ? void 0 : _input.replace(/\s+/g, "");
|
|
19107
|
+
input2 = (_input2 = input2) === null || _input2 === void 0 ? void 0 : _input2.replace(/\s+/g, "");
|
|
19108
|
+
input3 = (_input3 = input3) === null || _input3 === void 0 ? void 0 : _input3.replace(/\s+/g, "");
|
|
19099
19109
|
baseUrl = window.useLocal ? "http://localhost:3000" : "https://onchain-proxy.fileverse.io";
|
|
19100
19110
|
url = "".concat(baseUrl) + "/third-party?service=price";
|
|
19101
19111
|
returnSingleValue = false;
|
|
@@ -19103,65 +19113,65 @@ function _typeof(o) {
|
|
|
19103
19113
|
tokenAddress = input1;
|
|
19104
19114
|
url += "&token=".concat(tokenAddress, "&chain=").concat(input2);
|
|
19105
19115
|
if (input3) {
|
|
19106
|
-
url += "&time=".concat(
|
|
19116
|
+
url += "&time=".concat(input3);
|
|
19107
19117
|
}
|
|
19108
19118
|
} else {
|
|
19109
|
-
coin = input1
|
|
19119
|
+
coin = input1;
|
|
19110
19120
|
url += "&coin=".concat(coin);
|
|
19111
19121
|
if (input2) {
|
|
19112
|
-
url += "&time=".concat(
|
|
19113
|
-
} else if (coin.split(",") === 1) {
|
|
19122
|
+
url += "&time=".concat(input2);
|
|
19123
|
+
} else if (coin.split(",").length === 1) {
|
|
19114
19124
|
returnSingleValue = true;
|
|
19115
19125
|
}
|
|
19116
19126
|
}
|
|
19117
|
-
_context36.next =
|
|
19127
|
+
_context36.next = 12;
|
|
19118
19128
|
return fetch(url);
|
|
19119
19129
|
|
|
19120
|
-
case
|
|
19130
|
+
case 12:
|
|
19121
19131
|
res = _context36.sent;
|
|
19122
19132
|
if (!(res.status === 400)) {
|
|
19123
|
-
_context36.next =
|
|
19133
|
+
_context36.next = 18;
|
|
19124
19134
|
break;
|
|
19125
19135
|
}
|
|
19126
|
-
_context36.next =
|
|
19136
|
+
_context36.next = 16;
|
|
19127
19137
|
return res.json();
|
|
19128
19138
|
|
|
19129
|
-
case
|
|
19139
|
+
case 16:
|
|
19130
19140
|
errorData = _context36.sent;
|
|
19131
19141
|
throw new ValidationError(errorData.message);
|
|
19132
19142
|
|
|
19133
|
-
case
|
|
19143
|
+
case 18:
|
|
19134
19144
|
if (res.ok) {
|
|
19135
|
-
_context36.next =
|
|
19145
|
+
_context36.next = 20;
|
|
19136
19146
|
break;
|
|
19137
19147
|
}
|
|
19138
19148
|
throw new NetworkError("PRICE", res.status);
|
|
19139
19149
|
|
|
19140
|
-
case
|
|
19141
|
-
_context36.next =
|
|
19150
|
+
case 20:
|
|
19151
|
+
_context36.next = 22;
|
|
19142
19152
|
return res.json();
|
|
19143
19153
|
|
|
19144
|
-
case
|
|
19154
|
+
case 22:
|
|
19145
19155
|
_data9 = _context36.sent;
|
|
19146
19156
|
if (!returnSingleValue) {
|
|
19147
|
-
_context36.next =
|
|
19157
|
+
_context36.next = 25;
|
|
19148
19158
|
break;
|
|
19149
19159
|
}
|
|
19150
19160
|
return _context36.abrupt("return", _data9[0].price);
|
|
19151
19161
|
|
|
19152
|
-
case
|
|
19162
|
+
case 25:
|
|
19153
19163
|
return _context36.abrupt("return", _data9);
|
|
19154
19164
|
|
|
19155
|
-
case
|
|
19156
|
-
_context36.prev =
|
|
19165
|
+
case 28:
|
|
19166
|
+
_context36.prev = 28;
|
|
19157
19167
|
_context36.t0 = _context36["catch"](0);
|
|
19158
19168
|
return _context36.abrupt("return", errorMessageHandler(_context36.t0, "PRICE"));
|
|
19159
19169
|
|
|
19160
|
-
case
|
|
19170
|
+
case 31:
|
|
19161
19171
|
case "end":
|
|
19162
19172
|
return _context36.stop();
|
|
19163
19173
|
}
|
|
19164
|
-
}), _callee32, null, [ [ 0,
|
|
19174
|
+
}), _callee32, null, [ [ 0, 28 ] ]);
|
|
19165
19175
|
})));
|
|
19166
19176
|
return _PRICE.apply(this, arguments);
|
|
19167
19177
|
}
|
|
@@ -19240,7 +19250,7 @@ function _typeof(o) {
|
|
|
19240
19250
|
}
|
|
19241
19251
|
function _WALLET() {
|
|
19242
19252
|
_WALLET = _asyncToGenerator(_regeneratorRuntime().mark((function _callee33() {
|
|
19243
|
-
var _argsToArray35, _argsToArray36, addresses, chains, query, time, baseUrl, resolvedAddresses, url, res, errorData, json, _args37 = arguments;
|
|
19253
|
+
var _addresses, _chains, _chains2, _argsToArray35, _argsToArray36, addresses, chains, query, time, baseUrl, resolvedAddresses, url, res, errorData, json, _args37 = arguments;
|
|
19244
19254
|
return _regeneratorRuntime().wrap((function _callee33$(_context37) {
|
|
19245
19255
|
while (1) switch (_context37.prev = _context37.next) {
|
|
19246
19256
|
case 0:
|
|
@@ -19254,58 +19264,60 @@ function _typeof(o) {
|
|
|
19254
19264
|
query: query,
|
|
19255
19265
|
time: time
|
|
19256
19266
|
});
|
|
19257
|
-
addresses = addresses.replace(/\s+/g, "");
|
|
19267
|
+
addresses = (_addresses = addresses) === null || _addresses === void 0 ? void 0 : _addresses.replace(/\s+/g, "");
|
|
19268
|
+
chains = (_chains = chains) === null || _chains === void 0 ? void 0 : _chains.replace(/\s+/g, "");
|
|
19269
|
+
time = (_chains2 = chains) === null || _chains2 === void 0 ? void 0 : _chains2.replace(/\s+/g, "");
|
|
19258
19270
|
baseUrl = window.useLocal ? "http://localhost:3000" : "https://onchain-proxy.fileverse.io";
|
|
19259
|
-
_context37.next =
|
|
19271
|
+
_context37.next = 9;
|
|
19260
19272
|
return getResolvedAddresses(addresses);
|
|
19261
19273
|
|
|
19262
|
-
case
|
|
19274
|
+
case 9:
|
|
19263
19275
|
resolvedAddresses = _context37.sent;
|
|
19264
19276
|
url = "".concat(baseUrl, "/third-party?service=wallet&addresses=").concat(resolvedAddresses, "&chains=").concat(chains, "&query=").concat(query);
|
|
19265
19277
|
if (time) {
|
|
19266
19278
|
url += "&time=".concat(time);
|
|
19267
19279
|
}
|
|
19268
|
-
_context37.next =
|
|
19280
|
+
_context37.next = 14;
|
|
19269
19281
|
return fetch(url);
|
|
19270
19282
|
|
|
19271
|
-
case
|
|
19283
|
+
case 14:
|
|
19272
19284
|
res = _context37.sent;
|
|
19273
19285
|
if (!(res.status === 400)) {
|
|
19274
|
-
_context37.next =
|
|
19286
|
+
_context37.next = 20;
|
|
19275
19287
|
break;
|
|
19276
19288
|
}
|
|
19277
|
-
_context37.next =
|
|
19289
|
+
_context37.next = 18;
|
|
19278
19290
|
return res.json();
|
|
19279
19291
|
|
|
19280
|
-
case
|
|
19292
|
+
case 18:
|
|
19281
19293
|
errorData = _context37.sent;
|
|
19282
19294
|
throw new ValidationError(errorData.message);
|
|
19283
19295
|
|
|
19284
|
-
case
|
|
19296
|
+
case 20:
|
|
19285
19297
|
if (res.ok) {
|
|
19286
|
-
_context37.next =
|
|
19298
|
+
_context37.next = 22;
|
|
19287
19299
|
break;
|
|
19288
19300
|
}
|
|
19289
19301
|
throw new NetworkError("WALLET", res.status);
|
|
19290
19302
|
|
|
19291
|
-
case
|
|
19292
|
-
_context37.next =
|
|
19303
|
+
case 22:
|
|
19304
|
+
_context37.next = 24;
|
|
19293
19305
|
return res.json();
|
|
19294
19306
|
|
|
19295
|
-
case
|
|
19307
|
+
case 24:
|
|
19296
19308
|
json = _context37.sent;
|
|
19297
19309
|
return _context37.abrupt("return", json);
|
|
19298
19310
|
|
|
19299
|
-
case
|
|
19300
|
-
_context37.prev =
|
|
19311
|
+
case 28:
|
|
19312
|
+
_context37.prev = 28;
|
|
19301
19313
|
_context37.t0 = _context37["catch"](0);
|
|
19302
19314
|
return _context37.abrupt("return", errorMessageHandler(_context37.t0, "WALLET"));
|
|
19303
19315
|
|
|
19304
|
-
case
|
|
19316
|
+
case 31:
|
|
19305
19317
|
case "end":
|
|
19306
19318
|
return _context37.stop();
|
|
19307
19319
|
}
|
|
19308
|
-
}), _callee33, null, [ [ 0,
|
|
19320
|
+
}), _callee33, null, [ [ 0, 28 ] ]);
|
|
19309
19321
|
})));
|
|
19310
19322
|
return _WALLET.apply(this, arguments);
|
|
19311
19323
|
}
|