Skip to content
This repository was archived by the owner on Jul 30, 2022. It is now read-only.

Commit ff9b3e9

Browse files
Cleaned up recursive base cases in which types were being indexed where they shouldn't be
1 parent a9dd15c commit ff9b3e9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

index.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,21 @@ class InputDataDecoder {
7171
if (typeof data !== 'string') {
7272
data = ''
7373
}
74-
7574
data = data.trim()
7675

7776
const dataBuf = Buffer.from(data.replace(/^0x/, ''), 'hex')
7877
const methodId = toHexString(dataBuf.subarray(0, 4))
7978
var inputsBuf = dataBuf.subarray(4)
8079

80+
// console.log(methodId)
81+
// console.log(inputsBuf.toString('hex'))
82+
8183
const result = this.abi.reduce((acc, obj) => {
84+
// console.log('acc')
85+
// console.log(acc)
86+
// console.log('obj')
87+
// console.log(obj)
88+
8289
if (obj.type === 'constructor') return acc
8390
if (obj.type === 'event') return acc
8491
const method = obj.name || null
@@ -164,21 +171,20 @@ class InputDataDecoder {
164171

165172
// remove 0x from addresses
166173
function deepStripTupleAddresses (input, tupleTypes) {
167-
// check for deeper nested tuples recursively
168-
if (Array.isArray(input[0])) {
169-
return input.map(function (item) {
170-
return deepStripTupleAddresses(item, tupleTypes)
171-
})
172-
}
173174

174175
return input.map((item, i) => {
175-
const type = tupleTypes[i].type
176+
const type = tupleTypes[i] ? tupleTypes[i].type : tupleTypes
177+
176178
if (type === 'address' && typeof item === 'string') {
177179
return item.split('0x')[1]
178180
}
179181
if (type === 'address[]' || Array.isArray()) {
180182
return item.map(a => a.split('0x')[1])
181183
}
184+
185+
if (Array.isArray(item)) {
186+
return deepStripTupleAddresses(item, tupleTypes)
187+
}
182188
return item
183189
})
184190
}

0 commit comments

Comments
 (0)