import { address } from '@solana/kit';
import { HYPERLANE_SVM_PROGRAM_BYTES } from '../hyperlane/program-bytes.js';
import { SvmCollateralTokenReader, SvmCollateralTokenWriter, } from './collateral-token.js';
import { SvmCrossCollateralTokenReader, SvmCrossCollateralTokenWriter, } from './cross-collateral-token.js';
import { SvmNativeTokenReader, SvmNativeTokenWriter } from './native-token.js';
import { SvmSyntheticTokenReader, SvmSyntheticTokenWriter, } from './synthetic-token.js';
import { detectWarpTokenType } from './warp-query.js';
export class SvmWarpArtifactManager {
    rpc;
    ataPayerFundingAmount;
    constructor(rpc, ataPayerFundingAmount = 100000000n) {
        this.rpc = rpc;
        this.ataPayerFundingAmount = ataPayerFundingAmount;
    }
    async readWarpToken(tokenAddress) {
        const tokenType = await detectWarpTokenType(this.rpc, address(tokenAddress));
        const reader = this.createReader(tokenType);
        return reader.read(tokenAddress);
    }
    createReader(type) {
        const readers = {
            native: () => new SvmNativeTokenReader(this.rpc),
            synthetic: () => new SvmSyntheticTokenReader(this.rpc),
            collateral: () => new SvmCollateralTokenReader(this.rpc),
            crossCollateral: () => new SvmCrossCollateralTokenReader(this.rpc),
        };
        return readers[type]();
    }
    createWriter(type, signer) {
        const writers = {
            native: () => new SvmNativeTokenWriter({
                program: { programBytes: HYPERLANE_SVM_PROGRAM_BYTES.tokenNative },
                ataPayerFundingAmount: this.ataPayerFundingAmount,
            }, this.rpc, signer),
            synthetic: () => new SvmSyntheticTokenWriter({
                program: {
                    programBytes: HYPERLANE_SVM_PROGRAM_BYTES.tokenSynthetic,
                },
                ataPayerFundingAmount: this.ataPayerFundingAmount,
            }, this.rpc, signer),
            collateral: () => new SvmCollateralTokenWriter({
                program: {
                    programBytes: HYPERLANE_SVM_PROGRAM_BYTES.tokenCollateral,
                },
                ataPayerFundingAmount: this.ataPayerFundingAmount,
            }, this.rpc, signer),
            crossCollateral: () => new SvmCrossCollateralTokenWriter({
                program: {
                    programBytes: HYPERLANE_SVM_PROGRAM_BYTES.tokenCrossCollateral,
                },
                ataPayerFundingAmount: this.ataPayerFundingAmount,
            }, this.rpc, signer),
        };
        return writers[type]();
    }
    supportsHookUpdates() {
        return true;
    }
}
//# sourceMappingURL=warp-artifact-manager.js.map