@bankofai/x402-evm 1.0.0-beta.4 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,7 +41,10 @@ interface EvmClientConfig {
41
41
  *
42
42
  * This function registers:
43
43
  * - V2: eip155:* wildcard scheme with ExactEvmScheme (or specific networks if provided)
44
- * - V1: All supported EVM networks with ExactEvmSchemeV1
44
+ *
45
+ * Note: legacy x402 v1 schemes are no longer auto-registered. The v1 classes
46
+ * (`ExactEvmSchemeV1`, `NETWORKS`) are still exported under `@bankofai/x402-evm/v1`
47
+ * and `@bankofai/x402-evm/exact/v1/*` for callers that explicitly need them.
45
48
  *
46
49
  * @param client - The x402Client instance to register schemes to
47
50
  * @param config - Configuration for EVM client registration
@@ -585,129 +585,6 @@ var ExactEvmScheme = class {
585
585
  }
586
586
  };
587
587
 
588
- // src/exact/v1/client/scheme.ts
589
- var import_viem13 = require("viem");
590
-
591
- // src/exact/v1/facilitator/scheme.ts
592
- var import_viem12 = require("viem");
593
-
594
- // src/exact/facilitator/eip3009-utils.ts
595
- var import_viem11 = require("viem");
596
-
597
- // src/v1/index.ts
598
- var EVM_NETWORK_CHAIN_ID_MAP = {
599
- ethereum: 1,
600
- sepolia: 11155111,
601
- abstract: 2741,
602
- "abstract-testnet": 11124,
603
- "base-sepolia": 84532,
604
- base: 8453,
605
- "avalanche-fuji": 43113,
606
- avalanche: 43114,
607
- iotex: 4689,
608
- sei: 1329,
609
- "sei-testnet": 1328,
610
- polygon: 137,
611
- "polygon-amoy": 80002,
612
- peaq: 3338,
613
- story: 1514,
614
- educhain: 41923,
615
- "skale-base-sepolia": 324705682,
616
- megaeth: 4326,
617
- monad: 143,
618
- stable: 988,
619
- "stable-testnet": 2201
620
- };
621
- var NETWORKS = Object.keys(EVM_NETWORK_CHAIN_ID_MAP);
622
- function getEvmChainIdV1(network) {
623
- const chainId = EVM_NETWORK_CHAIN_ID_MAP[network];
624
- if (!chainId) {
625
- throw new Error(`Unsupported v1 network: ${network}`);
626
- }
627
- return chainId;
628
- }
629
-
630
- // src/exact/v1/client/scheme.ts
631
- var ExactEvmSchemeV1 = class {
632
- /**
633
- * Creates a new ExactEvmClientV1 instance.
634
- *
635
- * @param signer - The EVM signer for client operations
636
- */
637
- constructor(signer) {
638
- this.signer = signer;
639
- this.scheme = "exact";
640
- }
641
- /**
642
- * Creates a payment payload for the Exact scheme (V1).
643
- *
644
- * @param x402Version - The x402 protocol version
645
- * @param paymentRequirements - The payment requirements
646
- * @returns Promise resolving to a payment payload
647
- */
648
- async createPaymentPayload(x402Version, paymentRequirements) {
649
- const selectedV1 = paymentRequirements;
650
- const nonce = createNonce();
651
- const now = Math.floor(Date.now() / 1e3);
652
- const authorization = {
653
- from: this.signer.address,
654
- to: (0, import_viem13.getAddress)(selectedV1.payTo),
655
- value: selectedV1.maxAmountRequired,
656
- validAfter: (now - 600).toString(),
657
- // 10 minutes before
658
- validBefore: (now + selectedV1.maxTimeoutSeconds).toString(),
659
- nonce
660
- };
661
- const signature = await this.signAuthorization(authorization, selectedV1);
662
- const payload = {
663
- authorization,
664
- signature
665
- };
666
- return {
667
- x402Version,
668
- scheme: selectedV1.scheme,
669
- network: selectedV1.network,
670
- payload
671
- };
672
- }
673
- /**
674
- * Sign the EIP-3009 authorization using EIP-712
675
- *
676
- * @param authorization - The authorization to sign
677
- * @param requirements - The payment requirements
678
- * @returns Promise resolving to the signature
679
- */
680
- async signAuthorization(authorization, requirements) {
681
- const chainId = getEvmChainIdV1(requirements.network);
682
- if (!requirements.extra?.name || !requirements.extra?.version) {
683
- throw new Error(
684
- `EIP-712 domain parameters (name, version) are required in payment requirements for asset ${requirements.asset}`
685
- );
686
- }
687
- const { name, version } = requirements.extra;
688
- const domain = {
689
- name,
690
- version,
691
- chainId,
692
- verifyingContract: (0, import_viem13.getAddress)(requirements.asset)
693
- };
694
- const message = {
695
- from: (0, import_viem13.getAddress)(authorization.from),
696
- to: (0, import_viem13.getAddress)(authorization.to),
697
- value: BigInt(authorization.value),
698
- validAfter: BigInt(authorization.validAfter),
699
- validBefore: BigInt(authorization.validBefore),
700
- nonce: authorization.nonce
701
- };
702
- return await this.signer.signTypedData({
703
- domain,
704
- types: authorizationTypes,
705
- primaryType: "TransferWithAuthorization",
706
- message
707
- });
708
- }
709
- };
710
-
711
588
  // src/exact/client/register.ts
712
589
  function registerExactEvmScheme(client, config) {
713
590
  const evmScheme = new ExactEvmScheme(config.signer, config.schemeOptions);
@@ -718,9 +595,6 @@ function registerExactEvmScheme(client, config) {
718
595
  } else {
719
596
  client.register("eip155:*", evmScheme);
720
597
  }
721
- NETWORKS.forEach((network) => {
722
- client.registerV1(network, new ExactEvmSchemeV1(config.signer));
723
- });
724
598
  if (config.policies) {
725
599
  config.policies.forEach((policy) => {
726
600
  client.registerPolicy(policy);