diff --git a/python/x402/changelog.d/monad-testnet-paywall-faucet.bugfix.md b/python/x402/changelog.d/monad-testnet-paywall-faucet.bugfix.md new file mode 100644 index 0000000000..93da719a7d --- /dev/null +++ b/python/x402/changelog.d/monad-testnet-paywall-faucet.bugfix.md @@ -0,0 +1 @@ +Add Circle faucet URL for Monad Testnet (`eip155:10143`) to the embedded paywall faucet map so browser paywalls render the faucet link instead of "No faucet configured." diff --git a/python/x402/http/paywall/evm_paywall_template.py b/python/x402/http/paywall/evm_paywall_template.py index 8de786c3e7..beb18fd368 100644 --- a/python/x402/http/paywall/evm_paywall_template.py +++ b/python/x402/http/paywall/evm_paywall_template.py @@ -1,2 +1,2 @@ # THIS FILE IS AUTO-GENERATED - DO NOT EDIT -EVM_PAYWALL_TEMPLATE = '\n \n \n Payment Required\n \n
\n \n \n ' +EVM_PAYWALL_TEMPLATE = '\n \n \n Payment Required\n \n
\n \n \n ' diff --git a/python/x402/tests/unit/http/test_paywall.py b/python/x402/tests/unit/http/test_paywall.py index 45fc2418ed..ef98b3813d 100644 --- a/python/x402/tests/unit/http/test_paywall.py +++ b/python/x402/tests/unit/http/test_paywall.py @@ -2,17 +2,31 @@ from __future__ import annotations +import json +import re + from x402.http.paywall import ( EvmPaywallHandler, PaywallBuilder, SvmPaywallHandler, ) +from x402.http.paywall.evm_paywall_template import EVM_PAYWALL_TEMPLATE from x402.schemas import ( PaymentRequired, PaymentRequirements, ResourceInfo, ) +_EMBEDDED_FAUCET_MAP_RE = re.compile(r"\$xt=(\{.*?\})") + + +def _embedded_faucet_map(template: str) -> dict[str, str]: + match = _EMBEDDED_FAUCET_MAP_RE.search(template) + assert match is not None, "embedded paywall $xt faucet map not found" + parsed = json.loads(match.group(1)) + assert isinstance(parsed, dict) + return parsed + def _make_evm_payment_required() -> PaymentRequired: return PaymentRequired( @@ -139,3 +153,8 @@ def test_provider_runtime_faucet_urls_override_builder_faucet_urls() -> None: ) assert "https://example.com/runtime" in html assert "https://example.com/builder" not in html + + +def test_evm_embedded_faucet_map_includes_monad_testnet_circle_faucet() -> None: + faucet_map = _embedded_faucet_map(EVM_PAYWALL_TEMPLATE) + assert faucet_map["eip155:10143"] == "https://faucet.circle.com/"