import { ENVIRONMENT } from "./core/types/dimo.js";
import { createPublicClient, createWalletClient, http, } from "viem";
import { CHAIN_ABI_MAPPING, ENV_MAPPING, ENV_NETWORK_MAPPING } from "./core/constants/mappings.js";
import { sendDIMOTokensFromAccount } from "./core/actions/sendDIMOTokens.js";
import { polygon } from "viem/chains";
import { transferVehicleAndAftermarketDeviceIDsFromAccount } from "./core/actions/transferVehicleAndADs.js";
import { safeTransferVehicleID } from "./core/actions/safeTransferVehicles.js";
import { mintVehicleWithDeviceDefinitionFromAccount } from "./core/actions/mintVehicleWithDeviceDefinition.js";
export class AccountSigner {
    constructor(config) {
        var _a, _b, _c;
        this.config = config;
        this.chain = (_b = ENV_NETWORK_MAPPING.get((_a = ENV_MAPPING.get(this.config.environment)) !== null && _a !== void 0 ? _a : ENVIRONMENT.PROD)) !== null && _b !== void 0 ? _b : polygon;
        this.contractMapping = CHAIN_ABI_MAPPING[(_c = ENV_MAPPING.get(this.config.environment)) !== null && _c !== void 0 ? _c : ENVIRONMENT.PROD].contracts;
        this.publicClient = createPublicClient({
            transport: http(this.config.rpcUrl),
            chain: this.chain,
        });
        this.account = config.account;
        this.address = config.account.address;
        this.walletClient = createWalletClient({
            account: this.account,
            chain: this.chain,
            transport: http(this.config.rpcUrl),
        });
    }
    async sendDIMOTokens(args) {
        const txResult = sendDIMOTokensFromAccount(args, this.walletClient, this.publicClient, this.config.environment);
        return txResult;
    }
    async transferVehicleAndAftermarketDevices(args) {
        const txResult = transferVehicleAndAftermarketDeviceIDsFromAccount(args, this.walletClient, this.publicClient, this.config.environment);
        return txResult;
    }
    async transferVehicleID(args) {
        const txResult = safeTransferVehicleID(args, this.walletClient, this.publicClient, this.config.environment);
        return txResult;
    }
    async mintVehicleWithDeviceDefinition(args) {
        const txResult = mintVehicleWithDeviceDefinitionFromAccount(args, this.walletClient, this.publicClient, this.config.environment);
        return txResult;
    }
}
//# sourceMappingURL=AccountSigner.js.map