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 24, 2024
1 parent 633a2a1 commit 0b4a74a
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 @@ -296,6 +296,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 @@ -311,6 +312,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 0b4a74a

Please sign in to comment.