Skip to main content
Version: 6.11.0

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​

NameTypeDescription
selectorstringThe selector to be prepared.

Returns​

string

The prepared selector.

Defined in​

src/utils/typedData.ts:112


isMerkleTreeType​

â–¸ isMerkleTreeType(type): type is StarknetMerkleType

Checks if the given Starknet type is a Merkle tree type.

Parameters​

NameTypeDescription
typeStarknetTypeThe StarkNet type to check.

Returns​

type is StarknetMerkleType

  • True if the type is a Merkle tree type, false otherwise.

Defined in​

src/utils/typedData.ts:123


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​

NameTypeDefault value
typesRecord<string, StarknetType[]>undefined
typestringundefined
dependenciesstring[][]
containsstring''
revisionTypedDataRevisionRevision.LEGACY

Returns​

string[]

Defined in​

src/utils/typedData.ts:131


encodeType​

â–¸ encodeType(types, type, revision?): string

Encode a type to a string. All dependent types are alphabetically sorted.

Parameters​

NameTypeDefault value
typesRecord<string, StarknetType[]>undefined
typestringundefined
revisionTypedDataRevisionRevision.LEGACY

Returns​

string

Defined in​

src/utils/typedData.ts:189


getTypeHash​

â–¸ getTypeHash(types, type, revision?): string

Get a type string as hash.

Parameters​

NameTypeDefault value
typesRecord<string, StarknetType[]>undefined
typestringundefined
revisionTypedDataRevisionRevision.LEGACY

Returns​

string

Defined in​

src/utils/typedData.ts:234


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​

NameTypeDefault value
typesRecord<string, StarknetType[]>undefined
typestringundefined
dataunknownundefined
ctxContext{}
revisionTypedDataRevisionRevision.LEGACY

Returns​

[string, string]

Defined in​

src/utils/typedData.ts:246


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​

NameType
Textends TypedData

Parameters​

NameTypeDefault value
typesT["types"]undefined
typestringundefined
dataT["message"]undefined
revisionTypedDataRevisionRevision.LEGACY

Returns​

string[][]

Defined in​

src/utils/typedData.ts:377


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​

NameType
Textends TypedData

Parameters​

NameTypeDefault value
typesT["types"]undefined
typestringundefined
dataT["message"]undefined
revisionTypedDataRevisionRevision.LEGACY

Returns​

string

Defined in​

src/utils/typedData.ts:412


getMessageHash​

â–¸ getMessageHash(typedData, account): string

Get the SNIP-12 encoded message to sign, from the typedData object.

Parameters​

NameType
typedDataTypedData
accountBigNumberish

Returns​

string

Defined in​

src/utils/typedData.ts:424