Sponsor fallback never names a position the contract does not have yet: on a fresh contract the first member joins with sponsor 0 and becomes #1 (Marty's activate(1) reverted 'Unknown sponsor')
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,7 @@ async function ensureOnChain(acct, depth) {
|
||||
if (sp && sp.address) sponsorId = await ensureOnChain(sp, depth + 1);
|
||||
}
|
||||
if (!sponsorId) sponsorId = Number((X.siteConfig && X.siteConfig().defaultSponsorId) || 1) || 1;
|
||||
try { if (sponsorId > await X.chain.memberCount()) sponsorId = 0; } catch (e) {} // first member on a fresh contract: no catch position exists yet
|
||||
try {
|
||||
const w = signer(); const ctr = new ethers.Contract(X.chain.getConfig().contract, ABI, w);
|
||||
const tx = await ctr.activateFor(acct.address, sponsorId, { gasLimit: 160000n });
|
||||
|
||||
Reference in New Issue
Block a user