File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -145,12 +145,12 @@ extension ABIv2.Element {
145
145
func decodeInputData( _ rawData: Data ) -> [ String : Any ] ? {
146
146
var data = rawData
147
147
var sig : Data ? = nil
148
- switch rawData. count % 4 {
148
+ switch rawData. count % 32 {
149
149
case 0 :
150
150
break
151
151
case 4 :
152
152
sig = rawData [ 0 ..< 4 ]
153
- data = rawData [ 4 ..< rawData. count]
153
+ data = Data ( rawData [ 4 ..< rawData. count] )
154
154
default :
155
155
return nil
156
156
}
Original file line number Diff line number Diff line change @@ -2141,6 +2141,13 @@ class web3swiftTests: XCTestCase {
2141
2141
}
2142
2142
}
2143
2143
2144
+ func testDecodeInputData( ) {
2145
+ let contract = ContractV2 . init ( Web3 . Utils. erc20ABI) !
2146
+ let dataToDecode = Data . fromHex ( " 0xa9059cbb000000000000000000000000cdd45864e794fe5e3e1b0045b77e62f4c43b8bd9000000000000000000000000000000000000000000000224b5f018c3e30142d5 " ) !
2147
+ let decoded = contract. decodeInputData ( " transfer " , data: dataToDecode)
2148
+ XCTAssert ( decoded![ " _to " ] as? EthereumAddress == EthereumAddress ( " 0xcdd45864e794fe5e3e1b0045b77e62f4c43b8bd9 " ) )
2149
+ }
2150
+
2144
2151
func testPerformanceExample( ) {
2145
2152
// This is an example of a performance test case.
2146
2153
self . measure {
You can’t perform that action at this time.
0 commit comments