@caatinga/cli 0.2.2 → 0.2.3

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 (39) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
  3. package/templates/marketplace-with-token/README.md +0 -21
  4. package/templates/marketplace-with-token/caatinga.artifacts.json +0 -10
  5. package/templates/marketplace-with-token/caatinga.config.ts +0 -30
  6. package/templates/marketplace-with-token/caatinga.template.json +0 -21
  7. package/templates/marketplace-with-token/contracts/marketplace/Cargo.lock +0 -1731
  8. package/templates/marketplace-with-token/contracts/marketplace/Cargo.toml +0 -24
  9. package/templates/marketplace-with-token/contracts/marketplace/src/lib.rs +0 -43
  10. package/templates/marketplace-with-token/contracts/token/Cargo.lock +0 -1731
  11. package/templates/marketplace-with-token/contracts/token/Cargo.toml +0 -24
  12. package/templates/marketplace-with-token/contracts/token/src/lib.rs +0 -13
  13. package/templates/marketplace-with-token/index.html +0 -12
  14. package/templates/marketplace-with-token/package.json +0 -28
  15. package/templates/marketplace-with-token/src/App.tsx +0 -57
  16. package/templates/marketplace-with-token/src/main.ts +0 -12
  17. package/templates/marketplace-with-token/src/main.tsx +0 -10
  18. package/templates/marketplace-with-token/src/styles.css +0 -157
  19. package/templates/marketplace-with-token/tsconfig.json +0 -21
  20. package/templates/marketplace-with-token/vite.config.ts +0 -6
  21. package/templates/react-vite-counter/README.md +0 -58
  22. package/templates/react-vite-counter/caatinga.artifacts.json +0 -10
  23. package/templates/react-vite-counter/caatinga.config.ts +0 -26
  24. package/templates/react-vite-counter/caatinga.template.json +0 -21
  25. package/templates/react-vite-counter/contracts/counter/Cargo.lock +0 -1731
  26. package/templates/react-vite-counter/contracts/counter/Cargo.toml +0 -24
  27. package/templates/react-vite-counter/contracts/counter/src/lib.rs +0 -36
  28. package/templates/react-vite-counter/index.html +0 -12
  29. package/templates/react-vite-counter/package.json +0 -29
  30. package/templates/react-vite-counter/public/.gitkeep +0 -1
  31. package/templates/react-vite-counter/src/App.tsx +0 -18
  32. package/templates/react-vite-counter/src/caatinga.ts +0 -20
  33. package/templates/react-vite-counter/src/components/CounterCard.tsx +0 -66
  34. package/templates/react-vite-counter/src/components/WalletButton.tsx +0 -65
  35. package/templates/react-vite-counter/src/contracts/generated/counter.ts +0 -49
  36. package/templates/react-vite-counter/src/main.tsx +0 -10
  37. package/templates/react-vite-counter/src/styles.css +0 -176
  38. package/templates/react-vite-counter/tsconfig.json +0 -21
  39. package/templates/react-vite-counter/vite.config.ts +0 -6
