satellite/payments/monetary: remove pkg and all its references
Remove pkg satellite/payments/monetary as it moved to storj.io/common. Update all code pkg references from monetary to common/currency. Change-Id: If2519f4c80cf315a9299e6521a6b9bbc6c399156
This commit is contained in:
parent
731916ffa4
commit
ad7c5b1483
2
go.mod
2
go.mod
@ -51,7 +51,7 @@ require (
|
||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
|
||||
gopkg.in/segmentio/analytics-go.v3 v3.1.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6
|
||||
storj.io/drpc v0.0.32
|
||||
storj.io/monkit-jaeger v0.0.0-20220726162929-c3a9898b5bca
|
||||
storj.io/private v0.0.0-20220818074142-c354e3e64dd3
|
||||
|
4
go.sum
4
go.sum
@ -952,8 +952,8 @@ sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3
|
||||
storj.io/common v0.0.0-20220708152916-e2f08365ed65/go.mod h1:PdwPrX+QWAm4vgVyka5U13vA0jKk49MpV4tzW4HTaz0=
|
||||
storj.io/common v0.0.0-20220719163320-cd2ef8e1b9b0/go.mod h1:mCYV6Ud5+cdbuaxdPD5Zht/HYaIn0sffnnws9ErkrMQ=
|
||||
storj.io/common v0.0.0-20220802175255-aae0c09ec9d4/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1 h1:0NIhx8hyQ+UgG4ZC5UOdMu4uHhSizmEfAUsca0E4hMA=
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6 h1:qjerTUC3dl6XzF44LkOEGKFpyz7oDkbtyr/tZUa+CFU=
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/drpc v0.0.32 h1:5p5ZwsK/VOgapaCu+oxaPVwO6UwIs+iwdMiD50+R4PI=
|
||||
storj.io/drpc v0.0.32/go.mod h1:6rcOyR/QQkSTX/9L5ZGtlZaE2PtXTTZl8d+ulSeeYEg=
|
||||
storj.io/monkit-jaeger v0.0.0-20220726162929-c3a9898b5bca h1:+dSyCu45DLiNoWl/LNZ/kO0MLvSGQwjiM8zwdknwJbg=
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/macaroon"
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/storj"
|
||||
@ -35,7 +36,6 @@ import (
|
||||
"storj.io/storj/satellite/mailservice"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/billing"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/rewards"
|
||||
)
|
||||
|
||||
@ -2808,8 +2808,8 @@ type PaymentInfo struct {
|
||||
ID string
|
||||
Type string
|
||||
Wallet string
|
||||
Amount monetary.Amount
|
||||
Received monetary.Amount
|
||||
Amount currency.Amount
|
||||
Received currency.Amount
|
||||
Status string
|
||||
Link string
|
||||
Timestamp time.Time
|
||||
@ -2912,8 +2912,8 @@ func (payment Payments) WalletPayments(ctx context.Context) (_ WalletPayments, e
|
||||
ID: txInfo.ID.String(),
|
||||
Type: "coinpayments",
|
||||
Wallet: txInfo.Address,
|
||||
Amount: monetary.AmountFromBaseUnits(txInfo.AmountCents, monetary.USDollars),
|
||||
Received: monetary.AmountFromBaseUnits(txInfo.ReceivedCents, monetary.USDollars),
|
||||
Amount: currency.AmountFromBaseUnits(txInfo.AmountCents, currency.USDollars),
|
||||
Received: currency.AmountFromBaseUnits(txInfo.ReceivedCents, currency.USDollars),
|
||||
Status: txInfo.Status.String(),
|
||||
Link: txInfo.Link,
|
||||
Timestamp: txInfo.CreatedAt.UTC(),
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/macaroon"
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/storj"
|
||||
@ -28,7 +29,6 @@ import (
|
||||
"storj.io/storj/satellite/console"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/coinpayments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/storjscan"
|
||||
"storj.io/storj/satellite/payments/storjscan/blockchaintest"
|
||||
"storj.io/storj/satellite/payments/stripecoinpayments"
|
||||
@ -910,7 +910,7 @@ func TestLockAccount(t *testing.T) {
|
||||
func TestWalletJsonMarshall(t *testing.T) {
|
||||
wi := console.WalletInfo{
|
||||
Address: blockchain.Address{1, 2, 3},
|
||||
Balance: monetary.AmountFromBaseUnits(10000, monetary.USDollars).AsDecimal().String(),
|
||||
Balance: currency.AmountFromBaseUnits(10000, currency.USDollars).AsDecimal().String(),
|
||||
}
|
||||
|
||||
out, err := json.Marshal(wi)
|
||||
@ -984,8 +984,8 @@ func TestPaymentsWalletPayments(t *testing.T) {
|
||||
ID: coinpayments.TransactionID(fmt.Sprintf("%d", i)),
|
||||
AccountID: user.ID,
|
||||
Address: blockchaintest.NewAddress().Hex(),
|
||||
Amount: monetary.AmountFromBaseUnits(1000000000, monetary.StorjToken),
|
||||
Received: monetary.AmountFromBaseUnits(1000000000, monetary.StorjToken),
|
||||
Amount: currency.AmountFromBaseUnits(1000000000, currency.StorjToken),
|
||||
Received: currency.AmountFromBaseUnits(1000000000, currency.StorjToken),
|
||||
Status: coinpayments.StatusCompleted,
|
||||
Key: "key",
|
||||
Timeout: 0,
|
||||
@ -1005,8 +1005,8 @@ func TestPaymentsWalletPayments(t *testing.T) {
|
||||
cachedPayments = append(cachedPayments, storjscan.CachedPayment{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet,
|
||||
TokenValue: monetary.AmountFromBaseUnits(1000, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(1000, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(1000, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(1000, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: int64(i),
|
||||
@ -1044,8 +1044,8 @@ func TestPaymentsWalletPayments(t *testing.T) {
|
||||
ID: tx.ID.String(),
|
||||
Type: "coinpayments",
|
||||
Wallet: tx.Address,
|
||||
Amount: monetary.AmountFromBaseUnits(1000, monetary.USDollars),
|
||||
Received: monetary.AmountFromBaseUnits(1000, monetary.USDollars),
|
||||
Amount: currency.AmountFromBaseUnits(1000, currency.USDollars),
|
||||
Received: currency.AmountFromBaseUnits(1000, currency.USDollars),
|
||||
Status: tx.Status.String(),
|
||||
Link: coinpayments.GetCheckoutURL(tx.Key, tx.ID),
|
||||
Timestamp: tx.CreatedAt,
|
||||
|
@ -12,13 +12,13 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/payments/billing"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
)
|
||||
|
||||
@ -85,9 +85,9 @@ func TestChore(t *testing.T) {
|
||||
}
|
||||
|
||||
func createBatch(t *testing.T, userID uuid.UUID, blockNumber int64, logIndex int) []billing.Transaction {
|
||||
tenUSD := monetary.AmountFromBaseUnits(1000, monetary.USDollars)
|
||||
twentyUSD := monetary.AmountFromBaseUnits(2000, monetary.USDollars)
|
||||
thirtyUSD := monetary.AmountFromBaseUnits(3000, monetary.USDollars)
|
||||
tenUSD := currency.AmountFromBaseUnits(1000, currency.USDollars)
|
||||
twentyUSD := currency.AmountFromBaseUnits(2000, currency.USDollars)
|
||||
thirtyUSD := currency.AmountFromBaseUnits(3000, currency.USDollars)
|
||||
|
||||
address, err := blockchain.BytesToAddress(testrand.Bytes(20))
|
||||
require.NoError(t, err)
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
// TransactionStatus indicates transaction status.
|
||||
@ -62,7 +62,7 @@ type TransactionsDB interface {
|
||||
// List returns all transactions for the specified user.
|
||||
List(ctx context.Context, userID uuid.UUID) ([]Transaction, error)
|
||||
// GetBalance returns the current usable balance for the specified user.
|
||||
GetBalance(ctx context.Context, userID uuid.UUID) (monetary.Amount, error)
|
||||
GetBalance(ctx context.Context, userID uuid.UUID) (currency.Amount, error)
|
||||
}
|
||||
|
||||
// PaymentType is an interface which defines functionality required for all billing payment types. Payment types can
|
||||
@ -82,7 +82,7 @@ type PaymentType interface {
|
||||
type Transaction struct {
|
||||
ID int64
|
||||
UserID uuid.UUID
|
||||
Amount monetary.Amount
|
||||
Amount currency.Amount
|
||||
Description string
|
||||
Source string
|
||||
Status TransactionStatus
|
||||
|
@ -11,12 +11,12 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/payments/billing"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
)
|
||||
|
||||
@ -54,7 +54,7 @@ func TestTransactionsDBList(t *testing.T) {
|
||||
|
||||
createTX := billing.Transaction{
|
||||
UserID: userID,
|
||||
Amount: monetary.AmountFromBaseUnits(4, monetary.USDollars),
|
||||
Amount: currency.AmountFromBaseUnits(4, currency.USDollars),
|
||||
Description: "credit from storjscan payment",
|
||||
Source: txSource,
|
||||
Status: txStatus,
|
||||
@ -89,12 +89,12 @@ func TestTransactionsDBList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTransactionsDBBalance(t *testing.T) {
|
||||
tenUSD := monetary.AmountFromBaseUnits(1000, monetary.USDollars)
|
||||
tenMicroUSD := monetary.AmountFromBaseUnits(10000000, monetary.USDollarsMicro)
|
||||
twentyMicroUSD := monetary.AmountFromBaseUnits(20000000, monetary.USDollarsMicro)
|
||||
thirtyUSD := monetary.AmountFromBaseUnits(3000, monetary.USDollars)
|
||||
fortyMicroUSD := monetary.AmountFromBaseUnits(40000000, monetary.USDollarsMicro)
|
||||
negativeTwentyUSD := monetary.AmountFromBaseUnits(-2000, monetary.USDollars)
|
||||
tenUSD := currency.AmountFromBaseUnits(1000, currency.USDollars)
|
||||
tenMicroUSD := currency.AmountFromBaseUnits(10000000, currency.USDollarsMicro)
|
||||
twentyMicroUSD := currency.AmountFromBaseUnits(20000000, currency.USDollarsMicro)
|
||||
thirtyUSD := currency.AmountFromBaseUnits(3000, currency.USDollars)
|
||||
fortyMicroUSD := currency.AmountFromBaseUnits(40000000, currency.USDollarsMicro)
|
||||
negativeTwentyUSD := currency.AmountFromBaseUnits(-2000, currency.USDollars)
|
||||
|
||||
userID := testrand.UUID()
|
||||
|
||||
@ -196,7 +196,7 @@ func TestTransactionsDBBalance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTransactions(t *testing.T) {
|
||||
tenUSD := monetary.AmountFromBaseUnits(1000, monetary.USDollars)
|
||||
tenUSD := currency.AmountFromBaseUnits(1000, currency.USDollars)
|
||||
userID := testrand.UUID()
|
||||
address, err := blockchain.BytesToAddress(testrand.Bytes(20))
|
||||
require.NoError(t, err)
|
||||
@ -266,7 +266,7 @@ func TestUpdateMetadata(t *testing.T) {
|
||||
// ensures that is not empty.
|
||||
func compareTransactions(t *testing.T, exp, act billing.Transaction) {
|
||||
assert.Equal(t, exp.UserID, act.UserID)
|
||||
assert.Equal(t, monetary.AmountFromDecimal(exp.Amount.AsDecimal().Truncate(monetary.USDollarsMicro.DecimalPlaces()), monetary.USDollarsMicro), act.Amount)
|
||||
assert.Equal(t, currency.AmountFromDecimal(exp.Amount.AsDecimal().Truncate(currency.USDollarsMicro.DecimalPlaces()), currency.USDollarsMicro), act.Amount)
|
||||
assert.Equal(t, exp.Description, act.Description)
|
||||
assert.Equal(t, exp.Status, act.Status)
|
||||
assert.Equal(t, exp.Source, act.Source)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/common/currency"
|
||||
)
|
||||
|
||||
// cmdRates is API command for retrieving currency rate infos.
|
||||
@ -81,7 +81,7 @@ type CurrencyRateInfos map[CurrencySymbol]CurrencyRateInfo
|
||||
|
||||
// ForCurrency allows lookup into a CurrencyRateInfos map by currency
|
||||
// object, instead of by its coinpayments.net-specific symbol.
|
||||
func (infos CurrencyRateInfos) ForCurrency(currency *monetary.Currency) (info CurrencyRateInfo, ok bool) {
|
||||
func (infos CurrencyRateInfos) ForCurrency(currency *currency.Currency) (info CurrencyRateInfo, ok bool) {
|
||||
coinpaymentsSymbol, ok := currencySymbols[currency]
|
||||
if !ok {
|
||||
return info, false
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -88,11 +88,11 @@ func TestProcessingConversionRates(t *testing.T) {
|
||||
require.Truef(t, rateInfos["USD"].RateBTC.LessThan(decimal.NewFromInt(1)),
|
||||
"expected value less than 1, but got %v", rateInfos["USD"].RateBTC.String())
|
||||
|
||||
rateInfo, ok := rateInfos.ForCurrency(monetary.USDollars)
|
||||
rateInfo, ok := rateInfos.ForCurrency(currency.USDollars)
|
||||
require.True(t, ok)
|
||||
require.True(t, rateInfo.IsFiat)
|
||||
|
||||
_, ok = rateInfos.ForCurrency(monetary.LiveGoats)
|
||||
_, ok = rateInfos.ForCurrency(currency.LiveGoats)
|
||||
require.False(t, ok)
|
||||
|
||||
rateInfo, ok = rateInfos.ForCurrency(CurrencyLTCT)
|
||||
|
@ -4,7 +4,7 @@
|
||||
package coinpayments
|
||||
|
||||
import (
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/common/currency"
|
||||
)
|
||||
|
||||
// CurrencySymbol is a symbol for a currency as recognized by coinpayments.net.
|
||||
@ -12,17 +12,17 @@ type CurrencySymbol string
|
||||
|
||||
var (
|
||||
// CurrencyLTCT defines LTCT, coins used for testing purpose.
|
||||
CurrencyLTCT = monetary.NewCurrency("LTCT test coins", "LTCT", 8)
|
||||
CurrencyLTCT = currency.New("LTCT test coins", "LTCT", 8)
|
||||
|
||||
// currencySymbols maps known currency objects to the currency symbols
|
||||
// as recognized on coinpayments.net. In many cases, the currency's own
|
||||
// idea of its symbol (currency.Symbol()) will be the same as this
|
||||
// CurrencySymbol, but we should probably not count on that always being
|
||||
// the case.
|
||||
currencySymbols = map[*monetary.Currency]CurrencySymbol{
|
||||
monetary.USDollars: "USD",
|
||||
monetary.StorjToken: "STORJ",
|
||||
monetary.Bitcoin: "BTC",
|
||||
currencySymbols = map[*currency.Currency]CurrencySymbol{
|
||||
currency.USDollars: "USD",
|
||||
currency.StorjToken: "STORJ",
|
||||
currency.Bitcoin: "BTC",
|
||||
CurrencyLTCT: "LTCT",
|
||||
}
|
||||
)
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/common/currency"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -92,7 +92,7 @@ func (list TransactionIDList) Encode() string {
|
||||
type Transaction struct {
|
||||
ID TransactionID
|
||||
Address string
|
||||
Amount monetary.Amount
|
||||
Amount currency.Amount
|
||||
DestTag string
|
||||
ConfirmsNeeded int
|
||||
Timeout time.Duration
|
||||
@ -119,7 +119,7 @@ func (tx *Transaction) UnmarshalJSON(b []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
amount, err := monetary.AmountFromString(txRaw.Amount, monetary.StorjToken)
|
||||
amount, err := currency.AmountFromString(txRaw.Amount, currency.StorjToken)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -227,8 +227,8 @@ func (infos *TransactionInfos) UnmarshalJSON(b []byte) error {
|
||||
// CreateTX defines parameters for transaction creating.
|
||||
type CreateTX struct {
|
||||
Amount decimal.Decimal
|
||||
CurrencyIn *monetary.Currency
|
||||
CurrencyOut *monetary.Currency
|
||||
CurrencyIn *currency.Currency
|
||||
CurrencyOut *currency.Currency
|
||||
BuyerEmail string
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/payments/coinpayments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
)
|
||||
|
||||
@ -38,8 +38,8 @@ func TestListInfos(t *testing.T) {
|
||||
tx, err := payments.Create(ctx,
|
||||
&coinpayments.CreateTX{
|
||||
Amount: decimal.NewFromInt(100),
|
||||
CurrencyIn: monetary.StorjToken,
|
||||
CurrencyOut: monetary.StorjToken,
|
||||
CurrencyIn: currency.StorjToken,
|
||||
CurrencyOut: currency.StorjToken,
|
||||
BuyerEmail: "test@test.com",
|
||||
},
|
||||
)
|
||||
|
@ -1,263 +0,0 @@
|
||||
// Copyright (C) 2021 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package monetary
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/zeebo/errs"
|
||||
)
|
||||
|
||||
// Currency represents a currency for the purpose of representing amounts in
|
||||
// that currency. Currency instances have a name, a symbol, and a number of
|
||||
// supported decimal places of supported precision.
|
||||
type Currency struct {
|
||||
name string
|
||||
symbol string
|
||||
decimalPlaces int32
|
||||
}
|
||||
|
||||
// NewCurrency creates a new Currency instance.
|
||||
func NewCurrency(name, symbol string, decimalPlaces int32) *Currency {
|
||||
return &Currency{name: name, symbol: symbol, decimalPlaces: decimalPlaces}
|
||||
}
|
||||
|
||||
// Name returns the name of the currency.
|
||||
func (c *Currency) Name() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
// Symbol returns the symbol of the currency.
|
||||
func (c *Currency) Symbol() string {
|
||||
return c.symbol
|
||||
}
|
||||
|
||||
// DecimalPlaces returns the decimal places of the currency.
|
||||
func (c *Currency) DecimalPlaces() int32 {
|
||||
return c.decimalPlaces
|
||||
}
|
||||
|
||||
// Zero returns the zero value of the currency.
|
||||
func (c *Currency) Zero() Amount {
|
||||
return AmountFromBaseUnits(0, c)
|
||||
}
|
||||
|
||||
var (
|
||||
// StorjToken is the currency for the STORJ ERC20 token, which powers
|
||||
// most payments on the current Storj network.
|
||||
StorjToken = NewCurrency("STORJ Token", "STORJ", 8)
|
||||
// USDollars is the currency of United States dollars, where fractional
|
||||
// cents are not supported.
|
||||
USDollars = NewCurrency("US dollars", "USD", 2)
|
||||
// USDollarsMicro is the currency of United States dollars, where fractional
|
||||
// cents are supported with 2 decimal places.
|
||||
USDollarsMicro = NewCurrency("US dollars", "USDMicro", 6)
|
||||
// Bitcoin is the currency for the well-known cryptocurrency Bitcoin
|
||||
// (a.k.a. BTC).
|
||||
Bitcoin = NewCurrency("Bitcoin (BTC)", "BTC", 8)
|
||||
// LiveGoats is the currency of live goats, which some Storj network
|
||||
// satellites may elect to support for payments.
|
||||
LiveGoats = NewCurrency("Live goats", "goats", 0)
|
||||
|
||||
// Error is a class of errors encountered in the monetary package.
|
||||
Error = errs.Class("monetary error")
|
||||
)
|
||||
|
||||
// CurrencyFromSymbol returns currency based on symbol.
|
||||
func CurrencyFromSymbol(symbol string) (*Currency, error) {
|
||||
switch symbol {
|
||||
case "STORJ":
|
||||
return StorjToken, nil
|
||||
case "BTC":
|
||||
return Bitcoin, nil
|
||||
case "USD":
|
||||
return USDollars, nil
|
||||
case "USDMicro":
|
||||
return USDollarsMicro, nil
|
||||
case "goats":
|
||||
return LiveGoats, nil
|
||||
default:
|
||||
return nil, errs.New("invalid currency symbol")
|
||||
}
|
||||
}
|
||||
|
||||
// Amount represents a monetary amount, encapsulating a value and a currency.
|
||||
//
|
||||
// The value of the Amount is represented in "base units", meaning units of the
|
||||
// smallest indivisible portion of the given currency. For example, when
|
||||
// the currency is USDollars, the base unit would be cents.
|
||||
type Amount struct {
|
||||
baseUnits int64
|
||||
currency *Currency
|
||||
}
|
||||
|
||||
// AsFloat returns the monetary value in currency units expressed as a
|
||||
// floating point number. _Warning_ may lose precision! (float64 has the
|
||||
// equivalent of 53 bits of precision, as defined by big.Float.)
|
||||
func (a Amount) AsFloat() float64 {
|
||||
return float64(a.baseUnits) * math.Pow10(int(-a.currency.decimalPlaces))
|
||||
}
|
||||
|
||||
// AsBigFloat returns the monetary value in currency units expressed as an
|
||||
// instance of *big.Float with precision=64. _Warning_ may lose precision!
|
||||
func (a Amount) AsBigFloat() *big.Float {
|
||||
return a.AsBigFloatWithPrecision(64)
|
||||
}
|
||||
|
||||
// AsBigFloatWithPrecision returns the monetary value in currency units
|
||||
// expressed as an instance of *big.Float with the given precision.
|
||||
// _Warning_ this may lose precision if the specified precision is not
|
||||
// large enough!
|
||||
func (a Amount) AsBigFloatWithPrecision(p uint) *big.Float {
|
||||
stringVal := a.AsDecimal().String()
|
||||
bf, _, err := big.ParseFloat(stringVal, 10, p, big.ToNearestEven)
|
||||
if err != nil {
|
||||
// it does not appear that this is possible, after a review of
|
||||
// decimal.Decimal{}.String() and big.ParseFloat().
|
||||
panic(fmt.Sprintf("could not parse output of Decimal.String() (%q) as big.Float: %v", stringVal, err))
|
||||
}
|
||||
return bf
|
||||
}
|
||||
|
||||
// AsDecimal returns the monetary value in currency units expressed as an
|
||||
// arbitrary precision decimal number.
|
||||
func (a Amount) AsDecimal() decimal.Decimal {
|
||||
d := decimal.NewFromInt(a.baseUnits)
|
||||
return d.Shift(-a.currency.decimalPlaces)
|
||||
}
|
||||
|
||||
// BaseUnits returns the monetary value expressed in its base units.
|
||||
func (a Amount) BaseUnits() int64 {
|
||||
return a.baseUnits
|
||||
}
|
||||
|
||||
// Currency returns the currency of the amount.
|
||||
func (a Amount) Currency() *Currency {
|
||||
return a.currency
|
||||
}
|
||||
|
||||
// Equal returns true if a and other are in the same currency and have the
|
||||
// same value.
|
||||
func (a Amount) Equal(other Amount) bool {
|
||||
return a.currency == other.currency && a.baseUnits == other.baseUnits
|
||||
}
|
||||
|
||||
// amountJSON is amount json data structure.
|
||||
type amountJSON struct {
|
||||
Value decimal.Decimal `json:"value"`
|
||||
Currency string `json:"currency"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals json bytes into amount.
|
||||
func (a *Amount) UnmarshalJSON(data []byte) error {
|
||||
var amountJSON amountJSON
|
||||
if err := json.Unmarshal(data, &amountJSON); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
curr, err := CurrencyFromSymbol(amountJSON.Currency)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*a = AmountFromDecimal(amountJSON.Value, curr)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON marshals amount into json.
|
||||
func (a Amount) MarshalJSON() ([]byte, error) {
|
||||
amountJSON := amountJSON{
|
||||
Value: a.AsDecimal(),
|
||||
Currency: a.currency.symbol,
|
||||
}
|
||||
|
||||
return json.Marshal(amountJSON)
|
||||
}
|
||||
|
||||
// IsNegative returns true if the base unit amount is negative.
|
||||
func (a Amount) IsNegative() bool {
|
||||
return a.baseUnits < 0
|
||||
}
|
||||
|
||||
// AmountFromBaseUnits creates a new Amount instance from the given count of
|
||||
// base units and in the given currency.
|
||||
func AmountFromBaseUnits(units int64, currency *Currency) Amount {
|
||||
return Amount{
|
||||
baseUnits: units,
|
||||
currency: currency,
|
||||
}
|
||||
}
|
||||
|
||||
// AmountFromDecimal creates a new Amount instance from the given decimal
|
||||
// value and in the given currency. The decimal value is expected to be in
|
||||
// currency units.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// AmountFromDecimal(decimal.NewFromFloat(3.50), USDollars) == Amount{baseUnits: 350, currency: USDollars}
|
||||
func AmountFromDecimal(d decimal.Decimal, currency *Currency) Amount {
|
||||
return AmountFromBaseUnits(d.Shift(currency.decimalPlaces).Round(0).IntPart(), currency)
|
||||
}
|
||||
|
||||
// AmountFromString creates a new Amount instance from the given base 10
|
||||
// value and in the given currency. The string is expected to give the
|
||||
// value of the amount in currency units.
|
||||
func AmountFromString(s string, currency *Currency) (Amount, error) {
|
||||
d, err := decimal.NewFromString(s)
|
||||
if err != nil {
|
||||
return Amount{}, Error.Wrap(err)
|
||||
}
|
||||
return AmountFromDecimal(d, currency), nil
|
||||
}
|
||||
|
||||
// AmountFromBigFloat creates a new Amount instance from the given floating
|
||||
// point value and in the given currency. The big.Float is expected to give
|
||||
// the value of the amount in currency units.
|
||||
func AmountFromBigFloat(f *big.Float, currency *Currency) (Amount, error) {
|
||||
dec, err := DecimalFromBigFloat(f)
|
||||
if err != nil {
|
||||
return Amount{}, err
|
||||
}
|
||||
return AmountFromDecimal(dec, currency), nil
|
||||
}
|
||||
|
||||
// DecimalFromBigFloat creates a new decimal.Decimal instance from the given
|
||||
// floating point value.
|
||||
func DecimalFromBigFloat(f *big.Float) (decimal.Decimal, error) {
|
||||
if f.IsInf() {
|
||||
return decimal.Decimal{}, Error.New("Cannot represent infinite amount")
|
||||
}
|
||||
// This is probably not computationally ideal, but it should be the most
|
||||
// straightforward way to convert (unless/until the decimal package adds
|
||||
// a NewFromBigFloat method).
|
||||
stringVal := f.Text('e', -1)
|
||||
dec, err := decimal.NewFromString(stringVal)
|
||||
return dec, Error.Wrap(err)
|
||||
}
|
||||
|
||||
// Add adds two monetary amounts and returns the result. If the currencies are different, an error is thrown.
|
||||
func Add(i, j Amount) (Amount, error) {
|
||||
if !sameCurrency(i.currency, j.currency) {
|
||||
return i.currency.Zero(), errs.New("Amounts to add must use the same currency")
|
||||
}
|
||||
return AmountFromBaseUnits(i.baseUnits+j.baseUnits, i.currency), nil
|
||||
}
|
||||
|
||||
// Greater returns true if the first monetary amount is greater than the second.
|
||||
// If the currencies are different, an error is thrown.
|
||||
func Greater(i, j Amount) (bool, error) {
|
||||
if !sameCurrency(i.currency, j.currency) {
|
||||
return false, errs.New("Amounts to compare must use the same currency")
|
||||
}
|
||||
return i.baseUnits > j.baseUnits, nil
|
||||
}
|
||||
|
||||
// returns true if the currencies are the same and not nil.
|
||||
func sameCurrency(i, j *Currency) bool {
|
||||
return i != nil && j != nil && i == j
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
// Copyright (C) 2021 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package monetary
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
// If we use more than 18 decimal places, baseUnits values will overflow int64
|
||||
// even if there is only one digit to the left of the decimal point.
|
||||
manyDigitsCurrency = &Currency{name: "manyDigitsCurrency", symbol: "mdc", decimalPlaces: 18}
|
||||
noDigitsCurrency = &Currency{name: "noDigitsCurrency", symbol: "ndc", decimalPlaces: 0}
|
||||
)
|
||||
|
||||
func TestAmountFromBigFloatAndAmountAsBigFloat(t *testing.T) {
|
||||
parseFloat := func(s string) *big.Float {
|
||||
bf, _, err := big.ParseFloat(s, 10, 256, big.ToNearestEven)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse %q as float: %v", s, err)
|
||||
}
|
||||
return bf
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
floatValue *big.Float
|
||||
currency *Currency
|
||||
baseUnits int64
|
||||
wantErr bool
|
||||
}{
|
||||
{"zero", big.NewFloat(0), StorjToken, 0, false},
|
||||
{"one", big.NewFloat(1), USDollars, 100, false},
|
||||
{"negative", big.NewFloat(-1), Bitcoin, -100000000, false},
|
||||
{"smallest", big.NewFloat(1e-8), StorjToken, 1, false},
|
||||
{"minus smallest", big.NewFloat(-1e-8), StorjToken, -1, false},
|
||||
{"one+delta", parseFloat("1.000000000000000001"), manyDigitsCurrency, 1000000000000000001, false},
|
||||
{"minus one+delta", parseFloat("-1.000000000000000001"), manyDigitsCurrency, -1000000000000000001, false},
|
||||
{"large number", parseFloat("4611686018427387904.0"), noDigitsCurrency, 4611686018427387904, false},
|
||||
{"infinity", parseFloat("Inf"), StorjToken, 0, true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := AmountFromBigFloat(tt.floatValue, tt.currency)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("AmountFromBigFloat() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if tt.wantErr {
|
||||
return
|
||||
}
|
||||
want := Amount{baseUnits: tt.baseUnits, currency: tt.currency}
|
||||
assert.Equal(t, want, got)
|
||||
assert.Equal(t, tt.baseUnits, got.BaseUnits())
|
||||
|
||||
fullPrecValue, err := tt.floatValue.MarshalText()
|
||||
require.NoError(t, err)
|
||||
gotAsFloat := got.AsBigFloatWithPrecision(tt.floatValue.Prec())
|
||||
fullPrecGot, err := gotAsFloat.MarshalText()
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Truef(t, tt.floatValue.Cmp(gotAsFloat) == 0,
|
||||
"(expected) %v != (got) %v", string(fullPrecValue), string(fullPrecGot))
|
||||
})
|
||||
}
|
||||
}
|
||||
func TestAmountFromDecimalAndAmountAsDecimal(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
decimalValue decimal.Decimal
|
||||
currency *Currency
|
||||
baseUnits int64
|
||||
wantErr bool
|
||||
}{
|
||||
{"zero", decimal.Decimal{}, StorjToken, 0, false},
|
||||
{"one", decimal.NewFromInt(1), USDollars, 100, false},
|
||||
{"negative", decimal.NewFromInt(-1), Bitcoin, -100000000, false},
|
||||
{"smallest", decimal.NewFromFloat(1e-8), StorjToken, 1, false},
|
||||
{"one+delta", decimal.RequireFromString("1.000000000000000001"), manyDigitsCurrency, 1000000000000000001, false},
|
||||
{"minus one+delta", decimal.RequireFromString("-1.000000000000000001"), manyDigitsCurrency, -1000000000000000001, false},
|
||||
{"large number", decimal.RequireFromString("4611686018427387904.0"), noDigitsCurrency, 4611686018427387904, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := AmountFromDecimal(tt.decimalValue, tt.currency)
|
||||
want := Amount{baseUnits: tt.baseUnits, currency: tt.currency}
|
||||
assert.Equal(t, want, got)
|
||||
assert.Equal(t, tt.baseUnits, got.BaseUnits())
|
||||
assert.Truef(t, tt.decimalValue.Equal(got.AsDecimal()),
|
||||
"%v != %v", tt.decimalValue, got.AsDecimal())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAmountJSONMarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
Amount Amount
|
||||
JSON string
|
||||
}{
|
||||
{
|
||||
Amount: AmountFromBaseUnits(100000000000, StorjToken),
|
||||
JSON: fmt.Sprintf(`{"value":"1000","currency":"%s"}`, StorjToken.Symbol()),
|
||||
},
|
||||
{
|
||||
Amount: AmountFromBaseUnits(10055, USDollars),
|
||||
JSON: fmt.Sprintf(`{"value":"100.55","currency":"%s"}`, USDollars.Symbol()),
|
||||
},
|
||||
{
|
||||
Amount: AmountFromBaseUnits(100555500, USDollarsMicro),
|
||||
JSON: fmt.Sprintf(`{"value":"100.5555","currency":"%s"}`, USDollarsMicro.Symbol()),
|
||||
},
|
||||
{
|
||||
Amount: AmountFromBaseUnits(100555555, USDollarsMicro),
|
||||
JSON: fmt.Sprintf(`{"value":"100.555555","currency":"%s"}`, USDollarsMicro.Symbol()),
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
b, err := json.Marshal(test.Amount)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, test.JSON, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAmountJSONUnmarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
JSON string
|
||||
BaseUnits int64
|
||||
Currency *Currency
|
||||
}{
|
||||
{
|
||||
JSON: fmt.Sprintf(`{"value":"100","currency":"%s"}`, StorjToken.Symbol()),
|
||||
BaseUnits: 10000000000,
|
||||
Currency: StorjToken,
|
||||
},
|
||||
{
|
||||
JSON: fmt.Sprintf(`{"value":"50","currency":"%s"}`, Bitcoin.Symbol()),
|
||||
BaseUnits: 5000000000,
|
||||
Currency: Bitcoin,
|
||||
},
|
||||
{
|
||||
JSON: fmt.Sprintf(`{"value":"100.55","currency":"%s"}`, USDollars.Symbol()),
|
||||
BaseUnits: 10055,
|
||||
Currency: USDollars,
|
||||
},
|
||||
{
|
||||
JSON: fmt.Sprintf(`{"value":"100.5555","currency":"%s"}`, USDollarsMicro.Symbol()),
|
||||
BaseUnits: 100555500,
|
||||
Currency: USDollarsMicro,
|
||||
},
|
||||
{
|
||||
JSON: fmt.Sprintf(`{"value":"100.555555","currency":"%s"}`, USDollarsMicro.Symbol()),
|
||||
BaseUnits: 100555555,
|
||||
Currency: USDollarsMicro,
|
||||
},
|
||||
{
|
||||
JSON: fmt.Sprintf(`{"value":"10","currency":"%s"}`, LiveGoats.Symbol()),
|
||||
BaseUnits: 10,
|
||||
Currency: LiveGoats,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
var amount Amount
|
||||
|
||||
err := json.Unmarshal([]byte(test.JSON), &amount)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, test.BaseUnits, amount.BaseUnits())
|
||||
require.Equal(t, test.Currency, amount.Currency())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGreater(t *testing.T) {
|
||||
oneHundredUSDMicro := AmountFromBaseUnits(100000000, USDollarsMicro)
|
||||
twoHundredUSDMicro := AmountFromBaseUnits(200000000, USDollarsMicro)
|
||||
|
||||
checkGreater, err := Greater(twoHundredUSDMicro, oneHundredUSDMicro)
|
||||
require.NoError(t, err)
|
||||
require.True(t, checkGreater)
|
||||
}
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
oneHundredUSD := AmountFromBaseUnits(10000, USDollars)
|
||||
twoHundredUSD := AmountFromBaseUnits(20000, USDollars)
|
||||
|
||||
sum, err := Add(oneHundredUSD, oneHundredUSD)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, twoHundredUSD, sum)
|
||||
}
|
||||
|
||||
func TestZero(t *testing.T) {
|
||||
require.Equal(t, AmountFromBaseUnits(0, USDollarsMicro), USDollarsMicro.Zero())
|
||||
require.Equal(t, AmountFromBaseUnits(0, USDollars), USDollars.Zero())
|
||||
require.NotEqual(t, AmountFromBaseUnits(0, USDollars), USDollarsMicro.Zero())
|
||||
}
|
||||
|
||||
func TestNegative(t *testing.T) {
|
||||
require.False(t, USDollarsMicro.Zero().IsNegative())
|
||||
require.False(t, USDollars.Zero().IsNegative())
|
||||
require.True(t, AmountFromBaseUnits(-10000, USDollars).IsNegative())
|
||||
}
|
@ -11,9 +11,9 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/sync2"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
// ChoreErr is storjscan chore err class.
|
||||
@ -88,8 +88,8 @@ func (chore *Chore) Run(ctx context.Context) (err error) {
|
||||
cachedPayments = append(cachedPayments, CachedPayment{
|
||||
From: payment.From,
|
||||
To: payment.To,
|
||||
TokenValue: monetary.AmountFromBaseUnits(payment.TokenValue.Int64(), monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromDecimal(decimal.NewFromFloat(payment.USDValue), monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(payment.TokenValue.Int64(), currency.StorjToken),
|
||||
USDValue: currency.AmountFromDecimal(decimal.NewFromFloat(payment.USDValue), currency.USDollarsMicro),
|
||||
Status: status,
|
||||
BlockHash: payment.BlockHash,
|
||||
BlockNumber: payment.BlockNumber,
|
||||
|
@ -16,10 +16,10 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/storjscan"
|
||||
"storj.io/storj/satellite/payments/storjscan/blockchaintest"
|
||||
"storj.io/storj/satellite/payments/storjscan/storjscantest"
|
||||
@ -61,8 +61,8 @@ func TestChore(t *testing.T) {
|
||||
cachedPayments = append(cachedPayments, storjscan.CachedPayment{
|
||||
From: payment.From,
|
||||
To: payment.To,
|
||||
TokenValue: monetary.AmountFromBaseUnits(payment.TokenValue.Int64(), monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromDecimal(decimal.NewFromFloat(payment.USDValue), monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(payment.TokenValue.Int64(), currency.StorjToken),
|
||||
USDValue: currency.AmountFromDecimal(decimal.NewFromFloat(payment.USDValue), currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusPending,
|
||||
BlockHash: payment.BlockHash,
|
||||
BlockNumber: payment.BlockNumber,
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
// ErrNoPayments represents err when there is no payments in the DB.
|
||||
@ -39,8 +39,8 @@ type PaymentsDB interface {
|
||||
type CachedPayment struct {
|
||||
From blockchain.Address `json:"from"`
|
||||
To blockchain.Address `json:"to"`
|
||||
TokenValue monetary.Amount `json:"tokenValue"`
|
||||
USDValue monetary.Amount `json:"usdValue"`
|
||||
TokenValue currency.Amount `json:"tokenValue"`
|
||||
USDValue currency.Amount `json:"usdValue"`
|
||||
Status payments.PaymentStatus `json:"status"`
|
||||
BlockHash blockchain.Hash `json:"blockHash"`
|
||||
BlockNumber int64 `json:"blockNumber"`
|
||||
|
@ -11,12 +11,12 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/storjscan"
|
||||
"storj.io/storj/satellite/payments/storjscan/blockchaintest"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
@ -32,8 +32,8 @@ func TestPaymentsDBInsertBatch(t *testing.T) {
|
||||
cachedPayments = append(cachedPayments, storjscan.CachedPayment{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: monetary.AmountFromBaseUnits(1000, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(1000, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro),
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: int64(i),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
@ -73,70 +73,70 @@ func TestPaymentsDBList(t *testing.T) {
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: tx1,
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[0].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: tx1,
|
||||
Index: 1,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[0].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 2,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[1].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[1].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet2,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 1,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[2].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet2,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[3].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[4].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusPending),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusPending),
|
||||
blocks[4].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet2,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: tx2,
|
||||
Index: 1,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusPending),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusPending),
|
||||
blocks[4].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet2,
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: tx2,
|
||||
Index: 2,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusPending),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusPending),
|
||||
}
|
||||
|
||||
err := paymentsDB.InsertBatch(ctx, expected)
|
||||
@ -169,8 +169,8 @@ func TestPaymentsDBLastBlock(t *testing.T) {
|
||||
cachedPayments = append(cachedPayments, storjscan.CachedPayment{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: monetary.AmountFromBaseUnits(1000, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(1000, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(1000, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(1000, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: int64(i),
|
||||
@ -182,8 +182,8 @@ func TestPaymentsDBLastBlock(t *testing.T) {
|
||||
cachedPayments = append(cachedPayments, storjscan.CachedPayment{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: monetary.AmountFromBaseUnits(1000, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(1000, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(1000, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(1000, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusPending,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: int64(10),
|
||||
@ -236,42 +236,42 @@ func TestPaymentsDBDeletePending(t *testing.T) {
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[1].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[2].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[3].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusConfirmed),
|
||||
blocks[4].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusPending),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusPending),
|
||||
blocks[5].NewPayment(paymentLog{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: blockchaintest.NewAddress(),
|
||||
TokenValue: new(big.Int).SetInt64(testrand.Int63n(1000)),
|
||||
Transaction: blockchaintest.NewHash(),
|
||||
Index: 0,
|
||||
}, monetary.AmountFromBaseUnits(testrand.Int63n(1000), monetary.USDollarsMicro), payments.PaymentStatusPending),
|
||||
}, currency.AmountFromBaseUnits(testrand.Int63n(1000), currency.USDollarsMicro), payments.PaymentStatusPending),
|
||||
}
|
||||
require.NoError(t, paymentsDB.InsertBatch(ctx, payments))
|
||||
|
||||
@ -297,11 +297,11 @@ type blockHeader struct {
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
func (block blockHeader) NewPayment(log paymentLog, usdValue monetary.Amount, status payments.PaymentStatus) storjscan.CachedPayment {
|
||||
func (block blockHeader) NewPayment(log paymentLog, usdValue currency.Amount, status payments.PaymentStatus) storjscan.CachedPayment {
|
||||
return storjscan.CachedPayment{
|
||||
From: log.From,
|
||||
To: log.To,
|
||||
TokenValue: monetary.AmountFromBaseUnits(log.TokenValue.Int64(), monetary.StorjToken),
|
||||
TokenValue: currency.AmountFromBaseUnits(log.TokenValue.Int64(), currency.StorjToken),
|
||||
USDValue: usdValue,
|
||||
Status: status,
|
||||
BlockHash: block.Hash,
|
||||
|
@ -11,12 +11,12 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/storjscan"
|
||||
"storj.io/storj/satellite/payments/storjscan/blockchaintest"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
@ -34,8 +34,8 @@ func TestServicePayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(100, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(100, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 0,
|
||||
@ -46,8 +46,8 @@ func TestServicePayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(100, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(100, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 0,
|
||||
@ -58,8 +58,8 @@ func TestServicePayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet2,
|
||||
TokenValue: monetary.AmountFromBaseUnits(100, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(100, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 0,
|
||||
@ -70,8 +70,8 @@ func TestServicePayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(200, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(200, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusPending,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 1,
|
||||
@ -189,8 +189,8 @@ func TestListPayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(100, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(100, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 0,
|
||||
@ -201,8 +201,8 @@ func TestListPayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(100, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(100, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 0,
|
||||
@ -213,8 +213,8 @@ func TestListPayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(100, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(100, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 0,
|
||||
@ -225,8 +225,8 @@ func TestListPayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(200, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(200, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 1,
|
||||
@ -272,8 +272,8 @@ func TestListPayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(100, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(100, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 1,
|
||||
@ -284,8 +284,8 @@ func TestListPayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(200, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(200, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 1,
|
||||
@ -296,8 +296,8 @@ func TestListPayments(t *testing.T) {
|
||||
{
|
||||
From: blockchaintest.NewAddress(),
|
||||
To: wallet1,
|
||||
TokenValue: monetary.AmountFromBaseUnits(200, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(100, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(200, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(100, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusConfirmed,
|
||||
BlockHash: blockchaintest.NewHash(),
|
||||
BlockNumber: 2,
|
||||
|
@ -11,12 +11,12 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/sync2"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
// convertToCents convert amount to USD cents with given rate.
|
||||
func convertToCents(rate decimal.Decimal, amount monetary.Amount) int64 {
|
||||
func convertToCents(rate decimal.Decimal, amount currency.Amount) int64 {
|
||||
amountDecimal := amount.AsDecimal()
|
||||
usd := amountDecimal.Mul(rate)
|
||||
usdCents := usd.Shift(2)
|
||||
@ -24,10 +24,10 @@ func convertToCents(rate decimal.Decimal, amount monetary.Amount) int64 {
|
||||
}
|
||||
|
||||
// convertFromCents convert amount in cents to a StorjTokenAmount with given rate.
|
||||
func convertFromCents(rate decimal.Decimal, usdCents int64) monetary.Amount {
|
||||
func convertFromCents(rate decimal.Decimal, usdCents int64) currency.Amount {
|
||||
usd := decimal.NewFromInt(usdCents).Shift(-2)
|
||||
numStorj := usd.Div(rate)
|
||||
return monetary.AmountFromDecimal(numStorj, monetary.USDollars)
|
||||
return currency.AmountFromDecimal(numStorj, currency.USDollars)
|
||||
}
|
||||
|
||||
// ErrConversion defines version service error.
|
||||
|
@ -19,13 +19,13 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/satellite/accounting"
|
||||
"storj.io/storj/satellite/console"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/billing"
|
||||
"storj.io/storj/satellite/payments/coinpayments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/storjscan"
|
||||
)
|
||||
|
||||
@ -195,7 +195,7 @@ func (service *Service) updateTransactions(ctx context.Context, ids TransactionA
|
||||
TransactionUpdate{
|
||||
TransactionID: id,
|
||||
Status: info.Status,
|
||||
Received: monetary.AmountFromDecimal(info.Received, monetary.StorjToken),
|
||||
Received: currency.AmountFromDecimal(info.Received, currency.StorjToken),
|
||||
},
|
||||
)
|
||||
|
||||
@ -366,7 +366,7 @@ func (service *Service) UpdateRates(ctx context.Context) (err error) {
|
||||
}
|
||||
|
||||
// GetRate returns conversion rate for specified currencies.
|
||||
func (service *Service) GetRate(ctx context.Context, curr1, curr2 *monetary.Currency) (_ decimal.Decimal, err error) {
|
||||
func (service *Service) GetRate(ctx context.Context, curr1, curr2 *currency.Currency) (_ decimal.Decimal, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
service.mu.Lock()
|
||||
@ -560,7 +560,7 @@ func (service *Service) InvoiceApplyTokenBalance(ctx context.Context) (err error
|
||||
monetaryTokenBalance, err := service.billingDB.GetBalance(ctx, wallet.UserID)
|
||||
// truncate here since stripe only has cent level precision for invoices.
|
||||
// The users account balance will still maintain the full precision monetary value!
|
||||
tokenBalance := monetary.AmountFromDecimal(monetaryTokenBalance.AsDecimal().Truncate(2), monetary.USDollars)
|
||||
tokenBalance := currency.AmountFromDecimal(monetaryTokenBalance.AsDecimal().Truncate(2), currency.USDollars)
|
||||
if err != nil {
|
||||
errGrp.Add(Error.New("unable to compute balance for user ID %s", wallet.UserID.String()))
|
||||
continue
|
||||
@ -678,7 +678,7 @@ func (service *Service) createTokenPaymentBillingTransaction(ctx context.Context
|
||||
|
||||
transaction := billing.Transaction{
|
||||
UserID: userID,
|
||||
Amount: monetary.AmountFromBaseUnits(amount, monetary.USDollars),
|
||||
Amount: currency.AmountFromBaseUnits(amount, currency.USDollars),
|
||||
Description: "Paid Stripe Invoice",
|
||||
Source: "stripe",
|
||||
Status: billing.TransactionStatusPending,
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/testcontext"
|
||||
@ -22,7 +23,6 @@ import (
|
||||
"storj.io/storj/satellite/console"
|
||||
"storj.io/storj/satellite/metabase"
|
||||
"storj.io/storj/satellite/payments/billing"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/stripecoinpayments"
|
||||
)
|
||||
|
||||
@ -326,7 +326,7 @@ func TestService_InvoiceItemsFromZeroTokenBalance(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
_, err = satellite.DB.Billing().Insert(ctx, billing.Transaction{
|
||||
UserID: userID,
|
||||
Amount: monetary.AmountFromBaseUnits(1000, monetary.USDollars),
|
||||
Amount: currency.AmountFromBaseUnits(1000, currency.USDollars),
|
||||
Description: "token payment credit",
|
||||
Source: "storjscan",
|
||||
Status: billing.TransactionStatusCompleted,
|
||||
|
@ -13,10 +13,10 @@ import (
|
||||
"github.com/stripe/stripe-go/v72"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/coinpayments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -61,7 +61,7 @@ func (tokens *storjTokens) Deposit(ctx context.Context, userID uuid.UUID, amount
|
||||
return nil, Error.Wrap(err)
|
||||
}
|
||||
|
||||
rate, err := tokens.service.GetRate(ctx, monetary.StorjToken, monetary.USDollars)
|
||||
rate, err := tokens.service.GetRate(ctx, currency.StorjToken, currency.USDollars)
|
||||
if err != nil {
|
||||
return nil, Error.Wrap(err)
|
||||
}
|
||||
@ -71,8 +71,8 @@ func (tokens *storjTokens) Deposit(ctx context.Context, userID uuid.UUID, amount
|
||||
tx, err := tokens.service.coinPayments.Transactions().Create(ctx,
|
||||
&coinpayments.CreateTX{
|
||||
Amount: tokenAmount.AsDecimal(),
|
||||
CurrencyIn: monetary.StorjToken,
|
||||
CurrencyOut: monetary.StorjToken,
|
||||
CurrencyIn: currency.StorjToken,
|
||||
CurrencyOut: currency.StorjToken,
|
||||
BuyerEmail: c.Email,
|
||||
},
|
||||
)
|
||||
@ -95,7 +95,7 @@ func (tokens *storjTokens) Deposit(ctx context.Context, userID uuid.UUID, amount
|
||||
AccountID: userID,
|
||||
Address: tx.Address,
|
||||
Amount: tx.Amount,
|
||||
Received: monetary.AmountFromBaseUnits(0, tx.Amount.Currency()),
|
||||
Received: currency.AmountFromBaseUnits(0, tx.Amount.Currency()),
|
||||
Status: coinpayments.StatusPending,
|
||||
Key: key,
|
||||
Timeout: tx.Timeout,
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/satellite/payments/coinpayments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
// ErrTransactionConsumed is thrown when trying to consume already consumed transaction.
|
||||
@ -46,8 +46,8 @@ type Transaction struct {
|
||||
ID coinpayments.TransactionID
|
||||
AccountID uuid.UUID
|
||||
Address string
|
||||
Amount monetary.Amount
|
||||
Received monetary.Amount
|
||||
Amount currency.Amount
|
||||
Received currency.Amount
|
||||
Status coinpayments.Status
|
||||
Key string
|
||||
Timeout time.Duration
|
||||
@ -58,7 +58,7 @@ type Transaction struct {
|
||||
type TransactionUpdate struct {
|
||||
TransactionID coinpayments.TransactionID
|
||||
Status coinpayments.Status
|
||||
Received monetary.Amount
|
||||
Received currency.Amount
|
||||
}
|
||||
|
||||
// TransactionsPage holds set of transaction and indicates if
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"github.com/stripe/stripe-go/v72"
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/errs2"
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/testcontext"
|
||||
@ -24,7 +25,6 @@ import (
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/payments/coinpayments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/stripecoinpayments"
|
||||
"storj.io/storj/satellite/satellitedb/satellitedbtest"
|
||||
)
|
||||
@ -33,9 +33,9 @@ func TestTransactionsDB(t *testing.T) {
|
||||
satellitedbtest.Run(t, func(ctx *testcontext.Context, t *testing.T, db satellite.DB) {
|
||||
transactions := db.StripeCoinPayments().Transactions()
|
||||
|
||||
amount, err := monetary.AmountFromString("2.0000000000000000005", monetary.StorjToken)
|
||||
amount, err := currency.AmountFromString("2.0000000000000000005", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
received, err := monetary.AmountFromString("1.0000000000000000003", monetary.StorjToken)
|
||||
received, err := currency.AmountFromString("1.0000000000000000003", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
userID := testrand.UUID()
|
||||
|
||||
@ -61,7 +61,7 @@ func TestTransactionsDB(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("update", func(t *testing.T) {
|
||||
received, err := monetary.AmountFromString("6.0000000000000000001", monetary.StorjToken)
|
||||
received, err := currency.AmountFromString("6.0000000000000000001", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
|
||||
update := stripecoinpayments.TransactionUpdate{
|
||||
@ -132,9 +132,9 @@ func TestConcurrentConsume(t *testing.T) {
|
||||
|
||||
const concurrentTries = 30
|
||||
|
||||
amount, err := monetary.AmountFromString("2.0000000000000000005", monetary.StorjToken)
|
||||
amount, err := currency.AmountFromString("2.0000000000000000005", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
received, err := monetary.AmountFromString("1.0000000000000000003", monetary.StorjToken)
|
||||
received, err := currency.AmountFromString("1.0000000000000000003", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
userID := testrand.UUID()
|
||||
txID := coinpayments.TransactionID("testID")
|
||||
@ -207,9 +207,9 @@ func TestTransactionsDBList(t *testing.T) {
|
||||
)
|
||||
|
||||
// create transactions
|
||||
amount, err := monetary.AmountFromString("4.0000000000000000005", monetary.StorjToken)
|
||||
amount, err := currency.AmountFromString("4.0000000000000000005", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
received, err := monetary.AmountFromString("5.0000000000000000003", monetary.StorjToken)
|
||||
received, err := currency.AmountFromString("5.0000000000000000003", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
|
||||
var txs []stripecoinpayments.Transaction
|
||||
@ -368,7 +368,7 @@ func TestTransactions_ApplyTransactionBalance(t *testing.T) {
|
||||
|
||||
// Emulate a deposit through CoinPayments.
|
||||
txID := coinpayments.TransactionID("testID")
|
||||
storjAmount, err := monetary.AmountFromString("100", monetary.StorjToken)
|
||||
storjAmount, err := currency.AmountFromString("100", currency.StorjToken)
|
||||
require.NoError(t, err)
|
||||
storjUSDRate, err := decimal.NewFromString("0.2")
|
||||
require.NoError(t, err)
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
)
|
||||
|
||||
// StorjTokens defines all payments STORJ token related functionality.
|
||||
@ -68,7 +68,7 @@ func (id TransactionID) String() string {
|
||||
// accepts user funds on a specific wallet address.
|
||||
type Transaction struct {
|
||||
ID TransactionID
|
||||
Amount monetary.Amount
|
||||
Amount currency.Amount
|
||||
Rate decimal.Decimal
|
||||
Address string
|
||||
Status TransactionStatus
|
||||
@ -81,8 +81,8 @@ type Transaction struct {
|
||||
// such as links and expiration time.
|
||||
type TransactionInfo struct {
|
||||
ID TransactionID
|
||||
Amount monetary.Amount
|
||||
Received monetary.Amount
|
||||
Amount currency.Amount
|
||||
Received currency.Amount
|
||||
AmountCents int64
|
||||
ReceivedCents int64
|
||||
Address string
|
||||
@ -114,8 +114,8 @@ const (
|
||||
type WalletPayment struct {
|
||||
From blockchain.Address `json:"from"`
|
||||
To blockchain.Address `json:"to"`
|
||||
TokenValue monetary.Amount `json:"tokenValue"`
|
||||
USDValue monetary.Amount `json:"usdValue"`
|
||||
TokenValue currency.Amount `json:"tokenValue"`
|
||||
USDValue currency.Amount `json:"usdValue"`
|
||||
Status PaymentStatus `json:"status"`
|
||||
BlockHash blockchain.Hash `json:"blockHash"`
|
||||
BlockNumber int64 `json:"blockNumber"`
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/private/dbutil/pgutil/pgerrcode"
|
||||
"storj.io/storj/satellite/payments/billing"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/satellitedb/dbx"
|
||||
)
|
||||
|
||||
@ -38,8 +38,8 @@ func (db billingDB) Insert(ctx context.Context, billingTX billing.Transaction) (
|
||||
if err != nil {
|
||||
return 0, Error.Wrap(err)
|
||||
}
|
||||
billingAmount := monetary.AmountFromDecimal(billingTX.Amount.AsDecimal().Truncate(monetary.USDollarsMicro.DecimalPlaces()), monetary.USDollarsMicro)
|
||||
newBalance, err := monetary.Add(oldBalance, billingAmount)
|
||||
billingAmount := currency.AmountFromDecimal(billingTX.Amount.AsDecimal().Truncate(currency.USDollarsMicro.DecimalPlaces()), currency.USDollarsMicro)
|
||||
newBalance, err := currency.Add(oldBalance, billingAmount)
|
||||
if err != nil {
|
||||
return 0, Error.Wrap(err)
|
||||
}
|
||||
@ -160,18 +160,18 @@ func (db billingDB) List(ctx context.Context, userID uuid.UUID) (txs []billing.T
|
||||
return txs, nil
|
||||
}
|
||||
|
||||
func (db billingDB) GetBalance(ctx context.Context, userID uuid.UUID) (_ monetary.Amount, err error) {
|
||||
func (db billingDB) GetBalance(ctx context.Context, userID uuid.UUID) (_ currency.Amount, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
dbxBilling, err := db.db.Get_BillingBalance_Balance_By_UserId(ctx,
|
||||
dbx.BillingBalance_UserId(userID[:]))
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return monetary.USDollarsMicro.Zero(), nil
|
||||
return currency.USDollarsMicro.Zero(), nil
|
||||
}
|
||||
return monetary.USDollarsMicro.Zero(), Error.Wrap(err)
|
||||
return currency.USDollarsMicro.Zero(), Error.Wrap(err)
|
||||
}
|
||||
|
||||
return monetary.AmountFromBaseUnits(dbxBilling.Balance, monetary.USDollarsMicro), nil
|
||||
return currency.AmountFromBaseUnits(dbxBilling.Balance, currency.USDollarsMicro), nil
|
||||
}
|
||||
|
||||
// fromDBXBillingTransaction converts *dbx.BillingTransaction to *billing.Transaction.
|
||||
@ -183,7 +183,7 @@ func fromDBXBillingTransaction(dbxTX *dbx.BillingTransaction) (*billing.Transact
|
||||
return &billing.Transaction{
|
||||
ID: dbxTX.Id,
|
||||
UserID: userID,
|
||||
Amount: monetary.AmountFromBaseUnits(dbxTX.Amount, monetary.USDollarsMicro),
|
||||
Amount: currency.AmountFromBaseUnits(dbxTX.Amount, currency.USDollarsMicro),
|
||||
Description: dbxTX.Description,
|
||||
Source: dbxTX.Source,
|
||||
Status: billing.TransactionStatus(dbxTX.Status),
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/common/uuid"
|
||||
"storj.io/storj/satellite/payments/coinpayments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/stripecoinpayments"
|
||||
"storj.io/storj/satellite/satellitedb/dbx"
|
||||
)
|
||||
@ -258,15 +258,14 @@ func (db *coinPaymentsTransactions) ListPending(ctx context.Context, offset int6
|
||||
|
||||
// TODO: the currency here should be passed in to this function or stored
|
||||
// in the database.
|
||||
currency := monetary.StorjToken
|
||||
|
||||
page.Transactions = append(page.Transactions,
|
||||
stripecoinpayments.Transaction{
|
||||
ID: coinpayments.TransactionID(id),
|
||||
AccountID: userID,
|
||||
Address: address,
|
||||
Amount: monetary.AmountFromBaseUnits(*amount, currency),
|
||||
Received: monetary.AmountFromBaseUnits(*received, currency),
|
||||
Amount: currency.AmountFromBaseUnits(*amount, currency.StorjToken),
|
||||
Received: currency.AmountFromBaseUnits(*received, currency.StorjToken),
|
||||
Status: coinpayments.Status(status),
|
||||
Key: key,
|
||||
CreatedAt: createdAt,
|
||||
@ -332,15 +331,14 @@ func (db *coinPaymentsTransactions) ListUnapplied(ctx context.Context, offset in
|
||||
|
||||
// TODO: the currency here should be passed in to this function or stored
|
||||
// in the database.
|
||||
currency := monetary.StorjToken
|
||||
|
||||
page.Transactions = append(page.Transactions,
|
||||
stripecoinpayments.Transaction{
|
||||
ID: coinpayments.TransactionID(id),
|
||||
AccountID: userID,
|
||||
Address: address,
|
||||
Amount: monetary.AmountFromBaseUnits(*amountNumeric, currency),
|
||||
Received: monetary.AmountFromBaseUnits(*receivedNumeric, currency),
|
||||
Amount: currency.AmountFromBaseUnits(*amountNumeric, currency.StorjToken),
|
||||
Received: currency.AmountFromBaseUnits(*receivedNumeric, currency.StorjToken),
|
||||
Status: coinpayments.Status(status),
|
||||
Key: key,
|
||||
CreatedAt: createdAt,
|
||||
@ -370,14 +368,13 @@ func fromDBXCoinpaymentsTransaction(dbxCPTX *dbx.CoinpaymentsTransaction) (*stri
|
||||
|
||||
// TODO: the currency here should be passed in to this function or stored
|
||||
// in the database.
|
||||
currency := monetary.StorjToken
|
||||
|
||||
return &stripecoinpayments.Transaction{
|
||||
ID: coinpayments.TransactionID(dbxCPTX.Id),
|
||||
AccountID: userID,
|
||||
Address: dbxCPTX.Address,
|
||||
Amount: monetary.AmountFromBaseUnits(dbxCPTX.AmountNumeric, currency),
|
||||
Received: monetary.AmountFromBaseUnits(dbxCPTX.ReceivedNumeric, currency),
|
||||
Amount: currency.AmountFromBaseUnits(dbxCPTX.AmountNumeric, currency.StorjToken),
|
||||
Received: currency.AmountFromBaseUnits(dbxCPTX.ReceivedNumeric, currency.StorjToken),
|
||||
Status: coinpayments.Status(dbxCPTX.Status),
|
||||
Key: dbxCPTX.Key,
|
||||
Timeout: time.Second * time.Duration(dbxCPTX.Timeout),
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/common/currency"
|
||||
"storj.io/private/dbutil/pgutil"
|
||||
"storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/satellite/payments/storjscan"
|
||||
"storj.io/storj/satellite/satellitedb/dbx"
|
||||
)
|
||||
@ -185,8 +185,8 @@ func (storjscanPayments storjscanPayments) ListConfirmed(ctx context.Context, bl
|
||||
// fromDBXPayment converts dbx storjscan payment type to storjscan.CachedPayment.
|
||||
func fromDBXPayment(dbxPmnt *dbx.StorjscanPayment) storjscan.CachedPayment {
|
||||
payment := storjscan.CachedPayment{
|
||||
TokenValue: monetary.AmountFromBaseUnits(dbxPmnt.TokenValue, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(dbxPmnt.UsdValue, monetary.USDollarsMicro),
|
||||
TokenValue: currency.AmountFromBaseUnits(dbxPmnt.TokenValue, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(dbxPmnt.UsdValue, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatus(dbxPmnt.Status),
|
||||
BlockNumber: dbxPmnt.BlockNumber,
|
||||
LogIndex: dbxPmnt.LogIndex,
|
||||
|
@ -8,13 +8,14 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"storj.io/common/currency"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
blockchain2 "storj.io/storj/private/blockchain"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite/payments"
|
||||
"storj.io/storj/satellite/payments/monetary"
|
||||
"storj.io/storj/testsuite/storjscan/storjscantest"
|
||||
"storj.io/storjscan/blockchain"
|
||||
"storj.io/storjscan/private/testeth/testtoken"
|
||||
@ -61,8 +62,8 @@ func TestChore(t *testing.T) {
|
||||
expected := payments.WalletPayment{
|
||||
From: blockchain2.Address(accs[0].Address),
|
||||
To: blockchain2.Address(receiver),
|
||||
TokenValue: monetary.AmountFromBaseUnits(10000, monetary.StorjToken),
|
||||
USDValue: monetary.AmountFromBaseUnits(1000000, monetary.USDollars),
|
||||
TokenValue: currency.AmountFromBaseUnits(10000, currency.StorjToken),
|
||||
USDValue: currency.AmountFromBaseUnits(10000000000, currency.USDollarsMicro),
|
||||
Status: payments.PaymentStatusPending,
|
||||
BlockHash: blockchain2.Hash(block.Hash()),
|
||||
BlockNumber: block.Number().Int64(),
|
||||
|
@ -10,7 +10,7 @@ require (
|
||||
github.com/zeebo/errs v1.3.0
|
||||
go.uber.org/zap v1.21.0
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6
|
||||
storj.io/private v0.0.0-20220818074142-c354e3e64dd3
|
||||
storj.io/storj v1.59.1
|
||||
storj.io/storjscan v0.0.0-20220722004446-7e3c50357dc2
|
||||
|
@ -1286,8 +1286,8 @@ storj.io/common v0.0.0-20211217122906-6be0b96ce7e0/go.mod h1:Lufva6X8BVz5dEDNabp
|
||||
storj.io/common v0.0.0-20220708152916-e2f08365ed65/go.mod h1:PdwPrX+QWAm4vgVyka5U13vA0jKk49MpV4tzW4HTaz0=
|
||||
storj.io/common v0.0.0-20220719163320-cd2ef8e1b9b0/go.mod h1:mCYV6Ud5+cdbuaxdPD5Zht/HYaIn0sffnnws9ErkrMQ=
|
||||
storj.io/common v0.0.0-20220802175255-aae0c09ec9d4/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1 h1:0NIhx8hyQ+UgG4ZC5UOdMu4uHhSizmEfAUsca0E4hMA=
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6 h1:qjerTUC3dl6XzF44LkOEGKFpyz7oDkbtyr/tZUa+CFU=
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw=
|
||||
storj.io/drpc v0.0.24/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=
|
||||
storj.io/drpc v0.0.26/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=
|
||||
|
@ -10,7 +10,7 @@ require (
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.uber.org/zap v1.17.0
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6
|
||||
storj.io/gateway-mt v1.18.1-0.20211210081136-cada9a567d31
|
||||
storj.io/private v0.0.0-20220818074142-c354e3e64dd3
|
||||
storj.io/storj v0.12.1-0.20220705102727-0f626a59c103
|
||||
|
@ -1495,8 +1495,8 @@ storj.io/common v0.0.0-20211102144601-401a79f0706a/go.mod h1:a2Kw7Uipu929OFANfWK
|
||||
storj.io/common v0.0.0-20220708152916-e2f08365ed65/go.mod h1:PdwPrX+QWAm4vgVyka5U13vA0jKk49MpV4tzW4HTaz0=
|
||||
storj.io/common v0.0.0-20220719163320-cd2ef8e1b9b0/go.mod h1:mCYV6Ud5+cdbuaxdPD5Zht/HYaIn0sffnnws9ErkrMQ=
|
||||
storj.io/common v0.0.0-20220802175255-aae0c09ec9d4/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1 h1:0NIhx8hyQ+UgG4ZC5UOdMu4uHhSizmEfAUsca0E4hMA=
|
||||
storj.io/common v0.0.0-20220822090045-1b57fc2bbda1/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6 h1:qjerTUC3dl6XzF44LkOEGKFpyz7oDkbtyr/tZUa+CFU=
|
||||
storj.io/common v0.0.0-20220902050723-654fd98b53c6/go.mod h1:+gF7jbVvpjVIVHhK+EJFhfPbudX395lnPq/dKkj/Qys=
|
||||
storj.io/dotworld v0.0.0-20210324183515-0d11aeccd840/go.mod h1:KU9YvEgRrMMiWLvH8pzn1UkoCoxggKIPvQxmNdx7aXQ=
|
||||
storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw=
|
||||
storj.io/drpc v0.0.24/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=
|
||||
|
Loading…
Reference in New Issue
Block a user