Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit 7f952c9

Browse files
authored
Merge pull request #263 from zallo-labs/Z-309-fix-approve
Z 309 fix approve
2 parents b0caf57 + cf3b2d9 commit 7f952c9

File tree

4 files changed

+49
-29
lines changed

4 files changed

+49
-29
lines changed

api/dbschema/default.esdl

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ module default {
6262

6363
constraint exclusive on ((.proposal, .approver));
6464

65-
access policy anyone_select allow select
66-
using (true);
65+
access policy members_select allow select
66+
using (is_member(.proposal.account));
6767

6868
access policy user_all allow all
6969
using (.approver ?= global current_approver or .approver.user ?= global current_user);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE MIGRATION m1qek7a23nqh42rms7kw536pjj74szxn437qw75exsqiml5k55qlja
2+
ONTO m1k3vtvlgbxrn6n7kipby46a6okbxajclyuvlps7djvck76yr4mfaq
3+
{
4+
ALTER TYPE default::ProposalResponse {
5+
ALTER ACCESS POLICY anyone_select RENAME TO members_select;
6+
};
7+
ALTER TYPE default::ProposalResponse {
8+
ALTER ACCESS POLICY members_select USING (default::is_member(.proposal.account));
9+
};
10+
};

app/src/app/(nav)/contacts/[address].tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useRouter } from 'expo-router';
55
import { Address, ZERO_ADDR, asAddress, asChain, asUAddress, tryAsUAddress } from 'lib';
66
import { RemoveIcon } from '@theme/icons';
77
import { useForm } from 'react-hook-form';
8-
import { StyleSheet } from 'react-native';
98
import { View } from 'react-native';
109
import { Menu } from 'react-native-paper';
1110
import { AppbarMore } from '#/Appbar/AppbarMore';
@@ -15,7 +14,6 @@ import { Actions } from '#/layout/Actions';
1514
import { FormResetIcon } from '#/fields/ResetFormIcon';
1615
import { useConfirmRemoval } from '~/hooks/useConfirm';
1716
import { withSuspense } from '#/skeleton/withSuspense';
18-
import { ScrollableScreenSurface } from '#/layout/ScrollableScreenSurface';
1917
import { Chain } from 'chains';
2018
import { zodResolver } from '@hookform/resolvers/zod';
2119
import { useSelectedChain } from '~/hooks/useSelectedAccount';
@@ -28,6 +26,8 @@ import { useLazyLoadQuery } from 'react-relay';
2826
import { Address_ContactScreenQuery } from '~/api/__generated__/Address_ContactScreenQuery.graphql';
2927
import { useUpsertContact } from '~/hooks/mutations/useUpsertContact';
3028
import { useRemoveContact } from '~/hooks/mutations/useRemoveContact';
29+
import { Scrollable } from '#/Scrollable';
30+
import { createStyles } from '@theme/styles';
3131

