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

Calling StdLib.JsonSerialize on a contract manifest returns error "Specified cast is not valid." #2571

Closed
csmuller opened this issue Aug 12, 2021 · 3 comments

Comments

@csmuller
Copy link

Describe the bug

Calling StdLib.JsonSerialize on a contract manifest returns error "Specified cast is not valid."

To Reproduce

  • Create, compile, deploy the following contract:
      public class ExampleContract : SmartContract
      {
    
          public static object method()
          {
              Contract c = ContractManagement.GetContract(NEO.Hash);
              return StdLib.JsonDeserialize(c.Manifest);
          }
      }
  • Run neo-express: neoxp reset -f && neoxp run
  • Deploy the contract: neoxp contract deploy bin/sc/ExampleContract.nef genesis
  • Invoke the method:
    • Create an invoke file:
      [
          {
              "contract": "ExampleContract",
              "operation": "method",
              "args": []
          }
      ]
    • Run neoxp contract invoke invoke.json genesis

Expected behavior
As mentioned in this PR's discussion, it should be easy to replace the contract name in a manifest with a new name by, e.g., using StdLib.jsonSerialze.

Platform:

  • OS: MacOS 11.4
  • Version nccs 3.0.2, neoxp 3.0.5
@irshadnilam
Copy link

To add to this,
without having an ability to change the manifest name, it is difficult to create a factory contract in NEO.

@roman-khimov
Copy link
Contributor

c.Manifest is not a string since #2254, that's why it fails. At the same time if we're talking about factories why do need to take manifest from GetContract, why factory doesn't have it stored internally?

@csmuller
Copy link
Author

Great, thanks @roman-khimov. We missed that change.
@shargon, The dotnet devpack needs this update as well, AFAIK.

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

No branches or pull requests

3 participants