Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ web3.eth.getTransactionReceipt("0x9199e262aaab0a6ec99558b3e9f42397c07a2bb9c6befb
const decodedLogs = abiDecoder.decodeLogs(receipt.logs);
});
```

# PR applied
- Decode Logs function : Support tokenId with uint256 #88(https://github.com/Consensys/abi-decoder/pull/88)
- Fix for issue #52 #54(https://github.com/Consensys/abi-decoder/pull/54)
- fix can not decode struct tuple logs #62(https://github.com/Consensys/abi-decoder/pull/62)
- Upgrade deps web3-eth-abi to v1.8.0. #86(https://github.com/Consensys/abi-decoder/pull/86)
- Add support for tuple array #101(https://github.com/Consensys/abi-decoder/pull/101/files)
26 changes: 23 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ function _getABIs() {
}

function _typeToString(input) {
if (input.type === "tuple[]") {
return "(" + input.components.map(_typeToString).join(",") + ")[]";
}
if (input.type === "tuple") {
return "(" + input.components.map(_typeToString).join(",") + ")";
}
Expand Down Expand Up @@ -71,11 +74,18 @@ function _removeABI(abiArray) {
}
}
});

// Remove the ABI from state.savedABIs
state.savedABIs = state.savedABIs.filter((savedAbi) => {
return !abiArray.includes(savedAbi);
});

} else {
throw new Error("Expected ABI array, got " + typeof abiArray);
}
}


function _getMethodIDs() {
return state.methodIDs;
}
Expand Down Expand Up @@ -113,7 +123,12 @@ function _decodeMethod(data) {
const isArray = Array.isArray(param);

if (isArray) {
parsedParam = param.map(_ => _.toLowerCase());
//parsedParam = param.map(_ => _.toLowerCase());
if (param[0].constructor === Array) {
parsedParam = eval(param.toString().toLowerCase());
} else {
parsedParam = param.map(_ => _.toLowerCase());
}
} else {
parsedParam = param.toLowerCase();
}
Expand Down Expand Up @@ -143,7 +158,12 @@ function _decodeLogs(logs) {
let dataTypes = [];
method.inputs.map(function(input) {
if (!input.indexed) {
dataTypes.push(input.type);
//dataTypes.push(input.type);
if(input.type === "tuple") {
dataTypes.push("tuple" + _typeToString(input) );
} else {
dataTypes.push(input);
}
}
});

Expand Down Expand Up @@ -185,7 +205,7 @@ function _decodeLogs(logs) {
) {
// ensure to remove leading 0x for hex numbers
if (typeof decodedP.value === "string" && decodedP.value.startsWith("0x")) {
decodedP.value = new BN(decodedP.value.slice(2), 16).toString(10);
decodedP.value = new BN(decodedP.value, 16).toString(10);
} else {
decodedP.value = new BN(decodedP.value).toString(10);
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abi-decoder",
"version": "2.3.0",
"name": "abi-decoder-ex",
"version": "2.3.4",
"description": "Nodejs and Javascript library for decoding data params and events from ethereum transactions\"",
"main": "index.js",
"scripts": {
Expand All @@ -10,7 +10,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/ConsenSys/abi-decoder.git"
"url": "git+https://github.com/eigenphi/abi-decoder"
},
"keywords": [
"ethereum",
Expand All @@ -20,11 +20,11 @@
"author": "denis@gnosis.pm",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/ConsenSys/abi-decoder/issues"
"url": "https://github.com/eigenphi/abi-decoder/issues"
},
"homepage": "https://github.com/ConsenSys/abi-decoder#readme",
"homepage": "https://github.com/eigenphi/abi-decoder#readme",
"dependencies": {
"web3-eth-abi": "^1.2.1",
"web3-eth-abi": "^1.8.0",
"web3-utils": "^1.2.1"
},
"devDependencies": {
Expand Down