@caatinga/cli 0.2.3 → 2.0.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.
Files changed (49) hide show
  1. package/README.md +6 -7
  2. package/dist/index.js +220 -157
  3. package/package.json +3 -2
  4. package/templates/marketplace-with-token/README.md +21 -0
  5. package/templates/marketplace-with-token/caatinga.artifacts.json +10 -0
  6. package/templates/marketplace-with-token/caatinga.config.ts +30 -0
  7. package/templates/marketplace-with-token/caatinga.template.json +21 -0
  8. package/templates/marketplace-with-token/contracts/marketplace/Cargo.lock +1731 -0
  9. package/templates/marketplace-with-token/contracts/marketplace/Cargo.toml +24 -0
  10. package/templates/marketplace-with-token/contracts/marketplace/src/lib.rs +43 -0
  11. package/templates/marketplace-with-token/contracts/marketplace/test_snapshots/test/stores_token_contract_id_in_constructor.1.json +86 -0
  12. package/templates/marketplace-with-token/contracts/token/Cargo.lock +1731 -0
  13. package/templates/marketplace-with-token/contracts/token/Cargo.toml +24 -0
  14. package/templates/marketplace-with-token/contracts/token/src/lib.rs +13 -0
  15. package/templates/marketplace-with-token/index.html +12 -0
  16. package/templates/marketplace-with-token/package.json +28 -0
  17. package/templates/marketplace-with-token/src/App.tsx +57 -0
  18. package/templates/marketplace-with-token/src/main.ts +12 -0
  19. package/templates/marketplace-with-token/src/main.tsx +10 -0
  20. package/templates/marketplace-with-token/src/styles.css +157 -0
  21. package/templates/marketplace-with-token/tsconfig.json +21 -0
  22. package/templates/marketplace-with-token/vite.config.ts +6 -0
  23. package/templates/react-vite-counter/.env.example +5 -0
  24. package/templates/react-vite-counter/README.md +83 -0
  25. package/templates/react-vite-counter/caatinga.artifacts.json +10 -0
  26. package/templates/react-vite-counter/caatinga.config.ts +26 -0
  27. package/templates/react-vite-counter/caatinga.template.json +21 -0
  28. package/templates/react-vite-counter/contracts/counter/Cargo.lock +1731 -0
  29. package/templates/react-vite-counter/contracts/counter/Cargo.toml +24 -0
  30. package/templates/react-vite-counter/contracts/counter/src/lib.rs +100 -0
  31. package/templates/react-vite-counter/contracts/counter/test_snapshots/test/get_returns_zero_before_increment.1.json +76 -0
  32. package/templates/react-vite-counter/contracts/counter/test_snapshots/test/increment_returns_overflow_error.1.json +91 -0
  33. package/templates/react-vite-counter/contracts/counter/test_snapshots/test/increments_counter.1.json +91 -0
  34. package/templates/react-vite-counter/contracts/counter/test_snapshots/test/repeated_increments_preserve_state.1.json +92 -0
  35. package/templates/react-vite-counter/index.html +12 -0
  36. package/templates/react-vite-counter/package.json +30 -0
  37. package/templates/react-vite-counter/pnpm-workspace.yaml +12 -0
  38. package/templates/react-vite-counter/public/.gitkeep +1 -0
  39. package/templates/react-vite-counter/src/App.tsx +18 -0
  40. package/templates/react-vite-counter/src/caatinga.ts +20 -0
  41. package/templates/react-vite-counter/src/components/CounterCard.tsx +86 -0
  42. package/templates/react-vite-counter/src/components/WalletButton.tsx +69 -0
  43. package/templates/react-vite-counter/src/contracts/generated/counter.ts +58 -0
  44. package/templates/react-vite-counter/src/hooks/useStellarWallet.ts +70 -0
  45. package/templates/react-vite-counter/src/main.tsx +10 -0
  46. package/templates/react-vite-counter/src/styles.css +206 -0
  47. package/templates/react-vite-counter/src/wallet.ts +29 -0
  48. package/templates/react-vite-counter/tsconfig.json +22 -0
  49. package/templates/react-vite-counter/vite.config.ts +18 -0
