Skip to content

Commit

Permalink
Release v1.1.10 (#50)
Browse files Browse the repository at this point in the history
* fix: chunk getting token details into 10 at a time
chore: refactored transfer tracer
chore: bumped version to 1.1.10

* chore: updated Ethereum client trace support matrix
  • Loading branch information
naddison36 authored Mar 5, 2023
1 parent 3a7e437 commit d10bd69
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 57 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ curl --location --request POST 'https://your.node.url/yourApiKey' \

| | OpenEthereum | Nethereum | Besu | Geth | Erigon | Akula | Anvil | Hardhat | Ganache |
|---|---|---|---|---|---|---|---|---|---|
| trace_replayTransaction | X | X | | | | X | | | |
| trace_transaction | X | X | X | | | | X | | |
| trace_replayTransaction | X | X | | | X | X | | | |
| trace_transaction | X | X | X | | X | | X | | |
| trace_rawTransaction | X | X | X | | | X | | | |
| debug_traceTransaction | | | | X | X | | X | X | X |
| debug_traceTransaction | | X | X | X | X | | X | X | X |
| debug_traceTransaction with tracer param | | | | X | X | | | | |

### Ethereum API provider trace support
Expand All @@ -273,7 +273,7 @@ Most Ethereum API providers do not provide tracing or debugging APIs as they are

- [Alchemy](https://alchemyapi.io/) supports both [trace_transaction](https://docs.alchemy.com/reference/trace-transaction) and [debug_traceTransaction](https://docs.alchemy.com/reference/sdk-tracetransaction) on their paid [Growth plan](https://alchemyapi.io/pricing). Only the in-built `call` and `prestate` tracers are supported. Custom tracers is not supported.

- [QuickNode](https://www.quicknode.com/) supports both [trace_transaction](https://www.quicknode.com/docs/ethereum/trace_transaction) and [debug_traceTransaction](https://www.quicknode.com/docs/ethereum/debug_traceTransaction) on their paid plan. Only the in-built `call` and `prestate` tracers are supported. Custom tracers is not supported.
- [QuickNode](https://www.quicknode.com/) supports both [trace_transaction](https://www.quicknode.com/docs/ethereum/trace_transaction) and [debug_traceTransaction](https://www.quicknode.com/docs/ethereum/debug_traceTransaction) on their paid plan. The in-built `call` and `prestate` tracers are supported. Custom tracers can be requested via support and approved if within resourcing limits.

- [Chainstack](https://chainstack.com/) supports both [trace_transaction](https://docs.chainstack.com/api/ethereum/trace_transaction) and [debug_traceTransaction](https://docs.chainstack.com/api/ethereum/debug_traceTransaction) on their Business plan. Tracers are not supported.

Expand Down
28 changes: 18 additions & 10 deletions lib/clients/EthereumNodeClient.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 19 additions & 15 deletions lib/clients/GethClient.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/transaction.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tx2uml",
"version": "1.1.9",
"version": "1.1.10",
"description": "Ethereum transaction visualizer that generates UML sequence diagrams.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
33 changes: 23 additions & 10 deletions src/ts/clients/EthereumNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,29 @@ export default abstract class EthereumNodeClient {
this.ethersProvider
) as TokenInfo
try {
const results = await tokenInfo.getInfoBatch(contractAddresses)
debug(`Got token information for ${results.length} contracts`)
return results.map((result, i) => ({
address: contractAddresses[i],
noContract: result.noContract,
nft: result.nft,
tokenSymbol: result.symbol,
tokenName: result.name,
decimals: result.decimals.toNumber(),
}))
// Break up the calls into 10 contracts at a time
let tokenDetails: TokenDetails[] = []
const chunkSize = 10
for (let i = 0; i < contractAddresses.length; i += chunkSize) {
const cunkedAddresses = contractAddresses.slice(
i,
i + chunkSize
)
const results = await tokenInfo.getInfoBatch(cunkedAddresses)
const mappedResponse: TokenDetails[] = results.map(
(result, r) => ({
address: contractAddresses[i + r],
noContract: result.noContract,
nft: result.nft,
tokenSymbol: result.symbol,
tokenName: result.name,
decimals: result.decimals.toNumber(),
})
)
tokenDetails = tokenDetails.concat(mappedResponse)
}
debug(`Got token information for ${tokenDetails.length} contracts`)
return tokenDetails
} catch (err) {
console.error(
`Failed to get token information for contracts: ${contractAddresses}.\nerror: ${err.message}`
Expand Down
34 changes: 19 additions & 15 deletions src/ts/clients/GethClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,25 @@ export default class GethClient extends EthereumNodeClient {
data: [],
fault: function(log) {},
step: function(log) {
if(log.op.toString().match(/LOG/) && log.stack.peek(2).toString(16) === "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") {
this.data.push({
event: "Transfer",
pc: log.getPC(),
tokenAddress: toHex(log.contract.getAddress())})
} else if(log.op.toString().match(/LOG/) && log.stack.peek(2).toString(16) === "e1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c" ) {
this.data.push({
event: "Deposit",
pc: log.getPC(),
tokenAddress: toHex(log.contract.getAddress())})
} else if(log.op.toString().match(/LOG/) && log.stack.peek(2).toString(16) === "7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65" ) {
this.data.push({
event: "Withdraw",
pc: log.getPC(),
tokenAddress: toHex(log.contract.getAddress())})
if (log.op.toString().match(/LOG/)) {
const topic1 = log.stack.peek(2).toString(16);
const tokenAddress = toHex(log.contract.getAddress());
if (topic1 === "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef") {
this.data.push({
event: "Transfer",
pc: log.getPC(),
tokenAddress})
} else if (topic1 === "e1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c" ) {
this.data.push({
event: "Deposit",
pc: log.getPC(),
tokenAddress})
} else if (topic1 === "7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65" ) {
this.data.push({
event: "Withdraw",
pc: log.getPC(),
tokenAddress})
}
} else if(log.op.toString() == "CALL" && log.stack.length() >= 3 && log.stack.peek(2) > 0) {
// Ether transfer in call
this.data.push({
Expand Down
2 changes: 1 addition & 1 deletion src/ts/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class TransactionManager {
const participant = participants[transfer.tokenAddress]
if (participant) {
transfer.tokenSymbol = participant.tokenSymbol
transfer.tokenName = participant.address
transfer.tokenName = participant.tokenName
transfer.decimals = participant.decimals
// if an NFT, move the value to the tokenId
if (participant.nft) {
Expand Down

0 comments on commit d10bd69

Please sign in to comment.