fix: vault как ATA + фандинг беттора; E2E на localnet ok
This commit is contained in:
+10
-3
@@ -94,7 +94,7 @@ async function main(): Promise<void> {
|
||||
// mint ещё не создан (плейсхолдер) — дефолт из ТЗ контракта
|
||||
}
|
||||
|
||||
const global = await readGlobal(program, program.programId);
|
||||
const global = await readGlobal(program, program.programId, cfg.tokenMint);
|
||||
if (!global) {
|
||||
if (!process.argv.includes("--init")) {
|
||||
throw new Error(
|
||||
@@ -127,7 +127,14 @@ async function main(): Promise<void> {
|
||||
const req = nextBetRequest(cfg.minAmount, cfg.maxAmount);
|
||||
await fundBettor(connection, req.bettor.publicKey);
|
||||
// Беттору нужен токен-аккаунт (ATA) — без него create_bet не пройдёт.
|
||||
await ensureBettorTokenAccount(connection, admin, cfg.tokenMint, req.bettor.publicKey);
|
||||
// На localnet (allowAirdrop) после создания ATA наливает фантики (аналог SOL-airdrop).
|
||||
await ensureBettorTokenAccount(
|
||||
connection,
|
||||
admin,
|
||||
cfg.tokenMint,
|
||||
req.bettor.publicKey,
|
||||
cfg.allowAirdrop ? BigInt(cfg.startBalance) : undefined
|
||||
);
|
||||
|
||||
const entryPrice = await getPrice();
|
||||
await createBet(program, cfg.tokenMint, req.bettor, {
|
||||
@@ -141,7 +148,7 @@ async function main(): Promise<void> {
|
||||
);
|
||||
await sleep((cfg.expirySeconds + 1) * 1000);
|
||||
|
||||
const g0 = await readGlobal(program, program.programId);
|
||||
const g0 = await readGlobal(program, program.programId, cfg.tokenMint);
|
||||
const id = g0!.counter.subn(1);
|
||||
await settleBet(program, id, entryPrice, admin, req.bettor.publicKey, cfg.tokenMint);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user