Skip to main content
Version: Next

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

byteArrayFromString

byteArrayFromString(targetString): Object

Parameters

NameType
targetStringstring

Returns

Object

NameType
dataBigNumberish[]
pending_wordBigNumberish
pending_word_lennumber

Defined in

src/utils/typedData.ts:65


prepareSelector

prepareSelector(selector): string

Parameters

NameType
selectorstring

Returns

string

Defined in

src/utils/typedData.ts:116


isMerkleTreeType

isMerkleTreeType(type): type is StarkNetMerkleType

Parameters

NameType
typeStarkNetType

Returns

type is StarkNetMerkleType

Defined in

src/utils/typedData.ts:120


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:128


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:186


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:221


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:233


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:337


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:369


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:381