fix serialization issues
This commit is contained in:
parent
38a5bcd659
commit
3f0c7f37f9
@ -71,6 +71,9 @@ func (bi *BigInt) UnmarshalJSON(b []byte) error {
|
|||||||
|
|
||||||
i, ok := big.NewInt(0).SetString(s, 10)
|
i, ok := big.NewInt(0).SetString(s, 10)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if string(s) == "<nil>" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return fmt.Errorf("failed to parse bigint string")
|
return fmt.Errorf("failed to parse bigint string")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
chain/types_test.go
Normal file
36
chain/types_test.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package chain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-lotus/chain/address"
|
||||||
|
"github.com/filecoin-project/go-lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSignedMessageJsonRoundtrip(t *testing.T) {
|
||||||
|
to, _ := address.NewIDAddress(5234623)
|
||||||
|
from, _ := address.NewIDAddress(603911192)
|
||||||
|
smsg := &SignedMessage{
|
||||||
|
Message: types.Message{
|
||||||
|
To: to,
|
||||||
|
From: from,
|
||||||
|
Params: []byte("some bytes, idk"),
|
||||||
|
Method: 1235126,
|
||||||
|
Value: types.NewInt(123123),
|
||||||
|
GasPrice: types.NewInt(1234),
|
||||||
|
GasLimit: types.NewInt(9992969384),
|
||||||
|
Nonce: 123123,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err := json.Marshal(smsg)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var osmsg SignedMessage
|
||||||
|
if err := json.Unmarshal(out, &osmsg); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
@ -78,6 +78,7 @@ var createMinerCmd = &cli.Command{
|
|||||||
From: addr,
|
From: addr,
|
||||||
Method: 1, // TODO: constants pls
|
Method: 1, // TODO: constants pls
|
||||||
Params: params,
|
Params: params,
|
||||||
|
Value: types.NewInt(0),
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
GasPrice: types.NewInt(1),
|
GasPrice: types.NewInt(1),
|
||||||
GasLimit: types.NewInt(1),
|
GasLimit: types.NewInt(1),
|
||||||
|
@ -141,7 +141,10 @@ func (a *API) WalletSign(ctx context.Context, k address.Address, msg []byte) (*c
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) WalletDefaultAddress(ctx context.Context) (address.Address, error) {
|
func (a *API) WalletDefaultAddress(ctx context.Context) (address.Address, error) {
|
||||||
addrs := a.Wallet.ListAddrs()
|
addrs, err := a.Wallet.ListAddrs()
|
||||||
|
if err != nil {
|
||||||
|
return address.Undef, err
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: store a default address in the config or 'wallet' portion of the repo
|
// TODO: store a default address in the config or 'wallet' portion of the repo
|
||||||
return addrs[0], nil
|
return addrs[0], nil
|
||||||
|
Loading…
Reference in New Issue
Block a user