Skip to content

Commit 5ace79a

Browse files
committed
Final cleanup: remove console.log leak, fix stale references, update mocks
- Remove console.log leaking contract config in contracts/util.ts - Update gene_splicer.ts comment to reflect GitHub secrets workflow - Update test mock (contract.ts): fix stale get_entropy, add batch methods - Fix keepAlive.sh: default source to splicers-server, accept override arg - Update .env.example: cleaner layout, document GitHub secret relationship - Fix Home.tsx: remove Debugger reference from production text
1 parent 44d5cd4 commit 5ace79a

5 files changed

Lines changed: 45 additions & 69 deletions

File tree

.env.example

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,25 @@
1-
# The environment to use `development`, `testing`, `staging`, `production`
1+
# Environment: development | staging | production
22
STELLAR_SCAFFOLD_ENV=development
33

4-
# Location of the config files for this project for the scaffold stellar CLI.
5-
# Learn more at https://developers.stellar.org/docs/tools/cli/stellar-cli#stellar-config-dir
4+
# Stellar CLI config directory
65
XDG_CONFIG_HOME=".config"
76

8-
# Prefix with "PUBLIC_" to make available in frontend files
9-
# Which Stellar network to use in the frontend: local, testnet, futurenet, or mainnet
10-
# More on Stellar networks: https://developers.stellar.org/docs/networks
7+
# Network configuration (uncomment ONE block)
118

9+
# --- Local development ---
1210
PUBLIC_STELLAR_NETWORK="LOCAL"
13-
# The Stellar network passphrase, this is local
1411
PUBLIC_STELLAR_NETWORK_PASSPHRASE="Standalone Network ; February 2017"
15-
# The Stellar network RPC URL. this is local
1612
PUBLIC_STELLAR_RPC_URL="http://localhost:8000/rpc"
17-
# The Stellar Horizon URL. this is local
1813
PUBLIC_STELLAR_HORIZON_URL="http://localhost:8000"
1914

20-
# PUBLIC_STELLAR_NETWORK="TESTNET"
21-
# PUBLIC_STELLAR_NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
22-
# PUBLIC_STELLAR_RPC_URL="https://soroban-testnet.stellar.org"
23-
# PUBLIC_STELLAR_HORIZON_URL="https://horizon-testnet.stellar.org"
15+
# --- Testnet ---
16+
# PUBLIC_STELLAR_NETWORK=TESTNET
17+
# PUBLIC_STELLAR_NETWORK_PASSPHRASE=Test SDF Network ; September 2015
18+
# PUBLIC_STELLAR_RPC_URL=https://soroban-testnet.stellar.org
19+
# PUBLIC_STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
2420

25-
# PUBLIC_STELLAR_NETWORK="MAINNET"
26-
# PUBLIC_STELLAR_NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015"
27-
# PUBLIC_STELLAR_RPC_URL=
28-
# PUBLIC_STELLAR_HORIZON_URL=
29-
30-
# ============================================================================
31-
# CONTRACT IDs - CRITICAL: MUST UPDATE AFTER EVERY DEPLOYMENT!
32-
# ============================================================================
33-
# After deploying contracts, you MUST manually update these IDs.
34-
# Check: cat .config/stellar/contract-ids/gene_splicer.json
35-
# Then copy the ID here and restart the dev server.
36-
#
37-
# ⚠️ If these IDs don't match the deployed contract, your frontend will fail
38-
# silently - transactions will simulate successfully but not actually execute!
39-
# ============================================================================
40-
41-
# Gene Splicer contract ID
42-
PUBLIC_GENE_SPLICER_CONTRACT_ID="YOUR_CONTRACT_ID_HERE"
21+
# Contract ID — must match the deployed contract.
22+
# For local dev: auto-populated by `stellar scaffold watch`
23+
# For testnet/mainnet: update manually after deployment
24+
# Also stored as TESTNET_CONTRACT_ID GitHub secret for CI/CD
25+
PUBLIC_GENE_SPLICER_CONTRACT_ID=YOUR_CONTRACT_ID_HERE

scripts/keepAlive.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
#!/bin/bash
2-
# Keep-alive script for the Gene Splicer contract on Soroban testnet
2+
# Keep-alive script for the Gene Splicer contract on Soroban testnet.
33
# Extends the TTL for the contract instance and WASM code to prevent expiration.
44
#
55
# Usage:
6-
# bash scripts/keepAlive.sh
6+
# bash scripts/keepAlive.sh [source-identity]
77
#
8-
# Recommended: Run weekly via cron or GitHub Actions scheduled workflow.
9-
# Soroban testnet minimum persistent TTL is ~24 hours (4096 ledgers).
8+
# The source identity defaults to "splicers-server" (the funded server wallet).
109
# The contract's extend_ttl() sets TTL to ~30 days (432,000 ledgers).
1110

1211
set -euo pipefail
1312

14-
# Load contract ID from .env
1513
CONTRACT_ID=$(grep PUBLIC_GENE_SPLICER_CONTRACT_ID .env | cut -d= -f2)
1614
NETWORK="testnet"
17-
SOURCE="testnet-user"
15+
SOURCE="${1:-splicers-server}"
1816

