diff --git a/artifacts/artifacts.go b/artifacts/artifacts.go index 678b3827..d58a81b0 100644 --- a/artifacts/artifacts.go +++ b/artifacts/artifacts.go @@ -8,12 +8,6 @@ import ( "github.com/NethermindEth/starknet.go/types" ) -//go:embed hello_starknet_compiled.casm.json -var ExampleWorldCasm []byte - -//go:embed hello_starknet_compiled.sierra.json -var ExampleWorldSierra []byte - //go:embed account.json var AccountCompiled []byte diff --git a/contracts/contracts.go b/contracts/contracts.go index d4bd3048..115fe16d 100644 --- a/contracts/contracts.go +++ b/contracts/contracts.go @@ -2,7 +2,6 @@ package contracts import ( "encoding/json" - "io/ioutil" "os" "github.com/NethermindEth/juno/core/felt" @@ -29,13 +28,8 @@ type CasmClassEntryPoint struct { } func UnmarshalCasmClass(filePath string) (*CasmClass, error) { - file, err := os.Open(filePath) - if err != nil { - return nil, err - } - defer file.Close() - content, err := ioutil.ReadAll(file) + content, err := os.ReadFile(filePath) if err != nil { return nil, err } diff --git a/contracts/contracts_test.go b/contracts/contracts_test.go index b5ca03a9..64d50fa0 100644 --- a/contracts/contracts_test.go +++ b/contracts/contracts_test.go @@ -2,29 +2,32 @@ package contracts_test import ( "encoding/json" + "os" "testing" - "github.com/NethermindEth/starknet.go/artifacts" "github.com/NethermindEth/starknet.go/contracts" "github.com/NethermindEth/starknet.go/rpc" + "github.com/test-go/testify/assert" "github.com/test-go/testify/require" ) func TestUnmarshalContractClass(t *testing.T) { - compiledClass := artifacts.ExampleWorldSierra + content, err := os.ReadFile("./tests/hello_starknet_compiled.sierra.json") + require.NoError(t, err) + var class rpc.ContractClass - err := json.Unmarshal(compiledClass, &class) + err = json.Unmarshal(content, &class) require.NoError(t, err) - require.Equal(t, class.SierraProgram[0].String(), "0x1") - require.Equal(t, class.SierraProgram[1].String(), "0x3") + assert.Equal(t, class.SierraProgram[0].String(), "0x1") + assert.Equal(t, class.SierraProgram[1].String(), "0x3") } func TestUnmarshalCasmClass(t *testing.T) { - casmClass, err := contracts.UnmarshalCasmClass("../artifacts/hello_starknet_compiled.casm.json") + casmClass, err := contracts.UnmarshalCasmClass("./tests/hello_starknet_compiled.casm.json") require.NoError(t, err) - require.Equal(t, casmClass.Prime, "0x800000000000011000000000000000000000000000000000000000000000001") - require.Equal(t, casmClass.Version, "2.1.0") - require.Equal(t, casmClass.EntryPointByType.External[0].Selector.String(), "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320") - require.Equal(t, casmClass.EntryPointByType.External[1].Offset, 130) - require.Equal(t, casmClass.EntryPointByType.External[1].Builtins[0], "range_check") + assert.Equal(t, casmClass.Prime, "0x800000000000011000000000000000000000000000000000000000000000001") + assert.Equal(t, casmClass.Version, "2.1.0") + assert.Equal(t, casmClass.EntryPointByType.External[0].Selector.String(), "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320") + assert.Equal(t, casmClass.EntryPointByType.External[1].Offset, 130) + assert.Equal(t, casmClass.EntryPointByType.External[1].Builtins[0], "range_check") } diff --git a/artifacts/hello_starknet_compiled.casm.json b/contracts/tests/hello_starknet_compiled.casm.json similarity index 100% rename from artifacts/hello_starknet_compiled.casm.json rename to contracts/tests/hello_starknet_compiled.casm.json diff --git a/artifacts/hello_starknet_compiled.sierra.json b/contracts/tests/hello_starknet_compiled.sierra.json similarity index 100% rename from artifacts/hello_starknet_compiled.sierra.json rename to contracts/tests/hello_starknet_compiled.sierra.json diff --git a/hash/hash.go b/hash/hash.go index e745db5e..0e0129b5 100644 --- a/hash/hash.go +++ b/hash/hash.go @@ -8,7 +8,7 @@ import ( "github.com/NethermindEth/starknet.go/utils" ) -// computeHashOnElementsFelt hashes the array of felts provided as input +// ComputeHashOnElementsFelt hashes the array of felts provided as input func ComputeHashOnElementsFelt(feltArr []*felt.Felt) (*felt.Felt, error) { bigIntArr := utils.FeltArrToBigIntArr(feltArr) @@ -19,7 +19,7 @@ func ComputeHashOnElementsFelt(feltArr []*felt.Felt) (*felt.Felt, error) { return utils.BigIntToFelt(hash), nil } -// calculateTransactionHashCommon [specification] calculates the transaction hash in the StarkNet network - a unique identifier of the transaction. +// CalculateTransactionHashCommon [specification] calculates the transaction hash in the StarkNet network - a unique identifier of the transaction. // [specification]: https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/core/os/transaction_hash/transaction_hash.py#L27C5-L27C38 func CalculateTransactionHashCommon( txHashPrefix *felt.Felt, @@ -63,7 +63,7 @@ func ClassHash(contract rpc.ContractClass) (*felt.Felt, error) { } func hashEntryPointByType(entryPoint []rpc.SierraEntryPoint) *felt.Felt { - flattened := []*felt.Felt{} + flattened := make([]*felt.Felt, 0, len(entryPoint)) for _, elt := range entryPoint { flattened = append(flattened, elt.Selector, new(felt.Felt).SetUint64(uint64(elt.FunctionIdx))) } diff --git a/hash/hash_test.go b/hash/hash_test.go index 351abb92..0f258442 100644 --- a/hash/hash_test.go +++ b/hash/hash_test.go @@ -2,9 +2,9 @@ package hash_test import ( "encoding/json" + "os" "testing" - "github.com/NethermindEth/starknet.go/artifacts" "github.com/NethermindEth/starknet.go/contracts" "github.com/NethermindEth/starknet.go/hash" "github.com/NethermindEth/starknet.go/rpc" @@ -12,9 +12,11 @@ import ( ) func TestUnmarshalCasmClassHash(t *testing.T) { - compiledClass := artifacts.ExampleWorldCasm + content, err := os.ReadFile("./tests/hello_starknet_compiled.casm.json") + require.NoError(t, err) + var class contracts.CasmClass - err := json.Unmarshal(compiledClass, &class) + err = json.Unmarshal(content, &class) require.NoError(t, err) } @@ -22,9 +24,11 @@ func TestClassHash(t *testing.T) { //https://github.com/software-mansion/starknet.py/blob/development/starknet_py/hash/class_hash_test.py expectedClasshash := "0x4ec2ecf58014bc2ffd7c84843c3525e5ecb0a2cac33c47e9c347f39fc0c0944" - compiledClass := artifacts.ExampleWorldSierra + content, err := os.ReadFile("./tests/hello_starknet_compiled.sierra.json") + require.NoError(t, err) + var class rpc.ContractClass - err := json.Unmarshal(compiledClass, &class) + err = json.Unmarshal(content, &class) require.NoError(t, err) compClassHash, err := hash.ClassHash(class) require.NoError(t, err) @@ -35,9 +39,11 @@ func TestCompiledClassHash(t *testing.T) { //https://github.com/software-mansion/starknet.py/blob/development/starknet_py/hash/casm_class_hash_test.py expectedHash := "0x785fa5f2bacf0bfe3bc413be5820a61e1ea63f2ec27ef00331ee9f46ad07603" - compiledClass := artifacts.ExampleWorldCasm + content, err := os.ReadFile("./tests/hello_starknet_compiled.casm.json") + require.NoError(t, err) + var casmClass contracts.CasmClass - err := json.Unmarshal(compiledClass, &casmClass) + err = json.Unmarshal(content, &casmClass) require.NoError(t, err) hash := hash.CompiledClassHash(casmClass) diff --git a/hash/tests/hello_starknet_compiled.casm.json b/hash/tests/hello_starknet_compiled.casm.json new file mode 100644 index 00000000..0253732e --- /dev/null +++ b/hash/tests/hello_starknet_compiled.casm.json @@ -0,0 +1,829 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.1.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffa9e8", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x6e", + "0x4825800180007ffa", + "0x5618", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xe8", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x55", + "0x48307ffb80007ffc", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x13", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xfe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff77fff8000", + "0x48127fe67fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x1b0", + "0x482480017fff8000", + "0x1af", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fe8", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff67fff", + "0x10780017fff7fff", + "0x20", + "0x4824800180007fe8", + "0x0", + "0x400080007ff77fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x48127ff47fff8000", + "0x1104800180018000", + "0xdc", + "0x482480017fbe8000", + "0x1", + "0x20680017fff7ffc", + "0xc", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff48000", + "0x1", + "0x48127fe37fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fec7fff8000", + "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", + "0xffffffffffffffffffffffffffffe2f0", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x5e", + "0x4825800180007ffa", + "0x1d10", + "0x400280007ff97fff", + "0x48297ffc80007ffd", + "0x482680017ff98000", + "0x1", + "0x4824800180007ffe", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x13", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x82", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff87fff8000", + "0x48127ff57fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x134", + "0x482480017fff8000", + "0x133", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007ff7", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff77fff", + "0x10780017fff7fff", + "0x24", + "0x4824800180007ff7", + "0x0", + "0x400080007ff87fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x87", + "0x482480017fd88000", + "0x1", + "0x20680017fff7ffc", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffd7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0x91", + "0x48127ff77fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff58000", + "0x1", + "0x48127ff27fff8000", + "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", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x8", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480080007ffa8000", + "0x208b7fff7fff7ffe", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0x3e", + "0x20680017fff7ffd", + "0x19", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48287ffd7ffd8000", + "0x1104800180018000", + "0x68", + "0x20680017fff7ffd", + "0xb", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x18", + "0x48127fe37fff8000", + "0x48127fe37fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fe37fff8000", + "0x48127fe37fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x18", + "0x20680017fff7ffd", + "0xa", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091", + "0x480680017fff8000", + "0x53746f7261676552656164", + "0x400280007ffd7fff", + "0x400380017ffd7ffc", + "0x400280027ffd7ffd", + "0x400280037ffd7ffe", + "0x480280057ffd8000", + "0x20680017fff7fff", + "0xc", + "0x480280047ffd8000", + "0x482680017ffd8000", + "0x7", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480280067ffd8000", + "0x10780017fff7fff", + "0x9", + "0x480280047ffd8000", + "0x482680017ffd8000", + "0x8", + "0x480680017fff8000", + "0x1", + "0x480280067ffd8000", + "0x480280077ffd8000", + "0x1104800180018000", + "0x47", + "0x20680017fff7ffd", + "0xa", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091", + "0x480680017fff8000", + "0x53746f726167655772697465", + "0x400280007ffc7fff", + "0x400380017ffc7ffb", + "0x400280027ffc7ffd", + "0x400280037ffc7ffe", + "0x400380047ffc7ffd", + "0x480280067ffc8000", + "0x20680017fff7fff", + "0xd", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x7", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x9", + "0x480680017fff8000", + "0x1", + "0x480280077ffc8000", + "0x480280087ffc8000", + "0x1104800180018000", + "0x21", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x9", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x5618" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 28, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 47, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -23 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 68, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 86, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 101, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 115, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 130, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x1d10" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 152, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 171, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -8 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 191, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 214, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 229, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 356, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -3 + } + } + } + } + ] + ], + [ + 406, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -4 + } + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 22040 <= memory[fp + -6]" + ] + ], + [ + 28, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 47, + [ + "memory[ap + 0] = 0 <= memory[ap + -23]" + ] + ], + [ + 68, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 86, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 101, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 115, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 130, + [ + "memory[ap + 0] = 7440 <= memory[fp + -6]" + ] + ], + [ + 152, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 171, + [ + "memory[ap + 0] = 0 <= memory[ap + -8]" + ] + ], + [ + 191, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 214, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 229, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 356, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -3])" + ] + ], + [ + 406, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -4])" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320", + "offset": 0, + "builtins": [ + "range_check" + ] + }, + { + "selector": "0x39e11d48192e4333233c7eb19d10ad67c362bb28580c604d67884c85da39695", + "offset": 130, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/hash/tests/hello_starknet_compiled.sierra.json b/hash/tests/hello_starknet_compiled.sierra.json new file mode 100644 index 00000000..11f135fb --- /dev/null +++ b/hash/tests/hello_starknet_compiled.sierra.json @@ -0,0 +1,362 @@ +{ + "sierra_program": [ + "0x1", + "0x3", + "0x0", + "0x2", + "0x1", + "0x0", + "0xc9", + "0x37", + "0x1f", + "0x52616e6765436865636b", + "0x0", + "0x4761734275696c74696e", + "0x66656c74323532", + "0x4172726179", + "0x1", + "0x2", + "0x536e617073686f74", + "0x3", + "0x537472756374", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x4", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x456e756d", + "0x11c6d8087e00642489f92d2821ad6ebd6532ad1a3b6d12833da6d6810391511", + "0x6", + "0x753332", + "0x53797374656d", + "0x16a4c8d7c05909052238a862d8cc3e7975bf05a07b3a69c6b28951083a6d672", + "0xa", + "0x5", + "0x9931c641b913035ae674b400b61a51476d506bbe8bba2ff8a6272790aba9e6", + "0xc", + "0xb", + "0x4275696c74696e436f737473", + "0x390d672b6ef7fab63615b63b7b11a75e5990713c9ddf68193ca9b10945e38ac", + "0x2578e47cd71d87b33ad91e134e4e415edd84a92da79ae22f04fefe2af44e7e1", + "0xf", + "0x10", + "0x10f0a6fc0de86b4d1a026feeb2748bbff826fc0ca66eee62d311e6c5f147001", + "0x11", + "0x10203be321c62a7bd4c060d69539c1fbe065baa9e253c74d2cc48be163e259", + "0x13", + "0x426f78", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0x15", + "0xe62f25996808c24adc45bae715a43bae20055af68a813f4a403f0fcf8526b3", + "0x17", + "0x53746f726167654261736541646472657373", + "0x53746f7261676541646472657373", + "0x90d0203c41ad646d024845257a6eceb2f8b59b29ce7420dd518053d2edeedc", + "0x101dc0399934cc08fa0d6f6f2daead4e4a38cabeea1c743e1fc28d2d6e58e99", + "0xcc5e86243f861d2d64b08c35db21013e773ac5cf10097946fe0011304886d5", + "0x1d", + "0x6f", + "0x7265766f6b655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x73746f72655f74656d70", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0x7", + "0x7374727563745f6465636f6e737472756374", + "0x61727261795f6c656e", + "0x736e617073686f745f74616b65", + "0x8", + "0x64726f70", + "0x7533325f636f6e7374", + "0x72656e616d65", + "0x7533325f6571", + "0x9", + "0x61727261795f6e6577", + "0x66656c743235325f636f6e7374", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x61727261795f617070656e64", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0xd", + "0x6765745f6275696c74696e5f636f737473", + "0xe", + "0x77697468647261775f6761735f616c6c", + "0x12", + "0x4f7574206f6620676173", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x14", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x16", + "0x6a756d70", + "0x756e626f78", + "0x66656c743235325f616464", + "0x18", + "0x73746f726167655f626173655f616464726573735f636f6e7374", + "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091", + "0x73746f726167655f616464726573735f66726f6d5f62617365", + "0x1a", + "0x73746f726167655f726561645f73797363616c6c", + "0x1b", + "0x73746f726167655f77726974655f73797363616c6c", + "0x1c", + "0x1e", + "0x199", + "0xffffffffffffffff", + "0x63", + "0x54", + "0x24", + "0x19", + "0x20", + "0x21", + "0x22", + "0x23", + "0x25", + "0x46", + "0x26", + "0x27", + "0x28", + "0x29", + "0x2d", + "0x2e", + "0x2f", + "0x30", + "0x2a", + "0x2b", + "0x2c", + "0x31", + "0x3f", + "0x32", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x39", + "0x3a", + "0x3b", + "0x3c", + "0x3d", + "0x3e", + "0x40", + "0x41", + "0x42", + "0x43", + "0x44", + "0x45", + "0x47", + "0x48", + "0x49", + "0x4a", + "0x4b", + "0x4c", + "0x4d", + "0x4e", + "0x4f", + "0x50", + "0x51", + "0x52", + "0x53", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5a", + "0x5b", + "0x5c", + "0x5d", + "0x5e", + "0x5f", + "0xc6", + "0x90", + "0xb9", + "0xb2", + "0xdb", + "0xe0", + "0xea", + "0x116", + "0x110", + "0x12c", + "0x145", + "0x14a", + "0x155", + "0x16a", + "0x16f", + "0x60", + "0x61", + "0x62", + "0x17a", + "0x64", + "0x65", + "0x66", + "0x67", + "0x68", + "0x69", + "0x187", + "0x6a", + "0x193", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x71", + "0xd4", + "0xf1", + "0xf5", + "0x11e", + "0x132", + "0x138", + "0x15b", + "0x181", + "0x18d", + "0xf51", + "0x7060f02090e0d02060a0c060b02070a090606080706060502040203020100", + "0x617061602090e15060d02070a090614060d02090a1302060a021202111006", + "0x70a18061f061e02090e10061d060d02090a1c061b02070a1a02060a021918", + "0x61c060d02090a100624062302090e07060622180621062002090e07060d02", + "0x70a090610062a02090e090607062902090e02280227180626062502090e10", + "0x206063107090632150606310230022f022e2d18062c062b02090e10060d02", + "0x606313806063b0207063a3806063938060637070606361506063534060633", + "0x70606314007063f0706063e10060639090906323d06063107060639023c38", + "0x6063102454406063106060631060744060743180606421406064207060641", + "0x90606371f060639480606330c0906321d0606311d0606421c060642024746", + "0x374a07063f150606394907063f020744060743170606421506064209060639", + "0x100906320906063107060637210606354b060633150906321d0606391d0606", + "0x3306074d06074310060642024e4d0606310c06063102074d0607430706064c", + "0x10060631060734060743340606310207340607430706063b0706064f4d0606", + "0x422606063551060633380906320250340906321c0606311c0606371d060635", + "0x4b060743210606421c060639060748060743480606310207480607431f0606", + "0x3102075706074302565506063102545307065206074b0607434b0606310207", + "0x7435906063102075906074302583d0906325706063b060757060743570606", + "0x31020751060743260606422c0606355a060633140906325906063b06075906", + "0x5a06063102075a0607432c0606425906063357060633060751060743510606", + "0x60207023410075d150c075c070602070602025c060202025b06075a060743", + "0x3d0610020c065c060c0615023d38075c0614060c0214065c0609060902025c", + "0x3d0246065c064406380244065c0638063402025c0602070217065e18065c07", + "0x22148075c061f063d021f065c06021802025c061c0614021d1c075c064606", + "0x24b065c064b06440224065c06210617024b065c061d061702025c06480614", + "0x251065c0607061d02025c0618061c02025c06020702025f025c07244b0746", + "0x240255065c06024b0260065c06022102025c0626064802264d075c0651061f", + "0x2c065c06575907510259065c0602260257065c065560074d0255065c065506", + "0x65c064d061d0261065c061506550200065c060c0615025a065c062c066002", + "0x62c0264065c06025902025c06020702636261000c0663065c065a06570262", + "0x5c06020002025c0602070268670766655f075c0764150c095a0264065c0664", + "0x66a0662026c065c0607061d026b065c06650655026a065c06690661026906", + "0x65c065f06150271706f095c066e6d6c6b0c63026e065c06180624026d065c", + "0x65c06022102025c0672065f02025c0602070274067372065c07710664025f", + "0x5c067806690278065c0677066802025c06760667027776075c067506650275", + "0x670061d027c065c066f0655027b065c065f0615027a065c0679066a027906", + "0x7f065c0674066002025c060207027e7d7c7b0c067e065c067a0657027d065c", + "0x65c067f06570281065c0670061d0273065c066f06550280065c065f061502", + "0x6026f0283065c06022102025c0618061c02025c06020702828173800c0682", + "0x8607510286065c0602260285065c068483074d0284065c068406240284065c", + "0x1d0289065c066806550288065c066706150287065c066606600266065c0685", + "0x617064802025c060207028b8a89880c068b065c06870657028a065c060706", + "0x8d065c068d0624028d065c060271028c065c06022102025c0638067002025c", + "0x5c069006600290065c068e8f0751028f065c060226028e065c068d8c074d02", + "0x6910657025e065c0607061d0293065c061506550292065c060c0615029106", + "0x6f0295065c06022102025c0609067002025c06020702945e93920c0694065c", + "0x510298065c0602260297065c069695074d0296065c069606240296065c0602", + "0x9c065c06340655029b065c06100615029a065c069906600299065c06979807", + "0x70602025c060202029e9d9c9b0c069e065c069a0657029d065c0607061d02", + "0x5c063806380238065c0609063402025c060207023410079f150c075c070602", + "0x5c0617063d0217065c06021802025c06140614021814075c063d063d023d06", + "0x61c0644021d065c06460617021c065c0618061702025c0644061402464407", + "0x7061d02025c0602070202a0025c071d1c0746020c065c060c0615021c065c", + "0x6024b024b065c06022102025c0648064802481f075c0621061f0221065c06", + "0x2607510226065c060226024d065c06244b074d0224065c062406240224065c", + "0x1d0257065c061506550255065c060c06150260065c065106600251065c064d", + "0x5c06025902025c060207022c5957550c062c065c066006570259065c061f06", + "0x25c06020702636207a16100075c075a150c095a025a065c065a062c025a06", + "0x25c0665066c026765075c065f066b025f065c066406610264065c06020002", + "0x671706f096d0271065c066706620270065c0607061d026f065c0661065502", + "0x2025c060207026c06a26b065c076a066e0200065c06000615026a6968095c", + "0x2025c0672061c027472075c066d0674026e065c060221026d065c066b0672", + "0x5c06760648027675075c06787707760278065c066e06750277065c06740624", + "0x5c067b0669027b065c067a066802025c06790667027a79075c067506650202", + "0x669061d027f065c06680655027e065c06000615027d065c067c066a027c06", + "0x81065c066c066002025c0602070273807f7e0c0673065c067d06570280065c", + "0x65c068106570284065c0669061d0283065c066806550282065c0600061502", + "0x6606240266065c06026f0286065c06022102025c06020702858483820c0685", + "0x600289065c06878807510288065c0602260287065c066686074d0266065c06", + "0x28d065c0607061d028c065c06630655028b065c06620615028a065c068906", + "0x5c06022102025c0609067002025c060207028e8d8c8b0c068e065c068a0657", + "0x5c0602260291065c06908f074d0290065c069006240290065c06026f028f06", + "0x3406550294065c06100615025e065c069306600293065c0691920751029206", + "0x602063402979695940c0697065c065e06570296065c0607061d0295065c06", + "0x790215065c0609067802025c060207020c06a30907075c070606770206065c", + "0x5c06027c02025c0602070202a406027b0234065c0615067a0210065c060706", + "0x61006680234065c063d067a0210065c060c0679023d065c0638067d023806", + "0x67f02025c060207021706a518065c0734067e0214065c061406090214065c", + "0x81021d065c06140609021c065c064606730246065c064406800244065c0618", + "0x248065c06027c02025c0617064802025c060207021f1d07061f065c061c06", + "0x6027c02244b070624065c06210681024b065c061406090221065c06480682", + "0xc065c06070684020907070609065c060606830207065c0602061d0206065c", + "0x5c061006860218065c0606061d0214065c06020655021015075c060c068502", + "0x25c060207024606a644065c073d066e023d3834095c061718140966021706", + "0x5c0638061d024b065c06340655021d065c06091c0787021c065c0644067202", + "0x21481f095c06264d244b0c880226065c061d0624024d065c06150686022406", + "0x6570648025755075c0651068a02025c060207026006a751065c0721068902", + "0x65a068c025a065c062c59078b022c065c06027c0259065c0655066102025c", + "0x6261090663065c0600068d0262065c0648061d0261065c061f06550200065c", + "0x65065c0648061d025f065c061f06550264065c0660068e02025c0602070263", + "0x609061c02025c0615068f02025c0602070267655f090667065c0664068d02", + "0x668068d026a065c0638061d0269065c063406550268065c0646068e02025c", + "0x65c0606061d0234065c060206550209065c06070684026f6a6909066f065c", + "0x6a814065c0710066e0210150c095c063d38340966023d065c060906860238", + "0x46065c064406910244065c061706900217065c0614067202025c0602070218", + "0x7021f1d1c09061f065c06460692021d065c0615061d021c065c060c065502", + "0x692024b065c0615061d0221065c060c06550248065c0618069302025c0602", + "0x6027c0209065c060706074d0207065c0602068002244b21090624065c0648", + "0x2025c0607068f021015070610065c060c06830215065c06090675020c065c", + "0x950215065c061506440215065c060218020c065c060906940209065c06025e", + "0x2025c0602070218143d09a9383410095c070c1506020c96020c065c060c06", + "0x1c065c061706980246065c0634061d0244065c061006550217065c06380697", + "0x61d0244065c063d0655021d065c0618069902025c0602070202aa06027b02", + "0x6e021f065c0648069b0248065c061c069a021c065c061d06980246065c0614", + "0x4d065c062406900224065c0621067202025c060207024b06ab21065c071f06", + "0x65c062606920260065c0646061d0251065c064406550226065c064d069102", + "0x61d0259065c064406550257065c064b069302025c06020702556051090655", + "0x15068f02150c075c06070685025a2c5909065a065c06570692022c065c0646", + "0x5c063806440238065c0602180234065c061006940210065c06025e02025c06", + "0x2070244171809ac143d075c070934380602159c0234065c06340695023806", + "0x614061d021d065c063d0655021c065c0646069d0246065c06027c02025c06", + "0x21065c064406ae02025c0602070202ad06027b0248065c061c069e021f065c", + "0x65c064806af0248065c0621069e021f065c0617061d021d065c0618065502", + "0x64d06b202025c060207022606b14d065c074b065d024b065c062406b00224", + "0x61d0257065c061d06550255065c066006b40260065c06510c07b30251065c", + "0x25c060c068f02025c060207022c595709062c065c065506b50259065c061f", + "0x65c065a06b50261065c061f061d0200065c061d0655025a065c062606b602", + "0x9065c0606069002025c060207020706b806065c070206b702626100090662", + "0x65c06022602025c0602070215060615065c060c0692020c065c0609069102", + "0xb9023d06063d065c063806920238065c063406930234065c06071007510210", + "0xc065c060906bc0209065c060606bb02025c060207020706ba06065c070206", + "0x5c06071007510210065c06022602025c0602070215060615065c060c06bd02", + "0x3d06020c153d06020c183d06063d065c063806bd0238065c063406be023406", + "0x73d06c0023415071506bf09070602443d06020c153d06020c020907060244", + "0x7c30706024b3d06091d3d0609c209070602483d0609071d3d060cc102103d", + "0x602513d0609071c3d060cc50706024b3d06091c3d0609c406021009070907", + "0xc8025a065906c7024b065706c60907" + ], + "sierra_program_debug_info": { + "type_names": [], + "libfunc_names": [], + "user_func_names": [] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320", + "function_idx": 0 + }, + { + "selector": "0x39e11d48192e4333233c7eb19d10ad67c362bb28580c604d67884c85da39695", + "function_idx": 1 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + }, + "abi": "[{\"type\": \"function\", \"name\": \"increase_balance\", \"inputs\": [{\"name\": \"amount\", \"type\": \"core::felt252\"}], \"outputs\": [], \"state_mutability\": \"external\"}, {\"type\": \"function\", \"name\": \"get_balance\", \"inputs\": [], \"outputs\": [{\"type\": \"core::felt252\"}], \"state_mutability\": \"view\"}, {\"type\": \"event\", \"name\": \"hello_starknet::hello_starknet::hello_starknet::Event\", \"kind\": \"enum\", \"variants\": []}]" +} \ No newline at end of file