Skip to content

Commit

Permalink
update tx signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Sokkary authored and unclezoro committed Feb 2, 2019
1 parent 4fad79d commit 64cc76b
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 54 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
build
vendor
.DS_Store

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# ide files and temp files
.idea/
*.swp
.vscode/*.json
bnc-go-sdk
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
module github.com/BiJie/bnc-go-sdk

require (
github.com/BiJie/BinanceChain v0.0.0-20181116123007-d131ded17b6b
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac // indirect
github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/structs v1.1.0
github.com/go-kit/kit v0.7.0 // indirect
github.com/go-kit/kit v0.8.0 // indirect
github.com/go-logfmt/logfmt v0.3.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.1.1 // indirect
github.com/golang/protobuf v1.2.0 // indirect
github.com/pkg/errors v0.8.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
github.com/tendermint/ed25519 v0.0.0-20171027050219-d8387025d2b9 // indirect
github.com/tendermint/go-amino v0.14.1
github.com/tendermint/tendermint v0.25.0
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 // indirect
gopkg.in/resty.v1 v1.10.1
github.com/tendermint/tendermint v0.22.8
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869 // indirect
golang.org/x/sys v0.0.0-20181116161606-93218def8b18 // indirect
gopkg.in/resty.v1 v1.10.2
)
24 changes: 14 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
github.com/BiJie/BinanceChain v0.0.0-20181116123007-d131ded17b6b h1:VPJfmPWSRUKQefgsiHMey4sK1F4965o63d4xkSNnP1I=
github.com/BiJie/BinanceChain v0.0.0-20181116123007-d131ded17b6b/go.mod h1:e8lEuFJRD48Razs8euXmG1XCVprVEni8apfgJqCo2Dg=
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac h1:/zx+Hglw2JN/pwVam1Z8cTCTl4pWyrbvOn2oooqCQSs=
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ=
github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a h1:RQMUrEILyYJEoAT34XS/kLu40vC0+po/UfxrBBA4qZE=
github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/go-kit/kit v0.7.0 h1:ApufNmWF1H6/wUbAG81hZOHmqwd0zRf8mNfLjYj/064=
github.com/go-kit/kit v0.7.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2ic=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
Expand All @@ -27,11 +25,17 @@ github.com/tendermint/ed25519 v0.0.0-20171027050219-d8387025d2b9 h1:zccWau0P8FEL
github.com/tendermint/ed25519 v0.0.0-20171027050219-d8387025d2b9/go.mod h1:nt45hbhDkWVdMBkr2TOgOzCrpBccXdN09WOiOYTHVEk=
github.com/tendermint/go-amino v0.14.1 h1:o2WudxNfdLNBwMyl2dqOJxiro5rfrEaU0Ugs6offJMk=
github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/tendermint/tendermint v0.22.8 h1:+snbj1NZtTvTFqjErEVYfPjXVZcm2SUvB5cwwd7X5+c=
github.com/tendermint/tendermint v0.22.8/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc=
github.com/tendermint/tendermint v0.25.0 h1:addKuzem/QXnCpQtCLmgxgDP4Kba67HglB6Y3y2mmG0=
github.com/tendermint/tendermint v0.25.0/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
github.com/tendermint/tendermint v0.26.3 h1:RilJ/9X0yzTJXRoYRJLucg/5diH4lTRciLmMINgruHI=
github.com/tendermint/tendermint v0.26.3/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc=
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869 h1:kkXA53yGe04D0adEYJwEVQjeBppL01Exg+fnMjfUraU=
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1 h1:Y/KGZSOdz/2r0WJ9Mkmz6NJBusp0kiNx1Cn82lzJQ6w=
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
gopkg.in/resty.v1 v1.10.1 h1:8ES+C4z05zrZ/UNEu5YwU3MjpAQhOQCEXfCAuOcdVFo=
gopkg.in/resty.v1 v1.10.1/go.mod h1:nrgQYbPhkRfn2BfT32NNTLfq3K9NuHRB0MsAcA9weWY=
golang.org/x/sys v0.0.0-20181116161606-93218def8b18 h1:Wh+XCfg3kNpjhdq2LXrsiOProjtQZKme5XUx7VcxwAw=
golang.org/x/sys v0.0.0-20181116161606-93218def8b18/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
gopkg.in/resty.v1 v1.10.2 h1:0kn7/nSP3fjAddBOjnYDq0rmyvVFvuk4iFtWQUWptjc=
gopkg.in/resty.v1 v1.10.2/go.mod h1:nrgQYbPhkRfn2BfT32NNTLfq3K9NuHRB0MsAcA9weWY=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func main() {
sdk, _ := sdk.NewSDK("http://localhost:8080/api/v1")
sdk, _ := sdk.NewBncSDK("http://localhost:8080/api/v1")
markets, _ := sdk.GetMarkets(100)
fmt.Println("markets: ", markets)
}
5 changes: 0 additions & 5 deletions sdk/orders_closed.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func (sdk *SDK) GetClosedOrders(query *ClosedOrdersQuery) ([]*Order, error) {
return nil, fmt.Errorf("Invalid `Query.Side` param")
}

<<<<<<< HEAD
dqj, err := json.Marshal(query)
if err != nil {
return nil, err
Expand All @@ -35,10 +34,6 @@ func (sdk *SDK) GetClosedOrders(query *ClosedOrdersQuery) ([]*Order, error) {
json.Unmarshal(dqj, &qp)

resp, err := sdk.dexAPI.Get("/orders/closed", qp)
=======
qp := structs.Map(query)
resp, err := sdk.dexAPI.Get("/orders/closed", ToMapStrStr(qp))
>>>>>>> add open/closed orders endpoints
if err != nil {
return nil, err
}
Expand Down
14 changes: 0 additions & 14 deletions sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,3 @@ func NewBncSDK(baseURL string) (*SDK, error) {
dexAPI: &DexAPI{baseURL},
}, nil
}

// ToMapStrStr conversion
func ToMapStrStr(m map[string]interface{}) map[string]string {
mStrStr := make(map[string]string)
for k, v := range m {
strValue := fmt.Sprintf("%v", v)

// skip empty values
if strValue != "" && strValue != "0" {
mStrStr[k] = strValue
}
}
return mStrStr
}
2 changes: 1 addition & 1 deletion sdk/tx/setup.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tx

import (
"./txmsg"
"github.com/BiJie/bnc-go-sdk/sdk/tx/txmsg"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
Expand Down
2 changes: 1 addition & 1 deletion sdk/tx/sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"./txmsg"
"github.com/BiJie/bnc-go-sdk/sdk/tx/txmsg"
)

func TestSign(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions sdk/tx/stdsign.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tx
import (
"encoding/json"

"./txmsg"
"github.com/BiJie/bnc-go-sdk/sdk/tx/txmsg"
tmcrypto "github.com/tendermint/tendermint/crypto"
)

Expand All @@ -27,12 +27,12 @@ type StdSignMsg struct {
Sequence int64
}

// StdSignature def
// StdSignature Signature
type StdSignature struct {
tmcrypto.PubKey `json:"pub_key"` // optional
Signature []byte `json:"signature"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
tmcrypto.PubKey `json:"pub_key"` // optional
tmcrypto.Signature `json:"signature"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
}

// Bytes gets message bytes
Expand Down
2 changes: 1 addition & 1 deletion sdk/tx/stdsign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"./txmsg"
"github.com/BiJie/bnc-go-sdk/sdk/tx/txmsg"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/ed25519"
)
Expand Down
2 changes: 1 addition & 1 deletion sdk/tx/stdtx.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tx

import (
"./txmsg"
"github.com/BiJie/bnc-go-sdk/sdk/tx/txmsg"
)

// StdTx def
Expand Down
2 changes: 1 addition & 1 deletion sdk/tx/stdtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tx
import (
"testing"

"./txmsg"
"github.com/BiJie/bnc-go-sdk/sdk/tx/txmsg"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/ed25519"
)
Expand Down
8 changes: 3 additions & 5 deletions sdk/tx/txmsg/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package txmsg
import (
"fmt"
"strings"

"github.com/BiJie/BinanceChain/common/utils"
)

// constants
Expand Down Expand Up @@ -49,9 +47,9 @@ func ValidateSymbol(symbol string) error {
symbol = strings.TrimSuffix(symbol, DotBSuffix)
}

if !utils.IsAlphaNum(symbol) {
return fmt.Errorf("Token symbol should be alphanumeric")
}
// if !tx.IsAlphaNum(symbol) {
// return fmt.Errorf("Token symbol should be alphanumeric")
// }

return nil
}
11 changes: 10 additions & 1 deletion sdk/tx/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"encoding/hex"
"encoding/json"
"log"
"regexp"

"./txmsg"
"github.com/BiJie/bnc-go-sdk/sdk/tx/txmsg"
tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/secp256k1"
)
Expand Down Expand Up @@ -62,3 +63,11 @@ func DecodeHex(h []byte) []byte {

return b
}

var (
isAlphaNumFunc = regexp.MustCompile(`^[[:alnum:]]+$`).MatchString
)

func IsAlphaNum(s string) bool {
return isAlphaNumFunc(s)
}

0 comments on commit 64cc76b

Please sign in to comment.