GithubHelp home page GithubHelp logo

nipz / yulrc1155 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jerobar/yulrc1155

1.0 0.0 0.0 707 KB

An implementation of the ERC1155 token standard written entirely in Yul.

JavaScript 58.96% Solidity 3.97% Yul 37.07%

yulrc1155's Introduction

YULRC1155

A basic implementation of the ERC1155 token standard written entirely in Yul!

Yul contract: contracts/YULRC1155.yul.

Testing:

npx hardhat test test/YULRC1155.test.js

Note that the test will automatically compile the contract bytecode if it does not already exist in contracts/YULRC1155.bytecode.json.

  YULRC1155
    uri
      ✔ sets the initial uri for all token types (7866ms)
    balanceOf
      ✔ reverts when queried about the zero address
      ✔ returns zero for addresses with no tokens
      ✔ returns the amount of tokens owned by the given addresses (55ms)
    balanceOfBatch
      ✔ reverts when input arrays don't match up (51ms)
      ✔ reverts when one of the addresses is the zero address
      ✔ returns zeros for each account with no tokens
      ✔ returns amounts owned by each account in order passed (98ms)
    setApprovalForAll/isApprovedForAll
      ✔ reverts if attempting to approve self as an operator
      ✔ sets approval status which can be queried via isApprovedForAll (52ms)
      ✔ can unset approval for an operator (61ms)
      ✔ emits an ApprovalForAll log
    safeTransferFrom
      ✔ reverts when transferring more than balance (47ms)
      ✔ reverts when transferring to zero address (45ms)
      ✔ reverts when operator is not approved by multiTokenHolder
      ✔ reverts when receiver contract returns unexpected value (79ms)
      ✔ reverts when receiver contract reverts (74ms)
      ✔ reverts when receiver does not implement the required function (65ms)
      ✔ debits transferred balance from sender (46ms)
      ✔ credits transferred balance to receiver (47ms)
      ✔ preserves existing balances which are not transferred by multiTokenHolder (67ms)
      ✔ succeeds when operator is approved by multiTokenHolder (87ms)
      ✔ preserves operator's balances not involved in the transfer (89ms)
      ✔ succeeds when calling onERC1155Received without data (69ms)
      ✔ succeeds when calling onERC1155Received with data (82ms)
      ✔ emits a TransferSingle log (47ms)
    safeBatchTransferFrom
      ✔ reverts when transferring amount more than any of balances (52ms)
      ✔ reverts when ids array length doesn't match amounts array length (50ms)
      ✔ reverts when transferring to zero address (42ms)
      ✔ reverts when operator is not approved by multiTokenHolder (42ms)
      ✔ reverts when receiver contract returns unexpected value (78ms)
      ✔ reverts when receiver contract reverts (82ms)
      ✔ reverts when receiver does not implement the required function (78ms)
      ✔ debits transferred balances from sender (75ms)
      ✔ credits transferred balances to receiver (77ms)
      ✔ succeeds when operator is approved by multiTokenHolder (83ms)
      ✔ preserves operator's balances not involved in the transfer (112ms)
      ✔ succeeds when calling onERC1155Received without data (103ms)
      ✔ succeeds when calling onERC1155Received with data (100ms)
      ✔ succeeds when calling a receiver contract that reverts only on single transfers (85ms)
      ✔ emits a TransferBatch log (81ms)
    mint
      ✔ reverts with a zero destination address
      ✔ credits the minted amount of tokens
      ✔ emits a TransferSingle event
    mintBatch
      ✔ reverts with a zero destination address
      ✔ reverts if length of inputs do not match
      ✔ credits the minted batch of tokens (38ms)
      ✔ emits a TransferBatch event
    burn
      ✔ reverts when burning the zero account's tokens
      ✔ reverts when burning a non-existent token id
      ✔ reverts when burning more than available tokens
      ✔ accounts for both minting and burning
      ✔ emits a TransferSingle event
    burnBatch
      ✔ reverts when burning the zero account's tokens
      ✔ reverts if length of inputs do not match
      ✔ reverts when burning a non-existent token id
      ✔ accounts for both minting and burning (64ms)
      ✔ emits a TransferBatch event (43ms)


  58 passing (11s)

yulrc1155's People

Contributors

jerobar avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.