Code Monkey home page Code Monkey logo

orbs-contract-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orbs-contract-sdk's Issues

gamma-cli deploy: doesn't always work

sometimes when deploying a smart contract the following error appears:

screen shot 2018-12-05 at 15 13 59

when attempting to deploy again it usually works. I have encountered this error multiple times

unexpected error when deploying contract before server is ready

  1. I started gamma and immediately tried to deploy a contract(probably before the contract was ready) using the following command:
    gamma-cli deploy ../../ERC20Token/token.go
  2. I recieved this error:
    ERROR:
    Failed sending transaction request to Gamma server.

failed decoding response: reserved ExecutionResult received
3) a few seconds I ran the same command and the contract deployed successfully.

Expected behaviour
I would expect an error to say that the server isn't ready

SafeMath - issue with complying with ERC20 demands

The ERC20 standard demands that in certain cases a function should return a boolean which represents wether or not the request was successful.

For example, if Alice has 5 tokens and she wants to transfer 10 tokens to Bob, the function should return false.

despite this, in ethereum's documentation, the methods in their erc20 implementation that return boolean only return 'true' because safeMath generates an error if the condition shouldn't be possible.

In Orbs, the gamma cli does not recognize the type "boolean", so the ERC20 interface is not identical to ethereum. I think that it is not necessary to include a boolean type in Orbs because just like in ethereum, if there is no error then there is no issue with the conditions and there is no reason to return a boolean.

The way I see it, we need either to add a boolean type to the gamma-cli in order to implement the same ERC20 interface as ethereum, or explicitly state that in Orbs, the ERC20 implementation is slightly different and returns void instead of a boolean in a few specific functions.

Gamma installation conflicts with Orbs Core developer env.

Gamma installation checks out two repositories under $GOPATH, compiles there, and leaves the keys files in the repository folder. This collides with working on the repos and interferes with dev experience.

