Skip to content

Add get_referral_stats SDK method #412

Description

@Levi-Ojukwu

Description:

The contract tracks referral counts per referral code (at lib.rs:915-920). When a freelancer submits an invoice with a referral code, the count for that code is incremented. The SDK does not expose a method to query these counts.

The contract implementation:

pub fn get_referral_stats(env: Env, code: BytesN<32>) -> u64 {
    env.storage()
        .persistent()
        .get(&DataKey::ReferralCount(code))
        .unwrap_or(0)
}

The referral code is a BytesN<32> (32-byte hash). The SDK method should:

  1. Accept a hex-encoded string referral code
  2. Convert it to BytesN<32> for the contract call
  3. Return the count as a number

Why it matters: Referral tracking is a growth mechanism. Affiliates and marketing teams need to query referral performance to optimize campaigns.

Acceptance Criteria:

  • Create a function that accepts a hex string referral code
  • Convert hex string to BytesN<32> using Stellar SDK utilities
  • Call the contract's get_referral_stats view
  • Return Promise<number>
  • Add tests

Relevant Files: contracts/invoice_liquidity/src/lib.rs:915-920, sdk/src/index.ts


Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions