Skip to content

Commit

Permalink
both classes
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Aug 22, 2023
1 parent ffd9f42 commit 89b2b0a
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions rpc/types_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type NumAsHex string

type EntryPoint struct {
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
Expand All @@ -21,17 +21,16 @@ type EntryPoint struct {

type ABI []ABIEntry

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

type DepcreatedContractClass 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 Down Expand Up @@ -61,7 +60,7 @@ func (c *DepcreatedContractClass) 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 Expand Up @@ -113,6 +112,32 @@ func (c *DepcreatedContractClass) UnmarshalJSON(content []byte) error {
return nil
}

// https://github.com/starkware-libs/starknet-specs/blob/v0.3.0/api/starknet_api_openrpc.json#L2372
type ContractClass struct {
// The list of Sierra instructions of which the program consists
SierraProgram []*felt.Felt `json:"sierra_program"`

// The version of the contract class object. Currently, the Starknet OS supports version 0.1.0
Version string `json:"contract_class_version"`

EntryPointsByType EntryPointsByType `json:"entry_points_by_type"`

ABI string `json:"abi,omitempty"`
}

type SierraEntryPoint struct {
// The index of the function in the program
FunctionIdx int `json:"function_idx"`
// A unique identifier of the entry point (function) in the program
Selector *felt.Felt `json:"selector"`
}

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

type ABIEntry interface {
IsType() ABIType
}
Expand Down

0 comments on commit 89b2b0a

Please sign in to comment.