Skip to content

Add ERC1155 token support to CLI and library#11

Open
alexx855 wants to merge 2 commits intomainfrom
claude/add-erc1155-token-support-011CUqFZzCp1WQe4LcAMFDFh
Open

Add ERC1155 token support to CLI and library#11
alexx855 wants to merge 2 commits intomainfrom
claude/add-erc1155-token-support-011CUqFZzCp1WQe4LcAMFDFh

Conversation

@alexx855
Copy link
Owner

@alexx855 alexx855 commented Jan 3, 2026

No description provided.

- 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).
Copilot AI review requested due to automatic review settings January 3, 2026 13:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +5 to +6
buyConsumableOrder,
cancelConsumableOrder,
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports buyConsumableOrder, cancelConsumableOrder.

Suggested change
buyConsumableOrder,
cancelConsumableOrder,

Copilot uses AI. Check for mistakes.
gasPrice: parseUnits("26", "gwei"),
},
);
const receipt = await tx.wait();
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable receipt.

Copilot uses AI. Check for mistakes.
consumableId,
quantity: inputQuantity,
unitPrice,
endedUnitPrice,
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable endedUnitPrice.

Suggested change
endedUnitPrice,

Copilot uses AI. Check for mistakes.
unitPrice,
endedUnitPrice,
startedAt,
endedAt,
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable endedAt.

Suggested change
endedAt,

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,64 @@
import { test, expect } from "bun:test";
import { buyConsumableOrder } from "../lib/marketplace/settle-consumable-order";
import { Wallet, Contract } from "ethers";
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import Contract.

Suggested change
import { Wallet, Contract } from "ethers";
import { Wallet } from "ethers";

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants