Giter VIP home page Giter VIP logo

solidity-conv's Introduction

Solidity Type Conversion Utils

Greenkeeper badge

NOTE: this repo is super early in development and no where near production-ready. Please use under careful discretion.

Motivation

Conversion between types in Solidity can be tricky. Sometimes explicit typecasting would do the work, while it won't in other occasions (e.g. addressToString, i.e. hexstring to UTF-8).

If you are looking for utility library for bytes and string operations, look no further than Goncalo's bytes-utils and Nick Johnson's stringutils.

This library is mainly for conversion between types, especially between uint, bytes and string, fixed or dyanmic, we would like to abstract away those details and provide clean, intuitive API for Solidity dev.

Installation

npm install solidity-conv

TODO: publish under EthPM when more ready.

Usage

  1. in your Solidity contract, import it using:
import "solidity-conv/contracts/(whichever).sol";
  1. make sure your solc version is update to date, (currently the library uses ^0.5.5) otherwise compilation errors occur. My personal recommendation is specify this in your truffle-config.json (or whatever name you give to your truffle config)
module.exports = {
  compilers: {
    solc: {
      version: "0.5.5",
    },
  }
}

Examples

pragma solidity ^0.5.5;

import "solidity-conv/contracts/LibBytesString.sol";

contract myContract is LibBytesString {
  function myFunc() public pure returns (string memory) {
    address dai = 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359;
    // ERROR: Explicit type conversion not allowed (from fixed to dyanmic)
    // string memory greet = string(dai);
    
    // CORRECT: this how you rock:
    string memory greet = addressToString(dai);
    return greet;
  }
}

Contributing

All contributions are welcomed.

Roadmap:

  • addressToString PoC with tests
  • extending to bytesToString, stringToBytes, uintToBytes, etc.
  • consider exposing better API
  • inline assembly optimization

solidity-conv's People

Contributors

alxiong avatar greenkeeper[bot] avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

solidity-conv's Issues

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 11.12.4 to 11.13.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: lockfile: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of ganache-cli is breaking the build 🚨

The devDependency ganache-cli was updated from 6.4.1 to 6.4.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ganache-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: lockfile: Your tests failed on CircleCI (Details).

Commits

The new version differs by 9 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @types/node is breaking the build 🚨

The devDependency @types/node was updated from 11.12.1 to 11.12.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of ethereum-waffle is breaking the build 🚨

The devDependency ethereum-waffle was updated from 2.0.7 to 2.0.8.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ethereum-waffle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: lockfile: Your tests failed on CircleCI (Details).

Commits

The new version differs by 13 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of ts-node is breaking the build 🚨

The devDependency ts-node was updated from 8.0.3 to 8.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ts-node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).

Commits

The new version differs by 4 commits.

  • d117650 8.1.0
  • 66d54af Cache file system operations (#803)
  • 038f83d Remove incremental & tsBuildInfoFile compiler opts (#815)
  • 750ecca Add --log-error option (#818)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of ethereum-waffle is breaking the build 🚨

The devDependency ethereum-waffle was updated from 2.0.8 to 2.0.9.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

ethereum-waffle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: lockfile: Your tests failed on CircleCI (Details).

Release Notes for 2.0.9

This release contains a minor feature.

Extend configuration file to support async operations.

Commits

The new version differs by 2 commits.

  • 7bb1148 bump version to 2.0.9
  • 9ab5eed Fix #97 extending to async user configuration file (#99)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of truffle is breaking the build 🚨

The devDependency truffle was updated from 5.0.10 to 5.0.11.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

truffle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: lockfile: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

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.