File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Sources/web3swift/Utils/EIP/EIP712 Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -187,17 +187,21 @@ public struct EIP712TypedData {
187187
188188 internal func encodeType( _ type: String , _ typeData: [ EIP712TypeProperty ] , typesCovered: [ String ] = [ ] ) throws -> String {
189189 var typesCovered = typesCovered
190- var encodedSubtypes : [ String ] = [ ]
190+ var encodedSubtypes : [ String : String ] = [ : ]
191191 let parameters = try typeData. map { attributeType in
192192 if let innerTypes = types [ attributeType. coreType] , !typesCovered. contains ( attributeType. coreType) {
193193 typesCovered. append ( attributeType. coreType)
194194 if attributeType. coreType != type {
195- encodedSubtypes. append ( try encodeType ( attributeType. coreType, innerTypes) )
195+ encodedSubtypes [ attributeType . coreType ] = try encodeType ( attributeType. coreType, innerTypes)
196196 }
197197 }
198198 return " \( attributeType. type) \( attributeType. name) "
199199 }
200- return type + " ( " + parameters. joined ( separator: " , " ) + " ) " + encodedSubtypes. joined ( separator: " " )
200+ return type + " ( " + parameters. joined ( separator: " , " ) + " ) " + encodedSubtypes. sorted { lhs, rhs in
201+ return lhs. key < rhs. key
202+ }
203+ . map { $0. value }
204+ . joined ( separator: " " )
201205 }
202206
203207 /// Convenience function for ``encodeData(_:data:)`` that uses ``primaryType`` and ``message`` as values.
You can’t perform that action at this time.
0 commit comments