Skip to content

Commit

Permalink
Fix detection of Abi version in contract with only constructor (#1243)
Browse files Browse the repository at this point in the history
* fix: getAbiVersion doesn't work on contracts without any function

* fix: getAbiVersion doesn't work on contracts without any function
  • Loading branch information
taco-paco authored Oct 7, 2024
1 parent 312aa13 commit 6bd26a1
Show file tree
Hide file tree
Showing 8 changed files with 467 additions and 7 deletions.
15 changes: 15 additions & 0 deletions __mocks__/cairo/onlyConstructor/onlyConstructor.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[starknet::contract]
pub mod OnlyConstructor {
use starknet::ContractAddress;
use starknet::storage::Map;

#[storage]
struct Storage {
names: Map::<ContractAddress, felt252>,
}

#[constructor]
fn constructor(ref self: ContractState, name: felt252, address: ContractAddress) {
self.names.write(address, name);
}
}
1 change: 1 addition & 0 deletions __mocks__/cairo/onlyConstructor/onlyConstructor.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"prime":"0x800000000000011000000000000000000000000000000000000000000000001","compiler_version":"2.8.2","bytecode":["0xa0680017fff8000","0x7","0x482680017ffa8000","0x100000000000000000000000000000000","0x400280007ff97fff","0x10780017fff7fff","0xec","0x4825800180007ffa","0x0","0x400280007ff97fff","0x482680017ff98000","0x1","0x48297ffc80007ffd","0x20680017fff7fff","0x4","0x10780017fff7fff","0xa","0x482680017ffc8000","0x1","0x480a7ffd7fff8000","0x480680017fff8000","0x0","0x480280007ffc8000","0x10780017fff7fff","0x8","0x480a7ffc7fff8000","0x480a7ffd7fff8000","0x480680017fff8000","0x1","0x480680017fff8000","0x0","0x20680017fff7ffe","0xc3","0x48307ffc80007ffd","0x20680017fff7fff","0x4","0x10780017fff7fff","0xa","0x482480017ffb8000","0x1","0x48127ffb7fff8000","0x480680017fff8000","0x0","0x480080007ff88000","0x10780017fff7fff","0x8","0x48127ffb7fff8000","0x48127ffb7fff8000","0x480680017fff8000","0x1","0x480680017fff8000","0x0","0x20680017fff7ffe","0x9c","0xa0680017fff8004","0xe","0x4824800180047ffe","0x800000000000000000000000000000000000000000000000000000000000000","0x484480017ffe8000","0x110000000000000000","0x48307ffe7fff8002","0x480080007ff17ffc","0x480080017ff07ffc","0x402480017ffb7ffd","0xffffffffffffffeeffffffffffffffff","0x400080027fef7ffd","0x10780017fff7fff","0x8a","0x484480017fff8001","0x8000000000000000000000000000000","0x48307fff80007ffd","0x480080007ff27ffd","0x480080017ff17ffd","0x402480017ffc7ffe","0xf8000000000000000000000000000000","0x400080027ff07ffe","0x482480017ff08000","0x3","0x48307ff680007ff7","0x20680017fff7fff","0x4","0x10780017fff7fff","0x11","0x40780017fff7fff","0x1","0x480680017fff8000","0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473","0x400080007ffe7fff","0x480a7ff87fff8000","0x48127ffb7fff8000","0x48127fe97fff8000","0x480a7ffb7fff8000","0x480680017fff8000","0x1","0x48127ff97fff8000","0x482480017ff88000","0x1","0x208b7fff7fff7ffe","0x1104800180018000","0x9f","0x482480017fff8000","0x9e","0x480080007fff8000","0x480080007fff8000","0x482480017fff8000","0x1eb4","0xa0680017fff8000","0x8","0x48307ffe80007fe6","0x482480017fff8000","0x100000000000000000000000000000000","0x400080007ff57fff","0x10780017fff7fff","0x4c","0x48307ffe80007fe6","0x400080007ff67fff","0x480680017fff8000","0x968a09a4841848cf6a616f8edef20d474b416f4e8fa338d2c6ff1c1b7cda16","0x400280007ff87fff","0x400280017ff87fef","0x480280027ff88000","0xa0680017fff8005","0xe","0x4824800180057ffe","0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00","0x484480017ffe8000","0x110000000000000000","0x48307ffe7fff8003","0x480080017ff07ffc","0x480080027fef7ffc","0x482480017ffb7ffd","0xffffffffffffffeefffffffffffffeff","0x400080037fed7ffc","0x10780017fff7fff","0x11","0x48127ffe7fff8005","0x484480017ffe8000","0x8000000000000000000000000000000","0x48307ffe7fff8003","0x480080017ff07ffd","0x482480017ffc7ffe","0xf0000000000000000000000000000100","0x480080027fee7ffd","0x400080037fed7ff9","0x402480017ffd7ff9","0xffffffffffffffffffffffffffffffff","0x20680017fff7ffd","0x4","0x402780017fff7fff","0x1","0x480680017fff8000","0x0","0x482680017ff88000","0x3","0x482480017feb8000","0x4","0x480680017fff8000","0x53746f726167655772697465","0x400280007ffb7fff","0x400280017ffb7ff2","0x400280027ffb7ffc","0x400280037ffb7ffb","0x400280047ffb7fde","0x480280067ffb8000","0x20680017fff7fff","0xe","0x40780017fff7fff","0x1","0x48127ffb7fff8000","0x48127ffb7fff8000","0x480280057ffb8000","0x482680017ffb8000","0x7","0x480680017fff8000","0x0","0x48127ffa7fff8000","0x48127ff97fff8000","0x208b7fff7fff7ffe","0x48127ffc7fff8000","0x48127ffc7fff8000","0x480280057ffb8000","0x482680017ffb8000","0x9","0x480680017fff8000","0x1","0x480280077ffb8000","0x480280087ffb8000","0x208b7fff7fff7ffe","0x40780017fff7fff","0x1","0x480680017fff8000","0x4f7574206f6620676173","0x400080007ffe7fff","0x480a7ff87fff8000","0x482480017ff28000","0x1","0x48127fe07fff8000","0x480a7ffb7fff8000","0x480680017fff8000","0x1","0x48127ff97fff8000","0x482480017ff88000","0x1","0x208b7fff7fff7ffe","0x482480017fef8000","0x3","0x10780017fff7fff","0x5","0x40780017fff7fff","0x6","0x48127fef7fff8000","0x40780017fff7fff","0x1","0x480680017fff8000","0x4661696c656420746f20646573657269616c697a6520706172616d202332","0x400080007ffe7fff","0x480a7ff87fff8000","0x48127ffc7fff8000","0x48127fe97fff8000","0x480a7ffb7fff8000","0x480680017fff8000","0x1","0x48127ff97fff8000","0x482480017ff88000","0x1","0x208b7fff7fff7ffe","0x40780017fff7fff","0x1","0x480680017fff8000","0x4661696c656420746f20646573657269616c697a6520706172616d202331","0x400080007ffe7fff","0x480a7ff87fff8000","0x48127ff77fff8000","0x48127ff57fff8000","0x480a7ffb7fff8000","0x480680017fff8000","0x1","0x48127ff97fff8000","0x482480017ff88000","0x1","0x208b7fff7fff7ffe","0x40780017fff7fff","0x1","0x480680017fff8000","0x4f7574206f6620676173","0x400080007ffe7fff","0x480a7ff87fff8000","0x482680017ff98000","0x1","0x480a7ffa7fff8000","0x480a7ffb7fff8000","0x480680017fff8000","0x1","0x48127ff97fff8000","0x482480017ff88000","0x1","0x208b7fff7fff7ffe"],"bytecode_segment_lengths":[257],"hints":[[0,[{"TestLessThanOrEqual":{"lhs":{"Immediate":"0x0"},"rhs":{"Deref":{"register":"FP","offset":-6}},"dst":{"register":"AP","offset":0}}}]],[54,[{"TestLessThan":{"lhs":{"Deref":{"register":"AP","offset":-1}},"rhs":{"Immediate":"0x800000000000000000000000000000000000000000000000000000000000000"},"dst":{"register":"AP","offset":4}}}]],[58,[{"LinearSplit":{"value":{"Deref":{"register":"AP","offset":3}},"scalar":{"Immediate":"0x110000000000000000"},"max_x":{"Immediate":"0xffffffffffffffffffffffffffffffff"},"x":{"register":"AP","offset":-2},"y":{"register":"AP","offset":-1}}}]],[68,[{"LinearSplit":{"value":{"Deref":{"register":"AP","offset":-2}},"scalar":{"Immediate":"0x8000000000000000000000000000000"},"max_x":{"Immediate":"0xffffffffffffffffffffffffffffffff"},"x":{"register":"AP","offset":-1},"y":{"register":"AP","offset":0}}}]],[83,[{"AllocSegment":{"dst":{"register":"AP","offset":0}}}]],[106,[{"TestLessThanOrEqual":{"lhs":{"Deref":{"register":"AP","offset":-1}},"rhs":{"Deref":{"register":"AP","offset":-25}},"dst":{"register":"AP","offset":0}}}]],[121,[{"TestLessThan":{"lhs":{"Deref":{"register":"AP","offset":-1}},"rhs":{"Immediate":"0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00"},"dst":{"register":"AP","offset":5}}}]],[125,[{"LinearSplit":{"value":{"Deref":{"register":"AP","offset":4}},"scalar":{"Immediate":"0x110000000000000000"},"max_x":{"Immediate":"0xffffffffffffffffffffffffffffffff"},"x":{"register":"AP","offset":-2},"y":{"register":"AP","offset":-1}}}]],[136,[{"LinearSplit":{"value":{"Deref":{"register":"AP","offset":4}},"scalar":{"Immediate":"0x8000000000000000000000000000000"},"max_x":{"Immediate":"0xfffffffffffffffffffffffffffffffe"},"x":{"register":"AP","offset":-2},"y":{"register":"AP","offset":-1}}}]],[163,[{"SystemCall":{"system":{"Deref":{"register":"FP","offset":-5}}}}]],[166,[{"AllocSegment":{"dst":{"register":"AP","offset":0}}}]],[188,[{"AllocSegment":{"dst":{"register":"AP","offset":0}}}]],[211,[{"AllocSegment":{"dst":{"register":"AP","offset":0}}}]],[226,[{"AllocSegment":{"dst":{"register":"AP","offset":0}}}]],[241,[{"AllocSegment":{"dst":{"register":"AP","offset":0}}}]]],"entry_points_by_type":{"EXTERNAL":[],"L1_HANDLER":[],"CONSTRUCTOR":[{"selector":"0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194","offset":0,"builtins":["pedersen","range_check"]}]}}
Loading

0 comments on commit 6bd26a1

Please sign in to comment.