Skip to content

Commit

Permalink
Merge branch 'develop' into PS/tangle-dapp-wallet-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
devpavan04 authored Nov 7, 2023
2 parents 0eb7c74 + 615e2a5 commit 12fc9db
Show file tree
Hide file tree
Showing 63 changed files with 1,527 additions and 1,658 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build 🏗️

on:
pull_request:
branches: [develop, staging, master]
branches: [develop, staging, master, feature/**]
push:
branches: [develop, staging, master]
branches: [develop, staging, master, feature/**]

workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: clean 🧹

on:
pull_request:
branches: [develop, staging, master]
branches: [develop, staging, master, feature/**]

workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'scan 🔎'

on:
pull_request:
branches: [develop, staging, master]
branches: [develop, staging, master, feature/**]

schedule:
# ┌───────────── minute (0 - 59)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-bridge-dapp-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: deploy-bridge-dapp 🌐
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [develop]
branches: [develop, feature/**]
paths:
- 'apps/bridge-dapp/**'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-faucet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: deploy-faucet 🌐
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [develop]
branches: [develop, feature/**]
paths:
- 'apps/faucet/**'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-stats-dapp-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: deploy-stats-dapp 🌐
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [develop]
branches: [develop, feature/**]
paths:
- 'apps/stats-dapp/**'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-storybook-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- develop
- feature/**
paths: [
'libs/webb-ui-components/src/stories/**',
'libs/webb-ui-components/.storybook/**',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ui-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: 'visual ✨'
on:
pull_request:
# types: [opened, synchronize, reopened, ready_for_review]
branches: [develop]
branches: [develop, feature/**]

workflow_dispatch:

Expand Down
31 changes: 17 additions & 14 deletions apps/bridge-dapp/src/components/RelayerFeeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { FeeDetails } from '@webb-tools/webb-ui-components/components/FeeDetails
import type { FeeItem } from '@webb-tools/webb-ui-components/components/FeeDetails/types';
import { Typography } from '@webb-tools/webb-ui-components/typography/Typography';
import { formatEther } from 'viem';
import getRelayerFeePercentage from '../utils/getRelayerFeePercentage';
import { useMemo } from 'react';
import { getRelayerFeePercentage } from '../utils';
import { type FC, useMemo } from 'react';
import { calculateTypedChainId } from '@webb-tools/sdk-core/typed-chain-id';

const RelayerFeeDetails = (props: {
interface RelayerFeeDetailsProps {
totalFeeWei: bigint | undefined;
totalFeeToken: string | undefined;
gasFeeInfo: bigint | undefined;
Expand All @@ -21,18 +21,20 @@ const RelayerFeeDetails = (props: {
srcChainCfg: ChainConfig | undefined;
fungibleCfg: CurrencyConfig | undefined;
activeRelayer: OptionalActiveRelayer;
}) => {
const {
activeRelayer,
fungibleCfg,
gasFeeInfo,
isFeeLoading,
relayerFeeInfo,
srcChainCfg,
totalFeeToken,
totalFeeWei,
} = props;
info?: string;
}

const RelayerFeeDetails: FC<RelayerFeeDetailsProps> = ({
activeRelayer,
fungibleCfg,
gasFeeInfo,
isFeeLoading,
relayerFeeInfo,
srcChainCfg,
totalFeeToken,
totalFeeWei,
info,
}) => {
const relayerFeePercentage = useMemo(() => {
if (!activeRelayer || !srcChainCfg) {
return;
Expand All @@ -48,6 +50,7 @@ const RelayerFeeDetails = (props: {

return (
<FeeDetails
info={info}
isTotalLoading={isFeeLoading}
totalFee={
typeof totalFeeWei === 'bigint'
Expand Down
1 change: 0 additions & 1 deletion apps/bridge-dapp/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from './EducationCard';
export * from './Header';
export * from './InteractiveFeedbackView';
export { default as RelayerFeeDetails } from './RelayerFeeDetails';
export { default as SlideAnimation } from './SlideAnimation';
export { default as SubmittedTxModal } from './SubmittedTxModal';
export { default as TxInfoItem } from './TxInfoItem';
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import {
Transaction,
TransactionState,
} from '@webb-tools/abstract-api-provider';
import { GasStationFill } from '@webb-tools/icons';
import { chainsConfig } from '@webb-tools/dapp-config/chains/chain-config';
import { useWebContext } from '@webb-tools/api-provider-environment/webb-context';
import { downloadString } from '@webb-tools/browser-utils';
import { getExplorerURI } from '@webb-tools/api-provider-environment/transaction/utils';
import { useBalancesFromNotes } from '@webb-tools/react-hooks/currency/useBalancesFromNotes';
import { handleStoreNote } from '../../utils';
import { useVAnchor } from '@webb-tools/react-hooks';
import { Note } from '@webb-tools/sdk-core';
import { isViemError } from '@webb-tools/web3-api-provider';
import { DepositConfirm } from '@webb-tools/webb-ui-components';
import { FeeDetails, DepositConfirm } from '@webb-tools/webb-ui-components';
import { forwardRef, useCallback, useMemo, useState } from 'react';
import { ContractFunctionRevertedError, formatUnits } from 'viem';
import { ContractFunctionRevertedError, formatUnits, formatEther } from 'viem';
import { useEnqueueSubmittedTx } from '../../hooks';
import useInProgressTxInfo from '../../hooks/useInProgressTxInfo';
import {
Expand All @@ -30,12 +33,12 @@ const DepositConfirmContainer = forwardRef<
(
{
amount,
destChain,
fungibleTokenId,
note,
onResetState,
onClose,
sourceChain,
sourceTypedChainId: sourceTypedChainIdProp,
destTypedChainId: destTypedChainIdProp,
wrappableTokenId,
},
ref
Expand All @@ -55,6 +58,8 @@ const DepositConfirmContainer = forwardRef<

const { api: txQueueApi } = txQueue;

const { balances } = useBalancesFromNotes();

const fungibleToken = useMemo(() => {
return new Currency(apiConfig.currencies[fungibleTokenId]);
}, [apiConfig.currencies, fungibleTokenId]);
Expand Down Expand Up @@ -83,14 +88,40 @@ const DepositConfirmContainer = forwardRef<
txStatusMessage,
} = useInProgressTxInfo(wrappingFlow, onResetState);

// Download for the deposit confirm
const downloadNote = useCallback((note: Note) => {
const noteStr = note.serialize();
downloadString(
JSON.stringify(noteStr),
noteStr.slice(-noteStr.length) + '.json'
);
}, []);
const sourceTypedChainId = useMemo(
() => sourceTypedChainIdProp ?? +note.note.sourceChainId,
[sourceTypedChainIdProp, note.note.sourceChainId]
);

const destTypedChainId = useMemo(
() => destTypedChainIdProp ?? +note.note.targetChainId,
[destTypedChainIdProp, note.note.targetChainId]
);

const newBalance = useMemo(() => {
const balance = balances?.[fungibleTokenId]?.[destTypedChainId];
if (!balance) return amount;
return Number(formatEther(balance)) + amount;
}, [balances, fungibleTokenId, destTypedChainId, note, amount]);

Check warning on line 105 in apps/bridge-dapp/src/containers/DepositConfirmContainer/DepositConfirmContainer.tsx

View workflow job for this annotation

GitHub Actions / lint (18.x)

React Hook useMemo has an unnecessary dependency: 'note'. Either exclude it or remove the dependency array

const poolAddress = useMemo(
() => apiConfig.anchors[fungibleTokenId][destTypedChainId],
[apiConfig, fungibleTokenId, destTypedChainId]
);

const poolExplorerUrl = useMemo(() => {
const blockExplorerUrl =
chainsConfig[destTypedChainId]?.blockExplorers?.default.url;

if (!blockExplorerUrl) return undefined;

return getExplorerURI(
blockExplorerUrl,
poolAddress,
'address',
'web3'
).toString();
}, [destTypedChainId, poolAddress]);

const handleExecuteDeposit = useCallback(
async () => {
Expand Down Expand Up @@ -185,8 +216,7 @@ const DepositConfirmContainer = forwardRef<

const transactionHash = await api.transact(...args);

downloadNote(note);
await addNoteToNoteManager(note);
await handleStoreNote(note, addNoteToNoteManager);

enqueueSubmittedTx(
transactionHash,
Expand Down Expand Up @@ -236,7 +266,7 @@ const DepositConfirmContainer = forwardRef<
}
},
// prettier-ignore
[activeAccount?.address, activeApi, activeChain, addNoteToNoteManager, api, apiConfig, downloadNote, enqueueSubmittedTx, fungibleTokenId, inProgressTxId.length, note, onResetState, removeNoteFromNoteManager, setInProgressTxId, setTotalStep, startNewTransaction, txQueueApi, wrappableToken]
[activeAccount?.address, activeApi, activeChain, addNoteToNoteManager, api, apiConfig, enqueueSubmittedTx, fungibleTokenId, inProgressTxId.length, note, onResetState, removeNoteFromNoteManager, setInProgressTxId, setTotalStep, startNewTransaction, txQueueApi, wrappableToken]
);

return (
Expand All @@ -261,12 +291,16 @@ const DepositConfirmContainer = forwardRef<
}}
totalProgress={totalStep}
progress={currentStep}
onDownload={() => downloadNote(note)}
amount={amount}
wrappingAmount={String(amount)}
wrappingAmount={amount}
fungibleTokenSymbol={fungibleToken.view.symbol}
sourceChain={sourceChain}
destChain={destChain}
sourceTypedChainId={sourceTypedChainId}
destTypedChainId={destTypedChainId}
sourceAddress={activeAccount?.address ?? ''}
destAddress={note.note.targetIdentifyingData}
poolAddress={poolAddress}
poolExplorerUrl={poolExplorerUrl}
newBalance={newBalance}
wrappableTokenSymbol={wrappableToken?.view.symbol}
txStatusColor={
txStatus === 'completed'
Expand All @@ -277,6 +311,17 @@ const DepositConfirmContainer = forwardRef<
}
txStatusMessage={txStatusMessage}
onClose={onClose}
feesSection={
<FeeDetails
info="The fee pays for the transaction to be processed on the network."
items={[
{
name: 'Gas',
Icon: <GasStationFill />,
},
]}
/>
}
/>
);
}
Expand Down
11 changes: 2 additions & 9 deletions apps/bridge-dapp/src/containers/DepositConfirmContainer/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ChainGroup } from '@webb-tools/dapp-config/chains/chain-config.interface';
import { Note } from '@webb-tools/sdk-core/note';
import { PropsOf } from '@webb-tools/webb-ui-components/types';

Expand All @@ -16,18 +15,12 @@ export interface DepositConfirmContainerProps extends PropsOf<'div'> {
/**
* The source chain
*/
sourceChain?: {
type: ChainGroup;
name: string;
};
sourceTypedChainId?: number;

/**
* The destination chain
*/
destChain?: {
type: ChainGroup;
name: string;
};
destTypedChainId?: number;

/**
* The fungible token id
Expand Down
Loading

0 comments on commit 12fc9db

Please sign in to comment.