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

Add support for numbers in multicall #2245

Closed
Arcticae opened this issue Jun 21, 2024 · 4 comments · Fixed by #2612
Closed

Add support for numbers in multicall #2245

Arcticae opened this issue Jun 21, 2024 · 4 comments · Fixed by #2612
Assignees
Labels
feature New feature request/description ODHack9 Label for tasks to be done in the ODHack October sncast

Comments

@Arcticae
Copy link
Contributor

Arcticae commented Jun 21, 2024

Description

It seems counterintuitive not to allow raw integers inputs in the mutlicall, right now it's not supported and only string inputs are accepted

Example:

[[call]]
call_type = "deploy"
class_hash = "0x076e94149fc55e7ad9c5fe3b9af570970ae2cf51205f8452f39753e9497fe849"
inputs = []
id = "map_contract"
unique = false

[[call]]
call_type = "invoke"
contract_address = "map_contract"
function = "put"
inputs = ["0x123", "234"]

Desired Behavior

We can allow the inputs to be array of numbers:

...
[[call]]
call_type = "invoke"
contract_address = "map_contract"
function = "put"
inputs = [123, 0x234]

Also contract_address and class_hash can be numbers,
Example:

[[call]]
call_type = "deploy"
class_hash = 0x076e94149fc55e7ad9c5fe3b9af570970ae2cf51205f8452f39753e9497fe849"
inputs = []
id = "map_contract"
unique = false

Context

@Arcticae Arcticae added feature New feature request/description sncast labels Jun 21, 2024
@Arcticae Arcticae moved this to Backlog in Starknet foundry Jun 21, 2024
@github-actions github-actions bot added the new label Jun 21, 2024
@Arcticae Arcticae removed the snforge label Jun 21, 2024
@Arcticae Arcticae added this to the Cast UX improvements milestone Aug 2, 2024
@cptartur cptartur removed the new label Aug 29, 2024
@cptartur cptartur changed the title Add support for numbers in mutlicall Add support for numbers in multicall Sep 23, 2024
@Arcticae Arcticae added the ODHack9 Label for tasks to be done in the ODHack October label Oct 18, 2024
@JoE11-y
Copy link

JoE11-y commented Oct 24, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Joseph a blockchain developer with over four years in blockchain and backend development, I’ve worked across different ecosystems, handling everything from smart contract design to on-chain interactions and protocol integration. I focus on building secure, scalable, and reliable blockchain applications, managing both on-chain and off-chain infrastructure.

How I plan on tackling this issue

Begin by studying the codebase to ensure design consistency, then proceed to work on the task.

  1. Study current codebase design
  2. Identify parts of code that needs to be changed
  3. Make necessary changes
  4. Add tests to make sure the changes are working and no adverse effects
  5. And lastly optimize

@kfastov
Copy link
Contributor

kfastov commented Oct 24, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm a Full Stack Web3 Developer with experience in Rust and Cairo and participated in ODHacks since 2.0, working as both a contributor and maintainer.
I am also using starknet-foundry in my own projects and familiar with different features and would be happy to help

How I plan on tackling this issue

I would define a new [untagged] enum for the Input type with two options: one for String and one for number (will determine the correct type later). Then I'll use this type in DeployCall and InvokeCall for its inputs field instead of String. Then I'll update tests, including different edge cases, like invalid numbers, large numbers and so on

@suhas-sensei
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i have experience in cairo and blockchain previously as personal projects and OS, so hoping to make use of them here and mark my first odhack contribution.

How I plan on tackling this issue

I'll enhance the multicall configuration by implementing a custom TOML deserializer that intelligently handles both string and numeric inputs, automatically detects and converts hexadecimal/decimal formats for all numeric fields (class_hash, contract_address, inputs), while maintaining backward compatibility with existing string inputs. This allows for a more intuitive developer experience without breaking existing configurations.

@Arcticae
Copy link
Contributor Author

@kfastov any progress on this?

github-merge-queue bot pushed a commit that referenced this issue Nov 4, 2024
<!-- Reference any GitHub issues resolved by this PR -->

Closes #2245

## Introduced changes

<!-- A brief description of the changes -->

- Added new enum type `Input` with variants `String` and `Number(i64)`
to support both string and numeric inputs in TOML files
- Updated `DeployCall` and `InvokeCall` structs to use `Vec<Input>`
instead of `Vec<String>` for their `inputs` field
- Modified `parse_inputs` function to handle both string and numeric
input variants
- Added `#[serde(untagged)]` attribute to enable seamless
deserialization of both input types from TOML

## Checklist

<!-- Make sure all of these are complete -->

- [x] Linked relevant issue
- [x] Updated relevant documentation
- [x] Added relevant tests
- [x] Performed self-review of the code
- [x] Added changes to `CHANGELOG.md`

## Other notes
- Numbers larger than 2^64 are not supported by TOML format:
https://toml.io/en/v1.0.0#integer
- However, numbers outside i64 range cannot be supported currently due
to an [issue](toml-rs/toml#705) in the toml
parser

---------

Co-authored-by: Franciszek Job <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to Done in Starknet foundry Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request/description ODHack9 Label for tasks to be done in the ODHack October sncast
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants