@iota/dapp-kit 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/cjs/components/AccountDropdownMenu.css +50 -16
- package/dist/cjs/components/AccountDropdownMenu.css.css +39 -16
- package/dist/cjs/components/AccountDropdownMenu.css.css.map +3 -3
- package/dist/cjs/components/AccountDropdownMenu.css.d.ts +3 -0
- package/dist/cjs/components/AccountDropdownMenu.css.d.ts.map +1 -1
- package/dist/cjs/components/AccountDropdownMenu.css.js +12 -6
- package/dist/cjs/components/AccountDropdownMenu.css.js.map +2 -2
- package/dist/cjs/components/AccountDropdownMenu.css.map +3 -3
- package/dist/cjs/components/AccountDropdownMenu.d.ts.map +1 -1
- package/dist/cjs/components/AccountDropdownMenu.js +184 -86
- package/dist/cjs/components/AccountDropdownMenu.js.map +4 -4
- package/dist/cjs/components/ConnectButton.css +50 -16
- package/dist/cjs/components/ConnectButton.css.map +3 -3
- package/dist/cjs/components/ConnectButton.js +259 -161
- package/dist/cjs/components/ConnectButton.js.map +4 -4
- package/dist/cjs/components/IotaNameNftImage.css +11 -0
- package/dist/cjs/components/IotaNameNftImage.css.css +11 -0
- package/dist/cjs/components/IotaNameNftImage.css.css.map +7 -0
- package/dist/cjs/components/IotaNameNftImage.css.d.ts +2 -0
- package/dist/cjs/components/IotaNameNftImage.css.d.ts.map +1 -0
- package/dist/cjs/components/IotaNameNftImage.css.js +27 -0
- package/dist/cjs/components/IotaNameNftImage.css.js.map +7 -0
- package/dist/cjs/components/IotaNameNftImage.css.map +7 -0
- package/dist/cjs/components/IotaNameNftImage.d.ts +8 -0
- package/dist/cjs/components/IotaNameNftImage.d.ts.map +1 -0
- package/dist/cjs/components/IotaNameNftImage.js +165 -0
- package/dist/cjs/components/IotaNameNftImage.js.map +7 -0
- package/dist/cjs/hooks/useGetDefaultIotaName.d.ts +1 -1
- package/dist/cjs/hooks/useGetDefaultIotaName.d.ts.map +1 -1
- package/dist/cjs/hooks/useGetDefaultIotaName.js +26 -16
- package/dist/cjs/hooks/useGetDefaultIotaName.js.map +4 -4
- package/dist/cjs/hooks/useGetIotaNameAvatar.d.ts +2 -0
- package/dist/cjs/hooks/useGetIotaNameAvatar.d.ts.map +1 -0
- package/dist/cjs/hooks/useGetIotaNameAvatar.js +144 -0
- package/dist/cjs/hooks/useGetIotaNameAvatar.js.map +7 -0
- package/dist/cjs/hooks/useIotaNamesClient.d.ts +7 -0
- package/dist/cjs/hooks/useIotaNamesClient.d.ts.map +1 -0
- package/dist/cjs/hooks/useIotaNamesClient.js +71 -0
- package/dist/cjs/hooks/useIotaNamesClient.js.map +7 -0
- package/dist/cjs/index.css +50 -16
- package/dist/cjs/index.css.map +3 -3
- package/dist/cjs/index.js +171 -76
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/components/AccountDropdownMenu.css +50 -16
- package/dist/esm/components/AccountDropdownMenu.css.css +39 -16
- package/dist/esm/components/AccountDropdownMenu.css.css.map +3 -3
- package/dist/esm/components/AccountDropdownMenu.css.d.ts +3 -0
- package/dist/esm/components/AccountDropdownMenu.css.d.ts.map +1 -1
- package/dist/esm/components/AccountDropdownMenu.css.js +12 -6
- package/dist/esm/components/AccountDropdownMenu.css.js.map +2 -2
- package/dist/esm/components/AccountDropdownMenu.css.map +3 -3
- package/dist/esm/components/AccountDropdownMenu.d.ts.map +1 -1
- package/dist/esm/components/AccountDropdownMenu.js +177 -79
- package/dist/esm/components/AccountDropdownMenu.js.map +4 -4
- package/dist/esm/components/ConnectButton.css +50 -16
- package/dist/esm/components/ConnectButton.css.map +3 -3
- package/dist/esm/components/ConnectButton.js +236 -138
- package/dist/esm/components/ConnectButton.js.map +4 -4
- package/dist/esm/components/IotaNameNftImage.css +11 -0
- package/dist/esm/components/IotaNameNftImage.css.css +11 -0
- package/dist/esm/components/IotaNameNftImage.css.css.map +7 -0
- package/dist/esm/components/IotaNameNftImage.css.d.ts +2 -0
- package/dist/esm/components/IotaNameNftImage.css.d.ts.map +1 -0
- package/dist/esm/components/IotaNameNftImage.css.js +6 -0
- package/dist/esm/components/IotaNameNftImage.css.js.map +7 -0
- package/dist/esm/components/IotaNameNftImage.css.map +7 -0
- package/dist/esm/components/IotaNameNftImage.d.ts +8 -0
- package/dist/esm/components/IotaNameNftImage.d.ts.map +1 -0
- package/dist/esm/components/IotaNameNftImage.js +144 -0
- package/dist/esm/components/IotaNameNftImage.js.map +7 -0
- package/dist/esm/hooks/useGetDefaultIotaName.d.ts +1 -1
- package/dist/esm/hooks/useGetDefaultIotaName.d.ts.map +1 -1
- package/dist/esm/hooks/useGetDefaultIotaName.js +26 -16
- package/dist/esm/hooks/useGetDefaultIotaName.js.map +4 -4
- package/dist/esm/hooks/useGetIotaNameAvatar.d.ts +2 -0
- package/dist/esm/hooks/useGetIotaNameAvatar.d.ts.map +1 -0
- package/dist/esm/hooks/useGetIotaNameAvatar.js +123 -0
- package/dist/esm/hooks/useGetIotaNameAvatar.js.map +7 -0
- package/dist/esm/hooks/useIotaNamesClient.d.ts +7 -0
- package/dist/esm/hooks/useIotaNamesClient.d.ts.map +1 -0
- package/dist/esm/hooks/useIotaNamesClient.js +50 -0
- package/dist/esm/hooks/useIotaNamesClient.js.map +7 -0
- package/dist/esm/index.css +50 -16
- package/dist/esm/index.css.map +3 -3
- package/dist/esm/index.js +142 -47
- package/dist/esm/index.js.map +4 -4
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/AccountDropdownMenu.css.ts +24 -1
- package/src/components/AccountDropdownMenu.tsx +12 -2
- package/src/components/IotaNameNftImage.css.ts +14 -0
- package/src/components/IotaNameNftImage.tsx +30 -0
- package/src/hooks/useGetDefaultIotaName.ts +6 -22
- package/src/hooks/useGetIotaNameAvatar.ts +72 -0
- package/src/hooks/useIotaNamesClient.ts +29 -0
package/dist/cjs/index.js
CHANGED
|
@@ -794,13 +794,16 @@ function useSwitchAccount({
|
|
|
794
794
|
}
|
|
795
795
|
|
|
796
796
|
// src/components/AccountDropdownMenu.css.ts
|
|
797
|
+
var accountIdentity = "AccountDropdownMenu_accountIdentity__1x0gmpf8";
|
|
798
|
+
var accountName = "AccountDropdownMenu_accountName__1x0gmpf1";
|
|
799
|
+
var accountNameMenuItem = "AccountDropdownMenu_accountNameMenuItem__1x0gmpf2";
|
|
797
800
|
var connectedAccount = "AccountDropdownMenu_connectedAccount__1x0gmpf0";
|
|
798
|
-
var menuContainer = "
|
|
799
|
-
var menuContent = "
|
|
800
|
-
var menuItem = "
|
|
801
|
-
var scrollableContent = "
|
|
802
|
-
var separator = "
|
|
803
|
-
var switchAccountMenuItem = "
|
|
801
|
+
var menuContainer = "AccountDropdownMenu_menuContainer__1x0gmpf3";
|
|
802
|
+
var menuContent = "AccountDropdownMenu_menuContent__1x0gmpf4";
|
|
803
|
+
var menuItem = "AccountDropdownMenu_menuItem__1x0gmpf6";
|
|
804
|
+
var scrollableContent = "AccountDropdownMenu_scrollableContent__1x0gmpf5";
|
|
805
|
+
var separator = "AccountDropdownMenu_separator__1x0gmpf9";
|
|
806
|
+
var switchAccountMenuItem = "AccountDropdownMenu_switchAccountMenuItem__1x0gmpf7";
|
|
804
807
|
|
|
805
808
|
// src/components/icons/CheckIcon.tsx
|
|
806
809
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
@@ -829,10 +832,22 @@ function ChevronIcon(props) {
|
|
|
829
832
|
) });
|
|
830
833
|
}
|
|
831
834
|
|
|
835
|
+
// src/components/IotaNameNftImage.tsx
|
|
836
|
+
var import_react12 = require("react");
|
|
837
|
+
|
|
838
|
+
// src/hooks/useGetIotaNameAvatar.ts
|
|
839
|
+
var import_iota_names_sdk3 = require("@iota/iota-names-sdk");
|
|
840
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
841
|
+
|
|
832
842
|
// src/hooks/useGetDefaultIotaName.ts
|
|
833
|
-
var
|
|
843
|
+
var import_iota_names_sdk2 = require("@iota/iota-names-sdk");
|
|
834
844
|
var import_react_query4 = require("@tanstack/react-query");
|
|
845
|
+
|
|
846
|
+
// src/hooks/useIotaNamesClient.ts
|
|
847
|
+
var import_graphql = require("@iota/iota-sdk/graphql");
|
|
835
848
|
var import_iota_names_sdk = require("@iota/iota-names-sdk");
|
|
849
|
+
var import_client2 = require("@iota/iota-sdk/client");
|
|
850
|
+
var import_react11 = require("react");
|
|
836
851
|
|
|
837
852
|
// src/hooks/useIotaClient.ts
|
|
838
853
|
var import_react10 = require("react");
|
|
@@ -896,36 +911,106 @@ function useIotaClient() {
|
|
|
896
911
|
return useIotaClientContext().client;
|
|
897
912
|
}
|
|
898
913
|
|
|
899
|
-
// src/hooks/
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const iotaContext = useIotaClientContext();
|
|
904
|
-
const network = (0, import_client2.getNetwork)(iotaContext.network);
|
|
914
|
+
// src/hooks/useIotaNamesClient.ts
|
|
915
|
+
function useIotaNamesClient() {
|
|
916
|
+
const { network: networkId } = useIotaClientContext();
|
|
917
|
+
const network = (0, import_client2.getNetwork)(networkId);
|
|
905
918
|
const iotaNamesClient = (0, import_react11.useMemo)(() => {
|
|
906
|
-
|
|
907
|
-
url: network.graphql
|
|
908
|
-
});
|
|
919
|
+
if (!network.graphql) return null;
|
|
909
920
|
return new import_iota_names_sdk.IotaNamesClient({
|
|
910
|
-
graphQlClient:
|
|
921
|
+
graphQlClient: new import_graphql.IotaGraphQLClient({ url: network.graphql }),
|
|
911
922
|
network: network.id
|
|
912
923
|
});
|
|
913
|
-
}, [network.id]);
|
|
914
|
-
|
|
924
|
+
}, [network.id, network.graphql]);
|
|
925
|
+
return {
|
|
926
|
+
iotaNamesClient,
|
|
927
|
+
networkId: network.id,
|
|
928
|
+
isSupported: !!iotaNamesClient?.config
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// src/hooks/useGetDefaultIotaName.ts
|
|
933
|
+
function useGetDefaultIotaName(address, iotaNamesEnabled) {
|
|
934
|
+
const { iotaNamesClient, networkId, isSupported } = useIotaNamesClient();
|
|
915
935
|
return (0, import_react_query4.useQuery)({
|
|
916
|
-
queryKey: ["iota-name", "default-name", address],
|
|
936
|
+
queryKey: ["iota-name", "default-name", address, networkId],
|
|
917
937
|
queryFn: async () => {
|
|
918
938
|
if (!address) return null;
|
|
919
939
|
const name = await iotaNamesClient?.getPublicName(address);
|
|
920
|
-
return name ? (0,
|
|
940
|
+
return name ? (0, import_iota_names_sdk2.normalizeIotaName)(name) : name;
|
|
921
941
|
},
|
|
922
|
-
enabled: !!
|
|
942
|
+
enabled: !!address && iotaNamesEnabled && isSupported,
|
|
923
943
|
staleTime: 1e3 * 60 * 10
|
|
924
944
|
});
|
|
925
945
|
}
|
|
926
946
|
|
|
927
|
-
// src/
|
|
947
|
+
// src/hooks/useGetIotaNameAvatar.ts
|
|
948
|
+
function useGetIotaNameAvatar(address, iotaNamesEnabled) {
|
|
949
|
+
const client = useIotaClient();
|
|
950
|
+
const { iotaNamesClient, networkId, isSupported } = useIotaNamesClient();
|
|
951
|
+
const { data: name } = useGetDefaultIotaName(address, iotaNamesEnabled);
|
|
952
|
+
return (0, import_react_query5.useQuery)({
|
|
953
|
+
// eslint-disable-next-line @tanstack/query/exhaustive-deps
|
|
954
|
+
queryKey: ["iota-name", "avatar", name, networkId],
|
|
955
|
+
queryFn: async () => {
|
|
956
|
+
if (!name || !address || !iotaNamesClient) return null;
|
|
957
|
+
const nameRecord = await iotaNamesClient.getNameRecord(name);
|
|
958
|
+
if (!nameRecord) return null;
|
|
959
|
+
const avatarObjectId = nameRecord.avatar ?? ((0, import_iota_names_sdk3.isSubname)(name) ? await findSubnameNftId() : nameRecord.nftId);
|
|
960
|
+
if (!avatarObjectId) return null;
|
|
961
|
+
const objectResponse = await client.getObject({
|
|
962
|
+
id: avatarObjectId,
|
|
963
|
+
options: { showDisplay: true }
|
|
964
|
+
});
|
|
965
|
+
return objectResponse?.data?.display?.data?.image_url ?? null;
|
|
966
|
+
async function findSubnameNftId() {
|
|
967
|
+
let subnameType;
|
|
968
|
+
try {
|
|
969
|
+
subnameType = (0, import_iota_names_sdk3.getSubnameRegistrationType)(
|
|
970
|
+
iotaNamesClient.getPackage("packageId", "v1")
|
|
971
|
+
);
|
|
972
|
+
} catch {
|
|
973
|
+
return null;
|
|
974
|
+
}
|
|
975
|
+
const { data } = await client.getOwnedObjects({
|
|
976
|
+
owner: address,
|
|
977
|
+
filter: { StructType: subnameType },
|
|
978
|
+
options: { showDisplay: true }
|
|
979
|
+
});
|
|
980
|
+
return data.find((object) => {
|
|
981
|
+
try {
|
|
982
|
+
return (0, import_iota_names_sdk3.normalizeIotaName)(object.data?.display?.data?.name ?? "") === name;
|
|
983
|
+
} catch {
|
|
984
|
+
return false;
|
|
985
|
+
}
|
|
986
|
+
})?.data?.objectId ?? null;
|
|
987
|
+
}
|
|
988
|
+
},
|
|
989
|
+
enabled: iotaNamesEnabled && isSupported && !!name && !!address,
|
|
990
|
+
staleTime: 1e3 * 60 * 5
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// src/components/IotaNameNftImage.css.ts
|
|
995
|
+
var image = "IotaNameNftImage_image__qs9r060";
|
|
996
|
+
|
|
997
|
+
// src/components/IotaNameNftImage.tsx
|
|
928
998
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
999
|
+
function IotaNameNftImage({
|
|
1000
|
+
address,
|
|
1001
|
+
iotaNamesEnabled,
|
|
1002
|
+
alt = "name NFT avatar"
|
|
1003
|
+
}) {
|
|
1004
|
+
const { data: imageUrl, isLoading } = useGetIotaNameAvatar(address, iotaNamesEnabled);
|
|
1005
|
+
const [imgError, setImgError] = (0, import_react12.useState)(false);
|
|
1006
|
+
if (!iotaNamesEnabled || isLoading || !imageUrl || imgError) {
|
|
1007
|
+
return null;
|
|
1008
|
+
}
|
|
1009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", { src: imageUrl, alt, className: image, onError: () => setImgError(true) });
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/components/AccountDropdownMenu.tsx
|
|
1013
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
929
1014
|
function AccountDropdownMenu({
|
|
930
1015
|
currentAccount,
|
|
931
1016
|
size = "lg",
|
|
@@ -935,13 +1020,20 @@ function AccountDropdownMenu({
|
|
|
935
1020
|
const accounts = useAccounts();
|
|
936
1021
|
const { data: iotaName } = useGetDefaultIotaName(currentAccount.address, iotaNamesEnabled);
|
|
937
1022
|
const displayAccount = iotaName ?? currentAccount.label ?? (0, import_utils.formatAddress)(currentAccount.address);
|
|
938
|
-
return /* @__PURE__ */ (0,
|
|
939
|
-
/* @__PURE__ */ (0,
|
|
940
|
-
/* @__PURE__ */ (0,
|
|
941
|
-
|
|
1023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropdownMenu.Root, { modal: false, children: [
|
|
1024
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Button, { size, className: connectedAccount, children: [
|
|
1025
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1026
|
+
IotaNameNftImage,
|
|
1027
|
+
{
|
|
1028
|
+
address: currentAccount.address,
|
|
1029
|
+
iotaNamesEnabled
|
|
1030
|
+
}
|
|
1031
|
+
),
|
|
1032
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { mono: true, weight: "bold", className: accountName, children: displayAccount }),
|
|
1033
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ChevronIcon, {})
|
|
942
1034
|
] }) }) }),
|
|
943
|
-
/* @__PURE__ */ (0,
|
|
944
|
-
/* @__PURE__ */ (0,
|
|
1035
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownMenu.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(StyleMarker, { className: menuContainer, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropdownMenu.Content, { className: menuContent, children: [
|
|
1036
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: scrollableContent, children: accounts.map((account) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
945
1037
|
AccountDropdownMenuItem,
|
|
946
1038
|
{
|
|
947
1039
|
account,
|
|
@@ -950,8 +1042,8 @@ function AccountDropdownMenu({
|
|
|
950
1042
|
},
|
|
951
1043
|
account.address
|
|
952
1044
|
)) }),
|
|
953
|
-
/* @__PURE__ */ (0,
|
|
954
|
-
/* @__PURE__ */ (0,
|
|
1045
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DropdownMenu.Separator, { className: separator }),
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
955
1047
|
DropdownMenu.Item,
|
|
956
1048
|
{
|
|
957
1049
|
className: (0, import_clsx7.default)(menuItem),
|
|
@@ -970,21 +1062,24 @@ function AccountDropdownMenuItem({
|
|
|
970
1062
|
const { mutate: switchAccount } = useSwitchAccount();
|
|
971
1063
|
const { data: iotaName } = useGetDefaultIotaName(account.address, iotaNamesEnabled);
|
|
972
1064
|
const displayAccount = iotaName ?? account.label ?? (0, import_utils.formatAddress)(account.address);
|
|
973
|
-
return /* @__PURE__ */ (0,
|
|
1065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
974
1066
|
DropdownMenu.Item,
|
|
975
1067
|
{
|
|
976
1068
|
className: (0, import_clsx7.default)(menuItem, switchAccountMenuItem),
|
|
977
1069
|
onSelect: () => switchAccount({ account }),
|
|
978
1070
|
children: [
|
|
979
|
-
/* @__PURE__ */ (0,
|
|
980
|
-
|
|
1071
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: accountIdentity, children: [
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(IotaNameNftImage, { address: account.address, iotaNamesEnabled }),
|
|
1073
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Text, { mono: true, className: accountNameMenuItem, children: displayAccount })
|
|
1074
|
+
] }),
|
|
1075
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CheckIcon, {}) : null
|
|
981
1076
|
]
|
|
982
1077
|
}
|
|
983
1078
|
);
|
|
984
1079
|
}
|
|
985
1080
|
|
|
986
1081
|
// src/components/ConnectButton.tsx
|
|
987
|
-
var
|
|
1082
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
988
1083
|
function ConnectButton({
|
|
989
1084
|
connectText = "Connect Wallet",
|
|
990
1085
|
size,
|
|
@@ -993,24 +1088,24 @@ function ConnectButton({
|
|
|
993
1088
|
...buttonProps
|
|
994
1089
|
}) {
|
|
995
1090
|
const currentAccount = useCurrentAccount();
|
|
996
|
-
return currentAccount ? /* @__PURE__ */ (0,
|
|
1091
|
+
return currentAccount ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
997
1092
|
AccountDropdownMenu,
|
|
998
1093
|
{
|
|
999
1094
|
currentAccount,
|
|
1000
1095
|
size,
|
|
1001
1096
|
iotaNamesEnabled
|
|
1002
1097
|
}
|
|
1003
|
-
) : /* @__PURE__ */ (0,
|
|
1098
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1004
1099
|
ConnectModal,
|
|
1005
1100
|
{
|
|
1006
1101
|
onConnected,
|
|
1007
|
-
trigger: /* @__PURE__ */ (0,
|
|
1102
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { ...buttonProps, size, children: connectText }) })
|
|
1008
1103
|
}
|
|
1009
1104
|
);
|
|
1010
1105
|
}
|
|
1011
1106
|
|
|
1012
1107
|
// src/components/WalletProvider.tsx
|
|
1013
|
-
var
|
|
1108
|
+
var import_react17 = require("react");
|
|
1014
1109
|
|
|
1015
1110
|
// src/utils/stateStorage.ts
|
|
1016
1111
|
function createInMemoryStore() {
|
|
@@ -1039,8 +1134,8 @@ var WALLET_CHROME_EXTENSION_ID = "iidjkmdceolghepehaaddojmnjnkkija";
|
|
|
1039
1134
|
var WALLET_DOWNLOAD_URL = "https://chromewebstore.google.com/detail/" + WALLET_CHROME_EXTENSION_ID;
|
|
1040
1135
|
|
|
1041
1136
|
// src/hooks/wallet/useAutoConnectWallet.ts
|
|
1042
|
-
var
|
|
1043
|
-
var
|
|
1137
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
1138
|
+
var import_react13 = require("react");
|
|
1044
1139
|
function useAutoConnectWallet() {
|
|
1045
1140
|
const { mutateAsync: connectWallet } = useConnectWallet();
|
|
1046
1141
|
const autoConnectEnabled = useWalletStore((state) => state.autoConnectEnabled);
|
|
@@ -1050,11 +1145,11 @@ function useAutoConnectWallet() {
|
|
|
1050
1145
|
);
|
|
1051
1146
|
const wallets = useWallets();
|
|
1052
1147
|
const { isConnected } = useCurrentWallet();
|
|
1053
|
-
const [clientOnly, setClientOnly] = (0,
|
|
1054
|
-
(0,
|
|
1148
|
+
const [clientOnly, setClientOnly] = (0, import_react13.useState)(false);
|
|
1149
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
1055
1150
|
setClientOnly(true);
|
|
1056
1151
|
}, []);
|
|
1057
|
-
const { data, isError } = (0,
|
|
1152
|
+
const { data, isError } = (0, import_react_query6.useQuery)({
|
|
1058
1153
|
queryKey: [
|
|
1059
1154
|
"@iota/dapp-kit",
|
|
1060
1155
|
"autoconnect",
|
|
@@ -1118,11 +1213,11 @@ var import_ed25519 = require("@iota/iota-sdk/keypairs/ed25519");
|
|
|
1118
1213
|
var import_transactions = require("@iota/iota-sdk/transactions");
|
|
1119
1214
|
var import_utils2 = require("@iota/iota-sdk/utils");
|
|
1120
1215
|
var import_wallet_standard3 = require("@iota/wallet-standard");
|
|
1121
|
-
var
|
|
1216
|
+
var import_react14 = require("react");
|
|
1122
1217
|
var WALLET_NAME = "Unsafe Burner Wallet";
|
|
1123
1218
|
function useUnsafeBurnerWallet(enabled) {
|
|
1124
1219
|
const iotaClient = useIotaClient();
|
|
1125
|
-
(0,
|
|
1220
|
+
(0, import_react14.useEffect)(() => {
|
|
1126
1221
|
if (!enabled) {
|
|
1127
1222
|
return;
|
|
1128
1223
|
}
|
|
@@ -1249,11 +1344,11 @@ function registerUnsafeBurnerWallet(iotaClient) {
|
|
|
1249
1344
|
}
|
|
1250
1345
|
|
|
1251
1346
|
// src/hooks/wallet/useWalletPropertiesChanged.ts
|
|
1252
|
-
var
|
|
1347
|
+
var import_react15 = require("react");
|
|
1253
1348
|
function useWalletPropertiesChanged() {
|
|
1254
1349
|
const { currentWallet } = useCurrentWallet();
|
|
1255
1350
|
const updateWalletAccounts = useWalletStore((state) => state.updateWalletAccounts);
|
|
1256
|
-
(0,
|
|
1351
|
+
(0, import_react15.useEffect)(() => {
|
|
1257
1352
|
const unsubscribeFromEvents = currentWallet?.features["standard:events"].on(
|
|
1258
1353
|
"change",
|
|
1259
1354
|
({ accounts }) => {
|
|
@@ -1268,11 +1363,11 @@ function useWalletPropertiesChanged() {
|
|
|
1268
1363
|
|
|
1269
1364
|
// src/hooks/wallet/useWalletsChanged.ts
|
|
1270
1365
|
var import_wallet_standard4 = require("@iota/wallet-standard");
|
|
1271
|
-
var
|
|
1366
|
+
var import_react16 = require("react");
|
|
1272
1367
|
function useWalletsChanged(preferredWallets, walletFilter) {
|
|
1273
1368
|
const setWalletRegistered = useWalletStore((state) => state.setWalletRegistered);
|
|
1274
1369
|
const setWalletUnregistered = useWalletStore((state) => state.setWalletUnregistered);
|
|
1275
|
-
(0,
|
|
1370
|
+
(0, import_react16.useEffect)(() => {
|
|
1276
1371
|
const walletsApi = (0, import_wallet_standard4.getWallets)();
|
|
1277
1372
|
setWalletRegistered(getRegisteredWallets(preferredWallets, walletFilter));
|
|
1278
1373
|
const unsubscribeFromRegister = walletsApi.on("register", () => {
|
|
@@ -1528,10 +1623,10 @@ var themeVars = (0, import_css.createGlobalThemeContract)(
|
|
|
1528
1623
|
);
|
|
1529
1624
|
|
|
1530
1625
|
// src/components/styling/InjectedThemeStyles.tsx
|
|
1531
|
-
var
|
|
1626
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1532
1627
|
function InjectedThemeStyles({ theme }) {
|
|
1533
1628
|
const themeStyles = Array.isArray(theme) ? getDynamicThemeStyles(theme) : getStaticThemeStyles(theme);
|
|
1534
|
-
return /* @__PURE__ */ (0,
|
|
1629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1535
1630
|
"style",
|
|
1536
1631
|
{
|
|
1537
1632
|
precedence: "default",
|
|
@@ -1557,7 +1652,7 @@ function cssStringFromTheme(theme) {
|
|
|
1557
1652
|
}
|
|
1558
1653
|
|
|
1559
1654
|
// src/components/WalletProvider.tsx
|
|
1560
|
-
var
|
|
1655
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1561
1656
|
function WalletProvider({
|
|
1562
1657
|
preferredWallets = DEFAULT_PREFERRED_WALLETS,
|
|
1563
1658
|
walletFilter = DEFAULT_WALLET_FILTER,
|
|
@@ -1569,7 +1664,7 @@ function WalletProvider({
|
|
|
1569
1664
|
children,
|
|
1570
1665
|
chain
|
|
1571
1666
|
}) {
|
|
1572
|
-
const storeRef = (0,
|
|
1667
|
+
const storeRef = (0, import_react17.useRef)(
|
|
1573
1668
|
createWalletStore({
|
|
1574
1669
|
autoConnectEnabled: autoConnect,
|
|
1575
1670
|
wallets: getRegisteredWallets(preferredWallets, walletFilter),
|
|
@@ -1581,14 +1676,14 @@ function WalletProvider({
|
|
|
1581
1676
|
if (storeRef.current.getState().chain != chain) {
|
|
1582
1677
|
storeRef.current.getState().setChain(chain);
|
|
1583
1678
|
}
|
|
1584
|
-
return /* @__PURE__ */ (0,
|
|
1679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(WalletContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1585
1680
|
WalletConnectionManager,
|
|
1586
1681
|
{
|
|
1587
1682
|
preferredWallets,
|
|
1588
1683
|
walletFilter,
|
|
1589
1684
|
enableUnsafeBurner,
|
|
1590
1685
|
children: [
|
|
1591
|
-
theme ? /* @__PURE__ */ (0,
|
|
1686
|
+
theme ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(InjectedThemeStyles, { theme }) : null,
|
|
1592
1687
|
children
|
|
1593
1688
|
]
|
|
1594
1689
|
}
|
|
@@ -1633,14 +1728,14 @@ function createNetworkConfig(networkConfig) {
|
|
|
1633
1728
|
}
|
|
1634
1729
|
|
|
1635
1730
|
// src/hooks/useIotaClientInfiniteQuery.ts
|
|
1636
|
-
var
|
|
1731
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
1637
1732
|
function useIotaClientInfiniteQuery(method, params, {
|
|
1638
1733
|
queryKey = [],
|
|
1639
1734
|
enabled = !!params,
|
|
1640
1735
|
...options
|
|
1641
1736
|
} = {}) {
|
|
1642
1737
|
const iotaContext = useIotaClientContext();
|
|
1643
|
-
return (0,
|
|
1738
|
+
return (0, import_react_query7.useInfiniteQuery)({
|
|
1644
1739
|
...options,
|
|
1645
1740
|
initialPageParam: null,
|
|
1646
1741
|
queryKey: [iotaContext.network, method, params, ...queryKey],
|
|
@@ -1654,10 +1749,10 @@ function useIotaClientInfiniteQuery(method, params, {
|
|
|
1654
1749
|
}
|
|
1655
1750
|
|
|
1656
1751
|
// src/hooks/useIotaClientMutation.ts
|
|
1657
|
-
var
|
|
1752
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
1658
1753
|
function useIotaClientMutation(method, options = {}) {
|
|
1659
1754
|
const iotaContext = useIotaClientContext();
|
|
1660
|
-
return (0,
|
|
1755
|
+
return (0, import_react_query8.useMutation)({
|
|
1661
1756
|
...options,
|
|
1662
1757
|
mutationFn: async (params) => {
|
|
1663
1758
|
return await iotaContext.client[method](params);
|
|
@@ -1666,8 +1761,8 @@ function useIotaClientMutation(method, options = {}) {
|
|
|
1666
1761
|
}
|
|
1667
1762
|
|
|
1668
1763
|
// src/hooks/useIotaClientQuery.ts
|
|
1669
|
-
var
|
|
1670
|
-
var
|
|
1764
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
1765
|
+
var import_react18 = require("react");
|
|
1671
1766
|
function getIotaClientQuery({
|
|
1672
1767
|
client,
|
|
1673
1768
|
network,
|
|
@@ -1675,7 +1770,7 @@ function getIotaClientQuery({
|
|
|
1675
1770
|
params,
|
|
1676
1771
|
options
|
|
1677
1772
|
}) {
|
|
1678
|
-
return (0,
|
|
1773
|
+
return (0, import_react_query9.queryOptions)({
|
|
1679
1774
|
...options,
|
|
1680
1775
|
queryKey: [network, method, params],
|
|
1681
1776
|
queryFn: async () => {
|
|
@@ -1686,7 +1781,7 @@ function getIotaClientQuery({
|
|
|
1686
1781
|
function useIotaClientQuery(...args) {
|
|
1687
1782
|
const [method, params, { queryKey = [], ...options } = {}] = args;
|
|
1688
1783
|
const iotaContext = useIotaClientContext();
|
|
1689
|
-
return (0,
|
|
1784
|
+
return (0, import_react_query9.useQuery)({
|
|
1690
1785
|
...options,
|
|
1691
1786
|
queryKey: [iotaContext.network, method, params, ...queryKey],
|
|
1692
1787
|
queryFn: async () => {
|
|
@@ -1699,7 +1794,7 @@ function useIotaClientQuery(...args) {
|
|
|
1699
1794
|
function useIotaClientSuspenseQuery(...args) {
|
|
1700
1795
|
const [method, params, options = {}] = args;
|
|
1701
1796
|
const iotaContext = useIotaClientContext();
|
|
1702
|
-
const query = (0,
|
|
1797
|
+
const query = (0, import_react18.useMemo)(() => {
|
|
1703
1798
|
return getIotaClientQuery({
|
|
1704
1799
|
client: iotaContext.client,
|
|
1705
1800
|
network: iotaContext.network,
|
|
@@ -1708,17 +1803,17 @@ function useIotaClientSuspenseQuery(...args) {
|
|
|
1708
1803
|
options
|
|
1709
1804
|
});
|
|
1710
1805
|
}, [iotaContext.network, method, params, options]);
|
|
1711
|
-
return (0,
|
|
1806
|
+
return (0, import_react_query9.useSuspenseQuery)(query);
|
|
1712
1807
|
}
|
|
1713
1808
|
|
|
1714
1809
|
// src/hooks/useIotaClientQueries.ts
|
|
1715
|
-
var
|
|
1810
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
1716
1811
|
function useIotaClientQueries({
|
|
1717
1812
|
queries,
|
|
1718
1813
|
combine
|
|
1719
1814
|
}) {
|
|
1720
1815
|
const iotaContext = useIotaClientContext();
|
|
1721
|
-
return (0,
|
|
1816
|
+
return (0, import_react_query10.useQueries)({
|
|
1722
1817
|
combine,
|
|
1723
1818
|
queries: queries.map((query) => {
|
|
1724
1819
|
const { method, params, options: { queryKey = [], ...restOptions } = {} } = query;
|
|
@@ -1736,18 +1831,18 @@ function useIotaClientQueries({
|
|
|
1736
1831
|
// src/hooks/wallet/useSignAndExecuteTransaction.ts
|
|
1737
1832
|
var import_utils4 = require("@iota/iota-sdk/utils");
|
|
1738
1833
|
var import_wallet_standard5 = require("@iota/wallet-standard");
|
|
1739
|
-
var
|
|
1834
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
1740
1835
|
|
|
1741
1836
|
// src/hooks/wallet/useReportTransactionEffects.ts
|
|
1742
1837
|
var import_utils3 = require("@iota/iota-sdk/utils");
|
|
1743
|
-
var
|
|
1838
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
1744
1839
|
function useReportTransactionEffects({
|
|
1745
1840
|
mutationKey,
|
|
1746
1841
|
...mutationOptions
|
|
1747
1842
|
} = {}) {
|
|
1748
1843
|
const { currentWallet } = useCurrentWallet();
|
|
1749
1844
|
const currentAccount = useCurrentAccount();
|
|
1750
|
-
return (0,
|
|
1845
|
+
return (0, import_react_query11.useMutation)({
|
|
1751
1846
|
mutationKey: walletMutationKeys.reportTransactionEffects(mutationKey),
|
|
1752
1847
|
mutationFn: async ({
|
|
1753
1848
|
effects,
|
|
@@ -1807,7 +1902,7 @@ function useSignAndExecuteTransaction({
|
|
|
1807
1902
|
signature
|
|
1808
1903
|
};
|
|
1809
1904
|
});
|
|
1810
|
-
return (0,
|
|
1905
|
+
return (0, import_react_query12.useMutation)({
|
|
1811
1906
|
mutationKey: walletMutationKeys.signAndExecuteTransaction(mutationKey),
|
|
1812
1907
|
mutationFn: async ({ transaction, ...signTransactionArgs }) => {
|
|
1813
1908
|
if (!currentWallet) {
|
|
@@ -1860,14 +1955,14 @@ function useSignAndExecuteTransaction({
|
|
|
1860
1955
|
}
|
|
1861
1956
|
|
|
1862
1957
|
// src/hooks/wallet/useSignPersonalMessage.ts
|
|
1863
|
-
var
|
|
1958
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
1864
1959
|
function useSignPersonalMessage({
|
|
1865
1960
|
mutationKey,
|
|
1866
1961
|
...mutationOptions
|
|
1867
1962
|
} = {}) {
|
|
1868
1963
|
const { currentWallet } = useCurrentWallet();
|
|
1869
1964
|
const currentAccount = useCurrentAccount();
|
|
1870
|
-
return (0,
|
|
1965
|
+
return (0, import_react_query13.useMutation)({
|
|
1871
1966
|
mutationKey: walletMutationKeys.signPersonalMessage(mutationKey),
|
|
1872
1967
|
mutationFn: async (signPersonalMessageArgs) => {
|
|
1873
1968
|
if (!currentWallet) {
|
|
@@ -1896,7 +1991,7 @@ function useSignPersonalMessage({
|
|
|
1896
1991
|
|
|
1897
1992
|
// src/hooks/wallet/useSignTransaction.ts
|
|
1898
1993
|
var import_wallet_standard6 = require("@iota/wallet-standard");
|
|
1899
|
-
var
|
|
1994
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
1900
1995
|
function useSignTransaction({
|
|
1901
1996
|
mutationKey,
|
|
1902
1997
|
...mutationOptions
|
|
@@ -1905,7 +2000,7 @@ function useSignTransaction({
|
|
|
1905
2000
|
const currentAccount = useCurrentAccount();
|
|
1906
2001
|
const client = useIotaClient();
|
|
1907
2002
|
const { mutate: reportTransactionEffects } = useReportTransactionEffects();
|
|
1908
|
-
return (0,
|
|
2003
|
+
return (0, import_react_query14.useMutation)({
|
|
1909
2004
|
mutationKey: walletMutationKeys.signTransaction(mutationKey),
|
|
1910
2005
|
mutationFn: async ({ transaction, ...signTransactionArgs }) => {
|
|
1911
2006
|
if (!currentWallet) {
|