Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadOnly methods #93

Open
wants to merge 34 commits into
base: master
from

Conversation

@shargon
Copy link
Member

commented Aug 24, 2019

Required for neo-project/neo#1052

Fix some issues:

  • entrypoint to entryPoint (from string to method)
  • functions to methods
  • returntype to returnType
  • Unit test for cover all the abi
@igormcoelho
Copy link
Contributor

left a comment

Please let's merge #94 first... too complicated to review now.

@igormcoelho

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

I'll have to reproduce your commits one by one... the conflicting file is exactly the most complicated one........ another excellent reason for doing 94 before, it would be impossible to review.

@igormcoelho

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

Can you merge @shargon? It's about 5 blocks of code... for me I'm blind, have to understand everything step by step to fix this... perhaps you can do it quicker, as you precisely know the changes.

@shargon shargon force-pushed the shargon:readonly-abi branch from a0555fa to 057f94c Aug 26, 2019

@shargon

This comment has been minimized.

Copy link
Member Author

commented Aug 26, 2019

@igormcoelho is done

@erikzhang

This comment has been minimized.

Copy link
Member

commented Aug 28, 2019

Can you give an example of the output json from the changes?

@shargon

This comment has been minimized.

Copy link
Member Author

commented Aug 28, 2019

This is the final format (was adjusted considering that neo have the good one)

{
    "hash": "0x77811b3127dea2df1a18230f91396fbcf8c648f4",
    "methods": [
        {
            "name": "readOnlyTrue",
            "parameters": [],
            "returnType": "Void"
        },
        {
            "name": "readOnlyFalse1",
            "parameters": [],
            "returnType": "Void"
        },
        {
            "name": "readOnlyFalse2",
            "parameters": [],
            "returnType": "Void"
        }
    ],
    "readOnlyMethods": [
        "readOnlyTrue"
    ],
    "entryPoint": {
        "name": "Main",
        "parameters": [
            {
                "name": "method",
                "type": "String"
            },
            {
                "name": "args",
                "type": "Array"
            }
        ],
        "returnType": "Void"
    },
    "events": [
        {
            "name": "transfer",
            "parameters": [
                {
                    "name": "arg1",
                    "type": "ByteArray"
                },
                {
                    "name": "arg2",
                    "type": "ByteArray"
                },
                {
                    "name": "arg3",
                    "type": "Integer"
                }
            ]
        }
    ]
}

for the code:

public class Contract_Abi : SmartContract.Framework.SmartContract
    {
        [DisplayName("transfer")]
        public static event Action<byte[], byte[], BigInteger> Transferred;

        public static void Main(string method, object[] args) { }

        [ReadOnly(true)]
        public static void readOnlyTrue() { }

        [ReadOnly(false)]
        public static void readOnlyFalse1() { }

        public static void readOnlyFalse2() { }
    }

Note that Main is not in methods

@erikzhang

This comment has been minimized.

Copy link
Member

commented Aug 28, 2019

I think we don't have readOnlyMethods in ABI specification.

@shargon

This comment has been minimized.

Copy link
Member Author

commented Aug 28, 2019

These changes are precisely for this neo-project/neo#927

@erikzhang

This comment has been minimized.

Copy link
Member

commented Aug 28, 2019

Maybe we can output in this format:

{
    "methods": [
        {
            "name": "readOnlyTrue",
            "parameters": [],
            "returnType": "Void",
            "readonly": true,
        }
    ]
}

Or just not modify the ABI, we keep readonly in the manifest.

@shargon

This comment has been minimized.

Copy link
Member Author

commented Aug 28, 2019

I prefer to modify the abi, is more readable, i like your way.
If is on the abi, the compiler can deal with it

@erikzhang

This comment has been minimized.

Copy link
Member

commented Aug 28, 2019

Okay. Let's amend the NEP-3 specification first.

@igormcoelho

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2019

Fully agree on "readonly": true. Just one camel case standard... shouldn't it be readOnly:true ? Let's ammend NEP-3.

@shargon

This comment has been minimized.

Copy link
Member Author

commented Sep 3, 2019

@igormcoelho could amend the NEP-3? and as you said, yes, must be in camel case

shargon added 3 commits Sep 9, 2019
@shargon

This comment has been minimized.

Copy link
Member Author

commented Sep 9, 2019

Changes made, requires updating the NEP-3 and NEO manifest before merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.