@@ -1,24 +0,0 @@
1
- [package]
2
- name = "counter"
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
@@ -1,36 +0,0 @@
1
- #![no_std]
2
-
3
- use soroban_sdk::{contract, contractimpl, Env};
4
-
5
- #[contract]
6
- pub struct CounterContract;
7
-
8
- #[contractimpl]
9
- impl CounterContract {
10
- pub fn get(env: Env) -> u32 {
11
- env.storage().instance().get(&"count").unwrap_or(0)
12
- }
13
-
14
- pub fn increment(env: Env) -> u32 {
15
- let count = Self::get(env.clone()) + 1;
16
- env.storage().instance().set(&"count", &count);
17
- count
18
- }
19
- }
20
-
21
- #[cfg(test)]
22
- mod test {
23
- use super::*;
24
- use soroban_sdk::Env;
25
-
26
- #[test]
27
- fn increments_counter() {
28
- let env = Env::default();
29
- let contract_id = env.register(CounterContract, ());
30
- let client = CounterContractClient::new(&env, &contract_id);
31
-
32
- assert_eq!(client.get(), 0);
33
- assert_eq!(client.increment(), 1);
34
- assert_eq!(client.get(), 1);
35
- }
36
- }
@@ -1,12 +0,0 @@
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>
@@ -1,29 +0,0 @@
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 counter",
11
- "caatinga:deploy": "caatinga deploy counter",
12
- "caatinga:generate": "caatinga generate counter"
13
- },
14
- "dependencies": {
15
- "@caatinga/client": "^0.2.2",
16
- "@caatinga/core": "^0.2.2",
17
- "@stellar/freighter-api": "^4.0.0",
18
- "@vitejs/plugin-react": "^4.3.4",
19
- "vite": "^6.0.6",
20
- "react": "^18.3.1",
21
- "react-dom": "^18.3.1"
22
- },
23
- "devDependencies": {
24
- "@caatinga/cli": "^0.2.2",
25
- "@types/react": "^18.3.18",
26
- "@types/react-dom": "^18.3.5",
27
- "typescript": "^5.7.2"
28
- }
29
- }
@@ -1,18 +0,0 @@
1
- import { CounterCard } from "./components/CounterCard";
2
- import { WalletButton } from "./components/WalletButton";
3
-
4
- export default function App() {
5
- return (
6
- <main className="app-shell">
7
- <header className="topbar">
8
- <div>
9
- <p className="eyebrow">Caatinga</p>
10
- <h1>__PROJECT_NAME__</h1>
11
- </div>
12
- <WalletButton />
13
- </header>
14
-
15
- <CounterCard />
16
- </main>
17
- );
18
- }
@@ -1,20 +0,0 @@
1
- import { createCaatingaClient } from "@caatinga/client";
2
- import { freighterWalletAdapter } from "@caatinga/client/freighter";
3
- import type { CaatingaArtifacts } from "@caatinga/core/browser";
4
- import artifactsJson from "../caatinga.artifacts.json";
5
- import * as Counter from "./contracts/generated/counter.js";
6
-
7
- const artifacts = artifactsJson as CaatingaArtifacts;
8
-
9
- export const caatingaClient = createCaatingaClient({
10
- network: {
11
- name: "testnet",
12
- rpcUrl: "https://soroban-testnet.stellar.org",
13
- networkPassphrase: "Test SDF Network ; September 2015"
14
- },
15
- artifacts,
16
- wallet: freighterWalletAdapter,
17
- contracts: {
18
- counter: { binding: Counter }
19
- }
20
- });
@@ -1,66 +0,0 @@
1
- import { useMemo, useState } from "react";
2
- import { caatingaClient } from "../caatinga.js";
3
- import { CaatingaError } from "@caatinga/core/browser";
4
-
5
- function formatCaatingaError(error: unknown): string {
6
- if (error instanceof CaatingaError) {
7
- return `[${error.code}] ${error.message}\n\n${error.hint}`;
8
- }
9
-
10
- return error instanceof Error ? error.message : String(error);
11
- }
12
-
13
- export function CounterCard() {
14
- const [count, setCount] = useState(0);
15
- const [loading, setLoading] = useState(false);
16
- const [error, setError] = useState<string | null>(null);
17
- const formattedCount = useMemo(() => new Intl.NumberFormat().format(count), [count]);
18
-
19
- async function increment() {
20
- setLoading(true);
21
- setError(null);
22
-
23
- try {
24
- await caatingaClient.contract("counter").invoke("increment");
25
- setCount((value) => value + 1);
26
- } catch (caught) {
27
- setError(formatCaatingaError(caught));
28
- } finally {
29
- setLoading(false);
30
- }
31
- }
32
-
33
- function reset() {
34
- setCount(0);
35
- setError(null);
36
- }
37
-
38
- return (
39
- <section className="counter-panel" aria-labelledby="counter-title">
40
- <div className="counter-panel__header">
41
- <div>
42
- <p className="eyebrow">Counter Contract</p>
43
- <h2 id="counter-title">Counter</h2>
44
- </div>
45
- <span className="network-pill">testnet</span>
46
- </div>
47
-
48
- <div className="counter-value">{formattedCount}</div>
49
-
50
- <div className="counter-actions">
51
- <button type="button" onClick={increment} disabled={loading}>
52
- {loading ? "Incrementing…" : "Increment"}
53
- </button>
54
- <button className="secondary-button" type="button" onClick={reset} disabled={loading}>
55
- Reset
56
- </button>
57
- </div>
58
-
59
- {error ? (
60
- <pre className="counter-error" role="alert">
61
- {error}
62
- </pre>
63
- ) : null}
64
- </section>
65
- );
66
- }
@@ -1,65 +0,0 @@
1
- import { freighterWalletAdapter } from "@caatinga/client/freighter";
2
- import { useState } from "react";
3
- import { CaatingaError } from "@caatinga/core/browser";
4
-
5
- function formatWalletError(error: unknown): string {
6
- if (error instanceof CaatingaError) {
7
- return `[${error.code}] ${error.message}`;
8
- }
9
-
10
- return error instanceof Error ? error.message : String(error);
11
- }
12
-
13
- function shortenAddress(address: string): string {
14
- if (address.length <= 12) {
15
- return address;
16
- }
17
-
18
- return `${address.slice(0, 4)}…${address.slice(-4)}`;
19
- }
20
-
21
- export function WalletButton() {
22
- const [publicKey, setPublicKey] = useState<string | null>(null);
23
- const [error, setError] = useState<string | null>(null);
24
- const [loading, setLoading] = useState(false);
25
-
26
- async function connect() {
27
- setLoading(true);
28
- setError(null);
29
-
30
- try {
31
- const key = await freighterWalletAdapter.getPublicKey();
32
- setPublicKey(key);
33
- } catch (caught) {
34
- setPublicKey(null);
35
- setError(formatWalletError(caught));
36
- } finally {
37
- setLoading(false);
38
- }
39
- }
40
-
41
- function disconnect() {
42
- setPublicKey(null);
43
- setError(null);
44
- }
45
-
46
- return (
47
- <div className="wallet-shell">
48
- <button
49
- className="wallet-button"
50
- type="button"
51
- onClick={publicKey ? disconnect : connect}
52
- disabled={loading}
53
- aria-live="polite"
54
- >
55
- <span className={publicKey ? "status-dot status-dot--on" : "status-dot"} />
56
- {loading ? "Connecting…" : publicKey ? shortenAddress(publicKey) : "Connect"}
57
- </button>
58
- {error ? (
59
- <p className="wallet-error" role="alert">
60
- {error}
61
- </p>
62
- ) : null}
63
- </div>
64
- );
65
- }
@@ -1,49 +0,0 @@
1
- type TransactionResult = {
2
- txHash: string;
3
- result?: unknown;
4
- };
5
-
6
- class ExampleTransaction {
7
- constructor(
8
- private readonly method: string,
9
- private readonly result?: unknown
10
- ) {}
11
-
12
- toXDR(): string {
13
- return `example-${this.method}-xdr`;
14
- }
15
-
16
- async prepare(): Promise<ExampleTransaction> {
17
- return this;
18
- }
19
-
20
- async signAndSend(): Promise<TransactionResult> {
21
- return {
22
- txHash: "example-transaction-hash",
23
- result: this.result
24
- };
25
- }
26
- }
27
-
28
- export class Client {
29
- constructor(
30
- private readonly input: {
31
- contractId: string;
32
- publicKey: string;
33
- rpcUrl: string;
34
- networkPassphrase: string;
35
- }
36
- ) {}
37
-
38
- increment(): ExampleTransaction {
39
- return new ExampleTransaction("increment");
40
- }
41
-
42
- get(): ExampleTransaction {
43
- return new ExampleTransaction("get", 1);
44
- }
45
-
46
- describe(): string {
47
- return `${this.input.contractId}:${this.input.publicKey}`;
48
- }
49
- }
@@ -1,10 +0,0 @@
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
- );
@@ -1,176 +0,0 @@
1
- :root {
2
- color: #20232a;
3
- background: #f4f2ec;
4
- font-family:
5
- Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
6
- font-synthesis: none;
7
- text-rendering: optimizeLegibility;
8
- }
9
-
10
- * {
11
- box-sizing: border-box;
12
- }
13
-
14
- body {
15
- min-width: 320px;
16
- min-height: 100vh;
17
- margin: 0;
18
- }
19
-
20
- button {
21
- min-height: 44px;
22
- border: 0;
23
- border-radius: 8px;
24
- padding: 0 16px;
25
- background: #1d6154;
26
- color: #ffffff;
27
- font: inherit;
28
- font-weight: 700;
29
- cursor: pointer;
30
- }
31
-
32
- button:hover {
33
- background: #174d44;
34
- }
35
-
36
- .app-shell {
37
- width: min(960px, calc(100vw - 32px));
38
- margin: 0 auto;
39
- padding: 24px 0;
40
- }
41
-
42
- .topbar {
43
- display: flex;
44
- align-items: center;
45
- justify-content: space-between;
46
- gap: 16px;
47
- margin-bottom: 32px;
48
- }
49
-
50
- .topbar h1,
51
- .counter-panel h2 {
52
- margin: 0;
53
- color: #16181d;
54
- letter-spacing: 0;
55
- }
56
-
57
- .topbar h1 {
58
- font-size: clamp(2rem, 8vw, 4rem);
59
- line-height: 1;
60
- }
61
-
62
- .counter-panel h2 {
63
- font-size: 1.35rem;
64
- }
65
-
66
- .eyebrow {
67
- margin: 0 0 8px;
68
- color: #697076;
69
- font-size: 0.78rem;
70
- font-weight: 800;
71
- letter-spacing: 0.08em;
72
- text-transform: uppercase;
73
- }
74
-
75
- .wallet-shell {
76
- display: flex;
77
- flex-direction: column;
78
- align-items: flex-end;
79
- gap: 8px;
80
- }
81
-
82
- .wallet-error,
83
- .counter-error {
84
- margin: 0;
85
- max-width: min(360px, 100%);
86
- color: #8b1e1e;
87
- font-size: 0.82rem;
88
- line-height: 1.4;
89
- white-space: pre-wrap;
90
- }
91
-
92
- .counter-error {
93
- margin-top: 16px;
94
- }
95
-
96
- .wallet-button,
97
- .network-pill {
98
- display: inline-flex;
99
- align-items: center;
100
- gap: 8px;
101
- white-space: nowrap;
102
- }
103
-
104
- .status-dot {
105
- width: 8px;
106
- height: 8px;
107
- border-radius: 999px;
108
- background: #a9afb4;
109
- }
110
-
111
- .status-dot--on {
112
- background: #66c887;
113
- }
114
-
115
- .counter-panel {
116
- border: 1px solid #d9d5ca;
117
- border-radius: 8px;
118
- padding: clamp(20px, 5vw, 40px);
119
- background: #fffdf7;
120
- box-shadow: 0 18px 60px rgba(32, 35, 42, 0.08);
121
- }
122
-
123
- .counter-panel__header {
124
- display: flex;
125
- align-items: flex-start;
126
- justify-content: space-between;
127
- gap: 16px;
128
- }
129
-
130
- .network-pill {
131
- min-height: 32px;
132
- border: 1px solid #d9d5ca;
133
- border-radius: 999px;
134
- padding: 0 12px;
135
- color: #45515a;
136
- font-weight: 700;
137
- }
138
-
139
- .counter-value {
140
- margin: 48px 0;
141
- color: #111318;
142
- font-size: clamp(5rem, 24vw, 12rem);
143
- font-weight: 900;
144
- line-height: 0.9;
145
- letter-spacing: 0;
146
- }
147
-
148
- .counter-actions {
149
- display: flex;
150
- flex-wrap: wrap;
151
- gap: 12px;
152
- }
153
-
154
- .secondary-button {
155
- border: 1px solid #d9d5ca;
156
- background: #ffffff;
157
- color: #20232a;
158
- }
159
-
160
- .secondary-button:hover {
161
- background: #f4f2ec;
162
- }
163
-
164
- @media (max-width: 560px) {
165
- .topbar,
166
- .counter-panel__header {
167
- align-items: stretch;
168
- flex-direction: column;
169
- }
170
-
171
- .wallet-button,
172
- .counter-actions button {
173
- width: 100%;
174
- justify-content: center;
175
- }
176
- }
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "lib": ["DOM", "DOM.Iterable", "ES2020"],
6
- "allowJs": false,
7
- "skipLibCheck": true,
8
- "esModuleInterop": true,
9
- "allowSyntheticDefaultImports": true,
10
- "strict": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "module": "ESNext",
13
- "moduleResolution": "bundler",
14
- "resolveJsonModule": true,
15
- "isolatedModules": true,
16
- "noEmit": true,
17
- "jsx": "react-jsx"
18
- },
19
- "include": ["src"],
20
- "references": []
21
- }
@@ -1,6 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import react from "@vitejs/plugin-react";
3
-
4
- export default defineConfig({
5
- plugins: [react()]
6
- });