Commit b0ddc0bd authored by yann300's avatar yann300

fix formatting value if error

parent 2a446d30
...@@ -21,7 +21,7 @@ export async function solidityLocals (vmtraceIndex, internalTreeCall, stack, mem ...@@ -21,7 +21,7 @@ export async function solidityLocals (vmtraceIndex, internalTreeCall, stack, mem
locals[name] = await variable.type.decodeFromStack(variable.stackDepth, stack, memory, storageResolver, calldata, cursor, variable) locals[name] = await variable.type.decodeFromStack(variable.stackDepth, stack, memory, storageResolver, calldata, cursor, variable)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
locals[name] = '<decoding failed - ' + e.message + '>' locals[name] = { error: '<decoding failed - ' + e.message + '>' }
} }
} }
} }
......
...@@ -25,7 +25,7 @@ export async function decodeState (stateVars, storageResolver) { ...@@ -25,7 +25,7 @@ export async function decodeState (stateVars, storageResolver) {
ret[stateVar.name] = decoded ret[stateVar.name] = decoded
} catch (e) { } catch (e) {
console.log(e) console.log(e)
ret[stateVar.name] = '<decoding failed - ' + e.message + '>' ret[stateVar.name] = { error: '<decoding failed - ' + e.message + '>' }
} }
} }
return ret return ret
...@@ -64,6 +64,6 @@ export async function solidityState (storageResolver, astList, contractName) { ...@@ -64,6 +64,6 @@ export async function solidityState (storageResolver, astList, contractName) {
try { try {
return await decodeState(stateVars, storageResolver) return await decodeState(stateVars, storageResolver)
} catch (e) { } catch (e) {
return '<decoding failed - ' + e.message + '>' return { error: '<decoding failed - ' + e.message + '>' }
} }
} }
...@@ -36,7 +36,7 @@ export class ArrayType extends RefType { ...@@ -36,7 +36,7 @@ export class ArrayType extends RefType {
} catch (e) { } catch (e) {
console.log(e) console.log(e)
return { return {
value: '<decoding failed - ' + e.message + '>', error: '<decoding failed - ' + e.message + '>',
type: this.typeName type: this.typeName
} }
} }
...@@ -56,7 +56,7 @@ export class ArrayType extends RefType { ...@@ -56,7 +56,7 @@ export class ArrayType extends RefType {
ret.push(await this.underlyingType.decodeFromStorage(currentLocation, storageResolver)) ret.push(await this.underlyingType.decodeFromStorage(currentLocation, storageResolver))
} catch (e) { } catch (e) {
return { return {
value: '<decoding failed - ' + e.message + '>', error: '<decoding failed - ' + e.message + '>',
type: this.typeName type: this.typeName
} }
} }
...@@ -84,7 +84,7 @@ export class ArrayType extends RefType { ...@@ -84,7 +84,7 @@ export class ArrayType extends RefType {
} }
if (isNaN(length)) { if (isNaN(length)) {
return { return {
value: '<decoding failed - length is NaN>', error: '<decoding failed - length is NaN>',
type: 'Error' type: 'Error'
} }
} }
......
...@@ -16,7 +16,7 @@ export class DynamicByteArray extends RefType { ...@@ -16,7 +16,7 @@ export class DynamicByteArray extends RefType {
value = await extractHexValue(location, storageResolver, this.storageBytes) value = await extractHexValue(location, storageResolver, this.storageBytes)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
return { value: '<decoding failed - ' + e.message + '>', type: this.typeName } return { error: '<decoding failed - ' + e.message + '>', type: this.typeName }
} }
const length = new BN(value, 16) const length = new BN(value, 16)
if (length.testn(0)) { if (length.testn(0)) {
...@@ -27,7 +27,7 @@ export class DynamicByteArray extends RefType { ...@@ -27,7 +27,7 @@ export class DynamicByteArray extends RefType {
currentSlot = await readFromStorage(dataPos, storageResolver) currentSlot = await readFromStorage(dataPos, storageResolver)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
return { value: '<decoding failed - ' + e.message + '>', type: this.typeName } return { error: '<decoding failed - ' + e.message + '>', type: this.typeName }
} }
while (length.gt(new BN(ret.length)) && ret.length < 32000) { while (length.gt(new BN(ret.length)) && ret.length < 32000) {
currentSlot = currentSlot.replace('0x', '') currentSlot = currentSlot.replace('0x', '')
...@@ -37,7 +37,7 @@ export class DynamicByteArray extends RefType { ...@@ -37,7 +37,7 @@ export class DynamicByteArray extends RefType {
currentSlot = await readFromStorage(dataPos, storageResolver) currentSlot = await readFromStorage(dataPos, storageResolver)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
return { value: '<decoding failed - ' + e.message + '>', type: this.typeName } return { error: '<decoding failed - ' + e.message + '>', type: this.typeName }
} }
} }
return { value: '0x' + ret.replace(/(00)+$/, ''), length: '0x' + length.toString(16), type: this.typeName } return { value: '0x' + ret.replace(/(00)+$/, ''), length: '0x' + length.toString(16), type: this.typeName }
......
...@@ -15,7 +15,7 @@ export class StringType extends DynamicByteArray { ...@@ -15,7 +15,7 @@ export class StringType extends DynamicByteArray {
decoded = await super.decodeFromStorage(location, storageResolver) decoded = await super.decodeFromStorage(location, storageResolver)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
return '<decoding failed - ' + e.message + '>' return { error: '<decoding failed - ' + e.message + '>' }
} }
return format(decoded) return format(decoded)
} }
...@@ -25,7 +25,7 @@ export class StringType extends DynamicByteArray { ...@@ -25,7 +25,7 @@ export class StringType extends DynamicByteArray {
return await super.decodeFromStack(stackDepth, stack, memory, null, calldata, variableDetails) return await super.decodeFromStack(stackDepth, stack, memory, null, calldata, variableDetails)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
return '<decoding failed - ' + e.message + '>' return { error: '<decoding failed - ' + e.message + '>' }
} }
} }
......
...@@ -22,7 +22,7 @@ export class Struct extends RefType { ...@@ -22,7 +22,7 @@ export class Struct extends RefType {
ret[item.name] = await item.type.decodeFromStorage(globalLocation, storageResolver) ret[item.name] = await item.type.decodeFromStorage(globalLocation, storageResolver)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
ret[item.name] = '<decoding failed - ' + e.message + '>' ret[item.name] = { error: '<decoding failed - ' + e.message + '>' }
} }
} }
return { value: ret, type: this.typeName } return { value: ret, type: this.typeName }
......
...@@ -31,7 +31,7 @@ export class ValueType { ...@@ -31,7 +31,7 @@ export class ValueType {
return { value: this.decodeValue(value), type: this.typeName } return { value: this.decodeValue(value), type: this.typeName }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
return { value: '<decoding failed - ' + e.message + '>', type: this.typeName } return { error: '<decoding failed - ' + e.message + '>', type: this.typeName }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment