Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions cmd/commands/cli/command_identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,8 @@ func (c *cliApp) settle(args []string) (err error) {
if err != nil {
clio.Warn("could not get transactor fee: ", err)
}
trFee := new(big.Float).Quo(new(big.Float).SetInt(fees.Settlement), new(big.Float).SetInt(money.MystSize))
hermesFee := new(big.Float).Quo(new(big.Float).SetInt(big.NewInt(int64(fees.Hermes))), new(big.Float).SetInt(money.MystSize))
clio.Info(fmt.Sprintf("Transactor fee: %v MYST", trFee.String()))
clio.Info(fmt.Sprintf("Hermes fee: %v MYST", hermesFee.String()))
clio.Info(fmt.Sprintf("Transactor fee: %v MYST", fees.SettlementTokens.Human))
clio.Info(fmt.Sprintf("Hermes fee: %v MYST", fees.HermesTokens.Human))
return errWrongArgumentCount
}
hermesID, err := c.config.GetHermesID()
Expand Down Expand Up @@ -405,10 +403,8 @@ func (c *cliApp) withdraw(args []string) error {
if err != nil {
clio.Warn("could not get transactor fee: ", err)
}
trFee := new(big.Float).Quo(new(big.Float).SetInt(fees.Settlement), new(big.Float).SetInt(money.MystSize))
hermesFee := new(big.Float).Quo(new(big.Float).SetInt(big.NewInt(int64(fees.Hermes))), new(big.Float).SetInt(money.MystSize))
clio.Info(fmt.Sprintf("Transactor fee: %v MYST", trFee.String()))
clio.Info(fmt.Sprintf("Hermes fee: %v MYST", hermesFee.String()))
clio.Info(fmt.Sprintf("Transactor fee: %v MYST", fees.SettlementTokens.Human))
clio.Info(fmt.Sprintf("Hermes fee: %v MYST", fees.HermesTokens.Human))
return errWrongArgumentCount
}
hermesID, err := c.config.GetHermesID()
Expand Down
8 changes: 2 additions & 6 deletions cmd/commands/connection/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ package connection

import (
"fmt"
"math/big"

"github.com/mysteriumnetwork/node/money"
"github.com/mysteriumnetwork/node/tequilapi/contract"
)

func proposalFormatted(p *contract.ProposalDTO) string {
ph := money.New(new(big.Int).SetUint64(p.Price.PerHour))
pg := money.New(new(big.Int).SetUint64(p.Price.PerGiB))
return fmt.Sprintf("| Identity: %s\t| Type: %s\t| Country: %s\t | Price: %s/hour\t%s/GiB\t|",
p.ProviderID,
p.Location.IPType,
p.Location.Country,
ph.String(),
pg.String(),
p.Price.PerHourTokens.Human,
p.Price.PerGiBTokens.Human,
)
}
3 changes: 3 additions & 0 deletions tequilapi/contract/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func NewConnectionStatisticsDTO(session connectionstate.Status, statistics conne
ThroughputSent: datasize.BitSize(throughput.Up).Bits(),
ThroughputReceived: datasize.BitSize(throughput.Down).Bits(),
TokensSpent: agreementTotal,
SpentTokens: NewTokens(agreementTotal),
}
}

Expand All @@ -128,6 +129,8 @@ type ConnectionStatisticsDTO struct {

// example: 500000
TokensSpent *big.Int `json:"tokens_spent"`

SpentTokens Tokens `json:"spent_tokens"`
}

