diff --git a/datanode/api/trading_data_v2.go b/datanode/api/trading_data_v2.go index 2cdbe30119..c54f16c0db 100644 --- a/datanode/api/trading_data_v2.go +++ b/datanode/api/trading_data_v2.go @@ -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, diff --git a/datanode/gateway/graphql/vault_resolver.go b/datanode/gateway/graphql/vault_resolver.go index 00eccaa88d..3fffa5d2df 100644 --- a/datanode/gateway/graphql/vault_resolver.go +++ b/datanode/gateway/graphql/vault_resolver.go @@ -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 . + package gql import ( diff --git a/datanode/sqlstore/vault.go b/datanode/sqlstore/vault.go index 22d83e2dfe..8a49de2b7c 100644 --- a/datanode/sqlstore/vault.go +++ b/datanode/sqlstore/vault.go @@ -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" ) @@ -87,7 +86,6 @@ 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) } @@ -95,7 +93,6 @@ func (vs *Vault) GetByVaultID( 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) } @@ -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 } diff --git a/datanode/sqlstore/vault_test.go b/datanode/sqlstore/vault_test.go index 08f2f19017..3954f75e21 100644 --- a/datanode/sqlstore/vault_test.go +++ b/datanode/sqlstore/vault_test.go @@ -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" @@ -157,7 +157,7 @@ func TestVaultState(t *testing.T) { } func TestListVaults(t *testing.T) { - _, vs := setupVaultTest(t) + vs := setupVaultTest(t) const ( vault1 = "70432aa1dc6bc20a9b404d30f23e6a8def11a1692609dcef0ad8dc558d9df7db"