diff --git a/README.md b/README.md index de313b7..08c9426 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,21 @@ With the simapp process running, run these commands in another window: npm install npm run dev ``` + +### Protobuf + +Prerequisite: [protoc](https://protobuf.dev/installation/) + +Run following scripts when [proto files](./proto/) are updated. + +- Install dependencies: + + ```bash + yarn + ``` + +- Generate typescript bindings for the proto files: + + ```bash + ./scripts/protocgen.sh + ``` diff --git a/components/dataViews/BalancesTable.tsx b/components/dataViews/BalancesTable.tsx index ee479df..658a247 100644 --- a/components/dataViews/BalancesTable.tsx +++ b/components/dataViews/BalancesTable.tsx @@ -2,7 +2,7 @@ import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table"; import { printableCoin, thinSpace } from "@/lib/displayHelpers"; import { toastError } from "@/lib/utils"; import { Coin } from "@cosmjs/amino"; -import { accountFromAny, SigningZenithClient } from "@/utils/account"; +import { accountFromAny, SigningZenithClient } from "@/utils/cosmos-client.ts"; import { useEffect, useState } from "react"; import { useChains } from "../../context/ChainsContext"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; diff --git a/components/dataViews/ListMultisigTxs.tsx b/components/dataViews/ListMultisigTxs.tsx index 47a5596..80776c0 100644 --- a/components/dataViews/ListMultisigTxs.tsx +++ b/components/dataViews/ListMultisigTxs.tsx @@ -8,7 +8,7 @@ import { msgTypeCountsFromJson } from "@/lib/txMsgHelpers"; import { cn, toastError } from "@/lib/utils"; import { WalletInfo } from "@/types/signing"; import { toBase64 } from "@cosmjs/encoding"; -import { accountFromAny, SigningZenithClient } from "@/utils/account"; +import { accountFromAny, SigningZenithClient } from "@/utils/cosmos-client.ts"; import { Loader2, MoveRightIcon } from "lucide-react"; import Image from "next/image"; import Link from "next/link"; diff --git a/components/dataViews/ListUserMultisigs.tsx b/components/dataViews/ListUserMultisigs.tsx index d627140..da2ea80 100644 --- a/components/dataViews/ListUserMultisigs.tsx +++ b/components/dataViews/ListUserMultisigs.tsx @@ -6,7 +6,7 @@ import { toastError } from "@/lib/utils"; import { WalletInfo } from "@/types/signing"; import { MultisigThresholdPubkey } from "@cosmjs/amino"; import { toBase64 } from "@cosmjs/encoding"; -import { accountFromAny, SigningZenithClient } from "@/utils/account"; +import { accountFromAny, SigningZenithClient } from "@/utils/cosmos-client.ts"; import { Loader2, MoveRightIcon } from "lucide-react"; import Image from "next/image"; import Link from "next/link"; diff --git a/components/forms/CreateMultisigForm/formSchema.ts b/components/forms/CreateMultisigForm/formSchema.ts index 84f0d5e..212c3d5 100644 --- a/components/forms/CreateMultisigForm/formSchema.ts +++ b/components/forms/CreateMultisigForm/formSchema.ts @@ -2,7 +2,7 @@ import { ChainInfo } from "@/context/ChainsContext/types"; import { pubkeyToAddress } from "@cosmjs/amino"; import { z } from "zod"; import { checkAddressOrPubkey } from "../../../lib/displayHelpers"; -import { accountFromAny, SigningZenithClient } from "@/utils/account"; +import { accountFromAny, SigningZenithClient } from "@/utils/cosmos-client.ts"; export const getCreateMultisigSchema = (chain: ChainInfo) => z @@ -26,13 +26,13 @@ export const getCreateMultisigSchema = (chain: ChainInfo) => const address = member.startsWith(chain.addressPrefix) ? member : pubkeyToAddress( - { type: "tendermint/PubKeySecp256k1", value: member }, - chain.addressPrefix, - ); + { type: "tendermint/PubKeySecp256k1", value: member }, + chain.addressPrefix, + ); - const client = await SigningZenithClient.connect(chain.nodeAddress, { - accountParser: accountFromAny - }); + const client = await SigningZenithClient.connect(chain.nodeAddress, { + accountParser: accountFromAny + }); const accountOnChain = await client.getAccount(address); @@ -81,7 +81,7 @@ export const getCreateMultisigSchema = (chain: ChainInfo) => ); return address; - } catch {} + } catch { } } return member; @@ -125,9 +125,8 @@ export const getCreateMultisigSchema = (chain: ChainInfo) => .refine( ({ members, threshold }) => threshold <= members.filter(({ member }) => member !== "").length, ({ members }) => ({ - message: `Threshold can't be higher than the number of members (${ - members.filter(({ member }) => member !== "").length - })`, + message: `Threshold can't be higher than the number of members (${members.filter(({ member }) => member !== "").length + })`, path: ["threshold"], }), ); diff --git a/components/forms/CreateMultisigForm/index.tsx b/components/forms/CreateMultisigForm/index.tsx index afe4946..7fdeccf 100644 --- a/components/forms/CreateMultisigForm/index.tsx +++ b/components/forms/CreateMultisigForm/index.tsx @@ -21,7 +21,7 @@ import { createMultisigFromCompressedSecp256k1Pubkeys } from "../../../lib/multi import ConfirmCreateMultisig from "./ConfirmCreateMultisig"; import MemberFormField from "./MemberFormField"; import { getCreateMultisigSchema } from "./formSchema"; -import { accountFromAny, SigningZenithClient } from "@/utils/account"; +import { accountFromAny, SigningZenithClient } from "@/utils/cosmos-client.ts"; export default function CreateMultisigForm() { const router = useRouter(); diff --git a/components/forms/FindMultisigForm.tsx b/components/forms/FindMultisigForm.tsx index 4c581a3..8b18e02 100644 --- a/components/forms/FindMultisigForm.tsx +++ b/components/forms/FindMultisigForm.tsx @@ -11,7 +11,7 @@ import { import { Input } from "@/components/ui/input"; import { ChainInfo } from "@/context/ChainsContext/types"; import { zodResolver } from "@hookform/resolvers/zod"; -import { accountFromAny, SigningZenithClient } from "@/utils/account"; +import { accountFromAny, SigningZenithClient } from "@/utils/cosmos-client.ts"; import Link from "next/link"; import { NextRouter, withRouter } from "next/router"; import { useForm } from "react-hook-form"; diff --git a/context/ChainsContext/service.tsx b/context/ChainsContext/service.tsx index 92f3458..3a2a0a9 100644 --- a/context/ChainsContext/service.tsx +++ b/context/ChainsContext/service.tsx @@ -13,7 +13,7 @@ import { setShaInStorage, } from "./storage"; import { ChainItems } from "./types"; -import { SigningZenithClient } from "@/utils/account"; +import { SigningZenithClient } from "@/utils/cosmos-client.ts"; export const useChainsFromRegistry = () => { const [chainItems, setChainItems] = useState({ diff --git a/lib/multisigHelpers.ts b/lib/multisigHelpers.ts index 552fc58..7877ff7 100644 --- a/lib/multisigHelpers.ts +++ b/lib/multisigHelpers.ts @@ -6,7 +6,7 @@ import { pubkeyToAddress, } from "@cosmjs/amino"; import { Account, StargateClient } from "@cosmjs/stargate"; -import { SigningZenithClient } from "@/utils/account"; +import { SigningZenithClient } from "@/utils/cosmos-client.ts"; import { createDbMultisig, getDbMultisig } from "./api"; import { checkAddress, explorerLinkAccount } from "./displayHelpers"; diff --git a/pages/[chainName]/[address]/transaction/[transactionID].tsx b/pages/[chainName]/[address]/transaction/[transactionID].tsx index e3e926a..05448c0 100644 --- a/pages/[chainName]/[address]/transaction/[transactionID].tsx +++ b/pages/[chainName]/[address]/transaction/[transactionID].tsx @@ -7,7 +7,7 @@ import { MultisigThresholdPubkey } from "@cosmjs/amino"; import { fromBase64 } from "@cosmjs/encoding"; import { Account, makeMultisignedTxBytes } from "@cosmjs/stargate"; import { assert } from "@cosmjs/utils"; -import { SigningZenithClient } from "@/utils/account"; +import { SigningZenithClient } from "@/utils/cosmos-client.ts"; import { GetServerSideProps } from "next"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; diff --git a/pages/api/chain/[chainId]/multisig/list/index.ts b/pages/api/chain/[chainId]/multisig/list/index.ts index 42079b2..4df80a3 100644 --- a/pages/api/chain/[chainId]/multisig/list/index.ts +++ b/pages/api/chain/[chainId]/multisig/list/index.ts @@ -2,7 +2,7 @@ import { getBelongedMultisigs, getCreatedMultisigs } from "@/graphql/multisig"; import { getNonce, incrementNonce } from "@/graphql/nonce"; import { GetDbMultisigTxsBody } from "@/lib/api"; import { verifyKeplrSignature } from "@/lib/keplr"; -import { SigningZenithClient } from "@/utils/account"; +import { SigningZenithClient } from "@/utils/cosmos-client.ts"; import { decodeSignature, pubkeyToAddress } from "@cosmjs/amino"; import { toBase64 } from "@cosmjs/encoding"; import type { NextApiRequest, NextApiResponse } from "next"; diff --git a/pages/api/transaction/list/index.ts b/pages/api/transaction/list/index.ts index 40299df..c41531a 100644 --- a/pages/api/transaction/list/index.ts +++ b/pages/api/transaction/list/index.ts @@ -3,7 +3,7 @@ import { getNonce, incrementNonce } from "@/graphql/nonce"; import { getTransactions } from "@/graphql/transaction"; import { GetDbMultisigTxsBody } from "@/lib/api"; import { verifyKeplrSignature } from "@/lib/keplr"; -import { SigningZenithClient } from "@/utils/account"; +import { SigningZenithClient } from "@/utils/cosmos-client.ts"; import { decodeSignature, pubkeyToAddress } from "@cosmjs/amino"; import { toBase64 } from "@cosmjs/encoding"; import type { NextApiRequest, NextApiResponse } from "next"; diff --git a/utils/account.ts b/utils/cosmos-client.ts.ts similarity index 100% rename from utils/account.ts rename to utils/cosmos-client.ts.ts