Update CLI cashout module to allow cashout to a specific email, and show actual unlocked balance
This commit is contained in:
@@ -404,7 +404,8 @@ export default class Client {
|
||||
async cashout(catchall) {
|
||||
if (!catchall) throw new Error('No catchall was provided.');
|
||||
|
||||
this.email = `${faker.internet.userName()}@${catchall}`;
|
||||
if (catchall.includes('@')) this.email = catchall;
|
||||
else this.email = `${faker.internet.userName()}@${catchall}`;
|
||||
|
||||
const { body } = await request.promise('https://api-quiz.hype.space/users/me/payouts', {
|
||||
method: 'POST',
|
||||
|
||||
@@ -33,7 +33,7 @@ export default async () => {
|
||||
|
||||
clients.push(client);
|
||||
|
||||
const { balance, eligibleForPayout } = await client.getBalance();
|
||||
const { available: balance, eligibleForPayout } = await client.getBalance();
|
||||
const { lives, erase1s } = await client.getUserData();
|
||||
|
||||
livesCount += lives;
|
||||
@@ -75,14 +75,24 @@ export default async () => {
|
||||
if (!num) return console.log('Canceling...');
|
||||
if (num > accounts.length) return console.log(`Only ${accounts.length} account(s) are able to cashout.`.red);
|
||||
|
||||
const { catchall } = await prompt({
|
||||
type: 'input',
|
||||
name: 'catchall',
|
||||
message: 'What catchall would you like to use?',
|
||||
});
|
||||
let email;
|
||||
|
||||
if (num === 1) {
|
||||
({ email } = await prompt({
|
||||
type: 'input',
|
||||
name: 'email',
|
||||
message: 'What email would you like to cashout to?',
|
||||
}));
|
||||
} else {
|
||||
({ catchall: email } = await prompt({
|
||||
type: 'input',
|
||||
name: 'catchall',
|
||||
message: 'What catchall would you like to use?',
|
||||
}));
|
||||
}
|
||||
|
||||
for (let i = 0; i < num; i += 1) {
|
||||
await accounts[i].cashout(catchall);
|
||||
await accounts[i].cashout(email);
|
||||
}
|
||||
|
||||
console.log(`Finished cashing out ${num} account(s)!`.green);
|
||||
|
||||
Reference in New Issue
Block a user