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

fix: web3auth env. var. #126

Merged
merged 6 commits into from
Dec 13, 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
10 changes: 10 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NEXT_PUBLIC_WALLETCONNECT_KEY=test_walletconnect_key
NEXT_PUBLIC_WEB3AUTH_NETWORK=testnet
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=test_client_id
NEXT_PUBLIC_CHAIN=manifest
NEXT_PUBLIC_CHAIN_ID=test_chain_id
NEXT_PUBLIC_CHAIN_TIER=testnet
NEXT_PUBLIC_RPC_URL=https://test.rpc.url
NEXT_PUBLIC_API_URL=https://test.api.url
NEXT_PUBLIC_EXPLORER_URL=https://test.explorer.url
NEXT_PUBLIC_INDEXER_URL=https://test.indexer.url
18 changes: 7 additions & 11 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ jobs:
touch .env
echo "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" >> .env
echo "NEXT_PUBLIC_CHAIN_ID=${{ vars.NEXT_PUBLIC_CHAIN_ID }}" >> .env
echo "NEXT_PUBLIC_TESTNET_CHAIN_ID=${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }}" >> .env
echo "NEXT_PUBLIC_MAINNET_RPC_URL=${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }}" >> .env
echo "NEXT_PUBLIC_TESTNET_RPC_URL=${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }}" >> .env
echo "NEXT_PUBLIC_MAINNET_API_URL=${{ vars.NEXT_PUBLIC_MAINNET_API_URL }}" >> .env
echo "NEXT_PUBLIC_TESTNET_API_URL=${{ vars.NEXT_PUBLIC_TESTNET_API_URL }}" >> .env
echo "NEXT_PUBLIC_ABLY_API_KEY=${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }}" >> .env
echo "NEXT_PUBLIC_CHAIN_TIER=${{ vars.NEXT_PUBLIC_CHAIN_TIER }}" >> .env
echo "NEXT_PUBLIC_RPC_URL=${{ vars.NEXT_PUBLIC_RPC_URL }}" >> .env
echo "NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }}" >> .env
echo "NEXT_PUBLIC_WALLETCONNECT_KEY=${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }}" >> .env
echo "NEXT_PUBLIC_WEB3_CLIENT_ID=${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }}" >> .env
echo "NEXT_PUBLIC_TESTNET_EXPLORER_URL=${{ vars.NEXT_PUBLIC_TESTNET_EXPLORER_URL }}" >> .env
echo "NEXT_PUBLIC_MAINNET_EXPLORER_URL=${{ vars.NEXT_PUBLIC_MAINNET_EXPLORER_URL }}" >> .env
echo "NEXT_PUBLIC_TESTNET_INDEXER_URL=${{ vars.NEXT_PUBLIC_TESTNET_INDEXER_URL }}" >> .env
echo "NEXT_PUBLIC_MAINNET_INDEXER_URL=${{ vars.NEXT_PUBLIC_MAINNET_INDEXER_URL }}" >> .env
echo "NEXT_PUBLIC_WEB3AUTH_NETWORK=${{ vars.NEXT_PUBLIC_WEB3AUTH_NETWORK }}" >> .env
echo "NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=${{ secrets.NEXT_PUBLIC_WEB3AUTH_CLIENT_ID }}" >> .env
echo "NEXT_PUBLIC_EXPLORER_URL=${{ vars.NEXT_PUBLIC_EXPLORER_URL }}" >> .env
echo "NEXT_PUBLIC_INDEXER_URL=${{ vars.NEXT_PUBLIC_INDEXER_URL }}" >> .env
cat .env

- name: Get the Git tag
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*
!.env.test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove or mask sensitive test configuration in .env.test

The .env.test file contains a WalletConnect key configuration. Even though it's marked as a test key, it's recommended to:

  • Use placeholder values (e.g., NEXT_PUBLIC_WALLETCONNECT_KEY=dummy_key) instead of actual test credentials
  • Document the required format in a .env.example file instead
🔗 Analysis chain

Verify .env.test contents and security implications.

