create-sbc-app 0.1.3 → 0.2.0
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/LICENSE +21 -0
- package/README.md +17 -8
- package/bin/cli.js +30 -7
- package/package.json +1 -2
- package/templates/README.md +0 -2
- package/templates/react/.env.template +3 -0
- package/templates/react/README.md.template +7 -4
- package/templates/react/package.json.template +3 -5
- package/templates/react/src/App.tsx.template +2 -0
- package/templates/react-dynamic/.env.template +7 -0
- package/templates/react-dynamic/README.md.template +24 -0
- package/templates/react-dynamic/eslint.config.js.template +34 -0
- package/templates/react-dynamic/index.html.template +14 -0
- package/templates/react-dynamic/package.json.template +33 -0
- package/templates/react-dynamic/postcss.config.js.template +8 -0
- package/templates/react-dynamic/public/sbc-logo.png +0 -0
- package/templates/react-dynamic/src/App.css.template +5 -0
- package/templates/react-dynamic/src/App.tsx.template +322 -0
- package/templates/react-dynamic/src/env.d.ts.template +14 -0
- package/templates/react-dynamic/src/index.css.template +15 -0
- package/templates/react-dynamic/src/main.tsx.template +12 -0
- package/templates/react-dynamic/tailwind.config.js.template +13 -0
- package/templates/react-dynamic/tsconfig.json.template +18 -0
- package/templates/react-dynamic/vite.config.ts.template +11 -0
- package/templates/react-para/.env.template +7 -0
- package/templates/react-para/README.md.template +24 -0
- package/templates/react-para/eslint.config.js.template +34 -0
- package/templates/react-para/index.html.template +14 -0
- package/templates/react-para/package.json.template +35 -0
- package/templates/react-para/postcss.config.js.template +8 -0
- package/templates/react-para/public/sbc-logo.png +0 -0
- package/templates/react-para/src/App.tsx.template +333 -0
- package/templates/react-para/src/components/ConnectButton.tsx.template +99 -0
- package/templates/react-para/src/env.d.ts.template +14 -0
- package/templates/react-para/src/hooks/usePara.ts.template +34 -0
- package/templates/react-para/src/hooks/useParaViem.ts.template +61 -0
- package/templates/react-para/src/index.css.template +5 -0
- package/templates/react-para/src/main.tsx.template +12 -0
- package/templates/react-para/src/providers.tsx.template +39 -0
- package/templates/react-para/src/utils/permit.ts.template +217 -0
- package/templates/react-para/tailwind.config.js.template +13 -0
- package/templates/react-para/tsconfig.json.template +18 -0
- package/templates/react-para/vite.config.ts.template +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Stable Coin Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Arguments:
|
|
|
33
33
|
|
|
34
34
|
Options:
|
|
35
35
|
-V, --version output the version number
|
|
36
|
-
-t, --template <type> Template to use: react,
|
|
36
|
+
-t, --template <type> Template to use: react, react-dynamic, or react-para
|
|
37
37
|
--api-key <apiKey> Your SBC API key for immediate configuration
|
|
38
38
|
--wallet <wallet> Wallet integration (not yet implemented)
|
|
39
39
|
-h, --help display help for command
|
|
@@ -41,11 +41,14 @@ Options:
|
|
|
41
41
|
Examples:
|
|
42
42
|
$ create-sbc-app my-app
|
|
43
43
|
$ create-sbc-app my-app --template react
|
|
44
|
-
$ create-sbc-app my-app --template react
|
|
44
|
+
$ create-sbc-app my-app --template react-dynamic
|
|
45
|
+
$ create-sbc-app my-app --template react-para
|
|
46
|
+
# Next.js template removed for now
|
|
45
47
|
|
|
46
48
|
Available Templates:
|
|
47
|
-
- react
|
|
48
|
-
-
|
|
49
|
+
- react React + Vite template with SBC integration
|
|
50
|
+
- react-dynamic React + Vite with Dynamic wallet integration
|
|
51
|
+
- react-para React + Vite with Para wallet integration
|
|
49
52
|
```
|
|
50
53
|
|
|
51
54
|
## ✨ Features
|
|
@@ -134,8 +137,14 @@ cd my-sbc-app
|
|
|
134
137
|
# Copy environment template
|
|
135
138
|
cp .env.template .env
|
|
136
139
|
|
|
137
|
-
#
|
|
138
|
-
|
|
140
|
+
# then ensure your .env has the environment variables set up
|
|
141
|
+
|
|
142
|
+
# "base" or "baseSepolia"
|
|
143
|
+
VITE_CHAIN="baseSepolia"
|
|
144
|
+
# Custom RPC URL (optional) - e.g. get one from Alchemey at https://dashboard.alchemy.com/apps
|
|
145
|
+
VITE_RPC_URL=
|
|
146
|
+
# Get your SBC API Key at https://dashboard.stablecoin.xyz
|
|
147
|
+
VITE_SBC_API_KEY=
|
|
139
148
|
```
|
|
140
149
|
|
|
141
150
|
### 3. Start Development
|
|
@@ -160,8 +169,8 @@ npm run dev
|
|
|
160
169
|
|
|
161
170
|
## 📚 Documentation
|
|
162
171
|
|
|
163
|
-
- **[SBC
|
|
164
|
-
- **[GitHub Repository](https://github.com/stablecoinxyz/app-kit)** - Source code and examples
|
|
172
|
+
- **[SBC Documentation](https://docs.stablecoin.xyz)** - Official docs
|
|
173
|
+
- **[GitHub Repository](https://github.com/stablecoinxyz/app-kit)** - AppKit API Reference. Source code and examples
|
|
165
174
|
|
|
166
175
|
## 📄 License
|
|
167
176
|
|
package/bin/cli.js
CHANGED
|
@@ -10,9 +10,9 @@ const program = new Command();
|
|
|
10
10
|
program
|
|
11
11
|
.name('create-sbc-app')
|
|
12
12
|
.description('Create a new SBC App Kit project with an opinionated template')
|
|
13
|
-
.version('0.
|
|
13
|
+
.version('0.2.0')
|
|
14
14
|
.argument('[project-directory]', 'Directory to create the new app in')
|
|
15
|
-
.option('-t, --template <template>', 'Template to use: react,
|
|
15
|
+
.option('-t, --template <template>', 'Template to use: react, react-dynamic, or react-para')
|
|
16
16
|
.option('--api-key <apiKey>', 'Your SBC API key for immediate configuration')
|
|
17
17
|
.option('--wallet <wallet>', 'Wallet integration (not yet implemented)')
|
|
18
18
|
.addHelpText('after', `
|
|
@@ -22,8 +22,9 @@ Examples:
|
|
|
22
22
|
$ create-sbc-app my-app --template react --api-key your-api-key
|
|
23
23
|
|
|
24
24
|
Available Templates:
|
|
25
|
-
- react
|
|
26
|
-
-
|
|
25
|
+
- react React + Vite template with SBC integration
|
|
26
|
+
- react-dynamic React + Vite with Dynamic wallet integration
|
|
27
|
+
- react-para React + Vite with Para wallet integration
|
|
27
28
|
`)
|
|
28
29
|
.action(async (dir, options) => {
|
|
29
30
|
if (options.wallet) {
|
|
@@ -32,7 +33,8 @@ Available Templates:
|
|
|
32
33
|
}
|
|
33
34
|
const templateChoices = [
|
|
34
35
|
{ title: 'React', value: 'react' },
|
|
35
|
-
{ title: '
|
|
36
|
+
{ title: 'React (Dynamic wallet)', value: 'react-dynamic' },
|
|
37
|
+
{ title: 'React (Para wallet)', value: 'react-para' }
|
|
36
38
|
];
|
|
37
39
|
// Use provided argument or prompt for project directory
|
|
38
40
|
let projectDir = dir && dir.trim() ? dir.trim() : '';
|
|
@@ -49,7 +51,7 @@ Available Templates:
|
|
|
49
51
|
projectDir = res.dir.trim();
|
|
50
52
|
}
|
|
51
53
|
// Use provided option or prompt for template
|
|
52
|
-
let template = options.template && ['react', '
|
|
54
|
+
let template = options.template && ['react', 'react-dynamic', 'react-para'].includes(options.template) ? options.template : '';
|
|
53
55
|
if (!template) {
|
|
54
56
|
const res = await prompts({
|
|
55
57
|
type: 'select',
|
|
@@ -62,7 +64,7 @@ Available Templates:
|
|
|
62
64
|
process.exit(1);
|
|
63
65
|
}
|
|
64
66
|
template = res.template; // The value is already what we want from the choices
|
|
65
|
-
if (!template || !['react', '
|
|
67
|
+
if (!template || !['react', 'react-dynamic', 'react-para'].includes(template)) {
|
|
66
68
|
console.log('Template selection is required.');
|
|
67
69
|
process.exit(1);
|
|
68
70
|
}
|
|
@@ -97,6 +99,27 @@ Available Templates:
|
|
|
97
99
|
chain: 'baseSepolia',
|
|
98
100
|
apiKey: apiKey
|
|
99
101
|
});
|
|
102
|
+
// Ensure SBC logo exists in public/ for all templates
|
|
103
|
+
try {
|
|
104
|
+
const publicDir = path.join(targetDir, 'public');
|
|
105
|
+
await fs.ensureDir(publicDir);
|
|
106
|
+
const sourceLogo = path.resolve(__dirname, '../templates/react/public/sbc-logo.png');
|
|
107
|
+
const destLogo = path.join(publicDir, 'sbc-logo.png');
|
|
108
|
+
if (!(await fs.pathExists(destLogo)) && (await fs.pathExists(sourceLogo))) {
|
|
109
|
+
await fs.copy(sourceLogo, destLogo);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch { }
|
|
113
|
+
// If .env.template exists, ensure apiKey placeholder is applied (copyTemplate already replaces)
|
|
114
|
+
// Also, create a default .env if none exists to make onboarding faster
|
|
115
|
+
try {
|
|
116
|
+
const envTemplatePath = path.join(targetDir, '.env.template');
|
|
117
|
+
const envPath = path.join(targetDir, '.env');
|
|
118
|
+
if (await fs.pathExists(envTemplatePath) && !(await fs.pathExists(envPath))) {
|
|
119
|
+
await fs.copy(envTemplatePath, envPath);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch { }
|
|
100
123
|
console.log(`\nSuccess! Created ${projectDir} using the ${template} template.`);
|
|
101
124
|
console.log(`\nNext steps:`);
|
|
102
125
|
console.log(` cd ${projectDir}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sbc-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Scaffold a new SBC App Kit project with one command.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-sbc-app": "bin/cli.js"
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"create-app",
|
|
48
48
|
"template",
|
|
49
49
|
"react",
|
|
50
|
-
"nextjs",
|
|
51
50
|
"vite"
|
|
52
51
|
],
|
|
53
52
|
"author": "SBC Team",
|
package/templates/README.md
CHANGED
|
@@ -16,11 +16,14 @@ Copy the example environment file and add your SBC API key:
|
|
|
16
16
|
cp .env.example .env # Optional: for local overrides
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Edit `.env` and add your SBC API key:
|
|
19
|
+
Edit `.env` and add your SBC API key and Chain, with the optional for a custom RPC:
|
|
20
20
|
```bash
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
# "base" or "baseSepolia"
|
|
22
|
+
VITE_CHAIN="baseSepolia"
|
|
23
|
+
# Custom RPC URL (optional) - e.g. get one from Alchemey at https://dashboard.alchemy.com/apps
|
|
24
|
+
VITE_RPC_URL=
|
|
25
|
+
# Get your SBC API Key at https://dashboard.stablecoin.xyz
|
|
26
|
+
VITE_SBC_API_KEY=
|
|
24
27
|
```
|
|
25
28
|
|
|
26
29
|
> **Get your API key:** Visit the [SBC Dashboard](https://dashboard.stablecoin.xyz) to create an account and get your API key.
|
|
@@ -11,13 +11,11 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@stablecoin.xyz/core": "latest",
|
|
13
13
|
"@stablecoin.xyz/react": "latest",
|
|
14
|
-
"react": "^
|
|
15
|
-
"react-dom": "^
|
|
16
|
-
"viem": "^2.
|
|
14
|
+
"react": "^19.1.0",
|
|
15
|
+
"react-dom": "^19.1.0",
|
|
16
|
+
"viem": "^2.33.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/react": "^18.2.0",
|
|
20
|
-
"@types/react-dom": "^18.2.0",
|
|
21
19
|
"@vitejs/plugin-react": "^4.0.0",
|
|
22
20
|
"typescript": "^5.0.0",
|
|
23
21
|
"vite": "^5.0.0"
|
|
@@ -7,6 +7,7 @@ import './App.css';
|
|
|
7
7
|
|
|
8
8
|
// Chain selection helpers
|
|
9
9
|
const chain = (import.meta.env.VITE_CHAIN === 'base') ? base : baseSepolia;
|
|
10
|
+
const rpcUrl = import.meta.env.VITE_RPC_URL;
|
|
10
11
|
|
|
11
12
|
const SBC_TOKEN_ADDRESS = (chain) => {
|
|
12
13
|
if (chain.id === baseSepolia.id) {
|
|
@@ -400,6 +401,7 @@ export default function App() {
|
|
|
400
401
|
const sbcConfig = {
|
|
401
402
|
apiKey: import.meta.env.VITE_SBC_API_KEY || '{{apiKey}}',
|
|
402
403
|
chain,
|
|
404
|
+
rpcUrl,
|
|
403
405
|
wallet: 'auto' as const,
|
|
404
406
|
debug: true,
|
|
405
407
|
walletOptions: { autoConnect: false },
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# React + Dynamic + SBC App Kit
|
|
2
|
+
|
|
3
|
+
Gasless transactions on Base using Dynamic SDK with SBC App Kit.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Environment
|
|
13
|
+
|
|
14
|
+
Create `.env` from `.env.template` and fill in values:
|
|
15
|
+
|
|
16
|
+
```env
|
|
17
|
+
VITE_SBC_API_KEY={{apiKey}}
|
|
18
|
+
VITE_DYNAMIC_ENVIRONMENT_ID=your_dynamic_env_id
|
|
19
|
+
# Optional
|
|
20
|
+
VITE_CHAIN=baseSepolia # or "base"
|
|
21
|
+
VITE_RPC_URL=
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import tseslint from '@typescript-eslint/eslint-plugin'
|
|
6
|
+
import tsparser from '@typescript-eslint/parser'
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{ ignores: ['dist'] },
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.{ts,tsx}'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
ecmaVersion: 2020,
|
|
14
|
+
globals: globals.browser,
|
|
15
|
+
parser: tsparser,
|
|
16
|
+
},
|
|
17
|
+
plugins: {
|
|
18
|
+
'@typescript-eslint': tseslint,
|
|
19
|
+
'react-hooks': reactHooks,
|
|
20
|
+
'react-refresh': reactRefresh,
|
|
21
|
+
},
|
|
22
|
+
rules: {
|
|
23
|
+
...js.configs.recommended.rules,
|
|
24
|
+
...tseslint.configs.recommended.rules,
|
|
25
|
+
...reactHooks.configs.recommended.rules,
|
|
26
|
+
'react-refresh/only-export-components': [
|
|
27
|
+
'warn',
|
|
28
|
+
{ allowConstantExport: true },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>{{projectName}} – SBC + Dynamic</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
13
|
+
|
|
14
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@dynamic-labs/ethereum": "^4.25.7",
|
|
13
|
+
"@dynamic-labs/ethereum-aa": "^4.25.7",
|
|
14
|
+
"@dynamic-labs/sdk-react-core": "^4.25.7",
|
|
15
|
+
"@stablecoin.xyz/core": "latest",
|
|
16
|
+
"@stablecoin.xyz/react": "latest",
|
|
17
|
+
"react": "^19.1.0",
|
|
18
|
+
"react-dom": "^19.1.0",
|
|
19
|
+
"viem": "^2.33.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/react": "^18.2.0",
|
|
23
|
+
"@types/react-dom": "^18.2.0",
|
|
24
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
25
|
+
"autoprefixer": "^10.4.0",
|
|
26
|
+
"postcss": "^8.4.0",
|
|
27
|
+
"tailwindcss": "^3.4.17",
|
|
28
|
+
"typescript": "^5.0.0",
|
|
29
|
+
"vite": "^5.0.0"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
Binary file
|