From c9e1ac3f714d01f3292ce01a3ed112cc65b4ba65 Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Thu, 24 Oct 2024 13:10:13 +0300 Subject: [PATCH] return array of pointers in get account keys for consistency --- access/grpc/client.go | 4 ++-- access/grpc/convert/convert.go | 6 +++--- access/grpc/grpc.go | 4 ++-- access/grpc/grpc_test.go | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/access/grpc/client.go b/access/grpc/client.go index 73c174f0f..c9d308dfb 100644 --- a/access/grpc/client.go +++ b/access/grpc/client.go @@ -239,11 +239,11 @@ func (c *Client) GetAccountKeyAtBlockHeight(ctx context.Context, address flow.Ad return c.grpc.GetAccountKeyAtBlockHeight(ctx, address, keyIndex, height) } -func (c *Client) GetAccountKeysAtLatestBlock(ctx context.Context, address flow.Address) ([]flow.AccountKey, error) { +func (c *Client) GetAccountKeysAtLatestBlock(ctx context.Context, address flow.Address) ([]*flow.AccountKey, error) { return c.grpc.GetAccountKeysAtLatestBlock(ctx, address) } -func (c *Client) GetAccountKeysAtBlockHeight(ctx context.Context, address flow.Address, height uint64) ([]flow.AccountKey, error) { +func (c *Client) GetAccountKeysAtBlockHeight(ctx context.Context, address flow.Address, height uint64) ([]*flow.AccountKey, error) { return c.grpc.GetAccountKeysAtBlockHeight(ctx, address, height) } diff --git a/access/grpc/convert/convert.go b/access/grpc/convert/convert.go index b93003231..86fdce62a 100644 --- a/access/grpc/convert/convert.go +++ b/access/grpc/convert/convert.go @@ -150,8 +150,8 @@ func MessageToAccountKey(m *entities.AccountKey) (*flow.AccountKey, error) { }, nil } -func MessageToAccountKeys(m []*entities.AccountKey) ([]flow.AccountKey, error) { - var accountKeys []flow.AccountKey +func MessageToAccountKeys(m []*entities.AccountKey) ([]*flow.AccountKey, error) { + var accountKeys []*flow.AccountKey for _, entity := range m { accountKey, err := MessageToAccountKey(entity) @@ -159,7 +159,7 @@ func MessageToAccountKeys(m []*entities.AccountKey) ([]flow.AccountKey, error) { return nil, err } - accountKeys = append(accountKeys, *accountKey) + accountKeys = append(accountKeys, accountKey) } return accountKeys, nil diff --git a/access/grpc/grpc.go b/access/grpc/grpc.go index c2f668908..2b462bda3 100644 --- a/access/grpc/grpc.go +++ b/access/grpc/grpc.go @@ -703,7 +703,7 @@ func (c *BaseClient) GetAccountKeyAtBlockHeight( func (c *BaseClient) GetAccountKeysAtLatestBlock( ctx context.Context, address flow.Address, -) ([]flow.AccountKey, error) { +) ([]*flow.AccountKey, error) { request := &access.GetAccountKeysAtLatestBlockRequest{ Address: address.Bytes(), } @@ -725,7 +725,7 @@ func (c *BaseClient) GetAccountKeysAtBlockHeight( ctx context.Context, address flow.Address, height uint64, -) ([]flow.AccountKey, error) { +) ([]*flow.AccountKey, error) { request := &access.GetAccountKeysAtBlockHeightRequest{ Address: address.Bytes(), BlockHeight: height, diff --git a/access/grpc/grpc_test.go b/access/grpc/grpc_test.go index 30844d9a7..fb6099efc 100644 --- a/access/grpc/grpc_test.go +++ b/access/grpc/grpc_test.go @@ -1069,7 +1069,7 @@ func TestClient_GetAccountKeysAtLatestBlock(t *testing.T) { keys, err := c.GetAccountKeysAtLatestBlock(ctx, account.Address) require.NoError(t, err) - assert.Equal(t, *account.Keys[index], keys[index]) + assert.Equal(t, *account.Keys[index], *keys[index]) })) t.Run("Not found error", clientTest(func(t *testing.T, ctx context.Context, rpc *mocks.MockRPCClient, c *BaseClient) { @@ -1105,7 +1105,7 @@ func TestClient_GetAccountKeysAtBlockHeight(t *testing.T) { keys, err := c.GetAccountKeysAtBlockHeight(ctx, account.Address, height) require.NoError(t, err) - assert.Equal(t, *account.Keys[index], keys[index]) + assert.Equal(t, *account.Keys[index], *keys[index]) })) t.Run("Not found error", clientTest(func(t *testing.T, ctx context.Context, rpc *mocks.MockRPCClient, c *BaseClient) {