Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: gnoboard: Resolve ts:check errors, put in Makefile #182

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/js/expo/gnoboard/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ go_service_files := $(shell find $(PROJECT_DIR)/service -iname '*.go')
go_files := $(go_framework_files) $(go_service_files)
go_deps := $(PROJECT_DIR)/go.mod $(PROJECT_DIR)/go.sum $(go_files)

ts_check:
npm run ts:check

# - Node: Handle node_modules

node_modules: package.json package-lock.json
node_modules: ts_check package.json package-lock.json
$(call check-program, npm)
(npm install && touch $@) || true
.PHONY: node_modules
Expand Down
1 change: 1 addition & 0 deletions examples/js/expo/gnoboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lint:fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx,json}'",
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc",
"storybook-generate": "sb-rn-get-stories",
"ts:check": "tsc",
"storybook-watch": "sb-rn-watcher"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,24 @@ export default {
};

export const Basic = () => {
// This callback isn't used by the storybook
const onNetworkChange = async () => {}
return (
<>
<NetworkList networkMetainfos={chains} currentNetworkId='test3' />
<NetworkList networkMetainfos={chains} currentChainId='test3' onNetworkChange={onNetworkChange} />
</>
);
};

export const ListItem = ({ networkMetainfo }: Props) => {
// This callback isn't used by the storybook
const onPress = async () => {}
return (
<>
<Spacer />
<NetworkListItem networkMetainfo={networkMetainfo} currentNetworkId={undefined} />
<NetworkListItem networkMetainfo={networkMetainfo} currentChainId={undefined} onPress={onPress} />
<Spacer />
<NetworkListItem networkMetainfo={networkMetainfo} currentNetworkId={'test3'} />
<NetworkListItem networkMetainfo={networkMetainfo} currentChainId={'test3'} onPress={onPress} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Button from '@gno/components/buttons';
import { Spacer } from '@gno/components/row';
import { GnoAccount } from '@gno/native_modules/types';
import { KeyInfo } from '@gnolang/gnonative';

interface SideMenuAccountItemProps {
account: GnoAccount;
changeAccount: (account: GnoAccount) => void;
account: KeyInfo;
changeAccount: (account: KeyInfo) => void;
}

const SideMenuAccountItem = (props: SideMenuAccountItemProps) => {
Expand Down
14 changes: 8 additions & 6 deletions examples/js/expo/gnoboard/src/screens/devmode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ function DevMode() {
console.log('response: ', response);
setAppConsole(Buffer.from(response.result).toString());
}
} catch (error: ConnectError | unknown) {
const err = new GRPCError(error);
if (err.errCode() === ErrCode.ErrDecryptionFailed) {
const account = await gnonative.getActiveAccount();
setReenterPassword(account.key?.name);
return;
} catch (error) {
if (error instanceof ConnectError) {
const err = new GRPCError(error);
if (err.errCode() === ErrCode.ErrDecryptionFailed) {
const account = await gnonative.getActiveAccount();
setReenterPassword(account.key?.name);
return;
}
}
console.log(error);
setAppConsole('error' + JSON.stringify(error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Text from '@gno/components/texts';
import { ErrCode, GRPCError, useGnoNativeContext } from '@gnolang/gnonative';
import { useState } from 'react';
import { Modal as NativeModal } from 'react-native';
import { ConnectError } from '@connectrpc/connect';

export type Props = {
visible: boolean;
Expand All @@ -27,12 +28,14 @@ const ReenterPassword = ({ visible, accountName, onClose }: Props) => {
await gnonative.setPassword(password);
onClose(true);
} catch (error) {
const err = new GRPCError(error);
if (err.errCode() === ErrCode.ErrDecryptionFailed) {
setError('Wrong password, please try again.');
} else {
setError(JSON.stringify(error));
if (error instanceof ConnectError) {
const err = new GRPCError(error);
if (err.errCode() === ErrCode.ErrDecryptionFailed) {
setError('Wrong password, please try again.');
return;
}
}
setError(JSON.stringify(error));
}
};

Expand Down
10 changes: 6 additions & 4 deletions examples/js/expo/gnoboard/src/screens/wallet/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export const Home: React.FC = () => {
const balance = await gnonative.queryAccount(response.key.address);
setBalance(balance);
}
} catch (error: ConnectError | unknown) {
const err = new GRPCError(error);
if (err.errCode() === ErrCode.ErrNoActiveAccount) {
setUnknownAddress(true);
} catch (error) {
if (error instanceof ConnectError) {
const err = new GRPCError(error);
if (err.errCode() === ErrCode.ErrNoActiveAccount) {
setUnknownAddress(true);
}
}
} finally {
setLoading(undefined);
Expand Down