Skip to content

Commit

Permalink
Merge branch 'main' into fix/android-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
sakul-budhathoki authored Mar 30, 2024
2 parents 0f649ff + 426db3a commit 81d58bc
Show file tree
Hide file tree
Showing 20 changed files with 934 additions and 135 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ SUBSTREAMS_API_TOKEN=<get_from_substream_site>
EXPO_PUBLIC_IMG_PROXY_URL=https://imgproxy.tools.teritori.com/insecure/
EXPO_PUBLIC_PUBLIC_TENOR_KEY=AIzaSyA8TpVfoyoBaDdLww6wJ1Xe0OVN-Hi8qPE

#map token
EXPO_PUBLIC_LEAFLET_MAP_TOKEN=QkwJFLzzxPan25YCgnDExGpMFPxA3x4lnyKiUf8zmaqXLP5XyOR8n3yEM8jlKV3W

# MULTISIG_BACKEND_URL=http://localhost:9091 # you can use this for local testing
69 changes: 47 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# Contributing
# Contributing 🤝

## Contributor guidelines
## Contributor guidelines 📝

### Core contributor loop
### Core contributor loop 🔁

- Check the [list of PRs that need review](https://github.com/TERITORI/teritori-dapp/pulls?q=is%3Apr+is%3Aopen+review%3Arequired+draft%3Afalse+) and review relevant PRs, see [Reviewing a PR](#reviewing-a-pr)
- Check your [assigned PRs that require changes](https://github.com/TERITORI/teritori-dapp/pulls?q=is%3Apr+is%3Aopen+review%3Achanges_requested+draft%3Afalse+assignee%3A%40me+) and address the reviews
- Make sure you have self-reviewed your existing PRs and the CI passes on them, see [Reviewing a PR](#reviewing-a-pr)
- Continue on your assigned tasks
- If you have nothing to do at this point, ask for a new task
- Check the [list of PRs that need review](https://github.com/TERITORI/teritori-dapp/pulls?q=is%3Apr+is%3Aopen+review%3Arequired+draft%3Afalse+) and review relevant PRs, see [Reviewing a PR](#reviewing-a-pr)
- 🛠️ Check your [assigned PRs that require changes](https://github.com/TERITORI/teritori-dapp/pulls?q=is%3Apr+is%3Aopen+review%3Achanges_requested+draft%3Afalse+assignee%3A%40me+) and address the reviews
- 🔍 Make sure you have self-reviewed your existing PRs and the CI passes on them, see [Reviewing a PR](#reviewing-a-pr)
- 🚀 Continue on your assigned tasks
- 🆕 If you have nothing to do at this point, ask for a new task

For all tasks, create a PR as soon as possible to make other mates aware of your work and to prevent you from going in a bad direction
For all tasks, create a PR as soon as possible to make other mates aware of your work and to prevent you from going in a bad direction 🔄

### Creating a PR
### Creating a PR

- Make sure the branch name is lowercase, git will automatically lowercase the branch name is some environment and branch names with uppercase characters are a pain to manage.
- We recommend NOT to use the `/` character in branch names since it's the syntax for specifying a remote branch with `<remote>/<branch>` like `origin/main` and can be confusing
- We recommend working with the [git cli](https://git-scm.com/docs/git) and not github tools except to review diffs.
- Make sure the PR's title follows [the conventional commits standard](https://www.conventionalcommits.org/en/v1.0.0/) as it will be used as the squashed commit title on main
- Make sure your are assigned to the PR, this helps you to know [which PRs require your attention](https://github.com/TERITORI/teritori-dapp/pulls?q=is%3Apr+is%3Aopen+assignee%3A%40me)
- Try to keep the PR [atomic](https://fagnerbrack.com/one-pull-request-one-concern-e84a27dfe9f1), it will be merged faster and benefit all your mates
- Self-review the changes and pass CI before asking for other peoples reviews, see [Reviewing a PR](#reviewing-a-pr)
- 🔤 Make sure the branch name is lowercase, git will automatically lowercase the branch name is some environment and branch names with uppercase characters are a pain to manage.
- We recommend NOT to use the `/` character in branch names since it's the syntax for specifying a remote branch with `<remote>/<branch>` like `origin/main` and can be confusing
- 💻 We recommend working with the [git cli](https://git-scm.com/docs/git) and not GitHub tools except to review diffs.
- 📝 Make sure the PR's title follows [the conventional commits standard](https://www.conventionalcommits.org/en/v1.0.0/) as it will be used as the squashed commit title on main
- 👤 Make sure you are assigned to the PR, this helps you to know [which PRs require your attention](https://github.com/TERITORI/teritori-dapp/pulls?q=is%3Apr+is%3Aopen+assignee%3A%40me)
- 📊 Try to keep the PR [atomic](https://fagnerbrack.com/one-pull-request-one-concern-e84a27dfe9f1), it will be merged faster and benefit all your mates
- 🔎 Self-review the changes and pass CI before asking for other people's reviews, see [Reviewing a PR](#reviewing-a-pr)

### Reviewing a PR
### Reviewing a PR 👀

- Read and understand all changes
- 📖 Read and understand all changes

You can use the GitHub diff and mark each file as viewed, this will help in subsequent reviews as unchanged files will keep the "Viewed" status

<img width="448" alt="Screenshot 2024-03-21 at 20 01 38" src="https://github.com/TERITORI/teritori-dapp/assets/7917064/6141fdd3-2746-498d-916f-9945a56c7ff0">

- Test
- 🧪 Test

Check that the feature works or the bug is fixed

If there is changes in code used at other places, test for regressions in affected features
If there are changes in code used at other places, test for regressions in affected features

If the PR is not atomic enough and makes reviewing hard, you can ask the author to split it

Expand Down Expand Up @@ -115,7 +115,7 @@ The Cosmos SDK itself is written in golang.

#### Protocol for extra services: GRPC

We use [GRPC](https://grpc.io/) as communication protocol for the centralized APIs. The models and endpoints definition are written in [protobuf](https://protobuf.dev/), this allows to generate types, servers and clients in any language. The definition are in the [api folder](api). The backend servers in the [go/pkg folder](go/pkg). The clients in the [js/packages/api folder](js/packages/api).
We use [GRPC](https://grpc.io/) as communication protocol for the centralized APIs. The models and endpoints definition are written in [protobuf](https://protobuf.dev/), this allows to generate types, servers and clients in any language. The definition are in the [api folder](api). The backend servers in the [go/pkg folder](go/pkg). The clients in the [packages/api folder](packages/api).

The Cosmos SDK is also using protobuf for it's endpoints definition but with custom encodings and extra layers on top of it.

Expand All @@ -125,6 +125,31 @@ We plan to transition from Cosmos SDK to [Gno](https://docs.gno.land/) for the b

## Patterns

### Comments in code
- Do you really need a comment? Using [meaningful names](https://workat.tech/machine-coding/tutorial/writing-meaningful-variable-names-clean-code-za4m83tiesy0) and low [cognitive complexity](https://www.sonarsource.com/docs/CognitiveComplexity.pdf) is very often enough to make the code understandable without comments. Comments are not validated by CI and can/will become outdated without notice.
- Don't push commented-out code, remove it! See [this article](https://methodpoet.com/commented-out-code/) for a deeper explanation.
- Add comments to explain the intent of code if it's not obvious. A good example is when adding a hack to work around an upstream issue, adding a comment linking to the upstream issue is very meaningful there. When maintainers revisit this code they can understand why this "weird" bit of code is here and easily check if the issue is resolved.
- Add comments to signal areas of improvement you think of but can't put in current scope ("TODO:"s and "FIXME:"s).

```typescript
// bad

// get index for current elem from deep thought
let k = s.gi(x)
// add 42
k += 42
// do something with index
cb(k)
```

```typescript
// good

let index = deepThought.getIndex(elem)
index += 42 // we need this hack due to a bug in DeepThought initialization, see https://github.com/deepthought/core/issues/21. TODO: remove this line when resolved upstream
doSomethingWithIndex(index)
```

### Continuous Integration (CI)

- Our project uses a CI pipeline to automatically build, test, and validate every pull request. This helps to ensure that all changes integrate smoothly and do not introduce new issues.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ Please feel free to use PR & Issues, and to join us on Discord for any question!

___

Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([`LICENSE-APACHE`](LICENSE-APACHE)) or the [MIT license](https://opensource.org/licenses/MIT) ([`LICENSE-MIT`](LICENSE-MIT)), at your discretion. See the [`COPYRIGHT`](COPYRIGHT) file for more details.
Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) or the [MIT license](https://opensource.org/licenses/MIT), at your discretion.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@reduxjs/toolkit": "^1.8.3",
"@solana/web3.js": "^1.87.6",
"@tanstack/react-query": "^4.12.0",
"@types/leaflet": "^1.9.8",
"assert": "^2.1.0",
"axios": "^1.6.2",
"bech32": "^2.0.0",
Expand Down Expand Up @@ -94,14 +95,17 @@
"expo-sharing": "~11.10.0",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"glob": "^10.3.10",
"google-protobuf": "^3.21.2",
"html-to-draftjs": "^1.5.0",
"immutable": "^4.0.0",
"kubernetes-models": "^4.3.1",
"leaflet": "^1.9.4",
"listr2": "^8.0.1",
"lodash": "^4.17.21",
"long": "^5.2.1",
"lottie-react-native": "6.5.1",
"markdown-it": "^14.1.0",
"metamask-react": "^2.4.1",
"moment": "^2.29.4",
"multiformats": "^12.1.3",
Expand All @@ -111,6 +115,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.50.1",
"react-leaflet": "^4.2.1",
"react-native": "0.73.6",
"react-native-click-outside": "^0.1.1",
"react-native-confetti-cannon": "^1.5.2",
Expand All @@ -122,6 +127,7 @@
"react-native-heroicons": "^3.2.0",
"react-native-image-picker": "^7.1.0",
"react-native-keyboard-aware-scrollview": "^2.1.0",
"react-native-leaflet-view": "^0.1.2",
"react-native-paper": "^4.12.5",
"react-native-pell-rich-editor": "^1.8.8",
"react-native-pie-chart": "^3.0.1",
Expand Down Expand Up @@ -169,6 +175,7 @@
"@types/draft-convert": "^2.1.4",
"@types/draft-js": "^0.11.9",
"@types/html-to-draftjs": "^1.4.0",
"@types/markdown-it": "^13.0.7",
"@types/node": "^20.9.1",
"@types/react": "~18.2.45",
"@types/react-native-countdown-component": "^2.7.0",
Expand Down
146 changes: 75 additions & 71 deletions packages/components/modals/ModalBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
ViewStyle,
useWindowDimensions,
StyleProp,
TouchableOpacity,
} from "react-native";
import { TouchableOpacity } from "react-native-gesture-handler";
import { useSafeAreaInsets } from "react-native-safe-area-context";

import chevronLeft from "../../../assets/icons/chevron-left.svg";
Expand All @@ -32,14 +32,15 @@ import { useAppNavigation } from "@/hooks/navigation/useAppNavigation";

// TODO: Simplify this component (Useless childrenBottom ?. Better to let the parent totally decides which children to use ? Used in WalletManager.tsx, be careful !)

type ModalBaseProps = {
export type ModalBaseProps = {
label?: string;
labelComponent?: ReactNode;
onClose?: () => void;
onBackPress?: () => void;
width?: number;
visible?: boolean;
Header?: ComponentType;
hideHeader?: boolean;
childrenBottom?: JSX.Element | JSX.Element[];
hideMainSeparator?: boolean;
description?: string;
Expand Down Expand Up @@ -78,6 +79,7 @@ const ModalBase: React.FC<ModalBaseProps> = ({
childrenBottom,
children,
Header,
hideHeader = false,
hideMainSeparator,
description,
scrollable,
Expand Down Expand Up @@ -160,81 +162,83 @@ const ModalBase: React.FC<ModalBaseProps> = ({
]}
>
{/*------ Modal header */}
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
width: "100%",
paddingHorizontal: modalMarginPadding,
paddingVertical: layout.spacing_x2,
}}
>
{!!(label || labelComponent || description) && (
<View
style={{ flex: 1, flexDirection: "row", alignItems: "center" }}
>
{onBackPress && (
<TouchableOpacity
activeOpacity={0.9}
style={{
height: 32,
width: 32,
backgroundColor: neutral22,
borderRadius: 20,
alignItems: "center",
justifyContent: "center",
marginRight: 12,
}}
onPress={onBackPress}
>
<SVG source={chevronLeft} height={12} width={12} />
</TouchableOpacity>
)}

<View style={{ flex: 1, width: "100%" }}>
{!!label && (
<BrandText style={{ color: "white", lineHeight: 24 }}>
{label}
</BrandText>
{!hideHeader && (
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
width: "100%",
paddingHorizontal: modalMarginPadding,
paddingVertical: layout.spacing_x1_5,
}}
>
{(label || labelComponent || description) && (
<View
style={{
flex: 1,
flexDirection: "row",
alignItems: "center",
}}
>
{onBackPress && (
<TouchableOpacity
activeOpacity={0.9}
style={{
height: 32,
width: 32,
backgroundColor: neutral22,
borderRadius: 20,
alignItems: "center",
justifyContent: "center",
marginRight: layout.spacing_x1_5,
}}
onPress={onBackPress}
>
<SVG source={chevronLeft} height={12} width={12} />
</TouchableOpacity>
)}

{labelComponent}

{!!description && (
<>
<SpacerColumn size={1} />
<BrandText
style={[
fontSemibold14,
{
color: neutral77,
width: "100%",
lineHeight: 20,
flexWrap: "wrap",
},
]}
>
{description}
<View style={{ flex: 1, width: "100%" }}>
{!!label && (
<BrandText style={{ color: "white", lineHeight: 24 }}>
{label}
</BrandText>
</>
)}
)}

{labelComponent}

{!!description && (
<>
<SpacerColumn size={1} />
<BrandText
style={[
fontSemibold14,
{
color: neutral77,
width: "100%",
lineHeight: 20,
flexWrap: "wrap",
},
]}
>
{description}
</BrandText>
</>
)}
</View>
</View>
</View>
)}
)}

{!!Header && <Header />}
{!!Header && <Header />}

<TouchableOpacity
containerStyle={[
{ marginLeft: modalMarginPadding },
closeButtonStyle,
]}
style={{ justifyContent: "center" }}
onPress={onClose}
>
<SVG width={32} height={32} source={closeSVG} />
</TouchableOpacity>
</View>
<TouchableOpacity
style={{ justifyContent: "center" }}
onPress={onClose}
>
<SVG width={32} height={32} source={closeSVG} />
</TouchableOpacity>
</View>
)}
{!!children && (
<View
style={[
Expand Down
9 changes: 9 additions & 0 deletions packages/components/modals/ModalWithoutHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";

import ModalBase, { ModalBaseProps } from "./ModalBase";

interface ModalWithoutHeaderProps extends ModalBaseProps {}

export const ModalWithoutHeader: React.FC<ModalWithoutHeaderProps> = ({
...props
}) => <ModalBase hideHeader {...props} />;
Loading

0 comments on commit 81d58bc

Please sign in to comment.