Skip to content

Commit

Permalink
chore: Resolve ts:check errors, put in Makefile (#132)
Browse files Browse the repository at this point in the history
* chore: Add @ts-ignore for process.env values. See the PR.

Signed-off-by: Jeff Thompson <[email protected]>

* chore: In types.ts, add NetworkMetainfo and GnoAccount. Fix imports. See the PR.

Signed-off-by: Jeff Thompson <[email protected]>

* chore: In transport_web, ignore ts:check errors for declaration file in imported modules

Signed-off-by: Jeff Thompson <[email protected]>

* chore: In transport_web forEach, declare "any" type of key, value to make ts:check happy

Signed-off-by: Jeff Thompson <[email protected]>

* chore: In Makefile, add target ts_check. Use it to make node_modules. See the PR.

Signed-off-by: Jeff Thompson <[email protected]>

---------

Signed-off-by: Jeff Thompson <[email protected]>
  • Loading branch information
jefft0 authored Sep 24, 2024
1 parent 1f0b034 commit 33cdfc4
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 7 deletions.
5 changes: 4 additions & 1 deletion mobile/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
check-program = $(foreach exec,$(1),$(if $(shell PATH="$(PATH)" which $(exec)),,$(error "Missing deps: no '$(exec)' in PATH")))
check-file = $(foreach file,$(1),$(if $(wildcard $(file)),,$(error "Missing file: $(file)")))

node_modules: package.json package-lock.json
ts_check:
npm run ts:check

node_modules: ts_check package.json package-lock.json
$(call check-program, npm)
(npm install && touch $@) || true
.PHONY: node_modules
Expand Down
4 changes: 4 additions & 0 deletions mobile/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ import { NotificationProvider } from "@gno/provider/notification-provider";
import { ReduxProvider } from "redux/redux-provider";

const gnoDefaultConfig = {
// @ts-ignore
remote: process.env.EXPO_PUBLIC_GNO_REMOTE!,
// @ts-ignore
chain_id: process.env.EXPO_PUBLIC_GNO_CHAIN_ID!,
};

const indexerDefaultConfig = {
// @ts-ignore
remote: process.env.EXPO_PUBLIC_INDEXER_REMOTE!,
};

const notificationDefaultConfig = {
// @ts-ignore
remote: process.env.EXPO_PUBLIC_NOTIFICATION_REMOTE!,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Icons from '@gno/components/icons';
import Text from '@gno/components/text';
import { colors } from '@gno/styles/colors';
import { NetworkMetainfo } from '@gnolang/gnonative/build/hooks/types';
import { NetworkMetainfo } from "@gno/types";
import styled from 'styled-components/native';

export interface Props {
Expand Down
2 changes: 1 addition & 1 deletion mobile/components/change-network/network-list/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NetworkListItem from "../network-list-item";
import styled from "styled-components/native";
import Text from "components/text";
import { NetworkMetainfo } from "@gnolang/gnonative/build/hooks/types";
import { NetworkMetainfo } from "@gno/types";

interface Props {
currentChainId: string | undefined;
Expand Down
2 changes: 1 addition & 1 deletion mobile/components/feed/post-row.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Image, Pressable, StyleSheet, View } from "react-native";
import { Post } from "../../types";
import { Post } from "@gno/types";
import Text from "@gno/components/text";
import RepliesLabel from "./replies-label";
import TimeStampLabel from "./timestamp-label";
Expand Down
2 changes: 1 addition & 1 deletion mobile/components/feed/repost-row.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Image, Pressable, StyleSheet, View } from "react-native";
import { Post } from "../../types";
import { Post } from "@gno/types";
import Text from "@gno/components/text";
import RepliesLabel from "./replies-label";
import TimeStampLabel from "./timestamp-label";
Expand Down
3 changes: 2 additions & 1 deletion mobile/components/list/account/account-item.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Button from "@gno/components/button";
import Spacer from "@gno/components/spacer";
import { GnoAccount } from "@gnolang/gnonative/build/hooks/types";
import { GnoAccount } from "@gno/types";


interface SideMenuAccountItemProps {
account: GnoAccount;
Expand Down
1 change: 1 addition & 0 deletions mobile/redux/features/signupSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ const sendCoins = async (address: string) => {
reactNative: { textStreaming: true },
};

// @ts-ignore
const faucetRemote = process.env.EXPO_PUBLIC_FAUCET_REMOTE;
if (!faucetRemote) {
throw new Error("faucet remote address is undefined");
Expand Down
4 changes: 3 additions & 1 deletion mobile/src/grpc/transport_web.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-ignore
import { polyfill as polyfillReadableStream } from "react-native-polyfill-globals/src/readable-stream";
polyfillReadableStream();
// @ts-ignore
import { fetch as fetchPolyfill, Headers as HeadersPolyfill } from "react-native-fetch-api";

import type { AnyMessage, MethodInfo, PartialMessage, ServiceType } from "@bufbuild/protobuf";
Expand Down Expand Up @@ -241,7 +243,7 @@ export function createXHRGrpcWebTransport(options: GrpcWebTransportOptions): Tra
throw endStream.error;
}

endStream.metadata.forEach((value, key) => trailerTarget.set(key, value));
endStream.metadata.forEach((value:any, key:any) => trailerTarget.set(key, value));
continue;
}

Expand Down
18 changes: 18 additions & 0 deletions mobile/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ export interface GetJsonFollowingResult {
following: Following[];
n_following: number;
}

export type GnoConfig = {
Remote: string;
ChainID: string;
KeyName: string;
Password: string;
GasFee: string;
GasWanted: bigint;
Mnemonic: string;
};

export type NetworkMetainfo = {
chainId: string;
chainName: string;
gnoAddress: string;
};

export type GnoAccount = KeyInfo;

0 comments on commit 33cdfc4

Please sign in to comment.