// ConnectionCreateRequest request used to start a connection.
Expand Down
16 changes: 10 additions & 6 deletions tequilapi/contract/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ func NewProposalDTO(p proposal.PricedServiceProposal) ProposalDTO {
Bandwidth: p.Quality.Bandwidth,
},
Price: Price{
Currency: money.CurrencyMyst.String(),
PerHour: p.Price.PricePerHour.Uint64(),
PerGiB: p.Price.PricePerGiB.Uint64(),
Currency: money.CurrencyMyst.String(),
PerHour: p.Price.PricePerHour.Uint64(),
PerHourTokens: NewTokens(p.Price.PricePerHour),
PerGiB: p.Price.PricePerGiB.Uint64(),
PerGiBTokens: NewTokens(p.Price.PricePerGiB),
},
}
}
Expand Down Expand Up @@ -107,9 +109,11 @@ type ProposalDTO struct {
// Price represents the service price.
// swagger:model Price
type Price struct {
Currency string `json:"currency"`
PerHour uint64 `json:"per_hour"`
PerGiB uint64 `json:"per_gib"`
Currency string `json:"currency"`
PerHour uint64 `json:"per_hour"`
PerHourTokens Tokens `json:"per_hour_tokens"`
PerGiB uint64 `json:"per_gib"`
PerGiBTokens Tokens `json:"per_gib_tokens"`
}

func (p ProposalDTO) String() string {
Expand Down
12 changes: 8 additions & 4 deletions tequilapi/contract/transactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ import (
// FeesDTO represents the transactor fees
// swagger:model FeesDTO
type FeesDTO struct {
Registration *big.Int `json:"registration"`
Settlement *big.Int `json:"settlement"`
Hermes uint16 `json:"hermes"`
DecreaseStake *big.Int `json:"decreaseStake"`
Registration *big.Int `json:"registration"`
RegistrationTokens Tokens `json:"registration_tokens"`
Settlement *big.Int `json:"settlement"`
SettlementTokens Tokens `json:"settlement_tokens"`
Hermes uint16 `json:"hermes"`
HermesTokens Tokens `json:"hermes_tokens"`
DecreaseStake *big.Int `json:"decreaseStake"`
DecreaseStakeTokens Tokens `json:"decrease_stake_tokens"`
}

// NewSettlementListQuery creates settlement list query with default values.
Expand Down
21 changes: 21 additions & 0 deletions tequilapi/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3071,6 +3071,9 @@
"x-go-name": "Duration",
"example": 60
},
"spent_tokens": {
"$ref": "#/definitions/Tokens"
},
"throughput_received": {
"description": "Download speed in bits per second",
"type": "integer",
Expand Down Expand Up @@ -3270,16 +3273,28 @@
"decreaseStake": {
"$ref": "#/definitions/Int"
},
"decrease_stake_tokens": {
"$ref": "#/definitions/Tokens"
},
"hermes": {
"type": "integer",
"format": "uint16",
"x-go-name": "Hermes"
},
"hermes_tokens": {
"$ref": "#/definitions/Tokens"
},
"registration": {
"$ref": "#/definitions/Int"
},
"registration_tokens": {
"$ref": "#/definitions/Tokens"
},
"settlement": {
"$ref": "#/definitions/Int"
},
"settlement_tokens": {
"$ref": "#/definitions/Tokens"
}
},
"x-go-package": "github.com/mysteriumnetwork/node/tequilapi/contract"
Expand Down Expand Up @@ -4019,10 +4034,16 @@
"format": "uint64",
"x-go-name": "PerGiB"
},
"per_gib_tokens": {
"$ref": "#/definitions/Tokens"
},
"per_hour": {
"type": "integer",
"format": "uint64",
"x-go-name": "PerHour"
},
"per_hour_tokens": {
"$ref": "#/definitions/Tokens"
}
},
"x-go-package": "github.com/mysteriumnetwork/node/tequilapi/contract"
Expand Down
10 changes: 5 additions & 5 deletions tequilapi/endpoints/assets/docs.go

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions tequilapi/endpoints/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ func TestAddRoutesForConnectionAddsRoutes(t *testing.T) {
"throughput_received": 0,
"throughput_sent": 0,
"duration": 0,
"tokens_spent": 0
"tokens_spent": 0,
"spent_tokens": {
"ether": "0",
"human": "0",
"wei": "0"
}
}`,
},
}
Expand Down Expand Up @@ -424,7 +429,12 @@ func TestGetStatisticsEndpointReturnsStatistics(t *testing.T) {
"throughput_sent": 1000,
"throughput_received": 2000,
"duration": 0,
"tokens_spent": 10001
"tokens_spent": 10001,
"spent_tokens": {
"ether": "0.000000000000010001",
"human": "0",
"wei": "10001"
}
}`,
resp.Body.String(),
)
Expand Down
72 changes: 56 additions & 16 deletions tequilapi/endpoints/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ var serviceProposals = []proposal.PricedServiceProposal{
Quality: &mockQuality,
}),
Price: market.Price{
PricePerHour: big.NewInt(1),
PricePerGiB: big.NewInt(2),
PricePerHour: big.NewInt(500_000_000_000_000_000),
PricePerGiB: big.NewInt(1_000_000_000_000_000_000),
},
},
{
Expand All @@ -61,8 +61,8 @@ var serviceProposals = []proposal.PricedServiceProposal{
Quality: &mockQuality,
}),
Price: market.Price{
PricePerHour: big.NewInt(1),
PricePerGiB: big.NewInt(2),
PricePerHour: big.NewInt(500_000_000_000_000_000),
PricePerGiB: big.NewInt(1_000_000_000_000_000_000),
},
},
}
Expand Down Expand Up @@ -122,9 +122,19 @@ func TestProposalsEndpointListByNodeId(t *testing.T) {
"bandwidth": 10
},
"price": {
"currency": "MYST",
"per_gib": 2.0,
"per_hour": 1.0
"currency": "MYST",
"per_gib": 1000000000000000000,
"per_gib_tokens": {
"ether": "1",
"human": "1",
"wei": "1000000000000000000"
},
"per_hour": 500000000000000000,
"per_hour_tokens": {
"ether": "0.5",
"human": "0.5",
"wei": "500000000000000000"
}
}
}
]
Expand Down Expand Up @@ -182,9 +192,19 @@ func TestProposalsEndpointAcceptsAccessPolicyParams(t *testing.T) {
"bandwidth": 10
},
"price": {
"currency": "MYST",
"per_gib": 2.0,
"per_hour": 1.0
"currency": "MYST",
"per_gib": 1000000000000000000,
"per_gib_tokens": {
"ether": "1",
"human": "1",
"wei": "1000000000000000000"
},
"per_hour": 500000000000000000,
"per_hour_tokens": {
"ether": "0.5",
"human": "0.5",
"wei": "500000000000000000"
}
}
}
]
Expand Down Expand Up @@ -249,9 +269,19 @@ func TestProposalsEndpointFilterByPresetID(t *testing.T) {
"bandwidth": 10
},
"price": {
"currency": "MYST",
"per_gib": 2.0,
"per_hour": 1.0
"currency": "MYST",
"per_gib": 1000000000000000000,
"per_gib_tokens": {
"ether": "1",
"human": "1",
"wei": "1000000000000000000"
},
"per_hour": 500000000000000000,
"per_hour_tokens": {
"ether": "0.5",
"human": "0.5",
"wei": "500000000000000000"
}
}
},
{
Expand All @@ -270,9 +300,19 @@ func TestProposalsEndpointFilterByPresetID(t *testing.T) {
"bandwidth": 10
},
"price": {
"currency": "MYST",
"per_gib": 2.0,
"per_hour": 1.0
"currency": "MYST",
"per_gib": 1000000000000000000,
"per_gib_tokens": {
"ether": "1",
"human": "1",
"wei": "1000000000000000000"
},
"per_hour": 500000000000000000,
"per_hour_tokens": {
"ether": "0.5",
"human": "0.5",
"wei": "500000000000000000"
}
}
}
]
Expand Down
Loading