@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.d.mts +61 -6
- package/dist/index.d.ts +61 -6
- package/dist/index.js +431 -150
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +462 -193
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -975,6 +975,207 @@ var getPageRequestWithLimit = (limit) => {
|
|
|
975
975
|
// src/query/burner.ts
|
|
976
976
|
import { bze as bze2 } from "@bze/bzejs";
|
|
977
977
|
import { PageRequest as PageRequest2 } from "@bze/bzejs/cosmos/base/query/v1beta1/pagination";
|
|
978
|
+
|
|
979
|
+
// src/constants/endpoints.ts
|
|
980
|
+
function getRestURL() {
|
|
981
|
+
return process.env.NEXT_PUBLIC_REST_URL || "";
|
|
982
|
+
}
|
|
983
|
+
function getRpcURL() {
|
|
984
|
+
return process.env.NEXT_PUBLIC_RPC_URL || "";
|
|
985
|
+
}
|
|
986
|
+
function getArchwayRpcURL() {
|
|
987
|
+
return process.env.NEXT_PUBLIC_RPC_URL_ARCHWAY || "";
|
|
988
|
+
}
|
|
989
|
+
function getOsmosisRpcUrl() {
|
|
990
|
+
return process.env.NEXT_PUBLIC_RPC_URL_OSMOSIS || "";
|
|
991
|
+
}
|
|
992
|
+
function getNobleRpcUrl() {
|
|
993
|
+
return process.env.NEXT_PUBLIC_RPC_URL_NOBLE || "";
|
|
994
|
+
}
|
|
995
|
+
function getJackalRpcUrl() {
|
|
996
|
+
return process.env.NEXT_PUBLIC_RPC_URL_JACKAL || "";
|
|
997
|
+
}
|
|
998
|
+
function getOmniFlixRpcUrl() {
|
|
999
|
+
return process.env.NEXT_PUBLIC_RPC_URL_FLIX || "";
|
|
1000
|
+
}
|
|
1001
|
+
function getAtomOneRpcUrl() {
|
|
1002
|
+
return process.env.NEXT_PUBLIC_RPC_URL_ATOMONE || "";
|
|
1003
|
+
}
|
|
1004
|
+
function getArchwayRestURL() {
|
|
1005
|
+
return process.env.NEXT_PUBLIC_REST_URL_ARCHWAY || "";
|
|
1006
|
+
}
|
|
1007
|
+
function getOsmosisRestURL() {
|
|
1008
|
+
return process.env.NEXT_PUBLIC_REST_URL_OSMOSIS || "";
|
|
1009
|
+
}
|
|
1010
|
+
function getNobleRestURL() {
|
|
1011
|
+
return process.env.NEXT_PUBLIC_REST_URL_NOBLE || "";
|
|
1012
|
+
}
|
|
1013
|
+
function getJackalRestURL() {
|
|
1014
|
+
return process.env.NEXT_PUBLIC_REST_URL_JACKAL || "";
|
|
1015
|
+
}
|
|
1016
|
+
function getOmniFlixRestURL() {
|
|
1017
|
+
return process.env.NEXT_PUBLIC_REST_URL_FLIX || "";
|
|
1018
|
+
}
|
|
1019
|
+
function getAtomOneRestURL() {
|
|
1020
|
+
return process.env.NEXT_PUBLIC_REST_URL_ATOMONE || "";
|
|
1021
|
+
}
|
|
1022
|
+
var getAggregatorHost = () => {
|
|
1023
|
+
var _a2;
|
|
1024
|
+
return (_a2 = process.env.NEXT_PUBLIC_AGG_API_HOST) != null ? _a2 : "https://getbze.com";
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
// src/query/module.ts
|
|
1028
|
+
var MODULE_ADDRESS_KEY = "auth:module:address:";
|
|
1029
|
+
var MODULE_ADDRESS_CACHE_TTL = 60 * 60 * 48;
|
|
1030
|
+
function getHardcodedBurnerAddress() {
|
|
1031
|
+
return "bze1v7uw4xhrcv0vk7qp8jf9lu3hm5d8uu5yjp5qun";
|
|
1032
|
+
}
|
|
1033
|
+
function getHardcodedRaffleAddress() {
|
|
1034
|
+
return "bze18hsqalgwlzqavrrkfnxmrjmygwyjy8senx5tgs";
|
|
1035
|
+
}
|
|
1036
|
+
function getHardcodedLockAddress() {
|
|
1037
|
+
return "bze1pc5zjcvhx3e8l305zjl72grytfa30r5mdypmw4";
|
|
1038
|
+
}
|
|
1039
|
+
function getBurnerModuleAddress() {
|
|
1040
|
+
return getHardcodedBurnerAddress();
|
|
1041
|
+
}
|
|
1042
|
+
function getRaffleModuleAddress() {
|
|
1043
|
+
return getHardcodedRaffleAddress();
|
|
1044
|
+
}
|
|
1045
|
+
async function getModuleAddress(module) {
|
|
1046
|
+
var _a2;
|
|
1047
|
+
try {
|
|
1048
|
+
const cacheKey = `${MODULE_ADDRESS_KEY}${module}`;
|
|
1049
|
+
const localData = getFromLocalStorage(cacheKey);
|
|
1050
|
+
if (null !== localData) {
|
|
1051
|
+
return localData;
|
|
1052
|
+
}
|
|
1053
|
+
const url = getRestURL();
|
|
1054
|
+
const response = await fetch(`${url}/cosmos/auth/v1beta1/module_accounts/${module}`);
|
|
1055
|
+
if (!response.ok) {
|
|
1056
|
+
return "";
|
|
1057
|
+
}
|
|
1058
|
+
const parsed = await response.json();
|
|
1059
|
+
const addy = (_a2 = parsed.account.base_account) == null ? void 0 : _a2.address;
|
|
1060
|
+
if (addy === void 0) {
|
|
1061
|
+
return "";
|
|
1062
|
+
}
|
|
1063
|
+
setInLocalStorage(cacheKey, addy, MODULE_ADDRESS_CACHE_TTL);
|
|
1064
|
+
return addy;
|
|
1065
|
+
} catch (e) {
|
|
1066
|
+
console.error(e);
|
|
1067
|
+
return "";
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// src/query/bank.ts
|
|
1072
|
+
async function getAddressBalances(address) {
|
|
1073
|
+
try {
|
|
1074
|
+
const client = await getRestClient();
|
|
1075
|
+
const response = await client.cosmos.bank.v1beta1.spendableBalances({ address });
|
|
1076
|
+
return response.balances;
|
|
1077
|
+
} catch (e) {
|
|
1078
|
+
console.error("failed to get balances", e);
|
|
1079
|
+
return [];
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
async function getLockedBalances() {
|
|
1083
|
+
try {
|
|
1084
|
+
const lockerAddress = getLockerAddress();
|
|
1085
|
+
if (!lockerAddress) {
|
|
1086
|
+
console.warn("Locker address not configured");
|
|
1087
|
+
return [];
|
|
1088
|
+
}
|
|
1089
|
+
return await getAddressBalances(lockerAddress);
|
|
1090
|
+
} catch (e) {
|
|
1091
|
+
console.error("failed to get locked balances", e);
|
|
1092
|
+
return [];
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// src/query/epoch.ts
|
|
1097
|
+
var EPOCH_HOUR = "hour";
|
|
1098
|
+
var EPOCH_DAY = "day";
|
|
1099
|
+
var EPOCH_WEEK = "week";
|
|
1100
|
+
var EPOCHS_INFO_CACHE_KEY = "epochs:info";
|
|
1101
|
+
var EPOCHS_INFO_CACHE_TTL = 60 * 60;
|
|
1102
|
+
async function getEpochsInfo() {
|
|
1103
|
+
try {
|
|
1104
|
+
const cachedData = getFromLocalStorage(EPOCHS_INFO_CACHE_KEY);
|
|
1105
|
+
let shouldFetchFromEndpoint = false;
|
|
1106
|
+
if (cachedData !== null) {
|
|
1107
|
+
const cached = JSON.parse(cachedData);
|
|
1108
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1109
|
+
for (const epoch of cached.epochs) {
|
|
1110
|
+
if (epoch.current_epoch_start_time) {
|
|
1111
|
+
const startTime = new Date(epoch.current_epoch_start_time).getTime();
|
|
1112
|
+
const duration = getEpochDurationByIdentifier(epoch.identifier);
|
|
1113
|
+
const epochEndTime = startTime + duration - 15 * 1e3;
|
|
1114
|
+
if (now >= epochEndTime) {
|
|
1115
|
+
shouldFetchFromEndpoint = true;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if (!shouldFetchFromEndpoint) {
|
|
1121
|
+
return cached;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
const client = await getRestClient();
|
|
1125
|
+
const response = await client.bze.epochs.epochInfos();
|
|
1126
|
+
setInLocalStorage(EPOCHS_INFO_CACHE_KEY, JSON.stringify(response), EPOCHS_INFO_CACHE_TTL);
|
|
1127
|
+
return response;
|
|
1128
|
+
} catch (e) {
|
|
1129
|
+
console.error(e);
|
|
1130
|
+
return { epochs: [] };
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
async function getCurrentEpoch(identifier) {
|
|
1134
|
+
const all = await getEpochsInfo();
|
|
1135
|
+
return all.epochs.find((item) => item.identifier === identifier);
|
|
1136
|
+
}
|
|
1137
|
+
async function getHourEpochInfo() {
|
|
1138
|
+
return getCurrentEpoch(EPOCH_HOUR);
|
|
1139
|
+
}
|
|
1140
|
+
async function getWeekEpochInfo() {
|
|
1141
|
+
return getCurrentEpoch(EPOCH_WEEK);
|
|
1142
|
+
}
|
|
1143
|
+
async function getCurrentWeekEpochEndTime() {
|
|
1144
|
+
return getPeriodicEpochEndTime(EPOCH_WEEK);
|
|
1145
|
+
}
|
|
1146
|
+
async function getPeriodicWeekEpochEndTime(modWeek = 1) {
|
|
1147
|
+
return getPeriodicEpochEndTime(EPOCH_WEEK, modWeek);
|
|
1148
|
+
}
|
|
1149
|
+
async function getPeriodicEpochEndTime(identifier, mod = 1) {
|
|
1150
|
+
const epoch = await getCurrentEpoch(identifier);
|
|
1151
|
+
if (!epoch || !epoch.current_epoch_start_time) {
|
|
1152
|
+
return void 0;
|
|
1153
|
+
}
|
|
1154
|
+
const current = toBigNumber(epoch.current_epoch);
|
|
1155
|
+
let remainingEpochs = mod - current.toNumber() % mod;
|
|
1156
|
+
if (remainingEpochs === mod) {
|
|
1157
|
+
remainingEpochs = 0;
|
|
1158
|
+
}
|
|
1159
|
+
const startAt = new Date(epoch.current_epoch_start_time);
|
|
1160
|
+
const duration = getEpochDurationByIdentifier(identifier);
|
|
1161
|
+
startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
|
|
1162
|
+
return startAt;
|
|
1163
|
+
}
|
|
1164
|
+
function getEpochDurationByIdentifier(identifier) {
|
|
1165
|
+
const hourMs = 60 * 60 * 1e3;
|
|
1166
|
+
switch (identifier) {
|
|
1167
|
+
case EPOCH_HOUR:
|
|
1168
|
+
return hourMs;
|
|
1169
|
+
case EPOCH_DAY:
|
|
1170
|
+
return hourMs * 24;
|
|
1171
|
+
case EPOCH_WEEK:
|
|
1172
|
+
return hourMs * 24 * 7;
|
|
1173
|
+
default:
|
|
1174
|
+
return hourMs;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// src/query/burner.ts
|
|
978
1179
|
var BURNED_KEY = "burner:all_burned_coins";
|
|
979
1180
|
var LOCAL_CACHE_TTL = 60 * 60 * 4;
|
|
980
1181
|
var { fromPartial: QueryAllBurnedCoinsRequestFromPartial } = bze2.burner.QueryAllBurnedCoinsRequest;
|
|
@@ -1020,6 +1221,33 @@ async function getAllBurnedCoins() {
|
|
|
1020
1221
|
};
|
|
1021
1222
|
}
|
|
1022
1223
|
}
|
|
1224
|
+
var BURN_EPOCH_COUNT = 4;
|
|
1225
|
+
async function getNextBurning() {
|
|
1226
|
+
const address = getBurnerModuleAddress();
|
|
1227
|
+
if (address === "") {
|
|
1228
|
+
return void 0;
|
|
1229
|
+
}
|
|
1230
|
+
const balances = await getAddressBalances(address);
|
|
1231
|
+
if (balances.length === 0) {
|
|
1232
|
+
return void 0;
|
|
1233
|
+
}
|
|
1234
|
+
const timeFromEpoch = await getBurningTimeFromEpoch();
|
|
1235
|
+
if (!timeFromEpoch) {
|
|
1236
|
+
return void 0;
|
|
1237
|
+
}
|
|
1238
|
+
return {
|
|
1239
|
+
coins: balances,
|
|
1240
|
+
date: timeFromEpoch
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
async function getBurningTimeFromEpoch() {
|
|
1244
|
+
const params = await getBurnerParams();
|
|
1245
|
+
let defaultBurningMod = BURN_EPOCH_COUNT;
|
|
1246
|
+
if (params) {
|
|
1247
|
+
defaultBurningMod = toBigNumber(params.periodic_burning_weeks).toNumber();
|
|
1248
|
+
}
|
|
1249
|
+
return await getPeriodicWeekEpochEndTime(defaultBurningMod);
|
|
1250
|
+
}
|
|
1023
1251
|
|
|
1024
1252
|
// src/utils/validation.ts
|
|
1025
1253
|
function isValidUrl(urlString) {
|
|
@@ -1140,54 +1368,6 @@ var isPoolSupportedByValidator = (baseDenom, quoteDenom) => {
|
|
|
1140
1368
|
return supportedDenoms.includes(baseDenom) || supportedDenoms.includes(quoteDenom);
|
|
1141
1369
|
};
|
|
1142
1370
|
|
|
1143
|
-
// src/constants/endpoints.ts
|
|
1144
|
-
function getRestURL() {
|
|
1145
|
-
return process.env.NEXT_PUBLIC_REST_URL || "";
|
|
1146
|
-
}
|
|
1147
|
-
function getRpcURL() {
|
|
1148
|
-
return process.env.NEXT_PUBLIC_RPC_URL || "";
|
|
1149
|
-
}
|
|
1150
|
-
function getArchwayRpcURL() {
|
|
1151
|
-
return process.env.NEXT_PUBLIC_RPC_URL_ARCHWAY || "";
|
|
1152
|
-
}
|
|
1153
|
-
function getOsmosisRpcUrl() {
|
|
1154
|
-
return process.env.NEXT_PUBLIC_RPC_URL_OSMOSIS || "";
|
|
1155
|
-
}
|
|
1156
|
-
function getNobleRpcUrl() {
|
|
1157
|
-
return process.env.NEXT_PUBLIC_RPC_URL_NOBLE || "";
|
|
1158
|
-
}
|
|
1159
|
-
function getJackalRpcUrl() {
|
|
1160
|
-
return process.env.NEXT_PUBLIC_RPC_URL_JACKAL || "";
|
|
1161
|
-
}
|
|
1162
|
-
function getOmniFlixRpcUrl() {
|
|
1163
|
-
return process.env.NEXT_PUBLIC_RPC_URL_FLIX || "";
|
|
1164
|
-
}
|
|
1165
|
-
function getAtomOneRpcUrl() {
|
|
1166
|
-
return process.env.NEXT_PUBLIC_RPC_URL_ATOMONE || "";
|
|
1167
|
-
}
|
|
1168
|
-
function getArchwayRestURL() {
|
|
1169
|
-
return process.env.NEXT_PUBLIC_REST_URL_ARCHWAY || "";
|
|
1170
|
-
}
|
|
1171
|
-
function getOsmosisRestURL() {
|
|
1172
|
-
return process.env.NEXT_PUBLIC_REST_URL_OSMOSIS || "";
|
|
1173
|
-
}
|
|
1174
|
-
function getNobleRestURL() {
|
|
1175
|
-
return process.env.NEXT_PUBLIC_REST_URL_NOBLE || "";
|
|
1176
|
-
}
|
|
1177
|
-
function getJackalRestURL() {
|
|
1178
|
-
return process.env.NEXT_PUBLIC_REST_URL_JACKAL || "";
|
|
1179
|
-
}
|
|
1180
|
-
function getOmniFlixRestURL() {
|
|
1181
|
-
return process.env.NEXT_PUBLIC_REST_URL_FLIX || "";
|
|
1182
|
-
}
|
|
1183
|
-
function getAtomOneRestURL() {
|
|
1184
|
-
return process.env.NEXT_PUBLIC_REST_URL_ATOMONE || "";
|
|
1185
|
-
}
|
|
1186
|
-
var getAggregatorHost = () => {
|
|
1187
|
-
var _a2;
|
|
1188
|
-
return (_a2 = process.env.NEXT_PUBLIC_AGG_API_HOST) != null ? _a2 : "https://getbze.com";
|
|
1189
|
-
};
|
|
1190
|
-
|
|
1191
1371
|
// src/constants/market.ts
|
|
1192
1372
|
var EXCLUDED_MARKETS = {
|
|
1193
1373
|
"factory/bze1f0qgels0eu96ev6a67znu70q7rquy9eragn8nw/ucorey/factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl": true,
|
|
@@ -2001,111 +2181,125 @@ async function keplrSuggestChain(chainId) {
|
|
|
2001
2181
|
return await ((_a2 = window.keplr) == null ? void 0 : _a2.experimentalSuggestChain(await getKeplrChainInfo(chainId)));
|
|
2002
2182
|
}
|
|
2003
2183
|
|
|
2004
|
-
// src/query/
|
|
2005
|
-
|
|
2184
|
+
// src/query/block.ts
|
|
2185
|
+
var FAILOVER_BLOCKTIMES = {
|
|
2186
|
+
"9334084": "2023-12-07T14:30:55.034845214Z",
|
|
2187
|
+
"4423602": "2023-01-18T07:51:31.391193017Z",
|
|
2188
|
+
"4827583": "2023-02-14T03:34:27.791387761Z",
|
|
2189
|
+
"5149043": "2023-03-07T11:41:10.455072975Z",
|
|
2190
|
+
"10855457": "2024-03-17T19:41:34.031980836Z"
|
|
2191
|
+
};
|
|
2192
|
+
var BLOCK_KEY = "tendermint:block:";
|
|
2193
|
+
async function getBlockDetailsByHeight(height) {
|
|
2006
2194
|
try {
|
|
2195
|
+
const cacheKey = `${BLOCK_KEY}${height}`;
|
|
2196
|
+
const localData = getFromLocalStorage(cacheKey);
|
|
2197
|
+
if (null !== localData) {
|
|
2198
|
+
const parsed = JSON.parse(localData);
|
|
2199
|
+
if (parsed) {
|
|
2200
|
+
return parsed;
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2007
2203
|
const client = await getRestClient();
|
|
2008
|
-
const response = await client.cosmos.
|
|
2009
|
-
|
|
2204
|
+
const response = await client.cosmos.base.tendermint.v1beta1.getBlockByHeight({ height: BigInt(height.toFixed(0)) });
|
|
2205
|
+
setInLocalStorage(cacheKey, JSON.stringify(response), 0);
|
|
2206
|
+
return response;
|
|
2010
2207
|
} catch (e) {
|
|
2011
|
-
console.error(
|
|
2012
|
-
return
|
|
2208
|
+
console.error(e);
|
|
2209
|
+
return {};
|
|
2013
2210
|
}
|
|
2014
2211
|
}
|
|
2015
|
-
async function
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
return [];
|
|
2212
|
+
async function getBlockTimeByHeight(height) {
|
|
2213
|
+
var _a2, _b2;
|
|
2214
|
+
const details = await getBlockDetailsByHeight(height);
|
|
2215
|
+
if (details.block_id === void 0) {
|
|
2216
|
+
if (height.toFixed(0) in FAILOVER_BLOCKTIMES) {
|
|
2217
|
+
return new Date(FAILOVER_BLOCKTIMES[height.toFixed(0)]);
|
|
2021
2218
|
}
|
|
2022
|
-
return await getAddressBalances(lockerAddress);
|
|
2023
|
-
} catch (e) {
|
|
2024
|
-
console.error("failed to get locked balances", e);
|
|
2025
|
-
return [];
|
|
2026
2219
|
}
|
|
2220
|
+
return (_b2 = (_a2 = details.block) == null ? void 0 : _a2.header) == null ? void 0 : _b2.time;
|
|
2027
2221
|
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
var EPOCH_WEEK = "week";
|
|
2033
|
-
var EPOCHS_INFO_CACHE_KEY = "epochs:info";
|
|
2034
|
-
var EPOCHS_INFO_CACHE_TTL = 60 * 60;
|
|
2035
|
-
async function getEpochsInfo() {
|
|
2222
|
+
async function getBlockResults(height) {
|
|
2223
|
+
const settings = getSettings();
|
|
2224
|
+
const rpcUrl = settings.endpoints.rpcEndpoint.replace("wss", "https");
|
|
2225
|
+
const url = `${rpcUrl}/block_results?height=${height}`;
|
|
2036
2226
|
try {
|
|
2037
|
-
const
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
2042
|
-
for (const epoch of cached.epochs) {
|
|
2043
|
-
if (epoch.current_epoch_start_time) {
|
|
2044
|
-
const startTime = new Date(epoch.current_epoch_start_time).getTime();
|
|
2045
|
-
const duration = getEpochDurationByIdentifier(epoch.identifier);
|
|
2046
|
-
const epochEndTime = startTime + duration - 15 * 1e3;
|
|
2047
|
-
if (now >= epochEndTime) {
|
|
2048
|
-
shouldFetchFromEndpoint = true;
|
|
2049
|
-
break;
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
if (!shouldFetchFromEndpoint) {
|
|
2054
|
-
return cached;
|
|
2227
|
+
const response = await fetch(url, {
|
|
2228
|
+
method: "GET",
|
|
2229
|
+
headers: {
|
|
2230
|
+
"Content-Type": "application/json"
|
|
2055
2231
|
}
|
|
2232
|
+
});
|
|
2233
|
+
if (!response.ok) {
|
|
2234
|
+
console.log("not ok response from RPC: ", response);
|
|
2235
|
+
return void 0;
|
|
2056
2236
|
}
|
|
2237
|
+
return await response.json();
|
|
2238
|
+
} catch (error) {
|
|
2239
|
+
console.error("Failed to fetch block results:", error);
|
|
2240
|
+
throw error;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
// src/query/raffle.ts
|
|
2245
|
+
async function getRaffles() {
|
|
2246
|
+
try {
|
|
2057
2247
|
const client = await getRestClient();
|
|
2058
|
-
const response = await client.bze.
|
|
2059
|
-
|
|
2060
|
-
return response;
|
|
2248
|
+
const response = await client.bze.burner.raffles();
|
|
2249
|
+
return response.list;
|
|
2061
2250
|
} catch (e) {
|
|
2062
2251
|
console.error(e);
|
|
2063
|
-
return
|
|
2252
|
+
return [];
|
|
2064
2253
|
}
|
|
2065
2254
|
}
|
|
2066
|
-
async function
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
}
|
|
2076
|
-
async function getCurrentWeekEpochEndTime() {
|
|
2077
|
-
return getPeriodicEpochEndTime(EPOCH_WEEK);
|
|
2078
|
-
}
|
|
2079
|
-
async function getPeriodicWeekEpochEndTime(modWeek = 1) {
|
|
2080
|
-
return getPeriodicEpochEndTime(EPOCH_WEEK, modWeek);
|
|
2255
|
+
async function getRaffleWinners(denom) {
|
|
2256
|
+
try {
|
|
2257
|
+
const client = await getRestClient();
|
|
2258
|
+
const response = await client.bze.burner.raffleWinners({ denom });
|
|
2259
|
+
return response.list;
|
|
2260
|
+
} catch (e) {
|
|
2261
|
+
console.error(e);
|
|
2262
|
+
return [];
|
|
2263
|
+
}
|
|
2081
2264
|
}
|
|
2082
|
-
async function
|
|
2083
|
-
|
|
2084
|
-
|
|
2265
|
+
async function checkAddressWonRaffle(address, denom, height) {
|
|
2266
|
+
var _a2;
|
|
2267
|
+
const response = {
|
|
2268
|
+
hasWon: false,
|
|
2269
|
+
amount: "0",
|
|
2270
|
+
denom,
|
|
2271
|
+
address
|
|
2272
|
+
};
|
|
2273
|
+
if (address == "" || height <= 0) {
|
|
2085
2274
|
return void 0;
|
|
2086
2275
|
}
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
remainingEpochs = 0;
|
|
2276
|
+
const blockResults = await getBlockResults(height);
|
|
2277
|
+
if (!blockResults) {
|
|
2278
|
+
return void 0;
|
|
2091
2279
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
const
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2280
|
+
if (!((_a2 = blockResults.result) == null ? void 0 : _a2.finalize_block_events)) {
|
|
2281
|
+
return void 0;
|
|
2282
|
+
}
|
|
2283
|
+
if (blockResults.result.finalize_block_events.length === 0) {
|
|
2284
|
+
return void 0;
|
|
2285
|
+
}
|
|
2286
|
+
const raffleEvents = blockResults.result.finalize_block_events.filter((ev) => ev.type.includes("Raffle"));
|
|
2287
|
+
if (!raffleEvents || raffleEvents.length === 0) {
|
|
2288
|
+
return void 0;
|
|
2289
|
+
}
|
|
2290
|
+
for (let i = 0; i < raffleEvents.length; i++) {
|
|
2291
|
+
const ev = raffleEvents[i];
|
|
2292
|
+
const converted = mapEventAttributes(ev.attributes);
|
|
2293
|
+
if ("participant" in converted && ev.type.includes("RaffleLostEvent") && converted["participant"] === address) {
|
|
2294
|
+
return response;
|
|
2295
|
+
}
|
|
2296
|
+
if ("winner" in converted && ev.type.includes("RaffleWinnerEvent") && converted["winner"] === address && converted["denom"] === denom) {
|
|
2297
|
+
response.hasWon = true;
|
|
2298
|
+
response.amount = converted["amount"];
|
|
2299
|
+
return response;
|
|
2300
|
+
}
|
|
2108
2301
|
}
|
|
2302
|
+
return response;
|
|
2109
2303
|
}
|
|
2110
2304
|
|
|
2111
2305
|
// src/query/factory.ts
|
|
@@ -2949,12 +3143,29 @@ function useBalance(denom) {
|
|
|
2949
3143
|
}
|
|
2950
3144
|
|
|
2951
3145
|
// src/hooks/useEpochs.ts
|
|
2952
|
-
import { useMemo as useMemo6 } from "react";
|
|
3146
|
+
import { useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
3147
|
+
import BigNumber9 from "bignumber.js";
|
|
2953
3148
|
var EPOCH_HOUR2 = "hour";
|
|
2954
3149
|
var EPOCH_DAY2 = "day";
|
|
2955
3150
|
var EPOCH_WEEK2 = "week";
|
|
3151
|
+
function getEpochDurationByIdentifier2(identifier) {
|
|
3152
|
+
const hourMs = 60 * 60 * 1e3;
|
|
3153
|
+
switch (identifier) {
|
|
3154
|
+
case EPOCH_HOUR2:
|
|
3155
|
+
return hourMs;
|
|
3156
|
+
case EPOCH_DAY2:
|
|
3157
|
+
return hourMs * 24;
|
|
3158
|
+
case EPOCH_WEEK2:
|
|
3159
|
+
return hourMs * 24 * 7;
|
|
3160
|
+
default:
|
|
3161
|
+
return hourMs;
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
2956
3164
|
function useEpochs() {
|
|
2957
3165
|
const { epochs, isLoading, updateEpochs } = useAssetsContext();
|
|
3166
|
+
const getCurrentEpoch2 = useCallback6((identifier) => {
|
|
3167
|
+
return epochs.get(identifier);
|
|
3168
|
+
}, [epochs]);
|
|
2958
3169
|
const hourEpochInfo = useMemo6(() => {
|
|
2959
3170
|
return epochs.get(EPOCH_HOUR2);
|
|
2960
3171
|
}, [epochs]);
|
|
@@ -2964,19 +3175,65 @@ function useEpochs() {
|
|
|
2964
3175
|
const weekEpochInfo = useMemo6(() => {
|
|
2965
3176
|
return epochs.get(EPOCH_WEEK2);
|
|
2966
3177
|
}, [epochs]);
|
|
3178
|
+
const getHourEpochInfo2 = useCallback6(() => {
|
|
3179
|
+
return epochs.get(EPOCH_HOUR2);
|
|
3180
|
+
}, [epochs]);
|
|
3181
|
+
const getDayEpochInfo = useCallback6(() => {
|
|
3182
|
+
return epochs.get(EPOCH_DAY2);
|
|
3183
|
+
}, [epochs]);
|
|
3184
|
+
const getWeekEpochInfo2 = useCallback6(() => {
|
|
3185
|
+
return epochs.get(EPOCH_WEEK2);
|
|
3186
|
+
}, [epochs]);
|
|
3187
|
+
const getPeriodicEpochEndTime2 = useCallback6((identifier, modWeek = 1) => {
|
|
3188
|
+
const epoch = epochs.get(identifier);
|
|
3189
|
+
if (!epoch || !epoch.current_epoch_start_time) {
|
|
3190
|
+
return void 0;
|
|
3191
|
+
}
|
|
3192
|
+
const current = new BigNumber9(epoch.current_epoch);
|
|
3193
|
+
let remainingEpochs = modWeek - current.toNumber() % modWeek;
|
|
3194
|
+
if (remainingEpochs === modWeek) {
|
|
3195
|
+
remainingEpochs = 0;
|
|
3196
|
+
}
|
|
3197
|
+
const startAt = new Date(epoch.current_epoch_start_time);
|
|
3198
|
+
const duration = getEpochDurationByIdentifier2(identifier);
|
|
3199
|
+
startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
|
|
3200
|
+
return startAt;
|
|
3201
|
+
}, [epochs]);
|
|
3202
|
+
const getCurrentWeekEpochEndTime2 = useCallback6(() => {
|
|
3203
|
+
return getPeriodicEpochEndTime2(EPOCH_WEEK2);
|
|
3204
|
+
}, [getPeriodicEpochEndTime2]);
|
|
3205
|
+
const getPeriodicWeekEpochEndTime2 = useCallback6((modWeek = 1) => {
|
|
3206
|
+
return getPeriodicEpochEndTime2(EPOCH_WEEK2, modWeek);
|
|
3207
|
+
}, [getPeriodicEpochEndTime2]);
|
|
3208
|
+
const epochsList = useMemo6(() => Array.from(epochs.values()), [epochs]);
|
|
2967
3209
|
return {
|
|
2968
|
-
epochs,
|
|
3210
|
+
epochs: epochsList,
|
|
3211
|
+
epochsMap: epochs,
|
|
2969
3212
|
hourEpochInfo,
|
|
2970
3213
|
dayEpochInfo,
|
|
2971
3214
|
weekEpochInfo,
|
|
2972
3215
|
isLoading,
|
|
2973
|
-
updateEpochs
|
|
3216
|
+
updateEpochs,
|
|
3217
|
+
getCurrentEpoch: getCurrentEpoch2,
|
|
3218
|
+
getHourEpochInfo: getHourEpochInfo2,
|
|
3219
|
+
getDayEpochInfo,
|
|
3220
|
+
getWeekEpochInfo: getWeekEpochInfo2,
|
|
3221
|
+
getCurrentWeekEpochEndTime: getCurrentWeekEpochEndTime2,
|
|
3222
|
+
getPeriodicWeekEpochEndTime: getPeriodicWeekEpochEndTime2,
|
|
3223
|
+
getPeriodicEpochEndTime: getPeriodicEpochEndTime2
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3226
|
+
function useEpochsManager() {
|
|
3227
|
+
const { updateEpochs, isLoading } = useAssetsContext();
|
|
3228
|
+
return {
|
|
3229
|
+
updateEpochs,
|
|
3230
|
+
isLoading
|
|
2974
3231
|
};
|
|
2975
3232
|
}
|
|
2976
3233
|
|
|
2977
3234
|
// src/hooks/useLiquidityPools.ts
|
|
2978
|
-
import { useCallback as
|
|
2979
|
-
import
|
|
3235
|
+
import { useCallback as useCallback7, useMemo as useMemo7 } from "react";
|
|
3236
|
+
import BigNumber10 from "bignumber.js";
|
|
2980
3237
|
function useLiquidityPools() {
|
|
2981
3238
|
const { poolsMap, poolsDataMap, updateLiquidityPools, isLoading, assetsMap } = useAssetsContext();
|
|
2982
3239
|
const pools = useMemo7(() => {
|
|
@@ -2986,7 +3243,7 @@ function useLiquidityPools() {
|
|
|
2986
3243
|
const poolId = poolIdFromPoolDenom(lpDenom);
|
|
2987
3244
|
return poolsMap.get(poolId);
|
|
2988
3245
|
};
|
|
2989
|
-
const getDenomsPool =
|
|
3246
|
+
const getDenomsPool = useCallback7((denomA, denomB) => {
|
|
2990
3247
|
const poolId = createPoolId(denomA, denomB);
|
|
2991
3248
|
return poolsMap.get(poolId);
|
|
2992
3249
|
}, [poolsMap]);
|
|
@@ -3030,7 +3287,7 @@ function useAssetLiquidityPools(denom) {
|
|
|
3030
3287
|
return newMap;
|
|
3031
3288
|
}, [assetPools, poolsDataMap, isLoading, denom]);
|
|
3032
3289
|
const asset24HoursVolume = useMemo7(() => {
|
|
3033
|
-
let volume =
|
|
3290
|
+
let volume = BigNumber10(0);
|
|
3034
3291
|
if (isLoading || denom === "") return volume;
|
|
3035
3292
|
assetPoolsData.forEach((poolData) => {
|
|
3036
3293
|
if (poolData.base === denom) {
|
|
@@ -3085,13 +3342,13 @@ function useLiquidityPool(poolId) {
|
|
|
3085
3342
|
const reserveQuote = toBigNumber(pool.reserve_quote);
|
|
3086
3343
|
return userShares.dividedBy(totalShares).multipliedBy(reserveQuote);
|
|
3087
3344
|
}, [pool, userShares, totalShares]);
|
|
3088
|
-
const calculateOppositeAmount =
|
|
3345
|
+
const calculateOppositeAmount = useCallback7((amount, isBase) => {
|
|
3089
3346
|
if (!pool) {
|
|
3090
3347
|
return toBigNumber(0);
|
|
3091
3348
|
}
|
|
3092
3349
|
return calculatePoolOppositeAmount(pool, amount, isBase);
|
|
3093
3350
|
}, [pool]);
|
|
3094
|
-
const calculateSharesFromAmounts =
|
|
3351
|
+
const calculateSharesFromAmounts = useCallback7((baseAmount, quoteAmount) => {
|
|
3095
3352
|
if (!pool || !totalShares) {
|
|
3096
3353
|
return toBigNumber(0);
|
|
3097
3354
|
}
|
|
@@ -3107,9 +3364,9 @@ function useLiquidityPool(poolId) {
|
|
|
3107
3364
|
}
|
|
3108
3365
|
const baseRatio = baseAmountBN.dividedBy(reserveBase);
|
|
3109
3366
|
const quoteRatio = quoteAmountBN.dividedBy(reserveQuote);
|
|
3110
|
-
const mintRatio =
|
|
3367
|
+
const mintRatio = BigNumber10.minimum(baseRatio, quoteRatio);
|
|
3111
3368
|
const tokensToMint = mintRatio.multipliedBy(totalShares);
|
|
3112
|
-
return tokensToMint.integerValue(
|
|
3369
|
+
return tokensToMint.integerValue(BigNumber10.ROUND_DOWN);
|
|
3113
3370
|
}, [pool, totalShares]);
|
|
3114
3371
|
return {
|
|
3115
3372
|
isLoading,
|
|
@@ -3126,12 +3383,12 @@ function useLiquidityPool(poolId) {
|
|
|
3126
3383
|
}
|
|
3127
3384
|
|
|
3128
3385
|
// src/hooks/useAssetsValue.ts
|
|
3129
|
-
import { useCallback as
|
|
3130
|
-
import
|
|
3386
|
+
import { useCallback as useCallback8, useMemo as useMemo8 } from "react";
|
|
3387
|
+
import BigNumber11 from "bignumber.js";
|
|
3131
3388
|
function useAssetsValue() {
|
|
3132
3389
|
const { assetsMap, usdPricesMap, balancesMap, isLoading: isLoadingPrices } = useAssetsContext();
|
|
3133
|
-
const totalUsdValue =
|
|
3134
|
-
let usdValue =
|
|
3390
|
+
const totalUsdValue = useCallback8((prettyBalances) => {
|
|
3391
|
+
let usdValue = BigNumber11(0);
|
|
3135
3392
|
prettyBalances.map((denomBalance) => {
|
|
3136
3393
|
const assetPrice = usdPricesMap.get(denomBalance.denom);
|
|
3137
3394
|
if (assetPrice && assetPrice.gt(0)) {
|
|
@@ -3151,21 +3408,21 @@ function useAssetsValue() {
|
|
|
3151
3408
|
});
|
|
3152
3409
|
return total;
|
|
3153
3410
|
}, [balancesMap, usdPricesMap, assetsMap]);
|
|
3154
|
-
const denomUsdValue =
|
|
3411
|
+
const denomUsdValue = useCallback8((denom, uAmount) => {
|
|
3155
3412
|
const price = usdPricesMap.get(denom);
|
|
3156
3413
|
if (!price || !price.gt(0)) return toBigNumber(0);
|
|
3157
3414
|
const asset = assetsMap.get(denom);
|
|
3158
3415
|
if (!asset) return toBigNumber(0);
|
|
3159
3416
|
return price.multipliedBy(uAmountToBigNumberAmount(uAmount, asset.decimals));
|
|
3160
3417
|
}, [usdPricesMap, assetsMap]);
|
|
3161
|
-
const compareValues =
|
|
3418
|
+
const compareValues = useCallback8((a, b) => {
|
|
3162
3419
|
var _a2;
|
|
3163
|
-
let aValue =
|
|
3420
|
+
let aValue = BigNumber11(0);
|
|
3164
3421
|
const aPrice = usdPricesMap.get(a.denom);
|
|
3165
3422
|
if (aPrice) {
|
|
3166
3423
|
aValue = aPrice.multipliedBy(a.amount);
|
|
3167
3424
|
}
|
|
3168
|
-
let bValue =
|
|
3425
|
+
let bValue = BigNumber11(0);
|
|
3169
3426
|
const bPrice = usdPricesMap.get(b.denom);
|
|
3170
3427
|
if (bPrice) {
|
|
3171
3428
|
bValue = bPrice.multipliedBy(b.amount);
|
|
@@ -3218,17 +3475,17 @@ function useFeeTokens() {
|
|
|
3218
3475
|
}
|
|
3219
3476
|
|
|
3220
3477
|
// src/hooks/useMarkets.ts
|
|
3221
|
-
import { useCallback as
|
|
3222
|
-
import
|
|
3478
|
+
import { useCallback as useCallback9, useMemo as useMemo10 } from "react";
|
|
3479
|
+
import BigNumber12 from "bignumber.js";
|
|
3223
3480
|
function useMarkets() {
|
|
3224
3481
|
const { marketsMap, marketsDataMap, updateMarkets, isLoading } = useAssetsContext();
|
|
3225
3482
|
const markets = useMemo10(() => {
|
|
3226
3483
|
return Array.from(marketsMap.values());
|
|
3227
3484
|
}, [marketsMap]);
|
|
3228
3485
|
const marketsData = useMemo10(() => Array.from(marketsDataMap.values()), [marketsDataMap]);
|
|
3229
|
-
const marketExists =
|
|
3230
|
-
const getMarketData =
|
|
3231
|
-
const getMarket =
|
|
3486
|
+
const marketExists = useCallback9((marketId) => marketsMap.has(marketId), [marketsMap]);
|
|
3487
|
+
const getMarketData = useCallback9((marketId) => marketsDataMap.get(marketId), [marketsDataMap]);
|
|
3488
|
+
const getMarket = useCallback9((marketId) => marketsMap.get(marketId), [marketsMap]);
|
|
3232
3489
|
return {
|
|
3233
3490
|
markets,
|
|
3234
3491
|
marketsData,
|
|
@@ -3271,7 +3528,7 @@ function useAssetMarkets(denom) {
|
|
|
3271
3528
|
return acc.plus(market.quote_volume || 0);
|
|
3272
3529
|
}
|
|
3273
3530
|
return acc;
|
|
3274
|
-
}, new
|
|
3531
|
+
}, new BigNumber12(0));
|
|
3275
3532
|
}, [assetMarketsData, denom]);
|
|
3276
3533
|
return {
|
|
3277
3534
|
isLoading,
|
|
@@ -3324,7 +3581,7 @@ function useMarketsManager() {
|
|
|
3324
3581
|
}
|
|
3325
3582
|
|
|
3326
3583
|
// src/hooks/useToast.tsx
|
|
3327
|
-
import { useCallback as
|
|
3584
|
+
import { useCallback as useCallback10, useMemo as useMemo11 } from "react";
|
|
3328
3585
|
|
|
3329
3586
|
// src/components/toaster.tsx
|
|
3330
3587
|
import {
|
|
@@ -3354,7 +3611,7 @@ var Toaster = () => {
|
|
|
3354
3611
|
|
|
3355
3612
|
// src/hooks/useToast.tsx
|
|
3356
3613
|
var useToast = () => {
|
|
3357
|
-
const clickableSuccess =
|
|
3614
|
+
const clickableSuccess = useCallback10((title, actionFn, actionLabel, description, duration = 5e3) => {
|
|
3358
3615
|
toaster.create({
|
|
3359
3616
|
title,
|
|
3360
3617
|
description,
|
|
@@ -3367,7 +3624,7 @@ var useToast = () => {
|
|
|
3367
3624
|
}
|
|
3368
3625
|
});
|
|
3369
3626
|
}, []);
|
|
3370
|
-
const success =
|
|
3627
|
+
const success = useCallback10((title, description, duration = 5e3) => {
|
|
3371
3628
|
toaster.create({
|
|
3372
3629
|
title,
|
|
3373
3630
|
description,
|
|
@@ -3376,7 +3633,7 @@ var useToast = () => {
|
|
|
3376
3633
|
closable: true
|
|
3377
3634
|
});
|
|
3378
3635
|
}, []);
|
|
3379
|
-
const error =
|
|
3636
|
+
const error = useCallback10((title, description, duration = 8e3) => {
|
|
3380
3637
|
toaster.create({
|
|
3381
3638
|
title,
|
|
3382
3639
|
description,
|
|
@@ -3385,7 +3642,7 @@ var useToast = () => {
|
|
|
3385
3642
|
closable: true
|
|
3386
3643
|
});
|
|
3387
3644
|
}, []);
|
|
3388
|
-
const warning =
|
|
3645
|
+
const warning = useCallback10((title, description, duration = 6e3) => {
|
|
3389
3646
|
toaster.create({
|
|
3390
3647
|
title,
|
|
3391
3648
|
description,
|
|
@@ -3394,7 +3651,7 @@ var useToast = () => {
|
|
|
3394
3651
|
closable: true
|
|
3395
3652
|
});
|
|
3396
3653
|
}, []);
|
|
3397
|
-
const info =
|
|
3654
|
+
const info = useCallback10((title, description, duration = 5e3) => {
|
|
3398
3655
|
toaster.create({
|
|
3399
3656
|
title,
|
|
3400
3657
|
description,
|
|
@@ -3403,7 +3660,7 @@ var useToast = () => {
|
|
|
3403
3660
|
closable: true
|
|
3404
3661
|
});
|
|
3405
3662
|
}, []);
|
|
3406
|
-
const loading =
|
|
3663
|
+
const loading = useCallback10((title, description) => {
|
|
3407
3664
|
return toaster.create({
|
|
3408
3665
|
title,
|
|
3409
3666
|
description,
|
|
@@ -3411,7 +3668,7 @@ var useToast = () => {
|
|
|
3411
3668
|
closable: false
|
|
3412
3669
|
});
|
|
3413
3670
|
}, []);
|
|
3414
|
-
const dismiss =
|
|
3671
|
+
const dismiss = useCallback10((id) => {
|
|
3415
3672
|
toaster.dismiss(id);
|
|
3416
3673
|
}, []);
|
|
3417
3674
|
const toast = useMemo11(() => ({
|
|
@@ -3429,8 +3686,8 @@ var useToast = () => {
|
|
|
3429
3686
|
// src/hooks/useTx.tsx
|
|
3430
3687
|
import { coins, isDeliverTxSuccess } from "@cosmjs/stargate";
|
|
3431
3688
|
import { useChain as useChain2 } from "@interchain-kit/react";
|
|
3432
|
-
import
|
|
3433
|
-
import { useCallback as
|
|
3689
|
+
import BigNumber13 from "bignumber.js";
|
|
3690
|
+
import { useCallback as useCallback11, useMemo as useMemo12, useState as useState3 } from "react";
|
|
3434
3691
|
var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
3435
3692
|
TxStatus2["Failed"] = "Transaction Failed";
|
|
3436
3693
|
TxStatus2["Successful"] = "Transaction Successful";
|
|
@@ -3470,18 +3727,18 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3470
3727
|
const { getDenomsPool } = useLiquidityPools();
|
|
3471
3728
|
const { feeDenom } = useSettings();
|
|
3472
3729
|
const defaultChainName = useMemo12(() => getChainName(), []);
|
|
3473
|
-
const canUseClient =
|
|
3730
|
+
const canUseClient = useCallback11(async () => {
|
|
3474
3731
|
if (!isSigningClientReady) {
|
|
3475
3732
|
console.error("waiting for signing client to be ready", signingClientError);
|
|
3476
3733
|
await sleep(1e3);
|
|
3477
3734
|
}
|
|
3478
3735
|
return isSigningClientReady;
|
|
3479
3736
|
}, [isSigningClientReady, signingClientError]);
|
|
3480
|
-
const simulateFee =
|
|
3737
|
+
const simulateFee = useCallback11(async (messages, memo) => {
|
|
3481
3738
|
const gasPrice = 0.02;
|
|
3482
3739
|
const nativeDenom = getChainNativeAssetDenom();
|
|
3483
3740
|
const gasEstimated = await signingClient.simulate(address, messages, memo);
|
|
3484
|
-
const gasAmount =
|
|
3741
|
+
const gasAmount = BigNumber13(gasEstimated).multipliedBy(1.5);
|
|
3485
3742
|
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
3486
3743
|
const nativeFee = {
|
|
3487
3744
|
amount: coins(gasPayment.toFixed(0).toString(), nativeDenom),
|
|
@@ -3498,16 +3755,16 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3498
3755
|
if (!expectedAmount.isPositive()) {
|
|
3499
3756
|
return nativeFee;
|
|
3500
3757
|
}
|
|
3501
|
-
expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(
|
|
3758
|
+
expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(BigNumber13.ROUND_FLOOR);
|
|
3502
3759
|
if (expectedAmount.multipliedBy(pool.fee).lt(1)) {
|
|
3503
|
-
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(
|
|
3760
|
+
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(BigNumber13.ROUND_CEIL);
|
|
3504
3761
|
}
|
|
3505
3762
|
return {
|
|
3506
3763
|
amount: coins(expectedAmount.toFixed(0).toString(), feeDenom),
|
|
3507
3764
|
gas: gasAmount.multipliedBy(1.5).toFixed(0)
|
|
3508
3765
|
};
|
|
3509
3766
|
}, [signingClient, address, feeDenom, getDenomsPool]);
|
|
3510
|
-
const getFee =
|
|
3767
|
+
const getFee = useCallback11(async (messages, options) => {
|
|
3511
3768
|
try {
|
|
3512
3769
|
if (options == null ? void 0 : options.fee) {
|
|
3513
3770
|
return options.fee;
|
|
@@ -3524,7 +3781,7 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3524
3781
|
}
|
|
3525
3782
|
}
|
|
3526
3783
|
}, [simulateFee]);
|
|
3527
|
-
const tx =
|
|
3784
|
+
const tx = useCallback11(async (msgs, options) => {
|
|
3528
3785
|
var _a2;
|
|
3529
3786
|
if (!address) {
|
|
3530
3787
|
toast.error("Transaction Failed" /* Failed */, "Please connect the wallet");
|
|
@@ -3777,7 +4034,7 @@ import {
|
|
|
3777
4034
|
} from "@chakra-ui/react";
|
|
3778
4035
|
import { Select, Portal as Portal3 } from "@chakra-ui/react";
|
|
3779
4036
|
import { useTheme } from "next-themes";
|
|
3780
|
-
import { useState as useState6, useEffect as useEffect4, useMemo as useMemo13, useCallback as
|
|
4037
|
+
import { useState as useState6, useEffect as useEffect4, useMemo as useMemo13, useCallback as useCallback12 } from "react";
|
|
3781
4038
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
3782
4039
|
var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
3783
4040
|
const { setTheme, resolvedTheme } = useTheme();
|
|
@@ -3797,7 +4054,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3797
4054
|
setPreferredFeeDenom(settings.preferredFeeDenom || getChainNativeAssetDenom());
|
|
3798
4055
|
}
|
|
3799
4056
|
}, [isLoaded, settings]);
|
|
3800
|
-
const handleValidateEndpoints =
|
|
4057
|
+
const handleValidateEndpoints = useCallback12(async (rest, rpc) => {
|
|
3801
4058
|
setIsValidating(true);
|
|
3802
4059
|
setValidationResults({});
|
|
3803
4060
|
try {
|
|
@@ -3817,7 +4074,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3817
4074
|
setTimeout(() => setValidationResults({}), 1e4);
|
|
3818
4075
|
}
|
|
3819
4076
|
}, []);
|
|
3820
|
-
const handleSaveSettings =
|
|
4077
|
+
const handleSaveSettings = useCallback12(async (rest, rpc, feeDenom) => {
|
|
3821
4078
|
setValidationResults({});
|
|
3822
4079
|
const results = await validateEndpoints(rest, rpc);
|
|
3823
4080
|
if (!results.isValid) {
|
|
@@ -3837,7 +4094,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3837
4094
|
toast.success("Success!", "Settings have been saved.");
|
|
3838
4095
|
}
|
|
3839
4096
|
}, []);
|
|
3840
|
-
const handleResetToDefaults =
|
|
4097
|
+
const handleResetToDefaults = useCallback12(() => {
|
|
3841
4098
|
setRestEndpoint(defaultSettings.endpoints.restEndpoint);
|
|
3842
4099
|
setRpcEndpoint(defaultSettings.endpoints.rpcEndpoint);
|
|
3843
4100
|
setPreferredFeeDenom(defaultSettings.preferredFeeDenom);
|
|
@@ -3870,7 +4127,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3870
4127
|
name: token.ticker || token.name
|
|
3871
4128
|
}))
|
|
3872
4129
|
}), [feeTokens]);
|
|
3873
|
-
const handleFeeTokenChange =
|
|
4130
|
+
const handleFeeTokenChange = useCallback12((denom) => {
|
|
3874
4131
|
setPreferredFeeDenom(denom || void 0);
|
|
3875
4132
|
}, []);
|
|
3876
4133
|
const hasUnsavedChanges = restEndpoint !== settings.endpoints.restEndpoint || rpcEndpoint !== settings.endpoints.rpcEndpoint || preferredFeeDenom !== settings.preferredFeeDenom;
|
|
@@ -4046,15 +4303,15 @@ import {
|
|
|
4046
4303
|
VStack as VStack2
|
|
4047
4304
|
} from "@chakra-ui/react";
|
|
4048
4305
|
import { LuCopy, LuExternalLink, LuX as LuX2 } from "react-icons/lu";
|
|
4049
|
-
import { useCallback as
|
|
4306
|
+
import { useCallback as useCallback13, useEffect as useEffect5, useMemo as useMemo14, useRef as useRef3, useState as useState7 } from "react";
|
|
4050
4307
|
import { WalletState } from "@interchain-kit/core";
|
|
4051
|
-
import
|
|
4308
|
+
import BigNumber14 from "bignumber.js";
|
|
4052
4309
|
import { cosmos } from "@bze/bzejs";
|
|
4053
4310
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4054
4311
|
var validateAmount = (amount, coin, onError) => {
|
|
4055
4312
|
if (!coin) return;
|
|
4056
4313
|
if (amount === "") return;
|
|
4057
|
-
const amountNumber =
|
|
4314
|
+
const amountNumber = BigNumber14(amount);
|
|
4058
4315
|
if (amountNumber.isNaN()) {
|
|
4059
4316
|
onError("Invalid amount");
|
|
4060
4317
|
return;
|
|
@@ -4148,13 +4405,13 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4148
4405
|
const isValidForm = useMemo14(() => {
|
|
4149
4406
|
return selectedCoin && memoError === "" && recipientError === "" && sendAmountError === "" && sendAmount !== "" && recipient !== "";
|
|
4150
4407
|
}, [selectedCoin, memoError, recipientError, sendAmountError, sendAmount, recipient]);
|
|
4151
|
-
const resetSendForm =
|
|
4408
|
+
const resetSendForm = useCallback13(() => {
|
|
4152
4409
|
setSelectedCoin(void 0);
|
|
4153
4410
|
setSendAmount("");
|
|
4154
4411
|
setRecipient("");
|
|
4155
4412
|
setMemo("");
|
|
4156
4413
|
}, []);
|
|
4157
|
-
const handleSend =
|
|
4414
|
+
const handleSend = useCallback13(async () => {
|
|
4158
4415
|
var _a2, _b2;
|
|
4159
4416
|
if (!isValidForm) {
|
|
4160
4417
|
toast.error("Can not send coins!", "Please check the input data.");
|
|
@@ -4179,11 +4436,11 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4179
4436
|
setIsLoading(false);
|
|
4180
4437
|
onClose();
|
|
4181
4438
|
}, [address, memo, onClose, recipient, selectedCoin, sendAmount, status]);
|
|
4182
|
-
const handleCancel =
|
|
4439
|
+
const handleCancel = useCallback13(() => {
|
|
4183
4440
|
resetSendForm();
|
|
4184
4441
|
onClose();
|
|
4185
4442
|
}, [onClose, resetSendForm]);
|
|
4186
|
-
const onRecipientChange =
|
|
4443
|
+
const onRecipientChange = useCallback13((recipient2) => {
|
|
4187
4444
|
setRecipient(recipient2);
|
|
4188
4445
|
if (recipient2.length === 0) {
|
|
4189
4446
|
setRecipientError("");
|
|
@@ -4196,11 +4453,11 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4196
4453
|
setRecipientError(validate.message);
|
|
4197
4454
|
}
|
|
4198
4455
|
}, []);
|
|
4199
|
-
const onAmountChange =
|
|
4456
|
+
const onAmountChange = useCallback13((amount) => {
|
|
4200
4457
|
setSendAmount(sanitizeNumberInput(amount));
|
|
4201
4458
|
setSendAmountError("");
|
|
4202
4459
|
}, []);
|
|
4203
|
-
const onCoinSelectChange =
|
|
4460
|
+
const onCoinSelectChange = useCallback13((ticker) => {
|
|
4204
4461
|
if (ticker === "") return;
|
|
4205
4462
|
const selectedCoin2 = balances.find((item) => item.ticker === ticker);
|
|
4206
4463
|
if (selectedCoin2) {
|
|
@@ -4208,13 +4465,13 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4208
4465
|
validateAmount(sendAmount, selectedCoin2, setSendAmountError);
|
|
4209
4466
|
}
|
|
4210
4467
|
}, [sendAmount, balances]);
|
|
4211
|
-
const setMaxAmount =
|
|
4468
|
+
const setMaxAmount = useCallback13(() => {
|
|
4212
4469
|
if (!selectedCoin) return;
|
|
4213
4470
|
const maxAmount = uAmountToBigNumberAmount(selectedCoin.amount, selectedCoin.decimals);
|
|
4214
4471
|
onAmountChange(maxAmount.toString());
|
|
4215
4472
|
validateAmount(maxAmount.toString(), selectedCoin, setSendAmountError);
|
|
4216
4473
|
}, [selectedCoin, onAmountChange]);
|
|
4217
|
-
const onMemoChange =
|
|
4474
|
+
const onMemoChange = useCallback13((memo2) => {
|
|
4218
4475
|
setMemo(memo2);
|
|
4219
4476
|
if (memo2.length > 256) {
|
|
4220
4477
|
setMemoError("Memo must be less than or equal to 256 characters");
|
|
@@ -4425,15 +4682,15 @@ var WalletSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
4425
4682
|
setShowCopiedTooltip(true);
|
|
4426
4683
|
setTimeout(() => setShowCopiedTooltip(false), 2e3);
|
|
4427
4684
|
};
|
|
4428
|
-
const handleCancel =
|
|
4685
|
+
const handleCancel = useCallback13(() => {
|
|
4429
4686
|
setViewState("balances");
|
|
4430
4687
|
setClickedBalance("");
|
|
4431
4688
|
}, []);
|
|
4432
|
-
const onBalanceClick =
|
|
4689
|
+
const onBalanceClick = useCallback13((ticker) => {
|
|
4433
4690
|
setClickedBalance(ticker);
|
|
4434
4691
|
setViewState("send");
|
|
4435
4692
|
}, []);
|
|
4436
|
-
const handleDisconnectAll =
|
|
4693
|
+
const handleDisconnectAll = useCallback13(async () => {
|
|
4437
4694
|
setIsDisconnecting(true);
|
|
4438
4695
|
try {
|
|
4439
4696
|
console.log("Disconnected from all chains");
|
|
@@ -4673,6 +4930,7 @@ export {
|
|
|
4673
4930
|
canDepositFromIBC,
|
|
4674
4931
|
canSendToIBC,
|
|
4675
4932
|
cancelDebounce,
|
|
4933
|
+
checkAddressWonRaffle,
|
|
4676
4934
|
convertToWebSocketUrl,
|
|
4677
4935
|
counterpartyChainForChannel,
|
|
4678
4936
|
createMarketId,
|
|
@@ -4709,6 +4967,10 @@ export {
|
|
|
4709
4967
|
getAtomOneRestURL,
|
|
4710
4968
|
getAtomOneRpcUrl,
|
|
4711
4969
|
getBZEUSDPrice,
|
|
4970
|
+
getBlockDetailsByHeight,
|
|
4971
|
+
getBlockResults,
|
|
4972
|
+
getBlockTimeByHeight,
|
|
4973
|
+
getBurnerModuleAddress,
|
|
4712
4974
|
getBurnerParams,
|
|
4713
4975
|
getBurnerParamsWithClient,
|
|
4714
4976
|
getChainAddressPrefix,
|
|
@@ -4732,6 +4994,7 @@ export {
|
|
|
4732
4994
|
getEpochsInfo,
|
|
4733
4995
|
getFactoryDenomAdminAddress,
|
|
4734
4996
|
getFromLocalStorage,
|
|
4997
|
+
getHardcodedLockAddress,
|
|
4735
4998
|
getHashIBCTrace,
|
|
4736
4999
|
getHourEpochInfo,
|
|
4737
5000
|
getIBCAssetList,
|
|
@@ -4754,6 +5017,8 @@ export {
|
|
|
4754
5017
|
getMarketSellOrders,
|
|
4755
5018
|
getMarkets,
|
|
4756
5019
|
getMinAmount,
|
|
5020
|
+
getModuleAddress,
|
|
5021
|
+
getNextBurning,
|
|
4757
5022
|
getNoOfIntervalsNeeded,
|
|
4758
5023
|
getNobleRestURL,
|
|
4759
5024
|
getNobleRpcUrl,
|
|
@@ -4765,6 +5030,9 @@ export {
|
|
|
4765
5030
|
getPendingUnlockParticipants,
|
|
4766
5031
|
getPeriodicEpochEndTime,
|
|
4767
5032
|
getPeriodicWeekEpochEndTime,
|
|
5033
|
+
getRaffleModuleAddress,
|
|
5034
|
+
getRaffleWinners,
|
|
5035
|
+
getRaffles,
|
|
4768
5036
|
getRestClient,
|
|
4769
5037
|
getRestURL,
|
|
4770
5038
|
getRpcURL,
|
|
@@ -4829,6 +5097,7 @@ export {
|
|
|
4829
5097
|
useBalances,
|
|
4830
5098
|
useConnectionType,
|
|
4831
5099
|
useEpochs,
|
|
5100
|
+
useEpochsManager,
|
|
4832
5101
|
useFeeTokens,
|
|
4833
5102
|
useIBCChains,
|
|
4834
5103
|
useIBCTx,
|