Fix carry.ensureOnChain: sponsorId/txHash/lastErr were declared inside the try but read after the finally, so every engine activation since a5c2c38 (2026-10-22) threw 'sponsorId is not defined' after the activateFor tx mined: member number not saved, notice not sent, in-flight flag stuck, and a buy whose sponsor needed activation fell back to #1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -147,8 +147,8 @@ async function ensureOnChain(acct, depth, why) {
|
||||
try { const id = await X.chain.memberIdByAccount(acct.address); if (id) { if (Number(acct.memberId) !== Number(id)) await X.accounts.setMemberId(acct.email, id).catch(() => {}); return id; } } catch (e) {}
|
||||
if (!engineReady() || depth > 25) return 0;
|
||||
const me = norm(acct.email); inflight.add(me); let id = 0; // binding from here: the sponsor read below is the one the contract gets
|
||||
let sponsorId = 0, txHash = null, lastErr = null; // read after the finally below, so declared out here (inside the try they were not defined there, 2026-10-22..27)
|
||||
try {
|
||||
let sponsorId = 0;
|
||||
if (acct.sponsorRef) {
|
||||
let sp = await X.accounts.byCode(acct.sponsorRef); if (!sp) sp = await X.accounts.byUsername(acct.sponsorRef);
|
||||
if (sp && sp.address) sponsorId = await ensureOnChain(sp, depth + 1);
|
||||
@@ -157,7 +157,6 @@ async function ensureOnChain(acct, depth, why) {
|
||||
try { if (sponsorId > await X.chain.memberCount()) sponsorId = 0; } catch (e) {} // first member on a fresh contract: no catch position exists yet
|
||||
// send with provider rotation; after ANY error re-read the chain first (2026-10-15 seed: six activations
|
||||
// mined while a 403 on the follow-up read logged them as failures and skipped their notices)
|
||||
let txHash = null, lastErr = null;
|
||||
for (let attempt = 0; attempt < 3 && !id; attempt++) {
|
||||
try {
|
||||
const w = signer(attempt); const ctr = new ethers.Contract(X.chain.getConfig().contract, ABI, w);
|
||||
|
||||
Reference in New Issue
Block a user