0a4eeb7cb1
Switch go-fil-components to go-fil-markets
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package retrievaladapter
|
|
|
|
import (
|
|
"bytes"
|
|
sharedamount "github.com/filecoin-project/go-fil-markets/shared/tokenamount"
|
|
sharedtypes "github.com/filecoin-project/go-fil-markets/shared/types"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
)
|
|
|
|
|
|
func FromSharedTokenAmount(in sharedamount.TokenAmount) types.BigInt {
|
|
return types.BigInt{Int: in.Int}
|
|
}
|
|
|
|
func ToSharedTokenAmount(in types.BigInt) sharedamount.TokenAmount {
|
|
return sharedamount.TokenAmount{Int: in.Int}
|
|
}
|
|
|
|
func ToSharedSignedVoucher(in *types.SignedVoucher) (*sharedtypes.SignedVoucher, error) {
|
|
var encoded bytes.Buffer
|
|
err := in.MarshalCBOR(&encoded)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var out sharedtypes.SignedVoucher
|
|
err = out.UnmarshalCBOR(&encoded)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &out, nil
|
|
}
|
|
|
|
func FromSharedSignedVoucher(in *sharedtypes.SignedVoucher) (*types.SignedVoucher, error) {
|
|
var encoded bytes.Buffer
|
|
err := in.MarshalCBOR(&encoded)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var out types.SignedVoucher
|
|
err = out.UnmarshalCBOR(&encoded)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &out, nil
|
|
}
|