-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
PR for Supporting Get ETH Tx Receipt by Tx Hash #62
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f60d795
ci: use Github Actions
nanmu42 d7619c6
doc: update docs
nanmu42 b2589b7
refactor: cleanup code
nanmu42 45bbbc6
ci: fix env access, add cron
nanmu42 52fa07a
doc: fix ci badge link
nanmu42 2ab97d1
Query Transaction Receipt using Transaction Hash
avislash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
schedule: | ||
- cron: "42 6 * * 0" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.x" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
go mod download github.com/davecgh/go-spew | ||
go mod download github.com/google/go-cmp | ||
|
||
- name: Test | ||
env: | ||
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} | ||
run: go test -v -coverprofile=coverage.txt -covermode=count ./... | ||
|
||
- name: Codecov | ||
uses: codecov/[email protected] | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
module github.com/nanmu42/etherscan-api | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 | ||
github.com/google/go-cmp v0.5.6 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2021 LI Zhennan | ||
* | ||
* Use of this work is governed by a MIT License. | ||
* You may find a license copy in project root. | ||
*/ | ||
|
||
package etherscan | ||
|
||
// GetTransactionReceipt gets ETH Transaction Receipt for a given transaction hash | ||
func (c *Client) GetTransactionReceipt(txHash string) (receipt TxReceipt, err error) { | ||
param := M{ | ||
"txhash": txHash, | ||
} | ||
|
||
err = c.call("proxy", "eth_getTransactionReceipt", param, &receipt) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2021 LI Zhennan | ||
* | ||
* Use of this work is governed by a MIT License. | ||
* You may find a license copy in project root. | ||
*/ | ||
|
||
package etherscan | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/davecgh/go-spew/spew" | ||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestClient_GetTransactionReceipt(t *testing.T) { | ||
var expectedReceipt TxReceipt | ||
//Response grabbed from random transaction on Etherscan.io. This is a good test since it has a couple of embedded Logs | ||
cannedResp := []byte(`{"blockHash":"0x9d4d4c6bab3dcd3b0b3a65f3b1880a9414990090da9315183b81a1b9a309b79e","blockNumber":"0xccc210","contractAddress":null,"cumulativeGasUsed":"0x35365c","effectiveGasPrice":"0x26d7dd3724","from":"0xf878c632317b5c58c88e8b7e8de6aa17bb3dfe83","gasUsed":"0x200ea","logs":[{"address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","topics":["0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c","0x00000000000000000000000003f7724180aa6b939894b5ca4314783b0b36b329"],"data":"0x000000000000000000000000000000000000000000000000008e1bc9bf040000","blockNumber":"0xccc210","transactionHash":"0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5","transactionIndex":"0x12","blockHash":"0x9d4d4c6bab3dcd3b0b3a65f3b1880a9414990090da9315183b81a1b9a309b79e","logIndex":"0x37","removed":false},{"address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x00000000000000000000000003f7724180aa6b939894b5ca4314783b0b36b329","0x000000000000000000000000d0dcb7a4f8cfcdb29364d621ca5d997b7eddbc46"],"data":"0x000000000000000000000000000000000000000000000000008e1bc9bf040000","blockNumber":"0xccc210","transactionHash":"0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5","transactionIndex":"0x12","blockHash":"0x9d4d4c6bab3dcd3b0b3a65f3b1880a9414990090da9315183b81a1b9a309b79e","logIndex":"0x38","removed":false},{"address":"0x8b3192f5eebd8579568a2ed41e6feb402f93f73f","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000d0dcb7a4f8cfcdb29364d621ca5d997b7eddbc46","0x000000000000000000000000f878c632317b5c58c88e8b7e8de6aa17bb3dfe83"],"data":"0x000000000000000000000000000000000000000000000000932a9ca104b8bd31","blockNumber":"0xccc210","transactionHash":"0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5","transactionIndex":"0x12","blockHash":"0x9d4d4c6bab3dcd3b0b3a65f3b1880a9414990090da9315183b81a1b9a309b79e","logIndex":"0x39","removed":false},{"address":"0xd0dcb7a4f8cfcdb29364d621ca5d997b7eddbc46","topics":["0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"],"data":"0x0000000000000000000000000000000000000000000000f2ce932331c81806b2000000000000000000000000000000000000000000000000e5a3780b0117856d","blockNumber":"0xccc210","transactionHash":"0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5","transactionIndex":"0x12","blockHash":"0x9d4d4c6bab3dcd3b0b3a65f3b1880a9414990090da9315183b81a1b9a309b79e","logIndex":"0x3a","removed":false},{"address":"0xd0dcb7a4f8cfcdb29364d621ca5d997b7eddbc46","topics":["0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822","0x00000000000000000000000003f7724180aa6b939894b5ca4314783b0b36b329","0x000000000000000000000000f878c632317b5c58c88e8b7e8de6aa17bb3dfe83"],"data":"0x000000000000000000000000000000000000000000000000000008d0e801213b000000000000000000000000000000000000000000000000008e1bc9bf040000000000000000000000000000000000000000000000000000962b7b410a0ae0650000000000000000000000000000000000000000000000000000000000000000","blockNumber":"0xccc210","transactionHash":"0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5","transactionIndex":"0x12","blockHash":"0x9d4d4c6bab3dcd3b0b3a65f3b1880a9414990090da9315183b81a1b9a309b79e","logIndex":"0x3b","removed":false}],"logsBloom":"0x00200000000000000000000080000004000000000800000000000000000040000000000000000000000000000000000003000000080001000000000000000000000000000000000000000008000000200000000000000000000020008000000000000000000000000000000000000000000210000000000000000010000000000000000000000000100000000000000400000001000000080000004000000000000000000000000000000000000200000000001000000000000000000000000100000002001000000000000000000000000000000000001000000000000000000000200000000080000000000000000000000000000000400000000000000000","status":"0x1","to":"0x03f7724180aa6b939894b5ca4314783b0b36b329","transactionHash":"0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5","transactionIndex":"0x12","type":"0x2"}`) | ||
|
||
json.Unmarshal(cannedResp, &expectedReceipt) | ||
|
||
actualReceipt, err := api.GetTransactionReceipt("0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5") | ||
noError(t, err, "api.GetTransactionReceipt") | ||
|
||
if !cmp.Equal(expectedReceipt, actualReceipt) { | ||
t.Errorf(`api.GetTransactionReceipt("0x162681c37d4e5db904b85a9953cbbe213e9631d5c928ad6b772f696aac9f67f5" not working, got %s, want %s`, spew.Sdump(actualReceipt), spew.Sdump(expectedReceipt)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These only got added to make testing in proxy_e2e_test.go easier. I can simplify the test case by using a simpler txn receipt and test more similar to the other cases just let me know.