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
erc1155 tx struct and ERC1155Transfers added
  • Loading branch information
Dodonov Pavel authored and Dodonov Pavel committed Dec 12, 2022
commit cf99fda6d3e7b8c40e2f2e93ed29499c0fed52af
24 changes: 24 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,30 @@ func (c *Client) ERC721Transfers(contractAddress, address *string, startBlock *i
return
}

// ERC1155Transfers get a list of "erc1155 - token transfer events" by
// contract address and/or from/to address.
//
// leave undesired condition to nil.
func (c *Client) ERC1155Transfers(contractAddress, address *string, startBlock *int, endBlock *int, page int, offset int, desc bool) (txs []ERC1155Transfer, err error) {
param := M{
"page": page,
"offset": offset,
}
compose(param, "contractaddress", contractAddress)
compose(param, "address", address)
compose(param, "startblock", startBlock)
compose(param, "endblock", endBlock)

if desc {
param["sort"] = "desc"
} else {
param["sort"] = "asc"
}

err = c.call("account", "token1155tx", param, &txs)
return
}

// BlocksMinedByAddress gets list of blocks mined by address
func (c *Client) BlocksMinedByAddress(address string, page int, offset int) (mined []MinedBlock, err error) {
param := M{
Expand Down
18 changes: 18 additions & 0 deletions account_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,21 @@ func TestClient_ERC721Transfers(t *testing.T) {
t.Errorf("got txs length %v, want %v", len(txs), wantLen)
}
}

func TestClient_ERC1155Transfers(t *testing.T) {
const (
wantLen = 1
)

var a, b = 128135633, 1802672
var contract, address = "0x3edf71a31b80Ff6a45Fdb0858eC54DE98dF047AA", "0x4b986EF20Bb83532911521FB4F6F5605122a0721"
txs, err := api.ERC1155Transfers(&contract, &address, &b, &a, 0, 0, true)
noError(t, err, "api.ERC721Transfers")

j, _ := json.MarshalIndent(txs, "", " ")
fmt.Printf("%s\n", j)

if len(txs) != wantLen {
t.Errorf("got txs length %v, want %v", len(txs), wantLen)
}
}
28 changes: 26 additions & 2 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,30 @@ type ERC721Transfer struct {
Confirmations int `json:"confirmations,string"`
}

// ERC1155Transfer holds info from ERC1155 token transfer event query
type ERC1155Transfer struct {
BlockNumber int `json:"blockNumber,string"`
TimeStamp Time `json:"timeStamp"`
Hash string `json:"hash"`
Nonce int `json:"nonce,string"`
BlockHash string `json:"blockHash"`
From string `json:"from"`
ContractAddress string `json:"contractAddress"`
To string `json:"to"`
TokenID *BigInt `json:"tokenID"`
TokenName string `json:"tokenName"`
TokenSymbol string `json:"tokenSymbol"`
TokenDecimal uint8 `json:"tokenDecimal,string"`
TokenValue uint8 `json:"tokenValue,string"`
TransactionIndex int `json:"transactionIndex,string"`
Gas int `json:"gas,string"`
GasPrice *BigInt `json:"gasPrice"`
GasUsed int `json:"gasUsed,string"`
CumulativeGasUsed int `json:"cumulativeGasUsed,string"`
Input string `json:"input"`
Confirmations int `json:"confirmations,string"`
}

// MinedBlock holds info from query for mined block by address
type MinedBlock struct {
BlockNumber int `json:"blockNumber,string"`
Expand Down Expand Up @@ -180,8 +204,8 @@ type Log struct {
Removed bool `json:"removed"`
}

//GasPrices holds info for Gas Oracle queries
//Gas Prices are returned in Gwei
// GasPrices holds info for Gas Oracle queries
// Gas Prices are returned in Gwei
type GasPrices struct {
LastBlock int
SafeGasPrice float64
Expand Down