const crypto = require('crypto');

class MockChainAdapter {
  constructor() {
    this.networkId = 'aisfor-mainnet-mock';
    this.height = 100000;
  }

  async submit(payload) {
    this.height += 1;

    const source = JSON.stringify({
      networkId: this.networkId,
      height: this.height,
      payload,
      timestamp: Date.now()
    });

    return {
      networkId: this.networkId,
      status: 'CONFIRMED_MOCK',
      txHash: `0x${crypto.createHash('sha256').update(source).digest('hex')}`,
      blockHeight: this.height,
      confirmedAt: new Date().toISOString()
    };
  }

  getStatus() {
    return {
      networkId: this.networkId,
      mode: 'mock',
      currentBlockHeight: this.height
    };
  }
}

module.exports = new MockChainAdapter();
