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.

37 lines (36 loc) 1.54 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = transferAllAxies; const axie_1 = require("../lib/axie"); const batch_transfer_1 = __importDefault(require("../lib/batch-transfer")); async function transferAllAxies(taskArgs, hre) { if (hre.network.name != 'ronin') { throw new Error('Network not supported'); } try { const accounts = await hre.ethers.getSigners(); const signer = accounts[0]; const address = signer.address.toLowerCase(); let axies = taskArgs.axies ? taskArgs.axies.split(',').map((axie) => { // remove whitespaces and # and convert to int return axie.replace(/\s/g, '').replace('#', ''); }) : []; // if no axies provided, get all axies from the account if (!axies || axies.length == 0) { // get all axies ids from the account const axieIds = await (0, axie_1.getAxieIdsFromAccount)(address, hre.ethers.provider); axies = axieIds; } // wait for tx to be mined and get receipt const receipt = await (0, batch_transfer_1.default)(signer, taskArgs.address.replace('ronin:', '0x').toLowerCase(), axies); console.log('Receipt:', receipt.transactionHash); return receipt.transactionHash; } catch (error) { console.error(error); } return false; }