Documentation ¶
Index ¶
- type Definition
- type Domain
- type TypeDef
- type TypedData
- func (td TypedData) EncodeType(inType string) (enc string, err error)
- func (td TypedData) GetMessageHash(account *big.Int, msg TypedMessage, sc curve.StarkCurve) (hash *big.Int, err error)
- func (td TypedData) GetTypeHash(inType string) (ret *big.Int, err error)
- func (td TypedData) GetTypedMessageHash(inType string, msg TypedMessage, sc curve.StarkCurve) (hash *big.Int, err error)
- type TypedMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Definition ¶
type TypeDef ¶
type TypeDef struct { Encoding *big.Int Definitions []Definition }
type TypedData ¶
type TypedData struct { Types map[string]TypeDef PrimaryType string Domain Domain Message TypedMessage }
func NewTypedData ¶
NewTypedData initializes a new TypedData object with the given types, primary type, and domain for interacting and signing in accordance with https://github.com/0xs34n/starknet.js/tree/develop/src/utils/typedData If the primary type is invalid, it returns an error with the message "invalid primary type: {pType}". If there is an error encoding the type hash, it returns an error with the message "error encoding type hash: {enc.String()} {err}".
Parameters: - types: a map[string]TypeDef representing the types associated with their names. - pType: a string representing the primary type. - dom: a Domain representing the domain. Returns: - td: a TypedData object - err: an error if any
func (TypedData) EncodeType ¶
EncodeType encodes the given inType using the TypedData struct.
Parameters: - inType: the type to encode Returns: - enc: the encoded type - err: any error if any
func (TypedData) GetMessageHash ¶
func (td TypedData) GetMessageHash(account *big.Int, msg TypedMessage, sc curve.StarkCurve) (hash *big.Int, err error)
GetMessageHash calculates the hash of a typed message for a given account using the StarkCurve. (ref: https://github.com/0xs34n/starknet.js/blob/767021a203ac0b9cdb282eb6d63b33bfd7614858/src/utils/typedData/index.ts#L166)
Parameters: - account: A pointer to a big.Int representing the account. - msg: A TypedMessage object representing the message. - sc: A StarkCurve object representing the curve. Returns: - hash: A pointer to a big.Int representing the calculated hash. - err: An error object indicating any error that occurred during the calculation.
func (TypedData) GetTypeHash ¶
GetTypeHash returns the hash of the given type.
Parameters: - inType: the type to hash Returns: - ret: the hash of the given type - err: any error if any
func (TypedData) GetTypedMessageHash ¶
func (td TypedData) GetTypedMessageHash(inType string, msg TypedMessage, sc curve.StarkCurve) (hash *big.Int, err error)
GetTypedMessageHash calculates the hash of a typed message using the provided StarkCurve.
Parameters:
- inType: the type of the message
- msg: the typed message
- sc: the StarkCurve used for hashing
Returns:
- hash: the calculated hash
- err: any error if any