Skip to content

Commit cad3910

Browse files
Seongjae ChoiSeongjae Choi
authored andcommitted
Add GetLatestSeq()
1 parent 2618c2f commit cad3910

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

chain.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,16 @@ func (c *Chain) IsAssetSpent(tracker string, transactionIndex int, shardID int,
109109
return spent, err
110110
}
111111

112-
func (c *Chain) GetSeq(address string, blockNumber int) (int, error) {
112+
func (c *Chain) GetLatestSeq(address string) (uint, error) {
113113
const method = "chain_getSeq"
114-
var seq int
114+
var seq uint
115+
err := c.rpcClient.call(callInterface{method: method, id: ""}, &seq, address)
116+
return seq, err
117+
}
118+
119+
func (c *Chain) GetSeq(address string, blockNumber int) (uint, error) {
120+
const method = "chain_getSeq"
121+
var seq uint
115122
err := c.rpcClient.call(callInterface{method: method, id: ""}, &seq, address, blockNumber)
116123
return seq, err
117124
}

chain_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package rpc
22

33
import (
4-
"fmt"
54
"testing"
65
)
76

87
func TestChain(t *testing.T) {
98
chain := NewRPC("https://corgi-rpc.codechain.io/").Chain
10-
res, err := chain.GetBlockByNumber(5)
9+
_, err := chain.GetBlockByNumber(5)
1110
if err != nil {
1211
t.Fatal("Chain test failed")
1312
}
14-
fmt.Println(res.Hash)
13+
14+
_, err = chain.GetLatestSeq("wccq9dddym9sc6rn3jgsnmp8qel57s5mwjq6v5ye68e")
15+
if err != nil {
16+
t.Fatal("GetLatestSeq() Failed")
17+
}
1518
}

0 commit comments

Comments
 (0)