-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from InjectiveLabs/feat/add_missing_explorer_…
…endpoints Feat/add missing explorer endpoints
- Loading branch information
Showing
9 changed files
with
402 additions
and
28 deletions.
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
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,48 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
"github.com/InjectiveLabs/sdk-go/client/explorer" | ||
explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" | ||
) | ||
|
||
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
|
||
explorerClient, err := explorer.NewExplorerClient(network) | ||
if err != nil { | ||
log.Fatalf("Failed to create explorer client: %v", err) | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
defer cancel() | ||
|
||
// Example contract address (replace with an actual contract address) | ||
contractAddress := "inj1ady3s7whq30l4fx8sj3x6muv5mx4dfdlcpv8n7" | ||
|
||
req := &explorerPB.GetContractTxsRequest{ | ||
Address: contractAddress, | ||
Limit: 10, // Fetch 10 transactions | ||
} | ||
|
||
response, err := explorerClient.FetchContractTxs(ctx, req) | ||
if err != nil { | ||
log.Fatalf("Failed to fetch contract transactions: %v", err) | ||
} | ||
|
||
fmt.Println("Total Contract Transactions:", len(response.Data)) | ||
for _, tx := range response.Data { | ||
fmt.Printf("Tx Hash: %s, Block: %d\n", tx.Hash, tx.BlockNumber) | ||
} | ||
|
||
fmt.Printf("\n\n") | ||
fmt.Println("Full response:") | ||
str, _ := json.MarshalIndent(response, "", " ") | ||
fmt.Print(string(str)) | ||
} |
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,49 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
"github.com/InjectiveLabs/sdk-go/client/common" | ||
"github.com/InjectiveLabs/sdk-go/client/explorer" | ||
explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" | ||
) | ||
|
||
func main() { | ||
network := common.LoadNetwork("testnet", "lb") | ||
|
||
explorerClient, err := explorer.NewExplorerClient(network) | ||
if err != nil { | ||
log.Fatalf("Failed to create explorer client: %v", err) | ||
} | ||
defer explorerClient.Close() | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
defer cancel() | ||
|
||
// Example contract address (replace with an actual contract address) | ||
contractAddress := "inj1ady3s7whq30l4fx8sj3x6muv5mx4dfdlcpv8n7" | ||
|
||
req := &explorerPB.GetContractTxsV2Request{ | ||
Address: contractAddress, | ||
Limit: 10, // Fetch 10 transactions | ||
} | ||
|
||
response, err := explorerClient.FetchContractTxsV2(ctx, req) | ||
if err != nil { | ||
log.Fatalf("Failed to fetch contract transactions V2: %v", err) | ||
} | ||
|
||
fmt.Println("Total Contract Transactions:", len(response.Data)) | ||
for _, tx := range response.Data { | ||
fmt.Printf("Tx Hash: %s, Block: %d\n", tx.Hash, tx.BlockNumber) | ||
} | ||
|
||
fmt.Printf("\n\n") | ||
fmt.Println("Full response:") | ||
str, _ := json.MarshalIndent(response, "", " ") | ||
fmt.Print(string(str)) | ||
} |
Oops, something went wrong.