@@ -0,0 +1,24 @@
1
+ [package]
2
+ name = "token"
3
+ version = "0.1.0"
4
+ rust-version = "1.84.0"
5
+ edition = "2021"
6
+
7
+ [lib]
8
+ crate-type = ["cdylib"]
9
+
10
+ [dependencies]
11
+ soroban-sdk = "22.0.1"
12
+
13
+ [dev-dependencies]
14
+ soroban-sdk = { version = "22.0.1", features = ["testutils"] }
15
+
16
+ [profile.release]
17
+ opt-level = "z"
18
+ overflow-checks = true
19
+ debug = 0
20
+ strip = "symbols"
21
+ debug-assertions = false
22
+ panic = "abort"
23
+ codegen-units = 1
24
+ lto = true
@@ -0,0 +1,13 @@
1
+ #![no_std]
2
+
3
+ use soroban_sdk::{contract, contractimpl, Env};
4
+
5
+ #[contract]
6
+ pub struct TokenContract;
7
+
8
+ #[contractimpl]
9
+ impl TokenContract {
10
+ pub fn version(_env: Env) -> u32 {
11
+ 1
12
+ }
13
+ }
@@ -0,0 +1,12 @@
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>__PROJECT_NAME__</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
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
+ "caatinga:build": "caatinga build token && caatinga build marketplace",
11
+ "caatinga:deploy": "caatinga deploy --network testnet",
12
+ "caatinga:generate": "caatinga generate token && caatinga generate marketplace"
13
+ },
14
+ "dependencies": {
15
+ "@caatinga/client": "^2.0.0",
16
+ "@caatinga/core": "^2.0.0",
17
+ "@vitejs/plugin-react": "^4.3.4",
18
+ "react": "^18.3.1",
19
+ "react-dom": "^18.3.1",
20
+ "vite": "^6.0.6"
21
+ },
22
+ "devDependencies": {
23
+ "@caatinga/cli": "^2.0.0",
24
+ "@types/react": "^18.3.18",
25
+ "@types/react-dom": "^18.3.5",
26
+ "typescript": "^5.7.2"
27
+ }
28
+ }
@@ -0,0 +1,57 @@
1
+ const deploySteps = [
2
+ "Build token and marketplace contracts",
3
+ "Deploy token first so artifacts capture its contractId",
4
+ "Deploy marketplace and inject tokenContractId via __constructor",
5
+ "Generate bindings for both contracts"
6
+ ];
7
+
8
+ export default function App() {
9
+ return (
10
+ <main className="app-shell">
11
+ <header className="hero">
12
+ <p className="eyebrow">Caatinga Multi-Contract</p>
13
+ <h1>__PROJECT_NAME__</h1>
14
+ <p className="lede">
15
+ Official demo template for dependency-ordered deploys where the marketplace constructor
16
+ receives the deployed token contract ID.
17
+ </p>
18
+ </header>
19
+
20
+ <section className="panel">
21
+ <div className="panel__header">
22
+ <div>
23
+ <p className="eyebrow">Contracts</p>
24
+ <h2>Deployment graph</h2>
25
+ </div>
26
+ <span className="network-pill">testnet</span>
27
+ </div>
28
+
29
+ <div className="graph">
30
+ <article className="graph-card">
31
+ <p className="graph-card__label">Root contract</p>
32
+ <h3>token</h3>
33
+ <p>Deploys first and publishes its contract ID into local artifacts.</p>
34
+ </article>
35
+ <article className="graph-card graph-card--dependent">
36
+ <p className="graph-card__label">Dependent contract</p>
37
+ <h3>marketplace</h3>
38
+ <p>
39
+ Receives <code>tokenContractId</code> through <code>deployArgs</code> mapped to the
40
+ contract <code>__constructor</code>.
41
+ </p>
42
+ </article>
43
+ </div>
44
+ </section>
45
+
46
+ <section className="panel">
47
+ <p className="eyebrow">Flow</p>
48
+ <h2>What this template proves</h2>
49
+ <ol className="steps">
50
+ {deploySteps.map((step) => (
51
+ <li key={step}>{step}</li>
52
+ ))}
53
+ </ol>
54
+ </section>
55
+ </main>
56
+ );
57
+ }
@@ -0,0 +1,12 @@
1
+ export const templateId = "marketplace-with-token";
2
+
3
+ export function describeDeployFlow(): string {
4
+ return [
5
+ "1. caatinga build token",
6
+ "2. caatinga build marketplace",
7
+ "3. caatinga deploy --network testnet --source <identity>",
8
+ "4. caatinga generate token",
9
+ "5. caatinga generate marketplace",
10
+ "marketplace.deployArgs.tokenContractId resolves from caatinga.artifacts.json and is passed to __constructor"
11
+ ].join("\n");
12
+ }
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import App from "./App";
4
+ import "./styles.css";
5
+
6
+ ReactDOM.createRoot(document.getElementById("root")!).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
@@ -0,0 +1,157 @@
1
+ :root {
2
+ color: #142322;
3
+ background:
4
+ radial-gradient(circle at top, rgba(255, 208, 118, 0.22), transparent 32%),
5
+ linear-gradient(180deg, #f7f1e4 0%, #efe7d2 100%);
6
+ font-family:
7
+ "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
8
+ font-synthesis: none;
9
+ text-rendering: optimizeLegibility;
10
+ }
11
+
12
+ * {
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ body {
17
+ margin: 0;
18
+ min-width: 320px;
19
+ min-height: 100vh;
20
+ }
21
+
22
+ code {
23
+ padding: 0.1rem 0.35rem;
24
+ border-radius: 0.35rem;
25
+ background: rgba(20, 35, 34, 0.08);
26
+ font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
27
+ }
28
+
29
+ .app-shell {
30
+ width: min(960px, calc(100vw - 32px));
31
+ margin: 0 auto;
32
+ padding: 32px 0 48px;
33
+ }
34
+
35
+ .hero,
36
+ .panel {
37
+ border: 1px solid rgba(20, 35, 34, 0.12);
38
+ border-radius: 24px;
39
+ background: rgba(255, 252, 245, 0.86);
40
+ box-shadow: 0 18px 60px rgba(20, 35, 34, 0.08);
41
+ }
42
+
43
+ .hero {
44
+ margin-bottom: 20px;
45
+ padding: clamp(24px, 5vw, 48px);
46
+ }
47
+
48
+ .panel {
49
+ margin-bottom: 20px;
50
+ padding: 24px;
51
+ }
52
+
53
+ .hero h1,
54
+ .panel h2,
55
+ .graph-card h3 {
56
+ margin: 0;
57
+ }
58
+
59
+ .hero h1 {
60
+ font-size: clamp(2.4rem, 8vw, 4.6rem);
61
+ line-height: 0.95;
62
+ max-width: 10ch;
63
+ }
64
+
65
+ .lede {
66
+ max-width: 60ch;
67
+ margin: 16px 0 0;
68
+ font-size: 1.05rem;
69
+ line-height: 1.6;
70
+ }
71
+
72
+ .eyebrow {
73
+ margin: 0 0 10px;
74
+ color: #7c5a16;
75
+ font-family: "Trebuchet MS", "Avenir Next", sans-serif;
76
+ font-size: 0.78rem;
77
+ font-weight: 800;
78
+ letter-spacing: 0.12em;
79
+ text-transform: uppercase;
80
+ }
81
+
82
+ .panel__header {
83
+ display: flex;
84
+ align-items: flex-start;
85
+ justify-content: space-between;
86
+ gap: 16px;
87
+ margin-bottom: 20px;
88
+ }
89
+
90
+ .network-pill {
91
+ display: inline-flex;
92
+ align-items: center;
93
+ min-height: 32px;
94
+ border-radius: 999px;
95
+ padding: 0 12px;
96
+ background: #173f3a;
97
+ color: #fff8ec;
98
+ font-family: "Trebuchet MS", "Avenir Next", sans-serif;
99
+ font-size: 0.8rem;
100
+ font-weight: 700;
101
+ letter-spacing: 0.08em;
102
+ text-transform: uppercase;
103
+ }
104
+
105
+ .graph {
106
+ display: grid;
107
+ gap: 16px;
108
+ }
109
+
110
+ .graph-card {
111
+ position: relative;
112
+ padding: 18px;
113
+ border-radius: 18px;
114
+ background: #fffdfa;
115
+ border: 1px solid rgba(20, 35, 34, 0.1);
116
+ }
117
+
118
+ .graph-card--dependent::before {
119
+ content: "dependsOn token";
120
+ display: inline-block;
121
+ margin-bottom: 12px;
122
+ padding: 0.3rem 0.6rem;
123
+ border-radius: 999px;
124
+ background: rgba(124, 90, 22, 0.12);
125
+ color: #7c5a16;
126
+ font-family: "Trebuchet MS", "Avenir Next", sans-serif;
127
+ font-size: 0.75rem;
128
+ font-weight: 700;
129
+ letter-spacing: 0.04em;
130
+ text-transform: uppercase;
131
+ }
132
+
133
+ .graph-card__label {
134
+ margin: 0 0 6px;
135
+ color: #5d6766;
136
+ font-family: "Trebuchet MS", "Avenir Next", sans-serif;
137
+ font-size: 0.8rem;
138
+ text-transform: uppercase;
139
+ }
140
+
141
+ .steps {
142
+ margin: 16px 0 0;
143
+ padding-left: 1.25rem;
144
+ line-height: 1.7;
145
+ }
146
+
147
+ @media (min-width: 700px) {
148
+ .graph {
149
+ grid-template-columns: repeat(2, minmax(0, 1fr));
150
+ }
151
+ }
152
+
153
+ @media (max-width: 560px) {
154
+ .panel__header {
155
+ flex-direction: column;
156
+ }
157
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["DOM", "DOM.Iterable", "ES2020"],
6
+ "allowJs": false,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "module": "ESNext",
13
+ "moduleResolution": "Node",
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "noEmit": true,
17
+ "jsx": "react-jsx"
18
+ },
19
+ "include": ["src"],
20
+ "references": []
21
+ }
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ export default defineConfig({
5
+ plugins: [react()]
6
+ });
@@ -0,0 +1,5 @@
1
+ VITE_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id
2
+ VITE_APP_NAME=__PROJECT_NAME__
3
+ VITE_APP_DESCRIPTION=Caatinga counter dApp
4
+ VITE_APP_URL=https://your-dapp-url.com
5
+ VITE_APP_ICON_URL=https://your-dapp-url.com/icon.png
@@ -0,0 +1,83 @@
1
+ # __PROJECT_NAME__
2
+
3
+ Caatinga counter dApp for Stellar/Soroban.
4
+
5
+ ## CLI Flow
6
+
7
+ ```bash
8
+ npm install # or: pnpm install
9
+ npx caatinga build counter
10
+ npx caatinga deploy counter --network testnet --source alice
11
+ npx caatinga generate counter --network testnet
12
+ npx caatinga invoke counter.increment --network testnet --source alice
13
+ npm run dev # or: pnpm dev
14
+ ```
15
+
16
+ Run `build` before `deploy` (WASM required) and `deploy` before `generate` (contract ID required).
17
+
18
+ Use a local Stellar CLI identity alias for `--source`; public `G...` addresses, seed phrases, and secret keys are rejected for signing operations.
19
+
20
+ ## Package managers
21
+
22
+ Templates default to npm, but pnpm 10.26+/11.x is supported via the shipped `pnpm-workspace.yaml` (`allowBuilds.esbuild: true`, `blockExoticSubdeps: false`).
23
+
24
+ Package scripts wrap the CLI:
25
+
26
+ ```bash
27
+ npm run caatinga:build
28
+ npm run caatinga:deploy -- --network testnet --source alice
29
+ npm run caatinga:generate -- --network testnet
30
+ ```
31
+
32
+ With pnpm, use `pnpm run caatinga:build` (and the same pattern for deploy/generate). `npx caatinga build counter` works without going through the package manager.
33
+
34
+ ## Client Smoke Path
35
+
36
+ After `caatinga generate`, wire generated bindings to the client:
37
+
38
+ ```ts
39
+ import { createCaatingaClient } from "@caatinga/client";
40
+ import { createStellarWalletsKitAdapter } from "@caatinga/client/stellar-wallets-kit";
41
+ import * as Counter from "./contracts/generated/counter";
42
+ import artifacts from "../caatinga.artifacts.json";
43
+
44
+ const wallet = createStellarWalletsKitAdapter();
45
+
46
+ export const caatingaClient = createCaatingaClient({
47
+ network: {
48
+ name: "testnet",
49
+ rpcUrl: "https://soroban-testnet.stellar.org",
50
+ networkPassphrase: "Test SDF Network ; September 2015"
51
+ },
52
+ artifacts,
53
+ wallet,
54
+ contracts: {
55
+ counter: {
56
+ binding: Counter
57
+ }
58
+ }
59
+ });
60
+ ```
61
+
62
+ Build XDR without wallet signing:
63
+
64
+ ```ts
65
+ const tx = await caatingaClient.contract("counter").buildXdr("increment");
66
+ console.log(tx.preparedXdr);
67
+ ```
68
+
69
+ Read the on-chain counter through simulation:
70
+
71
+ ```ts
72
+ const count = await caatingaClient.contract("counter").read<number>("get");
73
+ console.log(count);
74
+ ```
75
+
76
+ Invoke through a connected wallet:
77
+
78
+ ```ts
79
+ const result = await caatingaClient.contract("counter").invoke("increment", {
80
+ debugXdr: true
81
+ });
82
+ console.log(result.transactionHash);
83
+ ```
@@ -0,0 +1,10 @@
1
+ {
2
+ "project": "__PROJECT_NAME__",
3
+ "version": 1,
4
+ "networks": {
5
+ "testnet": {
6
+ "contracts": {},
7
+ "dependencyGraph": {}
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,26 @@
1
+ import { defineConfig } from "@caatinga/core";
2
+
3
+ export default defineConfig({
4
+ project: "__PROJECT_NAME__",
5
+ defaultNetwork: "testnet",
6
+ contracts: {
7
+ counter: {
8
+ path: "./contracts/counter",
9
+ wasm: "./contracts/counter/target/wasm32v1-none/release/counter.wasm"
10
+ }
11
+ },
12
+ networks: {
13
+ testnet: {
14
+ rpcUrl: "https://soroban-testnet.stellar.org",
15
+ networkPassphrase: "Test SDF Network ; September 2015"
16
+ },
17
+ mainnet: {
18
+ rpcUrl: "https://mainnet.sorobanrpc.com",
19
+ networkPassphrase: "Public Global Stellar Network ; September 2015"
20
+ }
21
+ },
22
+ frontend: {
23
+ framework: "vite-react",
24
+ bindingsOutput: "./src/contracts/generated"
25
+ }
26
+ });
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "react-vite-counter",
3
+ "version": "0.1.0",
4
+ "description": "Minimal Vite + React + Soroban counter dApp.",
5
+ "caatinga": {
6
+ "compatibleCore": "^2.0.0",
7
+ "templateVersion": 1
8
+ },
9
+ "frontend": {
10
+ "framework": "vite-react",
11
+ "packageManager": "npm"
12
+ },
13
+ "contracts": {
14
+ "path": "contracts",
15
+ "default": "counter"
16
+ },
17
+ "files": {
18
+ "config": "caatinga.config.ts",
19
+ "artifacts": "caatinga.artifacts.json"
20
+ }
21
+ }