UNPKG

axie-ronin-ethers-js-tools

Version:

A set of functions that make it easier for developers to interact with their Axies on the Ronin network and the maketplace.

40 lines (39 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAxieId = exports.askToContinue = void 0; exports.apiRequest = apiRequest; const prompts_1 = require("@inquirer/prompts"); async function apiRequest(url, body = null, headers = {}, method = 'POST') { const response = await fetch(url, { method, headers: { 'Content-Type': 'application/json', ...headers }, ...(method === 'GET' ? {} : { body }) }); const res = await response.json(); return res; } const askToContinue = async () => { const continueUsing = await (0, prompts_1.confirm)({ message: '🔄 Would you like to do something else?' }); if (!continueUsing) { console.log('👋 Goodbye!'); process.exit(0); } }; exports.askToContinue = askToContinue; const getAxieId = async () => { const axieId = await (0, prompts_1.number)({ message: '🆔 Enter Axie ID:', validate: (value) => value !== undefined && !isNaN(value) }); if (axieId === undefined) { console.log('❌ Invalid Axie ID!'); return null; } return axieId; }; exports.getAxieId = getAxieId;