@lukso/up-connector 0.5.1-dev.e515cef → 0.5.1

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.
Files changed (34) hide show
  1. package/dist/auto-setup.cjs +3 -3
  2. package/dist/auto-setup.js +2 -2
  3. package/dist/{chunk-SAQWNAQ6.js → chunk-3ME6PKYE.js} +80 -138
  4. package/dist/chunk-3ME6PKYE.js.map +1 -0
  5. package/dist/{chunk-KMCCANMJ.js → chunk-5P7EGEE5.js} +4 -4
  6. package/dist/{chunk-KMCCANMJ.js.map → chunk-5P7EGEE5.js.map} +1 -1
  7. package/dist/{chunk-GCYDV7FB.cjs → chunk-CN2BMW6Y.cjs} +101 -159
  8. package/dist/chunk-CN2BMW6Y.cjs.map +1 -0
  9. package/dist/{chunk-W7QI6BTA.cjs → chunk-M4UJAKZ2.cjs} +3 -3
  10. package/dist/{chunk-W7QI6BTA.cjs.map → chunk-M4UJAKZ2.cjs.map} +1 -1
  11. package/dist/connect-modal/index.cjs +2 -4
  12. package/dist/connect-modal/index.cjs.map +1 -1
  13. package/dist/connect-modal/index.d.cts +1 -1
  14. package/dist/connect-modal/index.d.ts +1 -1
  15. package/dist/connect-modal/index.js +9 -11
  16. package/dist/index.cjs +16 -24
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +23 -31
  21. package/dist/index.js.map +1 -1
  22. package/dist/{wagmi-DgjkdmGk.d.cts → wagmi-BLnqILO_.d.cts} +21 -77
  23. package/dist/{wagmi-DgjkdmGk.d.ts → wagmi-BLnqILO_.d.ts} +21 -77
  24. package/package.json +5 -5
  25. package/src/connect-modal/components/connection-view.ts +1 -4
  26. package/src/connect-modal/components/eoa-connection-view.ts +0 -4
  27. package/src/connect-modal/connect-modal.types.ts +0 -4
  28. package/src/connect-modal/index.ts +4 -6
  29. package/src/connect-modal/services/wagmi.ts +76 -176
  30. package/src/connector.ts +12 -18
  31. package/src/index.ts +4 -6
  32. package/dist/chunk-GCYDV7FB.cjs.map +0 -1
  33. package/dist/chunk-SAQWNAQ6.js.map +0 -1
  34. package/src/connect-modal/utils/chainParams.ts +0 -32
@@ -4,8 +4,8 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkW7QI6BTAcjs = require('./chunk-W7QI6BTA.cjs');
8
- require('./chunk-GCYDV7FB.cjs');
7
+ var _chunkM4UJAKZ2cjs = require('./chunk-M4UJAKZ2.cjs');
8
+ require('./chunk-CN2BMW6Y.cjs');
9
9
  require('./chunk-ZBDE64SD.cjs');
10
10
 
11
11
 
@@ -13,5 +13,5 @@ require('./chunk-ZBDE64SD.cjs');
13
13
 
14
14
 
15
15
 
16
- exports.EMBEDDED_WALLET_ID = _chunkW7QI6BTAcjs.EMBEDDED_WALLET_ID; exports.EMBEDDED_WALLET_URL_DEV = _chunkW7QI6BTAcjs.EMBEDDED_WALLET_URL_DEV; exports.EMBEDDED_WALLET_URL_PROD = _chunkW7QI6BTAcjs.EMBEDDED_WALLET_URL_PROD; exports.UP_EXTENSION_ID = _chunkW7QI6BTAcjs.UP_EXTENSION_ID; exports.setupLuksoConnector = _chunkW7QI6BTAcjs.setupLuksoConnector;
16
+ exports.EMBEDDED_WALLET_ID = _chunkM4UJAKZ2cjs.EMBEDDED_WALLET_ID; exports.EMBEDDED_WALLET_URL_DEV = _chunkM4UJAKZ2cjs.EMBEDDED_WALLET_URL_DEV; exports.EMBEDDED_WALLET_URL_PROD = _chunkM4UJAKZ2cjs.EMBEDDED_WALLET_URL_PROD; exports.UP_EXTENSION_ID = _chunkM4UJAKZ2cjs.UP_EXTENSION_ID; exports.setupLuksoConnector = _chunkM4UJAKZ2cjs.setupLuksoConnector;
17
17
  //# sourceMappingURL=auto-setup.cjs.map