While tracking .env.test in version control is a common practice, please ensure:

  1. The file contains only non-sensitive test configuration
  2. No production credentials or keys are included
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check .env.test existence and content for sensitive data
if [ -f ".env.test" ]; then
    echo "Checking .env.test for potential sensitive data..."
    rg -i "key|secret|password|token|credential" .env.test
fi

Length of output: 243


# vercel
.vercel
Expand Down
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,30 @@ For more information on the Manifest Network and its modules, please visit the [

```
NEXT_PUBLIC_WALLETCONNECT_KEY=
NEXT_PUBLIC_WEB3_CLIENT_ID=
NEXT_PUBLIC_CHAIN=manifest
NEXT_PUBLIC_CHAIN_ID=manifest-1
NEXT_PUBLIC_TESTNET_CHAIN_ID=manifest-ledger-beta
NEXT_PUBLIC_MAINNET_RPC_URL=https://nodes.chandrastation.com/rpc/manifest/
NEXT_PUBLIC_TESTNET_RPC_URL=https://manifest-beta-rpc.liftedinit.tech/
NEXT_PUBLIC_MAINNET_API_URL=https://nodes.chandrastation.com/api/manifest/
NEXT_PUBLIC_TESTNET_API_URL=https://manifest-beta-rest.liftedinit.tech/
NEXT_PUBLIC_TESTNET_EXPLORER_URL=https://testnet.manifest.explorers.guru
NEXT_PUBLIC_MAINNET_EXPLORER_URL=https://manifest.explorers.guru
NEXT_PUBLIC_TESTNET_INDEXER_URL=https://testnet-indexer.liftedinit.tech
NEXT_PUBLIC_MAINNET_INDEXER_URL=https://indexer.liftedinit.app
NEXT_PUBLIC_WEB3AUTH_NETWORK=
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=
NEXT_PUBLIC_CHAIN=
NEXT_PUBLIC_CHAIN_ID=
NEXT_PUBLIC_CHAIN_TIER=
NEXT_PUBLIC_RPC_URL=
NEXT_PUBLIC_API_URL=
NEXT_PUBLIC_EXPLORER_URL=
NEXT_PUBLIC_INDEXER_URL=
```

where

- `NEXT_PUBLIC_WALLETCONNECT_KEY` is the WalletConnect key
- `NEXT_PUBLIC_WEB3AUTH_NETWORK` is the Web3Auth network to use for social login
- `NEXT_PUBLIC_WEB3AUTH_CLIENT_ID` is the Web3Auth client ID to use for social login
- `NEXT_PUBLIC_CHAIN` is the chain name
- `NEXT_PUBLIC_CHAIN_ID` is the chain ID
- `NEXT_PUBLIC_CHAIN_TIER` is the chain tier (e.g., `testnet`, `mainnet`)
- `NEXT_PUBLIC_RPC_URL` is the chain RPC URL
- `NEXT_PUBLIC_API_URL` is the chain API URL
- `NEXT_PUBLIC_EXPLORER_URL` is the block explorer URL
- `NEXT_PUBLIC_INDEXER_URL` is the YACI indexer URL

### Development

1. Start the server
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion bunfig.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[test]
preload = "./happydom.ts"
preload = "./setup.ts"
coverageSkipTestFiles = true
coverageReporter = ["text", "lcov"]
6 changes: 3 additions & 3 deletions components/admins/modals/cancelUpgradeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { cosmos } from '@liftedinit/manifestjs';
import { useFeeEstimation, useTx } from '@/hooks';
import { Any } from '@liftedinit/manifestjs/dist/codegen/google/protobuf/any';
import { chainName } from '@/config';
import { MsgCancelUpgrade } from '@liftedinit/manifestjs/dist/codegen/cosmos/upgrade/v1beta1/tx';
import { PlanSDKType } from '@liftedinit/manifestjs/dist/codegen/cosmos/upgrade/v1beta1/upgrade';
import env from '@/config/env';

interface BaseModalProps {
isOpen: boolean;
Expand Down Expand Up @@ -37,8 +37,8 @@
}: BaseModalProps) {
const { cancelUpgrade } = cosmos.upgrade.v1beta1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;
const { tx, isSigning, setIsSigning } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { tx, isSigning, setIsSigning } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);

