Ask SPONSOR_SIGNER

This commit is contained in:
Shreyaschorge
2025-07-07 21:47:40 +05:30
parent bed12bd303
commit 1d736d823e
3 changed files with 72 additions and 2 deletions

View File

@@ -65,7 +65,7 @@ async function loadEnvLocal() {
let newEnvContent = envContent;
for (const [key, value] of Object.entries(localEnv)) {
if (key !== 'SEED_PHRASE') {
if (key !== 'SEED_PHRASE' && key !== 'SPONSOR_SIGNER') {
// Update process.env
process.env[key] = value;
// Add to .env content if not already there
@@ -87,6 +87,9 @@ async function loadEnvLocal() {
if (localEnv.SEED_PHRASE) {
process.env.SEED_PHRASE = localEnv.SEED_PHRASE;
}
if (localEnv.SPONSOR_SIGNER) {
process.env.SPONSOR_SIGNER = localEnv.SPONSOR_SIGNER;
}
}
} catch (error) {
// Error reading .env.local, which is fine
@@ -370,6 +373,8 @@ async function main() {
[`NEYNAR_API_KEY="${process.env.NEYNAR_API_KEY}"`] : []),
...(neynarClientId ?
[`NEYNAR_CLIENT_ID="${neynarClientId}"`] : []),
...(process.env.SPONSOR_SIGNER ?
[`SPONSOR_SIGNER="${process.env.SPONSOR_SIGNER}"`] : []),
// FID (if it exists in current env)
...(process.env.FID ? [`FID="${process.env.FID}"`] : []),

View File

@@ -115,6 +115,7 @@ async function loadEnvLocal() {
const allowedVars = [
'SEED_PHRASE',
'SPONSOR_SIGNER',
'NEXT_PUBLIC_MINI_APP_NAME',
'NEXT_PUBLIC_MINI_APP_DESCRIPTION',
'NEXT_PUBLIC_MINI_APP_PRIMARY_CATEGORY',
@@ -131,7 +132,7 @@ async function loadEnvLocal() {
for (const [key, value] of Object.entries(localEnv)) {
if (allowedVars.includes(key)) {
process.env[key] = value;
if (key !== 'SEED_PHRASE' && !envContent.includes(`${key}=`)) {
if (key !== 'SEED_PHRASE' && key !== 'SPONSOR_SIGNER' && !envContent.includes(`${key}=`)) {
newEnvContent += `${key}="${value}"\n`;
}
}
@@ -224,6 +225,35 @@ async function checkRequiredEnvVars() {
} else {
console.log(' Seed phrase will only be used for this deployment');
}
// Ask about sponsor signer if SEED_PHRASE is provided
if (!process.env.SPONSOR_SIGNER) {
const { sponsorSigner } = await inquirer.prompt([
{
type: 'confirm',
name: 'sponsorSigner',
message:
'Do you want to sponsor the signer? (This will be used in Sign In With Neynar)\n' +
'Note: If you choose to sponsor the signer, Neynar will sponsor it for you and you will be charged in CUs.',
default: false,
},
]);
process.env.SPONSOR_SIGNER = sponsorSigner.toString();
if (storeSeedPhrase) {
fs.appendFileSync('.env.local', `\nSPONSOR_SIGNER="${sponsorSigner}"`);
console.log('✅ Sponsor signer preference stored in .env.local');
}
}
}
}
// Load SPONSOR_SIGNER from .env.local if SEED_PHRASE exists but SPONSOR_SIGNER doesn't
if (process.env.SEED_PHRASE && !process.env.SPONSOR_SIGNER && fs.existsSync('.env.local')) {
const localEnv = dotenv.parse(fs.readFileSync('.env.local'));
if (localEnv.SPONSOR_SIGNER) {
process.env.SPONSOR_SIGNER = localEnv.SPONSOR_SIGNER;
}
}
}
@@ -585,6 +615,7 @@ async function deployToVercel(useGitHub = false) {
...(process.env.NEYNAR_API_KEY && { NEYNAR_API_KEY: process.env.NEYNAR_API_KEY }),
...(process.env.NEYNAR_CLIENT_ID && { NEYNAR_CLIENT_ID: process.env.NEYNAR_CLIENT_ID }),
...(process.env.SPONSOR_SIGNER && { SPONSOR_SIGNER: process.env.SPONSOR_SIGNER }),
...(miniAppMetadata && { MINI_APP_METADATA: miniAppMetadata }),
...Object.fromEntries(