@getpara/graz-integration 2.0.0-dev.10 → 2.0.0-dev.11

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/connector.js CHANGED
@@ -18,9 +18,15 @@ class ParaGrazConnector extends CoreParaGrazConnector {
18
18
  let delay = 500;
19
19
  const MAX_DELAY = 5e3;
20
20
  while (true) {
21
- if (yield this.paraWebClient.isFullyLoggedIn()) return;
22
- if (this.isModalClosed) throw new Error("Para connector: user closed login modal");
23
- if (Date.now() >= deadline) throw new Error("Para connector: login timeout");
21
+ if (yield this.paraWebClient.isFullyLoggedIn()) {
22
+ return;
23
+ }
24
+ if (this.isModalClosed) {
25
+ throw new Error("Login modal closed by user");
26
+ }
27
+ if (Date.now() >= deadline) {
28
+ throw new Error(`Login timeout after ${timeoutMs / 1e3}s`);
29
+ }
24
30
  yield new Promise((r) => setTimeout(r, delay));
25
31
  delay = Math.min(delay * 1.5, MAX_DELAY);
26
32
  }
@@ -51,7 +57,10 @@ class ParaGrazConnector extends CoreParaGrazConnector {
51
57
  (_e = (_d = this.events) == null ? void 0 : _d.onEnabled) == null ? void 0 : _e.call(_d, chainIds, this);
52
58
  } catch (err) {
53
59
  this.enabledChainIds = previousEnabled;
54
- throw err;
60
+ if (err instanceof Error) {
61
+ throw err;
62
+ }
63
+ throw new Error("Failed to enable Para wallet with modal");
55
64
  } finally {
56
65
  this.isModalClosed = true;
57
66
  }
@@ -8,13 +8,20 @@ import { jsx } from "react/jsx-runtime";
8
8
  import { setIsOpen } from "@getpara/react-sdk-lite";
9
9
  let rendererPromise = null;
10
10
  function getRenderer() {
11
+ console.log("[DEBUG] getRenderer called.");
11
12
  if (!rendererPromise) {
12
13
  rendererPromise = (() => __async(this, null, function* () {
13
14
  try {
14
15
  const { createRoot } = yield import("react-dom/client");
16
+ console.log("[DEBUG] Imported createRoot from react-dom/client.");
15
17
  return { createRoot: (el) => createRoot(el) };
16
- } catch (e) {
18
+ } catch (err) {
19
+ console.log(
20
+ "[DEBUG] Failed to import react-dom/client; falling back to legacy ReactDOM. Error:",
21
+ err.message
22
+ );
17
23
  const ReactDOM = yield import("react-dom");
24
+ console.log("[DEBUG] Imported legacy ReactDOM.");
18
25
  return {
19
26
  legacyRender: ReactDOM.render,
20
27
  legacyUnmount: ReactDOM.unmountComponentAtNode
@@ -24,54 +31,83 @@ function getRenderer() {
24
31
  }
25
32
  return rendererPromise;
26
33
  }
34
+ const wrap = (ctx, err, extraInfo) => {
35
+ const baseMsg = `connectorModal error in ${ctx}: ${err.message}`;
36
+ const fullMsg = extraInfo ? `${baseMsg}. Additional details: ${extraInfo}` : baseMsg;
37
+ throw new Error(fullMsg);
38
+ };
27
39
  function renderModal(para, modalProps, onCloseArg, queryClient) {
28
40
  return __async(this, null, function* () {
29
41
  var _a, _b, _c;
42
+ console.log("[DEBUG] renderModal called with para:", para, "modalProps:", modalProps, "queryClient:", queryClient);
30
43
  if (typeof window === "undefined") {
44
+ console.log("[DEBUG] renderModal: window undefined, returning early.");
31
45
  return;
32
46
  }
33
47
  const props = modalProps != null ? modalProps : {};
48
+ console.log("[DEBUG] Using modal props:", props);
34
49
  const containerId = "para-modal";
35
50
  let container = document.getElementById(containerId);
51
+ console.log("[DEBUG] Existing container:", container);
36
52
  if (!container) {
37
53
  container = document.createElement("div");
38
54
  container.id = containerId;
39
55
  document.body.appendChild(container);
56
+ console.log("[DEBUG] Created new container:", container);
40
57
  }
41
- const renderer = yield getRenderer();
42
- let root = (_a = container.__paraRoot) != null ? _a : null;
43
- if (!root && renderer.createRoot) {
44
- root = renderer.createRoot(container);
45
- container.__paraRoot = root;
46
- }
47
- const { ParaProvider } = yield import("@getpara/react-sdk-lite");
48
- const { QueryClientProvider } = yield import("@tanstack/react-query");
49
- const handleClose = () => {
50
- var _a2, _b2;
51
- onCloseArg();
52
- (_a2 = props.onClose) == null ? void 0 : _a2.call(props);
53
- setIsOpen(false);
58
+ try {
59
+ const renderer = yield getRenderer();
60
+ console.log("[DEBUG] Retrieved renderer:", renderer);
61
+ let root = (_a = container.__paraRoot) != null ? _a : null;
62
+ console.log("[DEBUG] Existing root:", root);
63
+ if (!root && renderer.createRoot) {
64
+ root = renderer.createRoot(container);
65
+ container.__paraRoot = root;
66
+ console.log("[DEBUG] Created new root with createRoot.");
67
+ }
68
+ const { ParaProvider } = yield import("@getpara/react-sdk-lite");
69
+ console.log("[DEBUG] Imported ParaProvider from @getpara/react-sdk-lite.");
70
+ const { QueryClientProvider } = yield import("@tanstack/react-query");
71
+ console.log("[DEBUG] Imported QueryClientProvider from @tanstack/react-query.");
72
+ const handleClose = () => {
73
+ var _a2, _b2;
74
+ console.log("[DEBUG] handleClose triggered.");
75
+ onCloseArg();
76
+ (_a2 = props.onClose) == null ? void 0 : _a2.call(props);
77
+ setIsOpen(false);
78
+ if (root) {
79
+ root.unmount();
80
+ console.log("[DEBUG] Unmounted using root.unmount.");
81
+ } else {
82
+ (_b2 = renderer.legacyUnmount) == null ? void 0 : _b2.call(renderer, container);
83
+ console.log("[DEBUG] Unmounted using legacyUnmount.");
84
+ }
85
+ container == null ? void 0 : container.remove();
86
+ console.log("[DEBUG] Removed container.");
87
+ };
88
+ const element = /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(
89
+ ParaProvider,
90
+ {
91
+ paraClientConfig: para,
92
+ config: { appName: (_b = props.appName) != null ? _b : "" },
93
+ paraModalConfig: __spreadProps(__spreadValues({}, props), { onClose: handleClose })
94
+ }
95
+ ) });
96
+ console.log("[DEBUG] Created render element.");
54
97
  if (root) {
55
- root.unmount();
98
+ root.render(element);
99
+ console.log("[DEBUG] Rendered using root.render.");
56
100
  } else {
57
- (_b2 = renderer.legacyUnmount) == null ? void 0 : _b2.call(renderer, container);
101
+ (_c = renderer.legacyRender) == null ? void 0 : _c.call(renderer, element, container);
102
+ console.log("[DEBUG] Rendered using legacyRender.");
58
103
  }
104
+ setIsOpen(true);
105
+ console.log("[DEBUG] Set modal isOpen to true.");
106
+ } catch (err) {
107
+ console.log("[DEBUG] Error in renderModal; cleaning up container.");
59
108
  container == null ? void 0 : container.remove();
60
- };
61
- const element = /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(
62
- ParaProvider,
63
- {
64
- paraClientConfig: para,
65
- config: { appName: (_b = props.appName) != null ? _b : "" },
66
- paraModalConfig: __spreadProps(__spreadValues({}, props), { onClose: handleClose })
67
- }
68
- ) });
69
- if (root) {
70
- root.render(element);
71
- } else {
72
- (_c = renderer.legacyRender) == null ? void 0 : _c.call(renderer, element, container);
109
+ throw wrap("renderModal", err, `containerId: ${containerId}, modalProps: ${JSON.stringify(props)}`);
73
110
  }
74
- setIsOpen(true);
75
111
  });
76
112
  }
77
113
  export {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export { ParaGrazConnector } from './connector';
2
2
  export type { ParaModalProps, ParaGrazConfig } from './connector';
3
- export type { ParaGrazConfig as CoreParaGrazConfig } from '@getpara/graz-connector';
4
- export { ParaWeb, Environment, WalletType, AuthLayout, AuthMethod, OAuthMethod } from '@getpara/react-sdk-lite';
package/dist/index.js CHANGED
@@ -1,13 +1,6 @@
1
1
  "use client";
2
2
  import "./chunk-IV3L3JVM.js";
3
3
  import { ParaGrazConnector } from "./connector";
4
- import { ParaWeb, Environment, WalletType, AuthLayout, AuthMethod, OAuthMethod } from "@getpara/react-sdk-lite";
5
4
  export {
6
- AuthLayout,
7
- AuthMethod,
8
- Environment,
9
- OAuthMethod,
10
- ParaGrazConnector,
11
- ParaWeb,
12
- WalletType
5
+ ParaGrazConnector
13
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/graz-integration",
3
- "version": "2.0.0-dev.10",
3
+ "version": "2.0.0-dev.11",
4
4
  "sideEffects": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,15 +11,16 @@
11
11
  "typegen": "tsc --emitDeclarationOnly"
12
12
  },
13
13
  "dependencies": {
14
- "@getpara/graz-connector": "2.0.0-dev.10",
15
- "@getpara/react-sdk-lite": "2.0.0-alpha.42"
14
+ "@getpara/graz-connector": "~2.0.0-dev.11"
16
15
  },
17
16
  "devDependencies": {
17
+ "@getpara/react-sdk-lite": "~2.0.0-alpha.44",
18
18
  "@tanstack/react-query": "^5.74.0",
19
19
  "graz": "^0.3.3",
20
20
  "typescript": "5.1.6"
21
21
  },
22
22
  "peerDependencies": {
23
+ "@getpara/react-sdk-lite": "~2.0.0-alpha.44",
23
24
  "@tanstack/react-query": "^5.74.0",
24
25
  "graz": "^0.3.3",
25
26
  "react": ">=18",
package/src/connector.ts CHANGED
@@ -27,10 +27,20 @@ export class ParaGrazConnector extends CoreParaGrazConnector {
27
27
  const deadline = Date.now() + timeoutMs;
28
28
  let delay = 500;
29
29
  const MAX_DELAY = 5_000;
30
+
30
31
  while (true) {
31
- if (await this.paraWebClient.isFullyLoggedIn()) return;
32
- if (this.isModalClosed) throw new Error('Para connector: user closed login modal');
33
- if (Date.now() >= deadline) throw new Error('Para connector: login timeout');
32
+ if (await this.paraWebClient.isFullyLoggedIn()) {
33
+ return;
34
+ }
35
+
36
+ if (this.isModalClosed) {
37
+ throw new Error('Login modal closed by user');
38
+ }
39
+
40
+ if (Date.now() >= deadline) {
41
+ throw new Error(`Login timeout after ${timeoutMs / 1000}s`);
42
+ }
43
+
34
44
  await new Promise(r => setTimeout(r, delay));
35
45
  delay = Math.min(delay * 1.5, MAX_DELAY);
36
46
  }
@@ -39,13 +49,17 @@ export class ParaGrazConnector extends CoreParaGrazConnector {
39
49
  async enable(chainIdsInput: string | string[]): Promise<void> {
40
50
  const chainIds = toArray(chainIdsInput);
41
51
  const previousEnabled = new Set(this.enabledChainIds);
52
+
42
53
  try {
43
54
  chainIds.forEach(id => this.enabledChainIds.add(id));
55
+
44
56
  if (await this.hasCosmosWallet()) {
45
57
  this.events?.onEnabled?.(chainIds, this);
46
58
  return;
47
59
  }
60
+
48
61
  this.isModalClosed = false;
62
+
49
63
  await renderModal(
50
64
  this.paraWebClient,
51
65
  this.config.modalProps ?? {},
@@ -54,12 +68,19 @@ export class ParaGrazConnector extends CoreParaGrazConnector {
54
68
  },
55
69
  this.config.queryClient!,
56
70
  );
71
+
57
72
  await this.waitForLogin();
58
73
  await this.waitForAccounts();
74
+
59
75
  this.events?.onEnabled?.(chainIds, this);
60
76
  } catch (err) {
61
77
  this.enabledChainIds = previousEnabled;
62
- throw err;
78
+
79
+ if (err instanceof Error) {
80
+ throw err;
81
+ }
82
+
83
+ throw new Error('Failed to enable Para wallet with modal');
63
84
  } finally {
64
85
  this.isModalClosed = true;
65
86
  }
@@ -12,13 +12,20 @@ let rendererPromise: Promise<{
12
12
  }> | null = null;
13
13
 
14
14
  function getRenderer() {
15
+ console.log('[DEBUG] getRenderer called.');
15
16
  if (!rendererPromise) {
16
17
  rendererPromise = (async () => {
17
18
  try {
18
19
  const { createRoot } = await import('react-dom/client');
20
+ console.log('[DEBUG] Imported createRoot from react-dom/client.');
19
21
  return { createRoot: (el: HTMLElement) => createRoot(el) };
20
- } catch {
22
+ } catch (err) {
23
+ console.log(
24
+ '[DEBUG] Failed to import react-dom/client; falling back to legacy ReactDOM. Error:',
25
+ (err as Error).message,
26
+ );
21
27
  const ReactDOM = await import('react-dom');
28
+ console.log('[DEBUG] Imported legacy ReactDOM.');
22
29
  return {
23
30
  legacyRender: ReactDOM.render,
24
31
  legacyUnmount: ReactDOM.unmountComponentAtNode,
@@ -29,55 +36,85 @@ function getRenderer() {
29
36
  return rendererPromise;
30
37
  }
31
38
 
39
+ const wrap = (ctx: string, err: unknown, extraInfo?: string): never => {
40
+ const baseMsg = `connectorModal error in ${ctx}: ${(err as Error).message}`;
41
+ const fullMsg = extraInfo ? `${baseMsg}. Additional details: ${extraInfo}` : baseMsg;
42
+ throw new Error(fullMsg);
43
+ };
44
+
32
45
  export async function renderModal(
33
46
  para: ParaWeb,
34
47
  modalProps: Partial<ParaModalProps> | undefined,
35
48
  onCloseArg: () => void,
36
49
  queryClient: QueryClient,
37
50
  ): Promise<void> {
51
+ console.log('[DEBUG] renderModal called with para:', para, 'modalProps:', modalProps, 'queryClient:', queryClient);
38
52
  if (typeof window === 'undefined') {
53
+ console.log('[DEBUG] renderModal: window undefined, returning early.');
39
54
  return;
40
55
  }
41
56
  const props = modalProps ?? {};
57
+ console.log('[DEBUG] Using modal props:', props);
42
58
  const containerId = 'para-modal';
43
59
  let container = document.getElementById(containerId) as HTMLElement | null;
60
+ console.log('[DEBUG] Existing container:', container);
44
61
  if (!container) {
45
62
  container = document.createElement('div');
46
63
  container.id = containerId;
47
64
  document.body.appendChild(container);
65
+ console.log('[DEBUG] Created new container:', container);
48
66
  }
49
- const renderer = await getRenderer();
50
- let root: Root | null = (container as any).__paraRoot ?? null;
51
- if (!root && renderer.createRoot) {
52
- root = renderer.createRoot(container);
53
- (container as any).__paraRoot = root;
54
- }
55
- const { ParaProvider } = await import('@getpara/react-sdk-lite');
56
- const { QueryClientProvider } = await import('@tanstack/react-query');
57
- const handleClose = () => {
58
- onCloseArg();
59
- props.onClose?.();
60
- setIsOpen(false);
67
+ try {
68
+ const renderer = await getRenderer();
69
+ console.log('[DEBUG] Retrieved renderer:', renderer);
70
+ let root: Root | null = (container as any).__paraRoot ?? null;
71
+ console.log('[DEBUG] Existing root:', root);
72
+ if (!root && renderer.createRoot) {
73
+ root = renderer.createRoot(container);
74
+ (container as any).__paraRoot = root;
75
+ console.log('[DEBUG] Created new root with createRoot.');
76
+ }
77
+ const { ParaProvider } = await import('@getpara/react-sdk-lite');
78
+ console.log('[DEBUG] Imported ParaProvider from @getpara/react-sdk-lite.');
79
+ const { QueryClientProvider } = await import('@tanstack/react-query');
80
+ console.log('[DEBUG] Imported QueryClientProvider from @tanstack/react-query.');
81
+ const handleClose = () => {
82
+ console.log('[DEBUG] handleClose triggered.');
83
+ onCloseArg();
84
+ props.onClose?.();
85
+ setIsOpen(false);
86
+ if (root) {
87
+ root.unmount();
88
+ console.log('[DEBUG] Unmounted using root.unmount.');
89
+ } else {
90
+ renderer.legacyUnmount?.(container!);
91
+ console.log('[DEBUG] Unmounted using legacyUnmount.');
92
+ }
93
+ container?.remove();
94
+ console.log('[DEBUG] Removed container.');
95
+ };
96
+ const element = (
97
+ <QueryClientProvider client={queryClient}>
98
+ <ParaProvider
99
+ paraClientConfig={para}
100
+ config={{ appName: props.appName ?? '' }}
101
+ paraModalConfig={{ ...props, onClose: handleClose }}
102
+ />
103
+ </QueryClientProvider>
104
+ );
105
+ console.log('[DEBUG] Created render element.');
61
106
  if (root) {
62
- root.unmount();
107
+ root.render(element);
108
+ console.log('[DEBUG] Rendered using root.render.');
63
109
  } else {
64
- renderer.legacyUnmount?.(container!);
110
+ renderer.legacyRender?.(element, container!);
111
+ console.log('[DEBUG] Rendered using legacyRender.');
65
112
  }
113
+ setIsOpen(true);
114
+ console.log('[DEBUG] Set modal isOpen to true.');
115
+ } catch (err) {
116
+ console.log('[DEBUG] Error in renderModal; cleaning up container.');
66
117
  container?.remove();
67
- };
68
- const element = (
69
- <QueryClientProvider client={queryClient}>
70
- <ParaProvider
71
- paraClientConfig={para}
72
- config={{ appName: props.appName ?? '' }}
73
- paraModalConfig={{ ...props, onClose: handleClose }}
74
- />
75
- </QueryClientProvider>
76
- );
77
- if (root) {
78
- root.render(element);
79
- } else {
80
- renderer.legacyRender?.(element, container!);
118
+ throw wrap('renderModal', err, `containerId: ${containerId}, modalProps: ${JSON.stringify(props)}`);
81
119
  }
82
- setIsOpen(true);
83
120
  }
package/src/index.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export { ParaGrazConnector } from './connector';
2
2
  export type { ParaModalProps, ParaGrazConfig } from './connector';
3
- export type { ParaGrazConfig as CoreParaGrazConfig } from '@getpara/graz-connector';
4
- export { ParaWeb, Environment, WalletType, AuthLayout, AuthMethod, OAuthMethod } from '@getpara/react-sdk-lite';