Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all vega commands into a commands subfolder / package in the proto package #3438

Merged
merged 9 commits into from
May 1, 2021
3 changes: 2 additions & 1 deletion accounts/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"code.vegaprotocol.io/vega/contextutil"
"code.vegaprotocol.io/vega/logging"
types "code.vegaprotocol.io/vega/proto"
commandspb "code.vegaprotocol.io/vega/proto/commands/v1"
)

var (
Expand Down Expand Up @@ -63,7 +64,7 @@ func (s *Svc) ReloadConf(cfg Config) {
s.Config = cfg
}

func (s *Svc) PrepareWithdraw(ctx context.Context, w *types.WithdrawSubmission) error {
func (s *Svc) PrepareWithdraw(ctx context.Context, w *commandspb.WithdrawSubmission) error {
if len(w.PartyId) <= 0 {
return ErrMissingPartyID
}
Expand Down
4 changes: 2 additions & 2 deletions api/mocks/account_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/mocks/accounts_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/mocks/evt_forwarder_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions api/mocks/governance_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/mocks/liquidity_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/mocks/notary_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions api/mocks/trade_order_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions api/trading.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"code.vegaprotocol.io/vega/monitoring"
types "code.vegaprotocol.io/vega/proto"
protoapi "code.vegaprotocol.io/vega/proto/api"
commandspb "code.vegaprotocol.io/vega/proto/commands/v1"
"code.vegaprotocol.io/vega/txn"
"code.vegaprotocol.io/vega/wallet/crypto"

Expand All @@ -26,35 +27,35 @@ var (
// TradeOrderService ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/trade_order_service_mock.go -package mocks code.vegaprotocol.io/vega/api TradeOrderService
type TradeOrderService interface {
PrepareSubmitOrder(ctx context.Context, submission *types.OrderSubmission) error
PrepareCancelOrder(ctx context.Context, cancellation *types.OrderCancellation) error
PrepareAmendOrder(ctx context.Context, amendment *types.OrderAmendment) error
PrepareSubmitOrder(ctx context.Context, submission *commandspb.OrderSubmission) error
PrepareCancelOrder(ctx context.Context, cancellation *commandspb.OrderCancellation) error
PrepareAmendOrder(ctx context.Context, amendment *commandspb.OrderAmendment) error
}

// LiquidityService ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/liquidity_service_mock.go -package mocks code.vegaprotocol.io/vega/api LiquidityService
type LiquidityService interface {
PrepareLiquidityProvisionSubmission(context.Context, *types.LiquidityProvisionSubmission) error
PrepareLiquidityProvisionSubmission(context.Context, *commandspb.LiquidityProvisionSubmission) error
Get(party, market string) ([]types.LiquidityProvision, error)
}

// AccountService ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/account_service_mock.go -package mocks code.vegaprotocol.io/vega/api AccountService
type AccountService interface {
PrepareWithdraw(context.Context, *types.WithdrawSubmission) error
PrepareWithdraw(context.Context, *commandspb.WithdrawSubmission) error
}

// GovernanceService ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/governance_service_mock.go -package mocks code.vegaprotocol.io/vega/api GovernanceService
type GovernanceService interface {
PrepareProposal(ctx context.Context, reference string, terms *types.ProposalTerms) (*types.ProposalSubmission, error)
PrepareVote(vote *types.VoteSubmission) (*types.VoteSubmission, error)
PrepareProposal(ctx context.Context, reference string, terms *types.ProposalTerms) (*commandspb.ProposalSubmission, error)
PrepareVote(vote *commandspb.VoteSubmission) (*commandspb.VoteSubmission, error)
}

// EvtForwarder
//go:generate go run github.com/golang/mock/mockgen -destination mocks/evt_forwarder_mock.go -package mocks code.vegaprotocol.io/vega/api EvtForwarder
type EvtForwarder interface {
Forward(ctx context.Context, e *types.ChainEvent, pk string) error
Forward(ctx context.Context, e *commandspb.ChainEvent, pk string) error
}

// Blockchain ...
Expand Down
7 changes: 4 additions & 3 deletions api/trading_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"code.vegaprotocol.io/vega/monitoring"
types "code.vegaprotocol.io/vega/proto"
protoapi "code.vegaprotocol.io/vega/proto/api"
commandspb "code.vegaprotocol.io/vega/proto/commands/v1"
eventspb "code.vegaprotocol.io/vega/proto/events/v1"
oraclespb "code.vegaprotocol.io/vega/proto/oracles/v1"
"code.vegaprotocol.io/vega/stats"
Expand Down Expand Up @@ -114,7 +115,7 @@ type AccountsService interface {
GetFeeInfrastructureAccounts(asset string) ([]*types.Account, error)
ObserveAccounts(ctx context.Context, retries int, marketID, partyID, asset string, ty types.AccountType) (candleCh <-chan []*types.Account, ref uint64)
GetAccountSubscribersCount() int32
PrepareWithdraw(context.Context, *types.WithdrawSubmission) error
PrepareWithdraw(context.Context, *commandspb.WithdrawSubmission) error
}

// TransferResponseService ...
Expand Down Expand Up @@ -158,7 +159,7 @@ type RiskService interface {
// Notary ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/notary_service_mock.go -package mocks code.vegaprotocol.io/vega/api NotaryService
type NotaryService interface {
GetByID(id string) ([]types.NodeSignature, error)
GetByID(id string) ([]commandspb.NodeSignature, error)
}

// Withdrawal ...
Expand Down Expand Up @@ -506,7 +507,7 @@ func (t *tradingDataService) GetNodeSignaturesAggregate(ctx context.Context,
return nil, apiError(codes.NotFound, err)
}

out := make([]*types.NodeSignature, 0, len(sigs))
out := make([]*commandspb.NodeSignature, 0, len(sigs))
for _, v := range sigs {
v := v
out = append(out, &v)
Expand Down
5 changes: 3 additions & 2 deletions api/trading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (

types "code.vegaprotocol.io/vega/proto"
protoapi "code.vegaprotocol.io/vega/proto/api"
commandspb "code.vegaprotocol.io/vega/proto/commands/v1"

"github.com/golang/mock/gomock"
"github.com/pkg/errors"
Expand Down Expand Up @@ -69,7 +70,7 @@ func waitForNode(t *testing.T, ctx context.Context, conn *grpc.ClientConn) {
const maxSleep = 2000 // milliseconds

req := &protoapi.PrepareSubmitOrderRequest{
Submission: &types.OrderSubmission{
Submission: &commandspb.OrderSubmission{
Type: types.Order_TYPE_LIMIT,
MarketId: "nonexistantmarket",
},
Expand Down Expand Up @@ -334,7 +335,7 @@ func TestPrepareProposal(t *testing.T) {
assert.NotNil(t, client)

proposal, err := client.PrepareProposalSubmission(ctx, &protoapi.PrepareProposalSubmissionRequest{
Submission: &types.ProposalSubmission{
Submission: &commandspb.ProposalSubmission{
Terms: &types.ProposalTerms{
Change: &types.ProposalTerms_UpdateNetworkParameter{
UpdateNetworkParameter: &types.UpdateNetworkParameter{
Expand Down
13 changes: 7 additions & 6 deletions banking/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"code.vegaprotocol.io/vega/events"
"code.vegaprotocol.io/vega/logging"
types "code.vegaprotocol.io/vega/proto"
commandspb "code.vegaprotocol.io/vega/proto/commands/v1"
"code.vegaprotocol.io/vega/validators"
)

Expand All @@ -38,9 +39,9 @@ type Assets interface {
// Notary ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/notary_mock.go -package mocks code.vegaprotocol.io/vega/banking Notary
type Notary interface {
StartAggregate(resID string, kind types.NodeSignatureKind) error
SendSignature(ctx context.Context, id string, sig []byte, kind types.NodeSignatureKind) error
IsSigned(ctx context.Context, id string, kind types.NodeSignatureKind) ([]types.NodeSignature, bool)
StartAggregate(resID string, kind commandspb.NodeSignatureKind) error
SendSignature(ctx context.Context, id string, sig []byte, kind commandspb.NodeSignatureKind) error
IsSigned(ctx context.Context, id string, kind commandspb.NodeSignatureKind) ([]commandspb.NodeSignature, bool)
}

// Collateral engine
Expand Down Expand Up @@ -310,7 +311,7 @@ func (e *Engine) WithdrawalERC20(ctx context.Context, w *types.ERC20Withdrawal,
return ErrInvalidWithdrawalState
}
withd.TxHash = txHash
if _, ok := e.notary.IsSigned(ctx, withd.Id, types.NodeSignatureKind_NODE_SIGNATURE_KIND_ASSET_WITHDRAWAL); !ok {
if _, ok := e.notary.IsSigned(ctx, withd.Id, commandspb.NodeSignatureKind_NODE_SIGNATURE_KIND_ASSET_WITHDRAWAL); !ok {
return ErrWithdrawalNotReady
}

Expand Down Expand Up @@ -371,7 +372,7 @@ func (e *Engine) LockWithdrawalERC20(ctx context.Context, id, party, assetID str
e.broker.Send(events.NewTransferResponse(ctx, []*types.TransferResponse{res}))

// we were able to lock the funds, then we can send the vote through the network
if err := e.notary.StartAggregate(w.Id, types.NodeSignatureKind_NODE_SIGNATURE_KIND_ASSET_WITHDRAWAL); err != nil {
if err := e.notary.StartAggregate(w.Id, commandspb.NodeSignatureKind_NODE_SIGNATURE_KIND_ASSET_WITHDRAWAL); err != nil {
w.Status = types.Withdrawal_STATUS_CANCELLED
e.broker.Send(events.NewWithdrawalEvent(ctx, *w))
e.withdrawals[w.Id] = withdrawalRef{w, ref}
Expand Down Expand Up @@ -401,7 +402,7 @@ func (e *Engine) LockWithdrawalERC20(ctx context.Context, id, party, assetID str
}

err = e.notary.SendSignature(
ctx, w.Id, sig, types.NodeSignatureKind_NODE_SIGNATURE_KIND_ASSET_WITHDRAWAL)
ctx, w.Id, sig, commandspb.NodeSignatureKind_NODE_SIGNATURE_KIND_ASSET_WITHDRAWAL)
if err != nil {
// we don't cancel it here
// we may not be able to sign for some reason, but other may be able
Expand Down
10 changes: 5 additions & 5 deletions banking/mocks/notary_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/vegabenchmark/mocks/evtforwarder_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.