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.

60 lines (59 loc) 2.4 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = buyAxie; const buy_order_1 = __importDefault(require("../lib/marketplace/buy-order")); const dotenv = __importStar(require("dotenv")); // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import dotenv.config(); async function buyAxie(taskArgs, hre) { if (hre.network.name != 'ronin') { throw new Error('Network not supported'); } try { const axieId = parseInt(taskArgs.axie, 10); if (isNaN(axieId)) { console.log('Invalid Axie ID provided'); return false; } // Get signer account const accounts = await hre.ethers.getSigners(); const signer = accounts[0]; // wait for the transaction to be mined const receipt = await (0, buy_order_1.default)(axieId, signer, process.env.MARKETPLACE_ACCESS_TOKEN, process.env.SKIMAVIS_DAPP_KEY); if (!receipt) { console.log('Error buying axie'); return false; } console.log('Receipt:', receipt.transactionHash); return receipt.transactionHash; } catch (error) { console.error(error); } return false; }