File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Sources/web3swift/Utils/EIP/EIP712 Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,6 @@ public extension EIP712Hashable {
6363 case let boolean as Bool :
6464 result = ABIEncoder . encodeSingleType ( type: . uint( bits: 8 ) , value: boolean ? 1 : 0 ) !
6565 case let hashable as EIP712Hashable :
66- // TODO: should it be hashed here?
6766 result = try hashable. hash ( )
6867 default :
6968 /// Cast to `AnyObject` is required. Otherwise, `nil` value will fail this condition.
Original file line number Diff line number Diff line change 77import Foundation
88import Web3Core
99
10- /// The only purpose of this class is to parse raw JSON and output an EIP712 hash.
10+ /// The only purpose of this class is to parse raw JSON and output an EIP712 hash ready for signing .
1111/// Example of a payload that is received via `eth_signTypedData` for signing:
1212/// ```
1313/// {
@@ -75,7 +75,19 @@ import Web3Core
7575/// }
7676/// }
7777/// ```
78+ ///
79+ /// Example use case:
80+ /// ```
81+ /// let payload: String = ... // This is the payload received from eth_signTypedData
82+ /// let eip712TypedData = try EIP712Parser.parse(payload)
83+ /// let signature = try Web3Signer.signEIP712(
84+ /// eip712TypedData,
85+ /// keystore: keystore,
86+ /// account: account,
87+ /// password: password)
88+ /// ```
7889public class EIP712Parser {
90+
7991 static func toData( _ json: String ) throws -> Data {
8092 guard let json = json. data ( using: . utf8) else {
8193 throw Web3Error . inputError ( desc: " Failed to parse EIP712 payload. Given string is not valid UTF8 string. \( json) " )
You can’t perform that action at this time.
0 commit comments