-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Labels
Description
🎯 Objective
Generate TypeScript bindings for the Crowdfunding Collective Contract using the Stellar CLI to provide type-safe contract interactions in the StarShop Frontend application.
c
🏗 Implementation Steps
1. Contract Deployment
# Install the compiled contract
stellar contract upload \
--source-account <identity or secret key> \
--network testnet \
--wasm ./target/wasm32v1-none/release/crowdfunding_collective.wasm
# Deploy a contract instance
stellar contract deploy \
--source-account <identity or secret key> \
--network testnet \
--wasm-hash <wasm_hash_from_install_step>2. Generate TypeScript Bindings
stellar contract bindings typescript \
--network testnet \
--id <contract_address_from_deploy_step> \
--output-dir ./packages/crowdfunding_collective \
--overwrite3. Build Bindings Package
cd packages/crowdfunding_collective
npm install
npm run build
cd ../..4. Add to Frontend Dependencies
npm install file:./packages/crowdfunding_collective5. Create Contract Client
// src/lib/contracts/crowdfunding_collective.ts
import * as Client from "crowdfunding_collective";
import { PUBLIC_STELLAR_RPC_URL } from "$env/static/public";
export default new Client.Client({
...Client.networks.testnet,
rpcUrl: PUBLIC_STELLAR_RPC_URL,
});🗂 Expected Bindings Structure
// Generated types and functions
- initialize(admin: Address): void
- create_product(creator: Address, name: String, description: String, funding_goal: u64, deadline: u64, reward_tiers: Vec<RewardTier>, milestones: Vec<Milestone>): u32
- contribute(contributor: Address, product_id: u32, amount: u64): void
- distribute_funds(caller: Address, product_id: u32): void
- refund_contributors(caller: Address, product_id: u32): void
- claim_reward(contributor: Address, product_id: u32): void
- update_milestone(creator: Address, product_id: u32, milestone_id: u32): void
- get_product(product_id: u32): Product
- get_contributions(product_id: u32): Vec<Contribution>
- get_milestones(product_id: u32): Vec<Milestone>
- get_reward_tiers(product_id: u32): Vec<RewardTier>
- get_product_status(product_id: u32): ProductStatus✅ Acceptance Criteria
- Contract successfully deployed to testnet
- TypeScript bindings generated and built
- Bindings package added to frontend dependencies
- Contract client created and exported
- All contract functions properly typed
- Integration tests pass