@bze/bze-ui-kit 0.2.1 → 0.3.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/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,
@@ -281,6 +292,7 @@ __export(index_exports, {
281
292
  useBalances: () => useBalances,
282
293
  useConnectionType: () => useConnectionType,
283
294
  useEpochs: () => useEpochs,
295
+ useEpochsManager: () => useEpochsManager,
284
296
  useFeeTokens: () => useFeeTokens,
285
297
  useIBCChains: () => useIBCChains,
286
298
  useIBCTx: () => useIBCTx,
@@ -1246,6 +1258,207 @@ var getPageRequestWithLimit = (limit) => {
1246
1258
  // src/query/burner.ts
1247
1259
  var import_bzejs2 = require("@bze/bzejs");
1248
1260
  var import_pagination2 = require("@bze/bzejs/cosmos/base/query/v1beta1/pagination");
1261
+
1262
+ // src/constants/endpoints.ts
1263
+ function getRestURL() {
1264
+ return process.env.NEXT_PUBLIC_REST_URL || "";
1265
+ }
1266
+ function getRpcURL() {
1267
+ return process.env.NEXT_PUBLIC_RPC_URL || "";
1268
+ }
1269
+ function getArchwayRpcURL() {
1270
+ return process.env.NEXT_PUBLIC_RPC_URL_ARCHWAY || "";
1271
+ }
1272
+ function getOsmosisRpcUrl() {
1273
+ return process.env.NEXT_PUBLIC_RPC_URL_OSMOSIS || "";
1274
+ }
1275
+ function getNobleRpcUrl() {
1276
+ return process.env.NEXT_PUBLIC_RPC_URL_NOBLE || "";
1277
+ }
1278
+ function getJackalRpcUrl() {
1279
+ return process.env.NEXT_PUBLIC_RPC_URL_JACKAL || "";
1280
+ }
1281
+ function getOmniFlixRpcUrl() {
1282
+ return process.env.NEXT_PUBLIC_RPC_URL_FLIX || "";
1283
+ }
1284
+ function getAtomOneRpcUrl() {
1285
+ return process.env.NEXT_PUBLIC_RPC_URL_ATOMONE || "";
1286
+ }
1287
+ function getArchwayRestURL() {
1288
+ return process.env.NEXT_PUBLIC_REST_URL_ARCHWAY || "";
1289
+ }
1290
+ function getOsmosisRestURL() {
1291
+ return process.env.NEXT_PUBLIC_REST_URL_OSMOSIS || "";
1292
+ }
1293
+ function getNobleRestURL() {
1294
+ return process.env.NEXT_PUBLIC_REST_URL_NOBLE || "";
1295
+ }
1296
+ function getJackalRestURL() {
1297
+ return process.env.NEXT_PUBLIC_REST_URL_JACKAL || "";
1298
+ }
1299
+ function getOmniFlixRestURL() {
1300
+ return process.env.NEXT_PUBLIC_REST_URL_FLIX || "";
1301
+ }
1302
+ function getAtomOneRestURL() {
1303
+ return process.env.NEXT_PUBLIC_REST_URL_ATOMONE || "";
1304
+ }
1305
+ var getAggregatorHost = () => {
1306
+ var _a2;
1307
+ return (_a2 = process.env.NEXT_PUBLIC_AGG_API_HOST) != null ? _a2 : "https://getbze.com";
1308
+ };
1309
+
1310
+ // src/query/module.ts
1311
+ var MODULE_ADDRESS_KEY = "auth:module:address:";
1312
+ var MODULE_ADDRESS_CACHE_TTL = 60 * 60 * 48;
1313
+ function getHardcodedBurnerAddress() {
1314
+ return "bze1v7uw4xhrcv0vk7qp8jf9lu3hm5d8uu5yjp5qun";
1315
+ }
1316
+ function getHardcodedRaffleAddress() {
1317
+ return "bze18hsqalgwlzqavrrkfnxmrjmygwyjy8senx5tgs";
1318
+ }
1319
+ function getHardcodedLockAddress() {
1320
+ return "bze1pc5zjcvhx3e8l305zjl72grytfa30r5mdypmw4";
1321
+ }
1322
+ function getBurnerModuleAddress() {
1323
+ return getHardcodedBurnerAddress();
1324
+ }
1325
+ function getRaffleModuleAddress() {
1326
+ return getHardcodedRaffleAddress();
1327
+ }
1328
+ async function getModuleAddress(module2) {
1329
+ var _a2;
1330
+ try {
1331
+ const cacheKey = `${MODULE_ADDRESS_KEY}${module2}`;
1332
+ const localData = getFromLocalStorage(cacheKey);
1333
+ if (null !== localData) {
1334
+ return localData;
1335
+ }
1336
+ const url = getRestURL();
1337
+ const response = await fetch(`${url}/cosmos/auth/v1beta1/module_accounts/${module2}`);
1338
+ if (!response.ok) {
1339
+ return "";
1340
+ }
1341
+ const parsed = await response.json();
1342
+ const addy = (_a2 = parsed.account.base_account) == null ? void 0 : _a2.address;
1343
+ if (addy === void 0) {
1344
+ return "";
1345
+ }
1346
+ setInLocalStorage(cacheKey, addy, MODULE_ADDRESS_CACHE_TTL);
1347
+ return addy;
1348
+ } catch (e) {
1349
+ console.error(e);
1350
+ return "";
1351
+ }
1352
+ }
1353
+
1354
+ // src/query/bank.ts
1355
+ async function getAddressBalances(address) {
1356
+ try {
1357
+ const client = await getRestClient();
1358
+ const response = await client.cosmos.bank.v1beta1.spendableBalances({ address });
1359
+ return response.balances;
1360
+ } catch (e) {
1361
+ console.error("failed to get balances", e);
1362
+ return [];
1363
+ }
1364
+ }
1365
+ async function getLockedBalances() {
1366
+ try {
1367
+ const lockerAddress = getLockerAddress();
1368
+ if (!lockerAddress) {
1369
+ console.warn("Locker address not configured");
1370
+ return [];
1371
+ }
1372
+ return await getAddressBalances(lockerAddress);
1373
+ } catch (e) {
1374
+ console.error("failed to get locked balances", e);
1375
+ return [];
1376
+ }
1377
+ }
1378
+
1379
+ // src/query/epoch.ts
1380
+ var EPOCH_HOUR = "hour";
1381
+ var EPOCH_DAY = "day";
1382
+ var EPOCH_WEEK = "week";
1383
+ var EPOCHS_INFO_CACHE_KEY = "epochs:info";
1384
+ var EPOCHS_INFO_CACHE_TTL = 60 * 60;
1385
+ async function getEpochsInfo() {
1386
+ try {
1387
+ const cachedData = getFromLocalStorage(EPOCHS_INFO_CACHE_KEY);
1388
+ let shouldFetchFromEndpoint = false;
1389
+ if (cachedData !== null) {
1390
+ const cached = JSON.parse(cachedData);
1391
+ const now = (/* @__PURE__ */ new Date()).getTime();
1392
+ for (const epoch of cached.epochs) {
1393
+ if (epoch.current_epoch_start_time) {
1394
+ const startTime = new Date(epoch.current_epoch_start_time).getTime();
1395
+ const duration = getEpochDurationByIdentifier(epoch.identifier);
1396
+ const epochEndTime = startTime + duration - 15 * 1e3;
1397
+ if (now >= epochEndTime) {
1398
+ shouldFetchFromEndpoint = true;
1399
+ break;
1400
+ }
1401
+ }
1402
+ }
1403
+ if (!shouldFetchFromEndpoint) {
1404
+ return cached;
1405
+ }
1406
+ }
1407
+ const client = await getRestClient();
1408
+ const response = await client.bze.epochs.epochInfos();
1409
+ setInLocalStorage(EPOCHS_INFO_CACHE_KEY, JSON.stringify(response), EPOCHS_INFO_CACHE_TTL);
1410
+ return response;
1411
+ } catch (e) {
1412
+ console.error(e);
1413
+ return { epochs: [] };
1414
+ }
1415
+ }
1416
+ async function getCurrentEpoch(identifier) {
1417
+ const all = await getEpochsInfo();
1418
+ return all.epochs.find((item) => item.identifier === identifier);
1419
+ }
1420
+ async function getHourEpochInfo() {
1421
+ return getCurrentEpoch(EPOCH_HOUR);
1422
+ }
1423
+ async function getWeekEpochInfo() {
1424
+ return getCurrentEpoch(EPOCH_WEEK);
1425
+ }
1426
+ async function getCurrentWeekEpochEndTime() {
1427
+ return getPeriodicEpochEndTime(EPOCH_WEEK);
1428
+ }
1429
+ async function getPeriodicWeekEpochEndTime(modWeek = 1) {
1430
+ return getPeriodicEpochEndTime(EPOCH_WEEK, modWeek);
1431
+ }
1432
+ async function getPeriodicEpochEndTime(identifier, mod = 1) {
1433
+ const epoch = await getCurrentEpoch(identifier);
1434
+ if (!epoch || !epoch.current_epoch_start_time) {
1435
+ return void 0;
1436
+ }
1437
+ const current = toBigNumber(epoch.current_epoch);
1438
+ let remainingEpochs = mod - current.toNumber() % mod;
1439
+ if (remainingEpochs === mod) {
1440
+ remainingEpochs = 0;
1441
+ }
1442
+ const startAt = new Date(epoch.current_epoch_start_time);
1443
+ const duration = getEpochDurationByIdentifier(identifier);
1444
+ startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
1445
+ return startAt;
1446
+ }
1447
+ function getEpochDurationByIdentifier(identifier) {
1448
+ const hourMs = 60 * 60 * 1e3;
1449
+ switch (identifier) {
1450
+ case EPOCH_HOUR:
1451
+ return hourMs;
1452
+ case EPOCH_DAY:
1453
+ return hourMs * 24;
1454
+ case EPOCH_WEEK:
1455
+ return hourMs * 24 * 7;
1456
+ default:
1457
+ return hourMs;
1458
+ }
1459
+ }
1460
+
1461
+ // src/query/burner.ts
1249
1462
  var BURNED_KEY = "burner:all_burned_coins";
1250
1463
  var LOCAL_CACHE_TTL = 60 * 60 * 4;
1251
1464
  var { fromPartial: QueryAllBurnedCoinsRequestFromPartial } = import_bzejs2.bze.burner.QueryAllBurnedCoinsRequest;
@@ -1291,6 +1504,33 @@ async function getAllBurnedCoins() {
1291
1504
  };
1292
1505
  }
1293
1506
  }
1507
+ var BURN_EPOCH_COUNT = 4;
1508
+ async function getNextBurning() {
1509
+ const address = getBurnerModuleAddress();
1510
+ if (address === "") {
1511
+ return void 0;
1512
+ }
1513
+ const balances = await getAddressBalances(address);
1514
+ if (balances.length === 0) {
1515
+ return void 0;
1516
+ }
1517
+ const timeFromEpoch = await getBurningTimeFromEpoch();
1518
+ if (!timeFromEpoch) {
1519
+ return void 0;
1520
+ }
1521
+ return {
1522
+ coins: balances,
1523
+ date: timeFromEpoch
1524
+ };
1525
+ }
1526
+ async function getBurningTimeFromEpoch() {
1527
+ const params = await getBurnerParams();
1528
+ let defaultBurningMod = BURN_EPOCH_COUNT;
1529
+ if (params) {
1530
+ defaultBurningMod = toBigNumber(params.periodic_burning_weeks).toNumber();
1531
+ }
1532
+ return await getPeriodicWeekEpochEndTime(defaultBurningMod);
1533
+ }
1294
1534
 
1295
1535
  // src/utils/validation.ts
1296
1536
  function isValidUrl(urlString) {
@@ -1411,54 +1651,6 @@ var isPoolSupportedByValidator = (baseDenom, quoteDenom) => {
1411
1651
  return supportedDenoms.includes(baseDenom) || supportedDenoms.includes(quoteDenom);
1412
1652
  };
1413
1653
 
1414
- // src/constants/endpoints.ts
1415
- function getRestURL() {
1416
- return process.env.NEXT_PUBLIC_REST_URL || "";
1417
- }
1418
- function getRpcURL() {
1419
- return process.env.NEXT_PUBLIC_RPC_URL || "";
1420
- }
1421
- function getArchwayRpcURL() {
1422
- return process.env.NEXT_PUBLIC_RPC_URL_ARCHWAY || "";
1423
- }
1424
- function getOsmosisRpcUrl() {
1425
- return process.env.NEXT_PUBLIC_RPC_URL_OSMOSIS || "";
1426
- }
1427
- function getNobleRpcUrl() {
1428
- return process.env.NEXT_PUBLIC_RPC_URL_NOBLE || "";
1429
- }
1430
- function getJackalRpcUrl() {
1431
- return process.env.NEXT_PUBLIC_RPC_URL_JACKAL || "";
1432
- }
1433
- function getOmniFlixRpcUrl() {
1434
- return process.env.NEXT_PUBLIC_RPC_URL_FLIX || "";
1435
- }
1436
- function getAtomOneRpcUrl() {
1437
- return process.env.NEXT_PUBLIC_RPC_URL_ATOMONE || "";
1438
- }
1439
- function getArchwayRestURL() {
1440
- return process.env.NEXT_PUBLIC_REST_URL_ARCHWAY || "";
1441
- }
1442
- function getOsmosisRestURL() {
1443
- return process.env.NEXT_PUBLIC_REST_URL_OSMOSIS || "";
1444
- }
1445
- function getNobleRestURL() {
1446
- return process.env.NEXT_PUBLIC_REST_URL_NOBLE || "";
1447
- }
1448
- function getJackalRestURL() {
1449
- return process.env.NEXT_PUBLIC_REST_URL_JACKAL || "";
1450
- }
1451
- function getOmniFlixRestURL() {
1452
- return process.env.NEXT_PUBLIC_REST_URL_FLIX || "";
1453
- }
1454
- function getAtomOneRestURL() {
1455
- return process.env.NEXT_PUBLIC_REST_URL_ATOMONE || "";
1456
- }
1457
- var getAggregatorHost = () => {
1458
- var _a2;
1459
- return (_a2 = process.env.NEXT_PUBLIC_AGG_API_HOST) != null ? _a2 : "https://getbze.com";
1460
- };
1461
-
1462
1654
  // src/constants/market.ts
1463
1655
  var EXCLUDED_MARKETS = {
1464
1656
  "factory/bze1f0qgels0eu96ev6a67znu70q7rquy9eragn8nw/ucorey/factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl": true,
@@ -2272,111 +2464,125 @@ async function keplrSuggestChain(chainId) {
2272
2464
  return await ((_a2 = window.keplr) == null ? void 0 : _a2.experimentalSuggestChain(await getKeplrChainInfo(chainId)));
2273
2465
  }
2274
2466
 
2275
- // src/query/bank.ts
2276
- async function getAddressBalances(address) {
2467
+ // src/query/block.ts
2468
+ var FAILOVER_BLOCKTIMES = {
2469
+ "9334084": "2023-12-07T14:30:55.034845214Z",
2470
+ "4423602": "2023-01-18T07:51:31.391193017Z",
2471
+ "4827583": "2023-02-14T03:34:27.791387761Z",
2472
+ "5149043": "2023-03-07T11:41:10.455072975Z",
2473
+ "10855457": "2024-03-17T19:41:34.031980836Z"
2474
+ };
2475
+ var BLOCK_KEY = "tendermint:block:";
2476
+ async function getBlockDetailsByHeight(height) {
2277
2477
  try {
2478
+ const cacheKey = `${BLOCK_KEY}${height}`;
2479
+ const localData = getFromLocalStorage(cacheKey);
2480
+ if (null !== localData) {
2481
+ const parsed = JSON.parse(localData);
2482
+ if (parsed) {
2483
+ return parsed;
2484
+ }
2485
+ }
2278
2486
  const client = await getRestClient();
2279
- const response = await client.cosmos.bank.v1beta1.spendableBalances({ address });
2280
- return response.balances;
2487
+ const response = await client.cosmos.base.tendermint.v1beta1.getBlockByHeight({ height: BigInt(height.toFixed(0)) });
2488
+ setInLocalStorage(cacheKey, JSON.stringify(response), 0);
2489
+ return response;
2281
2490
  } catch (e) {
2282
- console.error("failed to get balances", e);
2283
- return [];
2491
+ console.error(e);
2492
+ return {};
2284
2493
  }
2285
2494
  }
2286
- async function getLockedBalances() {
2287
- try {
2288
- const lockerAddress = getLockerAddress();
2289
- if (!lockerAddress) {
2290
- console.warn("Locker address not configured");
2291
- return [];
2495
+ async function getBlockTimeByHeight(height) {
2496
+ var _a2, _b2;
2497
+ const details = await getBlockDetailsByHeight(height);
2498
+ if (details.block_id === void 0) {
2499
+ if (height.toFixed(0) in FAILOVER_BLOCKTIMES) {
2500
+ return new Date(FAILOVER_BLOCKTIMES[height.toFixed(0)]);
2292
2501
  }
2293
- return await getAddressBalances(lockerAddress);
2294
- } catch (e) {
2295
- console.error("failed to get locked balances", e);
2296
- return [];
2297
2502
  }
2503
+ return (_b2 = (_a2 = details.block) == null ? void 0 : _a2.header) == null ? void 0 : _b2.time;
2298
2504
  }
2299
-
2300
- // src/query/epoch.ts
2301
- var EPOCH_HOUR = "hour";
2302
- var EPOCH_DAY = "day";
2303
- var EPOCH_WEEK = "week";
2304
- var EPOCHS_INFO_CACHE_KEY = "epochs:info";
2305
- var EPOCHS_INFO_CACHE_TTL = 60 * 60;
2306
- async function getEpochsInfo() {
2505
+ async function getBlockResults(height) {
2506
+ const settings = getSettings();
2507
+ const rpcUrl = settings.endpoints.rpcEndpoint.replace("wss", "https");
2508
+ const url = `${rpcUrl}/block_results?height=${height}`;
2307
2509
  try {
2308
- const cachedData = getFromLocalStorage(EPOCHS_INFO_CACHE_KEY);
2309
- let shouldFetchFromEndpoint = false;
2310
- if (cachedData !== null) {
2311
- const cached = JSON.parse(cachedData);
2312
- const now = (/* @__PURE__ */ new Date()).getTime();
2313
- for (const epoch of cached.epochs) {
2314
- if (epoch.current_epoch_start_time) {
2315
- const startTime = new Date(epoch.current_epoch_start_time).getTime();
2316
- const duration = getEpochDurationByIdentifier(epoch.identifier);
2317
- const epochEndTime = startTime + duration - 15 * 1e3;
2318
- if (now >= epochEndTime) {
2319
- shouldFetchFromEndpoint = true;
2320
- break;
2321
- }
2322
- }
2323
- }
2324
- if (!shouldFetchFromEndpoint) {
2325
- return cached;
2510
+ const response = await fetch(url, {
2511
+ method: "GET",
2512
+ headers: {
2513
+ "Content-Type": "application/json"
2326
2514
  }
2515
+ });
2516
+ if (!response.ok) {
2517
+ console.log("not ok response from RPC: ", response);
2518
+ return void 0;
2327
2519
  }
2520
+ return await response.json();
2521
+ } catch (error) {
2522
+ console.error("Failed to fetch block results:", error);
2523
+ throw error;
2524
+ }
2525
+ }
2526
+
2527
+ // src/query/raffle.ts
2528
+ async function getRaffles() {
2529
+ try {
2328
2530
  const client = await getRestClient();
2329
- const response = await client.bze.epochs.epochInfos();
2330
- setInLocalStorage(EPOCHS_INFO_CACHE_KEY, JSON.stringify(response), EPOCHS_INFO_CACHE_TTL);
2331
- return response;
2531
+ const response = await client.bze.burner.raffles();
2532
+ return response.list;
2332
2533
  } catch (e) {
2333
2534
  console.error(e);
2334
- return { epochs: [] };
2535
+ return [];
2335
2536
  }
2336
2537
  }
2337
- async function getCurrentEpoch(identifier) {
2338
- const all = await getEpochsInfo();
2339
- return all.epochs.find((item) => item.identifier === identifier);
2340
- }
2341
- async function getHourEpochInfo() {
2342
- return getCurrentEpoch(EPOCH_HOUR);
2343
- }
2344
- async function getWeekEpochInfo() {
2345
- return getCurrentEpoch(EPOCH_WEEK);
2346
- }
2347
- async function getCurrentWeekEpochEndTime() {
2348
- return getPeriodicEpochEndTime(EPOCH_WEEK);
2349
- }
2350
- async function getPeriodicWeekEpochEndTime(modWeek = 1) {
2351
- return getPeriodicEpochEndTime(EPOCH_WEEK, modWeek);
2538
+ async function getRaffleWinners(denom) {
2539
+ try {
2540
+ const client = await getRestClient();
2541
+ const response = await client.bze.burner.raffleWinners({ denom });
2542
+ return response.list;
2543
+ } catch (e) {
2544
+ console.error(e);
2545
+ return [];
2546
+ }
2352
2547
  }
2353
- async function getPeriodicEpochEndTime(identifier, mod = 1) {
2354
- const epoch = await getCurrentEpoch(identifier);
2355
- if (!epoch || !epoch.current_epoch_start_time) {
2548
+ async function checkAddressWonRaffle(address, denom, height) {
2549
+ var _a2;
2550
+ const response = {
2551
+ hasWon: false,
2552
+ amount: "0",
2553
+ denom,
2554
+ address
2555
+ };
2556
+ if (address == "" || height <= 0) {
2356
2557
  return void 0;
2357
2558
  }
2358
- const current = toBigNumber(epoch.current_epoch);
2359
- let remainingEpochs = mod - current.toNumber() % mod;
2360
- if (remainingEpochs === mod) {
2361
- remainingEpochs = 0;
2559
+ const blockResults = await getBlockResults(height);
2560
+ if (!blockResults) {
2561
+ return void 0;
2362
2562
  }
2363
- const startAt = new Date(epoch.current_epoch_start_time);
2364
- const duration = getEpochDurationByIdentifier(identifier);
2365
- startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
2366
- return startAt;
2367
- }
2368
- function getEpochDurationByIdentifier(identifier) {
2369
- const hourMs = 60 * 60 * 1e3;
2370
- switch (identifier) {
2371
- case EPOCH_HOUR:
2372
- return hourMs;
2373
- case EPOCH_DAY:
2374
- return hourMs * 24;
2375
- case EPOCH_WEEK:
2376
- return hourMs * 24 * 7;
2377
- default:
2378
- return hourMs;
2563
+ if (!((_a2 = blockResults.result) == null ? void 0 : _a2.finalize_block_events)) {
2564
+ return void 0;
2565
+ }
2566
+ if (blockResults.result.finalize_block_events.length === 0) {
2567
+ return void 0;
2568
+ }
2569
+ const raffleEvents = blockResults.result.finalize_block_events.filter((ev) => ev.type.includes("Raffle"));
2570
+ if (!raffleEvents || raffleEvents.length === 0) {
2571
+ return void 0;
2572
+ }
2573
+ for (let i = 0; i < raffleEvents.length; i++) {
2574
+ const ev = raffleEvents[i];
2575
+ const converted = mapEventAttributes(ev.attributes);
2576
+ if ("participant" in converted && ev.type.includes("RaffleLostEvent") && converted["participant"] === address) {
2577
+ return response;
2578
+ }
2579
+ if ("winner" in converted && ev.type.includes("RaffleWinnerEvent") && converted["winner"] === address && converted["denom"] === denom) {
2580
+ response.hasWon = true;
2581
+ response.amount = converted["amount"];
2582
+ return response;
2583
+ }
2379
2584
  }
2585
+ return response;
2380
2586
  }
2381
2587
 
2382
2588
  // src/query/factory.ts
@@ -3211,11 +3417,28 @@ function useBalance(denom) {
3211
3417
 
3212
3418
  // src/hooks/useEpochs.ts
3213
3419
  var import_react8 = require("react");
3420
+ var import_bignumber9 = __toESM(require("bignumber.js"));
3214
3421
  var EPOCH_HOUR2 = "hour";
3215
3422
  var EPOCH_DAY2 = "day";
3216
3423
  var EPOCH_WEEK2 = "week";
3424
+ function getEpochDurationByIdentifier2(identifier) {
3425
+ const hourMs = 60 * 60 * 1e3;
3426
+ switch (identifier) {
3427
+ case EPOCH_HOUR2:
3428
+ return hourMs;
3429
+ case EPOCH_DAY2:
3430
+ return hourMs * 24;
3431
+ case EPOCH_WEEK2:
3432
+ return hourMs * 24 * 7;
3433
+ default:
3434
+ return hourMs;
3435
+ }
3436
+ }
3217
3437
  function useEpochs() {
3218
3438
  const { epochs, isLoading, updateEpochs } = useAssetsContext();
3439
+ const getCurrentEpoch2 = (0, import_react8.useCallback)((identifier) => {
3440
+ return epochs.get(identifier);
3441
+ }, [epochs]);
3219
3442
  const hourEpochInfo = (0, import_react8.useMemo)(() => {
3220
3443
  return epochs.get(EPOCH_HOUR2);
3221
3444
  }, [epochs]);
@@ -3225,19 +3448,65 @@ function useEpochs() {
3225
3448
  const weekEpochInfo = (0, import_react8.useMemo)(() => {
3226
3449
  return epochs.get(EPOCH_WEEK2);
3227
3450
  }, [epochs]);
3451
+ const getHourEpochInfo2 = (0, import_react8.useCallback)(() => {
3452
+ return epochs.get(EPOCH_HOUR2);
3453
+ }, [epochs]);
3454
+ const getDayEpochInfo = (0, import_react8.useCallback)(() => {
3455
+ return epochs.get(EPOCH_DAY2);
3456
+ }, [epochs]);
3457
+ const getWeekEpochInfo2 = (0, import_react8.useCallback)(() => {
3458
+ return epochs.get(EPOCH_WEEK2);
3459
+ }, [epochs]);
3460
+ const getPeriodicEpochEndTime2 = (0, import_react8.useCallback)((identifier, modWeek = 1) => {
3461
+ const epoch = epochs.get(identifier);
3462
+ if (!epoch || !epoch.current_epoch_start_time) {
3463
+ return void 0;
3464
+ }
3465
+ const current = new import_bignumber9.default(epoch.current_epoch);
3466
+ let remainingEpochs = modWeek - current.toNumber() % modWeek;
3467
+ if (remainingEpochs === modWeek) {
3468
+ remainingEpochs = 0;
3469
+ }
3470
+ const startAt = new Date(epoch.current_epoch_start_time);
3471
+ const duration = getEpochDurationByIdentifier2(identifier);
3472
+ startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
3473
+ return startAt;
3474
+ }, [epochs]);
3475
+ const getCurrentWeekEpochEndTime2 = (0, import_react8.useCallback)(() => {
3476
+ return getPeriodicEpochEndTime2(EPOCH_WEEK2);
3477
+ }, [getPeriodicEpochEndTime2]);
3478
+ const getPeriodicWeekEpochEndTime2 = (0, import_react8.useCallback)((modWeek = 1) => {
3479
+ return getPeriodicEpochEndTime2(EPOCH_WEEK2, modWeek);
3480
+ }, [getPeriodicEpochEndTime2]);
3481
+ const epochsList = (0, import_react8.useMemo)(() => Array.from(epochs.values()), [epochs]);
3228
3482
  return {
3229
- epochs,
3483
+ epochs: epochsList,
3484
+ epochsMap: epochs,
3230
3485
  hourEpochInfo,
3231
3486
  dayEpochInfo,
3232
3487
  weekEpochInfo,
3233
3488
  isLoading,
3234
- updateEpochs
3489
+ updateEpochs,
3490
+ getCurrentEpoch: getCurrentEpoch2,
3491
+ getHourEpochInfo: getHourEpochInfo2,
3492
+ getDayEpochInfo,
3493
+ getWeekEpochInfo: getWeekEpochInfo2,
3494
+ getCurrentWeekEpochEndTime: getCurrentWeekEpochEndTime2,
3495
+ getPeriodicWeekEpochEndTime: getPeriodicWeekEpochEndTime2,
3496
+ getPeriodicEpochEndTime: getPeriodicEpochEndTime2
3497
+ };
3498
+ }
3499
+ function useEpochsManager() {
3500
+ const { updateEpochs, isLoading } = useAssetsContext();
3501
+ return {
3502
+ updateEpochs,
3503
+ isLoading
3235
3504
  };
3236
3505
  }
3237
3506
 
3238
3507
  // src/hooks/useLiquidityPools.ts
3239
3508
  var import_react9 = require("react");
3240
- var import_bignumber9 = __toESM(require("bignumber.js"));
3509
+ var import_bignumber10 = __toESM(require("bignumber.js"));
3241
3510
  function useLiquidityPools() {
3242
3511
  const { poolsMap, poolsDataMap, updateLiquidityPools, isLoading, assetsMap } = useAssetsContext();
3243
3512
  const pools = (0, import_react9.useMemo)(() => {
@@ -3291,7 +3560,7 @@ function useAssetLiquidityPools(denom) {
3291
3560
  return newMap;
3292
3561
  }, [assetPools, poolsDataMap, isLoading, denom]);
3293
3562
  const asset24HoursVolume = (0, import_react9.useMemo)(() => {
3294
- let volume = (0, import_bignumber9.default)(0);
3563
+ let volume = (0, import_bignumber10.default)(0);
3295
3564
  if (isLoading || denom === "") return volume;
3296
3565
  assetPoolsData.forEach((poolData) => {
3297
3566
  if (poolData.base === denom) {
@@ -3368,9 +3637,9 @@ function useLiquidityPool(poolId) {
3368
3637
  }
3369
3638
  const baseRatio = baseAmountBN.dividedBy(reserveBase);
3370
3639
  const quoteRatio = quoteAmountBN.dividedBy(reserveQuote);
3371
- const mintRatio = import_bignumber9.default.minimum(baseRatio, quoteRatio);
3640
+ const mintRatio = import_bignumber10.default.minimum(baseRatio, quoteRatio);
3372
3641
  const tokensToMint = mintRatio.multipliedBy(totalShares);
3373
- return tokensToMint.integerValue(import_bignumber9.default.ROUND_DOWN);
3642
+ return tokensToMint.integerValue(import_bignumber10.default.ROUND_DOWN);
3374
3643
  }, [pool, totalShares]);
3375
3644
  return {
3376
3645
  isLoading,
@@ -3388,11 +3657,11 @@ function useLiquidityPool(poolId) {
3388
3657
 
3389
3658
  // src/hooks/useAssetsValue.ts
3390
3659
  var import_react10 = require("react");
3391
- var import_bignumber10 = __toESM(require("bignumber.js"));
3660
+ var import_bignumber11 = __toESM(require("bignumber.js"));
3392
3661
  function useAssetsValue() {
3393
3662
  const { assetsMap, usdPricesMap, balancesMap, isLoading: isLoadingPrices } = useAssetsContext();
3394
3663
  const totalUsdValue = (0, import_react10.useCallback)((prettyBalances) => {
3395
- let usdValue = (0, import_bignumber10.default)(0);
3664
+ let usdValue = (0, import_bignumber11.default)(0);
3396
3665
  prettyBalances.map((denomBalance) => {
3397
3666
  const assetPrice = usdPricesMap.get(denomBalance.denom);
3398
3667
  if (assetPrice && assetPrice.gt(0)) {
@@ -3421,12 +3690,12 @@ function useAssetsValue() {
3421
3690
  }, [usdPricesMap, assetsMap]);
3422
3691
  const compareValues = (0, import_react10.useCallback)((a, b) => {
3423
3692
  var _a2;
3424
- let aValue = (0, import_bignumber10.default)(0);
3693
+ let aValue = (0, import_bignumber11.default)(0);
3425
3694
  const aPrice = usdPricesMap.get(a.denom);
3426
3695
  if (aPrice) {
3427
3696
  aValue = aPrice.multipliedBy(a.amount);
3428
3697
  }
3429
- let bValue = (0, import_bignumber10.default)(0);
3698
+ let bValue = (0, import_bignumber11.default)(0);
3430
3699
  const bPrice = usdPricesMap.get(b.denom);
3431
3700
  if (bPrice) {
3432
3701
  bValue = bPrice.multipliedBy(b.amount);
@@ -3480,7 +3749,7 @@ function useFeeTokens() {
3480
3749
 
3481
3750
  // src/hooks/useMarkets.ts
3482
3751
  var import_react12 = require("react");
3483
- var import_bignumber11 = __toESM(require("bignumber.js"));
3752
+ var import_bignumber12 = __toESM(require("bignumber.js"));
3484
3753
  function useMarkets() {
3485
3754
  const { marketsMap, marketsDataMap, updateMarkets, isLoading } = useAssetsContext();
3486
3755
  const markets = (0, import_react12.useMemo)(() => {
@@ -3532,7 +3801,7 @@ function useAssetMarkets(denom) {
3532
3801
  return acc.plus(market.quote_volume || 0);
3533
3802
  }
3534
3803
  return acc;
3535
- }, new import_bignumber11.default(0));
3804
+ }, new import_bignumber12.default(0));
3536
3805
  }, [assetMarketsData, denom]);
3537
3806
  return {
3538
3807
  isLoading,
@@ -3683,7 +3952,7 @@ var useToast = () => {
3683
3952
  // src/hooks/useTx.tsx
3684
3953
  var import_stargate = require("@cosmjs/stargate");
3685
3954
  var import_react15 = require("@interchain-kit/react");
3686
- var import_bignumber12 = __toESM(require("bignumber.js"));
3955
+ var import_bignumber13 = __toESM(require("bignumber.js"));
3687
3956
  var import_react16 = require("react");
3688
3957
  var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
3689
3958
  TxStatus2["Failed"] = "Transaction Failed";
@@ -3735,7 +4004,7 @@ var useTx = (chainName, isCosmos, isIBC) => {
3735
4004
  const gasPrice = 0.02;
3736
4005
  const nativeDenom = getChainNativeAssetDenom();
3737
4006
  const gasEstimated = await signingClient.simulate(address, messages, memo);
3738
- const gasAmount = (0, import_bignumber12.default)(gasEstimated).multipliedBy(1.5);
4007
+ const gasAmount = (0, import_bignumber13.default)(gasEstimated).multipliedBy(1.5);
3739
4008
  const gasPayment = gasAmount.multipliedBy(gasPrice);
3740
4009
  const nativeFee = {
3741
4010
  amount: (0, import_stargate.coins)(gasPayment.toFixed(0).toString(), nativeDenom),
@@ -3752,9 +4021,9 @@ var useTx = (chainName, isCosmos, isIBC) => {
3752
4021
  if (!expectedAmount.isPositive()) {
3753
4022
  return nativeFee;
3754
4023
  }
3755
- expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(import_bignumber12.default.ROUND_FLOOR);
4024
+ expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(import_bignumber13.default.ROUND_FLOOR);
3756
4025
  if (expectedAmount.multipliedBy(pool.fee).lt(1)) {
3757
- expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(import_bignumber12.default.ROUND_CEIL);
4026
+ expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(import_bignumber13.default.ROUND_CEIL);
3758
4027
  }
3759
4028
  return {
3760
4029
  amount: (0, import_stargate.coins)(expectedAmount.toFixed(0).toString(), feeDenom),
@@ -4275,13 +4544,13 @@ var import_react25 = require("@chakra-ui/react");
4275
4544
  var import_lu3 = require("react-icons/lu");
4276
4545
  var import_react26 = require("react");
4277
4546
  var import_core = require("@interchain-kit/core");
4278
- var import_bignumber13 = __toESM(require("bignumber.js"));
4547
+ var import_bignumber14 = __toESM(require("bignumber.js"));
4279
4548
  var import_bzejs5 = require("@bze/bzejs");
4280
4549
  var import_jsx_runtime5 = require("react/jsx-runtime");
4281
4550
  var validateAmount = (amount, coin, onError) => {
4282
4551
  if (!coin) return;
4283
4552
  if (amount === "") return;
4284
- const amountNumber = (0, import_bignumber13.default)(amount);
4553
+ const amountNumber = (0, import_bignumber14.default)(amount);
4285
4554
  if (amountNumber.isNaN()) {
4286
4555
  onError("Invalid amount");
4287
4556
  return;
@@ -4901,6 +5170,7 @@ function SettingsToggle({ accentColor }) {
4901
5170
  canDepositFromIBC,
4902
5171
  canSendToIBC,
4903
5172
  cancelDebounce,
5173
+ checkAddressWonRaffle,
4904
5174
  convertToWebSocketUrl,
4905
5175
  counterpartyChainForChannel,
4906
5176
  createMarketId,
@@ -4937,6 +5207,10 @@ function SettingsToggle({ accentColor }) {
4937
5207
  getAtomOneRestURL,
4938
5208
  getAtomOneRpcUrl,
4939
5209
  getBZEUSDPrice,
5210
+ getBlockDetailsByHeight,
5211
+ getBlockResults,
5212
+ getBlockTimeByHeight,
5213
+ getBurnerModuleAddress,
4940
5214
  getBurnerParams,
4941
5215
  getBurnerParamsWithClient,
4942
5216
  getChainAddressPrefix,
@@ -4960,6 +5234,7 @@ function SettingsToggle({ accentColor }) {
4960
5234
  getEpochsInfo,
4961
5235
  getFactoryDenomAdminAddress,
4962
5236
  getFromLocalStorage,
5237
+ getHardcodedLockAddress,
4963
5238
  getHashIBCTrace,
4964
5239
  getHourEpochInfo,
4965
5240
  getIBCAssetList,
@@ -4982,6 +5257,8 @@ function SettingsToggle({ accentColor }) {
4982
5257
  getMarketSellOrders,
4983
5258
  getMarkets,
4984
5259
  getMinAmount,
5260
+ getModuleAddress,
5261
+ getNextBurning,
4985
5262
  getNoOfIntervalsNeeded,
4986
5263
  getNobleRestURL,
4987
5264
  getNobleRpcUrl,
@@ -4993,6 +5270,9 @@ function SettingsToggle({ accentColor }) {
4993
5270
  getPendingUnlockParticipants,
4994
5271
  getPeriodicEpochEndTime,
4995
5272
  getPeriodicWeekEpochEndTime,
5273
+ getRaffleModuleAddress,
5274
+ getRaffleWinners,
5275
+ getRaffles,
4996
5276
  getRestClient,
4997
5277
  getRestURL,
4998
5278
  getRpcURL,
@@ -5057,6 +5337,7 @@ function SettingsToggle({ accentColor }) {
5057
5337
  useBalances,
5058
5338
  useConnectionType,
5059
5339
  useEpochs,
5340
+ useEpochsManager,
5060
5341
  useFeeTokens,
5061
5342
  useIBCChains,
5062
5343
  useIBCTx,