"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Client = void 0;
const tslib_1 = require("tslib");
const ethers_1 = require("ethers");
const counterJson = tslib_1.__importStar(require("../out/Counter.sol/Counter.json"));
class Client {
    constructor(rpcUrl, splendidContractAddress, signer) {
        if (!rpcUrl) {
            throw new Error('RPC URL passed to client must be defined');
        }
        if (!splendidContractAddress) {
            throw new Error('RPC URL passed to client must be defined');
        }
        this.provider = new ethers_1.ethers.providers.JsonRpcProvider(rpcUrl);
        if (signer) {
            const signerWithProvider = signer.connect(this.provider);
            this.splendid = new ethers_1.ethers.Contract(splendidContractAddress, counterJson.abi, signerWithProvider);
        }
        else {
            this.splendid = new ethers_1.ethers.Contract(splendidContractAddress, counterJson.abi, this.provider);
        }
        this.splendidInterface = new ethers_1.ethers.utils.Interface(counterJson.abi);
    }
    async createCollection() {
        return this.splendid.createCollection();
    }
    async parseEventLog(data, topics) {
        return this.splendidInterface.parseLog({
            topics,
            data,
        });
    }
}
exports.Client = Client;
//# sourceMappingURL=splendidClient.js.map