diff --git a/__mocks__/cairo/cairo260/u512.cairo b/__mocks__/cairo/cairo260/u512.cairo new file mode 100644 index 000000000..da799b8f9 --- /dev/null +++ b/__mocks__/cairo/cairo260/u512.cairo @@ -0,0 +1,41 @@ +// Cairo 2.6.0 + +use core::integer::u512; + +#[starknet::interface] +trait IUint512 { + fn get_u512(self: @TContractState) -> u512; + fn return_u512(self: @TContractState, my_u512: u512) -> u512; + fn div_u512(self: @TContractState, my_u512: u512, divisor: u256) -> (u512, u256); +} + + +#[starknet::contract] +mod TestUint512 { + use core::integer::{u512, u512_safe_div_rem_by_u256}; + + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl Uint512 of super::IUint512 { + fn get_u512(self: @ContractState) -> u512 { + u512 { + limb0: 0x00000000000000000000000000000000, + limb1: 0x11111111111111111111111111111111, + limb2: 0x22222222222222222222222222222222, + limb3: 0x33333333333333333333333333333333, + } + } + + fn return_u512(self: @ContractState, my_u512: u512) -> u512 { + my_u512 + } + + fn div_u512(self: @ContractState, my_u512: u512, divisor: u256) -> (u512, u256) { + let (q, r) = u512_safe_div_rem_by_u256(my_u512, divisor.try_into().unwrap()); + (q, r) + } + } +} + diff --git a/__mocks__/cairo/cairo260/u512.casm b/__mocks__/cairo/cairo260/u512.casm new file mode 100644 index 000000000..41f898f6b --- /dev/null +++ b/__mocks__/cairo/cairo260/u512.casm @@ -0,0 +1,2332 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.6.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0x100000000000000000000000000000000", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x52", + "0x4825800180007ffa", + "0x0", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x10", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffc7fff8000", + "0x48127ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x3e5", + "0x482480017fff8000", + "0x3e4", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007ff8", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff77fff", + "0x10780017fff7fff", + "0x1d", + "0x4824800180007ff8", + "0x0", + "0x400080007ff87fff", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x11111111111111111111111111111111", + "0x480680017fff8000", + "0x22222222222222222222222222222222", + "0x480680017fff8000", + "0x33333333333333333333333333333333", + "0x400080007ffb7ffc", + "0x400080017ffb7ffd", + "0x400080027ffb7ffe", + "0x400080037ffb7fff", + "0x482480017ff38000", + "0x1", + "0x48127ff97fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff77fff8000", + "0x482480017ff68000", + "0x4", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff58000", + "0x1", + "0x48127ff37fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffffc4", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x5e", + "0x4825800180007ffa", + "0x3c", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x269", + "0x20680017fff7ffb", + "0x45", + "0x48307ff980007ffa", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x10", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff57fff8000", + "0x48127fca7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x379", + "0x482480017fff8000", + "0x378", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fc8", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff07fff", + "0x10780017fff7fff", + "0x15", + "0x4824800180007fc8", + "0x0", + "0x400080007ff17fff", + "0x40780017fff7fff", + "0x1", + "0x400080007fff7ff4", + "0x400080017fff7ff5", + "0x400080027fff7ff6", + "0x400080037fff7ff7", + "0x482480017ff08000", + "0x1", + "0x48127ffd7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x482480017ffa8000", + "0x4", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fee8000", + "0x1", + "0x48127fc37fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4661696c656420746f20646573657269616c697a6520706172616d202331", + "0x400080007ffe7fff", + "0x48127ff67fff8000", + "0x48127fcb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffeea8", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x1f1", + "0x4825800180007ffa", + "0x1158", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x1f7", + "0x20680017fff7ffb", + "0x1d8", + "0x48307ff980007ffa", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482480017ff88000", + "0x1", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x10780017fff7fff", + "0x8", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0x6c", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x16", + "0x480080007ff18003", + "0x480080017ff08003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483080017ffd7ffb", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400080027fec7ffd", + "0x20680017fff7ffe", + "0x51", + "0x402780017fff7fff", + "0x1", + "0x400080007ff17ffe", + "0x482480017ff18000", + "0x1", + "0x48307ff980007ffa", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482480017ff88000", + "0x1", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x10780017fff7fff", + "0x8", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0x2a", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x16", + "0x480080007ff88003", + "0x480080017ff78003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483080017ffd7ffb", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400080027ff37ffd", + "0x20680017fff7ffe", + "0x11", + "0x402780017fff7fff", + "0x1", + "0x400080007ff87ffe", + "0x40780017fff7fff", + "0x5", + "0x482480017ff38000", + "0x1", + "0x48127ff47fff8000", + "0x48127ff47fff8000", + "0x480680017fff8000", + "0x0", + "0x48127fed7fff8000", + "0x48127ff47fff8000", + "0x10780017fff7fff", + "0x24", + "0x482480017ff38000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0x7", + "0x48127ff37fff8000", + "0x48127ff47fff8000", + "0x48127ff47fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x13", + "0x40780017fff7fff", + "0x8", + "0x482480017fe48000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0xf", + "0x48127fe47fff8000", + "0x48127fec7fff8000", + "0x48127fec7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffd", + "0x13e", + "0x48307ffb80007ffc", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x10", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff77fff8000", + "0x48127fb07fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x27b", + "0x482480017fff8000", + "0x27a", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fae", + "0x5582", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff27fff", + "0x10780017fff7fff", + "0x10e", + "0x4824800180007fae", + "0x5582", + "0x400080007ff37fff", + "0x482480017ff38000", + "0x1", + "0x20680017fff7ff6", + "0x12", + "0x20680017fff7ff7", + "0x10", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7074696f6e3a3a756e77726170206661696c65642e", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480080007fff8000", + "0x480080017ffe8000", + "0x480080027ffd8000", + "0x480080037ffc8000", + "0x480080047ffb8000", + "0x480080057ffa8000", + "0x48307fff80007ff1", + "0x40780017fff7fff", + "0xc", + "0x20680017fff7ff3", + "0x8", + "0x40307ff17ff47fe3", + "0x402480017ff57ff4", + "0x1", + "0x400080067fec7ff5", + "0x10780017fff7fff", + "0x3", + "0x400080067fec7ff3", + "0x48307ff17ff68000", + "0x48307fc680007fff", + "0x4844800180007fff", + "0x100000000000000000000000000000000", + "0x40507fff7fff7fff", + "0x48307ff47fff8000", + "0x48307ff47fff8000", + "0x48307ff57fff8000", + "0x48307fec7fff8000", + "0x48307fc180007fff", + "0x4844800180007fff", + "0x100000000000000000000000000000000", + "0x400080077fe37fff", + "0x482480017fff8000", + "0xfffffffffffffffffffffffffffffffc", + "0x400080087fe27fff", + "0x48307fef7ffe8000", + "0x48307ff07fff8000", + "0x48307ff07fff8000", + "0x48307ff17fff8000", + "0x48307fbb80007fff", + "0x4844800180007fff", + "0x100000000000000000000000000000000", + "0x400080097fdc7fff", + "0x482480017fff8000", + "0xfffffffffffffffffffffffffffffffc", + "0x4000800a7fdb7fff", + "0xa0680017fff7fdf", + "0xc", + "0xa0680017fff8001", + "0x6", + "0x48127fd17fff7ffe", + "0x40127fdb7fff7ffe", + "0x10780017fff7fff", + "0x10", + "0x48127fdc7fff7ffe", + "0x40127fd07fff7ffe", + "0x10780017fff7fff", + "0xc", + "0x480680017fff7fd2", + "0x0", + "0xa0680017fff8000", + "0x6", + "0x40127fcf7fff7ffd", + "0x40127fdc7fff7ffe", + "0x10780017fff7fff", + "0x4", + "0x40127fdc7fff7ffd", + "0x40127fcf7fff7ffe", + "0x482480017ffd8000", + "0xffffffffffffffff0000000000000000", + "0x4000800b7fd77fff", + "0x48507ffd7ffc8000", + "0x48307fe97ff98000", + "0x48307fe67fff8000", + "0x40307ffd7fff7fb2", + "0x4824800180008002", + "0xffffffffffffffff0000000000000000", + "0x4800800c7fd38001", + "0x4800800d7fd27ffe", + "0x4000800e7fd17ffe", + "0x484480017ffe8000", + "0x10000000000000000", + "0x40307ffc7fff7fd3", + "0x48507fc77ffc8000", + "0x48507fc67ffc8000", + "0x4824800180018002", + "0xffffffffffffffff0000000000000000", + "0x4800800f7fcd8001", + "0x480080107fcc7fff", + "0x400080117fcb7ffd", + "0x484480017ffd8000", + "0x10000000000000000", + "0x40307ffd7fff7ffb", + "0x484480017ffd8000", + "0x10000000000000000", + "0x48307fff7ff98003", + "0x482480017fff8000", + "0xfffffffffffffffe0000000000000000", + "0x480080127fc77fff", + "0x480080137fc67ffd", + "0x400080147fc57fd7", + "0x404480017ffc7ffe", + "0x100000000000000000000000000000000", + "0x40307fd77ffe7fff", + "0x40307ffc7ff77fd8", + "0x4824800180008002", + "0xffffffffffffffff0000000000000000", + "0x480080157fc48001", + "0x480080167fc37ffe", + "0x400080177fc27ffe", + "0x484480017ffe8000", + "0x10000000000000000", + "0x40307ffc7fff7fc3", + "0x48507fb97ffc8000", + "0x48507fb87ffc8000", + "0x4824800180018002", + "0xffffffffffffffff0000000000000000", + "0x480080187fbe8001", + "0x480080197fbd7fff", + "0x4000801a7fbc7ffd", + "0x484480017ffd8000", + "0x10000000000000000", + "0x40307ffd7fff7ffb", + "0x484480017ffd8000", + "0x10000000000000000", + "0x48307fff7ff98003", + "0x482480017fff8000", + "0xfffffffffffffffe0000000000000000", + "0x4800801b7fb87fff", + "0x4800801c7fb77ffd", + "0x4000801d7fb67fc6", + "0x404480017ffc7ffe", + "0x100000000000000000000000000000000", + "0x40307fc67ffe7fff", + "0x40307ffc7ff77fc7", + "0x4824800180008002", + "0xffffffffffffffff0000000000000000", + "0x4800801e7fb58001", + "0x4800801f7fb47ffe", + "0x400080207fb37ffe", + "0x484480017ffe8000", + "0x10000000000000000", + "0x40307ffc7fff7fb4", + "0x48507fa97ffc8000", + "0x48507fa87ffc8000", + "0x4824800180018002", + "0xffffffffffffffff0000000000000000", + "0x480080217faf8001", + "0x480080227fae7fff", + "0x400080237fad7ffd", + "0x484480017ffd8000", + "0x10000000000000000", + "0x40307ffd7fff7ffb", + "0x484480017ffd8000", + "0x10000000000000000", + "0x48307fff7ff98003", + "0x482480017fff8000", + "0xfffffffffffffffe0000000000000000", + "0x480080247fa97fff", + "0x480080257fa87ffd", + "0x400080267fa77fb3", + "0x404480017ffc7ffe", + "0x100000000000000000000000000000000", + "0x40307fb37ffe7fff", + "0x40307ffc7ff77fb4", + "0x4824800180008002", + "0xffffffffffffffff0000000000000000", + "0x480080277fa68001", + "0x480080287fa57ffe", + "0x400080297fa47ffe", + "0x484480017ffe8000", + "0x10000000000000000", + "0x40307ffc7fff7fa4", + "0x48507f9b7ffc8000", + "0x48507f9a7ffc8000", + "0x4824800180018002", + "0xffffffffffffffff0000000000000000", + "0x4800802a7fa08001", + "0x4800802b7f9f7fff", + "0x4000802c7f9e7ffd", + "0x484480017ffd8000", + "0x10000000000000000", + "0x40307ffd7fff7ffb", + "0x484480017ffd8000", + "0x10000000000000000", + "0x48307fff7ff98003", + "0x482480017fff8000", + "0xfffffffffffffffe0000000000000000", + "0x4800802d7f9a7fff", + "0x4800802e7f997ffd", + "0x4000802f7f987fa6", + "0x404480017ffc7ffe", + "0x100000000000000000000000000000000", + "0x40307fa67ffe7fff", + "0x40307ffc7ff77fa7", + "0x4824800180008002", + "0xffffffffffffffff0000000000000000", + "0x480080307f978001", + "0x480080317f967ffe", + "0x400080327f957ffe", + "0x484480017ffe8000", + "0x10000000000000000", + "0x40307ffc7fff7f95", + "0x48507f8b7ffc8000", + "0x48507f8a7ffc8000", + "0x4824800180018002", + "0xffffffffffffffff0000000000000000", + "0x480080337f918001", + "0x480080347f907fff", + "0x400080357f8f7ffd", + "0x484480017ffd8000", + "0x10000000000000000", + "0x40307ffd7fff7ffb", + "0x484480017ffd8000", + "0x10000000000000000", + "0x48307fff7ff98003", + "0x482480017fff8000", + "0xfffffffffffffffe0000000000000000", + "0x480080367f8b7fff", + "0x480080377f8a7ffd", + "0x400080387f897f93", + "0x404480017ffc7ffe", + "0x100000000000000000000000000000000", + "0x40307f937ffe7fff", + "0x40307ffc7ff77f94", + "0x40780017fff7fff", + "0x1", + "0x48127f897fff8000", + "0x48127f897fff8000", + "0x48127f897fff8000", + "0x48127f897fff8000", + "0x48127f897fff8000", + "0x48127f897fff8000", + "0x48127ff97fff8000", + "0x48127ff87fff8000", + "0x1104800180018000", + "0x162", + "0x482480017f7c8000", + "0x39", + "0x48127f7a7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff08000", + "0x1", + "0x48127fa97fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4661696c656420746f20646573657269616c697a6520706172616d202332", + "0x400080007ffe7fff", + "0x48127ff87fff8000", + "0x48127fb17fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4661696c656420746f20646573657269616c697a6520706172616d202331", + "0x400080007ffe7fff", + "0x48127ff67fff8000", + "0x48127fcb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0xfa", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x16", + "0x480280007ffb8003", + "0x480280017ffb8003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483080017ffd7ffb", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400280027ffb7ffd", + "0x20680017fff7ffe", + "0xdf", + "0x402780017fff7fff", + "0x1", + "0x400280007ffb7ffe", + "0x482680017ffb8000", + "0x1", + "0x48307ff980007ffa", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482480017ff88000", + "0x1", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x10780017fff7fff", + "0x8", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0xb5", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x16", + "0x480080007ff88003", + "0x480080017ff78003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483080017ffd7ffb", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400080027ff37ffd", + "0x20680017fff7ffe", + "0x9a", + "0x402780017fff7fff", + "0x1", + "0x400080007ff87ffe", + "0x482480017ff88000", + "0x1", + "0x48307ff980007ffa", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482480017ff88000", + "0x1", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x10780017fff7fff", + "0x8", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0x70", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x16", + "0x480080007ff88003", + "0x480080017ff78003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483080017ffd7ffb", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400080027ff37ffd", + "0x20680017fff7ffe", + "0x55", + "0x402780017fff7fff", + "0x1", + "0x400080007ff87ffe", + "0x482480017ff88000", + "0x1", + "0x48307ff980007ffa", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482480017ff88000", + "0x1", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x10780017fff7fff", + "0x8", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0x2b", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x16", + "0x480080007ff88003", + "0x480080017ff78003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483080017ffd7ffb", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400080027ff37ffd", + "0x20680017fff7ffe", + "0x12", + "0x402780017fff7fff", + "0x1", + "0x400080007ff87ffe", + "0x40780017fff7fff", + "0x5", + "0x482480017ff38000", + "0x1", + "0x48127ff47fff8000", + "0x48127ff47fff8000", + "0x480680017fff8000", + "0x0", + "0x48127fdd7fff8000", + "0x48127fe47fff8000", + "0x48127feb7fff8000", + "0x48127ff27fff8000", + "0x208b7fff7fff7ffe", + "0x482480017ff38000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0x7", + "0x48127ff37fff8000", + "0x48127ff47fff8000", + "0x48127ff47fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x8", + "0x482480017feb8000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0xf", + "0x48127feb7fff8000", + "0x48127fec7fff8000", + "0x48127fec7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x10", + "0x482480017fe38000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0x17", + "0x48127fe37fff8000", + "0x48127fe47fff8000", + "0x48127fe47fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x18", + "0x482680017ffb8000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0x1f", + "0x480a7ffb7fff8000", + "0x48127fdc7fff8000", + "0x48127fdc7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ff6", + "0x400380017ffd7ff7", + "0x400380027ffd7ff8", + "0x400380037ffd7ff9", + "0x400380047ffd7ffa", + "0x400380057ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x6", + "0x208b7fff7fff7ffe" + ], + "bytecode_segment_lengths": [ + 102, + 114, + 517, + 285, + 10 + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 17, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 36, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -7 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 48, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 72, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 87, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 102, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x3c" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 125, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 144, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -55 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 156, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 172, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 187, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 201, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 216, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x1158" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 256, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 258, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 303, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 305, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 379, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 398, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x5582" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -81 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 416, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 430, + [ + { + "Uint512DivModByUint256": { + "dividend0": { + "Deref": { + "register": "AP", + "offset": -38 + } + }, + "dividend1": { + "Deref": { + "register": "AP", + "offset": -37 + } + }, + "dividend2": { + "Deref": { + "register": "AP", + "offset": -36 + } + }, + "dividend3": { + "Deref": { + "register": "AP", + "offset": -35 + } + }, + "divisor0": { + "Deref": { + "register": "AP", + "offset": -10 + } + }, + "divisor1": { + "Deref": { + "register": "AP", + "offset": -9 + } + }, + "quotient0": { + "register": "AP", + "offset": 0 + }, + "quotient1": { + "register": "AP", + "offset": 1 + }, + "quotient2": { + "register": "AP", + "offset": 2 + }, + "quotient3": { + "register": "AP", + "offset": 3 + }, + "remainder0": { + "register": "AP", + "offset": 4 + }, + "remainder1": { + "register": "AP", + "offset": 5 + } + } + } + ] + ], + [ + 448, + [ + { + "WideMul128": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -19 + } + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -29 + } + }, + "high": { + "register": "AP", + "offset": -9 + }, + "low": { + "register": "AP", + "offset": -10 + } + } + }, + { + "WideMul128": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -18 + } + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -29 + } + }, + "high": { + "register": "AP", + "offset": -7 + }, + "low": { + "register": "AP", + "offset": -8 + } + } + }, + { + "WideMul128": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -19 + } + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -28 + } + }, + "high": { + "register": "AP", + "offset": -5 + }, + "low": { + "register": "AP", + "offset": -6 + } + } + }, + { + "WideMul128": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -18 + } + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -28 + } + }, + "high": { + "register": "AP", + "offset": -3 + }, + "low": { + "register": "AP", + "offset": -4 + } + } + }, + { + "WideMul128": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -17 + } + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -29 + } + }, + "high": { + "register": "AP", + "offset": -1 + }, + "low": { + "register": "AP", + "offset": -2 + } + } + } + ] + ], + [ + 477, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -35 + } + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -46 + } + }, + "dst": { + "register": "AP", + "offset": 1 + } + } + } + ] + ], + [ + 489, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -35 + } + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -48 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 504, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -41 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 1 + }, + "remainder": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 514, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 0 + }, + "remainder": { + "register": "AP", + "offset": 1 + } + } + } + ] + ], + [ + 525, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": 2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": -1 + }, + "remainder": { + "register": "AP", + "offset": -38 + } + } + } + ] + ], + [ + 534, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -57 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 1 + }, + "remainder": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 544, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 0 + }, + "remainder": { + "register": "AP", + "offset": 1 + } + } + } + ] + ], + [ + 555, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": 2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": -1 + }, + "remainder": { + "register": "AP", + "offset": -55 + } + } + } + ] + ], + [ + 564, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -72 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 1 + }, + "remainder": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 574, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 0 + }, + "remainder": { + "register": "AP", + "offset": 1 + } + } + } + ] + ], + [ + 585, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": 2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": -1 + }, + "remainder": { + "register": "AP", + "offset": -74 + } + } + } + ] + ], + [ + 594, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -88 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 1 + }, + "remainder": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 604, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 0 + }, + "remainder": { + "register": "AP", + "offset": 1 + } + } + } + ] + ], + [ + 615, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": 2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": -1 + }, + "remainder": { + "register": "AP", + "offset": -87 + } + } + } + ] + ], + [ + 624, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -103 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 1 + }, + "remainder": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 634, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x10000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 0 + }, + "remainder": { + "register": "AP", + "offset": 1 + } + } + } + ] + ], + [ + 645, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": 2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": -1 + }, + "remainder": { + "register": "AP", + "offset": -106 + } + } + } + ] + ], + [ + 654, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 675, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 690, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 704, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 718, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 755, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 757, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 802, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 804, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 849, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 851, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 896, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 898, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -2 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0xbffc6a437c6d569cf809118ae879d8c29850d01d30ffbd358142e8ca9e2abd", + "offset": 102, + "builtins": [ + "range_check" + ] + }, + { + "selector": "0x1a51b32fb11323778cf7223ce2f741af61cf28f900e59fc300d44e7e8fa1af2", + "offset": 216, + "builtins": [ + "range_check" + ] + }, + { + "selector": "0x363f0fa4491d64ba1b2e461e750e272b424805998f3bd334a5f5b1acaa2aaf5", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/__mocks__/cairo/cairo260/u512.sierra.json b/__mocks__/cairo/cairo260/u512.sierra.json new file mode 100644 index 000000000..1940f995c --- /dev/null +++ b/__mocks__/cairo/cairo260/u512.sierra.json @@ -0,0 +1,564 @@ +{ + "sierra_program": [ + "0x1", + "0x5", + "0x0", + "0x2", + "0x6", + "0x0", + "0xf4", + "0xc", + "0x20", + "0x52616e6765436865636b", + "0x800000000000000100000000000000000000000000000000", + "0x436f6e7374", + "0x800000000000000000000000000000000000000000000002", + "0x1", + "0x1e", + "0x2", + "0x4661696c656420746f20646573657269616c697a6520706172616d202332", + "0x75313238", + "0x800000000000000700000000000000000000000000000000", + "0x537472756374", + "0x800000000000000700000000000000000000000000000005", + "0x0", + "0x2907a9767b8e0b68c23345eea8650b1366373b598791523a07fddaa450ba526", + "0x800000000000000700000000000000000000000000000003", + "0x25e2ca4b84968c2d8b83ef476ca8549410346b00836ce79beaf538155990bb2", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x3", + "0x4", + "0x553132384d756c47756172616e746565", + "0x4f7074696f6e3a3a756e77726170206661696c65642e", + "0x4e6f6e5a65726f", + "0x800000000000000700000000000000000000000000000001", + "0x800000000000000f00000000000000000000000000000001", + "0x456e756d", + "0x12867ecd09c884a5cf1f6d9eb0193b4695ce3bb3b2d796a8367d0c371f59cb2", + "0x9", + "0x426f78", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0xb", + "0x4661696c656420746f20646573657269616c697a6520706172616d202331", + "0x9ff3d80dd57f290c7231ed72006c73fd2ebf30f036ffb15a809d8e3ab4e2e2", + "0x4f7574206f6620676173", + "0x4172726179", + "0x800000000000000300000000000000000000000000000001", + "0x536e617073686f74", + "0x10", + "0x800000000000000700000000000000000000000000000002", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x11", + "0x12", + "0x33333333333333333333333333333333", + "0x22222222222222222222222222222222", + "0x11111111111111111111111111111111", + "0x4275696c74696e436f737473", + "0x53797374656d", + "0x16a4c8d7c05909052238a862d8cc3e7975bf05a07b3a69c6b28951083a6d672", + "0x800000000000000300000000000000000000000000000003", + "0x1a", + "0x9931c641b913035ae674b400b61a51476d506bbe8bba2ff8a6272790aba9e6", + "0x13", + "0x1b", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x66656c74323532", + "0x4761734275696c74696e", + "0x53", + "0x7265766f6b655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x7374727563745f6465636f6e737472756374", + "0x73746f72655f74656d70", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x64726f70", + "0x61727261795f6e6577", + "0x636f6e73745f61735f696d6d656469617465", + "0x1d", + "0x61727261795f617070656e64", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0x1c", + "0x1f", + "0x19", + "0x6765745f6275696c74696e5f636f737473", + "0x18", + "0x77697468647261775f6761735f616c6c", + "0x17", + "0x16", + "0x15", + "0x14", + "0x736e617073686f745f74616b65", + "0x647570", + "0x72656e616d65", + "0x753132385f746f5f66656c74323532", + "0xf", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0xe", + "0xd", + "0x656e61626c655f61705f747261636b696e67", + "0xc", + "0x6a756d70", + "0x756e626f78", + "0x75313238735f66726f6d5f66656c74323532", + "0xa", + "0x64697361626c655f61705f747261636b696e67", + "0x753235365f69735f7a65726f", + "0x7", + "0x753531325f736166655f6469766d6f645f62795f75323536", + "0x753132385f6d756c5f67756172616e7465655f766572696679", + "0x5", + "0x283", + "0xffffffffffffffff", + "0x5a", + "0x6", + "0x8", + "0x4d", + "0x21", + "0x22", + "0x23", + "0x24", + "0x25", + "0x26", + "0x27", + "0x28", + "0x29", + "0x2a", + "0x2b", + "0x2c", + "0x2d", + "0x2e", + "0x2f", + "0x30", + "0x31", + "0x32", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x39", + "0x3a", + "0x3b", + "0x3c", + "0x3d", + "0x3e", + "0x3f", + "0x40", + "0x41", + "0x42", + "0x43", + "0x44", + "0x45", + "0x46", + "0x47", + "0x48", + "0x49", + "0x4a", + "0x4b", + "0x4c", + "0x4e", + "0xd1", + "0xc2", + "0x82", + "0xb4", + "0x4f", + "0x50", + "0x51", + "0x52", + "0x54", + "0x1a6", + "0x197", + "0xef", + "0xf4", + "0x129", + "0x124", + "0x102", + "0x107", + "0x11a", + "0x114", + "0x131", + "0x11e", + "0x12c", + "0x186", + "0x146", + "0x176", + "0x15d", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5b", + "0x5c", + "0x5d", + "0x5e", + "0x5f", + "0x60", + "0x61", + "0x62", + "0x63", + "0x64", + "0x65", + "0x66", + "0x67", + "0x68", + "0x69", + "0x6a", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x6f", + "0x70", + "0x71", + "0x72", + "0x73", + "0x74", + "0x75", + "0x76", + "0x77", + "0x78", + "0x79", + "0x7a", + "0x7b", + "0x7c", + "0x7d", + "0x7e", + "0x7f", + "0x80", + "0x1bb", + "0x1c0", + "0x24d", + "0x247", + "0x1d1", + "0x1d6", + "0x23d", + "0x236", + "0x1e7", + "0x1ec", + "0x22b", + "0x223", + "0x1fd", + "0x202", + "0x218", + "0x210", + "0x21e", + "0x231", + "0x242", + "0x251", + "0xdf", + "0x1b4", + "0x256", + "0x15d0", + "0x7050705100d0f0b07050705070507050e0d0c0b0a09080706050403020100", + "0x513051a0d0f19110d180b13051716150706050403021413051205110d0f0b", + "0x60504031b051205200d0f191f07060504031b051e051d0d0f190605171c1b", + "0x504032a07070504032905110d260b2805270d260b25051724060523222107", + "0x25053105110d300b2f0d180b022e0a2d0d07070504032c07070504032b0707", + "0x53d2905053c0d3b0d3a0d393802370a3635070605040334053305320d3019", + "0x44060505430605053d42050541060505401e05053f2805053f0605053e0d05", + "0x4a05053d0d494605053d4805053d4705053d05074605074534050544310505", + "0x3d1205053f12050550120505444f0505414e0505414d0505414c0505410d4b", + "0x5442505053f250505500d53070505520705053f1205053c12050551120505", + "0x50556121205552905053d2905053f540505410d0746050745330505442905", + "0x1b0505440d5b5a05053d2805053d0d075a0507450d59580505411b05053f57", + "0x3d0d075e050745130505440d5d060505520605055c5a05055605075a050745", + "0xd62610505410d601305053f0d5f5e0505560d05055205075e0507455e0505", + "0x5105050541131205552505053d6405053d6405053f64050550640505440d63", + "0x1305053c130505516405053c0507570507455705053d0d0757050745280505", + "0x1205120d0d66050d070d616807676413076607050d07050d0d66050d0d0d65", + "0xd0d66050d070d1e054e5e1b0766076905640d130566051305130d69056605", + "0x58055e0d580566050d1b0d5a0566050d690d0d66055e05610d0d66051b0568", + "0x570d25056605575407580d540566050d5a0d57056605585a071e0d58056605", + "0xd070566050705250d640566056405540d130566051305130d280566052505", + "0x66050d290d0d66051e05680d0d66050d070d28076413130528056605280528", + "0xd66050d070d4d4e076a4f33076607296413124f0d290566052905330d2905", + "0xd4a0d310566050d4c0d480566050d4d0d4a0566050d4e0d4c0566050d690d", + "0xd66054205340d06420766054605310d460566053431484a13480d34056605", + "0x5470d6d6c6b001366054705060d47060766050605420d060566050605460d", + "0x56e056b0d6e0566050005000d0d66056d05470d0d66056c05470d0d66056b", + "0x7473721366057105060d71060766050605420d700566056f4c071e0d6f0566", + "0xd760566057305000d0d66057505470d0d66057405470d0d66057205470d75", + "0x66057905060d79060766050605420d780566057770071e0d7705660576056b", + "0x57c05000d0d66057d05470d0d66057b05470d0d66057a05470d7d7c7b7a13", + "0x848382811366050605060d800566057f78071e0d7f0566057e056b0d7e0566", + "0x6b0d850566058405000d0d66058305470d0d66058205470d0d66058105470d", + "0xd660588056d0d898807660587056c0d870566058680071e0d860566058505", + "0x566053305130d8c0566058b05700d8b0566058a056f0d8a05660589056e0d", + "0x8c074f3313058c0566058c05280d070566050705250d4f0566054f05540d33", + "0x71e0d8e0566058e055e0d8e0566050d710d8d0566050d690d0d66050d070d", + "0xd920566059105570d910566058f9007580d900566050d5a0d8f0566058e8d", + "0x920566059205280d070566050705250d4d0566054d05540d4e0566054e0513", + "0x66050d710d930566050d690d0d66051205720d0d66050d070d92074d4e1305", + "0x959607580d960566050d5a0d950566059493071e0d9405660594055e0d9405", + "0x5250d610566056105540d680566056805130d970566056a05570d6a056605", + "0x7050d07050d0d66050d0d0d970761681305970566059705280d0705660507", + "0xd120566051205730d130566051305130d0d66050d070d6168079864130766", + "0x1b05120d0d66050d070d5a05991e0566075e05750d5e1b6912660512130774", + "0x610d0d66055705680d0d66050d070d25059a54570766075805640d58056605", + "0x529055e0d290566050d1b0d280566050d690d0d66051e05340d0d66055405", + "0x5570d4e056605334f07580d4f0566050d5a0d330566052928071e0d290566", + "0x280d070566050705250d640566056405540d690566056905130d4d0566054e", + "0x566050d290d0d66052505680d0d66050d070d4d07646913054d0566054d05", + "0xd0d66050d070d3431079b484a0766074c6469124f0d4c0566054c05330d4c", + "0x47060766050605420d0d66054205340d06420766051e05310d460566050d69", + "0x66056d05470d0d66056c05470d0d66056b05470d6d6c6b001366054705060d", + "0x50605420d700566056f46071e0d6f0566056e056b0d6e0566050005000d0d", + "0x470d0d66057405470d0d66057205470d757473721366057105060d71060766", + "0xd780566057770071e0d7705660576056b0d760566057305000d0d66057505", + "0x57b05470d0d66057a05470d7d7c7b7a1366057905060d7906076605060542", + "0x57f78071e0d7f0566057e056b0d7e0566057c05000d0d66057d05470d0d66", + "0x5470d0d66058205470d0d66058105470d848382811366050605060d800566", + "0x6c0d870566058680071e0d8605660585056b0d850566058405000d0d660583", + "0xd8b0566058a056f0d8a05660589056e0d0d660588056d0d89880766058705", + "0x70566050705250d480566054805540d4a0566054a05130d8c0566058b0570", + "0x50d690d0d66051e05340d0d66050d070d8c07484a13058c0566058c05280d", + "0x50d5a0d8f0566058e8d071e0d8e0566058e055e0d8e0566050d710d8d0566", + "0x5540d310566053105130d920566059105570d910566058f9007580d900566", + "0x50d070d920734311305920566059205280d070566050705250d3405660534", + "0xd940566050d770d930566050d690d0d66051b05720d0d66055a05760d0d66", + "0x56605959607580d960566050d5a0d950566059493071e0d9405660594055e", + "0x66050705250d640566056405540d690566056905130d970566056a05570d6a", + "0x690d0d66051205720d0d66050d070d970764691305970566059705280d0705", + "0x5a0d9e0566059d9c071e0d9d0566059d055e0d9d0566050d710d9c0566050d", + "0xd680566056805130da00566053805570d380566059e9f07580d9f0566050d", + "0xd0da00761681305a0056605a005280d070566050705250d61056605610554", + "0x566051305130d0d66050d070d616807a16413076607050d07050d0d66050d", + "0x5a05a21e0566075e05750d5e1b69126605121307740d120566051205730d13", + "0x5a354570766075805640d0d66050d780d580566051b05120d0d66050d070d", + "0x3305660528057b0d2905660557057a0d280566055405790d0d66050d070d25", + "0x25057a0d4e0566054f057e0d4f0566050d7d0d0d66050d070d0da4050d7c0d", + "0x800d0d66050d070d4c05a54d05660733057f0d330566054e057b0d29056605", + "0x31076607486907820d4805660548055e0d480566054a05810d4a0566054d05", + "0x5a700470766072905640d310566053105130d0d66050d070d06424612a634", + "0x6e0566056c057b0d6d05660547057a0d6c0566050005790d0d66050d070d6b", + "0x6b057a0d700566056f057e0d6f0566050d7d0d0d66050d070d0da8050d7c0d", + "0x800d0d66050d070d7205a9710566076e057f0d6e05660570057b0d6d056605", + "0x75076607743107820d7405660574055e0d740566057305810d730566057105", + "0x130d7b0566057a05840d7a056605763407830d0d66050d070d79787712aa76", + "0xd070d0dab050d7c0d7e0566057b05850d7d0566056d057a0d7c0566057505", + "0x566057705130d0d66053405470d0d66057905470d0d66057805470d0d6605", + "0x3105130d0d66053405470d0d66057205760d0d66050d070d0dac050d7c0d7f", + "0x6d057a0d7c0566057f05870d810566058005860d800566050d7d0d7f056605", + "0xd66054205470d0d66050d070d0dab050d7c0d7e0566058105850d7d056605", + "0x4c05760d0d66050d070d0dad050d7c0d820566054605130d0d66050605470d", + "0x58205870d840566058305860d830566050d7d0d820566056905130d0d6605", + "0xd8605ae850566077e05880d7e0566058405850d7d05660529057a0d7c0566", + "0x680d0d66050d890d0d66050d070d8905af88870766077d05640d0d66050d07", + "0x66050d690d0d66051e05340d0d660585058a0d0d66058805610d0d66058705", + "0x66050d5a0d8c0566058b8a071e0d8b0566058b055e0d8b0566050d1b0d8a05", + "0x6405540d7c0566057c05130d8f0566058e05570d8e0566058c8d07580d8d05", + "0x66050d070d8f07647c13058f0566058f05280d070566050705250d64056605", + "0x660790647c124f0d900566059005330d900566050d290d0d66058905680d0d", + "0x9505b10d660785058b0d910566059105130d0d66050d070d949307b0929107", + "0x66050d8c0d960566050d690d0d66051e05340d0d66050d890d0d66050d070d", + "0x979c07580d9c0566050d5a0d970566056a96071e0d6a0566056a055e0d6a05", + "0x5250d920566059205540d910566059105130d9e0566059d05570d9d056605", + "0xd66050d890d0d66050d070d9e07929113059e0566059e05280d0705660507", + "0xb567078e0d67056605b69f078e0db6b5b4b3b2a0389f696605951e91128d0d", + "0xba056605b2b9078e0db9056605b3b8078e0db8056605b4b7078e0db7056605", + "0x6605bd05910dbebd076605bc05900dbc056605a038078f0dbb0566050d690d", + "0x5bf056c0dbf056605bbbe07940dbb056605bb05930dbe056605be05920d0d", + "0xc305700dc3056605c2056f0dc2056605c1056e0d0d6605c0056d0dc1c00766", + "0x5280d070566050705250d920566059205540dba056605ba05130dc4056605", + "0xd0d660585058a0d0d66050d890d0d66050d070dc40792ba1305c4056605c4", + "0x71e0dc6056605c6055e0dc60566050d710dc50566050d690d0d66051e0534", + "0xdca056605c905570dc9056605c7c807580dc80566050d5a0dc7056605c6c5", + "0xca056605ca05280d070566050705250d940566059405540d93056605930513", + "0x66057d05680d0d66058605760d0d66050d890d0d66050d070dca0794931305", + "0xdcc056605cc055e0dcc0566050d950dcb0566050d690d0d66051e05340d0d", + "0x56605cf05570dcf056605cdce07580dce0566050d5a0dcd056605cccb071e", + "0x6605d005280d070566050705250d640566056405540d7c0566057c05130dd0", + "0xd690d0d66051b05720d0d66055a05760d0d66050d070dd007647c1305d005", + "0xd5a0dd3056605d2d1071e0dd2056605d2055e0dd20566050d770dd1056605", + "0x540d690566056905130dd6056605d505570dd5056605d3d407580dd4056605", + "0xd070dd60764691305d6056605d605280d070566050705250d640566056405", + "0x56605d8055e0dd80566050d710dd70566050d690d0d66051205720d0d6605", + "0x5db05570ddb056605d9da07580dda0566050d5a0dd9056605d8d7071e0dd8", + "0xdc05280d070566050705250d610566056105540d680566056805130ddc0566", + "0xd6405dd13120766070705640d070566050505120ddc0761681305dc056605", + "0x7c0d6905660568057b0d6105660512057a0d680566051305790d0d66050d07", + "0x660564057a0d5e0566051b057e0d1b0566050d7d0d0d66050d070d0dde050d", + "0x69057f0d5a0566051e056e0d1e610766056105960d690566055e057b0d6105", + "0x5e0d250566055405810d540566055805800d0d66050d070d5705df58056607", + "0x5a05720d0d66050d070d4e4f3312e02928076607250d07820d250566052505", + "0x790d0d66050d070d4a05e14c4d0766076105640d280566052805130d0d6605", + "0xd070d0de2050d7c0d3405660548057b0d310566054d057a0d480566054c05", + "0x542057b0d310566054a057a0d4205660546057e0d460566050d7d0d0d6605", + "0x6b05e30005660734057f0d4705660506056e0d06310766053105960d340566", + "0xd6d0566056d055e0d6d0566056c05810d6c0566050005800d0d66050d070d", + "0x6e05130d0d66054705720d0d66050d070d72717012e46f6e0766076d280782", + "0xd760566057405790d0d66050d070d7505e574730766073105640d6e056605", + "0x50d7d0d0d66050d070d0de6050d7c0d7805660576057b0d7705660573057a", + "0x7705960d780566057a057b0d7705660575057a0d7a05660579057e0d790566", + "0xd0d66050d070d7e05e77d05660778057f0d7c0566057b056e0d7b77076605", + "0x76607806e07820d8005660580055e0d800566057f05810d7f0566057d0580", + "0x5640d810566058105130d0d66057c05720d0d66050d070d85848312e88281", + "0x8a05660586057a0d890566058705790d0d66050d070d8805e9878607660777", + "0x8c057e0d8c0566050d7d0d0d66050d070d0dea050d7c0d8b05660589057b0d", + "0x57f0d8e0566058a056e0d8b0566058d057b0d8a05660588057a0d8d056605", + "0xd920566059105810d910566058f05800d0d66050d070d9005eb8f0566078b", + "0x13480d0d66050d070d6a969512ec9493076607928107820d9205660592055e", + "0x566058e05730d930566059305130d9c05660597056a0d9705660594826f29", + "0x6a05470d0d66059605470d0d66050d070d9c8e9312059c0566059c05970d8e", + "0x566059505130d0d66058205470d0d66056f05470d0d66052905470d0d6605", + "0x6f05470d0d66052905470d0d66059005760d0d66050d070d0ded050d7c0d9d", + "0x66059e059c0d9e0566050d7d0d9d0566058105130d0d66058205470d0d6605", + "0x470d0d66050d070d9f8e9d12059f0566059f05970d8e0566058e05730d9f05", + "0x56f05470d0d66057705680d0d66052905470d0d66058505470d0d66058405", + "0x470d0d66057e05760d0d66050d070d0dee050d7c0d380566058305130d0d66", + "0x50d7d0d380566056e05130d0d66056f05470d0d66057705680d0d66052905", + "0x7c381205b2056605b205970d7c0566057c05730db2056605a0059c0da00566", + "0x5680d0d66052905470d0d66057205470d0d66057105470d0d66050d070db2", + "0xd66056b05760d0d66050d070d0def050d7c0db30566057005130d0d660531", + "0x9c0db40566050d7d0db30566052805130d0d66053105680d0d66052905470d", + "0x50d070db547b31205b5056605b505970d470566054705730db5056605b405", + "0xb60566053305130d0d66056105680d0d66054e05470d0d66054f05470d0d66", + "0x50d05130d0d66056105680d0d66055705760d0d66050d070d0df0050d7c0d", + "0x5b705970d5a0566055a05730db705660567059c0d670566050d7d0db60566", + "0x51305060d13070766050705420d12070766050d059d0db75ab61205b70566", + "0x6405000d0d66056905470d0d66056105470d0d66056805470d696168641366", + "0xd5a070766050705420d1e0566055e05071e0d5e0566051b056b0d1b056605", + "0xd66052505470d0d66055405470d0d66055805470d255457581366055a0506", + "0x66050705420d33056605291e071e0d2905660528056b0d280566055705000d", + "0x5470d0d66054d05470d0d66054e05470d4a4c4d4e1366054f05060d4f0707", + "0x60d340566053133071e0d3105660548056b0d480566054c05000d0d66054a", + "0xd0d66050605470d0d66054205470d0d66054605470d470642461366050705", + "0x7660512059e0d6c0566056b34071e0d6b05660500056b0d00056605470500", + "0x570056b0d700566056e05000d0d66056f05470d6f6e0766056d059f0d6d12", + "0x5000d0d66057305470d747307660512059f0d72056605716c071e0d710566", + "0x5770566057705930d770566057672071e0d7605660575056b0d7505660574", + "0x7050d4648470d132948470d130d1207050d4648470d132948470d13647705", + "0x5256407f2050d57290d12290d07f11207050d4648470d132948470d13c412", + "0xf3050d25" + ], + "sierra_program_debug_info": { + "type_names": [], + "libfunc_names": [], + "user_func_names": [] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0xbffc6a437c6d569cf809118ae879d8c29850d01d30ffbd358142e8ca9e2abd", + "function_idx": 1 + }, + { + "selector": "0x1a51b32fb11323778cf7223ce2f741af61cf28f900e59fc300d44e7e8fa1af2", + "function_idx": 2 + }, + { + "selector": "0x363f0fa4491d64ba1b2e461e750e272b424805998f3bd334a5f5b1acaa2aaf5", + "function_idx": 0 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + }, + "abi": [ + { + "type": "impl", + "name": "Uint512", + "interface_name": "u512::u512::IUint512" + }, + { + "type": "struct", + "name": "core::integer::u512", + "members": [ + { + "name": "limb0", + "type": "core::integer::u128" + }, + { + "name": "limb1", + "type": "core::integer::u128" + }, + { + "name": "limb2", + "type": "core::integer::u128" + }, + { + "name": "limb3", + "type": "core::integer::u128" + } + ] + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "interface", + "name": "u512::u512::IUint512", + "items": [ + { + "type": "function", + "name": "get_u512", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u512" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "return_u512", + "inputs": [ + { + "name": "my_u512", + "type": "core::integer::u512" + } + ], + "outputs": [ + { + "type": "core::integer::u512" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "div_u512", + "inputs": [ + { + "name": "my_u512", + "type": "core::integer::u512" + }, + { + "name": "divisor", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "(core::integer::u512, core::integer::u256)" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "u512::u512::TestUint512::Event", + "kind": "enum", + "variants": [] + } + ] +} diff --git a/__tests__/cairo1v2.test.ts b/__tests__/cairo1v2.test.ts index 5520fc876..a83685d0c 100644 --- a/__tests__/cairo1v2.test.ts +++ b/__tests__/cairo1v2.test.ts @@ -6,6 +6,8 @@ import { CairoOptionVariant, CairoResult, CairoResultVariant, + CairoUint256, + CairoUint512, CallData, Calldata, CompiledSierra, @@ -22,6 +24,7 @@ import { shortString, stark, types, + type Uint512, } from '../src'; import { hexToDecimalString } from '../src/utils/num'; import { encodeShortString } from '../src/utils/shortString'; @@ -41,6 +44,8 @@ import { compiledHelloSierra, compiledTuple, compiledTupleCasm, + compiledU512, + compiledU512Casm, getTestAccount, getTestProvider, } from './config/fixtures'; @@ -1178,4 +1183,80 @@ describe('Cairo 1', () => { ); }); }); + + describe('cairo u512 type', () => { + let u512Contract: Contract; + const myU512 = + '0x33333333333333333333333333333333222222222222222222222222222222221111111111111111111111111111111100000000000000000000000000000000'; + const serializedU512 = new CairoUint512({ + limb0: '0x00000000000000000000000000000000', + limb1: '0x11111111111111111111111111111111', + limb2: '0x22222222222222222222222222222222', + limb3: '0x33333333333333333333333333333333', + }); + const myUint256 = new CairoUint256('0x55544444433233223222222122112111111011001'); + + beforeAll(async () => { + const { deploy } = await account.declareAndDeploy({ + contract: compiledU512, + casm: compiledU512Casm, + }); + + u512Contract = new Contract(compiledU512.abi, deploy.contract_address, account); + }); + + test('u512 compile', async () => { + const u512_1: Uint512 = cairo.uint512(myU512); + expect(u512_1).toEqual({ + limb0: '0', + limb1: '22685491128062564230891640495451214097', + limb2: '45370982256125128461783280990902428194', + limb3: '68056473384187692692674921486353642291', + }); + + const myCalldata1 = CallData.compile([u512_1]); + const myCalldata2 = CallData.compile({ my_u512: u512_1 }); + const expected1 = [ + '0', + '22685491128062564230891640495451214097', + '45370982256125128461783280990902428194', + '68056473384187692692674921486353642291', + ]; + expect(myCalldata1).toEqual(expected1); + expect(myCalldata2).toEqual(expected1); + + const myCallData = new CallData(u512Contract.abi); + const myCalldata3 = myCallData.compile('div_u512', { + my_u512: serializedU512, + divisor: myUint256, + }); + const myCalldata4 = myCallData.compile('div_u512', [serializedU512, myUint256]); + const expected2 = [ + '0', + '22685491128062564230891640495451214097', + '45370982256125128461783280990902428194', + '68056473384187692692674921486353642291', + '67973375079109053774543167123544412161', + '22905373764', + ]; + expect(myCalldata3).toEqual(expected2); + expect(myCalldata4).toEqual(expected2); + + const myCall1 = u512Contract.populate('return_u512', { my_u512: serializedU512 }); + const myCall2 = u512Contract.populate('return_u512', [serializedU512]); + expect(myCall1.calldata).toEqual(expected1); + expect(myCall2.calldata).toEqual(expected1); + }); + + test('u512 call', async () => { + const resp1 = await u512Contract.div_u512(myU512, myUint256); + const expected = { + '0': 344041591305341143461698062540412331701024044049418150896694357470676311354588133518143452261258807949095n, + '1': 3408778323931873632420467616107826476746211809497n, + }; + expect(resp1).toEqual(expected); + const resp2 = await u512Contract.call('div_u512', [serializedU512, myUint256]); + expect(resp2).toEqual(expected); + }); + }); }); diff --git a/__tests__/config/fixtures.ts b/__tests__/config/fixtures.ts index 65bfd68f6..9371f9ee9 100644 --- a/__tests__/config/fixtures.ts +++ b/__tests__/config/fixtures.ts @@ -50,6 +50,8 @@ export const compiledC260 = readContractSierra('cairo/cairo260/hello260.sierra') export const compiledC260Casm = readContractSierraCasm('cairo/cairo260/hello260'); export const compiledTuple = readContractSierra('cairo/cairo253/tupleResponse.sierra'); export const compiledTupleCasm = readContractSierraCasm('cairo/cairo253/tupleResponse'); +export const compiledU512 = readContractSierra('cairo/cairo260/u512.sierra'); +export const compiledU512Casm = readContractSierraCasm('cairo/cairo260/u512'); // StarknetId export const compiledStarknetId = readContractSierra('starknetId/identity/identity.sierra'); export const compiledStarknetIdCasm = readContractSierraCasm('starknetId/identity/identity'); diff --git a/__tests__/utils/CairoTypes/uint512.test.ts b/__tests__/utils/CairoTypes/uint512.test.ts new file mode 100644 index 000000000..62437c688 --- /dev/null +++ b/__tests__/utils/CairoTypes/uint512.test.ts @@ -0,0 +1,226 @@ +/* eslint-disable no-new */ +import { UINT_128_MAX, Uint512, num } from '../../../src'; +import { + CairoUint512, + UINT_128_MIN, + UINT_512_MAX, + UINT_512_MIN, +} from '../../../src/utils/cairoDataTypes/uint512'; + +describe('CairoUint512 class test', () => { + test('constructor 1 should throw on < UINT_512_MIN', () => { + expect(() => { + new CairoUint512(UINT_512_MIN - 1n); + }).toThrow('bigNumberish is smaller than UINT_512_MIN'); + }); + + test('constructor 1 should throw on > UINT_512_MAX', () => { + expect(() => { + new CairoUint512(UINT_512_MAX + 1n); + }).toThrow('bigNumberish is bigger than UINT_512_MAX'); + }); + + test('constructor 1 should support BigNumberish', () => { + const case1 = new CairoUint512(10n); + const case2 = new CairoUint512(10); + const case3 = new CairoUint512('10'); + const case4 = new CairoUint512('0xA'); + expect(case1.toBigInt()).toBe(10n); + expect(case2.toBigInt()).toBe(10n); + expect(case3.toBigInt()).toBe(10n); + expect(case4.toBigInt()).toBe(10n); + }); + + test('constructor 2 (limb0, limb1, limb2, limb3)', () => { + const u512 = new CairoUint512(1000, 1001, 1002, 1003); + expect(u512.toApiRequest()).toEqual(['1000', '1001', '1002', '1003']); + }); + + test('constructor 2 should throw out of bounds', () => { + expect(() => { + new CairoUint512(UINT_128_MIN - 1n, 1000, 1000, 1000); + }).toThrow('limb0 is not in the range of a u128 number'); + expect(() => { + new CairoUint512(UINT_128_MAX + 1n, 1000, 1000, 1000); + }).toThrow('limb0 is not in the range of a u128 number'); + expect(() => { + new CairoUint512(1000, UINT_128_MIN - 1n, 1000, 1000); + }).toThrow('limb1 is not in the range of a u128 number'); + expect(() => { + new CairoUint512(1000, UINT_128_MAX + 1n, 1000, 1000); + }).toThrow('limb1 is not in the range of a u128 number'); + expect(() => { + new CairoUint512(1000, 1000, UINT_128_MIN - 1n, 1000); + }).toThrow('limb2 is not in the range of a u128 number'); + expect(() => { + new CairoUint512(1000, 1000, UINT_128_MAX + 1n, 1000); + }).toThrow('limb2 is not in the range of a u128 number'); + expect(() => { + new CairoUint512(1000, 1000, 1000, UINT_128_MIN - 1n); + }).toThrow('limb3 is not in the range of a u128 number'); + expect(() => { + new CairoUint512(1000, 1000, 1000, UINT_128_MAX + 1n); + }).toThrow('limb3 is not in the range of a u128 number'); + }); + + test('constructor 2 should support Uint512 {limb0, limb1, limb2, limb3}', () => { + const cases: Uint512[] = []; + cases[cases.length] = new CairoUint512({ limb0: 1000, limb1: 1001, limb2: 1002, limb3: 1003 }); + cases[cases.length] = new CairoUint512({ + limb0: '1000', + limb1: '1001', + limb2: '1002', + limb3: '1003', + }); + cases[cases.length] = new CairoUint512({ + limb0: 1000n, + limb1: 1001n, + limb2: 1002n, + limb3: 1003n, + }); + cases[cases.length] = new CairoUint512({ + limb0: '0x3e8', + limb1: '0x3e9', + limb2: '0x3ea', + limb3: '0x3eb', + }); + expect( + cases.every((it) => { + return it.limb0 === 1000n && it.limb1 === 1001n && it.limb2 === 1002n && it.limb3 === 1003n; + }) + ).toEqual(true); + }); + + test('constructor 3 ({limb0, limb1, limb2, limb3})', () => { + const u512 = new CairoUint512({ limb0: 1000, limb1: 1001, limb2: 1002, limb3: 1003 }); + expect(u512.toApiRequest()).toEqual(['1000', '1001', '1002', '1003']); + }); + + test('constructor 3 should throw out of bounds', () => { + expect(() => { + new CairoUint512({ limb0: UINT_128_MIN - 1n, limb1: 1001, limb2: 1002, limb3: 1003 }); + }).toThrow('limb0 is not in the range of a u128 number'); + expect(() => { + new CairoUint512({ limb0: UINT_128_MAX + 1n, limb1: 1001, limb2: 1002, limb3: 1003 }); + }).toThrow('limb0 is not in the range of a u128 number'); + expect(() => { + new CairoUint512({ limb0: 1000, limb1: UINT_128_MIN - 1n, limb2: 1002, limb3: 1003 }); + }).toThrow('limb1 is not in the range of a u128 number'); + expect(() => { + new CairoUint512({ limb0: 1000, limb1: UINT_128_MAX + 1n, limb2: 1002, limb3: 1003 }); + }).toThrow('limb1 is not in the range of a u128 number'); + expect(() => { + new CairoUint512({ limb0: 1000, limb1: 1001, limb2: UINT_128_MIN - 1n, limb3: 1003 }); + }).toThrow('limb2 is not in the range of a u128 number'); + expect(() => { + new CairoUint512({ limb0: 1000, limb1: 1001, limb2: UINT_128_MAX + 1n, limb3: 1003 }); + }).toThrow('limb2 is not in the range of a u128 number'); + expect(() => { + new CairoUint512({ limb0: 1000, limb1: 1001, limb2: 1002, limb3: UINT_128_MIN - 1n }); + }).toThrow('limb3 is not in the range of a u128 number'); + expect(() => { + new CairoUint512({ limb0: 1000, limb1: 1001, limb2: 1002, limb3: UINT_128_MAX + 1n }); + }).toThrow('limb3 is not in the range of a u128 number'); + }); + + test('validate should throw on < UINT_512_MIN', () => { + expect(() => { + CairoUint512.validate(UINT_512_MIN - 1n); + }).toThrow('bigNumberish is smaller than UINT_512_MIN'); + }); + + test('validate should throw on > UINT_512_MAX', () => { + expect(() => { + CairoUint512.validate(UINT_512_MAX + 1n); + }).toThrow('bigNumberish is bigger than UINT_512_MAX'); + }); + + test('validate should pass and return bigint', () => { + const validate = CairoUint512.validate(UINT_512_MAX); + expect(typeof validate).toBe('bigint'); + }); + + test('validateProps should pass', () => { + expect(CairoUint512.validateProps(1000, 1001, 1002, 1003)).toEqual({ + limb0: 1000n, + limb1: 1001n, + limb2: 1002n, + limb3: 1003n, + }); + }); + + test('validateProps out of range', () => { + expect(() => { + CairoUint512.validateProps(UINT_128_MIN - 1n, 1001, 1002, 1003); + }).toThrow('limb0 is not in the range of a u128 number'); + expect(() => { + CairoUint512.validateProps(UINT_128_MAX + 1n, 1001, 1002, 1003); + }).toThrow('limb0 is not in the range of a u128 number'); + expect(() => { + CairoUint512.validateProps(1000, UINT_128_MIN - 1n, 1002, 1003); + }).toThrow('limb1 is not in the range of a u128 number'); + expect(() => { + CairoUint512.validateProps(1000, UINT_128_MAX + 1n, 1002, 1003); + }).toThrow('limb1 is not in the range of a u128 number'); + expect(() => { + CairoUint512.validateProps(1000, 1001, UINT_128_MIN - 1n, 1003); + }).toThrow('limb2 is not in the range of a u128 number'); + expect(() => { + CairoUint512.validateProps(1000, 1001, UINT_128_MAX + 1n, 1003); + }).toThrow('limb2 is not in the range of a u128 number'); + expect(() => { + CairoUint512.validateProps(1000, 1001, 1002, UINT_128_MIN - 1n); + }).toThrow('limb3 is not in the range of a u128 number'); + expect(() => { + CairoUint512.validateProps(1000, 1001, 1002, UINT_128_MAX + 1n); + }).toThrow('limb3 is not in the range of a u128 number'); + }); + + test('isAbiType', () => { + expect(CairoUint512.isAbiType('core::integer::u512')).toBe(true); + }); + + test('is should return true', () => { + const is = CairoUint512.is(UINT_512_MIN); + expect(is).toBe(true); + }); + + test('is should return false', () => { + const is = CairoUint512.is(UINT_512_MAX + 1n); + expect(is).toBe(false); + }); + + test('should convert UINT_512_MAX to Uint512 bigint', () => { + const numb = + '0x33333333333333333333333333333333222222222222222222222222222222221111111111111111111111111111111100000000000000000000000000000000'; + const u512 = new CairoUint512(numb); + const u512bigint = u512.toBigInt(); + expect(num.toHex(u512bigint)).toBe(numb); + }); + + test('should convert UINT_512_MAX to Uint512 dec struct', () => { + const numb = + '0x33333333333333333333333333333333222222222222222222222222222222221111111111111111111111111111111100000000000000000000000000000000'; + const u512 = new CairoUint512(numb); + const u512Hex = u512.toUint512DecimalString(); + expect(u512Hex).toEqual({ + limb0: '0', + limb1: '22685491128062564230891640495451214097', + limb2: '45370982256125128461783280990902428194', + limb3: '68056473384187692692674921486353642291', + }); + }); + + test('should convert UINT_512_MAX to Uint512 hex struct', () => { + const numb = + '0x33333333333333333333333333333333222222222222222222222222222222221111111111111111111111111111111100000000000000000000000000000000'; + const u512 = new CairoUint512(numb); + const u512Decimal = u512.toUint512HexString(); + expect(u512Decimal).toEqual({ + limb0: '0x0', + limb1: '0x11111111111111111111111111111111', + limb2: '0x22222222222222222222222222222222', + limb3: '0x33333333333333333333333333333333', + }); + }); +}); diff --git a/__tests__/utils/uint256.test.ts b/__tests__/utils/uint256.test.ts index f78332d95..c838f837c 100644 --- a/__tests__/utils/uint256.test.ts +++ b/__tests__/utils/uint256.test.ts @@ -25,6 +25,24 @@ describe('cairo uint256', () => { `); }); + test('uint512 should not convert -1 to uint512 dec struct', () => { + expect(() => { + cairo.uint512(-1n); + }).toThrow('bigNumberish is smaller than UINT_512_MIN'); + }); + + test('uint512 should convert to uint512 dec struct', () => { + const uint512 = cairo.uint512( + '0x33333333333333333333333333333333222222222222222222222222222222221111111111111111111111111111111100000000000000000000000000000000' + ); + expect(uint512).toEqual({ + limb0: '0', + limb1: '22685491128062564230891640495451214097', + limb2: '45370982256125128461783280990902428194', + limb3: '68056473384187692692674921486353642291', + }); + }); + test('should convert 0 from BN to uint256 struct', () => { const uint256 = bnToUint256(0n); expect(uint256).toMatchInlineSnapshot(` diff --git a/src/index.ts b/src/index.ts index 3a2c4576e..a45cdc5c6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,6 +34,8 @@ export * as starknetId from './utils/starknetId'; export * as provider from './utils/provider'; export * as selector from './utils/selector'; export * as events from './utils/events/index'; +export * from './utils/cairoDataTypes/uint256'; +export * from './utils/cairoDataTypes/uint512'; export * from './utils/address'; export * from './utils/url'; export * from './utils/calldata'; diff --git a/src/types/calldata.ts b/src/types/calldata.ts index ae5558726..7e5203b71 100644 --- a/src/types/calldata.ts +++ b/src/types/calldata.ts @@ -11,6 +11,7 @@ export enum Uint { u64 = 'core::integer::u64', u128 = 'core::integer::u128', u256 = 'core::integer::u256', // This one is struct + u512 = 'core::integer::u512', // This one is struct } export enum Literal { diff --git a/src/types/lib/index.ts b/src/types/lib/index.ts index db718e7ad..d70f2d9de 100644 --- a/src/types/lib/index.ts +++ b/src/types/lib/index.ts @@ -32,6 +32,18 @@ export interface Uint256 { high: BigNumberish; } +/** + * Represents an integer in the range [0, 2^256) + */ +export interface Uint512 { + // The lowest 128 bits of the value + limb0: BigNumberish; + limb1: BigNumberish; + limb2: BigNumberish; + // The higher 128 bits of the value + limb3: BigNumberish; +} + /** * BigNumberish array * use CallData.compile() to convert to Calldata diff --git a/src/utils/cairoDataTypes/uint512.ts b/src/utils/cairoDataTypes/uint512.ts new file mode 100644 index 000000000..9f6e2d4c2 --- /dev/null +++ b/src/utils/cairoDataTypes/uint512.ts @@ -0,0 +1,176 @@ +/* eslint-disable no-bitwise */ +/** + * Singular class handling cairo u512 data type + */ + +import { BigNumberish, type Uint512 } from '../../types'; +import { addHexPrefix } from '../encode'; +import { CairoFelt } from './felt'; +import { UINT_128_MAX } from './uint256'; + +export const UINT_512_MAX = (1n << 512n) - 1n; +export const UINT_512_MIN = 0n; +export const UINT_128_MIN = 0n; + +export class CairoUint512 { + public limb0: bigint; + + public limb1: bigint; + + public limb2: bigint; + + public limb3: bigint; + + static abiSelector = 'core::integer::u512'; + + /** + * Default constructor (Lib usage) + * @param bigNumberish BigNumberish value representing u512 + */ + public constructor(bigNumberish: BigNumberish); + /** + * Direct props initialization (Api response) + */ + public constructor( + limb0: BigNumberish, + limb1: BigNumberish, + limb2: BigNumberish, + limb3: BigNumberish + ); + /** + * Initialization from Uint512 object + */ + public constructor(uint512: Uint512); + + public constructor(...arr: any[]) { + if ( + typeof arr[0] === 'object' && + arr.length === 1 && + 'limb0' in arr[0] && + 'limb1' in arr[0] && + 'limb2' in arr[0] && + 'limb3' in arr[0] + ) { + const props = CairoUint512.validateProps( + arr[0].limb0, + arr[0].limb1, + arr[0].limb2, + arr[0].limb3 + ); + this.limb0 = props.limb0; + this.limb1 = props.limb1; + this.limb2 = props.limb2; + this.limb3 = props.limb3; + } else if (arr.length === 1) { + const bigInt = CairoUint512.validate(arr[0]); + this.limb0 = bigInt & UINT_128_MAX; + this.limb1 = (bigInt & (UINT_128_MAX << 128n)) >> 128n; + this.limb2 = (bigInt & (UINT_128_MAX << 256n)) >> 256n; + this.limb3 = bigInt >> 384n; + } else if (arr.length === 4) { + const props = CairoUint512.validateProps(arr[0], arr[1], arr[2], arr[3]); + this.limb0 = props.limb0; + this.limb1 = props.limb1; + this.limb2 = props.limb2; + this.limb3 = props.limb3; + } else { + throw Error('Incorrect Uint512 constructor parameters'); + } + } + + /** + * Validate if BigNumberish can be represented as Uint512 + */ + static validate(bigNumberish: BigNumberish): bigint { + const bigInt = BigInt(bigNumberish); + if (bigInt < UINT_512_MIN) throw Error('bigNumberish is smaller than UINT_512_MIN.'); + if (bigInt > UINT_512_MAX) throw Error('bigNumberish is bigger than UINT_512_MAX.'); + return bigInt; + } + + /** + * Validate if limbs can be represented as Uint512 + */ + static validateProps( + limb0: BigNumberish, + limb1: BigNumberish, + limb2: BigNumberish, + limb3: BigNumberish + ): { limb0: bigint; limb1: bigint; limb2: bigint; limb3: bigint } { + const l0 = BigInt(limb0); + const l1 = BigInt(limb1); + const l2 = BigInt(limb2); + const l3 = BigInt(limb3); + [l0, l1, l2, l3].forEach((value: bigint, index) => { + if (value < UINT_128_MIN || value > UINT_128_MAX) { + throw Error(`limb${index} is not in the range of a u128 number`); + } + }); + return { limb0: l0, limb1: l1, limb2: l2, limb3: l3 }; + } + + /** + * Check if BigNumberish can be represented as Uint512 + */ + static is(bigNumberish: BigNumberish): boolean { + try { + CairoUint512.validate(bigNumberish); + } catch (error) { + return false; + } + return true; + } + + /** + * Check if provided abi type is this data type + */ + static isAbiType(abiType: string): boolean { + return abiType === CairoUint512.abiSelector; + } + + /** + * Return bigint representation + */ + toBigInt(): bigint { + return (this.limb3 << 384n) + (this.limb2 << 256n) + (this.limb1 << 128n) + this.limb0; + } + + /** + * Return Uint512 structure with HexString props + * limbx: HexString + */ + toUint512HexString() { + return { + limb0: addHexPrefix(this.limb0.toString(16)), + limb1: addHexPrefix(this.limb1.toString(16)), + limb2: addHexPrefix(this.limb2.toString(16)), + limb3: addHexPrefix(this.limb3.toString(16)), + }; + } + + /** + * Return Uint512 structure with DecimalString props + * limbx DecString + */ + toUint512DecimalString() { + return { + limb0: this.limb0.toString(10), + limb1: this.limb1.toString(10), + limb2: this.limb2.toString(10), + limb3: this.limb3.toString(10), + }; + } + + /** + * Return api requests representation witch is felt array + */ + toApiRequest(): string[] { + // lower limb first : https://github.com/starkware-libs/cairo/blob/07484c52791b76abcc18fd86265756904557d0d2/corelib/src/test/integer_test.cairo#L767 + return [ + CairoFelt(this.limb0), + CairoFelt(this.limb1), + CairoFelt(this.limb2), + CairoFelt(this.limb3), + ]; + } +} diff --git a/src/utils/calldata/cairo.ts b/src/utils/calldata/cairo.ts index a049b969d..8a6e63441 100644 --- a/src/utils/calldata/cairo.ts +++ b/src/utils/calldata/cairo.ts @@ -7,9 +7,11 @@ import { Literal, Uint, Uint256, + Uint512, } from '../../types'; import { CairoFelt } from '../cairoDataTypes/felt'; import { CairoUint256 } from '../cairoDataTypes/uint256'; +import { CairoUint512 } from '../cairoDataTypes/uint512'; // Intended for internal usage, maybe should be exported somewhere else and not exported to utils export const isLen = (name: string) => /_len$/.test(name); @@ -104,6 +106,19 @@ export const uint256 = (it: BigNumberish): Uint256 => { return new CairoUint256(it).toUint256DecimalString(); }; +/** + * Create Uint512 Cairo type (helper for common struct type) + * @param it BigNumberish representation of a 512 bits unsigned number + * @returns Uint512 struct + * @example + * ```typescript + * uint512('345745685892349863487563453485768723498'); + * ``` + */ +export const uint512 = (it: BigNumberish): Uint512 => { + return new CairoUint512(it).toUint512DecimalString(); +}; + /** * Create unnamed tuple Cairo type (helper same as common struct type) * @example diff --git a/src/utils/calldata/propertyOrder.ts b/src/utils/calldata/propertyOrder.ts index 8fc9916d3..cf6847472 100644 --- a/src/utils/calldata/propertyOrder.ts +++ b/src/utils/calldata/propertyOrder.ts @@ -1,5 +1,6 @@ import { AbiEntry, AbiEnums, AbiStructs, CairoEnum, RawArgsObject } from '../../types'; import { CairoUint256 } from '../cairoDataTypes/uint256'; +import { CairoUint512 } from '../cairoDataTypes/uint512'; import { getArrayType, isCairo1Type, @@ -29,6 +30,13 @@ function errorU256(key: string) { `Your object includes the property : ${key}, containing an Uint256 object without the 'low' and 'high' keys.` ); } + +function errorU512(key: string) { + return Error( + `Your object includes the property : ${key}, containing an Uint512 object without the 'limb0' to 'limb3' keys.` + ); +} + export default function orderPropsByAbi( unorderedObject: RawArgsObject, abiOfObject: AbiEntry[], @@ -64,6 +72,17 @@ export default function orderPropsByAbi( } return { low: u256.low, high: u256.high }; } + if (CairoUint512.isAbiType(abiType)) { + const u512 = unorderedItem; + if (typeof u512 !== 'object') { + // BigNumberish --> just copy + return u512; + } + if (!['limb0', 'limb1', 'limb2', 'limb3'].every((key) => key in u512)) { + throw errorU512(abiType); + } + return { limb0: u512.limb0, limb1: u512.limb1, limb2: u512.limb2, limb3: u512.limb3 }; + } if (isTypeStruct(abiType, structs)) { const abiOfStruct = structs[abiType].members; // eslint-disable-next-line @typescript-eslint/no-use-before-define diff --git a/src/utils/calldata/requestParser.ts b/src/utils/calldata/requestParser.ts index f7fb61382..68cf78cf0 100644 --- a/src/utils/calldata/requestParser.ts +++ b/src/utils/calldata/requestParser.ts @@ -9,6 +9,7 @@ import { Tupled, } from '../../types'; import { CairoUint256 } from '../cairoDataTypes/uint256'; +import { CairoUint512 } from '../cairoDataTypes/uint512'; import { encodeShortString, isString, isText, splitLongString } from '../shortString'; import { byteArrayFromString } from './byteArray'; import { @@ -41,6 +42,8 @@ function parseBaseTypes(type: string, val: BigNumberish) { switch (true) { case CairoUint256.isAbiType(type): return new CairoUint256(val).toApiRequest(); + case CairoUint512.isAbiType(type): + return new CairoUint512(val).toApiRequest(); case isTypeBytes31(type): return encodeShortString(val.toString()); default: @@ -125,7 +128,9 @@ function parseCalldataValue( if (CairoUint256.isAbiType(type)) { return new CairoUint256(element as any).toApiRequest(); } - + if (CairoUint512.isAbiType(type)) { + return new CairoUint512(element as any).toApiRequest(); + } if (type === 'core::starknet::eth_address::EthAddress') return parseBaseTypes(type, element as BigNumberish); @@ -151,6 +156,10 @@ function parseCalldataValue( if (CairoUint256.isAbiType(type)) { return new CairoUint256(element as any).toApiRequest(); } + // check if u512 + if (CairoUint512.isAbiType(type)) { + return new CairoUint512(element as any).toApiRequest(); + } // check if Enum if (isTypeEnum(type, enums)) { const { variants } = enums[type]; @@ -275,7 +284,10 @@ export function parseCalldataField( case type === 'core::starknet::eth_address::EthAddress': return parseBaseTypes(type, value); // Struct or Tuple - case isTypeStruct(type, structs) || isTypeTuple(type) || CairoUint256.isAbiType(type): + case isTypeStruct(type, structs) || + isTypeTuple(type) || + CairoUint256.isAbiType(type) || + CairoUint256.isAbiType(type): return parseCalldataValue(value as ParsedStruct | BigNumberish[], type, structs, enums); // Enums diff --git a/src/utils/calldata/responseParser.ts b/src/utils/calldata/responseParser.ts index 9744fb25e..ffe90e5e7 100644 --- a/src/utils/calldata/responseParser.ts +++ b/src/utils/calldata/responseParser.ts @@ -11,6 +11,7 @@ import { ParsedStruct, } from '../../types'; import { CairoUint256 } from '../cairoDataTypes/uint256'; +import { CairoUint512 } from '../cairoDataTypes/uint512'; import { toHex } from '../num'; import { decodeShortString } from '../shortString'; import { stringFromByteArray } from './byteArray'; @@ -50,6 +51,12 @@ function parseBaseTypes(type: string, it: Iterator) { const low = it.next().value; const high = it.next().value; return new CairoUint256(low, high).toBigInt(); + case CairoUint512.isAbiType(type): + const limb0 = it.next().value; + const limb1 = it.next().value; + const limb2 = it.next().value; + const limb3 = it.next().value; + return new CairoUint512(limb0, limb1, limb2, limb3).toBigInt(); case type === 'core::starknet::eth_address::EthAddress': temp = it.next().value; return BigInt(temp); @@ -85,7 +92,14 @@ function parseResponseValue( const high = responseIterator.next().value; return new CairoUint256(low, high).toBigInt(); } - + // type uint512 struct + if (CairoUint512.isAbiType(element.type)) { + const limb0 = responseIterator.next().value; + const limb1 = responseIterator.next().value; + const limb2 = responseIterator.next().value; + const limb3 = responseIterator.next().value; + return new CairoUint512(limb0, limb1, limb2, limb3).toBigInt(); + } // type C1 ByteArray struct, representing a LongString if (isTypeByteArray(element.type)) { const parsedBytes31Arr: BigNumberish[] = []; diff --git a/src/utils/calldata/validate.ts b/src/utils/calldata/validate.ts index 56b4e28fb..6c89c16f7 100644 --- a/src/utils/calldata/validate.ts +++ b/src/utils/calldata/validate.ts @@ -13,6 +13,7 @@ import { } from '../../types'; import assert from '../assert'; import { CairoUint256 } from '../cairoDataTypes/uint256'; +import { CairoUint512 } from '../cairoDataTypes/uint512'; import { isBigInt, isBoolean, isHex, isNumber, toBigInt } from '../num'; import { isLongText, isString } from '../shortString'; import { @@ -69,14 +70,24 @@ const validateUint = (parameter: any, input: AbiEntry) => { isString(parameter) || isNumber(parameter) || isBigInt(parameter) || - (typeof parameter === 'object' && 'low' in parameter && 'high' in parameter), + (typeof parameter === 'object' && 'low' in parameter && 'high' in parameter) || + (typeof parameter === 'object' && + ['limb0', 'limb1', 'limb2', 'limb3'].every((key) => key in parameter)), `Validate: arg ${input.name} of cairo type ${ input.type } should be type (String, Number or BigInt), but is ${typeof parameter} ${parameter}.` ); - const param = - typeof parameter === 'object' ? new CairoUint256(parameter).toBigInt() : toBigInt(parameter); - + let param: bigint; + switch (input.type) { + case Uint.u256: + param = new CairoUint256(parameter).toBigInt(); + break; + case Uint.u512: + param = new CairoUint512(parameter).toBigInt(); + break; + default: + param = toBigInt(parameter); + } switch (input.type) { case Uint.u8: assert( @@ -120,6 +131,10 @@ const validateUint = (parameter: any, input: AbiEntry) => { ); break; + case Uint.u512: + assert(CairoUint512.is(param), `Validate: arg ${input.name} is ${input.type} 0 - 2^512-1`); + break; + case Literal.ClassHash: assert( // from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1670 @@ -148,8 +163,8 @@ const validateBool = (parameter: any, input: AbiEntry) => { }; const validateStruct = (parameter: any, input: AbiEntry, structs: AbiStructs) => { - // c1v2 uint256 in struct - if (input.type === Uint.u256) { + // c1v2 uint256 or u512 in struct + if (input.type === Uint.u256 || input.type === Uint.u512) { validateUint(parameter, input); return; } @@ -251,7 +266,7 @@ const validateArray = (parameter: any, input: AbiEntry, structs: AbiStructs, enu parameter.forEach((it: any) => validateEnum(it, { name: input.name, type: baseType })); break; case isTypeUint(baseType) || isTypeLiteral(baseType): - parameter.forEach((param: BigNumberish) => validateUint(param, input)); + parameter.forEach((param: BigNumberish) => validateUint(param, { name: '', type: baseType })); break; case isTypeBool(baseType): parameter.forEach((param: BigNumberish) => validateBool(param, input)); diff --git a/www/docs/guides/define_call_message.md b/www/docs/guides/define_call_message.md index 26fd66e90..b7cdb55be 100644 --- a/www/docs/guides/define_call_message.md +++ b/www/docs/guides/define_call_message.md @@ -94,6 +94,32 @@ const a2: Uint256 = { const a3: Uint256 = { low: a1.low, high: a1.high }; ``` +### u512 + +Starknet is waiting for 4 u128, the first one has the lowest weight. +You can send to Starknet.js methods: bigNumberish or Uint512 object. + +```typescript +await myContract0.my_function(553844998243714947043252949842317834769n); +await myContract1.my_function( + cairo.uint512( + '0xa9d2d1501ad0a2eb5337a9d2d1501ad0a2eb5337a9d2d1501ad0a2eb5337a9d2d1501ad0a2eb5337a9d2d1501ad0a2eb5337' + ) +); +await myContract2.my_function(12345678, '13456789765', '0xe23a40b543f', 1534566734334n); +``` + +In specific cases, you can use an object, with the following format: + +```typescript +const a2: Uint512 = { + limb0: '0xeb5337d9a885be310x9365205a414fdd', + limb1: '0x1fd465baff2ba9d2d1501ad0a2eb5337', + limb2: '0x05f7cd1fd465baff2ba9d2d1501ad0a2', + limb3: '0x2eb5337d9a885be319366b5205a414fd', +}; +``` + ### shortString or bytes31 For a shortString, Starknet is waiting for a felt, including 31 ASCII characters max. @@ -469,6 +495,7 @@ const amount = myContract.call(...); | | | string representing an hex number | `const res=myContract.call(...`
`const address: string = num.toHex(res);` | | u8, u16, u32, usize | `func get_v() -> u16` | number (53 bits max) | `const res=myContract.call(...`
`const total: number = Number(res)` | | u256 (255 bits max) | `func get_v() -> u256` | bigint | `const res: bigint = myContract.call(...` | +| u512 (512 bits max) | `func get_v() -> u512` | bigint | `const res: bigint = myContract.call(...` | | array of u8, u16, u32, usize, u64, u128, felt252, address | `func get_v() -> Array` | bigint[] | `const res: bigint[] = myContract.call(...` | | bytes31 (31 ASCII characters max) | `func get_v() -> bytes31` | string | `const res: string = myContract.call(...` | | felt252 (31 ASCII characters max) | `func get_v() -> felt252` | string | `const res = myContract.call(...`
`const title:string = shortString.decodeShortstring(res);` |