1917
if [ -z "$CONTRACT_ID" ]; then
2018
echo "ERROR: CONTRACT_ID not found in .env"
2119
exit 1
2220
fi
2321

24-
echo "Extending TTL for contract: $CONTRACT_ID"
22+
echo "Extending TTL for contract: $CONTRACT_ID (source: $SOURCE)"
2523

26-
# Call the contract's extend_ttl() function
27-
# This extends both instance storage and WASM code TTL
2824
stellar contract invoke \
2925
--id "$CONTRACT_ID" \
3026
--network "$NETWORK" \

src/contracts/gene_splicer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import * as Client from 'gene_splicer';
22
import { rpcUrl, networkPassphrase } from './util';
33

4-
// CRITICAL: Contract ID must be updated in .env after EVERY deployment!
5-
// The auto-generated TypeScript bindings cannot be relied upon for staging/production.
6-
// Always use PUBLIC_GENE_SPLICER_CONTRACT_ID from .env as the single source of truth.
4+
// Contract ID is read from PUBLIC_GENE_SPLICER_CONTRACT_ID in .env (local dev)
5+
// and from TESTNET_CONTRACT_ID GitHub secret (CI/CD deployments).
76
const contractId = import.meta.env.PUBLIC_GENE_SPLICER_CONTRACT_ID;
87

98
if (!contractId) {

src/contracts/util.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ export async function createGeneSplicerClient(publicKey: string) {
107107
);
108108
}
109109

110-
console.log(
111-
"[createGeneSplicerClient] Write client using contract ID:",
112-
contractId,
113-
"Network:",
114-
stellarNetwork,
115-
);
116-
117110
return new GeneSplicerModule.Client({
118111
networkPassphrase,
119112
contractId,

src/test/mocks/contract.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { vi } from "vitest";
22
import type { GenomeCartridge, Creature, Gene } from "gene_splicer";
33

4+
export function createMockGene(overrides?: Partial<Gene>): Gene {
5+
return {
6+
id: 6,
7+
rarity: { tag: "Normal", values: undefined as never },
8+
...overrides,
9+
};
10+
}
11+
412
export function createMockCartridge(
513
overrides?: Partial<GenomeCartridge>,
614
): GenomeCartridge {
@@ -15,32 +23,26 @@ export function createMockCartridge(
1523
};
1624
}
1725

18-
export function createMockGene(overrides?: Partial<Gene>): Gene {
19-
return {
20-
id: 3,
21-
rarity: { tag: "Normal", values: undefined },
22-
...overrides,
23-
};
24-
}
25-
2626
export function createMockCreature(overrides?: Partial<Creature>): Creature {
2727
return {
2828
id: 1,
2929
owner: "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI",
3030
skin_id: 5,
3131
entropy_round: 12345n,
3232
finalized_at: BigInt(Date.now()),
33-
head_gene: createMockGene({ id: 2 }),
34-
body_gene: createMockGene({ id: 4 }),
35-
legs_gene: createMockGene({
36-
id: 7,
37-
rarity: { tag: "Rare", values: undefined },
33+
head_gene: createMockGene({
34+
id: 2,
35+
rarity: { tag: "Rare", values: undefined as never },
3836
}),
37+
body_gene: createMockGene({
38+
id: 4,
39+
rarity: { tag: "Legendary", values: undefined as never },
40+
}),
41+
legs_gene: createMockGene({ id: 7 }),
3942
...overrides,
4043
};
4144
}
4245

43-
// Mock contract client
4446
export function createMockContractClient() {
4547
return {
4648
splice_genome: vi.fn().mockResolvedValue({
@@ -55,17 +57,20 @@ export function createMockContractClient() {
5557
get_user_cartridges: vi.fn().mockResolvedValue({
5658
simulate: vi.fn().mockResolvedValue({ result: [1] }),
5759
}),
60+
get_cartridges_batch: vi.fn().mockResolvedValue({
61+
simulate: vi.fn().mockResolvedValue({ result: [createMockCartridge()] }),
62+
}),
5863
get_user_creatures: vi.fn().mockResolvedValue({
5964
simulate: vi.fn().mockResolvedValue({ result: [1] }),
6065
}),
6166
get_creature: vi.fn().mockResolvedValue({
6267
simulate: vi.fn().mockResolvedValue({ result: createMockCreature() }),
6368
}),
64-
get_entropy: vi.fn().mockResolvedValue({
65-
simulate: vi.fn().mockResolvedValue({ result: null }),
69+
get_creatures_batch: vi.fn().mockResolvedValue({
70+
simulate: vi.fn().mockResolvedValue({ result: [createMockCreature()] }),
71+
}),
72+
extend_ttl: vi.fn().mockResolvedValue({
73+
simulate: vi.fn().mockResolvedValue({}),
6674
}),
6775
};
6876
}
69-
70-
// Mock GeneSplicer default export
71-
export const mockGeneSplicerClient = createMockContractClient();

0 commit comments

Comments
 (0)