// The host adapter must return a completed receipt only after its rewarded-ad // success callback. No ad SDK or network service is bundled with this prototype. export async function requestReward(game, provider, isCurrent = () => true) { if (game.rewardPending || game.won || game.deadlocked || !isCurrent()) return { status: 'unavailable' }; game.rewardPending = true; try { const receipt = await provider({ levelId: game.level.id, steps: game.level.reward.steps }); if (!isCurrent()) return { status: 'stale' }; return { status: game.grantReward(receipt) ? 'granted' : 'cancelled' }; } catch { return { status: 'failed' }; } finally { game.rewardPending = false; } }