Skip to content

Commit

Permalink
chore: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ze97286 committed Nov 4, 2024
1 parent d2f03e5 commit 4019a2d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion datanode/api/trading_data_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (t *TradingDataServiceV2) ListVaults(ctx context.Context, req *v2.ListVault
if err != nil {
return nil, err
}
edges := make([]*v2.VaultEdge, len(vaults))
edges := make([]*v2.VaultEdge, 0, len(vaults))
for _, vault := range vaults {
vaultEvent := &v1.VaultState{
Vault: vault.Vault,
Expand Down
15 changes: 15 additions & 0 deletions datanode/gateway/graphql/vault_resolver.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (C) 2023 Gobalsky Labs Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package gql

import (
Expand Down
5 changes: 1 addition & 4 deletions datanode/sqlstore/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"code.vegaprotocol.io/vega/datanode/entities"
"code.vegaprotocol.io/vega/datanode/metrics"
v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2"

"github.com/georgysavva/scany/pgxscan"
)
Expand Down Expand Up @@ -87,15 +86,13 @@ func (vs *Vault) GetByVaultID(
err := pgxscan.Select(ctx, vs.ConnectionSource, &pvs,
`SELECT * FROM vault_party_shares_current WHERE vault_id=$1`,
entities.VaultID(id))

if err != nil {
return vaultState, vs.wrapE(err)
}

err = pgxscan.Get(ctx, vs.ConnectionSource, &vaultState,
`SELECT * FROM vault_state_current WHERE vault_id=$1`,
entities.VaultID(id))

if err != nil {
return vaultState, vs.wrapE(err)
}
Expand Down Expand Up @@ -137,7 +134,7 @@ func (v *Vault) ListVaultsWithCursor(ctx context.Context,
vault.PartyShares = pvs
vaultStateWithPartyShare = append(vaultStateWithPartyShare, vault)
}
vaultStateWithPartyShare, pageInfo = entities.PageEntities[*v2.VaultEdge](vaultStateWithPartyShare, pagination)
vaultStateWithPartyShare, pageInfo = entities.PageEntities(vaultStateWithPartyShare, pagination)
return vaultStateWithPartyShare, pageInfo, nil
}

Expand Down
10 changes: 5 additions & 5 deletions datanode/sqlstore/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ import (
"code.vegaprotocol.io/vega/datanode/sqlstore"
"code.vegaprotocol.io/vega/libs/num"
"code.vegaprotocol.io/vega/protos/vega"

"github.com/stretchr/testify/require"
)

func setupVaultTest(t *testing.T) (*sqlstore.Blocks, *sqlstore.Vault) {
func setupVaultTest(t *testing.T) *sqlstore.Vault {
t.Helper()
bs := sqlstore.NewBlocks(connectionSource)
plbs := sqlstore.NewVault(connectionSource)

return bs, plbs
return plbs
}

func TestVaultState(t *testing.T) {
_, vs := setupVaultTest(t)
vs := setupVaultTest(t)

const (
vault1 = "70432aa1dc6bc20a9b404d30f23e6a8def11a1692609dcef0ad8dc558d9df7db"
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestVaultState(t *testing.T) {
}

func TestListVaults(t *testing.T) {
_, vs := setupVaultTest(t)
vs := setupVaultTest(t)

const (
vault1 = "70432aa1dc6bc20a9b404d30f23e6a8def11a1692609dcef0ad8dc558d9df7db"
Expand Down

0 comments on commit 4019a2d

Please sign in to comment.