keep-starknet-strange / alexandria

Community maintained Cairo libraries and set of well maintained, optimised and secure components.
MIT License
231 stars 100 forks source link

feat: add pow2 and pow10 utilizing const arrays #323

Open milancermak opened 2 months ago

milancermak commented 2 months ago

Feature Request

Describe the Feature Request

Cairo 2.7.0 brought back the use of dw in const array. In Cairo0, it was used by a lot of projects to have the most efficient implementation of power of 2 and power of 10 since instead of looping it's just a lookup table.

pow2 and pow10 are the most commonly used powers - for example, the former is used in Alexandria as well for bitshifting, the latter is often used for defi applications as we deal with powers of ERC20.decimals there.

Describe Preferred Solution

Something like:

pub fn pow10(n: usize) -> u128 {
    *(P10.span()[n])
}

And similarly for pow2.

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR? (Help can be provided if you need assistance submitting a PR)

PavitraAgarwal21 commented 1 month ago

can i take this up

onlydustapp[bot] commented 1 month ago

Hey @PavitraAgarwal21! Thanks for showing interest. We've created an application for you to contribute to Alexandria. Go check it out on OnlyDust!

oluwa-peski commented 1 month ago

Is this issue still open? I'd like to complete it, but can't find a way to apply for it on onlydust @milancermak

onlydustapp[bot] commented 1 month ago

Hey @oluwa-peski! Thanks for showing interest. We've created an application for you to contribute to Alexandria. Go check it out on OnlyDust!

github-actions[bot] commented 1 week ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

milancermak commented 1 week ago

issue still valid