diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..b735373 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..066b2d9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..61d57e0 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ +## Description + + + + +## Review Suggestion + + + +## Status + +### Implementation + +- [ ] **ready for review** + diff --git a/provider/provider.go b/provider/provider.go index 848da2f..e6b97ef 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -489,7 +489,7 @@ func (provider *Provider) GetPendingTxn(tx string) (*jsonrpc.RPCResponse, error) // false 2 Could not fit in as microblock gas limit reached // false 3 Transaction valid but consensus not reached func (provider *Provider) GetPendingTxns() (*jsonrpc.RPCResponse, error) { - return provider.call("GetPendingTxn") + return provider.call("GetPendingTxns") } // Create a new Transaction object and send it to the network to be process. @@ -541,6 +541,38 @@ func (provider *Provider) GetTransaction(transaction_hash string) (*core.Transac return &transaction, nil } +func (provider *Provider) GetTransactionBatch(transactionHashes []string) ([]*core.Transaction, error) { + var requests jsonrpc.RPCRequests + for _, hash := range transactionHashes { + r := jsonrpc.NewRequest("GetTransaction",[]string{hash}) + requests = append(requests,r) + } + + results,err := provider.rpcClient.CallBatch(requests) + if err != nil { + return nil, err + } + + var transactions []*core.Transaction + + for _,result := range results { + var transaction core.Transaction + jsonString, err2 := json.Marshal(result.Result) + if err2 != nil { + return transactions, err2 + } + err3 := json.Unmarshal(jsonString, &transaction) + if err3 != nil { + return transactions, err3 + } + + transactions = append(transactions,&transaction) + } + + return transactions,nil + +} + // Returns the most recent 100 transactions that are validated by the Zilliqa network. func (provider *Provider) GetRecentTransactions() (*core.Transactions, error) { result, err := provider.call("GetRecentTransactions") diff --git a/provider/provider_test.go b/provider/provider_test.go index 9786b62..f0c1822 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -203,6 +203,14 @@ func TestGetTransaction(t *testing.T) { fmt.Println(result) } +func TestProvider_GetTransactionBatch(t *testing.T) { + SkipIfCI(t) + provider := NewProvider("https://dev-api.zilliqa.com/") + transactions,_ := provider.GetTransactionBatch([]string{"c7d6550a6558edcddbf4b3c7cf14db9f1025200b89bcbcd6a570c84db58d554f","c7d6550a6558edcddbf4b3c7cf14db9f1025200b89bcbcd6a570c84db58d554f"}) + st,_ := json.Marshal(transactions) + fmt.Println(string(st)) +} + func TestGetRecentTransactions(t *testing.T) { SkipIfCI(t) provider := NewProvider("https://dev-api.zilliqa.com/")