Documentation
¶
Index ¶
- Variables
- func EncodeData(typeDef *TypeDefinition, td *TypedData, context ...string) (enc []*felt.Felt, err error)
- func GetRevision(version uint8) (rev *revision, err error)
- type Domain
- type RevisionTypes
- type TypeDefinition
- type TypeParameter
- type TypedData
- func (td *TypedData) Domain() Domain
- func (td *TypedData) GetMessageHash(account string) (hash *felt.Felt, err error)
- func (td *TypedData) GetStructHash(typeName string, context ...string) (hash *felt.Felt, err error)
- func (td *TypedData) GetTypeHash(typeName string) (*felt.Felt, error)
- func (td *TypedData) Message() map[string]any
- func (td *TypedData) PrimaryType() string
- func (td *TypedData) Revision() revision
- func (td *TypedData) Types() map[string]TypeDefinition
- func (td *TypedData) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
var RevisionV0 revision
var RevisionV1 revision
Functions ¶
func EncodeData ¶
func EncodeData(typeDef *TypeDefinition, td *TypedData, context ...string) (enc []*felt.Felt, err error)
EncodeData encodes the given type definition using the TypedData struct.
func GetRevision ¶
Types ¶
type Domain ¶
type Domain struct { Name string `json:"name"` Version string `json:"version"` ChainId string `json:"chainId"` Revision uint8 `json:"revision,omitempty"` }
func (*Domain) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for Domain
type RevisionTypes ¶
type RevisionTypes struct { Basic []string Preset map[string]TypeDefinition }
type TypeDefinition ¶
type TypeParameter ¶
type TypedData ¶
type TypedData struct {
// contains filtered or unexported fields
}
func NewTypedData ¶
func NewTypedData(types []TypeDefinition, primaryType string, domain Domain, message []byte) (td *TypedData, err error)
NewTypedData creates a new instance of TypedData.
Parameters: - types: a slice of TypeDefinition representing the types used in the TypedData. - primaryType: a string representing the primary type of the TypedData. - domain: a Domain struct representing the domain information of the TypedData. - message: a byte slice containing the JSON-encoded message.
Returns: - td: a pointer to the newly created TypedData instance. - err: an error if any occurred during the creation of the TypedData.
func (*TypedData) GetMessageHash ¶
GetMessageHash calculates the hash of a typed message for a given account using the StarkCurve.
Parameters: - account: A string representing the account. Returns: - hash: A pointer to a felt.Felt representing the calculated hash.
func (*TypedData) GetStructHash ¶
GetStructHash calculates the hash of a struct type and its respective data.
Parameters: - typeName: the name of the type to be hashed. - context: optional context strings to be included in the hash calculation.
You can use 'context' to specify the path of the type you want to hash. Example: if you want to hash the type "ExampleInner" that is within the "Example" primary type with the name of "example_inner", you can specify the context as ["example_inner"]. If "ExampleInner" has a parameter with the name of "example_inner_inner" that you want to know the hash, you can specify the context as ["example_inner", "example_inner_inner"].
Returns: - hash: A pointer to a felt.Felt representing the calculated hash. - err: an error if any occurred during the hash calculation.
func (*TypedData) GetTypeHash ¶
GetTypeHash returns the hash of the given type.
Parameters: - typeName: the name of the type to hash Returns: - hash: A pointer to a felt.Felt representing the calculated hash. - err: an error if any occurred during the hash calculation.
func (*TypedData) PrimaryType ¶
PrimaryType returns the primary type name of the TypedData
func (*TypedData) Revision ¶
func (td *TypedData) Revision() revision
Revision returns the revision value of the TypedData
func (*TypedData) Types ¶
func (td *TypedData) Types() map[string]TypeDefinition
Types returns a copy of the TypedData's type definitions map
func (*TypedData) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for TypedData