For instance, the installation script does not work when there are already changes in the workdir folder (and it also fails to abort in this case, leaving to version collisions, see #22 ) but even if there are no changes, it leaves the workdir in the gamma version tag:

➜  orbs-network-go git:(5039a4f) git status
HEAD detached at v0.1-gamma

Suggest:

# setup temp GOPATH
export GOPATH=`mktemp -d -t gamma-install-gopath`
function cleanup {      
  rm -rf "$GOPATH"
  echo "Deleted temp working directory $GOPATH"
} 
trap cleanup EXIT

# ... rest of the script as it is today ...

# ... copy artifacts outside of temp dir (/opt/orbs/gamma/v1/bin with symlinks to /opt/bin?) before setting symlinks ...

gamma-cli status

when running the gamma-cli status the following error appears:

ERROR:
status request failed on gamma server

failed decoding response: response is corrupt and cannot be decoded.

screen shot 2018-12-05 at 16 26 19

support for non primitive types

As of now, there is no support for non primitive types on the sdk. It would a lot easier for a developer to write smart contracts if there was support for structs and other non primitive types.
In addition, the user cannot serialize structs or interfaces because it is not possible to write those types in the smart contract nor to import them from other libraries that the user may have created

append crash

the following lines make the append crash the smart contract:

screen shot 2018-12-19 at 23 00 52

this is the json file used to call this function:

screen shot 2018-12-19 at 23 01 51

this is the error:
ERROR:
Request send-tx failed on Gamma server.

failed decoding response: reserved ExecutionResult received

installation issue - #2

From Andrey:
I've encountered some issues with Gamma installation:

  1. See the attached screenshot.
    It seems that not all tools are downloaded - specifically, jsonapi is missing, so gamma-cli doesn't get compiled.
    I think the issue is with this line:

git fetch --all && git checkout feature/gamma-cli

automatic 10 new test keys

  1. When starting gamma-cli it automatically creates 10 new test keys. This seems unnecessary because 10 test keys are created when deploying a smart contract.

  2. The test keys are generated inside the working directory. I think it would be more comfortable if the test keys would be generated in the directory of the smart contract. That way you won't end up finding a bunch of orbs-test-keys.json all over your computer (depending what your working directory was when you deployed the contract).

gamma testing tool doen't recognize filepath when there are multiple spaces between command and path

please note that this error only occurred while using the gamma testing tool and not when using the cli

  • the contract used is the counter contract from the examples provided by orbs here

steps to reproduce:

  1. I created a GO file, using the gamma test package to deploy and run transactions. see file attached (i added it as text file instead of go file).
    test.txt

  2. I run the file and got the following error:

**ERROR:
Could not open input file.

open : no such file or directory**

It seems that the issue is in line 26 in the file attached, where by mistake I added 2 spaces to the beginning of the file path.

Expected behaviour
I would like the tool to trim the space and not fail it.

Safe math - missing div

Hi Tal,
If possible to add also the functionality of div to align our library with what is expected.

Gamma cli - start command should return the terminal.

Now:

  1. Once I start the gamma cli gamma-cli start, you need to open a second terminal to deploy the contracts.

Desired behaviour:

  1. a devloper should be able to work on the same terminal window after starting gamma blockchain and cli

When installing - got warning

`Installing Orbs Network Go, Please wait..

github.com/orbs-network/orbs-network-go

ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//Security.framework/Security.tbd and library file /System/Library/Frameworks//Security.framework/Security are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/Versions/A/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/Versions/A/IOKit are out of sync. Falling back to library file for linking.
Fetching origin
Branch 'feature/gamma-cli' set up to track remote branch 'feature/gamma-cli' from 'origin'.
Switched to a new branch 'feature/gamma-cli'`

Change syntax of commands with required arguments

Do we want gamma-cli commands with required arguments to not use the options syntax?

for example:
gamma-cli deploy -name <name> -code <path to code>
should be:
gamma-cli deploy <name> <path to code>

Current syntax is a bit confusing.
Could maybe add a default parameter to -name option to create a full suite of default values.

relevant commands are:

  • gamma-cli deploy
  • gamma-cli send-tx
  • gamma-cli read
  • gamma-cli status

Command to get the current deployed contracts on a virtual chain.

Motivation:
when testing the test-net and trying to deploy many contracts, it is not that easy to get all the contracts that are currently deployed.

Suggestion:

  • New command "get-contracts" - return the contracts that are deployed to the virtual chain.
    This command should work with the -env option.
  • contracts details that should be provided : contract name, contract address (nice to have - the time the contract was deployed and the signer who deployed the contract).

no error appears when there is an improper flag for name

  1. i deployed a contract using the following command:
    deploy ../token.go - name ERC20Token -signer user1
  2. I ran a run-query command and got an error.

I have realized that the error occurred because there is a space between "-" and "name", and because of that the name was set to the name of the file of the contract and not to the name that appears after the flag.

Expected behaviour
I would expect an error to appear that states that the contract cannot be deployed because of an improper flag, or at the very least a message to the user stating the real name of the contract that has been deployed

Should there be an execution result for run call command?

When I run:
gamma-cli run send ./go/examples/counter/jsons/add.json
I get:
{"TransactionReceipt":{"Txhash":"Dq8hQbkLHYcxR2mmd8t8ef9hsuyglG0b0CyP00LhwUs=","ExecutionResult":1,"OutputArguments":null},"TransactionStatus":1,"BlockHeight":1094,"BlockTimestamp":0}

But when I use the call command:
gamma-cli run call ./go/examples/counter/jsons/get.json
I get:
{"OutputArguments":[{"Name":"uint64","Type":"uint64","Value":100}],"CallResult":0,"BlockHeight":0,"BlockTimestamp":0}

Does execution result is only for write commands?

On responses via Gamma - blockhight is wrong.

{"OutputArguments":[{"Name":"uint64","Type":"uint64","Value":600}],"CallResult":1,"BlockHeight":7347,"BlockTimestamp":0}.
Problem with the “Name” field

Blocktimestamp- is always 0.

BlockHeight - also looks like a random number.

Gamma-cli - update the welcome text

  • Here is the new welcome text :

Gamma by ORBS v0.5

Gamma is a local ORBS blockchain to empower developers to easily and efficiently deploy, run & test smart contracts. Gamma runs an in-memory virtual chain on top of an ORBS blockchain with N nodes on your local machine.
Gamma-cli - the command line interface is deigned to help you to interact with the virtual chain.

Commands supported:

  • $ gamma-cli start
start a local virtual chain over ORBS blockchain network, running on 3 nodes.

  • $ gamma-cli deploy [contract name] [contract file]
Compile the smart contract with go v10.0 and deploy it on the personal orbs blockchain on your machine. 
Example: 
cd "$GOPATH/src/github.com/orbs-network/orbs-contract-sdk/"
gamma-cli deploy Counter ./go/examples/counter/counter.go

  • $ gamma-cli run  send [json file]
Use send when you want to send a transaction to a smart contract method that may change the the contract state. The transaction will be added to the blockchain under consensus.|
Example: gamma-cli run send ./go/examples/counter/jsons/add.json


  • $ gamma-cli run call [json file]
Use  when you want to access a smart contract method that reads from your state variables. In this case, the read is done on a local node, without undergoing consensus.
Example: gamma-cli run call ./go/examples/counter/jsons/get.json

  • $gamma-cli genKeys
generates a new pair public and private key to sign on the transactions you send or you contract sends. The keys are stored on your computer on a file named ORBS.KEYS.

For more information : https://github.com/orbs-network/orbs-contract-sdk.
Enjoy!

Install does not fail when orbs-network-go repo has uncommitted changes

got this output when installing while some changes exist on my orbs-network-go repo.

The problem is that there seem to be an error message - it says "Aborting" but then it goes on.

➜  ~ curl -o- https://raw.githubusercontent.com/orbs-network/orbs-contract-sdk/master/install.sh | bash

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1429  100  1429    0     0   3444      0 --:--:-- --:--:-- --:--:--  3443
Installing Orbs Network Go, Please wait..
Fetching origin
remote: Enumerating objects: 138, done.
remote: Counting objects: 100% (138/138), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 187 (delta 109), reused 123 (delta 102), pack-reused 49
Receiving objects: 100% (187/187), 42.91 KiB | 272.00 KiB/s, done.
Resolving deltas: 100% (116/116), completed with 55 local objects.
From https://github.com/orbs-network/orbs-network-go
   d76eccc..ac1b724  master                              -> origin/master
 * [new branch]      feature/lean-helix-adapter-creation -> origin/feature/lean-helix-adapter-creation
error: Your local changes to the following files would be overwritten by checkout:
	test.acceptance.sh
	test/acceptance/simple_transfer_test.go
Please commit your changes or stash them before you switch branches.
Aborting
Submodule path 'vendor/github.com/VividCortex/ewma': checked out '43880d236f695d39c62cf7aa4ebd4508c258e6c0'
Submodule path 'vendor/github.com/codahale/hdrhistogram': checked out '3a0bb77429bd3a61596f5e8a3172445844342120'
Submodule path 'vendor/github.com/google/go-cmp': checked out '5411ab924f9ffa6566244a9e504bc347edacffd3'
Submodule path 'vendor/github.com/orbs-network/go-mock': checked out '890a1ee8d0a15609de7a834b53949382923e97dd'
Submodule path 'vendor/github.com/orbs-network/lean-helix-go': checked out 'bff7a5578a91e35f0a1a6ce7b48c30c02f2da43e'
Submodule path 'vendor/github.com/orbs-network/lean-helix-go/vendor/github.com/google/go-cmp': checked out '875f8df8b7965f1eac1098d36d677f807ac0b49e'
Submodule path 'vendor/github.com/orbs-network/lean-helix-go/vendor/github.com/orbs-network/go-mock': checked out '890a1ee8d0a15609de7a834b53949382923e97dd'
Submodule path 'vendor/github.com/orbs-network/lean-helix-go/vendor/github.com/stretchr/testify': checked out '2db35c88b92a1631e987089b5485a95e68bc5d3a'
Submodule path 'vendor/github.com/orbs-network/membuffers': checked out 'ba56557e09c28f08c3d52b71fad25fa480f8b4ee'
Submodule path 'vendor/github.com/orbs-network/orbs-contract-sdk': checked out 'b52b160c961b27ed61208ec0e06590857fa1043c'
Submodule path 'vendor/github.com/orbs-network/orbs-spec': checked out '914085d4bc49a6929ce42347363f6786966dba3b'
Submodule path 'vendor/github.com/pkg/errors': checked out '816c9085562cd7ee03e7f8188a1cfd942858cded'
Submodule path 'vendor/github.com/stretchr/testify': checked out 'f35b8ab0b5a2cef36673838d662e249dd9c94686'
Submodule path 'vendor/golang.org/x/crypto': checked out 'c126467f60eb25f8f27e5a981f32a87e3965053f'
Submodule path 'vendor/golang.org/x/time': checked out 'fbb02b2291d28baffd63558aa44b4b56f178d650'
Installing the Developer SDK, Please wait..
Compiling gamma-server binary..
Compiling gamma-cli binary..
Password:
Password:

State variables are erased after reading them?

Steps to reproduce by Gil.
after reading the state once, it seems that the contract will also erase the state that was read. ex: after executing
err = contract.State.WriteUint64ByKey(ctx, “supply”, 20)
a, err := contract.State.ReadUint64ByKey(ctx, “supply”)
b, err := contract.State.ReadUint64ByKey(ctx, “supply”)
a = 20 while b = 0.
I’m not quite sure about the implementation details but it seems it is implemented as a stack \ queue.

boolean primitive type

Are we interested in this?

It will have to be saved as a byte (8 bits), so this is basically just a typedef for uint8

Readme installation instructions not always working

I tested the instructions on several computers (one of them is “clean” computer, all of them are NOT core dev team computers).

One of the steps didn’t work on 3 of them , and that is the command ‘go get -u github.com/orbs-network/orbs-contract-sdk’.

The response was: “package github.com/orbs-network/orbs-contract-sdk: no Go files in /Users/estiedelstein/dev/go/src/github.com/orbs-network/orbs-contract-sdk”

I noticed that when I am on the go workspace (GOPATH) sometimes it works ….

For now clone seems to work .

This is not urgent, unless there is a big disadvantage for using clone.
Let me know your thoughts

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.