import { ethers } from 'ethers';
import { Duration } from 'luxon';
import { MIN_EPOCH_LENGTH_SECONDS } from '../constants';
import { Client } from '../index';

const GOERLI_ADDRESS = '0x40B0dA2f307CFCF1ef8d0acE5f04ABf8A60fE88C';
const RPC_URL = 'https://eth-goerli.g.alchemy.com/v2/gudez0Qh0zWC5DIkuXDA6lJ94TBgDE32';
const wallet = new ethers.Wallet('d39bab751c9c7f6da6cd7ca464dcdb931a65cd28b9d84c8e5ab694870fc75ffd');
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const signerWithProvider = wallet.connect(provider);

const client = new Client(GOERLI_ADDRESS, signerWithProvider);

jest.setTimeout(50_000);

describe('Testing Splendid client', () => {
  it('can create collection', async () => {
    const tx = await client.createCollection({
      curatorFee: `10`,
      initialCollectionContent: [
        { creatorId: 0, lastUpdatedEpoch: 0, currentFeeBips: 20000 },
        { creatorId: 1, lastUpdatedEpoch: 0, currentFeeBips: 10000 },
        { creatorId: 2, lastUpdatedEpoch: 1, currentFeeBips: 10000 },
        { creatorId: 3, lastUpdatedEpoch: 2, currentFeeBips: 10000 },
      ],
      epochLength: Duration.fromMillis(MIN_EPOCH_LENGTH_SECONDS * 1000),
    });
    console.log('TX:', tx);
  });
});
