Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion skills/build-on-base/scripts/register.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ RESPONSE=$(curl -sf -X POST "$API_URL" \
exit 1
}

BUILDER_CODE=$(echo "$RESPONSE" | grep -o '"builder_code":"[^"]*"' | cut -d'"' -f4)
BUILDER_CODE=$(printf '%s' "$RESPONSE" | jq -r '.builder_code // empty') || {
echo "Error: Failed to parse API response" >&2
echo "Response: $RESPONSE" >&2
exit 1
}

if [ -z "$BUILDER_CODE" ]; then
echo "Error: No builder_code in API response" >&2
Expand Down
34 changes: 34 additions & 0 deletions skills/build-on-base/scripts/register_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT

cat >"$TMP_DIR/curl" <<'FAKE_CURL'
#!/usr/bin/env bash
cat <<'JSON'
{
"builder_code": "bc_a1b2c3d4",
"wallet_address": "0x123",
"usage_instructions": "Append this builder code to your onchain transactions."
}
JSON
FAKE_CURL
chmod +x "$TMP_DIR/curl"

set +e
output=$(PATH="$TMP_DIR:$PATH" bash "$SCRIPT_DIR/register.sh" "0x123" 2>&1)
status=$?
set -e

if [ "$status" -ne 0 ]; then
echo "Expected register.sh to succeed, got exit $status:" >&2
echo "$output" >&2
exit 1
fi

if [ "$output" != "bc_a1b2c3d4" ]; then
echo "Expected builder code bc_a1b2c3d4, got: $output" >&2
exit 1
fi