UNPKG

n8n-nodes-wax

Version:

n8n Community Node Package for the WAX Blockchain

82 lines 3.08 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.WaxVerifyAddress = void 0; const axios_1 = __importDefault(require("axios")); class WaxVerifyAddress { constructor() { this.description = { hidden: true, displayName: 'WAX Verify Address', name: 'waxVerifyAddress', icon: 'file:wax.svg', group: ['transform'], version: 1, description: 'Verify an address exists on the WAX blockchain', defaults: { name: 'Verify Address', }, inputs: ['main'], outputs: ['main', 'main'], outputNames: ['valid', 'invalid'], properties: [ { displayName: 'Account Name', name: 'account', type: 'string', default: '', required: true, description: 'WAX account name to verify', }, { displayName: 'API Endpoint', name: 'endpoint', type: 'string', default: 'https://wax.greymass.com', required: true, } ], }; } async execute() { const items = this.getInputData(); const validData = []; const invalidData = []; for (let i = 0; i < items.length; i++) { const account = this.getNodeParameter('account', i); const endpoint = this.getNodeParameter('endpoint', i); try { const result = await axios_1.default.post(`${endpoint}/v1/chain/get_account`, { account_name: account }); validData.push({ json: { account, created: result.data.created, message: 'Account exists on the WAX blockchain' } }); } catch (error) { let message = 'Account does not exist on the WAX blockchain'; if (axios_1.default.isAxiosError(error) && error.response) { if (error.response.status === 404) { message = 'Account not found (404)'; } else if (error.response.data && error.response.data.error) { message = `Account verification failed: ${error.response.data.error.what || error.response.data.error}`; } } invalidData.push({ json: { account, message } }); } } return [validData, invalidData]; } } exports.WaxVerifyAddress = WaxVerifyAddress; //# sourceMappingURL=WaxVerifyAddress.node.js.map