Skip to content

Commit 17bf03b

Browse files
Merge pull request #34 from Golem-Base/develop
Develop -> main
2 parents 086100a + 5624da4 commit 17bf03b

15 files changed

+112
-28
lines changed

.github/workflows/docker.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: Docker
33
on:
44
push:
55
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
6+
tags: [ 'release-**' ]
87

98
jobs:
109
build_and_push:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@chakra-ui/react": "3.15.0",
5555
"@cloudnouns/kit": "1.1.6",
5656
"@emotion/react": "11.14.0",
57-
"@golembase/l3-indexer-types": "^0.0.3",
57+
"@golembase/l3-indexer-types": "^0.0.4",
5858
"@growthbook/growthbook-react": "0.21.0",
5959
"@helia/verified-fetch": "2.6.12",
6060
"@hypelab/sdk-react": "^1.0.0",

public/icons/name.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
| "MUD_menu"
117117
| "MUD"
118118
| "networks"
119+
| "networks/golem-base-logo-black"
119120
| "networks/icon-placeholder"
120121
| "networks/logo-placeholder"
121122
| "nft_shield"

ui/address/AddressEntityOps.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { useRouter } from 'next/router';
22
import React from 'react';
33

4+
import useApiQuery from 'lib/api/useApiQuery';
45
import getQueryParamString from 'lib/router/getQueryParamString';
56
import EntityOps from 'ui/entityOps/EntityOps';
7+
import useEntityOpsQuery from 'ui/entityOps/useEntityOpsQuery';
68

