@orderly.network/wallet-connector-privy 2.3.2 → 2.4.0-alpha.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/dist/index.js CHANGED
@@ -432,20 +432,18 @@ var useSolanaWalletStore = zustand.create((set, get) => ({
432
432
  try {
433
433
  set({ isConnecting: true, error: null });
434
434
  const { walletSolana, select } = walletMethods;
435
- if (!walletSolana) {
436
- select(walletName);
437
- await new Promise((resolve) => {
438
- const checkWallet = () => {
439
- const currentWallet = get().walletMethods?.walletSolana;
440
- if (currentWallet) {
441
- resolve();
442
- } else {
443
- setTimeout(checkWallet, 500);
444
- }
445
- };
446
- checkWallet();
447
- });
448
- }
435
+ select(walletName);
436
+ await new Promise((resolve) => {
437
+ const checkWallet = () => {
438
+ const currentWallet = get().walletMethods?.walletSolana;
439
+ if (currentWallet) {
440
+ resolve();
441
+ } else {
442
+ setTimeout(checkWallet, 500);
443
+ }
444
+ };
445
+ checkWallet();
446
+ });
449
447
  const updatedWalletMethods = get().walletMethods;
450
448
  if (!updatedWalletMethods) {
451
449
  throw new Error("Wallet methods not initialized");
@@ -457,6 +455,9 @@ var useSolanaWalletStore = zustand.create((set, get) => ({
457
455
  if (!lastestWalletMethods) {
458
456
  throw new Error("Wallet methods not initialized");
459
457
  }
458
+ if (!lastestWalletMethods.publicKey) {
459
+ throw new Error("Wallet not connected");
460
+ }
460
461
  const wallet = {
461
462
  label: updatedWalletMethods.walletSolana.adapter.name,
462
463
  icon: "",
@@ -469,7 +470,7 @@ var useSolanaWalletStore = zustand.create((set, get) => ({
469
470
  },
470
471
  accounts: [
471
472
  {
472
- address: updatedWalletMethods.publicKey.toBase58()
473
+ address: lastestWalletMethods.publicKey.toBase58()
473
474
  }
474
475
  ],
475
476
  chains: [
@@ -563,7 +564,6 @@ var SolanaWalletProvider = ({
563
564
  if (!walletSolana || isManual)
564
565
  return;
565
566
  if (!publicKey) {
566
- connectSolana();
567
567
  return;
568
568
  }
569
569
  const newWallet = {
@@ -1137,7 +1137,71 @@ function PrivyConnectArea({
1137
1137
  }) {
1138
1138
  const { t } = i18n.useTranslation();
1139
1139
  const { isMobile, isDesktop } = ui.useScreen();
1140
- const { connectorWalletType } = useWalletConnectorPrivy();
1140
+ const { connectorWalletType, privyConfig } = useWalletConnectorPrivy();
1141
+ const loginMethods = privyConfig.loginMethods;
1142
+ const renderLoginMethodsDom = () => {
1143
+ const arr = [];
1144
+ if (loginMethods?.includes("email")) {
1145
+ arr.push(
1146
+ /* @__PURE__ */ React19__default.default.createElement(
1147
+ "div",
1148
+ {
1149
+ className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#333948] oui-px-2 oui-py-[11px]",
1150
+ onClick: () => connect({ walletType: "privy", extraType: "email" })
1151
+ },
1152
+ /* @__PURE__ */ React19__default.default.createElement(
1153
+ "img",
1154
+ {
1155
+ src: "https://oss.orderly.network/static/sdk/privy/email.svg",
1156
+ className: "oui-size-[18px]"
1157
+ }
1158
+ ),
1159
+ /* @__PURE__ */ React19__default.default.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.email"))
1160
+ )
1161
+ );
1162
+ }
1163
+ if (loginMethods?.includes("google")) {
1164
+ arr.push(
1165
+ /* @__PURE__ */ React19__default.default.createElement(
1166
+ "div",
1167
+ {
1168
+ className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#335FFC] oui-px-2 oui-py-[11px]",
1169
+ onClick: () => connect({ walletType: "privy", extraType: "google" })
1170
+ },
1171
+ /* @__PURE__ */ React19__default.default.createElement(
1172
+ "img",
1173
+ {
1174
+ src: "https://oss.orderly.network/static/sdk/privy/google.svg",
1175
+ className: "oui-size-[18px]"
1176
+ }
1177
+ ),
1178
+ /* @__PURE__ */ React19__default.default.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.google"))
1179
+ )
1180
+ );
1181
+ }
1182
+ if (loginMethods?.includes("twitter")) {
1183
+ arr.push(
1184
+ /* @__PURE__ */ React19__default.default.createElement(
1185
+ "div",
1186
+ {
1187
+ className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]",
1188
+ onClick: () => connect({ walletType: "privy", extraType: "twitter" })
1189
+ },
1190
+ /* @__PURE__ */ React19__default.default.createElement(
1191
+ "img",
1192
+ {
1193
+ src: "https://oss.orderly.network/static/sdk/privy/twitter.svg",
1194
+ className: "oui-size-[18px]"
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ React19__default.default.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.twitter"))
1198
+ )
1199
+ );
1200
+ }
1201
+ return arr.map((item, index) => {
1202
+ return /* @__PURE__ */ React19__default.default.createElement("div", { key: index }, item);
1203
+ });
1204
+ };
1141
1205
  return /* @__PURE__ */ React19__default.default.createElement("div", { className: "" }, /* @__PURE__ */ React19__default.default.createElement(
1142
1206
  "div",
1143
1207
  {
@@ -1163,51 +1227,7 @@ function PrivyConnectArea({
1163
1227
  "md:oui-flex md:oui-flex-col md:oui-gap-2"
1164
1228
  )
1165
1229
  },
1166
- /* @__PURE__ */ React19__default.default.createElement(
1167
- "div",
1168
- {
1169
- className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#333948] oui-px-2 oui-py-[11px]",
1170
- onClick: () => connect({ walletType: "privy", extraType: "email" })
1171
- },
1172
- /* @__PURE__ */ React19__default.default.createElement(
1173
- "img",
1174
- {
1175
- src: "https://oss.orderly.network/static/sdk/privy/email.svg",
1176
- className: "oui-size-[18px]"
1177
- }
1178
- ),
1179
- /* @__PURE__ */ React19__default.default.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.email"))
1180
- ),
1181
- /* @__PURE__ */ React19__default.default.createElement(
1182
- "div",
1183
- {
1184
- className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#335FFC] oui-px-2 oui-py-[11px]",
1185
- onClick: () => connect({ walletType: "privy", extraType: "google" })
1186
- },
1187
- /* @__PURE__ */ React19__default.default.createElement(
1188
- "img",
1189
- {
1190
- src: "https://oss.orderly.network/static/sdk/privy/google.svg",
1191
- className: "oui-size-[18px]"
1192
- }
1193
- ),
1194
- /* @__PURE__ */ React19__default.default.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.google"))
1195
- ),
1196
- /* @__PURE__ */ React19__default.default.createElement(
1197
- "div",
1198
- {
1199
- className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]",
1200
- onClick: () => connect({ walletType: "privy", extraType: "twitter" })
1201
- },
1202
- /* @__PURE__ */ React19__default.default.createElement(
1203
- "img",
1204
- {
1205
- src: "https://oss.orderly.network/static/sdk/privy/twitter.svg",
1206
- className: "oui-size-[18px]"
1207
- }
1208
- ),
1209
- /* @__PURE__ */ React19__default.default.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.twitter"))
1210
- )
1230
+ renderLoginMethodsDom()
1211
1231
  ), isDesktop && /* @__PURE__ */ React19__default.default.createElement("div", { className: "oui-mt-4 oui-flex oui-h-3 oui-justify-center" }, /* @__PURE__ */ React19__default.default.createElement(
1212
1232
  "img",
1213
1233
  {
@@ -2674,7 +2694,7 @@ function InitSolanaProvider({
2674
2694
  network: network === "mainnet" ? walletAdapterBase.WalletAdapterNetwork.Mainnet : walletAdapterBase.WalletAdapterNetwork.Devnet
2675
2695
  });
2676
2696
  }, [network, mainnetRpc, devnetRpc, setSolanaInfo]);
2677
- return /* @__PURE__ */ React19__default.default.createElement(walletAdapterReact.WalletProvider, { wallets, onError }, children);
2697
+ return /* @__PURE__ */ React19__default.default.createElement(walletAdapterReact.WalletProvider, { wallets, onError, autoConnect: true }, children);
2678
2698
  }
2679
2699
 
2680
2700
  // src/providers/solana/index.tsx
@@ -2784,9 +2804,17 @@ var WalletConnectorPrivyContext = React19.createContext({
2784
2804
  disablePrivy: false,
2785
2805
  disableSolana: false,
2786
2806
  disableAGW: false
2807
+ },
2808
+ privyConfig: {
2809
+ loginMethods: []
2787
2810
  }
2788
2811
  });
2789
2812
  var useWalletConnectorPrivy = () => React19.useContext(WalletConnectorPrivyContext);
2813
+ var defaultPrivyLoginMethod = [
2814
+ "email",
2815
+ "google",
2816
+ "twitter"
2817
+ ];
2790
2818
  function WalletConnectorPrivyProvider(props) {
2791
2819
  const [walletChainType, setWalletChainType] = React19.useState(
2792
2820
  "EVM_SOL" /* EVM_SOL */
@@ -2799,6 +2827,9 @@ function WalletConnectorPrivyProvider(props) {
2799
2827
  const initRef = React19.useRef(false);
2800
2828
  const [openConnectDrawer, setOpenConnectDrawer] = React19.useState(false);
2801
2829
  const [targetWalletType, setTargetWalletType] = React19.useState();
2830
+ const [privyConfig, setPrivyConfig] = React19.useState({
2831
+ loginMethods: props.privyConfig ? props.privyConfig?.config?.loginMethods ?? defaultPrivyLoginMethod : defaultPrivyLoginMethod
2832
+ });
2802
2833
  const [solanaInfo, setSolanaInfo] = React19.useState(null);
2803
2834
  const connectorWalletType = React19.useMemo(() => {
2804
2835
  const type = {
@@ -2923,7 +2954,8 @@ function WalletConnectorPrivyProvider(props) {
2923
2954
  termsOfUse,
2924
2955
  walletChainType,
2925
2956
  connectorWalletType,
2926
- walletChainTypeConfig
2957
+ walletChainTypeConfig,
2958
+ privyConfig
2927
2959
  }),
2928
2960
  [
2929
2961
  initChains,
@@ -2941,7 +2973,8 @@ function WalletConnectorPrivyProvider(props) {
2941
2973
  termsOfUse,
2942
2974
  walletChainType,
2943
2975
  connectorWalletType,
2944
- walletChainTypeConfig
2976
+ walletChainTypeConfig,
2977
+ privyConfig
2945
2978
  ]
2946
2979
  );
2947
2980
  React19.useEffect(() => {