Conversation
- Add consumable.ts module with GraphQL queries and utility functions - Implement create/buy/cancel operations for consumables - Add CLI commands for consumable marketplace operations - Add approveConsumableMarketplace function - Export all consumable functions in index.ts - Update package.json description and keywords - Support for Cocochoco, Premium Cocochoco, and all ERC1155 consumables Similar to materials implementation but for consumable token type. All operations work through the same ERC1155 contract.
- Add create-order-consumables.test.ts - Add settle-order-consumables.test.ts - Add cancel-order-consumables.test.ts - Add consumable-floor-price.test.ts - Add examples/consumable-order.js example - Add test scripts to package.json for consumables Tests follow the same pattern as materials tests. Example demonstrates creating consumable orders with Cocochoco (ID: 1).
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive ERC1155 token support for "Consumables" to the axie-tools library and CLI, expanding marketplace capabilities beyond the existing Axie and Material support. The implementation mirrors the existing Materials infrastructure, as both Consumables and Materials use the same ERC1155 contract on the Ronin network, differentiated only by the tokenType parameter in GraphQL API calls.
Key Changes:
- Added consumable marketplace operations (create, buy/settle, cancel orders) with WETH payment support
- Integrated consumable functionality into the CLI with dedicated menu options and floor price calculations
- Implemented floor price calculation with quantity-aware averaging across multiple orders
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
lib/consumable.ts |
New module providing consumable-specific GraphQL queries, type definitions, and utility functions (validateConsumableToken, getConsumableFloorPrice, checkConsumableOwnership, encodeConsumableOrderData) following the same patterns as material.ts |
lib/contracts.ts |
Added getConsumableContract() function that reuses the MATERIAL_ERC_1155_PROXY contract, as consumables share the same ERC1155 contract with materials |
lib/marketplace/create-consumable-order.ts |
Implements consumable order creation with ownership verification, quantity validation, EIP-712 signature generation, and API integration |
lib/marketplace/settle-consumable-order.ts |
Implements consumable order settlement/purchase with order filtering, WETH balance/allowance checks, and marketplace gateway interaction |
lib/marketplace/cancel-consumable-order.ts |
Implements consumable order cancellation through the ERC1155 exchange contract via marketplace gateway |
lib/marketplace/approve.ts |
Added approveConsumableMarketplace() function for setting ERC1155 operator approval on the marketplace contract |
index.ts |
Exports new consumable functions (validateConsumableToken, getConsumableFloorPrice, createConsumableMarketplaceOrder, buyConsumableOrder, cancelConsumableOrder, approveConsumableMarketplace) |
cli.ts |
Added CLI menu options for consumable operations (approve, settle, create, cancel) with getConsumableId() helper and extended getPrice() to support consumable floor prices |
package.json |
Updated description to mention Consumables, added test scripts for consumable operations, and added keywords (erc1155, consumables, materials) |
tests/create-order-consumables.test.ts |
Test suite for consumable order creation with validation and error handling |
tests/settle-order-consumables.test.ts |
Test suite for consumable order settlement with WETH balance checks and transaction verification |
tests/cancel-order-consumables.test.ts |
Test suite for consumable order cancellation |
tests/consumable-floor-price.test.ts |
Test suite for floor price calculations with various quantity parameters |
examples/consumable-order.js |
Example script demonstrating consumable order creation with floor price lookup and marketplace approval |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| buyConsumableOrder, | ||
| cancelConsumableOrder, |
There was a problem hiding this comment.
Unused imports buyConsumableOrder, cancelConsumableOrder.
| buyConsumableOrder, | |
| cancelConsumableOrder, |
| gasPrice: parseUnits("26", "gwei"), | ||
| }, | ||
| ); | ||
| const receipt = await tx.wait(); |
There was a problem hiding this comment.
Unused variable receipt.
| consumableId, | ||
| quantity: inputQuantity, | ||
| unitPrice, | ||
| endedUnitPrice, |
There was a problem hiding this comment.
Unused variable endedUnitPrice.
| endedUnitPrice, |
| unitPrice, | ||
| endedUnitPrice, | ||
| startedAt, | ||
| endedAt, |
There was a problem hiding this comment.
Unused variable endedAt.
| endedAt, |
| @@ -0,0 +1,64 @@ | |||
| import { test, expect } from "bun:test"; | |||
| import { buyConsumableOrder } from "../lib/marketplace/settle-consumable-order"; | |||
| import { Wallet, Contract } from "ethers"; | |||
There was a problem hiding this comment.
Unused import Contract.
| import { Wallet, Contract } from "ethers"; | |
| import { Wallet } from "ethers"; |
No description provided.