UNPKG

n8n-nodes-wax

Version:

n8n Community Node Package for the WAX Blockchain

104 lines 3.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WaxTransferNft = void 0; const util_1 = require("util"); const eosjs_1 = require("eosjs"); const eosjs_jssig_1 = require("eosjs/dist/eosjs-jssig"); class WaxTransferNft { constructor() { this.description = { hidden: true, displayName: 'WAX Transfer NFT', name: 'waxTransferNft', icon: 'file:wax.svg', group: ['transform'], version: 1, description: 'Transfer an NFT on the WAX blockchain', defaults: { name: 'Transfer NFT', }, credentials: [ { name: 'waxPrivateKeyApi', required: true, } ], inputs: ['main'], outputs: ['main'], properties: [ { displayName: 'To Account', name: 'to', type: 'string', default: '', required: true, }, { displayName: 'Asset IDs (Comma-Separated)', name: 'assetIds', type: 'string', default: '', required: true, }, { displayName: 'Memo', name: 'memo', type: 'string', default: '', }, { displayName: 'API Endpoint', name: 'endpoint', type: 'string', default: 'https://wax.greymass.com', required: true, }, { displayName: 'Contract', name: 'contract', type: 'string', default: 'atomicassets', } ], }; } async execute() { const items = this.getInputData(); const returnData = []; for (let i = 0; i < items.length; i++) { const credentials = await this.getCredentials('waxPrivateKeyApi'); const from = credentials.account; const key = credentials.privateKey; const to = this.getNodeParameter('to', i); const memo = this.getNodeParameter('memo', i); const endpoint = this.getNodeParameter('endpoint', i); const assetIdsString = this.getNodeParameter('assetIds', i); const contract = this.getNodeParameter('contract', i); const assetIds = assetIdsString.split(',').map(id => id.trim()); const signatureProvider = new eosjs_jssig_1.JsSignatureProvider([key]); const rpc = new eosjs_1.JsonRpc(endpoint, { fetch }); const api = new eosjs_1.Api({ rpc, signatureProvider, textDecoder: new util_1.TextDecoder(), textEncoder: new util_1.TextEncoder() }); const actions = [{ account: contract, name: 'transfer', authorization: [{ actor: from, permission: 'active' }], data: { from, to, asset_ids: assetIds, memo, } }]; const result = await api.transact({ actions }, { blocksBehind: 3, expireSeconds: 30, }); returnData.push({ json: { result } }); } return [returnData]; } } exports.WaxTransferNft = WaxTransferNft; //# sourceMappingURL=WaxTransferNft.node.js.map