@@ -4,8 +4,8 @@ import {
4
4
  EMBEDDED_WALLET_URL_PROD,
5
5
  UP_EXTENSION_ID,
6
6
  setupLuksoConnector
7
- } from "./chunk-KMCCANMJ.js";
8
- import "./chunk-SAQWNAQ6.js";
7
+ } from "./chunk-5P7EGEE5.js";
8
+ import "./chunk-3ME6PKYE.js";
9
9
  import "./chunk-EUXUH3YW.js";
10
10
  export {
11
11
  EMBEDDED_WALLET_ID,
@@ -20,89 +20,14 @@ var ConnectModalBase = class extends LitElement {
20
20
 
21
21
  // src/connect-modal/connect-modal.ts
22
22
  import { withDeviceService as withDeviceService3 } from "@lukso/core/mixins";
23
- import debug4 from "debug";
23
+ import debug3 from "debug";
24
24
  import { html as html5 } from "lit";
25
25
  import { property as property4, state as state2 } from "lit/decorators.js";
26
26
 
27
27
  // src/connect-modal/services/wagmi.ts
28
- import { getChainById } from "@lukso/core/chains";
29
28
  import { slug } from "@lukso/core/utils";
30
- import debug from "debug";
31
-
32
- // src/connect-modal/utils/chainParams.ts
33
- function constructAddEthereumChainParameter(chain) {
34
- return {
35
- chainName: chain.name,
36
- nativeCurrency: {
37
- name: chain.nativeCurrency.name,
38
- symbol: chain.nativeCurrency.symbol,
39
- decimals: chain.nativeCurrency.decimals
40
- },
41
- rpcUrls: [...chain.rpcUrls.default.http],
42
- blockExplorerUrls: chain.blockExplorers?.default.url ? [chain.blockExplorers.default.url] : void 0
43
- };
44
- }
45
-
46
- // src/connect-modal/services/wagmi.ts
47
- var logInfo = debug("connect-modal:info");
48
29
  var UP_EXTENSION_ID = "cloud.universalprofile";
49
- var WagmiService = class {
50
- constructor() {
51
- this.setup = null;
52
- this.wagmiCore = null;
53
- }
54
- configure(setup) {
55
- this.setup = setup;
56
- }
57
- getSetup() {
58
- return this.setup;
59
- }
60
- /**
61
- * Ensure wagmi/core is loaded and return initialized state
62
- * Returns { core, config } if ready, null otherwise
63
- */
64
- async init() {
65
- if (!this.setup) return null;
66
- if (!this.wagmiCore) {
67
- try {
68
- this.wagmiCore = await import("@wagmi/core");
69
- } catch {
70
- return null;
71
- }
72
- }
73
- return { core: this.wagmiCore, config: this.setup.wagmiConfig };
74
- }
75
- async getConnection() {
76
- const wagmi = await this.init();
77
- if (!wagmi) return null;
78
- try {
79
- return wagmi.core.getConnection(wagmi.config);
80
- } catch {
81
- return null;
82
- }
83
- }
84
- async watchConnection(callback) {
85
- const wagmi = await this.init();
86
- if (!wagmi) return null;
87
- try {
88
- return wagmi.core.watchConnection(wagmi.config, { onChange: callback });
89
- } catch {
90
- return null;
91
- }
92
- }
93
- async disconnect() {
94
- const wagmi = await this.init();
95
- if (!wagmi) return false;
96
- try {
97
- await wagmi.core.disconnect(wagmi.config);
98
- return true;
99
- } catch (error) {
100
- console.warn("Failed to disconnect from wagmi", error);
101
- return false;
102
- }
103
- }
104
- };
105
- var wagmiService = new WagmiService();
30
+ var globalWagmiSetup = null;
106
31
  function fromWagmiConnector(connector, connectFn, chainId) {
107
32
  let type = "injected";
108
33
  const rdns = connector.id;
@@ -123,27 +48,7 @@ function fromWagmiConnector(connector, connectFn, chainId) {
123
48
  connect: async () => {
124
49
  await connectFn({ connector, chainId });
125
50
  },
126
- getProvider: connector.getProvider ? () => connector.getProvider() : void 0,
127
- switchChain: connector.switchChain ? async (params) => {
128
- if (!params.chainId) {
129
- console.warn("No chainId provided for switchChain, skipping");
130
- return;
131
- }
132
- let addEthereumChainParameter = params.addEthereumChainParameter;
133
- if (!addEthereumChainParameter) {
134
- const chain = getChainById(params.chainId);
135
- if (chain) {
136
- addEthereumChainParameter = constructAddEthereumChainParameter(chain);
137
- }
138
- }
139
- await connector.switchChain({
140
- chainId: params.chainId,
141
- addEthereumChainParameter
142
- });
143
- logInfo(
144
- `Switched to chainId ${params.chainId} via connector "${connector.name}"`
145
- );
146
- } : void 0
51
+ getProvider: connector.getProvider ? () => connector.getProvider() : void 0
147
52
  };
148
53
  }
149
54
  function fromWagmiConnectors(connectors, connectFn, chainId, embeddedWalletId) {
@@ -197,20 +102,62 @@ function fromWagmiConnectors(connectors, connectFn, chainId, embeddedWalletId) {
197
102
  result.push(...others);
198
103
  return result;
199
104
  }
200
- function setupWagmi(setup) {
201
- wagmiService.configure(setup);
105
+ function setupConnectModal(setup) {
106
+ globalWagmiSetup = setup;
202
107
  }
203
108
  function getWagmiSetup() {
204
- return wagmiService.getSetup();
109
+ return globalWagmiSetup;
205
110
  }
206
- async function getConnection() {
207
- return wagmiService.getConnection();
111
+ async function getWagmiAccount() {
112
+ if (!globalWagmiSetup) {
113
+ return null;
114
+ }
115
+ try {
116
+ const { getConnection } = await import("@wagmi/core");
117
+ const connection = getConnection(globalWagmiSetup.wagmiConfig);
118
+ return {
119
+ isConnected: connection.status === "connected",
120
+ address: connection.address,
121
+ chainId: connection.chainId,
122
+ connector: connection.connector
123
+ };
124
+ } catch (_error) {
125
+ return null;
126
+ }
208
127
  }
209
- async function watchConnection(callback) {
210
- return wagmiService.watchConnection(callback);
128
+ async function watchWagmiAccount(callback) {
129
+ if (!globalWagmiSetup) {
130
+ return null;
131
+ }
132
+ try {
133
+ const { watchConnection } = await import("@wagmi/core");
134
+ const unsubscribe = watchConnection(globalWagmiSetup.wagmiConfig, {
135
+ onChange: (connection) => {
136
+ callback({
137
+ isConnected: connection.status === "connected",
138
+ address: connection.address,
139
+ chainId: connection.chainId,
140
+ connector: connection.connector
141
+ });
142
+ }
143
+ });
144
+ return unsubscribe;
145
+ } catch (_error) {
146
+ return null;
147
+ }
211
148
  }
212
- async function disconnect() {
213
- return wagmiService.disconnect();
149
+ async function disconnectWagmi() {
150
+ if (!globalWagmiSetup) {
151
+ return false;
152
+ }
153
+ try {
154
+ const { disconnect } = await import("@wagmi/core");
155
+ await disconnect(globalWagmiSetup.wagmiConfig);
156
+ return true;
157
+ } catch (error) {
158
+ console.warn("Failed to disconnect from wagmi", error);
159
+ return false;
160
+ }
214
161
  }
215
162
 
216
163
  // src/connect-modal/connect-modal.ts
@@ -219,7 +166,7 @@ import "@lukso/web-components/dist/components/lukso-modal";
219
166
  // src/connect-modal/components/eoa-connection-view.ts
220
167
  import { Task } from "@lit/task";
221
168
  import { withDeviceService, withIntlService } from "@lukso/core/mixins";
222
- import debug2 from "debug";
169
+ import debug from "debug";
223
170
  import { html as html2, nothing } from "lit";
224
171
  import { property, state } from "lit/decorators.js";
225
172
  import { keyed } from "lit/directives/keyed.js";
@@ -263,7 +210,7 @@ var renderPlaceholder = (style2) => html`<div class="${cn("bg-neutral-90 dark:bg
263
210
  import "@lukso/web-components/dist/components/lukso-button";
264
211
  import "@lukso/web-components/dist/components/lukso-icon";
265
212
  import "@lukso/web-components/dist/components/lukso-tag";
266
- var logInfo2 = debug2("connect-modal:info");
213
+ var logInfo = debug("connect-modal:info");
267
214
  var EoaConnectionView = class extends withIntlService(
268
215
  withDeviceService(ConnectModalBase)
269
216
  ) {
@@ -392,10 +339,8 @@ var EoaConnectionView = class extends withIntlService(
392
339
  const connector = wallet.connector;
393
340
  if (connector) {
394
341
  try {
395
- logInfo2("Connecting via connector:", connector);
342
+ logInfo("Connecting via connector:", connector);
396
343
  this.isConnecting = true;
397
- const setup = getWagmiSetup();
398
- await connector.switchChain?.({ chainId: setup?.chainId });
399
344
  await connector.connect();
400
345
  this.dispatchEvent(
401
346
  new CustomEvent("on-connect", {
@@ -424,13 +369,13 @@ var EoaConnectionView = class extends withIntlService(
424
369
  const connector = this.walletConnectConnector;
425
370
  if (connector) {
426
371
  try {
427
- logInfo2("Connecting via WalletConnect connector:", connector);
372
+ logInfo("Connecting via WalletConnect connector:", connector);
428
373
  this.isConnecting = true;
429
374
  const connectPromise = connector.connect();
430
375
  const provider = await connector.getProvider?.();
431
376
  if (provider) {
432
377
  const handleDisplayUri = (displayUri) => {
433
- logInfo2("WalletConnect URI received:", displayUri);
378
+ logInfo("WalletConnect URI received:", displayUri);
434
379
  const encodedUri = encodeURIComponent(displayUri);
435
380
  if (wallet.mobile?.native) {
436
381
  window.location.href = `${wallet.mobile.native}wc?uri=${encodedUri}`;
@@ -567,7 +512,7 @@ import "@lukso/web-components/dist/components/lukso-button";
567
512
  import "@lukso/web-components/dist/components/lukso-icon";
568
513
  import { browserInfo } from "@lukso/core/utils";
569
514
  import { cn as cn2 } from "@lukso/web-components/tools";
570
- import debug3 from "debug";
515
+ import debug2 from "debug";
571
516
 
572
517
  // src/connect-modal/utils/walletConnectDeepLinkUrl.ts
573
518
  var walletConnectDeepLinkUrl = (data, options) => {
@@ -594,7 +539,7 @@ var walletConnectDeepLinkUrl = (data, options) => {
594
539
  };
595
540
 
596
541
  // src/connect-modal/components/connection-view.ts
597
- var logInfo3 = debug3("connect-modal:info");
542
+ var logInfo2 = debug2("connect-modal:info");
598
543
  var ConnectionView = class extends withIntlService2(
599
544
  withDeviceService2(ConnectModalBase)
600
545
  ) {
@@ -609,7 +554,7 @@ var ConnectionView = class extends withIntlService2(
609
554
  this.handleConnectEmbedded = async () => {
610
555
  const connector = this.embeddedWalletConnector;
611
556
  try {
612
- logInfo3("Connecting via connector:", connector);
557
+ logInfo2("Connecting via connector:", connector);
613
558
  await connector?.connect();
614
559
  this.dispatchEvent(
615
560
  new CustomEvent("on-connect", {
@@ -639,11 +584,9 @@ var ConnectionView = class extends withIntlService2(
639
584
  }
640
585
  if (connector) {
641
586
  try {
642
- logInfo3("Connecting via connector:", connector);
587
+ logInfo2("Connecting via connector:", connector);
643
588
  this.isConnecting = true;
644
589
  this.connectingRdns = connector.rdns;
645
- const setup = getWagmiSetup();
646
- await connector.switchChain?.({ chainId: setup?.chainId });
647
590
  await connector.connect();
648
591
  this.dispatchEvent(
649
592
  new CustomEvent("on-connect", {
@@ -673,16 +616,16 @@ var ConnectionView = class extends withIntlService2(
673
616
  const connector = this.walletConnectConnector;
674
617
  if (connector) {
675
618
  try {
676
- logInfo3("Connecting via connector:", connector);
619
+ logInfo2("Connecting via connector:", connector);
677
620
  this.isConnecting = true;
678
621
  this.connectingRdns = connector.rdns;
679
622
  const connectPromise = connector.connect();
680
623
  const provider = await connector.getProvider?.();
681
624
  if (provider) {
682
625
  const handleDisplayUri = (displayUri) => {
683
- logInfo3("WalletConnect original URI:", displayUri);
626
+ logInfo2("WalletConnect original URI:", displayUri);
684
627
  const deepLink = walletConnectDeepLinkUrl(displayUri);
685
- logInfo3("Mobile App Deep Link:", deepLink);
628
+ logInfo2("Mobile App Deep Link:", deepLink);
686
629
  if (this.device.isMobile) {
687
630
  window.open(deepLink, "_blank");
688
631
  } else {
@@ -965,7 +908,7 @@ __decorateClass([
965
908
  customElements.define("qr-code-view", QrCodeView);
966
909
 
967
910
  // src/connect-modal/connect-modal.ts
968
- var logInfo4 = debug4("connect-modal:info");
911
+ var logInfo3 = debug3("connect-modal:info");
969
912
  var ConnectModal = class extends withDeviceService3(ConnectModalBase) {
970
913
  constructor() {
971
914
  super(...arguments);
@@ -1043,9 +986,9 @@ var ConnectModal = class extends withDeviceService3(ConnectModalBase) {
1043
986
  }
1044
987
  }
1045
988
  async loadConnectors() {
1046
- const globalWagmiSetup = getWagmiSetup();
1047
- logInfo4("Global wagmi setup:", globalWagmiSetup);
1048
- if (!globalWagmiSetup) {
989
+ const globalWagmiSetup2 = getWagmiSetup();
990
+ logInfo3("Global wagmi setup:", globalWagmiSetup2);
991
+ if (!globalWagmiSetup2) {
1049
992
  console.warn(
1050
993
  "No global wagmi setup found! Call setupConnectModal() first."
1051
994
  );
@@ -1053,9 +996,9 @@ var ConnectModal = class extends withDeviceService3(ConnectModalBase) {
1053
996
  return;
1054
997
  }
1055
998
  try {
1056
- const { wagmiConfig, chainId, embeddedWalletId } = globalWagmiSetup;
999
+ const { wagmiConfig, chainId, embeddedWalletId } = globalWagmiSetup2;
1057
1000
  const wagmiConnectors = wagmiConfig?.connectors || [];
1058
- logInfo4("Initial connectors:", wagmiConnectors);
1001
+ logInfo3("Initial connectors:", wagmiConnectors);
1059
1002
  const wagmiCore = await import("@wagmi/core").catch((error) => {
1060
1003
  throw new Error("@wagmi/core is required when using wagmi connectors", {
1061
1004
  cause: error
@@ -1072,7 +1015,7 @@ var ConnectModal = class extends withDeviceService3(ConnectModalBase) {
1072
1015
  chainId,
1073
1016
  embeddedWalletId
1074
1017
  );
1075
- logInfo4("Converted connectors:", this.connectors);
1018
+ logInfo3("Converted connectors:", this.connectors);
1076
1019
  } catch (error) {
1077
1020
  console.warn("Failed to load connectors", error);
1078
1021
  this.connectors = [];
@@ -1086,7 +1029,7 @@ var ConnectModal = class extends withDeviceService3(ConnectModalBase) {
1086
1029
  handleOnConnectSuccess(event) {
1087
1030
  event.stopPropagation();
1088
1031
  const connector = event.detail.connector;
1089
- logInfo4("Connection success:", connector);
1032
+ logInfo3("Connection success:", connector);
1090
1033
  this.open = false;
1091
1034
  this.dispatchEvent(
1092
1035
  new CustomEvent("on-connect", {
@@ -1104,7 +1047,7 @@ var ConnectModal = class extends withDeviceService3(ConnectModalBase) {
1104
1047
  handleOnConnectError(event) {
1105
1048
  event.stopPropagation();
1106
1049
  const error = event.detail.error;
1107
- logInfo4("Connection error:", error);
1050
+ logInfo3("Connection error:", error);
1108
1051
  this.dispatchEvent(
1109
1052
  new CustomEvent("on-error", {
1110
1053
  detail: { error },
@@ -1187,14 +1130,13 @@ customElements.define("connect-modal", ConnectModal);
1187
1130
 
1188
1131
  export {
1189
1132
  ConnectModalBase,
1190
- wagmiService,
1191
1133
  fromWagmiConnector,
1192
1134
  fromWagmiConnectors,
1193
- setupWagmi,
1135
+ setupConnectModal,
1194
1136
  getWagmiSetup,
1195
- getConnection,
1196
- watchConnection,
1197
- disconnect,
1137
+ getWagmiAccount,
1138
+ watchWagmiAccount,
1139
+ disconnectWagmi,
1198
1140
  ConnectModal
1199
1141
  };
1200
- //# sourceMappingURL=chunk-SAQWNAQ6.js.map
1142
+ //# sourceMappingURL=chunk-3ME6PKYE.js.map