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

Unable to execute script/transaction that takes Type as argument with the flow cli v0.31.2 #470

Closed
mellosti opened this issue Mar 13, 2022 · 14 comments
Assignees
Labels

Comments

@mellosti
Copy link

mellosti commented Mar 13, 2022

Problem

Unable to execute script/transaction that takes Type as argument with the flow cli v0.31.2 using emulator.

Steps to Reproduce

  1. Createtest.cdc file
  pub fun main(type: Type): Type {
      return type
  }
  1. Execute script with flow cli (version v0.31.2)
 flow scripts execute ./test.cdc --args-json '[{"type":"Type","value": { "staticType": "Int" }}]'
  1. Inspect the error
    You should get following error:
  Command Error: failed to submit executable script: client: rpc error: code = Unknown desc = [Error Code: 1101] cadence runtime error Execution failed:
  error: invalid argument at index 0: cannot import value of type cadence.TypeValue
  --> c8d7f11eb3e66c689948824787ad26617e943407a6ec506b9962bd670ab9ec10
@devbugging
Copy link
Contributor

Thank you for the feedback, will take a look and report back.

@mellosti
Copy link
Author

Hello, what is the status on this? Did you find something. Would be awesome if this could get fixed soon.

@devbugging
Copy link
Contributor

@onkel-skrue cc-ing @SupunS from Cadence team he might have a better idea what is the problem here.

@SupunS
Copy link
Member

SupunS commented Mar 16, 2022

Hi @onkel-skrue,
I checked the code, and the argument needs to be:

'[ { "type" : "Type", "value" : { "staticType" : { "kind" : "Int" } } } ]'

Seems like documentation (https://docs.onflow.org/cadence/json-cadence-spec/#type) is incorrect there.
We need to update the docs. Thanks for catching that!

@mellosti
Copy link
Author

Hi @SupunS.

I tried:

 '[ { "type" : "Type", "value" : { "staticType" : { "kind" : "Int" } } } ]'

but, getting:

❌ Command Error: error parsing script arguments: failed to decode value: invalid JSON Cadence structure

@SupunS
Copy link
Member

SupunS commented Mar 16, 2022

Oh, I just realized this feature for importing type values (onflow/cadence#1202) is not yet released to the networks. This should be available with the next release of Cadence.

@mellosti
Copy link
Author

Oh, I just realized this feature for importing type values (onflow/cadence#1202) is not yet released to the networks. This should be available with the next release of Cadence.

Thanks for help. Will wait for it :)

@mellosti
Copy link
Author

One question. What does staticType mean her? Can I use NFT resource, e.g. A.877931736ee77cff.TopShot.NFT as the param for Type here (which I am trying to achieve)?

@mellosti
Copy link
Author

I need a generic script that can check if a collection contains a specific Type of NFT's.

@SupunS
Copy link
Member

SupunS commented Mar 16, 2022

StaticType is a structure that captures all details about the type.
A sample JSON for a resource would look like: https://github.com/onflow/cadence/blob/314f5fa8a5da8c452d23a42148a1d7927915d613/encoding/json/encoding_test.go#L1180-L1193
Again, I think these should be available in the documentation. I'll create an issue for the doc improvements (Or please feel free to create an issue in https://github.com/onflow/cadence repo).

Looping in @dsainati1 in case I miss anything and/or for any further details

@devbugging
Copy link
Contributor

devbugging commented Mar 17, 2022

@onkel-skrue so are we okay to close this issue? It looks to me the issues should be opened on Cadence with a documentation tag.

@mellosti
Copy link
Author

Yes, closing now. Thanks for the help :)

@mellosti
Copy link
Author

mellosti commented Apr 28, 2022

@SupunS I tried this again with latest cli, but no luck. I see that you have merged the changes. What am I doing wrong?

onkelskrue@Onkels-MBP:~/Projects/foo^master ±
%  flow scripts execute ./test.cdc --args-json '[ { "type" : "Type", "value" : { "staticType" : { "kind" : "Int" } } } ]'


⚠️  Version warning: a new version of Flow CLI is available (v0.33.0).
   Read the installation guide for upgrade instructions: https://docs.onflow.org/flow-cli/install

❌ Command Error: error parsing script arguments: failed to decode value: invalid JSON Cadence structure

onkelskrue@Onkels-MBP:~/Projects/foo^master ±
% flow version                                                                                                    :( 1 22-04-28 - 20:46:02
Version: v0.33.1

@SupunS
Copy link
Member

SupunS commented Apr 28, 2022

Unfortunately, this hasn't still made it to the emulator/networks yet. The most recent releases have all been mostly bug fixes, etc. and no major features were shipped.

More details about the next big release can be found here: https://forum.onflow.org/t/breaking-changes-coming-with-secure-cadence-release/3052, which will also include this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants