import { getCallData, unsignedExtrinsic } from '../codecs.js';
import { getSlotDuration, getCurrentTimestamp } from './slot-utils.js';

const timestampInherent = async (chain, parentBlock) => {
  const now = await getNextTimestamp(chain, parentBlock);
  const callData = await getCallData(parentBlock, "Timestamp", "set", {
    now
  });
  return callData && unsignedExtrinsic(callData);
};
const getNextTimestamp = async (chain, block) => {
  const [slotDuration, timestamp] = await Promise.all([
    getSlotDuration(chain, block),
    getCurrentTimestamp(chain, block)
  ]);
  return timestamp + slotDuration;
};

export { timestampInherent };
//# sourceMappingURL=timestamp.js.map
