@@ -2,6 +2,8 @@ import BigInt
22import CryptoSwift
33import Foundation
44
5+ // TODO: Refactor me
6+
57struct EIP712Domain : EIP712DomainHashable {
68 let chainId : EIP712 . UInt256 ?
79 let verifyingContract : EIP712 . Address
@@ -20,28 +22,42 @@ public struct SafeTx: EIP712Hashable {
2022 let gasToken : EIP712 . Address
2123 let refundReceiver : EIP712 . Address
2224 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+
2339}
2440
2541/// Protocol defines EIP712 struct encoding
26- protocol EIP712Hashable {
42+ public protocol EIP712Hashable {
2743 var typehash : Data { get }
2844 func hash( ) throws -> Data
2945}
3046
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
3652}
3753
38- extension EIP712 . Address {
54+ public extension EIP712 . Address {
3955 static var zero : Self {
4056 EthereumAddress ( Data ( count: 20 ) ) !
4157 }
4258}
4359
44- extension EIP712Hashable {
60+ public extension EIP712Hashable {
4561 private var name : String {
4662 let fullName = " \( Self . self) "
4763 let name = fullName. components ( separatedBy: " . " ) . last ?? fullName
0 commit comments