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

feat: Allow felt252 short strings on init_calldata #2587

Closed
rsodre opened this issue Oct 28, 2024 · 4 comments · Fixed by #2625
Closed

feat: Allow felt252 short strings on init_calldata #2587

rsodre opened this issue Oct 28, 2024 · 4 comments · Fixed by #2625
Assignees

Comments

@rsodre
Copy link

rsodre commented Oct 28, 2024

Is your feature request related to a problem? Please describe.

Currently, we can pass only numbers and addresses to dojo_init() through a profile config init_calldata.

Would be good to allow felt252 short strings.

EVEN BETTER: make it generic enough and accept anything, like sozo --calldata

Describe the solution you'd like

Use sozo execute prefixes to format init_calldata

$ sozo execute --help
  -c, --calldata <CALLDATA>
          The calldata to be passed to the system. Comma separated values e.g., 0x12345,128,u256:9999999999. Sozo supports some prefixes that you can use to automatically parse some types. The supported prefixes are:
                            - u256: A 256-bit unsigned integer.
                            - sstr: A cairo short string.
                            - str: A cairo string (ByteArray).
                            - int: A signed integer.
                            - no prefix: A cairo felt or any type that fit into one felt.

Describe alternatives you've considered

None

Additional context

A good usage example for short strings (and why I need it) is to pass base_uri to an ERC-721 token contract.

# sepolia profile
init_calldata = [
  "sstr:https://testnet.pistols.gg", # base_uri
]

# mainnet profile
init_calldata = [
  "sstr:https://play.pistols.gg", # base_uri
]
@edisontim
Copy link
Contributor

Hello, would love to work on this!

@glihm
Copy link
Collaborator

glihm commented Nov 3, 2024

Hello, would love to work on this!

@edisontim still interested to tackled that?

@glihm
Copy link
Collaborator

glihm commented Nov 3, 2024

@edisontim if yes, the idea is to move the calldata_decoder that is inside bin/sozo into dojo/world and re-use it a bit everywhere it can apply. 👍

@edisontim
Copy link
Contributor

Hey @glihm, I'm still up for it yeah!

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

Successfully merging a pull request may close this issue.

3 participants