feat: add stellar payment utilities for tip transactions#262
feat: add stellar payment utilities for tip transactions#262davedumto merged 2 commits intoStreamFi-x:devfrom
Conversation
|
@Hallab7 is attempting to deploy a commit to the david's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Great work on this PR! The implementation is excellent with comprehensive tests and documentation. 👏 However, I noticed a security concern: Issue: Hardcoded Secret Key in Test FileIn lib/stellar/tests/payments.test.ts:30, there's a hardcoded secret key: sourceSecretKey: "SDTIZXLNUEXETRYIBQKYQ7MO3YXRKBPPTRJDZODQHZT57LZ7DBNENRTC", // Viewer secretEven though this is a testnet key with no real value, it's bad practice to commit any secrets to the repository. Recommended FixUpdate the test to load the secret from an environment variable and skip the transaction submission test if not provided: const TEST_CONFIG = {
sourcePublicKey: "GA5AJZ2HYSKNN5MGZGBBVCJ73RXOGXTWFV4FWCUDLVCJXKSLGTAI7L5F",
sourceSecretKey: process.env.TEST_STELLAR_SECRET_KEY || "", // Load from env
destinationPublicKey: "GD4KLYVQBT225M5UVGIKAQCHRI3YU2S7IOJG6B667ZVDTPGIXKJAOTQT",
amount: "10.0000000",
network: "testnet" as const,
};
// In Test 7, add a check:
if (\!TEST_CONFIG.sourceSecretKey) {
console.log(" ⚠️ SKIPPED: Set TEST_STELLAR_SECRET_KEY env var to test submission");
} else {
// ... existing submission test
}Could you update this before we merge? Thanks! |
Merge Conflict AlertThis PR has merge conflicts that need to be resolved before merging. Please pull the latest changes from git checkout dev
git pull origin dev
# Resolve conflicts
git add .
git commit -m "fix: resolve merge conflicts with dev"
git pushOnce conflicts are resolved, we can proceed with the merge after you address the hardcoded secret key issue mentioned above. |
|
@davedumto secret key issue fixed and merge conflict resolved |
Description
Closes #247
This PR implements Stellar payment utilities to enable XLM tip transactions from viewers to creators on the StreamFi platform. It introduces a reusable, well-tested utility module for building and submitting Stellar payment transactions, which will be consumed by the tip modal feature.
Changes proposed
What were you told to do?
Create a utility module for building Stellar payment transactions using
@stellar/stellar-sdk. The module should support constructing XLM tip transactions from viewers to creators, handle network selection, validate inputs, and provide proper error handling.What did you do?
I implemented a complete Stellar payment utility with full TypeScript support and testing.
Files Created:
lib/stellar/payments.tsbuildTipTransaction()to construct unsigned Stellar payment transactionssubmitTransaction()to submit signed transactions to the Horizon APIgetCurrentNetwork()to resolve testnet/mainnet from environment variablesisValidStellarPublicKey()for public key validationformatXLMAmount()to format XLM amounts to 7 decimal placeslib/stellar/__tests__/payments.test.tsFiles Modified:
package-lock.json– Updated to properly install@stellar/stellar-sdktsconfig.json– Minor configuration adjustmentDependencies Installed:
@stellar/stellar-sdk@^14.5.0ts-node@10.9.2(dev dependency for running tests)Key Features:
NEXT_PUBLIC_STELLAR_NETWORK"StreamFi Tip"Check List (Check all the applicable boxes)
🚨Please review the contribution guideline for this repository.
Screenshots/Videos
Test Results (Stellar Testnet)
A video demo showing test execution, transaction submission, and Stellar Expert verification link in added below.
https://www.loom.com/share/12e1a92964a34674a543f2fda082613c