@coinbase/create-cdp-app 0.0.36 → 0.0.38
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 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/template-nextjs/README.md +3 -2
- package/template-nextjs/env.example +2 -0
- 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/Providers.tsx +32 -14
- 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 +3 -0
- package/template-react/package.json +3 -1
- package/template-react/public/sol.svg +13 -0
- package/template-react/src/Header.tsx +20 -8
- 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 +25 -11
- package/template-react/src/index.css +6 -0
- package/template-react/src/main.tsx +2 -2
- package/template-react-native/App.tsx +79 -62
- 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/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 ? "smart" : "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,50 +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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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"],
|
|
74
101
|
};`
|
|
75
102
|
);
|
|
76
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
|
+
},` : "";
|
|
77
112
|
configContent = configContent.replace(
|
|
78
113
|
/export const CDP_CONFIG: Config = \{[\s\S]*?\};/,
|
|
79
114
|
`export const CDP_CONFIG: Config = {
|
|
80
|
-
projectId: import.meta.env.VITE_CDP_PROJECT_ID
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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"],
|
|
84
119
|
};`
|
|
85
120
|
);
|
|
86
121
|
}
|
|
87
122
|
return configContent;
|
|
88
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
|
+
}
|
|
89
157
|
function copyFileSelectively({
|
|
90
158
|
filePath,
|
|
91
159
|
destPath,
|
|
92
|
-
|
|
160
|
+
accountType,
|
|
93
161
|
enableOnramp
|
|
94
162
|
}) {
|
|
95
163
|
const stat = fs.statSync(filePath);
|
|
96
164
|
if (stat.isDirectory()) {
|
|
97
165
|
const baseDir = path.basename(filePath);
|
|
98
166
|
if (!enableOnramp && (baseDir === "api" || baseDir === "lib")) return;
|
|
99
|
-
copyDirSelectively({ srcDir: filePath, destDir: destPath,
|
|
167
|
+
copyDirSelectively({ srcDir: filePath, destDir: destPath, accountType, enableOnramp });
|
|
100
168
|
} else {
|
|
101
169
|
const fileName = path.basename(filePath);
|
|
102
|
-
if (
|
|
103
|
-
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;
|
|
104
176
|
if (!enableOnramp && ["FundWallet.tsx", "SignedInScreenWithOnramp.tsx"].includes(fileName))
|
|
105
177
|
return;
|
|
106
178
|
if (enableOnramp) {
|
|
@@ -117,14 +189,14 @@ function copyFileSelectively({
|
|
|
117
189
|
function copyDirSelectively({
|
|
118
190
|
srcDir,
|
|
119
191
|
destDir,
|
|
120
|
-
|
|
192
|
+
accountType,
|
|
121
193
|
enableOnramp
|
|
122
194
|
}) {
|
|
123
195
|
fs.mkdirSync(destDir, { recursive: true });
|
|
124
196
|
for (const file of fs.readdirSync(srcDir)) {
|
|
125
197
|
const srcFile = path.resolve(srcDir, file);
|
|
126
198
|
const destFile = path.resolve(destDir, file);
|
|
127
|
-
copyFileSelectively({ filePath: srcFile, destPath: destFile,
|
|
199
|
+
copyFileSelectively({ filePath: srcFile, destPath: destFile, accountType, enableOnramp });
|
|
128
200
|
}
|
|
129
201
|
}
|
|
130
202
|
function isDirEmpty(dirPath) {
|
|
@@ -219,6 +291,23 @@ const TEMPLATES = [
|
|
|
219
291
|
}
|
|
220
292
|
];
|
|
221
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
|
+
];
|
|
222
311
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
223
312
|
async function getAppDetails() {
|
|
224
313
|
const argv = minimist(process.argv.slice(2));
|
|
@@ -227,7 +316,7 @@ async function getAppDetails() {
|
|
|
227
316
|
let templateFromArgs = void 0;
|
|
228
317
|
let projectIdFromArgs = void 0;
|
|
229
318
|
let enableOnrampFromArgs = void 0;
|
|
230
|
-
|
|
319
|
+
let accountTypeFromArgs = void 0;
|
|
231
320
|
if (argv.template) {
|
|
232
321
|
if (!TEMPLATE_NAMES.includes(argv.template)) {
|
|
233
322
|
console.log(
|
|
@@ -248,6 +337,18 @@ async function getAppDetails() {
|
|
|
248
337
|
projectIdFromArgs = argv["project-id"];
|
|
249
338
|
}
|
|
250
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
|
+
}
|
|
251
352
|
if (argv["onramp"] !== void 0) {
|
|
252
353
|
if (!argv["onramp"]) {
|
|
253
354
|
enableOnrampFromArgs = false;
|
|
@@ -301,15 +402,18 @@ async function getAppDetails() {
|
|
|
301
402
|
initial: ""
|
|
302
403
|
},
|
|
303
404
|
{
|
|
304
|
-
type:
|
|
305
|
-
name: "
|
|
306
|
-
message: reset(
|
|
307
|
-
|
|
308
|
-
)
|
|
309
|
-
|
|
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
|
+
}))
|
|
310
414
|
},
|
|
311
415
|
{
|
|
312
|
-
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",
|
|
313
417
|
name: "enableOnramp",
|
|
314
418
|
message: reset("Enable Coinbase Onramp? (Onramp enables users to buy crypto with fiat):"),
|
|
315
419
|
initial: false
|
|
@@ -370,7 +474,7 @@ async function getAppDetails() {
|
|
|
370
474
|
template: templateFromArgs || result.template,
|
|
371
475
|
targetDirectory: targetDir,
|
|
372
476
|
projectId: projectIdFromArgs || result.projectId,
|
|
373
|
-
|
|
477
|
+
accountType: accountTypeFromArgs || result.accountType,
|
|
374
478
|
enableOnramp: enableOnrampFromArgs ?? result.enableOnramp ?? false,
|
|
375
479
|
apiKeyId: result.apiKeyId,
|
|
376
480
|
apiKeySecret: result.apiKeySecret
|
|
@@ -391,7 +495,7 @@ async function init() {
|
|
|
391
495
|
template,
|
|
392
496
|
targetDirectory,
|
|
393
497
|
projectId,
|
|
394
|
-
|
|
498
|
+
accountType,
|
|
395
499
|
enableOnramp,
|
|
396
500
|
apiKeyId,
|
|
397
501
|
apiKeySecret
|
|
@@ -405,7 +509,7 @@ Scaffolding app in ${targetDirectory}...`);
|
|
|
405
509
|
root,
|
|
406
510
|
appName,
|
|
407
511
|
projectId,
|
|
408
|
-
|
|
512
|
+
accountType,
|
|
409
513
|
enableOnramp,
|
|
410
514
|
apiKeyId,
|
|
411
515
|
apiKeySecret
|
|
@@ -432,7 +536,7 @@ function copyTemplateFiles({
|
|
|
432
536
|
root,
|
|
433
537
|
appName,
|
|
434
538
|
projectId,
|
|
435
|
-
|
|
539
|
+
accountType,
|
|
436
540
|
enableOnramp,
|
|
437
541
|
apiKeyId,
|
|
438
542
|
apiKeySecret
|
|
@@ -445,7 +549,7 @@ function copyTemplateFiles({
|
|
|
445
549
|
copyFileSelectively({
|
|
446
550
|
filePath: path.join(templateDir, file),
|
|
447
551
|
destPath: targetPath,
|
|
448
|
-
|
|
552
|
+
accountType,
|
|
449
553
|
enableOnramp
|
|
450
554
|
});
|
|
451
555
|
}
|
|
@@ -463,7 +567,7 @@ function copyTemplateFiles({
|
|
|
463
567
|
const customizedEnv = customizeEnv({
|
|
464
568
|
templateDir,
|
|
465
569
|
projectId,
|
|
466
|
-
|
|
570
|
+
accountType,
|
|
467
571
|
apiKeyId,
|
|
468
572
|
apiKeySecret
|
|
469
573
|
});
|
|
@@ -471,8 +575,10 @@ function copyTemplateFiles({
|
|
|
471
575
|
if (apiKeyId && apiKeySecret) {
|
|
472
576
|
console.log("Copying CDP API credentials to .env");
|
|
473
577
|
}
|
|
474
|
-
if (
|
|
578
|
+
if (accountType === "evm-smart") {
|
|
475
579
|
console.log("Configuring Smart Accounts in environment");
|
|
580
|
+
} else if (accountType === "solana") {
|
|
581
|
+
console.log("Configuring Solana accounts in environment");
|
|
476
582
|
}
|
|
477
583
|
writeFileToTarget(".env", customizedEnv);
|
|
478
584
|
} else if (file === "app.json" && isReactNative && (reactNativeCustomizations == null ? void 0 : reactNativeCustomizations.appJson)) {
|
|
@@ -481,21 +587,35 @@ function copyTemplateFiles({
|
|
|
481
587
|
writeFileToTarget(file);
|
|
482
588
|
}
|
|
483
589
|
}
|
|
484
|
-
if (
|
|
590
|
+
if (accountType !== "evm-eoa" && !isReactNative) {
|
|
485
591
|
const configFileName = isNextjs ? "src/components/Providers.tsx" : "src/config.ts";
|
|
486
|
-
const customizedConfig = customizeConfig(templateDir,
|
|
592
|
+
const customizedConfig = customizeConfig(templateDir, accountType, isNextjs);
|
|
487
593
|
if (customizedConfig) {
|
|
488
|
-
|
|
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
|
+
}
|
|
489
599
|
writeFileToTarget(configFileName, customizedConfig);
|
|
490
600
|
}
|
|
491
601
|
}
|
|
492
602
|
if (isReactNative) {
|
|
493
|
-
const transactionContent = generateTransactionComponent(
|
|
603
|
+
const transactionContent = generateTransactionComponent(accountType);
|
|
494
604
|
writeFileToTarget("Transaction.tsx", transactionContent);
|
|
495
605
|
} else {
|
|
496
|
-
const
|
|
497
|
-
const
|
|
498
|
-
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
|
+
}
|
|
499
619
|
}
|
|
500
620
|
if (isReactNative && reactNativeCustomizations) {
|
|
501
621
|
if (reactNativeCustomizations.infoPlist) {
|
|
@@ -545,9 +665,11 @@ function copyTemplateFiles({
|
|
|
545
665
|
}
|
|
546
666
|
}
|
|
547
667
|
}
|
|
548
|
-
function generateTransactionComponent(
|
|
549
|
-
if (
|
|
668
|
+
function generateTransactionComponent(accountType) {
|
|
669
|
+
if (accountType === "evm-smart") {
|
|
550
670
|
return `export { default } from "./SmartAccountTransaction";`;
|
|
671
|
+
} else if (accountType === "solana") {
|
|
672
|
+
return `export { default } from "./SolanaTransaction";`;
|
|
551
673
|
} else {
|
|
552
674
|
return `export { default } from "./EOATransaction";`;
|
|
553
675
|
}
|