Namespace: typedData
References​
TypedDataRevision​
Re-exports TypedDataRevision
StarknetEnumType​
Re-exports StarknetEnumType
StarknetMerkleType​
Re-exports StarknetMerkleType
StarknetType​
Re-exports StarknetType
StarknetDomain​
Re-exports StarknetDomain
TypedData​
Re-exports TypedData
Functions​
prepareSelector​
â–¸ prepareSelector(selector
): string
Prepares the selector for use.
Parameters​
Name | Type | Description |
---|---|---|
selector | string | The selector to be prepared. |
Returns​
string
The prepared selector.
Defined in​
isMerkleTreeType​
â–¸ isMerkleTreeType(type
): type is StarknetMerkleType
Checks if the given Starknet type is a Merkle tree type.
Parameters​
Name | Type | Description |
---|---|---|
type | StarknetType | The StarkNet type to check. |
Returns​
type is StarknetMerkleType
- True if the type is a Merkle tree type, false otherwise.
Defined in​
getDependencies​
â–¸ getDependencies(types
, type
, dependencies?
, contains?
, revision?
): string
[]
Get the dependencies of a struct type. If a struct has the same dependency multiple times, it's only included once in the resulting array.
Parameters​
Name | Type | Default value |
---|---|---|
types | Record <string , StarknetType []> | undefined |
type | string | undefined |
dependencies | string [] | [] |
contains | string | '' |
revision | TypedDataRevision | Revision.LEGACY |
Returns​
string
[]
Defined in​
encodeType​
â–¸ encodeType(types
, type
, revision?
): string
Encode a type to a string. All dependent types are alphabetically sorted.
Parameters​
Name | Type | Default value |
---|---|---|
types | Record <string , StarknetType []> | undefined |
type | string | undefined |
revision | TypedDataRevision | Revision.LEGACY |
Returns​
string
Defined in​
getTypeHash​
â–¸ getTypeHash(types
, type
, revision?
): string
Get a type string as hash.
Parameters​
Name | Type | Default value |
---|---|---|
types | Record <string , StarknetType []> | undefined |
type | string | undefined |
revision | TypedDataRevision | Revision.LEGACY |
Returns​
string
Defined in​
encodeValue​
â–¸ encodeValue(types
, type
, data
, ctx?
, revision?
): [string
, string
]
Encodes a single value to an ABI serialisable string, number or Buffer. Returns the data as tuple, which consists of an array of ABI compatible types, and an array of corresponding values.
Parameters​
Name | Type | Default value |
---|---|---|
types | Record <string , StarknetType []> | undefined |
type | string | undefined |
data | unknown | undefined |
ctx | Context | {} |
revision | TypedDataRevision | Revision.LEGACY |
Returns​
[string
, string
]
Defined in​
encodeData​
â–¸ encodeData<T
>(types
, type
, data
, revision?
): string
[][]
Encode the data to an ABI encoded Buffer. The data should be a key -> value object with all the required values. All dependent types are automatically encoded.
Type parameters​
Name | Type |
---|---|
T | extends TypedData |
Parameters​
Name | Type | Default value |
---|---|---|
types | T ["types" ] | undefined |
type | string | undefined |
data | T ["message" ] | undefined |
revision | TypedDataRevision | Revision.LEGACY |
Returns​
string
[][]
Defined in​
getStructHash​
â–¸ getStructHash<T
>(types
, type
, data
, revision?
): string
Get encoded data as a hash. The data should be a key -> value object with all the required values. All dependent types are automatically encoded.
Type parameters​
Name | Type |
---|---|
T | extends TypedData |
Parameters​
Name | Type | Default value |
---|---|---|
types | T ["types" ] | undefined |
type | string | undefined |
data | T ["message" ] | undefined |
revision | TypedDataRevision | Revision.LEGACY |
Returns​
string
Defined in​
getMessageHash​
â–¸ getMessageHash(typedData
, account
): string
Get the SNIP-12 encoded message to sign, from the typedData object.
Parameters​
Name | Type |
---|---|
typedData | TypedData |
account | BigNumberish |
Returns​
string