import { assert } from '@hyperlane-xyz/utils';
import { address as parseAddress } from '@solana/kit';
import { SvmMailboxArtifactManager } from '../core/mailbox-artifact-manager.js';
import { SvmValidatorAnnounceArtifactManager } from '../core/validator-announce-artifact-manager.js';
import { SvmHookArtifactManager } from '../hook/hook-artifact-manager.js';
import { SvmIsmArtifactManager } from '../ism/ism-artifact-manager.js';
import { createRpc } from '../rpc.js';
import { SvmWarpArtifactManager } from '../warp/warp-artifact-manager.js';
import { SvmProvider } from './provider.js';
import { SvmSigner } from './signer.js';
export class SvmProtocolProvider {
    createProvider(chainMetadata) {
        const rpcUrls = this.getRpcUrls(chainMetadata);
        return SvmProvider.connect(rpcUrls, chainMetadata.chainId);
    }
    async createSigner(chainMetadata, config) {
        const rpcUrls = this.getRpcUrls(chainMetadata);
        return SvmSigner.connectWithSigner(rpcUrls, config.privateKey);
    }
    createSubmitter(_chainMetadata, _config) {
        throw new Error('Transaction submitter not yet implemented for Sealevel');
    }
    createIsmArtifactManager(chainMetadata) {
        const rpc = createRpc(this.getRpcUrls(chainMetadata)[0]);
        return new SvmIsmArtifactManager(rpc);
    }
    createHookArtifactManager(chainMetadata, context) {
        const rpc = createRpc(this.getRpcUrls(chainMetadata)[0]);
        const mailbox = context?.mailbox
            ? parseAddress(context.mailbox)
            : undefined;
        return new SvmHookArtifactManager(rpc, mailbox);
    }
    createWarpArtifactManager(chainMetadata, _context) {
        const rpc = createRpc(this.getRpcUrls(chainMetadata)[0]);
        return new SvmWarpArtifactManager(rpc);
    }
    createMailboxArtifactManager(chainMetadata) {
        const rpc = createRpc(this.getRpcUrls(chainMetadata)[0]);
        return new SvmMailboxArtifactManager(rpc, chainMetadata.domainId);
    }
    createValidatorAnnounceArtifactManager(chainMetadata) {
        const rpc = createRpc(this.getRpcUrls(chainMetadata)[0]);
        return new SvmValidatorAnnounceArtifactManager(rpc, chainMetadata.domainId);
    }
    getMinGas() {
        return {
            CORE_DEPLOY_GAS: 10000000000n,
            // ~2.6 SOL covers program account rent + token PDA rent + ATA payer funding
            WARP_DEPLOY_GAS: 2600000000n,
            TEST_SEND_GAS: 0n,
            AVS_GAS: 0n,
            ISM_DEPLOY_GAS: 0n,
        };
    }
    getRpcUrls(chainMetadata) {
        assert(chainMetadata.rpcUrls && chainMetadata.rpcUrls.length > 0, 'At least one RPC URL is required');
        return chainMetadata.rpcUrls.map((r) => r.http);
    }
}
//# sourceMappingURL=protocol.js.map