@bze/bze-ui-kit 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +46 -2
- package/dist/index.d.ts +46 -2
- package/dist/index.js +369 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +358 -136
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -125,6 +125,7 @@ __export(index_exports, {
|
|
|
125
125
|
canDepositFromIBC: () => canDepositFromIBC,
|
|
126
126
|
canSendToIBC: () => canSendToIBC,
|
|
127
127
|
cancelDebounce: () => cancelDebounce,
|
|
128
|
+
checkAddressWonRaffle: () => checkAddressWonRaffle,
|
|
128
129
|
convertToWebSocketUrl: () => convertToWebSocketUrl,
|
|
129
130
|
counterpartyChainForChannel: () => counterpartyChainForChannel,
|
|
130
131
|
createMarketId: () => createMarketId,
|
|
@@ -161,6 +162,10 @@ __export(index_exports, {
|
|
|
161
162
|
getAtomOneRestURL: () => getAtomOneRestURL,
|
|
162
163
|
getAtomOneRpcUrl: () => getAtomOneRpcUrl,
|
|
163
164
|
getBZEUSDPrice: () => getBZEUSDPrice,
|
|
165
|
+
getBlockDetailsByHeight: () => getBlockDetailsByHeight,
|
|
166
|
+
getBlockResults: () => getBlockResults,
|
|
167
|
+
getBlockTimeByHeight: () => getBlockTimeByHeight,
|
|
168
|
+
getBurnerModuleAddress: () => getBurnerModuleAddress,
|
|
164
169
|
getBurnerParams: () => getBurnerParams,
|
|
165
170
|
getBurnerParamsWithClient: () => getBurnerParamsWithClient,
|
|
166
171
|
getChainAddressPrefix: () => getChainAddressPrefix,
|
|
@@ -184,6 +189,7 @@ __export(index_exports, {
|
|
|
184
189
|
getEpochsInfo: () => getEpochsInfo,
|
|
185
190
|
getFactoryDenomAdminAddress: () => getFactoryDenomAdminAddress,
|
|
186
191
|
getFromLocalStorage: () => getFromLocalStorage,
|
|
192
|
+
getHardcodedLockAddress: () => getHardcodedLockAddress,
|
|
187
193
|
getHashIBCTrace: () => getHashIBCTrace,
|
|
188
194
|
getHourEpochInfo: () => getHourEpochInfo,
|
|
189
195
|
getIBCAssetList: () => getIBCAssetList,
|
|
@@ -206,6 +212,8 @@ __export(index_exports, {
|
|
|
206
212
|
getMarketSellOrders: () => getMarketSellOrders,
|
|
207
213
|
getMarkets: () => getMarkets,
|
|
208
214
|
getMinAmount: () => getMinAmount,
|
|
215
|
+
getModuleAddress: () => getModuleAddress,
|
|
216
|
+
getNextBurning: () => getNextBurning,
|
|
209
217
|
getNoOfIntervalsNeeded: () => getNoOfIntervalsNeeded,
|
|
210
218
|
getNobleRestURL: () => getNobleRestURL,
|
|
211
219
|
getNobleRpcUrl: () => getNobleRpcUrl,
|
|
@@ -217,6 +225,9 @@ __export(index_exports, {
|
|
|
217
225
|
getPendingUnlockParticipants: () => getPendingUnlockParticipants,
|
|
218
226
|
getPeriodicEpochEndTime: () => getPeriodicEpochEndTime,
|
|
219
227
|
getPeriodicWeekEpochEndTime: () => getPeriodicWeekEpochEndTime,
|
|
228
|
+
getRaffleModuleAddress: () => getRaffleModuleAddress,
|
|
229
|
+
getRaffleWinners: () => getRaffleWinners,
|
|
230
|
+
getRaffles: () => getRaffles,
|
|
220
231
|
getRestClient: () => getRestClient,
|
|
221
232
|
getRestURL: () => getRestURL,
|
|
222
233
|
getRpcURL: () => getRpcURL,
|
|
@@ -950,11 +961,28 @@ var formatTimeRemaining = (targetDate) => {
|
|
|
950
961
|
if (minutes > 0) parts.push(`${minutes}m`);
|
|
951
962
|
return parts.join(" ") || "Now";
|
|
952
963
|
};
|
|
953
|
-
|
|
954
|
-
|
|
964
|
+
function formatTimeRemainingFromEpochs(endEpoch, currentEpoch) {
|
|
965
|
+
let epochDiff;
|
|
966
|
+
if (currentEpoch !== void 0) {
|
|
967
|
+
const endBN = toBigNumber(endEpoch);
|
|
968
|
+
const currentBN = toBigNumber(currentEpoch);
|
|
969
|
+
epochDiff = endBN.minus(currentBN);
|
|
970
|
+
if (epochDiff.lte(0)) {
|
|
971
|
+
return "Ended";
|
|
972
|
+
}
|
|
973
|
+
const hoursRemaining = epochDiff.toNumber();
|
|
974
|
+
const daysRemaining = Math.floor(hoursRemaining / 24);
|
|
975
|
+
const hoursRemainder = hoursRemaining % 24;
|
|
976
|
+
if (daysRemaining > 0) {
|
|
977
|
+
return `${daysRemaining}d ${hoursRemainder}h`;
|
|
978
|
+
}
|
|
979
|
+
return `${hoursRemainder}h`;
|
|
980
|
+
}
|
|
981
|
+
epochDiff = toBigNumber(endEpoch);
|
|
982
|
+
if (epochDiff.lte(0)) {
|
|
955
983
|
return "Now";
|
|
956
984
|
}
|
|
957
|
-
const totalSeconds =
|
|
985
|
+
const totalSeconds = epochDiff.multipliedBy(60).toNumber();
|
|
958
986
|
const days = Math.floor(totalSeconds / (60 * 60 * 24));
|
|
959
987
|
const hours = Math.floor(totalSeconds % (60 * 60 * 24) / (60 * 60));
|
|
960
988
|
const minutes = Math.floor(totalSeconds % (60 * 60) / 60);
|
|
@@ -963,7 +991,7 @@ var formatTimeRemainingFromEpochs = (epochs) => {
|
|
|
963
991
|
if (hours > 0) parts.push(`${hours}h`);
|
|
964
992
|
if (minutes > 0) parts.push(`${minutes}m`);
|
|
965
993
|
return parts.join(" ") || "Now";
|
|
966
|
-
}
|
|
994
|
+
}
|
|
967
995
|
|
|
968
996
|
// src/utils/functions.ts
|
|
969
997
|
async function sleep(ms) {
|
|
@@ -1247,6 +1275,207 @@ var getPageRequestWithLimit = (limit) => {
|
|
|
1247
1275
|
// src/query/burner.ts
|
|
1248
1276
|
var import_bzejs2 = require("@bze/bzejs");
|
|
1249
1277
|
var import_pagination2 = require("@bze/bzejs/cosmos/base/query/v1beta1/pagination");
|
|
1278
|
+
|
|
1279
|
+
// src/constants/endpoints.ts
|
|
1280
|
+
function getRestURL() {
|
|
1281
|
+
return process.env.NEXT_PUBLIC_REST_URL || "";
|
|
1282
|
+
}
|
|
1283
|
+
function getRpcURL() {
|
|
1284
|
+
return process.env.NEXT_PUBLIC_RPC_URL || "";
|
|
1285
|
+
}
|
|
1286
|
+
function getArchwayRpcURL() {
|
|
1287
|
+
return process.env.NEXT_PUBLIC_RPC_URL_ARCHWAY || "";
|
|
1288
|
+
}
|
|
1289
|
+
function getOsmosisRpcUrl() {
|
|
1290
|
+
return process.env.NEXT_PUBLIC_RPC_URL_OSMOSIS || "";
|
|
1291
|
+
}
|
|
1292
|
+
function getNobleRpcUrl() {
|
|
1293
|
+
return process.env.NEXT_PUBLIC_RPC_URL_NOBLE || "";
|
|
1294
|
+
}
|
|
1295
|
+
function getJackalRpcUrl() {
|
|
1296
|
+
return process.env.NEXT_PUBLIC_RPC_URL_JACKAL || "";
|
|
1297
|
+
}
|
|
1298
|
+
function getOmniFlixRpcUrl() {
|
|
1299
|
+
return process.env.NEXT_PUBLIC_RPC_URL_FLIX || "";
|
|
1300
|
+
}
|
|
1301
|
+
function getAtomOneRpcUrl() {
|
|
1302
|
+
return process.env.NEXT_PUBLIC_RPC_URL_ATOMONE || "";
|
|
1303
|
+
}
|
|
1304
|
+
function getArchwayRestURL() {
|
|
1305
|
+
return process.env.NEXT_PUBLIC_REST_URL_ARCHWAY || "";
|
|
1306
|
+
}
|
|
1307
|
+
function getOsmosisRestURL() {
|
|
1308
|
+
return process.env.NEXT_PUBLIC_REST_URL_OSMOSIS || "";
|
|
1309
|
+
}
|
|
1310
|
+
function getNobleRestURL() {
|
|
1311
|
+
return process.env.NEXT_PUBLIC_REST_URL_NOBLE || "";
|
|
1312
|
+
}
|
|
1313
|
+
function getJackalRestURL() {
|
|
1314
|
+
return process.env.NEXT_PUBLIC_REST_URL_JACKAL || "";
|
|
1315
|
+
}
|
|
1316
|
+
function getOmniFlixRestURL() {
|
|
1317
|
+
return process.env.NEXT_PUBLIC_REST_URL_FLIX || "";
|
|
1318
|
+
}
|
|
1319
|
+
function getAtomOneRestURL() {
|
|
1320
|
+
return process.env.NEXT_PUBLIC_REST_URL_ATOMONE || "";
|
|
1321
|
+
}
|
|
1322
|
+
var getAggregatorHost = () => {
|
|
1323
|
+
var _a2;
|
|
1324
|
+
return (_a2 = process.env.NEXT_PUBLIC_AGG_API_HOST) != null ? _a2 : "https://getbze.com";
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
// src/query/module.ts
|
|
1328
|
+
var MODULE_ADDRESS_KEY = "auth:module:address:";
|
|
1329
|
+
var MODULE_ADDRESS_CACHE_TTL = 60 * 60 * 48;
|
|
1330
|
+
function getHardcodedBurnerAddress() {
|
|
1331
|
+
return "bze1v7uw4xhrcv0vk7qp8jf9lu3hm5d8uu5yjp5qun";
|
|
1332
|
+
}
|
|
1333
|
+
function getHardcodedRaffleAddress() {
|
|
1334
|
+
return "bze18hsqalgwlzqavrrkfnxmrjmygwyjy8senx5tgs";
|
|
1335
|
+
}
|
|
1336
|
+
function getHardcodedLockAddress() {
|
|
1337
|
+
return "bze1pc5zjcvhx3e8l305zjl72grytfa30r5mdypmw4";
|
|
1338
|
+
}
|
|
1339
|
+
function getBurnerModuleAddress() {
|
|
1340
|
+
return getHardcodedBurnerAddress();
|
|
1341
|
+
}
|
|
1342
|
+
function getRaffleModuleAddress() {
|
|
1343
|
+
return getHardcodedRaffleAddress();
|
|
1344
|
+
}
|
|
1345
|
+
async function getModuleAddress(module2) {
|
|
1346
|
+
var _a2;
|
|
1347
|
+
try {
|
|
1348
|
+
const cacheKey = `${MODULE_ADDRESS_KEY}${module2}`;
|
|
1349
|
+
const localData = getFromLocalStorage(cacheKey);
|
|
1350
|
+
if (null !== localData) {
|
|
1351
|
+
return localData;
|
|
1352
|
+
}
|
|
1353
|
+
const url = getRestURL();
|
|
1354
|
+
const response = await fetch(`${url}/cosmos/auth/v1beta1/module_accounts/${module2}`);
|
|
1355
|
+
if (!response.ok) {
|
|
1356
|
+
return "";
|
|
1357
|
+
}
|
|
1358
|
+
const parsed = await response.json();
|
|
1359
|
+
const addy = (_a2 = parsed.account.base_account) == null ? void 0 : _a2.address;
|
|
1360
|
+
if (addy === void 0) {
|
|
1361
|
+
return "";
|
|
1362
|
+
}
|
|
1363
|
+
setInLocalStorage(cacheKey, addy, MODULE_ADDRESS_CACHE_TTL);
|
|
1364
|
+
return addy;
|
|
1365
|
+
} catch (e) {
|
|
1366
|
+
console.error(e);
|
|
1367
|
+
return "";
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
// src/query/bank.ts
|
|
1372
|
+
async function getAddressBalances(address) {
|
|
1373
|
+
try {
|
|
1374
|
+
const client = await getRestClient();
|
|
1375
|
+
const response = await client.cosmos.bank.v1beta1.spendableBalances({ address });
|
|
1376
|
+
return response.balances;
|
|
1377
|
+
} catch (e) {
|
|
1378
|
+
console.error("failed to get balances", e);
|
|
1379
|
+
return [];
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
async function getLockedBalances() {
|
|
1383
|
+
try {
|
|
1384
|
+
const lockerAddress = getLockerAddress();
|
|
1385
|
+
if (!lockerAddress) {
|
|
1386
|
+
console.warn("Locker address not configured");
|
|
1387
|
+
return [];
|
|
1388
|
+
}
|
|
1389
|
+
return await getAddressBalances(lockerAddress);
|
|
1390
|
+
} catch (e) {
|
|
1391
|
+
console.error("failed to get locked balances", e);
|
|
1392
|
+
return [];
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
// src/query/epoch.ts
|
|
1397
|
+
var EPOCH_HOUR = "hour";
|
|
1398
|
+
var EPOCH_DAY = "day";
|
|
1399
|
+
var EPOCH_WEEK = "week";
|
|
1400
|
+
var EPOCHS_INFO_CACHE_KEY = "epochs:info";
|
|
1401
|
+
var EPOCHS_INFO_CACHE_TTL = 60 * 60;
|
|
1402
|
+
async function getEpochsInfo() {
|
|
1403
|
+
try {
|
|
1404
|
+
const cachedData = getFromLocalStorage(EPOCHS_INFO_CACHE_KEY);
|
|
1405
|
+
let shouldFetchFromEndpoint = false;
|
|
1406
|
+
if (cachedData !== null) {
|
|
1407
|
+
const cached = JSON.parse(cachedData);
|
|
1408
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1409
|
+
for (const epoch of cached.epochs) {
|
|
1410
|
+
if (epoch.current_epoch_start_time) {
|
|
1411
|
+
const startTime = new Date(epoch.current_epoch_start_time).getTime();
|
|
1412
|
+
const duration = getEpochDurationByIdentifier(epoch.identifier);
|
|
1413
|
+
const epochEndTime = startTime + duration - 15 * 1e3;
|
|
1414
|
+
if (now >= epochEndTime) {
|
|
1415
|
+
shouldFetchFromEndpoint = true;
|
|
1416
|
+
break;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
if (!shouldFetchFromEndpoint) {
|
|
1421
|
+
return cached;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
const client = await getRestClient();
|
|
1425
|
+
const response = await client.bze.epochs.epochInfos();
|
|
1426
|
+
setInLocalStorage(EPOCHS_INFO_CACHE_KEY, JSON.stringify(response), EPOCHS_INFO_CACHE_TTL);
|
|
1427
|
+
return response;
|
|
1428
|
+
} catch (e) {
|
|
1429
|
+
console.error(e);
|
|
1430
|
+
return { epochs: [] };
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
async function getCurrentEpoch(identifier) {
|
|
1434
|
+
const all = await getEpochsInfo();
|
|
1435
|
+
return all.epochs.find((item) => item.identifier === identifier);
|
|
1436
|
+
}
|
|
1437
|
+
async function getHourEpochInfo() {
|
|
1438
|
+
return getCurrentEpoch(EPOCH_HOUR);
|
|
1439
|
+
}
|
|
1440
|
+
async function getWeekEpochInfo() {
|
|
1441
|
+
return getCurrentEpoch(EPOCH_WEEK);
|
|
1442
|
+
}
|
|
1443
|
+
async function getCurrentWeekEpochEndTime() {
|
|
1444
|
+
return getPeriodicEpochEndTime(EPOCH_WEEK);
|
|
1445
|
+
}
|
|
1446
|
+
async function getPeriodicWeekEpochEndTime(modWeek = 1) {
|
|
1447
|
+
return getPeriodicEpochEndTime(EPOCH_WEEK, modWeek);
|
|
1448
|
+
}
|
|
1449
|
+
async function getPeriodicEpochEndTime(identifier, mod = 1) {
|
|
1450
|
+
const epoch = await getCurrentEpoch(identifier);
|
|
1451
|
+
if (!epoch || !epoch.current_epoch_start_time) {
|
|
1452
|
+
return void 0;
|
|
1453
|
+
}
|
|
1454
|
+
const current = toBigNumber(epoch.current_epoch);
|
|
1455
|
+
let remainingEpochs = mod - current.toNumber() % mod;
|
|
1456
|
+
if (remainingEpochs === mod) {
|
|
1457
|
+
remainingEpochs = 0;
|
|
1458
|
+
}
|
|
1459
|
+
const startAt = new Date(epoch.current_epoch_start_time);
|
|
1460
|
+
const duration = getEpochDurationByIdentifier(identifier);
|
|
1461
|
+
startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
|
|
1462
|
+
return startAt;
|
|
1463
|
+
}
|
|
1464
|
+
function getEpochDurationByIdentifier(identifier) {
|
|
1465
|
+
const hourMs = 60 * 60 * 1e3;
|
|
1466
|
+
switch (identifier) {
|
|
1467
|
+
case EPOCH_HOUR:
|
|
1468
|
+
return hourMs;
|
|
1469
|
+
case EPOCH_DAY:
|
|
1470
|
+
return hourMs * 24;
|
|
1471
|
+
case EPOCH_WEEK:
|
|
1472
|
+
return hourMs * 24 * 7;
|
|
1473
|
+
default:
|
|
1474
|
+
return hourMs;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
// src/query/burner.ts
|
|
1250
1479
|
var BURNED_KEY = "burner:all_burned_coins";
|
|
1251
1480
|
var LOCAL_CACHE_TTL = 60 * 60 * 4;
|
|
1252
1481
|
var { fromPartial: QueryAllBurnedCoinsRequestFromPartial } = import_bzejs2.bze.burner.QueryAllBurnedCoinsRequest;
|
|
@@ -1292,6 +1521,33 @@ async function getAllBurnedCoins() {
|
|
|
1292
1521
|
};
|
|
1293
1522
|
}
|
|
1294
1523
|
}
|
|
1524
|
+
var BURN_EPOCH_COUNT = 4;
|
|
1525
|
+
async function getNextBurning() {
|
|
1526
|
+
const address = getBurnerModuleAddress();
|
|
1527
|
+
if (address === "") {
|
|
1528
|
+
return void 0;
|
|
1529
|
+
}
|
|
1530
|
+
const balances = await getAddressBalances(address);
|
|
1531
|
+
if (balances.length === 0) {
|
|
1532
|
+
return void 0;
|
|
1533
|
+
}
|
|
1534
|
+
const timeFromEpoch = await getBurningTimeFromEpoch();
|
|
1535
|
+
if (!timeFromEpoch) {
|
|
1536
|
+
return void 0;
|
|
1537
|
+
}
|
|
1538
|
+
return {
|
|
1539
|
+
coins: balances,
|
|
1540
|
+
date: timeFromEpoch
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
async function getBurningTimeFromEpoch() {
|
|
1544
|
+
const params = await getBurnerParams();
|
|
1545
|
+
let defaultBurningMod = BURN_EPOCH_COUNT;
|
|
1546
|
+
if (params) {
|
|
1547
|
+
defaultBurningMod = toBigNumber(params.periodic_burning_weeks).toNumber();
|
|
1548
|
+
}
|
|
1549
|
+
return await getPeriodicWeekEpochEndTime(defaultBurningMod);
|
|
1550
|
+
}
|
|
1295
1551
|
|
|
1296
1552
|
// src/utils/validation.ts
|
|
1297
1553
|
function isValidUrl(urlString) {
|
|
@@ -1412,54 +1668,6 @@ var isPoolSupportedByValidator = (baseDenom, quoteDenom) => {
|
|
|
1412
1668
|
return supportedDenoms.includes(baseDenom) || supportedDenoms.includes(quoteDenom);
|
|
1413
1669
|
};
|
|
1414
1670
|
|
|
1415
|
-
// src/constants/endpoints.ts
|
|
1416
|
-
function getRestURL() {
|
|
1417
|
-
return process.env.NEXT_PUBLIC_REST_URL || "";
|
|
1418
|
-
}
|
|
1419
|
-
function getRpcURL() {
|
|
1420
|
-
return process.env.NEXT_PUBLIC_RPC_URL || "";
|
|
1421
|
-
}
|
|
1422
|
-
function getArchwayRpcURL() {
|
|
1423
|
-
return process.env.NEXT_PUBLIC_RPC_URL_ARCHWAY || "";
|
|
1424
|
-
}
|
|
1425
|
-
function getOsmosisRpcUrl() {
|
|
1426
|
-
return process.env.NEXT_PUBLIC_RPC_URL_OSMOSIS || "";
|
|
1427
|
-
}
|
|
1428
|
-
function getNobleRpcUrl() {
|
|
1429
|
-
return process.env.NEXT_PUBLIC_RPC_URL_NOBLE || "";
|
|
1430
|
-
}
|
|
1431
|
-
function getJackalRpcUrl() {
|
|
1432
|
-
return process.env.NEXT_PUBLIC_RPC_URL_JACKAL || "";
|
|
1433
|
-
}
|
|
1434
|
-
function getOmniFlixRpcUrl() {
|
|
1435
|
-
return process.env.NEXT_PUBLIC_RPC_URL_FLIX || "";
|
|
1436
|
-
}
|
|
1437
|
-
function getAtomOneRpcUrl() {
|
|
1438
|
-
return process.env.NEXT_PUBLIC_RPC_URL_ATOMONE || "";
|
|
1439
|
-
}
|
|
1440
|
-
function getArchwayRestURL() {
|
|
1441
|
-
return process.env.NEXT_PUBLIC_REST_URL_ARCHWAY || "";
|
|
1442
|
-
}
|
|
1443
|
-
function getOsmosisRestURL() {
|
|
1444
|
-
return process.env.NEXT_PUBLIC_REST_URL_OSMOSIS || "";
|
|
1445
|
-
}
|
|
1446
|
-
function getNobleRestURL() {
|
|
1447
|
-
return process.env.NEXT_PUBLIC_REST_URL_NOBLE || "";
|
|
1448
|
-
}
|
|
1449
|
-
function getJackalRestURL() {
|
|
1450
|
-
return process.env.NEXT_PUBLIC_REST_URL_JACKAL || "";
|
|
1451
|
-
}
|
|
1452
|
-
function getOmniFlixRestURL() {
|
|
1453
|
-
return process.env.NEXT_PUBLIC_REST_URL_FLIX || "";
|
|
1454
|
-
}
|
|
1455
|
-
function getAtomOneRestURL() {
|
|
1456
|
-
return process.env.NEXT_PUBLIC_REST_URL_ATOMONE || "";
|
|
1457
|
-
}
|
|
1458
|
-
var getAggregatorHost = () => {
|
|
1459
|
-
var _a2;
|
|
1460
|
-
return (_a2 = process.env.NEXT_PUBLIC_AGG_API_HOST) != null ? _a2 : "https://getbze.com";
|
|
1461
|
-
};
|
|
1462
|
-
|
|
1463
1671
|
// src/constants/market.ts
|
|
1464
1672
|
var EXCLUDED_MARKETS = {
|
|
1465
1673
|
"factory/bze1f0qgels0eu96ev6a67znu70q7rquy9eragn8nw/ucorey/factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl": true,
|
|
@@ -2273,111 +2481,125 @@ async function keplrSuggestChain(chainId) {
|
|
|
2273
2481
|
return await ((_a2 = window.keplr) == null ? void 0 : _a2.experimentalSuggestChain(await getKeplrChainInfo(chainId)));
|
|
2274
2482
|
}
|
|
2275
2483
|
|
|
2276
|
-
// src/query/
|
|
2277
|
-
|
|
2484
|
+
// src/query/block.ts
|
|
2485
|
+
var FAILOVER_BLOCKTIMES = {
|
|
2486
|
+
"9334084": "2023-12-07T14:30:55.034845214Z",
|
|
2487
|
+
"4423602": "2023-01-18T07:51:31.391193017Z",
|
|
2488
|
+
"4827583": "2023-02-14T03:34:27.791387761Z",
|
|
2489
|
+
"5149043": "2023-03-07T11:41:10.455072975Z",
|
|
2490
|
+
"10855457": "2024-03-17T19:41:34.031980836Z"
|
|
2491
|
+
};
|
|
2492
|
+
var BLOCK_KEY = "tendermint:block:";
|
|
2493
|
+
async function getBlockDetailsByHeight(height) {
|
|
2278
2494
|
try {
|
|
2495
|
+
const cacheKey = `${BLOCK_KEY}${height}`;
|
|
2496
|
+
const localData = getFromLocalStorage(cacheKey);
|
|
2497
|
+
if (null !== localData) {
|
|
2498
|
+
const parsed = JSON.parse(localData);
|
|
2499
|
+
if (parsed) {
|
|
2500
|
+
return parsed;
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2279
2503
|
const client = await getRestClient();
|
|
2280
|
-
const response = await client.cosmos.
|
|
2281
|
-
|
|
2504
|
+
const response = await client.cosmos.base.tendermint.v1beta1.getBlockByHeight({ height: BigInt(height.toFixed(0)) });
|
|
2505
|
+
setInLocalStorage(cacheKey, JSON.stringify(response), 0);
|
|
2506
|
+
return response;
|
|
2282
2507
|
} catch (e) {
|
|
2283
|
-
console.error(
|
|
2284
|
-
return
|
|
2508
|
+
console.error(e);
|
|
2509
|
+
return {};
|
|
2285
2510
|
}
|
|
2286
2511
|
}
|
|
2287
|
-
async function
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
return [];
|
|
2512
|
+
async function getBlockTimeByHeight(height) {
|
|
2513
|
+
var _a2, _b2;
|
|
2514
|
+
const details = await getBlockDetailsByHeight(height);
|
|
2515
|
+
if (details.block_id === void 0) {
|
|
2516
|
+
if (height.toFixed(0) in FAILOVER_BLOCKTIMES) {
|
|
2517
|
+
return new Date(FAILOVER_BLOCKTIMES[height.toFixed(0)]);
|
|
2293
2518
|
}
|
|
2294
|
-
return await getAddressBalances(lockerAddress);
|
|
2295
|
-
} catch (e) {
|
|
2296
|
-
console.error("failed to get locked balances", e);
|
|
2297
|
-
return [];
|
|
2298
2519
|
}
|
|
2520
|
+
return (_b2 = (_a2 = details.block) == null ? void 0 : _a2.header) == null ? void 0 : _b2.time;
|
|
2299
2521
|
}
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
var EPOCH_WEEK = "week";
|
|
2305
|
-
var EPOCHS_INFO_CACHE_KEY = "epochs:info";
|
|
2306
|
-
var EPOCHS_INFO_CACHE_TTL = 60 * 60;
|
|
2307
|
-
async function getEpochsInfo() {
|
|
2522
|
+
async function getBlockResults(height) {
|
|
2523
|
+
const settings = getSettings();
|
|
2524
|
+
const rpcUrl = settings.endpoints.rpcEndpoint.replace("wss", "https");
|
|
2525
|
+
const url = `${rpcUrl}/block_results?height=${height}`;
|
|
2308
2526
|
try {
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
2314
|
-
for (const epoch of cached.epochs) {
|
|
2315
|
-
if (epoch.current_epoch_start_time) {
|
|
2316
|
-
const startTime = new Date(epoch.current_epoch_start_time).getTime();
|
|
2317
|
-
const duration = getEpochDurationByIdentifier(epoch.identifier);
|
|
2318
|
-
const epochEndTime = startTime + duration - 15 * 1e3;
|
|
2319
|
-
if (now >= epochEndTime) {
|
|
2320
|
-
shouldFetchFromEndpoint = true;
|
|
2321
|
-
break;
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
if (!shouldFetchFromEndpoint) {
|
|
2326
|
-
return cached;
|
|
2527
|
+
const response = await fetch(url, {
|
|
2528
|
+
method: "GET",
|
|
2529
|
+
headers: {
|
|
2530
|
+
"Content-Type": "application/json"
|
|
2327
2531
|
}
|
|
2532
|
+
});
|
|
2533
|
+
if (!response.ok) {
|
|
2534
|
+
console.log("not ok response from RPC: ", response);
|
|
2535
|
+
return void 0;
|
|
2328
2536
|
}
|
|
2537
|
+
return await response.json();
|
|
2538
|
+
} catch (error) {
|
|
2539
|
+
console.error("Failed to fetch block results:", error);
|
|
2540
|
+
throw error;
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
// src/query/raffle.ts
|
|
2545
|
+
async function getRaffles() {
|
|
2546
|
+
try {
|
|
2329
2547
|
const client = await getRestClient();
|
|
2330
|
-
const response = await client.bze.
|
|
2331
|
-
|
|
2332
|
-
return response;
|
|
2548
|
+
const response = await client.bze.burner.raffles();
|
|
2549
|
+
return response.list;
|
|
2333
2550
|
} catch (e) {
|
|
2334
2551
|
console.error(e);
|
|
2335
|
-
return
|
|
2552
|
+
return [];
|
|
2336
2553
|
}
|
|
2337
2554
|
}
|
|
2338
|
-
async function
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
}
|
|
2348
|
-
async function getCurrentWeekEpochEndTime() {
|
|
2349
|
-
return getPeriodicEpochEndTime(EPOCH_WEEK);
|
|
2350
|
-
}
|
|
2351
|
-
async function getPeriodicWeekEpochEndTime(modWeek = 1) {
|
|
2352
|
-
return getPeriodicEpochEndTime(EPOCH_WEEK, modWeek);
|
|
2555
|
+
async function getRaffleWinners(denom) {
|
|
2556
|
+
try {
|
|
2557
|
+
const client = await getRestClient();
|
|
2558
|
+
const response = await client.bze.burner.raffleWinners({ denom });
|
|
2559
|
+
return response.list;
|
|
2560
|
+
} catch (e) {
|
|
2561
|
+
console.error(e);
|
|
2562
|
+
return [];
|
|
2563
|
+
}
|
|
2353
2564
|
}
|
|
2354
|
-
async function
|
|
2355
|
-
|
|
2356
|
-
|
|
2565
|
+
async function checkAddressWonRaffle(address, denom, height) {
|
|
2566
|
+
var _a2;
|
|
2567
|
+
const response = {
|
|
2568
|
+
hasWon: false,
|
|
2569
|
+
amount: "0",
|
|
2570
|
+
denom,
|
|
2571
|
+
address
|
|
2572
|
+
};
|
|
2573
|
+
if (address == "" || height <= 0) {
|
|
2357
2574
|
return void 0;
|
|
2358
2575
|
}
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
remainingEpochs = 0;
|
|
2576
|
+
const blockResults = await getBlockResults(height);
|
|
2577
|
+
if (!blockResults) {
|
|
2578
|
+
return void 0;
|
|
2363
2579
|
}
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
const
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2580
|
+
if (!((_a2 = blockResults.result) == null ? void 0 : _a2.finalize_block_events)) {
|
|
2581
|
+
return void 0;
|
|
2582
|
+
}
|
|
2583
|
+
if (blockResults.result.finalize_block_events.length === 0) {
|
|
2584
|
+
return void 0;
|
|
2585
|
+
}
|
|
2586
|
+
const raffleEvents = blockResults.result.finalize_block_events.filter((ev) => ev.type.includes("Raffle"));
|
|
2587
|
+
if (!raffleEvents || raffleEvents.length === 0) {
|
|
2588
|
+
return void 0;
|
|
2589
|
+
}
|
|
2590
|
+
for (let i = 0; i < raffleEvents.length; i++) {
|
|
2591
|
+
const ev = raffleEvents[i];
|
|
2592
|
+
const converted = mapEventAttributes(ev.attributes);
|
|
2593
|
+
if ("participant" in converted && ev.type.includes("RaffleLostEvent") && converted["participant"] === address) {
|
|
2594
|
+
return response;
|
|
2595
|
+
}
|
|
2596
|
+
if ("winner" in converted && ev.type.includes("RaffleWinnerEvent") && converted["winner"] === address && converted["denom"] === denom) {
|
|
2597
|
+
response.hasWon = true;
|
|
2598
|
+
response.amount = converted["amount"];
|
|
2599
|
+
return response;
|
|
2600
|
+
}
|
|
2380
2601
|
}
|
|
2602
|
+
return response;
|
|
2381
2603
|
}
|
|
2382
2604
|
|
|
2383
2605
|
// src/query/factory.ts
|
|
@@ -4965,6 +5187,7 @@ function SettingsToggle({ accentColor }) {
|
|
|
4965
5187
|
canDepositFromIBC,
|
|
4966
5188
|
canSendToIBC,
|
|
4967
5189
|
cancelDebounce,
|
|
5190
|
+
checkAddressWonRaffle,
|
|
4968
5191
|
convertToWebSocketUrl,
|
|
4969
5192
|
counterpartyChainForChannel,
|
|
4970
5193
|
createMarketId,
|
|
@@ -5001,6 +5224,10 @@ function SettingsToggle({ accentColor }) {
|
|
|
5001
5224
|
getAtomOneRestURL,
|
|
5002
5225
|
getAtomOneRpcUrl,
|
|
5003
5226
|
getBZEUSDPrice,
|
|
5227
|
+
getBlockDetailsByHeight,
|
|
5228
|
+
getBlockResults,
|
|
5229
|
+
getBlockTimeByHeight,
|
|
5230
|
+
getBurnerModuleAddress,
|
|
5004
5231
|
getBurnerParams,
|
|
5005
5232
|
getBurnerParamsWithClient,
|
|
5006
5233
|
getChainAddressPrefix,
|
|
@@ -5024,6 +5251,7 @@ function SettingsToggle({ accentColor }) {
|
|
|
5024
5251
|
getEpochsInfo,
|
|
5025
5252
|
getFactoryDenomAdminAddress,
|
|
5026
5253
|
getFromLocalStorage,
|
|
5254
|
+
getHardcodedLockAddress,
|
|
5027
5255
|
getHashIBCTrace,
|
|
5028
5256
|
getHourEpochInfo,
|
|
5029
5257
|
getIBCAssetList,
|
|
@@ -5046,6 +5274,8 @@ function SettingsToggle({ accentColor }) {
|
|
|
5046
5274
|
getMarketSellOrders,
|
|
5047
5275
|
getMarkets,
|
|
5048
5276
|
getMinAmount,
|
|
5277
|
+
getModuleAddress,
|
|
5278
|
+
getNextBurning,
|
|
5049
5279
|
getNoOfIntervalsNeeded,
|
|
5050
5280
|
getNobleRestURL,
|
|
5051
5281
|
getNobleRpcUrl,
|
|
@@ -5057,6 +5287,9 @@ function SettingsToggle({ accentColor }) {
|
|
|
5057
5287
|
getPendingUnlockParticipants,
|
|
5058
5288
|
getPeriodicEpochEndTime,
|
|
5059
5289
|
getPeriodicWeekEpochEndTime,
|
|
5290
|
+
getRaffleModuleAddress,
|
|
5291
|
+
getRaffleWinners,
|
|
5292
|
+
getRaffles,
|
|
5060
5293
|
getRestClient,
|
|
5061
5294
|
getRestURL,
|
|
5062
5295
|
getRpcURL,
|