Skip to content

merging back #2

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

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dbb9f1b
fix CI test
nanmu42 Aug 9, 2022
108d273
Merge pull request #73 from nanmu42/nanmu42-patch-1
nanmu42 Aug 9, 2022
caf06a3
Implemented Free Gas Tracker Endpoints
avislash Oct 24, 2022
384329f
Use numeric data types for gas prices, confirmation times, and block …
avislash Oct 25, 2022
115bac1
Merge pull request #74 from avislash/feature/gas_tracker
nanmu42 Oct 25, 2022
cf99fda
erc1155 tx struct and ERC1155Transfers added
Dec 12, 2022
6be0541
Merge pull request #1 from Pashteto/feat/add_erc1155
Pashteto Dec 12, 2022
5b06ae3
go mod replace
Dec 12, 2022
baa647b
Merge pull request #2 from Pashteto/feat/add_erc1155
Pashteto Dec 12, 2022
f615701
go mod replace
Dec 12, 2022
fd417e1
Merge pull request #3 from Pashteto/feat/add_erc1155
Pashteto Dec 12, 2022
d7387da
go mod replace
Dec 12, 2022
d075a55
Merge pull request #4 from Pashteto/feat/add_erc1155
Pashteto Dec 12, 2022
0e26ffd
go mod replace
Dec 12, 2022
56ca3af
Merge pull request #5 from Pashteto/feat/add_erc1155
Pashteto Dec 12, 2022
6a8ea3a
go mod replace
Dec 12, 2022
bbbcecd
Merge pull request #6 from Pashteto/feat/add_erc1155
Pashteto Dec 12, 2022
890f9df
go mod replace
Dec 13, 2022
6c29f9b
Merge pull request #7 from Pashteto/feat/add_erc1155
Pashteto Dec 13, 2022
b8dd9f4
go mod replace
Dec 13, 2022
74c5135
Merge pull request #75 from Pashteto/feat/add_erc1155
nanmu42 Dec 14, 2022
07a1d97
Create FUNDING.yml
nanmu42 Feb 14, 2023
67da1ed
Update response.go
coolestowl Mar 11, 2024
0d2eec1
Merge pull request #84 from coolestowl/master
nanmu42 Mar 12, 2024
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
Prev Previous commit
Next Next commit
Implemented Free Gas Tracker Endpoints
  • Loading branch information
avislash committed Oct 24, 2022
commit caf06a33dbcb0723ee242d9fb880b1040c1ac6f6
21 changes: 21 additions & 0 deletions gas_tracker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 Avi Misra
*
* Use of this work is governed by a MIT License.
* You may find a license copy in project root.
*/

package etherscan

// GasEstiamte gets estiamted confirmation time (in seconds) at the given gas price
func (c *Client) GasEstimate(gasPrice int) (confirmationTimeInSec string, err error) {
params := M{"gasPrice": gasPrice}
err = c.call("gastracker", "gasestimate", params, &confirmationTimeInSec)
return
}

// GasOracle gets suggested gas prices (in Gwei)
func (c *Client) GasOracle() (gasPrices GasPrices, err error) {
err = c.call("gastracker", "gasoracle", M{}, &gasPrices)
return
}
53 changes: 53 additions & 0 deletions gas_tracker_e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018 LI Zhennan
*
* Use of this work is governed by a MIT License.
* You may find a license copy in project root.
*/

package etherscan

import (
"testing"
)

//GasEstiamte generates dynamic data. Best we can do is ensure all fields are populated
func TestClient_GasEstimate(t *testing.T) {
confirmationTime, err := api.GasEstimate(20000000)
noError(t, err, "api.GasEstimate")

if 0 == len(confirmationTime) {
t.Errorf("confirmationTime empty string")
}
}

//GasOracle generates dynamic data. Best we can do is ensure all fields are populated
func TestClient_GasOracle(t *testing.T) {
gasPrice, err := api.GasOracle()
noError(t, err, "api.GasOrcale")

if 0 == len(gasPrice.LastBlock) {
t.Errorf("gasPrice.LastBlock empty string")
}

if 0 == len(gasPrice.SafeGasPrice) {
t.Errorf("gasPrice.SafeGasPrice empty string")
}

if 0 == len(gasPrice.ProposeGasPrice) {
t.Errorf("gasPrice.ProposeGasPrice empty string")
}

if 0 == len(gasPrice.FastGasPrice) {
t.Errorf("gasPrice.FastGasPrice empty string")
}

if 0 == len(gasPrice.SuggestBaseFeeInGwei) {
t.Errorf("gasPrice.SuggestBaseFeeInGwei empty string")
}

if 0 == len(gasPrice.GasUsedRatio) {
t.Errorf("gasPrice.GasUsedRatio empty string")
}

}
10 changes: 10 additions & 0 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,13 @@ type Log struct {
Removed bool `json:"removed"`
}

//GasPrices holds info for Gas Oracle queries
//Gas Prices are returned in Gwei
type GasPrices struct {
LastBlock string
SafeGasPrice string
ProposeGasPrice string
FastGasPrice string
SuggestBaseFeeInGwei string `json:"suggestBaseFee"`
GasUsedRatio string `json:"gasUsedRatio"`
}