Skip to content

Commit

Permalink
Modification of EntryPoint related types
Browse files Browse the repository at this point in the history
  • Loading branch information
cicr99 committed Jul 26, 2023
1 parent de1a49f commit 6b1edc9
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions rpc/types_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,40 @@ import (

type NumAsHex string

type EntryPoint struct {
type ABI []ABIEntry

type DeprecatedCairoEntryPoint struct {
// The offset of the entry point in the program
Offset NumAsHex `json:"offset"`
// A unique identifier of the entry point (function) in the program
Selector *felt.Felt `json:"selector"`
}

type ABI []ABIEntry
type SierraEntryPoint struct {
// A unique identifier of the entry point (function) in the program
Selector *felt.Felt `json:"selector"`

// The index of the function in the program
FunctionIdx uint64 `json:"selector"`
}

type DeprecatedEntryPointsByType struct {
Constructor []DeprecatedCairoEntryPoint `json:"CONSTRUCTOR"`
External []DeprecatedCairoEntryPoint `json:"EXTERNAL"`
L1Handler []DeprecatedCairoEntryPoint `json:"L1_HANDLER"`
}

type EntryPointsByType struct {
Constructor []EntryPoint `json:"CONSTRUCTOR"`
External []EntryPoint `json:"EXTERNAL"`
L1Handler []EntryPoint `json:"L1_HANDLER"`
Constructor []SierraEntryPoint `json:"CONSTRUCTOR"`
External []SierraEntryPoint `json:"EXTERNAL"`
L1Handler []SierraEntryPoint `json:"L1_HANDLER"`
}

type DeprecatedContractClass struct {
// Program A base64 representation of the compressed program code
Program string `json:"program"`

EntryPointsByType EntryPointsByType `json:"entry_points_by_type"`
EntryPointsByType DeprecatedEntryPointsByType `json:"entry_points_by_type"`

ABI *ABI `json:"abi,omitempty"`
}
Expand All @@ -47,7 +61,7 @@ type ContractClass struct {
ABI string `json:"abi, omitempty"`
}

func (c *ContractClass) UnmarshalJSON(content []byte) error {
func (c *DeprecatedContractClass) UnmarshalJSON(content []byte) error {
v := map[string]json.RawMessage{}
if err := json.Unmarshal(content, &v); err != nil {
return err
Expand All @@ -72,7 +86,7 @@ func (c *ContractClass) UnmarshalJSON(content []byte) error {
return fmt.Errorf("missing entry_points_by_type in json object")
}

entryPointsByType := EntryPointsByType{}
entryPointsByType := DeprecatedEntryPointsByType{}
if err := json.Unmarshal(data, &entryPointsByType); err != nil {
return err
}
Expand Down

0 comments on commit 6b1edc9

Please sign in to comment.