import { AptosWalletAdapterProvider } from "@aptos-labs/wallet-adapter-react";
import { PropsWithChildren } from "react";

// Movement Network Configuration
const MOVEMENT_NETWORK = {
  testnet: {
    name: "Movement Testnet",
    chainId: "250",
    url: "https://full.testnet.movementinfra.xyz/v1",
  },
  mainnet: {
    name: "Movement Mainnet", 
    chainId: "126",
    url: "https://full.mainnet.movementinfra.xyz/v1",
  },
};

// Default to testnet
const currentNetwork = MOVEMENT_NETWORK.testnet;

export function WalletProvider({ children }: PropsWithChildren) {
  return (
    <AptosWalletAdapterProvider
      autoConnect={true}
      dappConfig={{
        network: "testnet",
        aptosApiKey: import.meta.env.VITE_APTOS_API_KEY,
        aptosConnect: {
          dappId: "movement-dapp",
        },
      }}
      onError={(error) => {
        console.error("Wallet error:", error);
      }}
    >
      {children}
    </AptosWalletAdapterProvider>
  );
}

export { currentNetwork };