Check warning on line 41 in components/admins/modals/cancelUpgradeModal.tsx

View check run for this annotation

Codecov / codecov/patch

components/admins/modals/cancelUpgradeModal.tsx#L40-L41

Added lines #L40 - L41 were not covered by tests

useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
Expand Down
6 changes: 3 additions & 3 deletions components/admins/modals/multiMfxBurnModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import { PlusIcon, MinusIcon } from '@/components/icons';
import { MdContacts } from 'react-icons/md';
import { useTx, useFeeEstimation } from '@/hooks';
import { chainName } from '@/config';
import { cosmos, liftedinit } from '@liftedinit/manifestjs';
import { Any } from '@liftedinit/manifestjs/dist/codegen/google/protobuf/any';

import { parseNumberToBigInt } from '@/utils';
import { MetadataSDKType } from '@liftedinit/manifestjs/dist/codegen/cosmos/bank/v1beta1/bank';
import { TailwindModal } from '@/components/react';
import env from '@/config/env';

interface BurnPair {
address: string;
Expand Down Expand Up @@ -48,8 +48,8 @@

export function MultiBurnModal({ isOpen, onClose, admin, address, denom }: MultiBurnModalProps) {
const [burnPairs, setBurnPairs] = useState([{ address: admin, amount: '' }]);
const { tx, isSigning, setIsSigning } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { tx, isSigning, setIsSigning } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);

Check warning on line 52 in components/admins/modals/multiMfxBurnModal.tsx

View check run for this annotation

Codecov / codecov/patch

components/admins/modals/multiMfxBurnModal.tsx#L51-L52

Added lines #L51 - L52 were not covered by tests
const { burnHeldBalance } = liftedinit.manifest.v1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;
const [isContactsOpen, setIsContactsOpen] = useState(false);
Expand Down
6 changes: 3 additions & 3 deletions components/admins/modals/multiMfxMintModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import { MdContacts } from 'react-icons/md';
import { PlusIcon, MinusIcon } from '@/components/icons';
import { useTx, useFeeEstimation } from '@/hooks';
import { chainName } from '@/config';
import { cosmos, liftedinit } from '@liftedinit/manifestjs';
import { Any } from '@liftedinit/manifestjs/dist/codegen/google/protobuf/any';
import { MsgPayout } from '@liftedinit/manifestjs/dist/codegen/liftedinit/manifest/v1/tx';
import { parseNumberToBigInt, shiftDigits } from '@/utils';
import { MetadataSDKType } from '@liftedinit/manifestjs/dist/codegen/cosmos/bank/v1beta1/bank';
import env from '@/config/env';
//TODO: find max mint amount from team for mfx. Find tx size limit for max payout pairs
interface PayoutPair {
address: string;
Expand Down Expand Up @@ -48,8 +48,8 @@

export function MultiMintModal({ isOpen, onClose, admin, address, denom }: MultiMintModalProps) {
const [payoutPairs, setPayoutPairs] = useState([{ address: '', amount: '' }]);
const { tx, isSigning, setIsSigning } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { tx, isSigning, setIsSigning } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);

Check warning on line 52 in components/admins/modals/multiMfxMintModal.tsx

View check run for this annotation

Codecov / codecov/patch

components/admins/modals/multiMfxMintModal.tsx#L51-L52

Added lines #L51 - L52 were not covered by tests
const { payout } = liftedinit.manifest.v1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;
const [isContactsOpen, setIsContactsOpen] = useState(false);
Expand Down
6 changes: 3 additions & 3 deletions components/admins/modals/upgradeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import { createPortal } from 'react-dom';
import { cosmos } from '@liftedinit/manifestjs';
import { useTx, useFeeEstimation, useGitHubReleases, GitHubRelease } from '@/hooks';
import { chainName } from '@/config';
import { Any } from '@liftedinit/manifestjs/dist/codegen/google/protobuf/any';
import { MsgSoftwareUpgrade } from '@liftedinit/manifestjs/dist/codegen/cosmos/upgrade/v1beta1/tx';
import { Formik, Form } from 'formik';
import Yup from '@/utils/yupExtensions';
import { TextInput } from '@/components/react/inputs';
import { PiCaretDownBold } from 'react-icons/pi';
import { SearchIcon } from '@/components/icons';
import env from '@/config/env';

interface BaseModalProps {
isOpen: boolean;
Expand Down Expand Up @@ -82,8 +82,8 @@

const { softwareUpgrade } = cosmos.upgrade.v1beta1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;
const { tx, isSigning, setIsSigning } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { tx, isSigning, setIsSigning } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);

Check warning on line 86 in components/admins/modals/upgradeModal.tsx

View check run for this annotation

Codecov / codecov/patch

components/admins/modals/upgradeModal.tsx#L85-L86

Added lines #L85 - L86 were not covered by tests

const handleUpgrade = async (values: { name: string; height: string; info: string }) => {
setIsSigning(true);
Expand Down
15 changes: 7 additions & 8 deletions components/admins/modals/validatorModal.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React, { useState, useEffect } from 'react';
import { TruncatedAddressWithCopy } from '@/components/react/addressCopy';
import { ExtendedValidatorSDKType } from '../components';
import { ExtendedValidatorSDKType } from '@/components';
import ProfileAvatar from '@/utils/identicon';
import { BsThreeDots } from 'react-icons/bs';
import { DescriptionModal } from './descriptionModal';
import { chainName } from '@/config';
import { useTx, useFeeEstimation } from '@/hooks';
import { strangelove_ventures } from '@liftedinit/manifestjs';
import { strangelove_ventures, cosmos } from '@liftedinit/manifestjs';
import { useChain } from '@cosmos-kit/react';
import { cosmos } from '@liftedinit/manifestjs';
import { Any } from '@liftedinit/manifestjs/dist/codegen/google/protobuf/any';
import { MsgSetPower } from '@liftedinit/manifestjs/dist/codegen/strangelove_ventures/poa/v1/tx';
import { Formik, Form, Field, ErrorMessage, FieldProps } from 'formik';
import { Formik, Field, FieldProps } from 'formik';
import * as Yup from 'yup';
import { calculateIsUnsafe } from '@/utils/maths';
import { TextInput } from '@/components/react';
import env from '@/config/env';
import { createPortal } from 'react-dom';

const PowerUpdateSchema = Yup.object().shape({
Expand Down Expand Up @@ -55,9 +54,9 @@ export function ValidatorDetailsModal({

const [power, setPowerInput] = useState(validator?.consensus_power?.toString() || '');

const { tx, isSigning, setIsSigning } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { address: userAddress } = useChain(chainName);
const { tx, isSigning, setIsSigning } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);
const { address: userAddress } = useChain(env.chain);

const { setPower } = strangelove_ventures.poa.v1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;
Expand Down
8 changes: 4 additions & 4 deletions components/admins/modals/warningModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { chainName } from '@/config';
import { useFeeEstimation, useTx } from '@/hooks';
import { cosmos, strangelove_ventures } from '@liftedinit/manifestjs';
import { Any } from '@liftedinit/manifestjs/dist/codegen/google/protobuf/any';
import { MsgRemoveValidator } from '@liftedinit/manifestjs/dist/codegen/strangelove_ventures/poa/v1/tx';
import { useChain } from '@cosmos-kit/react';
import React, { useEffect } from 'react';
import { PiWarning } from 'react-icons/pi';
import env from '@/config/env';
import { createPortal } from 'react-dom';

interface WarningModalProps {
Expand Down Expand Up @@ -38,9 +38,9 @@ export function WarningModal({
return () => document.removeEventListener('keydown', handleEscape);
}, [openWarningModal]);

const { tx, isSigning, setIsSigning } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { address: userAddress } = useChain(chainName);
const { tx, isSigning, setIsSigning } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);
const { address: userAddress } = useChain(env.chain);
const { removePending, removeValidator } =
strangelove_ventures.poa.v1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;
Expand Down
20 changes: 12 additions & 8 deletions components/bank/forms/ibcSendForm.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import React, { useState, useMemo } from 'react';
import { chainName } from '@/config';
import { useFeeEstimation, useTx } from '@/hooks';
import { ibc } from '@liftedinit/manifestjs';
import { getIbcInfo, parseNumberToBigInt } from '@/utils';
import {
getIbcInfo,
parseNumberToBigInt,
shiftDigits,
truncateString,
formatTokenDisplayName,
} from '@/utils';
import { PiCaretDownBold } from 'react-icons/pi';
import { MdContacts } from 'react-icons/md';
import { CombinedBalanceInfo } from '@/utils/types';
import { DenomImage } from '@/components/factory';
import { Formik, Form } from 'formik';
import Yup from '@/utils/yupExtensions';
import { TextInput } from '@/components/react/inputs';
import { IbcChain } from '../components/sendBox';
import { IbcChain } from '@/components';
import Image from 'next/image';
import { shiftDigits, truncateString } from '@/utils';
import { SearchIcon } from '@/components/icons';

import { TailwindModal } from '@/components/react/modal';
import { formatTokenDisplayName } from '@/utils';
import env from '@/config/env';

//TODO: use formatTokenDisplayName instead of repeating format
export default function IbcSendForm({
Expand Down Expand Up @@ -49,8 +53,8 @@
const [isSending, setIsSending] = useState(false);
const [searchTerm, setSearchTerm] = useState('');
const [feeWarning, setFeeWarning] = useState('');
const { tx } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { tx } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);
const { transfer } = ibc.applications.transfer.v1.MessageComposer.withTypeUrl;
const [isContactsOpen, setIsContactsOpen] = useState(false);

Expand Down Expand Up @@ -114,7 +118,7 @@
const exponent = values.selectedToken.metadata?.denom_units[1]?.exponent ?? 6;
const amountInBaseUnits = parseNumberToBigInt(values.amount, exponent).toString();

const { source_port, source_channel } = getIbcInfo(chainName ?? '', destinationChain ?? '');
const { source_port, source_channel } = getIbcInfo(env.chain, destinationChain ?? '');

Check warning on line 121 in components/bank/forms/ibcSendForm.tsx

View check run for this annotation

Codecov / codecov/patch

components/bank/forms/ibcSendForm.tsx#L121

Added line #L121 was not covered by tests

const token = {
denom: values.selectedToken.coreDenom,
Expand Down
6 changes: 3 additions & 3 deletions components/bank/forms/sendForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState } from 'react';
import { chainName } from '@/config';
import { useFeeEstimation, useTx } from '@/hooks';
import { cosmos } from '@liftedinit/manifestjs';
import { PiCaretDownBold } from 'react-icons/pi';
Expand All @@ -12,6 +11,7 @@ import { TextInput } from '@/components/react/inputs';
import { SearchIcon } from '@/components/icons';
import { TailwindModal } from '@/components/react/modal';
import { MdContacts } from 'react-icons/md';
import env from '@/config/env';
import { Any } from 'cosmjs-types/google/protobuf/any';
import { MsgSend } from '@liftedinit/manifestjs/dist/codegen/cosmos/bank/v1beta1/tx';

Expand Down Expand Up @@ -39,8 +39,8 @@ export default function SendForm({
const [isSending, setIsSending] = useState(false);
const [searchTerm, setSearchTerm] = useState('');
const [feeWarning, setFeeWarning] = useState('');
const { tx } = useTx(chainName);
const { estimateFee } = useFeeEstimation(chainName);
const { tx } = useTx(env.chain);
const { estimateFee } = useFeeEstimation(env.chain);
const { send } = cosmos.bank.v1beta1.MessageComposer.withTypeUrl;
const { submitProposal } = cosmos.group.v1.MessageComposer.withTypeUrl;
const [isContactsOpen, setIsContactsOpen] = useState(false);
Expand Down
Loading
Loading