79
type Props = {
810
shouldRender?: boolean;
@@ -12,15 +14,25 @@ type Props = {
1214
const AddressEntityOps = ({ shouldRender = true, isQueryEnabled = true }: Props) => {
1315
const router = useRouter();
1416
const currentAddress = getQueryParamString(router.query.hash);
17+
const queryParams = { sender: currentAddress };
18+
19+
const opsCountQuery = useApiQuery('golemBaseIndexer:operationsCount', {
20+
queryOptions: {
21+
enabled: isQueryEnabled,
22+
},
23+
queryParams,
24+
});
25+
26+
const opsQuery = useEntityOpsQuery({ filters: queryParams, enabled: isQueryEnabled });
1527

1628
if (!shouldRender) {
1729
return null;
1830
}
1931

2032
return (
2133
<EntityOps
22-
isQueryEnabled={ isQueryEnabled && Boolean(currentAddress) }
23-
queryParams={{ sender: currentAddress }}
34+
opsQuery={ opsQuery }
35+
opsCountQuery={ opsCountQuery }
2436
/>
2537
);
2638
};

ui/blocks/BlockEntityOps.pw.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Box } from '@chakra-ui/react';
2+
import React from 'react';
3+
4+
import { baseEntityOperation } from 'mocks/operations/entityOps';
5+
import { expect, test } from 'playwright/lib';
6+
7+
import BlocksEntityOps from './BlockEntityOps';
8+
9+
const BLOCK_HASH = '0x1234567890abcdef1234567890abcdef12345678';
10+
11+
const mockOperationsResponse = {
12+
items: [ baseEntityOperation ],
13+
next_page_params: null,
14+
};
15+
16+
test('base view +@mobile', async({ render, mockApiResponse }) => {
17+
18+
await mockApiResponse('golemBaseIndexer:operations', mockOperationsResponse, {
19+
queryParams: { operation: 'CREATE', page_size: '50', block_number_or_hash: BLOCK_HASH },
20+
});
21+
await mockApiResponse('golemBaseIndexer:operationsCount', {
22+
create_count: '1',
23+
update_count: '2',
24+
extend_count: '3',
25+
delete_count: '0',
26+
}, {
27+
queryParams: { block_number_or_hash: BLOCK_HASH },
28+
});
29+
30+
const component = await render(
31+
<Box pt={{ base: '134px', lg: 6 }}>
32+
<BlocksEntityOps heightOrHash={ BLOCK_HASH }/>
33+
</Box>,
34+
);
35+
36+
await expect(component).toHaveScreenshot();
37+
});

ui/blocks/BlockEntityOps.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
3+
import useApiQuery from 'lib/api/useApiQuery';
4+
import EntityOps from 'ui/entityOps/EntityOps';
5+
import useEntityOpsQuery from 'ui/entityOps/useEntityOpsQuery';
6+
7+
type Props = {
8+
heightOrHash: string;
9+
};
10+
11+
const BlockEntityOps = ({ heightOrHash }: Props) => {
12+
const queryParams = { block_number_or_hash: heightOrHash };
13+
14+
const opsQuery = useEntityOpsQuery({ filters: { block_number_or_hash: heightOrHash }, enabled: true });
15+
const opsCountQuery = useApiQuery('golemBaseIndexer:operationsCount', {
16+
queryOptions: {
17+
enabled: true,
18+
},
19+
queryParams,
20+
});
21+
22+
return (
23+
<EntityOps
24+
opsQuery={ opsQuery }
25+
opsCountQuery={ opsCountQuery }
26+
/>
27+
);
28+
};
29+
30+
export default BlockEntityOps;
16 KB
Loading
26.1 KB
Loading

ui/entityOps/EntityOps.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
import type { UseQueryResult } from '@tanstack/react-query';
12
import { map } from 'es-toolkit/compat';
23
import React from 'react';
34

45
import { OperationType } from '@golembase/l3-indexer-types';
5-
import type { FilterOperationType, GolemBaseIndexerOpsFilters } from 'types/api/golemBaseIndexer';
6+
import type { FilterOperationType } from 'types/api/golemBaseIndexer';
67

7-
import useApiQuery from 'lib/api/useApiQuery';
8+
import type { ResourceError, ResourcePayload } from 'lib/api/resources';
89
import useIsMobile from 'lib/hooks/useIsMobile';
910
import useIsMounted from 'lib/hooks/useIsMounted';
1011
import type { TabItemRegular } from 'toolkit/components/AdaptiveTabs';
1112
import { RoutedTabs } from 'toolkit/components/RoutedTabs';
1213
import Pagination from 'ui/shared/pagination/Pagination';
14+
import type { QueryWithPagesResult } from 'ui/shared/pagination/useQueryWithPages';
1315

1416
import EntityOpsContent from './EntityOpsContent';
15-
import useEntityOpsQuery from './useEntityOpsQuery';
1617

1718
const TAB_LIST_PROPS = {
1819
mt: 1,
@@ -39,22 +40,14 @@ export const ENTITY_OPS_TABS = Object.keys(LABELS).map(operationToTab);
3940

4041
type Props = {
4142
isQueryEnabled?: boolean;
42-
queryParams: Omit<GolemBaseIndexerOpsFilters, 'operation'>;
43+
opsQuery: QueryWithPagesResult<'golemBaseIndexer:operations'>;
44+
opsCountQuery: UseQueryResult<ResourcePayload<'golemBaseIndexer:operationsCount'>, ResourceError<unknown>>;
4345
};
4446

45-
const EntityOps = ({ isQueryEnabled = true, queryParams }: Props) => {
47+
const EntityOps = ({ opsQuery, opsCountQuery }: Props) => {
4648
const isMounted = useIsMounted();
4749
const isMobile = useIsMobile();
4850

49-
const opsCountQuery = useApiQuery('golemBaseIndexer:operationsCount', {
50-
queryOptions: {
51-
enabled: isQueryEnabled,
52-
},
53-
queryParams,
54-
});
55-
56-
const opsQuery = useEntityOpsQuery({ filters: queryParams, enabled: isQueryEnabled });
57-
5851
const component = React.useMemo(() => (
5952
<EntityOpsContent
6053
pagination={ opsQuery.pagination }

ui/entityOps/useEntityOpsQuery.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ export default function useEntityOpsQuery({ enabled, filters }: Props) {
2929
filters: { operation, page_size: '50', ...filters },
3030
options: {
3131
enabled: enabled,
32-
placeholderData: generateListStub<'golemBaseIndexer:operations'>(ENTITY_OPERATION, 50, { next_page_params: {
33-
page: 2,
34-
page_size: 50,
35-
} },
32+
placeholderData: generateListStub<'golemBaseIndexer:operations'>(ENTITY_OPERATION, 50, {
33+
next_page_params: {
34+
page: 2,
35+
page_size: 50,
36+
},
37+
},
3638
),
3739
},
3840
});

0 commit comments

Comments
 (0)