|
1 | 1 | import type { Abi } from "abitype"; |
2 | 2 | import { toFunctionSelector } from "viem/utils"; |
3 | | -import { type Money, moneySchema } from "x402/types"; |
| 3 | +import { ChainIdToNetwork, type Money, moneySchema } from "x402/types"; |
4 | 4 | import { getCachedChain } from "../chains/utils.js"; |
5 | 5 | import type { ThirdwebClient } from "../client/client.js"; |
6 | 6 | import { resolveContractAbi } from "../contract/actions/resolve-abi.js"; |
@@ -98,9 +98,10 @@ export async function decodePaymentRequest( |
98 | 98 |
|
99 | 99 | const paymentRequirements: RequestedPaymentRequirements[] = []; |
100 | 100 |
|
| 101 | + const mappedNetwork = ChainIdToNetwork[chainId]; |
101 | 102 | paymentRequirements.push({ |
102 | 103 | scheme: "exact", |
103 | | - network: `eip155:${chainId}`, |
| 104 | + network: mappedNetwork ? mappedNetwork : `eip155:${chainId}`, |
104 | 105 | maxAmountRequired, |
105 | 106 | resource: resourceUrl, |
106 | 107 | description: description ?? "", |
@@ -263,7 +264,7 @@ async function getDefaultAsset( |
263 | 264 | ): Promise<DefaultAsset | undefined> { |
264 | 265 | const supportedAssets = await facilitator.supported(); |
265 | 266 | const matchingAsset = supportedAssets.kinds.find( |
266 | | - (supported) => supported.network === `eip155:${chainId}`, |
| 267 | + (supported) => networkToChainId(supported.network) === chainId, |
267 | 268 | ); |
268 | 269 | const assetConfig = matchingAsset?.extra?.defaultAsset as DefaultAsset; |
269 | 270 | return assetConfig; |
|
0 commit comments