diff --git a/packages/lib/bankrun-utils/src/bankrun.ts b/packages/lib/bankrun-utils/src/bankrun.ts index e3683e4..eb006b7 100644 --- a/packages/lib/bankrun-utils/src/bankrun.ts +++ b/packages/lib/bankrun-utils/src/bankrun.ts @@ -10,15 +10,16 @@ export async function assertNotExist( } // https://github.com/solana-labs/solana/blob/v1.17.7/sdk/program/src/epoch_schedule.rs#L29C1-L29C45 -export const MINIMUM_SLOTS_PER_EPOCH = 32 +export const MINIMUM_SLOTS_PER_EPOCH = BigInt(32) // https://github.com/solana-labs/solana/blob/v1.17.7/sdk/program/src/epoch_schedule.rs#L167 -export function warpToEpoch(provider: BankrunProvider, epoch: number) { +export function warpToEpoch(provider: BankrunProvider, epoch: number | bigint) { const epochBigInt = BigInt(epoch) const { slotsPerEpoch, firstNormalEpoch, firstNormalSlot } = provider.context.genesisConfig.epochSchedule let warpToSlot: bigint if (epochBigInt <= firstNormalEpoch) { - warpToSlot = BigInt((2 ** epoch - 1) * MINIMUM_SLOTS_PER_EPOCH) + warpToSlot = + (BigInt(2) ** epochBigInt - BigInt(1)) * MINIMUM_SLOTS_PER_EPOCH } else { warpToSlot = (epochBigInt - firstNormalEpoch) * slotsPerEpoch + firstNormalSlot @@ -26,20 +27,32 @@ export function warpToEpoch(provider: BankrunProvider, epoch: number) { provider.context.warpToSlot(warpToSlot) } -export async function warpToNextEpoch(provider: BankrunProvider) { - await warpOffsetEpoch(provider, 1) +export async function currentEpoch(provider: BankrunProvider): Promise { + return (await provider.context.banksClient.getClock()).epoch } export async function warpOffsetEpoch( provider: BankrunProvider, - plusEpochs: number + plusEpochs: number | bigint ) { - const nextEpoch = (await currentEpoch(provider)) + plusEpochs + const nextEpoch = (await currentEpoch(provider)) + BigInt(plusEpochs) warpToEpoch(provider, nextEpoch) } -export async function currentEpoch(provider: BankrunProvider): Promise { - return Number((await provider.context.banksClient.getClock()).epoch) +export async function warpToNextEpoch(provider: BankrunProvider) { + await warpOffsetEpoch(provider, 1) +} + +export async function currentSlot(provider: BankrunProvider): Promise { + return (await provider.context.banksClient.getClock()).slot +} + +export async function warpOffsetSlot( + provider: BankrunProvider, + plusSlots: number | bigint +) { + const nextSlot = (await currentSlot(provider)) + BigInt(plusSlots) + warpOffsetSlot(provider, nextSlot) } export async function warpToNextSlot(provider: BankrunProvider) { diff --git a/packages/lib/web3js-common/src/tx.ts b/packages/lib/web3js-common/src/tx.ts index 38f86d6..f737dcb 100644 --- a/packages/lib/web3js-common/src/tx.ts +++ b/packages/lib/web3js-common/src/tx.ts @@ -233,7 +233,7 @@ export async function executeTx({ connection, transaction, sendOpts, - logger, + logger ) // Checking if executed txResponse = await confirmTransaction(