@caatinga/cli 2.0.2 → 2.1.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/README.md +1 -1
- package/dist/index.js +39 -12
- package/package.json +2 -2
- package/templates/marketplace-with-token/caatinga.template.json +1 -1
- package/templates/marketplace-with-token/package.json +3 -3
- package/templates/react-vite-counter/caatinga.template.json +1 -1
- package/templates/react-vite-counter/package.json +3 -3
- package/templates/react-vite-counter/src/components/CounterCard.tsx +1 -9
- package/templates/react-vite-counter/src/contracts/generated/counter/src/index.ts +23 -38
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ npx caatinga invoke counter.increment --network testnet --source alice
|
|
|
49
49
|
| `caatinga doctor [--network <network>] [--source <identity>]` | Check local Node, Stellar CLI, Rust, config, artifacts, network, and source identity setup |
|
|
50
50
|
| `caatinga build [contract]` | Compile contract WASM through Stellar CLI (default contract: `counter`) |
|
|
51
51
|
| `caatinga deploy [contract]` | Deploy one contract or the full configured graph; record IDs in artifacts |
|
|
52
|
-
| `caatinga generate
|
|
52
|
+
| `caatinga generate [contract]` | Generate TypeScript bindings from a deployed contract ID; omit the name to generate for all deployed contracts |
|
|
53
53
|
| `caatinga invoke <contract.method>` | Invoke a deployed contract method; extra args forward to Stellar CLI |
|
|
54
54
|
|
|
55
55
|
The supported CLI flow is `init -> build -> deploy -> generate -> invoke`.
|
package/dist/index.js
CHANGED
|
@@ -197,6 +197,16 @@ function registerDeployCommand(program2) {
|
|
|
197
197
|
logger.info(` Contract ID: ${contract.contractId}`);
|
|
198
198
|
}
|
|
199
199
|
logger.info("Artifacts updated: caatinga.artifacts.json");
|
|
200
|
+
if (result.deployedContracts.length > 0) {
|
|
201
|
+
logger.info("");
|
|
202
|
+
logger.info("Next:");
|
|
203
|
+
for (const contract of result.deployedContracts) {
|
|
204
|
+
logger.info(` npx caatinga generate ${contract.name} --network ${result.network.name}`);
|
|
205
|
+
}
|
|
206
|
+
logger.info(" npm run dev");
|
|
207
|
+
logger.info("");
|
|
208
|
+
logger.info("Run generate before npm run dev so the app uses real bindings, not the stub.");
|
|
209
|
+
}
|
|
200
210
|
}));
|
|
201
211
|
}
|
|
202
212
|
|
|
@@ -441,23 +451,26 @@ function registerDoctorCommand(program2) {
|
|
|
441
451
|
}
|
|
442
452
|
|
|
443
453
|
// src/commands/generate.command.ts
|
|
444
|
-
import {
|
|
454
|
+
import { generateBindingsGraph, loadConfig as loadConfig5 } from "@caatinga/core";
|
|
445
455
|
function registerGenerateCommand(program2) {
|
|
446
|
-
program2.command("generate").description("Generate TypeScript bindings for
|
|
456
|
+
program2.command("generate").description("Generate TypeScript bindings for deployed contracts").argument("[contract]", "Contract name (defaults to all deployed contracts)").option("-n, --network <network>", "Configured network name").action((contractName, options) => runCliAction(async () => {
|
|
447
457
|
const config = await loadConfig5();
|
|
448
|
-
const
|
|
458
|
+
const { network, results } = await generateBindingsGraph({
|
|
449
459
|
config,
|
|
450
460
|
contractName,
|
|
451
461
|
networkName: options.network
|
|
452
462
|
});
|
|
453
463
|
logger.success("Client generated");
|
|
454
464
|
logger.info("");
|
|
455
|
-
logger.info(`
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
logger.info(`
|
|
465
|
+
logger.info(`Network: ${network.name}`);
|
|
466
|
+
for (const result of results) {
|
|
467
|
+
logger.info("");
|
|
468
|
+
logger.info(`Contract: ${result.contractName}`);
|
|
469
|
+
logger.info(`Output: ${result.outputDir}`);
|
|
470
|
+
logger.info(`Import path: ${result.importPath}`);
|
|
471
|
+
if (result.legacyStubRemoved) {
|
|
472
|
+
logger.info(`Removed legacy stub: ${config.frontend.bindingsOutput}/${result.contractName}.ts`);
|
|
473
|
+
}
|
|
461
474
|
}
|
|
462
475
|
logger.info("");
|
|
463
476
|
logger.info("Next: import bindings from the import path above, then run npm run dev");
|
|
@@ -540,13 +553,27 @@ function registerInitCommand(program2) {
|
|
|
540
553
|
logger.info(`Template: ${result.template.name}@${result.template.version}`);
|
|
541
554
|
logger.info(`Path: ${targetDir}`);
|
|
542
555
|
logger.info("");
|
|
556
|
+
const defaultContract = result.template.contracts.default;
|
|
543
557
|
logger.info("Next steps:");
|
|
544
558
|
logger.info(` cd ${projectDirectory}`);
|
|
545
559
|
logger.info(" npm install");
|
|
546
|
-
|
|
560
|
+
if (defaultContract) {
|
|
561
|
+
logger.info(` npx caatinga build ${defaultContract}`);
|
|
562
|
+
logger.info(
|
|
563
|
+
` npx caatinga deploy ${defaultContract} --network testnet --source <identity>`
|
|
564
|
+
);
|
|
565
|
+
logger.info(` npx caatinga generate ${defaultContract} --network testnet`);
|
|
566
|
+
} else {
|
|
567
|
+
logger.info(" npx caatinga build");
|
|
568
|
+
logger.info(" npx caatinga deploy --network testnet --source <identity>");
|
|
569
|
+
logger.info(" npx caatinga generate --network testnet");
|
|
570
|
+
}
|
|
571
|
+
logger.info(" npm run dev");
|
|
572
|
+
logger.info("");
|
|
547
573
|
logger.info(
|
|
548
|
-
|
|
574
|
+
"Note: deploy and generate the contract before interacting in the frontend \u2014"
|
|
549
575
|
);
|
|
576
|
+
logger.info("the dApp reads the contract ID from caatinga.artifacts.json.");
|
|
550
577
|
}));
|
|
551
578
|
}
|
|
552
579
|
|
|
@@ -575,7 +602,7 @@ function registerInvokeCommand(program2) {
|
|
|
575
602
|
}
|
|
576
603
|
|
|
577
604
|
// src/version.ts
|
|
578
|
-
var CAATINGA_CLI_VERSION = "2.0
|
|
605
|
+
var CAATINGA_CLI_VERSION = "2.1.0";
|
|
579
606
|
|
|
580
607
|
// src/program.ts
|
|
581
608
|
function createProgram() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caatinga/cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Caatinga CLI for building dApps on Stellar/Soroban",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stellar",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"LICENSE"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@caatinga/core": "^2.0
|
|
46
|
+
"@caatinga/core": "^2.1.0",
|
|
47
47
|
"chalk": "^5.4.1",
|
|
48
48
|
"commander": "^12.1.0"
|
|
49
49
|
},
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"caatinga:generate": "caatinga generate token && caatinga generate marketplace"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@caatinga/client": "^2.0
|
|
16
|
-
"@caatinga/core": "^2.0
|
|
15
|
+
"@caatinga/client": "^2.1.0",
|
|
16
|
+
"@caatinga/core": "^2.1.0",
|
|
17
17
|
"@vitejs/plugin-react": "^4.3.4",
|
|
18
18
|
"react": "^18.3.1",
|
|
19
19
|
"react-dom": "^18.3.1",
|
|
20
20
|
"vite": "^6.0.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@caatinga/cli": "^2.0
|
|
23
|
+
"@caatinga/cli": "^2.1.0",
|
|
24
24
|
"@types/react": "^18.3.18",
|
|
25
25
|
"@types/react-dom": "^18.3.5",
|
|
26
26
|
"typescript": "^5.7.2"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"caatinga:generate": "caatinga generate counter"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@caatinga/client": "^2.0
|
|
16
|
-
"@caatinga/core": "^2.0
|
|
15
|
+
"@caatinga/client": "^2.1.0",
|
|
16
|
+
"@caatinga/core": "^2.1.0",
|
|
17
17
|
"@creit.tech/stellar-wallets-kit": "^1.9.5",
|
|
18
18
|
"@stellar/stellar-sdk": "^14.5.0",
|
|
19
19
|
"buffer": "^6.0.3",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"vite": "^6.0.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@caatinga/cli": "^2.0
|
|
26
|
+
"@caatinga/cli": "^2.1.0",
|
|
27
27
|
"@types/react": "^18.3.18",
|
|
28
28
|
"@types/react-dom": "^18.3.5",
|
|
29
29
|
"typescript": "^5.7.2"
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { caatingaClient } from "../caatinga.js";
|
|
3
|
-
import {
|
|
3
|
+
import { formatCaatingaError } from "@caatinga/core/browser";
|
|
4
4
|
import { useWallet } from "../context/WalletContext.js";
|
|
5
5
|
import { LoadingModal } from "./LoadingModal.js";
|
|
6
6
|
|
|
7
|
-
function formatCaatingaError(error: unknown): string {
|
|
8
|
-
if (error instanceof CaatingaError) {
|
|
9
|
-
return `[${error.code}] ${error.message}\n\n${error.hint}`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return error instanceof Error ? error.message : String(error);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
export function CounterCard() {
|
|
16
8
|
const { publicKey } = useWallet();
|
|
17
9
|
const [count, setCount] = useState<number | null>(null);
|
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
async prepare(): Promise<ExampleTransaction> {
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async signAndSend(input?: { signTransaction?: SignTransaction }): Promise<TransactionResult> {
|
|
26
|
-
const signed = input?.signTransaction
|
|
27
|
-
? await input.signTransaction(this.toXDR())
|
|
28
|
-
: { signedTxXdr: this.toXDR() };
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
txHash: `example-transaction-hash:${signed.signedTxXdr}`,
|
|
32
|
-
result: this.result
|
|
33
|
-
};
|
|
34
|
-
}
|
|
1
|
+
// Placeholder bindings. This file exists so the template type-checks before you
|
|
2
|
+
// run `caatinga generate`. It does NOT talk to the chain — every method throws a
|
|
3
|
+
// clear, actionable error. `caatinga generate counter` overwrites this file with
|
|
4
|
+
// real Stellar CLI bindings.
|
|
5
|
+
import { CaatingaError, CaatingaErrorCode } from "@caatinga/core/browser";
|
|
6
|
+
|
|
7
|
+
// Marker the client checks to detect that real bindings haven't been generated
|
|
8
|
+
// yet. Real Stellar CLI bindings never export this.
|
|
9
|
+
export const __caatingaPlaceholder = true;
|
|
10
|
+
|
|
11
|
+
const GENERATE_HINT =
|
|
12
|
+
"Run `npx caatinga generate counter --network testnet`, then restart the dev server.";
|
|
13
|
+
|
|
14
|
+
function placeholderBinding(method: string): never {
|
|
15
|
+
throw new CaatingaError(
|
|
16
|
+
`Placeholder bindings are still in use for "counter.${method}".`,
|
|
17
|
+
CaatingaErrorCode.PLACEHOLDER_BINDING,
|
|
18
|
+
GENERATE_HINT
|
|
19
|
+
);
|
|
35
20
|
}
|
|
36
21
|
|
|
37
22
|
export class Client {
|
|
@@ -44,12 +29,12 @@ export class Client {
|
|
|
44
29
|
}
|
|
45
30
|
) {}
|
|
46
31
|
|
|
47
|
-
increment():
|
|
48
|
-
return
|
|
32
|
+
increment(): never {
|
|
33
|
+
return placeholderBinding("increment");
|
|
49
34
|
}
|
|
50
35
|
|
|
51
|
-
get():
|
|
52
|
-
return
|
|
36
|
+
get(): never {
|
|
37
|
+
return placeholderBinding("get");
|
|
53
38
|
}
|
|
54
39
|
|
|
55
40
|
describe(): string {
|