use fuels::{
    accounts::{
        signers::private_key::PrivateKeySigner,
        wallet::{
            Unlocked,
            Wallet,
        },
    },
    macros::abigen,
    programs::contract::Contract,
    types::{
        ContractId,
        Salt,
        transaction::TxPolicies,
    },
};

abigen!(Contract(
    name = "LargeContract",
    abi = "artifacts/test_artifacts/large_contract-abi.json"
));
pub const LARGE_CONTRACT_BYTECODE: &[u8] =
    include_bytes!("../artifacts/test_artifacts/large_contract.bin");

pub async fn setup_large_contract(
    wallet: &Wallet<Unlocked<PrivateKeySigner>>,
) -> (
    LargeContract<Wallet<Unlocked<PrivateKeySigner>>>,
    ContractId,
) {
    // 375 KB — far over the realistic per-tx size limit, so deploy it the
    // way any large contract is deployed on a real network: as a loader
    // contract whose data blobs are uploaded first.
    let id = Contract::regular(LARGE_CONTRACT_BYTECODE.to_vec(), Salt::default(), vec![])
        .convert_to_loader(10_000)
        .unwrap()
        .deploy(wallet, TxPolicies::default())
        .await
        .unwrap()
        .contract_id;

    let instance = LargeContract::new(id, wallet.clone());

    (instance, id)
}
