@bze/bze-ui-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +212 -0
- package/dist/index.d.mts +1172 -0
- package/dist/index.d.ts +1172 -0
- package/dist/index.js +4889 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4663 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4889 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
|
|
59
|
+
// src/index.ts
|
|
60
|
+
var index_exports = {};
|
|
61
|
+
__export(index_exports, {
|
|
62
|
+
ASSET_TYPE_FACTORY: () => ASSET_TYPE_FACTORY,
|
|
63
|
+
ASSET_TYPE_IBC: () => ASSET_TYPE_IBC,
|
|
64
|
+
ASSET_TYPE_LP: () => ASSET_TYPE_LP,
|
|
65
|
+
ASSET_TYPE_NATIVE: () => ASSET_TYPE_NATIVE,
|
|
66
|
+
AssetsContext: () => AssetsContext,
|
|
67
|
+
BZE_CIRCLE_LOGO: () => BZE_CIRCLE_LOGO,
|
|
68
|
+
BZE_TESTNET_2_SUGGEST_CHAIN: () => BZE_TESTNET_2_SUGGEST_CHAIN,
|
|
69
|
+
BZE_TESTNET_NETWORK: () => BZE_TESTNET_NETWORK,
|
|
70
|
+
CHART_1D: () => CHART_1D,
|
|
71
|
+
CHART_1Y: () => CHART_1Y,
|
|
72
|
+
CHART_30D: () => CHART_30D,
|
|
73
|
+
CHART_4H: () => CHART_4H,
|
|
74
|
+
CHART_7D: () => CHART_7D,
|
|
75
|
+
CONNECTION_TYPE_NONE: () => CONNECTION_TYPE_NONE,
|
|
76
|
+
CONNECTION_TYPE_POLLING: () => CONNECTION_TYPE_POLLING,
|
|
77
|
+
CONNECTION_TYPE_WS: () => CONNECTION_TYPE_WS,
|
|
78
|
+
CURRENT_WALLET_BALANCE_EVENT: () => CURRENT_WALLET_BALANCE_EVENT,
|
|
79
|
+
DEFAULT_SETTINGS: () => DEFAULT_SETTINGS,
|
|
80
|
+
DEFAULT_TX_MEMO: () => DEFAULT_TX_MEMO,
|
|
81
|
+
ECOSYSTEM_MENU_LABEL: () => ECOSYSTEM_MENU_LABEL,
|
|
82
|
+
EPOCH_START_EVENT: () => EPOCH_START_EVENT,
|
|
83
|
+
EXCLUDED_ASSETS: () => EXCLUDED_ASSETS,
|
|
84
|
+
EXCLUDED_MARKETS: () => EXCLUDED_MARKETS,
|
|
85
|
+
HighlightText: () => HighlightText,
|
|
86
|
+
LOCK_CHANGED_EVENT: () => LOCK_CHANGED_EVENT,
|
|
87
|
+
LP_ASSETS_DECIMALS: () => LP_ASSETS_DECIMALS,
|
|
88
|
+
MAINNET_CHAIN_INFO_FALLBACK: () => MAINNET_CHAIN_INFO_FALLBACK,
|
|
89
|
+
NEXT_BURN_CHANGED_EVENT: () => NEXT_BURN_CHANGED_EVENT,
|
|
90
|
+
ORDER_BOOK_CHANGED_EVENT: () => ORDER_BOOK_CHANGED_EVENT,
|
|
91
|
+
ORDER_EXECUTED_EVENT: () => ORDER_EXECUTED_EVENT,
|
|
92
|
+
ORDER_TYPE_BUY: () => ORDER_TYPE_BUY,
|
|
93
|
+
ORDER_TYPE_SELL: () => ORDER_TYPE_SELL,
|
|
94
|
+
RAFFLE_CHANGED_EVENT: () => RAFFLE_CHANGED_EVENT,
|
|
95
|
+
SETTINGS_STORAGE_KEY: () => SETTINGS_STORAGE_KEY,
|
|
96
|
+
STABLE_COINS: () => STABLE_COINS,
|
|
97
|
+
SUPPLY_CHANGED_EVENT: () => SUPPLY_CHANGED_EVENT,
|
|
98
|
+
SWAP_EXECUTED_EVENT: () => SWAP_EXECUTED_EVENT,
|
|
99
|
+
SettingsSidebarContent: () => SettingsSidebarContent,
|
|
100
|
+
SettingsToggle: () => SettingsToggle,
|
|
101
|
+
Sidebar: () => Sidebar,
|
|
102
|
+
TESTNET_CHAIN_INFO_FALLBACK: () => TESTNET_CHAIN_INFO_FALLBACK,
|
|
103
|
+
TOKEN_LOGO_PLACEHOLDER: () => TOKEN_LOGO_PLACEHOLDER,
|
|
104
|
+
TTL_NO_EXPIRY: () => TTL_NO_EXPIRY,
|
|
105
|
+
Toaster: () => Toaster,
|
|
106
|
+
TxStatus: () => TxStatus,
|
|
107
|
+
VALIDATION_ERRORS: () => VALIDATION_ERRORS,
|
|
108
|
+
VERIFIED_ASSETS: () => VERIFIED_ASSETS,
|
|
109
|
+
WalletSidebarContent: () => WalletSidebarContent,
|
|
110
|
+
addDebounce: () => addDebounce,
|
|
111
|
+
addMultipleDebounce: () => addMultipleDebounce,
|
|
112
|
+
ammRouter: () => ammRouter,
|
|
113
|
+
amountToBigNumberUAmount: () => amountToBigNumberUAmount,
|
|
114
|
+
amountToUAmount: () => amountToUAmount,
|
|
115
|
+
blockchainEventManager: () => blockchainEventManager,
|
|
116
|
+
calcNativeStakingApr: () => calcNativeStakingApr,
|
|
117
|
+
calculateAmountFromPrice: () => calculateAmountFromPrice,
|
|
118
|
+
calculatePoolOppositeAmount: () => calculatePoolOppositeAmount,
|
|
119
|
+
calculatePoolPrice: () => calculatePoolPrice,
|
|
120
|
+
calculatePricePerUnit: () => calculatePricePerUnit,
|
|
121
|
+
calculateRewardsStakingApr: () => calculateRewardsStakingApr,
|
|
122
|
+
calculateRewardsStakingPendingRewards: () => calculateRewardsStakingPendingRewards,
|
|
123
|
+
calculateTotalAmount: () => calculateTotalAmount,
|
|
124
|
+
calculateUserPoolData: () => calculateUserPoolData,
|
|
125
|
+
canDepositFromIBC: () => canDepositFromIBC,
|
|
126
|
+
canSendToIBC: () => canSendToIBC,
|
|
127
|
+
cancelDebounce: () => cancelDebounce,
|
|
128
|
+
convertToWebSocketUrl: () => convertToWebSocketUrl,
|
|
129
|
+
counterpartyChainForChannel: () => counterpartyChainForChannel,
|
|
130
|
+
createMarketId: () => createMarketId,
|
|
131
|
+
createPoolId: () => createPoolId,
|
|
132
|
+
createRestClient: () => createRestClient,
|
|
133
|
+
denomOnFirstHopChainFromTrace: () => denomOnFirstHopChainFromTrace,
|
|
134
|
+
formatDate: () => formatDate,
|
|
135
|
+
formatTimeRemaining: () => formatTimeRemaining,
|
|
136
|
+
formatTimeRemainingFromEpochs: () => formatTimeRemainingFromEpochs,
|
|
137
|
+
formatUsdAmount: () => formatUsdAmount,
|
|
138
|
+
getAddressBalances: () => getAddressBalances,
|
|
139
|
+
getAddressDelegations: () => getAddressDelegations,
|
|
140
|
+
getAddressFullMarketOrders: () => getAddressFullMarketOrders,
|
|
141
|
+
getAddressHistory: () => getAddressHistory,
|
|
142
|
+
getAddressMarketOrders: () => getAddressMarketOrders,
|
|
143
|
+
getAddressNativeDelegatedBalance: () => getAddressNativeDelegatedBalance,
|
|
144
|
+
getAddressNativeTotalRewards: () => getAddressNativeTotalRewards,
|
|
145
|
+
getAddressPendingUnlock: () => getAddressPendingUnlock,
|
|
146
|
+
getAddressRewards: () => getAddressRewards,
|
|
147
|
+
getAddressStakingRewards: () => getAddressStakingRewards,
|
|
148
|
+
getAddressSwapHistory: () => getAddressSwapHistory,
|
|
149
|
+
getAddressUnbondingDelegations: () => getAddressUnbondingDelegations,
|
|
150
|
+
getAddressUnbondingDelegationsSummary: () => getAddressUnbondingDelegationsSummary,
|
|
151
|
+
getAggregatorHost: () => getAggregatorHost,
|
|
152
|
+
getAllBurnedCoins: () => getAllBurnedCoins,
|
|
153
|
+
getAllSupply: () => getAllSupply,
|
|
154
|
+
getAllSupplyMetadata: () => getAllSupplyMetadata,
|
|
155
|
+
getAllTickers: () => getAllTickers,
|
|
156
|
+
getAnnualProvisions: () => getAnnualProvisions,
|
|
157
|
+
getAppName: () => getAppName,
|
|
158
|
+
getArchwayRestURL: () => getArchwayRestURL,
|
|
159
|
+
getArchwayRpcURL: () => getArchwayRpcURL,
|
|
160
|
+
getAssetLists: () => getAssetLists,
|
|
161
|
+
getAtomOneRestURL: () => getAtomOneRestURL,
|
|
162
|
+
getAtomOneRpcUrl: () => getAtomOneRpcUrl,
|
|
163
|
+
getBZEUSDPrice: () => getBZEUSDPrice,
|
|
164
|
+
getBurnerParams: () => getBurnerParams,
|
|
165
|
+
getBurnerParamsWithClient: () => getBurnerParamsWithClient,
|
|
166
|
+
getChainAddressPrefix: () => getChainAddressPrefix,
|
|
167
|
+
getChainAssets: () => getChainAssets,
|
|
168
|
+
getChainByChainId: () => getChainByChainId,
|
|
169
|
+
getChainByName: () => getChainByName,
|
|
170
|
+
getChainExplorerURL: () => getChainExplorerURL,
|
|
171
|
+
getChainId: () => getChainId,
|
|
172
|
+
getChainName: () => getChainName,
|
|
173
|
+
getChainNativeAssetDenom: () => getChainNativeAssetDenom,
|
|
174
|
+
getChains: () => getChains,
|
|
175
|
+
getChartIntervalsLimit: () => getChartIntervalsLimit,
|
|
176
|
+
getChartMinutes: () => getChartMinutes,
|
|
177
|
+
getCurrentEpoch: () => getCurrentEpoch,
|
|
178
|
+
getCurrentWeekEpochEndTime: () => getCurrentWeekEpochEndTime,
|
|
179
|
+
getDefaultTxMemo: () => getDefaultTxMemo,
|
|
180
|
+
getDenomType: () => getDenomType,
|
|
181
|
+
getDistributionParams: () => getDistributionParams,
|
|
182
|
+
getEcosystemApps: () => getEcosystemApps,
|
|
183
|
+
getEpochDurationByIdentifier: () => getEpochDurationByIdentifier,
|
|
184
|
+
getEpochsInfo: () => getEpochsInfo,
|
|
185
|
+
getFactoryDenomAdminAddress: () => getFactoryDenomAdminAddress,
|
|
186
|
+
getFromLocalStorage: () => getFromLocalStorage,
|
|
187
|
+
getHashIBCTrace: () => getHashIBCTrace,
|
|
188
|
+
getHourEpochInfo: () => getHourEpochInfo,
|
|
189
|
+
getIBCAssetList: () => getIBCAssetList,
|
|
190
|
+
getIBCTraces: () => getIBCTraces,
|
|
191
|
+
getIbcTransferTimeout: () => getIbcTransferTimeout,
|
|
192
|
+
getJackalRestURL: () => getJackalRestURL,
|
|
193
|
+
getJackalRpcUrl: () => getJackalRpcUrl,
|
|
194
|
+
getKeyExpiry: () => getKeyExpiry,
|
|
195
|
+
getLiquidityPool: () => getLiquidityPool,
|
|
196
|
+
getLiquidityPools: () => getLiquidityPools,
|
|
197
|
+
getLockedBalances: () => getLockedBalances,
|
|
198
|
+
getLockerAddress: () => getLockerAddress,
|
|
199
|
+
getMarketBuyOrders: () => getMarketBuyOrders,
|
|
200
|
+
getMarketEventKey: () => getMarketEventKey,
|
|
201
|
+
getMarketHistory: () => getMarketHistory,
|
|
202
|
+
getMarketOrder: () => getMarketOrder,
|
|
203
|
+
getMarketOrderBookChangedEvent: () => getMarketOrderBookChangedEvent,
|
|
204
|
+
getMarketOrders: () => getMarketOrders,
|
|
205
|
+
getMarketOrdersHistory: () => getMarketOrdersHistory,
|
|
206
|
+
getMarketSellOrders: () => getMarketSellOrders,
|
|
207
|
+
getMarkets: () => getMarkets,
|
|
208
|
+
getMinAmount: () => getMinAmount,
|
|
209
|
+
getNoOfIntervalsNeeded: () => getNoOfIntervalsNeeded,
|
|
210
|
+
getNobleRestURL: () => getNobleRestURL,
|
|
211
|
+
getNobleRpcUrl: () => getNobleRpcUrl,
|
|
212
|
+
getOmniFlixRestURL: () => getOmniFlixRestURL,
|
|
213
|
+
getOmniFlixRpcUrl: () => getOmniFlixRpcUrl,
|
|
214
|
+
getOsmosisRestURL: () => getOsmosisRestURL,
|
|
215
|
+
getOsmosisRpcUrl: () => getOsmosisRpcUrl,
|
|
216
|
+
getPageRequestWithLimit: () => getPageRequestWithLimit,
|
|
217
|
+
getPendingUnlockParticipants: () => getPendingUnlockParticipants,
|
|
218
|
+
getPeriodicEpochEndTime: () => getPeriodicEpochEndTime,
|
|
219
|
+
getPeriodicWeekEpochEndTime: () => getPeriodicWeekEpochEndTime,
|
|
220
|
+
getRestClient: () => getRestClient,
|
|
221
|
+
getRestURL: () => getRestURL,
|
|
222
|
+
getRpcURL: () => getRpcURL,
|
|
223
|
+
getSettings: () => getSettings,
|
|
224
|
+
getStakingParams: () => getStakingParams,
|
|
225
|
+
getStakingPool: () => getStakingPool,
|
|
226
|
+
getStakingRewardParticipantByAddress: () => getStakingRewardParticipantByAddress,
|
|
227
|
+
getStakingRewards: () => getStakingRewards,
|
|
228
|
+
getTradingViewIntervals: () => getTradingViewIntervals,
|
|
229
|
+
getUSDCDenom: () => getUSDCDenom,
|
|
230
|
+
getValidatorPageUrl: () => getValidatorPageUrl,
|
|
231
|
+
getValidatorSupportedDenoms: () => getValidatorSupportedDenoms,
|
|
232
|
+
getWalletChainsNames: () => getWalletChainsNames,
|
|
233
|
+
getWeekEpochInfo: () => getWeekEpochInfo,
|
|
234
|
+
intlDateFormat: () => intlDateFormat,
|
|
235
|
+
isFactoryDenom: () => isFactoryDenom,
|
|
236
|
+
isIbcAsset: () => isIbcAsset,
|
|
237
|
+
isIbcDenom: () => isIbcDenom,
|
|
238
|
+
isLpDenom: () => isLpDenom,
|
|
239
|
+
isNativeDenom: () => isNativeDenom,
|
|
240
|
+
isPoolSupportedByValidator: () => isPoolSupportedByValidator,
|
|
241
|
+
isTestnetChain: () => isTestnetChain,
|
|
242
|
+
keplrSuggestChain: () => keplrSuggestChain,
|
|
243
|
+
mapEventAttributes: () => mapEventAttributes,
|
|
244
|
+
openExternalLink: () => openExternalLink,
|
|
245
|
+
parseUnbondingDays: () => parseUnbondingDays,
|
|
246
|
+
poolIdFromPoolDenom: () => poolIdFromPoolDenom,
|
|
247
|
+
prettyAmount: () => prettyAmount,
|
|
248
|
+
prettyError: () => prettyError,
|
|
249
|
+
priceToBigNumberUPrice: () => priceToBigNumberUPrice,
|
|
250
|
+
priceToUPrice: () => priceToUPrice,
|
|
251
|
+
removeFromLocalStorage: () => removeFromLocalStorage,
|
|
252
|
+
removeLeadingZeros: () => removeLeadingZeros,
|
|
253
|
+
sanitizeIntegerInput: () => sanitizeIntegerInput,
|
|
254
|
+
sanitizeNumberInput: () => sanitizeNumberInput,
|
|
255
|
+
setDefaultTxMemo: () => setDefaultTxMemo,
|
|
256
|
+
setInLocalStorage: () => setInLocalStorage,
|
|
257
|
+
setKeyExpiry: () => setKeyExpiry,
|
|
258
|
+
setSettings: () => setSettings,
|
|
259
|
+
setStorageKeyVersion: () => setStorageKeyVersion,
|
|
260
|
+
shortNumberFormat: () => shortNumberFormat,
|
|
261
|
+
sleep: () => sleep,
|
|
262
|
+
stringTruncateFromCenter: () => stringTruncateFromCenter,
|
|
263
|
+
toBigNumber: () => toBigNumber,
|
|
264
|
+
toPercentage: () => toPercentage,
|
|
265
|
+
truncateAddress: () => truncateAddress,
|
|
266
|
+
truncateDenom: () => truncateDenom,
|
|
267
|
+
uAmountToAmount: () => uAmountToAmount,
|
|
268
|
+
uAmountToBigNumberAmount: () => uAmountToBigNumberAmount,
|
|
269
|
+
uPriceToBigNumberPrice: () => uPriceToBigNumberPrice,
|
|
270
|
+
uPriceToPrice: () => uPriceToPrice,
|
|
271
|
+
useAsset: () => useAsset,
|
|
272
|
+
useAssetLiquidityPools: () => useAssetLiquidityPools,
|
|
273
|
+
useAssetMarkets: () => useAssetMarkets,
|
|
274
|
+
useAssetPrice: () => useAssetPrice,
|
|
275
|
+
useAssets: () => useAssets,
|
|
276
|
+
useAssetsContext: () => useAssetsContext,
|
|
277
|
+
useAssetsManager: () => useAssetsManager,
|
|
278
|
+
useAssetsValue: () => useAssetsValue,
|
|
279
|
+
useBZETx: () => useBZETx,
|
|
280
|
+
useBalance: () => useBalance,
|
|
281
|
+
useBalances: () => useBalances,
|
|
282
|
+
useConnectionType: () => useConnectionType,
|
|
283
|
+
useEpochs: () => useEpochs,
|
|
284
|
+
useFeeTokens: () => useFeeTokens,
|
|
285
|
+
useIBCChains: () => useIBCChains,
|
|
286
|
+
useIBCTx: () => useIBCTx,
|
|
287
|
+
useLiquidityPools: () => useLiquidityPools,
|
|
288
|
+
useMarket: () => useMarket,
|
|
289
|
+
useMarkets: () => useMarkets,
|
|
290
|
+
useSDKTx: () => useSDKTx,
|
|
291
|
+
useSettings: () => useSettings,
|
|
292
|
+
useSigningClient: () => useSigningClient,
|
|
293
|
+
useToast: () => useToast,
|
|
294
|
+
validateBZEBech32Address: () => validateBZEBech32Address,
|
|
295
|
+
validateBech32Address: () => validateBech32Address,
|
|
296
|
+
validateEndpoints: () => validateEndpoints,
|
|
297
|
+
validateRestEndpoint: () => validateRestEndpoint,
|
|
298
|
+
validateRpcEndpoint: () => validateRpcEndpoint
|
|
299
|
+
});
|
|
300
|
+
module.exports = __toCommonJS(index_exports);
|
|
301
|
+
|
|
302
|
+
// src/constants/chain.ts
|
|
303
|
+
var import_testnet = require("chain-registry/testnet");
|
|
304
|
+
var import_utils = require("@chain-registry/utils");
|
|
305
|
+
|
|
306
|
+
// src/constants/assets.ts
|
|
307
|
+
var ASSET_TYPE_FACTORY = "Factory";
|
|
308
|
+
var ASSET_TYPE_IBC = "IBC";
|
|
309
|
+
var ASSET_TYPE_NATIVE = "Native";
|
|
310
|
+
var ASSET_TYPE_LP = "LP";
|
|
311
|
+
var VERIFIED_ASSETS = {
|
|
312
|
+
"factory/testbz1w9vva0muctcrmd9xgret9x4wasw2rrflsdkwfs/faneatiku2": true,
|
|
313
|
+
"factory/testbz1z3mkcr2jz424w6m49frgjmy9uhlrx69p4cvrgf/vidulum": true,
|
|
314
|
+
"factory/testbz1z3mkcr2jz424w6m49frgjmy9uhlrx69p4cvrgf/bitcoinz": true,
|
|
315
|
+
"ubze": true,
|
|
316
|
+
"utbz": true,
|
|
317
|
+
"factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl": true,
|
|
318
|
+
"factory/bze15pqjgk4la0mfphwddce00d05n3th3u66n3ptcv/2MARS": true,
|
|
319
|
+
"factory/bze12gyp30f29zg26nuqrwdhl26ej4q066pt572fhm/GGE": true
|
|
320
|
+
};
|
|
321
|
+
var EXCLUDED_ASSETS = {
|
|
322
|
+
"factory/testbz1w9vva0muctcrmd9xgret9x4wasw2rrflsdkwfs/faneatiku1": false,
|
|
323
|
+
"factory/bze1972aqfzdg29ugjln74edx0xvcg4ehvysjptk77/1000000000": true,
|
|
324
|
+
"ibc/689DD6F80E4DBCE14877462B182504037FAEAD0699D5804A7F5CB328D33ED24B": true,
|
|
325
|
+
"factory/bze1f0qgels0eu96ev6a67znu70q7rquy9eragn8nw/ucorey": true
|
|
326
|
+
};
|
|
327
|
+
var STABLE_COINS = {
|
|
328
|
+
"factory/testbz1z3mkcr2jz424w6m49frgjmy9uhlrx69p4cvrgf/uusdt": true,
|
|
329
|
+
"factory/bze1z3mkcr2jz424w6m49frgjmy9uhlrx69phqwg3l/testusd": true,
|
|
330
|
+
"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4": true
|
|
331
|
+
};
|
|
332
|
+
var getChainNativeAssetDenom = () => {
|
|
333
|
+
return process.env.NEXT_PUBLIC_CHAIN_NATIVE_ASSET_DENOM || "ubze";
|
|
334
|
+
};
|
|
335
|
+
var getUSDCDenom = () => {
|
|
336
|
+
return process.env.NEXT_PUBLIC_USDC_IBC_DENOM || "";
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// src/constants/testnet.ts
|
|
340
|
+
var BZE_TESTNET_2_SUGGEST_CHAIN = {
|
|
341
|
+
chainId: "bzetestnet-3",
|
|
342
|
+
chainType: "cosmos",
|
|
343
|
+
chainName: "BeeZee Testnet 3",
|
|
344
|
+
prettyName: "BeeZee Testnet 3",
|
|
345
|
+
networkType: "mainnet",
|
|
346
|
+
bech32Prefix: "bze",
|
|
347
|
+
status: "live",
|
|
348
|
+
slip44: 118,
|
|
349
|
+
logoURIs: {
|
|
350
|
+
svg: "https://raw.githubusercontent.com/cosmos/chain-registry/master/beezee/images/bze.svg"
|
|
351
|
+
},
|
|
352
|
+
fees: {
|
|
353
|
+
feeTokens: [
|
|
354
|
+
{
|
|
355
|
+
denom: getChainNativeAssetDenom(),
|
|
356
|
+
fixedMinGasPrice: 0.01,
|
|
357
|
+
lowGasPrice: 0.01,
|
|
358
|
+
averageGasPrice: 0.025,
|
|
359
|
+
highGasPrice: 0.04
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
},
|
|
363
|
+
keyAlgos: [
|
|
364
|
+
"secp256k1"
|
|
365
|
+
],
|
|
366
|
+
staking: {
|
|
367
|
+
stakingTokens: [
|
|
368
|
+
{
|
|
369
|
+
denom: getChainNativeAssetDenom()
|
|
370
|
+
}
|
|
371
|
+
]
|
|
372
|
+
},
|
|
373
|
+
explorers: [
|
|
374
|
+
{
|
|
375
|
+
"kind": "ping.pub",
|
|
376
|
+
"url": "https://testnet.explorer.thesilverfox.pro/beezee",
|
|
377
|
+
"tx_page": "https://testnet.explorer.thesilverfox.pro/beezee/tx/${txHash}"
|
|
378
|
+
}
|
|
379
|
+
],
|
|
380
|
+
codebase: {
|
|
381
|
+
"git_repo": "https://github.com/bze-alphateam/bze",
|
|
382
|
+
"recommended_version": "v5.1.2",
|
|
383
|
+
"compatible_versions": [
|
|
384
|
+
"v5.1.2"
|
|
385
|
+
],
|
|
386
|
+
"binaries": {
|
|
387
|
+
"darwin/amd64": "https://github.com/bze-alphateam/bze/releases/download/v5.1.2/bze-5.1.2-darwin-amd64.tar.gz",
|
|
388
|
+
"darwin/arm64": "https://github.com/bze-alphateam/bze/releases/download/v5.1.2/bze-5.1.2-darwin-arm64.tar.gz",
|
|
389
|
+
"linux/amd64": "https://github.com/bze-alphateam/bze/releases/download/v5.1.2/bze-5.1.2-linux-amd64.tar.gz",
|
|
390
|
+
"linux/arm64": "https://github.com/bze-alphateam/bze/releases/download/v5.1.2/bze-5.1.2-linux-arm64.tar.gz",
|
|
391
|
+
"windows/amd64": "https://github.com/bze-alphateam/bze/releases/download/v5.1.2/bze-5.1.2-win64.zip"
|
|
392
|
+
},
|
|
393
|
+
"genesis": {
|
|
394
|
+
"genesis_url": "https://raw.githubusercontent.com/bze-alphateam/bze/main/genesis.json"
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
apis: {
|
|
398
|
+
"rpc": [
|
|
399
|
+
{
|
|
400
|
+
"address": "https://testnet-rpc.getbze.com",
|
|
401
|
+
"provider": "AlphaTeam"
|
|
402
|
+
}
|
|
403
|
+
],
|
|
404
|
+
"rest": [
|
|
405
|
+
{
|
|
406
|
+
"address": "https://testnet.getbze.com",
|
|
407
|
+
"provider": "AlphaTeam"
|
|
408
|
+
}
|
|
409
|
+
],
|
|
410
|
+
"grpc": [
|
|
411
|
+
{
|
|
412
|
+
"address": "grpc.getbze.com:9999",
|
|
413
|
+
"provider": "AlphaTeam"
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
var BZE_TESTNET_NETWORK = {
|
|
419
|
+
base: {
|
|
420
|
+
explorerBaseUrl: "https://explorer.getbze.com/bze%20testnet",
|
|
421
|
+
rpcUrl: "https://testnet-rpc.getbze.com",
|
|
422
|
+
restUrl: "https://testnet.getbze.com",
|
|
423
|
+
chainName: BZE_TESTNET_2_SUGGEST_CHAIN.chainName
|
|
424
|
+
},
|
|
425
|
+
chain: [BZE_TESTNET_2_SUGGEST_CHAIN],
|
|
426
|
+
assets: [
|
|
427
|
+
{
|
|
428
|
+
chainName: BZE_TESTNET_2_SUGGEST_CHAIN.chainName,
|
|
429
|
+
assets: [
|
|
430
|
+
{
|
|
431
|
+
"description": "BeeZee native blockchain",
|
|
432
|
+
"typeAsset": "sdk.coin",
|
|
433
|
+
"denomUnits": [
|
|
434
|
+
{
|
|
435
|
+
"denom": getChainNativeAssetDenom(),
|
|
436
|
+
"exponent": 0
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"denom": "TBZE",
|
|
440
|
+
"exponent": 6
|
|
441
|
+
}
|
|
442
|
+
],
|
|
443
|
+
"base": getChainNativeAssetDenom(),
|
|
444
|
+
"name": "BeeZee",
|
|
445
|
+
"display": "TBZE",
|
|
446
|
+
"symbol": "TBZE",
|
|
447
|
+
"logoURIs": {
|
|
448
|
+
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/beezee/images/bze.svg",
|
|
449
|
+
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/beezee/images/bze.png"
|
|
450
|
+
},
|
|
451
|
+
"coingeckoId": "bzedge"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"description": "Lumen",
|
|
455
|
+
"typeAsset": "sdk.coin",
|
|
456
|
+
"denomUnits": [
|
|
457
|
+
{
|
|
458
|
+
"denom": "ibc/9DA252F9F9C86132CC282EA431DFB7DE7729501F6DC9A3E0F50EC8C6EE380CC7",
|
|
459
|
+
"exponent": 0,
|
|
460
|
+
"aliases": []
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"denom": "LMN",
|
|
464
|
+
"exponent": 6,
|
|
465
|
+
"aliases": []
|
|
466
|
+
}
|
|
467
|
+
],
|
|
468
|
+
"base": "ibc/9DA252F9F9C86132CC282EA431DFB7DE7729501F6DC9A3E0F50EC8C6EE380CC7",
|
|
469
|
+
"display": "LMN",
|
|
470
|
+
"name": "Lumen",
|
|
471
|
+
"symbol": "LMN",
|
|
472
|
+
"logoURIs": {
|
|
473
|
+
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/lumen/images/lmn.png"
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"description": "Vidulum app token",
|
|
478
|
+
"typeAsset": "sdk.coin",
|
|
479
|
+
"denomUnits": [
|
|
480
|
+
{
|
|
481
|
+
"denom": "factory/bze1z3mkcr2jz424w6m49frgjmy9uhlrx69phqwg3l/vidulum",
|
|
482
|
+
"exponent": 0,
|
|
483
|
+
"aliases": []
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"denom": "VDL",
|
|
487
|
+
"exponent": 6,
|
|
488
|
+
"aliases": []
|
|
489
|
+
}
|
|
490
|
+
],
|
|
491
|
+
"base": "factory/bze1z3mkcr2jz424w6m49frgjmy9uhlrx69phqwg3l/vidulum",
|
|
492
|
+
"display": "VDL",
|
|
493
|
+
"name": "Vidulum",
|
|
494
|
+
"symbol": "VDL",
|
|
495
|
+
"logoURIs": {
|
|
496
|
+
"png": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/beezee/factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl.png"
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
]
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// src/constants/chain.ts
|
|
505
|
+
var import_v2 = require("@chain-registry/v2");
|
|
506
|
+
var getChainId = () => {
|
|
507
|
+
return process.env.NEXT_PUBLIC_CHAIN_ID || "beezee-1";
|
|
508
|
+
};
|
|
509
|
+
var getChainName = () => {
|
|
510
|
+
return process.env.NEXT_PUBLIC_CHAIN_NAME || "beezee";
|
|
511
|
+
};
|
|
512
|
+
var isTestnetChain = () => {
|
|
513
|
+
const isTestnet = process.env.NEXT_PUBLIC_CHAIN_IS_TESTNET;
|
|
514
|
+
return isTestnet === "true" || isTestnet === "1";
|
|
515
|
+
};
|
|
516
|
+
var getChains = () => {
|
|
517
|
+
let localChains = import_v2.chains;
|
|
518
|
+
if (isTestnetChain()) {
|
|
519
|
+
localChains = [...import_testnet.chains, BZE_TESTNET_2_SUGGEST_CHAIN];
|
|
520
|
+
}
|
|
521
|
+
return localChains;
|
|
522
|
+
};
|
|
523
|
+
var getChainByChainId = (chainId) => {
|
|
524
|
+
let localChains = import_v2.chains;
|
|
525
|
+
if (isTestnetChain()) {
|
|
526
|
+
localChains = [...import_testnet.chains, BZE_TESTNET_2_SUGGEST_CHAIN];
|
|
527
|
+
}
|
|
528
|
+
return localChains.find((c) => {
|
|
529
|
+
var _a2;
|
|
530
|
+
return ((_a2 = c.chainId) == null ? void 0 : _a2.toLowerCase()) === chainId.toLowerCase();
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
var getChainByName = (name) => {
|
|
534
|
+
let localChains = import_v2.chains;
|
|
535
|
+
if (isTestnetChain()) {
|
|
536
|
+
localChains = [...import_testnet.chains, BZE_TESTNET_2_SUGGEST_CHAIN];
|
|
537
|
+
}
|
|
538
|
+
return localChains.find((c) => c.chainName.toLowerCase() === name.toLowerCase());
|
|
539
|
+
};
|
|
540
|
+
var getWalletChainsNames = () => {
|
|
541
|
+
const localChains = getChains();
|
|
542
|
+
const envChainsNames = process.env.NEXT_PUBLIC_WALLET_CHAINS_NAMES;
|
|
543
|
+
if (!envChainsNames) {
|
|
544
|
+
return localChains.filter((c) => c.chainId === getChainId());
|
|
545
|
+
}
|
|
546
|
+
const split = envChainsNames.split(",");
|
|
547
|
+
return appChainFirst(localChains.filter((c) => split.includes(c.chainName)));
|
|
548
|
+
};
|
|
549
|
+
var appChainFirst = (chains2) => {
|
|
550
|
+
return chains2.sort((a, b) => a.chainId === getChainId() ? -1 : b.chainId === getChainId() ? 1 : 0);
|
|
551
|
+
};
|
|
552
|
+
var getAssetLists = () => {
|
|
553
|
+
let localAssetLists = import_v2.assetLists;
|
|
554
|
+
if (isTestnetChain()) {
|
|
555
|
+
localAssetLists = BZE_TESTNET_NETWORK.assets;
|
|
556
|
+
}
|
|
557
|
+
return localAssetLists;
|
|
558
|
+
};
|
|
559
|
+
var getIBCAssetList = () => {
|
|
560
|
+
const all = (0, import_utils.getAssetLists)(getChainName(), import_v2.ibcData, getAssetLists());
|
|
561
|
+
return all.length > 0 ? all[0].assets : [];
|
|
562
|
+
};
|
|
563
|
+
var getChainAddressPrefix = () => {
|
|
564
|
+
return process.env.NEXT_PUBLIC_CHAIN_ADDRESS_PREFIX || "bze";
|
|
565
|
+
};
|
|
566
|
+
var getChainExplorerURL = (chainName) => {
|
|
567
|
+
if (process.env.NEXT_PUBLIC_EXPLORER_URL) {
|
|
568
|
+
return `${process.env.NEXT_PUBLIC_EXPLORER_URL}/${chainName}`;
|
|
569
|
+
}
|
|
570
|
+
return `https://explorer.chaintools.tech/${chainName}`;
|
|
571
|
+
};
|
|
572
|
+
var getLockerAddress = () => {
|
|
573
|
+
return process.env.NEXT_PUBLIC_LOCKER_ADDRESS || "bze1pc5zjcvhx3e8l305zjl72grytfa30r5mdypmw4";
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
// src/storage/storage.ts
|
|
577
|
+
var TTL_NO_EXPIRY = 0;
|
|
578
|
+
var _storageKeyVersion = "1";
|
|
579
|
+
var setStorageKeyVersion = (version) => {
|
|
580
|
+
_storageKeyVersion = version;
|
|
581
|
+
};
|
|
582
|
+
var getFromLocalStorage = (key) => {
|
|
583
|
+
if (typeof window === "undefined") return null;
|
|
584
|
+
try {
|
|
585
|
+
const cachedItem = localStorage.getItem(prefixedKey(key));
|
|
586
|
+
if (cachedItem) {
|
|
587
|
+
const item = JSON.parse(cachedItem);
|
|
588
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
589
|
+
if (item.expiry === TTL_NO_EXPIRY || now < item.expiry) {
|
|
590
|
+
return item.data;
|
|
591
|
+
}
|
|
592
|
+
localStorage.removeItem(prefixedKey(key));
|
|
593
|
+
}
|
|
594
|
+
} catch (error) {
|
|
595
|
+
console.error("Failed to get data from localStorage:", error);
|
|
596
|
+
}
|
|
597
|
+
return null;
|
|
598
|
+
};
|
|
599
|
+
var setInLocalStorage = (key, data, ttl) => {
|
|
600
|
+
if (typeof window === "undefined") return false;
|
|
601
|
+
try {
|
|
602
|
+
if (ttl < 0) ttl = 0;
|
|
603
|
+
const item = {
|
|
604
|
+
data,
|
|
605
|
+
expiry: TTL_NO_EXPIRY
|
|
606
|
+
};
|
|
607
|
+
if (ttl > 0) {
|
|
608
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
609
|
+
item.expiry = now + ttl * 1e3;
|
|
610
|
+
}
|
|
611
|
+
localStorage.setItem(prefixedKey(key), JSON.stringify(item));
|
|
612
|
+
return true;
|
|
613
|
+
} catch (error) {
|
|
614
|
+
console.error("Failed to set data in localStorage:", error);
|
|
615
|
+
}
|
|
616
|
+
return false;
|
|
617
|
+
};
|
|
618
|
+
var removeFromLocalStorage = (key) => {
|
|
619
|
+
if (typeof window === "undefined") return;
|
|
620
|
+
try {
|
|
621
|
+
localStorage.removeItem(prefixedKey(key));
|
|
622
|
+
} catch (error) {
|
|
623
|
+
console.error("Failed to remove data from localStorage:", error);
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
var getKeyExpiry = (key) => {
|
|
627
|
+
if (typeof window === "undefined") return null;
|
|
628
|
+
try {
|
|
629
|
+
const cachedItem = localStorage.getItem(prefixedKey(key));
|
|
630
|
+
if (cachedItem) {
|
|
631
|
+
const item = JSON.parse(cachedItem);
|
|
632
|
+
if (item.expiry > TTL_NO_EXPIRY) {
|
|
633
|
+
return new Date(item.expiry);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
} catch (error) {
|
|
637
|
+
console.error("Failed to get data from localStorage:", error);
|
|
638
|
+
}
|
|
639
|
+
return null;
|
|
640
|
+
};
|
|
641
|
+
var setKeyExpiry = (key, expiry) => {
|
|
642
|
+
if (typeof window === "undefined") return false;
|
|
643
|
+
try {
|
|
644
|
+
const cachedItem = localStorage.getItem(prefixedKey(key));
|
|
645
|
+
if (cachedItem) {
|
|
646
|
+
const item = JSON.parse(cachedItem);
|
|
647
|
+
if (item) {
|
|
648
|
+
item.expiry = expiry.getTime();
|
|
649
|
+
localStorage.setItem(prefixedKey(key), JSON.stringify(item));
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
} catch (error) {
|
|
654
|
+
console.error("Failed to set data in localStorage:", error);
|
|
655
|
+
}
|
|
656
|
+
return false;
|
|
657
|
+
};
|
|
658
|
+
var prefixedKey = (key) => {
|
|
659
|
+
return `${_storageKeyVersion}-${getChainId()}:${key}`;
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// src/constants/placeholders.ts
|
|
663
|
+
var TOKEN_LOGO_PLACEHOLDER = "/images/token.svg";
|
|
664
|
+
var BZE_CIRCLE_LOGO = "/images/bze_alternative_512x512.png";
|
|
665
|
+
var _defaultTxMemo = "getbze.com";
|
|
666
|
+
var DEFAULT_TX_MEMO = _defaultTxMemo;
|
|
667
|
+
var setDefaultTxMemo = (memo) => {
|
|
668
|
+
_defaultTxMemo = memo;
|
|
669
|
+
};
|
|
670
|
+
var getDefaultTxMemo = () => {
|
|
671
|
+
return _defaultTxMemo;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
// src/types/asset.ts
|
|
675
|
+
var LP_ASSETS_DECIMALS = 12;
|
|
676
|
+
|
|
677
|
+
// src/types/market.ts
|
|
678
|
+
var ORDER_TYPE_BUY = "buy";
|
|
679
|
+
var ORDER_TYPE_SELL = "sell";
|
|
680
|
+
|
|
681
|
+
// src/types/settings.ts
|
|
682
|
+
var CONNECTION_TYPE_WS = 2;
|
|
683
|
+
var CONNECTION_TYPE_POLLING = 1;
|
|
684
|
+
var CONNECTION_TYPE_NONE = 0;
|
|
685
|
+
|
|
686
|
+
// src/types/events.ts
|
|
687
|
+
var CURRENT_WALLET_BALANCE_EVENT = "current_wallet_balance";
|
|
688
|
+
var ORDER_EXECUTED_EVENT = "order_executed";
|
|
689
|
+
var ORDER_BOOK_CHANGED_EVENT = "order_book_changed";
|
|
690
|
+
var SUPPLY_CHANGED_EVENT = "supply_changed";
|
|
691
|
+
var SWAP_EXECUTED_EVENT = "swap_executed";
|
|
692
|
+
var NEXT_BURN_CHANGED_EVENT = "next_burn_changed";
|
|
693
|
+
var RAFFLE_CHANGED_EVENT = "raffle_changed";
|
|
694
|
+
var LOCK_CHANGED_EVENT = "lock_changed";
|
|
695
|
+
var EPOCH_START_EVENT = "epoch_start";
|
|
696
|
+
|
|
697
|
+
// src/utils/amount.ts
|
|
698
|
+
var import_bignumber = __toESM(require("bignumber.js"));
|
|
699
|
+
var MAX_PRICE_DECIMALS = 14;
|
|
700
|
+
function toBigNumber(amount) {
|
|
701
|
+
if (amount instanceof import_bignumber.default) {
|
|
702
|
+
return amount;
|
|
703
|
+
}
|
|
704
|
+
return new import_bignumber.default(amount);
|
|
705
|
+
}
|
|
706
|
+
function uAmountToAmount(amount, noOfDecimals) {
|
|
707
|
+
return uAmountToBigNumberAmount(amount, noOfDecimals).toString();
|
|
708
|
+
}
|
|
709
|
+
function uAmountToBigNumberAmount(amount, noOfDecimals) {
|
|
710
|
+
return toBigNumber(amount || 0).shiftedBy(-1 * noOfDecimals).decimalPlaces(noOfDecimals || 6);
|
|
711
|
+
}
|
|
712
|
+
function amountToBigNumberUAmount(amount, noOfDecimals) {
|
|
713
|
+
return toBigNumber(amount).shiftedBy(noOfDecimals).decimalPlaces(noOfDecimals || 6);
|
|
714
|
+
}
|
|
715
|
+
function amountToUAmount(amount, noOfDecimals) {
|
|
716
|
+
return amountToBigNumberUAmount(amount, noOfDecimals).toString();
|
|
717
|
+
}
|
|
718
|
+
function prettyAmount(amount) {
|
|
719
|
+
const num = toBigNumber(amount);
|
|
720
|
+
if (num.isNaN()) {
|
|
721
|
+
return "0";
|
|
722
|
+
}
|
|
723
|
+
if (num.lt(1) && num.gt(0)) {
|
|
724
|
+
return num.toFixed(6);
|
|
725
|
+
}
|
|
726
|
+
return Intl.NumberFormat("en", { notation: "standard" }).format(num.toNumber());
|
|
727
|
+
}
|
|
728
|
+
var priceToUPrice = (price, quoteExponent, baseExponent) => {
|
|
729
|
+
return priceToBigNumberUPrice(price, quoteExponent, baseExponent).toFixed(MAX_PRICE_DECIMALS).toString();
|
|
730
|
+
};
|
|
731
|
+
var priceToBigNumberUPrice = (price, quoteExponent, baseExponent) => {
|
|
732
|
+
price = toBigNumber(price);
|
|
733
|
+
return price.multipliedBy(Math.pow(10, quoteExponent - baseExponent));
|
|
734
|
+
};
|
|
735
|
+
var uPriceToPrice = (price, quoteExponent, baseExponent) => {
|
|
736
|
+
return uPriceToBigNumberPrice(toBigNumber(price), quoteExponent, baseExponent).toString();
|
|
737
|
+
};
|
|
738
|
+
var uPriceToBigNumberPrice = (price, quoteExponent, baseExponent) => {
|
|
739
|
+
const converted = toBigNumber(price);
|
|
740
|
+
return converted.multipliedBy(Math.pow(10, baseExponent - quoteExponent));
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
// src/utils/address.ts
|
|
744
|
+
var import_encoding = require("@interchainjs/encoding");
|
|
745
|
+
|
|
746
|
+
// src/utils/strings.ts
|
|
747
|
+
function stringTruncateFromCenter(str, maxLength) {
|
|
748
|
+
const midChar = "\u2026";
|
|
749
|
+
if (str.length <= maxLength) return str;
|
|
750
|
+
const left = Math.ceil(maxLength / 2);
|
|
751
|
+
const right = str.length - Math.floor(maxLength / 2) + 1;
|
|
752
|
+
return str.substring(0, left) + midChar + str.substring(right);
|
|
753
|
+
}
|
|
754
|
+
function removeLeadingZeros(str) {
|
|
755
|
+
return str.replace(/^0+/, "") || "0";
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// src/utils/address.ts
|
|
759
|
+
var truncateAddress = (address) => {
|
|
760
|
+
return stringTruncateFromCenter(address, 12);
|
|
761
|
+
};
|
|
762
|
+
var validateBech32Address = (address, prefix) => {
|
|
763
|
+
const result = {
|
|
764
|
+
isValid: false,
|
|
765
|
+
message: ""
|
|
766
|
+
};
|
|
767
|
+
try {
|
|
768
|
+
const { prefix: addressPrefix } = (0, import_encoding.fromBech32)(address);
|
|
769
|
+
if (addressPrefix === prefix) {
|
|
770
|
+
result.isValid = true;
|
|
771
|
+
return result;
|
|
772
|
+
}
|
|
773
|
+
result.message = `This address is from another network (${addressPrefix}). Please use an address from the destination network (${prefix}).`;
|
|
774
|
+
} catch (e) {
|
|
775
|
+
console.error("invalid address ", e);
|
|
776
|
+
result.message = "Invalid address";
|
|
777
|
+
}
|
|
778
|
+
return result;
|
|
779
|
+
};
|
|
780
|
+
var validateBZEBech32Address = (address) => validateBech32Address(address, getChainAddressPrefix());
|
|
781
|
+
|
|
782
|
+
// src/utils/charts.ts
|
|
783
|
+
var CHART_4H = "4H";
|
|
784
|
+
var CHART_1D = "1D";
|
|
785
|
+
var CHART_7D = "7D";
|
|
786
|
+
var CHART_30D = "30D";
|
|
787
|
+
var CHART_1Y = "1Y";
|
|
788
|
+
function getNoOfIntervalsNeeded(chart) {
|
|
789
|
+
switch (chart) {
|
|
790
|
+
case CHART_4H:
|
|
791
|
+
return 12 * 4;
|
|
792
|
+
case CHART_1D:
|
|
793
|
+
return 4 * 24;
|
|
794
|
+
case CHART_7D:
|
|
795
|
+
return 24 * 7;
|
|
796
|
+
case CHART_30D:
|
|
797
|
+
return 6 * 30;
|
|
798
|
+
case CHART_1Y:
|
|
799
|
+
return 365;
|
|
800
|
+
default:
|
|
801
|
+
return 0;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function getChartIntervalsLimit(chart) {
|
|
805
|
+
switch (chart) {
|
|
806
|
+
case CHART_4H:
|
|
807
|
+
return 12 * 24 * 7;
|
|
808
|
+
case CHART_1D:
|
|
809
|
+
return 4 * 24 * 30;
|
|
810
|
+
case CHART_7D:
|
|
811
|
+
return 24 * 90;
|
|
812
|
+
case CHART_30D:
|
|
813
|
+
return 6 * 365;
|
|
814
|
+
case CHART_1Y:
|
|
815
|
+
return 365 * 3;
|
|
816
|
+
default:
|
|
817
|
+
return 12;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
function getChartMinutes(chart) {
|
|
821
|
+
switch (chart) {
|
|
822
|
+
case CHART_4H:
|
|
823
|
+
return 5;
|
|
824
|
+
case CHART_1D:
|
|
825
|
+
return 15;
|
|
826
|
+
case CHART_7D:
|
|
827
|
+
return 60;
|
|
828
|
+
case CHART_30D:
|
|
829
|
+
return 240;
|
|
830
|
+
case CHART_1Y:
|
|
831
|
+
return 1440;
|
|
832
|
+
default:
|
|
833
|
+
return 5;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// src/utils/debounce.ts
|
|
838
|
+
var debounces = /* @__PURE__ */ new Map();
|
|
839
|
+
async function addMultipleDebounce(name, delay, callback, times) {
|
|
840
|
+
for (let index = 1; index <= times; index++) {
|
|
841
|
+
addDebounce(`${name}-${index}`, delay * index, callback);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
async function addDebounce(name, delay, callback) {
|
|
845
|
+
cancelDebounce(name);
|
|
846
|
+
const newTimer = setTimeout(() => {
|
|
847
|
+
callback();
|
|
848
|
+
}, delay);
|
|
849
|
+
debounces.set(name, newTimer);
|
|
850
|
+
}
|
|
851
|
+
async function cancelDebounce(name) {
|
|
852
|
+
const timer = debounces.get(name);
|
|
853
|
+
if (timer) {
|
|
854
|
+
clearTimeout(timer);
|
|
855
|
+
debounces.delete(name);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// src/utils/denom.ts
|
|
860
|
+
var MAX_DENOM_LEN = 8;
|
|
861
|
+
var isFactoryDenom = (denom) => denom.startsWith("factory/");
|
|
862
|
+
var isIbcDenom = (denom) => denom.startsWith("ibc/");
|
|
863
|
+
var isLpDenom = (denom) => denom.startsWith("ulp_");
|
|
864
|
+
var isNativeDenom = (denom) => getChainNativeAssetDenom() === denom;
|
|
865
|
+
var getDenomType = (denom) => isFactoryDenom(denom) ? ASSET_TYPE_FACTORY : isIbcDenom(denom) ? ASSET_TYPE_IBC : isLpDenom(denom) ? ASSET_TYPE_LP : ASSET_TYPE_NATIVE;
|
|
866
|
+
function truncateDenom(denom) {
|
|
867
|
+
return stringTruncateFromCenter(denom, MAX_DENOM_LEN);
|
|
868
|
+
}
|
|
869
|
+
var isIbcAsset = (asset) => asset.type === ASSET_TYPE_IBC;
|
|
870
|
+
|
|
871
|
+
// src/utils/events.ts
|
|
872
|
+
var getMarketOrderBookChangedEvent = (marketId) => getMarketEventKey(ORDER_BOOK_CHANGED_EVENT, marketId);
|
|
873
|
+
var getMarketEventKey = (eventType, marketId) => `${eventType}:${marketId}`;
|
|
874
|
+
var mapEventAttributes = (attributes) => {
|
|
875
|
+
return attributes.reduce((acc, attr) => __spreadProps(__spreadValues({}, acc), { [attr.key]: attr.value.replace('"', "").replace('"', "") }), {});
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// src/utils/formatter.ts
|
|
879
|
+
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
880
|
+
var formatUsdAmount = (priceNum) => {
|
|
881
|
+
const price = priceNum.toString();
|
|
882
|
+
const decimalIndex = price.indexOf(".");
|
|
883
|
+
if (decimalIndex === -1) {
|
|
884
|
+
return price;
|
|
885
|
+
}
|
|
886
|
+
const decimalPart = price.substring(decimalIndex + 1);
|
|
887
|
+
let significantDigitCount = 0;
|
|
888
|
+
let decimalsFound = 0;
|
|
889
|
+
for (let i = 0; i < decimalPart.length; i++) {
|
|
890
|
+
const digit = decimalPart[i];
|
|
891
|
+
decimalsFound++;
|
|
892
|
+
if (digit !== "0" || significantDigitCount > 0) {
|
|
893
|
+
significantDigitCount++;
|
|
894
|
+
}
|
|
895
|
+
if (significantDigitCount >= 6) {
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return priceNum.toFixed(decimalsFound).toString();
|
|
900
|
+
};
|
|
901
|
+
function shortNumberFormat(amount) {
|
|
902
|
+
if (amount.isNaN() || amount.isZero()) {
|
|
903
|
+
return "0";
|
|
904
|
+
}
|
|
905
|
+
if (amount.lt(1e-3)) {
|
|
906
|
+
return "0";
|
|
907
|
+
}
|
|
908
|
+
const units = [
|
|
909
|
+
{ value: new import_bignumber2.default("1e15"), suffix: "Q" },
|
|
910
|
+
{ value: new import_bignumber2.default("1e12"), suffix: "T" },
|
|
911
|
+
{ value: new import_bignumber2.default("1e9"), suffix: "B" },
|
|
912
|
+
{ value: new import_bignumber2.default("1e6"), suffix: "M" },
|
|
913
|
+
{ value: new import_bignumber2.default("1e3"), suffix: "K" }
|
|
914
|
+
];
|
|
915
|
+
for (const unit of units) {
|
|
916
|
+
if (amount.gte(unit.value)) {
|
|
917
|
+
const formatted = amount.div(unit.value);
|
|
918
|
+
const result = formatted.toFixed(3).replace(/\.?0+$/, "");
|
|
919
|
+
return `${result}${unit.suffix}`;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
return amount.toFixed(3).replace(/\.?0+$/, "");
|
|
923
|
+
}
|
|
924
|
+
var intlDateFormat = new Intl.DateTimeFormat("en-US", {
|
|
925
|
+
year: "2-digit",
|
|
926
|
+
month: "2-digit",
|
|
927
|
+
day: "2-digit",
|
|
928
|
+
hour: "numeric",
|
|
929
|
+
minute: "2-digit",
|
|
930
|
+
hour12: false
|
|
931
|
+
});
|
|
932
|
+
var formatDate = (date) => {
|
|
933
|
+
return intlDateFormat.format(date);
|
|
934
|
+
};
|
|
935
|
+
var formatTimeRemaining = (targetDate) => {
|
|
936
|
+
const now = /* @__PURE__ */ new Date();
|
|
937
|
+
const diff = targetDate.getTime() - now.getTime();
|
|
938
|
+
if (diff <= 0) {
|
|
939
|
+
return "Now";
|
|
940
|
+
}
|
|
941
|
+
const days = Math.floor(diff / (1e3 * 60 * 60 * 24));
|
|
942
|
+
const hours = Math.floor(diff % (1e3 * 60 * 60 * 24) / (1e3 * 60 * 60));
|
|
943
|
+
const minutes = Math.floor(diff % (1e3 * 60 * 60) / (1e3 * 60));
|
|
944
|
+
const parts = [];
|
|
945
|
+
if (days > 0) parts.push(`${days}d`);
|
|
946
|
+
if (hours > 0) parts.push(`${hours}h`);
|
|
947
|
+
if (minutes > 0) parts.push(`${minutes}m`);
|
|
948
|
+
return parts.join(" ") || "Now";
|
|
949
|
+
};
|
|
950
|
+
var formatTimeRemainingFromEpochs = (epochs) => {
|
|
951
|
+
if (epochs.lte(0)) {
|
|
952
|
+
return "Now";
|
|
953
|
+
}
|
|
954
|
+
const totalSeconds = epochs.multipliedBy(60).toNumber();
|
|
955
|
+
const days = Math.floor(totalSeconds / (60 * 60 * 24));
|
|
956
|
+
const hours = Math.floor(totalSeconds % (60 * 60 * 24) / (60 * 60));
|
|
957
|
+
const minutes = Math.floor(totalSeconds % (60 * 60) / 60);
|
|
958
|
+
const parts = [];
|
|
959
|
+
if (days > 0) parts.push(`${days}d`);
|
|
960
|
+
if (hours > 0) parts.push(`${hours}h`);
|
|
961
|
+
if (minutes > 0) parts.push(`${minutes}m`);
|
|
962
|
+
return parts.join(" ") || "Now";
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
// src/utils/functions.ts
|
|
966
|
+
async function sleep(ms) {
|
|
967
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
968
|
+
}
|
|
969
|
+
var openExternalLink = (url) => {
|
|
970
|
+
if (!window) return;
|
|
971
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
// src/utils/ibc.ts
|
|
975
|
+
var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
976
|
+
var canDepositFromIBC = (ibcData2) => {
|
|
977
|
+
return ibcData2.counterparty.baseDenom !== "" && ibcData2.counterparty.channelId !== "" && ibcData2.counterparty.chainName != "";
|
|
978
|
+
};
|
|
979
|
+
var canSendToIBC = (ibcData2) => {
|
|
980
|
+
return ibcData2.chain.channelId !== "" && ibcData2.counterparty.chainName != "";
|
|
981
|
+
};
|
|
982
|
+
async function denomOnFirstHopChainFromTrace(trace) {
|
|
983
|
+
try {
|
|
984
|
+
if (!(trace == null ? void 0 : trace.base_denom)) return void 0;
|
|
985
|
+
const parts = trace.path.split("/").filter(Boolean);
|
|
986
|
+
if (parts.length < 2) {
|
|
987
|
+
return trace.base_denom || void 0;
|
|
988
|
+
}
|
|
989
|
+
const remaining = parts.slice(2);
|
|
990
|
+
if (remaining.length === 0) {
|
|
991
|
+
return trace.base_denom;
|
|
992
|
+
}
|
|
993
|
+
const remainingPath = remaining.join("/");
|
|
994
|
+
const full = `${remainingPath}/${trace.base_denom}`;
|
|
995
|
+
const enc = new TextEncoder();
|
|
996
|
+
const buf = enc.encode(full);
|
|
997
|
+
const digest = await crypto.subtle.digest("SHA-256", buf);
|
|
998
|
+
const hashBytes = new Uint8Array(digest);
|
|
999
|
+
let hex = "";
|
|
1000
|
+
for (let i = 0; i < hashBytes.length; i++) {
|
|
1001
|
+
const b = hashBytes[i].toString(16).padStart(2, "0");
|
|
1002
|
+
hex += b;
|
|
1003
|
+
}
|
|
1004
|
+
return `ibc/${hex.toUpperCase()}`;
|
|
1005
|
+
} catch (e) {
|
|
1006
|
+
console.error("[denomOnFirstHopChainFromTrace] error:", e);
|
|
1007
|
+
return void 0;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
var getIbcTransferTimeout = () => {
|
|
1011
|
+
return new import_bignumber3.default(Date.now() + 6e5).multipliedBy(1e6);
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
// src/utils/liquidity_pool.ts
|
|
1015
|
+
var calculateUserPoolData = (balance, lpAsset, poolData) => {
|
|
1016
|
+
const zeroBN = toBigNumber(0);
|
|
1017
|
+
if (!balance || balance.amount.isZero()) {
|
|
1018
|
+
return { userLiquidityUsd: zeroBN, userSharesPercentage: 0 };
|
|
1019
|
+
}
|
|
1020
|
+
if (!lpAsset) {
|
|
1021
|
+
return { userLiquidityUsd: zeroBN, userSharesPercentage: 0 };
|
|
1022
|
+
}
|
|
1023
|
+
const userShares = toBigNumber(balance.amount);
|
|
1024
|
+
const totalShares = toBigNumber(lpAsset.supply);
|
|
1025
|
+
if (totalShares.isZero()) {
|
|
1026
|
+
return { userLiquidityUsd: zeroBN, userSharesPercentage: 0 };
|
|
1027
|
+
}
|
|
1028
|
+
const userSharesPercentage = userShares.dividedBy(totalShares).multipliedBy(100).toNumber();
|
|
1029
|
+
let userLiquidityUsd = zeroBN;
|
|
1030
|
+
if (poolData && poolData.usdValue) {
|
|
1031
|
+
userLiquidityUsd = userShares.dividedBy(totalShares).multipliedBy(poolData.usdValue);
|
|
1032
|
+
}
|
|
1033
|
+
return { userLiquidityUsd, userSharesPercentage };
|
|
1034
|
+
};
|
|
1035
|
+
var calculatePoolOppositeAmount = (pool, amount, isBase) => {
|
|
1036
|
+
const amountBN = toBigNumber(amount);
|
|
1037
|
+
if (amountBN.isZero() || amountBN.isNaN()) {
|
|
1038
|
+
return toBigNumber(0);
|
|
1039
|
+
}
|
|
1040
|
+
const reserveBase = toBigNumber(pool.reserve_base);
|
|
1041
|
+
const reserveQuote = toBigNumber(pool.reserve_quote);
|
|
1042
|
+
if (reserveBase.isZero() || reserveQuote.isZero()) {
|
|
1043
|
+
return toBigNumber(0);
|
|
1044
|
+
}
|
|
1045
|
+
if (isBase) {
|
|
1046
|
+
return amountBN.multipliedBy(reserveQuote).dividedBy(reserveBase);
|
|
1047
|
+
} else {
|
|
1048
|
+
return amountBN.multipliedBy(reserveBase).dividedBy(reserveQuote);
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
var calculatePoolPrice = (denom, pool) => {
|
|
1052
|
+
if (!pool || !denom) return null;
|
|
1053
|
+
const reserveBase = toBigNumber(pool.reserve_base);
|
|
1054
|
+
const reserveQuote = toBigNumber(pool.reserve_quote);
|
|
1055
|
+
if (reserveBase.lte(0) || reserveQuote.lte(0)) {
|
|
1056
|
+
return null;
|
|
1057
|
+
}
|
|
1058
|
+
if (denom === pool.base) {
|
|
1059
|
+
return reserveQuote.dividedBy(reserveBase);
|
|
1060
|
+
}
|
|
1061
|
+
if (denom === pool.quote) {
|
|
1062
|
+
return reserveBase.dividedBy(reserveQuote);
|
|
1063
|
+
}
|
|
1064
|
+
return null;
|
|
1065
|
+
};
|
|
1066
|
+
var createPoolId = (base, quote) => {
|
|
1067
|
+
if (base > quote) return `${quote}_${base}`;
|
|
1068
|
+
return `${base}_${quote}`;
|
|
1069
|
+
};
|
|
1070
|
+
var poolIdFromPoolDenom = (poolDenom) => poolDenom.replace("ulp_", "");
|
|
1071
|
+
|
|
1072
|
+
// src/utils/market.ts
|
|
1073
|
+
var import_bignumber4 = __toESM(require("bignumber.js"));
|
|
1074
|
+
var createMarketId = (base, quote) => `${base}/${quote}`;
|
|
1075
|
+
var calculateTotalAmount = (price, amount, decimals) => {
|
|
1076
|
+
const priceNum = toBigNumber(price);
|
|
1077
|
+
const amountNum = toBigNumber(amount);
|
|
1078
|
+
if (priceNum.isNaN() || amountNum.isNaN() || priceNum.isZero() || amountNum.isZero()) return "";
|
|
1079
|
+
const total = priceNum.multipliedBy(amountNum);
|
|
1080
|
+
return total.decimalPlaces(decimals).toString();
|
|
1081
|
+
};
|
|
1082
|
+
var calculatePricePerUnit = (amount, totalPrice, decimals) => {
|
|
1083
|
+
const amountNum = toBigNumber(amount);
|
|
1084
|
+
const total = toBigNumber(totalPrice);
|
|
1085
|
+
if (amountNum.isNaN() || total.isNaN() || amountNum.isZero() || total.isZero()) return "";
|
|
1086
|
+
return total.dividedBy(amountNum).decimalPlaces(decimals).toString();
|
|
1087
|
+
};
|
|
1088
|
+
var calculateAmountFromPrice = (price, totalPrice, decimals) => {
|
|
1089
|
+
const total = toBigNumber(totalPrice);
|
|
1090
|
+
const priceNum = toBigNumber(price);
|
|
1091
|
+
if (total.isNaN() || priceNum.isNaN() || total.isZero() || priceNum.isZero()) return "";
|
|
1092
|
+
return total.div(priceNum).decimalPlaces(decimals).toString();
|
|
1093
|
+
};
|
|
1094
|
+
var getMinAmount = (uPrice, noOfDecimals) => {
|
|
1095
|
+
const uPriceDec = toBigNumber(uPrice);
|
|
1096
|
+
if (uPriceDec.lte(0)) {
|
|
1097
|
+
return new import_bignumber4.default(0);
|
|
1098
|
+
}
|
|
1099
|
+
const oneDec = new import_bignumber4.default(1);
|
|
1100
|
+
const amtDec = oneDec.dividedBy(uPriceDec).decimalPlaces(0, import_bignumber4.default.ROUND_CEIL).multipliedBy(2);
|
|
1101
|
+
return amtDec.shiftedBy(-1 * noOfDecimals).decimalPlaces(noOfDecimals || 6).multipliedBy(2);
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
// src/utils/number.ts
|
|
1105
|
+
var sanitizeNumberInput = (input) => {
|
|
1106
|
+
let sanitized = input.replace(/[^0-9.,]/g, "");
|
|
1107
|
+
sanitized = sanitized.replace(",", ".");
|
|
1108
|
+
const parts = sanitized.split(".");
|
|
1109
|
+
if (parts.length > 2) {
|
|
1110
|
+
sanitized = parts[0] + "." + parts.slice(1).join("");
|
|
1111
|
+
}
|
|
1112
|
+
return sanitized;
|
|
1113
|
+
};
|
|
1114
|
+
var sanitizeIntegerInput = (input) => {
|
|
1115
|
+
if (input.length === 0) {
|
|
1116
|
+
return "";
|
|
1117
|
+
}
|
|
1118
|
+
const sanitized = input.replace(/[^0-9]/g, "");
|
|
1119
|
+
const parsed = parseInt(sanitized, 10);
|
|
1120
|
+
if (!parsed) {
|
|
1121
|
+
return "1";
|
|
1122
|
+
}
|
|
1123
|
+
return `${parsed}`;
|
|
1124
|
+
};
|
|
1125
|
+
var toPercentage = (dec) => toBigNumber(dec).multipliedBy(100).decimalPlaces(2).toString();
|
|
1126
|
+
|
|
1127
|
+
// src/utils/staking.ts
|
|
1128
|
+
var import_bignumber5 = __toESM(require("bignumber.js"));
|
|
1129
|
+
var DAY_TO_SECONDS = 24 * 60 * 60;
|
|
1130
|
+
var calcNativeStakingApr = (pool, communityTax, annualProvisions) => {
|
|
1131
|
+
const totalSupply = new import_bignumber5.default((pool == null ? void 0 : pool.bonded_tokens) || 0).plus(
|
|
1132
|
+
(pool == null ? void 0 : pool.not_bonded_tokens) || 0
|
|
1133
|
+
);
|
|
1134
|
+
if (totalSupply.isZero() || annualProvisions.isZero()) {
|
|
1135
|
+
return "0.00";
|
|
1136
|
+
}
|
|
1137
|
+
const bondedTokens = new import_bignumber5.default((pool == null ? void 0 : pool.bonded_tokens) || 0);
|
|
1138
|
+
if (bondedTokens.isZero()) {
|
|
1139
|
+
return "0.00";
|
|
1140
|
+
}
|
|
1141
|
+
const bondedTokensRatio = bondedTokens.div(totalSupply);
|
|
1142
|
+
const inflation = annualProvisions.div(totalSupply);
|
|
1143
|
+
const communityTaxRate = new import_bignumber5.default(communityTax || 0);
|
|
1144
|
+
const apr = inflation.multipliedBy(new import_bignumber5.default(1).minus(communityTaxRate)).div(bondedTokensRatio).multipliedBy(100).decimalPlaces(2, import_bignumber5.default.ROUND_DOWN);
|
|
1145
|
+
return apr.toString();
|
|
1146
|
+
};
|
|
1147
|
+
var parseUnbondingDays = (unbondingTime) => {
|
|
1148
|
+
const split = unbondingTime.split("s");
|
|
1149
|
+
return new import_bignumber5.default(split[0] || 0).div(DAY_TO_SECONDS).decimalPlaces(0).toString();
|
|
1150
|
+
};
|
|
1151
|
+
var calculateRewardsStakingApr = (dailyAmount, staked) => {
|
|
1152
|
+
const stakedNum = new import_bignumber5.default(staked);
|
|
1153
|
+
let computedApr = new import_bignumber5.default(dailyAmount).dividedBy(stakedNum).multipliedBy(365).multipliedBy(100);
|
|
1154
|
+
if (computedApr.lt(1)) {
|
|
1155
|
+
computedApr = computedApr.decimalPlaces(6);
|
|
1156
|
+
} else {
|
|
1157
|
+
computedApr = computedApr.decimalPlaces(2);
|
|
1158
|
+
}
|
|
1159
|
+
return computedApr;
|
|
1160
|
+
};
|
|
1161
|
+
var calculateRewardsStakingPendingRewards = (stakingReward, userStake) => {
|
|
1162
|
+
const distr = new import_bignumber5.default((stakingReward == null ? void 0 : stakingReward.distributed_stake) || 0);
|
|
1163
|
+
const joinedAt = new import_bignumber5.default((userStake == null ? void 0 : userStake.joined_at) || 0);
|
|
1164
|
+
if (distr.isEqualTo(joinedAt)) {
|
|
1165
|
+
return new import_bignumber5.default(0);
|
|
1166
|
+
}
|
|
1167
|
+
const deposited = new import_bignumber5.default((userStake == null ? void 0 : userStake.amount) || 0);
|
|
1168
|
+
return deposited.multipliedBy(distr.minus(joinedAt)).decimalPlaces(0);
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
// src/utils/user_errors.ts
|
|
1172
|
+
var errorsMap = {
|
|
1173
|
+
"failed to execute message; message index: 0: amount is smaller than staking reward min stake": "Amount is smaller than minimum required stake",
|
|
1174
|
+
"the resulted amount is too low": "Swap minimum amount could not be met. Increase the slippage and try again.",
|
|
1175
|
+
"amount is too low to be traded": "Amount is too low to be traded",
|
|
1176
|
+
"can not buy more than 50 tickets": "You can only contribute up to 50 times per transaction."
|
|
1177
|
+
};
|
|
1178
|
+
var prettyError = (err) => {
|
|
1179
|
+
if (!err) return void 0;
|
|
1180
|
+
if (errorsMap[err]) {
|
|
1181
|
+
return errorsMap[err];
|
|
1182
|
+
}
|
|
1183
|
+
for (const [key, value] of Object.entries(errorsMap)) {
|
|
1184
|
+
if (err.includes(key)) {
|
|
1185
|
+
return value;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
return err;
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
// src/constants/settings.ts
|
|
1192
|
+
var SETTINGS_STORAGE_KEY = "bze_app_settings";
|
|
1193
|
+
var _a, _b;
|
|
1194
|
+
var DEFAULT_SETTINGS = {
|
|
1195
|
+
endpoints: {
|
|
1196
|
+
restEndpoint: (_a = process.env.NEXT_PUBLIC_REST_ENDPOINT) != null ? _a : "",
|
|
1197
|
+
rpcEndpoint: (_b = process.env.NEXT_PUBLIC_RPC_ENDPOINT) != null ? _b : ""
|
|
1198
|
+
},
|
|
1199
|
+
preferredFeeDenom: getChainNativeAssetDenom()
|
|
1200
|
+
};
|
|
1201
|
+
var VALIDATION_ERRORS = {
|
|
1202
|
+
EMPTY_ENDPOINT: "Endpoint cannot be empty",
|
|
1203
|
+
INVALID_URL: "Invalid URL format",
|
|
1204
|
+
INVALID_REST_PROTOCOL: "REST endpoint must use HTTP or HTTPS protocol",
|
|
1205
|
+
INVALID_RPC_PROTOCOL: "RPC endpoint must use WS or WSS protocol for WebSocket connection",
|
|
1206
|
+
CORS_ERROR: "Endpoint validation failed - unable to connect or CORS not enabled",
|
|
1207
|
+
WEBSOCKET_ERROR: "WebSocket connection failed - unable to connect to RPC endpoint",
|
|
1208
|
+
NETWORK_ERROR: "Network error - unable to validate endpoint"
|
|
1209
|
+
};
|
|
1210
|
+
var getAppName = () => {
|
|
1211
|
+
var _a2;
|
|
1212
|
+
return (_a2 = process.env.NEXT_PUBLIC_APP_NAME) != null ? _a2 : "BZE";
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
// src/storage/settings.ts
|
|
1216
|
+
var getSettings = () => {
|
|
1217
|
+
const saved = getFromLocalStorage(SETTINGS_STORAGE_KEY);
|
|
1218
|
+
if (saved) {
|
|
1219
|
+
const parsed = JSON.parse(saved);
|
|
1220
|
+
return __spreadValues(__spreadValues({}, DEFAULT_SETTINGS), parsed);
|
|
1221
|
+
}
|
|
1222
|
+
return DEFAULT_SETTINGS;
|
|
1223
|
+
};
|
|
1224
|
+
var setSettings = (newSettings) => {
|
|
1225
|
+
return setInLocalStorage(SETTINGS_STORAGE_KEY, JSON.stringify(newSettings), TTL_NO_EXPIRY);
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
// src/query/client.ts
|
|
1229
|
+
var import_bzejs = require("@bze/bzejs");
|
|
1230
|
+
var import_pagination = require("@bze/bzejs/cosmos/base/query/v1beta1/pagination");
|
|
1231
|
+
var getRestClient = () => {
|
|
1232
|
+
const settings = getSettings();
|
|
1233
|
+
return createRestClient(settings.endpoints.restEndpoint);
|
|
1234
|
+
};
|
|
1235
|
+
var createRestClient = async (endpoint) => {
|
|
1236
|
+
return import_bzejs.bze.ClientFactory.createLCDClient({ restEndpoint: endpoint });
|
|
1237
|
+
};
|
|
1238
|
+
var getPageRequestWithLimit = (limit) => {
|
|
1239
|
+
return import_pagination.PageRequest.fromPartial({
|
|
1240
|
+
limit: BigInt(limit)
|
|
1241
|
+
});
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
// src/query/burner.ts
|
|
1245
|
+
var import_bzejs2 = require("@bze/bzejs");
|
|
1246
|
+
var import_pagination2 = require("@bze/bzejs/cosmos/base/query/v1beta1/pagination");
|
|
1247
|
+
var BURNED_KEY = "burner:all_burned_coins";
|
|
1248
|
+
var LOCAL_CACHE_TTL = 60 * 60 * 4;
|
|
1249
|
+
var { fromPartial: QueryAllBurnedCoinsRequestFromPartial } = import_bzejs2.bze.burner.QueryAllBurnedCoinsRequest;
|
|
1250
|
+
var getBurnerParams = async () => {
|
|
1251
|
+
try {
|
|
1252
|
+
const client = await getRestClient();
|
|
1253
|
+
return getBurnerParamsWithClient(client);
|
|
1254
|
+
} catch (error) {
|
|
1255
|
+
console.error("failed to get burner params: ", error);
|
|
1256
|
+
}
|
|
1257
|
+
return void 0;
|
|
1258
|
+
};
|
|
1259
|
+
var getBurnerParamsWithClient = async (client) => {
|
|
1260
|
+
try {
|
|
1261
|
+
const response = await client.bze.burner.params();
|
|
1262
|
+
return response.params;
|
|
1263
|
+
} catch (error) {
|
|
1264
|
+
console.error("failed to get burner params: ", error);
|
|
1265
|
+
}
|
|
1266
|
+
return void 0;
|
|
1267
|
+
};
|
|
1268
|
+
async function getAllBurnedCoins() {
|
|
1269
|
+
try {
|
|
1270
|
+
const localData = getFromLocalStorage(BURNED_KEY);
|
|
1271
|
+
if (null !== localData) {
|
|
1272
|
+
const parsed = JSON.parse(localData);
|
|
1273
|
+
if (parsed) {
|
|
1274
|
+
return parsed;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
const client = await getRestClient();
|
|
1278
|
+
const response = await client.bze.burner.allBurnedCoins(
|
|
1279
|
+
QueryAllBurnedCoinsRequestFromPartial({
|
|
1280
|
+
pagination: import_pagination2.PageRequest.fromPartial({ reverse: true })
|
|
1281
|
+
})
|
|
1282
|
+
);
|
|
1283
|
+
setInLocalStorage(BURNED_KEY, JSON.stringify(response), LOCAL_CACHE_TTL);
|
|
1284
|
+
return response;
|
|
1285
|
+
} catch (e) {
|
|
1286
|
+
console.error(e);
|
|
1287
|
+
return {
|
|
1288
|
+
burnedCoins: []
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/utils/validation.ts
|
|
1294
|
+
function isValidUrl(urlString) {
|
|
1295
|
+
try {
|
|
1296
|
+
const url = new URL(urlString);
|
|
1297
|
+
return url.protocol === "http:" || url.protocol === "https:" || url.protocol === "ws:" || url.protocol === "wss:";
|
|
1298
|
+
} catch (e) {
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
async function validateRestEndpoint(endpoint) {
|
|
1303
|
+
if (!endpoint.trim()) {
|
|
1304
|
+
return { isValid: false, error: VALIDATION_ERRORS.EMPTY_ENDPOINT };
|
|
1305
|
+
}
|
|
1306
|
+
if (!isValidUrl(endpoint)) {
|
|
1307
|
+
return { isValid: false, error: VALIDATION_ERRORS.INVALID_URL };
|
|
1308
|
+
}
|
|
1309
|
+
const url = new URL(endpoint);
|
|
1310
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
1311
|
+
return { isValid: false, error: VALIDATION_ERRORS.INVALID_REST_PROTOCOL };
|
|
1312
|
+
}
|
|
1313
|
+
try {
|
|
1314
|
+
const client = await createRestClient(endpoint);
|
|
1315
|
+
const params = await getBurnerParamsWithClient(client);
|
|
1316
|
+
if (params) {
|
|
1317
|
+
return { isValid: true };
|
|
1318
|
+
}
|
|
1319
|
+
return { isValid: false, error: VALIDATION_ERRORS.CORS_ERROR };
|
|
1320
|
+
} catch (error) {
|
|
1321
|
+
console.error(error);
|
|
1322
|
+
return { isValid: false, error: VALIDATION_ERRORS.NETWORK_ERROR };
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
async function validateRpcEndpoint(endpoint) {
|
|
1326
|
+
if (!endpoint.trim()) {
|
|
1327
|
+
return { isValid: false, error: VALIDATION_ERRORS.EMPTY_ENDPOINT };
|
|
1328
|
+
}
|
|
1329
|
+
if (!isValidUrl(endpoint)) {
|
|
1330
|
+
return { isValid: false, error: VALIDATION_ERRORS.INVALID_URL };
|
|
1331
|
+
}
|
|
1332
|
+
const wsEndpoint = convertToWebSocketUrl(endpoint);
|
|
1333
|
+
const url = new URL(wsEndpoint);
|
|
1334
|
+
if (url.protocol !== "ws:" && url.protocol !== "wss:") {
|
|
1335
|
+
return { isValid: false, error: VALIDATION_ERRORS.INVALID_RPC_PROTOCOL };
|
|
1336
|
+
}
|
|
1337
|
+
try {
|
|
1338
|
+
const isConnectable = await testWebSocketConnection(wsEndpoint);
|
|
1339
|
+
if (isConnectable) {
|
|
1340
|
+
return { isValid: true };
|
|
1341
|
+
} else {
|
|
1342
|
+
return { isValid: false, error: VALIDATION_ERRORS.WEBSOCKET_ERROR };
|
|
1343
|
+
}
|
|
1344
|
+
} catch (error) {
|
|
1345
|
+
console.error("WebSocket validation error:", error);
|
|
1346
|
+
return { isValid: false, error: VALIDATION_ERRORS.NETWORK_ERROR };
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
function testWebSocketConnection(endpoint) {
|
|
1350
|
+
return new Promise((resolve) => {
|
|
1351
|
+
const ws = new WebSocket(`${endpoint}/websocket`);
|
|
1352
|
+
const timeout = setTimeout(() => {
|
|
1353
|
+
ws.close();
|
|
1354
|
+
resolve(false);
|
|
1355
|
+
}, 5e3);
|
|
1356
|
+
ws.onopen = () => {
|
|
1357
|
+
clearTimeout(timeout);
|
|
1358
|
+
ws.close();
|
|
1359
|
+
resolve(true);
|
|
1360
|
+
};
|
|
1361
|
+
ws.onerror = () => {
|
|
1362
|
+
clearTimeout(timeout);
|
|
1363
|
+
resolve(false);
|
|
1364
|
+
};
|
|
1365
|
+
ws.onclose = (event) => {
|
|
1366
|
+
clearTimeout(timeout);
|
|
1367
|
+
if (event.wasClean) {
|
|
1368
|
+
resolve(true);
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
async function validateEndpoints(restEndpoint, rpcEndpoint) {
|
|
1374
|
+
const [restResult, rpcResult] = await Promise.all([
|
|
1375
|
+
validateRestEndpoint(restEndpoint),
|
|
1376
|
+
validateRpcEndpoint(rpcEndpoint)
|
|
1377
|
+
]);
|
|
1378
|
+
return {
|
|
1379
|
+
rest: restResult,
|
|
1380
|
+
rpc: rpcResult,
|
|
1381
|
+
isValid: restResult.isValid && rpcResult.isValid
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
function convertToWebSocketUrl(url) {
|
|
1385
|
+
try {
|
|
1386
|
+
const parsedUrl = new URL(url);
|
|
1387
|
+
if (parsedUrl.protocol === "http:") {
|
|
1388
|
+
parsedUrl.protocol = "ws:";
|
|
1389
|
+
} else if (parsedUrl.protocol === "https:") {
|
|
1390
|
+
parsedUrl.protocol = "wss:";
|
|
1391
|
+
}
|
|
1392
|
+
return parsedUrl.toString();
|
|
1393
|
+
} catch (error) {
|
|
1394
|
+
console.warn("Failed to parse URL for WebSocket conversion:", error);
|
|
1395
|
+
return url;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
// src/utils/validator.ts
|
|
1400
|
+
var getValidatorSupportedDenoms = () => {
|
|
1401
|
+
const denoms = process.env.NEXT_PUBLIC_ATONE_VALIDATOR_SUPPORTED_DENOMS || "";
|
|
1402
|
+
return denoms.split(",").map((d) => d.trim()).filter((d) => d.length > 0);
|
|
1403
|
+
};
|
|
1404
|
+
var getValidatorPageUrl = () => {
|
|
1405
|
+
return process.env.NEXT_PUBLIC_ATONE_VALIDATOR_PAGE_URL || "";
|
|
1406
|
+
};
|
|
1407
|
+
var isPoolSupportedByValidator = (baseDenom, quoteDenom) => {
|
|
1408
|
+
const supportedDenoms = getValidatorSupportedDenoms();
|
|
1409
|
+
return supportedDenoms.includes(baseDenom) || supportedDenoms.includes(quoteDenom);
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
// src/constants/endpoints.ts
|
|
1413
|
+
function getRestURL() {
|
|
1414
|
+
return process.env.NEXT_PUBLIC_REST_URL || "";
|
|
1415
|
+
}
|
|
1416
|
+
function getRpcURL() {
|
|
1417
|
+
return process.env.NEXT_PUBLIC_RPC_URL || "";
|
|
1418
|
+
}
|
|
1419
|
+
function getArchwayRpcURL() {
|
|
1420
|
+
return process.env.NEXT_PUBLIC_RPC_URL_ARCHWAY || "";
|
|
1421
|
+
}
|
|
1422
|
+
function getOsmosisRpcUrl() {
|
|
1423
|
+
return process.env.NEXT_PUBLIC_RPC_URL_OSMOSIS || "";
|
|
1424
|
+
}
|
|
1425
|
+
function getNobleRpcUrl() {
|
|
1426
|
+
return process.env.NEXT_PUBLIC_RPC_URL_NOBLE || "";
|
|
1427
|
+
}
|
|
1428
|
+
function getJackalRpcUrl() {
|
|
1429
|
+
return process.env.NEXT_PUBLIC_RPC_URL_JACKAL || "";
|
|
1430
|
+
}
|
|
1431
|
+
function getOmniFlixRpcUrl() {
|
|
1432
|
+
return process.env.NEXT_PUBLIC_RPC_URL_FLIX || "";
|
|
1433
|
+
}
|
|
1434
|
+
function getAtomOneRpcUrl() {
|
|
1435
|
+
return process.env.NEXT_PUBLIC_RPC_URL_ATOMONE || "";
|
|
1436
|
+
}
|
|
1437
|
+
function getArchwayRestURL() {
|
|
1438
|
+
return process.env.NEXT_PUBLIC_REST_URL_ARCHWAY || "";
|
|
1439
|
+
}
|
|
1440
|
+
function getOsmosisRestURL() {
|
|
1441
|
+
return process.env.NEXT_PUBLIC_REST_URL_OSMOSIS || "";
|
|
1442
|
+
}
|
|
1443
|
+
function getNobleRestURL() {
|
|
1444
|
+
return process.env.NEXT_PUBLIC_REST_URL_NOBLE || "";
|
|
1445
|
+
}
|
|
1446
|
+
function getJackalRestURL() {
|
|
1447
|
+
return process.env.NEXT_PUBLIC_REST_URL_JACKAL || "";
|
|
1448
|
+
}
|
|
1449
|
+
function getOmniFlixRestURL() {
|
|
1450
|
+
return process.env.NEXT_PUBLIC_REST_URL_FLIX || "";
|
|
1451
|
+
}
|
|
1452
|
+
function getAtomOneRestURL() {
|
|
1453
|
+
return process.env.NEXT_PUBLIC_REST_URL_ATOMONE || "";
|
|
1454
|
+
}
|
|
1455
|
+
var getAggregatorHost = () => {
|
|
1456
|
+
var _a2;
|
|
1457
|
+
return (_a2 = process.env.NEXT_PUBLIC_AGG_API_HOST) != null ? _a2 : "https://getbze.com";
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
// src/constants/market.ts
|
|
1461
|
+
var EXCLUDED_MARKETS = {
|
|
1462
|
+
"factory/bze1f0qgels0eu96ev6a67znu70q7rquy9eragn8nw/ucorey/factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl": true,
|
|
1463
|
+
"factory/bze1f0qgels0eu96ev6a67znu70q7rquy9eragn8nw/ucorey/ubze": true
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
// src/constants/ecosystem.ts
|
|
1467
|
+
var import_lu = require("react-icons/lu");
|
|
1468
|
+
var ECOSYSTEM_MENU_LABEL = "Other";
|
|
1469
|
+
var ALL_APPS = [
|
|
1470
|
+
{ name: "Website", href: "https://getbze.com", disabled: false, icon: import_lu.LuGlobe },
|
|
1471
|
+
{ name: "Staking", href: "https://staking.getbze.com", disabled: false, icon: import_lu.LuCoins },
|
|
1472
|
+
{ name: "DEX", href: "https://dex.getbze.com", disabled: false, icon: import_lu.LuChartColumn },
|
|
1473
|
+
{ name: "Burner", href: "https://burner.getbze.com", disabled: false, icon: import_lu.LuFlame },
|
|
1474
|
+
{ name: "Factory", href: "#", disabled: true, icon: import_lu.LuFactory }
|
|
1475
|
+
];
|
|
1476
|
+
var getEcosystemApps = () => {
|
|
1477
|
+
const currentHost = process.env.NEXT_PUBLIC_SITE_URL || "";
|
|
1478
|
+
if (!currentHost) {
|
|
1479
|
+
return ALL_APPS;
|
|
1480
|
+
}
|
|
1481
|
+
return ALL_APPS.filter((app) => app.href !== currentHost);
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
// src/constants/keplr.ts
|
|
1485
|
+
var MAINNET_CHAIN_INFO_FALLBACK = {
|
|
1486
|
+
"chainId": "beezee-1",
|
|
1487
|
+
"chainName": "BeeZee",
|
|
1488
|
+
"chainSymbolImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/beezee/chain.png",
|
|
1489
|
+
"rpc": "https://rpc.getbze.com",
|
|
1490
|
+
"rest": "https://rest.getbze.com",
|
|
1491
|
+
"nodeProvider": {
|
|
1492
|
+
"name": "BZE Alpha Team",
|
|
1493
|
+
"email": "alphateam@getbze.com",
|
|
1494
|
+
"website": "https://getbze.com"
|
|
1495
|
+
},
|
|
1496
|
+
"stakeCurrency": {
|
|
1497
|
+
"coinDenom": "BZE",
|
|
1498
|
+
"coinMinimalDenom": "ubze",
|
|
1499
|
+
"coinDecimals": 6,
|
|
1500
|
+
"coinGeckoId": "bzedge",
|
|
1501
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/beezee/chain.png"
|
|
1502
|
+
},
|
|
1503
|
+
"bip44": {
|
|
1504
|
+
"coinType": 118
|
|
1505
|
+
},
|
|
1506
|
+
"bech32Config": {
|
|
1507
|
+
"bech32PrefixAccAddr": "bze",
|
|
1508
|
+
"bech32PrefixAccPub": "bzepub",
|
|
1509
|
+
"bech32PrefixValAddr": "bzevaloper",
|
|
1510
|
+
"bech32PrefixValPub": "bzevaloperpub",
|
|
1511
|
+
"bech32PrefixConsAddr": "bzevalcons",
|
|
1512
|
+
"bech32PrefixConsPub": "bzevalconspub"
|
|
1513
|
+
},
|
|
1514
|
+
"currencies": [
|
|
1515
|
+
{
|
|
1516
|
+
"coinDenom": "BZE",
|
|
1517
|
+
"coinMinimalDenom": "ubze",
|
|
1518
|
+
"coinDecimals": 6,
|
|
1519
|
+
"coinGeckoId": "bzedge",
|
|
1520
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/beezee/chain.png"
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
"coinDenom": "VDL",
|
|
1524
|
+
"coinMinimalDenom": "factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl",
|
|
1525
|
+
"coinDecimals": 6,
|
|
1526
|
+
"coinGeckoId": "vidulum",
|
|
1527
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/beezee/factory/bze13gzq40che93tgfm9kzmkpjamah5nj0j73pyhqk/uvdl.png"
|
|
1528
|
+
}
|
|
1529
|
+
],
|
|
1530
|
+
"feeCurrencies": [{
|
|
1531
|
+
"coinDenom": "BZE",
|
|
1532
|
+
"coinMinimalDenom": "ubze",
|
|
1533
|
+
"coinDecimals": 6,
|
|
1534
|
+
"coinGeckoId": "bzedge",
|
|
1535
|
+
"gasPriceStep": {
|
|
1536
|
+
"low": 1e-3,
|
|
1537
|
+
"average": 0.01,
|
|
1538
|
+
"high": 0.1
|
|
1539
|
+
},
|
|
1540
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/beezee/chain.png"
|
|
1541
|
+
}],
|
|
1542
|
+
"features": []
|
|
1543
|
+
};
|
|
1544
|
+
var TESTNET_CHAIN_INFO_FALLBACK = {
|
|
1545
|
+
"chainId": "bzetestnet-3",
|
|
1546
|
+
"chainName": "BeeZee Testnet 3",
|
|
1547
|
+
"chainSymbolImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bzetestnet/chain.png",
|
|
1548
|
+
"rpc": "https://testnet-rpc.getbze.com",
|
|
1549
|
+
"rest": "https://testnet.getbze.com",
|
|
1550
|
+
"nodeProvider": {
|
|
1551
|
+
"name": "BZE Alpha Team",
|
|
1552
|
+
"email": "alphateam@getbze.com",
|
|
1553
|
+
"website": "https://getbze.com"
|
|
1554
|
+
},
|
|
1555
|
+
"stakeCurrency": {
|
|
1556
|
+
"coinDenom": "TBZE",
|
|
1557
|
+
"coinMinimalDenom": "ubze",
|
|
1558
|
+
"coinDecimals": 6,
|
|
1559
|
+
"coinGeckoId": "bzedge",
|
|
1560
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bzetestnet/chain.png"
|
|
1561
|
+
},
|
|
1562
|
+
"bip44": {
|
|
1563
|
+
"coinType": 118
|
|
1564
|
+
},
|
|
1565
|
+
"bech32Config": {
|
|
1566
|
+
"bech32PrefixAccAddr": "bze",
|
|
1567
|
+
"bech32PrefixAccPub": "bzepub",
|
|
1568
|
+
"bech32PrefixValAddr": "bzevaloper",
|
|
1569
|
+
"bech32PrefixValPub": "bzevaloperpub",
|
|
1570
|
+
"bech32PrefixConsAddr": "bzevalcons",
|
|
1571
|
+
"bech32PrefixConsPub": "bzevalconspub"
|
|
1572
|
+
},
|
|
1573
|
+
"currencies": [
|
|
1574
|
+
{
|
|
1575
|
+
"coinDenom": "TBZE",
|
|
1576
|
+
"coinMinimalDenom": "ubze",
|
|
1577
|
+
"coinDecimals": 6,
|
|
1578
|
+
"coinGeckoId": "bzedge",
|
|
1579
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bzetestnet/chain.png"
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
"coinDenom": "TVDL",
|
|
1583
|
+
"coinMinimalDenom": "factory/bze1z3mkcr2jz424w6m49frgjmy9uhlrx69phqwg3l/vidulum",
|
|
1584
|
+
"coinDecimals": 6,
|
|
1585
|
+
"coinGeckoId": "vidulum",
|
|
1586
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bzetestnet/factory/testbz1z3mkcr2jz424w6m49frgjmy9uhlrx69p4cvrgf/vidulum.png"
|
|
1587
|
+
}
|
|
1588
|
+
],
|
|
1589
|
+
"feeCurrencies": [{
|
|
1590
|
+
"coinDenom": "TBZE",
|
|
1591
|
+
"coinMinimalDenom": "ubze",
|
|
1592
|
+
"coinDecimals": 6,
|
|
1593
|
+
"coinGeckoId": "bzedge",
|
|
1594
|
+
"gasPriceStep": {
|
|
1595
|
+
"low": 1e-3,
|
|
1596
|
+
"average": 0.01,
|
|
1597
|
+
"high": 0.1
|
|
1598
|
+
},
|
|
1599
|
+
"coinImageUrl": "https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/bzetestnet/chain.png"
|
|
1600
|
+
}],
|
|
1601
|
+
"features": []
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
// src/service/amm_router.ts
|
|
1605
|
+
var AmmRouter = class _AmmRouter {
|
|
1606
|
+
constructor() {
|
|
1607
|
+
this.routeCache = /* @__PURE__ */ new Map();
|
|
1608
|
+
this.routeMap = /* @__PURE__ */ new Map();
|
|
1609
|
+
}
|
|
1610
|
+
static getInstance() {
|
|
1611
|
+
if (!_AmmRouter.instance) {
|
|
1612
|
+
_AmmRouter.instance = new _AmmRouter();
|
|
1613
|
+
}
|
|
1614
|
+
return _AmmRouter.instance;
|
|
1615
|
+
}
|
|
1616
|
+
updatePools(pools) {
|
|
1617
|
+
this.routeMap = this.mapLiquidityPoolRoutes(pools);
|
|
1618
|
+
this.clearCache();
|
|
1619
|
+
}
|
|
1620
|
+
mapLiquidityPoolRoutes(pools) {
|
|
1621
|
+
const routeMap = /* @__PURE__ */ new Map();
|
|
1622
|
+
for (const pool of pools) {
|
|
1623
|
+
if (!routeMap.has(pool.base)) {
|
|
1624
|
+
routeMap.set(pool.base, /* @__PURE__ */ new Map());
|
|
1625
|
+
}
|
|
1626
|
+
routeMap.get(pool.base).set(pool.quote, pool);
|
|
1627
|
+
if (!routeMap.has(pool.quote)) {
|
|
1628
|
+
routeMap.set(pool.quote, /* @__PURE__ */ new Map());
|
|
1629
|
+
}
|
|
1630
|
+
routeMap.get(pool.quote).set(pool.base, pool);
|
|
1631
|
+
}
|
|
1632
|
+
return routeMap;
|
|
1633
|
+
}
|
|
1634
|
+
findOptimalRoute(fromDenom, toDenom, amountIn, maxHops, useCache = true) {
|
|
1635
|
+
const cacheKey = this.getCacheKey(fromDenom, toDenom, maxHops);
|
|
1636
|
+
if (useCache) {
|
|
1637
|
+
const cached = this.routeCache.get(cacheKey);
|
|
1638
|
+
if (cached) {
|
|
1639
|
+
return __spreadValues(__spreadValues({}, cached.result), this.calculateRouteOutput(cached.result.pools, cached.result.path, amountIn));
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
const result = this.findOptimalSwapRoute(fromDenom, toDenom, amountIn, maxHops);
|
|
1643
|
+
if (result) {
|
|
1644
|
+
this.routeCache.set(cacheKey, {
|
|
1645
|
+
result,
|
|
1646
|
+
timestamp: Date.now()
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
return result;
|
|
1650
|
+
}
|
|
1651
|
+
calculateRouteOutput(pools, path, amountIn) {
|
|
1652
|
+
let currentAmount = amountIn;
|
|
1653
|
+
const fees = [];
|
|
1654
|
+
for (let i = 0; i < pools.length; i++) {
|
|
1655
|
+
const pool = pools[i];
|
|
1656
|
+
const currentDenom = path[i];
|
|
1657
|
+
const isBaseToQuote = pool.base === currentDenom;
|
|
1658
|
+
const { amountOut, fee } = this.calculateSwapOutput(pool, currentAmount, isBaseToQuote);
|
|
1659
|
+
fees.push(fee);
|
|
1660
|
+
currentAmount = amountOut;
|
|
1661
|
+
}
|
|
1662
|
+
const expectedOutput = currentAmount;
|
|
1663
|
+
const theoretical = this.calculateTheoreticalOutputs(pools, path, amountIn);
|
|
1664
|
+
const totalFees = theoretical.withoutFees.minus(theoretical.withFees);
|
|
1665
|
+
const priceImpact = theoretical.withFees.isZero() ? toBigNumber(0) : theoretical.withFees.minus(expectedOutput).dividedBy(theoretical.withFees).multipliedBy(100);
|
|
1666
|
+
return {
|
|
1667
|
+
expectedOutput,
|
|
1668
|
+
priceImpact,
|
|
1669
|
+
totalFees,
|
|
1670
|
+
feesPerHop: fees
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
clearCache(filter) {
|
|
1674
|
+
if (!filter) {
|
|
1675
|
+
this.routeCache.clear();
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
for (const [key, cache] of this.routeCache.entries()) {
|
|
1679
|
+
if (filter(key, cache)) {
|
|
1680
|
+
this.routeCache.delete(key);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
getCacheStats() {
|
|
1685
|
+
return {
|
|
1686
|
+
size: this.routeCache.size,
|
|
1687
|
+
keys: Array.from(this.routeCache.keys())
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
calculateTheoreticalOutputs(pools, path, amountIn) {
|
|
1691
|
+
let theoreticalOutputNoFees = amountIn;
|
|
1692
|
+
let theoreticalOutputWithFees = amountIn;
|
|
1693
|
+
for (let i = 0; i < pools.length; i++) {
|
|
1694
|
+
const pool = pools[i];
|
|
1695
|
+
const currentDenom = path[i];
|
|
1696
|
+
const isBaseToQuote = pool.base === currentDenom;
|
|
1697
|
+
const reserveIn = toBigNumber(isBaseToQuote ? pool.reserve_base : pool.reserve_quote);
|
|
1698
|
+
const reserveOut = toBigNumber(isBaseToQuote ? pool.reserve_quote : pool.reserve_base);
|
|
1699
|
+
const midPrice = reserveOut.dividedBy(reserveIn);
|
|
1700
|
+
theoreticalOutputNoFees = theoreticalOutputNoFees.multipliedBy(midPrice);
|
|
1701
|
+
const fee = toBigNumber(pool.fee);
|
|
1702
|
+
theoreticalOutputWithFees = theoreticalOutputWithFees.multipliedBy(toBigNumber(1).minus(fee)).multipliedBy(midPrice);
|
|
1703
|
+
}
|
|
1704
|
+
return {
|
|
1705
|
+
withoutFees: theoreticalOutputNoFees,
|
|
1706
|
+
withFees: theoreticalOutputWithFees
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
calculateSwapOutput(pool, amountIn, isBaseToQuote) {
|
|
1710
|
+
const fee = toBigNumber(pool.fee);
|
|
1711
|
+
const reserveIn = toBigNumber(isBaseToQuote ? pool.reserve_base : pool.reserve_quote);
|
|
1712
|
+
const reserveOut = toBigNumber(isBaseToQuote ? pool.reserve_quote : pool.reserve_base);
|
|
1713
|
+
const feeAmount = amountIn.multipliedBy(fee);
|
|
1714
|
+
const amountInAfterFee = amountIn.minus(feeAmount);
|
|
1715
|
+
const amountOut = amountInAfterFee.multipliedBy(reserveOut).dividedBy(reserveIn.plus(amountInAfterFee));
|
|
1716
|
+
return { amountOut, fee: feeAmount };
|
|
1717
|
+
}
|
|
1718
|
+
findOptimalSwapRoute(fromDenom, toDenom, amountIn, maxHops) {
|
|
1719
|
+
if (fromDenom === toDenom) {
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
const queue = [{
|
|
1723
|
+
denom: fromDenom,
|
|
1724
|
+
amount: amountIn,
|
|
1725
|
+
path: [fromDenom],
|
|
1726
|
+
poolIds: [],
|
|
1727
|
+
pools: [],
|
|
1728
|
+
fees: [],
|
|
1729
|
+
hops: 0
|
|
1730
|
+
}];
|
|
1731
|
+
const bestAmounts = /* @__PURE__ */ new Map();
|
|
1732
|
+
bestAmounts.set(fromDenom, amountIn);
|
|
1733
|
+
let bestRoute = null;
|
|
1734
|
+
while (queue.length > 0) {
|
|
1735
|
+
queue.sort((a, b) => {
|
|
1736
|
+
var _a2;
|
|
1737
|
+
return (_a2 = b.amount.comparedTo(a.amount)) != null ? _a2 : 0;
|
|
1738
|
+
});
|
|
1739
|
+
const current = queue.shift();
|
|
1740
|
+
if (current.denom === toDenom) {
|
|
1741
|
+
if (!bestRoute || current.amount.isGreaterThan(bestRoute.amount)) {
|
|
1742
|
+
bestRoute = current;
|
|
1743
|
+
}
|
|
1744
|
+
continue;
|
|
1745
|
+
}
|
|
1746
|
+
if (current.hops >= maxHops) {
|
|
1747
|
+
continue;
|
|
1748
|
+
}
|
|
1749
|
+
const neighbors = this.routeMap.get(current.denom);
|
|
1750
|
+
if (!neighbors) continue;
|
|
1751
|
+
for (const [nextDenom, pool] of neighbors.entries()) {
|
|
1752
|
+
if (current.path.includes(nextDenom)) {
|
|
1753
|
+
continue;
|
|
1754
|
+
}
|
|
1755
|
+
const isBaseToQuote = pool.base === current.denom;
|
|
1756
|
+
const { amountOut, fee } = this.calculateSwapOutput(pool, current.amount, isBaseToQuote);
|
|
1757
|
+
if (amountOut.lte(0)) {
|
|
1758
|
+
continue;
|
|
1759
|
+
}
|
|
1760
|
+
const previousBest = bestAmounts.get(nextDenom);
|
|
1761
|
+
if (previousBest && amountOut.lte(previousBest)) {
|
|
1762
|
+
continue;
|
|
1763
|
+
}
|
|
1764
|
+
bestAmounts.set(nextDenom, amountOut);
|
|
1765
|
+
queue.push({
|
|
1766
|
+
denom: nextDenom,
|
|
1767
|
+
amount: amountOut,
|
|
1768
|
+
path: [...current.path, nextDenom],
|
|
1769
|
+
poolIds: [...current.poolIds, pool.id],
|
|
1770
|
+
pools: [...current.pools, pool],
|
|
1771
|
+
fees: [...current.fees, fee],
|
|
1772
|
+
hops: current.hops + 1
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
if (!bestRoute) {
|
|
1777
|
+
return null;
|
|
1778
|
+
}
|
|
1779
|
+
const theoretical = this.calculateTheoreticalOutputs(bestRoute.pools, bestRoute.path, amountIn);
|
|
1780
|
+
const totalFees = theoretical.withoutFees.minus(theoretical.withFees);
|
|
1781
|
+
const priceImpact = theoretical.withFees.isZero() ? toBigNumber(0) : theoretical.withFees.minus(bestRoute.amount).dividedBy(theoretical.withFees).multipliedBy(100);
|
|
1782
|
+
return {
|
|
1783
|
+
route: bestRoute.poolIds,
|
|
1784
|
+
path: bestRoute.path,
|
|
1785
|
+
pools: bestRoute.pools,
|
|
1786
|
+
expectedOutput: bestRoute.amount,
|
|
1787
|
+
priceImpact,
|
|
1788
|
+
totalFees,
|
|
1789
|
+
feesPerHop: bestRoute.fees
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
getCacheKey(fromDenom, toDenom, maxHops) {
|
|
1793
|
+
return `${fromDenom}_${toDenom}_${maxHops}`;
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
var ammRouter = AmmRouter.getInstance();
|
|
1797
|
+
|
|
1798
|
+
// src/service/blockchain_event_manager.ts
|
|
1799
|
+
var BlockchainEventManager = class _BlockchainEventManager {
|
|
1800
|
+
constructor() {
|
|
1801
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
1802
|
+
}
|
|
1803
|
+
static getInstance() {
|
|
1804
|
+
if (!_BlockchainEventManager.instance) {
|
|
1805
|
+
_BlockchainEventManager.instance = new _BlockchainEventManager();
|
|
1806
|
+
}
|
|
1807
|
+
return _BlockchainEventManager.instance;
|
|
1808
|
+
}
|
|
1809
|
+
subscribe(eventType, callback) {
|
|
1810
|
+
if (!this.listeners.has(eventType)) {
|
|
1811
|
+
this.listeners.set(eventType, /* @__PURE__ */ new Set());
|
|
1812
|
+
}
|
|
1813
|
+
this.listeners.get(eventType).add(callback);
|
|
1814
|
+
return () => {
|
|
1815
|
+
const handlers = this.listeners.get(eventType);
|
|
1816
|
+
if (handlers) {
|
|
1817
|
+
handlers.delete(callback);
|
|
1818
|
+
if (handlers.size === 0) {
|
|
1819
|
+
this.listeners.delete(eventType);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
emit(eventType, event) {
|
|
1825
|
+
const generalListeners = this.listeners.get(eventType);
|
|
1826
|
+
if (generalListeners) {
|
|
1827
|
+
generalListeners.forEach((callback) => callback(event));
|
|
1828
|
+
}
|
|
1829
|
+
if (!event) {
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
if (event.marketId) {
|
|
1833
|
+
const marketListeners = this.listeners.get(getMarketEventKey(eventType, event.marketId));
|
|
1834
|
+
if (marketListeners) {
|
|
1835
|
+
marketListeners.forEach((callback) => callback(event));
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
var blockchainEventManager = BlockchainEventManager.getInstance();
|
|
1841
|
+
|
|
1842
|
+
// src/query/supply.ts
|
|
1843
|
+
var import_query = require("@bze/bzejs/cosmos/bank/v1beta1/query");
|
|
1844
|
+
var { fromPartial: TotalSupplyRequest } = import_query.QueryTotalSupplyRequest;
|
|
1845
|
+
var { fromPartial: MetadataRequest } = import_query.QueryDenomsMetadataRequest;
|
|
1846
|
+
var DEFAULT_LIMIT = 200;
|
|
1847
|
+
var getAllSupply = async () => {
|
|
1848
|
+
try {
|
|
1849
|
+
const client = await getRestClient();
|
|
1850
|
+
const resp = await client.cosmos.bank.v1beta1.totalSupply(
|
|
1851
|
+
TotalSupplyRequest(
|
|
1852
|
+
{ pagination: getPageRequestWithLimit(DEFAULT_LIMIT) }
|
|
1853
|
+
)
|
|
1854
|
+
);
|
|
1855
|
+
return resp.supply;
|
|
1856
|
+
} catch (error) {
|
|
1857
|
+
console.error("failed to get supply: ", error);
|
|
1858
|
+
}
|
|
1859
|
+
return void 0;
|
|
1860
|
+
};
|
|
1861
|
+
var getAllSupplyMetadata = async () => {
|
|
1862
|
+
try {
|
|
1863
|
+
const client = await getRestClient();
|
|
1864
|
+
const resp = await client.cosmos.bank.v1beta1.denomsMetadata(MetadataRequest({
|
|
1865
|
+
pagination: getPageRequestWithLimit(DEFAULT_LIMIT)
|
|
1866
|
+
}));
|
|
1867
|
+
return resp.metadatas;
|
|
1868
|
+
} catch (error) {
|
|
1869
|
+
console.error("failed to get supply metadata: ", error);
|
|
1870
|
+
}
|
|
1871
|
+
return void 0;
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
// src/service/assets_factory.ts
|
|
1875
|
+
var import_utils2 = require("@chain-registry/utils");
|
|
1876
|
+
|
|
1877
|
+
// src/query/ibc.ts
|
|
1878
|
+
var TRACES_CACHE_KEY = "ibc:traces";
|
|
1879
|
+
var TRACES_CACHE_TTL = 5 * 60;
|
|
1880
|
+
var HASH_TRACE_CACHE_TTL = 0;
|
|
1881
|
+
var IBC_COUNTERPARTY_CACHE_TTL = 0;
|
|
1882
|
+
var DEFAULT_LIMIT2 = 1e3;
|
|
1883
|
+
var getDenomTracesUrl = (limit) => {
|
|
1884
|
+
const settings = getSettings();
|
|
1885
|
+
return `${settings.endpoints.restEndpoint}/ibc/apps/transfer/v1/denom_traces?pagination.limit=${limit}`;
|
|
1886
|
+
};
|
|
1887
|
+
var getHashDenomTracesUrl = (hash) => {
|
|
1888
|
+
const settings = getSettings();
|
|
1889
|
+
return `${settings.endpoints.restEndpoint}/ibc/apps/transfer/v1/denom_traces/${hash}`;
|
|
1890
|
+
};
|
|
1891
|
+
var getIBCTraces = async () => {
|
|
1892
|
+
const cached = getFromLocalStorage(TRACES_CACHE_KEY);
|
|
1893
|
+
if (cached) {
|
|
1894
|
+
return JSON.parse(cached);
|
|
1895
|
+
}
|
|
1896
|
+
try {
|
|
1897
|
+
const resp = await fetch(getDenomTracesUrl(DEFAULT_LIMIT2));
|
|
1898
|
+
if (resp.status !== 200) {
|
|
1899
|
+
console.error("failed to fetch denom traces. status: ", resp.status);
|
|
1900
|
+
return [];
|
|
1901
|
+
}
|
|
1902
|
+
const responseJson = await resp.json();
|
|
1903
|
+
if (!responseJson.denom_traces) {
|
|
1904
|
+
return [];
|
|
1905
|
+
}
|
|
1906
|
+
setInLocalStorage(TRACES_CACHE_KEY, JSON.stringify(responseJson.denom_traces), TRACES_CACHE_TTL);
|
|
1907
|
+
return responseJson.denom_traces;
|
|
1908
|
+
} catch (e) {
|
|
1909
|
+
console.error("[IBC] failed to fetch denom traces", e);
|
|
1910
|
+
return [];
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
var createHashTraceCacheKey = (hash) => {
|
|
1914
|
+
return `${TRACES_CACHE_KEY}:${hash}`;
|
|
1915
|
+
};
|
|
1916
|
+
var getHashIBCTrace = async (hash) => {
|
|
1917
|
+
const cacheKey = createHashTraceCacheKey(hash);
|
|
1918
|
+
const cached = getFromLocalStorage(cacheKey);
|
|
1919
|
+
if (cached) {
|
|
1920
|
+
return JSON.parse(cached);
|
|
1921
|
+
}
|
|
1922
|
+
try {
|
|
1923
|
+
const resp = await fetch(getHashDenomTracesUrl(hash));
|
|
1924
|
+
if (resp.status !== 200) {
|
|
1925
|
+
console.error("failed to fetch hash denom trace. status: ", resp.status);
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
const responseJson = await resp.json();
|
|
1929
|
+
if (!responseJson.denom_trace) {
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
setInLocalStorage(cacheKey, JSON.stringify(responseJson.denom_trace), HASH_TRACE_CACHE_TTL);
|
|
1933
|
+
return responseJson.denom_trace;
|
|
1934
|
+
} catch (e) {
|
|
1935
|
+
console.error("[IBC] failed to fetch denom traces", e);
|
|
1936
|
+
}
|
|
1937
|
+
return;
|
|
1938
|
+
};
|
|
1939
|
+
var getChannelIdUrl = (channelId, portId) => {
|
|
1940
|
+
const settings = getSettings();
|
|
1941
|
+
return `${settings.endpoints.restEndpoint}/ibc/core/channel/v1/channels/${channelId}/ports/${portId}`;
|
|
1942
|
+
};
|
|
1943
|
+
var getConnectionIdUrl = (connectionId) => {
|
|
1944
|
+
const settings = getSettings();
|
|
1945
|
+
return `${settings.endpoints.restEndpoint}/ibc/core/connection/v1/connections/${connectionId}`;
|
|
1946
|
+
};
|
|
1947
|
+
var getClientStateUrl = (clientId) => {
|
|
1948
|
+
const settings = getSettings();
|
|
1949
|
+
return `${settings.endpoints.restEndpoint}/ibc/core/client/v1/client_states/${clientId}`;
|
|
1950
|
+
};
|
|
1951
|
+
var getIbcCounterpartyChainIdCacheKey = (channelId, portId) => {
|
|
1952
|
+
return `ibc:counterparty:${channelId}:${portId}`;
|
|
1953
|
+
};
|
|
1954
|
+
var counterpartyChainForChannel = async (channelId, portId = "transfer") => {
|
|
1955
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
1956
|
+
const cacheKey = getIbcCounterpartyChainIdCacheKey(channelId, portId);
|
|
1957
|
+
const cached = getFromLocalStorage(cacheKey);
|
|
1958
|
+
if (cached) {
|
|
1959
|
+
return JSON.parse(cached);
|
|
1960
|
+
}
|
|
1961
|
+
const result = {
|
|
1962
|
+
chainId: "",
|
|
1963
|
+
channelId: ""
|
|
1964
|
+
};
|
|
1965
|
+
try {
|
|
1966
|
+
const chRes = await fetch(getChannelIdUrl(channelId, portId));
|
|
1967
|
+
if (!chRes.ok) {
|
|
1968
|
+
console.error(`[counterpartyChainForChannel] channel fetch failed: ${chRes.status} ${chRes.statusText}`);
|
|
1969
|
+
return void 0;
|
|
1970
|
+
}
|
|
1971
|
+
const chJson = await chRes.json();
|
|
1972
|
+
const connectionId = (_b2 = (_a2 = chJson == null ? void 0 : chJson.channel) == null ? void 0 : _a2.connection_hops) == null ? void 0 : _b2[0];
|
|
1973
|
+
result.channelId = (_d = (_c = chJson == null ? void 0 : chJson.channel) == null ? void 0 : _c.counterparty) == null ? void 0 : _d.channel_id;
|
|
1974
|
+
if (!connectionId || !result.channelId) {
|
|
1975
|
+
console.error(`[counterpartyChainForChannel] no connection_hops for ${channelId}/${portId}`);
|
|
1976
|
+
return void 0;
|
|
1977
|
+
}
|
|
1978
|
+
const connRes = await fetch(getConnectionIdUrl(connectionId));
|
|
1979
|
+
if (!connRes.ok) {
|
|
1980
|
+
console.error(`[counterpartyChainForChannel] connection fetch failed: ${connRes.status} ${connRes.statusText}`);
|
|
1981
|
+
return void 0;
|
|
1982
|
+
}
|
|
1983
|
+
const connJson = await connRes.json();
|
|
1984
|
+
const clientId = (_e = connJson == null ? void 0 : connJson.connection) == null ? void 0 : _e.client_id;
|
|
1985
|
+
if (!clientId) {
|
|
1986
|
+
console.error(`[counterpartyChainForChannel] no client_id on ${connectionId}`);
|
|
1987
|
+
return void 0;
|
|
1988
|
+
}
|
|
1989
|
+
const csRes = await fetch(getClientStateUrl(clientId));
|
|
1990
|
+
if (!csRes.ok) {
|
|
1991
|
+
console.error(`[counterpartyChainForChannel] client_state fetch failed: ${csRes.status} ${csRes.statusText}`);
|
|
1992
|
+
return void 0;
|
|
1993
|
+
}
|
|
1994
|
+
const csJson = await csRes.json();
|
|
1995
|
+
const clientState = (_g = (_f = csJson == null ? void 0 : csJson.client_state) == null ? void 0 : _f.value) != null ? _g : csJson == null ? void 0 : csJson.client_state;
|
|
1996
|
+
const chainId = (_h = clientState == null ? void 0 : clientState.chain_id) != null ? _h : clientState == null ? void 0 : clientState.chainId;
|
|
1997
|
+
if (!chainId) {
|
|
1998
|
+
console.error(`[counterpartyChainForChannel] chain_id missing in client_state for ${clientId}`);
|
|
1999
|
+
return void 0;
|
|
2000
|
+
}
|
|
2001
|
+
result.chainId = chainId;
|
|
2002
|
+
setInLocalStorage(cacheKey, JSON.stringify(result), IBC_COUNTERPARTY_CACHE_TTL);
|
|
2003
|
+
return result;
|
|
2004
|
+
} catch (err) {
|
|
2005
|
+
console.error("[counterpartyChainForChannel] unexpected error:", err);
|
|
2006
|
+
return void 0;
|
|
2007
|
+
}
|
|
2008
|
+
};
|
|
2009
|
+
|
|
2010
|
+
// src/service/assets_factory.ts
|
|
2011
|
+
var ORIGIN_CHAIN_PLACEHOLDER = "Unknown chain";
|
|
2012
|
+
var getChainAssets = async () => {
|
|
2013
|
+
const [metadata, supply] = await Promise.all([getAllMetadataMap(), getAllSupply()]);
|
|
2014
|
+
const result = {
|
|
2015
|
+
assets: /* @__PURE__ */ new Map(),
|
|
2016
|
+
ibcData: /* @__PURE__ */ new Map()
|
|
2017
|
+
};
|
|
2018
|
+
if (!metadata || !supply) {
|
|
2019
|
+
return result;
|
|
2020
|
+
}
|
|
2021
|
+
const filtered = supply.filter((asset) => !EXCLUDED_ASSETS[asset.denom]);
|
|
2022
|
+
const lpAssets = [];
|
|
2023
|
+
for (const asset of filtered) {
|
|
2024
|
+
const baseAsset = createAsset(asset.denom, BigInt(asset.amount));
|
|
2025
|
+
if (isLpDenom(asset.denom)) {
|
|
2026
|
+
lpAssets.push(baseAsset);
|
|
2027
|
+
continue;
|
|
2028
|
+
}
|
|
2029
|
+
let finalAsset = await populateAssetFromChainRegistry(baseAsset);
|
|
2030
|
+
if (!finalAsset) {
|
|
2031
|
+
const metadataEntry = metadata[asset.denom];
|
|
2032
|
+
finalAsset = populateAssetFromBlockchainMetadata(baseAsset, metadataEntry);
|
|
2033
|
+
}
|
|
2034
|
+
result.assets.set(finalAsset.denom, finalAsset);
|
|
2035
|
+
if (isIbcDenom(finalAsset.denom) && finalAsset.IBCData && finalAsset.IBCData.chain.channelId !== "") {
|
|
2036
|
+
result.ibcData.set(finalAsset.IBCData.chain.channelId, finalAsset.IBCData);
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
for (const lpAsset of lpAssets) {
|
|
2040
|
+
const split = lpAsset.denom.split("_");
|
|
2041
|
+
if (split.length !== 3) {
|
|
2042
|
+
continue;
|
|
2043
|
+
}
|
|
2044
|
+
const baseAsset = result.assets.get(split[1]);
|
|
2045
|
+
const quoteAsset = result.assets.get(split[2]);
|
|
2046
|
+
if (!baseAsset || !quoteAsset) {
|
|
2047
|
+
result.assets.set(lpAsset.denom, lpAsset);
|
|
2048
|
+
continue;
|
|
2049
|
+
}
|
|
2050
|
+
lpAsset.name = `${baseAsset.ticker}/${quoteAsset.ticker} LP Shares`;
|
|
2051
|
+
lpAsset.ticker = `${baseAsset.ticker}/${quoteAsset.ticker} LP`;
|
|
2052
|
+
lpAsset.verified = true;
|
|
2053
|
+
lpAsset.decimals = LP_ASSETS_DECIMALS;
|
|
2054
|
+
result.assets.set(lpAsset.denom, lpAsset);
|
|
2055
|
+
}
|
|
2056
|
+
return result;
|
|
2057
|
+
};
|
|
2058
|
+
var populateIBCAsset = async (asset) => {
|
|
2059
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2060
|
+
const ibcList = getIBCAssetList();
|
|
2061
|
+
const ibcData2 = ibcList.find((item) => item.base === asset.denom);
|
|
2062
|
+
if (ibcData2 && ibcData2.traces && ibcData2.traces.length > 0) {
|
|
2063
|
+
const firstTrace = ibcData2.traces.find((t) => t.type === "ibc");
|
|
2064
|
+
if (firstTrace) {
|
|
2065
|
+
const ibcAssetChain = getChains().find((c) => c.chainName === firstTrace.counterparty.chain_name);
|
|
2066
|
+
if (ibcAssetChain) {
|
|
2067
|
+
asset.name = ibcData2.name;
|
|
2068
|
+
asset.ticker = ibcData2.symbol.toUpperCase();
|
|
2069
|
+
asset.decimals = (_a2 = (0, import_utils2.getExponentByDenomFromAsset)(ibcData2, ibcData2.display)) != null ? _a2 : 0;
|
|
2070
|
+
asset.logo = (_e = (_d = (_b2 = ibcData2.logoURIs) == null ? void 0 : _b2.svg) != null ? _d : (_c = ibcData2.logoURIs) == null ? void 0 : _c.png) != null ? _e : TOKEN_LOGO_PLACEHOLDER;
|
|
2071
|
+
asset.verified = true;
|
|
2072
|
+
asset.IBCData = {
|
|
2073
|
+
chain: {
|
|
2074
|
+
channelId: firstTrace.chain.channel_id
|
|
2075
|
+
},
|
|
2076
|
+
counterparty: {
|
|
2077
|
+
chainName: firstTrace.counterparty.chain_name,
|
|
2078
|
+
channelId: firstTrace.counterparty.channel_id,
|
|
2079
|
+
baseDenom: firstTrace.counterparty.base_denom,
|
|
2080
|
+
chainPrettyName: (_f = ibcAssetChain.prettyName) != null ? _f : ibcAssetChain.chainName
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2083
|
+
return asset;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
const ibcTrace = await getHashIBCTrace(asset.denom.replace("ibc/", ""));
|
|
2088
|
+
if (!ibcTrace) {
|
|
2089
|
+
return;
|
|
2090
|
+
}
|
|
2091
|
+
const splitPath = ibcTrace.path.split("/");
|
|
2092
|
+
if (splitPath.length < 2) {
|
|
2093
|
+
return;
|
|
2094
|
+
}
|
|
2095
|
+
asset.IBCData = {
|
|
2096
|
+
chain: {
|
|
2097
|
+
channelId: splitPath[1]
|
|
2098
|
+
},
|
|
2099
|
+
counterparty: {
|
|
2100
|
+
chainName: "",
|
|
2101
|
+
channelId: "",
|
|
2102
|
+
baseDenom: "",
|
|
2103
|
+
chainPrettyName: ORIGIN_CHAIN_PLACEHOLDER
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
const denomOnCounterparty = await denomOnFirstHopChainFromTrace(ibcTrace);
|
|
2107
|
+
if (denomOnCounterparty) {
|
|
2108
|
+
asset.IBCData.counterparty.baseDenom = denomOnCounterparty;
|
|
2109
|
+
}
|
|
2110
|
+
const counterPartyChain = await counterpartyChainForChannel(splitPath[1], splitPath[0]);
|
|
2111
|
+
if (counterPartyChain) {
|
|
2112
|
+
asset.IBCData.counterparty.channelId = counterPartyChain.channelId;
|
|
2113
|
+
const fullChain = getChainByChainId(counterPartyChain.chainId);
|
|
2114
|
+
if (fullChain) {
|
|
2115
|
+
asset.IBCData.counterparty.chainName = fullChain.chainName;
|
|
2116
|
+
asset.IBCData.counterparty.chainPrettyName = (_g = fullChain.prettyName) != null ? _g : fullChain.chainName;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
const registryAssetChain = getAssetLists().find((item) => {
|
|
2120
|
+
const a = item.assets.find((i) => i.base === ibcTrace.base_denom);
|
|
2121
|
+
return !!a;
|
|
2122
|
+
});
|
|
2123
|
+
if (registryAssetChain) {
|
|
2124
|
+
const registryAsset = registryAssetChain.assets.find((i) => i.base === ibcTrace.base_denom);
|
|
2125
|
+
asset.name = registryAsset.name;
|
|
2126
|
+
asset.ticker = registryAsset.symbol.toUpperCase();
|
|
2127
|
+
asset.decimals = (_h = (0, import_utils2.getExponentByDenomFromAsset)(registryAsset, registryAsset.display)) != null ? _h : 0;
|
|
2128
|
+
asset.logo = (_l = (_k = (_i = registryAsset.logoURIs) == null ? void 0 : _i.svg) != null ? _k : (_j = registryAsset.logoURIs) == null ? void 0 : _j.png) != null ? _l : TOKEN_LOGO_PLACEHOLDER;
|
|
2129
|
+
asset.verified = true;
|
|
2130
|
+
return asset;
|
|
2131
|
+
}
|
|
2132
|
+
const localAsset = await populateAssetFromBZEChainRegistryAssetList(asset);
|
|
2133
|
+
if (localAsset) {
|
|
2134
|
+
localAsset.verified = true;
|
|
2135
|
+
return localAsset;
|
|
2136
|
+
}
|
|
2137
|
+
if (!ibcTrace.base_denom.includes("/")) {
|
|
2138
|
+
let counterPartyDenom = ibcTrace.base_denom;
|
|
2139
|
+
if (counterPartyDenom.length > 10) {
|
|
2140
|
+
counterPartyDenom = truncateDenom(counterPartyDenom);
|
|
2141
|
+
}
|
|
2142
|
+
asset.name = counterPartyDenom;
|
|
2143
|
+
}
|
|
2144
|
+
asset.verified = false;
|
|
2145
|
+
asset.decimals = 0;
|
|
2146
|
+
return asset;
|
|
2147
|
+
};
|
|
2148
|
+
var populateAssetFromChainRegistry = async (asset) => {
|
|
2149
|
+
if (isIbcDenom(asset.denom)) {
|
|
2150
|
+
return populateIBCAsset(asset);
|
|
2151
|
+
}
|
|
2152
|
+
if (isNativeDenom(asset.denom) || isFactoryDenom(asset.denom)) {
|
|
2153
|
+
return populateAssetFromBZEChainRegistryAssetList(asset);
|
|
2154
|
+
}
|
|
2155
|
+
return void 0;
|
|
2156
|
+
};
|
|
2157
|
+
var populateAssetFromBZEChainRegistryAssetList = async (asset) => {
|
|
2158
|
+
var _a2, _b2, _c, _d, _e;
|
|
2159
|
+
const data = getAssetLists().find((item) => item.chainName.toLowerCase() === getChainName().toLowerCase());
|
|
2160
|
+
if (!data) {
|
|
2161
|
+
return void 0;
|
|
2162
|
+
}
|
|
2163
|
+
const assetData = data.assets.find((item) => item.base === asset.denom);
|
|
2164
|
+
if (!assetData) {
|
|
2165
|
+
return void 0;
|
|
2166
|
+
}
|
|
2167
|
+
asset.decimals = (_a2 = (0, import_utils2.getExponentByDenomFromAsset)(assetData, assetData.display)) != null ? _a2 : 0;
|
|
2168
|
+
asset.name = assetData.name;
|
|
2169
|
+
asset.ticker = assetData.display.toUpperCase();
|
|
2170
|
+
asset.logo = isNativeDenom(asset.denom) ? BZE_CIRCLE_LOGO : (_e = (_d = (_b2 = assetData.logoURIs) == null ? void 0 : _b2.svg) != null ? _d : (_c = assetData.logoURIs) == null ? void 0 : _c.png) != null ? _e : TOKEN_LOGO_PLACEHOLDER;
|
|
2171
|
+
return asset;
|
|
2172
|
+
};
|
|
2173
|
+
var populateAssetFromBlockchainMetadata = (asset, meta) => {
|
|
2174
|
+
if (!meta || meta.base !== asset.denom) {
|
|
2175
|
+
return asset;
|
|
2176
|
+
}
|
|
2177
|
+
if (meta.name.length > 0) {
|
|
2178
|
+
asset.name = meta.name;
|
|
2179
|
+
}
|
|
2180
|
+
if (meta.symbol.length > 0) {
|
|
2181
|
+
asset.ticker = meta.symbol.toUpperCase();
|
|
2182
|
+
}
|
|
2183
|
+
if (meta.denom_units.length === 0) {
|
|
2184
|
+
return asset;
|
|
2185
|
+
}
|
|
2186
|
+
meta.denom_units.map((unit) => {
|
|
2187
|
+
if (unit.denom === meta.display) {
|
|
2188
|
+
asset.decimals = unit.exponent;
|
|
2189
|
+
asset.ticker = unit.denom.toUpperCase();
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
return asset;
|
|
2193
|
+
};
|
|
2194
|
+
var createAsset = (denom, supply) => {
|
|
2195
|
+
var _a2, _b2;
|
|
2196
|
+
return {
|
|
2197
|
+
denom,
|
|
2198
|
+
type: getDenomType(denom),
|
|
2199
|
+
name: truncateDenom(denom),
|
|
2200
|
+
ticker: truncateDenom(denom),
|
|
2201
|
+
decimals: 0,
|
|
2202
|
+
logo: TOKEN_LOGO_PLACEHOLDER,
|
|
2203
|
+
stable: (_a2 = STABLE_COINS[denom]) != null ? _a2 : false,
|
|
2204
|
+
verified: (_b2 = VERIFIED_ASSETS[denom]) != null ? _b2 : false,
|
|
2205
|
+
supply
|
|
2206
|
+
};
|
|
2207
|
+
};
|
|
2208
|
+
var getAllMetadataMap = async () => {
|
|
2209
|
+
const allMetadata = await getAllSupplyMetadata();
|
|
2210
|
+
if (!allMetadata) {
|
|
2211
|
+
return {};
|
|
2212
|
+
}
|
|
2213
|
+
return allMetadata.reduce((acc, asset) => {
|
|
2214
|
+
acc[asset.base] = asset;
|
|
2215
|
+
return acc;
|
|
2216
|
+
}, {});
|
|
2217
|
+
};
|
|
2218
|
+
|
|
2219
|
+
// src/service/keplr.ts
|
|
2220
|
+
async function getKeplrMainnetChainInfo() {
|
|
2221
|
+
const localKey = "ci:keplr:mainnet";
|
|
2222
|
+
const cachedData = getFromLocalStorage(localKey);
|
|
2223
|
+
if (cachedData) {
|
|
2224
|
+
return JSON.parse(cachedData);
|
|
2225
|
+
}
|
|
2226
|
+
const url = "https://raw.githubusercontent.com/faneaatiku/keplr-chain-registry/main/cosmos/beezee.json";
|
|
2227
|
+
try {
|
|
2228
|
+
const response = await fetch(url);
|
|
2229
|
+
if (!response.ok) {
|
|
2230
|
+
console.error(`HTTP error when fetching mainnet keplr data. status: ${response.status}`);
|
|
2231
|
+
return MAINNET_CHAIN_INFO_FALLBACK;
|
|
2232
|
+
}
|
|
2233
|
+
const json = await response.json();
|
|
2234
|
+
setInLocalStorage(localKey, JSON.stringify(json), 60 * 60 * 24);
|
|
2235
|
+
return json;
|
|
2236
|
+
} catch (error) {
|
|
2237
|
+
console.error(`Error fetching mainnet keplr data from ${url}:`, error);
|
|
2238
|
+
return MAINNET_CHAIN_INFO_FALLBACK;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
async function getKeplrTestnetChainInfo() {
|
|
2242
|
+
const localKey = "ci:keplr:testnet";
|
|
2243
|
+
const cachedData = getFromLocalStorage(localKey);
|
|
2244
|
+
if (cachedData) {
|
|
2245
|
+
return JSON.parse(cachedData);
|
|
2246
|
+
}
|
|
2247
|
+
const url = "https://raw.githubusercontent.com/faneaatiku/keplr-chain-registry/refs/heads/patch-2/cosmos/bzetestnet.json";
|
|
2248
|
+
try {
|
|
2249
|
+
const response = await fetch(url);
|
|
2250
|
+
if (!response.ok) {
|
|
2251
|
+
console.error(`HTTP error when fetching testnet keplr data. status: ${response.status}`);
|
|
2252
|
+
return TESTNET_CHAIN_INFO_FALLBACK;
|
|
2253
|
+
}
|
|
2254
|
+
const json = await response.json();
|
|
2255
|
+
setInLocalStorage(localKey, JSON.stringify(json), 60 * 60 * 24);
|
|
2256
|
+
return json;
|
|
2257
|
+
} catch (error) {
|
|
2258
|
+
console.error(`Error fetching testnet keplr data from ${url}:`, error);
|
|
2259
|
+
return TESTNET_CHAIN_INFO_FALLBACK;
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
async function getKeplrChainInfo(chainId) {
|
|
2263
|
+
if (chainId !== "beezee") {
|
|
2264
|
+
return getKeplrTestnetChainInfo();
|
|
2265
|
+
}
|
|
2266
|
+
return getKeplrMainnetChainInfo();
|
|
2267
|
+
}
|
|
2268
|
+
async function keplrSuggestChain(chainId) {
|
|
2269
|
+
var _a2;
|
|
2270
|
+
return await ((_a2 = window.keplr) == null ? void 0 : _a2.experimentalSuggestChain(await getKeplrChainInfo(chainId)));
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
// src/query/bank.ts
|
|
2274
|
+
async function getAddressBalances(address) {
|
|
2275
|
+
try {
|
|
2276
|
+
const client = await getRestClient();
|
|
2277
|
+
const response = await client.cosmos.bank.v1beta1.spendableBalances({ address });
|
|
2278
|
+
return response.balances;
|
|
2279
|
+
} catch (e) {
|
|
2280
|
+
console.error("failed to get balances", e);
|
|
2281
|
+
return [];
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
async function getLockedBalances() {
|
|
2285
|
+
try {
|
|
2286
|
+
const lockerAddress = getLockerAddress();
|
|
2287
|
+
if (!lockerAddress) {
|
|
2288
|
+
console.warn("Locker address not configured");
|
|
2289
|
+
return [];
|
|
2290
|
+
}
|
|
2291
|
+
return await getAddressBalances(lockerAddress);
|
|
2292
|
+
} catch (e) {
|
|
2293
|
+
console.error("failed to get locked balances", e);
|
|
2294
|
+
return [];
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
// src/query/epoch.ts
|
|
2299
|
+
var EPOCH_HOUR = "hour";
|
|
2300
|
+
var EPOCH_DAY = "day";
|
|
2301
|
+
var EPOCH_WEEK = "week";
|
|
2302
|
+
var EPOCHS_INFO_CACHE_KEY = "epochs:info";
|
|
2303
|
+
var EPOCHS_INFO_CACHE_TTL = 60 * 60;
|
|
2304
|
+
async function getEpochsInfo() {
|
|
2305
|
+
try {
|
|
2306
|
+
const cachedData = getFromLocalStorage(EPOCHS_INFO_CACHE_KEY);
|
|
2307
|
+
let shouldFetchFromEndpoint = false;
|
|
2308
|
+
if (cachedData !== null) {
|
|
2309
|
+
const cached = JSON.parse(cachedData);
|
|
2310
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
2311
|
+
for (const epoch of cached.epochs) {
|
|
2312
|
+
if (epoch.current_epoch_start_time) {
|
|
2313
|
+
const startTime = new Date(epoch.current_epoch_start_time).getTime();
|
|
2314
|
+
const duration = getEpochDurationByIdentifier(epoch.identifier);
|
|
2315
|
+
const epochEndTime = startTime + duration - 15 * 1e3;
|
|
2316
|
+
if (now >= epochEndTime) {
|
|
2317
|
+
shouldFetchFromEndpoint = true;
|
|
2318
|
+
break;
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
if (!shouldFetchFromEndpoint) {
|
|
2323
|
+
return cached;
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
const client = await getRestClient();
|
|
2327
|
+
const response = await client.bze.epochs.epochInfos();
|
|
2328
|
+
setInLocalStorage(EPOCHS_INFO_CACHE_KEY, JSON.stringify(response), EPOCHS_INFO_CACHE_TTL);
|
|
2329
|
+
return response;
|
|
2330
|
+
} catch (e) {
|
|
2331
|
+
console.error(e);
|
|
2332
|
+
return { epochs: [] };
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
async function getCurrentEpoch(identifier) {
|
|
2336
|
+
const all = await getEpochsInfo();
|
|
2337
|
+
return all.epochs.find((item) => item.identifier === identifier);
|
|
2338
|
+
}
|
|
2339
|
+
async function getHourEpochInfo() {
|
|
2340
|
+
return getCurrentEpoch(EPOCH_HOUR);
|
|
2341
|
+
}
|
|
2342
|
+
async function getWeekEpochInfo() {
|
|
2343
|
+
return getCurrentEpoch(EPOCH_WEEK);
|
|
2344
|
+
}
|
|
2345
|
+
async function getCurrentWeekEpochEndTime() {
|
|
2346
|
+
return getPeriodicEpochEndTime(EPOCH_WEEK);
|
|
2347
|
+
}
|
|
2348
|
+
async function getPeriodicWeekEpochEndTime(modWeek = 1) {
|
|
2349
|
+
return getPeriodicEpochEndTime(EPOCH_WEEK, modWeek);
|
|
2350
|
+
}
|
|
2351
|
+
async function getPeriodicEpochEndTime(identifier, mod = 1) {
|
|
2352
|
+
const epoch = await getCurrentEpoch(identifier);
|
|
2353
|
+
if (!epoch || !epoch.current_epoch_start_time) {
|
|
2354
|
+
return void 0;
|
|
2355
|
+
}
|
|
2356
|
+
const current = toBigNumber(epoch.current_epoch);
|
|
2357
|
+
let remainingEpochs = mod - current.toNumber() % mod;
|
|
2358
|
+
if (remainingEpochs === mod) {
|
|
2359
|
+
remainingEpochs = 0;
|
|
2360
|
+
}
|
|
2361
|
+
const startAt = new Date(epoch.current_epoch_start_time);
|
|
2362
|
+
const duration = getEpochDurationByIdentifier(identifier);
|
|
2363
|
+
startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
|
|
2364
|
+
return startAt;
|
|
2365
|
+
}
|
|
2366
|
+
function getEpochDurationByIdentifier(identifier) {
|
|
2367
|
+
const hourMs = 60 * 60 * 1e3;
|
|
2368
|
+
switch (identifier) {
|
|
2369
|
+
case EPOCH_HOUR:
|
|
2370
|
+
return hourMs;
|
|
2371
|
+
case EPOCH_DAY:
|
|
2372
|
+
return hourMs * 24;
|
|
2373
|
+
case EPOCH_WEEK:
|
|
2374
|
+
return hourMs * 24 * 7;
|
|
2375
|
+
default:
|
|
2376
|
+
return hourMs;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
// src/query/factory.ts
|
|
2381
|
+
async function getFactoryDenomAdminAddress(denom) {
|
|
2382
|
+
var _a2, _b2;
|
|
2383
|
+
try {
|
|
2384
|
+
const client = await getRestClient();
|
|
2385
|
+
const res = await client.bze.tokenfactory.denomAuthority({ denom });
|
|
2386
|
+
return (_b2 = (_a2 = res.denomAuthority) == null ? void 0 : _a2.admin) != null ? _b2 : "";
|
|
2387
|
+
} catch (e) {
|
|
2388
|
+
console.error(e);
|
|
2389
|
+
return "";
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
// src/query/liquidity_pools.ts
|
|
2394
|
+
var import_query2 = require("@bze/bzejs/bze/tradebin/query");
|
|
2395
|
+
var { fromPartial: AllLpsRequest } = import_query2.QueryAllLiquidityPoolsRequest;
|
|
2396
|
+
var { fromPartial: LpRequest } = import_query2.QueryLiquidityPoolRequest;
|
|
2397
|
+
var DEFAULT_LIMIT3 = 1e3;
|
|
2398
|
+
var getLiquidityPools = async () => {
|
|
2399
|
+
try {
|
|
2400
|
+
const client = await getRestClient();
|
|
2401
|
+
const resp = await client.bze.tradebin.allLiquidityPools(
|
|
2402
|
+
AllLpsRequest(
|
|
2403
|
+
{ pagination: getPageRequestWithLimit(DEFAULT_LIMIT3) }
|
|
2404
|
+
)
|
|
2405
|
+
);
|
|
2406
|
+
return resp.list;
|
|
2407
|
+
} catch (error) {
|
|
2408
|
+
console.error("failed to get markets: ", error);
|
|
2409
|
+
}
|
|
2410
|
+
return [];
|
|
2411
|
+
};
|
|
2412
|
+
var getLiquidityPool = async (poolId) => {
|
|
2413
|
+
try {
|
|
2414
|
+
const client = await getRestClient();
|
|
2415
|
+
const resp = await client.bze.tradebin.liquidityPool(LpRequest({
|
|
2416
|
+
poolId
|
|
2417
|
+
}));
|
|
2418
|
+
return resp.pool;
|
|
2419
|
+
} catch (error) {
|
|
2420
|
+
console.error("failed to get markets: ", error);
|
|
2421
|
+
}
|
|
2422
|
+
return void 0;
|
|
2423
|
+
};
|
|
2424
|
+
|
|
2425
|
+
// src/query/markets.ts
|
|
2426
|
+
var import_query3 = require("@bze/bzejs/bze/tradebin/query");
|
|
2427
|
+
var import_pagination3 = require("@bze/bzejs/cosmos/base/query/v1beta1/pagination");
|
|
2428
|
+
var { fromPartial: AllMarketsRequest } = import_query3.QueryAllMarketsRequest;
|
|
2429
|
+
var { fromPartial: QueryMarketAggregatedOrdersRequestFromPartyal } = import_query3.QueryMarketAggregatedOrdersRequest;
|
|
2430
|
+
var { fromPartial: QueryMarketHistoryRequestFromPartial } = import_query3.QueryMarketHistoryRequest;
|
|
2431
|
+
var { fromPartial: QueryUserMarketOrdersRequestFromPartial } = import_query3.QueryUserMarketOrdersRequest;
|
|
2432
|
+
var { fromPartial: QueryMarketOrderRequestFromPartial } = import_query3.QueryMarketOrderRequest;
|
|
2433
|
+
var DEFAULT_LIMIT4 = 1e3;
|
|
2434
|
+
var getMarkets = async () => {
|
|
2435
|
+
try {
|
|
2436
|
+
const client = await getRestClient();
|
|
2437
|
+
const resp = await client.bze.tradebin.allMarkets(
|
|
2438
|
+
AllMarketsRequest(
|
|
2439
|
+
{ pagination: getPageRequestWithLimit(DEFAULT_LIMIT4) }
|
|
2440
|
+
)
|
|
2441
|
+
);
|
|
2442
|
+
return resp.market;
|
|
2443
|
+
} catch (error) {
|
|
2444
|
+
console.error("failed to get markets: ", error);
|
|
2445
|
+
}
|
|
2446
|
+
return [];
|
|
2447
|
+
};
|
|
2448
|
+
async function getMarketBuyOrders(marketId) {
|
|
2449
|
+
return getMarketOrders(marketId, ORDER_TYPE_BUY);
|
|
2450
|
+
}
|
|
2451
|
+
async function getMarketSellOrders(marketId) {
|
|
2452
|
+
return getMarketOrders(marketId, ORDER_TYPE_SELL);
|
|
2453
|
+
}
|
|
2454
|
+
async function getMarketOrders(marketId, orderType) {
|
|
2455
|
+
try {
|
|
2456
|
+
const reversed = orderType === ORDER_TYPE_BUY;
|
|
2457
|
+
const client = await getRestClient();
|
|
2458
|
+
return client.bze.tradebin.marketAggregatedOrders(QueryMarketAggregatedOrdersRequestFromPartyal({
|
|
2459
|
+
market: marketId,
|
|
2460
|
+
orderType,
|
|
2461
|
+
pagination: import_pagination3.PageRequest.fromPartial({ limit: BigInt(15), reverse: reversed })
|
|
2462
|
+
}));
|
|
2463
|
+
} catch (e) {
|
|
2464
|
+
console.error(e);
|
|
2465
|
+
return { list: [] };
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
async function getMarketHistory(marketId) {
|
|
2469
|
+
try {
|
|
2470
|
+
const client = await getRestClient();
|
|
2471
|
+
return client.bze.tradebin.marketHistory(QueryMarketHistoryRequestFromPartial({
|
|
2472
|
+
market: marketId,
|
|
2473
|
+
pagination: import_pagination3.PageRequest.fromPartial({ limit: BigInt(50), reverse: true })
|
|
2474
|
+
}));
|
|
2475
|
+
} catch (e) {
|
|
2476
|
+
console.error(e);
|
|
2477
|
+
return { list: [] };
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
async function getAddressMarketOrders(marketId, address) {
|
|
2481
|
+
try {
|
|
2482
|
+
const client = await getRestClient();
|
|
2483
|
+
return client.bze.tradebin.userMarketOrders(QueryUserMarketOrdersRequestFromPartial({
|
|
2484
|
+
market: marketId,
|
|
2485
|
+
address,
|
|
2486
|
+
pagination: import_pagination3.PageRequest.fromPartial({ limit: BigInt(100), reverse: true })
|
|
2487
|
+
}));
|
|
2488
|
+
} catch (e) {
|
|
2489
|
+
console.error(e);
|
|
2490
|
+
return { list: [] };
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
async function getAddressFullMarketOrders(marketId, address) {
|
|
2494
|
+
const addressOrders = await getAddressMarketOrders(marketId, address);
|
|
2495
|
+
if (addressOrders.list.length === 0) {
|
|
2496
|
+
return [];
|
|
2497
|
+
}
|
|
2498
|
+
const promises = [];
|
|
2499
|
+
for (const reference of addressOrders.list) {
|
|
2500
|
+
promises.push(getMarketOrder(reference.market_id, reference.order_type, reference.id));
|
|
2501
|
+
}
|
|
2502
|
+
const orders = await Promise.all(promises);
|
|
2503
|
+
return orders.filter((item) => item !== void 0).map((resp) => resp.order);
|
|
2504
|
+
}
|
|
2505
|
+
async function getMarketOrder(marketId, orderType, orderId) {
|
|
2506
|
+
try {
|
|
2507
|
+
const client = await getRestClient();
|
|
2508
|
+
return client.bze.tradebin.marketOrder(QueryMarketOrderRequestFromPartial({
|
|
2509
|
+
market: marketId,
|
|
2510
|
+
orderType,
|
|
2511
|
+
orderId
|
|
2512
|
+
}));
|
|
2513
|
+
} catch (e) {
|
|
2514
|
+
console.error(e);
|
|
2515
|
+
return void 0;
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
// src/query/prices.ts
|
|
2520
|
+
var PRICE_PATH = "/api/prices";
|
|
2521
|
+
var usdPriceDenom = "usd";
|
|
2522
|
+
var usdPriceCacheKey = "price:usd";
|
|
2523
|
+
var priceCacheTtl = 5 * 60;
|
|
2524
|
+
var getPriceUrl = () => {
|
|
2525
|
+
return `${getAggregatorHost()}${PRICE_PATH}`;
|
|
2526
|
+
};
|
|
2527
|
+
var getAssetPriceCacheKey = (asset) => {
|
|
2528
|
+
return `${usdPriceCacheKey}:${asset.toLowerCase()};`;
|
|
2529
|
+
};
|
|
2530
|
+
var fetchAssetUsdPrice = async (asset) => {
|
|
2531
|
+
const cacheKey = getAssetPriceCacheKey(asset);
|
|
2532
|
+
const cached = getFromLocalStorage(cacheKey);
|
|
2533
|
+
if (cached) {
|
|
2534
|
+
return JSON.parse(cached);
|
|
2535
|
+
}
|
|
2536
|
+
try {
|
|
2537
|
+
const resp = await fetch(getPriceUrl());
|
|
2538
|
+
if (resp.status !== 200) {
|
|
2539
|
+
return void 0;
|
|
2540
|
+
}
|
|
2541
|
+
const decodedResp = await resp.json();
|
|
2542
|
+
const result = decodedResp.find((item) => item.denom.toLowerCase() === asset.toLowerCase() && item.price_denom.toLowerCase() === usdPriceDenom);
|
|
2543
|
+
setInLocalStorage(cacheKey, JSON.stringify(result), priceCacheTtl);
|
|
2544
|
+
return result;
|
|
2545
|
+
} catch (e) {
|
|
2546
|
+
console.log("error on getAssetUsdPrice: ", e);
|
|
2547
|
+
return void 0;
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
2550
|
+
var getBZEUSDPrice = async () => {
|
|
2551
|
+
const usdPrice = await fetchAssetUsdPrice("bzedge");
|
|
2552
|
+
if (!usdPrice) {
|
|
2553
|
+
return 0;
|
|
2554
|
+
}
|
|
2555
|
+
return usdPrice.price;
|
|
2556
|
+
};
|
|
2557
|
+
|
|
2558
|
+
// src/query/rewards.ts
|
|
2559
|
+
var import_bzejs3 = require("@bze/bzejs");
|
|
2560
|
+
var import_pagination4 = require("@bze/bzejs/cosmos/base/query/v1beta1/pagination");
|
|
2561
|
+
var import_bignumber6 = __toESM(require("bignumber.js"));
|
|
2562
|
+
var { fromPartial: QueryAllStakingRewardRequestFromPartial } = import_bzejs3.bze.rewards.QueryAllStakingRewardsRequest;
|
|
2563
|
+
var { fromPartial: QueryGetStakingRewardParticipantRequestFromPartial } = import_bzejs3.bze.rewards.QueryStakingRewardParticipantRequest;
|
|
2564
|
+
var { fromPartial: QueryAllPendingUnlockParticipantRequestFromPartial } = import_bzejs3.bze.rewards.QueryAllPendingUnlockParticipantsRequest;
|
|
2565
|
+
async function getStakingRewards(reverse = true) {
|
|
2566
|
+
try {
|
|
2567
|
+
const client = await getRestClient();
|
|
2568
|
+
return await client.bze.rewards.allStakingRewards(QueryAllStakingRewardRequestFromPartial({
|
|
2569
|
+
pagination: import_pagination4.PageRequest.fromPartial({
|
|
2570
|
+
reverse,
|
|
2571
|
+
limit: BigInt(1e3)
|
|
2572
|
+
})
|
|
2573
|
+
}));
|
|
2574
|
+
} catch (e) {
|
|
2575
|
+
console.error(e);
|
|
2576
|
+
return { list: [] };
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
async function getAddressPendingUnlock(address) {
|
|
2580
|
+
const all = await getPendingUnlockParticipants();
|
|
2581
|
+
if (!all || all.list.length === 0) {
|
|
2582
|
+
return [];
|
|
2583
|
+
}
|
|
2584
|
+
return all.list.filter((item) => item.address === address);
|
|
2585
|
+
}
|
|
2586
|
+
async function getPendingUnlockParticipants() {
|
|
2587
|
+
try {
|
|
2588
|
+
const client = await getRestClient();
|
|
2589
|
+
return client.bze.rewards.allPendingUnlockParticipants(QueryAllPendingUnlockParticipantRequestFromPartial({
|
|
2590
|
+
pagination: import_pagination4.PageRequest.fromPartial({ limit: BigInt(1e3) })
|
|
2591
|
+
}));
|
|
2592
|
+
} catch (e) {
|
|
2593
|
+
console.error(e);
|
|
2594
|
+
return { list: [] };
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
async function getStakingRewardParticipantByAddress(address) {
|
|
2598
|
+
try {
|
|
2599
|
+
const client = await getRestClient();
|
|
2600
|
+
return client.bze.rewards.stakingRewardParticipant(QueryGetStakingRewardParticipantRequestFromPartial({
|
|
2601
|
+
address,
|
|
2602
|
+
pagination: import_pagination4.PageRequest.fromPartial({ limit: BigInt(500) })
|
|
2603
|
+
}));
|
|
2604
|
+
} catch (e) {
|
|
2605
|
+
console.error(e);
|
|
2606
|
+
return { list: [] };
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
async function getAddressStakingRewards(address) {
|
|
2610
|
+
const result = {
|
|
2611
|
+
address,
|
|
2612
|
+
active: /* @__PURE__ */ new Map(),
|
|
2613
|
+
unlocking: /* @__PURE__ */ new Map()
|
|
2614
|
+
};
|
|
2615
|
+
if (address === "") {
|
|
2616
|
+
return result;
|
|
2617
|
+
}
|
|
2618
|
+
try {
|
|
2619
|
+
const [participantRewards, pending] = await Promise.all([getStakingRewardParticipantByAddress(address), getAddressPendingUnlock(address)]);
|
|
2620
|
+
[result.active, result.unlocking] = await Promise.all([mapParticipantRewards(participantRewards.list), mapPendingUnlock(pending)]);
|
|
2621
|
+
return result;
|
|
2622
|
+
} catch (e) {
|
|
2623
|
+
console.error(e);
|
|
2624
|
+
return result;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
async function mapParticipantRewards(participantRewards) {
|
|
2628
|
+
const result = /* @__PURE__ */ new Map();
|
|
2629
|
+
for (let i = 0; i < participantRewards.length; i++) {
|
|
2630
|
+
result.set(participantRewards[i].reward_id, participantRewards[i]);
|
|
2631
|
+
}
|
|
2632
|
+
return result;
|
|
2633
|
+
}
|
|
2634
|
+
async function mapPendingUnlock(pending) {
|
|
2635
|
+
var _a2;
|
|
2636
|
+
const result = /* @__PURE__ */ new Map();
|
|
2637
|
+
for (let i = 0; i < pending.length; i++) {
|
|
2638
|
+
const splitIndex = pending[i].index.split("/");
|
|
2639
|
+
if (splitIndex.length !== 3) {
|
|
2640
|
+
console.error("invalid pending unlock index", pending[i].index);
|
|
2641
|
+
continue;
|
|
2642
|
+
}
|
|
2643
|
+
const item = __spreadProps(__spreadValues({}, pending[i]), {
|
|
2644
|
+
rewardId: splitIndex[1],
|
|
2645
|
+
unlockEpoch: new import_bignumber6.default(splitIndex[0])
|
|
2646
|
+
});
|
|
2647
|
+
const allItems = (_a2 = result.get(item.rewardId)) != null ? _a2 : [];
|
|
2648
|
+
allItems.push(item);
|
|
2649
|
+
result.set(item.rewardId, allItems);
|
|
2650
|
+
}
|
|
2651
|
+
return result;
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
// src/query/staking.ts
|
|
2655
|
+
var import_pagination5 = require("@bze/bzejs/cosmos/base/query/v1beta1/pagination");
|
|
2656
|
+
var import_bignumber7 = __toESM(require("bignumber.js"));
|
|
2657
|
+
var getAddressDelegations = async (address) => {
|
|
2658
|
+
try {
|
|
2659
|
+
const client = await getRestClient();
|
|
2660
|
+
const response = await client.cosmos.staking.v1beta1.delegatorDelegations({
|
|
2661
|
+
delegatorAddr: address,
|
|
2662
|
+
pagination: import_pagination5.PageRequest.fromPartial({
|
|
2663
|
+
limit: BigInt(1e3)
|
|
2664
|
+
})
|
|
2665
|
+
});
|
|
2666
|
+
return response.delegation_responses;
|
|
2667
|
+
} catch (e) {
|
|
2668
|
+
console.error("failed to get address delegations", e);
|
|
2669
|
+
return [];
|
|
2670
|
+
}
|
|
2671
|
+
};
|
|
2672
|
+
var getAddressNativeDelegatedBalance = async (address) => {
|
|
2673
|
+
const delegations = await getAddressDelegations(address);
|
|
2674
|
+
const total = delegations.reduce((acc, delegation) => {
|
|
2675
|
+
if (!delegation.balance) return acc;
|
|
2676
|
+
if (delegation.balance.denom !== getChainNativeAssetDenom()) return acc;
|
|
2677
|
+
return acc.plus(delegation.balance.amount);
|
|
2678
|
+
}, new import_bignumber7.default(0));
|
|
2679
|
+
return {
|
|
2680
|
+
denom: getChainNativeAssetDenom(),
|
|
2681
|
+
amount: total
|
|
2682
|
+
};
|
|
2683
|
+
};
|
|
2684
|
+
var getAddressUnbondingDelegations = async (address) => {
|
|
2685
|
+
try {
|
|
2686
|
+
const client = await getRestClient();
|
|
2687
|
+
const resp = await client.cosmos.staking.v1beta1.delegatorUnbondingDelegations({
|
|
2688
|
+
delegatorAddr: address,
|
|
2689
|
+
pagination: import_pagination5.PageRequest.fromPartial({
|
|
2690
|
+
limit: BigInt(1e3)
|
|
2691
|
+
})
|
|
2692
|
+
});
|
|
2693
|
+
return resp.unbonding_responses;
|
|
2694
|
+
} catch (e) {
|
|
2695
|
+
console.error("failed to get address delegations", e);
|
|
2696
|
+
return [];
|
|
2697
|
+
}
|
|
2698
|
+
};
|
|
2699
|
+
var getAddressUnbondingDelegationsSummary = async (address) => {
|
|
2700
|
+
const unbondingDelegations = await getAddressUnbondingDelegations(address);
|
|
2701
|
+
let totalAmount = new import_bignumber7.default(0);
|
|
2702
|
+
let firstUnlockDate = void 0;
|
|
2703
|
+
let firstUnlock = void 0;
|
|
2704
|
+
unbondingDelegations.map((delegation) => {
|
|
2705
|
+
delegation.entries.forEach((entry) => {
|
|
2706
|
+
totalAmount = totalAmount.plus(entry.balance);
|
|
2707
|
+
const entryDate = new Date(entry.completion_time);
|
|
2708
|
+
if (!firstUnlockDate || entryDate < firstUnlockDate) {
|
|
2709
|
+
firstUnlockDate = entryDate;
|
|
2710
|
+
firstUnlock = {
|
|
2711
|
+
amount: new import_bignumber7.default(entry.balance),
|
|
2712
|
+
denom: getChainNativeAssetDenom()
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2715
|
+
});
|
|
2716
|
+
});
|
|
2717
|
+
return {
|
|
2718
|
+
total: {
|
|
2719
|
+
amount: totalAmount,
|
|
2720
|
+
denom: getChainNativeAssetDenom()
|
|
2721
|
+
},
|
|
2722
|
+
firstUnlock: {
|
|
2723
|
+
amount: firstUnlock,
|
|
2724
|
+
unlockTime: firstUnlockDate
|
|
2725
|
+
}
|
|
2726
|
+
};
|
|
2727
|
+
};
|
|
2728
|
+
var getAddressRewards = async (address) => {
|
|
2729
|
+
try {
|
|
2730
|
+
const client = await getRestClient();
|
|
2731
|
+
return await client.cosmos.distribution.v1beta1.delegationTotalRewards({ delegatorAddress: address });
|
|
2732
|
+
} catch (e) {
|
|
2733
|
+
console.error("failed to get address rewards", e);
|
|
2734
|
+
return {
|
|
2735
|
+
rewards: [],
|
|
2736
|
+
total: []
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
var getAddressNativeTotalRewards = async (address) => {
|
|
2741
|
+
const rewards = await getAddressRewards(address);
|
|
2742
|
+
const total = rewards.total.find((r) => r.denom === getChainNativeAssetDenom());
|
|
2743
|
+
if (!total) {
|
|
2744
|
+
return {
|
|
2745
|
+
total: {
|
|
2746
|
+
denom: getChainNativeAssetDenom(),
|
|
2747
|
+
amount: new import_bignumber7.default(0)
|
|
2748
|
+
},
|
|
2749
|
+
validators: []
|
|
2750
|
+
};
|
|
2751
|
+
}
|
|
2752
|
+
const validators = [];
|
|
2753
|
+
rewards.rewards.map((r) => {
|
|
2754
|
+
var _a2, _b2;
|
|
2755
|
+
const rewards2 = new import_bignumber7.default((_b2 = (_a2 = r.reward.find((r2) => r2.denom === getChainNativeAssetDenom())) == null ? void 0 : _a2.amount) != null ? _b2 : "0").integerValue();
|
|
2756
|
+
if (!rewards2.gt(0)) {
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
validators.push(r.validator_address);
|
|
2760
|
+
});
|
|
2761
|
+
return {
|
|
2762
|
+
total: {
|
|
2763
|
+
denom: getChainNativeAssetDenom(),
|
|
2764
|
+
amount: new import_bignumber7.default(total.amount).integerValue()
|
|
2765
|
+
},
|
|
2766
|
+
validators
|
|
2767
|
+
};
|
|
2768
|
+
};
|
|
2769
|
+
var getAnnualProvisions = async () => {
|
|
2770
|
+
try {
|
|
2771
|
+
const client = await getRestClient();
|
|
2772
|
+
const resp = await client.cosmos.mint.v1beta1.annualProvisions();
|
|
2773
|
+
return new import_bignumber7.default(resp.annual_provisions).integerValue();
|
|
2774
|
+
} catch (e) {
|
|
2775
|
+
console.error("failed to get annual provisions", e);
|
|
2776
|
+
return new import_bignumber7.default(0);
|
|
2777
|
+
}
|
|
2778
|
+
};
|
|
2779
|
+
var getDistributionParams = async () => {
|
|
2780
|
+
try {
|
|
2781
|
+
const client = await getRestClient();
|
|
2782
|
+
const resp = await client.cosmos.distribution.v1beta1.params();
|
|
2783
|
+
return resp.params;
|
|
2784
|
+
} catch (e) {
|
|
2785
|
+
console.error("failed to get distribution params", e);
|
|
2786
|
+
return {
|
|
2787
|
+
community_tax: "0.05",
|
|
2788
|
+
base_proposer_reward: "0.1",
|
|
2789
|
+
bonus_proposer_reward: "0.2",
|
|
2790
|
+
withdraw_addr_enabled: true
|
|
2791
|
+
};
|
|
2792
|
+
}
|
|
2793
|
+
};
|
|
2794
|
+
var getStakingParams = async () => {
|
|
2795
|
+
try {
|
|
2796
|
+
const client = await getRestClient();
|
|
2797
|
+
const resp = await client.cosmos.staking.v1beta1.params();
|
|
2798
|
+
return resp.params;
|
|
2799
|
+
} catch (e) {
|
|
2800
|
+
console.error("failed to get distribution params", e);
|
|
2801
|
+
return {
|
|
2802
|
+
unbonding_time: "1814400s",
|
|
2803
|
+
max_validators: 100,
|
|
2804
|
+
max_entries: 7,
|
|
2805
|
+
historical_entries: 0,
|
|
2806
|
+
bond_denom: "ubze"
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
};
|
|
2810
|
+
var getStakingPool = async () => {
|
|
2811
|
+
try {
|
|
2812
|
+
const client = await getRestClient();
|
|
2813
|
+
const resp = await client.cosmos.staking.v1beta1.pool();
|
|
2814
|
+
return resp.pool;
|
|
2815
|
+
} catch (e) {
|
|
2816
|
+
console.error("failed to get staking pool", e);
|
|
2817
|
+
return {
|
|
2818
|
+
not_bonded_tokens: "0",
|
|
2819
|
+
bonded_tokens: "0"
|
|
2820
|
+
};
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2823
|
+
|
|
2824
|
+
// src/query/aggregator.ts
|
|
2825
|
+
var getAllTickersUrl = () => {
|
|
2826
|
+
return `${getAggregatorHost()}/api/dex/tickers`;
|
|
2827
|
+
};
|
|
2828
|
+
var getHistoryUrl = () => {
|
|
2829
|
+
return `${getAggregatorHost()}/api/dex/history`;
|
|
2830
|
+
};
|
|
2831
|
+
async function getAllTickers() {
|
|
2832
|
+
try {
|
|
2833
|
+
const resp = await fetch(getAllTickersUrl());
|
|
2834
|
+
if (resp.status !== 200) {
|
|
2835
|
+
console.error("failed to fetch tickers. status: ", resp.status);
|
|
2836
|
+
return [];
|
|
2837
|
+
}
|
|
2838
|
+
return await resp.json();
|
|
2839
|
+
} catch (e) {
|
|
2840
|
+
console.error("[AGG] failed to fetch tickers", e);
|
|
2841
|
+
return [];
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
async function getMarketOrdersHistory(marketId, limit = 1) {
|
|
2845
|
+
try {
|
|
2846
|
+
const url = `${getHistoryUrl()}?market_id=${marketId}&limit=${limit}`;
|
|
2847
|
+
const resp = await fetch(url);
|
|
2848
|
+
if (resp.status !== 200) {
|
|
2849
|
+
return [];
|
|
2850
|
+
}
|
|
2851
|
+
return await resp.json();
|
|
2852
|
+
} catch (e) {
|
|
2853
|
+
console.error("[AGG] failed to fetch market orders", e);
|
|
2854
|
+
return [];
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
async function getAddressHistory(address, market) {
|
|
2858
|
+
try {
|
|
2859
|
+
const url = `${getHistoryUrl()}?address=${address}&market_id=${market}&limit=100`;
|
|
2860
|
+
const resp = await fetch(url);
|
|
2861
|
+
if (resp.status !== 200) {
|
|
2862
|
+
return [];
|
|
2863
|
+
}
|
|
2864
|
+
return await resp.json();
|
|
2865
|
+
} catch (e) {
|
|
2866
|
+
console.error("failed to fetch address orders", e);
|
|
2867
|
+
return [];
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
async function getTradingViewIntervals(market, minutes, limit) {
|
|
2871
|
+
try {
|
|
2872
|
+
const url = `${getAggregatorHost()}/api/dex/intervals?market_id=${market}&minutes=${minutes}&limit=${limit}&format=tv`;
|
|
2873
|
+
const resp = await fetch(url);
|
|
2874
|
+
if (resp.status !== 200) {
|
|
2875
|
+
return [];
|
|
2876
|
+
}
|
|
2877
|
+
const jsonResponse = await resp.json();
|
|
2878
|
+
if (!jsonResponse) {
|
|
2879
|
+
return [];
|
|
2880
|
+
}
|
|
2881
|
+
return jsonResponse;
|
|
2882
|
+
} catch (e) {
|
|
2883
|
+
console.error("failed to fetch trading view intervals", e);
|
|
2884
|
+
return [];
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
async function getAddressSwapHistory(address) {
|
|
2888
|
+
try {
|
|
2889
|
+
const url = `${getAggregatorHost()}/api/dex/swaps?address=${address}`;
|
|
2890
|
+
const resp = await fetch(url);
|
|
2891
|
+
if (resp.status !== 200) {
|
|
2892
|
+
console.error("failed to fetch swap history. status: ", resp.status);
|
|
2893
|
+
return [];
|
|
2894
|
+
}
|
|
2895
|
+
return await resp.json();
|
|
2896
|
+
} catch (e) {
|
|
2897
|
+
console.error("[AGG] failed to fetch swap history", e);
|
|
2898
|
+
return [];
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
// src/contexts/assets_context.ts
|
|
2903
|
+
var import_react = require("react");
|
|
2904
|
+
var AssetsContext = (0, import_react.createContext)(void 0);
|
|
2905
|
+
|
|
2906
|
+
// src/hooks/useAssets.ts
|
|
2907
|
+
var import_react2 = require("react");
|
|
2908
|
+
function useAssetsContext() {
|
|
2909
|
+
const context = (0, import_react2.useContext)(AssetsContext);
|
|
2910
|
+
if (context === void 0) {
|
|
2911
|
+
throw new Error("useAssets must be used within an AssetsProvider");
|
|
2912
|
+
}
|
|
2913
|
+
return context;
|
|
2914
|
+
}
|
|
2915
|
+
function useAssets() {
|
|
2916
|
+
const { assetsMap, isLoading } = useAssetsContext();
|
|
2917
|
+
const nativeAsset = (0, import_react2.useMemo)(
|
|
2918
|
+
() => assetsMap.get(getChainNativeAssetDenom()),
|
|
2919
|
+
[assetsMap]
|
|
2920
|
+
);
|
|
2921
|
+
const assets = (0, import_react2.useMemo)(
|
|
2922
|
+
() => Array.from(assetsMap.values()),
|
|
2923
|
+
[assetsMap]
|
|
2924
|
+
);
|
|
2925
|
+
const isVerifiedAsset = (0, import_react2.useCallback)((denom) => {
|
|
2926
|
+
const asset = assetsMap.get(denom);
|
|
2927
|
+
if (!asset) {
|
|
2928
|
+
return false;
|
|
2929
|
+
}
|
|
2930
|
+
return asset.verified;
|
|
2931
|
+
}, [assetsMap]);
|
|
2932
|
+
const denomTicker = (0, import_react2.useCallback)((denom) => {
|
|
2933
|
+
const asset = assetsMap.get(denom);
|
|
2934
|
+
if (!asset) {
|
|
2935
|
+
return truncateDenom(denom);
|
|
2936
|
+
}
|
|
2937
|
+
return asset.ticker;
|
|
2938
|
+
}, [assetsMap]);
|
|
2939
|
+
const denomDecimals = (0, import_react2.useCallback)((denom) => {
|
|
2940
|
+
const asset = assetsMap.get(denom);
|
|
2941
|
+
if (!asset) {
|
|
2942
|
+
return 0;
|
|
2943
|
+
}
|
|
2944
|
+
return asset.decimals;
|
|
2945
|
+
}, [assetsMap]);
|
|
2946
|
+
const getAsset = (0, import_react2.useCallback)((denom) => {
|
|
2947
|
+
return assetsMap.get(denom);
|
|
2948
|
+
}, [assetsMap]);
|
|
2949
|
+
const assetsLpExcluded = (0, import_react2.useMemo)(() => {
|
|
2950
|
+
return assets == null ? void 0 : assets.filter((item) => !isLpDenom(item.denom));
|
|
2951
|
+
}, [assets]);
|
|
2952
|
+
return {
|
|
2953
|
+
assets,
|
|
2954
|
+
isLoading,
|
|
2955
|
+
nativeAsset,
|
|
2956
|
+
isVerifiedAsset,
|
|
2957
|
+
denomTicker,
|
|
2958
|
+
denomDecimals,
|
|
2959
|
+
getAsset,
|
|
2960
|
+
assetsLpExcluded
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
function useAsset(denom) {
|
|
2964
|
+
const { assetsMap, isLoading } = useAssetsContext();
|
|
2965
|
+
const asset = (0, import_react2.useMemo)(
|
|
2966
|
+
() => assetsMap.get(denom),
|
|
2967
|
+
[assetsMap, denom]
|
|
2968
|
+
);
|
|
2969
|
+
return {
|
|
2970
|
+
asset,
|
|
2971
|
+
isLoading
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
function useAssetsManager() {
|
|
2975
|
+
const { updateAssets, isLoading } = useAssetsContext();
|
|
2976
|
+
return {
|
|
2977
|
+
updateAssets,
|
|
2978
|
+
isLoading
|
|
2979
|
+
};
|
|
2980
|
+
}
|
|
2981
|
+
function useIBCChains() {
|
|
2982
|
+
const { ibcChains, isLoading } = useAssetsContext();
|
|
2983
|
+
return {
|
|
2984
|
+
ibcChains,
|
|
2985
|
+
isLoading
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
// src/hooks/useConnectionType.ts
|
|
2990
|
+
function useConnectionType() {
|
|
2991
|
+
const { connectionType, updateConnectionType } = useAssetsContext();
|
|
2992
|
+
return {
|
|
2993
|
+
connectionType,
|
|
2994
|
+
updateConnectionType
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2998
|
+
// src/hooks/useSigningClient.ts
|
|
2999
|
+
var import_bzejs4 = require("@bze/bzejs");
|
|
3000
|
+
var import_react4 = require("react");
|
|
3001
|
+
var import_react5 = require("@interchain-kit/react");
|
|
3002
|
+
|
|
3003
|
+
// src/hooks/useSettings.ts
|
|
3004
|
+
var import_react3 = require("react");
|
|
3005
|
+
function useSettings() {
|
|
3006
|
+
const [settings, setSettingsState] = (0, import_react3.useState)(DEFAULT_SETTINGS);
|
|
3007
|
+
const [isLoaded, setIsLoaded] = (0, import_react3.useState)(false);
|
|
3008
|
+
(0, import_react3.useEffect)(() => {
|
|
3009
|
+
setSettingsState(getSettings());
|
|
3010
|
+
setIsLoaded(true);
|
|
3011
|
+
}, []);
|
|
3012
|
+
const saveSettings = (0, import_react3.useCallback)((newSettings) => {
|
|
3013
|
+
setSettings(newSettings);
|
|
3014
|
+
setSettingsState(newSettings);
|
|
3015
|
+
return true;
|
|
3016
|
+
}, []);
|
|
3017
|
+
const updateEndpoints = (0, import_react3.useCallback)((endpoints) => {
|
|
3018
|
+
const newSettings = __spreadProps(__spreadValues({}, settings), { endpoints });
|
|
3019
|
+
return saveSettings(newSettings);
|
|
3020
|
+
}, [settings, saveSettings]);
|
|
3021
|
+
const updatePreferredFeeDenom = (0, import_react3.useCallback)((preferredFeeDenom) => {
|
|
3022
|
+
const newSettings = __spreadProps(__spreadValues({}, settings), { preferredFeeDenom });
|
|
3023
|
+
return saveSettings(newSettings);
|
|
3024
|
+
}, [settings, saveSettings]);
|
|
3025
|
+
const resetToDefaults = (0, import_react3.useCallback)(() => {
|
|
3026
|
+
saveSettings(DEFAULT_SETTINGS);
|
|
3027
|
+
return true;
|
|
3028
|
+
}, [saveSettings]);
|
|
3029
|
+
const getEndpoints = (0, import_react3.useCallback)(() => {
|
|
3030
|
+
return settings.endpoints;
|
|
3031
|
+
}, [settings.endpoints]);
|
|
3032
|
+
const defaultSettings = (0, import_react3.useMemo)(() => DEFAULT_SETTINGS, []);
|
|
3033
|
+
const feeDenom = (0, import_react3.useMemo)(() => settings.preferredFeeDenom || getChainNativeAssetDenom(), [settings.preferredFeeDenom]);
|
|
3034
|
+
return {
|
|
3035
|
+
settings,
|
|
3036
|
+
isLoaded,
|
|
3037
|
+
saveSettings,
|
|
3038
|
+
updateEndpoints,
|
|
3039
|
+
updatePreferredFeeDenom,
|
|
3040
|
+
resetToDefaults,
|
|
3041
|
+
getEndpoints,
|
|
3042
|
+
defaultSettings,
|
|
3043
|
+
feeDenom
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
// src/hooks/useSigningClient.ts
|
|
3048
|
+
var useSigningClient = ({ chainName, isIbc, isCosmos }) => {
|
|
3049
|
+
const { getSigningClient, signingClientError, wallet, chain } = (0, import_react5.useChain)(chainName != null ? chainName : getChainName());
|
|
3050
|
+
const [signingClient, setSigningClient] = (0, import_react4.useState)(null);
|
|
3051
|
+
const [isSigningClientReady, setIsSigningClientReady] = (0, import_react4.useState)(false);
|
|
3052
|
+
const { settings } = useSettings();
|
|
3053
|
+
const hasInitialized = (0, import_react4.useRef)(false);
|
|
3054
|
+
const defaultChainName = (0, import_react4.useMemo)(() => getChainName(), []);
|
|
3055
|
+
const createSigningClient = (0, import_react4.useCallback)(async () => {
|
|
3056
|
+
var _a2;
|
|
3057
|
+
const signingResult = await getSigningClient();
|
|
3058
|
+
const offlineSigner = signingResult == null ? void 0 : signingResult.offlineSigner;
|
|
3059
|
+
const rpcEndpoint = settings.endpoints.rpcEndpoint.replace("wss://", "https://").replace("ws://", "http://");
|
|
3060
|
+
if (!offlineSigner) {
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3063
|
+
let clientFn = import_bzejs4.getSigningBzeClient;
|
|
3064
|
+
if (isIbc) {
|
|
3065
|
+
clientFn = import_bzejs4.getSigningIbcClient;
|
|
3066
|
+
} else if (isCosmos) {
|
|
3067
|
+
clientFn = import_bzejs4.getSigningCosmosClient;
|
|
3068
|
+
}
|
|
3069
|
+
const signer = (_a2 = offlineSigner == null ? void 0 : offlineSigner.offlineSigner) != null ? _a2 : offlineSigner;
|
|
3070
|
+
const getRpcForChain = (name) => {
|
|
3071
|
+
switch (name) {
|
|
3072
|
+
case "archway":
|
|
3073
|
+
return getArchwayRpcURL();
|
|
3074
|
+
case "osmosis":
|
|
3075
|
+
return getOsmosisRpcUrl();
|
|
3076
|
+
case "noble":
|
|
3077
|
+
return getNobleRpcUrl();
|
|
3078
|
+
case "jackal":
|
|
3079
|
+
return getJackalRpcUrl();
|
|
3080
|
+
case "omniflixhub":
|
|
3081
|
+
return getOmniFlixRpcUrl();
|
|
3082
|
+
case "atomone":
|
|
3083
|
+
return getAtomOneRpcUrl();
|
|
3084
|
+
default:
|
|
3085
|
+
return rpcEndpoint;
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
const endpoint = chainName && chainName !== defaultChainName ? getRpcForChain(chainName) : rpcEndpoint;
|
|
3089
|
+
return clientFn({ rpcEndpoint: endpoint, signer });
|
|
3090
|
+
}, [getSigningClient, settings.endpoints.rpcEndpoint, isIbc, isCosmos, chainName, defaultChainName]);
|
|
3091
|
+
(0, import_react4.useEffect)(() => {
|
|
3092
|
+
if (!wallet || !chain || hasInitialized.current) {
|
|
3093
|
+
return;
|
|
3094
|
+
}
|
|
3095
|
+
const load = async () => {
|
|
3096
|
+
const client = await createSigningClient();
|
|
3097
|
+
if (client) {
|
|
3098
|
+
setSigningClient(client);
|
|
3099
|
+
setIsSigningClientReady(true);
|
|
3100
|
+
hasInitialized.current = true;
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
load();
|
|
3104
|
+
}, [wallet, chain, createSigningClient]);
|
|
3105
|
+
return {
|
|
3106
|
+
signingClientError,
|
|
3107
|
+
signingClient,
|
|
3108
|
+
isSigningClientReady
|
|
3109
|
+
};
|
|
3110
|
+
};
|
|
3111
|
+
|
|
3112
|
+
// src/hooks/usePrices.ts
|
|
3113
|
+
var import_react6 = require("react");
|
|
3114
|
+
function useAssetPrice(denom) {
|
|
3115
|
+
const { usdPricesMap, marketsDataMap, isLoadingPrices } = useAssetsContext();
|
|
3116
|
+
const usdDenom = (0, import_react6.useMemo)(() => getUSDCDenom(), []);
|
|
3117
|
+
const bzeDenom = (0, import_react6.useMemo)(() => getChainNativeAssetDenom(), []);
|
|
3118
|
+
const change = (0, import_react6.useMemo)(() => {
|
|
3119
|
+
const marketData = marketsDataMap.get(createMarketId(denom, usdDenom));
|
|
3120
|
+
if (marketData) {
|
|
3121
|
+
return marketData.change;
|
|
3122
|
+
}
|
|
3123
|
+
const marketData2 = marketsDataMap.get(createMarketId(denom, bzeDenom));
|
|
3124
|
+
if (marketData2) {
|
|
3125
|
+
return marketData2.change;
|
|
3126
|
+
}
|
|
3127
|
+
return 0;
|
|
3128
|
+
}, [marketsDataMap, denom, usdDenom, bzeDenom]);
|
|
3129
|
+
const price = (0, import_react6.useMemo)(() => {
|
|
3130
|
+
const zeroBN = toBigNumber(0);
|
|
3131
|
+
if (denom === "") return zeroBN;
|
|
3132
|
+
if (denom === usdDenom) return toBigNumber(1);
|
|
3133
|
+
return usdPricesMap.get(denom) || zeroBN;
|
|
3134
|
+
}, [usdPricesMap, denom, usdDenom]);
|
|
3135
|
+
const totalUsdValue = (0, import_react6.useCallback)((amount) => {
|
|
3136
|
+
return price.multipliedBy(amount);
|
|
3137
|
+
}, [price]);
|
|
3138
|
+
const uAmountUsdValue = (0, import_react6.useCallback)((amount, decimals) => {
|
|
3139
|
+
return totalUsdValue(uAmountToBigNumberAmount(amount, decimals));
|
|
3140
|
+
}, [totalUsdValue]);
|
|
3141
|
+
const isUSDC = (0, import_react6.useMemo)(() => denom === usdDenom, [denom, usdDenom]);
|
|
3142
|
+
const hasPrice = (0, import_react6.useMemo)(() => price.gt(0), [price]);
|
|
3143
|
+
return {
|
|
3144
|
+
price,
|
|
3145
|
+
change,
|
|
3146
|
+
totalUsdValue,
|
|
3147
|
+
uAmountUsdValue,
|
|
3148
|
+
isLoading: isLoadingPrices,
|
|
3149
|
+
hasPrice,
|
|
3150
|
+
isUSDC
|
|
3151
|
+
};
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
// src/hooks/useBalances.ts
|
|
3155
|
+
var import_bignumber8 = __toESM(require("bignumber.js"));
|
|
3156
|
+
var import_react7 = require("react");
|
|
3157
|
+
function useBalances() {
|
|
3158
|
+
const { balancesMap, isLoading, assetsMap, usdPricesMap } = useAssetsContext();
|
|
3159
|
+
const balances = (0, import_react7.useMemo)(() => Array.from(balancesMap.values()), [balancesMap]);
|
|
3160
|
+
const getBalanceByDenom = (0, import_react7.useCallback)((denom) => {
|
|
3161
|
+
return balancesMap.get(denom) || { denom, amount: (0, import_bignumber8.default)(0) };
|
|
3162
|
+
}, [balancesMap]);
|
|
3163
|
+
const assetsBalances = (0, import_react7.useMemo)(() => {
|
|
3164
|
+
const result = [];
|
|
3165
|
+
balances.map((bal) => {
|
|
3166
|
+
const asset = assetsMap.get(bal.denom);
|
|
3167
|
+
if (!asset) {
|
|
3168
|
+
return;
|
|
3169
|
+
}
|
|
3170
|
+
let usdPrice = usdPricesMap.get(bal.denom);
|
|
3171
|
+
if (!usdPrice) {
|
|
3172
|
+
usdPrice = (0, import_bignumber8.default)(0);
|
|
3173
|
+
}
|
|
3174
|
+
if (asset.denom === getUSDCDenom()) {
|
|
3175
|
+
usdPrice = (0, import_bignumber8.default)(1);
|
|
3176
|
+
}
|
|
3177
|
+
result.push(__spreadProps(__spreadValues({}, asset), {
|
|
3178
|
+
amount: bal.amount,
|
|
3179
|
+
USDValue: uAmountToBigNumberAmount(bal.amount, asset.decimals).multipliedBy(usdPrice)
|
|
3180
|
+
}));
|
|
3181
|
+
});
|
|
3182
|
+
return result;
|
|
3183
|
+
}, [balances, assetsMap, usdPricesMap]);
|
|
3184
|
+
return {
|
|
3185
|
+
isLoading,
|
|
3186
|
+
balances,
|
|
3187
|
+
assetsBalances,
|
|
3188
|
+
getBalanceByDenom
|
|
3189
|
+
};
|
|
3190
|
+
}
|
|
3191
|
+
function useBalance(denom) {
|
|
3192
|
+
const { balancesMap, isLoading } = useAssetsContext();
|
|
3193
|
+
const balance = (0, import_react7.useMemo)(
|
|
3194
|
+
() => balancesMap.get(denom) || {
|
|
3195
|
+
denom,
|
|
3196
|
+
amount: (0, import_bignumber8.default)(0)
|
|
3197
|
+
},
|
|
3198
|
+
[balancesMap, denom]
|
|
3199
|
+
);
|
|
3200
|
+
const hasAmount = (0, import_react7.useCallback)((amount) => {
|
|
3201
|
+
return balance.amount.gte(amount);
|
|
3202
|
+
}, [balance]);
|
|
3203
|
+
return {
|
|
3204
|
+
balance,
|
|
3205
|
+
isLoading,
|
|
3206
|
+
hasAmount
|
|
3207
|
+
};
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
// src/hooks/useEpochs.ts
|
|
3211
|
+
var import_react8 = require("react");
|
|
3212
|
+
var EPOCH_HOUR2 = "hour";
|
|
3213
|
+
var EPOCH_DAY2 = "day";
|
|
3214
|
+
var EPOCH_WEEK2 = "week";
|
|
3215
|
+
function useEpochs() {
|
|
3216
|
+
const { epochs, isLoading, updateEpochs } = useAssetsContext();
|
|
3217
|
+
const hourEpochInfo = (0, import_react8.useMemo)(() => {
|
|
3218
|
+
return epochs.get(EPOCH_HOUR2);
|
|
3219
|
+
}, [epochs]);
|
|
3220
|
+
const dayEpochInfo = (0, import_react8.useMemo)(() => {
|
|
3221
|
+
return epochs.get(EPOCH_DAY2);
|
|
3222
|
+
}, [epochs]);
|
|
3223
|
+
const weekEpochInfo = (0, import_react8.useMemo)(() => {
|
|
3224
|
+
return epochs.get(EPOCH_WEEK2);
|
|
3225
|
+
}, [epochs]);
|
|
3226
|
+
return {
|
|
3227
|
+
epochs,
|
|
3228
|
+
hourEpochInfo,
|
|
3229
|
+
dayEpochInfo,
|
|
3230
|
+
weekEpochInfo,
|
|
3231
|
+
isLoading,
|
|
3232
|
+
updateEpochs
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
// src/hooks/useLiquidityPools.ts
|
|
3237
|
+
var import_react9 = require("react");
|
|
3238
|
+
function useLiquidityPools() {
|
|
3239
|
+
const { poolsMap, poolsDataMap, updateLiquidityPools, isLoading, assetsMap } = useAssetsContext();
|
|
3240
|
+
const pools = (0, import_react9.useMemo)(() => {
|
|
3241
|
+
return Array.from(poolsMap.values());
|
|
3242
|
+
}, [poolsMap]);
|
|
3243
|
+
const getPoolByLpDenom = (lpDenom) => {
|
|
3244
|
+
const poolId = poolIdFromPoolDenom(lpDenom);
|
|
3245
|
+
return poolsMap.get(poolId);
|
|
3246
|
+
};
|
|
3247
|
+
const getDenomsPool = (0, import_react9.useCallback)((denomA, denomB) => {
|
|
3248
|
+
const poolId = createPoolId(denomA, denomB);
|
|
3249
|
+
return poolsMap.get(poolId);
|
|
3250
|
+
}, [poolsMap]);
|
|
3251
|
+
const liquidAssets = (0, import_react9.useMemo)(() => {
|
|
3252
|
+
if (!assetsMap || assetsMap.size === 0) return [];
|
|
3253
|
+
const result = /* @__PURE__ */ new Map();
|
|
3254
|
+
pools.forEach((pool) => {
|
|
3255
|
+
result.set(pool.base, assetsMap.get(pool.base));
|
|
3256
|
+
result.set(pool.quote, assetsMap.get(pool.quote));
|
|
3257
|
+
});
|
|
3258
|
+
return Array.from(result.values()).filter((asset) => asset !== void 0);
|
|
3259
|
+
}, [assetsMap, pools]);
|
|
3260
|
+
return {
|
|
3261
|
+
pools,
|
|
3262
|
+
poolsMap,
|
|
3263
|
+
poolsDataMap,
|
|
3264
|
+
isLoading,
|
|
3265
|
+
updateLiquidityPools,
|
|
3266
|
+
getPoolByLpDenom,
|
|
3267
|
+
getDenomsPool,
|
|
3268
|
+
liquidAssets
|
|
3269
|
+
};
|
|
3270
|
+
}
|
|
3271
|
+
function useAssetLiquidityPools(denom) {
|
|
3272
|
+
const { poolsMap, poolsDataMap } = useAssetsContext();
|
|
3273
|
+
const assetPools = (0, import_react9.useMemo)(() => {
|
|
3274
|
+
return Array.from(poolsMap.values()).filter(
|
|
3275
|
+
(pool) => pool.base === denom || pool.quote === denom
|
|
3276
|
+
);
|
|
3277
|
+
}, [poolsMap, denom]);
|
|
3278
|
+
return {
|
|
3279
|
+
assetPools,
|
|
3280
|
+
poolsDataMap
|
|
3281
|
+
};
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
// src/hooks/useAssetsValue.ts
|
|
3285
|
+
var import_react10 = require("react");
|
|
3286
|
+
function useAssetsValue() {
|
|
3287
|
+
const { assetsMap, usdPricesMap, balancesMap, isLoading } = useAssetsContext();
|
|
3288
|
+
const totalUsdValue = (0, import_react10.useMemo)(() => {
|
|
3289
|
+
let total = toBigNumber(0);
|
|
3290
|
+
balancesMap.forEach((balance, denom) => {
|
|
3291
|
+
const price = usdPricesMap.get(denom);
|
|
3292
|
+
if (!price || !price.gt(0)) return;
|
|
3293
|
+
const asset = assetsMap.get(denom);
|
|
3294
|
+
if (!asset) return;
|
|
3295
|
+
total = total.plus(price.multipliedBy(uAmountToBigNumberAmount(balance.amount, asset.decimals)));
|
|
3296
|
+
});
|
|
3297
|
+
return total;
|
|
3298
|
+
}, [balancesMap, usdPricesMap, assetsMap]);
|
|
3299
|
+
const denomUsdValue = (denom, uAmount) => {
|
|
3300
|
+
const price = usdPricesMap.get(denom);
|
|
3301
|
+
if (!price || !price.gt(0)) return toBigNumber(0);
|
|
3302
|
+
const asset = assetsMap.get(denom);
|
|
3303
|
+
if (!asset) return toBigNumber(0);
|
|
3304
|
+
return price.multipliedBy(uAmountToBigNumberAmount(uAmount, asset.decimals));
|
|
3305
|
+
};
|
|
3306
|
+
return {
|
|
3307
|
+
totalUsdValue,
|
|
3308
|
+
denomUsdValue,
|
|
3309
|
+
isLoading
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
// src/hooks/useFeeTokens.ts
|
|
3314
|
+
var import_react11 = require("react");
|
|
3315
|
+
var MIN_LIQUIDITY_FOR_FEE_TOKEN = 5e10;
|
|
3316
|
+
function useFeeTokens() {
|
|
3317
|
+
const { pools, isLoading: poolsLoading } = useLiquidityPools();
|
|
3318
|
+
const { assetsMap, isLoading: assetsLoading } = useAssetsContext();
|
|
3319
|
+
const nativeDenom = getChainNativeAssetDenom();
|
|
3320
|
+
const feeTokens = (0, import_react11.useMemo)(() => {
|
|
3321
|
+
if (poolsLoading || assetsLoading) {
|
|
3322
|
+
return [];
|
|
3323
|
+
}
|
|
3324
|
+
const feeTokenDenoms = /* @__PURE__ */ new Set();
|
|
3325
|
+
pools.forEach((pool) => {
|
|
3326
|
+
if (pool.base === nativeDenom && toBigNumber(pool.reserve_base).gt(MIN_LIQUIDITY_FOR_FEE_TOKEN)) {
|
|
3327
|
+
feeTokenDenoms.add(pool.quote);
|
|
3328
|
+
} else if (pool.quote === nativeDenom && toBigNumber(pool.reserve_quote).gt(MIN_LIQUIDITY_FOR_FEE_TOKEN)) {
|
|
3329
|
+
feeTokenDenoms.add(pool.base);
|
|
3330
|
+
}
|
|
3331
|
+
});
|
|
3332
|
+
const tokens = Array.from(feeTokenDenoms).map((denom) => assetsMap.get(denom)).filter((asset) => asset !== void 0).sort((a, b) => {
|
|
3333
|
+
if (!a || !b) return 0;
|
|
3334
|
+
return a.denom.localeCompare(b.denom);
|
|
3335
|
+
});
|
|
3336
|
+
const bzeAsset = assetsMap.get(nativeDenom);
|
|
3337
|
+
if (!bzeAsset) {
|
|
3338
|
+
return tokens;
|
|
3339
|
+
}
|
|
3340
|
+
return [bzeAsset, ...tokens];
|
|
3341
|
+
}, [pools, poolsLoading, assetsLoading, nativeDenom, assetsMap]);
|
|
3342
|
+
return {
|
|
3343
|
+
feeTokens,
|
|
3344
|
+
isLoading: poolsLoading || assetsLoading,
|
|
3345
|
+
nativeDenom
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
// src/hooks/useMarkets.ts
|
|
3350
|
+
var import_react12 = require("react");
|
|
3351
|
+
function useMarkets() {
|
|
3352
|
+
const { marketsMap, marketsDataMap, updateMarkets, isLoading } = useAssetsContext();
|
|
3353
|
+
const markets = (0, import_react12.useMemo)(() => {
|
|
3354
|
+
return Array.from(marketsMap.values());
|
|
3355
|
+
}, [marketsMap]);
|
|
3356
|
+
return {
|
|
3357
|
+
markets,
|
|
3358
|
+
marketsMap,
|
|
3359
|
+
marketsDataMap,
|
|
3360
|
+
isLoading,
|
|
3361
|
+
updateMarkets
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
function useAssetMarkets(denom) {
|
|
3365
|
+
const { marketsMap } = useAssetsContext();
|
|
3366
|
+
const assetMarkets = (0, import_react12.useMemo)(() => {
|
|
3367
|
+
return Array.from(marketsMap.values()).filter(
|
|
3368
|
+
(market) => market.base === denom || market.quote === denom
|
|
3369
|
+
);
|
|
3370
|
+
}, [marketsMap, denom]);
|
|
3371
|
+
return {
|
|
3372
|
+
assetMarkets
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
function useMarket(base, quote) {
|
|
3376
|
+
const { marketsMap, marketsDataMap, assetsMap, isLoading } = useAssetsContext();
|
|
3377
|
+
const marketId = (0, import_react12.useMemo)(() => createMarketId(base, quote), [base, quote]);
|
|
3378
|
+
const market = (0, import_react12.useMemo)(() => {
|
|
3379
|
+
return marketsMap.get(marketId);
|
|
3380
|
+
}, [marketsMap, marketId]);
|
|
3381
|
+
const marketData = (0, import_react12.useMemo)(() => {
|
|
3382
|
+
return marketsDataMap.get(marketId);
|
|
3383
|
+
}, [marketsDataMap, marketId]);
|
|
3384
|
+
const marketExists = (0, import_react12.useMemo)(() => !!market, [market]);
|
|
3385
|
+
const volume24h = (0, import_react12.useMemo)(() => {
|
|
3386
|
+
if (!marketData) return toBigNumber(0);
|
|
3387
|
+
const quoteAsset = assetsMap.get(quote);
|
|
3388
|
+
if (!quoteAsset) return toBigNumber(0);
|
|
3389
|
+
return uAmountToBigNumberAmount(toBigNumber(marketData.quote_volume), quoteAsset.decimals);
|
|
3390
|
+
}, [marketData, assetsMap, quote]);
|
|
3391
|
+
return {
|
|
3392
|
+
market,
|
|
3393
|
+
marketData,
|
|
3394
|
+
marketExists,
|
|
3395
|
+
volume24h,
|
|
3396
|
+
isLoading
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
|
|
3400
|
+
// src/hooks/useToast.tsx
|
|
3401
|
+
var import_react14 = require("react");
|
|
3402
|
+
|
|
3403
|
+
// src/components/toaster.tsx
|
|
3404
|
+
var import_react13 = require("@chakra-ui/react");
|
|
3405
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3406
|
+
var toaster = (0, import_react13.createToaster)({
|
|
3407
|
+
placement: "top-end",
|
|
3408
|
+
pauseOnPageIdle: true
|
|
3409
|
+
});
|
|
3410
|
+
var Toaster = () => {
|
|
3411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Toaster, { toaster, insetInline: { mdDown: "4" }, children: (toast) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react13.Toast.Root, { width: { md: "sm" }, children: [
|
|
3412
|
+
toast.type === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Spinner, { size: "sm", color: "blue.solid" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Toast.Indicator, {}),
|
|
3413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react13.Stack, { gap: "1", flex: "1", maxWidth: "100%", children: [
|
|
3414
|
+
toast.title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Toast.Title, { children: toast.title }),
|
|
3415
|
+
toast.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Toast.Description, { children: toast.description })
|
|
3416
|
+
] }),
|
|
3417
|
+
toast.action && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Toast.ActionTrigger, { children: toast.action.label }),
|
|
3418
|
+
toast.closable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react13.Toast.CloseTrigger, {})
|
|
3419
|
+
] }) }) });
|
|
3420
|
+
};
|
|
3421
|
+
|
|
3422
|
+
// src/hooks/useToast.tsx
|
|
3423
|
+
var useToast = () => {
|
|
3424
|
+
const clickableSuccess = (0, import_react14.useCallback)((title, actionFn, actionLabel, description, duration = 5e3) => {
|
|
3425
|
+
toaster.create({
|
|
3426
|
+
title,
|
|
3427
|
+
description,
|
|
3428
|
+
type: "success",
|
|
3429
|
+
duration,
|
|
3430
|
+
closable: true,
|
|
3431
|
+
action: {
|
|
3432
|
+
label: actionLabel != null ? actionLabel : "",
|
|
3433
|
+
onClick: actionFn
|
|
3434
|
+
}
|
|
3435
|
+
});
|
|
3436
|
+
}, []);
|
|
3437
|
+
const success = (0, import_react14.useCallback)((title, description, duration = 5e3) => {
|
|
3438
|
+
toaster.create({
|
|
3439
|
+
title,
|
|
3440
|
+
description,
|
|
3441
|
+
type: "success",
|
|
3442
|
+
duration,
|
|
3443
|
+
closable: true
|
|
3444
|
+
});
|
|
3445
|
+
}, []);
|
|
3446
|
+
const error = (0, import_react14.useCallback)((title, description, duration = 8e3) => {
|
|
3447
|
+
toaster.create({
|
|
3448
|
+
title,
|
|
3449
|
+
description,
|
|
3450
|
+
type: "error",
|
|
3451
|
+
duration,
|
|
3452
|
+
closable: true
|
|
3453
|
+
});
|
|
3454
|
+
}, []);
|
|
3455
|
+
const warning = (0, import_react14.useCallback)((title, description, duration = 6e3) => {
|
|
3456
|
+
toaster.create({
|
|
3457
|
+
title,
|
|
3458
|
+
description,
|
|
3459
|
+
type: "warning",
|
|
3460
|
+
duration,
|
|
3461
|
+
closable: true
|
|
3462
|
+
});
|
|
3463
|
+
}, []);
|
|
3464
|
+
const info = (0, import_react14.useCallback)((title, description, duration = 5e3) => {
|
|
3465
|
+
toaster.create({
|
|
3466
|
+
title,
|
|
3467
|
+
description,
|
|
3468
|
+
type: "info",
|
|
3469
|
+
duration,
|
|
3470
|
+
closable: true
|
|
3471
|
+
});
|
|
3472
|
+
}, []);
|
|
3473
|
+
const loading = (0, import_react14.useCallback)((title, description) => {
|
|
3474
|
+
return toaster.create({
|
|
3475
|
+
title,
|
|
3476
|
+
description,
|
|
3477
|
+
type: "loading",
|
|
3478
|
+
closable: false
|
|
3479
|
+
});
|
|
3480
|
+
}, []);
|
|
3481
|
+
const dismiss = (0, import_react14.useCallback)((id) => {
|
|
3482
|
+
toaster.dismiss(id);
|
|
3483
|
+
}, []);
|
|
3484
|
+
const toast = (0, import_react14.useMemo)(() => ({
|
|
3485
|
+
clickableSuccess,
|
|
3486
|
+
success,
|
|
3487
|
+
error,
|
|
3488
|
+
warning,
|
|
3489
|
+
info,
|
|
3490
|
+
loading,
|
|
3491
|
+
dismiss
|
|
3492
|
+
}), [clickableSuccess, success, error, warning, info, loading, dismiss]);
|
|
3493
|
+
return { toast };
|
|
3494
|
+
};
|
|
3495
|
+
|
|
3496
|
+
// src/hooks/useTx.tsx
|
|
3497
|
+
var import_stargate = require("@cosmjs/stargate");
|
|
3498
|
+
var import_react15 = require("@interchain-kit/react");
|
|
3499
|
+
var import_bignumber9 = __toESM(require("bignumber.js"));
|
|
3500
|
+
var import_react16 = require("react");
|
|
3501
|
+
var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
3502
|
+
TxStatus2["Failed"] = "Transaction Failed";
|
|
3503
|
+
TxStatus2["Successful"] = "Transaction Successful";
|
|
3504
|
+
TxStatus2["Broadcasting"] = "Transaction Pending";
|
|
3505
|
+
return TxStatus2;
|
|
3506
|
+
})(TxStatus || {});
|
|
3507
|
+
var defaultFee = {
|
|
3508
|
+
amount: (0, import_stargate.coins)(2e4, getChainNativeAssetDenom()),
|
|
3509
|
+
gas: "500000"
|
|
3510
|
+
};
|
|
3511
|
+
var useSDKTx = (chainName) => {
|
|
3512
|
+
const { tx, progressTrack } = useTx(chainName != null ? chainName : getChainName(), true, false);
|
|
3513
|
+
return {
|
|
3514
|
+
tx,
|
|
3515
|
+
progressTrack
|
|
3516
|
+
};
|
|
3517
|
+
};
|
|
3518
|
+
var useBZETx = () => {
|
|
3519
|
+
const { tx, progressTrack } = useTx(getChainName(), false, false);
|
|
3520
|
+
return {
|
|
3521
|
+
tx,
|
|
3522
|
+
progressTrack
|
|
3523
|
+
};
|
|
3524
|
+
};
|
|
3525
|
+
var useIBCTx = (chainName) => {
|
|
3526
|
+
const { tx, progressTrack } = useTx(chainName != null ? chainName : getChainName(), false, true);
|
|
3527
|
+
return {
|
|
3528
|
+
tx,
|
|
3529
|
+
progressTrack
|
|
3530
|
+
};
|
|
3531
|
+
};
|
|
3532
|
+
var useTx = (chainName, isCosmos, isIBC) => {
|
|
3533
|
+
const { address, disconnect } = (0, import_react15.useChain)(chainName);
|
|
3534
|
+
const { toast } = useToast();
|
|
3535
|
+
const { signingClient, isSigningClientReady, signingClientError } = useSigningClient({ chainName, isCosmos, isIbc: isIBC });
|
|
3536
|
+
const [progressTrack, setProgressTrack] = (0, import_react16.useState)("");
|
|
3537
|
+
const { getDenomsPool } = useLiquidityPools();
|
|
3538
|
+
const { feeDenom } = useSettings();
|
|
3539
|
+
const defaultChainName = (0, import_react16.useMemo)(() => getChainName(), []);
|
|
3540
|
+
const canUseClient = (0, import_react16.useCallback)(async () => {
|
|
3541
|
+
if (!isSigningClientReady) {
|
|
3542
|
+
console.error("waiting for signing client to be ready", signingClientError);
|
|
3543
|
+
await sleep(1e3);
|
|
3544
|
+
}
|
|
3545
|
+
return isSigningClientReady;
|
|
3546
|
+
}, [isSigningClientReady, signingClientError]);
|
|
3547
|
+
const simulateFee = (0, import_react16.useCallback)(async (messages, memo) => {
|
|
3548
|
+
const gasPrice = 0.02;
|
|
3549
|
+
const nativeDenom = getChainNativeAssetDenom();
|
|
3550
|
+
const gasEstimated = await signingClient.simulate(address, messages, memo);
|
|
3551
|
+
const gasAmount = (0, import_bignumber9.default)(gasEstimated).multipliedBy(1.5);
|
|
3552
|
+
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
3553
|
+
const nativeFee = {
|
|
3554
|
+
amount: (0, import_stargate.coins)(gasPayment.toFixed(0).toString(), nativeDenom),
|
|
3555
|
+
gas: gasAmount.toFixed(0)
|
|
3556
|
+
};
|
|
3557
|
+
if (feeDenom === nativeDenom) {
|
|
3558
|
+
return nativeFee;
|
|
3559
|
+
}
|
|
3560
|
+
const pool = getDenomsPool(feeDenom, nativeDenom);
|
|
3561
|
+
if (!pool) {
|
|
3562
|
+
return nativeFee;
|
|
3563
|
+
}
|
|
3564
|
+
let expectedAmount = calculatePoolOppositeAmount(pool, gasPayment, pool.base === nativeDenom);
|
|
3565
|
+
if (!expectedAmount.isPositive()) {
|
|
3566
|
+
return nativeFee;
|
|
3567
|
+
}
|
|
3568
|
+
expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(import_bignumber9.default.ROUND_FLOOR);
|
|
3569
|
+
if (expectedAmount.multipliedBy(pool.fee).lt(1)) {
|
|
3570
|
+
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(import_bignumber9.default.ROUND_CEIL);
|
|
3571
|
+
}
|
|
3572
|
+
return {
|
|
3573
|
+
amount: (0, import_stargate.coins)(expectedAmount.toFixed(0).toString(), feeDenom),
|
|
3574
|
+
gas: gasAmount.multipliedBy(1.5).toFixed(0)
|
|
3575
|
+
};
|
|
3576
|
+
}, [signingClient, address, feeDenom, getDenomsPool]);
|
|
3577
|
+
const getFee = (0, import_react16.useCallback)(async (messages, options) => {
|
|
3578
|
+
try {
|
|
3579
|
+
if (options == null ? void 0 : options.fee) {
|
|
3580
|
+
return options.fee;
|
|
3581
|
+
} else {
|
|
3582
|
+
setProgressTrack("Simulating transaction");
|
|
3583
|
+
return await simulateFee(messages, options == null ? void 0 : options.memo);
|
|
3584
|
+
}
|
|
3585
|
+
} catch (e) {
|
|
3586
|
+
console.error("could not get fee: ", e);
|
|
3587
|
+
if (options == null ? void 0 : options.fallbackOnSimulate) {
|
|
3588
|
+
return defaultFee;
|
|
3589
|
+
} else {
|
|
3590
|
+
throw e;
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}, [simulateFee]);
|
|
3594
|
+
const tx = (0, import_react16.useCallback)(async (msgs, options) => {
|
|
3595
|
+
var _a2;
|
|
3596
|
+
if (!address) {
|
|
3597
|
+
toast.error("Transaction Failed" /* Failed */, "Please connect the wallet");
|
|
3598
|
+
return;
|
|
3599
|
+
}
|
|
3600
|
+
if (!await canUseClient()) {
|
|
3601
|
+
toast.error("Transaction Failed" /* Failed */, "Can not find suitable signing client. Make sure your wallet is installed, connected and unlocked.");
|
|
3602
|
+
disconnect();
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
setProgressTrack("Getting fee");
|
|
3606
|
+
const broadcastToastId = toast.loading("Transaction Pending" /* Broadcasting */, "Waiting for transaction to be signed and included in block");
|
|
3607
|
+
if (signingClient) {
|
|
3608
|
+
try {
|
|
3609
|
+
const fee = await getFee(msgs, options);
|
|
3610
|
+
setProgressTrack("Signing transaction");
|
|
3611
|
+
const resp = await signingClient.signAndBroadcast(address, msgs, fee, (_a2 = options == null ? void 0 : options.memo) != null ? _a2 : DEFAULT_TX_MEMO);
|
|
3612
|
+
if ((0, import_stargate.isDeliverTxSuccess)(resp)) {
|
|
3613
|
+
setProgressTrack("Transaction sent");
|
|
3614
|
+
toast.clickableSuccess("Transaction Successful" /* Successful */, () => {
|
|
3615
|
+
openExternalLink(`${getChainExplorerURL(chainName != null ? chainName : defaultChainName)}/tx/${resp.transactionHash}`);
|
|
3616
|
+
}, "View in Explorer");
|
|
3617
|
+
if (options == null ? void 0 : options.onSuccess) {
|
|
3618
|
+
options.onSuccess(resp);
|
|
3619
|
+
}
|
|
3620
|
+
} else {
|
|
3621
|
+
setProgressTrack("Transaction failed");
|
|
3622
|
+
toast.error("Transaction Failed" /* Failed */, prettyError(resp == null ? void 0 : resp.rawLog));
|
|
3623
|
+
if (options == null ? void 0 : options.onFailure) {
|
|
3624
|
+
options.onFailure(prettyError(resp == null ? void 0 : resp.rawLog) || "Unknown error");
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
} catch (e) {
|
|
3628
|
+
console.error(e);
|
|
3629
|
+
if (e.message.includes("Failed to retrieve account from signer")) {
|
|
3630
|
+
disconnect();
|
|
3631
|
+
}
|
|
3632
|
+
toast.error("Transaction Failed" /* Failed */, prettyError(e == null ? void 0 : e.message));
|
|
3633
|
+
if (options == null ? void 0 : options.onFailure) {
|
|
3634
|
+
options.onFailure(prettyError(e == null ? void 0 : e.message) || "Unknown error");
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
toast.dismiss(broadcastToastId);
|
|
3639
|
+
setTimeout(() => {
|
|
3640
|
+
setProgressTrack("");
|
|
3641
|
+
}, (options == null ? void 0 : options.progressTrackerTimeout) || 5e3);
|
|
3642
|
+
}, [address, canUseClient, toast, signingClient, disconnect, getFee, chainName, defaultChainName]);
|
|
3643
|
+
return {
|
|
3644
|
+
tx,
|
|
3645
|
+
progressTrack
|
|
3646
|
+
};
|
|
3647
|
+
};
|
|
3648
|
+
|
|
3649
|
+
// src/components/highlight.tsx
|
|
3650
|
+
var import_react17 = require("@chakra-ui/react");
|
|
3651
|
+
var import_react18 = require("react");
|
|
3652
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
3653
|
+
var HighlightText = (_a2) => {
|
|
3654
|
+
var _b2 = _a2, {
|
|
3655
|
+
duration = 200,
|
|
3656
|
+
highlightOnMount = false,
|
|
3657
|
+
highlightColor = "blue.500",
|
|
3658
|
+
highlightIntensity = "subtle",
|
|
3659
|
+
children
|
|
3660
|
+
} = _b2, textProps = __objRest(_b2, [
|
|
3661
|
+
"duration",
|
|
3662
|
+
"highlightOnMount",
|
|
3663
|
+
"highlightColor",
|
|
3664
|
+
"highlightIntensity",
|
|
3665
|
+
"children"
|
|
3666
|
+
]);
|
|
3667
|
+
const [isHighlighted, setIsHighlighted] = (0, import_react18.useState)(false);
|
|
3668
|
+
const isMountedRef = (0, import_react18.useRef)(false);
|
|
3669
|
+
const timeoutRef = (0, import_react18.useRef)(void 0);
|
|
3670
|
+
const childrenString = String(children);
|
|
3671
|
+
const previousValueRef = (0, import_react18.useRef)(childrenString);
|
|
3672
|
+
const highlightOpacity = highlightIntensity === "subtle" ? "15" : "50";
|
|
3673
|
+
const boxShadowStrength = highlightIntensity === "subtle" ? "10" : "25";
|
|
3674
|
+
(0, import_react18.useEffect)(() => {
|
|
3675
|
+
if (!isMountedRef.current) {
|
|
3676
|
+
isMountedRef.current = true;
|
|
3677
|
+
if (highlightOnMount) {
|
|
3678
|
+
setIsHighlighted(true);
|
|
3679
|
+
timeoutRef.current = setTimeout(() => {
|
|
3680
|
+
setIsHighlighted(false);
|
|
3681
|
+
}, duration);
|
|
3682
|
+
}
|
|
3683
|
+
previousValueRef.current = childrenString;
|
|
3684
|
+
return;
|
|
3685
|
+
}
|
|
3686
|
+
if (previousValueRef.current !== childrenString) {
|
|
3687
|
+
if (timeoutRef.current) {
|
|
3688
|
+
clearTimeout(timeoutRef.current);
|
|
3689
|
+
}
|
|
3690
|
+
setIsHighlighted(true);
|
|
3691
|
+
timeoutRef.current = setTimeout(() => {
|
|
3692
|
+
setIsHighlighted(false);
|
|
3693
|
+
}, duration);
|
|
3694
|
+
previousValueRef.current = childrenString;
|
|
3695
|
+
}
|
|
3696
|
+
return () => {
|
|
3697
|
+
if (timeoutRef.current) {
|
|
3698
|
+
clearTimeout(timeoutRef.current);
|
|
3699
|
+
}
|
|
3700
|
+
};
|
|
3701
|
+
}, [childrenString, duration, highlightOnMount]);
|
|
3702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3703
|
+
import_react17.Text,
|
|
3704
|
+
__spreadProps(__spreadValues({}, textProps), {
|
|
3705
|
+
transition: `all ${duration}ms ease-out`,
|
|
3706
|
+
bg: isHighlighted ? `${highlightColor}/${highlightOpacity}` : "transparent",
|
|
3707
|
+
boxShadow: isHighlighted ? `0 0 0 ${highlightIntensity === "evident" ? "4px" : "3px"} ${highlightColor}/${boxShadowStrength}` : "none",
|
|
3708
|
+
borderRadius: "md",
|
|
3709
|
+
px: isHighlighted ? "2" : "0",
|
|
3710
|
+
transform: isHighlighted && highlightIntensity === "evident" ? "scale(1.02)" : "scale(1)",
|
|
3711
|
+
fontWeight: isHighlighted && highlightIntensity === "evident" ? "semibold" : textProps.fontWeight,
|
|
3712
|
+
children
|
|
3713
|
+
})
|
|
3714
|
+
);
|
|
3715
|
+
};
|
|
3716
|
+
|
|
3717
|
+
// src/components/sidebar/sidebar.tsx
|
|
3718
|
+
var import_react19 = require("@chakra-ui/react");
|
|
3719
|
+
var import_lu2 = require("react-icons/lu");
|
|
3720
|
+
var import_react20 = require("react");
|
|
3721
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
3722
|
+
var Sidebar = ({ children, trigger, ariaLabel }) => {
|
|
3723
|
+
const [isOpen, setIsOpen] = (0, import_react20.useState)(false);
|
|
3724
|
+
const handleTriggerClick = () => {
|
|
3725
|
+
setIsOpen(true);
|
|
3726
|
+
};
|
|
3727
|
+
const handleClose = () => {
|
|
3728
|
+
setIsOpen(false);
|
|
3729
|
+
};
|
|
3730
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
3731
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { onClick: handleTriggerClick, style: { cursor: "pointer" }, children: trigger }),
|
|
3732
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react19.Portal, { children: [
|
|
3733
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3734
|
+
"div",
|
|
3735
|
+
{
|
|
3736
|
+
style: {
|
|
3737
|
+
position: "fixed",
|
|
3738
|
+
top: 0,
|
|
3739
|
+
left: 0,
|
|
3740
|
+
right: 0,
|
|
3741
|
+
bottom: 0,
|
|
3742
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
3743
|
+
zIndex: "3",
|
|
3744
|
+
display: "block"
|
|
3745
|
+
},
|
|
3746
|
+
onClick: (e) => {
|
|
3747
|
+
if (e.target === e.currentTarget) {
|
|
3748
|
+
handleClose();
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
),
|
|
3753
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
3754
|
+
"div",
|
|
3755
|
+
{
|
|
3756
|
+
id: "sidebar-content",
|
|
3757
|
+
style: {
|
|
3758
|
+
position: "fixed",
|
|
3759
|
+
top: 0,
|
|
3760
|
+
right: 0,
|
|
3761
|
+
bottom: 0,
|
|
3762
|
+
width: window.innerWidth < 768 ? "100vw" : "20vw",
|
|
3763
|
+
minWidth: window.innerWidth < 768 ? "100vw" : "300px",
|
|
3764
|
+
maxWidth: window.innerWidth < 768 ? "100vw" : "400px",
|
|
3765
|
+
backgroundColor: "var(--chakra-colors-bg-panel)",
|
|
3766
|
+
borderLeft: "1px solid var(--chakra-colors-border-subtle)",
|
|
3767
|
+
boxShadow: window.innerWidth >= 768 ? "-4px 0 12px rgba(0, 0, 0, 0.15)" : "none",
|
|
3768
|
+
zIndex: "99",
|
|
3769
|
+
display: "flex",
|
|
3770
|
+
flexDirection: "column",
|
|
3771
|
+
overflow: "hidden"
|
|
3772
|
+
},
|
|
3773
|
+
children: [
|
|
3774
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
3775
|
+
"div",
|
|
3776
|
+
{
|
|
3777
|
+
style: {
|
|
3778
|
+
display: "flex",
|
|
3779
|
+
justifyContent: "space-between",
|
|
3780
|
+
alignItems: "center",
|
|
3781
|
+
padding: "1rem",
|
|
3782
|
+
borderBottom: "1px solid var(--chakra-colors-border-subtle)",
|
|
3783
|
+
backgroundColor: "var(--chakra-colors-bg-panel)",
|
|
3784
|
+
flexShrink: 0
|
|
3785
|
+
},
|
|
3786
|
+
children: [
|
|
3787
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3788
|
+
"h3",
|
|
3789
|
+
{
|
|
3790
|
+
style: {
|
|
3791
|
+
fontSize: "1.125rem",
|
|
3792
|
+
fontWeight: "600",
|
|
3793
|
+
margin: 0,
|
|
3794
|
+
color: "var(--chakra-colors-fg)"
|
|
3795
|
+
},
|
|
3796
|
+
children: ariaLabel
|
|
3797
|
+
}
|
|
3798
|
+
),
|
|
3799
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3800
|
+
import_react19.IconButton,
|
|
3801
|
+
{
|
|
3802
|
+
"aria-label": "Close sidebar",
|
|
3803
|
+
variant: "ghost",
|
|
3804
|
+
size: "sm",
|
|
3805
|
+
onClick: handleClose,
|
|
3806
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react19.Icon, { size: "md", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lu2.LuX, {}) })
|
|
3807
|
+
}
|
|
3808
|
+
)
|
|
3809
|
+
]
|
|
3810
|
+
}
|
|
3811
|
+
),
|
|
3812
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
3813
|
+
"div",
|
|
3814
|
+
{
|
|
3815
|
+
style: {
|
|
3816
|
+
padding: "1rem",
|
|
3817
|
+
flex: 1,
|
|
3818
|
+
overflowY: "auto",
|
|
3819
|
+
backgroundColor: "var(--chakra-colors-bg-panel)",
|
|
3820
|
+
position: "relative"
|
|
3821
|
+
},
|
|
3822
|
+
children
|
|
3823
|
+
}
|
|
3824
|
+
)
|
|
3825
|
+
]
|
|
3826
|
+
}
|
|
3827
|
+
)
|
|
3828
|
+
] })
|
|
3829
|
+
] });
|
|
3830
|
+
};
|
|
3831
|
+
|
|
3832
|
+
// src/components/sidebar/settings-sidebar.tsx
|
|
3833
|
+
var import_react21 = require("@chakra-ui/react");
|
|
3834
|
+
var import_react22 = require("@chakra-ui/react");
|
|
3835
|
+
var import_next_themes = require("next-themes");
|
|
3836
|
+
var import_react23 = require("react");
|
|
3837
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3838
|
+
var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
3839
|
+
const { setTheme, resolvedTheme } = (0, import_next_themes.useTheme)();
|
|
3840
|
+
const { toast } = useToast();
|
|
3841
|
+
const { settings, isLoaded, updateEndpoints, updatePreferredFeeDenom, defaultSettings } = useSettings();
|
|
3842
|
+
const { connectionType } = useConnectionType();
|
|
3843
|
+
const { feeTokens, isLoading: feeTokensLoading } = useFeeTokens();
|
|
3844
|
+
const [restEndpoint, setRestEndpoint] = (0, import_react23.useState)("");
|
|
3845
|
+
const [rpcEndpoint, setRpcEndpoint] = (0, import_react23.useState)("");
|
|
3846
|
+
const [isValidating, setIsValidating] = (0, import_react23.useState)(false);
|
|
3847
|
+
const [validationResults, setValidationResults] = (0, import_react23.useState)({});
|
|
3848
|
+
const [preferredFeeDenom, setPreferredFeeDenom] = (0, import_react23.useState)(void 0);
|
|
3849
|
+
(0, import_react23.useEffect)(() => {
|
|
3850
|
+
if (isLoaded) {
|
|
3851
|
+
setRestEndpoint(settings.endpoints.restEndpoint);
|
|
3852
|
+
setRpcEndpoint(settings.endpoints.rpcEndpoint);
|
|
3853
|
+
setPreferredFeeDenom(settings.preferredFeeDenom || getChainNativeAssetDenom());
|
|
3854
|
+
}
|
|
3855
|
+
}, [isLoaded, settings]);
|
|
3856
|
+
const handleValidateEndpoints = (0, import_react23.useCallback)(async (rest, rpc) => {
|
|
3857
|
+
setIsValidating(true);
|
|
3858
|
+
setValidationResults({});
|
|
3859
|
+
try {
|
|
3860
|
+
const results = await validateEndpoints(rest, rpc);
|
|
3861
|
+
setValidationResults({
|
|
3862
|
+
rest: results.rest,
|
|
3863
|
+
rpc: results.rpc
|
|
3864
|
+
});
|
|
3865
|
+
} catch (error) {
|
|
3866
|
+
console.error(error);
|
|
3867
|
+
setValidationResults({
|
|
3868
|
+
rest: { isValid: false, error: "Validation failed" },
|
|
3869
|
+
rpc: { isValid: false, error: "Validation failed" }
|
|
3870
|
+
});
|
|
3871
|
+
} finally {
|
|
3872
|
+
setIsValidating(false);
|
|
3873
|
+
setTimeout(() => setValidationResults({}), 1e4);
|
|
3874
|
+
}
|
|
3875
|
+
}, []);
|
|
3876
|
+
const handleSaveSettings = (0, import_react23.useCallback)(async (rest, rpc, feeDenom) => {
|
|
3877
|
+
setValidationResults({});
|
|
3878
|
+
const results = await validateEndpoints(rest, rpc);
|
|
3879
|
+
if (!results.isValid) {
|
|
3880
|
+
setValidationResults({
|
|
3881
|
+
rest: results.rest,
|
|
3882
|
+
rpc: results.rpc
|
|
3883
|
+
});
|
|
3884
|
+
setTimeout(() => setValidationResults({}), 1e4);
|
|
3885
|
+
return;
|
|
3886
|
+
}
|
|
3887
|
+
const endpointsSuccess = updateEndpoints({
|
|
3888
|
+
restEndpoint: rest.trim(),
|
|
3889
|
+
rpcEndpoint: convertToWebSocketUrl(rpc.trim())
|
|
3890
|
+
});
|
|
3891
|
+
const feeTokenSuccess = updatePreferredFeeDenom(feeDenom);
|
|
3892
|
+
if (endpointsSuccess && feeTokenSuccess) {
|
|
3893
|
+
toast.success("Success!", "Settings have been saved.");
|
|
3894
|
+
}
|
|
3895
|
+
}, []);
|
|
3896
|
+
const handleResetToDefaults = (0, import_react23.useCallback)(() => {
|
|
3897
|
+
setRestEndpoint(defaultSettings.endpoints.restEndpoint);
|
|
3898
|
+
setRpcEndpoint(defaultSettings.endpoints.rpcEndpoint);
|
|
3899
|
+
setPreferredFeeDenom(defaultSettings.preferredFeeDenom);
|
|
3900
|
+
setValidationResults({});
|
|
3901
|
+
}, []);
|
|
3902
|
+
const connectionStatusText = (0, import_react23.useMemo)(() => {
|
|
3903
|
+
switch (connectionType) {
|
|
3904
|
+
case CONNECTION_TYPE_NONE:
|
|
3905
|
+
return "Failed";
|
|
3906
|
+
case CONNECTION_TYPE_POLLING:
|
|
3907
|
+
return "Polling";
|
|
3908
|
+
case CONNECTION_TYPE_WS:
|
|
3909
|
+
return "Connected";
|
|
3910
|
+
}
|
|
3911
|
+
}, [connectionType]);
|
|
3912
|
+
const connectionStatusBadgeColor = (0, import_react23.useMemo)(() => {
|
|
3913
|
+
switch (connectionType) {
|
|
3914
|
+
case CONNECTION_TYPE_NONE:
|
|
3915
|
+
return "red";
|
|
3916
|
+
case CONNECTION_TYPE_POLLING:
|
|
3917
|
+
return "orange";
|
|
3918
|
+
case CONNECTION_TYPE_WS:
|
|
3919
|
+
return "green";
|
|
3920
|
+
}
|
|
3921
|
+
}, [connectionType]);
|
|
3922
|
+
const feeTokensCollection = (0, import_react23.useMemo)(() => (0, import_react21.createListCollection)({
|
|
3923
|
+
items: feeTokens.map((token) => ({
|
|
3924
|
+
label: token.ticker || token.name,
|
|
3925
|
+
value: token.denom,
|
|
3926
|
+
name: token.ticker || token.name
|
|
3927
|
+
}))
|
|
3928
|
+
}), [feeTokens]);
|
|
3929
|
+
const handleFeeTokenChange = (0, import_react23.useCallback)((denom) => {
|
|
3930
|
+
setPreferredFeeDenom(denom || void 0);
|
|
3931
|
+
}, []);
|
|
3932
|
+
const hasUnsavedChanges = restEndpoint !== settings.endpoints.restEndpoint || rpcEndpoint !== settings.endpoints.rpcEndpoint || preferredFeeDenom !== settings.preferredFeeDenom;
|
|
3933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.VStack, { gap: "6", align: "stretch", children: [
|
|
3934
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.Box, { children: [
|
|
3935
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", fontWeight: "medium", mb: "3", children: "Appearance" }),
|
|
3936
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.VStack, { gap: "3", align: "stretch", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.HStack, { justify: "space-between", children: [
|
|
3937
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", children: "Dark Mode" }),
|
|
3938
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3939
|
+
import_react21.Switch.Root,
|
|
3940
|
+
{
|
|
3941
|
+
checked: resolvedTheme === "dark",
|
|
3942
|
+
onCheckedChange: (details) => {
|
|
3943
|
+
const newTheme = details.checked ? "dark" : "light";
|
|
3944
|
+
setTheme(newTheme);
|
|
3945
|
+
},
|
|
3946
|
+
children: [
|
|
3947
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Switch.HiddenInput, {}),
|
|
3948
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Switch.Control, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Switch.Thumb, {}) })
|
|
3949
|
+
]
|
|
3950
|
+
}
|
|
3951
|
+
)
|
|
3952
|
+
] }) })
|
|
3953
|
+
] }),
|
|
3954
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Separator, {}),
|
|
3955
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.Box, { children: [
|
|
3956
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", fontWeight: "medium", mb: "3", children: "Fee Token Preference" }),
|
|
3957
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.VStack, { gap: "3", align: "stretch", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.Box, { children: [
|
|
3958
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3959
|
+
import_react22.Select.Root,
|
|
3960
|
+
{
|
|
3961
|
+
collection: feeTokensCollection,
|
|
3962
|
+
size: "sm",
|
|
3963
|
+
value: preferredFeeDenom ? [preferredFeeDenom] : [""],
|
|
3964
|
+
onValueChange: (details) => handleFeeTokenChange(details.value[0] || ""),
|
|
3965
|
+
disabled: feeTokensLoading,
|
|
3966
|
+
children: [
|
|
3967
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.Label, { children: "Preferred Fee Token" }),
|
|
3968
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.HiddenSelect, {}),
|
|
3969
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react22.Select.Control, { children: [
|
|
3970
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.ValueText, { placeholder: "Native Token (default)" }) }),
|
|
3971
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.IndicatorGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.Indicator, {}) })
|
|
3972
|
+
] }),
|
|
3973
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.Positioner, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.Content, { children: feeTokensCollection.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react22.Select.Item, { item, children: [
|
|
3974
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { children: item.label }),
|
|
3975
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react22.Select.ItemIndicator, {})
|
|
3976
|
+
] }, item.value)) }) }) })
|
|
3977
|
+
]
|
|
3978
|
+
}
|
|
3979
|
+
),
|
|
3980
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "xs", color: "fg.muted", mt: "2", children: "Select your preferred token for paying transaction fees. Only tokens with liquidity pools paired with the native token are available." })
|
|
3981
|
+
] }) })
|
|
3982
|
+
] }),
|
|
3983
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Separator, {}),
|
|
3984
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.Box, { children: [
|
|
3985
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", fontWeight: "medium", mb: "3", children: "BeeZee Endpoints" }),
|
|
3986
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.VStack, { gap: "4", align: "stretch", children: [
|
|
3987
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.HStack, { gap: "2", align: "center", justify: "space-between", children: [
|
|
3988
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", mb: "1", children: "Status: " }),
|
|
3989
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Badge, { colorPalette: connectionStatusBadgeColor, children: connectionStatusText })
|
|
3990
|
+
] }) }),
|
|
3991
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.Box, { children: [
|
|
3992
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", mb: "1", children: "REST Endpoint" }),
|
|
3993
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "xs", color: "fg.muted", mb: "2", children: "Note: Endpoint must have CORS enabled to work in browser" }),
|
|
3994
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3995
|
+
import_react21.Input,
|
|
3996
|
+
{
|
|
3997
|
+
size: "sm",
|
|
3998
|
+
placeholder: "https://rest.getbze.com",
|
|
3999
|
+
value: restEndpoint,
|
|
4000
|
+
onChange: (e) => setRestEndpoint(e.target.value)
|
|
4001
|
+
}
|
|
4002
|
+
),
|
|
4003
|
+
validationResults.rest && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4004
|
+
import_react21.Box,
|
|
4005
|
+
{
|
|
4006
|
+
mt: "2",
|
|
4007
|
+
p: "3",
|
|
4008
|
+
bgGradient: "to-br",
|
|
4009
|
+
gradientFrom: validationResults.rest.isValid ? "green.500/15" : "red.500/15",
|
|
4010
|
+
gradientTo: validationResults.rest.isValid ? "green.600/15" : "red.600/15",
|
|
4011
|
+
borderWidth: "1px",
|
|
4012
|
+
borderColor: validationResults.rest.isValid ? "green.500/30" : "red.500/30",
|
|
4013
|
+
borderRadius: "md",
|
|
4014
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", color: validationResults.rest.isValid ? "green.700" : "red.700", _dark: { color: validationResults.rest.isValid ? "green.300" : "red.300" }, children: validationResults.rest.error || "REST endpoint is valid" })
|
|
4015
|
+
}
|
|
4016
|
+
)
|
|
4017
|
+
] }),
|
|
4018
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.Box, { children: [
|
|
4019
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", mb: "1", children: "RPC Endpoint" }),
|
|
4020
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "xs", color: "fg.muted", mb: "2", children: "Note: Must support WebSocket (WS/WSS) connections" }),
|
|
4021
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4022
|
+
import_react21.Input,
|
|
4023
|
+
{
|
|
4024
|
+
size: "sm",
|
|
4025
|
+
placeholder: "wss://rpc.getbze.com",
|
|
4026
|
+
value: rpcEndpoint,
|
|
4027
|
+
onChange: (e) => setRpcEndpoint(e.target.value)
|
|
4028
|
+
}
|
|
4029
|
+
),
|
|
4030
|
+
validationResults.rpc && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4031
|
+
import_react21.Box,
|
|
4032
|
+
{
|
|
4033
|
+
mt: "2",
|
|
4034
|
+
p: "3",
|
|
4035
|
+
bgGradient: "to-br",
|
|
4036
|
+
gradientFrom: validationResults.rpc.isValid ? "green.500/15" : "red.500/15",
|
|
4037
|
+
gradientTo: validationResults.rpc.isValid ? "green.600/15" : "red.600/15",
|
|
4038
|
+
borderWidth: "1px",
|
|
4039
|
+
borderColor: validationResults.rpc.isValid ? "green.500/30" : "red.500/30",
|
|
4040
|
+
borderRadius: "md",
|
|
4041
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Text, { fontSize: "sm", color: validationResults.rpc.isValid ? "green.700" : "red.700", _dark: { color: validationResults.rpc.isValid ? "green.300" : "red.300" }, children: validationResults.rpc.error || "RPC endpoint is valid" })
|
|
4042
|
+
}
|
|
4043
|
+
)
|
|
4044
|
+
] }),
|
|
4045
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4046
|
+
import_react21.Button,
|
|
4047
|
+
{
|
|
4048
|
+
size: "sm",
|
|
4049
|
+
variant: "outline",
|
|
4050
|
+
onClick: () => handleValidateEndpoints(restEndpoint, rpcEndpoint),
|
|
4051
|
+
loading: isValidating,
|
|
4052
|
+
disabled: !restEndpoint.trim() || !rpcEndpoint.trim(),
|
|
4053
|
+
children: isValidating ? "Validating..." : "Validate Endpoints"
|
|
4054
|
+
}
|
|
4055
|
+
)
|
|
4056
|
+
] })
|
|
4057
|
+
] }),
|
|
4058
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react21.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react21.VStack, { gap: "3", children: [
|
|
4059
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4060
|
+
import_react21.Button,
|
|
4061
|
+
{
|
|
4062
|
+
size: "sm",
|
|
4063
|
+
width: "full",
|
|
4064
|
+
onClick: () => handleSaveSettings(restEndpoint, rpcEndpoint, preferredFeeDenom),
|
|
4065
|
+
colorPalette: accentColor,
|
|
4066
|
+
disabled: !hasUnsavedChanges,
|
|
4067
|
+
children: "Save Settings"
|
|
4068
|
+
}
|
|
4069
|
+
),
|
|
4070
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4071
|
+
import_react21.Button,
|
|
4072
|
+
{
|
|
4073
|
+
size: "sm",
|
|
4074
|
+
width: "full",
|
|
4075
|
+
variant: "outline",
|
|
4076
|
+
onClick: handleResetToDefaults,
|
|
4077
|
+
children: "Reset to Defaults"
|
|
4078
|
+
}
|
|
4079
|
+
)
|
|
4080
|
+
] }) })
|
|
4081
|
+
] });
|
|
4082
|
+
};
|
|
4083
|
+
|
|
4084
|
+
// src/components/sidebar/wallet-sidebar.tsx
|
|
4085
|
+
var import_styles = require("@interchain-kit/react/styles.css");
|
|
4086
|
+
var import_react24 = require("@interchain-kit/react");
|
|
4087
|
+
var import_react25 = require("@chakra-ui/react");
|
|
4088
|
+
var import_lu3 = require("react-icons/lu");
|
|
4089
|
+
var import_react26 = require("react");
|
|
4090
|
+
var import_core = require("@interchain-kit/core");
|
|
4091
|
+
var import_bignumber10 = __toESM(require("bignumber.js"));
|
|
4092
|
+
var import_bzejs5 = require("@bze/bzejs");
|
|
4093
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
4094
|
+
var validateAmount = (amount, coin, onError) => {
|
|
4095
|
+
if (!coin) return;
|
|
4096
|
+
if (amount === "") return;
|
|
4097
|
+
const amountNumber = (0, import_bignumber10.default)(amount);
|
|
4098
|
+
if (amountNumber.isNaN()) {
|
|
4099
|
+
onError("Invalid amount");
|
|
4100
|
+
return;
|
|
4101
|
+
}
|
|
4102
|
+
const coinBalance = uAmountToBigNumberAmount(coin.amount, coin.decimals);
|
|
4103
|
+
if (coinBalance.isLessThan(amount)) {
|
|
4104
|
+
onError("Insufficient balance");
|
|
4105
|
+
} else {
|
|
4106
|
+
onError("");
|
|
4107
|
+
}
|
|
4108
|
+
};
|
|
4109
|
+
var BalanceItem = ({ asset, onClick, accentColor }) => {
|
|
4110
|
+
const [showSendButton, setShowSendButton] = (0, import_react26.useState)(false);
|
|
4111
|
+
const formattedBalanceAmount = (0, import_react26.useMemo)(() => {
|
|
4112
|
+
var _a2;
|
|
4113
|
+
return prettyAmount(uAmountToBigNumberAmount(asset.amount, (_a2 = asset.decimals) != null ? _a2 : 0));
|
|
4114
|
+
}, [asset.amount, asset.decimals]);
|
|
4115
|
+
const formattedBalanceUSDValue = (0, import_react26.useMemo)(() => {
|
|
4116
|
+
return shortNumberFormat(asset.USDValue);
|
|
4117
|
+
}, [asset.USDValue]);
|
|
4118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4119
|
+
import_react25.Box,
|
|
4120
|
+
{
|
|
4121
|
+
p: "3",
|
|
4122
|
+
bgGradient: "to-br",
|
|
4123
|
+
gradientFrom: `${accentColor}.500/5`,
|
|
4124
|
+
gradientTo: `${accentColor}.600/5`,
|
|
4125
|
+
borderRadius: "md",
|
|
4126
|
+
borderWidth: "1px",
|
|
4127
|
+
borderColor: `${accentColor}.500/15`,
|
|
4128
|
+
_hover: {
|
|
4129
|
+
gradientFrom: `${accentColor}.500/10`,
|
|
4130
|
+
gradientTo: `${accentColor}.600/10`,
|
|
4131
|
+
borderColor: `${accentColor}.500/25`
|
|
4132
|
+
},
|
|
4133
|
+
transition: "all 0.2s",
|
|
4134
|
+
onMouseLeave: () => setShowSendButton(false),
|
|
4135
|
+
onMouseEnter: () => setShowSendButton(true),
|
|
4136
|
+
children: [
|
|
4137
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { justify: "space-between", mb: "2", children: [
|
|
4138
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { children: [
|
|
4139
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4140
|
+
import_react25.Image,
|
|
4141
|
+
{
|
|
4142
|
+
src: asset.logo,
|
|
4143
|
+
alt: asset.ticker,
|
|
4144
|
+
width: "20px",
|
|
4145
|
+
height: "20px",
|
|
4146
|
+
borderRadius: "full"
|
|
4147
|
+
}
|
|
4148
|
+
),
|
|
4149
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "sm", fontWeight: "medium", children: asset.ticker }),
|
|
4150
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "xs", color: "fg.muted", children: asset.name }),
|
|
4151
|
+
isIbcDenom(asset.denom) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Badge, { size: "xs", colorPalette: accentColor, children: "IBC" })
|
|
4152
|
+
] }),
|
|
4153
|
+
showSendButton && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.HStack, { justify: "end", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Button, { size: "2xs", variant: "outline", onClick, children: "Send" }) })
|
|
4154
|
+
] }),
|
|
4155
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { justify: "space-between", children: [
|
|
4156
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HighlightText, { fontSize: "sm", fontFamily: "mono", children: formattedBalanceAmount }),
|
|
4157
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(HighlightText, { fontSize: "sm", color: "fg.muted", children: [
|
|
4158
|
+
"$",
|
|
4159
|
+
formattedBalanceUSDValue
|
|
4160
|
+
] })
|
|
4161
|
+
] })
|
|
4162
|
+
]
|
|
4163
|
+
}
|
|
4164
|
+
);
|
|
4165
|
+
};
|
|
4166
|
+
var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
4167
|
+
const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
|
|
4168
|
+
const [selectedCoin, setSelectedCoin] = (0, import_react26.useState)();
|
|
4169
|
+
const [sendAmount, setSendAmount] = (0, import_react26.useState)("");
|
|
4170
|
+
const [sendAmountError, setSendAmountError] = (0, import_react26.useState)("");
|
|
4171
|
+
const [recipient, setRecipient] = (0, import_react26.useState)("");
|
|
4172
|
+
const [recipientError, setRecipientError] = (0, import_react26.useState)("");
|
|
4173
|
+
const [memo, setMemo] = (0, import_react26.useState)("");
|
|
4174
|
+
const [memoError, setMemoError] = (0, import_react26.useState)("");
|
|
4175
|
+
const { toast } = useToast();
|
|
4176
|
+
const { status, address } = (0, import_react24.useChain)(getChainName());
|
|
4177
|
+
const { tx } = useSDKTx(getChainName());
|
|
4178
|
+
const coinsCollection = (0, import_react25.createListCollection)({
|
|
4179
|
+
items: balances.map((item) => {
|
|
4180
|
+
var _a2;
|
|
4181
|
+
return {
|
|
4182
|
+
label: `${item.ticker} - ${shortNumberFormat(uAmountToBigNumberAmount(item.amount, (_a2 = item == null ? void 0 : item.decimals) != null ? _a2 : 0))}`,
|
|
4183
|
+
value: item.ticker,
|
|
4184
|
+
logo: item.logo
|
|
4185
|
+
};
|
|
4186
|
+
})
|
|
4187
|
+
});
|
|
4188
|
+
const isValidForm = (0, import_react26.useMemo)(() => {
|
|
4189
|
+
return selectedCoin && memoError === "" && recipientError === "" && sendAmountError === "" && sendAmount !== "" && recipient !== "";
|
|
4190
|
+
}, [selectedCoin, memoError, recipientError, sendAmountError, sendAmount, recipient]);
|
|
4191
|
+
const resetSendForm = (0, import_react26.useCallback)(() => {
|
|
4192
|
+
setSelectedCoin(void 0);
|
|
4193
|
+
setSendAmount("");
|
|
4194
|
+
setRecipient("");
|
|
4195
|
+
setMemo("");
|
|
4196
|
+
}, []);
|
|
4197
|
+
const handleSend = (0, import_react26.useCallback)(async () => {
|
|
4198
|
+
var _a2, _b2;
|
|
4199
|
+
if (!isValidForm) {
|
|
4200
|
+
toast.error("Can not send coins!", "Please check the input data.");
|
|
4201
|
+
return;
|
|
4202
|
+
}
|
|
4203
|
+
if (status !== import_core.WalletState.Connected) {
|
|
4204
|
+
toast.error("Wallet not connected!", "Please connect your wallet first.");
|
|
4205
|
+
return;
|
|
4206
|
+
}
|
|
4207
|
+
const { send } = import_bzejs5.cosmos.bank.v1beta1.MessageComposer.withTypeUrl;
|
|
4208
|
+
const msg = send({
|
|
4209
|
+
fromAddress: address,
|
|
4210
|
+
toAddress: recipient,
|
|
4211
|
+
amount: [{
|
|
4212
|
+
denom: (_a2 = selectedCoin == null ? void 0 : selectedCoin.denom) != null ? _a2 : "",
|
|
4213
|
+
amount: amountToUAmount(sendAmount, (_b2 = selectedCoin == null ? void 0 : selectedCoin.decimals) != null ? _b2 : 0)
|
|
4214
|
+
}]
|
|
4215
|
+
});
|
|
4216
|
+
setIsLoading(true);
|
|
4217
|
+
await tx([msg], { memo: memo.length > 0 ? memo : void 0 });
|
|
4218
|
+
resetSendForm();
|
|
4219
|
+
setIsLoading(false);
|
|
4220
|
+
onClose();
|
|
4221
|
+
}, [address, memo, onClose, recipient, selectedCoin, sendAmount, status]);
|
|
4222
|
+
const handleCancel = (0, import_react26.useCallback)(() => {
|
|
4223
|
+
resetSendForm();
|
|
4224
|
+
onClose();
|
|
4225
|
+
}, [onClose, resetSendForm]);
|
|
4226
|
+
const onRecipientChange = (0, import_react26.useCallback)((recipient2) => {
|
|
4227
|
+
setRecipient(recipient2);
|
|
4228
|
+
if (recipient2.length === 0) {
|
|
4229
|
+
setRecipientError("");
|
|
4230
|
+
return;
|
|
4231
|
+
}
|
|
4232
|
+
const validate = validateBZEBech32Address(recipient2);
|
|
4233
|
+
if (validate.isValid) {
|
|
4234
|
+
setRecipientError("");
|
|
4235
|
+
} else {
|
|
4236
|
+
setRecipientError(validate.message);
|
|
4237
|
+
}
|
|
4238
|
+
}, []);
|
|
4239
|
+
const onAmountChange = (0, import_react26.useCallback)((amount) => {
|
|
4240
|
+
setSendAmount(sanitizeNumberInput(amount));
|
|
4241
|
+
setSendAmountError("");
|
|
4242
|
+
}, []);
|
|
4243
|
+
const onCoinSelectChange = (0, import_react26.useCallback)((ticker) => {
|
|
4244
|
+
if (ticker === "") return;
|
|
4245
|
+
const selectedCoin2 = balances.find((item) => item.ticker === ticker);
|
|
4246
|
+
if (selectedCoin2) {
|
|
4247
|
+
setSelectedCoin(selectedCoin2);
|
|
4248
|
+
validateAmount(sendAmount, selectedCoin2, setSendAmountError);
|
|
4249
|
+
}
|
|
4250
|
+
}, [sendAmount, balances]);
|
|
4251
|
+
const setMaxAmount = (0, import_react26.useCallback)(() => {
|
|
4252
|
+
if (!selectedCoin) return;
|
|
4253
|
+
const maxAmount = uAmountToBigNumberAmount(selectedCoin.amount, selectedCoin.decimals);
|
|
4254
|
+
onAmountChange(maxAmount.toString());
|
|
4255
|
+
validateAmount(maxAmount.toString(), selectedCoin, setSendAmountError);
|
|
4256
|
+
}, [selectedCoin, onAmountChange]);
|
|
4257
|
+
const onMemoChange = (0, import_react26.useCallback)((memo2) => {
|
|
4258
|
+
setMemo(memo2);
|
|
4259
|
+
if (memo2.length > 256) {
|
|
4260
|
+
setMemoError("Memo must be less than or equal to 256 characters");
|
|
4261
|
+
} else {
|
|
4262
|
+
setMemoError("");
|
|
4263
|
+
}
|
|
4264
|
+
}, []);
|
|
4265
|
+
(0, import_react26.useEffect)(() => {
|
|
4266
|
+
if (selectedTicker !== "") {
|
|
4267
|
+
onCoinSelectChange(selectedTicker);
|
|
4268
|
+
}
|
|
4269
|
+
}, [onCoinSelectChange, selectedTicker]);
|
|
4270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.VStack, { gap: "4", align: "stretch", children: [
|
|
4271
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { justify: "space-between", align: "center", children: [
|
|
4272
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "sm", fontWeight: "medium", children: "Send Coins" }),
|
|
4273
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4274
|
+
import_react25.Button,
|
|
4275
|
+
{
|
|
4276
|
+
size: "xs",
|
|
4277
|
+
variant: "ghost",
|
|
4278
|
+
onClick: handleCancel,
|
|
4279
|
+
disabled: isLoading,
|
|
4280
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lu3.LuX, { size: "14" })
|
|
4281
|
+
}
|
|
4282
|
+
)
|
|
4283
|
+
] }),
|
|
4284
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Box, { children: [
|
|
4285
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4286
|
+
import_react25.Select.Root,
|
|
4287
|
+
{
|
|
4288
|
+
collection: coinsCollection,
|
|
4289
|
+
size: "sm",
|
|
4290
|
+
value: (selectedCoin == null ? void 0 : selectedCoin.ticker) ? [selectedCoin.ticker] : [],
|
|
4291
|
+
onValueChange: (details) => onCoinSelectChange(details.value[0] || ""),
|
|
4292
|
+
children: [
|
|
4293
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.Label, { children: "Coin" }),
|
|
4294
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.HiddenSelect, {}),
|
|
4295
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Select.Control, { children: [
|
|
4296
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.ValueText, { placeholder: "Select coin" }) }),
|
|
4297
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.IndicatorGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.Indicator, {}) })
|
|
4298
|
+
] }),
|
|
4299
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.Positioner, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.Content, { children: coinsCollection.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Select.Item, { item, children: [
|
|
4300
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { gap: "2", children: [
|
|
4301
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4302
|
+
import_react25.Image,
|
|
4303
|
+
{
|
|
4304
|
+
src: item.logo,
|
|
4305
|
+
alt: item.value,
|
|
4306
|
+
width: "16px",
|
|
4307
|
+
height: "16px",
|
|
4308
|
+
borderRadius: "full"
|
|
4309
|
+
}
|
|
4310
|
+
),
|
|
4311
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { children: item.label })
|
|
4312
|
+
] }),
|
|
4313
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Select.ItemIndicator, {})
|
|
4314
|
+
] }, item.value)) }) }) })
|
|
4315
|
+
]
|
|
4316
|
+
}
|
|
4317
|
+
),
|
|
4318
|
+
selectedCoin && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4319
|
+
import_react25.Box,
|
|
4320
|
+
{
|
|
4321
|
+
mt: "2",
|
|
4322
|
+
p: "3",
|
|
4323
|
+
bgGradient: "to-br",
|
|
4324
|
+
gradientFrom: `${accentColor}.500/10`,
|
|
4325
|
+
gradientTo: `${accentColor}.600/10`,
|
|
4326
|
+
borderRadius: "md",
|
|
4327
|
+
borderWidth: "1px",
|
|
4328
|
+
borderColor: `${accentColor}.500/30`,
|
|
4329
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { justify: "space-between", children: [
|
|
4330
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "xs", color: "fg.muted", children: "Available:" }),
|
|
4331
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.VStack, { gap: "0", align: "end", children: [
|
|
4332
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Text, { fontSize: "sm", fontWeight: "medium", children: [
|
|
4333
|
+
uAmountToAmount(selectedCoin.amount, selectedCoin.decimals),
|
|
4334
|
+
" ",
|
|
4335
|
+
selectedCoin.ticker
|
|
4336
|
+
] }),
|
|
4337
|
+
selectedCoin.USDValue.gt(0) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Text, { fontSize: "xs", color: "fg.muted", children: [
|
|
4338
|
+
"\u2248 $",
|
|
4339
|
+
shortNumberFormat(selectedCoin.USDValue)
|
|
4340
|
+
] })
|
|
4341
|
+
] })
|
|
4342
|
+
] })
|
|
4343
|
+
}
|
|
4344
|
+
)
|
|
4345
|
+
] }),
|
|
4346
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Field.Root, { invalid: sendAmountError !== "", children: [
|
|
4347
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Field.Label, { children: "Amount" }),
|
|
4348
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Group, { attached: true, w: "full", maxW: "sm", children: [
|
|
4349
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4350
|
+
import_react25.Input,
|
|
4351
|
+
{
|
|
4352
|
+
size: "sm",
|
|
4353
|
+
placeholder: "Amount to send",
|
|
4354
|
+
value: sendAmount,
|
|
4355
|
+
onChange: (e) => onAmountChange(e.target.value),
|
|
4356
|
+
onBlur: () => validateAmount(sendAmount, selectedCoin, setSendAmountError)
|
|
4357
|
+
}
|
|
4358
|
+
),
|
|
4359
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Button, { variant: "outline", size: "sm", onClick: setMaxAmount, disabled: isLoading, children: "Max" })
|
|
4360
|
+
] }),
|
|
4361
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Field.ErrorText, { children: sendAmountError })
|
|
4362
|
+
] }) }),
|
|
4363
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Field.Root, { invalid: recipientError !== "", children: [
|
|
4364
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Field.Label, { children: "Recipient Address" }),
|
|
4365
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4366
|
+
import_react25.Input,
|
|
4367
|
+
{
|
|
4368
|
+
size: "sm",
|
|
4369
|
+
placeholder: "bze...2a1b",
|
|
4370
|
+
value: recipient,
|
|
4371
|
+
onChange: (e) => onRecipientChange(e.target.value)
|
|
4372
|
+
}
|
|
4373
|
+
),
|
|
4374
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Field.ErrorText, { children: recipientError })
|
|
4375
|
+
] }) }),
|
|
4376
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Field.Root, { invalid: memoError !== "", children: [
|
|
4377
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Field.Label, { children: [
|
|
4378
|
+
"Memo",
|
|
4379
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4380
|
+
import_react25.Field.RequiredIndicator,
|
|
4381
|
+
{
|
|
4382
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Badge, { size: "xs", variant: "surface", children: "Optional" })
|
|
4383
|
+
}
|
|
4384
|
+
)
|
|
4385
|
+
] }),
|
|
4386
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4387
|
+
import_react25.Textarea,
|
|
4388
|
+
{
|
|
4389
|
+
size: "sm",
|
|
4390
|
+
placeholder: "Transaction memo",
|
|
4391
|
+
rows: 3,
|
|
4392
|
+
value: memo,
|
|
4393
|
+
onChange: (e) => onMemoChange(e.target.value),
|
|
4394
|
+
resize: "none"
|
|
4395
|
+
}
|
|
4396
|
+
),
|
|
4397
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Field.ErrorText, { children: memoError })
|
|
4398
|
+
] }) }),
|
|
4399
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { gap: "2", children: [
|
|
4400
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4401
|
+
import_react25.Button,
|
|
4402
|
+
{
|
|
4403
|
+
size: "sm",
|
|
4404
|
+
flex: "1",
|
|
4405
|
+
onClick: handleSend,
|
|
4406
|
+
colorPalette: accentColor,
|
|
4407
|
+
disabled: !isValidForm || isLoading,
|
|
4408
|
+
loading: isLoading,
|
|
4409
|
+
loadingText: "Sending...",
|
|
4410
|
+
children: "Send"
|
|
4411
|
+
}
|
|
4412
|
+
),
|
|
4413
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4414
|
+
import_react25.Button,
|
|
4415
|
+
{
|
|
4416
|
+
size: "sm",
|
|
4417
|
+
flex: "1",
|
|
4418
|
+
variant: "outline",
|
|
4419
|
+
onClick: handleCancel,
|
|
4420
|
+
disabled: isLoading,
|
|
4421
|
+
children: "Cancel"
|
|
4422
|
+
}
|
|
4423
|
+
)
|
|
4424
|
+
] })
|
|
4425
|
+
] });
|
|
4426
|
+
};
|
|
4427
|
+
var WalletSidebarContent = ({ accentColor = "blue" }) => {
|
|
4428
|
+
const [viewState, setViewState] = (0, import_react26.useState)("balances");
|
|
4429
|
+
const [isDisconnecting, setIsDisconnecting] = (0, import_react26.useState)(false);
|
|
4430
|
+
const [showCopiedTooltip, setShowCopiedTooltip] = (0, import_react26.useState)(false);
|
|
4431
|
+
const [clickedBalance, setClickedBalance] = (0, import_react26.useState)("");
|
|
4432
|
+
const copyButtonRef = (0, import_react26.useRef)(null);
|
|
4433
|
+
const {
|
|
4434
|
+
status,
|
|
4435
|
+
username,
|
|
4436
|
+
address,
|
|
4437
|
+
disconnect,
|
|
4438
|
+
connect
|
|
4439
|
+
} = (0, import_react24.useChain)(getChainName());
|
|
4440
|
+
const { assetsBalances, isLoading: assetsLoading } = useBalances();
|
|
4441
|
+
const balancesWithoutLps = (0, import_react26.useMemo)(() => {
|
|
4442
|
+
if (assetsLoading) return [];
|
|
4443
|
+
return assetsBalances.filter((asset) => !isLpDenom(asset.denom));
|
|
4444
|
+
}, [assetsLoading, assetsBalances]);
|
|
4445
|
+
const nativeDenom = getChainNativeAssetDenom();
|
|
4446
|
+
const sortedBalances = (0, import_react26.useMemo)(() => {
|
|
4447
|
+
return balancesWithoutLps.sort((a, b) => {
|
|
4448
|
+
if (a.denom === nativeDenom) return -1;
|
|
4449
|
+
if (b.denom === nativeDenom) return 1;
|
|
4450
|
+
if (a.verified && !b.verified) return -1;
|
|
4451
|
+
if (!a.verified && b.verified) return 1;
|
|
4452
|
+
const aHasBalance = a.amount.gt(0);
|
|
4453
|
+
const bHasBalance = b.amount.gt(0);
|
|
4454
|
+
if (aHasBalance && !bHasBalance) return -1;
|
|
4455
|
+
if (!aHasBalance && bHasBalance) return 1;
|
|
4456
|
+
if (aHasBalance && bHasBalance) {
|
|
4457
|
+
return a.USDValue.gt(b.USDValue) ? -1 : 1;
|
|
4458
|
+
}
|
|
4459
|
+
return 0;
|
|
4460
|
+
});
|
|
4461
|
+
}, [balancesWithoutLps]);
|
|
4462
|
+
const walletAddress = (0, import_react26.useMemo)(() => stringTruncateFromCenter(address != null ? address : "", 16), [address]);
|
|
4463
|
+
const handleCopyAddress = () => {
|
|
4464
|
+
navigator.clipboard.writeText(address);
|
|
4465
|
+
setShowCopiedTooltip(true);
|
|
4466
|
+
setTimeout(() => setShowCopiedTooltip(false), 2e3);
|
|
4467
|
+
};
|
|
4468
|
+
const handleCancel = (0, import_react26.useCallback)(() => {
|
|
4469
|
+
setViewState("balances");
|
|
4470
|
+
setClickedBalance("");
|
|
4471
|
+
}, []);
|
|
4472
|
+
const onBalanceClick = (0, import_react26.useCallback)((ticker) => {
|
|
4473
|
+
setClickedBalance(ticker);
|
|
4474
|
+
setViewState("send");
|
|
4475
|
+
}, []);
|
|
4476
|
+
const handleDisconnectAll = (0, import_react26.useCallback)(async () => {
|
|
4477
|
+
setIsDisconnecting(true);
|
|
4478
|
+
try {
|
|
4479
|
+
console.log("Disconnected from all chains");
|
|
4480
|
+
} catch (error) {
|
|
4481
|
+
console.error("Error disconnecting:", error);
|
|
4482
|
+
} finally {
|
|
4483
|
+
disconnect();
|
|
4484
|
+
setIsDisconnecting(false);
|
|
4485
|
+
}
|
|
4486
|
+
}, [disconnect]);
|
|
4487
|
+
const renderBalancesView = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.VStack, { gap: "6", align: "stretch", children: [
|
|
4488
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Box, { children: [
|
|
4489
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "sm", fontWeight: "medium", mb: "3", children: "Balances" }),
|
|
4490
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.VStack, { gap: "2", align: "stretch", children: sortedBalances.map((bal) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BalanceItem, { asset: bal, onClick: () => onBalanceClick(bal.ticker), accentColor }, bal.denom)) })
|
|
4491
|
+
] }),
|
|
4492
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Box, { children: [
|
|
4493
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "sm", fontWeight: "medium", mb: "3", children: "Quick Actions" }),
|
|
4494
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.VStack, { gap: "2", align: "stretch", children: [
|
|
4495
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4496
|
+
import_react25.Button,
|
|
4497
|
+
{
|
|
4498
|
+
size: "sm",
|
|
4499
|
+
variant: "outline",
|
|
4500
|
+
onClick: () => setViewState("send"),
|
|
4501
|
+
w: "full",
|
|
4502
|
+
disabled: assetsLoading,
|
|
4503
|
+
children: "Send"
|
|
4504
|
+
}
|
|
4505
|
+
),
|
|
4506
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4507
|
+
import_react25.Button,
|
|
4508
|
+
{
|
|
4509
|
+
size: "sm",
|
|
4510
|
+
variant: "outline",
|
|
4511
|
+
w: "full",
|
|
4512
|
+
onClick: () => openExternalLink("https://go.skip.build/?src_chain=1&src_asset=ethereum-native&dest_chain=beezee-1&dest_asset=ubze"),
|
|
4513
|
+
children: [
|
|
4514
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lu3.LuExternalLink, {}),
|
|
4515
|
+
"Cross-chain Deposit"
|
|
4516
|
+
]
|
|
4517
|
+
}
|
|
4518
|
+
),
|
|
4519
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4520
|
+
import_react25.Button,
|
|
4521
|
+
{
|
|
4522
|
+
size: "sm",
|
|
4523
|
+
variant: "outline",
|
|
4524
|
+
w: "full",
|
|
4525
|
+
onClick: () => openExternalLink(`${getChainExplorerURL(getChainName())}/account/${address}`),
|
|
4526
|
+
children: [
|
|
4527
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lu3.LuExternalLink, {}),
|
|
4528
|
+
"View on Explorer"
|
|
4529
|
+
]
|
|
4530
|
+
}
|
|
4531
|
+
)
|
|
4532
|
+
] })
|
|
4533
|
+
] }),
|
|
4534
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4535
|
+
import_react25.Button,
|
|
4536
|
+
{
|
|
4537
|
+
size: "sm",
|
|
4538
|
+
width: "full",
|
|
4539
|
+
variant: "outline",
|
|
4540
|
+
colorPalette: "red",
|
|
4541
|
+
onClick: handleDisconnectAll,
|
|
4542
|
+
loading: isDisconnecting,
|
|
4543
|
+
loadingText: "Disconnecting...",
|
|
4544
|
+
children: "Disconnect Wallet"
|
|
4545
|
+
}
|
|
4546
|
+
) })
|
|
4547
|
+
] });
|
|
4548
|
+
const statusColor = (0, import_react26.useMemo)(() => {
|
|
4549
|
+
switch (status) {
|
|
4550
|
+
case import_core.WalletState.Connected:
|
|
4551
|
+
return "green";
|
|
4552
|
+
case import_core.WalletState.Connecting:
|
|
4553
|
+
return "yellow";
|
|
4554
|
+
case import_core.WalletState.Disconnected:
|
|
4555
|
+
return "red";
|
|
4556
|
+
default:
|
|
4557
|
+
return "gray";
|
|
4558
|
+
}
|
|
4559
|
+
}, [status]);
|
|
4560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.VStack, { gap: "6", align: "stretch", children: [
|
|
4561
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Box, { children: [
|
|
4562
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react24.InterchainWalletModal, {}),
|
|
4563
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { justify: "space-between", mb: "3", children: [
|
|
4564
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "sm", fontWeight: "medium", children: "Wallet Status" }),
|
|
4565
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Badge, { colorPalette: statusColor, size: "sm", children: status })
|
|
4566
|
+
] }),
|
|
4567
|
+
status === import_core.WalletState.Connected && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4568
|
+
import_react25.Box,
|
|
4569
|
+
{
|
|
4570
|
+
p: "3",
|
|
4571
|
+
bgGradient: "to-br",
|
|
4572
|
+
gradientFrom: `${accentColor}.500/8`,
|
|
4573
|
+
gradientTo: `${accentColor}.600/8`,
|
|
4574
|
+
borderRadius: "md",
|
|
4575
|
+
borderWidth: "1px",
|
|
4576
|
+
borderColor: `${accentColor}.500/20`,
|
|
4577
|
+
children: [
|
|
4578
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "xs", color: "fg.muted", mb: "1", children: username != null ? username : "Address" }),
|
|
4579
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.HStack, { justify: "space-between", children: [
|
|
4580
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Text, { fontSize: "sm", fontFamily: "mono", children: walletAddress }),
|
|
4581
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react25.Box, { position: "relative", children: [
|
|
4582
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4583
|
+
import_react25.Button,
|
|
4584
|
+
{
|
|
4585
|
+
ref: copyButtonRef,
|
|
4586
|
+
size: "xs",
|
|
4587
|
+
variant: "ghost",
|
|
4588
|
+
onClick: handleCopyAddress,
|
|
4589
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lu3.LuCopy, {})
|
|
4590
|
+
}
|
|
4591
|
+
),
|
|
4592
|
+
showCopiedTooltip && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4593
|
+
import_react25.Box,
|
|
4594
|
+
{
|
|
4595
|
+
position: "absolute",
|
|
4596
|
+
top: "-35px",
|
|
4597
|
+
right: "0",
|
|
4598
|
+
bgGradient: "to-br",
|
|
4599
|
+
gradientFrom: `${accentColor}.500`,
|
|
4600
|
+
gradientTo: `${accentColor}.600`,
|
|
4601
|
+
color: "white",
|
|
4602
|
+
px: "3",
|
|
4603
|
+
py: "1.5",
|
|
4604
|
+
borderRadius: "md",
|
|
4605
|
+
fontSize: "xs",
|
|
4606
|
+
fontWeight: "semibold",
|
|
4607
|
+
whiteSpace: "nowrap",
|
|
4608
|
+
zIndex: "tooltip",
|
|
4609
|
+
shadow: "md",
|
|
4610
|
+
children: "Copied!"
|
|
4611
|
+
}
|
|
4612
|
+
)
|
|
4613
|
+
] })
|
|
4614
|
+
] })
|
|
4615
|
+
]
|
|
4616
|
+
}
|
|
4617
|
+
),
|
|
4618
|
+
status !== import_core.WalletState.Connected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4619
|
+
import_react25.Button,
|
|
4620
|
+
{
|
|
4621
|
+
size: "sm",
|
|
4622
|
+
variant: "solid",
|
|
4623
|
+
w: "full",
|
|
4624
|
+
onClick: connect,
|
|
4625
|
+
children: "Connect Wallet"
|
|
4626
|
+
}
|
|
4627
|
+
)
|
|
4628
|
+
] }),
|
|
4629
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react25.Separator, {}),
|
|
4630
|
+
status === import_core.WalletState.Connected && viewState === "balances" && renderBalancesView(),
|
|
4631
|
+
status === import_core.WalletState.Connected && viewState === "send" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SendForm, { balances: sortedBalances, onClose: handleCancel, selectedTicker: clickedBalance, accentColor })
|
|
4632
|
+
] });
|
|
4633
|
+
};
|
|
4634
|
+
|
|
4635
|
+
// src/components/settings-toggle.tsx
|
|
4636
|
+
var import_react27 = require("@chakra-ui/react");
|
|
4637
|
+
var import_lu4 = require("react-icons/lu");
|
|
4638
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
4639
|
+
function SettingsToggle({ accentColor }) {
|
|
4640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
4641
|
+
Sidebar,
|
|
4642
|
+
{
|
|
4643
|
+
ariaLabel: "Settings",
|
|
4644
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react27.Button, { variant: "subtle", size: { base: "sm", md: "md" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lu4.LuSettings, {}) }),
|
|
4645
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SettingsSidebarContent, { accentColor })
|
|
4646
|
+
}
|
|
4647
|
+
);
|
|
4648
|
+
}
|
|
4649
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
4650
|
+
0 && (module.exports = {
|
|
4651
|
+
ASSET_TYPE_FACTORY,
|
|
4652
|
+
ASSET_TYPE_IBC,
|
|
4653
|
+
ASSET_TYPE_LP,
|
|
4654
|
+
ASSET_TYPE_NATIVE,
|
|
4655
|
+
AssetsContext,
|
|
4656
|
+
BZE_CIRCLE_LOGO,
|
|
4657
|
+
BZE_TESTNET_2_SUGGEST_CHAIN,
|
|
4658
|
+
BZE_TESTNET_NETWORK,
|
|
4659
|
+
CHART_1D,
|
|
4660
|
+
CHART_1Y,
|
|
4661
|
+
CHART_30D,
|
|
4662
|
+
CHART_4H,
|
|
4663
|
+
CHART_7D,
|
|
4664
|
+
CONNECTION_TYPE_NONE,
|
|
4665
|
+
CONNECTION_TYPE_POLLING,
|
|
4666
|
+
CONNECTION_TYPE_WS,
|
|
4667
|
+
CURRENT_WALLET_BALANCE_EVENT,
|
|
4668
|
+
DEFAULT_SETTINGS,
|
|
4669
|
+
DEFAULT_TX_MEMO,
|
|
4670
|
+
ECOSYSTEM_MENU_LABEL,
|
|
4671
|
+
EPOCH_START_EVENT,
|
|
4672
|
+
EXCLUDED_ASSETS,
|
|
4673
|
+
EXCLUDED_MARKETS,
|
|
4674
|
+
HighlightText,
|
|
4675
|
+
LOCK_CHANGED_EVENT,
|
|
4676
|
+
LP_ASSETS_DECIMALS,
|
|
4677
|
+
MAINNET_CHAIN_INFO_FALLBACK,
|
|
4678
|
+
NEXT_BURN_CHANGED_EVENT,
|
|
4679
|
+
ORDER_BOOK_CHANGED_EVENT,
|
|
4680
|
+
ORDER_EXECUTED_EVENT,
|
|
4681
|
+
ORDER_TYPE_BUY,
|
|
4682
|
+
ORDER_TYPE_SELL,
|
|
4683
|
+
RAFFLE_CHANGED_EVENT,
|
|
4684
|
+
SETTINGS_STORAGE_KEY,
|
|
4685
|
+
STABLE_COINS,
|
|
4686
|
+
SUPPLY_CHANGED_EVENT,
|
|
4687
|
+
SWAP_EXECUTED_EVENT,
|
|
4688
|
+
SettingsSidebarContent,
|
|
4689
|
+
SettingsToggle,
|
|
4690
|
+
Sidebar,
|
|
4691
|
+
TESTNET_CHAIN_INFO_FALLBACK,
|
|
4692
|
+
TOKEN_LOGO_PLACEHOLDER,
|
|
4693
|
+
TTL_NO_EXPIRY,
|
|
4694
|
+
Toaster,
|
|
4695
|
+
TxStatus,
|
|
4696
|
+
VALIDATION_ERRORS,
|
|
4697
|
+
VERIFIED_ASSETS,
|
|
4698
|
+
WalletSidebarContent,
|
|
4699
|
+
addDebounce,
|
|
4700
|
+
addMultipleDebounce,
|
|
4701
|
+
ammRouter,
|
|
4702
|
+
amountToBigNumberUAmount,
|
|
4703
|
+
amountToUAmount,
|
|
4704
|
+
blockchainEventManager,
|
|
4705
|
+
calcNativeStakingApr,
|
|
4706
|
+
calculateAmountFromPrice,
|
|
4707
|
+
calculatePoolOppositeAmount,
|
|
4708
|
+
calculatePoolPrice,
|
|
4709
|
+
calculatePricePerUnit,
|
|
4710
|
+
calculateRewardsStakingApr,
|
|
4711
|
+
calculateRewardsStakingPendingRewards,
|
|
4712
|
+
calculateTotalAmount,
|
|
4713
|
+
calculateUserPoolData,
|
|
4714
|
+
canDepositFromIBC,
|
|
4715
|
+
canSendToIBC,
|
|
4716
|
+
cancelDebounce,
|
|
4717
|
+
convertToWebSocketUrl,
|
|
4718
|
+
counterpartyChainForChannel,
|
|
4719
|
+
createMarketId,
|
|
4720
|
+
createPoolId,
|
|
4721
|
+
createRestClient,
|
|
4722
|
+
denomOnFirstHopChainFromTrace,
|
|
4723
|
+
formatDate,
|
|
4724
|
+
formatTimeRemaining,
|
|
4725
|
+
formatTimeRemainingFromEpochs,
|
|
4726
|
+
formatUsdAmount,
|
|
4727
|
+
getAddressBalances,
|
|
4728
|
+
getAddressDelegations,
|
|
4729
|
+
getAddressFullMarketOrders,
|
|
4730
|
+
getAddressHistory,
|
|
4731
|
+
getAddressMarketOrders,
|
|
4732
|
+
getAddressNativeDelegatedBalance,
|
|
4733
|
+
getAddressNativeTotalRewards,
|
|
4734
|
+
getAddressPendingUnlock,
|
|
4735
|
+
getAddressRewards,
|
|
4736
|
+
getAddressStakingRewards,
|
|
4737
|
+
getAddressSwapHistory,
|
|
4738
|
+
getAddressUnbondingDelegations,
|
|
4739
|
+
getAddressUnbondingDelegationsSummary,
|
|
4740
|
+
getAggregatorHost,
|
|
4741
|
+
getAllBurnedCoins,
|
|
4742
|
+
getAllSupply,
|
|
4743
|
+
getAllSupplyMetadata,
|
|
4744
|
+
getAllTickers,
|
|
4745
|
+
getAnnualProvisions,
|
|
4746
|
+
getAppName,
|
|
4747
|
+
getArchwayRestURL,
|
|
4748
|
+
getArchwayRpcURL,
|
|
4749
|
+
getAssetLists,
|
|
4750
|
+
getAtomOneRestURL,
|
|
4751
|
+
getAtomOneRpcUrl,
|
|
4752
|
+
getBZEUSDPrice,
|
|
4753
|
+
getBurnerParams,
|
|
4754
|
+
getBurnerParamsWithClient,
|
|
4755
|
+
getChainAddressPrefix,
|
|
4756
|
+
getChainAssets,
|
|
4757
|
+
getChainByChainId,
|
|
4758
|
+
getChainByName,
|
|
4759
|
+
getChainExplorerURL,
|
|
4760
|
+
getChainId,
|
|
4761
|
+
getChainName,
|
|
4762
|
+
getChainNativeAssetDenom,
|
|
4763
|
+
getChains,
|
|
4764
|
+
getChartIntervalsLimit,
|
|
4765
|
+
getChartMinutes,
|
|
4766
|
+
getCurrentEpoch,
|
|
4767
|
+
getCurrentWeekEpochEndTime,
|
|
4768
|
+
getDefaultTxMemo,
|
|
4769
|
+
getDenomType,
|
|
4770
|
+
getDistributionParams,
|
|
4771
|
+
getEcosystemApps,
|
|
4772
|
+
getEpochDurationByIdentifier,
|
|
4773
|
+
getEpochsInfo,
|
|
4774
|
+
getFactoryDenomAdminAddress,
|
|
4775
|
+
getFromLocalStorage,
|
|
4776
|
+
getHashIBCTrace,
|
|
4777
|
+
getHourEpochInfo,
|
|
4778
|
+
getIBCAssetList,
|
|
4779
|
+
getIBCTraces,
|
|
4780
|
+
getIbcTransferTimeout,
|
|
4781
|
+
getJackalRestURL,
|
|
4782
|
+
getJackalRpcUrl,
|
|
4783
|
+
getKeyExpiry,
|
|
4784
|
+
getLiquidityPool,
|
|
4785
|
+
getLiquidityPools,
|
|
4786
|
+
getLockedBalances,
|
|
4787
|
+
getLockerAddress,
|
|
4788
|
+
getMarketBuyOrders,
|
|
4789
|
+
getMarketEventKey,
|
|
4790
|
+
getMarketHistory,
|
|
4791
|
+
getMarketOrder,
|
|
4792
|
+
getMarketOrderBookChangedEvent,
|
|
4793
|
+
getMarketOrders,
|
|
4794
|
+
getMarketOrdersHistory,
|
|
4795
|
+
getMarketSellOrders,
|
|
4796
|
+
getMarkets,
|
|
4797
|
+
getMinAmount,
|
|
4798
|
+
getNoOfIntervalsNeeded,
|
|
4799
|
+
getNobleRestURL,
|
|
4800
|
+
getNobleRpcUrl,
|
|
4801
|
+
getOmniFlixRestURL,
|
|
4802
|
+
getOmniFlixRpcUrl,
|
|
4803
|
+
getOsmosisRestURL,
|
|
4804
|
+
getOsmosisRpcUrl,
|
|
4805
|
+
getPageRequestWithLimit,
|
|
4806
|
+
getPendingUnlockParticipants,
|
|
4807
|
+
getPeriodicEpochEndTime,
|
|
4808
|
+
getPeriodicWeekEpochEndTime,
|
|
4809
|
+
getRestClient,
|
|
4810
|
+
getRestURL,
|
|
4811
|
+
getRpcURL,
|
|
4812
|
+
getSettings,
|
|
4813
|
+
getStakingParams,
|
|
4814
|
+
getStakingPool,
|
|
4815
|
+
getStakingRewardParticipantByAddress,
|
|
4816
|
+
getStakingRewards,
|
|
4817
|
+
getTradingViewIntervals,
|
|
4818
|
+
getUSDCDenom,
|
|
4819
|
+
getValidatorPageUrl,
|
|
4820
|
+
getValidatorSupportedDenoms,
|
|
4821
|
+
getWalletChainsNames,
|
|
4822
|
+
getWeekEpochInfo,
|
|
4823
|
+
intlDateFormat,
|
|
4824
|
+
isFactoryDenom,
|
|
4825
|
+
isIbcAsset,
|
|
4826
|
+
isIbcDenom,
|
|
4827
|
+
isLpDenom,
|
|
4828
|
+
isNativeDenom,
|
|
4829
|
+
isPoolSupportedByValidator,
|
|
4830
|
+
isTestnetChain,
|
|
4831
|
+
keplrSuggestChain,
|
|
4832
|
+
mapEventAttributes,
|
|
4833
|
+
openExternalLink,
|
|
4834
|
+
parseUnbondingDays,
|
|
4835
|
+
poolIdFromPoolDenom,
|
|
4836
|
+
prettyAmount,
|
|
4837
|
+
prettyError,
|
|
4838
|
+
priceToBigNumberUPrice,
|
|
4839
|
+
priceToUPrice,
|
|
4840
|
+
removeFromLocalStorage,
|
|
4841
|
+
removeLeadingZeros,
|
|
4842
|
+
sanitizeIntegerInput,
|
|
4843
|
+
sanitizeNumberInput,
|
|
4844
|
+
setDefaultTxMemo,
|
|
4845
|
+
setInLocalStorage,
|
|
4846
|
+
setKeyExpiry,
|
|
4847
|
+
setSettings,
|
|
4848
|
+
setStorageKeyVersion,
|
|
4849
|
+
shortNumberFormat,
|
|
4850
|
+
sleep,
|
|
4851
|
+
stringTruncateFromCenter,
|
|
4852
|
+
toBigNumber,
|
|
4853
|
+
toPercentage,
|
|
4854
|
+
truncateAddress,
|
|
4855
|
+
truncateDenom,
|
|
4856
|
+
uAmountToAmount,
|
|
4857
|
+
uAmountToBigNumberAmount,
|
|
4858
|
+
uPriceToBigNumberPrice,
|
|
4859
|
+
uPriceToPrice,
|
|
4860
|
+
useAsset,
|
|
4861
|
+
useAssetLiquidityPools,
|
|
4862
|
+
useAssetMarkets,
|
|
4863
|
+
useAssetPrice,
|
|
4864
|
+
useAssets,
|
|
4865
|
+
useAssetsContext,
|
|
4866
|
+
useAssetsManager,
|
|
4867
|
+
useAssetsValue,
|
|
4868
|
+
useBZETx,
|
|
4869
|
+
useBalance,
|
|
4870
|
+
useBalances,
|
|
4871
|
+
useConnectionType,
|
|
4872
|
+
useEpochs,
|
|
4873
|
+
useFeeTokens,
|
|
4874
|
+
useIBCChains,
|
|
4875
|
+
useIBCTx,
|
|
4876
|
+
useLiquidityPools,
|
|
4877
|
+
useMarket,
|
|
4878
|
+
useMarkets,
|
|
4879
|
+
useSDKTx,
|
|
4880
|
+
useSettings,
|
|
4881
|
+
useSigningClient,
|
|
4882
|
+
useToast,
|
|
4883
|
+
validateBZEBech32Address,
|
|
4884
|
+
validateBech32Address,
|
|
4885
|
+
validateEndpoints,
|
|
4886
|
+
validateRestEndpoint,
|
|
4887
|
+
validateRpcEndpoint
|
|
4888
|
+
});
|
|
4889
|
+
//# sourceMappingURL=index.js.map
|