Skip to content

Commit

Permalink
Add bytecode segments to compiled classes
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak committed Feb 26, 2024
1 parent bb572ca commit 3a84d27
Show file tree
Hide file tree
Showing 10 changed files with 47,698 additions and 33 deletions.
8 changes: 8 additions & 0 deletions adapters/core2sn/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ import (
"github.com/NethermindEth/juno/utils"
)

func AdaptSegmentLengths(l core.SegmentLengths) starknet.SegmentLengths {
return starknet.SegmentLengths{
Length: l.Length,
Children: utils.Map(l.Children, AdaptSegmentLengths),
}
}

func AdaptCompiledClass(coreCompiledClass *core.CompiledClass) starknet.CompiledClass {
var feederCompiledClass starknet.CompiledClass
feederCompiledClass.Bytecode = coreCompiledClass.Bytecode
feederCompiledClass.PythonicHints = coreCompiledClass.PythonicHints
feederCompiledClass.CompilerVersion = coreCompiledClass.CompilerVersion
feederCompiledClass.Hints = coreCompiledClass.Hints
feederCompiledClass.Prime = "0x" + coreCompiledClass.Prime.Text(felt.Base16)
feederCompiledClass.BytecodeSegmentLengths = AdaptSegmentLengths(coreCompiledClass.BytecodeSegmentLengths)

adapt := func(ep core.CompiledEntryPoint) starknet.CompiledEntryPoint {
return starknet.CompiledEntryPoint{
Expand Down
8 changes: 8 additions & 0 deletions adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func AdaptCompiledClass(compiledClass *starknet.CompiledClass) (*core.CompiledCl
compiled.PythonicHints = compiledClass.PythonicHints
compiled.CompilerVersion = compiledClass.CompilerVersion
compiled.Hints = compiledClass.Hints
compiled.BytecodeSegmentLengths = AdaptSegmentLengths(compiledClass.BytecodeSegmentLengths)

var ok bool
compiled.Prime, ok = new(big.Int).SetString(compiledClass.Prime, 0)
Expand All @@ -313,6 +314,13 @@ func AdaptCompiledClass(compiledClass *starknet.CompiledClass) (*core.CompiledCl
return &compiled, nil
}

func AdaptSegmentLengths(l starknet.SegmentLengths) core.SegmentLengths {
return core.SegmentLengths{
Length: l.Length,
Children: utils.Map(l.Children, AdaptSegmentLengths),
}
}

func AdaptCairo0Class(response *starknet.Cairo0Definition) (core.Class, error) {
class := new(core.Cairo0Class)
class.Abi = response.Abi
Expand Down
Loading

0 comments on commit 3a84d27

Please sign in to comment.