@coinbase/create-cdp-app 0.0.27 → 0.0.29
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/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/template-nextjs/src/app/globals.css +4 -0
- package/template-nextjs/src/components/FundWallet.tsx +2 -2
- package/template-nextjs/src/components/theme.ts +2 -2
- package/template-react/src/index.css +4 -0
- package/template-react/src/theme.ts +2 -2
- package/template-react-native/App.tsx +201 -238
- package/template-react-native/EOATransaction.tsx +222 -263
- package/template-react-native/SmartAccountTransaction.tsx +346 -202
- package/template-react-native/components/DarkModeToggle.tsx +49 -0
- package/template-react-native/components/SignInModal.tsx +342 -0
- package/template-react-native/components/SunMoonIcon.tsx +105 -0
- package/template-react-native/components/UserIcon.tsx +54 -0
- package/template-react-native/components/WalletHeader.tsx +102 -0
- package/template-react-native/components/WelcomeScreen.tsx +73 -0
- package/template-react-native/theme/ThemeContext.tsx +58 -0
- package/template-react-native/types.ts +48 -0
package/dist/index.js
CHANGED
|
@@ -390,6 +390,12 @@ function copyTemplateFiles({
|
|
|
390
390
|
const transactionContent = generateTransactionComponent(useSmartAccounts);
|
|
391
391
|
writeFileToTarget(transactionFileName, transactionContent);
|
|
392
392
|
}
|
|
393
|
+
if (isReactNative) {
|
|
394
|
+
const gradlewPath = path.join(root, "android", "gradlew");
|
|
395
|
+
if (fs.existsSync(gradlewPath)) {
|
|
396
|
+
fs.chmodSync(gradlewPath, 493);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
393
399
|
}
|
|
394
400
|
function generateTransactionComponent(useSmartAccounts) {
|
|
395
401
|
if (useSmartAccounts) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/utils.ts","../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Prepare the app directory\n *\n * @param targetDir - The target directory for the app\n * @param shouldOverwrite - Whether to overwrite the existing directory\n * @returns The path to the prepared app directory\n */\nexport function prepareAppDirectory(targetDir: string, shouldOverwrite: boolean): string {\n const root = path.join(process.cwd(), targetDir);\n\n if (shouldOverwrite) {\n emptyDir(root);\n } else if (!fs.existsSync(root)) {\n fs.mkdirSync(root, { recursive: true });\n }\n\n return root;\n}\n\n/**\n * Customize package.json for the new app\n *\n * @param templateDir - The directory containing the template files\n * @param appName - The name of the app\n * @param includeSdk - Whether to include the CDP SDK in the dependencies\n * @returns The customized package.json content\n */\nexport function customizePackageJson(\n templateDir: string,\n appName: string,\n includeSdk?: boolean,\n): string {\n const packageJsonPath = path.join(templateDir, \"package.json\");\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n packageJson.name = appName;\n if (includeSdk) {\n packageJson.dependencies[\"@coinbase/cdp-sdk\"] = \"latest\";\n }\n return JSON.stringify(packageJson, null, 2) + \"\\n\";\n}\n\n/**\n * Set up the .env file for the new app\n *\n * @param params - The parameters for the function\n * @param params.templateDir - The directory containing the template files\n * @param params.projectId - The CDP Project ID\n * @param params.useSmartAccounts - Whether to enable smart accounts\n * @param params.apiKeyId - The API Key ID\n * @param params.apiKeySecret - The API Key Secret\n * @returns The customized .env content\n */\nexport function customizeEnv({\n templateDir,\n projectId,\n useSmartAccounts,\n apiKeyId,\n apiKeySecret,\n}: {\n templateDir: string;\n projectId: string;\n useSmartAccounts?: boolean;\n apiKeyId?: string;\n apiKeySecret?: string;\n}): string {\n const exampleEnvPath = path.join(templateDir, \"env.example\");\n const exampleEnv = fs.readFileSync(exampleEnvPath, \"utf-8\");\n\n let envContent = exampleEnv.replace(/(.*PROJECT_ID=).*(\\r?\\n|$)/, `$1${projectId}\\n`);\n\n // Set the account type based on user choice\n const accountType = useSmartAccounts ? \"evm-smart\" : \"evm-eoa\";\n let prefix: string;\n if (templateDir.includes(\"nextjs\")) {\n prefix = \"NEXT_PUBLIC_\";\n } else if (templateDir.includes(\"react-native\")) {\n prefix = \"EXPO_PUBLIC_\";\n } else {\n prefix = \"VITE_\";\n }\n envContent = envContent.replace(\n new RegExp(`(${prefix}CDP_CREATE_ACCOUNT_TYPE=).*(\\r?\\n|$)`),\n `$1${accountType}\\n`,\n );\n\n // Replace CDP API credentials if provided\n if (apiKeyId && apiKeySecret) {\n // Replace the commented API Key ID\n envContent = envContent.replace(/# CDP_API_KEY_ID=.*/, `CDP_API_KEY_ID=${apiKeyId}`);\n // Replace the commented API Key Secret\n envContent = envContent.replace(\n /# CDP_API_KEY_SECRET=.*/,\n `CDP_API_KEY_SECRET=${apiKeySecret}`,\n );\n }\n\n return envContent;\n}\n\n/**\n * Customize configuration files for smart accounts\n *\n * @param templateDir - The directory containing the template files\n * @param useSmartAccounts - Whether to enable smart accounts\n * @param isNextjs - Whether this is a Next.js template\n * @returns The customized config content\n */\nexport function customizeConfig(\n templateDir: string,\n useSmartAccounts: boolean,\n isNextjs: boolean,\n): string | null {\n if (!useSmartAccounts) return null;\n\n const configFileName = isNextjs ? \"src/components/Providers.tsx\" : \"src/config.ts\";\n const configPath = path.join(templateDir, configFileName);\n\n if (!fs.existsSync(configPath)) return null;\n\n let configContent = fs.readFileSync(configPath, \"utf-8\");\n\n if (isNextjs) {\n // For Next.js Providers.tsx\n configContent = configContent.replace(\n /const CDP_CONFIG: Config = \\{[\\s\\S]*?\\};/,\n `const CDP_CONFIG: Config = {\n projectId: process.env.NEXT_PUBLIC_CDP_PROJECT_ID ?? \"\",\n createAccountOnLogin: process.env.NEXT_PUBLIC_CDP_CREATE_ACCOUNT_TYPE === \"evm-smart\" ? \"evm-smart\" : \"evm-eoa\",\n};`,\n );\n } else {\n // For React config.ts\n configContent = configContent.replace(\n /export const CDP_CONFIG: Config = \\{[\\s\\S]*?\\};/,\n `export const CDP_CONFIG: Config = {\n projectId: import.meta.env.VITE_CDP_PROJECT_ID,\n createAccountOnLogin: import.meta.env.VITE_CDP_CREATE_ACCOUNT_TYPE === \"evm-smart\" ? \"evm-smart\" : \"evm-eoa\",\n};`,\n );\n }\n\n return configContent;\n}\n\n/**\n * Copy a file or directory recursively\n *\n * @param filePath - The source path\n * @param destPath - The destination path\n */\nexport function copyFile(filePath: string, destPath: string): void {\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n copyDir(filePath, destPath);\n } else {\n fs.copyFileSync(filePath, destPath);\n }\n}\n\n/**\n * Copy a file or directory recursively with selective filtering for transaction components\n *\n * @param params - The parameters for the function\n * @param params.filePath - The source path\n * @param params.destPath - The destination path\n * @param params.useSmartAccounts - Whether to use Smart Accounts\n * @param params.enableOnramp - Whether to include Onramp\n */\nexport function copyFileSelectively({\n filePath,\n destPath,\n useSmartAccounts,\n enableOnramp,\n}: {\n filePath: string;\n destPath: string;\n useSmartAccounts?: boolean;\n enableOnramp?: boolean;\n}): void {\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n const baseDir = path.basename(filePath);\n // skip api and lib directories if Onramp is not enabled\n if (!enableOnramp && (baseDir === \"api\" || baseDir === \"lib\")) return;\n // copy the directory\n copyDirSelectively({ srcDir: filePath, destDir: destPath, useSmartAccounts, enableOnramp });\n } else {\n const fileName = path.basename(filePath);\n\n // Skip transaction components that don't match the user's choice\n if (useSmartAccounts && fileName === \"EOATransaction.tsx\") return;\n if (!useSmartAccounts && fileName === \"SmartAccountTransaction.tsx\") return;\n\n // Skip Onramp files if the user didn't enable Onramp\n if (!enableOnramp && [\"FundWallet.tsx\", \"SignedInScreenWithOnramp.tsx\"].includes(fileName))\n return;\n // Onramp-specific SignedInScreen\n if (enableOnramp) {\n // Skip the default SignedInScreen.tsx file\n if (fileName === \"SignedInScreen.tsx\") return;\n // Copy the SignedInScreenWithOnramp.tsx file to SignedInScreen.tsx\n if (fileName === \"SignedInScreenWithOnramp.tsx\") {\n const newDestPath = destPath.replace(\"SignedInScreenWithOnramp.tsx\", \"SignedInScreen.tsx\");\n fs.copyFileSync(filePath, newDestPath);\n return;\n }\n }\n\n fs.copyFileSync(filePath, destPath);\n }\n}\n\n/**\n * Copy a directory recursively\n *\n * @param srcDir - The source directory path\n * @param destDir - The destination directory path\n */\nfunction copyDir(srcDir: string, destDir: string): void {\n fs.mkdirSync(destDir, { recursive: true });\n for (const file of fs.readdirSync(srcDir)) {\n const srcFile = path.resolve(srcDir, file);\n const destFile = path.resolve(destDir, file);\n copyFile(srcFile, destFile);\n }\n}\n\n/**\n * Copy a directory recursively with selective filtering\n *\n * @param params - The parameters for the function\n * @param params.srcDir - The source directory path\n * @param params.destDir - The destination directory path\n * @param params.useSmartAccounts - Whether to use Smart Accounts\n * @param params.enableOnramp - Whether to include Onramp\n */\nfunction copyDirSelectively({\n srcDir,\n destDir,\n useSmartAccounts,\n enableOnramp,\n}: {\n srcDir: string;\n destDir: string;\n useSmartAccounts?: boolean;\n enableOnramp?: boolean;\n}): void {\n fs.mkdirSync(destDir, { recursive: true });\n for (const file of fs.readdirSync(srcDir)) {\n const srcFile = path.resolve(srcDir, file);\n const destFile = path.resolve(destDir, file);\n copyFileSelectively({ filePath: srcFile, destPath: destFile, useSmartAccounts, enableOnramp });\n }\n}\n\n/**\n * Check if a directory is empty\n *\n * @param dirPath - The path to the directory\n * @returns True if the directory is empty, false otherwise\n */\nexport function isDirEmpty(dirPath: string): boolean {\n const files = fs.readdirSync(dirPath);\n return files.length === 0 || (files.length === 1 && files[0] === \".git\");\n}\n\n/**\n * Empty a directory while preserving .git\n *\n * @param dirPath - The path to the directory\n */\nfunction emptyDir(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n return;\n }\n for (const file of fs.readdirSync(dirPath)) {\n if (file === \".git\") {\n continue;\n }\n fs.rmSync(path.resolve(dirPath, file), { recursive: true, force: true });\n }\n}\n\n/**\n * Detect which package manager invoked the create command\n *\n * @returns The detected package manager or 'pnpm' as default\n */\nexport function detectPackageManager(): \"npm\" | \"pnpm\" | \"yarn\" {\n const userAgent = process.env.npm_config_user_agent;\n\n if (userAgent) {\n if (userAgent.startsWith(\"yarn\")) return \"yarn\";\n if (userAgent.startsWith(\"pnpm\")) return \"pnpm\";\n if (userAgent.startsWith(\"npm\")) return \"npm\";\n }\n\n return \"npm\"; // Default to npm if we can't detect\n}\n","#!/usr/bin/env node\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { red, green, reset } from \"kolorist\";\nimport prompts from \"prompts\";\n\nimport {\n prepareAppDirectory,\n isDirEmpty,\n customizePackageJson,\n copyFileSelectively,\n customizeEnv,\n customizeConfig,\n detectPackageManager,\n} from \"./utils.js\";\n\n// Available templates for app creation\nconst TEMPLATES = [\n {\n name: \"react\",\n display: \"React Single Page App\",\n color: green,\n },\n {\n name: \"nextjs\",\n display: \"Next.js Full Stack App\",\n color: green,\n },\n {\n name: \"react-native\",\n display: \"React Native with Expo\",\n color: green,\n },\n];\n\nconst defaultTargetDir = \"cdp-app\";\n\nconst fileRenames: Record<string, string | undefined> = {\n _gitignore: \".gitignore\",\n};\n\ninterface AppOptions {\n appName: string;\n template: string;\n targetDirectory: string;\n projectId: string;\n useSmartAccounts: boolean;\n enableOnramp: boolean;\n apiKeyId?: string;\n apiKeySecret?: string;\n}\n\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * Initialize a new CDP app\n */\nasync function init(): Promise<void> {\n const {\n appName,\n template,\n targetDirectory,\n projectId,\n useSmartAccounts,\n enableOnramp,\n apiKeyId,\n apiKeySecret,\n } = await getAppDetails();\n\n console.log(`\\nScaffolding app in ${targetDirectory}...`);\n\n const root = prepareAppDirectory(targetDirectory, false);\n const templateDir = path.resolve(fileURLToPath(import.meta.url), \"../..\", `template-${template}`);\n\n copyTemplateFiles({\n templateDir,\n root,\n appName,\n projectId,\n useSmartAccounts,\n enableOnramp,\n apiKeyId,\n apiKeySecret,\n });\n printNextSteps(root, template);\n}\n\n/**\n * Get app details from command line arguments or prompt the user\n *\n * @returns The app details\n */\nasync function getAppDetails(): Promise<AppOptions> {\n // Get target directory from command line args (first non-option argument)\n let targetDir = process.argv[2];\n const defaultAppName = targetDir ?? defaultTargetDir;\n\n try {\n const result = await prompts(\n [\n {\n type: targetDir ? null : \"text\",\n name: \"appName\",\n message: reset(\"App Name:\"),\n initial: defaultAppName,\n onState: state => {\n targetDir = String(state.value).trim() || defaultAppName;\n },\n },\n {\n type: \"select\",\n name: \"template\",\n message: reset(\"Template:\"),\n initial: 0,\n choices: TEMPLATES.map(template => ({\n title: template.color(template.display || template.name),\n value: template.name,\n })),\n },\n {\n type: \"text\",\n name: \"projectId\",\n message: reset(\n \"CDP Project ID (Find your project ID at https://portal.cdp.coinbase.com/projects/overview):\",\n ),\n validate: value => {\n if (!value) {\n return \"Project ID is required\";\n } else if (!uuidRegex.test(value)) {\n return \"Project ID must be a valid UUID\";\n }\n return true;\n },\n initial: \"\",\n },\n {\n type: \"confirm\",\n name: \"useSmartAccounts\",\n message: reset(\n \"Enable Smart Accounts? (Smart Accounts enable gasless transactions and improved UX):\",\n ),\n initial: false,\n },\n {\n type: (_, { template }: { template?: string }) =>\n template === \"nextjs\" ? \"confirm\" : null,\n name: \"enableOnramp\",\n message: reset(\n \"Enable Coinbase Onramp? (Onramp enables users to buy crypto with fiat) -- NOTE: EXPERIMENTAL FEATURE\",\n ),\n initial: false,\n },\n {\n type: (_, { enableOnramp }: { enableOnramp?: boolean }) => (enableOnramp ? \"text\" : null),\n name: \"apiKeyId\",\n message: reset(\"CDP API Key ID (Create at https://portal.cdp.coinbase.com/api-keys):\"),\n validate: value => {\n if (!value) {\n return \"API Key ID is required for Onramp\";\n }\n return true;\n },\n },\n {\n type: (_, { enableOnramp }: { enableOnramp?: boolean }) =>\n enableOnramp ? \"password\" : null,\n name: \"apiKeySecret\",\n message: reset(\"CDP API Key Secret (paste your private key - it will be hidden):\"),\n validate: value => {\n if (!value) {\n return \"API Key Secret is required for Onramp\";\n }\n return true;\n },\n },\n {\n type: (_, { template }: { template?: string }) =>\n template === \"react-native\" ? null : \"confirm\",\n name: \"corsConfirmation\",\n message: reset(\n \"Confirm you have whitelisted 'http://localhost:3000' at https://portal.cdp.coinbase.com/products/embedded-wallets/domains:\",\n ),\n initial: true,\n },\n {\n type: () => (!fs.existsSync(targetDir) || isDirEmpty(targetDir) ? null : \"confirm\"),\n name: \"overwrite\",\n message: () =>\n (targetDir === \".\" ? \"Current directory\" : `Target directory \"${targetDir}\"`) +\n \" is not empty. Remove existing files and continue?\",\n },\n {\n type: (_, { overwrite }: { overwrite?: boolean }) => {\n if (overwrite === false) {\n throw new Error(red(\"✖\") + \" Operation cancelled\");\n }\n return null;\n },\n name: \"overwriteChecker\",\n },\n ],\n {\n onCancel: () => {\n throw new Error(red(\"✖\") + \" Operation cancelled\");\n },\n },\n );\n\n return {\n appName: result.appName,\n template: result.template,\n targetDirectory: targetDir,\n projectId: result.projectId,\n useSmartAccounts: result.useSmartAccounts,\n enableOnramp: result.enableOnramp,\n apiKeyId: result.apiKeyId,\n apiKeySecret: result.apiKeySecret,\n };\n } catch (cancelled: unknown) {\n if (cancelled instanceof Error) {\n console.log(cancelled.message);\n }\n process.exit(0);\n }\n}\n\n/**\n * Print next steps for the user\n *\n * @param appRoot - The root directory of the app\n * @param template - The template that was used\n */\nfunction printNextSteps(appRoot: string, template: string): void {\n const packageManager = detectPackageManager();\n\n console.log(green(\"\\nDone. Now run your app:\\n\"));\n if (appRoot !== process.cwd()) {\n console.log(`cd ${path.relative(process.cwd(), appRoot)}`);\n }\n\n console.log(`${packageManager} install`);\n\n if (template === \"react-native\") {\n const startCommand =\n packageManager === \"npm\"\n ? \"npm run ios # or npm run android\"\n : `${packageManager} run ios # or ${packageManager} run android`;\n console.log(startCommand);\n } else {\n const devCommand = packageManager === \"npm\" ? \"npm run dev\" : `${packageManager} dev`;\n console.log(devCommand);\n }\n}\n\n/**\n * Copy template files to the app directory\n *\n * @param params - The parameters for the function\n * @param params.templateDir - The directory containing the template files\n * @param params.root - The root directory of the app\n * @param params.appName - The name of the app\n * @param params.projectId - The CDP Project ID\n * @param params.useSmartAccounts - Whether to enable smart accounts\n * @param params.enableOnramp - Whether to include Onramp\n * @param params.apiKeyId - The API Key ID\n * @param params.apiKeySecret - The API Key Secret\n */\nfunction copyTemplateFiles({\n templateDir,\n root,\n appName,\n projectId,\n useSmartAccounts,\n enableOnramp,\n apiKeyId,\n apiKeySecret,\n}: {\n templateDir: string;\n root: string;\n appName: string;\n projectId?: string;\n useSmartAccounts?: boolean;\n enableOnramp?: boolean;\n apiKeyId?: string;\n apiKeySecret?: string;\n}): void {\n const writeFileToTarget = (file: string, content?: string) => {\n const targetPath = path.join(root, fileRenames[file] ?? file);\n if (content) {\n fs.writeFileSync(targetPath, content);\n } else {\n copyFileSelectively({\n filePath: path.join(templateDir, file),\n destPath: targetPath,\n useSmartAccounts,\n enableOnramp,\n });\n }\n };\n\n const isNextjs = templateDir.includes(\"nextjs\");\n\n const files = fs.readdirSync(templateDir);\n for (const file of files) {\n if (file === \"package.json\") {\n const customizedPackageJson = customizePackageJson(templateDir, appName, enableOnramp);\n writeFileToTarget(file, customizedPackageJson);\n } else if (file === \"env.example\" && projectId) {\n writeFileToTarget(file);\n const customizedEnv = customizeEnv({\n templateDir,\n projectId,\n useSmartAccounts,\n apiKeyId,\n apiKeySecret,\n });\n console.log(\"Copying CDP Project ID to .env\");\n if (apiKeyId && apiKeySecret) {\n console.log(\"Copying CDP API credentials to .env\");\n }\n if (useSmartAccounts) {\n console.log(\"Configuring Smart Accounts in environment\");\n }\n writeFileToTarget(\".env\", customizedEnv);\n } else {\n writeFileToTarget(file);\n }\n }\n\n const isReactNative = templateDir.includes(\"react-native\");\n\n // Handle smart account configuration in config files\n if (useSmartAccounts && !isReactNative) {\n const configFileName = isNextjs ? \"src/components/Providers.tsx\" : \"src/config.ts\";\n const customizedConfig = customizeConfig(templateDir, useSmartAccounts, isNextjs);\n if (customizedConfig) {\n console.log(\"Configuring Smart Accounts in application config\");\n writeFileToTarget(configFileName, customizedConfig);\n }\n }\n\n // Generate the appropriate Transaction.tsx component\n if (isReactNative) {\n // For React Native, create the Transaction.tsx barrel file\n const transactionContent = generateTransactionComponent(useSmartAccounts);\n writeFileToTarget(\"Transaction.tsx\", transactionContent);\n } else {\n // For React/Next.js templates\n const transactionFileName = isNextjs ? \"src/components/Transaction.tsx\" : \"src/Transaction.tsx\";\n const transactionContent = generateTransactionComponent(useSmartAccounts);\n writeFileToTarget(transactionFileName, transactionContent);\n }\n}\n\n/**\n * Generate the appropriate Transaction component based on account type\n *\n * @param useSmartAccounts - Whether to use Smart Accounts\n * @returns The generated Transaction component content\n */\nfunction generateTransactionComponent(useSmartAccounts?: boolean): string {\n if (useSmartAccounts) {\n return `export { default } from \"./SmartAccountTransaction\";`;\n } else {\n return `export { default } from \"./EOATransaction\";`;\n }\n}\n\ninit().catch(e => {\n console.error(e);\n process.exit(1);\n});\n"],"names":[],"mappings":";;;;;;AAUgB,SAAA,oBAAoB,WAAmB,iBAAkC;AACvF,QAAM,OAAO,KAAK,KAAK,QAAQ,OAAO,SAAS;AAIpC,MAAA,CAAC,GAAG,WAAW,IAAI,GAAG;AAC/B,OAAG,UAAU,MAAM,EAAE,WAAW,MAAM;AAAA,EAAA;AAGjC,SAAA;AACT;AAUgB,SAAA,qBACd,aACA,SACA,YACQ;AACR,QAAM,kBAAkB,KAAK,KAAK,aAAa,cAAc;AAC7D,QAAM,cAAc,KAAK,MAAM,GAAG,aAAa,iBAAiB,OAAO,CAAC;AACxE,cAAY,OAAO;AACnB,MAAI,YAAY;AACF,gBAAA,aAAa,mBAAmB,IAAI;AAAA,EAAA;AAElD,SAAO,KAAK,UAAU,aAAa,MAAM,CAAC,IAAI;AAChD;AAaO,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMW;AACT,QAAM,iBAAiB,KAAK,KAAK,aAAa,aAAa;AAC3D,QAAM,aAAa,GA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gB,YAAY,SAAS,cAAc;AAGrD,MAAA,oBAAoB,CAAC,eAAe;AAChC,UAAA,iBAAiB,WAAW,iCAAiC;AACnE,UAAM,mBAAmB,gBAAgB,aAAa,kBAAkB,QAAQ;AAChF,QAAI,kBAAkB;AACpB,cAAQ,IAAI,kDAAkD;AAC9D,wBAAkB,gBAAgB,gBAAgB;AAAA,IAAA;AAAA,EACpD;AAIF,MAAI,eAAe;AAEX,UAAA,qBAAqB,6BAA6B,gBAAgB;AACxE,sBAAkB,mBAAmB,kBAAkB;AAAA,EAAA,OAClD;AAEC,UAAA,sBAAsB,WAAW,mCAAmC;AACpE,UAAA,qBAAqB,6BAA6B,gBAAgB;AACxE,sBAAkB,qBAAqB,kBAAkB;AAAA,EAAA;AAE7D;AAQA,SAAS,6BAA6B,kBAAoC;AACxE,MAAI,kBAAkB;AACb,WAAA;AAAA,EAAA,OACF;AACE,WAAA;AAAA,EAAA;AAEX;AAEA,OAAO,MAAM,CAAK,MAAA;AAChB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils.ts","../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Prepare the app directory\n *\n * @param targetDir - The target directory for the app\n * @param shouldOverwrite - Whether to overwrite the existing directory\n * @returns The path to the prepared app directory\n */\nexport function prepareAppDirectory(targetDir: string, shouldOverwrite: boolean): string {\n const root = path.join(process.cwd(), targetDir);\n\n if (shouldOverwrite) {\n emptyDir(root);\n } else if (!fs.existsSync(root)) {\n fs.mkdirSync(root, { recursive: true });\n }\n\n return root;\n}\n\n/**\n * Customize package.json for the new app\n *\n * @param templateDir - The directory containing the template files\n * @param appName - The name of the app\n * @param includeSdk - Whether to include the CDP SDK in the dependencies\n * @returns The customized package.json content\n */\nexport function customizePackageJson(\n templateDir: string,\n appName: string,\n includeSdk?: boolean,\n): string {\n const packageJsonPath = path.join(templateDir, \"package.json\");\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n packageJson.name = appName;\n if (includeSdk) {\n packageJson.dependencies[\"@coinbase/cdp-sdk\"] = \"latest\";\n }\n return JSON.stringify(packageJson, null, 2) + \"\\n\";\n}\n\n/**\n * Set up the .env file for the new app\n *\n * @param params - The parameters for the function\n * @param params.templateDir - The directory containing the template files\n * @param params.projectId - The CDP Project ID\n * @param params.useSmartAccounts - Whether to enable smart accounts\n * @param params.apiKeyId - The API Key ID\n * @param params.apiKeySecret - The API Key Secret\n * @returns The customized .env content\n */\nexport function customizeEnv({\n templateDir,\n projectId,\n useSmartAccounts,\n apiKeyId,\n apiKeySecret,\n}: {\n templateDir: string;\n projectId: string;\n useSmartAccounts?: boolean;\n apiKeyId?: string;\n apiKeySecret?: string;\n}): string {\n const exampleEnvPath = path.join(templateDir, \"env.example\");\n const exampleEnv = fs.readFileSync(exampleEnvPath, \"utf-8\");\n\n let envContent = exampleEnv.replace(/(.*PROJECT_ID=).*(\\r?\\n|$)/, `$1${projectId}\\n`);\n\n // Set the account type based on user choice\n const accountType = useSmartAccounts ? \"evm-smart\" : \"evm-eoa\";\n let prefix: string;\n if (templateDir.includes(\"nextjs\")) {\n prefix = \"NEXT_PUBLIC_\";\n } else if (templateDir.includes(\"react-native\")) {\n prefix = \"EXPO_PUBLIC_\";\n } else {\n prefix = \"VITE_\";\n }\n envContent = envContent.replace(\n new RegExp(`(${prefix}CDP_CREATE_ACCOUNT_TYPE=).*(\\r?\\n|$)`),\n `$1${accountType}\\n`,\n );\n\n // Replace CDP API credentials if provided\n if (apiKeyId && apiKeySecret) {\n // Replace the commented API Key ID\n envContent = envContent.replace(/# CDP_API_KEY_ID=.*/, `CDP_API_KEY_ID=${apiKeyId}`);\n // Replace the commented API Key Secret\n envContent = envContent.replace(\n /# CDP_API_KEY_SECRET=.*/,\n `CDP_API_KEY_SECRET=${apiKeySecret}`,\n );\n }\n\n return envContent;\n}\n\n/**\n * Customize configuration files for smart accounts\n *\n * @param templateDir - The directory containing the template files\n * @param useSmartAccounts - Whether to enable smart accounts\n * @param isNextjs - Whether this is a Next.js template\n * @returns The customized config content\n */\nexport function customizeConfig(\n templateDir: string,\n useSmartAccounts: boolean,\n isNextjs: boolean,\n): string | null {\n if (!useSmartAccounts) return null;\n\n const configFileName = isNextjs ? \"src/components/Providers.tsx\" : \"src/config.ts\";\n const configPath = path.join(templateDir, configFileName);\n\n if (!fs.existsSync(configPath)) return null;\n\n let configContent = fs.readFileSync(configPath, \"utf-8\");\n\n if (isNextjs) {\n // For Next.js Providers.tsx\n configContent = configContent.replace(\n /const CDP_CONFIG: Config = \\{[\\s\\S]*?\\};/,\n `const CDP_CONFIG: Config = {\n projectId: process.env.NEXT_PUBLIC_CDP_PROJECT_ID ?? \"\",\n createAccountOnLogin: process.env.NEXT_PUBLIC_CDP_CREATE_ACCOUNT_TYPE === \"evm-smart\" ? \"evm-smart\" : \"evm-eoa\",\n};`,\n );\n } else {\n // For React config.ts\n configContent = configContent.replace(\n /export const CDP_CONFIG: Config = \\{[\\s\\S]*?\\};/,\n `export const CDP_CONFIG: Config = {\n projectId: import.meta.env.VITE_CDP_PROJECT_ID,\n createAccountOnLogin: import.meta.env.VITE_CDP_CREATE_ACCOUNT_TYPE === \"evm-smart\" ? \"evm-smart\" : \"evm-eoa\",\n};`,\n );\n }\n\n return configContent;\n}\n\n/**\n * Copy a file or directory recursively\n *\n * @param filePath - The source path\n * @param destPath - The destination path\n */\nexport function copyFile(filePath: string, destPath: string): void {\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n copyDir(filePath, destPath);\n } else {\n fs.copyFileSync(filePath, destPath);\n }\n}\n\n/**\n * Copy a file or directory recursively with selective filtering for transaction components\n *\n * @param params - The parameters for the function\n * @param params.filePath - The source path\n * @param params.destPath - The destination path\n * @param params.useSmartAccounts - Whether to use Smart Accounts\n * @param params.enableOnramp - Whether to include Onramp\n */\nexport function copyFileSelectively({\n filePath,\n destPath,\n useSmartAccounts,\n enableOnramp,\n}: {\n filePath: string;\n destPath: string;\n useSmartAccounts?: boolean;\n enableOnramp?: boolean;\n}): void {\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n const baseDir = path.basename(filePath);\n // skip api and lib directories if Onramp is not enabled\n if (!enableOnramp && (baseDir === \"api\" || baseDir === \"lib\")) return;\n // copy the directory\n copyDirSelectively({ srcDir: filePath, destDir: destPath, useSmartAccounts, enableOnramp });\n } else {\n const fileName = path.basename(filePath);\n\n // Skip transaction components that don't match the user's choice\n if (useSmartAccounts && fileName === \"EOATransaction.tsx\") return;\n if (!useSmartAccounts && fileName === \"SmartAccountTransaction.tsx\") return;\n\n // Skip Onramp files if the user didn't enable Onramp\n if (!enableOnramp && [\"FundWallet.tsx\", \"SignedInScreenWithOnramp.tsx\"].includes(fileName))\n return;\n // Onramp-specific SignedInScreen\n if (enableOnramp) {\n // Skip the default SignedInScreen.tsx file\n if (fileName === \"SignedInScreen.tsx\") return;\n // Copy the SignedInScreenWithOnramp.tsx file to SignedInScreen.tsx\n if (fileName === \"SignedInScreenWithOnramp.tsx\") {\n const newDestPath = destPath.replace(\"SignedInScreenWithOnramp.tsx\", \"SignedInScreen.tsx\");\n fs.copyFileSync(filePath, newDestPath);\n return;\n }\n }\n\n fs.copyFileSync(filePath, destPath);\n }\n}\n\n/**\n * Copy a directory recursively\n *\n * @param srcDir - The source directory path\n * @param destDir - The destination directory path\n */\nfunction copyDir(srcDir: string, destDir: string): void {\n fs.mkdirSync(destDir, { recursive: true });\n for (const file of fs.readdirSync(srcDir)) {\n const srcFile = path.resolve(srcDir, file);\n const destFile = path.resolve(destDir, file);\n copyFile(srcFile, destFile);\n }\n}\n\n/**\n * Copy a directory recursively with selective filtering\n *\n * @param params - The parameters for the function\n * @param params.srcDir - The source directory path\n * @param params.destDir - The destination directory path\n * @param params.useSmartAccounts - Whether to use Smart Accounts\n * @param params.enableOnramp - Whether to include Onramp\n */\nfunction copyDirSelectively({\n srcDir,\n destDir,\n useSmartAccounts,\n enableOnramp,\n}: {\n srcDir: string;\n destDir: string;\n useSmartAccounts?: boolean;\n enableOnramp?: boolean;\n}): void {\n fs.mkdirSync(destDir, { recursive: true });\n for (const file of fs.readdirSync(srcDir)) {\n const srcFile = path.resolve(srcDir, file);\n const destFile = path.resolve(destDir, file);\n copyFileSelectively({ filePath: srcFile, destPath: destFile, useSmartAccounts, enableOnramp });\n }\n}\n\n/**\n * Check if a directory is empty\n *\n * @param dirPath - The path to the directory\n * @returns True if the directory is empty, false otherwise\n */\nexport function isDirEmpty(dirPath: string): boolean {\n const files = fs.readdirSync(dirPath);\n return files.length === 0 || (files.length === 1 && files[0] === \".git\");\n}\n\n/**\n * Empty a directory while preserving .git\n *\n * @param dirPath - The path to the directory\n */\nfunction emptyDir(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n return;\n }\n for (const file of fs.readdirSync(dirPath)) {\n if (file === \".git\") {\n continue;\n }\n fs.rmSync(path.resolve(dirPath, file), { recursive: true, force: true });\n }\n}\n\n/**\n * Detect which package manager invoked the create command\n *\n * @returns The detected package manager or 'pnpm' as default\n */\nexport function detectPackageManager(): \"npm\" | \"pnpm\" | \"yarn\" {\n const userAgent = process.env.npm_config_user_agent;\n\n if (userAgent) {\n if (userAgent.startsWith(\"yarn\")) return \"yarn\";\n if (userAgent.startsWith(\"pnpm\")) return \"pnpm\";\n if (userAgent.startsWith(\"npm\")) return \"npm\";\n }\n\n return \"npm\"; // Default to npm if we can't detect\n}\n","#!/usr/bin/env node\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { red, green, reset } from \"kolorist\";\nimport prompts from \"prompts\";\n\nimport {\n prepareAppDirectory,\n isDirEmpty,\n customizePackageJson,\n copyFileSelectively,\n customizeEnv,\n customizeConfig,\n detectPackageManager,\n} from \"./utils.js\";\n\n// Available templates for app creation\nconst TEMPLATES = [\n {\n name: \"react\",\n display: \"React Single Page App\",\n color: green,\n },\n {\n name: \"nextjs\",\n display: \"Next.js Full Stack App\",\n color: green,\n },\n {\n name: \"react-native\",\n display: \"React Native with Expo\",\n color: green,\n },\n];\n\nconst defaultTargetDir = \"cdp-app\";\n\nconst fileRenames: Record<string, string | undefined> = {\n _gitignore: \".gitignore\",\n};\n\ninterface AppOptions {\n appName: string;\n template: string;\n targetDirectory: string;\n projectId: string;\n useSmartAccounts: boolean;\n enableOnramp: boolean;\n apiKeyId?: string;\n apiKeySecret?: string;\n}\n\nconst uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * Initialize a new CDP app\n */\nasync function init(): Promise<void> {\n const {\n appName,\n template,\n targetDirectory,\n projectId,\n useSmartAccounts,\n enableOnramp,\n apiKeyId,\n apiKeySecret,\n } = await getAppDetails();\n\n console.log(`\\nScaffolding app in ${targetDirectory}...`);\n\n const root = prepareAppDirectory(targetDirectory, false);\n const templateDir = path.resolve(fileURLToPath(import.meta.url), \"../..\", `template-${template}`);\n\n copyTemplateFiles({\n templateDir,\n root,\n appName,\n projectId,\n useSmartAccounts,\n enableOnramp,\n apiKeyId,\n apiKeySecret,\n });\n printNextSteps(root, template);\n}\n\n/**\n * Get app details from command line arguments or prompt the user\n *\n * @returns The app details\n */\nasync function getAppDetails(): Promise<AppOptions> {\n // Get target directory from command line args (first non-option argument)\n let targetDir = process.argv[2];\n const defaultAppName = targetDir ?? defaultTargetDir;\n\n try {\n const result = await prompts(\n [\n {\n type: targetDir ? null : \"text\",\n name: \"appName\",\n message: reset(\"App Name:\"),\n initial: defaultAppName,\n onState: state => {\n targetDir = String(state.value).trim() || defaultAppName;\n },\n },\n {\n type: \"select\",\n name: \"template\",\n message: reset(\"Template:\"),\n initial: 0,\n choices: TEMPLATES.map(template => ({\n title: template.color(template.display || template.name),\n value: template.name,\n })),\n },\n {\n type: \"text\",\n name: \"projectId\",\n message: reset(\n \"CDP Project ID (Find your project ID at https://portal.cdp.coinbase.com/projects/overview):\",\n ),\n validate: value => {\n if (!value) {\n return \"Project ID is required\";\n } else if (!uuidRegex.test(value)) {\n return \"Project ID must be a valid UUID\";\n }\n return true;\n },\n initial: \"\",\n },\n {\n type: \"confirm\",\n name: \"useSmartAccounts\",\n message: reset(\n \"Enable Smart Accounts? (Smart Accounts enable gasless transactions and improved UX):\",\n ),\n initial: false,\n },\n {\n type: (_, { template }: { template?: string }) =>\n template === \"nextjs\" ? \"confirm\" : null,\n name: \"enableOnramp\",\n message: reset(\n \"Enable Coinbase Onramp? (Onramp enables users to buy crypto with fiat) -- NOTE: EXPERIMENTAL FEATURE\",\n ),\n initial: false,\n },\n {\n type: (_, { enableOnramp }: { enableOnramp?: boolean }) => (enableOnramp ? \"text\" : null),\n name: \"apiKeyId\",\n message: reset(\"CDP API Key ID (Create at https://portal.cdp.coinbase.com/api-keys):\"),\n validate: value => {\n if (!value) {\n return \"API Key ID is required for Onramp\";\n }\n return true;\n },\n },\n {\n type: (_, { enableOnramp }: { enableOnramp?: boolean }) =>\n enableOnramp ? \"password\" : null,\n name: \"apiKeySecret\",\n message: reset(\"CDP API Key Secret (paste your private key - it will be hidden):\"),\n validate: value => {\n if (!value) {\n return \"API Key Secret is required for Onramp\";\n }\n return true;\n },\n },\n {\n type: (_, { template }: { template?: string }) =>\n template === \"react-native\" ? null : \"confirm\",\n name: \"corsConfirmation\",\n message: reset(\n \"Confirm you have whitelisted 'http://localhost:3000' at https://portal.cdp.coinbase.com/products/embedded-wallets/domains:\",\n ),\n initial: true,\n },\n {\n type: () => (!fs.existsSync(targetDir) || isDirEmpty(targetDir) ? null : \"confirm\"),\n name: \"overwrite\",\n message: () =>\n (targetDir === \".\" ? \"Current directory\" : `Target directory \"${targetDir}\"`) +\n \" is not empty. Remove existing files and continue?\",\n },\n {\n type: (_, { overwrite }: { overwrite?: boolean }) => {\n if (overwrite === false) {\n throw new Error(red(\"✖\") + \" Operation cancelled\");\n }\n return null;\n },\n name: \"overwriteChecker\",\n },\n ],\n {\n onCancel: () => {\n throw new Error(red(\"✖\") + \" Operation cancelled\");\n },\n },\n );\n\n return {\n appName: result.appName,\n template: result.template,\n targetDirectory: targetDir,\n projectId: result.projectId,\n useSmartAccounts: result.useSmartAccounts,\n enableOnramp: result.enableOnramp,\n apiKeyId: result.apiKeyId,\n apiKeySecret: result.apiKeySecret,\n };\n } catch (cancelled: unknown) {\n if (cancelled instanceof Error) {\n console.log(cancelled.message);\n }\n process.exit(0);\n }\n}\n\n/**\n * Print next steps for the user\n *\n * @param appRoot - The root directory of the app\n * @param template - The template that was used\n */\nfunction printNextSteps(appRoot: string, template: string): void {\n const packageManager = detectPackageManager();\n\n console.log(green(\"\\nDone. Now run your app:\\n\"));\n if (appRoot !== process.cwd()) {\n console.log(`cd ${path.relative(process.cwd(), appRoot)}`);\n }\n\n console.log(`${packageManager} install`);\n\n if (template === \"react-native\") {\n const startCommand =\n packageManager === \"npm\"\n ? \"npm run ios # or npm run android\"\n : `${packageManager} run ios # or ${packageManager} run android`;\n console.log(startCommand);\n } else {\n const devCommand = packageManager === \"npm\" ? \"npm run dev\" : `${packageManager} dev`;\n console.log(devCommand);\n }\n}\n\n/**\n * Copy template files to the app directory\n *\n * @param params - The parameters for the function\n * @param params.templateDir - The directory containing the template files\n * @param params.root - The root directory of the app\n * @param params.appName - The name of the app\n * @param params.projectId - The CDP Project ID\n * @param params.useSmartAccounts - Whether to enable smart accounts\n * @param params.enableOnramp - Whether to include Onramp\n * @param params.apiKeyId - The API Key ID\n * @param params.apiKeySecret - The API Key Secret\n */\nfunction copyTemplateFiles({\n templateDir,\n root,\n appName,\n projectId,\n useSmartAccounts,\n enableOnramp,\n apiKeyId,\n apiKeySecret,\n}: {\n templateDir: string;\n root: string;\n appName: string;\n projectId?: string;\n useSmartAccounts?: boolean;\n enableOnramp?: boolean;\n apiKeyId?: string;\n apiKeySecret?: string;\n}): void {\n const writeFileToTarget = (file: string, content?: string) => {\n const targetPath = path.join(root, fileRenames[file] ?? file);\n if (content) {\n fs.writeFileSync(targetPath, content);\n } else {\n copyFileSelectively({\n filePath: path.join(templateDir, file),\n destPath: targetPath,\n useSmartAccounts,\n enableOnramp,\n });\n }\n };\n\n const isNextjs = templateDir.includes(\"nextjs\");\n\n const files = fs.readdirSync(templateDir);\n for (const file of files) {\n if (file === \"package.json\") {\n const customizedPackageJson = customizePackageJson(templateDir, appName, enableOnramp);\n writeFileToTarget(file, customizedPackageJson);\n } else if (file === \"env.example\" && projectId) {\n writeFileToTarget(file);\n const customizedEnv = customizeEnv({\n templateDir,\n projectId,\n useSmartAccounts,\n apiKeyId,\n apiKeySecret,\n });\n console.log(\"Copying CDP Project ID to .env\");\n if (apiKeyId && apiKeySecret) {\n console.log(\"Copying CDP API credentials to .env\");\n }\n if (useSmartAccounts) {\n console.log(\"Configuring Smart Accounts in environment\");\n }\n writeFileToTarget(\".env\", customizedEnv);\n } else {\n writeFileToTarget(file);\n }\n }\n\n const isReactNative = templateDir.includes(\"react-native\");\n\n // Handle smart account configuration in config files\n if (useSmartAccounts && !isReactNative) {\n const configFileName = isNextjs ? \"src/components/Providers.tsx\" : \"src/config.ts\";\n const customizedConfig = customizeConfig(templateDir, useSmartAccounts, isNextjs);\n if (customizedConfig) {\n console.log(\"Configuring Smart Accounts in application config\");\n writeFileToTarget(configFileName, customizedConfig);\n }\n }\n\n // Generate the appropriate Transaction.tsx component\n if (isReactNative) {\n // For React Native, create the Transaction.tsx barrel file\n const transactionContent = generateTransactionComponent(useSmartAccounts);\n writeFileToTarget(\"Transaction.tsx\", transactionContent);\n } else {\n // For React/Next.js templates\n const transactionFileName = isNextjs ? \"src/components/Transaction.tsx\" : \"src/Transaction.tsx\";\n const transactionContent = generateTransactionComponent(useSmartAccounts);\n writeFileToTarget(transactionFileName, transactionContent);\n }\n\n // Update android/gradlew permissions so that the template is runnable\n if (isReactNative) {\n const gradlewPath = path.join(root, \"android\", \"gradlew\");\n if (fs.existsSync(gradlewPath)) {\n fs.chmodSync(gradlewPath, 0o755);\n }\n }\n}\n\n/**\n * Generate the appropriate Transaction component based on account type\n *\n * @param useSmartAccounts - Whether to use Smart Accounts\n * @returns The generated Transaction component content\n */\nfunction generateTransactionComponent(useSmartAccounts?: boolean): string {\n if (useSmartAccounts) {\n return `export { default } from \"./SmartAccountTransaction\";`;\n } else {\n return `export { default } from \"./EOATransaction\";`;\n }\n}\n\ninit().catch(e => {\n console.error(e);\n process.exit(1);\n});\n"],"names":[],"mappings":";;;;;;AAUgB,SAAA,oBAAoB,WAAmB,iBAAkC;AACvF,QAAM,OAAO,KAAK,KAAK,QAAQ,OAAO,SAAS;AAIpC,MAAA,CAAC,GAAG,WAAW,IAAI,GAAG;AAC/B,OAAG,UAAU,MAAM,EAAE,WAAW,MAAM;AAAA,EAAA;AAGjC,SAAA;AACT;AAUgB,SAAA,qBACd,aACA,SACA,YACQ;AACR,QAAM,kBAAkB,KAAK,KAAK,aAAa,cAAc;AAC7D,QAAM,cAAc,KAAK,MAAM,GAAG,aAAa,iBAAiB,OAAO,CAAC;AACxE,cAAY,OAAO;AACnB,MAAI,YAAY;AACF,gBAAA,aAAa,mBAAmB,IAAI;AAAA,EAAA;AAElD,SAAO,KAAK,UAAU,aAAa,MAAM,CAAC,IAAI;AAChD;AAaO,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMW;AACT,QAAM,iBAAiB,KAAK,KAAK,aAAa,aAAa;AAC3D,QAAM,aAAa,GAAG,aAAa,gBAAgB,OAAO;AAE1D,MAAI,aAAa,WAAW,QAAQ,8BAA8B,KAAK,SAAS;AAAA,CAAI;AAG9E,QAAA,cAAc,mBAAmB,cAAc;AACjD,MAAA;AACA,MAAA,YAAY,SAAS,QAAQ,GAAG;AACzB,aAAA;AAAA,EACA,WAAA,YAAY,SAAS,cAAc,GAAG;AACtC,aAAA;AAAA,EAAA,OACJ;AACI,aAAA;AAAA,EAAA;AAEX,eAAa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A6B,gBAAgB;AACxE,sBAAkB,mBAAmB,kBAAkB;AAAA,EAAA,OAClD;AAEC,UAAA,sBAAsB,WAAW,mCAAmC;AACpE,UAAA,qBAAqB,6BAA6B,gBAAgB;AACxE,sBAAkB,qBAAqB,kBAAkB;AAAA,EAAA;AAI3D,MAAI,eAAe;AACjB,UAAM,cAAc,KAAK,KAAK,MAAM,WAAW,SAAS;AACpD,QAAA,GAAG,WAAW,WAAW,GAAG;AAC3B,SAAA,UAAU,aAAa,GAAK;AAAA,IAAA;AAAA,EACjC;AAEJ;AAQA,SAAS,6BAA6B,kBAAoC;AACxE,MAAI,kBAAkB;AACb,WAAA;AAAA,EAAA,OACF;AACE,WAAA;AAAA,EAAA;AAEX;AAEA,OAAO,MAAM,CAAK,MAAA;AAChB,UAAQ,MAAM,CAAC;AACf,UAAQ,KAAK,CAAC;AAChB,CAAC;"}
|
package/package.json
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
--cdp-example-accent-hover-color: #016969;
|
|
10
10
|
--cdp-example-accent-foreground-color: #ffffff;
|
|
11
11
|
--cdp-example-bg-low-contrast-color: #eeeeee;
|
|
12
|
+
--cdp-example-cdp-page-bg-color: #ffffff;
|
|
13
|
+
--cdp-example-cdp-page-bg-alt-color: #eef0f3;
|
|
12
14
|
--cdp-example-card-bg-color: #ffffff;
|
|
13
15
|
--cdp-example-card-border-color: #dcdcdc;
|
|
14
16
|
--cdp-example-card-max-width: 30rem;
|
|
@@ -40,6 +42,8 @@
|
|
|
40
42
|
--cdp-example-accent-hover-color: #04c0c0;
|
|
41
43
|
--cdp-example-accent-foreground-color: #0a0b0d;
|
|
42
44
|
--cdp-example-bg-low-contrast-color: #32353d;
|
|
45
|
+
--cdp-example-cdp-page-bg-color: #0a0b0d;
|
|
46
|
+
--cdp-example-cdp-page-bg-alt-color: #333333;
|
|
43
47
|
--cdp-example-card-bg-color: #141519;
|
|
44
48
|
--cdp-example-card-border-color: #24262a;
|
|
45
49
|
}
|
|
@@ -27,8 +27,8 @@ export default function FundWallet({ onSuccess }: { onSuccess: () => void }) {
|
|
|
27
27
|
<FundModal
|
|
28
28
|
country="US"
|
|
29
29
|
subdivision="CA"
|
|
30
|
-
cryptoCurrency="
|
|
31
|
-
fiatCurrency="
|
|
30
|
+
cryptoCurrency="eth"
|
|
31
|
+
fiatCurrency="usd"
|
|
32
32
|
fetchBuyQuote={fetchBuyQuote}
|
|
33
33
|
fetchBuyOptions={fetchBuyOptions}
|
|
34
34
|
network="base"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Theme } from "@coinbase/cdp-react/theme";
|
|
2
2
|
|
|
3
3
|
export const theme: Partial<Theme> = {
|
|
4
|
-
"colors-bg-alternate": "var(--cdp-example-page-bg-alt-color)",
|
|
5
|
-
"colors-bg-default": "var(--cdp-example-
|
|
4
|
+
"colors-bg-alternate": "var(--cdp-example-cdp-page-bg-alt-color)",
|
|
5
|
+
"colors-bg-default": "var(--cdp-example-cdp-page-bg-color)",
|
|
6
6
|
"colors-bg-overlay": "var(--cdp-example-bg-overlay-color)",
|
|
7
7
|
"colors-bg-skeleton": "var(--cdp-example-bg-skeleton-color)",
|
|
8
8
|
"colors-bg-primary": "var(--cdp-example-accent-color)",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
--cdp-example-accent-hover-color: #016969;
|
|
10
10
|
--cdp-example-accent-foreground-color: #ffffff;
|
|
11
11
|
--cdp-example-bg-low-contrast-color: #eeeeee;
|
|
12
|
+
--cdp-example-cdp-page-bg-color: #ffffff;
|
|
13
|
+
--cdp-example-cdp-page-bg-alt-color: #eef0f3;
|
|
12
14
|
--cdp-example-card-bg-color: #ffffff;
|
|
13
15
|
--cdp-example-card-border-color: #dcdcdc;
|
|
14
16
|
--cdp-example-card-max-width: 30rem;
|
|
@@ -40,6 +42,8 @@
|
|
|
40
42
|
--cdp-example-accent-hover-color: #04c0c0;
|
|
41
43
|
--cdp-example-accent-foreground-color: #0a0b0d;
|
|
42
44
|
--cdp-example-bg-low-contrast-color: #32353d;
|
|
45
|
+
--cdp-example-cdp-page-bg-color: #0a0b0d;
|
|
46
|
+
--cdp-example-cdp-page-bg-alt-color: #333333;
|
|
43
47
|
--cdp-example-card-bg-color: #141519;
|
|
44
48
|
--cdp-example-card-border-color: #24262a;
|
|
45
49
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Theme } from "@coinbase/cdp-react/theme";
|
|
2
2
|
|
|
3
3
|
export const theme: Partial<Theme> = {
|
|
4
|
-
"colors-bg-alternate": "var(--cdp-example-page-bg-alt-color)",
|
|
5
|
-
"colors-bg-default": "var(--cdp-example-
|
|
4
|
+
"colors-bg-alternate": "var(--cdp-example-cdp-page-bg-alt-color)",
|
|
5
|
+
"colors-bg-default": "var(--cdp-example-cdp-page-bg-color)",
|
|
6
6
|
"colors-bg-overlay": "var(--cdp-example-bg-overlay-color)",
|
|
7
7
|
"colors-bg-skeleton": "var(--cdp-example-bg-skeleton-color)",
|
|
8
8
|
"colors-bg-primary": "var(--cdp-example-accent-color)",
|