-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tx decoder #2415
add tx decoder #2415
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||
#!/bin/bash | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Takes the transaction hash as input | ||||||||||||||||||||||||||
rawTx=$1 | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Decode the transaction using cast dt and store the result in a variable | ||||||||||||||||||||||||||
decodedTx=$(cast dt $rawTx) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Use jq to pretty print the decoded transaction | ||||||||||||||||||||||||||
echo "$decodedTx" | jq '.' | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Use jq to extract the values from the decoded transaction | ||||||||||||||||||||||||||
type=$(echo "$decodedTx" | jq -r '.type') | ||||||||||||||||||||||||||
gas=$(echo "$decodedTx" | jq -r '.gas') | ||||||||||||||||||||||||||
value=$(echo "$decodedTx" | jq -r '.value') | ||||||||||||||||||||||||||
nonce=$(echo "$decodedTx" | jq -r '.nonce') | ||||||||||||||||||||||||||
maxPriorityFeePerGas=$(echo "$decodedTx" | jq -r '.maxPriorityFeePerGas') | ||||||||||||||||||||||||||
maxFeePerGas=$(echo "$decodedTx" | jq -r '.maxFeePerGas') | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# Note: The actual conversion commands will depend on the capabilities of 'cast' | ||||||||||||||||||||||||||
echo "Converted Values:" | ||||||||||||||||||||||||||
echo "Type: $(cast --to-dec $type)" # This specific conversion might not make sense for 'type', as it's not a value field. | ||||||||||||||||||||||||||
echo "Gas: $(cast --to-dec $gas)" | ||||||||||||||||||||||||||
echo "Value: $(cast --to-unit $value ether)" | ||||||||||||||||||||||||||
echo "Nonce: $(cast --to-dec $nonce)" | ||||||||||||||||||||||||||
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure variables are double-quoted in command substitutions to prevent globbing and word splitting. - echo "Gas: $(cast --to-dec $gas)"
- echo "Value: $(cast --to-unit $value ether)"
- echo "Nonce: $(cast --to-dec $nonce)"
+ echo "Gas: $(cast --to-dec "$gas")"
+ echo "Value: $(cast --to-unit "$value" ether)"
+ echo "Nonce: $(cast --to-dec "$nonce")" Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)" | ||||||||||||||||||||||||||
echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)" | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure the script's stability and prevent potential issues with globbing and word splitting, it's advisable to double-quote variables in all command substitutions. - echo "Type: $(cast --to-dec $type)"
- echo "Gas: $(cast --to-dec $gas)"
- echo "Value: $(cast --to-unit $value ether)"
- echo "Nonce: $(cast --to-dec $nonce)"
- echo "MaxPriorityFeePerGas: $(cast --to-unit $maxPriorityFeePerGas gwei)"
- echo "MaxFeePerGas: $(cast --to-unit $maxFeePerGas gwei)"
+ echo "Type: $(cast --to-dec "$type")"
+ echo "Gas: $(cast --to-dec "$gas")"
+ echo "Value: $(cast --to-unit "$value" ether)"
+ echo "Nonce: $(cast --to-dec "$nonce")"
+ echo "MaxPriorityFeePerGas: $(cast --to-unit "$maxPriorityFeePerGas" gwei)"
+ echo "MaxFeePerGas: $(cast --to-unit "$maxFeePerGas" gwei)" Committable suggestion
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent globbing and word splitting, double-quote variables in command substitutions.
Committable suggestion