@coinbase/cdp-react 0.0.35 → 0.0.37

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/README.md CHANGED
@@ -54,20 +54,15 @@ Update your main application file (e.g., `main.tsx` or `App.tsx`) to include the
54
54
  import React from 'react';
55
55
  import ReactDOM from 'react-dom/client';
56
56
  import { App } from './App'; // Your main App component
57
- import { CDPReactProvider, type Theme } from '@coinbase/cdp-react';
57
+ import { CDPReactProvider, type Config, type Theme } from '@coinbase/cdp-react';
58
58
 
59
- // Your CDP config
60
- const cdpConfig = {
59
+ // Config for your dapp
60
+ const config: Config = {
61
61
  projectId: "your-project-id", // Copy your Project ID here.
62
+ appName: "My app", // the name of your application
63
+ appLogoUrl: "https://picsum.photos/64", // logo will be displayed in select components
62
64
  }
63
65
 
64
- // Global config for your dapp
65
- const appConfig = {
66
- name: "My app", // the name of your application
67
- logoUrl: "https://picsum.photos/64", // logo will be displayed in select components
68
- }
69
-
70
-
71
66
  // You can customize the theme by overriding theme variables
72
67
  const themeOverrides: Partial<Theme> = {
73
68
  "colors-bg-default": "black",
@@ -78,7 +73,7 @@ const themeOverrides: Partial<Theme> = {
78
73
 
79
74
  ReactDOM.createRoot(document.getElementById('root')!).render(
80
75
  <React.StrictMode>
81
- <CDPReactProvider config={cdpConfig} app={appConfig} theme={themeOverrides}>
76
+ <CDPReactProvider config={config} theme={themeOverrides}>
82
77
  <App />
83
78
  </CDPReactProvider>
84
79
  </React.StrictMode>,
@@ -1,15 +1,16 @@
1
- import { CDPHooksProviderProps } from '@coinbase/cdp-hooks';
1
+ import { Config as CDPHooksConfig } from '@coinbase/cdp-hooks';
2
2
  import { ThemeProviderProps } from '../ThemeProvider';
3
3
  export declare const AUTH_METHODS: readonly ["email", "sms"];
4
4
  export type AuthMethod = (typeof AUTH_METHODS)[number];
5
5
  export interface AppConfig {
6
- name: string;
7
- logoUrl?: string;
6
+ appName?: string;
7
+ appLogoUrl?: string;
8
8
  showCoinbaseFooter?: boolean;
9
9
  authMethods?: AuthMethod[];
10
10
  }
11
+ export type Config = AppConfig & CDPHooksConfig;
11
12
  export type CDPReactProviderProps = {
12
- app?: AppConfig;
13
- } & CDPHooksProviderProps & ThemeProviderProps;
14
- export declare const CDPReactProvider: ({ children, config, theme, app }: CDPReactProviderProps) => import("react/jsx-runtime").JSX.Element;
13
+ config: Config;
14
+ } & ThemeProviderProps;
15
+ export declare const CDPReactProvider: ({ children, config, theme }: CDPReactProviderProps) => import("react/jsx-runtime").JSX.Element;
15
16
  export declare const useAppConfig: () => AppConfig;
@@ -1,39 +1,63 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { CDPContext as c, CDPHooksProvider as C } from "@coinbase/cdp-hooks";
3
- import { createContext as d, useContext as i, useMemo as m } from "react";
4
- import { ThemeProvider as u } from "../ThemeProvider/index.js";
5
- const A = [
2
+ import { CDPContext as v, CDPHooksProvider as A } from "@coinbase/cdp-hooks";
3
+ import { createContext as b, useMemo as n, useContext as g } from "react";
4
+ import { ThemeProvider as w } from "../ThemeProvider/index.js";
5
+ const E = [
6
6
  /** Email OTP method */
7
7
  "email",
8
8
  /** SMS OTP method */
9
9
  "sms"
10
- ], g = ({ children: o, config: e, theme: r, app: p }) => {
11
- const n = /* @__PURE__ */ t(f, { app: p, children: /* @__PURE__ */ t(u, { theme: r, children: o }) });
12
- return i(c) ? n : /* @__PURE__ */ t(C, { config: e, children: n });
13
- }, s = d(void 0), a = {
14
- name: "",
15
- logoUrl: "",
10
+ ], F = ({ children: o, config: e, theme: r }) => {
11
+ const {
12
+ appName: p,
13
+ appLogoUrl: s,
14
+ showCoinbaseFooter: i,
15
+ authMethods: a,
16
+ projectId: c,
17
+ useMock: d,
18
+ debugging: u,
19
+ basePath: C,
20
+ ethereum: m,
21
+ solana: h
22
+ } = e, P = n(
23
+ () => ({
24
+ projectId: c,
25
+ useMock: d,
26
+ debugging: u,
27
+ basePath: C,
28
+ ethereum: m || {},
29
+ solana: h || {}
30
+ }),
31
+ [c, d, u, C, m, h]
32
+ ), x = n(
33
+ () => ({ appName: p, appLogoUrl: s, showCoinbaseFooter: i, authMethods: a }),
34
+ [p, s, i, a]
35
+ ), f = /* @__PURE__ */ t(M, { config: x, children: /* @__PURE__ */ t(w, { theme: r, children: o }) });
36
+ return g(v) ? f : /* @__PURE__ */ t(A, { config: P, children: f });
37
+ }, l = b(void 0), D = {
38
+ appName: "",
39
+ appLogoUrl: "",
16
40
  showCoinbaseFooter: !0,
17
41
  authMethods: ["email"]
18
- }, f = ({ children: o, app: e }) => {
19
- const r = m(
42
+ }, M = ({ children: o, config: e }) => {
43
+ const r = n(
20
44
  () => ({
21
45
  app: {
22
- ...a,
46
+ ...D,
23
47
  ...e
24
48
  }
25
49
  }),
26
50
  [e]
27
51
  );
28
- return /* @__PURE__ */ t(s.Provider, { value: r, children: o });
29
- }, D = () => {
30
- const o = i(s);
52
+ return /* @__PURE__ */ t(l.Provider, { value: r, children: o });
53
+ }, L = () => {
54
+ const o = g(l);
31
55
  if (!o)
32
56
  throw new Error("useAppConfig must be used within an AppConfigProvider");
33
57
  return o.app;
34
58
  };
35
59
  export {
36
- A as AUTH_METHODS,
37
- g as CDPReactProvider,
38
- D as useAppConfig
60
+ E as AUTH_METHODS,
61
+ F as CDPReactProvider,
62
+ L as useAppConfig
39
63
  };
@@ -1,15 +1,15 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { useAppConfig as m } from "../CDPReactProvider/index.js";
3
- import '../../assets/SignInImage.css';const p = "SignInImage-module__logo___rlzt-", c = {
4
- logo: p
5
- }, n = (t) => /^https?:\/\//.test(t), f = ({ className: t = "", alt: s, src: l }) => {
6
- const o = m(), r = o.logoUrl && n(o.logoUrl) ? o.logoUrl : void 0, g = l && n(l) ? l : r, i = s || o.name;
7
- return g ? /* @__PURE__ */ e(
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { useAppConfig as e } from "../CDPReactProvider/index.js";
3
+ import '../../assets/SignInImage.css';const a = "SignInImage-module__logo___rlzt-", m = {
4
+ logo: a
5
+ }, p = (t) => /^https?:\/\//.test(t), f = ({ className: t = "", alt: n, src: g }) => {
6
+ const o = e(), s = o.appLogoUrl && p(o.appLogoUrl) ? o.appLogoUrl : void 0, l = g && p(g) ? g : s, r = n || o.appName || "";
7
+ return l ? /* @__PURE__ */ i(
8
8
  "img",
9
9
  {
10
- src: g,
11
- alt: i || "",
12
- className: `${c.logo} ${t}`,
10
+ src: l,
11
+ alt: r || "",
12
+ className: `${m.logo} ${t}`,
13
13
  width: 64,
14
14
  height: 64
15
15
  }
@@ -410,7 +410,7 @@ export type ComponentColors = Flattened<{
410
410
  export type FontTokens = Flattened<{
411
411
  font: typeof font;
412
412
  }>;
413
- export type ColorTokens = SemanticColors | ComponentColors;
413
+ export type ColorTokens = SemanticColors & ComponentColors;
414
414
  export type Theme = ColorTokens & FontTokens;
415
415
  export type ButtonVariant = "primary" | "secondary" | "linkPrimary" | "linkSecondary" | "transparentPrimary" | "transparentSecondary" | "control";
416
416
  export type Size = "lg" | "md" | "sm" | "xs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-react",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@internationalized/number": "3.6.4",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": ">=18.2.0",
17
- "@coinbase/cdp-core": "^0.0.35",
18
- "@coinbase/cdp-hooks": "^0.0.35"
17
+ "@coinbase/cdp-core": "^0.0.37",
18
+ "@coinbase/cdp-hooks": "^0.0.37"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@size-limit/preset-big-lib": "^11.2.0",
@@ -45,8 +45,8 @@
45
45
  "vite": "^7.0.4",
46
46
  "vite-plugin-dts": "^4.5.4",
47
47
  "vite-plugin-lib-inject-css": "^2.2.2",
48
- "@coinbase/cdp-core": "^0.0.35",
49
- "@coinbase/cdp-hooks": "^0.0.35"
48
+ "@coinbase/cdp-core": "^0.0.37",
49
+ "@coinbase/cdp-hooks": "^0.0.37"
50
50
  },
51
51
  "size-limit": [
52
52
  {