@coinbase/create-cdp-app 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 +22 -9
- package/dist/index.js +168 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/template-nextjs/README.md +3 -2
- package/template-nextjs/env.example +4 -2
- package/template-nextjs/package.json +3 -1
- package/template-nextjs/public/sol.svg +13 -0
- package/template-nextjs/src/app/globals.css +6 -0
- package/template-nextjs/src/components/Header.tsx +2 -1
- package/template-nextjs/src/components/Providers.tsx +32 -12
- package/template-nextjs/src/components/SignedInScreen.tsx +63 -15
- package/template-nextjs/src/components/SignedInScreenWithOnramp.tsx +22 -3
- package/template-nextjs/src/components/SolanaTransaction.tsx +157 -0
- package/template-nextjs/src/components/UserBalance.tsx +5 -3
- package/template-react/README.md +2 -1
- package/template-react/env.example +4 -2
- package/template-react/package.json +3 -1
- package/template-react/public/sol.svg +13 -0
- package/template-react/src/Header.tsx +21 -9
- package/template-react/src/SignedInScreen.tsx +66 -13
- package/template-react/src/SolanaTransaction.tsx +158 -0
- package/template-react/src/UserBalance.tsx +29 -10
- package/template-react/src/config.ts +31 -11
- package/template-react/src/index.css +6 -0
- package/template-react/src/main.tsx +2 -2
- package/template-react-native/App.tsx +83 -63
- package/template-react-native/EOATransaction.tsx +35 -22
- package/template-react-native/SmartAccountTransaction.tsx +9 -9
- package/template-react-native/components/SignInForm.tsx +433 -0
- package/template-react-native/env.example +1 -1
- package/template-react-native/types.ts +0 -22
- package/template-react-native/components/SignInModal.tsx +0 -342
package/README.md
CHANGED
|
@@ -34,14 +34,16 @@ yarn create @coinbase/cdp-app@latest
|
|
|
34
34
|
|
|
35
35
|
The CLI will guide you through the setup process:
|
|
36
36
|
1. Enter your project name (defaults to "cdp-app")
|
|
37
|
-
2. Select a template (
|
|
37
|
+
2. Select a template (React, Next.js, or React Native)
|
|
38
38
|
3. Enter your CDP Project ID
|
|
39
|
-
4.
|
|
40
|
-
5.
|
|
39
|
+
4. Select account type (EVM EOA, EVM Smart Accounts, or Solana)
|
|
40
|
+
5. Configure Onramp (Next.js only)
|
|
41
|
+
6. Confirm you have whitelisted your app domain on the CDP Portal
|
|
42
|
+
7. Confirm directory overwrite if needed
|
|
41
43
|
|
|
42
44
|
## Available Templates
|
|
43
45
|
|
|
44
|
-
Currently, `create-cdp-app` offers the following
|
|
46
|
+
Currently, `create-cdp-app` offers the following templates:
|
|
45
47
|
|
|
46
48
|
- **React** (`react`): A React application template that includes:
|
|
47
49
|
- Vite for fast development and building
|
|
@@ -56,6 +58,12 @@ Currently, `create-cdp-app` offers the following template:
|
|
|
56
58
|
- Built-in TypeScript support
|
|
57
59
|
- ESLint with Next.js configuration
|
|
58
60
|
- Viem for type-safe Ethereum interactions
|
|
61
|
+
- **React Native** (`react-native`): A React Native with Expo template that includes:
|
|
62
|
+
- Expo SDK for cross-platform mobile development
|
|
63
|
+
- CDP React Native components for authentication
|
|
64
|
+
- Example transaction components
|
|
65
|
+
- TypeScript support
|
|
66
|
+
- Support for both iOS and Android
|
|
59
67
|
|
|
60
68
|
## Command-Line Arguments
|
|
61
69
|
|
|
@@ -66,14 +74,19 @@ You can also pass command-line arguments to pre-configure the setup process.
|
|
|
66
74
|
| `<directory>` | Optional. The name of the directory to create the project in. Defaults to `cdp-app`. |
|
|
67
75
|
| `--template <name>` | Specifies the project template to use. Options: `react`, `nextjs`, `react-native`. |
|
|
68
76
|
| `--project-id <id>` | Your CDP Project ID from the portal. |
|
|
69
|
-
| `--
|
|
70
|
-
| `--no-smart-accounts` | Disables Smart Accounts for the project. |
|
|
77
|
+
| `--account-type <type>` | Specifies the account type to configure. Options: `evm-eoa` (default), `evm-smart`, `solana`. |
|
|
71
78
|
| `--onramp` | Enables Coinbase Onramp. <br>**Note:** This is only compatible with the `nextjs` template. If no template is specified, `nextjs` will be used automatically. If an incompatible template (e.g., `react`) is specified, this flag will be ignored and Onramp will be disabled. |
|
|
72
79
|
| `--no-onramp` | Disables Coinbase Onramp. |
|
|
73
80
|
|
|
74
|
-
###
|
|
81
|
+
### Examples
|
|
75
82
|
|
|
76
83
|
```bash
|
|
77
|
-
# Create a Next.js app with
|
|
78
|
-
npm create @coinbase/cdp-app@latest my-next-app --template nextjs --project-id YOUR_PROJECT_ID --
|
|
84
|
+
# Create a Next.js app with EVM Smart Accounts and Onramp enabled
|
|
85
|
+
npm create @coinbase/cdp-app@latest my-next-app --template nextjs --project-id YOUR_PROJECT_ID --account-type evm-smart --onramp
|
|
86
|
+
|
|
87
|
+
# Create a React app with Solana support
|
|
88
|
+
npm create @coinbase/cdp-app@latest my-solana-app --template react --project-id YOUR_PROJECT_ID --account-type solana
|
|
89
|
+
|
|
90
|
+
# Create a React Native app with regular EVM accounts (default)
|
|
91
|
+
npm create @coinbase/cdp-app@latest my-mobile-app --template react-native --project-id YOUR_PROJECT_ID --account-type evm-eoa
|
|
79
92
|
```
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ function customizePackageJson(templateDir, appName, includeSdk) {
|
|
|
25
25
|
function customizeEnv({
|
|
26
26
|
templateDir,
|
|
27
27
|
projectId,
|
|
28
|
-
|
|
28
|
+
accountType,
|
|
29
29
|
apiKeyId,
|
|
30
30
|
apiKeySecret
|
|
31
31
|
}) {
|
|
@@ -33,7 +33,6 @@ function customizeEnv({
|
|
|
33
33
|
const exampleEnv = fs.readFileSync(exampleEnvPath, "utf-8");
|
|
34
34
|
let envContent = exampleEnv.replace(/(.*PROJECT_ID=).*(\r?\n|$)/, `$1${projectId}
|
|
35
35
|
`);
|
|
36
|
-
const accountType = useSmartAccounts ? "evm-smart" : "evm-eoa";
|
|
37
36
|
let prefix;
|
|
38
37
|
if (templateDir.includes("nextjs")) {
|
|
39
38
|
prefix = "NEXT_PUBLIC_";
|
|
@@ -42,12 +41,32 @@ function customizeEnv({
|
|
|
42
41
|
} else {
|
|
43
42
|
prefix = "VITE_";
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (accountType === "solana") {
|
|
45
|
+
envContent = envContent.replace(
|
|
46
|
+
new RegExp(`${prefix}CDP_CREATE_ETHEREUM_ACCOUNT_TYPE=.*(\r?
|
|
47
|
+
|$)`, "g"),
|
|
48
|
+
""
|
|
49
|
+
);
|
|
50
|
+
envContent = envContent.replace(
|
|
51
|
+
new RegExp(`(${prefix}CDP_CREATE_SOLANA_ACCOUNT=).*(\r?
|
|
47
52
|
|$)`),
|
|
48
|
-
|
|
53
|
+
`$1true
|
|
49
54
|
`
|
|
50
|
-
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
const ethereumType = accountType === "evm-smart" ? "smart" : "eoa";
|
|
58
|
+
envContent = envContent.replace(
|
|
59
|
+
new RegExp(`(${prefix}CDP_CREATE_ETHEREUM_ACCOUNT_TYPE=).*(\r?
|
|
60
|
+
|$)`),
|
|
61
|
+
`$1${ethereumType}
|
|
62
|
+
`
|
|
63
|
+
);
|
|
64
|
+
envContent = envContent.replace(
|
|
65
|
+
new RegExp(`${prefix}CDP_CREATE_SOLANA_ACCOUNT=.*(\r?
|
|
66
|
+
|$)`, "g"),
|
|
67
|
+
""
|
|
68
|
+
);
|
|
69
|
+
}
|
|
51
70
|
if (apiKeyId && apiKeySecret) {
|
|
52
71
|
envContent = envContent.replace(/# CDP_API_KEY_ID=.*/, `CDP_API_KEY_ID=${apiKeyId}`);
|
|
53
72
|
envContent = envContent.replace(
|
|
@@ -57,46 +76,103 @@ function customizeEnv({
|
|
|
57
76
|
}
|
|
58
77
|
return envContent;
|
|
59
78
|
}
|
|
60
|
-
function customizeConfig(templateDir,
|
|
61
|
-
if (
|
|
79
|
+
function customizeConfig(templateDir, accountType, isNextjs) {
|
|
80
|
+
if (accountType === "evm-eoa") return null;
|
|
62
81
|
const configFileName = isNextjs ? "src/components/Providers.tsx" : "src/config.ts";
|
|
63
82
|
const configPath = path.join(templateDir, configFileName);
|
|
64
83
|
if (!fs.existsSync(configPath)) return null;
|
|
65
84
|
let configContent = fs.readFileSync(configPath, "utf-8");
|
|
66
85
|
if (isNextjs) {
|
|
86
|
+
const ethereumConfig = accountType !== "solana" ? `
|
|
87
|
+
ethereum: {
|
|
88
|
+
createOnLogin: process.env.NEXT_PUBLIC_CDP_CREATE_ETHEREUM_ACCOUNT_TYPE === "smart" ? "smart" : "eoa",
|
|
89
|
+
},` : "";
|
|
90
|
+
const solanaConfig = accountType === "solana" ? `
|
|
91
|
+
solana: {
|
|
92
|
+
createOnLogin: process.env.NEXT_PUBLIC_CDP_CREATE_SOLANA_ACCOUNT === "true" ? true : false,
|
|
93
|
+
},` : "";
|
|
67
94
|
configContent = configContent.replace(
|
|
68
95
|
/const CDP_CONFIG: Config = \{[\s\S]*?\};/,
|
|
69
96
|
`const CDP_CONFIG: Config = {
|
|
70
|
-
projectId: process.env.NEXT_PUBLIC_CDP_PROJECT_ID ?? ""
|
|
71
|
-
|
|
97
|
+
projectId: process.env.NEXT_PUBLIC_CDP_PROJECT_ID ?? "",${ethereumConfig}${solanaConfig}
|
|
98
|
+
appName: "CDP Next.js StarterKit",
|
|
99
|
+
appLogoUrl: "http://localhost:3000/logo.svg",
|
|
100
|
+
authMethods: ["email", "sms"],
|
|
72
101
|
};`
|
|
73
102
|
);
|
|
74
103
|
} else {
|
|
104
|
+
const ethereumConfig = accountType !== "solana" ? `
|
|
105
|
+
ethereum: {
|
|
106
|
+
createOnLogin: import.meta.env.VITE_CDP_CREATE_ETHEREUM_ACCOUNT_TYPE === "smart" ? "smart" : "eoa",
|
|
107
|
+
},` : "";
|
|
108
|
+
const solanaConfig = accountType === "solana" ? `
|
|
109
|
+
solana: {
|
|
110
|
+
createOnLogin: import.meta.env.VITE_CDP_CREATE_SOLANA_ACCOUNT === "true" ? true : false,
|
|
111
|
+
},` : "";
|
|
75
112
|
configContent = configContent.replace(
|
|
76
113
|
/export const CDP_CONFIG: Config = \{[\s\S]*?\};/,
|
|
77
114
|
`export const CDP_CONFIG: Config = {
|
|
78
|
-
projectId: import.meta.env.VITE_CDP_PROJECT_ID
|
|
79
|
-
|
|
115
|
+
projectId: import.meta.env.VITE_CDP_PROJECT_ID,${ethereumConfig}${solanaConfig}
|
|
116
|
+
appName: "CDP React StarterKit",
|
|
117
|
+
appLogoUrl: "http://localhost:3000/logo.svg",
|
|
118
|
+
authMethods: ["email", "sms"],
|
|
80
119
|
};`
|
|
81
120
|
);
|
|
82
121
|
}
|
|
83
122
|
return configContent;
|
|
84
123
|
}
|
|
124
|
+
function customizeSignedInScreen(templateDir, accountType, isNextjs, fileName = "SignedInScreen.tsx") {
|
|
125
|
+
const signedInScreenPath = isNextjs ? path.join(templateDir, `src/components/${fileName}`) : path.join(templateDir, `src/${fileName}`);
|
|
126
|
+
let content = fs.readFileSync(signedInScreenPath, "utf-8");
|
|
127
|
+
let componentPath;
|
|
128
|
+
if (fileName === "SignedInScreenWithOnramp.tsx") {
|
|
129
|
+
if (accountType === "evm-smart") {
|
|
130
|
+
componentPath = "@/components/SmartAccountTransaction";
|
|
131
|
+
} else {
|
|
132
|
+
componentPath = "@/components/EOATransaction";
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
if (accountType === "solana") {
|
|
136
|
+
componentPath = isNextjs ? "@/components/SolanaTransaction" : "./SolanaTransaction";
|
|
137
|
+
} else if (accountType === "evm-smart") {
|
|
138
|
+
componentPath = isNextjs ? "@/components/SmartAccountTransaction" : "./SmartAccountTransaction";
|
|
139
|
+
} else {
|
|
140
|
+
componentPath = isNextjs ? "@/components/EOATransaction" : "./EOATransaction";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const componentImport = `const TransactionComponent = lazy(() => import("${componentPath}"));`;
|
|
144
|
+
if (isNextjs) {
|
|
145
|
+
content = content.replace(
|
|
146
|
+
/\/\/ Dynamically (import components based on configuration|determine component path \(Onramp only supports EVM\))[\s\S]*?const TransactionComponent = lazy\(\(\) => (\{[\s\S]*?\}|import\(\/\* @vite-ignore \*\/ getComponentPath\(\)\))\);/,
|
|
147
|
+
componentImport
|
|
148
|
+
);
|
|
149
|
+
} else {
|
|
150
|
+
content = content.replace(
|
|
151
|
+
/\/\/ Dynamically determine component path to avoid Vite static analysis[\s\S]*?const TransactionComponent = lazy\(\(\) => import\(\/\* @vite-ignore \*\/ getComponentPath\(\)\)\);/,
|
|
152
|
+
componentImport
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
return content;
|
|
156
|
+
}
|
|
85
157
|
function copyFileSelectively({
|
|
86
158
|
filePath,
|
|
87
159
|
destPath,
|
|
88
|
-
|
|
160
|
+
accountType,
|
|
89
161
|
enableOnramp
|
|
90
162
|
}) {
|
|
91
163
|
const stat = fs.statSync(filePath);
|
|
92
164
|
if (stat.isDirectory()) {
|
|
93
165
|
const baseDir = path.basename(filePath);
|
|
94
166
|
if (!enableOnramp && (baseDir === "api" || baseDir === "lib")) return;
|
|
95
|
-
copyDirSelectively({ srcDir: filePath, destDir: destPath,
|
|
167
|
+
copyDirSelectively({ srcDir: filePath, destDir: destPath, accountType, enableOnramp });
|
|
96
168
|
} else {
|
|
97
169
|
const fileName = path.basename(filePath);
|
|
98
|
-
if (
|
|
99
|
-
if (
|
|
170
|
+
if (accountType === "evm-smart" && fileName === "EOATransaction.tsx") return;
|
|
171
|
+
if (accountType === "evm-smart" && fileName === "SolanaTransaction.tsx") return;
|
|
172
|
+
if (accountType === "evm-eoa" && fileName === "SmartAccountTransaction.tsx") return;
|
|
173
|
+
if (accountType === "evm-eoa" && fileName === "SolanaTransaction.tsx") return;
|
|
174
|
+
if (accountType === "solana" && fileName === "EOATransaction.tsx") return;
|
|
175
|
+
if (accountType === "solana" && fileName === "SmartAccountTransaction.tsx") return;
|
|
100
176
|
if (!enableOnramp && ["FundWallet.tsx", "SignedInScreenWithOnramp.tsx"].includes(fileName))
|
|
101
177
|
return;
|
|
102
178
|
if (enableOnramp) {
|
|
@@ -113,14 +189,14 @@ function copyFileSelectively({
|
|
|
113
189
|
function copyDirSelectively({
|
|
114
190
|
srcDir,
|
|
115
191
|
destDir,
|
|
116
|
-
|
|
192
|
+
accountType,
|
|
117
193
|
enableOnramp
|
|
118
194
|
}) {
|
|
119
195
|
fs.mkdirSync(destDir, { recursive: true });
|
|
120
196
|
for (const file of fs.readdirSync(srcDir)) {
|
|
121
197
|
const srcFile = path.resolve(srcDir, file);
|
|
122
198
|
const destFile = path.resolve(destDir, file);
|
|
123
|
-
copyFileSelectively({ filePath: srcFile, destPath: destFile,
|
|
199
|
+
copyFileSelectively({ filePath: srcFile, destPath: destFile, accountType, enableOnramp });
|
|
124
200
|
}
|
|
125
201
|
}
|
|
126
202
|
function isDirEmpty(dirPath) {
|
|
@@ -215,6 +291,23 @@ const TEMPLATES = [
|
|
|
215
291
|
}
|
|
216
292
|
];
|
|
217
293
|
const TEMPLATE_NAMES = TEMPLATES.map((template) => template.name);
|
|
294
|
+
const ACCOUNT_TYPES = [
|
|
295
|
+
{
|
|
296
|
+
value: "evm-eoa",
|
|
297
|
+
title: "EVM EOA (Regular Accounts)",
|
|
298
|
+
description: "Traditional Ethereum-compatible accounts"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
value: "evm-smart",
|
|
302
|
+
title: "EVM Smart Accounts",
|
|
303
|
+
description: "Account abstraction with gasless transactions and improved UX"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
value: "solana",
|
|
307
|
+
title: "Solana Accounts",
|
|
308
|
+
description: "Native Solana blockchain accounts"
|
|
309
|
+
}
|
|
310
|
+
];
|
|
218
311
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
219
312
|
async function getAppDetails() {
|
|
220
313
|
const argv = minimist(process.argv.slice(2));
|
|
@@ -223,7 +316,7 @@ async function getAppDetails() {
|
|
|
223
316
|
let templateFromArgs = void 0;
|
|
224
317
|
let projectIdFromArgs = void 0;
|
|
225
318
|
let enableOnrampFromArgs = void 0;
|
|
226
|
-
|
|
319
|
+
let accountTypeFromArgs = void 0;
|
|
227
320
|
if (argv.template) {
|
|
228
321
|
if (!TEMPLATE_NAMES.includes(argv.template)) {
|
|
229
322
|
console.log(
|
|
@@ -244,6 +337,18 @@ async function getAppDetails() {
|
|
|
244
337
|
projectIdFromArgs = argv["project-id"];
|
|
245
338
|
}
|
|
246
339
|
}
|
|
340
|
+
if (argv["account-type"]) {
|
|
341
|
+
const validAccountTypes = ACCOUNT_TYPES.map((type) => type.value);
|
|
342
|
+
if (!validAccountTypes.includes(argv["account-type"])) {
|
|
343
|
+
console.log(
|
|
344
|
+
yellow(
|
|
345
|
+
`✖ Invalid account type provided: "${argv["account-type"]}". Please choose from: ${validAccountTypes.join(", ")}.`
|
|
346
|
+
)
|
|
347
|
+
);
|
|
348
|
+
} else {
|
|
349
|
+
accountTypeFromArgs = argv["account-type"];
|
|
350
|
+
}
|
|
351
|
+
}
|
|
247
352
|
if (argv["onramp"] !== void 0) {
|
|
248
353
|
if (!argv["onramp"]) {
|
|
249
354
|
enableOnrampFromArgs = false;
|
|
@@ -297,15 +402,18 @@ async function getAppDetails() {
|
|
|
297
402
|
initial: ""
|
|
298
403
|
},
|
|
299
404
|
{
|
|
300
|
-
type:
|
|
301
|
-
name: "
|
|
302
|
-
message: reset(
|
|
303
|
-
|
|
304
|
-
)
|
|
305
|
-
|
|
405
|
+
type: accountTypeFromArgs ? null : "select",
|
|
406
|
+
name: "accountType",
|
|
407
|
+
message: reset("Account Type:"),
|
|
408
|
+
initial: 0,
|
|
409
|
+
choices: ACCOUNT_TYPES.map((accountType) => ({
|
|
410
|
+
title: accountType.title,
|
|
411
|
+
description: accountType.description,
|
|
412
|
+
value: accountType.value
|
|
413
|
+
}))
|
|
306
414
|
},
|
|
307
415
|
{
|
|
308
|
-
type: (_, { template }) => enableOnrampFromArgs !== void 0 || (templateFromArgs || template) !== "nextjs" ? null : "confirm",
|
|
416
|
+
type: (_, { template, accountType }) => enableOnrampFromArgs !== void 0 || (templateFromArgs || template) !== "nextjs" || (accountTypeFromArgs || accountType) === "solana" ? null : "confirm",
|
|
309
417
|
name: "enableOnramp",
|
|
310
418
|
message: reset("Enable Coinbase Onramp? (Onramp enables users to buy crypto with fiat):"),
|
|
311
419
|
initial: false
|
|
@@ -366,7 +474,7 @@ async function getAppDetails() {
|
|
|
366
474
|
template: templateFromArgs || result.template,
|
|
367
475
|
targetDirectory: targetDir,
|
|
368
476
|
projectId: projectIdFromArgs || result.projectId,
|
|
369
|
-
|
|
477
|
+
accountType: accountTypeFromArgs || result.accountType,
|
|
370
478
|
enableOnramp: enableOnrampFromArgs ?? result.enableOnramp ?? false,
|
|
371
479
|
apiKeyId: result.apiKeyId,
|
|
372
480
|
apiKeySecret: result.apiKeySecret
|
|
@@ -387,7 +495,7 @@ async function init() {
|
|
|
387
495
|
template,
|
|
388
496
|
targetDirectory,
|
|
389
497
|
projectId,
|
|
390
|
-
|
|
498
|
+
accountType,
|
|
391
499
|
enableOnramp,
|
|
392
500
|
apiKeyId,
|
|
393
501
|
apiKeySecret
|
|
@@ -401,7 +509,7 @@ Scaffolding app in ${targetDirectory}...`);
|
|
|
401
509
|
root,
|
|
402
510
|
appName,
|
|
403
511
|
projectId,
|
|
404
|
-
|
|
512
|
+
accountType,
|
|
405
513
|
enableOnramp,
|
|
406
514
|
apiKeyId,
|
|
407
515
|
apiKeySecret
|
|
@@ -428,7 +536,7 @@ function copyTemplateFiles({
|
|
|
428
536
|
root,
|
|
429
537
|
appName,
|
|
430
538
|
projectId,
|
|
431
|
-
|
|
539
|
+
accountType,
|
|
432
540
|
enableOnramp,
|
|
433
541
|
apiKeyId,
|
|
434
542
|
apiKeySecret
|
|
@@ -441,7 +549,7 @@ function copyTemplateFiles({
|
|
|
441
549
|
copyFileSelectively({
|
|
442
550
|
filePath: path.join(templateDir, file),
|
|
443
551
|
destPath: targetPath,
|
|
444
|
-
|
|
552
|
+
accountType,
|
|
445
553
|
enableOnramp
|
|
446
554
|
});
|
|
447
555
|
}
|
|
@@ -459,7 +567,7 @@ function copyTemplateFiles({
|
|
|
459
567
|
const customizedEnv = customizeEnv({
|
|
460
568
|
templateDir,
|
|
461
569
|
projectId,
|
|
462
|
-
|
|
570
|
+
accountType,
|
|
463
571
|
apiKeyId,
|
|
464
572
|
apiKeySecret
|
|
465
573
|
});
|
|
@@ -467,8 +575,10 @@ function copyTemplateFiles({
|
|
|
467
575
|
if (apiKeyId && apiKeySecret) {
|
|
468
576
|
console.log("Copying CDP API credentials to .env");
|
|
469
577
|
}
|
|
470
|
-
if (
|
|
578
|
+
if (accountType === "evm-smart") {
|
|
471
579
|
console.log("Configuring Smart Accounts in environment");
|
|
580
|
+
} else if (accountType === "solana") {
|
|
581
|
+
console.log("Configuring Solana accounts in environment");
|
|
472
582
|
}
|
|
473
583
|
writeFileToTarget(".env", customizedEnv);
|
|
474
584
|
} else if (file === "app.json" && isReactNative && (reactNativeCustomizations == null ? void 0 : reactNativeCustomizations.appJson)) {
|
|
@@ -477,21 +587,35 @@ function copyTemplateFiles({
|
|
|
477
587
|
writeFileToTarget(file);
|
|
478
588
|
}
|
|
479
589
|
}
|
|
480
|
-
if (
|
|
590
|
+
if (accountType !== "evm-eoa" && !isReactNative) {
|
|
481
591
|
const configFileName = isNextjs ? "src/components/Providers.tsx" : "src/config.ts";
|
|
482
|
-
const customizedConfig = customizeConfig(templateDir,
|
|
592
|
+
const customizedConfig = customizeConfig(templateDir, accountType, isNextjs);
|
|
483
593
|
if (customizedConfig) {
|
|
484
|
-
|
|
594
|
+
if (accountType === "evm-smart") {
|
|
595
|
+
console.log("Configuring Smart Accounts in application config");
|
|
596
|
+
} else if (accountType === "solana") {
|
|
597
|
+
console.log("Configuring Solana accounts in application config");
|
|
598
|
+
}
|
|
485
599
|
writeFileToTarget(configFileName, customizedConfig);
|
|
486
600
|
}
|
|
487
601
|
}
|
|
488
602
|
if (isReactNative) {
|
|
489
|
-
const transactionContent = generateTransactionComponent(
|
|
603
|
+
const transactionContent = generateTransactionComponent(accountType);
|
|
490
604
|
writeFileToTarget("Transaction.tsx", transactionContent);
|
|
491
605
|
} else {
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
writeFileToTarget(
|
|
606
|
+
const signedInScreenFileName = isNextjs ? "src/components/SignedInScreen.tsx" : "src/SignedInScreen.tsx";
|
|
607
|
+
const customizedSignedInScreen = customizeSignedInScreen(templateDir, accountType, isNextjs);
|
|
608
|
+
writeFileToTarget(signedInScreenFileName, customizedSignedInScreen);
|
|
609
|
+
if (isNextjs) {
|
|
610
|
+
const onrampFileName = "src/components/SignedInScreenWithOnramp.tsx";
|
|
611
|
+
const customizedOnrampScreen = customizeSignedInScreen(
|
|
612
|
+
templateDir,
|
|
613
|
+
accountType,
|
|
614
|
+
isNextjs,
|
|
615
|
+
"SignedInScreenWithOnramp.tsx"
|
|
616
|
+
);
|
|
617
|
+
writeFileToTarget(onrampFileName, customizedOnrampScreen);
|
|
618
|
+
}
|
|
495
619
|
}
|
|
496
620
|
if (isReactNative && reactNativeCustomizations) {
|
|
497
621
|
if (reactNativeCustomizations.infoPlist) {
|
|
@@ -541,9 +665,11 @@ function copyTemplateFiles({
|
|
|
541
665
|
}
|
|
542
666
|
}
|
|
543
667
|
}
|
|
544
|
-
function generateTransactionComponent(
|
|
545
|
-
if (
|
|
668
|
+
function generateTransactionComponent(accountType) {
|
|
669
|
+
if (accountType === "evm-smart") {
|
|
546
670
|
return `export { default } from "./SmartAccountTransaction";`;
|
|
671
|
+
} else if (accountType === "solana") {
|
|
672
|
+
return `export { default } from "./SolanaTransaction";`;
|
|
547
673
|
} else {
|
|
548
674
|
return `export { default } from "./EOATransaction";`;
|
|
549
675
|
}
|