@vechain/vechain-kit 2.0.0-rc.3 → 2.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +433 -1426
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +182 -1292
- package/dist/index.d.ts +182 -1292
- package/dist/index.js +440 -1384
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/{thorUtils-BOhp47ZG.d.cts → thorUtils-BlZ9nLeD.d.cts} +1 -1
- package/dist/{thorUtils-BOhp47ZG.d.ts → thorUtils-BlZ9nLeD.d.ts} +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,10 +23,11 @@ var ethers = require('ethers');
|
|
|
23
23
|
var sdkCore = require('@vechain/sdk-core');
|
|
24
24
|
var viem = require('viem');
|
|
25
25
|
var zod = require('zod');
|
|
26
|
+
var bignumber_js = require('bignumber.js');
|
|
26
27
|
var wagmi = require('wagmi');
|
|
27
28
|
var rainbowKit = require('@privy-io/cross-app-connect/rainbow-kit');
|
|
28
29
|
var reactDeviceDetect = require('react-device-detect');
|
|
29
|
-
var
|
|
30
|
+
var axios = require('axios');
|
|
30
31
|
var imageCompression = require('browser-image-compression');
|
|
31
32
|
var lu = require('react-icons/lu');
|
|
32
33
|
var md = require('react-icons/md');
|
|
@@ -58,7 +59,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
58
59
|
var i18n__default = /*#__PURE__*/_interopDefault(i18n);
|
|
59
60
|
var React10__default = /*#__PURE__*/_interopDefault(React10);
|
|
60
61
|
var VeChainKitMixpanel__default = /*#__PURE__*/_interopDefault(VeChainKitMixpanel);
|
|
61
|
-
var
|
|
62
|
+
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
62
63
|
var imageCompression__default = /*#__PURE__*/_interopDefault(imageCompression);
|
|
63
64
|
var createCache__default = /*#__PURE__*/_interopDefault(createCache);
|
|
64
65
|
|
|
@@ -4361,15 +4362,15 @@ var Analytics = {
|
|
|
4361
4362
|
loginMethod
|
|
4362
4363
|
});
|
|
4363
4364
|
},
|
|
4364
|
-
tryAgain: (
|
|
4365
|
+
tryAgain: (method7, platform) => {
|
|
4365
4366
|
Analytics.auth.trackAuth("try_again", {
|
|
4366
|
-
loginMethod:
|
|
4367
|
+
loginMethod: method7,
|
|
4367
4368
|
platform
|
|
4368
4369
|
});
|
|
4369
4370
|
},
|
|
4370
|
-
methodSelected: (
|
|
4371
|
+
methodSelected: (method7) => {
|
|
4371
4372
|
Analytics.auth.trackAuth("method_selected", {
|
|
4372
|
-
loginMethod:
|
|
4373
|
+
loginMethod: method7
|
|
4373
4374
|
});
|
|
4374
4375
|
},
|
|
4375
4376
|
completed: ({
|
|
@@ -4824,7 +4825,7 @@ var AddressDisplay = ({
|
|
|
4824
4825
|
|
|
4825
4826
|
// package.json
|
|
4826
4827
|
var package_default = {
|
|
4827
|
-
version: "2.0.0-rc.
|
|
4828
|
+
version: "2.0.0-rc.4"};
|
|
4828
4829
|
var VersionFooter = ({ ...props }) => {
|
|
4829
4830
|
const { darkMode: isDark } = useVeChainKitConfig();
|
|
4830
4831
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -6127,13 +6128,13 @@ var useUnsetDomain = ({
|
|
|
6127
6128
|
}
|
|
6128
6129
|
};
|
|
6129
6130
|
};
|
|
6130
|
-
var useTokenBalances = (
|
|
6131
|
+
var useTokenBalances = (address) => {
|
|
6131
6132
|
const { network } = useVeChainKitConfig();
|
|
6132
6133
|
const config = chunkLMX37RCG_cjs.getConfig(network.type);
|
|
6133
6134
|
const { data: vetData, isLoading: vetLoading } = useAccountBalance(address);
|
|
6134
6135
|
const { data: b3trBalance, isLoading: b3trLoading } = useGetB3trBalance(address);
|
|
6135
6136
|
const { data: vot3Balance, isLoading: vot3Loading } = useGetVot3Balance(address);
|
|
6136
|
-
const { data: veDelegateBalance, isLoading: veDelegateLoading } =
|
|
6137
|
+
const { data: veDelegateBalance, isLoading: veDelegateLoading } = useGetErc20Balance(config.veDelegateTokenContractAddress, address);
|
|
6137
6138
|
const { data: gloDollarBalance, isLoading: gloDollarLoading } = useGetErc20Balance(config.gloDollarContractAddress, address);
|
|
6138
6139
|
const customTokenBalancesQueries = useGetCustomTokenBalances(address);
|
|
6139
6140
|
const customTokenBalances = customTokenBalancesQueries.map((query) => query.data).filter(Boolean);
|
|
@@ -6206,6 +6207,36 @@ var useTokenBalances = ({ address = "" }) => {
|
|
|
6206
6207
|
isLoading
|
|
6207
6208
|
};
|
|
6208
6209
|
};
|
|
6210
|
+
var PRICE_FEED_IDS = {
|
|
6211
|
+
B3TR: "0x623374722d757364000000000000000000000000000000000000000000000000",
|
|
6212
|
+
VET: "0x7665742d75736400000000000000000000000000000000000000000000000000",
|
|
6213
|
+
VTHO: "0x7674686f2d757364000000000000000000000000000000000000000000000000",
|
|
6214
|
+
GBP: "0x6762702d75736400000000000000000000000000000000000000000000000000",
|
|
6215
|
+
EUR: "0x657572742d757364000000000000000000000000000000000000000000000000"
|
|
6216
|
+
};
|
|
6217
|
+
var getTokenUsdPrice = async (thor, token, network) => {
|
|
6218
|
+
const res = await thor.contracts.load(
|
|
6219
|
+
chunkLMX37RCG_cjs.getConfig(network).oracleContractAddress,
|
|
6220
|
+
chunk5GZ7N47F_cjs.IVechainEnergyOracleV1__factory.abi
|
|
6221
|
+
).read.getLatestValue(PRICE_FEED_IDS[token]);
|
|
6222
|
+
if (!res) throw new Error(`Failed to get price of ${token}`);
|
|
6223
|
+
return new bignumber_js.BigNumber(res[0].toString()).div(1e12).toNumber();
|
|
6224
|
+
};
|
|
6225
|
+
var getTokenUsdPriceQueryKey = (token) => [
|
|
6226
|
+
"VECHAIN_KIT_PRICE",
|
|
6227
|
+
token
|
|
6228
|
+
];
|
|
6229
|
+
var useGetTokenUsdPrice = (token) => {
|
|
6230
|
+
const thor = dappKitReact.useThor();
|
|
6231
|
+
const { network } = useVeChainKitConfig();
|
|
6232
|
+
return reactQuery.useQuery({
|
|
6233
|
+
queryKey: getTokenUsdPriceQueryKey(token),
|
|
6234
|
+
queryFn: async () => getTokenUsdPrice(thor, token, network.type),
|
|
6235
|
+
enabled: !!thor && !!network.type
|
|
6236
|
+
});
|
|
6237
|
+
};
|
|
6238
|
+
|
|
6239
|
+
// src/hooks/api/wallet/useTokenPrices.ts
|
|
6209
6240
|
var useTokenPrices = () => {
|
|
6210
6241
|
const { network } = useVeChainKitConfig();
|
|
6211
6242
|
const config = chunkLMX37RCG_cjs.getConfig(network.type);
|
|
@@ -6295,9 +6326,7 @@ var useCurrency = () => {
|
|
|
6295
6326
|
var useTokensWithValues = ({
|
|
6296
6327
|
address = ""
|
|
6297
6328
|
}) => {
|
|
6298
|
-
const { balances, isLoading: balancesLoading } = useTokenBalances(
|
|
6299
|
-
address
|
|
6300
|
-
});
|
|
6329
|
+
const { balances, isLoading: balancesLoading } = useTokenBalances(address);
|
|
6301
6330
|
const {
|
|
6302
6331
|
prices,
|
|
6303
6332
|
exchangeRates,
|
|
@@ -6366,6 +6395,60 @@ var useTotalBalance = ({ address = "" }) => {
|
|
|
6366
6395
|
hasAnyBalance: tokensWithBalance.length > 0
|
|
6367
6396
|
};
|
|
6368
6397
|
};
|
|
6398
|
+
|
|
6399
|
+
// src/hooks/api/wallet/useCurrentAllocationsRoundId.ts
|
|
6400
|
+
var abi = chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi;
|
|
6401
|
+
var method = "currentRoundId";
|
|
6402
|
+
var getCurrentAllocationsRoundIdQueryKey = (address) => getCallClauseQueryKey({ abi, address, method });
|
|
6403
|
+
var useCurrentAllocationsRoundId = () => {
|
|
6404
|
+
const { network } = useVeChainKitConfig();
|
|
6405
|
+
const address = chunkLMX37RCG_cjs.getConfig(network.type).xAllocationVotingContractAddress;
|
|
6406
|
+
return useCallClause({
|
|
6407
|
+
abi,
|
|
6408
|
+
address,
|
|
6409
|
+
method,
|
|
6410
|
+
args: [],
|
|
6411
|
+
queryOptions: {
|
|
6412
|
+
select: (data) => data[0].toString()
|
|
6413
|
+
}
|
|
6414
|
+
});
|
|
6415
|
+
};
|
|
6416
|
+
var getTokenInfo = async (thor, tokenAddress) => {
|
|
6417
|
+
if (!tokenAddress) throw new Error("Token address is required");
|
|
6418
|
+
const contract = thor.contracts.load(tokenAddress, chunk5GZ7N47F_cjs.ERC20__factory.abi);
|
|
6419
|
+
const response = await thor.contracts.executeMultipleClausesCall([
|
|
6420
|
+
contract.clause.name(),
|
|
6421
|
+
contract.clause.symbol(),
|
|
6422
|
+
contract.clause.decimals()
|
|
6423
|
+
]);
|
|
6424
|
+
if (response.every((r) => r.success) === false) {
|
|
6425
|
+
throw new Error(`Failed to get token info of ${tokenAddress}`);
|
|
6426
|
+
}
|
|
6427
|
+
const [name, symbol, decimals] = response.map((res) => {
|
|
6428
|
+
return res.result.array?.[0];
|
|
6429
|
+
});
|
|
6430
|
+
return {
|
|
6431
|
+
name,
|
|
6432
|
+
address: tokenAddress,
|
|
6433
|
+
decimals,
|
|
6434
|
+
symbol
|
|
6435
|
+
};
|
|
6436
|
+
};
|
|
6437
|
+
var getCustomTokenInfo = (tokenAddress) => [
|
|
6438
|
+
"VECHAIN_KIT_CUSTOM_TOKEN_BALANCE",
|
|
6439
|
+
tokenAddress
|
|
6440
|
+
];
|
|
6441
|
+
var useGetCustomTokenInfo = (tokenAddress) => {
|
|
6442
|
+
const thor = dappKitReact.useThor();
|
|
6443
|
+
const { network } = useVeChainKitConfig();
|
|
6444
|
+
return reactQuery.useQuery({
|
|
6445
|
+
queryKey: getCustomTokenInfo(tokenAddress),
|
|
6446
|
+
queryFn: async () => getTokenInfo(thor, tokenAddress),
|
|
6447
|
+
enabled: !!thor && !!network.type && !!tokenAddress
|
|
6448
|
+
});
|
|
6449
|
+
};
|
|
6450
|
+
|
|
6451
|
+
// src/hooks/api/wallet/useCustomTokens.ts
|
|
6369
6452
|
var useCustomTokens = () => {
|
|
6370
6453
|
const [customTokens, setCustomTokens] = useLocalStorage(
|
|
6371
6454
|
"vechain_kit_custom_tokens" /* CUSTOM_TOKENS */,
|
|
@@ -6412,6 +6495,223 @@ var useCustomTokens = () => {
|
|
|
6412
6495
|
isDefaultToken
|
|
6413
6496
|
};
|
|
6414
6497
|
};
|
|
6498
|
+
var getB3trBalance = async (thor, network, address) => {
|
|
6499
|
+
const res = await thor.contracts.load(chunkLMX37RCG_cjs.getConfig(network).b3trContractAddress, chunk5GZ7N47F_cjs.B3TR__factory.abi).read.balanceOf(address);
|
|
6500
|
+
if (!res) throw new Error("Failed to get b3tr balance");
|
|
6501
|
+
const original = res[0].toString();
|
|
6502
|
+
const scaled = ethers.formatEther(original);
|
|
6503
|
+
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
6504
|
+
return {
|
|
6505
|
+
original,
|
|
6506
|
+
scaled,
|
|
6507
|
+
formatted
|
|
6508
|
+
};
|
|
6509
|
+
};
|
|
6510
|
+
var getB3trBalanceQueryKey = (address) => [
|
|
6511
|
+
"VEBETTERDAO_BALANCE",
|
|
6512
|
+
address,
|
|
6513
|
+
"B3TR"
|
|
6514
|
+
];
|
|
6515
|
+
var useGetB3trBalance = (address) => {
|
|
6516
|
+
const thor = dappKitReact.useThor();
|
|
6517
|
+
const { network } = useVeChainKitConfig();
|
|
6518
|
+
return reactQuery.useQuery({
|
|
6519
|
+
queryKey: getB3trBalanceQueryKey(address),
|
|
6520
|
+
queryFn: async () => getB3trBalance(thor, network.type, address),
|
|
6521
|
+
enabled: !!thor && !!address && !!network.type
|
|
6522
|
+
});
|
|
6523
|
+
};
|
|
6524
|
+
var getCustomTokenBalance = async (thor, token, address) => {
|
|
6525
|
+
const res = await thor.contracts.load(token.address, chunk5GZ7N47F_cjs.ERC20__factory.abi).read.balanceOf([address]);
|
|
6526
|
+
if (!res) throw new Error(`Failed to get balance of ${token.address}`);
|
|
6527
|
+
const original = res[0];
|
|
6528
|
+
const scaled = viem.formatEther(BigInt(original));
|
|
6529
|
+
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
6530
|
+
return {
|
|
6531
|
+
...token,
|
|
6532
|
+
original: original.toString(),
|
|
6533
|
+
scaled,
|
|
6534
|
+
formatted
|
|
6535
|
+
};
|
|
6536
|
+
};
|
|
6537
|
+
var getCustomTokenBalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT_BALANCE", address, "CUSTOM_TOKEN", tokenAddress];
|
|
6538
|
+
var useGetCustomTokenBalances = (address) => {
|
|
6539
|
+
const thor = dappKitReact.useThor();
|
|
6540
|
+
const { customTokens } = useCustomTokens();
|
|
6541
|
+
return reactQuery.useQueries({
|
|
6542
|
+
queries: customTokens.map((token) => ({
|
|
6543
|
+
queryKey: getCustomTokenBalanceQueryKey(token.address, address),
|
|
6544
|
+
queryFn: async () => {
|
|
6545
|
+
return await getCustomTokenBalance(thor, token, address);
|
|
6546
|
+
}
|
|
6547
|
+
}))
|
|
6548
|
+
});
|
|
6549
|
+
};
|
|
6550
|
+
var getErc20Balance = async (thor, tokenAddress, address) => {
|
|
6551
|
+
if (!tokenAddress || !address) {
|
|
6552
|
+
throw new Error("Token address and user address are required");
|
|
6553
|
+
}
|
|
6554
|
+
const res = await thor.contracts.load(tokenAddress, chunk5GZ7N47F_cjs.IERC20__factory.abi).read.balanceOf(address);
|
|
6555
|
+
if (!res) throw new Error(`Failed to get balance of ${tokenAddress}`);
|
|
6556
|
+
const original = res[0].toString();
|
|
6557
|
+
const scaled = ethers.formatEther(original);
|
|
6558
|
+
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
6559
|
+
return {
|
|
6560
|
+
original,
|
|
6561
|
+
scaled,
|
|
6562
|
+
formatted
|
|
6563
|
+
};
|
|
6564
|
+
};
|
|
6565
|
+
var getErc20BalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT", "BALANCE", "ERC20", tokenAddress, address];
|
|
6566
|
+
var useGetErc20Balance = (tokenAddress, address) => {
|
|
6567
|
+
const thor = dappKitReact.useThor();
|
|
6568
|
+
return reactQuery.useQuery({
|
|
6569
|
+
queryKey: getErc20BalanceQueryKey(tokenAddress, address),
|
|
6570
|
+
queryFn: async () => getErc20Balance(thor, tokenAddress, address),
|
|
6571
|
+
enabled: !!thor && !!address && !!tokenAddress
|
|
6572
|
+
});
|
|
6573
|
+
};
|
|
6574
|
+
var getVot3Balance = async (thor, network, address) => {
|
|
6575
|
+
const res = await thor.contracts.load(chunkLMX37RCG_cjs.getConfig(network).vot3ContractAddress, chunk5GZ7N47F_cjs.IVOT3__factory.abi).read.balanceOf(address);
|
|
6576
|
+
if (!res) throw new Error("Reverted");
|
|
6577
|
+
const original = res[0].toString();
|
|
6578
|
+
const scaled = ethers.formatEther(original);
|
|
6579
|
+
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
6580
|
+
return {
|
|
6581
|
+
original,
|
|
6582
|
+
scaled,
|
|
6583
|
+
formatted
|
|
6584
|
+
};
|
|
6585
|
+
};
|
|
6586
|
+
var getVot3BalanceQueryKey = (address) => [
|
|
6587
|
+
"VEBETTERDAO_BALANCE",
|
|
6588
|
+
address,
|
|
6589
|
+
"VOT3"
|
|
6590
|
+
];
|
|
6591
|
+
var useGetVot3Balance = (address) => {
|
|
6592
|
+
const thor = dappKitReact.useThor();
|
|
6593
|
+
const { network } = useVeChainKitConfig();
|
|
6594
|
+
return reactQuery.useQuery({
|
|
6595
|
+
queryKey: getVot3BalanceQueryKey(address),
|
|
6596
|
+
queryFn: async () => getVot3Balance(thor, network.type, address),
|
|
6597
|
+
enabled: !!thor && !!address && !!network.type
|
|
6598
|
+
});
|
|
6599
|
+
};
|
|
6600
|
+
|
|
6601
|
+
// src/hooks/api/wallet/useIsPerson.ts
|
|
6602
|
+
var abi2 = chunk5GZ7N47F_cjs.VeBetterPassport__factory.abi;
|
|
6603
|
+
var method2 = "isPerson";
|
|
6604
|
+
var getIsPersonQueryKey = (user, network) => {
|
|
6605
|
+
const address = chunkLMX37RCG_cjs.getConfig(network).veBetterPassportContractAddress;
|
|
6606
|
+
return getCallClauseQueryKeyWithArgs({
|
|
6607
|
+
abi: abi2,
|
|
6608
|
+
address,
|
|
6609
|
+
method: method2,
|
|
6610
|
+
args: [user]
|
|
6611
|
+
});
|
|
6612
|
+
};
|
|
6613
|
+
var useIsPerson = (user) => {
|
|
6614
|
+
const { network } = useVeChainKitConfig();
|
|
6615
|
+
const address = chunkLMX37RCG_cjs.getConfig(network.type).veBetterPassportContractAddress;
|
|
6616
|
+
return useCallClause({
|
|
6617
|
+
abi: abi2,
|
|
6618
|
+
address,
|
|
6619
|
+
method: method2,
|
|
6620
|
+
args: [user ?? "0x"],
|
|
6621
|
+
queryOptions: {
|
|
6622
|
+
enabled: !!user,
|
|
6623
|
+
select: (data) => data[0]
|
|
6624
|
+
}
|
|
6625
|
+
});
|
|
6626
|
+
};
|
|
6627
|
+
|
|
6628
|
+
// src/hooks/api/wallet/useRoundXApps.ts
|
|
6629
|
+
var abi3 = chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi;
|
|
6630
|
+
var method3 = "getAppsOfRound";
|
|
6631
|
+
var getRoundXAppsQueryKey = (roundId, networkType) => getCallClauseQueryKeyWithArgs({
|
|
6632
|
+
abi: abi3,
|
|
6633
|
+
address: chunkLMX37RCG_cjs.getConfig(networkType).xAllocationVotingContractAddress,
|
|
6634
|
+
method: method3,
|
|
6635
|
+
args: [BigInt(roundId ?? 0)]
|
|
6636
|
+
});
|
|
6637
|
+
var useRoundXApps = (roundId) => {
|
|
6638
|
+
const { network } = useVeChainKitConfig();
|
|
6639
|
+
const address = chunkLMX37RCG_cjs.getConfig(network.type).xAllocationVotingContractAddress;
|
|
6640
|
+
return useCallClause({
|
|
6641
|
+
abi: abi3,
|
|
6642
|
+
address,
|
|
6643
|
+
method: method3,
|
|
6644
|
+
args: [BigInt(roundId ?? 0)],
|
|
6645
|
+
queryOptions: {
|
|
6646
|
+
enabled: !!roundId,
|
|
6647
|
+
select: (data) => data[0].map((app) => ({
|
|
6648
|
+
id: app.id.toString(),
|
|
6649
|
+
teamWalletAddress: app.teamWalletAddress,
|
|
6650
|
+
name: app.name,
|
|
6651
|
+
metadataURI: app.metadataURI,
|
|
6652
|
+
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
6653
|
+
}))
|
|
6654
|
+
}
|
|
6655
|
+
});
|
|
6656
|
+
};
|
|
6657
|
+
var abi4 = chunk5GZ7N47F_cjs.XAllocationPool__factory.abi;
|
|
6658
|
+
var method4 = "getAppShares";
|
|
6659
|
+
var getXAppsSharesQueryKey = (roundId) => [
|
|
6660
|
+
"VECHAIN_KIT",
|
|
6661
|
+
"XApps",
|
|
6662
|
+
"Shares",
|
|
6663
|
+
roundId
|
|
6664
|
+
];
|
|
6665
|
+
var useXAppsShares = (apps, roundId) => {
|
|
6666
|
+
const thor = dappKitReact.useThor();
|
|
6667
|
+
const { network } = useVeChainKitConfig();
|
|
6668
|
+
const address = chunkLMX37RCG_cjs.getConfig(network.type).xAllocationPoolContractAddress;
|
|
6669
|
+
return reactQuery.useQuery({
|
|
6670
|
+
queryKey: getXAppsSharesQueryKey(roundId),
|
|
6671
|
+
queryFn: async () => {
|
|
6672
|
+
const shares = await chunkLMX37RCG_cjs.executeMultipleClausesCall({
|
|
6673
|
+
thor,
|
|
6674
|
+
calls: apps.map(
|
|
6675
|
+
(app) => ({
|
|
6676
|
+
abi: abi4,
|
|
6677
|
+
functionName: method4,
|
|
6678
|
+
address,
|
|
6679
|
+
args: [roundId, app]
|
|
6680
|
+
})
|
|
6681
|
+
)
|
|
6682
|
+
});
|
|
6683
|
+
return shares.map((share, index) => {
|
|
6684
|
+
return {
|
|
6685
|
+
app: apps[index],
|
|
6686
|
+
share: Number(share[0] || 0) / 100,
|
|
6687
|
+
unallocatedShare: Number(share[1] || 0) / 100
|
|
6688
|
+
};
|
|
6689
|
+
});
|
|
6690
|
+
},
|
|
6691
|
+
enabled: !!roundId && !!apps.length
|
|
6692
|
+
});
|
|
6693
|
+
};
|
|
6694
|
+
|
|
6695
|
+
// src/hooks/api/wallet/useMostVotedAppsInRound.ts
|
|
6696
|
+
var useMostVotedAppsInRound = (roundId) => {
|
|
6697
|
+
const { data: apps } = useRoundXApps(roundId);
|
|
6698
|
+
const xAppsShares = useXAppsShares(
|
|
6699
|
+
apps?.map((app) => app.id) ?? [],
|
|
6700
|
+
roundId
|
|
6701
|
+
);
|
|
6702
|
+
const mostVotedApps = React10.useMemo(
|
|
6703
|
+
() => xAppsShares.data?.map((appShares) => ({
|
|
6704
|
+
percentage: appShares.share + appShares.unallocatedShare,
|
|
6705
|
+
id: apps?.find((xa) => xa.id === appShares.app)?.id ?? "",
|
|
6706
|
+
app: apps?.find((xa) => xa.id === appShares.app) ?? {}
|
|
6707
|
+
})).sort((a, b) => Number(b.percentage) - Number(a.percentage)) ?? [],
|
|
6708
|
+
[xAppsShares.data, apps]
|
|
6709
|
+
);
|
|
6710
|
+
return {
|
|
6711
|
+
data: mostVotedApps,
|
|
6712
|
+
isLoading: xAppsShares.isLoading
|
|
6713
|
+
};
|
|
6714
|
+
};
|
|
6415
6715
|
var handlePopupError = ({
|
|
6416
6716
|
error,
|
|
6417
6717
|
mobileBrowserPopupMessage = "Mobile browser blocked the window. Please try again.",
|
|
@@ -6744,170 +7044,30 @@ var useRefreshBalances = () => {
|
|
|
6744
7044
|
};
|
|
6745
7045
|
return { refresh };
|
|
6746
7046
|
};
|
|
6747
|
-
var
|
|
6748
|
-
const
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
chunk5GZ7N47F_cjs.IERC20__factory.abi
|
|
6752
|
-
);
|
|
6753
|
-
return erc20Contract.clause.balanceOf([address]);
|
|
6754
|
-
});
|
|
6755
|
-
const response = await thor.contracts.executeMultipleClausesCall(clauses);
|
|
6756
|
-
if (!response.every((r) => r.success && !!r.result.plain)) {
|
|
6757
|
-
throw new Error("Failed to get custom token balances");
|
|
6758
|
-
}
|
|
6759
|
-
return response.map((r, index) => {
|
|
6760
|
-
const token = customTokens[index];
|
|
6761
|
-
const original = r.result.plain;
|
|
6762
|
-
const scaled = ethers.formatEther(BigInt(original)) || "0";
|
|
6763
|
-
return {
|
|
6764
|
-
address: token.address,
|
|
6765
|
-
symbol: token.symbol,
|
|
6766
|
-
balance: scaled
|
|
6767
|
-
};
|
|
6768
|
-
});
|
|
6769
|
-
};
|
|
6770
|
-
var getTokenBalances = async (thor, address, network) => {
|
|
6771
|
-
const config = chunkLMX37RCG_cjs.getConfig(network);
|
|
6772
|
-
const [b3trBalance, vot3Balance, veDelegateBalance, gloDollarBalance] = await chunkLMX37RCG_cjs.executeMultipleClausesCall({
|
|
6773
|
-
thor,
|
|
6774
|
-
calls: [
|
|
6775
|
-
{
|
|
6776
|
-
abi: chunk5GZ7N47F_cjs.IB3TR__factory.abi,
|
|
6777
|
-
address: config.b3trContractAddress,
|
|
6778
|
-
functionName: "balanceOf",
|
|
6779
|
-
args: [address]
|
|
6780
|
-
},
|
|
6781
|
-
{
|
|
6782
|
-
abi: chunk5GZ7N47F_cjs.IVOT3__factory.abi,
|
|
6783
|
-
address: config.vot3ContractAddress,
|
|
6784
|
-
functionName: "balanceOf",
|
|
6785
|
-
args: [address]
|
|
6786
|
-
},
|
|
6787
|
-
{
|
|
6788
|
-
abi: chunk5GZ7N47F_cjs.IERC20__factory.abi,
|
|
6789
|
-
address: config.veDelegate,
|
|
6790
|
-
functionName: "balanceOf",
|
|
6791
|
-
args: [address]
|
|
6792
|
-
},
|
|
6793
|
-
{
|
|
6794
|
-
abi: chunk5GZ7N47F_cjs.IERC20__factory.abi,
|
|
6795
|
-
address: config.gloDollarContractAddress,
|
|
6796
|
-
functionName: "balanceOf",
|
|
6797
|
-
args: [address]
|
|
6798
|
-
}
|
|
6799
|
-
]
|
|
6800
|
-
});
|
|
6801
|
-
const { balance: vetBalance, energy: vthoBalance } = await getAccountBalance(thor, address);
|
|
6802
|
-
return [
|
|
6803
|
-
{
|
|
6804
|
-
address: "0x",
|
|
6805
|
-
symbol: "VET",
|
|
6806
|
-
balance: vetBalance
|
|
6807
|
-
},
|
|
6808
|
-
{
|
|
6809
|
-
address: config.vthoContractAddress,
|
|
6810
|
-
symbol: "VTHO",
|
|
6811
|
-
balance: vthoBalance
|
|
6812
|
-
},
|
|
6813
|
-
{
|
|
6814
|
-
address: config.b3trContractAddress,
|
|
6815
|
-
symbol: "B3TR",
|
|
6816
|
-
balance: b3trBalance
|
|
6817
|
-
},
|
|
6818
|
-
{
|
|
6819
|
-
address: config.vot3ContractAddress,
|
|
6820
|
-
symbol: "VOT3",
|
|
6821
|
-
balance: vot3Balance
|
|
6822
|
-
},
|
|
6823
|
-
{
|
|
6824
|
-
address: config.veDelegate,
|
|
6825
|
-
symbol: "veDelegate",
|
|
6826
|
-
balance: veDelegateBalance
|
|
6827
|
-
},
|
|
6828
|
-
{
|
|
6829
|
-
address: config.gloDollarContractAddress,
|
|
6830
|
-
symbol: "USDGLO",
|
|
6831
|
-
balance: gloDollarBalance
|
|
6832
|
-
}
|
|
6833
|
-
];
|
|
6834
|
-
};
|
|
6835
|
-
var useTokenBalances2 = ({ address }) => {
|
|
6836
|
-
const thor = dappKitReact.useThor();
|
|
6837
|
-
const { network } = useVeChainKitConfig();
|
|
6838
|
-
const { customTokens } = useCustomTokens();
|
|
6839
|
-
return reactQuery.useQueries({
|
|
6840
|
-
queries: [
|
|
6841
|
-
{
|
|
6842
|
-
queryKey: ["base-token-balances", address],
|
|
6843
|
-
queryFn: () => getTokenBalances(thor, address, network.type)
|
|
6844
|
-
},
|
|
6845
|
-
{
|
|
6846
|
-
queryKey: ["custom-token-balances", address],
|
|
6847
|
-
queryFn: () => getCustomTokenBalances(thor, address, customTokens)
|
|
6848
|
-
}
|
|
6849
|
-
],
|
|
6850
|
-
combine: (data) => {
|
|
6851
|
-
return {
|
|
6852
|
-
data: data.flat(),
|
|
6853
|
-
loading: data[0].isLoading || data[1].isLoading,
|
|
6854
|
-
error: data[0].error || data[1].error
|
|
6855
|
-
};
|
|
6856
|
-
}
|
|
6857
|
-
});
|
|
6858
|
-
};
|
|
6859
|
-
var getTokenPrices = async (thor, tokens2, network) => {
|
|
6860
|
-
const config = chunkLMX37RCG_cjs.getConfig(network);
|
|
6861
|
-
const oracleContract = thor.contracts.load(
|
|
6862
|
-
config.oracleContractAddress,
|
|
6863
|
-
chunk5GZ7N47F_cjs.IVechainEnergyOracleV1__factory.abi
|
|
6864
|
-
);
|
|
6865
|
-
const clauses = tokens2.map(
|
|
6866
|
-
(token) => oracleContract.clause.getLatestValue(PRICE_FEED_IDS[token])
|
|
6867
|
-
);
|
|
6868
|
-
const response = await thor.transactions.executeMultipleClausesCall(
|
|
6869
|
-
clauses
|
|
6870
|
-
);
|
|
6871
|
-
if (!response.every((r) => r.success && !!r.result.array)) {
|
|
6872
|
-
throw new Error("Failed to get token prices");
|
|
6873
|
-
}
|
|
6874
|
-
return response.map(
|
|
6875
|
-
(r) => new BigNumber__default.default((r.result.array?.[0] ?? 0).toString()).div(1e12).toNumber()
|
|
7047
|
+
var getXAppMetadata = async (uri, networkType) => {
|
|
7048
|
+
const metadata = await axios__default.default.get(
|
|
7049
|
+
chunkLMX37RCG_cjs.convertUriToUrl(uri, networkType) || "",
|
|
7050
|
+
{ timeout: 2e4 }
|
|
6876
7051
|
);
|
|
7052
|
+
return metadata.data;
|
|
6877
7053
|
};
|
|
6878
|
-
var
|
|
6879
|
-
var
|
|
7054
|
+
var abi5 = chunk5GZ7N47F_cjs.X2EarnApps__factory.abi;
|
|
7055
|
+
var useXAppMetadata = (xAppId) => {
|
|
6880
7056
|
const thor = dappKitReact.useThor();
|
|
6881
7057
|
const { network } = useVeChainKitConfig();
|
|
6882
|
-
const config = chunkLMX37RCG_cjs.getConfig(network.type);
|
|
6883
7058
|
return reactQuery.useQuery({
|
|
6884
|
-
queryKey: ["
|
|
6885
|
-
queryFn: () =>
|
|
6886
|
-
|
|
6887
|
-
const
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
[config.vthoContractAddress]: vthoUsdPrice || 0,
|
|
6897
|
-
[config.b3trContractAddress]: b3trUsdPrice || 0,
|
|
6898
|
-
[config.vot3ContractAddress]: b3trUsdPrice || 0,
|
|
6899
|
-
[config.veDelegate]: b3trUsdPrice || 0,
|
|
6900
|
-
[config.gloDollarContractAddress]: 1
|
|
6901
|
-
// GloDollar is pegged to USD
|
|
6902
|
-
};
|
|
6903
|
-
const exchangeRates = {
|
|
6904
|
-
eurUsdPrice: eurUsdPrice || 1,
|
|
6905
|
-
gbpUsdPrice: gbpUsdPrice || 1
|
|
6906
|
-
};
|
|
6907
|
-
return {
|
|
6908
|
-
prices,
|
|
6909
|
-
exchangeRates
|
|
6910
|
-
};
|
|
7059
|
+
queryKey: ["xAppMetaData", xAppId],
|
|
7060
|
+
queryFn: async () => {
|
|
7061
|
+
const address = chunkLMX37RCG_cjs.getConfig(network.type).x2EarnAppsContractAddress;
|
|
7062
|
+
const contract = thor.contracts.load(address, abi5);
|
|
7063
|
+
const [app] = await contract.read.app(xAppId);
|
|
7064
|
+
const metadataURI = app?.[3] || "";
|
|
7065
|
+
const [baseUri] = await contract.read.baseURI();
|
|
7066
|
+
const metadata = await getXAppMetadata(
|
|
7067
|
+
`${baseUri}${metadataURI}`,
|
|
7068
|
+
network.type
|
|
7069
|
+
);
|
|
7070
|
+
return metadata;
|
|
6911
7071
|
}
|
|
6912
7072
|
});
|
|
6913
7073
|
};
|
|
@@ -7626,8 +7786,8 @@ var ConnectionOptionsStack = () => {
|
|
|
7626
7786
|
showMoreLogin,
|
|
7627
7787
|
isOfficialVeChainApp
|
|
7628
7788
|
} = useLoginModalContent();
|
|
7629
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.Stack, { spacing: 4, w: "full", align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(4, 1fr)", gap: 2, w: "full", children: loginMethods?.map(({ method:
|
|
7630
|
-
switch (
|
|
7789
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Stack, { spacing: 4, w: "full", align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(react.Grid, { templateColumns: "repeat(4, 1fr)", gap: 2, w: "full", children: loginMethods?.map(({ method: method7, gridColumn }) => {
|
|
7790
|
+
switch (method7) {
|
|
7631
7791
|
case "email":
|
|
7632
7792
|
return showEmailLogin && /* @__PURE__ */ jsxRuntime.jsx(EmailLoginButton, {}, "email");
|
|
7633
7793
|
case "google":
|
|
@@ -7734,7 +7894,7 @@ var MainContent = ({ setCurrentContent, onClose }) => {
|
|
|
7734
7894
|
}
|
|
7735
7895
|
}, [connection.isConnected, onClose]);
|
|
7736
7896
|
const showEcosystemButton = loginMethods?.some(
|
|
7737
|
-
({ method:
|
|
7897
|
+
({ method: method7 }) => method7 === "ecosystem"
|
|
7738
7898
|
);
|
|
7739
7899
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7740
7900
|
/* @__PURE__ */ jsxRuntime.jsxs(StickyHeaderContainer, { children: [
|
|
@@ -13022,13 +13182,13 @@ var PrivyLinkedAccounts = ({ onBack }) => {
|
|
|
13022
13182
|
} = reactAuth.usePrivy();
|
|
13023
13183
|
const canLinkWallets = React10.useMemo(() => {
|
|
13024
13184
|
const privyWallets = privy?.loginMethods?.filter(
|
|
13025
|
-
(
|
|
13185
|
+
(method7) => [
|
|
13026
13186
|
"rabby_wallet",
|
|
13027
13187
|
"coinbase_wallet",
|
|
13028
13188
|
"rainbow",
|
|
13029
13189
|
"phantom",
|
|
13030
13190
|
"metamask"
|
|
13031
|
-
].includes(
|
|
13191
|
+
].includes(method7)
|
|
13032
13192
|
) ?? [];
|
|
13033
13193
|
const dappKitWallets = dappKit?.allowedWallets ?? [];
|
|
13034
13194
|
return privyWallets.length > 0 || dappKitWallets.length > 0;
|
|
@@ -14172,17 +14332,7 @@ var ExploreEcosystemContent = ({
|
|
|
14172
14332
|
) : [];
|
|
14173
14333
|
const filteredDefaultApps = DEFAULT_APPS.filter(
|
|
14174
14334
|
(dapp) => dapp.name.toLowerCase().includes(searchQuery.toLowerCase())
|
|
14175
|
-
)
|
|
14176
|
-
if (dapp.logoComponent) {
|
|
14177
|
-
return {
|
|
14178
|
-
...dapp,
|
|
14179
|
-
logoComponent: React10__default.default.cloneElement(dapp.logoComponent, {
|
|
14180
|
-
isDark
|
|
14181
|
-
})
|
|
14182
|
-
};
|
|
14183
|
-
}
|
|
14184
|
-
return dapp;
|
|
14185
|
-
});
|
|
14335
|
+
);
|
|
14186
14336
|
const filteredAppHubApps = appHubApps?.filter(
|
|
14187
14337
|
(app) => (
|
|
14188
14338
|
// Text search filter
|
|
@@ -14269,10 +14419,7 @@ var ExploreEcosystemContent = ({
|
|
|
14269
14419
|
url: dapp.external_url,
|
|
14270
14420
|
setCurrentContent,
|
|
14271
14421
|
description: dapp.description,
|
|
14272
|
-
selectedCategory: currentCategory
|
|
14273
|
-
...dapp.logoComponent && {
|
|
14274
|
-
logoComponent: dapp.logoComponent
|
|
14275
|
-
}
|
|
14422
|
+
selectedCategory: currentCategory
|
|
14276
14423
|
}
|
|
14277
14424
|
) }, dapp.name)) }),
|
|
14278
14425
|
shouldShowVbdApps && filteredVbdApps.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: filteredVbdApps.map((dapp) => /* @__PURE__ */ jsxRuntime.jsx(react.GridItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -15021,7 +15168,7 @@ var ConnectPopover = ({
|
|
|
15021
15168
|
privyEcosystemAppIDS
|
|
15022
15169
|
} = useVeChainKitConfig();
|
|
15023
15170
|
const showEcosystemButton = loginMethods?.some(
|
|
15024
|
-
({ method:
|
|
15171
|
+
({ method: method7 }) => method7 === "ecosystem"
|
|
15025
15172
|
);
|
|
15026
15173
|
const { data: appsInfo, isLoading: isEcosystemAppsLoading } = useFetchAppInfo(privyEcosystemAppIDS);
|
|
15027
15174
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -16564,14 +16711,14 @@ var ReceiveModalProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxR
|
|
|
16564
16711
|
var useLoginModalContent = () => {
|
|
16565
16712
|
const { privy, loginMethods } = useVeChainKitConfig();
|
|
16566
16713
|
const isVeChainApp = privy?.appId === chunkLMX37RCG_cjs.VECHAIN_PRIVY_APP_ID;
|
|
16567
|
-
const isLoginMethodEnabled = (
|
|
16714
|
+
const isLoginMethodEnabled = (method7) => {
|
|
16568
16715
|
if (!loginMethods) return true;
|
|
16569
|
-
if (Array.isArray(
|
|
16570
|
-
return
|
|
16716
|
+
if (Array.isArray(method7)) {
|
|
16717
|
+
return method7.some(
|
|
16571
16718
|
(m) => loginMethods.some((lm) => lm.method === m)
|
|
16572
16719
|
);
|
|
16573
16720
|
}
|
|
16574
|
-
return loginMethods.some((lm) => lm.method ===
|
|
16721
|
+
return loginMethods.some((lm) => lm.method === method7);
|
|
16575
16722
|
};
|
|
16576
16723
|
const showEcosystemLogin = React10.useMemo(() => {
|
|
16577
16724
|
if (!loginMethods) return true;
|
|
@@ -16995,24 +17142,24 @@ var getCallClauseQueryKey = ({
|
|
|
16995
17142
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16996
17143
|
abi: abi9,
|
|
16997
17144
|
address,
|
|
16998
|
-
method:
|
|
16999
|
-
}) => ["callClause", address,
|
|
17145
|
+
method: method7
|
|
17146
|
+
}) => ["callClause", address, method7];
|
|
17000
17147
|
var getCallClauseQueryKeyWithArgs = ({
|
|
17001
17148
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17002
17149
|
abi: abi9,
|
|
17003
17150
|
address,
|
|
17004
|
-
method:
|
|
17151
|
+
method: method7,
|
|
17005
17152
|
args
|
|
17006
17153
|
}) => [
|
|
17007
17154
|
"callClause",
|
|
17008
17155
|
address,
|
|
17009
|
-
|
|
17156
|
+
method7,
|
|
17010
17157
|
...args?.length ? [args] : []
|
|
17011
17158
|
];
|
|
17012
17159
|
var useCallClause = ({
|
|
17013
17160
|
address,
|
|
17014
17161
|
abi: abi9,
|
|
17015
|
-
method:
|
|
17162
|
+
method: method7,
|
|
17016
17163
|
args,
|
|
17017
17164
|
queryOptions
|
|
17018
17165
|
}) => {
|
|
@@ -17021,14 +17168,14 @@ var useCallClause = ({
|
|
|
17021
17168
|
queryKey: getCallClauseQueryKeyWithArgs({
|
|
17022
17169
|
abi: abi9,
|
|
17023
17170
|
address,
|
|
17024
|
-
method:
|
|
17171
|
+
method: method7,
|
|
17025
17172
|
args
|
|
17026
17173
|
}),
|
|
17027
17174
|
queryFn: async () => chunkLMX37RCG_cjs.executeCallClause({
|
|
17028
17175
|
thor,
|
|
17029
17176
|
contractAddress: address,
|
|
17030
17177
|
abi: abi9,
|
|
17031
|
-
method:
|
|
17178
|
+
method: method7,
|
|
17032
17179
|
args
|
|
17033
17180
|
}),
|
|
17034
17181
|
...queryOptions
|
|
@@ -17266,9 +17413,9 @@ var useGetAccountAddress = (ownerAddress) => {
|
|
|
17266
17413
|
};
|
|
17267
17414
|
|
|
17268
17415
|
// src/hooks/thor/smartAccounts/useGetAccountVersion.ts
|
|
17269
|
-
var
|
|
17416
|
+
var abi6 = chunk5GZ7N47F_cjs.SimpleAccountFactory__factory.abi;
|
|
17270
17417
|
var getAccountVersionQueryKey = (accountAddress, ownerAddress, networkType) => getCallClauseQueryKeyWithArgs({
|
|
17271
|
-
abi,
|
|
17418
|
+
abi: abi6,
|
|
17272
17419
|
address: chunkLMX37RCG_cjs.getConfig(networkType).accountFactoryAddress,
|
|
17273
17420
|
method: "getAccountVersion",
|
|
17274
17421
|
args: [accountAddress, ownerAddress]
|
|
@@ -17277,7 +17424,7 @@ var useGetAccountVersion = (accountAddress, ownerAddress) => {
|
|
|
17277
17424
|
const { network } = useVeChainKitConfig();
|
|
17278
17425
|
return useCallClause({
|
|
17279
17426
|
address: chunkLMX37RCG_cjs.getConfig(network.type).accountFactoryAddress,
|
|
17280
|
-
abi,
|
|
17427
|
+
abi: abi6,
|
|
17281
17428
|
method: "getAccountVersion",
|
|
17282
17429
|
args: [accountAddress, ownerAddress],
|
|
17283
17430
|
queryOptions: {
|
|
@@ -17290,16 +17437,16 @@ var useGetAccountVersion = (accountAddress, ownerAddress) => {
|
|
|
17290
17437
|
}
|
|
17291
17438
|
});
|
|
17292
17439
|
};
|
|
17293
|
-
var
|
|
17294
|
-
var
|
|
17440
|
+
var abi7 = chunk5GZ7N47F_cjs.SimpleAccountFactory__factory.abi;
|
|
17441
|
+
var method5 = "hasLegacyAccount";
|
|
17295
17442
|
var getHasV1SmartAccount = async (thor, ownerAddress, networkType) => {
|
|
17296
17443
|
if (!ownerAddress) throw new Error("Owner address is required");
|
|
17297
17444
|
if (!networkType) throw new Error("Network type is required");
|
|
17298
17445
|
const [hasLegacyAccount] = await chunkLMX37RCG_cjs.executeCallClause({
|
|
17299
17446
|
thor,
|
|
17300
|
-
abi:
|
|
17447
|
+
abi: abi7,
|
|
17301
17448
|
contractAddress: chunkLMX37RCG_cjs.getConfig(networkType).accountFactoryAddress,
|
|
17302
|
-
method,
|
|
17449
|
+
method: method5,
|
|
17303
17450
|
args: [ownerAddress]
|
|
17304
17451
|
});
|
|
17305
17452
|
return hasLegacyAccount;
|
|
@@ -17510,15 +17657,15 @@ var useSmartAccount = (ownerAddress) => {
|
|
|
17510
17657
|
enabled: !!ownerAddress && !!network.type && !!thor
|
|
17511
17658
|
});
|
|
17512
17659
|
};
|
|
17513
|
-
var
|
|
17514
|
-
var
|
|
17660
|
+
var abi8 = chunk5GZ7N47F_cjs.SimpleAccountFactory__factory.abi;
|
|
17661
|
+
var method6 = "version";
|
|
17515
17662
|
var getVersion = async (thor, contractAddress) => {
|
|
17516
17663
|
if (!contractAddress) throw new Error("Contract address is required");
|
|
17517
17664
|
const [version] = await chunkLMX37RCG_cjs.executeCallClause({
|
|
17518
17665
|
thor,
|
|
17519
17666
|
contractAddress,
|
|
17520
|
-
abi:
|
|
17521
|
-
method:
|
|
17667
|
+
abi: abi8,
|
|
17668
|
+
method: method6,
|
|
17522
17669
|
args: []
|
|
17523
17670
|
});
|
|
17524
17671
|
return Number(version);
|
|
@@ -17706,1165 +17853,76 @@ var useGetChainId = () => {
|
|
|
17706
17853
|
refetchInterval: 1e4
|
|
17707
17854
|
});
|
|
17708
17855
|
};
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
}
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
});
|
|
17734
|
-
};
|
|
17735
|
-
var getCustomTokenBalance = async (thor, token, address) => {
|
|
17736
|
-
const res = await thor.contracts.load(token.address, chunk5GZ7N47F_cjs.ERC20__factory.abi).read.balanceOf([address]);
|
|
17737
|
-
if (!res) throw new Error(`Failed to get balance of ${token.address}`);
|
|
17738
|
-
const original = res[0];
|
|
17739
|
-
const scaled = viem.formatEther(BigInt(original));
|
|
17740
|
-
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
17741
|
-
return {
|
|
17742
|
-
...token,
|
|
17743
|
-
original: original.toString(),
|
|
17744
|
-
scaled,
|
|
17745
|
-
formatted
|
|
17746
|
-
};
|
|
17747
|
-
};
|
|
17748
|
-
var getCustomTokenBalanceQueryKey = (tokenAddress, address) => ["VECHAIN_KIT_BALANCE", address, "CUSTOM_TOKEN", tokenAddress];
|
|
17749
|
-
var useGetCustomTokenBalances = (address) => {
|
|
17750
|
-
const thor = dappKitReact.useThor();
|
|
17751
|
-
const { customTokens } = useCustomTokens();
|
|
17752
|
-
return reactQuery.useQueries({
|
|
17753
|
-
queries: customTokens.map((token) => ({
|
|
17754
|
-
queryKey: getCustomTokenBalanceQueryKey(token.address, address),
|
|
17755
|
-
queryFn: async () => {
|
|
17756
|
-
return await getCustomTokenBalance(thor, token, address);
|
|
17757
|
-
}
|
|
17758
|
-
}))
|
|
17856
|
+
|
|
17857
|
+
// src/hooks/thor/logs/logUtils.ts
|
|
17858
|
+
var MAX_EVENTS_PER_QUERY = 1e3;
|
|
17859
|
+
var getEventLogs = async ({
|
|
17860
|
+
thor,
|
|
17861
|
+
order = "asc",
|
|
17862
|
+
offset = 0,
|
|
17863
|
+
limit = MAX_EVENTS_PER_QUERY,
|
|
17864
|
+
from = 0,
|
|
17865
|
+
to = thor.blocks.getHeadBlock()?.number,
|
|
17866
|
+
filterCriteria
|
|
17867
|
+
}) => {
|
|
17868
|
+
const response = await thor.logs.filterEventLogs({
|
|
17869
|
+
range: {
|
|
17870
|
+
from,
|
|
17871
|
+
to,
|
|
17872
|
+
unit: "block"
|
|
17873
|
+
},
|
|
17874
|
+
options: {
|
|
17875
|
+
offset,
|
|
17876
|
+
limit
|
|
17877
|
+
},
|
|
17878
|
+
order,
|
|
17879
|
+
criteriaSet: filterCriteria
|
|
17759
17880
|
});
|
|
17881
|
+
if (!response) throw new Error("Failed to fetch events");
|
|
17882
|
+
return response;
|
|
17760
17883
|
};
|
|
17761
|
-
var
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17884
|
+
var getAllEventLogs = async ({
|
|
17885
|
+
nodeUrl,
|
|
17886
|
+
thor,
|
|
17887
|
+
order = "asc",
|
|
17888
|
+
from = 0,
|
|
17889
|
+
to,
|
|
17890
|
+
filterCriteria
|
|
17891
|
+
}) => {
|
|
17892
|
+
const allEvents = [];
|
|
17893
|
+
let offset = 0;
|
|
17894
|
+
while (true) {
|
|
17895
|
+
const events = await getEventLogs({
|
|
17896
|
+
thor,
|
|
17897
|
+
filterCriteria,
|
|
17898
|
+
from,
|
|
17899
|
+
to: to ?? Number.MAX_SAFE_INTEGER,
|
|
17900
|
+
limit: MAX_EVENTS_PER_QUERY,
|
|
17901
|
+
order,
|
|
17902
|
+
offset
|
|
17903
|
+
});
|
|
17904
|
+
allEvents.push(...events);
|
|
17905
|
+
if (events.length < MAX_EVENTS_PER_QUERY) {
|
|
17906
|
+
return allEvents;
|
|
17907
|
+
}
|
|
17908
|
+
offset += MAX_EVENTS_PER_QUERY;
|
|
17771
17909
|
}
|
|
17772
|
-
const [name, symbol, decimals] = response.map((res) => {
|
|
17773
|
-
return res.result.array?.[0];
|
|
17774
|
-
});
|
|
17775
|
-
return {
|
|
17776
|
-
name,
|
|
17777
|
-
address: tokenAddress,
|
|
17778
|
-
decimals,
|
|
17779
|
-
symbol
|
|
17780
|
-
};
|
|
17781
|
-
};
|
|
17782
|
-
var getCustomTokenInfo = (tokenAddress) => [
|
|
17783
|
-
"VECHAIN_KIT_CUSTOM_TOKEN_BALANCE",
|
|
17784
|
-
tokenAddress
|
|
17785
|
-
];
|
|
17786
|
-
var useGetCustomTokenInfo = (tokenAddress) => {
|
|
17787
|
-
const thor = dappKitReact.useThor();
|
|
17788
|
-
const { network } = useVeChainKitConfig();
|
|
17789
|
-
return reactQuery.useQuery({
|
|
17790
|
-
queryKey: getCustomTokenInfo(tokenAddress),
|
|
17791
|
-
queryFn: async () => getTokenInfo(thor, tokenAddress),
|
|
17792
|
-
enabled: !!thor && !!network.type && !!tokenAddress
|
|
17793
|
-
});
|
|
17794
17910
|
};
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
const original = res[0].toString();
|
|
17802
|
-
const scaled = ethers.formatEther(original);
|
|
17803
|
-
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
17804
|
-
return {
|
|
17805
|
-
original,
|
|
17806
|
-
scaled,
|
|
17807
|
-
formatted
|
|
17808
|
-
};
|
|
17911
|
+
|
|
17912
|
+
// src/hooks/thor/transactions/transactionUtils.ts
|
|
17913
|
+
var estimateTxGas = async (thor, clauses, caller) => {
|
|
17914
|
+
const response = await thor.transactions.estimateGas(clauses, caller);
|
|
17915
|
+
if (response.reverted) throw new Error("Failed to estimate gas");
|
|
17916
|
+
return response.totalGas;
|
|
17809
17917
|
};
|
|
17810
|
-
var
|
|
17811
|
-
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
};
|
|
17819
|
-
var getVeDelegateBalance = async (thor, network, address) => {
|
|
17820
|
-
const res = await thor.contracts.load(
|
|
17821
|
-
chunkLMX37RCG_cjs.getConfig(network).veDelegateTokenContractAddress,
|
|
17822
|
-
chunk5GZ7N47F_cjs.IERC20__factory.abi
|
|
17823
|
-
).read.balanceOf(address);
|
|
17824
|
-
if (!res)
|
|
17825
|
-
throw new Error(`Failed to get veDelegate balance for ${address}`);
|
|
17826
|
-
const original = res[0].toString();
|
|
17827
|
-
const scaled = ethers.formatEther(original);
|
|
17828
|
-
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
17829
|
-
return {
|
|
17830
|
-
original,
|
|
17831
|
-
scaled,
|
|
17832
|
-
formatted
|
|
17833
|
-
};
|
|
17834
|
-
};
|
|
17835
|
-
var getVeDelegateBalanceQueryKey = (address) => [
|
|
17836
|
-
"VECHAIN_KIT_BALANCE",
|
|
17837
|
-
address,
|
|
17838
|
-
"VE_DELEGATE"
|
|
17839
|
-
];
|
|
17840
|
-
var useGetVeDelegateBalance = (address) => {
|
|
17841
|
-
const thor = dappKitReact.useThor();
|
|
17842
|
-
const { network } = useVeChainKitConfig();
|
|
17843
|
-
return reactQuery.useQuery({
|
|
17844
|
-
queryKey: getVeDelegateBalanceQueryKey(address),
|
|
17845
|
-
queryFn: async () => getVeDelegateBalance(thor, network.type, address),
|
|
17846
|
-
enabled: !!thor && !!address && !!network.type
|
|
17847
|
-
});
|
|
17848
|
-
};
|
|
17849
|
-
var getTokensInfoByOwnerQueryKey = (owner) => [
|
|
17850
|
-
"VECHAIN_KIT_GALAXY_MEMBER_TOKENS_INFO",
|
|
17851
|
-
owner
|
|
17852
|
-
];
|
|
17853
|
-
var useGalaxyMemberTokensInfo = (owner, size = 10) => {
|
|
17854
|
-
const { network } = useVeChainKitConfig();
|
|
17855
|
-
const contractAddress = chunkLMX37RCG_cjs.getConfig(network.type).galaxyMemberContractAddress;
|
|
17856
|
-
const thor = dappKitReact.useThor();
|
|
17857
|
-
const fetchTokens = async ({ pageParam = 0 }) => {
|
|
17858
|
-
const data = await thor.contracts.load(contractAddress, chunk5GZ7N47F_cjs.GalaxyMember__factory.abi).read.getTokensInfoByOwner(owner, pageParam, size);
|
|
17859
|
-
if (!data)
|
|
17860
|
-
throw new Error(
|
|
17861
|
-
`Failed to fetch tokens info for page ${pageParam}`
|
|
17862
|
-
);
|
|
17863
|
-
return { data, nextPage: pageParam + 1 };
|
|
17864
|
-
};
|
|
17865
|
-
return reactQuery.useInfiniteQuery({
|
|
17866
|
-
queryKey: getTokensInfoByOwnerQueryKey(owner),
|
|
17867
|
-
queryFn: fetchTokens,
|
|
17868
|
-
getNextPageParam: (lastPage) => lastPage.data.length === size ? lastPage.nextPage : void 0,
|
|
17869
|
-
enabled: !!owner && !!network.type,
|
|
17870
|
-
initialPageParam: 0
|
|
17871
|
-
});
|
|
17872
|
-
};
|
|
17873
|
-
|
|
17874
|
-
// src/hooks/thor/contracts/NodeManagement/useGetUserNodes.ts
|
|
17875
|
-
var contractAbi = chunk5GZ7N47F_cjs.NodeManagement__factory.abi;
|
|
17876
|
-
var method3 = "getUserNodes";
|
|
17877
|
-
var getUserNodesQueryKey = (networkType, user) => getCallClauseQueryKeyWithArgs({
|
|
17878
|
-
abi: contractAbi,
|
|
17879
|
-
address: chunkLMX37RCG_cjs.getConfig(networkType).nodeManagementContractAddress,
|
|
17880
|
-
method: method3,
|
|
17881
|
-
args: [user]
|
|
17882
|
-
});
|
|
17883
|
-
var useGetUserNodes = (userInput) => {
|
|
17884
|
-
const { network } = useVeChainKitConfig();
|
|
17885
|
-
const contractAddress = chunkLMX37RCG_cjs.getConfig(
|
|
17886
|
-
network.type
|
|
17887
|
-
).nodeManagementContractAddress;
|
|
17888
|
-
return useCallClause({
|
|
17889
|
-
address: contractAddress,
|
|
17890
|
-
abi: contractAbi,
|
|
17891
|
-
method: method3,
|
|
17892
|
-
args: [userInput],
|
|
17893
|
-
queryOptions: {
|
|
17894
|
-
enabled: !!userInput && !!network.type && !!contractAddress,
|
|
17895
|
-
select: (response) => {
|
|
17896
|
-
return response[0].map((node) => ({
|
|
17897
|
-
nodeId: node.nodeId.toString(),
|
|
17898
|
-
nodeLevel: Number(node.nodeLevel),
|
|
17899
|
-
xNodeOwner: node.xNodeOwner,
|
|
17900
|
-
isXNodeHolder: node.isXNodeHolder,
|
|
17901
|
-
isXNodeDelegated: node.isXNodeDelegated,
|
|
17902
|
-
isXNodeDelegator: node.isXNodeDelegator,
|
|
17903
|
-
isXNodeDelegatee: node.isXNodeDelegatee,
|
|
17904
|
-
delegatee: node.delegatee
|
|
17905
|
-
}));
|
|
17906
|
-
}
|
|
17907
|
-
}
|
|
17908
|
-
});
|
|
17909
|
-
};
|
|
17910
|
-
var useGetUserNode = useGetUserNodes;
|
|
17911
|
-
var PRICE_FEED_IDS = {
|
|
17912
|
-
B3TR: "0x623374722d757364000000000000000000000000000000000000000000000000",
|
|
17913
|
-
VET: "0x7665742d75736400000000000000000000000000000000000000000000000000",
|
|
17914
|
-
VTHO: "0x7674686f2d757364000000000000000000000000000000000000000000000000",
|
|
17915
|
-
GBP: "0x6762702d75736400000000000000000000000000000000000000000000000000",
|
|
17916
|
-
EUR: "0x657572742d757364000000000000000000000000000000000000000000000000"
|
|
17917
|
-
};
|
|
17918
|
-
var getTokenUsdPrice = async (thor, token, network) => {
|
|
17919
|
-
const res = await thor.contracts.load(
|
|
17920
|
-
chunkLMX37RCG_cjs.getConfig(network).oracleContractAddress,
|
|
17921
|
-
chunk5GZ7N47F_cjs.IVechainEnergyOracleV1__factory.abi
|
|
17922
|
-
).read.getLatestValue(PRICE_FEED_IDS[token]);
|
|
17923
|
-
if (!res) throw new Error(`Failed to get price of ${token}`);
|
|
17924
|
-
return new BigNumber.BigNumber(res[0].toString()).div(1e12).toNumber();
|
|
17925
|
-
};
|
|
17926
|
-
var getTokenUsdPriceQueryKey = (token) => [
|
|
17927
|
-
"VECHAIN_KIT_PRICE",
|
|
17928
|
-
token
|
|
17929
|
-
];
|
|
17930
|
-
var useGetTokenUsdPrice = (token) => {
|
|
17931
|
-
const thor = dappKitReact.useThor();
|
|
17932
|
-
const { network } = useVeChainKitConfig();
|
|
17933
|
-
return reactQuery.useQuery({
|
|
17934
|
-
queryKey: getTokenUsdPriceQueryKey(token),
|
|
17935
|
-
queryFn: async () => getTokenUsdPrice(thor, token, network.type),
|
|
17936
|
-
enabled: !!thor && !!network.type
|
|
17937
|
-
});
|
|
17938
|
-
};
|
|
17939
|
-
var getVot3Balance = async (thor, network, address) => {
|
|
17940
|
-
const res = await thor.contracts.load(chunkLMX37RCG_cjs.getConfig(network).vot3ContractAddress, chunk5GZ7N47F_cjs.VOT3__factory.abi).read.balanceOf(address);
|
|
17941
|
-
if (!res) throw new Error("Reverted");
|
|
17942
|
-
const original = res[0].toString();
|
|
17943
|
-
const scaled = ethers.formatEther(original);
|
|
17944
|
-
const formatted = scaled === "0" ? "0" : chunkLMX37RCG_cjs.humanNumber(scaled);
|
|
17945
|
-
return {
|
|
17946
|
-
original,
|
|
17947
|
-
scaled,
|
|
17948
|
-
formatted
|
|
17949
|
-
};
|
|
17950
|
-
};
|
|
17951
|
-
var getVot3BalanceQueryKey = (address) => [
|
|
17952
|
-
"VEBETTERDAO_BALANCE",
|
|
17953
|
-
address,
|
|
17954
|
-
"VOT3"
|
|
17955
|
-
];
|
|
17956
|
-
var useGetVot3Balance = (address) => {
|
|
17957
|
-
const thor = dappKitReact.useThor();
|
|
17958
|
-
const { network } = useVeChainKitConfig();
|
|
17959
|
-
return reactQuery.useQuery({
|
|
17960
|
-
queryKey: getVot3BalanceQueryKey(address || ""),
|
|
17961
|
-
queryFn: async () => getVot3Balance(thor, network.type, address),
|
|
17962
|
-
enabled: !!thor && !!address && !!network.type
|
|
17963
|
-
});
|
|
17964
|
-
};
|
|
17965
|
-
var contractAbi2 = chunk5GZ7N47F_cjs.VeBetterPassport__factory.abi;
|
|
17966
|
-
var method4 = "isPerson";
|
|
17967
|
-
var getIsPersonQueryKey = (networkType, user) => {
|
|
17968
|
-
const veBetterPassportContractAddress = chunkLMX37RCG_cjs.getConfig(networkType).veBetterPassportContractAddress;
|
|
17969
|
-
return getCallClauseQueryKeyWithArgs({
|
|
17970
|
-
abi: contractAbi2,
|
|
17971
|
-
address: veBetterPassportContractAddress,
|
|
17972
|
-
method: method4,
|
|
17973
|
-
args: [user]
|
|
17974
|
-
});
|
|
17975
|
-
};
|
|
17976
|
-
var useIsPerson = (user, customEnabled = true) => {
|
|
17977
|
-
const { network } = useVeChainKitConfig();
|
|
17978
|
-
const veBetterPassportContractAddress = chunkLMX37RCG_cjs.getConfig(
|
|
17979
|
-
network.type
|
|
17980
|
-
).veBetterPassportContractAddress;
|
|
17981
|
-
return useCallClause({
|
|
17982
|
-
abi: contractAbi2,
|
|
17983
|
-
address: veBetterPassportContractAddress,
|
|
17984
|
-
method: method4,
|
|
17985
|
-
args: [user ?? sdkCore.ZERO_ADDRESS],
|
|
17986
|
-
queryOptions: {
|
|
17987
|
-
enabled: !!user && customEnabled && !!veBetterPassportContractAddress && !!network.type,
|
|
17988
|
-
select: (data) => data[0]
|
|
17989
|
-
}
|
|
17990
|
-
});
|
|
17991
|
-
};
|
|
17992
|
-
var useIsUserPerson = (address) => {
|
|
17993
|
-
return useIsPerson(address);
|
|
17994
|
-
};
|
|
17995
|
-
var contractAbi3 = chunk5GZ7N47F_cjs.VeBetterPassport__factory.abi;
|
|
17996
|
-
var method5 = "isPersonAtTimepoint";
|
|
17997
|
-
var getIsPersonAtTimepointQueryKey = (networkType, user, timepoint) => {
|
|
17998
|
-
const veBetterPassportContractAddress = chunkLMX37RCG_cjs.getConfig(networkType).veBetterPassportContractAddress;
|
|
17999
|
-
return getCallClauseQueryKeyWithArgs({
|
|
18000
|
-
abi: contractAbi3,
|
|
18001
|
-
address: veBetterPassportContractAddress,
|
|
18002
|
-
method: method5,
|
|
18003
|
-
args: [user, Number(timepoint)]
|
|
18004
|
-
});
|
|
18005
|
-
};
|
|
18006
|
-
var useIsPersonAtTimepoint = (user, timepoint, customEnabled = true) => {
|
|
18007
|
-
const { network } = useVeChainKitConfig();
|
|
18008
|
-
const veBetterPassportContractAddress = chunkLMX37RCG_cjs.getConfig(
|
|
18009
|
-
network.type
|
|
18010
|
-
).veBetterPassportContractAddress;
|
|
18011
|
-
return useCallClause({
|
|
18012
|
-
abi: contractAbi3,
|
|
18013
|
-
address: veBetterPassportContractAddress,
|
|
18014
|
-
method: method5,
|
|
18015
|
-
args: [
|
|
18016
|
-
user ?? sdkCore.ZERO_ADDRESS,
|
|
18017
|
-
timepoint ? Number(timepoint) : 0
|
|
18018
|
-
],
|
|
18019
|
-
queryOptions: {
|
|
18020
|
-
enabled: !!user && timepoint !== void 0 && customEnabled && !!veBetterPassportContractAddress && !!network.type,
|
|
18021
|
-
select: (data) => data[0]
|
|
18022
|
-
}
|
|
18023
|
-
});
|
|
18024
|
-
};
|
|
18025
|
-
|
|
18026
|
-
// src/hooks/thor/contracts/VeBetterPassport/useUserBotSignals.ts
|
|
18027
|
-
var contractAbi4 = chunk5GZ7N47F_cjs.VeBetterPassport__factory.abi;
|
|
18028
|
-
var method6 = "signaledCounter";
|
|
18029
|
-
var getUserBotSignalsQueryKey = (networkType, userAddress) => {
|
|
18030
|
-
return getCallClauseQueryKeyWithArgs({
|
|
18031
|
-
abi: contractAbi4,
|
|
18032
|
-
address: chunkLMX37RCG_cjs.getConfig(networkType).veBetterPassportContractAddress,
|
|
18033
|
-
method: method6,
|
|
18034
|
-
args: [userAddress]
|
|
18035
|
-
});
|
|
18036
|
-
};
|
|
18037
|
-
var useUserBotSignals = (userAddressInput) => {
|
|
18038
|
-
const { network } = useVeChainKitConfig();
|
|
18039
|
-
const veBetterPassportContractAddress = chunkLMX37RCG_cjs.getConfig(
|
|
18040
|
-
network.type
|
|
18041
|
-
).veBetterPassportContractAddress;
|
|
18042
|
-
return useCallClause({
|
|
18043
|
-
address: veBetterPassportContractAddress,
|
|
18044
|
-
abi: contractAbi4,
|
|
18045
|
-
method: method6,
|
|
18046
|
-
args: [userAddressInput],
|
|
18047
|
-
queryOptions: {
|
|
18048
|
-
enabled: !!userAddressInput && !!veBetterPassportContractAddress && !!network.type,
|
|
18049
|
-
select: (res) => Number(res[0])
|
|
18050
|
-
}
|
|
18051
|
-
});
|
|
18052
|
-
};
|
|
18053
|
-
var useVotingRewards = (currentRoundId, voter) => {
|
|
18054
|
-
const thor = dappKitReact.useThor();
|
|
18055
|
-
const queryClient = reactQuery.useQueryClient();
|
|
18056
|
-
const { network } = useVeChainKitConfig();
|
|
18057
|
-
const contractAddress = chunkLMX37RCG_cjs.getConfig(network.type).voterRewardsContractAddress;
|
|
18058
|
-
const rounds = React10.useMemo(() => {
|
|
18059
|
-
return Array.from(
|
|
18060
|
-
{ length: parseInt(currentRoundId ?? "0") - 1 },
|
|
18061
|
-
(_, i) => (i + 1).toString()
|
|
18062
|
-
);
|
|
18063
|
-
}, [currentRoundId]);
|
|
18064
|
-
return reactQuery.useQuery({
|
|
18065
|
-
queryKey: getRoundRewardQueryKey("ALL", voter),
|
|
18066
|
-
enabled: !!thor && !!voter && !!currentRoundId && !!rounds.length && !!network.type,
|
|
18067
|
-
queryFn: async () => {
|
|
18068
|
-
const contract = thor.contracts.load(
|
|
18069
|
-
contractAddress,
|
|
18070
|
-
chunk5GZ7N47F_cjs.VoterRewards__factory.abi
|
|
18071
|
-
);
|
|
18072
|
-
const clauses = rounds.map(
|
|
18073
|
-
(roundId) => (
|
|
18074
|
-
// Voter Rewards getReward result type: [ 0n ]
|
|
18075
|
-
contract.clause.getReward(roundId, voter)
|
|
18076
|
-
)
|
|
18077
|
-
);
|
|
18078
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18079
|
-
clauses
|
|
18080
|
-
);
|
|
18081
|
-
if (!res.every((r) => r.success))
|
|
18082
|
-
throw new Error("Failed to fetch voting rewards");
|
|
18083
|
-
let total = new BigNumber.BigNumber(0);
|
|
18084
|
-
const roundsRewards = res.map((r, index) => {
|
|
18085
|
-
const roundId = rounds[index];
|
|
18086
|
-
const rewards = r.result.plain;
|
|
18087
|
-
const formattedRewards = viem.formatEther(rewards);
|
|
18088
|
-
total = total.plus(BigNumber.BigNumber(rewards.toString()));
|
|
18089
|
-
queryClient.setQueryData(
|
|
18090
|
-
getRoundRewardQueryKey(roundId, voter),
|
|
18091
|
-
{
|
|
18092
|
-
roundId,
|
|
18093
|
-
rewards: formattedRewards
|
|
18094
|
-
}
|
|
18095
|
-
);
|
|
18096
|
-
return {
|
|
18097
|
-
roundId,
|
|
18098
|
-
rewards,
|
|
18099
|
-
formattedRewards
|
|
18100
|
-
};
|
|
18101
|
-
});
|
|
18102
|
-
const totalFormatted = viem.formatEther(BigInt(total.toFixed()));
|
|
18103
|
-
return {
|
|
18104
|
-
total: total.toFixed(),
|
|
18105
|
-
totalFormatted,
|
|
18106
|
-
roundsRewards
|
|
18107
|
-
};
|
|
18108
|
-
}
|
|
18109
|
-
});
|
|
18110
|
-
};
|
|
18111
|
-
var getRoundRewardQueryKey = (roundId, address) => [
|
|
18112
|
-
"VECHAIN_KIT",
|
|
18113
|
-
"roundReward",
|
|
18114
|
-
roundId,
|
|
18115
|
-
"voter",
|
|
18116
|
-
address
|
|
18117
|
-
];
|
|
18118
|
-
var useRoundReward = (address, roundId) => {
|
|
18119
|
-
const { network } = useVeChainKitConfig();
|
|
18120
|
-
return useCallClause({
|
|
18121
|
-
address: chunkLMX37RCG_cjs.getConfig(network.type).voterRewardsContractAddress,
|
|
18122
|
-
abi: chunk5GZ7N47F_cjs.VoterRewards__factory.abi,
|
|
18123
|
-
method: "getReward",
|
|
18124
|
-
args: [BigInt(roundId || 0), address],
|
|
18125
|
-
queryOptions: {
|
|
18126
|
-
enabled: !!address && !!roundId && !!network.type,
|
|
18127
|
-
select: (data) => ({
|
|
18128
|
-
roundId,
|
|
18129
|
-
rewards: viem.formatEther(BigInt(data[0]))
|
|
18130
|
-
})
|
|
18131
|
-
}
|
|
18132
|
-
});
|
|
18133
|
-
};
|
|
18134
|
-
|
|
18135
|
-
// src/hooks/thor/contracts/X2EarnApps/utils/getXAppMetadata.ts
|
|
18136
|
-
var getXAppMetadata = async (uri, networkType) => {
|
|
18137
|
-
const url = chunkLMX37RCG_cjs.convertUriToUrl(uri, networkType);
|
|
18138
|
-
if (!url) return void 0;
|
|
18139
|
-
const response = await fetch(url);
|
|
18140
|
-
if (!response.ok) {
|
|
18141
|
-
return void 0;
|
|
18142
|
-
}
|
|
18143
|
-
return response.json();
|
|
18144
|
-
};
|
|
18145
|
-
|
|
18146
|
-
// src/hooks/thor/contracts/X2EarnApps/utils/getXApps.ts
|
|
18147
|
-
var getXApps = async (thor, networkType) => {
|
|
18148
|
-
const contract = thor.contracts.load(
|
|
18149
|
-
chunkLMX37RCG_cjs.getConfig(networkType).x2EarnAppsContractAddress,
|
|
18150
|
-
chunk5GZ7N47F_cjs.X2EarnApps__factory.abi
|
|
18151
|
-
);
|
|
18152
|
-
const clauses = [contract.clause.unendorsedApps(), contract.clause.apps()];
|
|
18153
|
-
const res = await thor.transactions.executeMultipleClausesCall(clauses);
|
|
18154
|
-
if (!res.every((r) => r.success)) throw new Error(`Failed to fetch xApps`);
|
|
18155
|
-
const apps = res[0]?.result.plain;
|
|
18156
|
-
const unendorsedApps = res[1]?.result.plain;
|
|
18157
|
-
const allApps = {};
|
|
18158
|
-
for (const app of apps) {
|
|
18159
|
-
allApps[app.id] = {
|
|
18160
|
-
id: app.id,
|
|
18161
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18162
|
-
name: app.name,
|
|
18163
|
-
metadataURI: app.metadataURI,
|
|
18164
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18165
|
-
};
|
|
18166
|
-
}
|
|
18167
|
-
for (const app of unendorsedApps) {
|
|
18168
|
-
allApps[app.id] = {
|
|
18169
|
-
id: app.id,
|
|
18170
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18171
|
-
name: app.name,
|
|
18172
|
-
metadataURI: app.metadataURI,
|
|
18173
|
-
createdAtTimestamp: app.createdAtTimestamp.toString(),
|
|
18174
|
-
appAvailableForAllocationVoting: app.appAvailableForAllocationVoting
|
|
18175
|
-
};
|
|
18176
|
-
}
|
|
18177
|
-
const unendorsedIds = new Set(unendorsedApps.map((app) => app.id));
|
|
18178
|
-
return {
|
|
18179
|
-
allApps: Object.values(allApps),
|
|
18180
|
-
active: apps.map((app) => ({
|
|
18181
|
-
...app,
|
|
18182
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18183
|
-
})),
|
|
18184
|
-
unendorsed: unendorsedApps.map((app) => ({
|
|
18185
|
-
...app,
|
|
18186
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18187
|
-
})),
|
|
18188
|
-
endorsed: apps.filter((app) => !unendorsedIds.has(app.id)).map((app) => ({
|
|
18189
|
-
...app,
|
|
18190
|
-
createdAtTimestamp: app.createdAtTimestamp.toString()
|
|
18191
|
-
}))
|
|
18192
|
-
};
|
|
18193
|
-
};
|
|
18194
|
-
var abi4 = chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi;
|
|
18195
|
-
var method7 = "getAppsOfRound";
|
|
18196
|
-
var getRoundXApps = async (thor, networkType, roundId) => {
|
|
18197
|
-
if (!roundId) return [];
|
|
18198
|
-
const [xApps] = await chunkLMX37RCG_cjs.executeCallClause({
|
|
18199
|
-
thor,
|
|
18200
|
-
contractAddress: chunkLMX37RCG_cjs.getConfig(networkType).xAllocationVotingContractAddress,
|
|
18201
|
-
abi: abi4,
|
|
18202
|
-
method: method7,
|
|
18203
|
-
args: [BigInt(roundId)]
|
|
18204
|
-
});
|
|
18205
|
-
return xApps.map((app) => ({
|
|
18206
|
-
id: app.id.toString(),
|
|
18207
|
-
teamWalletAddress: app.teamWalletAddress,
|
|
18208
|
-
name: app.name,
|
|
18209
|
-
metadataURI: app.metadataURI,
|
|
18210
|
-
createdAtTimestamp: app.createdAtTimestamp.toString(),
|
|
18211
|
-
appAvailableForAllocationVoting: app.appAvailableForAllocationVoting
|
|
18212
|
-
}));
|
|
18213
|
-
};
|
|
18214
|
-
var getRoundXAppsQueryKey = (roundId) => [
|
|
18215
|
-
"VECHAIN_KIT",
|
|
18216
|
-
"round",
|
|
18217
|
-
roundId,
|
|
18218
|
-
"getXApps"
|
|
18219
|
-
];
|
|
18220
|
-
var useRoundXApps = (roundId) => {
|
|
18221
|
-
const thor = dappKitReact.useThor();
|
|
18222
|
-
const { network } = useVeChainKitConfig();
|
|
18223
|
-
return reactQuery.useQuery({
|
|
18224
|
-
queryKey: getRoundXAppsQueryKey(roundId),
|
|
18225
|
-
queryFn: async () => await getRoundXApps(thor, network.type, roundId),
|
|
18226
|
-
enabled: !!thor && !!roundId && !!network.type
|
|
18227
|
-
});
|
|
18228
|
-
};
|
|
18229
|
-
var getUserVotesInRound = async (thor, network, roundId, address) => {
|
|
18230
|
-
const xAllocationVotingContract = chunkLMX37RCG_cjs.getConfig(network).xAllocationVotingContractAddress;
|
|
18231
|
-
const eventAbi = thor.contracts.load(xAllocationVotingContract, chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi).getEventAbi("AllocationVoteCast");
|
|
18232
|
-
const topics = eventAbi.encodeFilterTopicsNoNull({
|
|
18233
|
-
...address ? { voter: address } : {},
|
|
18234
|
-
...roundId ? { roundId } : {}
|
|
18235
|
-
});
|
|
18236
|
-
const filterCriteria = [
|
|
18237
|
-
{
|
|
18238
|
-
criteria: {
|
|
18239
|
-
address: xAllocationVotingContract,
|
|
18240
|
-
topic0: topics[0] ?? void 0,
|
|
18241
|
-
topic1: topics[1] ?? void 0,
|
|
18242
|
-
topic2: topics[2] ?? void 0,
|
|
18243
|
-
topic3: topics[3] ?? void 0,
|
|
18244
|
-
topic4: topics[4] ?? void 0
|
|
18245
|
-
},
|
|
18246
|
-
eventAbi
|
|
18247
|
-
}
|
|
18248
|
-
];
|
|
18249
|
-
const events = await getAllEventLogs({
|
|
18250
|
-
thor,
|
|
18251
|
-
filterCriteria,
|
|
18252
|
-
nodeUrl: chunkLMX37RCG_cjs.getConfig(network).nodeUrl
|
|
18253
|
-
});
|
|
18254
|
-
const decodedAllocatedVoteEvents = [];
|
|
18255
|
-
events.forEach((event) => {
|
|
18256
|
-
if (!event.decodedData) {
|
|
18257
|
-
throw new Error("Event data not decoded");
|
|
18258
|
-
}
|
|
18259
|
-
if (!chunkLMX37RCG_cjs.compareAddresses(event.address, xAllocationVotingContract)) {
|
|
18260
|
-
throw new Error("Event address not valid");
|
|
18261
|
-
}
|
|
18262
|
-
const [voter, roundId2, appsIds, voteWeights] = event.decodedData;
|
|
18263
|
-
decodedAllocatedVoteEvents.push({
|
|
18264
|
-
voter,
|
|
18265
|
-
roundId: roundId2,
|
|
18266
|
-
appsIds,
|
|
18267
|
-
voteWeights
|
|
18268
|
-
});
|
|
18269
|
-
});
|
|
18270
|
-
return decodedAllocatedVoteEvents;
|
|
18271
|
-
};
|
|
18272
|
-
var getUserVotesInRoundQueryKey = (roundId, address) => [
|
|
18273
|
-
"VECHAIN_KIT",
|
|
18274
|
-
"allocationsRound",
|
|
18275
|
-
roundId,
|
|
18276
|
-
"userVotes",
|
|
18277
|
-
...address ? [address] : []
|
|
18278
|
-
];
|
|
18279
|
-
var useUserVotesInRound = (roundId, address) => {
|
|
18280
|
-
const thor = dappKitReact.useThor();
|
|
18281
|
-
const { network } = useVeChainKitConfig();
|
|
18282
|
-
return reactQuery.useQuery({
|
|
18283
|
-
queryKey: getUserVotesInRoundQueryKey(roundId, address),
|
|
18284
|
-
queryFn: async () => {
|
|
18285
|
-
const votes = await getUserVotesInRound(
|
|
18286
|
-
thor,
|
|
18287
|
-
network.type,
|
|
18288
|
-
roundId,
|
|
18289
|
-
address
|
|
18290
|
-
);
|
|
18291
|
-
if (votes.length > 1) throw new Error("More than one event found");
|
|
18292
|
-
if (votes.length === 0) throw new Error("No event found");
|
|
18293
|
-
return votes[0];
|
|
18294
|
-
},
|
|
18295
|
-
enabled: !!thor && !!thor.blocks.getHeadBlock() && !!roundId && !!address && !!network.type
|
|
18296
|
-
});
|
|
18297
|
-
};
|
|
18298
|
-
var getVotesInRoundQueryKey = (roundId) => [
|
|
18299
|
-
"VECHAIN_KIT",
|
|
18300
|
-
"allocationsRound",
|
|
18301
|
-
roundId,
|
|
18302
|
-
"totalVotes"
|
|
18303
|
-
];
|
|
18304
|
-
var useVotesInRound = (roundId, enabled = true) => {
|
|
18305
|
-
const thor = dappKitReact.useThor();
|
|
18306
|
-
const { network } = useVeChainKitConfig();
|
|
18307
|
-
return reactQuery.useQuery({
|
|
18308
|
-
queryKey: getVotesInRoundQueryKey(roundId),
|
|
18309
|
-
queryFn: async () => await getUserVotesInRound(thor, network.type, roundId),
|
|
18310
|
-
enabled: !!thor && !!thor.blocks.getHeadBlock() && !!roundId && enabled && !!network.type
|
|
18311
|
-
});
|
|
18312
|
-
};
|
|
18313
|
-
var getXAppsQueryKey = () => ["VECHAIN_KIT", "getXApps"];
|
|
18314
|
-
var useXApps = () => {
|
|
18315
|
-
const thor = dappKitReact.useThor();
|
|
18316
|
-
const { network } = useVeChainKitConfig();
|
|
18317
|
-
return reactQuery.useQuery({
|
|
18318
|
-
queryKey: getXAppsQueryKey(),
|
|
18319
|
-
queryFn: async () => await getXApps(thor, network.type),
|
|
18320
|
-
enabled: !!thor && !!network.type
|
|
18321
|
-
});
|
|
18322
|
-
};
|
|
18323
|
-
|
|
18324
|
-
// src/hooks/thor/contracts/X2EarnApps/custom/useXApp.ts
|
|
18325
|
-
var useXApp = (appId) => {
|
|
18326
|
-
const { data: xApps, ...props } = useXApps();
|
|
18327
|
-
const allApps = React10.useMemo(() => [...xApps?.active ?? [], ...xApps?.unendorsed ?? []], [xApps]);
|
|
18328
|
-
const app = allApps.find((xa) => xa.id === appId);
|
|
18329
|
-
return {
|
|
18330
|
-
data: app,
|
|
18331
|
-
...props
|
|
18332
|
-
};
|
|
18333
|
-
};
|
|
18334
|
-
var getXAppMetadataQueryKey = (metadataURI) => [
|
|
18335
|
-
"VECHAIN_KIT",
|
|
18336
|
-
"xApps",
|
|
18337
|
-
metadataURI,
|
|
18338
|
-
"metadata"
|
|
18339
|
-
];
|
|
18340
|
-
var useXAppMetadata = (xAppId) => {
|
|
18341
|
-
const { data: baseUri } = useXAppsMetadataBaseUri();
|
|
18342
|
-
const { data: xApp } = useXApp(xAppId ?? "");
|
|
18343
|
-
const { network } = useVeChainKitConfig();
|
|
18344
|
-
return reactQuery.useQuery({
|
|
18345
|
-
queryKey: getXAppMetadataQueryKey(xApp?.metadataURI || ""),
|
|
18346
|
-
queryFn: async () => !(!baseUri && xApp) ? await getXAppMetadata(
|
|
18347
|
-
`${baseUri}${xApp?.metadataURI}`,
|
|
18348
|
-
network.type
|
|
18349
|
-
) : null,
|
|
18350
|
-
enabled: !!baseUri && !!xApp && !!network.type
|
|
18351
|
-
});
|
|
18352
|
-
};
|
|
18353
|
-
var getXAppsSharesQueryKey = (roundId) => [
|
|
18354
|
-
"VECHAIN_KIT",
|
|
18355
|
-
"XApps",
|
|
18356
|
-
"Shares",
|
|
18357
|
-
roundId
|
|
18358
|
-
];
|
|
18359
|
-
var useXAppsShares = (apps, roundId) => {
|
|
18360
|
-
const thor = dappKitReact.useThor();
|
|
18361
|
-
const { network } = useVeChainKitConfig();
|
|
18362
|
-
return reactQuery.useQuery({
|
|
18363
|
-
queryKey: getXAppsSharesQueryKey(roundId),
|
|
18364
|
-
queryFn: async () => {
|
|
18365
|
-
const contract = thor.contracts.load(
|
|
18366
|
-
chunkLMX37RCG_cjs.getConfig(network.type).xAllocationPoolContractAddress,
|
|
18367
|
-
chunk5GZ7N47F_cjs.XAllocationPool__factory.abi
|
|
18368
|
-
);
|
|
18369
|
-
const clauses = apps.map(
|
|
18370
|
-
(app) => contract.clause.getAppShares(roundId, app)
|
|
18371
|
-
);
|
|
18372
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18373
|
-
clauses
|
|
18374
|
-
);
|
|
18375
|
-
if (!res.every((r) => r.success))
|
|
18376
|
-
throw new Error(
|
|
18377
|
-
`Failed to fetch xApps shares for ${apps} in round ${roundId}`
|
|
18378
|
-
);
|
|
18379
|
-
const shares = res.map((r, index) => {
|
|
18380
|
-
return {
|
|
18381
|
-
app: apps[index],
|
|
18382
|
-
share: Number(r.result.array?.[0] || 0) / 100,
|
|
18383
|
-
unallocatedShare: Number(r.result.array?.[1] || 0) / 100
|
|
18384
|
-
};
|
|
18385
|
-
});
|
|
18386
|
-
return shares;
|
|
18387
|
-
},
|
|
18388
|
-
enabled: !!roundId && !!apps.length
|
|
18389
|
-
});
|
|
18390
|
-
};
|
|
18391
|
-
|
|
18392
|
-
// src/hooks/thor/contracts/X2EarnApps/custom/useMostVotedAppsInRound.ts
|
|
18393
|
-
var useMostVotedAppsInRound = (roundId) => {
|
|
18394
|
-
const { data: roundXApps } = useRoundXApps(roundId);
|
|
18395
|
-
const { data: allXApps } = useXApps();
|
|
18396
|
-
const apps = roundId === "0" ? allXApps?.active : roundXApps;
|
|
18397
|
-
const xAppsShares = useXAppsShares(
|
|
18398
|
-
apps?.map((app) => app.id) ?? [],
|
|
18399
|
-
roundId
|
|
18400
|
-
);
|
|
18401
|
-
const mostVotedApps = React10.useMemo(
|
|
18402
|
-
() => xAppsShares.data?.map((appShares) => ({
|
|
18403
|
-
percentage: appShares.share + appShares.unallocatedShare,
|
|
18404
|
-
id: apps?.find((xa) => xa.id === appShares.app)?.id ?? "",
|
|
18405
|
-
app: apps?.find((xa) => xa.id === appShares.app) ?? {}
|
|
18406
|
-
})).sort((a, b) => Number(b.percentage) - Number(a.percentage)) ?? [],
|
|
18407
|
-
[xAppsShares.data, apps]
|
|
18408
|
-
);
|
|
18409
|
-
return {
|
|
18410
|
-
data: mostVotedApps,
|
|
18411
|
-
isLoading: xAppsShares.isLoading
|
|
18412
|
-
};
|
|
18413
|
-
};
|
|
18414
|
-
|
|
18415
|
-
// src/hooks/thor/contracts/X2EarnApps/useXAppsMetadataBaseUri.ts
|
|
18416
|
-
var abi5 = chunk5GZ7N47F_cjs.X2EarnApps__factory.abi;
|
|
18417
|
-
var method8 = "baseURI";
|
|
18418
|
-
var getXAppsMetadataBaseUriQueryKey = (network) => getCallClauseQueryKeyWithArgs({
|
|
18419
|
-
abi: abi5,
|
|
18420
|
-
method: method8,
|
|
18421
|
-
address: chunkLMX37RCG_cjs.getConfig(network).x2EarnAppsContractAddress,
|
|
18422
|
-
args: []
|
|
18423
|
-
});
|
|
18424
|
-
var useXAppsMetadataBaseUri = () => {
|
|
18425
|
-
const { network } = useVeChainKitConfig();
|
|
18426
|
-
return useCallClause({
|
|
18427
|
-
abi: abi5,
|
|
18428
|
-
address: chunkLMX37RCG_cjs.getConfig(network.type).x2EarnAppsContractAddress,
|
|
18429
|
-
method: method8,
|
|
18430
|
-
args: [],
|
|
18431
|
-
queryOptions: {
|
|
18432
|
-
enabled: !!network.type,
|
|
18433
|
-
staleTime: 1e3 * 60 * 60
|
|
18434
|
-
// 1 hour,
|
|
18435
|
-
}
|
|
18436
|
-
});
|
|
18437
|
-
};
|
|
18438
|
-
var getXAppRoundEarnings = async (thor, roundId, xAppId, networkType) => {
|
|
18439
|
-
const res = await thor.contracts.load(
|
|
18440
|
-
chunkLMX37RCG_cjs.getConfig(networkType).xAllocationPoolContractAddress,
|
|
18441
|
-
chunk5GZ7N47F_cjs.XAllocationPool__factory.abi
|
|
18442
|
-
).read.roundEarnings(roundId, xAppId);
|
|
18443
|
-
if (!res)
|
|
18444
|
-
throw new Error(
|
|
18445
|
-
`Failed to fetch xApp round earnings for ${xAppId} in round ${roundId}`
|
|
18446
|
-
);
|
|
18447
|
-
return { amount: viem.formatEther(BigInt(res[0] || 0)), appId: xAppId };
|
|
18448
|
-
};
|
|
18449
|
-
var getXAppRoundEarningsQueryKey = (roundId, xAppId) => [
|
|
18450
|
-
"VECHAIN_KIT",
|
|
18451
|
-
"roundEarnings",
|
|
18452
|
-
"roundId",
|
|
18453
|
-
Number(roundId),
|
|
18454
|
-
"appId",
|
|
18455
|
-
...xAppId ? [xAppId] : []
|
|
18456
|
-
];
|
|
18457
|
-
var useXAppRoundEarnings = (roundId, xAppId) => {
|
|
18458
|
-
const thor = dappKitReact.useThor();
|
|
18459
|
-
const queryClient = getOrCreateQueryClient();
|
|
18460
|
-
const { network } = useVeChainKitConfig();
|
|
18461
|
-
return reactQuery.useQuery({
|
|
18462
|
-
queryKey: getXAppRoundEarningsQueryKey(roundId, xAppId),
|
|
18463
|
-
queryFn: async () => {
|
|
18464
|
-
const data = await queryClient.ensureQueryData({
|
|
18465
|
-
queryFn: () => getRoundXApps(thor, network.type, roundId),
|
|
18466
|
-
queryKey: getRoundXAppsQueryKey(roundId)
|
|
18467
|
-
});
|
|
18468
|
-
const isXAppInRound = data.some((app) => app.id === xAppId);
|
|
18469
|
-
if (!isXAppInRound) return { amount: "0", xAppId };
|
|
18470
|
-
return await getXAppRoundEarnings(
|
|
18471
|
-
thor,
|
|
18472
|
-
roundId,
|
|
18473
|
-
xAppId,
|
|
18474
|
-
network.type
|
|
18475
|
-
);
|
|
18476
|
-
},
|
|
18477
|
-
enabled: !!thor && !!roundId && !!xAppId
|
|
18478
|
-
});
|
|
18479
|
-
};
|
|
18480
|
-
var useMultipleXAppRoundEarnings = (roundId, xAppIds) => {
|
|
18481
|
-
const thor = dappKitReact.useThor();
|
|
18482
|
-
const queryClient = getOrCreateQueryClient();
|
|
18483
|
-
const { network } = useVeChainKitConfig();
|
|
18484
|
-
return reactQuery.useQuery({
|
|
18485
|
-
queryKey: getXAppRoundEarningsQueryKey(roundId, "ALL"),
|
|
18486
|
-
queryFn: async () => {
|
|
18487
|
-
const data = await queryClient.ensureQueryData({
|
|
18488
|
-
queryFn: () => getRoundXApps(thor, network.type, roundId),
|
|
18489
|
-
queryKey: getRoundXAppsQueryKey(roundId)
|
|
18490
|
-
});
|
|
18491
|
-
const xAllocationPoolContract = chunkLMX37RCG_cjs.getConfig(
|
|
18492
|
-
network.type
|
|
18493
|
-
).xAllocationPoolContractAddress;
|
|
18494
|
-
const xAppsInRound = data.filter((app) => xAppIds.includes(app.id));
|
|
18495
|
-
const contract = thor.contracts.load(
|
|
18496
|
-
xAllocationPoolContract,
|
|
18497
|
-
chunk5GZ7N47F_cjs.XAllocationPool__factory.abi
|
|
18498
|
-
);
|
|
18499
|
-
const clauses = xAppsInRound.map(
|
|
18500
|
-
(app) => contract.clause.roundEarnings(roundId, app.id)
|
|
18501
|
-
);
|
|
18502
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18503
|
-
clauses
|
|
18504
|
-
);
|
|
18505
|
-
if (!res.every((r) => r.success))
|
|
18506
|
-
throw new Error("Failed to fetch xApp round earnings");
|
|
18507
|
-
const decoded = res.map((earnings, index) => {
|
|
18508
|
-
const parsedAmount = viem.formatEther(
|
|
18509
|
-
earnings.result.plain
|
|
18510
|
-
);
|
|
18511
|
-
const appId = xAppsInRound[index]?.id;
|
|
18512
|
-
queryClient.setQueryData(
|
|
18513
|
-
getXAppRoundEarningsQueryKey(roundId, appId),
|
|
18514
|
-
{
|
|
18515
|
-
amount: parsedAmount,
|
|
18516
|
-
appId
|
|
18517
|
-
}
|
|
18518
|
-
);
|
|
18519
|
-
return { amount: parsedAmount, appId };
|
|
18520
|
-
});
|
|
18521
|
-
return decoded;
|
|
18522
|
-
},
|
|
18523
|
-
enabled: !!thor && !!roundId && !!xAppIds.length
|
|
18524
|
-
});
|
|
18525
|
-
};
|
|
18526
|
-
var getXAppTotalEarningsQueryKey = (tillRoundId, appId) => [
|
|
18527
|
-
"VECHAIN_KIT",
|
|
18528
|
-
"XAllocationPool",
|
|
18529
|
-
"xApp",
|
|
18530
|
-
appId,
|
|
18531
|
-
"totalEarningsTillRound",
|
|
18532
|
-
tillRoundId
|
|
18533
|
-
];
|
|
18534
|
-
var useXAppTotalEarnings = (roundIds, appId) => {
|
|
18535
|
-
const thor = dappKitReact.useThor();
|
|
18536
|
-
const { network } = useVeChainKitConfig();
|
|
18537
|
-
const queryClient = getOrCreateQueryClient();
|
|
18538
|
-
const lastRound = roundIds[roundIds.length - 1] ?? 0;
|
|
18539
|
-
return reactQuery.useQuery({
|
|
18540
|
-
queryKey: getXAppTotalEarningsQueryKey(lastRound, appId),
|
|
18541
|
-
queryFn: async () => {
|
|
18542
|
-
const contract = thor.contracts.load(
|
|
18543
|
-
chunkLMX37RCG_cjs.getConfig(network.type).xAllocationPoolContractAddress,
|
|
18544
|
-
chunk5GZ7N47F_cjs.XAllocationPool__factory.abi
|
|
18545
|
-
);
|
|
18546
|
-
const clauses = roundIds.map(
|
|
18547
|
-
(roundId) => contract.clause.roundEarnings(roundId, appId)
|
|
18548
|
-
);
|
|
18549
|
-
const res = await thor.transactions.executeMultipleClausesCall(
|
|
18550
|
-
clauses
|
|
18551
|
-
);
|
|
18552
|
-
if (!res.every((r) => r.success))
|
|
18553
|
-
throw new Error(
|
|
18554
|
-
`Failed to fetch xApp total earnings of ${appId}`
|
|
18555
|
-
);
|
|
18556
|
-
const decoded = res.map((r, index) => {
|
|
18557
|
-
const parsedAmount = viem.formatEther(
|
|
18558
|
-
r.result.plain || BigInt(0)
|
|
18559
|
-
);
|
|
18560
|
-
queryClient.setQueryData(
|
|
18561
|
-
getXAppRoundEarningsQueryKey(
|
|
18562
|
-
roundIds[index],
|
|
18563
|
-
appId
|
|
18564
|
-
),
|
|
18565
|
-
{
|
|
18566
|
-
amount: parsedAmount,
|
|
18567
|
-
appId
|
|
18568
|
-
}
|
|
18569
|
-
);
|
|
18570
|
-
return parsedAmount;
|
|
18571
|
-
});
|
|
18572
|
-
return decoded.reduce((acc, amount) => {
|
|
18573
|
-
return acc + Number(amount);
|
|
18574
|
-
}, 0);
|
|
18575
|
-
}
|
|
18576
|
-
});
|
|
18577
|
-
};
|
|
18578
|
-
|
|
18579
|
-
// src/hooks/thor/contracts/XAllocationVoting/useAllocationsRoundState.ts
|
|
18580
|
-
var RoundState = {
|
|
18581
|
-
0: "Active",
|
|
18582
|
-
1: "Failed",
|
|
18583
|
-
2: "Succeeded"
|
|
18584
|
-
};
|
|
18585
|
-
var abi6 = chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi;
|
|
18586
|
-
var method9 = "state";
|
|
18587
|
-
var getAllocationsRoundStateQueryKey = (roundId, network) => getCallClauseQueryKeyWithArgs({
|
|
18588
|
-
abi: abi6,
|
|
18589
|
-
method: method9,
|
|
18590
|
-
address: chunkLMX37RCG_cjs.getConfig(network).xAllocationVotingContractAddress,
|
|
18591
|
-
args: [BigInt(roundId || 0)]
|
|
18592
|
-
});
|
|
18593
|
-
var useAllocationsRoundState = (roundId) => {
|
|
18594
|
-
const { network } = useVeChainKitConfig();
|
|
18595
|
-
return useCallClause({
|
|
18596
|
-
abi: abi6,
|
|
18597
|
-
address: chunkLMX37RCG_cjs.getConfig(network.type).xAllocationVotingContractAddress,
|
|
18598
|
-
method: method9,
|
|
18599
|
-
args: [BigInt(roundId || 0)],
|
|
18600
|
-
queryOptions: {
|
|
18601
|
-
enabled: !!roundId && !!network.type,
|
|
18602
|
-
select: (data) => data[0]
|
|
18603
|
-
}
|
|
18604
|
-
});
|
|
18605
|
-
};
|
|
18606
|
-
|
|
18607
|
-
// src/hooks/thor/contracts/XAllocationVoting/useCurrentAllocationsRoundId.ts
|
|
18608
|
-
var abi7 = chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi;
|
|
18609
|
-
var method10 = "currentRoundId";
|
|
18610
|
-
var getCurrentAllocationsRoundIdQueryKey = (network) => getCallClauseQueryKeyWithArgs({
|
|
18611
|
-
abi: abi7,
|
|
18612
|
-
method: method10,
|
|
18613
|
-
address: chunkLMX37RCG_cjs.getConfig(network).xAllocationVotingContractAddress,
|
|
18614
|
-
args: []
|
|
18615
|
-
});
|
|
18616
|
-
var useCurrentAllocationsRoundId = () => {
|
|
18617
|
-
const { network } = useVeChainKitConfig();
|
|
18618
|
-
return useCallClause({
|
|
18619
|
-
abi: abi7,
|
|
18620
|
-
address: chunkLMX37RCG_cjs.getConfig(network.type).xAllocationVotingContractAddress,
|
|
18621
|
-
method: method10,
|
|
18622
|
-
args: [],
|
|
18623
|
-
queryOptions: {
|
|
18624
|
-
enabled: !!network.type,
|
|
18625
|
-
select: (data) => data[0].toString()
|
|
18626
|
-
}
|
|
18627
|
-
});
|
|
18628
|
-
};
|
|
18629
|
-
|
|
18630
|
-
// src/hooks/thor/contracts/XAllocationVoting/useHasVotedInRound.ts
|
|
18631
|
-
var method11 = "hasVoted";
|
|
18632
|
-
var abi8 = chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi;
|
|
18633
|
-
var getHasVotedInRoundQueryKey = (roundId, address, networkType) => getCallClauseQueryKeyWithArgs({
|
|
18634
|
-
abi: abi8,
|
|
18635
|
-
address: chunkLMX37RCG_cjs.getConfig(networkType).xAllocationVotingContractAddress,
|
|
18636
|
-
method: method11,
|
|
18637
|
-
args: [BigInt(roundId || 0), address]
|
|
18638
|
-
});
|
|
18639
|
-
var useHasVotedInRound = (roundId, address) => {
|
|
18640
|
-
const { network } = useVeChainKitConfig();
|
|
18641
|
-
return useCallClause({
|
|
18642
|
-
abi: abi8,
|
|
18643
|
-
address: chunkLMX37RCG_cjs.getConfig(network.type).xAllocationVotingContractAddress,
|
|
18644
|
-
method: method11,
|
|
18645
|
-
args: [BigInt(roundId || 0), address],
|
|
18646
|
-
queryOptions: {
|
|
18647
|
-
enabled: !!roundId && !!address,
|
|
18648
|
-
select: (data) => data[0]
|
|
18649
|
-
}
|
|
18650
|
-
});
|
|
18651
|
-
};
|
|
18652
|
-
var getAllocationsRoundsEvents = async (thor, networkType) => {
|
|
18653
|
-
const xAllocationVotingContract = chunkLMX37RCG_cjs.getConfig(networkType).xAllocationVotingContractAddress;
|
|
18654
|
-
const eventAbi = thor.contracts.load(xAllocationVotingContract, chunk5GZ7N47F_cjs.XAllocationVoting__factory.abi).getEventAbi("RoundCreated");
|
|
18655
|
-
const events = await getAllEventLogs({
|
|
18656
|
-
thor,
|
|
18657
|
-
filterCriteria: [
|
|
18658
|
-
{
|
|
18659
|
-
criteria: {
|
|
18660
|
-
address: xAllocationVotingContract,
|
|
18661
|
-
topic0: eventAbi.signatureHash
|
|
18662
|
-
},
|
|
18663
|
-
eventAbi
|
|
18664
|
-
}
|
|
18665
|
-
],
|
|
18666
|
-
nodeUrl: chunkLMX37RCG_cjs.getConfig(networkType).nodeUrl
|
|
18667
|
-
});
|
|
18668
|
-
const decodedCreatedAllocationEvents = [];
|
|
18669
|
-
events.forEach((event) => {
|
|
18670
|
-
if (!event.decodedData) {
|
|
18671
|
-
throw new Error("Event data not decoded");
|
|
18672
|
-
}
|
|
18673
|
-
if (!chunkLMX37RCG_cjs.compareAddresses(event.address, xAllocationVotingContract)) {
|
|
18674
|
-
throw new Error("Event address not valid");
|
|
18675
|
-
}
|
|
18676
|
-
const [roundId, proposer, voteStart, voteEnd, appsIds] = event.decodedData;
|
|
18677
|
-
decodedCreatedAllocationEvents.push({
|
|
18678
|
-
roundId: roundId.toString(),
|
|
18679
|
-
proposer,
|
|
18680
|
-
voteStart: voteStart.toString(),
|
|
18681
|
-
voteEnd: voteEnd.toString(),
|
|
18682
|
-
appsIds: appsIds.map((appId) => appId.toString())
|
|
18683
|
-
});
|
|
18684
|
-
});
|
|
18685
|
-
return {
|
|
18686
|
-
created: decodedCreatedAllocationEvents
|
|
18687
|
-
};
|
|
18688
|
-
};
|
|
18689
|
-
var getAllocationsRoundsEventsQueryKey = () => [
|
|
18690
|
-
"VECHAIN_KIT",
|
|
18691
|
-
"allocationRoundsEvents"
|
|
18692
|
-
];
|
|
18693
|
-
var useAllocationsRoundsEvents = () => {
|
|
18694
|
-
const thor = dappKitReact.useThor();
|
|
18695
|
-
const { network } = useVeChainKitConfig();
|
|
18696
|
-
return reactQuery.useQuery({
|
|
18697
|
-
queryKey: getAllocationsRoundsEventsQueryKey(),
|
|
18698
|
-
queryFn: async () => await getAllocationsRoundsEvents(thor, network.type),
|
|
18699
|
-
enabled: !!thor && !!network.type
|
|
18700
|
-
});
|
|
18701
|
-
};
|
|
18702
|
-
|
|
18703
|
-
// src/hooks/thor/contracts/XAllocationVoting/custom/useCurrentAllocationsRound.ts
|
|
18704
|
-
var useCurrentAllocationsRound = () => {
|
|
18705
|
-
const currentRoundId = useCurrentAllocationsRoundId();
|
|
18706
|
-
const allocationsRound = useAllocationsRound(currentRoundId.data);
|
|
18707
|
-
return {
|
|
18708
|
-
...allocationsRound,
|
|
18709
|
-
isLoading: currentRoundId.isLoading || allocationsRound.isLoading,
|
|
18710
|
-
isError: currentRoundId.isError || allocationsRound.isError,
|
|
18711
|
-
error: currentRoundId.error || allocationsRound.error
|
|
18712
|
-
};
|
|
18713
|
-
};
|
|
18714
|
-
var useAllocationsRound = (roundId) => {
|
|
18715
|
-
const { data: currentBlock } = useCurrentBlock();
|
|
18716
|
-
const currentAllocationId = useCurrentAllocationsRoundId();
|
|
18717
|
-
const currentAllocationState = useAllocationsRoundState(roundId);
|
|
18718
|
-
const allocationRoundsEvents = useAllocationsRoundsEvents();
|
|
18719
|
-
const { network } = useVeChainKitConfig();
|
|
18720
|
-
const currentAllocationRound = React10.useMemo(() => {
|
|
18721
|
-
if (!currentAllocationId.data || !allocationRoundsEvents.data)
|
|
18722
|
-
return;
|
|
18723
|
-
const roundInfo = allocationRoundsEvents.data.created.find(
|
|
18724
|
-
(allocationRound) => allocationRound.roundId === roundId
|
|
18725
|
-
);
|
|
18726
|
-
if (!roundInfo) return;
|
|
18727
|
-
return {
|
|
18728
|
-
...roundInfo,
|
|
18729
|
-
state: currentAllocationState.data,
|
|
18730
|
-
isCurrent: roundId === currentAllocationId.data
|
|
18731
|
-
};
|
|
18732
|
-
}, [
|
|
18733
|
-
currentAllocationId,
|
|
18734
|
-
allocationRoundsEvents,
|
|
18735
|
-
currentAllocationState,
|
|
18736
|
-
roundId
|
|
18737
|
-
]);
|
|
18738
|
-
const isLoading = currentAllocationId.isLoading || allocationRoundsEvents.isLoading || currentAllocationState.isLoading;
|
|
18739
|
-
const isError = currentAllocationId.isError || allocationRoundsEvents.isError || currentAllocationState.isError;
|
|
18740
|
-
const error = currentAllocationId.error || allocationRoundsEvents.error || currentAllocationState.error;
|
|
18741
|
-
const blockTime = chunkLMX37RCG_cjs.getConfig(network.type).network.blockTime;
|
|
18742
|
-
const estimatedEndTime = React10.useMemo(() => {
|
|
18743
|
-
if (!currentAllocationRound) return null;
|
|
18744
|
-
const endBlock = Number(currentAllocationRound.voteEnd);
|
|
18745
|
-
if (!endBlock || !currentBlock) return null;
|
|
18746
|
-
const endBlockFromNow = endBlock - currentBlock.number;
|
|
18747
|
-
const durationLeftTimestamp = endBlockFromNow * blockTime;
|
|
18748
|
-
return Date.now() + durationLeftTimestamp;
|
|
18749
|
-
}, [currentBlock, currentAllocationRound, blockTime]);
|
|
18750
|
-
const estimatedStartTime = React10.useMemo(() => {
|
|
18751
|
-
if (!currentAllocationRound) return null;
|
|
18752
|
-
const startBlock = Number(currentAllocationRound.voteStart);
|
|
18753
|
-
if (!startBlock || !currentBlock) return null;
|
|
18754
|
-
const endBlockFromNow = startBlock - currentBlock.number;
|
|
18755
|
-
const durationLeftTimestamp = endBlockFromNow * blockTime;
|
|
18756
|
-
return Date.now() + durationLeftTimestamp;
|
|
18757
|
-
}, [currentBlock, currentAllocationRound, blockTime]);
|
|
18758
|
-
const isFirstRound = currentAllocationRound?.roundId === "1";
|
|
18759
|
-
const isLastRound = currentAllocationRound?.roundId === allocationRoundsEvents?.data?.created.length.toString();
|
|
18760
|
-
return {
|
|
18761
|
-
...allocationRoundsEvents,
|
|
18762
|
-
data: {
|
|
18763
|
-
...currentAllocationRound,
|
|
18764
|
-
voteStartTimestamp: estimatedStartTime,
|
|
18765
|
-
voteEndTimestamp: estimatedEndTime,
|
|
18766
|
-
isFirstRound,
|
|
18767
|
-
isLastRound
|
|
18768
|
-
},
|
|
18769
|
-
isLoading,
|
|
18770
|
-
isError,
|
|
18771
|
-
error
|
|
18772
|
-
};
|
|
18773
|
-
};
|
|
18774
|
-
var contractAbi5 = chunk5GZ7N47F_cjs.XAllocationVotingGovernor__factory.abi;
|
|
18775
|
-
var method12 = "getAppVotes";
|
|
18776
|
-
var getXAppVotesQueryKey = (networkType, roundId, appId) => getCallClauseQueryKeyWithArgs({
|
|
18777
|
-
abi: contractAbi5,
|
|
18778
|
-
address: chunkLMX37RCG_cjs.getConfig(networkType).xAllocationVotingContractAddress,
|
|
18779
|
-
method: method12,
|
|
18780
|
-
args: [BigInt(roundId || 0), appId]
|
|
18781
|
-
});
|
|
18782
|
-
var useXAppVotes = (roundId, appId) => {
|
|
18783
|
-
const { network } = useVeChainKitConfig();
|
|
18784
|
-
const contractAddress = chunkLMX37RCG_cjs.getConfig(
|
|
18785
|
-
network.type
|
|
18786
|
-
).xAllocationVotingContractAddress;
|
|
18787
|
-
return useCallClause({
|
|
18788
|
-
address: contractAddress,
|
|
18789
|
-
abi: contractAbi5,
|
|
18790
|
-
method: method12,
|
|
18791
|
-
args: [BigInt(roundId || 0), appId],
|
|
18792
|
-
queryOptions: {
|
|
18793
|
-
enabled: !!roundId && !!appId && !!network.type,
|
|
18794
|
-
select: (res) => viem.formatEther(BigInt(res[0]))
|
|
18795
|
-
}
|
|
18796
|
-
});
|
|
18797
|
-
};
|
|
18798
|
-
|
|
18799
|
-
// src/hooks/thor/logs/logUtils.ts
|
|
18800
|
-
var MAX_EVENTS_PER_QUERY = 1e3;
|
|
18801
|
-
var getEventLogs = async ({
|
|
18802
|
-
thor,
|
|
18803
|
-
order = "asc",
|
|
18804
|
-
offset = 0,
|
|
18805
|
-
limit = MAX_EVENTS_PER_QUERY,
|
|
18806
|
-
from = 0,
|
|
18807
|
-
to = thor.blocks.getHeadBlock()?.number,
|
|
18808
|
-
filterCriteria
|
|
18809
|
-
}) => {
|
|
18810
|
-
const response = await thor.logs.filterEventLogs({
|
|
18811
|
-
range: {
|
|
18812
|
-
from,
|
|
18813
|
-
to,
|
|
18814
|
-
unit: "block"
|
|
18815
|
-
},
|
|
18816
|
-
options: {
|
|
18817
|
-
offset,
|
|
18818
|
-
limit
|
|
18819
|
-
},
|
|
18820
|
-
order,
|
|
18821
|
-
criteriaSet: filterCriteria
|
|
18822
|
-
});
|
|
18823
|
-
if (!response) throw new Error("Failed to fetch events");
|
|
18824
|
-
return response;
|
|
18825
|
-
};
|
|
18826
|
-
var getAllEventLogs = async ({
|
|
18827
|
-
nodeUrl,
|
|
18828
|
-
thor,
|
|
18829
|
-
order = "asc",
|
|
18830
|
-
from = 0,
|
|
18831
|
-
to,
|
|
18832
|
-
filterCriteria
|
|
18833
|
-
}) => {
|
|
18834
|
-
const allEvents = [];
|
|
18835
|
-
let offset = 0;
|
|
18836
|
-
while (true) {
|
|
18837
|
-
const events = await getEventLogs({
|
|
18838
|
-
thor,
|
|
18839
|
-
filterCriteria,
|
|
18840
|
-
from,
|
|
18841
|
-
to: to ?? Number.MAX_SAFE_INTEGER,
|
|
18842
|
-
limit: MAX_EVENTS_PER_QUERY,
|
|
18843
|
-
order,
|
|
18844
|
-
offset
|
|
18845
|
-
});
|
|
18846
|
-
allEvents.push(...events);
|
|
18847
|
-
if (events.length < MAX_EVENTS_PER_QUERY) {
|
|
18848
|
-
return allEvents;
|
|
18849
|
-
}
|
|
18850
|
-
offset += MAX_EVENTS_PER_QUERY;
|
|
18851
|
-
}
|
|
18852
|
-
};
|
|
18853
|
-
|
|
18854
|
-
// src/hooks/thor/transactions/transactionUtils.ts
|
|
18855
|
-
var estimateTxGas = async (thor, clauses, caller) => {
|
|
18856
|
-
const response = await thor.transactions.estimateGas(clauses, caller);
|
|
18857
|
-
if (response.reverted) throw new Error("Failed to estimate gas");
|
|
18858
|
-
return response.totalGas;
|
|
18859
|
-
};
|
|
18860
|
-
var useSendTransaction = ({
|
|
18861
|
-
signerAccountAddress,
|
|
18862
|
-
clauses,
|
|
18863
|
-
onTxConfirmed,
|
|
18864
|
-
onTxFailedOrCancelled,
|
|
18865
|
-
suggestedMaxGas,
|
|
18866
|
-
privyUIOptions
|
|
18867
|
-
}) => {
|
|
17918
|
+
var useSendTransaction = ({
|
|
17919
|
+
signerAccountAddress,
|
|
17920
|
+
clauses,
|
|
17921
|
+
onTxConfirmed,
|
|
17922
|
+
onTxFailedOrCancelled,
|
|
17923
|
+
suggestedMaxGas,
|
|
17924
|
+
privyUIOptions
|
|
17925
|
+
}) => {
|
|
18868
17926
|
const thor = dappKitReact.useThor();
|
|
18869
17927
|
const { signer } = dappKitReact.useWallet();
|
|
18870
17928
|
const { connection } = useWallet();
|
|
@@ -19216,16 +18274,14 @@ var AddressDisplayCard = ({
|
|
|
19216
18274
|
}) => {
|
|
19217
18275
|
const { darkMode: isDark } = useVeChainKitConfig();
|
|
19218
18276
|
const { t } = reactI18next.useTranslation();
|
|
19219
|
-
const { isLoading: totalBalanceLoading } = useTotalBalance({
|
|
19220
|
-
|
|
19221
|
-
});
|
|
19222
|
-
const { tokens: tokens2, isLoading: tokensLoading } = useTokensWithValues({
|
|
18277
|
+
const { isLoading: totalBalanceLoading } = useTotalBalance({ address });
|
|
18278
|
+
const { tokens, isLoading: tokensLoading } = useTokensWithValues({
|
|
19223
18279
|
address
|
|
19224
18280
|
});
|
|
19225
18281
|
const tokenData = React10.useMemo(() => {
|
|
19226
18282
|
if (!tokenAddress) return null;
|
|
19227
|
-
return
|
|
19228
|
-
}, [
|
|
18283
|
+
return tokens.find((token) => token.address === tokenAddress);
|
|
18284
|
+
}, [tokens, tokenAddress]);
|
|
19229
18285
|
const displayBalance = React10.useMemo(() => {
|
|
19230
18286
|
if (balance !== void 0) return balance;
|
|
19231
18287
|
if (tokenData) {
|
|
@@ -20495,7 +19551,7 @@ var useVeChainKitConfig = () => {
|
|
|
20495
19551
|
var validateConfig = (props) => {
|
|
20496
19552
|
const errors = [];
|
|
20497
19553
|
const requiresFeeDelegation = props.privy !== void 0 || props.loginMethods?.some(
|
|
20498
|
-
(
|
|
19554
|
+
(method7) => method7.method === "vechain" || method7.method === "ecosystem"
|
|
20499
19555
|
);
|
|
20500
19556
|
if (requiresFeeDelegation) {
|
|
20501
19557
|
if (!props.feeDelegation) {
|
|
@@ -20523,7 +19579,7 @@ var validateConfig = (props) => {
|
|
|
20523
19579
|
if (props.loginMethods) {
|
|
20524
19580
|
if (!props.privy) {
|
|
20525
19581
|
const invalidMethods = props.loginMethods.filter(
|
|
20526
|
-
(
|
|
19582
|
+
(method7) => ["email", "google", "passkey", "more"].includes(method7.method)
|
|
20527
19583
|
);
|
|
20528
19584
|
if (invalidMethods.length > 0) {
|
|
20529
19585
|
errors.push(
|
|
@@ -20588,7 +19644,7 @@ var VeChainKitProvider = (props) => {
|
|
|
20588
19644
|
const validatedLoginMethods = loginMethods;
|
|
20589
19645
|
const allowedEcosystemApps = React10.useMemo(() => {
|
|
20590
19646
|
const userEcosystemMethods = validatedLoginMethods?.find(
|
|
20591
|
-
(
|
|
19647
|
+
(method7) => method7.method === "ecosystem"
|
|
20592
19648
|
);
|
|
20593
19649
|
return userEcosystemMethods?.allowedApps ?? chunkLMX37RCG_cjs.DEFAULT_PRIVY_ECOSYSTEM_APPS.map((app) => app.id);
|
|
20594
19650
|
}, [validatedLoginMethods]);
|
|
@@ -21265,7 +20321,6 @@ exports.ProfileModalProvider = ProfileModalProvider;
|
|
|
21265
20321
|
exports.QuickActionsSection = QuickActionsSection;
|
|
21266
20322
|
exports.ReceiveModalProvider = ReceiveModalProvider;
|
|
21267
20323
|
exports.ReceiveTokenContent = ReceiveTokenContent;
|
|
21268
|
-
exports.RoundState = RoundState;
|
|
21269
20324
|
exports.ScrollToTopWrapper = ScrollToTopWrapper;
|
|
21270
20325
|
exports.SelectTokenContent = SelectTokenContent;
|
|
21271
20326
|
exports.SendTokenContent = SendTokenContent;
|
|
@@ -21309,9 +20364,6 @@ exports.getAccountImplementationAddress = getAccountImplementationAddress;
|
|
|
21309
20364
|
exports.getAccountImplementationAddressQueryKey = getAccountImplementationAddressQueryKey;
|
|
21310
20365
|
exports.getAccountVersionQueryKey = getAccountVersionQueryKey;
|
|
21311
20366
|
exports.getAllEventLogs = getAllEventLogs;
|
|
21312
|
-
exports.getAllocationsRoundStateQueryKey = getAllocationsRoundStateQueryKey;
|
|
21313
|
-
exports.getAllocationsRoundsEvents = getAllocationsRoundsEvents;
|
|
21314
|
-
exports.getAllocationsRoundsEventsQueryKey = getAllocationsRoundsEventsQueryKey;
|
|
21315
20367
|
exports.getAppHubAppsQueryKey = getAppHubAppsQueryKey;
|
|
21316
20368
|
exports.getAvatar = getAvatar;
|
|
21317
20369
|
exports.getAvatarLegacy = getAvatarLegacy;
|
|
@@ -21338,7 +20390,6 @@ exports.getErc20BalanceQueryKey = getErc20BalanceQueryKey;
|
|
|
21338
20390
|
exports.getEventLogs = getEventLogs;
|
|
21339
20391
|
exports.getHasV1SmartAccount = getHasV1SmartAccount;
|
|
21340
20392
|
exports.getHasV1SmartAccountQueryKey = getHasV1SmartAccountQueryKey;
|
|
21341
|
-
exports.getHasVotedInRoundQueryKey = getHasVotedInRoundQueryKey;
|
|
21342
20393
|
exports.getIpfsImage = getIpfsImage;
|
|
21343
20394
|
exports.getIpfsImageQueryKey = getIpfsImageQueryKey;
|
|
21344
20395
|
exports.getIpfsMetadata = getIpfsMetadata;
|
|
@@ -21346,12 +20397,9 @@ exports.getIpfsMetadataQueryKey = getIpfsMetadataQueryKey;
|
|
|
21346
20397
|
exports.getIsDeployed = getIsDeployed;
|
|
21347
20398
|
exports.getIsDeployedQueryKey = getIsDeployedQueryKey;
|
|
21348
20399
|
exports.getIsDomainProtectedQueryKey = getIsDomainProtectedQueryKey;
|
|
21349
|
-
exports.getIsPersonAtTimepointQueryKey = getIsPersonAtTimepointQueryKey;
|
|
21350
20400
|
exports.getIsPersonQueryKey = getIsPersonQueryKey;
|
|
21351
20401
|
exports.getPrivyAppInfoQueryKey = getPrivyAppInfoQueryKey;
|
|
21352
20402
|
exports.getResolverAddressQueryKey = getResolverAddressQueryKey;
|
|
21353
|
-
exports.getRoundRewardQueryKey = getRoundRewardQueryKey;
|
|
21354
|
-
exports.getRoundXApps = getRoundXApps;
|
|
21355
20403
|
exports.getRoundXAppsQueryKey = getRoundXAppsQueryKey;
|
|
21356
20404
|
exports.getSmartAccount = getSmartAccount;
|
|
21357
20405
|
exports.getSmartAccountQueryKey = getSmartAccountQueryKey;
|
|
@@ -21360,32 +20408,16 @@ exports.getTextRecordsQueryKey = getTextRecordsQueryKey;
|
|
|
21360
20408
|
exports.getTokenInfo = getTokenInfo;
|
|
21361
20409
|
exports.getTokenUsdPrice = getTokenUsdPrice;
|
|
21362
20410
|
exports.getTokenUsdPriceQueryKey = getTokenUsdPriceQueryKey;
|
|
21363
|
-
exports.getTokensInfoByOwnerQueryKey = getTokensInfoByOwnerQueryKey;
|
|
21364
20411
|
exports.getUpgradeRequired = getUpgradeRequired;
|
|
21365
20412
|
exports.getUpgradeRequiredForAccount = getUpgradeRequiredForAccount;
|
|
21366
20413
|
exports.getUpgradeRequiredForAccountQueryKey = getUpgradeRequiredForAccountQueryKey;
|
|
21367
20414
|
exports.getUpgradeRequiredQueryKey = getUpgradeRequiredQueryKey;
|
|
21368
|
-
exports.getUserBotSignalsQueryKey = getUserBotSignalsQueryKey;
|
|
21369
|
-
exports.getUserNodesQueryKey = getUserNodesQueryKey;
|
|
21370
|
-
exports.getUserVotesInRound = getUserVotesInRound;
|
|
21371
|
-
exports.getUserVotesInRoundQueryKey = getUserVotesInRoundQueryKey;
|
|
21372
|
-
exports.getVeDelegateBalance = getVeDelegateBalance;
|
|
21373
|
-
exports.getVeDelegateBalanceQueryKey = getVeDelegateBalanceQueryKey;
|
|
21374
20415
|
exports.getVechainDomainQueryKey = getVechainDomainQueryKey;
|
|
21375
20416
|
exports.getVersion = getVersion;
|
|
21376
20417
|
exports.getVersionQueryKey = getVersionQueryKey;
|
|
21377
20418
|
exports.getVot3Balance = getVot3Balance;
|
|
21378
20419
|
exports.getVot3BalanceQueryKey = getVot3BalanceQueryKey;
|
|
21379
|
-
exports.getVotesInRoundQueryKey = getVotesInRoundQueryKey;
|
|
21380
20420
|
exports.getXAppMetadata = getXAppMetadata;
|
|
21381
|
-
exports.getXAppMetadataQueryKey = getXAppMetadataQueryKey;
|
|
21382
|
-
exports.getXAppRoundEarnings = getXAppRoundEarnings;
|
|
21383
|
-
exports.getXAppRoundEarningsQueryKey = getXAppRoundEarningsQueryKey;
|
|
21384
|
-
exports.getXAppTotalEarningsQueryKey = getXAppTotalEarningsQueryKey;
|
|
21385
|
-
exports.getXAppVotesQueryKey = getXAppVotesQueryKey;
|
|
21386
|
-
exports.getXApps = getXApps;
|
|
21387
|
-
exports.getXAppsMetadataBaseUriQueryKey = getXAppsMetadataBaseUriQueryKey;
|
|
21388
|
-
exports.getXAppsQueryKey = getXAppsQueryKey;
|
|
21389
20421
|
exports.getXAppsSharesQueryKey = getXAppsSharesQueryKey;
|
|
21390
20422
|
exports.imageCompressionOptions = imageCompressionOptions;
|
|
21391
20423
|
exports.txReceiptQueryKey = txReceiptQueryKey;
|
|
@@ -21394,9 +20426,6 @@ exports.useAccountBalance = useAccountBalance;
|
|
|
21394
20426
|
exports.useAccountCustomizationModal = useAccountCustomizationModal;
|
|
21395
20427
|
exports.useAccountImplementationAddress = useAccountImplementationAddress;
|
|
21396
20428
|
exports.useAccountModal = useAccountModal;
|
|
21397
|
-
exports.useAllocationsRound = useAllocationsRound;
|
|
21398
|
-
exports.useAllocationsRoundState = useAllocationsRoundState;
|
|
21399
|
-
exports.useAllocationsRoundsEvents = useAllocationsRoundsEvents;
|
|
21400
20429
|
exports.useAppHubApps = useAppHubApps;
|
|
21401
20430
|
exports.useBuildTransaction = useBuildTransaction;
|
|
21402
20431
|
exports.useCallClause = useCallClause;
|
|
@@ -21407,7 +20436,6 @@ exports.useConnectModal = useConnectModal;
|
|
|
21407
20436
|
exports.useCrossAppConnectionCache = useCrossAppConnectionCache;
|
|
21408
20437
|
exports.useCurrency = useCurrency;
|
|
21409
20438
|
exports.useCurrentAccountImplementationVersion = useCurrentAccountImplementationVersion;
|
|
21410
|
-
exports.useCurrentAllocationsRound = useCurrentAllocationsRound;
|
|
21411
20439
|
exports.useCurrentAllocationsRoundId = useCurrentAllocationsRoundId;
|
|
21412
20440
|
exports.useCurrentBlock = useCurrentBlock;
|
|
21413
20441
|
exports.useCustomTokens = useCustomTokens;
|
|
@@ -21418,7 +20446,6 @@ exports.useFAQModal = useFAQModal;
|
|
|
21418
20446
|
exports.useFeatureAnnouncement = useFeatureAnnouncement;
|
|
21419
20447
|
exports.useFetchAppInfo = useFetchAppInfo;
|
|
21420
20448
|
exports.useFetchPrivyStatus = useFetchPrivyStatus;
|
|
21421
|
-
exports.useGalaxyMemberTokensInfo = useGalaxyMemberTokensInfo;
|
|
21422
20449
|
exports.useGetAccountAddress = useGetAccountAddress;
|
|
21423
20450
|
exports.useGetAccountVersion = useGetAccountVersion;
|
|
21424
20451
|
exports.useGetAvatar = useGetAvatar;
|
|
@@ -21434,12 +20461,8 @@ exports.useGetNodeUrl = useGetNodeUrl;
|
|
|
21434
20461
|
exports.useGetResolverAddress = useGetResolverAddress;
|
|
21435
20462
|
exports.useGetTextRecords = useGetTextRecords;
|
|
21436
20463
|
exports.useGetTokenUsdPrice = useGetTokenUsdPrice;
|
|
21437
|
-
exports.useGetUserNode = useGetUserNode;
|
|
21438
|
-
exports.useGetUserNodes = useGetUserNodes;
|
|
21439
|
-
exports.useGetVeDelegateBalance = useGetVeDelegateBalance;
|
|
21440
20464
|
exports.useGetVot3Balance = useGetVot3Balance;
|
|
21441
20465
|
exports.useHasV1SmartAccount = useHasV1SmartAccount;
|
|
21442
|
-
exports.useHasVotedInRound = useHasVotedInRound;
|
|
21443
20466
|
exports.useIpfsImage = useIpfsImage;
|
|
21444
20467
|
exports.useIpfsImageList = useIpfsImageList;
|
|
21445
20468
|
exports.useIpfsMetadata = useIpfsMetadata;
|
|
@@ -21447,9 +20470,7 @@ exports.useIpfsMetadatas = useIpfsMetadatas;
|
|
|
21447
20470
|
exports.useIsDomainProtected = useIsDomainProtected;
|
|
21448
20471
|
exports.useIsPWA = useIsPWA;
|
|
21449
20472
|
exports.useIsPerson = useIsPerson;
|
|
21450
|
-
exports.useIsPersonAtTimepoint = useIsPersonAtTimepoint;
|
|
21451
20473
|
exports.useIsSmartAccountDeployed = useIsSmartAccountDeployed;
|
|
21452
|
-
exports.useIsUserPerson = useIsUserPerson;
|
|
21453
20474
|
exports.useLegalDocuments = useLegalDocuments;
|
|
21454
20475
|
exports.useLocalStorage = useLocalStorage;
|
|
21455
20476
|
exports.useLoginModalContent = useLoginModalContent;
|
|
@@ -21457,7 +20478,6 @@ exports.useLoginWithOAuth = useLoginWithOAuth2;
|
|
|
21457
20478
|
exports.useLoginWithPasskey = useLoginWithPasskey;
|
|
21458
20479
|
exports.useLoginWithVeChain = useLoginWithVeChain;
|
|
21459
20480
|
exports.useMostVotedAppsInRound = useMostVotedAppsInRound;
|
|
21460
|
-
exports.useMultipleXAppRoundEarnings = useMultipleXAppRoundEarnings;
|
|
21461
20481
|
exports.useNotificationAlerts = useNotificationAlerts;
|
|
21462
20482
|
exports.useNotifications = useNotifications;
|
|
21463
20483
|
exports.useNotificationsModal = useNotificationsModal;
|
|
@@ -21468,7 +20488,6 @@ exports.useRefreshBalances = useRefreshBalances;
|
|
|
21468
20488
|
exports.useRefreshFactoryQueries = useRefreshFactoryQueries;
|
|
21469
20489
|
exports.useRefreshMetadata = useRefreshMetadata;
|
|
21470
20490
|
exports.useRefreshSmartAccountQueries = useRefreshSmartAccountQueries;
|
|
21471
|
-
exports.useRoundReward = useRoundReward;
|
|
21472
20491
|
exports.useRoundXApps = useRoundXApps;
|
|
21473
20492
|
exports.useScrollToTop = useScrollToTop;
|
|
21474
20493
|
exports.useSendTokenModal = useSendTokenModal;
|
|
@@ -21480,9 +20499,7 @@ exports.useSmartAccount = useSmartAccount;
|
|
|
21480
20499
|
exports.useSmartAccountVersion = useSmartAccountVersion;
|
|
21481
20500
|
exports.useSyncableLocalStorage = useSyncableLocalStorage;
|
|
21482
20501
|
exports.useTokenBalances = useTokenBalances;
|
|
21483
|
-
exports.useTokenBalances2 = useTokenBalances2;
|
|
21484
20502
|
exports.useTokenPrices = useTokenPrices;
|
|
21485
|
-
exports.useTokenPrices2 = useTokenPrices2;
|
|
21486
20503
|
exports.useTokensWithValues = useTokensWithValues;
|
|
21487
20504
|
exports.useTotalBalance = useTotalBalance;
|
|
21488
20505
|
exports.useTransactionModal = useTransactionModal;
|
|
@@ -21497,22 +20514,12 @@ exports.useUpgradeRequiredForAccount = useUpgradeRequiredForAccount;
|
|
|
21497
20514
|
exports.useUpgradeSmartAccount = useUpgradeSmartAccount;
|
|
21498
20515
|
exports.useUpgradeSmartAccountModal = useUpgradeSmartAccountModal;
|
|
21499
20516
|
exports.useUploadImages = useUploadImages;
|
|
21500
|
-
exports.useUserBotSignals = useUserBotSignals;
|
|
21501
|
-
exports.useUserVotesInRound = useUserVotesInRound;
|
|
21502
20517
|
exports.useVeChainKitConfig = useVeChainKitConfig;
|
|
21503
20518
|
exports.useVechainDomain = useVechainDomain;
|
|
21504
|
-
exports.useVotesInRound = useVotesInRound;
|
|
21505
|
-
exports.useVotingRewards = useVotingRewards;
|
|
21506
20519
|
exports.useWallet = useWallet;
|
|
21507
20520
|
exports.useWalletMetadata = useWalletMetadata;
|
|
21508
20521
|
exports.useWalletModal = useWalletModal2;
|
|
21509
|
-
exports.useXApp = useXApp;
|
|
21510
20522
|
exports.useXAppMetadata = useXAppMetadata;
|
|
21511
|
-
exports.useXAppRoundEarnings = useXAppRoundEarnings;
|
|
21512
|
-
exports.useXAppTotalEarnings = useXAppTotalEarnings;
|
|
21513
|
-
exports.useXAppVotes = useXAppVotes;
|
|
21514
|
-
exports.useXApps = useXApps;
|
|
21515
|
-
exports.useXAppsMetadataBaseUri = useXAppsMetadataBaseUri;
|
|
21516
20523
|
exports.useXAppsShares = useXAppsShares;
|
|
21517
20524
|
//# sourceMappingURL=index.cjs.map
|
|
21518
20525
|
//# sourceMappingURL=index.cjs.map
|