@@ -2,6 +2,8 @@ import BigInt
2
2
import CryptoSwift
3
3
import Foundation
4
4
5
+ // TODO: Refactor me
6
+
5
7
struct EIP712Domain : EIP712DomainHashable {
6
8
let chainId : EIP712 . UInt256 ?
7
9
let verifyingContract : EIP712 . Address
@@ -20,28 +22,42 @@ public struct SafeTx: EIP712Hashable {
20
22
let gasToken : EIP712 . Address
21
23
let refundReceiver : EIP712 . Address
22
24
let nonce : EIP712 . UInt256
25
+
26
+ public init ( to: EIP712 . Address , value: EIP712 . UInt256 , data: EIP712 . Bytes , operation: EIP712 . UInt8 , safeTxGas: EIP712 . UInt256 , baseGas: EIP712 . UInt256 , gasPrice: EIP712 . UInt256 , gasToken: EIP712 . Address , refundReceiver: EIP712 . Address , nonce: EIP712 . UInt256 ) {
27
+ self . to = to
28
+ self . value = value
29
+ self . data = data
30
+ self . operation = operation
31
+ self . safeTxGas = safeTxGas
32
+ self . baseGas = baseGas
33
+ self . gasPrice = gasPrice
34
+ self . gasToken = gasToken
35
+ self . refundReceiver = refundReceiver
36
+ self . nonce = nonce
37
+ }
38
+
23
39
}
24
40
25
41
/// Protocol defines EIP712 struct encoding
26
- protocol EIP712Hashable {
42
+ public protocol EIP712Hashable {
27
43
var typehash : Data { get }
28
44
func hash( ) throws -> Data
29
45
}
30
46
31
- class EIP712 {
32
- typealias Address = EthereumAddress
33
- typealias UInt256 = BigUInt
34
- typealias UInt8 = Swift . UInt8
35
- typealias Bytes = Data
47
+ public class EIP712 {
48
+ public typealias Address = EthereumAddress
49
+ public typealias UInt256 = BigUInt
50
+ public typealias UInt8 = Swift . UInt8
51
+ public typealias Bytes = Data
36
52
}
37
53
38
- extension EIP712 . Address {
54
+ public extension EIP712 . Address {
39
55
static var zero : Self {
40
56
EthereumAddress ( Data ( count: 20 ) ) !
41
57
}
42
58
}
43
59
44
- extension EIP712Hashable {
60
+ public extension EIP712Hashable {
45
61
private var name : String {
46
62
let fullName = " \( Self . self) "
47
63
let name = fullName. components ( separatedBy: " . " ) . last ?? fullName
0 commit comments