3232
const Query = graphql`
3333
query Address_ContactScreenQuery($address: UAddress!, $include: Boolean!) {
@@ -117,7 +117,7 @@ function ContactScreen_(props: ContactScreenProps) {
117117
})}
118118
/>
119119

120-
<ScrollableScreenSurface>
120+
<Scrollable>
121121
<View style={styles.fields}>
122122
<FormTextField label="Name" name="name" control={control} required />
123123

@@ -143,12 +143,12 @@ function ContactScreen_(props: ContactScreenProps) {
143143
{current ? 'Update' : 'Add'}
144144
</FormSubmitButton>
145145
</Actions>
146-
</ScrollableScreenSurface>
146+
</Scrollable>
147147
</Pane>
148148
);
149149
}
150150

151-
const styles = StyleSheet.create({
151+
const styles = createStyles({
152152
fields: {
153153
gap: 16,
154154
margin: 16,

app/src/app/(nav)/token/[address].tsx

+32-22
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ import { Menu } from 'react-native-paper';
1010
import { AppbarOptions } from '#/Appbar/AppbarOptions';
1111
import { withSuspense } from '#/skeleton/withSuspense';
1212
import { ScreenSkeleton } from '#/skeleton/ScreenSkeleton';
13-
import { ScrollableScreenSurface } from '#/layout/ScrollableScreenSurface';
1413
import { z } from 'zod';
1514
import { zHex, zUAddress } from '~/lib/zod';
1615
import { useLocalParams } from '~/hooks/useLocalParams';
1716
import { zodResolver } from '@hookform/resolvers/zod';
1817
import { ListItem } from '#/list/ListItem';
1918
import { CHAINS } from 'chains';
2019
import { View } from 'react-native';
21-
import { createStyles } from '@theme/styles';
20+
import { createStyles, useStyles } from '@theme/styles';
2221
import { Button } from '#/Button';
2322
import { ExternalLinkIcon, GenericTokenIcon } from '@theme/icons';
2423
import { ICON_SIZE } from '@theme/paper';
25-
import { graphql, ROOT_ID } from 'relay-runtime';
24+
import { graphql } from 'relay-runtime';
2625
import { useLazyLoadQuery } from 'react-relay';
2726
import { useUpsertToken } from '~/hooks/mutations/useUpsertToken';
2827
import { Address_TokenScreenQuery } from '~/api/__generated__/Address_TokenScreenQuery.graphql';
2928
import { useRemoveToken } from '~/hooks/mutations/useRemoveToken';
30-
import { useInvalidateQueryOn, useQuery } from '~/api/useQuery';
29+
import { useInvalidateQueryOn } from '~/api/useQuery';
30+
import { Scrollable } from '#/Scrollable';
31+
import { Pane } from '#/layout/Pane';
32+
import { ItemList } from '#/layout/ItemList';
3133

3234
const PYTH_PRICE_FEEDS_URL = 'https://pyth.network/developers/price-feed-ids';
3335

@@ -68,6 +70,7 @@ const TokenScreenParams = z.object({ address: zUAddress() });
6870

6971
function TokenScreen_() {
7072
const { address: token } = useLocalParams(TokenScreenParams);
73+
const { styles } = useStyles(stylesheet);
7174
const router = useRouter();
7275
const chain = asChain(token);
7376

@@ -90,7 +93,7 @@ function TokenScreen_() {
9093
const iconValid = !!tryOrIgnore(() => icon && new URL(icon));
9194

9295
return (
93-
<>
96+
<Pane flex>
9497
<AppbarOptions
9598
headline="Token"
9699
{...(query.token?.userOwned && {
@@ -110,19 +113,23 @@ function TokenScreen_() {
110113
})}
111114
/>
112115

113-
<ScrollableScreenSurface contentContainerStyle={styles.sheet}>
114-
<ListItem
115-
leading={
116-
icon && iconValid ? (
117-
<Image source={[{ uri: icon }]} style={styles.icon} />
118-
) : (
119-
GenericTokenIcon
120-
)
121-
}
122-
headline={`${name || 'Token'} (${symbol || 'TKN'})`}
123-
supporting={asAddress(token)}
124-
trailing={CHAINS[chain].name}
125-
/>
116+
<Scrollable contentContainerStyle={styles.sheet}>
117+
<ItemList>
118+
<ListItem
119+
leading={
120+
icon && iconValid ? (
121+
<Image source={[{ uri: icon }]} style={styles.icon} />
122+
) : (
123+
GenericTokenIcon
124+
)
125+
}
126+
headline={`${name || 'Token'} (${symbol || 'TKN'})`}
127+
supporting={asAddress(token)}
128+
trailing={CHAINS[chain].name}
129+
containerStyle={styles.item}
130+
/>
131+
</ItemList>
132+
126133
<View style={styles.fields}>
127134
<FormTextField label="Name" name="name" placeholder="Token name" control={control} />
128135

@@ -167,15 +174,18 @@ function TokenScreen_() {
167174
{query.token ? 'Update' : 'Add'}
168175
</FormSubmitButton>
169176
</Actions>
170-
</ScrollableScreenSurface>
171-
</>
177+
</Scrollable>
178+
</Pane>
172179
);
173180
}
174181

175-
const styles = createStyles({
182+
const stylesheet = createStyles(({ colors }) => ({
176183
sheet: {
177184
paddingTop: 8,
178185
},
186+
item: {
187+
backgroundColor: colors.surface,
188+
},
179189
fields: {
180190
marginVertical: 16,
181191
marginHorizontal: 16,
@@ -185,7 +195,7 @@ const styles = createStyles({
185195
width: ICON_SIZE.medium,
186196
height: ICON_SIZE.medium,
187197
},
188-
});
198+
}));
189199

190200
export default withSuspense(TokenScreen_, <ScreenSkeleton />);
191201

0 commit comments

Comments
 (0)