@coinbase/create-cdp-app 0.0.0 → 0.0.5

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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,27 @@
1
+ import { useIsInitialized, useIsSignedIn } from "@coinbase/cdp-hooks";
2
+ import { AuthButton } from "@coinbase/cdp-react";
3
+
4
+ import Transaction from "./Transaction";
5
+
6
+ /**
7
+ *
8
+ */
9
+ function App() {
10
+ const isInitialized = useIsInitialized();
11
+ const isSignedIn = useIsSignedIn();
12
+
13
+ return (
14
+ <div className="app">
15
+ <h1>CDP React Demo</h1>
16
+ {!isInitialized && <div>Loading...</div>}
17
+ {isInitialized && (
18
+ <>
19
+ <AuthButton />
20
+ {isSignedIn && <Transaction />}
21
+ </>
22
+ )}
23
+ </div>
24
+ );
25
+ }
26
+
27
+ export default App;
@@ -0,0 +1,85 @@
1
+ import { useSendEvmTransaction, useEvmAddress } from "@coinbase/cdp-hooks";
2
+ import { type MouseEvent, useCallback, useState } from "react";
3
+
4
+ /**
5
+ *
6
+ */
7
+ function Transaction() {
8
+ const sendEvmTransaction = useSendEvmTransaction();
9
+ const evmAddress = useEvmAddress();
10
+
11
+ const [transactionHash, setTransactionHash] = useState<string | null>(null);
12
+
13
+ const handleSendTransaction = useCallback(
14
+ async (e: MouseEvent<HTMLButtonElement>) => {
15
+ if (!evmAddress) {
16
+ return;
17
+ }
18
+
19
+ e.preventDefault();
20
+
21
+ const { transactionHash } = await sendEvmTransaction({
22
+ transaction: {
23
+ to: evmAddress, // Send to yourself for testing
24
+ value: 100000000000000n, // 0.0001 ETH in wei
25
+ nonce: 0,
26
+ gas: 21000n,
27
+ maxFeePerGas: 30000000000n,
28
+ maxPriorityFeePerGas: 1000000000n,
29
+ chainId: 84532, // Base Sepolia
30
+ type: "eip1559",
31
+ },
32
+ evmAccount: evmAddress,
33
+ network: "base-sepolia",
34
+ });
35
+
36
+ setTransactionHash(transactionHash);
37
+ },
38
+ [evmAddress, sendEvmTransaction],
39
+ );
40
+
41
+ return (
42
+ <div className="transaction-form">
43
+ <h2>Wallet Address</h2>
44
+ <span className="wallet-address">{evmAddress}</span>
45
+ <p>
46
+ Get testnet ETH from{" "}
47
+ <a
48
+ href="https://portal.cdp.coinbase.com/products/faucet"
49
+ target="_blank"
50
+ rel="noopener noreferrer"
51
+ >
52
+ Base Sepolia Faucet
53
+ </a>
54
+ </p>
55
+ {!transactionHash && (
56
+ <>
57
+ <h2>Send 0.0001 ETH to yourself on Base Sepolia</h2>
58
+ <button className="button" onClick={handleSendTransaction}>
59
+ Send Transaction
60
+ </button>
61
+ </>
62
+ )}
63
+ {transactionHash && (
64
+ <div className="transaction-result">
65
+ <h2>Transaction Sent</h2>
66
+ <p>
67
+ Transaction Hash:{" "}
68
+ <a
69
+ href={`https://sepolia.basescan.org/tx/${transactionHash}`}
70
+ target="_blank"
71
+ rel="noopener noreferrer"
72
+ >
73
+ {transactionHash}
74
+ </a>
75
+ </p>
76
+ <button className="button" onClick={() => setTransactionHash(null)}>
77
+ Send Another Transaction
78
+ </button>
79
+ </div>
80
+ )}
81
+ </div>
82
+ );
83
+ }
84
+
85
+ export default Transaction;
@@ -0,0 +1,3 @@
1
+ import { type Config } from "@coinbase/cdp-core";
2
+
3
+ export const CDP_CONFIG: Config = { projectId: import.meta.env.VITE_CDP_PROJECT_ID };
@@ -0,0 +1,119 @@
1
+ :root {
2
+ font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ html,
17
+ html * {
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ #root {
22
+ margin: 0;
23
+ padding: 0;
24
+ width: 100vw;
25
+ height: 100vh;
26
+ }
27
+
28
+ .app {
29
+ display: flex;
30
+ flex-direction: column;
31
+ align-items: center;
32
+ width: 100%;
33
+ height: 100%;
34
+ color: var(--cdp-web-colors-text);
35
+ margin: 0 auto;
36
+ }
37
+
38
+ .button {
39
+ --cdp-web-button-ring-color: transparent;
40
+ --cdp-web-button-ring-width: 2px;
41
+ --cdp-web-button-ring-inset-color: transparent;
42
+ --cdp-web-button-ring-inset-width: 2px;
43
+
44
+ box-shadow:
45
+ inset 0 0 0 var(--cdp-web-button-ring-inset-width) var(--cdp-web-button-ring-inset-color),
46
+ 0 0 0 var(--cdp-web-button-ring-width) var(--cdp-web-button-ring-color);
47
+
48
+ display: inline-flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ gap: 0.5em;
52
+ padding: 1em;
53
+ border-radius: 9999em;
54
+ border: 0;
55
+ background-color: var(--cdp-web-colors-primary);
56
+ color: var(--cdp-web-colors-primaryText);
57
+ font-size: 1em;
58
+ font-weight: 500;
59
+ line-height: 1.5;
60
+ text-decoration: none;
61
+ cursor: pointer;
62
+ transition: all 0.15s ease-in-out;
63
+ user-select: none;
64
+ }
65
+
66
+ .transaction-button:hover {
67
+ background-color: var(--cdp-web-colors-primaryHoverBackground);
68
+ color: var(--cdp-web-colors-primaryHoverText);
69
+ }
70
+
71
+ .transaction-button:focus-visible {
72
+ --cdp-web-button-ring-color: var(--cdp-web-colors-primaryFocusRing);
73
+ --cdp-web-button-ring-inset-color: var(--cdp-web-colors-background);
74
+ outline: none;
75
+ }
76
+
77
+ .transaction-form {
78
+ width: 100%;
79
+ display: flex;
80
+ flex-direction: column;
81
+ align-items: center;
82
+ }
83
+
84
+ .transaction-info {
85
+ color: #666;
86
+ text-align: center;
87
+ }
88
+
89
+ .wallet-address {
90
+ font-family: monospace;
91
+ background: #f5f5f5;
92
+ padding: 0.5rem;
93
+ border-radius: 4px;
94
+ font-size: 0.9rem;
95
+ word-break: break-all;
96
+ }
97
+
98
+ .transaction-result {
99
+ text-align: center;
100
+ }
101
+
102
+ .transaction-result a {
103
+ color: #0052ff;
104
+ text-decoration: none;
105
+ }
106
+
107
+ .transaction-result a:hover {
108
+ text-decoration: underline;
109
+ }
110
+
111
+
112
+ body {
113
+ margin: 0;
114
+ display: flex;
115
+ place-items: center;
116
+ background-color: #ffffff;
117
+ min-width: 320px;
118
+ min-height: 100vh;
119
+ }
@@ -0,0 +1,15 @@
1
+ import { CDPReactProvider } from "@coinbase/cdp-react";
2
+ import { StrictMode } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+
5
+ import App from "./App.tsx";
6
+ import { CDP_CONFIG } from "./config.ts";
7
+ import "./index.css";
8
+
9
+ createRoot(document.getElementById("root")!).render(
10
+ <StrictMode>
11
+ <CDPReactProvider config={CDP_CONFIG}>
12
+ <App />
13
+ </CDPReactProvider>
14
+ </StrictMode>,
15
+ );
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2022",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "module": "ESNext",
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
+ "jsx": "react-jsx",
17
+
18
+ /* Linting */
19
+ "strict": true,
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "erasableSyntaxOnly": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "noUncheckedSideEffectImports": true
25
+ },
26
+ "include": ["src"]
27
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ]
7
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2023",
5
+ "lib": ["ES2023"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "verbatimModuleSyntax": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+
16
+ /* Linting */
17
+ "strict": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "erasableSyntaxOnly": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "noUncheckedSideEffectImports": true
23
+ },
24
+ "include": ["vite.config.ts"]
25
+ }
@@ -0,0 +1,9 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import { defineConfig } from "vite";
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ server: {
7
+ port: 3000,
8
+ },
9
+ });
package/index.js DELETED
@@ -1 +0,0 @@
1
- console.log("Temporary package");