Skip to content

Commit

Permalink
+ 修复优化,正式版本
Browse files Browse the repository at this point in the history
  • Loading branch information
赵波 committed Aug 27, 2020
1 parent 298ca2b commit b73152f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 316 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,40 @@

`go get github.com/myxtype/filecoin-client`


# 使用

```go
package main

import (
"context"
"fmt"
"github.com/filecoin-project/go-address"
"github.com/myxtype/filecoin-client"
)

func main() {

client := NewClient("http://127.0.0.1:1234/rpc/v0", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.cF__3r_0IR9KwZ2nLkqcBW8vuPePruZieJAVvTAoUA4")

b, err := client.WalletBalance(context.Background(), "t1e3soclcq34tq7wmykp7xkkmpkzjnghumm3syyay")
if err != nil {
//
}
client := filecoin.NewClient("http://127.0.0.1:1234/rpc/v0", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.cF__3r_0IR9KwZ2nLkqcBW8vuPePruZieJAVvTAoUA4")

fmt.Println(b.String())
addr, _ := address.NewFromString("t1e3soclcq34tq7wmykp7xkkmpkzjnghumm3syyay")
b, err := client.WalletBalance(context.Background(), addr)
if err != nil {
panic(err)
}

fmt.Println(b.String())
}
```

# 离线签名版

我将在后续提供离线签名版(不需要自行搭建Node),因为现在https://infura.io 还未开放Lotus Node的API,所有离线签名版将在后续更新
我将在后续提供离线签名版(不需要自行搭建Node),因为现在https://infura.io 还未开放Lotus Node的API,所以离线签名版将在后续更新

具体实现逻辑在官方库中:https://github.com/filecoin-project/go-filecoin

官方库太过笨重,导致某些情况下编译不通过,不太方便加入实际业务项目中。

# Lotus文档

https://lotu.sh/en+api-methods
5 changes: 0 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ go 1.15

require (
github.com/filecoin-project/go-address v0.0.3
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-ipfs-util v0.0.1
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/multiformats/go-multihash v0.0.14
github.com/shopspring/decimal v1.2.0
github.com/supranational/blst v0.1.1
)
60 changes: 0 additions & 60 deletions lib/sigs/bls/init.go

This file was deleted.

58 changes: 0 additions & 58 deletions lib/sigs/secp/secp256k1.go

This file was deleted.

104 changes: 0 additions & 104 deletions lib/sigs/sigs.go

This file was deleted.

2 changes: 1 addition & 1 deletion mpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestClient_MpoolPush(t *testing.T) {
Params: nil,
}

msg, err := c.GasEstimateMessageGas(context.Background(), msg, &types.MessageSendSpec{MaxFee: "1000000000000"}, nil)
msg, err := c.GasEstimateMessageGas(context.Background(), msg, &types.MessageSendSpec{MaxFee: decimal.RequireFromString("1000000000000")}, nil)
if err != nil {
t.Error(err)
}
Expand Down
59 changes: 0 additions & 59 deletions sign.go

This file was deleted.

19 changes: 0 additions & 19 deletions sign_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type KeyInfo struct {
}

type MessageSendSpec struct {
MaxFee string `json:"MaxFee"`
MaxFee decimal.Decimal `json:"MaxFee"`
}

type SignedMessage struct {
Expand Down

0 comments on commit b73152f

Please sign in to comment.