@vechain/vechain-kit 2.0.0-rc.3 → 2.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +433 -1426
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +182 -1292
- package/dist/index.d.ts +182 -1292
- package/dist/index.js +440 -1384
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/{thorUtils-BOhp47ZG.d.cts → thorUtils-BlZ9nLeD.d.cts} +1 -1
- package/dist/{thorUtils-BOhp47ZG.d.ts → thorUtils-BlZ9nLeD.d.ts} +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SubdomainClaimer__factory, IReverseRegistrar__factory,
|
|
2
|
-
import { VECHAIN_KIT_MIXPANEL_PROJECT_TOKEN, ENV, TIME, humanAddress, TOKEN_LOGO_COMPONENTS, TOKEN_LOGOS, DEFAULT_PRIVY_ECOSYSTEM_APPS, executeCallClause, getConfig, convertUriToUrl, ENS_TEXT_RECORDS, getPicassoImage, VECHAIN_PRIVY_APP_ID, compareAddresses, resolveMediaTypeFromMimeType, humanDomain, isRejectionError, isValidAddress,
|
|
1
|
+
import { SubdomainClaimer__factory, IReverseRegistrar__factory, XAllocationVoting__factory, VeBetterPassport__factory, XAllocationPool__factory, X2EarnApps__factory, SimpleAccountFactory__factory, SimpleAccount__factory, ERC20__factory, IVechainEnergyOracleV1__factory, B3TR__factory, IERC20__factory, IVOT3__factory, MockENS__factory } from './chunk-FOSPSOWT.js';
|
|
2
|
+
import { VECHAIN_KIT_MIXPANEL_PROJECT_TOKEN, ENV, TIME, humanAddress, TOKEN_LOGO_COMPONENTS, TOKEN_LOGOS, DEFAULT_PRIVY_ECOSYSTEM_APPS, executeCallClause, getConfig, convertUriToUrl, ENS_TEXT_RECORDS, getPicassoImage, humanNumber, executeMultipleClausesCall, VECHAIN_PRIVY_APP_ID, compareAddresses, resolveMediaTypeFromMimeType, humanDomain, isRejectionError, isValidAddress, VECHAIN_KIT_COOKIES_CONFIG, VECHAIN_KIT_STORAGE_KEYS, CURRENCY_SYMBOLS, uploadBlobToIPFS, randomTransactionUser, VECHAIN_KIT_TERMS_CONFIG, isValidUrl, notFoundImage } from './chunk-SNDIAFF7.js';
|
|
3
3
|
export { CURRENCY_SYMBOLS, ENS_TEXT_RECORDS, LegalDocumentSource, LegalDocumentType, NFTMediaType, VePassportUserStatus, buildCallClauses, executeCallClause, executeMultipleClausesCall, getConfig } from './chunk-SNDIAFF7.js';
|
|
4
4
|
import { VechainLogo, VechainLogoLight, VechainLogoDark, VeWorldLogoLight, VeWorldLogoDark, VechainEnergy, SimpleAccountFactoryABI, SimpleAccountABI, PrivyLogo } from './chunk-Z4FE6MMP.js';
|
|
5
5
|
import './chunk-PZ5AY32C.js';
|
|
@@ -11,7 +11,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
|
11
11
|
import { useThor, useWallet as useWallet$1, useWalletModal, DAppKitProvider } from '@vechain/dapp-kit-react';
|
|
12
12
|
export { WalletButton as DAppKitWalletButton, useWallet as useDAppKitWallet, useWalletModal as useDAppKitWalletModal, useThor } from '@vechain/dapp-kit-react';
|
|
13
13
|
import React10, { createContext, useEffect, useState, useRef, useCallback, useMemo, useContext, Fragment as Fragment$1 } from 'react';
|
|
14
|
-
import { useQuery, useQueryClient, useQueries,
|
|
14
|
+
import { useQuery, useQueryClient, useQueries, QueryClientContext, QueryClientProvider, QueryClient } from '@tanstack/react-query';
|
|
15
15
|
import { hashFn } from 'wagmi/query';
|
|
16
16
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
17
17
|
import { motion } from 'framer-motion';
|
|
@@ -20,14 +20,15 @@ import { IoChevronBack, IoCheckmarkOutline, IoCopyOutline, IoWalletOutline, IoCl
|
|
|
20
20
|
import { FaRegAddressCard, FaExternalLinkAlt, FaGlobe, FaEnvelope, FaArrowRight, FaTelegramPlane, FaChevronDown, FaEdit, FaGoogle, FaTwitter, FaPhone, FaSpotify, FaApple, FaInstagram, FaTiktok, FaGithub, FaLinkedin, FaTelegram, FaDiscord as FaDiscord$1, FaWallet, FaPlus } from 'react-icons/fa';
|
|
21
21
|
import { HiOutlineWallet, HiOutlineShieldCheck } from 'react-icons/hi2';
|
|
22
22
|
import VeChainKitMixpanel from 'mixpanel-browser';
|
|
23
|
-
import { Interface, isAddress, ethers, namehash, toUtf8String, zeroPadValue, toBeHex, formatEther
|
|
23
|
+
import { Interface, isAddress, ethers, namehash, toUtf8String, zeroPadValue, toBeHex, formatEther, parseEther as parseEther$1 } from 'ethers';
|
|
24
24
|
import { ZERO_ADDRESS, Address, Clause, ABIContract } from '@vechain/sdk-core';
|
|
25
|
-
import { defineChain, namehash as namehash$1, formatEther, parseEther, keccak256, toBytes, concat, encodeFunctionData } from 'viem';
|
|
25
|
+
import { defineChain, namehash as namehash$1, formatEther as formatEther$1, parseEther, keccak256, toBytes, concat, encodeFunctionData } from 'viem';
|
|
26
26
|
import { z } from 'zod';
|
|
27
|
+
import { BigNumber } from 'bignumber.js';
|
|
27
28
|
import { useAccount, useConnect, useSignTypedData, useSignMessage, useDisconnect, createConfig, http, WagmiProvider } from 'wagmi';
|
|
28
29
|
import { toPrivyWalletConnector } from '@privy-io/cross-app-connect/rainbow-kit';
|
|
29
30
|
import { isMobile } from 'react-device-detect';
|
|
30
|
-
import
|
|
31
|
+
import axios from 'axios';
|
|
31
32
|
import imageCompression from 'browser-image-compression';
|
|
32
33
|
import { LuMail, LuArrowDownToLine } from 'react-icons/lu';
|
|
33
34
|
import { MdOutlineNavigateNext, MdSwapHoriz, MdOutlineSettingsBackupRestore, MdPhotoCamera, MdCurrencyExchange, MdPrivacyTip, MdOutlineRefresh, MdOutlineErrorOutline, MdEmail, MdGavel, MdCheck } from 'react-icons/md';
|
|
@@ -4354,15 +4355,15 @@ var Analytics = {
|
|
|
4354
4355
|
loginMethod
|
|
4355
4356
|
});
|
|
4356
4357
|
},
|
|
4357
|
-
tryAgain: (
|
|
4358
|
+
tryAgain: (method7, platform) => {
|
|
4358
4359
|
Analytics.auth.trackAuth("try_again", {
|
|
4359
|
-
loginMethod:
|
|
4360
|
+
loginMethod: method7,
|
|
4360
4361
|
platform
|
|
4361
4362
|
});
|
|
4362
4363
|
},
|
|
4363
|
-
methodSelected: (
|
|
4364
|
+
methodSelected: (method7) => {
|
|
4364
4365
|
Analytics.auth.trackAuth("method_selected", {
|
|
4365
|
-
loginMethod:
|
|
4366
|
+
loginMethod: method7
|
|
4366
4367
|
});
|
|
4367
4368
|
},
|
|
4368
4369
|
completed: ({
|
|
@@ -4817,7 +4818,7 @@ var AddressDisplay = ({
|
|
|
4817
4818
|
|
|
4818
4819
|
// package.json
|
|
4819
4820
|
var package_default = {
|
|
4820
|
-
version: "2.0.0-rc.
|
|
4821
|
+
version: "2.0.0-rc.4"};
|
|
4821
4822
|
var VersionFooter = ({ ...props }) => {
|
|
4822
4823
|
const { darkMode: isDark } = useVeChainKitConfig();
|
|
4823
4824
|
return /* @__PURE__ */ jsxs(
|
|
@@ -6120,13 +6121,13 @@ var useUnsetDomain = ({
|
|
|
6120
6121
|
}
|
|
6121
6122
|
};
|
|
6122
6123
|
};
|
|
6123
|
-
var useTokenBalances = (
|
|
6124
|
+
var useTokenBalances = (address) => {
|
|
6124
6125
|
const { network } = useVeChainKitConfig();
|
|
6125
6126
|
const config = getConfig(network.type);
|
|
6126
6127
|
const { data: vetData, isLoading: vetLoading } = useAccountBalance(address);
|
|
6127
6128
|
const { data: b3trBalance, isLoading: b3trLoading } = useGetB3trBalance(address);
|
|
6128
6129
|
const { data: vot3Balance, isLoading: vot3Loading } = useGetVot3Balance(address);
|
|
6129
|
-
const { data: veDelegateBalance, isLoading: veDelegateLoading } =
|
|
6130
|
+
const { data: veDelegateBalance, isLoading: veDelegateLoading } = useGetErc20Balance(config.veDelegateTokenContractAddress, address);
|
|
6130
6131
|
const { data: gloDollarBalance, isLoading: gloDollarLoading } = useGetErc20Balance(config.gloDollarContractAddress, address);
|
|
6131
6132
|
const customTokenBalancesQueries = useGetCustomTokenBalances(address);
|
|
6132
6133
|
const customTokenBalances = customTokenBalancesQueries.map((query) => query.data).filter(Boolean);
|
|
@@ -6199,6 +6200,36 @@ var useTokenBalances = ({ address = "" }) => {
|
|
|
6199
6200
|
isLoading
|
|
6200
6201
|
};
|
|
6201
6202
|
};
|
|
6203
|
+
var PRICE_FEED_IDS = {
|
|
6204
|
+
B3TR: "0x623374722d757364000000000000000000000000000000000000000000000000",
|
|
6205
|
+
VET: "0x7665742d75736400000000000000000000000000000000000000000000000000",
|
|
6206
|
+
VTHO: "0x7674686f2d757364000000000000000000000000000000000000000000000000",
|
|
6207
|
+
GBP: "0x6762702d75736400000000000000000000000000000000000000000000000000",
|
|
6208
|
+
EUR: "0x657572742d757364000000000000000000000000000000000000000000000000"
|
|
6209
|
+
};
|
|
6210
|
+
var getTokenUsdPrice = async (thor, token, network) => {
|
|
6211
|
+
const res = await thor.contracts.load(
|
|
6212
|
+
getConfig(network).oracleContractAddress,
|
|
6213
|
+
IVechainEnergyOracleV1__factory.abi
|
|
6214
|
+
).read.getLatestValue(PRICE_FEED_IDS[token]);
|
|
6215
|
+
if (!res) throw new Error(`Failed to get price of ${token}`);
|
|
6216
|
+
return new BigNumber(res[0].toString()).div(1e12).toNumber();
|
|
6217
|
+
};
|
|
6218
|
+
var getTokenUsdPriceQueryKey = (token) => [
|
|
6219
|
+
"VECHAIN_KIT_PRICE",
|
|
6220
|
+
token
|
|
6221
|
+
];
|
|
6222
|
+
var useGetTokenUsdPrice = (token) => {
|
|
6223
|
+
const thor = useThor();
|
|
6224
|
+
const { network } = useVeChainKitConfig();
|
|
6225
|
+
return useQuery({
|
|
6226
|
+
queryKey: getTokenUsdPriceQueryKey(token),
|
|
6227
|
+
queryFn: async () => getTokenUsdPrice(thor, token, network.type),
|
|
6228
|
+
enabled: !!thor && !!network.type
|
|
6229
|
+
});
|
|
6230
|
+
};
|
|
6231
|
+
|
|
6232
|
+
// src/hooks/api/wallet/useTokenPrices.ts
|
|
6202
6233
|
var useTokenPrices = () => {
|
|
6203
6234
|
const { network } = useVeChainKitConfig();
|
|
6204
6235
|
const config = getConfig(network.type);
|
|
@@ -6288,9 +6319,7 @@ var useCurrency = () => {
|
|
|
6288
6319
|
var useTokensWithValues = ({
|
|
6289
6320
|
address = ""
|
|
6290
6321
|
}) => {
|
|
6291
|
-
const { balances, isLoading: balancesLoading } = useTokenBalances(
|
|
6292
|
-
address
|
|
6293
|
-
});
|
|
6322
|
+
const { balances, isLoading: balancesLoading } = useTokenBalances(address);
|
|
6294
6323
|
const {
|
|
6295
6324
|
prices,
|
|
6296
6325
|
exchangeRates,
|
|
@@ -6359,6 +6388,60 @@ var useTotalBalance = ({ address = "" }) => {
|
|
|
6359
6388
|
hasAnyBalance: tokensWithBalance.length > 0
|
|
6360
6389
|
};
|
|
6361
6390
|
};
|
|
6391
|
+
|
|
6392
|
+
// src/hooks/api/wallet/useCurrentAllocationsRoundId.ts
|
|
6393
|
+
var abi = XAllocationVoting__factory.abi;
|
|
6394
|
+
var method = "currentRoundId";
|
|
6395
|
+
var getCurrentAllocationsRoundIdQueryKey = (address) => getCallClauseQueryKey({ abi, address, method });
|
|
6396
|
+
var useCurrentAllocationsRoundId = () => {
|
|
6397
|
+
const { network } = useVeChainKitConfig();
|
|
6398
|
+
const address = getConfig(network.type).xAllocationVotingContractAddress;
|
|
6399
|
+
return useCallClause({
|
|
6400
|
+
abi,
|
|
6401
|
+
address,
|
|
6402
|
+
method,
|
|
6403
|
+
args: [],
|
|
6404
|
+
queryOptions: {
|
|
6405
|
+
select: (data) => data[0].toString()
|
|
6406
|
+
}
|
|
6407
|
+
});
|
|
6408
|
+
};
|
|
6409
|
+
var getTokenInfo = async (thor, tokenAddress) => {
|
|
6410
|
+
if (!tokenAddress) throw new Error("Token address is required");
|
|
6411
|
+
const contract = thor.contracts.load(tokenAddress, ERC20__factory.abi);
|
|
6412
|
+
const response = await thor.contracts.executeMultipleClausesCall([
|
|
6413
|
+
contract.clause.name(),
|
|
6414
|
+
contract.clause.symbol(),
|
|
6415
|
+
contract.clause.decimals()
|
|
6416
|
+
]);
|
|
6417
|
+
if (response.every((r) => r.success) === false) {
|
|
6418
|
+
throw new Error(`Failed to get token info of ${tokenAddress}`);
|
|
6419
|
+
}
|
|
6420
|
+
const [name, symbol, decimals] = response.map((res) => {
|
|
6421
|
+
return res.result.array?.[0];
|
|
6422
|
+
});
|
|
6423
|
+
return {
|
|
6424
|
+
name,
|
|
6425
|
+
address: tokenAddress,
|
|
6426
|
+
decimals,
|
|
6427
|
+
symbol
|
|
6428
|
+
};
|
|
6429
|
+
};
|
|
6430
|
+
var getCustomTokenInfo = (tokenAddress) => [
|
|
6431
|
+
"VECHAIN_KIT_CUSTOM_TOKEN_BALANCE",
|
|
6432
|
+
tokenAddress
|
|
6433
|
+
];
|
|
6434
|
+
var useGetCustomTokenInfo = (tokenAddress) => {
|
|
6435
|
+
const thor = useThor();
|
|
6436
|
+
const { network } = useVeChainKitConfig();
|
|
6437
|
+
return useQuery({
|
|
6438
|
+
queryKey: getCustomTokenInfo(tokenAddress),
|
|
6439
|
+
queryFn: async () => getTokenInfo(thor, tokenAddress),
|
|
6440
|
+
enabled: !!thor && !!network.type && !!tokenAddress
|
|
6441
|
+
});
|
|
6442
|
+
};
|
|
6443
|
+
|
|
6444
|
+
// src/hooks/api/wallet/useCustomTokens.ts
|
|
6362
6445
|
var useCustomTokens = () => {
|
|
6363
6446
|
const [customTokens, setCustomTokens] = useLocalStorage(
|
|
6364
6447
|
"vechain_kit_custom_tokens" /* CUSTOM_TOKENS */,
|
|
@@ -6405,6 +6488,223 @@ var useCustomTokens = () => {
|
|
|
6405
6488
|
isDefaultToken
|
|
6406
6489
|
};
|
|
6407
6490
|
};
|
|
6491
|
+
var getB3trBalance = async (thor, network, address) => {
|
|
6492
|
+
const res = await thor.contracts.load(getConfig(network).b3trContractAddress, B3TR__factory.abi).read.balanceOf(address);
|
|
6493
|
+
if (!res) throw new Error("Failed to get b3tr balance");
|
|
6494
|
+
const original = res[0].toString();
|
|
6495
|
+
const scaled = formatEther(original);
|
|
6496
|
+
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
6497
|
+
return {
|
|
6498
|
+
original,
|
|
6499
|
+
scaled,
|
|
6500
|
+
formatted
|
|
6501
|
+
};
|
|
6502
|
+
};
|
|
6503
|
+
var getB3trBalanceQueryKey = (address) => [
|
|
6504
|
+
"VEBETTERDAO_BALANCE",
|
|
6505
|
+
address,
|
|
6506
|
+
"B3TR"
|
|
6507
|
+
];
|
|
6508
|
+
var useGetB3trBalance = (address) => {
|
|
6509
|
+
const thor = useThor();
|
|
6510
|
+
const { network } = useVeChainKitConfig();
|
|
6511
|
+
return useQuery({
|
|
6512
|
+
queryKey: getB3trBalanceQueryKey(address),
|
|
6513
|
+
queryFn: async () => getB3trBalance(thor, network.type, address),
|
|
6514
|
+
enabled: !!thor && !!address && !!network.type
|
|
6515
|
+
});
|
|
6516
|
+
};
|
|
6517
|
+
var getCustomTokenBalance = async (thor, token, address) => {
|
|
6518
|
+
const res = await thor.contracts.load(token.address, ERC20__factory.abi).read.balanceOf([address]);
|
|
6519
|
+
if (!res) throw new Error(`Failed to get balance of ${token.address}`);
|
|
6520
|
+
const original = res[0];
|
|
6521
|
+
const scaled = formatEther$1(BigInt(original));
|
|
6522
|
+
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
6523
|
+
return {
|
|
6524
|
+
...token,
|
|
6525
|
+
original: original.toString(),
|
|
6526
|
+
scaled,
|
|
6527
|
+
formatted
|
|
6528
|
+
};
|
|
6529
|
+
};
|
|
6530
|
+
var getCustomTokenBalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT_BALANCE", address, "CUSTOM_TOKEN", tokenAddress];
|
|
6531
|
+
var useGetCustomTokenBalances = (address) => {
|
|
6532
|
+
const thor = useThor();
|
|
6533
|
+
const { customTokens } = useCustomTokens();
|
|
6534
|
+
return useQueries({
|
|
6535
|
+
queries: customTokens.map((token) => ({
|
|
6536
|
+
queryKey: getCustomTokenBalanceQueryKey(token.address, address),
|
|
6537
|
+
queryFn: async () => {
|
|
6538
|
+
return await getCustomTokenBalance(thor, token, address);
|
|
6539
|
+
}
|
|
6540
|
+
}))
|
|
6541
|
+
});
|
|
6542
|
+
};
|
|
6543
|
+
var getErc20Balance = async (thor, tokenAddress, address) => {
|
|
6544
|
+
if (!tokenAddress || !address) {
|
|
6545
|
+
throw new Error("Token address and user address are required");
|
|
6546
|
+
}
|
|
6547
|
+
const res = await thor.contracts.load(tokenAddress, IERC20__factory.abi).read.balanceOf(address);
|
|
6548
|
+
if (!res) throw new Error(`Failed to get balance of ${tokenAddress}`);
|
|
6549
|
+
const original = res[0].toString();
|
|
6550
|
+
const scaled = formatEther(original);
|
|
6551
|
+
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
6552
|
+
return {
|
|
6553
|
+
original,
|
|
6554
|
+
scaled,
|
|
6555
|
+
formatted
|
|
6556
|
+
};
|
|
6557
|
+
};
|
|
6558
|
+
var getErc20BalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT", "BALANCE", "ERC20", tokenAddress, address];
|
|
6559
|
+
var useGetErc20Balance = (tokenAddress, address) => {
|
|
6560
|
+
const thor = useThor();
|
|
6561
|
+
return useQuery({
|
|
6562
|
+
queryKey: getErc20BalanceQueryKey(tokenAddress, address),
|
|
6563
|
+
queryFn: async () => getErc20Balance(thor, tokenAddress, address),
|
|
6564
|
+
enabled: !!thor && !!address && !!tokenAddress
|
|
6565
|
+
});
|
|
6566
|
+
};
|
|
6567
|
+
var getVot3Balance = async (thor, network, address) => {
|
|
6568
|
+
const res = await thor.contracts.load(getConfig(network).vot3ContractAddress, IVOT3__factory.abi).read.balanceOf(address);
|
|
6569
|
+
if (!res) throw new Error("Reverted");
|
|
6570
|
+
const original = res[0].toString();
|
|
6571
|
+
const scaled = formatEther(original);
|
|
6572
|
+
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
6573
|
+
return {
|
|
6574
|
+
original,
|
|
6575
|
+
scaled,
|
|
6576
|
+
formatted
|
|
6577
|
+
};
|
|
6578
|
+
};
|
|
6579
|
+
var getVot3BalanceQueryKey = (address) => [
|
|
6580
|
+
"VEBETTERDAO_BALANCE",
|
|
6581
|
+
address,
|
|
6582
|
+
"VOT3"
|
|
6583
|
+
];
|
|
6584
|
+
var useGetVot3Balance = (address) => {
|
|
6585
|
+
const thor = useThor();
|
|
6586
|
+
const { network } = useVeChainKitConfig();
|
|
6587
|
+
return useQuery({
|
|
6588
|
+
queryKey: getVot3BalanceQueryKey(address),
|
|
6589
|
+
queryFn: async () => getVot3Balance(thor, network.type, address),
|
|
6590
|
+
enabled: !!thor && !!address && !!network.type
|
|
6591
|
+
});
|
|
6592
|
+
};
|
|
6593
|
+
|
|
6594
|
+
// src/hooks/api/wallet/useIsPerson.ts
|
|
6595
|
+
var abi2 = VeBetterPassport__factory.abi;
|
|
6596
|
+
var method2 = "isPerson";
|
|
6597
|
+
var getIsPersonQueryKey = (user, network) => {
|
|
6598
|
+
const address = getConfig(network).veBetterPassportContractAddress;
|
|
6599
|
+
return getCallClauseQueryKeyWithArgs({
|
|
6600
|
+
abi: abi2,
|
|
6601
|
+
address,
|
|
6602
|
+
method: method2,
|
|
6603
|
+
args: [user]
|
|
6604
|
+
});
|
|
6605
|
+
};
|
|
6606
|
+
var useIsPerson = (user) => {
|
|
6607
|
+
const { network } = useVeChainKitConfig();
|
|
6608
|
+
const address = getConfig(network.type).veBetterPassportContractAddress;
|
|
6609
|
+
return useCallClause({
|
|
6610
|
+
abi: abi2,
|
|
6611
|
+
address,
|
|
6612
|
+
method: method2,
|
|
6613
|
+
args: [user ?? "0x"],
|
|
6614
|
+
queryOptions: {
|
|
6615
|
+
enabled: !!user,
|
|
6616
|
+
select: (data) => data[0]
|
|
6617
|
+
}
|
|
6618
|
+
});
|
|
6619
|
+
};
|
|
6620
|
+
|
|
6621
|
+
// src/hooks/api/wallet/useRoundXApps.ts
|
|
6622
|
+
var abi3 = XAllocationVoting__factory.abi;
|
|
6623
|
+
var method3 = "getAppsOfRound";
|
|
6624
|
+
var getRoundXAppsQueryKey = (roundId, networkType) => getCallClauseQueryKeyWithArgs({
|
|
6625
|
+
abi: abi3,
|
|
6626
|
+
address: getConfig(networkType).xAllocationVotingContractAddress,
|
|
6627
|
+
method: method3,
|
|
6628
|
+
args: [BigInt(roundId ?? 0)]
|
|
6629
|
+
});
|
|
6630
|
+
var useRoundXApps = (roundId) => {
|
|
6631
|
+
const { network } = useVeChainKitConfig();
|
|
6632
|
+
const address = getConfig(network.type).xAllocationVotingContractAddress;
|
|
6633
|
+
return useCallClause({
|
|
6634
|
+
abi: abi3,
|
|
6635
|
+
address,
|
|
6636
|
+
method: method3,
|
|
6637
|
+
args: [BigInt(roundId ?? 0)],
|
|
6638
|
+
queryOptions: {
|
|
6639
|
+
enabled: !!roundId,
|
|
6640
|
+
select: (data) => data[0].map((app) => ({
|
|
6641
|
+
id: app.id.toString(),
|
|
6642
|
+
teamWalletAddress: app.teamWalletAddress,
|
|
6643
|
+
name: app.name,
|
|
6644
|
+
metadataURI: app.metadataURI,
|
|
6645
|
+
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
6646
|
+
}))
|
|
6647
|
+
}
|
|
6648
|
+
});
|
|
6649
|
+
};
|
|
6650
|
+
var abi4 = XAllocationPool__factory.abi;
|
|
6651
|
+
var method4 = "getAppShares";
|
|
6652
|
+
var getXAppsSharesQueryKey = (roundId) => [
|
|
6653
|
+
"VECHAIN_KIT",
|
|
6654
|
+
"XApps",
|
|
6655
|
+
"Shares",
|
|
6656
|
+
roundId
|
|
6657
|
+
];
|
|
6658
|
+
var useXAppsShares = (apps, roundId) => {
|
|
6659
|
+
const thor = useThor();
|
|
6660
|
+
const { network } = useVeChainKitConfig();
|
|
6661
|
+
const address = getConfig(network.type).xAllocationPoolContractAddress;
|
|
6662
|
+
return useQuery({
|
|
6663
|
+
queryKey: getXAppsSharesQueryKey(roundId),
|
|
6664
|
+
queryFn: async () => {
|
|
6665
|
+
const shares = await executeMultipleClausesCall({
|
|
6666
|
+
thor,
|
|
6667
|
+
calls: apps.map(
|
|
6668
|
+
(app) => ({
|
|
6669
|
+
abi: abi4,
|
|
6670
|
+
functionName: method4,
|
|
6671
|
+
address,
|
|
6672
|
+
args: [roundId, app]
|
|
6673
|
+
})
|
|
6674
|
+
)
|
|
6675
|
+
});
|
|
6676
|
+
return shares.map((share, index) => {
|
|
6677
|
+
return {
|
|
6678
|
+
app: apps[index],
|
|
6679
|
+
share: Number(share[0] || 0) / 100,
|
|
6680
|
+
unallocatedShare: Number(share[1] || 0) / 100
|
|
6681
|
+
};
|
|
6682
|
+
});
|
|
6683
|
+
},
|
|
6684
|
+
enabled: !!roundId && !!apps.length
|
|
6685
|
+
});
|
|
6686
|
+
};
|
|
6687
|
+
|
|
6688
|
+
// src/hooks/api/wallet/useMostVotedAppsInRound.ts
|
|
6689
|
+
var useMostVotedAppsInRound = (roundId) => {
|
|
6690
|
+
const { data: apps } = useRoundXApps(roundId);
|
|
6691
|
+
const xAppsShares = useXAppsShares(
|
|
6692
|
+
apps?.map((app) => app.id) ?? [],
|
|
6693
|
+
roundId
|
|
6694
|
+
);
|
|
6695
|
+
const mostVotedApps = useMemo(
|
|
6696
|
+
() => xAppsShares.data?.map((appShares) => ({
|
|
6697
|
+
percentage: appShares.share + appShares.unallocatedShare,
|
|
6698
|
+
id: apps?.find((xa) => xa.id === appShares.app)?.id ?? "",
|
|
6699
|
+
app: apps?.find((xa) => xa.id === appShares.app) ?? {}
|
|
6700
|
+
})).sort((a, b) => Number(b.percentage) - Number(a.percentage)) ?? [],
|
|
6701
|
+
[xAppsShares.data, apps]
|
|
6702
|
+
);
|
|
6703
|
+
return {
|
|
6704
|
+
data: mostVotedApps,
|
|
6705
|
+
isLoading: xAppsShares.isLoading
|
|
6706
|
+
};
|
|
6707
|
+
};
|
|
6408
6708
|
var handlePopupError = ({
|
|
6409
6709
|
error,
|
|
6410
6710
|
mobileBrowserPopupMessage = "Mobile browser blocked the window. Please try again.",
|
|
@@ -6737,170 +7037,30 @@ var useRefreshBalances = () => {
|
|
|
6737
7037
|
};
|
|
6738
7038
|
return { refresh };
|
|
6739
7039
|
};
|
|
6740
|
-
var
|
|
6741
|
-
const
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
IERC20__factory.abi
|
|
6745
|
-
);
|
|
6746
|
-
return erc20Contract.clause.balanceOf([address]);
|
|
6747
|
-
});
|
|
6748
|
-
const response = await thor.contracts.executeMultipleClausesCall(clauses);
|
|
6749
|
-
if (!response.every((r) => r.success && !!r.result.plain)) {
|
|
6750
|
-
throw new Error("Failed to get custom token balances");
|
|
6751
|
-
}
|
|
6752
|
-
return response.map((r, index) => {
|
|
6753
|
-
const token = customTokens[index];
|
|
6754
|
-
const original = r.result.plain;
|
|
6755
|
-
const scaled = formatEther$1(BigInt(original)) || "0";
|
|
6756
|
-
return {
|
|
6757
|
-
address: token.address,
|
|
6758
|
-
symbol: token.symbol,
|
|
6759
|
-
balance: scaled
|
|
6760
|
-
};
|
|
6761
|
-
});
|
|
6762
|
-
};
|
|
6763
|
-
var getTokenBalances = async (thor, address, network) => {
|
|
6764
|
-
const config = getConfig(network);
|
|
6765
|
-
const [b3trBalance, vot3Balance, veDelegateBalance, gloDollarBalance] = await executeMultipleClausesCall({
|
|
6766
|
-
thor,
|
|
6767
|
-
calls: [
|
|
6768
|
-
{
|
|
6769
|
-
abi: IB3TR__factory.abi,
|
|
6770
|
-
address: config.b3trContractAddress,
|
|
6771
|
-
functionName: "balanceOf",
|
|
6772
|
-
args: [address]
|
|
6773
|
-
},
|
|
6774
|
-
{
|
|
6775
|
-
abi: IVOT3__factory.abi,
|
|
6776
|
-
address: config.vot3ContractAddress,
|
|
6777
|
-
functionName: "balanceOf",
|
|
6778
|
-
args: [address]
|
|
6779
|
-
},
|
|
6780
|
-
{
|
|
6781
|
-
abi: IERC20__factory.abi,
|
|
6782
|
-
address: config.veDelegate,
|
|
6783
|
-
functionName: "balanceOf",
|
|
6784
|
-
args: [address]
|
|
6785
|
-
},
|
|
6786
|
-
{
|
|
6787
|
-
abi: IERC20__factory.abi,
|
|
6788
|
-
address: config.gloDollarContractAddress,
|
|
6789
|
-
functionName: "balanceOf",
|
|
6790
|
-
args: [address]
|
|
6791
|
-
}
|
|
6792
|
-
]
|
|
6793
|
-
});
|
|
6794
|
-
const { balance: vetBalance, energy: vthoBalance } = await getAccountBalance(thor, address);
|
|
6795
|
-
return [
|
|
6796
|
-
{
|
|
6797
|
-
address: "0x",
|
|
6798
|
-
symbol: "VET",
|
|
6799
|
-
balance: vetBalance
|
|
6800
|
-
},
|
|
6801
|
-
{
|
|
6802
|
-
address: config.vthoContractAddress,
|
|
6803
|
-
symbol: "VTHO",
|
|
6804
|
-
balance: vthoBalance
|
|
6805
|
-
},
|
|
6806
|
-
{
|
|
6807
|
-
address: config.b3trContractAddress,
|
|
6808
|
-
symbol: "B3TR",
|
|
6809
|
-
balance: b3trBalance
|
|
6810
|
-
},
|
|
6811
|
-
{
|
|
6812
|
-
address: config.vot3ContractAddress,
|
|
6813
|
-
symbol: "VOT3",
|
|
6814
|
-
balance: vot3Balance
|
|
6815
|
-
},
|
|
6816
|
-
{
|
|
6817
|
-
address: config.veDelegate,
|
|
6818
|
-
symbol: "veDelegate",
|
|
6819
|
-
balance: veDelegateBalance
|
|
6820
|
-
},
|
|
6821
|
-
{
|
|
6822
|
-
address: config.gloDollarContractAddress,
|
|
6823
|
-
symbol: "USDGLO",
|
|
6824
|
-
balance: gloDollarBalance
|
|
6825
|
-
}
|
|
6826
|
-
];
|
|
6827
|
-
};
|
|
6828
|
-
var useTokenBalances2 = ({ address }) => {
|
|
6829
|
-
const thor = useThor();
|
|
6830
|
-
const { network } = useVeChainKitConfig();
|
|
6831
|
-
const { customTokens } = useCustomTokens();
|
|
6832
|
-
return useQueries({
|
|
6833
|
-
queries: [
|
|
6834
|
-
{
|
|
6835
|
-
queryKey: ["base-token-balances", address],
|
|
6836
|
-
queryFn: () => getTokenBalances(thor, address, network.type)
|
|
6837
|
-
},
|
|
6838
|
-
{
|
|
6839
|
-
queryKey: ["custom-token-balances", address],
|
|
6840
|
-
queryFn: () => getCustomTokenBalances(thor, address, customTokens)
|
|
6841
|
-
}
|
|
6842
|
-
],
|
|
6843
|
-
combine: (data) => {
|
|
6844
|
-
return {
|
|
6845
|
-
data: data.flat(),
|
|
6846
|
-
loading: data[0].isLoading || data[1].isLoading,
|
|
6847
|
-
error: data[0].error || data[1].error
|
|
6848
|
-
};
|
|
6849
|
-
}
|
|
6850
|
-
});
|
|
6851
|
-
};
|
|
6852
|
-
var getTokenPrices = async (thor, tokens2, network) => {
|
|
6853
|
-
const config = getConfig(network);
|
|
6854
|
-
const oracleContract = thor.contracts.load(
|
|
6855
|
-
config.oracleContractAddress,
|
|
6856
|
-
IVechainEnergyOracleV1__factory.abi
|
|
6857
|
-
);
|
|
6858
|
-
const clauses = tokens2.map(
|
|
6859
|
-
(token) => oracleContract.clause.getLatestValue(PRICE_FEED_IDS[token])
|
|
6860
|
-
);
|
|
6861
|
-
const response = await thor.transactions.executeMultipleClausesCall(
|
|
6862
|
-
clauses
|
|
6863
|
-
);
|
|
6864
|
-
if (!response.every((r) => r.success && !!r.result.array)) {
|
|
6865
|
-
throw new Error("Failed to get token prices");
|
|
6866
|
-
}
|
|
6867
|
-
return response.map(
|
|
6868
|
-
(r) => new BigNumber$1((r.result.array?.[0] ?? 0).toString()).div(1e12).toNumber()
|
|
7040
|
+
var getXAppMetadata = async (uri, networkType) => {
|
|
7041
|
+
const metadata = await axios.get(
|
|
7042
|
+
convertUriToUrl(uri, networkType) || "",
|
|
7043
|
+
{ timeout: 2e4 }
|
|
6869
7044
|
);
|
|
7045
|
+
return metadata.data;
|
|
6870
7046
|
};
|
|
6871
|
-
var
|
|
6872
|
-
var
|
|
7047
|
+
var abi5 = X2EarnApps__factory.abi;
|
|
7048
|
+
var useXAppMetadata = (xAppId) => {
|
|
6873
7049
|
const thor = useThor();
|
|
6874
7050
|
const { network } = useVeChainKitConfig();
|
|
6875
|
-
const config = getConfig(network.type);
|
|
6876
7051
|
return useQuery({
|
|
6877
|
-
queryKey: ["
|
|
6878
|
-
queryFn: () =>
|
|
6879
|
-
|
|
6880
|
-
const
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
[config.vthoContractAddress]: vthoUsdPrice || 0,
|
|
6890
|
-
[config.b3trContractAddress]: b3trUsdPrice || 0,
|
|
6891
|
-
[config.vot3ContractAddress]: b3trUsdPrice || 0,
|
|
6892
|
-
[config.veDelegate]: b3trUsdPrice || 0,
|
|
6893
|
-
[config.gloDollarContractAddress]: 1
|
|
6894
|
-
// GloDollar is pegged to USD
|
|
6895
|
-
};
|
|
6896
|
-
const exchangeRates = {
|
|
6897
|
-
eurUsdPrice: eurUsdPrice || 1,
|
|
6898
|
-
gbpUsdPrice: gbpUsdPrice || 1
|
|
6899
|
-
};
|
|
6900
|
-
return {
|
|
6901
|
-
prices,
|
|
6902
|
-
exchangeRates
|
|
6903
|
-
};
|
|
7052
|
+
queryKey: ["xAppMetaData", xAppId],
|
|
7053
|
+
queryFn: async () => {
|
|
7054
|
+
const address = getConfig(network.type).x2EarnAppsContractAddress;
|
|
7055
|
+
const contract = thor.contracts.load(address, abi5);
|
|
7056
|
+
const [app] = await contract.read.app(xAppId);
|
|
7057
|
+
const metadataURI = app?.[3] || "";
|
|
7058
|
+
const [baseUri] = await contract.read.baseURI();
|
|
7059
|
+
const metadata = await getXAppMetadata(
|
|
7060
|
+
`${baseUri}${metadataURI}`,
|
|
7061
|
+
network.type
|
|
7062
|
+
);
|
|
7063
|
+
return metadata;
|
|
6904
7064
|
}
|
|
6905
7065
|
});
|
|
6906
7066
|
};
|
|
@@ -7619,8 +7779,8 @@ var ConnectionOptionsStack = () => {
|
|
|
7619
7779
|
showMoreLogin,
|
|
7620
7780
|
isOfficialVeChainApp
|
|
7621
7781
|
} = useLoginModalContent();
|
|
7622
|
-
return /* @__PURE__ */ jsx(Stack, { spacing: 4, w: "full", align: "center", children: /* @__PURE__ */ jsx(Grid, { templateColumns: "repeat(4, 1fr)", gap: 2, w: "full", children: loginMethods?.map(({ method:
|
|
7623
|
-
switch (
|
|
7782
|
+
return /* @__PURE__ */ jsx(Stack, { spacing: 4, w: "full", align: "center", children: /* @__PURE__ */ jsx(Grid, { templateColumns: "repeat(4, 1fr)", gap: 2, w: "full", children: loginMethods?.map(({ method: method7, gridColumn }) => {
|
|
7783
|
+
switch (method7) {
|
|
7624
7784
|
case "email":
|
|
7625
7785
|
return showEmailLogin && /* @__PURE__ */ jsx(EmailLoginButton, {}, "email");
|
|
7626
7786
|
case "google":
|
|
@@ -7727,7 +7887,7 @@ var MainContent = ({ setCurrentContent, onClose }) => {
|
|
|
7727
7887
|
}
|
|
7728
7888
|
}, [connection.isConnected, onClose]);
|
|
7729
7889
|
const showEcosystemButton = loginMethods?.some(
|
|
7730
|
-
({ method:
|
|
7890
|
+
({ method: method7 }) => method7 === "ecosystem"
|
|
7731
7891
|
);
|
|
7732
7892
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7733
7893
|
/* @__PURE__ */ jsxs(StickyHeaderContainer, { children: [
|
|
@@ -13015,13 +13175,13 @@ var PrivyLinkedAccounts = ({ onBack }) => {
|
|
|
13015
13175
|
} = usePrivy();
|
|
13016
13176
|
const canLinkWallets = useMemo(() => {
|
|
13017
13177
|
const privyWallets = privy?.loginMethods?.filter(
|
|
13018
|
-
(
|
|
13178
|
+
(method7) => [
|
|
13019
13179
|
"rabby_wallet",
|
|
13020
13180
|
"coinbase_wallet",
|
|
13021
13181
|
"rainbow",
|
|
13022
13182
|
"phantom",
|
|
13023
13183
|
"metamask"
|
|
13024
|
-
].includes(
|
|
13184
|
+
].includes(method7)
|
|
13025
13185
|
) ?? [];
|
|
13026
13186
|
const dappKitWallets = dappKit?.allowedWallets ?? [];
|
|
13027
13187
|
return privyWallets.length > 0 || dappKitWallets.length > 0;
|
|
@@ -14165,17 +14325,7 @@ var ExploreEcosystemContent = ({
|
|
|
14165
14325
|
) : [];
|
|
14166
14326
|
const filteredDefaultApps = DEFAULT_APPS.filter(
|
|
14167
14327
|
(dapp) => dapp.name.toLowerCase().includes(searchQuery.toLowerCase())
|
|
14168
|
-
)
|
|
14169
|
-
if (dapp.logoComponent) {
|
|
14170
|
-
return {
|
|
14171
|
-
...dapp,
|
|
14172
|
-
logoComponent: React10.cloneElement(dapp.logoComponent, {
|
|
14173
|
-
isDark
|
|
14174
|
-
})
|
|
14175
|
-
};
|
|
14176
|
-
}
|
|
14177
|
-
return dapp;
|
|
14178
|
-
});
|
|
14328
|
+
);
|
|
14179
14329
|
const filteredAppHubApps = appHubApps?.filter(
|
|
14180
14330
|
(app) => (
|
|
14181
14331
|
// Text search filter
|
|
@@ -14262,10 +14412,7 @@ var ExploreEcosystemContent = ({
|
|
|
14262
14412
|
url: dapp.external_url,
|
|
14263
14413
|
setCurrentContent,
|
|
14264
14414
|
description: dapp.description,
|
|
14265
|
-
selectedCategory: currentCategory
|
|
14266
|
-
...dapp.logoComponent && {
|
|
14267
|
-
logoComponent: dapp.logoComponent
|
|
14268
|
-
}
|
|
14415
|
+
selectedCategory: currentCategory
|
|
14269
14416
|
}
|
|
14270
14417
|
) }, dapp.name)) }),
|
|
14271
14418
|
shouldShowVbdApps && filteredVbdApps.length > 0 && /* @__PURE__ */ jsx(Fragment, { children: filteredVbdApps.map((dapp) => /* @__PURE__ */ jsx(GridItem, { children: /* @__PURE__ */ jsx(
|
|
@@ -15014,7 +15161,7 @@ var ConnectPopover = ({
|
|
|
15014
15161
|
privyEcosystemAppIDS
|
|
15015
15162
|
} = useVeChainKitConfig();
|
|
15016
15163
|
const showEcosystemButton = loginMethods?.some(
|
|
15017
|
-
({ method:
|
|
15164
|
+
({ method: method7 }) => method7 === "ecosystem"
|
|
15018
15165
|
);
|
|
15019
15166
|
const { data: appsInfo, isLoading: isEcosystemAppsLoading } = useFetchAppInfo(privyEcosystemAppIDS);
|
|
15020
15167
|
return /* @__PURE__ */ jsx(
|
|
@@ -16557,14 +16704,14 @@ var ReceiveModalProvider = ({ children }) => /* @__PURE__ */ jsx(Fragment, { chi
|
|
|
16557
16704
|
var useLoginModalContent = () => {
|
|
16558
16705
|
const { privy, loginMethods } = useVeChainKitConfig();
|
|
16559
16706
|
const isVeChainApp = privy?.appId === VECHAIN_PRIVY_APP_ID;
|
|
16560
|
-
const isLoginMethodEnabled = (
|
|
16707
|
+
const isLoginMethodEnabled = (method7) => {
|
|
16561
16708
|
if (!loginMethods) return true;
|
|
16562
|
-
if (Array.isArray(
|
|
16563
|
-
return
|
|
16709
|
+
if (Array.isArray(method7)) {
|
|
16710
|
+
return method7.some(
|
|
16564
16711
|
(m) => loginMethods.some((lm) => lm.method === m)
|
|
16565
16712
|
);
|
|
16566
16713
|
}
|
|
16567
|
-
return loginMethods.some((lm) => lm.method ===
|
|
16714
|
+
return loginMethods.some((lm) => lm.method === method7);
|
|
16568
16715
|
};
|
|
16569
16716
|
const showEcosystemLogin = useMemo(() => {
|
|
16570
16717
|
if (!loginMethods) return true;
|
|
@@ -16988,24 +17135,24 @@ var getCallClauseQueryKey = ({
|
|
|
16988
17135
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16989
17136
|
abi: abi9,
|
|
16990
17137
|
address,
|
|
16991
|
-
method:
|
|
16992
|
-
}) => ["callClause", address,
|
|
17138
|
+
method: method7
|
|
17139
|
+
}) => ["callClause", address, method7];
|
|
16993
17140
|
var getCallClauseQueryKeyWithArgs = ({
|
|
16994
17141
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16995
17142
|
abi: abi9,
|
|
16996
17143
|
address,
|
|
16997
|
-
method:
|
|
17144
|
+
method: method7,
|
|
16998
17145
|
args
|
|
16999
17146
|
}) => [
|
|
17000
17147
|
"callClause",
|
|
17001
17148
|
address,
|
|
17002
|
-
|
|
17149
|
+
method7,
|
|
17003
17150
|
...args?.length ? [args] : []
|
|
17004
17151
|
];
|
|
17005
17152
|
var useCallClause = ({
|
|
17006
17153
|
address,
|
|
17007
17154
|
abi: abi9,
|
|
17008
|
-
method:
|
|
17155
|
+
method: method7,
|
|
17009
17156
|
args,
|
|
17010
17157
|
queryOptions
|
|
17011
17158
|
}) => {
|
|
@@ -17014,14 +17161,14 @@ var useCallClause = ({
|
|
|
17014
17161
|
queryKey: getCallClauseQueryKeyWithArgs({
|
|
17015
17162
|
abi: abi9,
|
|
17016
17163
|
address,
|
|
17017
|
-
method:
|
|
17164
|
+
method: method7,
|
|
17018
17165
|
args
|
|
17019
17166
|
}),
|
|
17020
17167
|
queryFn: async () => executeCallClause({
|
|
17021
17168
|
thor,
|
|
17022
17169
|
contractAddress: address,
|
|
17023
17170
|
abi: abi9,
|
|
17024
|
-
method:
|
|
17171
|
+
method: method7,
|
|
17025
17172
|
args
|
|
17026
17173
|
}),
|
|
17027
17174
|
...queryOptions
|
|
@@ -17143,8 +17290,8 @@ var getAccountBalance = async (thor, address) => {
|
|
|
17143
17290
|
if (!address) throw new Error("Address is required");
|
|
17144
17291
|
const account = await thor.accounts.getAccount(Address.of(address));
|
|
17145
17292
|
return {
|
|
17146
|
-
balance: formatEther(BigInt(account.balance)).toString(),
|
|
17147
|
-
energy: formatEther(BigInt(account.energy)).toString()
|
|
17293
|
+
balance: formatEther$1(BigInt(account.balance)).toString(),
|
|
17294
|
+
energy: formatEther$1(BigInt(account.energy)).toString()
|
|
17148
17295
|
};
|
|
17149
17296
|
};
|
|
17150
17297
|
var getAccountBalanceQueryKey = (address) => [
|
|
@@ -17259,9 +17406,9 @@ var useGetAccountAddress = (ownerAddress) => {
|
|
|
17259
17406
|
};
|
|
17260
17407
|
|
|
17261
17408
|
// src/hooks/thor/smartAccounts/useGetAccountVersion.ts
|
|
17262
|
-
var
|
|
17409
|
+
var abi6 = SimpleAccountFactory__factory.abi;
|
|
17263
17410
|
var getAccountVersionQueryKey = (accountAddress, ownerAddress, networkType) => getCallClauseQueryKeyWithArgs({
|
|
17264
|
-
abi,
|
|
17411
|
+
abi: abi6,
|
|
17265
17412
|
address: getConfig(networkType).accountFactoryAddress,
|
|
17266
17413
|
method: "getAccountVersion",
|
|
17267
17414
|
args: [accountAddress, ownerAddress]
|
|
@@ -17270,7 +17417,7 @@ var useGetAccountVersion = (accountAddress, ownerAddress) => {
|
|
|
17270
17417
|
const { network } = useVeChainKitConfig();
|
|
17271
17418
|
return useCallClause({
|
|
17272
17419
|
address: getConfig(network.type).accountFactoryAddress,
|
|
17273
|
-
abi,
|
|
17420
|
+
abi: abi6,
|
|
17274
17421
|
method: "getAccountVersion",
|
|
17275
17422
|
args: [accountAddress, ownerAddress],
|
|
17276
17423
|
queryOptions: {
|
|
@@ -17283,16 +17430,16 @@ var useGetAccountVersion = (accountAddress, ownerAddress) => {
|
|
|
17283
17430
|
}
|
|
17284
17431
|
});
|
|
17285
17432
|
};
|
|
17286
|
-
var
|
|
17287
|
-
var
|
|
17433
|
+
var abi7 = SimpleAccountFactory__factory.abi;
|
|
17434
|
+
var method5 = "hasLegacyAccount";
|
|
17288
17435
|
var getHasV1SmartAccount = async (thor, ownerAddress, networkType) => {
|
|
17289
17436
|
if (!ownerAddress) throw new Error("Owner address is required");
|
|
17290
17437
|
if (!networkType) throw new Error("Network type is required");
|
|
17291
17438
|
const [hasLegacyAccount] = await executeCallClause({
|
|
17292
17439
|
thor,
|
|
17293
|
-
abi:
|
|
17440
|
+
abi: abi7,
|
|
17294
17441
|
contractAddress: getConfig(networkType).accountFactoryAddress,
|
|
17295
|
-
method,
|
|
17442
|
+
method: method5,
|
|
17296
17443
|
args: [ownerAddress]
|
|
17297
17444
|
});
|
|
17298
17445
|
return hasLegacyAccount;
|
|
@@ -17503,15 +17650,15 @@ var useSmartAccount = (ownerAddress) => {
|
|
|
17503
17650
|
enabled: !!ownerAddress && !!network.type && !!thor
|
|
17504
17651
|
});
|
|
17505
17652
|
};
|
|
17506
|
-
var
|
|
17507
|
-
var
|
|
17653
|
+
var abi8 = SimpleAccountFactory__factory.abi;
|
|
17654
|
+
var method6 = "version";
|
|
17508
17655
|
var getVersion = async (thor, contractAddress) => {
|
|
17509
17656
|
if (!contractAddress) throw new Error("Contract address is required");
|
|
17510
17657
|
const [version] = await executeCallClause({
|
|
17511
17658
|
thor,
|
|
17512
17659
|
contractAddress,
|
|
17513
|
-
abi:
|
|
17514
|
-
method:
|
|
17660
|
+
abi: abi8,
|
|
17661
|
+
method: method6,
|
|
17515
17662
|
args: []
|
|
17516
17663
|
});
|
|
17517
17664
|
return Number(version);
|
|
@@ -17699,1165 +17846,76 @@ var useGetChainId = () => {
|
|
|
17699
17846
|
refetchInterval: 1e4
|
|
17700
17847
|
});
|
|
17701
17848
|
};
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
}
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
});
|
|
17727
|
-
};
|
|
17728
|
-
var getCustomTokenBalance = async (thor, token, address) => {
|
|
17729
|
-
const res = await thor.contracts.load(token.address, ERC20__factory.abi).read.balanceOf([address]);
|
|
17730
|
-
if (!res) throw new Error(`Failed to get balance of ${token.address}`);
|
|
17731
|
-
const original = res[0];
|
|
17732
|
-
const scaled = formatEther(BigInt(original));
|
|
17733
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17734
|
-
return {
|
|
17735
|
-
...token,
|
|
17736
|
-
original: original.toString(),
|
|
17737
|
-
scaled,
|
|
17738
|
-
formatted
|
|
17739
|
-
};
|
|
17740
|
-
};
|
|
17741
|
-
var getCustomTokenBalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT_BALANCE", address, "CUSTOM_TOKEN", tokenAddress];
|
|
17742
|
-
var useGetCustomTokenBalances = (address) => {
|
|
17743
|
-
const thor = useThor();
|
|
17744
|
-
const { customTokens } = useCustomTokens();
|
|
17745
|
-
return useQueries({
|
|
17746
|
-
queries: customTokens.map((token) => ({
|
|
17747
|
-
queryKey: getCustomTokenBalanceQueryKey(token.address, address),
|
|
17748
|
-
queryFn: async () => {
|
|
17749
|
-
return await getCustomTokenBalance(thor, token, address);
|
|
17750
|
-
}
|
|
17751
|
-
}))
|
|
17849
|
+
|
|
17850
|
+
// src/hooks/thor/logs/logUtils.ts
|
|
17851
|
+
var MAX_EVENTS_PER_QUERY = 1e3;
|
|
17852
|
+
var getEventLogs = async ({
|
|
17853
|
+
thor,
|
|
17854
|
+
order = "asc",
|
|
17855
|
+
offset = 0,
|
|
17856
|
+
limit = MAX_EVENTS_PER_QUERY,
|
|
17857
|
+
from = 0,
|
|
17858
|
+
to = thor.blocks.getHeadBlock()?.number,
|
|
17859
|
+
filterCriteria
|
|
17860
|
+
}) => {
|
|
17861
|
+
const response = await thor.logs.filterEventLogs({
|
|
17862
|
+
range: {
|
|
17863
|
+
from,
|
|
17864
|
+
to,
|
|
17865
|
+
unit: "block"
|
|
17866
|
+
},
|
|
17867
|
+
options: {
|
|
17868
|
+
offset,
|
|
17869
|
+
limit
|
|
17870
|
+
},
|
|
17871
|
+
order,
|
|
17872
|
+
criteriaSet: filterCriteria
|
|
17752
17873
|
});
|
|
17874
|
+
if (!response) throw new Error("Failed to fetch events");
|
|
17875
|
+
return response;
|
|
17753
17876
|
};
|
|
17754
|
-
var
|
|
17755
|
-
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17877
|
+
var getAllEventLogs = async ({
|
|
17878
|
+
nodeUrl,
|
|
17879
|
+
thor,
|
|
17880
|
+
order = "asc",
|
|
17881
|
+
from = 0,
|
|
17882
|
+
to,
|
|
17883
|
+
filterCriteria
|
|
17884
|
+
}) => {
|
|
17885
|
+
const allEvents = [];
|
|
17886
|
+
let offset = 0;
|
|
17887
|
+
while (true) {
|
|
17888
|
+
const events = await getEventLogs({
|
|
17889
|
+
thor,
|
|
17890
|
+
filterCriteria,
|
|
17891
|
+
from,
|
|
17892
|
+
to: to ?? Number.MAX_SAFE_INTEGER,
|
|
17893
|
+
limit: MAX_EVENTS_PER_QUERY,
|
|
17894
|
+
order,
|
|
17895
|
+
offset
|
|
17896
|
+
});
|
|
17897
|
+
allEvents.push(...events);
|
|
17898
|
+
if (events.length < MAX_EVENTS_PER_QUERY) {
|
|
17899
|
+
return allEvents;
|
|
17900
|
+
}
|
|
17901
|
+
offset += MAX_EVENTS_PER_QUERY;
|
|
17764
17902
|
}
|
|
17765
|
-
const [name, symbol, decimals] = response.map((res) => {
|
|
17766
|
-
return res.result.array?.[0];
|
|
17767
|
-
});
|
|
17768
|
-
return {
|
|
17769
|
-
name,
|
|
17770
|
-
address: tokenAddress,
|
|
17771
|
-
decimals,
|
|
17772
|
-
symbol
|
|
17773
|
-
};
|
|
17774
|
-
};
|
|
17775
|
-
var getCustomTokenInfo = (tokenAddress) => [
|
|
17776
|
-
"VECHAIN_KIT_CUSTOM_TOKEN_BALANCE",
|
|
17777
|
-
tokenAddress
|
|
17778
|
-
];
|
|
17779
|
-
var useGetCustomTokenInfo = (tokenAddress) => {
|
|
17780
|
-
const thor = useThor();
|
|
17781
|
-
const { network } = useVeChainKitConfig();
|
|
17782
|
-
return useQuery({
|
|
17783
|
-
queryKey: getCustomTokenInfo(tokenAddress),
|
|
17784
|
-
queryFn: async () => getTokenInfo(thor, tokenAddress),
|
|
17785
|
-
enabled: !!thor && !!network.type && !!tokenAddress
|
|
17786
|
-
});
|
|
17787
17903
|
};
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
const original = res[0].toString();
|
|
17795
|
-
const scaled = formatEther$1(original);
|
|
17796
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17797
|
-
return {
|
|
17798
|
-
original,
|
|
17799
|
-
scaled,
|
|
17800
|
-
formatted
|
|
17801
|
-
};
|
|
17904
|
+
|
|
17905
|
+
// src/hooks/thor/transactions/transactionUtils.ts
|
|
17906
|
+
var estimateTxGas = async (thor, clauses, caller) => {
|
|
17907
|
+
const response = await thor.transactions.estimateGas(clauses, caller);
|
|
17908
|
+
if (response.reverted) throw new Error("Failed to estimate gas");
|
|
17909
|
+
return response.totalGas;
|
|
17802
17910
|
};
|
|
17803
|
-
var
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
|
|
17811
|
-
};
|
|
17812
|
-
var getVeDelegateBalance = async (thor, network, address) => {
|
|
17813
|
-
const res = await thor.contracts.load(
|
|
17814
|
-
getConfig(network).veDelegateTokenContractAddress,
|
|
17815
|
-
IERC20__factory.abi
|
|
17816
|
-
).read.balanceOf(address);
|
|
17817
|
-
if (!res)
|
|
17818
|
-
throw new Error(`Failed to get veDelegate balance for ${address}`);
|
|
17819
|
-
const original = res[0].toString();
|
|
17820
|
-
const scaled = formatEther$1(original);
|
|
17821
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17822
|
-
return {
|
|
17823
|
-
original,
|
|
17824
|
-
scaled,
|
|
17825
|
-
formatted
|
|
17826
|
-
};
|
|
17827
|
-
};
|
|
17828
|
-
var getVeDelegateBalanceQueryKey = (address) => [
|
|
17829
|
-
"VECHAIN_KIT_BALANCE",
|
|
17830
|
-
address,
|
|
17831
|
-
"VE_DELEGATE"
|
|
17832
|
-
];
|
|
17833
|
-
var useGetVeDelegateBalance = (address) => {
|
|
17834
|
-
const thor = useThor();
|
|
17835
|
-
const { network } = useVeChainKitConfig();
|
|
17836
|
-
return useQuery({
|
|
17837
|
-
queryKey: getVeDelegateBalanceQueryKey(address),
|
|
17838
|
-
queryFn: async () => getVeDelegateBalance(thor, network.type, address),
|
|
17839
|
-
enabled: !!thor && !!address && !!network.type
|
|
17840
|
-
});
|
|
17841
|
-
};
|
|
17842
|
-
var getTokensInfoByOwnerQueryKey = (owner) => [
|
|
17843
|
-
"VECHAIN_KIT_GALAXY_MEMBER_TOKENS_INFO",
|
|
17844
|
-
owner
|
|
17845
|
-
];
|
|
17846
|
-
var useGalaxyMemberTokensInfo = (owner, size = 10) => {
|
|
17847
|
-
const { network } = useVeChainKitConfig();
|
|
17848
|
-
const contractAddress = getConfig(network.type).galaxyMemberContractAddress;
|
|
17849
|
-
const thor = useThor();
|
|
17850
|
-
const fetchTokens = async ({ pageParam = 0 }) => {
|
|
17851
|
-
const data = await thor.contracts.load(contractAddress, GalaxyMember__factory.abi).read.getTokensInfoByOwner(owner, pageParam, size);
|
|
17852
|
-
if (!data)
|
|
17853
|
-
throw new Error(
|
|
17854
|
-
`Failed to fetch tokens info for page ${pageParam}`
|
|
17855
|
-
);
|
|
17856
|
-
return { data, nextPage: pageParam + 1 };
|
|
17857
|
-
};
|
|
17858
|
-
return useInfiniteQuery({
|
|
17859
|
-
queryKey: getTokensInfoByOwnerQueryKey(owner),
|
|
17860
|
-
queryFn: fetchTokens,
|
|
17861
|
-
getNextPageParam: (lastPage) => lastPage.data.length === size ? lastPage.nextPage : void 0,
|
|
17862
|
-
enabled: !!owner && !!network.type,
|
|
17863
|
-
initialPageParam: 0
|
|
17864
|
-
});
|
|
17865
|
-
};
|
|
17866
|
-
|
|
17867
|
-
// src/hooks/thor/contracts/NodeManagement/useGetUserNodes.ts
|
|
17868
|
-
var contractAbi = NodeManagement__factory.abi;
|
|
17869
|
-
var method3 = "getUserNodes";
|
|
17870
|
-
var getUserNodesQueryKey = (networkType, user) => getCallClauseQueryKeyWithArgs({
|
|
17871
|
-
abi: contractAbi,
|
|
17872
|
-
address: getConfig(networkType).nodeManagementContractAddress,
|
|
17873
|
-
method: method3,
|
|
17874
|
-
args: [user]
|
|
17875
|
-
});
|
|
17876
|
-
var useGetUserNodes = (userInput) => {
|
|
17877
|
-
const { network } = useVeChainKitConfig();
|
|
17878
|
-
const contractAddress = getConfig(
|
|
17879
|
-
network.type
|
|
17880
|
-
).nodeManagementContractAddress;
|
|
17881
|
-
return useCallClause({
|
|
17882
|
-
address: contractAddress,
|
|
17883
|
-
abi: contractAbi,
|
|
17884
|
-
method: method3,
|
|
17885
|
-
args: [userInput],
|
|
17886
|
-
queryOptions: {
|
|
17887
|
-
enabled: !!userInput && !!network.type && !!contractAddress,
|
|
17888
|
-
select: (response) => {
|
|
17889
|
-
return response[0].map((node) => ({
|
|
17890
|
-
nodeId: node.nodeId.toString(),
|
|
17891
|
-
nodeLevel: Number(node.nodeLevel),
|
|
17892
|
-
xNodeOwner: node.xNodeOwner,
|
|
17893
|
-
isXNodeHolder: node.isXNodeHolder,
|
|
17894
|
-
isXNodeDelegated: node.isXNodeDelegated,
|
|
17895
|
-
isXNodeDelegator: node.isXNodeDelegator,
|
|
17896
|
-
isXNodeDelegatee: node.isXNodeDelegatee,
|
|
17897
|
-
delegatee: node.delegatee
|
|
17898
|
-
}));
|
|
17899
|
-
}
|
|
17900
|
-
}
|
|
17901
|
-
});
|
|
17902
|
-
};
|
|
17903
|
-
var useGetUserNode = useGetUserNodes;
|
|
17904
|
-
var PRICE_FEED_IDS = {
|
|
17905
|
-
B3TR: "0x623374722d757364000000000000000000000000000000000000000000000000",
|
|
17906
|
-
VET: "0x7665742d75736400000000000000000000000000000000000000000000000000",
|
|
17907
|
-
VTHO: "0x7674686f2d757364000000000000000000000000000000000000000000000000",
|
|
17908
|
-
GBP: "0x6762702d75736400000000000000000000000000000000000000000000000000",
|
|
17909
|
-
EUR: "0x657572742d757364000000000000000000000000000000000000000000000000"
|
|
17910
|
-
};
|
|
17911
|
-
var getTokenUsdPrice = async (thor, token, network) => {
|
|
17912
|
-
const res = await thor.contracts.load(
|
|
17913
|
-
getConfig(network).oracleContractAddress,
|
|
17914
|
-
IVechainEnergyOracleV1__factory.abi
|
|
17915
|
-
).read.getLatestValue(PRICE_FEED_IDS[token]);
|
|
17916
|
-
if (!res) throw new Error(`Failed to get price of ${token}`);
|
|
17917
|
-
return new BigNumber(res[0].toString()).div(1e12).toNumber();
|
|
17918
|
-
};
|
|
17919
|
-
var getTokenUsdPriceQueryKey = (token) => [
|
|
17920
|
-
"VECHAIN_KIT_PRICE",
|
|
17921
|
-
token
|
|
17922
|
-
];
|
|
17923
|
-
var useGetTokenUsdPrice = (token) => {
|
|
17924
|
-
const thor = useThor();
|
|
17925
|
-
const { network } = useVeChainKitConfig();
|
|
17926
|
-
return useQuery({
|
|
17927
|
-
queryKey: getTokenUsdPriceQueryKey(token),
|
|
17928
|
-
queryFn: async () => getTokenUsdPrice(thor, token, network.type),
|
|
17929
|
-
enabled: !!thor && !!network.type
|
|
17930
|
-
});
|
|
17931
|
-
};
|
|
17932
|
-
var getVot3Balance = async (thor, network, address) => {
|
|
17933
|
-
const res = await thor.contracts.load(getConfig(network).vot3ContractAddress, VOT3__factory.abi).read.balanceOf(address);
|
|
17934
|
-
if (!res) throw new Error("Reverted");
|
|
17935
|
-
const original = res[0].toString();
|
|
17936
|
-
const scaled = formatEther$1(original);
|
|
17937
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17938
|
-
return {
|
|
17939
|
-
original,
|
|
17940
|
-
scaled,
|
|
17941
|
-
formatted
|
|
17942
|
-
};
|
|
17943
|
-
};
|
|
17944
|
-
var getVot3BalanceQueryKey = (address) => [
|
|
17945
|
-
"VEBETTERDAO_BALANCE",
|
|
17946
|
-
address,
|
|
17947
|
-
"VOT3"
|
|
17948
|
-
];
|
|
17949
|
-
var useGetVot3Balance = (address) => {
|
|
17950
|
-
const thor = useThor();
|
|
17951
|
-
const { network } = useVeChainKitConfig();
|
|
17952
|
-
return useQuery({
|
|
17953
|
-
queryKey: getVot3BalanceQueryKey(address || ""),
|
|
17954
|
-
queryFn: async () => getVot3Balance(thor, network.type, address),
|
|
17955
|
-
enabled: !!thor && !!address && !!network.type
|
|
17956
|
-
});
|
|
17957
|
-
};
|
|
17958
|
-
var contractAbi2 = VeBetterPassport__factory.abi;
|
|
17959
|
-
var method4 = "isPerson";
|
|
17960
|
-
var getIsPersonQueryKey = (networkType, user) => {
|
|
17961
|
-
const veBetterPassportContractAddress = getConfig(networkType).veBetterPassportContractAddress;
|
|
17962
|
-
return getCallClauseQueryKeyWithArgs({
|
|
17963
|
-
abi: contractAbi2,
|
|
17964
|
-
address: veBetterPassportContractAddress,
|
|
17965
|
-
method: method4,
|
|
17966
|
-
args: [user]
|
|
17967
|
-
});
|
|
17968
|
-
};
|
|
17969
|
-
var useIsPerson = (user, customEnabled = true) => {
|
|
17970
|
-
const { network } = useVeChainKitConfig();
|
|
17971
|
-
const veBetterPassportContractAddress = getConfig(
|
|
17972
|
-
network.type
|
|
17973
|
-
).veBetterPassportContractAddress;
|
|
17974
|
-
return useCallClause({
|
|
17975
|
-
abi: contractAbi2,
|
|
17976
|
-
address: veBetterPassportContractAddress,
|
|
17977
|
-
method: method4,
|
|
17978
|
-
args: [user ?? ZERO_ADDRESS],
|
|
17979
|
-
queryOptions: {
|
|
17980
|
-
enabled: !!user && customEnabled && !!veBetterPassportContractAddress && !!network.type,
|
|
17981
|
-
select: (data) => data[0]
|
|
17982
|
-
}
|
|
17983
|
-
});
|
|
17984
|
-
};
|
|
17985
|
-
var useIsUserPerson = (address) => {
|
|
17986
|
-
return useIsPerson(address);
|
|
17987
|
-
};
|
|
17988
|
-
var contractAbi3 = VeBetterPassport__factory.abi;
|
|
17989
|
-
var method5 = "isPersonAtTimepoint";
|
|
17990
|
-
var getIsPersonAtTimepointQueryKey = (networkType, user, timepoint) => {
|
|
17991
|
-
const veBetterPassportContractAddress = getConfig(networkType).veBetterPassportContractAddress;
|
|
17992
|
-
return getCallClauseQueryKeyWithArgs({
|
|
17993
|
-
abi: contractAbi3,
|
|
17994
|
-
address: veBetterPassportContractAddress,
|
|
17995
|
-
method: method5,
|
|
17996
|
-
args: [user, Number(timepoint)]
|
|
17997
|
-
});
|
|
17998
|
-
};
|
|
17999
|
-
var useIsPersonAtTimepoint = (user, timepoint, customEnabled = true) => {
|
|
18000
|
-
const { network } = useVeChainKitConfig();
|
|
18001
|
-
const veBetterPassportContractAddress = getConfig(
|
|
18002
|
-
network.type
|
|
18003
|
-
).veBetterPassportContractAddress;
|
|
18004
|
-
return useCallClause({
|
|
18005
|
-
abi: contractAbi3,
|
|
18006
|
-
address: veBetterPassportContractAddress,
|
|
18007
|
-
method: method5,
|
|
18008
|
-
args: [
|
|
18009
|
-
user ?? ZERO_ADDRESS,
|
|
18010
|
-
timepoint ? Number(timepoint) : 0
|
|
18011
|
-
],
|
|
18012
|
-
queryOptions: {
|
|
18013
|
-
enabled: !!user && timepoint !== void 0 && customEnabled && !!veBetterPassportContractAddress && !!network.type,
|
|
18014
|
-
select: (data) => data[0]
|
|
18015
|
-
}
|
|
18016
|
-
});
|
|
18017
|
-
};
|
|
18018
|
-
|
|
18019
|
-
// src/hooks/thor/contracts/VeBetterPassport/useUserBotSignals.ts
|
|
18020
|
-
var contractAbi4 = VeBetterPassport__factory.abi;
|
|
18021
|
-
var method6 = "signaledCounter";
|
|
18022
|
-
var getUserBotSignalsQueryKey = (networkType, userAddress) => {
|
|
18023
|
-
return getCallClauseQueryKeyWithArgs({
|
|
18024
|
-
abi: contractAbi4,
|
|
18025
|
-
address: getConfig(networkType).veBetterPassportContractAddress,
|
|
18026
|
-
method: method6,
|
|
18027
|
-
args: [userAddress]
|
|
18028
|
-
});
|
|
18029
|
-
};
|
|
18030
|
-
var useUserBotSignals = (userAddressInput) => {
|
|
18031
|
-
const { network } = useVeChainKitConfig();
|
|
18032
|
-
const veBetterPassportContractAddress = getConfig(
|
|
18033
|
-
network.type
|
|
18034
|
-
).veBetterPassportContractAddress;
|
|
18035
|
-
return useCallClause({
|
|
18036
|
-
address: veBetterPassportContractAddress,
|
|
18037
|
-
abi: contractAbi4,
|
|
18038
|
-
method: method6,
|
|
18039
|
-
args: [userAddressInput],
|
|
18040
|
-
queryOptions: {
|
|
18041
|
-
enabled: !!userAddressInput && !!veBetterPassportContractAddress && !!network.type,
|
|
18042
|
-
select: (res) => Number(res[0])
|
|
18043
|
-
}
|
|
18044
|
-
});
|
|
18045
|
-
};
|
|
18046
|
-
var useVotingRewards = (currentRoundId, voter) => {
|
|
18047
|
-
const thor = useThor();
|
|
18048
|
-
const queryClient = useQueryClient();
|
|
18049
|
-
const { network } = useVeChainKitConfig();
|
|
18050
|
-
const contractAddress = getConfig(network.type).voterRewardsContractAddress;
|
|
18051
|
-
const rounds = useMemo(() => {
|
|
18052
|
-
return Array.from(
|
|
18053
|
-
{ length: parseInt(currentRoundId ?? "0") - 1 },
|
|
18054
|
-
(_, i) => (i + 1).toString()
|
|
18055
|
-
);
|
|
18056
|
-
}, [currentRoundId]);
|
|
18057
|
-
return useQuery({
|
|
18058
|
-
queryKey: getRoundRewardQueryKey("ALL", voter),
|
|
18059
|
-
enabled: !!thor && !!voter && !!currentRoundId && !!rounds.length && !!network.type,
|
|
18060
|
-
queryFn: async () => {
|
|
18061
|
-
const contract = thor.contracts.load(
|
|
18062
|
-
contractAddress,
|
|
18063
|
-
VoterRewards__factory.abi
|
|
18064
|
-
);
|
|
18065
|
-
const clauses = rounds.map(
|
|
18066
|
-
(roundId) => (
|
|
18067
|
-
// Voter Rewards getReward result type: [ 0n ]
|
|
18068
|
-
contract.clause.getReward(roundId, voter)
|
|
18069
|
-
)
|
|
18070
|
-
);
|
|
18071
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18072
|
-
clauses
|
|
18073
|
-
);
|
|
18074
|
-
if (!res.every((r) => r.success))
|
|
18075
|
-
throw new Error("Failed to fetch voting rewards");
|
|
18076
|
-
let total = new BigNumber(0);
|
|
18077
|
-
const roundsRewards = res.map((r, index) => {
|
|
18078
|
-
const roundId = rounds[index];
|
|
18079
|
-
const rewards = r.result.plain;
|
|
18080
|
-
const formattedRewards = formatEther(rewards);
|
|
18081
|
-
total = total.plus(BigNumber(rewards.toString()));
|
|
18082
|
-
queryClient.setQueryData(
|
|
18083
|
-
getRoundRewardQueryKey(roundId, voter),
|
|
18084
|
-
{
|
|
18085
|
-
roundId,
|
|
18086
|
-
rewards: formattedRewards
|
|
18087
|
-
}
|
|
18088
|
-
);
|
|
18089
|
-
return {
|
|
18090
|
-
roundId,
|
|
18091
|
-
rewards,
|
|
18092
|
-
formattedRewards
|
|
18093
|
-
};
|
|
18094
|
-
});
|
|
18095
|
-
const totalFormatted = formatEther(BigInt(total.toFixed()));
|
|
18096
|
-
return {
|
|
18097
|
-
total: total.toFixed(),
|
|
18098
|
-
totalFormatted,
|
|
18099
|
-
roundsRewards
|
|
18100
|
-
};
|
|
18101
|
-
}
|
|
18102
|
-
});
|
|
18103
|
-
};
|
|
18104
|
-
var getRoundRewardQueryKey = (roundId, address) => [
|
|
18105
|
-
"VECHAIN_KIT",
|
|
18106
|
-
"roundReward",
|
|
18107
|
-
roundId,
|
|
18108
|
-
"voter",
|
|
18109
|
-
address
|
|
18110
|
-
];
|
|
18111
|
-
var useRoundReward = (address, roundId) => {
|
|
18112
|
-
const { network } = useVeChainKitConfig();
|
|
18113
|
-
return useCallClause({
|
|
18114
|
-
address: getConfig(network.type).voterRewardsContractAddress,
|
|
18115
|
-
abi: VoterRewards__factory.abi,
|
|
18116
|
-
method: "getReward",
|
|
18117
|
-
args: [BigInt(roundId || 0), address],
|
|
18118
|
-
queryOptions: {
|
|
18119
|
-
enabled: !!address && !!roundId && !!network.type,
|
|
18120
|
-
select: (data) => ({
|
|
18121
|
-
roundId,
|
|
18122
|
-
rewards: formatEther(BigInt(data[0]))
|
|
18123
|
-
})
|
|
18124
|
-
}
|
|
18125
|
-
});
|
|
18126
|
-
};
|
|
18127
|
-
|
|
18128
|
-
// src/hooks/thor/contracts/X2EarnApps/utils/getXAppMetadata.ts
|
|
18129
|
-
var getXAppMetadata = async (uri, networkType) => {
|
|
18130
|
-
const url = convertUriToUrl(uri, networkType);
|
|
18131
|
-
if (!url) return void 0;
|
|
18132
|
-
const response = await fetch(url);
|
|
18133
|
-
if (!response.ok) {
|
|
18134
|
-
return void 0;
|
|
18135
|
-
}
|
|
18136
|
-
return response.json();
|
|
18137
|
-
};
|
|
18138
|
-
|
|
18139
|
-
// src/hooks/thor/contracts/X2EarnApps/utils/getXApps.ts
|
|
18140
|
-
var getXApps = async (thor, networkType) => {
|
|
18141
|
-
const contract = thor.contracts.load(
|
|
18142
|
-
getConfig(networkType).x2EarnAppsContractAddress,
|
|
18143
|
-
X2EarnApps__factory.abi
|
|
18144
|
-
);
|
|
18145
|
-
const clauses = [contract.clause.unendorsedApps(), contract.clause.apps()];
|
|
18146
|
-
const res = await thor.transactions.executeMultipleClausesCall(clauses);
|
|
18147
|
-
if (!res.every((r) => r.success)) throw new Error(`Failed to fetch xApps`);
|
|
18148
|
-
const apps = res[0]?.result.plain;
|
|
18149
|
-
const unendorsedApps = res[1]?.result.plain;
|
|
18150
|
-
const allApps = {};
|
|
18151
|
-
for (const app of apps) {
|
|
18152
|
-
allApps[app.id] = {
|
|
18153
|
-
id: app.id,
|
|
18154
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18155
|
-
name: app.name,
|
|
18156
|
-
metadataURI: app.metadataURI,
|
|
18157
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18158
|
-
};
|
|
18159
|
-
}
|
|
18160
|
-
for (const app of unendorsedApps) {
|
|
18161
|
-
allApps[app.id] = {
|
|
18162
|
-
id: app.id,
|
|
18163
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18164
|
-
name: app.name,
|
|
18165
|
-
metadataURI: app.metadataURI,
|
|
18166
|
-
createdAtTimestamp: app.createdAtTimestamp.toString(),
|
|
18167
|
-
appAvailableForAllocationVoting: app.appAvailableForAllocationVoting
|
|
18168
|
-
};
|
|
18169
|
-
}
|
|
18170
|
-
const unendorsedIds = new Set(unendorsedApps.map((app) => app.id));
|
|
18171
|
-
return {
|
|
18172
|
-
allApps: Object.values(allApps),
|
|
18173
|
-
active: apps.map((app) => ({
|
|
18174
|
-
...app,
|
|
18175
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18176
|
-
})),
|
|
18177
|
-
unendorsed: unendorsedApps.map((app) => ({
|
|
18178
|
-
...app,
|
|
18179
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18180
|
-
})),
|
|
18181
|
-
endorsed: apps.filter((app) => !unendorsedIds.has(app.id)).map((app) => ({
|
|
18182
|
-
...app,
|
|
18183
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18184
|
-
}))
|
|
18185
|
-
};
|
|
18186
|
-
};
|
|
18187
|
-
var abi4 = XAllocationVoting__factory.abi;
|
|
18188
|
-
var method7 = "getAppsOfRound";
|
|
18189
|
-
var getRoundXApps = async (thor, networkType, roundId) => {
|
|
18190
|
-
if (!roundId) return [];
|
|
18191
|
-
const [xApps] = await executeCallClause({
|
|
18192
|
-
thor,
|
|
18193
|
-
contractAddress: getConfig(networkType).xAllocationVotingContractAddress,
|
|
18194
|
-
abi: abi4,
|
|
18195
|
-
method: method7,
|
|
18196
|
-
args: [BigInt(roundId)]
|
|
18197
|
-
});
|
|
18198
|
-
return xApps.map((app) => ({
|
|
18199
|
-
id: app.id.toString(),
|
|
18200
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18201
|
-
name: app.name,
|
|
18202
|
-
metadataURI: app.metadataURI,
|
|
18203
|
-
createdAtTimestamp: app.createdAtTimestamp.toString(),
|
|
18204
|
-
appAvailableForAllocationVoting: app.appAvailableForAllocationVoting
|
|
18205
|
-
}));
|
|
18206
|
-
};
|
|
18207
|
-
var getRoundXAppsQueryKey = (roundId) => [
|
|
18208
|
-
"VECHAIN_KIT",
|
|
18209
|
-
"round",
|
|
18210
|
-
roundId,
|
|
18211
|
-
"getXApps"
|
|
18212
|
-
];
|
|
18213
|
-
var useRoundXApps = (roundId) => {
|
|
18214
|
-
const thor = useThor();
|
|
18215
|
-
const { network } = useVeChainKitConfig();
|
|
18216
|
-
return useQuery({
|
|
18217
|
-
queryKey: getRoundXAppsQueryKey(roundId),
|
|
18218
|
-
queryFn: async () => await getRoundXApps(thor, network.type, roundId),
|
|
18219
|
-
enabled: !!thor && !!roundId && !!network.type
|
|
18220
|
-
});
|
|
18221
|
-
};
|
|
18222
|
-
var getUserVotesInRound = async (thor, network, roundId, address) => {
|
|
18223
|
-
const xAllocationVotingContract = getConfig(network).xAllocationVotingContractAddress;
|
|
18224
|
-
const eventAbi = thor.contracts.load(xAllocationVotingContract, XAllocationVoting__factory.abi).getEventAbi("AllocationVoteCast");
|
|
18225
|
-
const topics = eventAbi.encodeFilterTopicsNoNull({
|
|
18226
|
-
...address ? { voter: address } : {},
|
|
18227
|
-
...roundId ? { roundId } : {}
|
|
18228
|
-
});
|
|
18229
|
-
const filterCriteria = [
|
|
18230
|
-
{
|
|
18231
|
-
criteria: {
|
|
18232
|
-
address: xAllocationVotingContract,
|
|
18233
|
-
topic0: topics[0] ?? void 0,
|
|
18234
|
-
topic1: topics[1] ?? void 0,
|
|
18235
|
-
topic2: topics[2] ?? void 0,
|
|
18236
|
-
topic3: topics[3] ?? void 0,
|
|
18237
|
-
topic4: topics[4] ?? void 0
|
|
18238
|
-
},
|
|
18239
|
-
eventAbi
|
|
18240
|
-
}
|
|
18241
|
-
];
|
|
18242
|
-
const events = await getAllEventLogs({
|
|
18243
|
-
thor,
|
|
18244
|
-
filterCriteria,
|
|
18245
|
-
nodeUrl: getConfig(network).nodeUrl
|
|
18246
|
-
});
|
|
18247
|
-
const decodedAllocatedVoteEvents = [];
|
|
18248
|
-
events.forEach((event) => {
|
|
18249
|
-
if (!event.decodedData) {
|
|
18250
|
-
throw new Error("Event data not decoded");
|
|
18251
|
-
}
|
|
18252
|
-
if (!compareAddresses(event.address, xAllocationVotingContract)) {
|
|
18253
|
-
throw new Error("Event address not valid");
|
|
18254
|
-
}
|
|
18255
|
-
const [voter, roundId2, appsIds, voteWeights] = event.decodedData;
|
|
18256
|
-
decodedAllocatedVoteEvents.push({
|
|
18257
|
-
voter,
|
|
18258
|
-
roundId: roundId2,
|
|
18259
|
-
appsIds,
|
|
18260
|
-
voteWeights
|
|
18261
|
-
});
|
|
18262
|
-
});
|
|
18263
|
-
return decodedAllocatedVoteEvents;
|
|
18264
|
-
};
|
|
18265
|
-
var getUserVotesInRoundQueryKey = (roundId, address) => [
|
|
18266
|
-
"VECHAIN_KIT",
|
|
18267
|
-
"allocationsRound",
|
|
18268
|
-
roundId,
|
|
18269
|
-
"userVotes",
|
|
18270
|
-
...address ? [address] : []
|
|
18271
|
-
];
|
|
18272
|
-
var useUserVotesInRound = (roundId, address) => {
|
|
18273
|
-
const thor = useThor();
|
|
18274
|
-
const { network } = useVeChainKitConfig();
|
|
18275
|
-
return useQuery({
|
|
18276
|
-
queryKey: getUserVotesInRoundQueryKey(roundId, address),
|
|
18277
|
-
queryFn: async () => {
|
|
18278
|
-
const votes = await getUserVotesInRound(
|
|
18279
|
-
thor,
|
|
18280
|
-
network.type,
|
|
18281
|
-
roundId,
|
|
18282
|
-
address
|
|
18283
|
-
);
|
|
18284
|
-
if (votes.length > 1) throw new Error("More than one event found");
|
|
18285
|
-
if (votes.length === 0) throw new Error("No event found");
|
|
18286
|
-
return votes[0];
|
|
18287
|
-
},
|
|
18288
|
-
enabled: !!thor && !!thor.blocks.getHeadBlock() && !!roundId && !!address && !!network.type
|
|
18289
|
-
});
|
|
18290
|
-
};
|
|
18291
|
-
var getVotesInRoundQueryKey = (roundId) => [
|
|
18292
|
-
"VECHAIN_KIT",
|
|
18293
|
-
"allocationsRound",
|
|
18294
|
-
roundId,
|
|
18295
|
-
"totalVotes"
|
|
18296
|
-
];
|
|
18297
|
-
var useVotesInRound = (roundId, enabled = true) => {
|
|
18298
|
-
const thor = useThor();
|
|
18299
|
-
const { network } = useVeChainKitConfig();
|
|
18300
|
-
return useQuery({
|
|
18301
|
-
queryKey: getVotesInRoundQueryKey(roundId),
|
|
18302
|
-
queryFn: async () => await getUserVotesInRound(thor, network.type, roundId),
|
|
18303
|
-
enabled: !!thor && !!thor.blocks.getHeadBlock() && !!roundId && enabled && !!network.type
|
|
18304
|
-
});
|
|
18305
|
-
};
|
|
18306
|
-
var getXAppsQueryKey = () => ["VECHAIN_KIT", "getXApps"];
|
|
18307
|
-
var useXApps = () => {
|
|
18308
|
-
const thor = useThor();
|
|
18309
|
-
const { network } = useVeChainKitConfig();
|
|
18310
|
-
return useQuery({
|
|
18311
|
-
queryKey: getXAppsQueryKey(),
|
|
18312
|
-
queryFn: async () => await getXApps(thor, network.type),
|
|
18313
|
-
enabled: !!thor && !!network.type
|
|
18314
|
-
});
|
|
18315
|
-
};
|
|
18316
|
-
|
|
18317
|
-
// src/hooks/thor/contracts/X2EarnApps/custom/useXApp.ts
|
|
18318
|
-
var useXApp = (appId) => {
|
|
18319
|
-
const { data: xApps, ...props } = useXApps();
|
|
18320
|
-
const allApps = useMemo(() => [...xApps?.active ?? [], ...xApps?.unendorsed ?? []], [xApps]);
|
|
18321
|
-
const app = allApps.find((xa) => xa.id === appId);
|
|
18322
|
-
return {
|
|
18323
|
-
data: app,
|
|
18324
|
-
...props
|
|
18325
|
-
};
|
|
18326
|
-
};
|
|
18327
|
-
var getXAppMetadataQueryKey = (metadataURI) => [
|
|
18328
|
-
"VECHAIN_KIT",
|
|
18329
|
-
"xApps",
|
|
18330
|
-
metadataURI,
|
|
18331
|
-
"metadata"
|
|
18332
|
-
];
|
|
18333
|
-
var useXAppMetadata = (xAppId) => {
|
|
18334
|
-
const { data: baseUri } = useXAppsMetadataBaseUri();
|
|
18335
|
-
const { data: xApp } = useXApp(xAppId ?? "");
|
|
18336
|
-
const { network } = useVeChainKitConfig();
|
|
18337
|
-
return useQuery({
|
|
18338
|
-
queryKey: getXAppMetadataQueryKey(xApp?.metadataURI || ""),
|
|
18339
|
-
queryFn: async () => !(!baseUri && xApp) ? await getXAppMetadata(
|
|
18340
|
-
`${baseUri}${xApp?.metadataURI}`,
|
|
18341
|
-
network.type
|
|
18342
|
-
) : null,
|
|
18343
|
-
enabled: !!baseUri && !!xApp && !!network.type
|
|
18344
|
-
});
|
|
18345
|
-
};
|
|
18346
|
-
var getXAppsSharesQueryKey = (roundId) => [
|
|
18347
|
-
"VECHAIN_KIT",
|
|
18348
|
-
"XApps",
|
|
18349
|
-
"Shares",
|
|
18350
|
-
roundId
|
|
18351
|
-
];
|
|
18352
|
-
var useXAppsShares = (apps, roundId) => {
|
|
18353
|
-
const thor = useThor();
|
|
18354
|
-
const { network } = useVeChainKitConfig();
|
|
18355
|
-
return useQuery({
|
|
18356
|
-
queryKey: getXAppsSharesQueryKey(roundId),
|
|
18357
|
-
queryFn: async () => {
|
|
18358
|
-
const contract = thor.contracts.load(
|
|
18359
|
-
getConfig(network.type).xAllocationPoolContractAddress,
|
|
18360
|
-
XAllocationPool__factory.abi
|
|
18361
|
-
);
|
|
18362
|
-
const clauses = apps.map(
|
|
18363
|
-
(app) => contract.clause.getAppShares(roundId, app)
|
|
18364
|
-
);
|
|
18365
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18366
|
-
clauses
|
|
18367
|
-
);
|
|
18368
|
-
if (!res.every((r) => r.success))
|
|
18369
|
-
throw new Error(
|
|
18370
|
-
`Failed to fetch xApps shares for ${apps} in round ${roundId}`
|
|
18371
|
-
);
|
|
18372
|
-
const shares = res.map((r, index) => {
|
|
18373
|
-
return {
|
|
18374
|
-
app: apps[index],
|
|
18375
|
-
share: Number(r.result.array?.[0] || 0) / 100,
|
|
18376
|
-
unallocatedShare: Number(r.result.array?.[1] || 0) / 100
|
|
18377
|
-
};
|
|
18378
|
-
});
|
|
18379
|
-
return shares;
|
|
18380
|
-
},
|
|
18381
|
-
enabled: !!roundId && !!apps.length
|
|
18382
|
-
});
|
|
18383
|
-
};
|
|
18384
|
-
|
|
18385
|
-
// src/hooks/thor/contracts/X2EarnApps/custom/useMostVotedAppsInRound.ts
|
|
18386
|
-
var useMostVotedAppsInRound = (roundId) => {
|
|
18387
|
-
const { data: roundXApps } = useRoundXApps(roundId);
|
|
18388
|
-
const { data: allXApps } = useXApps();
|
|
18389
|
-
const apps = roundId === "0" ? allXApps?.active : roundXApps;
|
|
18390
|
-
const xAppsShares = useXAppsShares(
|
|
18391
|
-
apps?.map((app) => app.id) ?? [],
|
|
18392
|
-
roundId
|
|
18393
|
-
);
|
|
18394
|
-
const mostVotedApps = useMemo(
|
|
18395
|
-
() => xAppsShares.data?.map((appShares) => ({
|
|
18396
|
-
percentage: appShares.share + appShares.unallocatedShare,
|
|
18397
|
-
id: apps?.find((xa) => xa.id === appShares.app)?.id ?? "",
|
|
18398
|
-
app: apps?.find((xa) => xa.id === appShares.app) ?? {}
|
|
18399
|
-
})).sort((a, b) => Number(b.percentage) - Number(a.percentage)) ?? [],
|
|
18400
|
-
[xAppsShares.data, apps]
|
|
18401
|
-
);
|
|
18402
|
-
return {
|
|
18403
|
-
data: mostVotedApps,
|
|
18404
|
-
isLoading: xAppsShares.isLoading
|
|
18405
|
-
};
|
|
18406
|
-
};
|
|
18407
|
-
|
|
18408
|
-
// src/hooks/thor/contracts/X2EarnApps/useXAppsMetadataBaseUri.ts
|
|
18409
|
-
var abi5 = X2EarnApps__factory.abi;
|
|
18410
|
-
var method8 = "baseURI";
|
|
18411
|
-
var getXAppsMetadataBaseUriQueryKey = (network) => getCallClauseQueryKeyWithArgs({
|
|
18412
|
-
abi: abi5,
|
|
18413
|
-
method: method8,
|
|
18414
|
-
address: getConfig(network).x2EarnAppsContractAddress,
|
|
18415
|
-
args: []
|
|
18416
|
-
});
|
|
18417
|
-
var useXAppsMetadataBaseUri = () => {
|
|
18418
|
-
const { network } = useVeChainKitConfig();
|
|
18419
|
-
return useCallClause({
|
|
18420
|
-
abi: abi5,
|
|
18421
|
-
address: getConfig(network.type).x2EarnAppsContractAddress,
|
|
18422
|
-
method: method8,
|
|
18423
|
-
args: [],
|
|
18424
|
-
queryOptions: {
|
|
18425
|
-
enabled: !!network.type,
|
|
18426
|
-
staleTime: 1e3 * 60 * 60
|
|
18427
|
-
// 1 hour,
|
|
18428
|
-
}
|
|
18429
|
-
});
|
|
18430
|
-
};
|
|
18431
|
-
var getXAppRoundEarnings = async (thor, roundId, xAppId, networkType) => {
|
|
18432
|
-
const res = await thor.contracts.load(
|
|
18433
|
-
getConfig(networkType).xAllocationPoolContractAddress,
|
|
18434
|
-
XAllocationPool__factory.abi
|
|
18435
|
-
).read.roundEarnings(roundId, xAppId);
|
|
18436
|
-
if (!res)
|
|
18437
|
-
throw new Error(
|
|
18438
|
-
`Failed to fetch xApp round earnings for ${xAppId} in round ${roundId}`
|
|
18439
|
-
);
|
|
18440
|
-
return { amount: formatEther(BigInt(res[0] || 0)), appId: xAppId };
|
|
18441
|
-
};
|
|
18442
|
-
var getXAppRoundEarningsQueryKey = (roundId, xAppId) => [
|
|
18443
|
-
"VECHAIN_KIT",
|
|
18444
|
-
"roundEarnings",
|
|
18445
|
-
"roundId",
|
|
18446
|
-
Number(roundId),
|
|
18447
|
-
"appId",
|
|
18448
|
-
...xAppId ? [xAppId] : []
|
|
18449
|
-
];
|
|
18450
|
-
var useXAppRoundEarnings = (roundId, xAppId) => {
|
|
18451
|
-
const thor = useThor();
|
|
18452
|
-
const queryClient = getOrCreateQueryClient();
|
|
18453
|
-
const { network } = useVeChainKitConfig();
|
|
18454
|
-
return useQuery({
|
|
18455
|
-
queryKey: getXAppRoundEarningsQueryKey(roundId, xAppId),
|
|
18456
|
-
queryFn: async () => {
|
|
18457
|
-
const data = await queryClient.ensureQueryData({
|
|
18458
|
-
queryFn: () => getRoundXApps(thor, network.type, roundId),
|
|
18459
|
-
queryKey: getRoundXAppsQueryKey(roundId)
|
|
18460
|
-
});
|
|
18461
|
-
const isXAppInRound = data.some((app) => app.id === xAppId);
|
|
18462
|
-
if (!isXAppInRound) return { amount: "0", xAppId };
|
|
18463
|
-
return await getXAppRoundEarnings(
|
|
18464
|
-
thor,
|
|
18465
|
-
roundId,
|
|
18466
|
-
xAppId,
|
|
18467
|
-
network.type
|
|
18468
|
-
);
|
|
18469
|
-
},
|
|
18470
|
-
enabled: !!thor && !!roundId && !!xAppId
|
|
18471
|
-
});
|
|
18472
|
-
};
|
|
18473
|
-
var useMultipleXAppRoundEarnings = (roundId, xAppIds) => {
|
|
18474
|
-
const thor = useThor();
|
|
18475
|
-
const queryClient = getOrCreateQueryClient();
|
|
18476
|
-
const { network } = useVeChainKitConfig();
|
|
18477
|
-
return useQuery({
|
|
18478
|
-
queryKey: getXAppRoundEarningsQueryKey(roundId, "ALL"),
|
|
18479
|
-
queryFn: async () => {
|
|
18480
|
-
const data = await queryClient.ensureQueryData({
|
|
18481
|
-
queryFn: () => getRoundXApps(thor, network.type, roundId),
|
|
18482
|
-
queryKey: getRoundXAppsQueryKey(roundId)
|
|
18483
|
-
});
|
|
18484
|
-
const xAllocationPoolContract = getConfig(
|
|
18485
|
-
network.type
|
|
18486
|
-
).xAllocationPoolContractAddress;
|
|
18487
|
-
const xAppsInRound = data.filter((app) => xAppIds.includes(app.id));
|
|
18488
|
-
const contract = thor.contracts.load(
|
|
18489
|
-
xAllocationPoolContract,
|
|
18490
|
-
XAllocationPool__factory.abi
|
|
18491
|
-
);
|
|
18492
|
-
const clauses = xAppsInRound.map(
|
|
18493
|
-
(app) => contract.clause.roundEarnings(roundId, app.id)
|
|
18494
|
-
);
|
|
18495
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18496
|
-
clauses
|
|
18497
|
-
);
|
|
18498
|
-
if (!res.every((r) => r.success))
|
|
18499
|
-
throw new Error("Failed to fetch xApp round earnings");
|
|
18500
|
-
const decoded = res.map((earnings, index) => {
|
|
18501
|
-
const parsedAmount = formatEther(
|
|
18502
|
-
earnings.result.plain
|
|
18503
|
-
);
|
|
18504
|
-
const appId = xAppsInRound[index]?.id;
|
|
18505
|
-
queryClient.setQueryData(
|
|
18506
|
-
getXAppRoundEarningsQueryKey(roundId, appId),
|
|
18507
|
-
{
|
|
18508
|
-
amount: parsedAmount,
|
|
18509
|
-
appId
|
|
18510
|
-
}
|
|
18511
|
-
);
|
|
18512
|
-
return { amount: parsedAmount, appId };
|
|
18513
|
-
});
|
|
18514
|
-
return decoded;
|
|
18515
|
-
},
|
|
18516
|
-
enabled: !!thor && !!roundId && !!xAppIds.length
|
|
18517
|
-
});
|
|
18518
|
-
};
|
|
18519
|
-
var getXAppTotalEarningsQueryKey = (tillRoundId, appId) => [
|
|
18520
|
-
"VECHAIN_KIT",
|
|
18521
|
-
"XAllocationPool",
|
|
18522
|
-
"xApp",
|
|
18523
|
-
appId,
|
|
18524
|
-
"totalEarningsTillRound",
|
|
18525
|
-
tillRoundId
|
|
18526
|
-
];
|
|
18527
|
-
var useXAppTotalEarnings = (roundIds, appId) => {
|
|
18528
|
-
const thor = useThor();
|
|
18529
|
-
const { network } = useVeChainKitConfig();
|
|
18530
|
-
const queryClient = getOrCreateQueryClient();
|
|
18531
|
-
const lastRound = roundIds[roundIds.length - 1] ?? 0;
|
|
18532
|
-
return useQuery({
|
|
18533
|
-
queryKey: getXAppTotalEarningsQueryKey(lastRound, appId),
|
|
18534
|
-
queryFn: async () => {
|
|
18535
|
-
const contract = thor.contracts.load(
|
|
18536
|
-
getConfig(network.type).xAllocationPoolContractAddress,
|
|
18537
|
-
XAllocationPool__factory.abi
|
|
18538
|
-
);
|
|
18539
|
-
const clauses = roundIds.map(
|
|
18540
|
-
(roundId) => contract.clause.roundEarnings(roundId, appId)
|
|
18541
|
-
);
|
|
18542
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18543
|
-
clauses
|
|
18544
|
-
);
|
|
18545
|
-
if (!res.every((r) => r.success))
|
|
18546
|
-
throw new Error(
|
|
18547
|
-
`Failed to fetch xApp total earnings of ${appId}`
|
|
18548
|
-
);
|
|
18549
|
-
const decoded = res.map((r, index) => {
|
|
18550
|
-
const parsedAmount = formatEther(
|
|
18551
|
-
r.result.plain || BigInt(0)
|
|
18552
|
-
);
|
|
18553
|
-
queryClient.setQueryData(
|
|
18554
|
-
getXAppRoundEarningsQueryKey(
|
|
18555
|
-
roundIds[index],
|
|
18556
|
-
appId
|
|
18557
|
-
),
|
|
18558
|
-
{
|
|
18559
|
-
amount: parsedAmount,
|
|
18560
|
-
appId
|
|
18561
|
-
}
|
|
18562
|
-
);
|
|
18563
|
-
return parsedAmount;
|
|
18564
|
-
});
|
|
18565
|
-
return decoded.reduce((acc, amount) => {
|
|
18566
|
-
return acc + Number(amount);
|
|
18567
|
-
}, 0);
|
|
18568
|
-
}
|
|
18569
|
-
});
|
|
18570
|
-
};
|
|
18571
|
-
|
|
18572
|
-
// src/hooks/thor/contracts/XAllocationVoting/useAllocationsRoundState.ts
|
|
18573
|
-
var RoundState = {
|
|
18574
|
-
0: "Active",
|
|
18575
|
-
1: "Failed",
|
|
18576
|
-
2: "Succeeded"
|
|
18577
|
-
};
|
|
18578
|
-
var abi6 = XAllocationVoting__factory.abi;
|
|
18579
|
-
var method9 = "state";
|
|
18580
|
-
var getAllocationsRoundStateQueryKey = (roundId, network) => getCallClauseQueryKeyWithArgs({
|
|
18581
|
-
abi: abi6,
|
|
18582
|
-
method: method9,
|
|
18583
|
-
address: getConfig(network).xAllocationVotingContractAddress,
|
|
18584
|
-
args: [BigInt(roundId || 0)]
|
|
18585
|
-
});
|
|
18586
|
-
var useAllocationsRoundState = (roundId) => {
|
|
18587
|
-
const { network } = useVeChainKitConfig();
|
|
18588
|
-
return useCallClause({
|
|
18589
|
-
abi: abi6,
|
|
18590
|
-
address: getConfig(network.type).xAllocationVotingContractAddress,
|
|
18591
|
-
method: method9,
|
|
18592
|
-
args: [BigInt(roundId || 0)],
|
|
18593
|
-
queryOptions: {
|
|
18594
|
-
enabled: !!roundId && !!network.type,
|
|
18595
|
-
select: (data) => data[0]
|
|
18596
|
-
}
|
|
18597
|
-
});
|
|
18598
|
-
};
|
|
18599
|
-
|
|
18600
|
-
// src/hooks/thor/contracts/XAllocationVoting/useCurrentAllocationsRoundId.ts
|
|
18601
|
-
var abi7 = XAllocationVoting__factory.abi;
|
|
18602
|
-
var method10 = "currentRoundId";
|
|
18603
|
-
var getCurrentAllocationsRoundIdQueryKey = (network) => getCallClauseQueryKeyWithArgs({
|
|
18604
|
-
abi: abi7,
|
|
18605
|
-
method: method10,
|
|
18606
|
-
address: getConfig(network).xAllocationVotingContractAddress,
|
|
18607
|
-
args: []
|
|
18608
|
-
});
|
|
18609
|
-
var useCurrentAllocationsRoundId = () => {
|
|
18610
|
-
const { network } = useVeChainKitConfig();
|
|
18611
|
-
return useCallClause({
|
|
18612
|
-
abi: abi7,
|
|
18613
|
-
address: getConfig(network.type).xAllocationVotingContractAddress,
|
|
18614
|
-
method: method10,
|
|
18615
|
-
args: [],
|
|
18616
|
-
queryOptions: {
|
|
18617
|
-
enabled: !!network.type,
|
|
18618
|
-
select: (data) => data[0].toString()
|
|
18619
|
-
}
|
|
18620
|
-
});
|
|
18621
|
-
};
|
|
18622
|
-
|
|
18623
|
-
// src/hooks/thor/contracts/XAllocationVoting/useHasVotedInRound.ts
|
|
18624
|
-
var method11 = "hasVoted";
|
|
18625
|
-
var abi8 = XAllocationVoting__factory.abi;
|
|
18626
|
-
var getHasVotedInRoundQueryKey = (roundId, address, networkType) => getCallClauseQueryKeyWithArgs({
|
|
18627
|
-
abi: abi8,
|
|
18628
|
-
address: getConfig(networkType).xAllocationVotingContractAddress,
|
|
18629
|
-
method: method11,
|
|
18630
|
-
args: [BigInt(roundId || 0), address]
|
|
18631
|
-
});
|
|
18632
|
-
var useHasVotedInRound = (roundId, address) => {
|
|
18633
|
-
const { network } = useVeChainKitConfig();
|
|
18634
|
-
return useCallClause({
|
|
18635
|
-
abi: abi8,
|
|
18636
|
-
address: getConfig(network.type).xAllocationVotingContractAddress,
|
|
18637
|
-
method: method11,
|
|
18638
|
-
args: [BigInt(roundId || 0), address],
|
|
18639
|
-
queryOptions: {
|
|
18640
|
-
enabled: !!roundId && !!address,
|
|
18641
|
-
select: (data) => data[0]
|
|
18642
|
-
}
|
|
18643
|
-
});
|
|
18644
|
-
};
|
|
18645
|
-
var getAllocationsRoundsEvents = async (thor, networkType) => {
|
|
18646
|
-
const xAllocationVotingContract = getConfig(networkType).xAllocationVotingContractAddress;
|
|
18647
|
-
const eventAbi = thor.contracts.load(xAllocationVotingContract, XAllocationVoting__factory.abi).getEventAbi("RoundCreated");
|
|
18648
|
-
const events = await getAllEventLogs({
|
|
18649
|
-
thor,
|
|
18650
|
-
filterCriteria: [
|
|
18651
|
-
{
|
|
18652
|
-
criteria: {
|
|
18653
|
-
address: xAllocationVotingContract,
|
|
18654
|
-
topic0: eventAbi.signatureHash
|
|
18655
|
-
},
|
|
18656
|
-
eventAbi
|
|
18657
|
-
}
|
|
18658
|
-
],
|
|
18659
|
-
nodeUrl: getConfig(networkType).nodeUrl
|
|
18660
|
-
});
|
|
18661
|
-
const decodedCreatedAllocationEvents = [];
|
|
18662
|
-
events.forEach((event) => {
|
|
18663
|
-
if (!event.decodedData) {
|
|
18664
|
-
throw new Error("Event data not decoded");
|
|
18665
|
-
}
|
|
18666
|
-
if (!compareAddresses(event.address, xAllocationVotingContract)) {
|
|
18667
|
-
throw new Error("Event address not valid");
|
|
18668
|
-
}
|
|
18669
|
-
const [roundId, proposer, voteStart, voteEnd, appsIds] = event.decodedData;
|
|
18670
|
-
decodedCreatedAllocationEvents.push({
|
|
18671
|
-
roundId: roundId.toString(),
|
|
18672
|
-
proposer,
|
|
18673
|
-
voteStart: voteStart.toString(),
|
|
18674
|
-
voteEnd: voteEnd.toString(),
|
|
18675
|
-
appsIds: appsIds.map((appId) => appId.toString())
|
|
18676
|
-
});
|
|
18677
|
-
});
|
|
18678
|
-
return {
|
|
18679
|
-
created: decodedCreatedAllocationEvents
|
|
18680
|
-
};
|
|
18681
|
-
};
|
|
18682
|
-
var getAllocationsRoundsEventsQueryKey = () => [
|
|
18683
|
-
"VECHAIN_KIT",
|
|
18684
|
-
"allocationRoundsEvents"
|
|
18685
|
-
];
|
|
18686
|
-
var useAllocationsRoundsEvents = () => {
|
|
18687
|
-
const thor = useThor();
|
|
18688
|
-
const { network } = useVeChainKitConfig();
|
|
18689
|
-
return useQuery({
|
|
18690
|
-
queryKey: getAllocationsRoundsEventsQueryKey(),
|
|
18691
|
-
queryFn: async () => await getAllocationsRoundsEvents(thor, network.type),
|
|
18692
|
-
enabled: !!thor && !!network.type
|
|
18693
|
-
});
|
|
18694
|
-
};
|
|
18695
|
-
|
|
18696
|
-
// src/hooks/thor/contracts/XAllocationVoting/custom/useCurrentAllocationsRound.ts
|
|
18697
|
-
var useCurrentAllocationsRound = () => {
|
|
18698
|
-
const currentRoundId = useCurrentAllocationsRoundId();
|
|
18699
|
-
const allocationsRound = useAllocationsRound(currentRoundId.data);
|
|
18700
|
-
return {
|
|
18701
|
-
...allocationsRound,
|
|
18702
|
-
isLoading: currentRoundId.isLoading || allocationsRound.isLoading,
|
|
18703
|
-
isError: currentRoundId.isError || allocationsRound.isError,
|
|
18704
|
-
error: currentRoundId.error || allocationsRound.error
|
|
18705
|
-
};
|
|
18706
|
-
};
|
|
18707
|
-
var useAllocationsRound = (roundId) => {
|
|
18708
|
-
const { data: currentBlock } = useCurrentBlock();
|
|
18709
|
-
const currentAllocationId = useCurrentAllocationsRoundId();
|
|
18710
|
-
const currentAllocationState = useAllocationsRoundState(roundId);
|
|
18711
|
-
const allocationRoundsEvents = useAllocationsRoundsEvents();
|
|
18712
|
-
const { network } = useVeChainKitConfig();
|
|
18713
|
-
const currentAllocationRound = useMemo(() => {
|
|
18714
|
-
if (!currentAllocationId.data || !allocationRoundsEvents.data)
|
|
18715
|
-
return;
|
|
18716
|
-
const roundInfo = allocationRoundsEvents.data.created.find(
|
|
18717
|
-
(allocationRound) => allocationRound.roundId === roundId
|
|
18718
|
-
);
|
|
18719
|
-
if (!roundInfo) return;
|
|
18720
|
-
return {
|
|
18721
|
-
...roundInfo,
|
|
18722
|
-
state: currentAllocationState.data,
|
|
18723
|
-
isCurrent: roundId === currentAllocationId.data
|
|
18724
|
-
};
|
|
18725
|
-
}, [
|
|
18726
|
-
currentAllocationId,
|
|
18727
|
-
allocationRoundsEvents,
|
|
18728
|
-
currentAllocationState,
|
|
18729
|
-
roundId
|
|
18730
|
-
]);
|
|
18731
|
-
const isLoading = currentAllocationId.isLoading || allocationRoundsEvents.isLoading || currentAllocationState.isLoading;
|
|
18732
|
-
const isError = currentAllocationId.isError || allocationRoundsEvents.isError || currentAllocationState.isError;
|
|
18733
|
-
const error = currentAllocationId.error || allocationRoundsEvents.error || currentAllocationState.error;
|
|
18734
|
-
const blockTime = getConfig(network.type).network.blockTime;
|
|
18735
|
-
const estimatedEndTime = useMemo(() => {
|
|
18736
|
-
if (!currentAllocationRound) return null;
|
|
18737
|
-
const endBlock = Number(currentAllocationRound.voteEnd);
|
|
18738
|
-
if (!endBlock || !currentBlock) return null;
|
|
18739
|
-
const endBlockFromNow = endBlock - currentBlock.number;
|
|
18740
|
-
const durationLeftTimestamp = endBlockFromNow * blockTime;
|
|
18741
|
-
return Date.now() + durationLeftTimestamp;
|
|
18742
|
-
}, [currentBlock, currentAllocationRound, blockTime]);
|
|
18743
|
-
const estimatedStartTime = useMemo(() => {
|
|
18744
|
-
if (!currentAllocationRound) return null;
|
|
18745
|
-
const startBlock = Number(currentAllocationRound.voteStart);
|
|
18746
|
-
if (!startBlock || !currentBlock) return null;
|
|
18747
|
-
const endBlockFromNow = startBlock - currentBlock.number;
|
|
18748
|
-
const durationLeftTimestamp = endBlockFromNow * blockTime;
|
|
18749
|
-
return Date.now() + durationLeftTimestamp;
|
|
18750
|
-
}, [currentBlock, currentAllocationRound, blockTime]);
|
|
18751
|
-
const isFirstRound = currentAllocationRound?.roundId === "1";
|
|
18752
|
-
const isLastRound = currentAllocationRound?.roundId === allocationRoundsEvents?.data?.created.length.toString();
|
|
18753
|
-
return {
|
|
18754
|
-
...allocationRoundsEvents,
|
|
18755
|
-
data: {
|
|
18756
|
-
...currentAllocationRound,
|
|
18757
|
-
voteStartTimestamp: estimatedStartTime,
|
|
18758
|
-
voteEndTimestamp: estimatedEndTime,
|
|
18759
|
-
isFirstRound,
|
|
18760
|
-
isLastRound
|
|
18761
|
-
},
|
|
18762
|
-
isLoading,
|
|
18763
|
-
isError,
|
|
18764
|
-
error
|
|
18765
|
-
};
|
|
18766
|
-
};
|
|
18767
|
-
var contractAbi5 = XAllocationVotingGovernor__factory.abi;
|
|
18768
|
-
var method12 = "getAppVotes";
|
|
18769
|
-
var getXAppVotesQueryKey = (networkType, roundId, appId) => getCallClauseQueryKeyWithArgs({
|
|
18770
|
-
abi: contractAbi5,
|
|
18771
|
-
address: getConfig(networkType).xAllocationVotingContractAddress,
|
|
18772
|
-
method: method12,
|
|
18773
|
-
args: [BigInt(roundId || 0), appId]
|
|
18774
|
-
});
|
|
18775
|
-
var useXAppVotes = (roundId, appId) => {
|
|
18776
|
-
const { network } = useVeChainKitConfig();
|
|
18777
|
-
const contractAddress = getConfig(
|
|
18778
|
-
network.type
|
|
18779
|
-
).xAllocationVotingContractAddress;
|
|
18780
|
-
return useCallClause({
|
|
18781
|
-
address: contractAddress,
|
|
18782
|
-
abi: contractAbi5,
|
|
18783
|
-
method: method12,
|
|
18784
|
-
args: [BigInt(roundId || 0), appId],
|
|
18785
|
-
queryOptions: {
|
|
18786
|
-
enabled: !!roundId && !!appId && !!network.type,
|
|
18787
|
-
select: (res) => formatEther(BigInt(res[0]))
|
|
18788
|
-
}
|
|
18789
|
-
});
|
|
18790
|
-
};
|
|
18791
|
-
|
|
18792
|
-
// src/hooks/thor/logs/logUtils.ts
|
|
18793
|
-
var MAX_EVENTS_PER_QUERY = 1e3;
|
|
18794
|
-
var getEventLogs = async ({
|
|
18795
|
-
thor,
|
|
18796
|
-
order = "asc",
|
|
18797
|
-
offset = 0,
|
|
18798
|
-
limit = MAX_EVENTS_PER_QUERY,
|
|
18799
|
-
from = 0,
|
|
18800
|
-
to = thor.blocks.getHeadBlock()?.number,
|
|
18801
|
-
filterCriteria
|
|
18802
|
-
}) => {
|
|
18803
|
-
const response = await thor.logs.filterEventLogs({
|
|
18804
|
-
range: {
|
|
18805
|
-
from,
|
|
18806
|
-
to,
|
|
18807
|
-
unit: "block"
|
|
18808
|
-
},
|
|
18809
|
-
options: {
|
|
18810
|
-
offset,
|
|
18811
|
-
limit
|
|
18812
|
-
},
|
|
18813
|
-
order,
|
|
18814
|
-
criteriaSet: filterCriteria
|
|
18815
|
-
});
|
|
18816
|
-
if (!response) throw new Error("Failed to fetch events");
|
|
18817
|
-
return response;
|
|
18818
|
-
};
|
|
18819
|
-
var getAllEventLogs = async ({
|
|
18820
|
-
nodeUrl,
|
|
18821
|
-
thor,
|
|
18822
|
-
order = "asc",
|
|
18823
|
-
from = 0,
|
|
18824
|
-
to,
|
|
18825
|
-
filterCriteria
|
|
18826
|
-
}) => {
|
|
18827
|
-
const allEvents = [];
|
|
18828
|
-
let offset = 0;
|
|
18829
|
-
while (true) {
|
|
18830
|
-
const events = await getEventLogs({
|
|
18831
|
-
thor,
|
|
18832
|
-
filterCriteria,
|
|
18833
|
-
from,
|
|
18834
|
-
to: to ?? Number.MAX_SAFE_INTEGER,
|
|
18835
|
-
limit: MAX_EVENTS_PER_QUERY,
|
|
18836
|
-
order,
|
|
18837
|
-
offset
|
|
18838
|
-
});
|
|
18839
|
-
allEvents.push(...events);
|
|
18840
|
-
if (events.length < MAX_EVENTS_PER_QUERY) {
|
|
18841
|
-
return allEvents;
|
|
18842
|
-
}
|
|
18843
|
-
offset += MAX_EVENTS_PER_QUERY;
|
|
18844
|
-
}
|
|
18845
|
-
};
|
|
18846
|
-
|
|
18847
|
-
// src/hooks/thor/transactions/transactionUtils.ts
|
|
18848
|
-
var estimateTxGas = async (thor, clauses, caller) => {
|
|
18849
|
-
const response = await thor.transactions.estimateGas(clauses, caller);
|
|
18850
|
-
if (response.reverted) throw new Error("Failed to estimate gas");
|
|
18851
|
-
return response.totalGas;
|
|
18852
|
-
};
|
|
18853
|
-
var useSendTransaction = ({
|
|
18854
|
-
signerAccountAddress,
|
|
18855
|
-
clauses,
|
|
18856
|
-
onTxConfirmed,
|
|
18857
|
-
onTxFailedOrCancelled,
|
|
18858
|
-
suggestedMaxGas,
|
|
18859
|
-
privyUIOptions
|
|
18860
|
-
}) => {
|
|
17911
|
+
var useSendTransaction = ({
|
|
17912
|
+
signerAccountAddress,
|
|
17913
|
+
clauses,
|
|
17914
|
+
onTxConfirmed,
|
|
17915
|
+
onTxFailedOrCancelled,
|
|
17916
|
+
suggestedMaxGas,
|
|
17917
|
+
privyUIOptions
|
|
17918
|
+
}) => {
|
|
18861
17919
|
const thor = useThor();
|
|
18862
17920
|
const { signer } = useWallet$1();
|
|
18863
17921
|
const { connection } = useWallet();
|
|
@@ -19209,16 +18267,14 @@ var AddressDisplayCard = ({
|
|
|
19209
18267
|
}) => {
|
|
19210
18268
|
const { darkMode: isDark } = useVeChainKitConfig();
|
|
19211
18269
|
const { t } = useTranslation();
|
|
19212
|
-
const { isLoading: totalBalanceLoading } = useTotalBalance({
|
|
19213
|
-
|
|
19214
|
-
});
|
|
19215
|
-
const { tokens: tokens2, isLoading: tokensLoading } = useTokensWithValues({
|
|
18270
|
+
const { isLoading: totalBalanceLoading } = useTotalBalance({ address });
|
|
18271
|
+
const { tokens, isLoading: tokensLoading } = useTokensWithValues({
|
|
19216
18272
|
address
|
|
19217
18273
|
});
|
|
19218
18274
|
const tokenData = useMemo(() => {
|
|
19219
18275
|
if (!tokenAddress) return null;
|
|
19220
|
-
return
|
|
19221
|
-
}, [
|
|
18276
|
+
return tokens.find((token) => token.address === tokenAddress);
|
|
18277
|
+
}, [tokens, tokenAddress]);
|
|
19222
18278
|
const displayBalance = useMemo(() => {
|
|
19223
18279
|
if (balance !== void 0) return balance;
|
|
19224
18280
|
if (tokenData) {
|
|
@@ -20488,7 +19544,7 @@ var useVeChainKitConfig = () => {
|
|
|
20488
19544
|
var validateConfig = (props) => {
|
|
20489
19545
|
const errors = [];
|
|
20490
19546
|
const requiresFeeDelegation = props.privy !== void 0 || props.loginMethods?.some(
|
|
20491
|
-
(
|
|
19547
|
+
(method7) => method7.method === "vechain" || method7.method === "ecosystem"
|
|
20492
19548
|
);
|
|
20493
19549
|
if (requiresFeeDelegation) {
|
|
20494
19550
|
if (!props.feeDelegation) {
|
|
@@ -20516,7 +19572,7 @@ var validateConfig = (props) => {
|
|
|
20516
19572
|
if (props.loginMethods) {
|
|
20517
19573
|
if (!props.privy) {
|
|
20518
19574
|
const invalidMethods = props.loginMethods.filter(
|
|
20519
|
-
(
|
|
19575
|
+
(method7) => ["email", "google", "passkey", "more"].includes(method7.method)
|
|
20520
19576
|
);
|
|
20521
19577
|
if (invalidMethods.length > 0) {
|
|
20522
19578
|
errors.push(
|
|
@@ -20581,7 +19637,7 @@ var VeChainKitProvider = (props) => {
|
|
|
20581
19637
|
const validatedLoginMethods = loginMethods;
|
|
20582
19638
|
const allowedEcosystemApps = useMemo(() => {
|
|
20583
19639
|
const userEcosystemMethods = validatedLoginMethods?.find(
|
|
20584
|
-
(
|
|
19640
|
+
(method7) => method7.method === "ecosystem"
|
|
20585
19641
|
);
|
|
20586
19642
|
return userEcosystemMethods?.allowedApps ?? DEFAULT_PRIVY_ECOSYSTEM_APPS.map((app) => app.id);
|
|
20587
19643
|
}, [validatedLoginMethods]);
|
|
@@ -21115,6 +20171,6 @@ var VechainKitThemeProvider = ({
|
|
|
21115
20171
|
] });
|
|
21116
20172
|
};
|
|
21117
20173
|
|
|
21118
|
-
export { AccessAndSecurityContent, AccessAndSecurityModalProvider, AccountAvatar, AccountCustomizationModalProvider, AccountDetailsButton, AccountMainContent, AccountModal, AccountModalProvider, AccountSelector, ActionButton, AddressDisplay, AddressDisplayCard, AppearanceSettingsContent, AssetButton, AssetsContent, BalanceSection, BaseModal, BridgeContent, ChangeCurrencyContent, ChooseNameContent, ChooseNameModalProvider, ChooseNameSearchContent, ChooseNameSummaryContent, ConnectModal, ConnectModalProvider, ConnectPopover, ConnectionButton, CrossAppConnectionSecurityCard, CustomizationContent, CustomizationSummaryContent, DappKitButton, DisconnectConfirmContent, DomainRequiredAlert, EcosystemButton, EcosystemModal, EmailLoginButton, EmbeddedWalletContent, ExchangeWarningAlert, ExploreEcosystemModalProvider, FAQContent, FAQModalProvider, FadeInView, FadeInViewFromBottom, FadeInViewFromLeft, FadeInViewFromRight, FeatureAnnouncementCard, GeneralSettingsContent, LanguageSettingsContent, LegalDocumentItem, LegalDocumentsModal, LegalDocumentsProvider, LocalStorageKey, LoginLoadingModal, LoginWithGoogleButton, MAX_IMAGE_SIZE, MainContent, ManageCustomTokenContent, ModalBackButton, ModalFAQButton, ModalNotificationButton, NotificationsModalProvider, PRICE_FEED_IDS, PasskeyLoginButton, PrivyButton, PrivyWalletProvider, ProfileCard, ProfileContent, ProfileModalProvider, QuickActionsSection, ReceiveModalProvider, ReceiveTokenContent,
|
|
20174
|
+
export { AccessAndSecurityContent, AccessAndSecurityModalProvider, AccountAvatar, AccountCustomizationModalProvider, AccountDetailsButton, AccountMainContent, AccountModal, AccountModalProvider, AccountSelector, ActionButton, AddressDisplay, AddressDisplayCard, AppearanceSettingsContent, AssetButton, AssetsContent, BalanceSection, BaseModal, BridgeContent, ChangeCurrencyContent, ChooseNameContent, ChooseNameModalProvider, ChooseNameSearchContent, ChooseNameSummaryContent, ConnectModal, ConnectModalProvider, ConnectPopover, ConnectionButton, CrossAppConnectionSecurityCard, CustomizationContent, CustomizationSummaryContent, DappKitButton, DisconnectConfirmContent, DomainRequiredAlert, EcosystemButton, EcosystemModal, EmailLoginButton, EmbeddedWalletContent, ExchangeWarningAlert, ExploreEcosystemModalProvider, FAQContent, FAQModalProvider, FadeInView, FadeInViewFromBottom, FadeInViewFromLeft, FadeInViewFromRight, FeatureAnnouncementCard, GeneralSettingsContent, LanguageSettingsContent, LegalDocumentItem, LegalDocumentsModal, LegalDocumentsProvider, LocalStorageKey, LoginLoadingModal, LoginWithGoogleButton, MAX_IMAGE_SIZE, MainContent, ManageCustomTokenContent, ModalBackButton, ModalFAQButton, ModalNotificationButton, NotificationsModalProvider, PRICE_FEED_IDS, PasskeyLoginButton, PrivyButton, PrivyWalletProvider, ProfileCard, ProfileContent, ProfileModalProvider, QuickActionsSection, ReceiveModalProvider, ReceiveTokenContent, ScrollToTopWrapper, SelectTokenContent, SendTokenContent, SendTokenModalProvider, SendTokenSummaryContent, SettingsContent, ShareButtons, SocialIcons, StickyFooterContainer, StickyHeaderContainer, SwapTokenContent, TermsAndPrivacyContent, TransactionButtonAndStatus, TransactionModal, TransactionModalContent, TransactionModalProvider, TransactionToast, TransactionToastProvider, UpgradeSmartAccountContent, UpgradeSmartAccountModal, UpgradeSmartAccountModalProvider, VeChainKitContext, VeChainKitProvider, VeChainLoginButton, VeChainWithPrivyLoginButton, VechainKitThemeProvider, VersionFooter, WalletButton, WalletModalProvider, compressImages, currentBlockQueryKey, fetchAppHubApps, fetchPrivyAppInfo, fetchPrivyStatus, fetchVechainDomain, getAccountAddress, getAccountAddressQueryKey, getAccountBalance, getAccountBalanceQueryKey, getAccountImplementationAddress, getAccountImplementationAddressQueryKey, getAccountVersionQueryKey, getAllEventLogs, getAppHubAppsQueryKey, getAvatar, getAvatarLegacy, getAvatarLegacyQueryKey, getAvatarOfAddressQueryKey, getAvatarQueryKey, getB3trBalance, getB3trBalanceQueryKey, getCallClauseQueryKey, getCallClauseQueryKeyWithArgs, getChainId, getChainIdQueryKey, getCurrentAccountImplementationVersion, getCurrentAccountImplementationVersionQueryKey, getCurrentAllocationsRoundIdQueryKey, getCustomTokenBalance, getCustomTokenBalanceQueryKey, getCustomTokenInfo, getDomainsOfAddress, getDomainsOfAddressQueryKey, getEnsRecordExistsQueryKey, getErc20Balance, getErc20BalanceQueryKey, getEventLogs, getHasV1SmartAccount, getHasV1SmartAccountQueryKey, getIpfsImage, getIpfsImageQueryKey, getIpfsMetadata, getIpfsMetadataQueryKey, getIsDeployed, getIsDeployedQueryKey, getIsDomainProtectedQueryKey, getIsPersonQueryKey, getPrivyAppInfoQueryKey, getResolverAddressQueryKey, getRoundXAppsQueryKey, getSmartAccount, getSmartAccountQueryKey, getTextRecords, getTextRecordsQueryKey, getTokenInfo, getTokenUsdPrice, getTokenUsdPriceQueryKey, getUpgradeRequired, getUpgradeRequiredForAccount, getUpgradeRequiredForAccountQueryKey, getUpgradeRequiredQueryKey, getVechainDomainQueryKey, getVersion, getVersionQueryKey, getVot3Balance, getVot3BalanceQueryKey, getXAppMetadata, getXAppsSharesQueryKey, imageCompressionOptions, txReceiptQueryKey, useAccessAndSecurityModal, useAccountBalance, useAccountCustomizationModal, useAccountImplementationAddress, useAccountModal, useAppHubApps, useBuildTransaction, useCallClause, useChooseNameModal, useClaimVeWorldSubdomain, useClaimVetDomain, useConnectModal, useCrossAppConnectionCache, useCurrency, useCurrentAccountImplementationVersion, useCurrentAllocationsRoundId, useCurrentBlock, useCustomTokens, useEcosystemShortcuts, useEnsRecordExists, useExploreEcosystemModal, useFAQModal, useFeatureAnnouncement, useFetchAppInfo, useFetchPrivyStatus, useGetAccountAddress, useGetAccountVersion, useGetAvatar, useGetAvatarLegacy, useGetAvatarOfAddress, useGetB3trBalance, useGetChainId, useGetCustomTokenBalances, useGetCustomTokenInfo, useGetDomainsOfAddress, useGetErc20Balance, useGetNodeUrl, useGetResolverAddress, useGetTextRecords, useGetTokenUsdPrice, useGetVot3Balance, useHasV1SmartAccount, useIpfsImage, useIpfsImageList, useIpfsMetadata, useIpfsMetadatas, useIsDomainProtected, useIsPWA, useIsPerson, useIsSmartAccountDeployed, useLegalDocuments, useLocalStorage, useLoginModalContent, useLoginWithOAuth2 as useLoginWithOAuth, useLoginWithPasskey, useLoginWithVeChain, useMostVotedAppsInRound, useNotificationAlerts, useNotifications, useNotificationsModal, usePrivyWalletProvider, useProfileModal, useReceiveModal, useRefreshBalances, useRefreshFactoryQueries, useRefreshMetadata, useRefreshSmartAccountQueries, useRoundXApps, useScrollToTop, useSendTokenModal, useSendTransaction, useSignMessage2 as useSignMessage, useSignTypedData2 as useSignTypedData, useSingleImageUpload, useSmartAccount, useSmartAccountVersion, useSyncableLocalStorage, useTokenBalances, useTokenPrices, useTokensWithValues, useTotalBalance, useTransactionModal, useTransactionToast, useTransferERC20, useTransferVET, useTxReceipt, useUnsetDomain, useUpdateTextRecord, useUpgradeRequired, useUpgradeRequiredForAccount, useUpgradeSmartAccount, useUpgradeSmartAccountModal, useUploadImages, useVeChainKitConfig, useVechainDomain, useWallet, useWalletMetadata, useWalletModal2 as useWalletModal, useXAppMetadata, useXAppsShares };
|
|
21119
20175
|
//# sourceMappingURL=index.js.map
|
|
21120
20176
|
//# sourceMappingURL=index.js.map
|