feat(samples): add human-present crypto-solana scenario (AP2 + Solana Pay reference binding) - #228
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new sample scenario for human-present transactions using on-chain Solana USDC, including a detailed README on the Solana Pay reference binding mechanism and a shell script to orchestrate the necessary agents. Feedback was provided regarding the order of environment variable sourcing in the startup script to prevent unintended overrides from local configuration files and to improve the robustness of the cleanup process by initializing process tracking earlier.
| export PAYMENT_METHOD=CRYPTO_SOLANA | ||
|
|
||
| AGENTS_DIR="samples/python/src/roles" | ||
| LOG_DIR=".logs" | ||
|
|
||
| if [ ! -d "$AGENTS_DIR" ]; then | ||
| echo "Error: Directory '$AGENTS_DIR' not found." | ||
| echo "Please run this script from the root of the repository." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -f .env ]; then | ||
| set -a | ||
| source .env | ||
| set +a | ||
| fi |
There was a problem hiding this comment.
The PAYMENT_METHOD environment variable is set at line 12, but then .env is sourced at line 25. If the user has PAYMENT_METHOD defined in their .env file, it will override the scenario-specific value (CRYPTO_SOLANA), potentially causing the script to execute with the wrong payment logic. It is safer to source the .env file first and then set scenario-specific overrides. Additionally, initializing the pids array early ensures that the cleanup trap (line 80) is always safe even if the script fails during early setup (e.g., line 20).
| export PAYMENT_METHOD=CRYPTO_SOLANA | |
| AGENTS_DIR="samples/python/src/roles" | |
| LOG_DIR=".logs" | |
| if [ ! -d "$AGENTS_DIR" ]; then | |
| echo "Error: Directory '$AGENTS_DIR' not found." | |
| echo "Please run this script from the root of the repository." | |
| exit 1 | |
| fi | |
| if [ -f .env ]; then | |
| set -a | |
| source .env | |
| set +a | |
| fi | |
| if [ -f .env ]; then | |
| set -a | |
| source .env | |
| set +a | |
| fi | |
| export PAYMENT_METHOD=CRYPTO_SOLANA | |
| AGENTS_DIR="samples/python/src/roles" | |
| LOG_DIR=".logs" | |
| pids=() | |
| if [ ! -d "$AGENTS_DIR" ]; then | |
| echo "Error: Directory '$AGENTS_DIR' not found." | |
| echo "Please run this script from the root of the repository." | |
| exit 1 | |
| fi |
There was a problem hiding this comment.
This is already addressed in the current commit. PAYMENT_METHOD=CRYPTO_SOLANA is exported on line 13, before .env is processed. The while IFS= loop then uses [[ -v "$key" ]] to skip any variable that is already present in the environment — so a PAYMENT_METHOD entry in .env cannot override the scenario value. The result is identical to your suggestion (scenario value always wins) but the guard applies to every variable, not just PAYMENT_METHOD.
8557f75 to
3155852
Compare
|
Thanks for the review @gemini-code-assist. Both points addressed in the latest commit:
|
|
Thanks for the update, @chopmob-cloud. The changes to the environment variable sourcing and the process tracking initialization look solid and address the concerns raised. The use of a |
6c884bf to
e4b7a88
Compare
|
Bumping for maintainer visibility -- Gemini review is satisfied (env sourcing and process tracking both approved in the April 29 pass). Since then, the Solana Pay reference binding pattern this PR demonstrates has moved into production: the AlgoVoi gateway now settles on Solana in live agent payment flows using the same per-checkout Happy to rebase or split the PR if it would help. -- AlgoVoi (chopmob-cloud) |
1ac5b3c to
a090c45
Compare
… Pay reference binding) Signed-off-by: AlgoVoi <chopmob@gmail.com>
Signed-off-by: AlgoVoi <chopmob@gmail.com>
5188f61 to
623f3e9
Compare
Human-present crypto-solana scenario (AP2 + Solana Pay reference binding)
Adds a human-present AP2 sample where the buyer settles with on-chain USDC on Solana. It mirrors the existing x402 scenario but uses Solana Pay semantics, specifically the reference pubkey primitive, to bind the settling transaction deterministically to a signed PaymentMandate.
What it demonstrates
Files
Notes