@vechain/vechain-kit 2.0.0-rc.4 → 2.0.0-rc.5

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 CHANGED
@@ -4825,7 +4825,7 @@ var AddressDisplay = ({
4825
4825
 
4826
4826
  // package.json
4827
4827
  var package_default = {
4828
- version: "2.0.0-rc.4"};
4828
+ version: "2.0.0-rc.5"};
4829
4829
  var VersionFooter = ({ ...props }) => {
4830
4830
  const { darkMode: isDark } = useVeChainKitConfig();
4831
4831
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -15893,8 +15893,9 @@ var ProfileCard = ({
15893
15893
  style
15894
15894
  }) => {
15895
15895
  const { t } = reactI18next.useTranslation();
15896
- const { account } = useWallet();
15896
+ const { account, disconnect } = useWallet();
15897
15897
  const { network } = useVeChainKitConfig();
15898
+ const { openAccountModal, closeAccountModal } = useModal();
15898
15899
  const metadata = useWalletMetadata(address, network.type);
15899
15900
  const headerImageSvg = chunkLMX37RCG_cjs.getPicassoImage(address);
15900
15901
  const isConnectedAccount = address === account?.address;
@@ -16037,6 +16038,12 @@ var ProfileCard = ({
16037
16038
  variant: "ghost",
16038
16039
  leftIcon: /* @__PURE__ */ jsxRuntime.jsx(react.Icon, { as: fa.FaEdit }),
16039
16040
  onClick: onEditClick ?? (() => {
16041
+ openAccountModal({
16042
+ type: "account-customization",
16043
+ props: {
16044
+ setCurrentContent: () => closeAccountModal()
16045
+ }
16046
+ });
16040
16047
  }),
16041
16048
  "data-testid": "customize-button",
16042
16049
  children: t("Customize")
@@ -16051,7 +16058,18 @@ var ProfileCard = ({
16051
16058
  variant: "ghost",
16052
16059
  leftIcon: /* @__PURE__ */ jsxRuntime.jsx(react.Icon, { as: ri.RiLogoutBoxLine }),
16053
16060
  colorScheme: "red",
16054
- onClick: onLogout,
16061
+ onClick: onLogout ?? (() => {
16062
+ openAccountModal({
16063
+ type: "disconnect-confirm",
16064
+ props: {
16065
+ onDisconnect: () => {
16066
+ disconnect();
16067
+ closeAccountModal();
16068
+ },
16069
+ onBack: () => closeAccountModal()
16070
+ }
16071
+ });
16072
+ }),
16055
16073
  "data-testid": "logout-button",
16056
16074
  children: t("Logout")
16057
16075
  }
@@ -17181,6 +17199,16 @@ var useCallClause = ({
17181
17199
  ...queryOptions
17182
17200
  });
17183
17201
  };
17202
+ var useMultipleClausesCall = ({
17203
+ thor,
17204
+ calls,
17205
+ queryKey,
17206
+ enabled = true
17207
+ }) => reactQuery.useQuery({
17208
+ queryKey,
17209
+ queryFn: () => chunkLMX37RCG_cjs.executeMultipleClausesCall({ thor, calls }),
17210
+ enabled
17211
+ });
17184
17212
 
17185
17213
  // src/hooks/utils/useGetNodeUrl.ts
17186
17214
  var useGetNodeUrl = () => {
@@ -17210,89 +17238,6 @@ var useScrollToTop = () => {
17210
17238
  }
17211
17239
  }, []);
17212
17240
  };
17213
- var LocalStorageKey = /* @__PURE__ */ ((LocalStorageKey2) => {
17214
- LocalStorageKey2["CUSTOM_TOKENS"] = "vechain_kit_custom_tokens";
17215
- LocalStorageKey2["ECOSYSTEM_SHORTCUTS"] = "vechain-kit-ecosystem-shortcuts";
17216
- LocalStorageKey2["CURRENCY"] = "vechain_kit_currency";
17217
- LocalStorageKey2["NODE_URL"] = "vechain_kit_node_url";
17218
- LocalStorageKey2["NETWORK"] = "vechain_kit_network";
17219
- return LocalStorageKey2;
17220
- })(LocalStorageKey || {});
17221
- var useLocalStorage = (key, initialValue) => {
17222
- const [storedValue, setStoredValue] = React10.useState(() => {
17223
- try {
17224
- const item = window.localStorage.getItem(key);
17225
- return item ? JSON.parse(item) : initialValue;
17226
- } catch (error) {
17227
- console.error(error);
17228
- return initialValue;
17229
- }
17230
- });
17231
- React10.useEffect(() => {
17232
- window.localStorage.setItem(key, JSON.stringify(storedValue));
17233
- }, [key, storedValue]);
17234
- return [storedValue, setStoredValue];
17235
- };
17236
- var useSyncableLocalStorage = (key, defaultValue) => {
17237
- const [value, setValue] = React10.useState(() => {
17238
- if (typeof window === "undefined") return defaultValue;
17239
- try {
17240
- const stored = window.localStorage.getItem(key);
17241
- return stored ? JSON.parse(stored) : defaultValue;
17242
- } catch (err) {
17243
- console.error("Error loading from localStorage:", err);
17244
- return defaultValue;
17245
- }
17246
- });
17247
- React10.useEffect(() => {
17248
- if (typeof window === "undefined") return;
17249
- try {
17250
- window.localStorage.setItem(key, JSON.stringify(value));
17251
- } catch (err) {
17252
- console.error("Error writing to localStorage:", err);
17253
- }
17254
- }, [key, value]);
17255
- const sync = React10.useCallback(() => {
17256
- if (typeof window === "undefined") return;
17257
- try {
17258
- const stored = window.localStorage.getItem(key);
17259
- setValue(stored ? JSON.parse(stored) : defaultValue);
17260
- } catch (err) {
17261
- console.error("Error syncing localStorage:", err);
17262
- }
17263
- }, [key, defaultValue]);
17264
- const getValue = React10.useCallback(() => {
17265
- if (typeof window === "undefined") return defaultValue;
17266
- const stored = window.localStorage.getItem(key);
17267
- return stored ? JSON.parse(stored) : defaultValue;
17268
- }, [key, defaultValue]);
17269
- return [value, setValue, sync, getValue];
17270
- };
17271
-
17272
- // src/hooks/cache/useEcosystemShortcuts.ts
17273
- var useEcosystemShortcuts = () => {
17274
- const [shortcuts, setShortcuts] = useLocalStorage(
17275
- "vechain-kit-ecosystem-shortcuts" /* ECOSYSTEM_SHORTCUTS */,
17276
- []
17277
- );
17278
- const addShortcut = (shortcut) => {
17279
- if (!shortcuts.some((s) => s.url === shortcut.url)) {
17280
- setShortcuts([...shortcuts, shortcut]);
17281
- }
17282
- };
17283
- const removeShortcut = (url) => {
17284
- setShortcuts(shortcuts.filter((s) => s.url !== url));
17285
- };
17286
- const isShortcut = (url) => {
17287
- return shortcuts.some((s) => s.url === url);
17288
- };
17289
- return {
17290
- shortcuts,
17291
- addShortcut,
17292
- removeShortcut,
17293
- isShortcut
17294
- };
17295
- };
17296
17241
  var getAccountBalance = async (thor, address) => {
17297
17242
  if (!address) throw new Error("Address is required");
17298
17243
  const account = await thor.accounts.getAccount(sdkCore.Address.of(address));
@@ -18262,6 +18207,164 @@ var useTxReceipt = (txId, blockTimeout = 5) => {
18262
18207
  enabled: !!txId
18263
18208
  });
18264
18209
  };
18210
+
18211
+ // src/hooks/utils/useEvents.ts
18212
+ var decodeEventLog = (event, abi9) => {
18213
+ const decodedData = viem.decodeEventLog({
18214
+ abi: abi9,
18215
+ data: event.data.toString(),
18216
+ topics: event.topics.map((topic) => topic.toString())
18217
+ });
18218
+ return {
18219
+ meta: event.meta,
18220
+ decodedData
18221
+ };
18222
+ };
18223
+ var getEventsKey = ({
18224
+ eventName,
18225
+ filterParams
18226
+ }) => {
18227
+ return [eventName, filterParams ? JSON.stringify(filterParams) : "all"];
18228
+ };
18229
+ var useEvents = ({
18230
+ abi: abi9,
18231
+ contractAddress,
18232
+ eventName,
18233
+ filterParams,
18234
+ mapResponse,
18235
+ nodeUrl
18236
+ }) => {
18237
+ const thor = dappKitReact.useThor();
18238
+ const queryFn = React10.useCallback(async () => {
18239
+ if (!thor) return [];
18240
+ const eventAbi = thor.contracts.load(contractAddress, abi9).getEventAbi(eventName);
18241
+ const topics = eventAbi.encodeFilterTopicsNoNull(filterParams ?? {});
18242
+ const filterCriteria = [
18243
+ {
18244
+ criteria: {
18245
+ address: contractAddress,
18246
+ topic0: topics[0] ?? void 0,
18247
+ topic1: topics[1] ?? void 0,
18248
+ topic2: topics[2] ?? void 0,
18249
+ topic3: topics[3] ?? void 0,
18250
+ topic4: topics[4] ?? void 0
18251
+ },
18252
+ eventAbi
18253
+ }
18254
+ ];
18255
+ const events = (await getAllEventLogs({ thor, nodeUrl, filterCriteria })).map((event) => decodeEventLog(event, abi9));
18256
+ if (events.some(
18257
+ ({ decodedData }) => decodedData.eventName !== eventName
18258
+ ))
18259
+ throw new Error(`Unknown event`);
18260
+ return events.map(
18261
+ (event) => mapResponse({
18262
+ meta: event.meta,
18263
+ decodedData: event.decodedData
18264
+ })
18265
+ );
18266
+ }, [
18267
+ thor,
18268
+ contractAddress,
18269
+ abi9,
18270
+ eventName,
18271
+ filterParams,
18272
+ mapResponse,
18273
+ nodeUrl
18274
+ ]);
18275
+ const queryKey = React10.useMemo(
18276
+ () => getEventsKey({ eventName, filterParams }),
18277
+ [eventName, filterParams]
18278
+ );
18279
+ return reactQuery.useQuery({
18280
+ queryFn,
18281
+ queryKey,
18282
+ enabled: !!thor
18283
+ });
18284
+ };
18285
+ var LocalStorageKey = /* @__PURE__ */ ((LocalStorageKey2) => {
18286
+ LocalStorageKey2["CUSTOM_TOKENS"] = "vechain_kit_custom_tokens";
18287
+ LocalStorageKey2["ECOSYSTEM_SHORTCUTS"] = "vechain-kit-ecosystem-shortcuts";
18288
+ LocalStorageKey2["CURRENCY"] = "vechain_kit_currency";
18289
+ LocalStorageKey2["NODE_URL"] = "vechain_kit_node_url";
18290
+ LocalStorageKey2["NETWORK"] = "vechain_kit_network";
18291
+ return LocalStorageKey2;
18292
+ })(LocalStorageKey || {});
18293
+ var useLocalStorage = (key, initialValue) => {
18294
+ const [storedValue, setStoredValue] = React10.useState(() => {
18295
+ try {
18296
+ const item = window.localStorage.getItem(key);
18297
+ return item ? JSON.parse(item) : initialValue;
18298
+ } catch (error) {
18299
+ console.error(error);
18300
+ return initialValue;
18301
+ }
18302
+ });
18303
+ React10.useEffect(() => {
18304
+ window.localStorage.setItem(key, JSON.stringify(storedValue));
18305
+ }, [key, storedValue]);
18306
+ return [storedValue, setStoredValue];
18307
+ };
18308
+ var useSyncableLocalStorage = (key, defaultValue) => {
18309
+ const [value, setValue] = React10.useState(() => {
18310
+ if (typeof window === "undefined") return defaultValue;
18311
+ try {
18312
+ const stored = window.localStorage.getItem(key);
18313
+ return stored ? JSON.parse(stored) : defaultValue;
18314
+ } catch (err) {
18315
+ console.error("Error loading from localStorage:", err);
18316
+ return defaultValue;
18317
+ }
18318
+ });
18319
+ React10.useEffect(() => {
18320
+ if (typeof window === "undefined") return;
18321
+ try {
18322
+ window.localStorage.setItem(key, JSON.stringify(value));
18323
+ } catch (err) {
18324
+ console.error("Error writing to localStorage:", err);
18325
+ }
18326
+ }, [key, value]);
18327
+ const sync = React10.useCallback(() => {
18328
+ if (typeof window === "undefined") return;
18329
+ try {
18330
+ const stored = window.localStorage.getItem(key);
18331
+ setValue(stored ? JSON.parse(stored) : defaultValue);
18332
+ } catch (err) {
18333
+ console.error("Error syncing localStorage:", err);
18334
+ }
18335
+ }, [key, defaultValue]);
18336
+ const getValue = React10.useCallback(() => {
18337
+ if (typeof window === "undefined") return defaultValue;
18338
+ const stored = window.localStorage.getItem(key);
18339
+ return stored ? JSON.parse(stored) : defaultValue;
18340
+ }, [key, defaultValue]);
18341
+ return [value, setValue, sync, getValue];
18342
+ };
18343
+
18344
+ // src/hooks/cache/useEcosystemShortcuts.ts
18345
+ var useEcosystemShortcuts = () => {
18346
+ const [shortcuts, setShortcuts] = useLocalStorage(
18347
+ "vechain-kit-ecosystem-shortcuts" /* ECOSYSTEM_SHORTCUTS */,
18348
+ []
18349
+ );
18350
+ const addShortcut = (shortcut) => {
18351
+ if (!shortcuts.some((s) => s.url === shortcut.url)) {
18352
+ setShortcuts([...shortcuts, shortcut]);
18353
+ }
18354
+ };
18355
+ const removeShortcut = (url) => {
18356
+ setShortcuts(shortcuts.filter((s) => s.url !== url));
18357
+ };
18358
+ const isShortcut = (url) => {
18359
+ return shortcuts.some((s) => s.url === url);
18360
+ };
18361
+ return {
18362
+ shortcuts,
18363
+ addShortcut,
18364
+ removeShortcut,
18365
+ isShortcut
18366
+ };
18367
+ };
18265
18368
  var AddressDisplayCard = ({
18266
18369
  label,
18267
18370
  address,
@@ -20352,6 +20455,7 @@ exports.WalletButton = WalletButton;
20352
20455
  exports.WalletModalProvider = WalletModalProvider;
20353
20456
  exports.compressImages = compressImages;
20354
20457
  exports.currentBlockQueryKey = currentBlockQueryKey;
20458
+ exports.decodeEventLog = decodeEventLog;
20355
20459
  exports.fetchAppHubApps = fetchAppHubApps;
20356
20460
  exports.fetchPrivyAppInfo = fetchPrivyAppInfo;
20357
20461
  exports.fetchPrivyStatus = fetchPrivyStatus;
@@ -20388,6 +20492,7 @@ exports.getEnsRecordExistsQueryKey = getEnsRecordExistsQueryKey;
20388
20492
  exports.getErc20Balance = getErc20Balance;
20389
20493
  exports.getErc20BalanceQueryKey = getErc20BalanceQueryKey;
20390
20494
  exports.getEventLogs = getEventLogs;
20495
+ exports.getEventsKey = getEventsKey;
20391
20496
  exports.getHasV1SmartAccount = getHasV1SmartAccount;
20392
20497
  exports.getHasV1SmartAccountQueryKey = getHasV1SmartAccountQueryKey;
20393
20498
  exports.getIpfsImage = getIpfsImage;
@@ -20441,6 +20546,7 @@ exports.useCurrentBlock = useCurrentBlock;
20441
20546
  exports.useCustomTokens = useCustomTokens;
20442
20547
  exports.useEcosystemShortcuts = useEcosystemShortcuts;
20443
20548
  exports.useEnsRecordExists = useEnsRecordExists;
20549
+ exports.useEvents = useEvents;
20444
20550
  exports.useExploreEcosystemModal = useExploreEcosystemModal;
20445
20551
  exports.useFAQModal = useFAQModal;
20446
20552
  exports.useFeatureAnnouncement = useFeatureAnnouncement;
@@ -20478,6 +20584,7 @@ exports.useLoginWithOAuth = useLoginWithOAuth2;
20478
20584
  exports.useLoginWithPasskey = useLoginWithPasskey;
20479
20585
  exports.useLoginWithVeChain = useLoginWithVeChain;
20480
20586
  exports.useMostVotedAppsInRound = useMostVotedAppsInRound;
20587
+ exports.useMultipleClausesCall = useMultipleClausesCall;
20481
20588
  exports.useNotificationAlerts = useNotificationAlerts;
20482
20589
  exports.useNotifications = useNotifications;
20483
20590
  exports.useNotificationsModal = useNotificationsModal;