Skip to content

Commit

Permalink
Merge pull request #63 from Zilliqa/dev
Browse files Browse the repository at this point in the history
Merge from dev
  • Loading branch information
renlulu committed Jul 13, 2020
2 parents d6170e4 + 0b3fabb commit 8388182
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .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.
17 changes: 17 additions & 0 deletions .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.
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,15 @@
## Description
<!-- What is the overall goals of your pull request? -->
<!-- What is the context of your pull request? -->
<!-- What are the related issues and pull requests? -->

## Review Suggestion
<!-- How should the reviewers get started on reviewing your pull request-->
<!-- How can the reviewers verify the pull request is working as expected -->

## Status

### Implementation
<!-- Add more TODOs before "ready for review", if any -->
- [ ] **ready for review**

34 changes: 33 additions & 1 deletion provider/provider.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions provider/provider_test.go
Expand Up @@ -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/")
Expand Down

0 comments on commit 8388182

Please sign in to comment.