@celo/utils › "packages/sdk/utils/src/sign-typed-data-utils"
Module: "packages/sdk/utils/src/sign-typed-data-utils"
Index
Interfaces
Type aliases
Variables
Functions
- defined
- eip712OptionalSchema
- eip712OptionalType
- encodeData
- encodeType
- generateTypedDataHash
- structHash
- typeHash
- zeroValue
Object literals
Type aliases
EIP712ObjectValue
Ƭ EIP712ObjectValue: string | number | BigNumber | boolean | Buffer | EIP712Object | EIP712ObjectValue[]
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:21
EIP712Optional
Ƭ EIP712Optional: object
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:70
Utility type representing an optional value in a EIP-712 compatible manner, as long as the concrete type T is a subtype of EIP712ObjectValue.
remarks
EIP712Optonal is not part of the EIP712 standard, but is fully compatible with it.
Type declaration:
-
defined: boolean
-
value: T
Variables
Const
EIP712_ATOMIC_TYPES
• EIP712_ATOMIC_TYPES: string[] = [ 'bytes1', 'bytes32', 'uint8', 'uint256', 'int8', 'int256', 'bool', 'address', ]
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:42
Array of all EIP-712 atomic type names.
Const
EIP712_BUILTIN_TYPES
• EIP712_BUILTIN_TYPES: string[] = EIP712_ATOMIC_TYPES.concat(EIP712_DYNAMIC_TYPES)
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:55
Const
EIP712_DYNAMIC_TYPES
• EIP712_DYNAMIC_TYPES: string[] = ['bytes', 'string']
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:53
Functions
Const
defined
▸ defined<T>(value
: T): EIP712Optional‹T›
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:98
Utility to construct an defined EIP712Optional value with inferred type.
Type parameters:
▪ T: EIP712ObjectValue
Parameters:
Name | Type |
---|---|
value |
T |
Returns: EIP712Optional‹T›
Const
eip712OptionalSchema
▸ eip712OptionalSchema<S>(schema
: S): TypeC‹object›
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:91
Utility to build EIP712Optional
Type parameters:
▪ S: Mixed
Parameters:
Name | Type | Description |
---|---|---|
schema |
S | io-ts type (a.k.a. schema or codec) describing the inner type. |
Returns: TypeC‹object›
Const
eip712OptionalType
▸ eip712OptionalType(typeName
: string): EIP712Types
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:80
Utility to build EIP712Optional
Parameters:
Name | Type | Description |
---|---|---|
typeName |
string | EIP-712 string type name. Should be builtin or defined in the EIP712Types structure into which this type will be merged. |
Returns: EIP712Types
encodeData
▸ encodeData(primaryType
: string, data
: EIP712Object, types
: EIP712Types): Buffer
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:239
Constructs the struct encoding of the data as the primary type.
Parameters:
Name | Type |
---|---|
primaryType |
string |
data |
EIP712Object |
types |
EIP712Types |
Returns: Buffer
encodeType
▸ encodeType(primaryType
: string, types
: EIP712Types): string
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:172
Creates a string encoding of the primary type, including all dependencies. E.g. "Transaction(Person from,Person to,Asset tx)Asset(address token,uint256 amount)Person(address wallet,string name)"
Parameters:
Name | Type |
---|---|
primaryType |
string |
types |
EIP712Types |
Returns: string
generateTypedDataHash
▸ generateTypedDataHash(typedData
: EIP712TypedData): Buffer
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:126
Generates the EIP712 Typed Data hash for signing
Parameters:
Name | Type | Description |
---|---|---|
typedData |
EIP712TypedData | An object that conforms to the EIP712TypedData interface |
Returns: Buffer
A Buffer containing the hash of the typed data.
structHash
▸ structHash(primaryType
: string, data
: EIP712Object, types
: EIP712Types): Buffer
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:248
Parameters:
Name | Type |
---|---|
primaryType |
string |
data |
EIP712Object |
types |
EIP712Types |
Returns: Buffer
typeHash
▸ typeHash(primaryType
: string, types
: EIP712Types): Buffer
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:183
Parameters:
Name | Type |
---|---|
primaryType |
string |
types |
EIP712Types |
Returns: Buffer
zeroValue
▸ zeroValue(primaryType
: string, types
: EIP712Types): EIP712ObjectValue
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:264
Produce the zero value for a given type.
remarks
All atomic types will encode as the 32-byte zero value. Dynamic types as an empty hash.
Dynamic arrays will return an empty array. Fixed length arrays will have members set to zero.
Structs will have the values of all fields set to zero recursively.
Note that EIP-712 does not specify zero values, and so this is non-standard.
Parameters:
Name | Type | Default |
---|---|---|
primaryType |
string | - |
types |
EIP712Types | {} |
Returns: EIP712ObjectValue
Object literals
Const
noBool
▪ noBool: object
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:104
Undefined EIP712Optional type with value type boolean.
defined
• defined: false = false
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:105
value
• value: false = false
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:106
Const
noNumber
▪ noNumber: object
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:110
Undefined EIP712Optional type with value type number.
defined
• defined: false = false
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:111
value
• value: number = 0
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:112
Const
noString
▪ noString: object
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:116
Undefined EIP712Optional type with value type string.
defined
• defined: false = false
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:117
value
• value: string = ""
Defined in packages/sdk/utils/src/sign-typed-data-utils.ts:118