Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ describe("X402ActionProvider", () => {
expect(provider.supportsNetwork(network)).toBe(true);
});

it("should not support Solana networks with EVM protocol family", () => {
const network: Network = { protocolFamily: "evm", networkId: "solana-mainnet" };
expect(provider.supportsNetwork(network)).toBe(false);
});

it("should not support Base networks with SVM protocol family", () => {
const network: Network = { protocolFamily: "svm", networkId: "base-mainnet" };
expect(provider.supportsNetwork(network)).toBe(false);
});

it("should not support non-EVM/SVM networks", () => {
const network: Network = { protocolFamily: "bitcoin", networkId: "mainnet" };
expect(provider.supportsNetwork(network)).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,22 @@ These are the only services that can be called using make_http_request or make_h
* @param network - The network to check support for
* @returns True if the network is supported, false otherwise
*/
supportsNetwork = (network: Network) =>
(SUPPORTED_NETWORKS as readonly string[]).includes(network.networkId!);
supportsNetwork = (network: Network) => {
if (!(SUPPORTED_NETWORKS as readonly string[]).includes(network.networkId!)) {
return false;
}

switch (network.networkId) {
case "base-mainnet":
case "base-sepolia":
return network.protocolFamily === "evm";
case "solana-mainnet":
case "solana-devnet":
return network.protocolFamily === "svm";
default:
return false;
}
};

/**
* Creates an x402 client configured for the given wallet provider.
Expand Down
Loading