@vechain/vechain-kit 2.0.0-rc.2 → 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/{chunk-PTWGTINW.cjs → chunk-LMX37RCG.cjs} +3 -3
- package/dist/chunk-LMX37RCG.cjs.map +1 -0
- package/dist/{chunk-R722OBPE.js → chunk-SNDIAFF7.js} +3 -3
- package/dist/chunk-SNDIAFF7.js.map +1 -0
- package/dist/index.cjs +751 -1642
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +196 -1314
- package/dist/index.d.ts +196 -1314
- package/dist/index.js +595 -1439
- 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.cjs +52 -52
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-PTWGTINW.cjs.map +0 -1
- package/dist/chunk-R722OBPE.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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,
|
|
3
|
-
export { CURRENCY_SYMBOLS, ENS_TEXT_RECORDS, LegalDocumentSource, LegalDocumentType, NFTMediaType, VePassportUserStatus, buildCallClauses, executeCallClause, executeMultipleClausesCall, getConfig } from './chunk-
|
|
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
|
+
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';
|
|
6
6
|
import i18n from 'i18next';
|
|
@@ -11,22 +11,24 @@ 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
|
+
import { hashFn } from 'wagmi/query';
|
|
15
16
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
16
17
|
import { motion } from 'framer-motion';
|
|
17
|
-
import { createMultiStyleConfigHelpers, defineStyle, defineStyleConfig, extendTheme, createStandaloneToast, IconButton, VStack, Text, InputGroup, InputLeftElement, Icon, Input, InputRightElement, HStack, Link, Box, useMediaQuery, Modal, ModalOverlay, ModalContent, Button, Image, useDisclosure, GridItem, ModalHeader, ModalCloseButton, ModalBody, ModalFooter, Tag, Heading, Grid, useColorModeValue, Card, CardBody, Alert, AlertIcon, CardHeader, Center, CardFooter, Divider, Container, FormControl, Select, FormLabel, Textarea, Circle, AlertTitle, AlertDescription, Popover, PopoverTrigger, PopoverContent, PopoverBody, PopoverFooter, Spinner, Skeleton, Checkbox, useSteps, PinInput, PinInputField, Stack, Accordion, AccordionItem, AccordionButton, AccordionPanel, List, ColorModeScript, ChakraProvider, Flex, ListItem, Wrap, WrapItem } from '@chakra-ui/react';
|
|
18
|
+
import { createMultiStyleConfigHelpers, defineStyle, defineStyleConfig, theme, extendTheme, createStandaloneToast, IconButton, VStack, Text, InputGroup, InputLeftElement, Icon, Input, InputRightElement, HStack, Link, Box, useMediaQuery, Modal, ModalOverlay, ModalContent, Button, Image, useDisclosure, GridItem, ModalHeader, ModalCloseButton, ModalBody, ModalFooter, Tag, Heading, Grid, useColorModeValue, Card, CardBody, Alert, AlertIcon, CardHeader, Center, CardFooter, Divider, Container, FormControl, Select, FormLabel, Textarea, Circle, AlertTitle, AlertDescription, Popover, PopoverTrigger, PopoverContent, PopoverBody, PopoverFooter, Spinner, Skeleton, Checkbox, useSteps, PinInput, PinInputField, Stack, Accordion, AccordionItem, AccordionButton, AccordionPanel, List, ColorModeScript, ChakraProvider, Flex, ListItem, Wrap, WrapItem } from '@chakra-ui/react';
|
|
18
19
|
import { IoChevronBack, IoCheckmarkOutline, IoCopyOutline, IoWalletOutline, IoCloseCircle, IoCogSharp, IoShieldOutline, IoSettingsOutline, IoOpenOutline, IoTrashBin, IoLanguage, IoChevronUp, IoChevronDown, IoCloseOutline, IoTrashOutline } from 'react-icons/io5';
|
|
19
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';
|
|
20
21
|
import { HiOutlineWallet, HiOutlineShieldCheck } from 'react-icons/hi2';
|
|
21
22
|
import VeChainKitMixpanel from 'mixpanel-browser';
|
|
22
|
-
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';
|
|
23
24
|
import { ZERO_ADDRESS, Address, Clause, ABIContract } from '@vechain/sdk-core';
|
|
24
|
-
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';
|
|
25
26
|
import { z } from 'zod';
|
|
27
|
+
import { BigNumber } from 'bignumber.js';
|
|
26
28
|
import { useAccount, useConnect, useSignTypedData, useSignMessage, useDisconnect, createConfig, http, WagmiProvider } from 'wagmi';
|
|
27
29
|
import { toPrivyWalletConnector } from '@privy-io/cross-app-connect/rainbow-kit';
|
|
28
30
|
import { isMobile } from 'react-device-detect';
|
|
29
|
-
import
|
|
31
|
+
import axios from 'axios';
|
|
30
32
|
import imageCompression from 'browser-image-compression';
|
|
31
33
|
import { LuMail, LuArrowDownToLine } from 'react-icons/lu';
|
|
32
34
|
import { MdOutlineNavigateNext, MdSwapHoriz, MdOutlineSettingsBackupRestore, MdPhotoCamera, MdCurrencyExchange, MdPrivacyTip, MdOutlineRefresh, MdOutlineErrorOutline, MdEmail, MdGavel, MdCheck } from 'react-icons/md';
|
|
@@ -50,6 +52,8 @@ import { BiBell, BiArchive } from 'react-icons/bi';
|
|
|
50
52
|
import { GoLinkExternal, GoPlus } from 'react-icons/go';
|
|
51
53
|
import { ThorClient, signerUtils, ProviderInternalBaseWallet, VeChainProvider } from '@vechain/sdk-network';
|
|
52
54
|
export { ThorClient } from '@vechain/sdk-network';
|
|
55
|
+
import { CacheProvider, Global, css } from '@emotion/react';
|
|
56
|
+
import createCache from '@emotion/cache';
|
|
53
57
|
import { modalAnatomy, cardAnatomy, popoverAnatomy } from '@chakra-ui/anatomy';
|
|
54
58
|
|
|
55
59
|
// src/languages/en.json
|
|
@@ -4055,6 +4059,15 @@ var languageNames = {
|
|
|
4055
4059
|
zh: "\u4E2D\u6587",
|
|
4056
4060
|
ja: "\u65E5\u672C\u8A9E"
|
|
4057
4061
|
};
|
|
4062
|
+
var bcp47LanguageCodes = {
|
|
4063
|
+
en: "en-US",
|
|
4064
|
+
de: "de-DE",
|
|
4065
|
+
it: "it-IT",
|
|
4066
|
+
fr: "fr-FR",
|
|
4067
|
+
es: "es-ES",
|
|
4068
|
+
zh: "zh-CN",
|
|
4069
|
+
ja: "ja-JP"
|
|
4070
|
+
};
|
|
4058
4071
|
var customLanguageDetector = {
|
|
4059
4072
|
lookup: (options) => {
|
|
4060
4073
|
const propLanguage = options?.languages?.[0];
|
|
@@ -4124,6 +4137,7 @@ function getOrCreateQueryClient() {
|
|
|
4124
4137
|
internalQueryClient = new QueryClient({
|
|
4125
4138
|
defaultOptions: {
|
|
4126
4139
|
queries: {
|
|
4140
|
+
queryKeyHashFn: hashFn,
|
|
4127
4141
|
retry: 0,
|
|
4128
4142
|
staleTime: 3e4,
|
|
4129
4143
|
refetchOnWindowFocus: true,
|
|
@@ -4341,15 +4355,15 @@ var Analytics = {
|
|
|
4341
4355
|
loginMethod
|
|
4342
4356
|
});
|
|
4343
4357
|
},
|
|
4344
|
-
tryAgain: (
|
|
4358
|
+
tryAgain: (method7, platform) => {
|
|
4345
4359
|
Analytics.auth.trackAuth("try_again", {
|
|
4346
|
-
loginMethod:
|
|
4360
|
+
loginMethod: method7,
|
|
4347
4361
|
platform
|
|
4348
4362
|
});
|
|
4349
4363
|
},
|
|
4350
|
-
methodSelected: (
|
|
4364
|
+
methodSelected: (method7) => {
|
|
4351
4365
|
Analytics.auth.trackAuth("method_selected", {
|
|
4352
|
-
loginMethod:
|
|
4366
|
+
loginMethod: method7
|
|
4353
4367
|
});
|
|
4354
4368
|
},
|
|
4355
4369
|
completed: ({
|
|
@@ -4804,7 +4818,7 @@ var AddressDisplay = ({
|
|
|
4804
4818
|
|
|
4805
4819
|
// package.json
|
|
4806
4820
|
var package_default = {
|
|
4807
|
-
version: "2.0.0-rc.
|
|
4821
|
+
version: "2.0.0-rc.4"};
|
|
4808
4822
|
var VersionFooter = ({ ...props }) => {
|
|
4809
4823
|
const { darkMode: isDark } = useVeChainKitConfig();
|
|
4810
4824
|
return /* @__PURE__ */ jsxs(
|
|
@@ -4975,32 +4989,28 @@ var convertToSelectedCurrency = (amountUsd, currency, exchangeRates) => {
|
|
|
4975
4989
|
return amountUsd;
|
|
4976
4990
|
}
|
|
4977
4991
|
};
|
|
4978
|
-
var formatCurrencyValue = (value,
|
|
4992
|
+
var formatCurrencyValue = (value, lng = "en", options) => {
|
|
4979
4993
|
const defaultOptions = {
|
|
4980
4994
|
style: "currency",
|
|
4981
|
-
currency,
|
|
4982
4995
|
minimumFractionDigits: 2,
|
|
4983
4996
|
maximumFractionDigits: 2,
|
|
4997
|
+
currency: options?.currency ?? "usd",
|
|
4984
4998
|
...options
|
|
4985
4999
|
};
|
|
4986
|
-
return new Intl.NumberFormat(
|
|
5000
|
+
return new Intl.NumberFormat(bcp47LanguageCodes[lng], defaultOptions).format(value);
|
|
4987
5001
|
};
|
|
4988
|
-
var formatCompactCurrency = (value,
|
|
5002
|
+
var formatCompactCurrency = (value, options) => {
|
|
4989
5003
|
return formatCurrencyValue(
|
|
4990
5004
|
value,
|
|
4991
|
-
|
|
5005
|
+
i18n_default.resolvedLanguage,
|
|
4992
5006
|
{
|
|
4993
5007
|
notation: "compact",
|
|
4994
|
-
compactDisplay: "short"
|
|
4995
|
-
|
|
4996
|
-
|
|
5008
|
+
compactDisplay: "short",
|
|
5009
|
+
currency: options?.currency ?? "usd",
|
|
5010
|
+
...options
|
|
5011
|
+
}
|
|
4997
5012
|
);
|
|
4998
5013
|
};
|
|
4999
|
-
var amountFormatter = new Intl.NumberFormat("de-DE", {
|
|
5000
|
-
notation: "compact",
|
|
5001
|
-
compactDisplay: "short",
|
|
5002
|
-
maximumFractionDigits: 2
|
|
5003
|
-
});
|
|
5004
5014
|
var AssetButton = ({
|
|
5005
5015
|
symbol,
|
|
5006
5016
|
amount,
|
|
@@ -5056,7 +5066,12 @@ var AssetButton = ({
|
|
|
5056
5066
|
/* @__PURE__ */ jsx(Text, { children: symbol })
|
|
5057
5067
|
] }),
|
|
5058
5068
|
/* @__PURE__ */ jsxs(VStack, { align: "flex-end", spacing: 0, children: [
|
|
5059
|
-
/* @__PURE__ */
|
|
5069
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
5070
|
+
amount.toLocaleString(void 0, {
|
|
5071
|
+
maximumFractionDigits: 2
|
|
5072
|
+
}),
|
|
5073
|
+
" "
|
|
5074
|
+
] }),
|
|
5060
5075
|
/* @__PURE__ */ jsx(
|
|
5061
5076
|
Text,
|
|
5062
5077
|
{
|
|
@@ -5065,8 +5080,7 @@ var AssetButton = ({
|
|
|
5065
5080
|
"data-testid": `${symbol}-balance`,
|
|
5066
5081
|
children: formatCompactCurrency(
|
|
5067
5082
|
currencyValue,
|
|
5068
|
-
currentCurrency
|
|
5069
|
-
"de-DE"
|
|
5083
|
+
{ currency: currentCurrency }
|
|
5070
5084
|
)
|
|
5071
5085
|
}
|
|
5072
5086
|
)
|
|
@@ -6107,13 +6121,13 @@ var useUnsetDomain = ({
|
|
|
6107
6121
|
}
|
|
6108
6122
|
};
|
|
6109
6123
|
};
|
|
6110
|
-
var useTokenBalances = (
|
|
6124
|
+
var useTokenBalances = (address) => {
|
|
6111
6125
|
const { network } = useVeChainKitConfig();
|
|
6112
6126
|
const config = getConfig(network.type);
|
|
6113
6127
|
const { data: vetData, isLoading: vetLoading } = useAccountBalance(address);
|
|
6114
6128
|
const { data: b3trBalance, isLoading: b3trLoading } = useGetB3trBalance(address);
|
|
6115
6129
|
const { data: vot3Balance, isLoading: vot3Loading } = useGetVot3Balance(address);
|
|
6116
|
-
const { data: veDelegateBalance, isLoading: veDelegateLoading } =
|
|
6130
|
+
const { data: veDelegateBalance, isLoading: veDelegateLoading } = useGetErc20Balance(config.veDelegateTokenContractAddress, address);
|
|
6117
6131
|
const { data: gloDollarBalance, isLoading: gloDollarLoading } = useGetErc20Balance(config.gloDollarContractAddress, address);
|
|
6118
6132
|
const customTokenBalancesQueries = useGetCustomTokenBalances(address);
|
|
6119
6133
|
const customTokenBalances = customTokenBalancesQueries.map((query) => query.data).filter(Boolean);
|
|
@@ -6186,6 +6200,36 @@ var useTokenBalances = ({ address = "" }) => {
|
|
|
6186
6200
|
isLoading
|
|
6187
6201
|
};
|
|
6188
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
|
|
6189
6233
|
var useTokenPrices = () => {
|
|
6190
6234
|
const { network } = useVeChainKitConfig();
|
|
6191
6235
|
const config = getConfig(network.type);
|
|
@@ -6275,9 +6319,7 @@ var useCurrency = () => {
|
|
|
6275
6319
|
var useTokensWithValues = ({
|
|
6276
6320
|
address = ""
|
|
6277
6321
|
}) => {
|
|
6278
|
-
const { balances, isLoading: balancesLoading } = useTokenBalances(
|
|
6279
|
-
address
|
|
6280
|
-
});
|
|
6322
|
+
const { balances, isLoading: balancesLoading } = useTokenBalances(address);
|
|
6281
6323
|
const {
|
|
6282
6324
|
prices,
|
|
6283
6325
|
exchangeRates,
|
|
@@ -6335,7 +6377,7 @@ var useTotalBalance = ({ address = "" }) => {
|
|
|
6335
6377
|
const formattedBalance = useMemo(() => {
|
|
6336
6378
|
return formatCompactCurrency(
|
|
6337
6379
|
totalBalanceInCurrency,
|
|
6338
|
-
currentCurrency
|
|
6380
|
+
{ currency: currentCurrency }
|
|
6339
6381
|
);
|
|
6340
6382
|
}, [totalBalanceInCurrency, currentCurrency]);
|
|
6341
6383
|
return {
|
|
@@ -6346,6 +6388,60 @@ var useTotalBalance = ({ address = "" }) => {
|
|
|
6346
6388
|
hasAnyBalance: tokensWithBalance.length > 0
|
|
6347
6389
|
};
|
|
6348
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
|
|
6349
6445
|
var useCustomTokens = () => {
|
|
6350
6446
|
const [customTokens, setCustomTokens] = useLocalStorage(
|
|
6351
6447
|
"vechain_kit_custom_tokens" /* CUSTOM_TOKENS */,
|
|
@@ -6392,59 +6488,276 @@ var useCustomTokens = () => {
|
|
|
6392
6488
|
isDefaultToken
|
|
6393
6489
|
};
|
|
6394
6490
|
};
|
|
6395
|
-
var
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
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");
|
|
6407
6546
|
}
|
|
6408
|
-
|
|
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
|
+
};
|
|
6409
6557
|
};
|
|
6410
|
-
var
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
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]
|
|
6427
6617
|
}
|
|
6428
|
-
}
|
|
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)]
|
|
6429
6629
|
});
|
|
6430
|
-
var
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
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
|
+
}
|
|
6436
6648
|
});
|
|
6437
6649
|
};
|
|
6438
|
-
var
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
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
|
+
};
|
|
6708
|
+
var handlePopupError = ({
|
|
6709
|
+
error,
|
|
6710
|
+
mobileBrowserPopupMessage = "Mobile browser blocked the window. Please try again.",
|
|
6711
|
+
rejectedMessage = "Request was cancelled.",
|
|
6712
|
+
defaultMessage = "Operation failed"
|
|
6713
|
+
}) => {
|
|
6714
|
+
const errorMsg = error?.message;
|
|
6715
|
+
if (isMobile && errorMsg && !isRejectionError(errorMsg)) {
|
|
6716
|
+
return new Error(mobileBrowserPopupMessage);
|
|
6717
|
+
}
|
|
6718
|
+
if (errorMsg && isRejectionError(errorMsg)) {
|
|
6719
|
+
return new Error(rejectedMessage);
|
|
6720
|
+
}
|
|
6721
|
+
return error instanceof Error ? error : new Error(defaultMessage);
|
|
6722
|
+
};
|
|
6723
|
+
var vechain = defineChain({
|
|
6724
|
+
id: "1176455790972829965191905223412607679856028701100105089447013101863",
|
|
6725
|
+
name: "Vechain",
|
|
6726
|
+
nativeCurrency: { name: "VeChain", symbol: "VET", decimals: 18 },
|
|
6727
|
+
rpcUrls: {
|
|
6728
|
+
default: {
|
|
6729
|
+
http: ["https://mainnet.vechain.org"]
|
|
6730
|
+
}
|
|
6731
|
+
},
|
|
6732
|
+
blockExplorers: {
|
|
6733
|
+
default: {
|
|
6734
|
+
name: "Vechain Explorer",
|
|
6735
|
+
url: "https://explore.vechain.org"
|
|
6736
|
+
},
|
|
6737
|
+
vechainStats: {
|
|
6738
|
+
name: "Vechain Stats",
|
|
6739
|
+
url: "https://vechainstats.com"
|
|
6740
|
+
}
|
|
6741
|
+
}
|
|
6742
|
+
});
|
|
6743
|
+
var vechainConnector = () => {
|
|
6744
|
+
return toPrivyWalletConnector({
|
|
6745
|
+
id: VECHAIN_PRIVY_APP_ID,
|
|
6746
|
+
name: "VeChain",
|
|
6747
|
+
iconUrl: "https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon",
|
|
6748
|
+
smartWalletMode: false
|
|
6749
|
+
});
|
|
6750
|
+
};
|
|
6751
|
+
var PrivyCrossAppProvider = ({
|
|
6752
|
+
privyEcosystemAppIDS,
|
|
6753
|
+
children
|
|
6754
|
+
}) => {
|
|
6755
|
+
const wagmiConfigRef = useRef(
|
|
6756
|
+
createConfig({
|
|
6757
|
+
chains: [vechain],
|
|
6758
|
+
ssr: true,
|
|
6759
|
+
connectors: [
|
|
6760
|
+
vechainConnector(),
|
|
6448
6761
|
...privyEcosystemAppIDS.map(
|
|
6449
6762
|
(appId) => toPrivyWalletConnector({
|
|
6450
6763
|
id: appId,
|
|
@@ -6724,170 +7037,30 @@ var useRefreshBalances = () => {
|
|
|
6724
7037
|
};
|
|
6725
7038
|
return { refresh };
|
|
6726
7039
|
};
|
|
6727
|
-
var
|
|
6728
|
-
const
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
IERC20__factory.abi
|
|
6732
|
-
);
|
|
6733
|
-
return erc20Contract.clause.balanceOf([address]);
|
|
6734
|
-
});
|
|
6735
|
-
const response = await thor.contracts.executeMultipleClausesCall(clauses);
|
|
6736
|
-
if (!response.every((r) => r.success && !!r.result.plain)) {
|
|
6737
|
-
throw new Error("Failed to get custom token balances");
|
|
6738
|
-
}
|
|
6739
|
-
return response.map((r, index) => {
|
|
6740
|
-
const token = customTokens[index];
|
|
6741
|
-
const original = r.result.plain;
|
|
6742
|
-
const scaled = formatEther$1(BigInt(original)) || "0";
|
|
6743
|
-
return {
|
|
6744
|
-
address: token.address,
|
|
6745
|
-
symbol: token.symbol,
|
|
6746
|
-
balance: scaled
|
|
6747
|
-
};
|
|
6748
|
-
});
|
|
6749
|
-
};
|
|
6750
|
-
var getTokenBalances = async (thor, address, network) => {
|
|
6751
|
-
const config = getConfig(network);
|
|
6752
|
-
const [b3trBalance, vot3Balance, veDelegateBalance, gloDollarBalance] = await executeMultipleClausesCall({
|
|
6753
|
-
thor,
|
|
6754
|
-
calls: [
|
|
6755
|
-
{
|
|
6756
|
-
abi: IB3TR__factory.abi,
|
|
6757
|
-
address: config.b3trContractAddress,
|
|
6758
|
-
functionName: "balanceOf",
|
|
6759
|
-
args: [address]
|
|
6760
|
-
},
|
|
6761
|
-
{
|
|
6762
|
-
abi: IVOT3__factory.abi,
|
|
6763
|
-
address: config.vot3ContractAddress,
|
|
6764
|
-
functionName: "balanceOf",
|
|
6765
|
-
args: [address]
|
|
6766
|
-
},
|
|
6767
|
-
{
|
|
6768
|
-
abi: IERC20__factory.abi,
|
|
6769
|
-
address: config.veDelegate,
|
|
6770
|
-
functionName: "balanceOf",
|
|
6771
|
-
args: [address]
|
|
6772
|
-
},
|
|
6773
|
-
{
|
|
6774
|
-
abi: IERC20__factory.abi,
|
|
6775
|
-
address: config.gloDollarContractAddress,
|
|
6776
|
-
functionName: "balanceOf",
|
|
6777
|
-
args: [address]
|
|
6778
|
-
}
|
|
6779
|
-
]
|
|
6780
|
-
});
|
|
6781
|
-
const { balance: vetBalance, energy: vthoBalance } = await getAccountBalance(thor, address);
|
|
6782
|
-
return [
|
|
6783
|
-
{
|
|
6784
|
-
address: "0x",
|
|
6785
|
-
symbol: "VET",
|
|
6786
|
-
balance: vetBalance
|
|
6787
|
-
},
|
|
6788
|
-
{
|
|
6789
|
-
address: config.vthoContractAddress,
|
|
6790
|
-
symbol: "VTHO",
|
|
6791
|
-
balance: vthoBalance
|
|
6792
|
-
},
|
|
6793
|
-
{
|
|
6794
|
-
address: config.b3trContractAddress,
|
|
6795
|
-
symbol: "B3TR",
|
|
6796
|
-
balance: b3trBalance
|
|
6797
|
-
},
|
|
6798
|
-
{
|
|
6799
|
-
address: config.vot3ContractAddress,
|
|
6800
|
-
symbol: "VOT3",
|
|
6801
|
-
balance: vot3Balance
|
|
6802
|
-
},
|
|
6803
|
-
{
|
|
6804
|
-
address: config.veDelegate,
|
|
6805
|
-
symbol: "veDelegate",
|
|
6806
|
-
balance: veDelegateBalance
|
|
6807
|
-
},
|
|
6808
|
-
{
|
|
6809
|
-
address: config.gloDollarContractAddress,
|
|
6810
|
-
symbol: "USDGLO",
|
|
6811
|
-
balance: gloDollarBalance
|
|
6812
|
-
}
|
|
6813
|
-
];
|
|
6814
|
-
};
|
|
6815
|
-
var useTokenBalances2 = ({ address }) => {
|
|
6816
|
-
const thor = useThor();
|
|
6817
|
-
const { network } = useVeChainKitConfig();
|
|
6818
|
-
const { customTokens } = useCustomTokens();
|
|
6819
|
-
return useQueries({
|
|
6820
|
-
queries: [
|
|
6821
|
-
{
|
|
6822
|
-
queryKey: ["base-token-balances", address],
|
|
6823
|
-
queryFn: () => getTokenBalances(thor, address, network.type)
|
|
6824
|
-
},
|
|
6825
|
-
{
|
|
6826
|
-
queryKey: ["custom-token-balances", address],
|
|
6827
|
-
queryFn: () => getCustomTokenBalances(thor, address, customTokens)
|
|
6828
|
-
}
|
|
6829
|
-
],
|
|
6830
|
-
combine: (data) => {
|
|
6831
|
-
return {
|
|
6832
|
-
data: data.flat(),
|
|
6833
|
-
loading: data[0].isLoading || data[1].isLoading,
|
|
6834
|
-
error: data[0].error || data[1].error
|
|
6835
|
-
};
|
|
6836
|
-
}
|
|
6837
|
-
});
|
|
6838
|
-
};
|
|
6839
|
-
var getTokenPrices = async (thor, tokens2, network) => {
|
|
6840
|
-
const config = getConfig(network);
|
|
6841
|
-
const oracleContract = thor.contracts.load(
|
|
6842
|
-
config.oracleContractAddress,
|
|
6843
|
-
IVechainEnergyOracleV1__factory.abi
|
|
6844
|
-
);
|
|
6845
|
-
const clauses = tokens2.map(
|
|
6846
|
-
(token) => oracleContract.clause.getLatestValue(PRICE_FEED_IDS[token])
|
|
6847
|
-
);
|
|
6848
|
-
const response = await thor.transactions.executeMultipleClausesCall(
|
|
6849
|
-
clauses
|
|
6850
|
-
);
|
|
6851
|
-
if (!response.every((r) => r.success && !!r.result.array)) {
|
|
6852
|
-
throw new Error("Failed to get token prices");
|
|
6853
|
-
}
|
|
6854
|
-
return response.map(
|
|
6855
|
-
(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 }
|
|
6856
7044
|
);
|
|
7045
|
+
return metadata.data;
|
|
6857
7046
|
};
|
|
6858
|
-
var
|
|
6859
|
-
var
|
|
7047
|
+
var abi5 = X2EarnApps__factory.abi;
|
|
7048
|
+
var useXAppMetadata = (xAppId) => {
|
|
6860
7049
|
const thor = useThor();
|
|
6861
7050
|
const { network } = useVeChainKitConfig();
|
|
6862
|
-
const config = getConfig(network.type);
|
|
6863
7051
|
return useQuery({
|
|
6864
|
-
queryKey: ["
|
|
6865
|
-
queryFn: () =>
|
|
6866
|
-
|
|
6867
|
-
const
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
[config.vthoContractAddress]: vthoUsdPrice || 0,
|
|
6877
|
-
[config.b3trContractAddress]: b3trUsdPrice || 0,
|
|
6878
|
-
[config.vot3ContractAddress]: b3trUsdPrice || 0,
|
|
6879
|
-
[config.veDelegate]: b3trUsdPrice || 0,
|
|
6880
|
-
[config.gloDollarContractAddress]: 1
|
|
6881
|
-
// GloDollar is pegged to USD
|
|
6882
|
-
};
|
|
6883
|
-
const exchangeRates = {
|
|
6884
|
-
eurUsdPrice: eurUsdPrice || 1,
|
|
6885
|
-
gbpUsdPrice: gbpUsdPrice || 1
|
|
6886
|
-
};
|
|
6887
|
-
return {
|
|
6888
|
-
prices,
|
|
6889
|
-
exchangeRates
|
|
6890
|
-
};
|
|
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;
|
|
6891
7064
|
}
|
|
6892
7065
|
});
|
|
6893
7066
|
};
|
|
@@ -7606,8 +7779,8 @@ var ConnectionOptionsStack = () => {
|
|
|
7606
7779
|
showMoreLogin,
|
|
7607
7780
|
isOfficialVeChainApp
|
|
7608
7781
|
} = useLoginModalContent();
|
|
7609
|
-
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:
|
|
7610
|
-
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) {
|
|
7611
7784
|
case "email":
|
|
7612
7785
|
return showEmailLogin && /* @__PURE__ */ jsx(EmailLoginButton, {}, "email");
|
|
7613
7786
|
case "google":
|
|
@@ -7714,7 +7887,7 @@ var MainContent = ({ setCurrentContent, onClose }) => {
|
|
|
7714
7887
|
}
|
|
7715
7888
|
}, [connection.isConnected, onClose]);
|
|
7716
7889
|
const showEcosystemButton = loginMethods?.some(
|
|
7717
|
-
({ method:
|
|
7890
|
+
({ method: method7 }) => method7 === "ecosystem"
|
|
7718
7891
|
);
|
|
7719
7892
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7720
7893
|
/* @__PURE__ */ jsxs(StickyHeaderContainer, { children: [
|
|
@@ -9525,6 +9698,7 @@ var SendTokenContent = ({
|
|
|
9525
9698
|
const { t } = useTranslation();
|
|
9526
9699
|
const { darkMode: isDark } = useVeChainKitConfig();
|
|
9527
9700
|
const { currentCurrency } = useCurrency();
|
|
9701
|
+
const { exchangeRates } = useTokenPrices();
|
|
9528
9702
|
const [selectedToken, setSelectedToken] = useState(
|
|
9529
9703
|
preselectedToken ?? null
|
|
9530
9704
|
);
|
|
@@ -9547,6 +9721,19 @@ var SendTokenContent = ({
|
|
|
9547
9721
|
mode: "onChange"
|
|
9548
9722
|
});
|
|
9549
9723
|
const { toAddressOrDomain, amount } = watch();
|
|
9724
|
+
const formattedValue = useMemo(() => {
|
|
9725
|
+
if (selectedToken) {
|
|
9726
|
+
return formatCompactCurrency(
|
|
9727
|
+
convertToSelectedCurrency(
|
|
9728
|
+
Number(amount) * selectedToken.priceUsd,
|
|
9729
|
+
currentCurrency,
|
|
9730
|
+
exchangeRates
|
|
9731
|
+
),
|
|
9732
|
+
{ currency: currentCurrency }
|
|
9733
|
+
);
|
|
9734
|
+
}
|
|
9735
|
+
return "";
|
|
9736
|
+
}, [amount, selectedToken, currentCurrency, exchangeRates]);
|
|
9550
9737
|
useEffect(() => {
|
|
9551
9738
|
if (selectedToken && amount) {
|
|
9552
9739
|
Analytics.send.flow("amount", {
|
|
@@ -9641,6 +9828,7 @@ var SendTokenContent = ({
|
|
|
9641
9828
|
resolvedAddress: resolvedDomainData?.address,
|
|
9642
9829
|
amount: data.amount,
|
|
9643
9830
|
selectedToken,
|
|
9831
|
+
formattedTotalAmount: formattedValue,
|
|
9644
9832
|
setCurrentContent
|
|
9645
9833
|
}
|
|
9646
9834
|
});
|
|
@@ -9809,10 +9997,7 @@ var SendTokenContent = ({
|
|
|
9809
9997
|
/* @__PURE__ */ jsxs(Text, { opacity: 0.5, children: [
|
|
9810
9998
|
"\u2248",
|
|
9811
9999
|
" ",
|
|
9812
|
-
|
|
9813
|
-
Number(amount) * selectedToken.priceUsd,
|
|
9814
|
-
currentCurrency
|
|
9815
|
-
)
|
|
10000
|
+
formattedValue
|
|
9816
10001
|
] }),
|
|
9817
10002
|
/* @__PURE__ */ jsx(
|
|
9818
10003
|
Text,
|
|
@@ -9931,18 +10116,14 @@ var SendTokenContent = ({
|
|
|
9931
10116
|
) })
|
|
9932
10117
|
] });
|
|
9933
10118
|
};
|
|
9934
|
-
var summaryFormatter = new Intl.NumberFormat("de-DE", {
|
|
9935
|
-
notation: "standard",
|
|
9936
|
-
minimumFractionDigits: 2,
|
|
9937
|
-
maximumFractionDigits: 2
|
|
9938
|
-
});
|
|
9939
10119
|
var SendTokenSummaryContent = ({
|
|
9940
10120
|
setCurrentContent,
|
|
9941
10121
|
toAddressOrDomain,
|
|
9942
10122
|
resolvedDomain,
|
|
9943
10123
|
resolvedAddress,
|
|
9944
10124
|
amount,
|
|
9945
|
-
selectedToken
|
|
10125
|
+
selectedToken,
|
|
10126
|
+
formattedTotalAmount
|
|
9946
10127
|
}) => {
|
|
9947
10128
|
const { t } = useTranslation();
|
|
9948
10129
|
const { account, connection, connectedWallet } = useWallet();
|
|
@@ -9954,7 +10135,6 @@ var SendTokenSummaryContent = ({
|
|
|
9954
10135
|
3
|
|
9955
10136
|
);
|
|
9956
10137
|
const { open: openUpgradeSmartAccountModal } = useUpgradeSmartAccountModal();
|
|
9957
|
-
const { currentCurrency } = useCurrency();
|
|
9958
10138
|
const toImageSrc = useMemo(() => {
|
|
9959
10139
|
if (avatar) {
|
|
9960
10140
|
return avatar;
|
|
@@ -10173,7 +10353,10 @@ var SendTokenSummaryContent = ({
|
|
|
10173
10353
|
textAlign: "left",
|
|
10174
10354
|
"data-testid": "send-summary-amount",
|
|
10175
10355
|
children: [
|
|
10176
|
-
|
|
10356
|
+
Number(amount).toLocaleString(void 0, {
|
|
10357
|
+
minimumFractionDigits: 2,
|
|
10358
|
+
maximumFractionDigits: 2
|
|
10359
|
+
}),
|
|
10177
10360
|
" ",
|
|
10178
10361
|
selectedToken.symbol
|
|
10179
10362
|
]
|
|
@@ -10182,10 +10365,7 @@ var SendTokenSummaryContent = ({
|
|
|
10182
10365
|
/* @__PURE__ */ jsxs(Text, { opacity: 0.5, children: [
|
|
10183
10366
|
"\u2248",
|
|
10184
10367
|
" ",
|
|
10185
|
-
|
|
10186
|
-
Number(amount) * selectedToken.priceUsd,
|
|
10187
|
-
currentCurrency
|
|
10188
|
-
)
|
|
10368
|
+
formattedTotalAmount
|
|
10189
10369
|
] })
|
|
10190
10370
|
] })
|
|
10191
10371
|
]
|
|
@@ -12995,13 +13175,13 @@ var PrivyLinkedAccounts = ({ onBack }) => {
|
|
|
12995
13175
|
} = usePrivy();
|
|
12996
13176
|
const canLinkWallets = useMemo(() => {
|
|
12997
13177
|
const privyWallets = privy?.loginMethods?.filter(
|
|
12998
|
-
(
|
|
13178
|
+
(method7) => [
|
|
12999
13179
|
"rabby_wallet",
|
|
13000
13180
|
"coinbase_wallet",
|
|
13001
13181
|
"rainbow",
|
|
13002
13182
|
"phantom",
|
|
13003
13183
|
"metamask"
|
|
13004
|
-
].includes(
|
|
13184
|
+
].includes(method7)
|
|
13005
13185
|
) ?? [];
|
|
13006
13186
|
const dappKitWallets = dappKit?.allowedWallets ?? [];
|
|
13007
13187
|
return privyWallets.length > 0 || dappKitWallets.length > 0;
|
|
@@ -14068,7 +14248,8 @@ var DEFAULT_APPS = [
|
|
|
14068
14248
|
tweets: [],
|
|
14069
14249
|
ve_world: {
|
|
14070
14250
|
banner: "https://i.ibb.co/cgJBj83/vbd.png"
|
|
14071
|
-
}
|
|
14251
|
+
},
|
|
14252
|
+
categories: []
|
|
14072
14253
|
},
|
|
14073
14254
|
{
|
|
14074
14255
|
name: "vet.domains",
|
|
@@ -14082,7 +14263,8 @@ var DEFAULT_APPS = [
|
|
|
14082
14263
|
tweets: [],
|
|
14083
14264
|
ve_world: {
|
|
14084
14265
|
banner: "https://vet.domains/assets/walletconnect.png"
|
|
14085
|
-
}
|
|
14266
|
+
},
|
|
14267
|
+
categories: []
|
|
14086
14268
|
}
|
|
14087
14269
|
// {
|
|
14088
14270
|
// name: 'VeChain Kit',
|
|
@@ -14143,17 +14325,7 @@ var ExploreEcosystemContent = ({
|
|
|
14143
14325
|
) : [];
|
|
14144
14326
|
const filteredDefaultApps = DEFAULT_APPS.filter(
|
|
14145
14327
|
(dapp) => dapp.name.toLowerCase().includes(searchQuery.toLowerCase())
|
|
14146
|
-
)
|
|
14147
|
-
if (dapp.logoComponent) {
|
|
14148
|
-
return {
|
|
14149
|
-
...dapp,
|
|
14150
|
-
logoComponent: React10.cloneElement(dapp.logoComponent, {
|
|
14151
|
-
isDark
|
|
14152
|
-
})
|
|
14153
|
-
};
|
|
14154
|
-
}
|
|
14155
|
-
return dapp;
|
|
14156
|
-
});
|
|
14328
|
+
);
|
|
14157
14329
|
const filteredAppHubApps = appHubApps?.filter(
|
|
14158
14330
|
(app) => (
|
|
14159
14331
|
// Text search filter
|
|
@@ -14240,10 +14412,7 @@ var ExploreEcosystemContent = ({
|
|
|
14240
14412
|
url: dapp.external_url,
|
|
14241
14413
|
setCurrentContent,
|
|
14242
14414
|
description: dapp.description,
|
|
14243
|
-
selectedCategory: currentCategory
|
|
14244
|
-
...dapp.logoComponent && {
|
|
14245
|
-
logoComponent: dapp.logoComponent
|
|
14246
|
-
}
|
|
14415
|
+
selectedCategory: currentCategory
|
|
14247
14416
|
}
|
|
14248
14417
|
) }, dapp.name)) }),
|
|
14249
14418
|
shouldShowVbdApps && filteredVbdApps.length > 0 && /* @__PURE__ */ jsx(Fragment, { children: filteredVbdApps.map((dapp) => /* @__PURE__ */ jsx(GridItem, { children: /* @__PURE__ */ jsx(
|
|
@@ -14992,7 +15161,7 @@ var ConnectPopover = ({
|
|
|
14992
15161
|
privyEcosystemAppIDS
|
|
14993
15162
|
} = useVeChainKitConfig();
|
|
14994
15163
|
const showEcosystemButton = loginMethods?.some(
|
|
14995
|
-
({ method:
|
|
15164
|
+
({ method: method7 }) => method7 === "ecosystem"
|
|
14996
15165
|
);
|
|
14997
15166
|
const { data: appsInfo, isLoading: isEcosystemAppsLoading } = useFetchAppInfo(privyEcosystemAppIDS);
|
|
14998
15167
|
return /* @__PURE__ */ jsx(
|
|
@@ -16535,14 +16704,14 @@ var ReceiveModalProvider = ({ children }) => /* @__PURE__ */ jsx(Fragment, { chi
|
|
|
16535
16704
|
var useLoginModalContent = () => {
|
|
16536
16705
|
const { privy, loginMethods } = useVeChainKitConfig();
|
|
16537
16706
|
const isVeChainApp = privy?.appId === VECHAIN_PRIVY_APP_ID;
|
|
16538
|
-
const isLoginMethodEnabled = (
|
|
16707
|
+
const isLoginMethodEnabled = (method7) => {
|
|
16539
16708
|
if (!loginMethods) return true;
|
|
16540
|
-
if (Array.isArray(
|
|
16541
|
-
return
|
|
16709
|
+
if (Array.isArray(method7)) {
|
|
16710
|
+
return method7.some(
|
|
16542
16711
|
(m) => loginMethods.some((lm) => lm.method === m)
|
|
16543
16712
|
);
|
|
16544
16713
|
}
|
|
16545
|
-
return loginMethods.some((lm) => lm.method ===
|
|
16714
|
+
return loginMethods.some((lm) => lm.method === method7);
|
|
16546
16715
|
};
|
|
16547
16716
|
const showEcosystemLogin = useMemo(() => {
|
|
16548
16717
|
if (!loginMethods) return true;
|
|
@@ -16963,34 +17132,43 @@ var useAppHubApps = () => {
|
|
|
16963
17132
|
});
|
|
16964
17133
|
};
|
|
16965
17134
|
var getCallClauseQueryKey = ({
|
|
17135
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17136
|
+
abi: abi9,
|
|
17137
|
+
address,
|
|
17138
|
+
method: method7
|
|
17139
|
+
}) => ["callClause", address, method7];
|
|
17140
|
+
var getCallClauseQueryKeyWithArgs = ({
|
|
17141
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17142
|
+
abi: abi9,
|
|
16966
17143
|
address,
|
|
16967
|
-
method:
|
|
17144
|
+
method: method7,
|
|
16968
17145
|
args
|
|
16969
17146
|
}) => [
|
|
16970
17147
|
"callClause",
|
|
16971
17148
|
address,
|
|
16972
|
-
|
|
16973
|
-
...args ? [args] : []
|
|
17149
|
+
method7,
|
|
17150
|
+
...args?.length ? [args] : []
|
|
16974
17151
|
];
|
|
16975
17152
|
var useCallClause = ({
|
|
16976
17153
|
address,
|
|
16977
17154
|
abi: abi9,
|
|
16978
|
-
method:
|
|
17155
|
+
method: method7,
|
|
16979
17156
|
args,
|
|
16980
17157
|
queryOptions
|
|
16981
17158
|
}) => {
|
|
16982
17159
|
const thor = useThor();
|
|
16983
17160
|
return useQuery({
|
|
16984
|
-
queryKey:
|
|
17161
|
+
queryKey: getCallClauseQueryKeyWithArgs({
|
|
17162
|
+
abi: abi9,
|
|
16985
17163
|
address,
|
|
16986
|
-
method:
|
|
17164
|
+
method: method7,
|
|
16987
17165
|
args
|
|
16988
17166
|
}),
|
|
16989
17167
|
queryFn: async () => executeCallClause({
|
|
16990
17168
|
thor,
|
|
16991
17169
|
contractAddress: address,
|
|
16992
17170
|
abi: abi9,
|
|
16993
|
-
method:
|
|
17171
|
+
method: method7,
|
|
16994
17172
|
args
|
|
16995
17173
|
}),
|
|
16996
17174
|
...queryOptions
|
|
@@ -17112,8 +17290,8 @@ var getAccountBalance = async (thor, address) => {
|
|
|
17112
17290
|
if (!address) throw new Error("Address is required");
|
|
17113
17291
|
const account = await thor.accounts.getAccount(Address.of(address));
|
|
17114
17292
|
return {
|
|
17115
|
-
balance: formatEther(BigInt(account.balance)).toString(),
|
|
17116
|
-
energy: formatEther(BigInt(account.energy)).toString()
|
|
17293
|
+
balance: formatEther$1(BigInt(account.balance)).toString(),
|
|
17294
|
+
energy: formatEther$1(BigInt(account.energy)).toString()
|
|
17117
17295
|
};
|
|
17118
17296
|
};
|
|
17119
17297
|
var getAccountBalanceQueryKey = (address) => [
|
|
@@ -17228,8 +17406,9 @@ var useGetAccountAddress = (ownerAddress) => {
|
|
|
17228
17406
|
};
|
|
17229
17407
|
|
|
17230
17408
|
// src/hooks/thor/smartAccounts/useGetAccountVersion.ts
|
|
17231
|
-
var
|
|
17232
|
-
var getAccountVersionQueryKey = (accountAddress, ownerAddress, networkType) =>
|
|
17409
|
+
var abi6 = SimpleAccountFactory__factory.abi;
|
|
17410
|
+
var getAccountVersionQueryKey = (accountAddress, ownerAddress, networkType) => getCallClauseQueryKeyWithArgs({
|
|
17411
|
+
abi: abi6,
|
|
17233
17412
|
address: getConfig(networkType).accountFactoryAddress,
|
|
17234
17413
|
method: "getAccountVersion",
|
|
17235
17414
|
args: [accountAddress, ownerAddress]
|
|
@@ -17238,7 +17417,7 @@ var useGetAccountVersion = (accountAddress, ownerAddress) => {
|
|
|
17238
17417
|
const { network } = useVeChainKitConfig();
|
|
17239
17418
|
return useCallClause({
|
|
17240
17419
|
address: getConfig(network.type).accountFactoryAddress,
|
|
17241
|
-
abi,
|
|
17420
|
+
abi: abi6,
|
|
17242
17421
|
method: "getAccountVersion",
|
|
17243
17422
|
args: [accountAddress, ownerAddress],
|
|
17244
17423
|
queryOptions: {
|
|
@@ -17251,16 +17430,16 @@ var useGetAccountVersion = (accountAddress, ownerAddress) => {
|
|
|
17251
17430
|
}
|
|
17252
17431
|
});
|
|
17253
17432
|
};
|
|
17254
|
-
var
|
|
17255
|
-
var
|
|
17433
|
+
var abi7 = SimpleAccountFactory__factory.abi;
|
|
17434
|
+
var method5 = "hasLegacyAccount";
|
|
17256
17435
|
var getHasV1SmartAccount = async (thor, ownerAddress, networkType) => {
|
|
17257
17436
|
if (!ownerAddress) throw new Error("Owner address is required");
|
|
17258
17437
|
if (!networkType) throw new Error("Network type is required");
|
|
17259
17438
|
const [hasLegacyAccount] = await executeCallClause({
|
|
17260
17439
|
thor,
|
|
17261
|
-
abi:
|
|
17440
|
+
abi: abi7,
|
|
17262
17441
|
contractAddress: getConfig(networkType).accountFactoryAddress,
|
|
17263
|
-
method,
|
|
17442
|
+
method: method5,
|
|
17264
17443
|
args: [ownerAddress]
|
|
17265
17444
|
});
|
|
17266
17445
|
return hasLegacyAccount;
|
|
@@ -17471,15 +17650,15 @@ var useSmartAccount = (ownerAddress) => {
|
|
|
17471
17650
|
enabled: !!ownerAddress && !!network.type && !!thor
|
|
17472
17651
|
});
|
|
17473
17652
|
};
|
|
17474
|
-
var
|
|
17475
|
-
var
|
|
17653
|
+
var abi8 = SimpleAccountFactory__factory.abi;
|
|
17654
|
+
var method6 = "version";
|
|
17476
17655
|
var getVersion = async (thor, contractAddress) => {
|
|
17477
17656
|
if (!contractAddress) throw new Error("Contract address is required");
|
|
17478
17657
|
const [version] = await executeCallClause({
|
|
17479
17658
|
thor,
|
|
17480
17659
|
contractAddress,
|
|
17481
|
-
abi:
|
|
17482
|
-
method:
|
|
17660
|
+
abi: abi8,
|
|
17661
|
+
method: method6,
|
|
17483
17662
|
args: []
|
|
17484
17663
|
});
|
|
17485
17664
|
return Number(version);
|
|
@@ -17667,1113 +17846,33 @@ var useGetChainId = () => {
|
|
|
17667
17846
|
refetchInterval: 1e4
|
|
17668
17847
|
});
|
|
17669
17848
|
};
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
17676
|
-
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
}
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
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
|
|
17694
17873
|
});
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
const res = await thor.contracts.load(token.address, ERC20__factory.abi).read.balanceOf([address]);
|
|
17698
|
-
if (!res) throw new Error(`Failed to get balance of ${token.address}`);
|
|
17699
|
-
const original = res[0];
|
|
17700
|
-
const scaled = formatEther(BigInt(original));
|
|
17701
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17702
|
-
return {
|
|
17703
|
-
...token,
|
|
17704
|
-
original: original.toString(),
|
|
17705
|
-
scaled,
|
|
17706
|
-
formatted
|
|
17707
|
-
};
|
|
17708
|
-
};
|
|
17709
|
-
var getCustomTokenBalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT_BALANCE", address, "CUSTOM_TOKEN", tokenAddress];
|
|
17710
|
-
var useGetCustomTokenBalances = (address) => {
|
|
17711
|
-
const thor = useThor();
|
|
17712
|
-
const { customTokens } = useCustomTokens();
|
|
17713
|
-
return useQueries({
|
|
17714
|
-
queries: customTokens.map((token) => ({
|
|
17715
|
-
queryKey: getCustomTokenBalanceQueryKey(token.address, address),
|
|
17716
|
-
queryFn: async () => {
|
|
17717
|
-
return await getCustomTokenBalance(thor, token, address);
|
|
17718
|
-
}
|
|
17719
|
-
}))
|
|
17720
|
-
});
|
|
17721
|
-
};
|
|
17722
|
-
var getTokenInfo = async (thor, tokenAddress) => {
|
|
17723
|
-
if (!tokenAddress) throw new Error("Token address is required");
|
|
17724
|
-
const contract = thor.contracts.load(tokenAddress, ERC20__factory.abi);
|
|
17725
|
-
const response = await thor.contracts.executeMultipleClausesCall([
|
|
17726
|
-
contract.clause.name(),
|
|
17727
|
-
contract.clause.symbol(),
|
|
17728
|
-
contract.clause.decimals()
|
|
17729
|
-
]);
|
|
17730
|
-
if (response.every((r) => r.success) === false) {
|
|
17731
|
-
throw new Error(`Failed to get token info of ${tokenAddress}`);
|
|
17732
|
-
}
|
|
17733
|
-
const [name, symbol, decimals] = response.map((res) => {
|
|
17734
|
-
return res.result.array?.[0];
|
|
17735
|
-
});
|
|
17736
|
-
return {
|
|
17737
|
-
name,
|
|
17738
|
-
address: tokenAddress,
|
|
17739
|
-
decimals,
|
|
17740
|
-
symbol
|
|
17741
|
-
};
|
|
17742
|
-
};
|
|
17743
|
-
var getCustomTokenInfo = (tokenAddress) => [
|
|
17744
|
-
"VECHAIN_KIT_CUSTOM_TOKEN_BALANCE",
|
|
17745
|
-
tokenAddress
|
|
17746
|
-
];
|
|
17747
|
-
var useGetCustomTokenInfo = (tokenAddress) => {
|
|
17748
|
-
const thor = useThor();
|
|
17749
|
-
const { network } = useVeChainKitConfig();
|
|
17750
|
-
return useQuery({
|
|
17751
|
-
queryKey: getCustomTokenInfo(tokenAddress),
|
|
17752
|
-
queryFn: async () => getTokenInfo(thor, tokenAddress),
|
|
17753
|
-
enabled: !!thor && !!network.type && !!tokenAddress
|
|
17754
|
-
});
|
|
17755
|
-
};
|
|
17756
|
-
var getErc20Balance = async (thor, tokenAddress, address) => {
|
|
17757
|
-
if (!tokenAddress || !address) {
|
|
17758
|
-
throw new Error("Token address and user address are required");
|
|
17759
|
-
}
|
|
17760
|
-
const res = await thor.contracts.load(tokenAddress, IERC20__factory.abi).read.balanceOf(address);
|
|
17761
|
-
if (!res) throw new Error(`Failed to get balance of ${tokenAddress}`);
|
|
17762
|
-
const original = res[0].toString();
|
|
17763
|
-
const scaled = formatEther$1(original);
|
|
17764
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17765
|
-
return {
|
|
17766
|
-
original,
|
|
17767
|
-
scaled,
|
|
17768
|
-
formatted
|
|
17769
|
-
};
|
|
17770
|
-
};
|
|
17771
|
-
var getErc20BalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT", "BALANCE", "ERC20", tokenAddress, address];
|
|
17772
|
-
var useGetErc20Balance = (tokenAddress, address) => {
|
|
17773
|
-
const thor = useThor();
|
|
17774
|
-
return useQuery({
|
|
17775
|
-
queryKey: getErc20BalanceQueryKey(tokenAddress, address),
|
|
17776
|
-
queryFn: async () => getErc20Balance(thor, tokenAddress, address),
|
|
17777
|
-
enabled: !!thor && !!address && !!tokenAddress
|
|
17778
|
-
});
|
|
17779
|
-
};
|
|
17780
|
-
var getVeDelegateBalance = async (thor, network, address) => {
|
|
17781
|
-
const res = await thor.contracts.load(
|
|
17782
|
-
getConfig(network).veDelegateTokenContractAddress,
|
|
17783
|
-
IERC20__factory.abi
|
|
17784
|
-
).read.balanceOf(address);
|
|
17785
|
-
if (!res)
|
|
17786
|
-
throw new Error(`Failed to get veDelegate balance for ${address}`);
|
|
17787
|
-
const original = res[0].toString();
|
|
17788
|
-
const scaled = formatEther$1(original);
|
|
17789
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17790
|
-
return {
|
|
17791
|
-
original,
|
|
17792
|
-
scaled,
|
|
17793
|
-
formatted
|
|
17794
|
-
};
|
|
17795
|
-
};
|
|
17796
|
-
var getVeDelegateBalanceQueryKey = (address) => [
|
|
17797
|
-
"VECHAIN_KIT_BALANCE",
|
|
17798
|
-
address,
|
|
17799
|
-
"VE_DELEGATE"
|
|
17800
|
-
];
|
|
17801
|
-
var useGetVeDelegateBalance = (address) => {
|
|
17802
|
-
const thor = useThor();
|
|
17803
|
-
const { network } = useVeChainKitConfig();
|
|
17804
|
-
return useQuery({
|
|
17805
|
-
queryKey: getVeDelegateBalanceQueryKey(address),
|
|
17806
|
-
queryFn: async () => getVeDelegateBalance(thor, network.type, address),
|
|
17807
|
-
enabled: !!thor && !!address && !!network.type
|
|
17808
|
-
});
|
|
17809
|
-
};
|
|
17810
|
-
var getTokensInfoByOwnerQueryKey = (owner) => [
|
|
17811
|
-
"VECHAIN_KIT_GALAXY_MEMBER_TOKENS_INFO",
|
|
17812
|
-
owner
|
|
17813
|
-
];
|
|
17814
|
-
var useGalaxyMemberTokensInfo = (owner, size = 10) => {
|
|
17815
|
-
const { network } = useVeChainKitConfig();
|
|
17816
|
-
const contractAddress = getConfig(network.type).galaxyMemberContractAddress;
|
|
17817
|
-
const thor = useThor();
|
|
17818
|
-
const fetchTokens = async ({ pageParam = 0 }) => {
|
|
17819
|
-
const data = await thor.contracts.load(contractAddress, GalaxyMember__factory.abi).read.getTokensInfoByOwner(owner, pageParam, size);
|
|
17820
|
-
if (!data)
|
|
17821
|
-
throw new Error(
|
|
17822
|
-
`Failed to fetch tokens info for page ${pageParam}`
|
|
17823
|
-
);
|
|
17824
|
-
return { data, nextPage: pageParam + 1 };
|
|
17825
|
-
};
|
|
17826
|
-
return useInfiniteQuery({
|
|
17827
|
-
queryKey: getTokensInfoByOwnerQueryKey(owner),
|
|
17828
|
-
queryFn: fetchTokens,
|
|
17829
|
-
getNextPageParam: (lastPage) => lastPage.data.length === size ? lastPage.nextPage : void 0,
|
|
17830
|
-
enabled: !!owner && !!network.type,
|
|
17831
|
-
initialPageParam: 0
|
|
17832
|
-
});
|
|
17833
|
-
};
|
|
17834
|
-
|
|
17835
|
-
// src/hooks/thor/contracts/NodeManagement/useGetUserNodes.ts
|
|
17836
|
-
var contractAbi = NodeManagement__factory.abi;
|
|
17837
|
-
var method3 = "getUserNodes";
|
|
17838
|
-
var getUserNodesQueryKey = (networkType, user) => getCallClauseQueryKey({
|
|
17839
|
-
address: getConfig(networkType).nodeManagementContractAddress,
|
|
17840
|
-
method: method3,
|
|
17841
|
-
args: [user]
|
|
17842
|
-
});
|
|
17843
|
-
var useGetUserNodes = (userInput) => {
|
|
17844
|
-
const { network } = useVeChainKitConfig();
|
|
17845
|
-
const contractAddress = getConfig(
|
|
17846
|
-
network.type
|
|
17847
|
-
).nodeManagementContractAddress;
|
|
17848
|
-
return useCallClause({
|
|
17849
|
-
address: contractAddress,
|
|
17850
|
-
abi: contractAbi,
|
|
17851
|
-
method: method3,
|
|
17852
|
-
args: [userInput],
|
|
17853
|
-
queryOptions: {
|
|
17854
|
-
enabled: !!userInput && !!network.type && !!contractAddress,
|
|
17855
|
-
select: (response) => {
|
|
17856
|
-
return response[0].map((node) => ({
|
|
17857
|
-
nodeId: node.nodeId.toString(),
|
|
17858
|
-
nodeLevel: Number(node.nodeLevel),
|
|
17859
|
-
xNodeOwner: node.xNodeOwner,
|
|
17860
|
-
isXNodeHolder: node.isXNodeHolder,
|
|
17861
|
-
isXNodeDelegated: node.isXNodeDelegated,
|
|
17862
|
-
isXNodeDelegator: node.isXNodeDelegator,
|
|
17863
|
-
isXNodeDelegatee: node.isXNodeDelegatee,
|
|
17864
|
-
delegatee: node.delegatee
|
|
17865
|
-
}));
|
|
17866
|
-
}
|
|
17867
|
-
}
|
|
17868
|
-
});
|
|
17869
|
-
};
|
|
17870
|
-
var useGetUserNode = useGetUserNodes;
|
|
17871
|
-
var PRICE_FEED_IDS = {
|
|
17872
|
-
B3TR: "0x623374722d757364000000000000000000000000000000000000000000000000",
|
|
17873
|
-
VET: "0x7665742d75736400000000000000000000000000000000000000000000000000",
|
|
17874
|
-
VTHO: "0x7674686f2d757364000000000000000000000000000000000000000000000000",
|
|
17875
|
-
GBP: "0x6762702d75736400000000000000000000000000000000000000000000000000",
|
|
17876
|
-
EUR: "0x657572742d757364000000000000000000000000000000000000000000000000"
|
|
17877
|
-
};
|
|
17878
|
-
var getTokenUsdPrice = async (thor, token, network) => {
|
|
17879
|
-
const res = await thor.contracts.load(
|
|
17880
|
-
getConfig(network).oracleContractAddress,
|
|
17881
|
-
IVechainEnergyOracleV1__factory.abi
|
|
17882
|
-
).read.getLatestValue(PRICE_FEED_IDS[token]);
|
|
17883
|
-
if (!res) throw new Error(`Failed to get price of ${token}`);
|
|
17884
|
-
return new BigNumber(res[0].toString()).div(1e12).toNumber();
|
|
17885
|
-
};
|
|
17886
|
-
var getTokenUsdPriceQueryKey = (token) => [
|
|
17887
|
-
"VECHAIN_KIT_PRICE",
|
|
17888
|
-
token
|
|
17889
|
-
];
|
|
17890
|
-
var useGetTokenUsdPrice = (token) => {
|
|
17891
|
-
const thor = useThor();
|
|
17892
|
-
const { network } = useVeChainKitConfig();
|
|
17893
|
-
return useQuery({
|
|
17894
|
-
queryKey: getTokenUsdPriceQueryKey(token),
|
|
17895
|
-
queryFn: async () => getTokenUsdPrice(thor, token, network.type),
|
|
17896
|
-
enabled: !!thor && !!network.type
|
|
17897
|
-
});
|
|
17898
|
-
};
|
|
17899
|
-
var getVot3Balance = async (thor, network, address) => {
|
|
17900
|
-
const res = await thor.contracts.load(getConfig(network).vot3ContractAddress, IVOT3__factory.abi).read.balanceOf(address);
|
|
17901
|
-
if (!res) throw new Error("Reverted");
|
|
17902
|
-
const original = res[0].toString();
|
|
17903
|
-
const scaled = formatEther$1(original);
|
|
17904
|
-
const formatted = scaled === "0" ? "0" : humanNumber(scaled);
|
|
17905
|
-
return {
|
|
17906
|
-
original,
|
|
17907
|
-
scaled,
|
|
17908
|
-
formatted
|
|
17909
|
-
};
|
|
17910
|
-
};
|
|
17911
|
-
var getVot3BalanceQueryKey = (address) => [
|
|
17912
|
-
"VEBETTERDAO_BALANCE",
|
|
17913
|
-
address,
|
|
17914
|
-
"VOT3"
|
|
17915
|
-
];
|
|
17916
|
-
var useGetVot3Balance = (address) => {
|
|
17917
|
-
const thor = useThor();
|
|
17918
|
-
const { network } = useVeChainKitConfig();
|
|
17919
|
-
return useQuery({
|
|
17920
|
-
queryKey: getVot3BalanceQueryKey(address),
|
|
17921
|
-
queryFn: async () => getVot3Balance(thor, network.type, address),
|
|
17922
|
-
enabled: !!thor && !!address && !!network.type
|
|
17923
|
-
});
|
|
17924
|
-
};
|
|
17925
|
-
var contractAbi2 = VeBetterPassport__factory.abi;
|
|
17926
|
-
var method4 = "isPerson";
|
|
17927
|
-
var getIsPersonQueryKey = (networkType, user) => {
|
|
17928
|
-
const veBetterPassportContractAddress = getConfig(networkType).veBetterPassportContractAddress;
|
|
17929
|
-
return getCallClauseQueryKey({
|
|
17930
|
-
address: veBetterPassportContractAddress,
|
|
17931
|
-
method: method4,
|
|
17932
|
-
args: [user]
|
|
17933
|
-
});
|
|
17934
|
-
};
|
|
17935
|
-
var useIsPerson = (user, customEnabled = true) => {
|
|
17936
|
-
const { network } = useVeChainKitConfig();
|
|
17937
|
-
const veBetterPassportContractAddress = getConfig(
|
|
17938
|
-
network.type
|
|
17939
|
-
).veBetterPassportContractAddress;
|
|
17940
|
-
return useCallClause({
|
|
17941
|
-
abi: contractAbi2,
|
|
17942
|
-
address: veBetterPassportContractAddress,
|
|
17943
|
-
method: method4,
|
|
17944
|
-
args: [user ?? ZERO_ADDRESS],
|
|
17945
|
-
queryOptions: {
|
|
17946
|
-
enabled: !!user && customEnabled && !!veBetterPassportContractAddress && !!network.type,
|
|
17947
|
-
select: (data) => data[0]
|
|
17948
|
-
}
|
|
17949
|
-
});
|
|
17950
|
-
};
|
|
17951
|
-
var useIsUserPerson = (address) => {
|
|
17952
|
-
return useIsPerson(address);
|
|
17953
|
-
};
|
|
17954
|
-
var contractAbi3 = VeBetterPassport__factory.abi;
|
|
17955
|
-
var method5 = "isPersonAtTimepoint";
|
|
17956
|
-
var getIsPersonAtTimepointQueryKey = (networkType, user, timepoint) => {
|
|
17957
|
-
const veBetterPassportContractAddress = getConfig(networkType).veBetterPassportContractAddress;
|
|
17958
|
-
return getCallClauseQueryKey({
|
|
17959
|
-
address: veBetterPassportContractAddress,
|
|
17960
|
-
method: method5,
|
|
17961
|
-
args: [user, Number(timepoint)]
|
|
17962
|
-
});
|
|
17963
|
-
};
|
|
17964
|
-
var useIsPersonAtTimepoint = (user, timepoint, customEnabled = true) => {
|
|
17965
|
-
const { network } = useVeChainKitConfig();
|
|
17966
|
-
const veBetterPassportContractAddress = getConfig(
|
|
17967
|
-
network.type
|
|
17968
|
-
).veBetterPassportContractAddress;
|
|
17969
|
-
return useCallClause({
|
|
17970
|
-
abi: contractAbi3,
|
|
17971
|
-
address: veBetterPassportContractAddress,
|
|
17972
|
-
method: method5,
|
|
17973
|
-
args: [
|
|
17974
|
-
user ?? ZERO_ADDRESS,
|
|
17975
|
-
timepoint ? Number(timepoint) : 0
|
|
17976
|
-
],
|
|
17977
|
-
queryOptions: {
|
|
17978
|
-
enabled: !!user && timepoint !== void 0 && customEnabled && !!veBetterPassportContractAddress && !!network.type,
|
|
17979
|
-
select: (data) => data[0]
|
|
17980
|
-
}
|
|
17981
|
-
});
|
|
17982
|
-
};
|
|
17983
|
-
|
|
17984
|
-
// src/hooks/thor/contracts/VeBetterPassport/useUserBotSignals.ts
|
|
17985
|
-
var contractAbi4 = VeBetterPassport__factory.abi;
|
|
17986
|
-
var method6 = "signaledCounter";
|
|
17987
|
-
var getUserBotSignalsQueryKey = (networkType, userAddress) => {
|
|
17988
|
-
return getCallClauseQueryKey({
|
|
17989
|
-
address: getConfig(networkType).veBetterPassportContractAddress,
|
|
17990
|
-
method: method6,
|
|
17991
|
-
args: [userAddress]
|
|
17992
|
-
});
|
|
17993
|
-
};
|
|
17994
|
-
var useUserBotSignals = (userAddressInput) => {
|
|
17995
|
-
const { network } = useVeChainKitConfig();
|
|
17996
|
-
const veBetterPassportContractAddress = getConfig(
|
|
17997
|
-
network.type
|
|
17998
|
-
).veBetterPassportContractAddress;
|
|
17999
|
-
return useCallClause({
|
|
18000
|
-
address: veBetterPassportContractAddress,
|
|
18001
|
-
abi: contractAbi4,
|
|
18002
|
-
method: method6,
|
|
18003
|
-
args: [userAddressInput],
|
|
18004
|
-
queryOptions: {
|
|
18005
|
-
enabled: !!userAddressInput && !!veBetterPassportContractAddress && !!network.type,
|
|
18006
|
-
select: (res) => Number(res[0])
|
|
18007
|
-
}
|
|
18008
|
-
});
|
|
18009
|
-
};
|
|
18010
|
-
var useVotingRewards = (currentRoundId, voter) => {
|
|
18011
|
-
const thor = useThor();
|
|
18012
|
-
const queryClient = useQueryClient();
|
|
18013
|
-
const { network } = useVeChainKitConfig();
|
|
18014
|
-
const contractAddress = getConfig(network.type).voterRewardsContractAddress;
|
|
18015
|
-
const rounds = useMemo(() => {
|
|
18016
|
-
return Array.from(
|
|
18017
|
-
{ length: parseInt(currentRoundId ?? "0") - 1 },
|
|
18018
|
-
(_, i) => (i + 1).toString()
|
|
18019
|
-
);
|
|
18020
|
-
}, [currentRoundId]);
|
|
18021
|
-
return useQuery({
|
|
18022
|
-
queryKey: getRoundRewardQueryKey("ALL", voter),
|
|
18023
|
-
enabled: !!thor && !!voter && !!currentRoundId && !!rounds.length && !!network.type,
|
|
18024
|
-
queryFn: async () => {
|
|
18025
|
-
const contract = thor.contracts.load(
|
|
18026
|
-
contractAddress,
|
|
18027
|
-
VoterRewards__factory.abi
|
|
18028
|
-
);
|
|
18029
|
-
const clauses = rounds.map(
|
|
18030
|
-
(roundId) => (
|
|
18031
|
-
// Voter Rewards getReward result type: [ 0n ]
|
|
18032
|
-
contract.clause.getReward(roundId, voter)
|
|
18033
|
-
)
|
|
18034
|
-
);
|
|
18035
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18036
|
-
clauses
|
|
18037
|
-
);
|
|
18038
|
-
if (!res.every((r) => r.success))
|
|
18039
|
-
throw new Error("Failed to fetch voting rewards");
|
|
18040
|
-
let total = new BigNumber(0);
|
|
18041
|
-
const roundsRewards = res.map((r, index) => {
|
|
18042
|
-
const roundId = rounds[index];
|
|
18043
|
-
const rewards = r.result.plain;
|
|
18044
|
-
const formattedRewards = formatEther(rewards);
|
|
18045
|
-
total = total.plus(BigNumber(rewards.toString()));
|
|
18046
|
-
queryClient.setQueryData(
|
|
18047
|
-
getRoundRewardQueryKey(roundId, voter),
|
|
18048
|
-
{
|
|
18049
|
-
roundId,
|
|
18050
|
-
rewards: formattedRewards
|
|
18051
|
-
}
|
|
18052
|
-
);
|
|
18053
|
-
return {
|
|
18054
|
-
roundId,
|
|
18055
|
-
rewards,
|
|
18056
|
-
formattedRewards
|
|
18057
|
-
};
|
|
18058
|
-
});
|
|
18059
|
-
const totalFormatted = formatEther(BigInt(total.toFixed()));
|
|
18060
|
-
return {
|
|
18061
|
-
total: total.toFixed(),
|
|
18062
|
-
totalFormatted,
|
|
18063
|
-
roundsRewards
|
|
18064
|
-
};
|
|
18065
|
-
}
|
|
18066
|
-
});
|
|
18067
|
-
};
|
|
18068
|
-
var getRoundRewardQueryKey = (roundId, address) => [
|
|
18069
|
-
"VECHAIN_KIT",
|
|
18070
|
-
"roundReward",
|
|
18071
|
-
roundId,
|
|
18072
|
-
"voter",
|
|
18073
|
-
address
|
|
18074
|
-
];
|
|
18075
|
-
var useRoundReward = (address, roundId) => {
|
|
18076
|
-
const { network } = useVeChainKitConfig();
|
|
18077
|
-
return useCallClause({
|
|
18078
|
-
address: getConfig(network.type).voterRewardsContractAddress,
|
|
18079
|
-
abi: VoterRewards__factory.abi,
|
|
18080
|
-
method: "getReward",
|
|
18081
|
-
args: [BigInt(roundId || 0), address],
|
|
18082
|
-
queryOptions: {
|
|
18083
|
-
enabled: !!address && !!roundId && !!network.type,
|
|
18084
|
-
select: (data) => ({
|
|
18085
|
-
roundId,
|
|
18086
|
-
rewards: formatEther(data[0])
|
|
18087
|
-
})
|
|
18088
|
-
}
|
|
18089
|
-
});
|
|
18090
|
-
};
|
|
18091
|
-
|
|
18092
|
-
// src/hooks/thor/contracts/X2EarnApps/utils/getXAppMetadata.ts
|
|
18093
|
-
var getXAppMetadata = async (uri, networkType) => {
|
|
18094
|
-
const url = convertUriToUrl(uri, networkType);
|
|
18095
|
-
if (!url) return void 0;
|
|
18096
|
-
const response = await fetch(url);
|
|
18097
|
-
if (!response.ok) {
|
|
18098
|
-
return void 0;
|
|
18099
|
-
}
|
|
18100
|
-
return response.json();
|
|
18101
|
-
};
|
|
18102
|
-
|
|
18103
|
-
// src/hooks/thor/contracts/X2EarnApps/utils/getXApps.ts
|
|
18104
|
-
var getXApps = async (thor, networkType) => {
|
|
18105
|
-
const contract = thor.contracts.load(
|
|
18106
|
-
getConfig(networkType).x2EarnAppsContractAddress,
|
|
18107
|
-
X2EarnApps__factory.abi
|
|
18108
|
-
);
|
|
18109
|
-
const clauses = [contract.clause.unendorsedApps(), contract.clause.apps()];
|
|
18110
|
-
const res = await thor.transactions.executeMultipleClausesCall(clauses);
|
|
18111
|
-
if (!res.every((r) => r.success)) throw new Error(`Failed to fetch xApps`);
|
|
18112
|
-
const apps = res[0]?.result.plain;
|
|
18113
|
-
const unendorsedApps = res[1]?.result.plain;
|
|
18114
|
-
const allApps = {};
|
|
18115
|
-
for (const app of apps) {
|
|
18116
|
-
allApps[app.id] = {
|
|
18117
|
-
id: app.id,
|
|
18118
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18119
|
-
name: app.name,
|
|
18120
|
-
metadataURI: app.metadataURI,
|
|
18121
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18122
|
-
};
|
|
18123
|
-
}
|
|
18124
|
-
for (const app of unendorsedApps) {
|
|
18125
|
-
allApps[app.id] = {
|
|
18126
|
-
id: app.id,
|
|
18127
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18128
|
-
name: app.name,
|
|
18129
|
-
metadataURI: app.metadataURI,
|
|
18130
|
-
createdAtTimestamp: app.createdAtTimestamp.toString(),
|
|
18131
|
-
appAvailableForAllocationVoting: app.appAvailableForAllocationVoting
|
|
18132
|
-
};
|
|
18133
|
-
}
|
|
18134
|
-
const unendorsedIds = new Set(unendorsedApps.map((app) => app.id));
|
|
18135
|
-
return {
|
|
18136
|
-
allApps: Object.values(allApps),
|
|
18137
|
-
active: apps.map((app) => ({
|
|
18138
|
-
...app,
|
|
18139
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18140
|
-
})),
|
|
18141
|
-
unendorsed: unendorsedApps.map((app) => ({
|
|
18142
|
-
...app,
|
|
18143
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18144
|
-
})),
|
|
18145
|
-
endorsed: apps.filter((app) => !unendorsedIds.has(app.id)).map((app) => ({
|
|
18146
|
-
...app,
|
|
18147
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18148
|
-
}))
|
|
18149
|
-
};
|
|
18150
|
-
};
|
|
18151
|
-
var abi4 = XAllocationVoting__factory.abi;
|
|
18152
|
-
var method7 = "getAppsOfRound";
|
|
18153
|
-
var getRoundXApps = async (thor, networkType, roundId) => {
|
|
18154
|
-
if (!roundId) return [];
|
|
18155
|
-
const [xApps] = await executeCallClause({
|
|
18156
|
-
thor,
|
|
18157
|
-
contractAddress: getConfig(networkType).xAllocationVotingContractAddress,
|
|
18158
|
-
abi: abi4,
|
|
18159
|
-
method: method7,
|
|
18160
|
-
args: [BigInt(roundId)]
|
|
18161
|
-
});
|
|
18162
|
-
return xApps.map((app) => ({
|
|
18163
|
-
id: app.id.toString(),
|
|
18164
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18165
|
-
name: app.name,
|
|
18166
|
-
metadataURI: app.metadataURI,
|
|
18167
|
-
createdAtTimestamp: app.createdAtTimestamp.toString(),
|
|
18168
|
-
appAvailableForAllocationVoting: app.appAvailableForAllocationVoting
|
|
18169
|
-
}));
|
|
18170
|
-
};
|
|
18171
|
-
var getRoundXAppsQueryKey = (roundId) => [
|
|
18172
|
-
"VECHAIN_KIT",
|
|
18173
|
-
"round",
|
|
18174
|
-
roundId,
|
|
18175
|
-
"getXApps"
|
|
18176
|
-
];
|
|
18177
|
-
var useRoundXApps = (roundId) => {
|
|
18178
|
-
const thor = useThor();
|
|
18179
|
-
const { network } = useVeChainKitConfig();
|
|
18180
|
-
return useQuery({
|
|
18181
|
-
queryKey: getRoundXAppsQueryKey(roundId),
|
|
18182
|
-
queryFn: async () => await getRoundXApps(thor, network.type, roundId),
|
|
18183
|
-
enabled: !!thor && !!roundId && !!network.type
|
|
18184
|
-
});
|
|
18185
|
-
};
|
|
18186
|
-
var getUserVotesInRound = async (thor, network, roundId, address) => {
|
|
18187
|
-
const xAllocationVotingContract = getConfig(network).xAllocationVotingContractAddress;
|
|
18188
|
-
const eventAbi = thor.contracts.load(xAllocationVotingContract, XAllocationVoting__factory.abi).getEventAbi("AllocationVoteCast");
|
|
18189
|
-
const topics = eventAbi.encodeFilterTopicsNoNull({
|
|
18190
|
-
...address ? { voter: address } : {},
|
|
18191
|
-
...roundId ? { roundId } : {}
|
|
18192
|
-
});
|
|
18193
|
-
const filterCriteria = [
|
|
18194
|
-
{
|
|
18195
|
-
criteria: {
|
|
18196
|
-
address: xAllocationVotingContract,
|
|
18197
|
-
topic0: topics[0] ?? void 0,
|
|
18198
|
-
topic1: topics[1] ?? void 0,
|
|
18199
|
-
topic2: topics[2] ?? void 0,
|
|
18200
|
-
topic3: topics[3] ?? void 0,
|
|
18201
|
-
topic4: topics[4] ?? void 0
|
|
18202
|
-
},
|
|
18203
|
-
eventAbi
|
|
18204
|
-
}
|
|
18205
|
-
];
|
|
18206
|
-
const events = await getAllEventLogs({
|
|
18207
|
-
thor,
|
|
18208
|
-
filterCriteria,
|
|
18209
|
-
nodeUrl: getConfig(network).nodeUrl
|
|
18210
|
-
});
|
|
18211
|
-
const decodedAllocatedVoteEvents = [];
|
|
18212
|
-
events.forEach((event) => {
|
|
18213
|
-
if (!event.decodedData) {
|
|
18214
|
-
throw new Error("Event data not decoded");
|
|
18215
|
-
}
|
|
18216
|
-
if (!compareAddresses(event.address, xAllocationVotingContract)) {
|
|
18217
|
-
throw new Error("Event address not valid");
|
|
18218
|
-
}
|
|
18219
|
-
const [voter, roundId2, appsIds, voteWeights] = event.decodedData;
|
|
18220
|
-
decodedAllocatedVoteEvents.push({
|
|
18221
|
-
voter,
|
|
18222
|
-
roundId: roundId2,
|
|
18223
|
-
appsIds,
|
|
18224
|
-
voteWeights
|
|
18225
|
-
});
|
|
18226
|
-
});
|
|
18227
|
-
return decodedAllocatedVoteEvents;
|
|
18228
|
-
};
|
|
18229
|
-
var getUserVotesInRoundQueryKey = (roundId, address) => [
|
|
18230
|
-
"VECHAIN_KIT",
|
|
18231
|
-
"allocationsRound",
|
|
18232
|
-
roundId,
|
|
18233
|
-
"userVotes",
|
|
18234
|
-
...address ? [address] : []
|
|
18235
|
-
];
|
|
18236
|
-
var useUserVotesInRound = (roundId, address) => {
|
|
18237
|
-
const thor = useThor();
|
|
18238
|
-
const { network } = useVeChainKitConfig();
|
|
18239
|
-
return useQuery({
|
|
18240
|
-
queryKey: getUserVotesInRoundQueryKey(roundId, address),
|
|
18241
|
-
queryFn: async () => {
|
|
18242
|
-
const votes = await getUserVotesInRound(
|
|
18243
|
-
thor,
|
|
18244
|
-
network.type,
|
|
18245
|
-
roundId,
|
|
18246
|
-
address
|
|
18247
|
-
);
|
|
18248
|
-
if (votes.length > 1) throw new Error("More than one event found");
|
|
18249
|
-
if (votes.length === 0) throw new Error("No event found");
|
|
18250
|
-
return votes[0];
|
|
18251
|
-
},
|
|
18252
|
-
enabled: !!thor && !!thor.blocks.getHeadBlock() && !!roundId && !!address && !!network.type
|
|
18253
|
-
});
|
|
18254
|
-
};
|
|
18255
|
-
var getVotesInRoundQueryKey = (roundId) => [
|
|
18256
|
-
"VECHAIN_KIT",
|
|
18257
|
-
"allocationsRound",
|
|
18258
|
-
roundId,
|
|
18259
|
-
"totalVotes"
|
|
18260
|
-
];
|
|
18261
|
-
var useVotesInRound = (roundId, enabled = true) => {
|
|
18262
|
-
const thor = useThor();
|
|
18263
|
-
const { network } = useVeChainKitConfig();
|
|
18264
|
-
return useQuery({
|
|
18265
|
-
queryKey: getVotesInRoundQueryKey(roundId),
|
|
18266
|
-
queryFn: async () => await getUserVotesInRound(thor, network.type, roundId),
|
|
18267
|
-
enabled: !!thor && !!thor.blocks.getHeadBlock() && !!roundId && enabled && !!network.type
|
|
18268
|
-
});
|
|
18269
|
-
};
|
|
18270
|
-
var getXAppsQueryKey = () => ["VECHAIN_KIT", "getXApps"];
|
|
18271
|
-
var useXApps = () => {
|
|
18272
|
-
const thor = useThor();
|
|
18273
|
-
const { network } = useVeChainKitConfig();
|
|
18274
|
-
return useQuery({
|
|
18275
|
-
queryKey: getXAppsQueryKey(),
|
|
18276
|
-
queryFn: async () => await getXApps(thor, network.type),
|
|
18277
|
-
enabled: !!thor && !!network.type
|
|
18278
|
-
});
|
|
18279
|
-
};
|
|
18280
|
-
|
|
18281
|
-
// src/hooks/thor/contracts/X2EarnApps/custom/useXApp.ts
|
|
18282
|
-
var useXApp = (appId) => {
|
|
18283
|
-
const { data: xApps, ...props } = useXApps();
|
|
18284
|
-
const allApps = useMemo(() => [...xApps?.active ?? [], ...xApps?.unendorsed ?? []], [xApps]);
|
|
18285
|
-
const app = allApps.find((xa) => xa.id === appId);
|
|
18286
|
-
return {
|
|
18287
|
-
data: app,
|
|
18288
|
-
...props
|
|
18289
|
-
};
|
|
18290
|
-
};
|
|
18291
|
-
var getXAppMetadataQueryKey = (metadataURI) => [
|
|
18292
|
-
"VECHAIN_KIT",
|
|
18293
|
-
"xApps",
|
|
18294
|
-
metadataURI,
|
|
18295
|
-
"metadata"
|
|
18296
|
-
];
|
|
18297
|
-
var useXAppMetadata = (xAppId) => {
|
|
18298
|
-
const { data: baseUri } = useXAppsMetadataBaseUri();
|
|
18299
|
-
const { data: xApp } = useXApp(xAppId ?? "");
|
|
18300
|
-
const { network } = useVeChainKitConfig();
|
|
18301
|
-
return useQuery({
|
|
18302
|
-
queryKey: getXAppMetadataQueryKey(xApp?.metadataURI || ""),
|
|
18303
|
-
queryFn: async () => !(!baseUri && xApp) ? await getXAppMetadata(
|
|
18304
|
-
`${baseUri}${xApp?.metadataURI}`,
|
|
18305
|
-
network.type
|
|
18306
|
-
) : null,
|
|
18307
|
-
enabled: !!baseUri && !!xApp && !!network.type
|
|
18308
|
-
});
|
|
18309
|
-
};
|
|
18310
|
-
var getXAppsSharesQueryKey = (roundId) => [
|
|
18311
|
-
"VECHAIN_KIT",
|
|
18312
|
-
"XApps",
|
|
18313
|
-
"Shares",
|
|
18314
|
-
roundId
|
|
18315
|
-
];
|
|
18316
|
-
var useXAppsShares = (apps, roundId) => {
|
|
18317
|
-
const thor = useThor();
|
|
18318
|
-
const { network } = useVeChainKitConfig();
|
|
18319
|
-
return useQuery({
|
|
18320
|
-
queryKey: getXAppsSharesQueryKey(roundId),
|
|
18321
|
-
queryFn: async () => {
|
|
18322
|
-
const contract = thor.contracts.load(
|
|
18323
|
-
getConfig(network.type).xAllocationPoolContractAddress,
|
|
18324
|
-
XAllocationPool__factory.abi
|
|
18325
|
-
);
|
|
18326
|
-
const clauses = apps.map(
|
|
18327
|
-
(app) => contract.clause.getAppShares(roundId, app)
|
|
18328
|
-
);
|
|
18329
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18330
|
-
clauses
|
|
18331
|
-
);
|
|
18332
|
-
if (!res.every((r) => r.success))
|
|
18333
|
-
throw new Error(
|
|
18334
|
-
`Failed to fetch xApps shares for ${apps} in round ${roundId}`
|
|
18335
|
-
);
|
|
18336
|
-
const shares = res.map((r, index) => {
|
|
18337
|
-
return {
|
|
18338
|
-
app: apps[index],
|
|
18339
|
-
share: Number(r.result.array?.[0] || 0) / 100,
|
|
18340
|
-
unallocatedShare: Number(r.result.array?.[1] || 0) / 100
|
|
18341
|
-
};
|
|
18342
|
-
});
|
|
18343
|
-
return shares;
|
|
18344
|
-
},
|
|
18345
|
-
enabled: !!roundId && !!apps.length
|
|
18346
|
-
});
|
|
18347
|
-
};
|
|
18348
|
-
|
|
18349
|
-
// src/hooks/thor/contracts/X2EarnApps/custom/useMostVotedAppsInRound.ts
|
|
18350
|
-
var useMostVotedAppsInRound = (roundId) => {
|
|
18351
|
-
const { data: roundXApps } = useRoundXApps(roundId);
|
|
18352
|
-
const { data: allXApps } = useXApps();
|
|
18353
|
-
const apps = roundId === "0" ? allXApps?.active : roundXApps;
|
|
18354
|
-
const xAppsShares = useXAppsShares(
|
|
18355
|
-
apps?.map((app) => app.id) ?? [],
|
|
18356
|
-
roundId
|
|
18357
|
-
);
|
|
18358
|
-
const mostVotedApps = useMemo(
|
|
18359
|
-
() => xAppsShares.data?.map((appShares) => ({
|
|
18360
|
-
percentage: appShares.share + appShares.unallocatedShare,
|
|
18361
|
-
id: apps?.find((xa) => xa.id === appShares.app)?.id ?? "",
|
|
18362
|
-
app: apps?.find((xa) => xa.id === appShares.app) ?? {}
|
|
18363
|
-
})).sort((a, b) => Number(b.percentage) - Number(a.percentage)) ?? [],
|
|
18364
|
-
[xAppsShares.data, apps]
|
|
18365
|
-
);
|
|
18366
|
-
return {
|
|
18367
|
-
data: mostVotedApps,
|
|
18368
|
-
isLoading: xAppsShares.isLoading
|
|
18369
|
-
};
|
|
18370
|
-
};
|
|
18371
|
-
|
|
18372
|
-
// src/hooks/thor/contracts/X2EarnApps/useXAppsMetadataBaseUri.ts
|
|
18373
|
-
var abi5 = X2EarnApps__factory.abi;
|
|
18374
|
-
var method8 = "baseURI";
|
|
18375
|
-
var getXAppsMetadataBaseUriQueryKey = (network) => getCallClauseQueryKey({
|
|
18376
|
-
method: method8,
|
|
18377
|
-
address: getConfig(network).x2EarnAppsContractAddress,
|
|
18378
|
-
args: []
|
|
18379
|
-
});
|
|
18380
|
-
var useXAppsMetadataBaseUri = () => {
|
|
18381
|
-
const { network } = useVeChainKitConfig();
|
|
18382
|
-
return useCallClause({
|
|
18383
|
-
abi: abi5,
|
|
18384
|
-
address: getConfig(network.type).x2EarnAppsContractAddress,
|
|
18385
|
-
method: method8,
|
|
18386
|
-
args: [],
|
|
18387
|
-
queryOptions: {
|
|
18388
|
-
enabled: !!network.type,
|
|
18389
|
-
staleTime: 1e3 * 60 * 60
|
|
18390
|
-
// 1 hour,
|
|
18391
|
-
}
|
|
18392
|
-
});
|
|
18393
|
-
};
|
|
18394
|
-
var getXAppRoundEarnings = async (thor, roundId, xAppId, networkType) => {
|
|
18395
|
-
const res = await thor.contracts.load(
|
|
18396
|
-
getConfig(networkType).xAllocationPoolContractAddress,
|
|
18397
|
-
XAllocationPool__factory.abi
|
|
18398
|
-
).read.roundEarnings(roundId, xAppId);
|
|
18399
|
-
if (!res)
|
|
18400
|
-
throw new Error(
|
|
18401
|
-
`Failed to fetch xApp round earnings for ${xAppId} in round ${roundId}`
|
|
18402
|
-
);
|
|
18403
|
-
return { amount: formatEther(BigInt(res[0] || 0)), appId: xAppId };
|
|
18404
|
-
};
|
|
18405
|
-
var getXAppRoundEarningsQueryKey = (roundId, xAppId) => [
|
|
18406
|
-
"VECHAIN_KIT",
|
|
18407
|
-
"roundEarnings",
|
|
18408
|
-
"roundId",
|
|
18409
|
-
Number(roundId),
|
|
18410
|
-
"appId",
|
|
18411
|
-
...xAppId ? [xAppId] : []
|
|
18412
|
-
];
|
|
18413
|
-
var useXAppRoundEarnings = (roundId, xAppId) => {
|
|
18414
|
-
const thor = useThor();
|
|
18415
|
-
const queryClient = getOrCreateQueryClient();
|
|
18416
|
-
const { network } = useVeChainKitConfig();
|
|
18417
|
-
return useQuery({
|
|
18418
|
-
queryKey: getXAppRoundEarningsQueryKey(roundId, xAppId),
|
|
18419
|
-
queryFn: async () => {
|
|
18420
|
-
const data = await queryClient.ensureQueryData({
|
|
18421
|
-
queryFn: () => getRoundXApps(thor, network.type, roundId),
|
|
18422
|
-
queryKey: getRoundXAppsQueryKey(roundId)
|
|
18423
|
-
});
|
|
18424
|
-
const isXAppInRound = data.some((app) => app.id === xAppId);
|
|
18425
|
-
if (!isXAppInRound) return { amount: "0", xAppId };
|
|
18426
|
-
return await getXAppRoundEarnings(
|
|
18427
|
-
thor,
|
|
18428
|
-
roundId,
|
|
18429
|
-
xAppId,
|
|
18430
|
-
network.type
|
|
18431
|
-
);
|
|
18432
|
-
},
|
|
18433
|
-
enabled: !!thor && !!roundId && !!xAppId
|
|
18434
|
-
});
|
|
18435
|
-
};
|
|
18436
|
-
var useMultipleXAppRoundEarnings = (roundId, xAppIds) => {
|
|
18437
|
-
const thor = useThor();
|
|
18438
|
-
const queryClient = getOrCreateQueryClient();
|
|
18439
|
-
const { network } = useVeChainKitConfig();
|
|
18440
|
-
return useQuery({
|
|
18441
|
-
queryKey: getXAppRoundEarningsQueryKey(roundId, "ALL"),
|
|
18442
|
-
queryFn: async () => {
|
|
18443
|
-
const data = await queryClient.ensureQueryData({
|
|
18444
|
-
queryFn: () => getRoundXApps(thor, network.type, roundId),
|
|
18445
|
-
queryKey: getRoundXAppsQueryKey(roundId)
|
|
18446
|
-
});
|
|
18447
|
-
const xAllocationPoolContract = getConfig(
|
|
18448
|
-
network.type
|
|
18449
|
-
).xAllocationPoolContractAddress;
|
|
18450
|
-
const xAppsInRound = data.filter((app) => xAppIds.includes(app.id));
|
|
18451
|
-
const contract = thor.contracts.load(
|
|
18452
|
-
xAllocationPoolContract,
|
|
18453
|
-
XAllocationPool__factory.abi
|
|
18454
|
-
);
|
|
18455
|
-
const clauses = xAppsInRound.map(
|
|
18456
|
-
(app) => contract.clause.roundEarnings(roundId, app.id)
|
|
18457
|
-
);
|
|
18458
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18459
|
-
clauses
|
|
18460
|
-
);
|
|
18461
|
-
if (!res.every((r) => r.success))
|
|
18462
|
-
throw new Error("Failed to fetch xApp round earnings");
|
|
18463
|
-
const decoded = res.map((earnings, index) => {
|
|
18464
|
-
const parsedAmount = formatEther(
|
|
18465
|
-
earnings.result.plain
|
|
18466
|
-
);
|
|
18467
|
-
const appId = xAppsInRound[index]?.id;
|
|
18468
|
-
queryClient.setQueryData(
|
|
18469
|
-
getXAppRoundEarningsQueryKey(roundId, appId),
|
|
18470
|
-
{
|
|
18471
|
-
amount: parsedAmount,
|
|
18472
|
-
appId
|
|
18473
|
-
}
|
|
18474
|
-
);
|
|
18475
|
-
return { amount: parsedAmount, appId };
|
|
18476
|
-
});
|
|
18477
|
-
return decoded;
|
|
18478
|
-
},
|
|
18479
|
-
enabled: !!thor && !!roundId && !!xAppIds.length
|
|
18480
|
-
});
|
|
18481
|
-
};
|
|
18482
|
-
var getXAppTotalEarningsQueryKey = (tillRoundId, appId) => [
|
|
18483
|
-
"VECHAIN_KIT",
|
|
18484
|
-
"XAllocationPool",
|
|
18485
|
-
"xApp",
|
|
18486
|
-
appId,
|
|
18487
|
-
"totalEarningsTillRound",
|
|
18488
|
-
tillRoundId
|
|
18489
|
-
];
|
|
18490
|
-
var useXAppTotalEarnings = (roundIds, appId) => {
|
|
18491
|
-
const thor = useThor();
|
|
18492
|
-
const { network } = useVeChainKitConfig();
|
|
18493
|
-
const queryClient = getOrCreateQueryClient();
|
|
18494
|
-
const lastRound = roundIds[roundIds.length - 1] ?? 0;
|
|
18495
|
-
return useQuery({
|
|
18496
|
-
queryKey: getXAppTotalEarningsQueryKey(lastRound, appId),
|
|
18497
|
-
queryFn: async () => {
|
|
18498
|
-
const contract = thor.contracts.load(
|
|
18499
|
-
getConfig(network.type).xAllocationPoolContractAddress,
|
|
18500
|
-
XAllocationPool__factory.abi
|
|
18501
|
-
);
|
|
18502
|
-
const clauses = roundIds.map(
|
|
18503
|
-
(roundId) => contract.clause.roundEarnings(roundId, appId)
|
|
18504
|
-
);
|
|
18505
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18506
|
-
clauses
|
|
18507
|
-
);
|
|
18508
|
-
if (!res.every((r) => r.success))
|
|
18509
|
-
throw new Error(
|
|
18510
|
-
`Failed to fetch xApp total earnings of ${appId}`
|
|
18511
|
-
);
|
|
18512
|
-
const decoded = res.map((r, index) => {
|
|
18513
|
-
const parsedAmount = formatEther(
|
|
18514
|
-
r.result.plain || BigInt(0)
|
|
18515
|
-
);
|
|
18516
|
-
queryClient.setQueryData(
|
|
18517
|
-
getXAppRoundEarningsQueryKey(
|
|
18518
|
-
roundIds[index],
|
|
18519
|
-
appId
|
|
18520
|
-
),
|
|
18521
|
-
{
|
|
18522
|
-
amount: parsedAmount,
|
|
18523
|
-
appId
|
|
18524
|
-
}
|
|
18525
|
-
);
|
|
18526
|
-
return parsedAmount;
|
|
18527
|
-
});
|
|
18528
|
-
return decoded.reduce((acc, amount) => {
|
|
18529
|
-
return acc + Number(amount);
|
|
18530
|
-
}, 0);
|
|
18531
|
-
}
|
|
18532
|
-
});
|
|
18533
|
-
};
|
|
18534
|
-
|
|
18535
|
-
// src/hooks/thor/contracts/XAllocationVoting/useAllocationsRoundState.ts
|
|
18536
|
-
var RoundState = {
|
|
18537
|
-
0: "Active",
|
|
18538
|
-
1: "Failed",
|
|
18539
|
-
2: "Succeeded"
|
|
18540
|
-
};
|
|
18541
|
-
var abi6 = XAllocationVoting__factory.abi;
|
|
18542
|
-
var method9 = "state";
|
|
18543
|
-
var getAllocationsRoundStateQueryKey = (roundId, network) => getCallClauseQueryKey({
|
|
18544
|
-
method: method9,
|
|
18545
|
-
address: getConfig(network).xAllocationVotingContractAddress,
|
|
18546
|
-
args: [BigInt(roundId || 0)]
|
|
18547
|
-
});
|
|
18548
|
-
var useAllocationsRoundState = (roundId) => {
|
|
18549
|
-
const { network } = useVeChainKitConfig();
|
|
18550
|
-
return useCallClause({
|
|
18551
|
-
abi: abi6,
|
|
18552
|
-
address: getConfig(network.type).xAllocationVotingContractAddress,
|
|
18553
|
-
method: method9,
|
|
18554
|
-
args: [BigInt(roundId || 0)],
|
|
18555
|
-
queryOptions: {
|
|
18556
|
-
enabled: !!roundId && !!network.type,
|
|
18557
|
-
select: (data) => data[0]
|
|
18558
|
-
}
|
|
18559
|
-
});
|
|
18560
|
-
};
|
|
18561
|
-
|
|
18562
|
-
// src/hooks/thor/contracts/XAllocationVoting/useCurrentAllocationsRoundId.ts
|
|
18563
|
-
var abi7 = XAllocationVoting__factory.abi;
|
|
18564
|
-
var method10 = "currentRoundId";
|
|
18565
|
-
var getCurrentAllocationsRoundIdQueryKey = (network) => getCallClauseQueryKey({
|
|
18566
|
-
method: method10,
|
|
18567
|
-
address: getConfig(network).xAllocationVotingContractAddress,
|
|
18568
|
-
args: []
|
|
18569
|
-
});
|
|
18570
|
-
var useCurrentAllocationsRoundId = () => {
|
|
18571
|
-
const { network } = useVeChainKitConfig();
|
|
18572
|
-
return useCallClause({
|
|
18573
|
-
abi: abi7,
|
|
18574
|
-
address: getConfig(network.type).xAllocationVotingContractAddress,
|
|
18575
|
-
method: method10,
|
|
18576
|
-
args: [],
|
|
18577
|
-
queryOptions: {
|
|
18578
|
-
enabled: !!network.type,
|
|
18579
|
-
select: (data) => data[0].toString()
|
|
18580
|
-
}
|
|
18581
|
-
});
|
|
18582
|
-
};
|
|
18583
|
-
|
|
18584
|
-
// src/hooks/thor/contracts/XAllocationVoting/useHasVotedInRound.ts
|
|
18585
|
-
var method11 = "hasVoted";
|
|
18586
|
-
var abi8 = XAllocationVoting__factory.abi;
|
|
18587
|
-
var getHasVotedInRoundQueryKey = (roundId, address, networkType) => getCallClauseQueryKey({
|
|
18588
|
-
address: getConfig(networkType).xAllocationVotingContractAddress,
|
|
18589
|
-
method: method11,
|
|
18590
|
-
args: [BigInt(roundId || 0), address]
|
|
18591
|
-
});
|
|
18592
|
-
var useHasVotedInRound = (roundId, address) => {
|
|
18593
|
-
const { network } = useVeChainKitConfig();
|
|
18594
|
-
return useCallClause({
|
|
18595
|
-
abi: abi8,
|
|
18596
|
-
address: getConfig(network.type).xAllocationVotingContractAddress,
|
|
18597
|
-
method: method11,
|
|
18598
|
-
args: [BigInt(roundId || 0), address],
|
|
18599
|
-
queryOptions: {
|
|
18600
|
-
enabled: !!roundId && !!address,
|
|
18601
|
-
select: (data) => data[0]
|
|
18602
|
-
}
|
|
18603
|
-
});
|
|
18604
|
-
};
|
|
18605
|
-
var getAllocationsRoundsEvents = async (thor, networkType) => {
|
|
18606
|
-
const xAllocationVotingContract = getConfig(networkType).xAllocationVotingContractAddress;
|
|
18607
|
-
const eventAbi = thor.contracts.load(xAllocationVotingContract, XAllocationVoting__factory.abi).getEventAbi("RoundCreated");
|
|
18608
|
-
const events = await getAllEventLogs({
|
|
18609
|
-
thor,
|
|
18610
|
-
filterCriteria: [
|
|
18611
|
-
{
|
|
18612
|
-
criteria: {
|
|
18613
|
-
address: xAllocationVotingContract,
|
|
18614
|
-
topic0: eventAbi.signatureHash
|
|
18615
|
-
},
|
|
18616
|
-
eventAbi
|
|
18617
|
-
}
|
|
18618
|
-
],
|
|
18619
|
-
nodeUrl: getConfig(networkType).nodeUrl
|
|
18620
|
-
});
|
|
18621
|
-
const decodedCreatedAllocationEvents = [];
|
|
18622
|
-
events.forEach((event) => {
|
|
18623
|
-
if (!event.decodedData) {
|
|
18624
|
-
throw new Error("Event data not decoded");
|
|
18625
|
-
}
|
|
18626
|
-
if (!compareAddresses(event.address, xAllocationVotingContract)) {
|
|
18627
|
-
throw new Error("Event address not valid");
|
|
18628
|
-
}
|
|
18629
|
-
const [roundId, proposer, voteStart, voteEnd, appsIds] = event.decodedData;
|
|
18630
|
-
decodedCreatedAllocationEvents.push({
|
|
18631
|
-
roundId: roundId.toString(),
|
|
18632
|
-
proposer,
|
|
18633
|
-
voteStart: voteStart.toString(),
|
|
18634
|
-
voteEnd: voteEnd.toString(),
|
|
18635
|
-
appsIds: appsIds.map((appId) => appId.toString())
|
|
18636
|
-
});
|
|
18637
|
-
});
|
|
18638
|
-
return {
|
|
18639
|
-
created: decodedCreatedAllocationEvents
|
|
18640
|
-
};
|
|
18641
|
-
};
|
|
18642
|
-
var getAllocationsRoundsEventsQueryKey = () => [
|
|
18643
|
-
"VECHAIN_KIT",
|
|
18644
|
-
"allocationRoundsEvents"
|
|
18645
|
-
];
|
|
18646
|
-
var useAllocationsRoundsEvents = () => {
|
|
18647
|
-
const thor = useThor();
|
|
18648
|
-
const { network } = useVeChainKitConfig();
|
|
18649
|
-
return useQuery({
|
|
18650
|
-
queryKey: getAllocationsRoundsEventsQueryKey(),
|
|
18651
|
-
queryFn: async () => await getAllocationsRoundsEvents(thor, network.type),
|
|
18652
|
-
enabled: !!thor && !!network.type
|
|
18653
|
-
});
|
|
18654
|
-
};
|
|
18655
|
-
|
|
18656
|
-
// src/hooks/thor/contracts/XAllocationVoting/custom/useCurrentAllocationsRound.ts
|
|
18657
|
-
var useCurrentAllocationsRound = () => {
|
|
18658
|
-
const currentRoundId = useCurrentAllocationsRoundId();
|
|
18659
|
-
const allocationsRound = useAllocationsRound(currentRoundId.data);
|
|
18660
|
-
return {
|
|
18661
|
-
...allocationsRound,
|
|
18662
|
-
isLoading: currentRoundId.isLoading || allocationsRound.isLoading,
|
|
18663
|
-
isError: currentRoundId.isError || allocationsRound.isError,
|
|
18664
|
-
error: currentRoundId.error || allocationsRound.error
|
|
18665
|
-
};
|
|
18666
|
-
};
|
|
18667
|
-
var useAllocationsRound = (roundId) => {
|
|
18668
|
-
const { data: currentBlock } = useCurrentBlock();
|
|
18669
|
-
const currentAllocationId = useCurrentAllocationsRoundId();
|
|
18670
|
-
const currentAllocationState = useAllocationsRoundState(roundId);
|
|
18671
|
-
const allocationRoundsEvents = useAllocationsRoundsEvents();
|
|
18672
|
-
const { network } = useVeChainKitConfig();
|
|
18673
|
-
const currentAllocationRound = useMemo(() => {
|
|
18674
|
-
if (!currentAllocationId.data || !allocationRoundsEvents.data)
|
|
18675
|
-
return;
|
|
18676
|
-
const roundInfo = allocationRoundsEvents.data.created.find(
|
|
18677
|
-
(allocationRound) => allocationRound.roundId === roundId
|
|
18678
|
-
);
|
|
18679
|
-
if (!roundInfo) return;
|
|
18680
|
-
return {
|
|
18681
|
-
...roundInfo,
|
|
18682
|
-
state: currentAllocationState.data,
|
|
18683
|
-
isCurrent: roundId === currentAllocationId.data
|
|
18684
|
-
};
|
|
18685
|
-
}, [
|
|
18686
|
-
currentAllocationId,
|
|
18687
|
-
allocationRoundsEvents,
|
|
18688
|
-
currentAllocationState,
|
|
18689
|
-
roundId
|
|
18690
|
-
]);
|
|
18691
|
-
const isLoading = currentAllocationId.isLoading || allocationRoundsEvents.isLoading || currentAllocationState.isLoading;
|
|
18692
|
-
const isError = currentAllocationId.isError || allocationRoundsEvents.isError || currentAllocationState.isError;
|
|
18693
|
-
const error = currentAllocationId.error || allocationRoundsEvents.error || currentAllocationState.error;
|
|
18694
|
-
const blockTime = getConfig(network.type).network.blockTime;
|
|
18695
|
-
const estimatedEndTime = useMemo(() => {
|
|
18696
|
-
if (!currentAllocationRound) return null;
|
|
18697
|
-
const endBlock = Number(currentAllocationRound.voteEnd);
|
|
18698
|
-
if (!endBlock || !currentBlock) return null;
|
|
18699
|
-
const endBlockFromNow = endBlock - currentBlock.number;
|
|
18700
|
-
const durationLeftTimestamp = endBlockFromNow * blockTime;
|
|
18701
|
-
return Date.now() + durationLeftTimestamp;
|
|
18702
|
-
}, [currentBlock, currentAllocationRound, blockTime]);
|
|
18703
|
-
const estimatedStartTime = useMemo(() => {
|
|
18704
|
-
if (!currentAllocationRound) return null;
|
|
18705
|
-
const startBlock = Number(currentAllocationRound.voteStart);
|
|
18706
|
-
if (!startBlock || !currentBlock) return null;
|
|
18707
|
-
const endBlockFromNow = startBlock - currentBlock.number;
|
|
18708
|
-
const durationLeftTimestamp = endBlockFromNow * blockTime;
|
|
18709
|
-
return Date.now() + durationLeftTimestamp;
|
|
18710
|
-
}, [currentBlock, currentAllocationRound, blockTime]);
|
|
18711
|
-
const isFirstRound = currentAllocationRound?.roundId === "1";
|
|
18712
|
-
const isLastRound = currentAllocationRound?.roundId === allocationRoundsEvents?.data?.created.length.toString();
|
|
18713
|
-
return {
|
|
18714
|
-
...allocationRoundsEvents,
|
|
18715
|
-
data: {
|
|
18716
|
-
...currentAllocationRound,
|
|
18717
|
-
voteStartTimestamp: estimatedStartTime,
|
|
18718
|
-
voteEndTimestamp: estimatedEndTime,
|
|
18719
|
-
isFirstRound,
|
|
18720
|
-
isLastRound
|
|
18721
|
-
},
|
|
18722
|
-
isLoading,
|
|
18723
|
-
isError,
|
|
18724
|
-
error
|
|
18725
|
-
};
|
|
18726
|
-
};
|
|
18727
|
-
var contractAbi5 = XAllocationVotingGovernor__factory.abi;
|
|
18728
|
-
var method12 = "getAppVotes";
|
|
18729
|
-
var getXAppVotesQueryKey = (networkType, roundId, appId) => getCallClauseQueryKey({
|
|
18730
|
-
address: getConfig(networkType).xAllocationVotingContractAddress,
|
|
18731
|
-
method: method12,
|
|
18732
|
-
args: [BigInt(roundId || 0), appId]
|
|
18733
|
-
});
|
|
18734
|
-
var useXAppVotes = (roundId, appId) => {
|
|
18735
|
-
const { network } = useVeChainKitConfig();
|
|
18736
|
-
const contractAddress = getConfig(
|
|
18737
|
-
network.type
|
|
18738
|
-
).xAllocationVotingContractAddress;
|
|
18739
|
-
return useCallClause({
|
|
18740
|
-
address: contractAddress,
|
|
18741
|
-
abi: contractAbi5,
|
|
18742
|
-
method: method12,
|
|
18743
|
-
args: [BigInt(roundId || 0), appId],
|
|
18744
|
-
queryOptions: {
|
|
18745
|
-
enabled: !!roundId && !!appId && !!network.type,
|
|
18746
|
-
select: (res) => formatEther(res[0])
|
|
18747
|
-
}
|
|
18748
|
-
});
|
|
18749
|
-
};
|
|
18750
|
-
|
|
18751
|
-
// src/hooks/thor/logs/logUtils.ts
|
|
18752
|
-
var MAX_EVENTS_PER_QUERY = 1e3;
|
|
18753
|
-
var getEventLogs = async ({
|
|
18754
|
-
thor,
|
|
18755
|
-
order = "asc",
|
|
18756
|
-
offset = 0,
|
|
18757
|
-
limit = MAX_EVENTS_PER_QUERY,
|
|
18758
|
-
from = 0,
|
|
18759
|
-
to = thor.blocks.getHeadBlock()?.number,
|
|
18760
|
-
filterCriteria
|
|
18761
|
-
}) => {
|
|
18762
|
-
const response = await thor.logs.filterEventLogs({
|
|
18763
|
-
range: {
|
|
18764
|
-
from,
|
|
18765
|
-
to,
|
|
18766
|
-
unit: "block"
|
|
18767
|
-
},
|
|
18768
|
-
options: {
|
|
18769
|
-
offset,
|
|
18770
|
-
limit
|
|
18771
|
-
},
|
|
18772
|
-
order,
|
|
18773
|
-
criteriaSet: filterCriteria
|
|
18774
|
-
});
|
|
18775
|
-
if (!response) throw new Error("Failed to fetch events");
|
|
18776
|
-
return response;
|
|
17874
|
+
if (!response) throw new Error("Failed to fetch events");
|
|
17875
|
+
return response;
|
|
18777
17876
|
};
|
|
18778
17877
|
var getAllEventLogs = async ({
|
|
18779
17878
|
nodeUrl,
|
|
@@ -19168,16 +18267,14 @@ var AddressDisplayCard = ({
|
|
|
19168
18267
|
}) => {
|
|
19169
18268
|
const { darkMode: isDark } = useVeChainKitConfig();
|
|
19170
18269
|
const { t } = useTranslation();
|
|
19171
|
-
const { isLoading: totalBalanceLoading } = useTotalBalance({
|
|
19172
|
-
|
|
19173
|
-
});
|
|
19174
|
-
const { tokens: tokens2, isLoading: tokensLoading } = useTokensWithValues({
|
|
18270
|
+
const { isLoading: totalBalanceLoading } = useTotalBalance({ address });
|
|
18271
|
+
const { tokens, isLoading: tokensLoading } = useTokensWithValues({
|
|
19175
18272
|
address
|
|
19176
18273
|
});
|
|
19177
18274
|
const tokenData = useMemo(() => {
|
|
19178
18275
|
if (!tokenAddress) return null;
|
|
19179
|
-
return
|
|
19180
|
-
}, [
|
|
18276
|
+
return tokens.find((token) => token.address === tokenAddress);
|
|
18277
|
+
}, [tokens, tokenAddress]);
|
|
19181
18278
|
const displayBalance = useMemo(() => {
|
|
19182
18279
|
if (balance !== void 0) return balance;
|
|
19183
18280
|
if (tokenData) {
|
|
@@ -20447,7 +19544,7 @@ var useVeChainKitConfig = () => {
|
|
|
20447
19544
|
var validateConfig = (props) => {
|
|
20448
19545
|
const errors = [];
|
|
20449
19546
|
const requiresFeeDelegation = props.privy !== void 0 || props.loginMethods?.some(
|
|
20450
|
-
(
|
|
19547
|
+
(method7) => method7.method === "vechain" || method7.method === "ecosystem"
|
|
20451
19548
|
);
|
|
20452
19549
|
if (requiresFeeDelegation) {
|
|
20453
19550
|
if (!props.feeDelegation) {
|
|
@@ -20475,7 +19572,7 @@ var validateConfig = (props) => {
|
|
|
20475
19572
|
if (props.loginMethods) {
|
|
20476
19573
|
if (!props.privy) {
|
|
20477
19574
|
const invalidMethods = props.loginMethods.filter(
|
|
20478
|
-
(
|
|
19575
|
+
(method7) => ["email", "google", "passkey", "more"].includes(method7.method)
|
|
20479
19576
|
);
|
|
20480
19577
|
if (invalidMethods.length > 0) {
|
|
20481
19578
|
errors.push(
|
|
@@ -20540,7 +19637,7 @@ var VeChainKitProvider = (props) => {
|
|
|
20540
19637
|
const validatedLoginMethods = loginMethods;
|
|
20541
19638
|
const allowedEcosystemApps = useMemo(() => {
|
|
20542
19639
|
const userEcosystemMethods = validatedLoginMethods?.find(
|
|
20543
|
-
(
|
|
19640
|
+
(method7) => method7.method === "ecosystem"
|
|
20544
19641
|
);
|
|
20545
19642
|
return userEcosystemMethods?.allowedApps ?? DEFAULT_PRIVY_ECOSYSTEM_APPS.map((app) => app.id);
|
|
20546
19643
|
}, [validatedLoginMethods]);
|
|
@@ -20650,8 +19747,8 @@ var VeChainKitProvider = (props) => {
|
|
|
20650
19747
|
"--vdk-color-light-primary-hover": "#f8f8f8",
|
|
20651
19748
|
"--vdk-color-light-primary-active": "#f0f0f0",
|
|
20652
19749
|
"--vdk-color-light-secondary": "white",
|
|
20653
|
-
// Font settings
|
|
20654
|
-
"--vdk-font-family":
|
|
19750
|
+
// Font settings - using system fonts instead of Chakra variables
|
|
19751
|
+
"--vdk-font-family": 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
20655
19752
|
"--vdk-font-size-medium": "14px",
|
|
20656
19753
|
"--vdk-font-size-large": "16px",
|
|
20657
19754
|
"--vdk-font-weight-medium": "500"
|
|
@@ -20956,25 +20053,89 @@ var themeConfig = {
|
|
|
20956
20053
|
Button: buttonTheme,
|
|
20957
20054
|
Popover: popoverTheme
|
|
20958
20055
|
},
|
|
20959
|
-
cssVarPrefix: "
|
|
20056
|
+
cssVarPrefix: "vechain-kit",
|
|
20057
|
+
// consistent naming across all components
|
|
20058
|
+
// COMPLETELY disable global styles to prevent any conflicts
|
|
20059
|
+
styles: {
|
|
20060
|
+
global: () => ({})
|
|
20061
|
+
// empty object = no global styles injected
|
|
20062
|
+
},
|
|
20063
|
+
// only defining the semantic tokens we need, scoped to our components
|
|
20064
|
+
semanticTokens: {
|
|
20065
|
+
colors: {
|
|
20066
|
+
"chakra-body-text": {
|
|
20067
|
+
_light: "#1A202C",
|
|
20068
|
+
_dark: "#F7FAFC"
|
|
20069
|
+
},
|
|
20070
|
+
"chakra-body-bg": {
|
|
20071
|
+
_light: "#FFFFFF",
|
|
20072
|
+
_dark: "#1A202C"
|
|
20073
|
+
},
|
|
20074
|
+
"chakra-border-color": {
|
|
20075
|
+
_light: "#E2E8F0",
|
|
20076
|
+
_dark: "#2D3748"
|
|
20077
|
+
},
|
|
20078
|
+
"chakra-placeholder-color": {
|
|
20079
|
+
_light: "#A0AEC0",
|
|
20080
|
+
_dark: "#718096"
|
|
20081
|
+
}
|
|
20082
|
+
}
|
|
20083
|
+
},
|
|
20084
|
+
// minimal foundations to prevent global style injection
|
|
20085
|
+
fonts: theme.fonts,
|
|
20086
|
+
colors: theme.colors,
|
|
20087
|
+
space: theme.space
|
|
20960
20088
|
};
|
|
20961
20089
|
var VechainKitTheme = extendTheme(themeConfig);
|
|
20090
|
+
VechainKitTheme.styles.global = () => ({});
|
|
20091
|
+
if (VechainKitTheme.__cssVars) {
|
|
20092
|
+
VechainKitTheme.__cssVars.global = () => ({});
|
|
20093
|
+
}
|
|
20962
20094
|
var { ToastContainer } = createStandaloneToast();
|
|
20095
|
+
var createVeChainKitCache = () => {
|
|
20096
|
+
return createCache({
|
|
20097
|
+
key: "vechain-kit",
|
|
20098
|
+
// consistent with our layer and class names
|
|
20099
|
+
prepend: true
|
|
20100
|
+
// CSS layers will be handled via Global component injection
|
|
20101
|
+
});
|
|
20102
|
+
};
|
|
20103
|
+
var LayerSetup = () => {
|
|
20104
|
+
return /* @__PURE__ */ jsx(
|
|
20105
|
+
Global,
|
|
20106
|
+
{
|
|
20107
|
+
styles: css`
|
|
20108
|
+
/* define CSS layers with proper priority order */
|
|
20109
|
+
@layer vechain-kit, host-app;
|
|
20110
|
+
|
|
20111
|
+
/* All vechain-kit styles go in the vechain-kit layer */
|
|
20112
|
+
@layer vechain-kit {
|
|
20113
|
+
/* scope all Chakra styles to vechain-kit-root */
|
|
20114
|
+
.vechain-kit-root {
|
|
20115
|
+
/* vechain-kit styles are contained here */
|
|
20116
|
+
}
|
|
20117
|
+
}
|
|
20118
|
+
`
|
|
20119
|
+
}
|
|
20120
|
+
);
|
|
20121
|
+
};
|
|
20963
20122
|
var EnsureChakraProvider = ({
|
|
20964
20123
|
children,
|
|
20965
20124
|
theme
|
|
20966
20125
|
}) => {
|
|
20967
|
-
|
|
20968
|
-
|
|
20969
|
-
|
|
20970
|
-
|
|
20971
|
-
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
20975
|
-
|
|
20976
|
-
|
|
20977
|
-
|
|
20126
|
+
const cache = useMemo(() => createVeChainKitCache(), []);
|
|
20127
|
+
return /* @__PURE__ */ jsxs(CacheProvider, { value: cache, children: [
|
|
20128
|
+
/* @__PURE__ */ jsx(LayerSetup, {}),
|
|
20129
|
+
/* @__PURE__ */ jsx(
|
|
20130
|
+
ChakraProvider,
|
|
20131
|
+
{
|
|
20132
|
+
theme,
|
|
20133
|
+
resetCSS: false,
|
|
20134
|
+
portalZIndex: void 0,
|
|
20135
|
+
children: /* @__PURE__ */ jsx("div", { className: "vechain-kit-root", children })
|
|
20136
|
+
}
|
|
20137
|
+
)
|
|
20138
|
+
] });
|
|
20978
20139
|
};
|
|
20979
20140
|
var EnsureColorModeScript = ({ darkMode }) => {
|
|
20980
20141
|
try {
|
|
@@ -21010,11 +20171,6 @@ var VechainKitThemeProvider = ({
|
|
|
21010
20171
|
] });
|
|
21011
20172
|
};
|
|
21012
20173
|
|
|
21013
|
-
|
|
21014
|
-
BigInt.prototype.toJSON = function() {
|
|
21015
|
-
return { $bigint: this.toString() };
|
|
21016
|
-
};
|
|
21017
|
-
|
|
21018
|
-
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, RoundState, 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, getAllocationsRoundStateQueryKey, getAllocationsRoundsEvents, getAllocationsRoundsEventsQueryKey, getAppHubAppsQueryKey, getAvatar, getAvatarLegacy, getAvatarLegacyQueryKey, getAvatarOfAddressQueryKey, getAvatarQueryKey, getB3trBalance, getB3trBalanceQueryKey, getCallClauseQueryKey, getChainId, getChainIdQueryKey, getCurrentAccountImplementationVersion, getCurrentAccountImplementationVersionQueryKey, getCurrentAllocationsRoundIdQueryKey, getCustomTokenBalance, getCustomTokenBalanceQueryKey, getCustomTokenInfo, getDomainsOfAddress, getDomainsOfAddressQueryKey, getEnsRecordExistsQueryKey, getErc20Balance, getErc20BalanceQueryKey, getEventLogs, getHasV1SmartAccount, getHasV1SmartAccountQueryKey, getHasVotedInRoundQueryKey, getIpfsImage, getIpfsImageQueryKey, getIpfsMetadata, getIpfsMetadataQueryKey, getIsDeployed, getIsDeployedQueryKey, getIsDomainProtectedQueryKey, getIsPersonAtTimepointQueryKey, getIsPersonQueryKey, getPrivyAppInfoQueryKey, getResolverAddressQueryKey, getRoundRewardQueryKey, getRoundXApps, getRoundXAppsQueryKey, getSmartAccount, getSmartAccountQueryKey, getTextRecords, getTextRecordsQueryKey, getTokenInfo, getTokenUsdPrice, getTokenUsdPriceQueryKey, getTokensInfoByOwnerQueryKey, getUpgradeRequired, getUpgradeRequiredForAccount, getUpgradeRequiredForAccountQueryKey, getUpgradeRequiredQueryKey, getUserBotSignalsQueryKey, getUserNodesQueryKey, getUserVotesInRound, getUserVotesInRoundQueryKey, getVeDelegateBalance, getVeDelegateBalanceQueryKey, getVechainDomainQueryKey, getVersion, getVersionQueryKey, getVot3Balance, getVot3BalanceQueryKey, getVotesInRoundQueryKey, getXAppMetadata, getXAppMetadataQueryKey, getXAppRoundEarnings, getXAppRoundEarningsQueryKey, getXAppTotalEarningsQueryKey, getXAppVotesQueryKey, getXApps, getXAppsMetadataBaseUriQueryKey, getXAppsQueryKey, getXAppsSharesQueryKey, imageCompressionOptions, txReceiptQueryKey, useAccessAndSecurityModal, useAccountBalance, useAccountCustomizationModal, useAccountImplementationAddress, useAccountModal, useAllocationsRound, useAllocationsRoundState, useAllocationsRoundsEvents, useAppHubApps, useBuildTransaction, useCallClause, useChooseNameModal, useClaimVeWorldSubdomain, useClaimVetDomain, useConnectModal, useCrossAppConnectionCache, useCurrency, useCurrentAccountImplementationVersion, useCurrentAllocationsRound, useCurrentAllocationsRoundId, useCurrentBlock, useCustomTokens, useEcosystemShortcuts, useEnsRecordExists, useExploreEcosystemModal, useFAQModal, useFeatureAnnouncement, useFetchAppInfo, useFetchPrivyStatus, useGalaxyMemberTokensInfo, useGetAccountAddress, useGetAccountVersion, useGetAvatar, useGetAvatarLegacy, useGetAvatarOfAddress, useGetB3trBalance, useGetChainId, useGetCustomTokenBalances, useGetCustomTokenInfo, useGetDomainsOfAddress, useGetErc20Balance, useGetNodeUrl, useGetResolverAddress, useGetTextRecords, useGetTokenUsdPrice, useGetUserNode, useGetUserNodes, useGetVeDelegateBalance, useGetVot3Balance, useHasV1SmartAccount, useHasVotedInRound, useIpfsImage, useIpfsImageList, useIpfsMetadata, useIpfsMetadatas, useIsDomainProtected, useIsPWA, useIsPerson, useIsPersonAtTimepoint, useIsSmartAccountDeployed, useIsUserPerson, useLegalDocuments, useLocalStorage, useLoginModalContent, useLoginWithOAuth2 as useLoginWithOAuth, useLoginWithPasskey, useLoginWithVeChain, useMostVotedAppsInRound, useMultipleXAppRoundEarnings, useNotificationAlerts, useNotifications, useNotificationsModal, usePrivyWalletProvider, useProfileModal, useReceiveModal, useRefreshBalances, useRefreshFactoryQueries, useRefreshMetadata, useRefreshSmartAccountQueries, useRoundReward, useRoundXApps, useScrollToTop, useSendTokenModal, useSendTransaction, useSignMessage2 as useSignMessage, useSignTypedData2 as useSignTypedData, useSingleImageUpload, useSmartAccount, useSmartAccountVersion, useSyncableLocalStorage, useTokenBalances, useTokenBalances2, useTokenPrices, useTokenPrices2, useTokensWithValues, useTotalBalance, useTransactionModal, useTransactionToast, useTransferERC20, useTransferVET, useTxReceipt, useUnsetDomain, useUpdateTextRecord, useUpgradeRequired, useUpgradeRequiredForAccount, useUpgradeSmartAccount, useUpgradeSmartAccountModal, useUploadImages, useUserBotSignals, useUserVotesInRound, useVeChainKitConfig, useVechainDomain, useVotesInRound, useVotingRewards, useWallet, useWalletMetadata, useWalletModal2 as useWalletModal, useXApp, useXAppMetadata, useXAppRoundEarnings, useXAppTotalEarnings, useXAppVotes, useXApps, useXAppsMetadataBaseUri, useXAppsShares };
|
|
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 };
|
|
21019
20175
|
//# sourceMappingURL=index.js.map
|
|
21020
20176
|
//# sourceMappingURL=index.js.map
|